TMS320AV110 (mpeg layer 2 decoder chip) and ZBUS Melody board, which uses it.

No optionboards yet for Melody, only audio driver.
MPEG data types for audio.c
This commit is contained in:
is 1997-10-16 23:58:10 +00:00
parent 7a5c72bb88
commit 11446b9b6e
7 changed files with 980 additions and 10 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: GENERIC,v 1.90 1997/10/10 04:56:09 mhitch Exp $
# $NetBSD: GENERIC,v 1.91 1997/10/16 23:58:39 is Exp $
#
# GENERIC AMIGA
@ -203,6 +203,9 @@ a34kbbc0 at mainbus0 # A3000/A4000 battery backed clock
aucc* at mainbus0 # Amiga CC audio
audio* at aucc?
melody* at zbus0 # Melody MPEG audio decoder
audio* at melody?
# Ethernet cards:
le* at zbus0 # A2065, Ameristar, Ariadne
ed0 at zbus0 # Hydra
@ -215,7 +218,6 @@ bah* at zbus0 # C=/Ameristar A2060 / 560
# Greater Valley Product Bus
gvpbus* at zbus0
# scsi stuff, all possible
gtsc0 at gvpbus? # GVP series II scsi
ahsc0 at mainbus0 # A3000 scsi

View File

@ -1,4 +1,4 @@
# $NetBSD: files.amiga,v 1.67 1997/10/16 01:02:56 thorpej Exp $
# $NetBSD: files.amiga,v 1.68 1997/10/16 23:58:36 is Exp $
# maxpartitions must be first item in files.${ARCH}.newconf
maxpartitions 16 # NOTE THAT AMIGA IS SPECIAL!
@ -50,9 +50,13 @@ attach par at mainbus
file arch/amiga/dev/par.c par needs-count
# audio
device aucc: audio
attach aucc at mainbus
file arch/amiga/dev/aucc.c aucc needs-flag
device aucc: audio
attach aucc at mainbus
file arch/amiga/dev/aucc.c aucc needs-flag
device melody: audio, tms320av110
attach melody at zbus
file arch/amiga/dev/melody.c melody
# mouse
device ms: event
@ -179,14 +183,14 @@ device drsupio: supio
attach drsupio at mainbus
file arch/amiga/dev/drsupio.c drsupio
attach com at supio with com_supio
file arch/amiga/dev/com_supio.c com_supio
# handle gvp's odd autoconf info..
device gvpbus {}
attach gvpbus at zbus
file arch/amiga/dev/gvpbus.c gvpbus
attach com at supio with com_supio
file arch/amiga/dev/com_supio.c com_supio
device lpt
file dev/ic/lpt.c lpt needs-flag
@ -341,6 +345,7 @@ file arch/amiga/amiga/trap.c
file arch/amiga/amiga/vm_machdep.c
file arch/amiga/amiga/cc.c
file arch/amiga/amiga/db_memrw.c ddb
major {vnd = 6}
# Compatibility modules

144
sys/arch/amiga/dev/melody.c Normal file
View File

@ -0,0 +1,144 @@
/* $NetBSD: melody.c,v 1.1 1997/10/16 23:58:31 is Exp $ */
/*-
* Copyright (c) 1997 Ignatios Souvatzis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Melody audio driver.
*
* Currently, only minimum support for audio output. For audio/video
* synchronization, more is needed.
*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <dev/ic/tms320av110reg.h>
#include <dev/ic/tms320av110var.h>
#include <machine/bus.h>
#include <amiga/dev/zbusvar.h>
#include <amiga/amiga/isr.h>
struct melody_softc {
struct tav_softc sc_tav;
struct bus_space_tag sc_bst_leftbyte;
struct isr sc_isr;
caddr_t sc_intack;
};
int melody_match __P((struct device *, struct cfdata *, void *));
void melody_attach __P((struct device *, struct device *, void *));
void melody_intack __P((struct tav_softc *));
struct cfattach melody_ca = {
sizeof(struct melody_softc), melody_match, melody_attach
};
struct cfdriver melody_cd = {
NULL, "melody", DV_DULL
};
int
melody_match(parent, cfp, aux)
struct device *parent;
struct cfdata *cfp;
void *aux;
{
struct zbus_args *zap;
zap = aux;
if (zap->manid != 2145)
return (0);
if (zap->prodid != 128)
return (0);
return (1);
}
void
melody_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct melody_softc *sc;
struct zbus_args *zap;
bus_space_tag_t iot;
bus_space_handle_t ioh;
sc = (struct melody_softc *)self;
zap = aux;
sc->sc_bst_leftbyte.base = (u_long)zap->va + 0;
sc->sc_bst_leftbyte.stride = 1;
sc->sc_intack = zap->va + 0xc000;
/* set up board specific part in sc_tav */
iot = &sc->sc_bst_leftbyte;
if (bus_space_map(iot, 0, 128, 0, &ioh)) {
panic("melody: cant bus_space_map");
/* NOTREACHED */
}
sc->sc_tav.sc_iot = iot;
sc->sc_tav.sc_ioh = ioh;
sc->sc_tav.sc_pcm_ord = 0;
sc->sc_tav.sc_pcm_18 = 0;
sc->sc_tav.sc_dif = 0;
sc->sc_tav.sc_pcm_div = 12;
/*
* Attach option boards now. They might provide additional
* functionality to our audio part.
*/
/* attach our audio driver */
printf(" #%d", zap->serno);
tms320av110_attach_mi(&sc->sc_tav);
sc->sc_isr.isr_ipl = 6;
sc->sc_isr.isr_arg = &sc->sc_tav;
sc->sc_isr.isr_intr = tms320av110_intr;
add_isr(&sc->sc_isr);
}
void
melody_intack(p)
struct tav_softc *p;
{
struct melody_softc *sc;
sc = (struct melody_softc *)p;
*sc->sc_intack = 0;
}

View File

@ -1,4 +1,4 @@
# $NetBSD: files,v 1.153 1997/10/16 00:38:11 thorpej Exp $
# $NetBSD: files,v 1.154 1997/10/16 23:58:23 is Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@ -138,6 +138,10 @@ file dev/ic/smc91cxx.c sm
define interwave
file dev/ic/interwave.c interwave
# TMS 320av110 MPEG2/audio driver
define tms320av110
file dev/ic/tms320av110.c tms320av110
# Novell NE2000-compatible Ethernet cards, based on the
# National Semiconductor DS8390.
device ne: ether, ifnet, arp, dp8390nic

579
sys/dev/ic/tms320av110.c Normal file
View File

@ -0,0 +1,579 @@
/* $NetBSD: tms320av110.c,v 1.1 1997/10/16 23:58:16 is Exp $ */
/*-
* Copyright (c) 1997 Ignatios Souvatzis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Machine independent part of TMS320AV110 driver.
*
* Currently, only minimum support for audio output. For audio/video
* synchronization, more is needed.
*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/proc.h>
#include <sys/audioio.h>
#include <dev/audio_if.h>
#include <dev/ic/tms320av110reg.h>
#include <dev/ic/tms320av110var.h>
#include <machine/bus.h>
int tav_open __P((void*, int));
void tav_close __P((void *));
int tav_drain __P((void *));
int tav_query_encoding __P((void *, struct audio_encoding *));
int tav_set_params __P((void *, int, int, struct audio_params *,
struct audio_params *));
int tav_round_blocksize __P((void *, int));
int tav_set_out_port __P((void *, int));
int tav_get_out_port __P((void *));
int tav_set_in_port __P((void *, int));
int tav_get_in_port __P((void *));
int tav_init_output __P((void *, void *, int));
int tav_start_output __P((void *, void *, int, void (*)(void *), void *));
int tav_start_input __P((void *, void *, int, void (*)(void *), void *));
int tav_halt_output __P((void *));
int tav_halt_input __P((void *));
int tav_cont_output __P((void *));
int tav_cont_input __P((void *));
int tav_speaker_ctl __P((void *, int));
int tav_getdev __P((void *, struct audio_device *));
int tav_setfd __P((void *, int));
int tav_set_port __P((void *, mixer_ctrl_t *));
int tav_get_port __P((void *, mixer_ctrl_t *));
int tav_query_devinfo __P((void *, mixer_devinfo_t *));
int tav_get_props __P((void *));
struct audio_hw_if tav_audio_if = {
tav_open,
tav_close,
0 /* tav_drain*/, /* optional */
tav_query_encoding,
tav_set_params,
tav_round_blocksize,
tav_set_out_port,
tav_get_out_port,
tav_set_in_port,
tav_get_in_port,
0 /* commit_settings */, /* optional */
tav_init_output, /* optional */
0 /* tav_init_input */, /* optional */
tav_start_output,
tav_start_input,
tav_halt_output,
tav_halt_input,
tav_cont_output,
tav_cont_input,
tav_speaker_ctl, /* optional */
tav_getdev,
0 /* setfd */, /* optional */
tav_set_port,
tav_get_port,
tav_query_devinfo,
0 /* alloc */, /* optional */
0 /* free */, /* optional */
0 /* round_buffersize */, /* optional */
0 /* mappage */, /* optional */
tav_get_props
};
void
tms320av110_attach_mi(sc)
struct tav_softc *sc;
{
bus_space_tag_t iot = sc->sc_iot;
bus_space_handle_t ioh = sc->sc_ioh;
tav_write_byte(iot, ioh, TAV_RESET, 1);
while (tav_read_byte(iot, ioh, TAV_RESET))
delay(250);
tav_write_byte(iot, ioh, TAV_PCM_ORD, sc->sc_pcm_ord);
tav_write_byte(iot, ioh, TAV_PCM_18, sc->sc_pcm_18);
tav_write_byte(iot, ioh, TAV_DIF, sc->sc_dif);
tav_write_byte(iot, ioh, TAV_PCM_DIV, sc->sc_pcm_div);
printf(": chip rev. %d, %d bytes buffer\n",
tav_read_byte(iot, ioh, TAV_VERSION),
TAV_DRAM_SIZE(tav_read_byte(iot, ioh, TAV_DRAM_EXT)));
tav_write_byte(iot, ioh, TAV_AUD_ID_EN, 0);
tav_write_byte(iot, ioh, TAV_SKIP, 0);
tav_write_byte(iot, ioh, TAV_REPEAT, 0);
tav_write_byte(iot, ioh, TAV_MUTE, 0);
tav_write_byte(iot, ioh, TAV_PLAY, 1);
tav_write_byte(iot, ioh, TAV_SYNC_ECM, 0);
tav_write_byte(iot, ioh, TAV_CRC_ECM, 0);
tav_write_byte(iot, ioh, TAV_ATTEN_L, 0);
tav_write_byte(iot, ioh, TAV_ATTEN_R, 0);
tav_write_word(iot, ioh, TAV_FREE_FORM, 0);
tav_write_byte(iot, ioh, TAV_SIN_EN, 0);
tav_write_byte(iot, ioh, TAV_SYNC_ECM, TAV_ECM_REPEAT);
tav_write_byte(iot, ioh, TAV_CRC_ECM, TAV_ECM_REPEAT);
audio_attach_mi(&tav_audio_if, 0, sc, &sc->sc_dev);
}
int
tms320av110_intr(p)
void *p;
{
struct tav_softc *sc = p;
u_int16_t intlist;
intlist = tav_read_short(sc->sc_iot, sc->sc_ioh, TAV_INTR)
/* & tav_read_short(sc->sc_iot, sc->sc_ioh, TAV_INTR_EN)*/;
if (!intlist)
return 0;
/* ack now, so that we don't miss later interupts */
if (sc->sc_intack)
(sc->sc_intack)(sc);
if (intlist & TAV_INTR_LOWWATER) {
(*sc->sc_intr)(sc->sc_intrarg);
}
if (intlist & TAV_INTR_PCM_OUTPUT_UNDERFLOW) {
wakeup(sc);
}
return 1;
}
struct audio_encoding tav_encodings[] = {
{0, "mpg_l2_str", AUDIO_ENCODING_MPEG_L2_STREAM, 1, 0,},
{1, "mpg_l2_pkt", AUDIO_ENCODING_MPEG_L2_PACKETS, 1, 0,},
{2, "mpg_l2_sys", AUDIO_ENCODING_MPEG_L2_SYSTEM, 1, 0,},
{3, "slinear_be", AUDIO_ENCODING_SLINEAR_BE, 16, 0,},
};
int
tav_open(hdl, flags)
void *hdl;
int flags;
{
struct tav_softc *sc;
sc = hdl;
/* dummy */
return 0;
}
void
tav_close(hdl)
void *hdl;
{
struct tav_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
sc = hdl;
iot = sc->sc_iot;
ioh = sc->sc_ioh;
/* re"start" chip, also clears interupts and interupt enable */
tav_write_short(iot, ioh, TAV_INTR_EN, 0);
if (sc->sc_intack)
(*sc->sc_intack)(sc);
}
int
tav_drain(hdl)
void *hdl;
{
struct tav_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
u_int16_t mask;
sc = hdl;
iot = sc->sc_iot;
ioh = sc->sc_ioh;
/*
* tsleep waiting for underflow interupt.
*/
if (tav_read_short(iot, ioh, TAV_BUFF)) {
mask = tav_read_short(iot, ioh, TAV_INTR_EN);
tav_write_short(iot, ioh, TAV_INTR_EN,
mask|TAV_INTR_PCM_OUTPUT_UNDERFLOW);
/* still more than zero? */
if (tav_read_short(iot, ioh, TAV_BUFF))
(void)tsleep(sc, PCATCH, "tavdrain", 32*hz);
/* can be really that long for mpeg */
mask = tav_read_short(iot, ioh, TAV_INTR_EN);
tav_write_short(iot, ioh, TAV_INTR_EN,
mask & ~TAV_INTR_PCM_OUTPUT_UNDERFLOW);
}
return 0;
}
int
tav_query_encoding(hdl, ae)
void *hdl;
struct audio_encoding *ae;
{
struct tav_softc *sc;
sc = hdl;
if (ae->index >= sizeof(tav_encodings)/sizeof(*ae))
return EINVAL;
*ae = tav_encodings[ae->index];
return 0;
}
int
tav_start_input(hdl, block, bsize, intr, intrarg)
void *hdl;
void *block;
int bsize;
void (*intr) __P((void *));
void *intrarg;
{
return ENOTTY;
}
int
tav_halt_input(hdl)
void *hdl;
{
return ENOTTY;
}
int
tav_start_output(hdl, block, bsize, intr, intrarg)
void *hdl;
void *block;
int bsize;
void (*intr) __P((void *));
void *intrarg;
{
struct tav_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
u_int8_t *ptr;
int count;
sc = hdl;
iot = sc->sc_iot;
ioh = sc->sc_ioh;
ptr = block;
count = bsize;
sc->sc_intr = intr;
sc->sc_intrarg = intrarg;
while (--count >= 0) {
bus_space_write_1(iot, ioh, TAV_DATAIN, *ptr++);
delay(1);
}
tav_write_short(iot, ioh, TAV_INTR_EN, TAV_INTR_LOWWATER);
return 0;
}
int
tav_init_output(hdl, buffer, size)
void *hdl;
void *buffer;
int size;
{
struct tav_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
sc = hdl;
iot = sc->sc_iot;
ioh = sc->sc_ioh;
tav_write_byte(iot, ioh, TAV_PLAY, 1);
tav_write_byte(iot, ioh, TAV_MUTE, 0);
return 0;
}
int
tav_halt_output(hdl)
void *hdl;
{
struct tav_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
sc = hdl;
iot = sc->sc_iot;
ioh = sc->sc_ioh;
tav_write_byte(iot, ioh, TAV_PLAY, 0);
return 0;
}
int
tav_getdev(hdl, ret)
void *hdl;
struct audio_device *ret;
{
struct tav_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
sc = hdl;
iot = sc->sc_iot;
ioh = sc->sc_ioh;
strncpy(ret->name, "tms320av110", MAX_AUDIO_DEV_LEN);
sprintf(ret->version, "%u", /* guaranteed to be <= 4 in length */
tav_read_byte(iot, ioh, TAV_VERSION));
strncpy(ret->config, sc->sc_dev.dv_xname, MAX_AUDIO_DEV_LEN);
return 0;
}
int
tav_round_blocksize(hdl, size)
void *hdl;
int size;
{
struct tav_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
int maxhalf;
sc = hdl;
iot = sc->sc_iot;
ioh = sc->sc_ioh;
maxhalf = TAV_DRAM_HSIZE(tav_read_byte(iot, ioh, TAV_DRAM_EXT));
if (size > maxhalf)
size = maxhalf;
/* XXX should round to 128 bytes limits for audio bypass */
size &= ~3;
tav_write_short(iot, ioh, TAV_BALE_LIM, size/8);
/* the buffer limits are in units of 4 bytes */
return (size);
}
int
tav_get_props(hdl)
void *hdl;
{
return 0;
}
int
tav_set_params(hdl, setmode, usemode, p, r)
void *hdl;
int setmode, usemode;
struct audio_params *p, *r;
{
struct tav_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
sc = hdl;
iot = sc->sc_iot;
ioh = sc->sc_ioh;
if (!(setmode & AUMODE_PLAY))
return 0;
if (p->encoding == AUDIO_ENCODING_ULAW)
p->encoding = AUDIO_ENCODING_MPEG_L2_STREAM;
switch(p->encoding) {
default:
return EINVAL;
case AUDIO_ENCODING_SLINEAR_BE:
/* XXX: todo: add 8bit and mono using software */
p->precision = 16;
p->channels = 2;
/* XXX: this might depend on the specific board.
should be handled by the backend */
p->sample_rate = 44100;
bus_space_write_1(iot, ioh, TAV_STR_SEL,
TAV_STR_SEL_AUDIO_BYPASS);
break;
/* XXX: later: add ULINEAR, and LE using software encoding */
case AUDIO_ENCODING_MPEG_L1_STREAM:
/* FALLTHROUGH */
case AUDIO_ENCODING_MPEG_L2_STREAM:
bus_space_write_1(iot, ioh, TAV_STR_SEL,
TAV_STR_SEL_MPEG_AUDIO_STREAM);
p->sample_rate = 44100;
p->precision = 1;
break;
case AUDIO_ENCODING_MPEG_L1_PACKETS:
/* FALLTHROUGH */
case AUDIO_ENCODING_MPEG_L2_PACKETS:
bus_space_write_1(iot, ioh, TAV_STR_SEL,
TAV_STR_SEL_MPEG_AUDIO_PACKETS);
p->sample_rate = 44100;
p->precision = 1;
break;
case AUDIO_ENCODING_MPEG_L1_SYSTEM:
/* FALLTHROUGH */
case AUDIO_ENCODING_MPEG_L2_SYSTEM:
bus_space_write_1(iot, ioh, TAV_STR_SEL,
TAV_STR_SEL_MPEG_SYSTEM_STREAM);
p->sample_rate = 44100;
p->precision = 1;
break;
}
tav_write_byte(iot, ioh, TAV_RESTART, 1);
do {
delay(10);
} while (tav_read_byte(iot, ioh, TAV_RESTART));
return 0;
}
int
tav_set_port(hdl, mc)
void *hdl;
mixer_ctrl_t *mc;
{
struct tav_softc *sc;
sc = hdl;
/* dummy */
return 0;
}
int
tav_get_port(hdl, mc)
void *hdl;
mixer_ctrl_t *mc;
{
struct tav_softc *sc;
sc = hdl;
/* dummy */
return 0;
}
int
tav_query_devinfo(hdl, di)
void *hdl;
mixer_devinfo_t *di;
{
return EINVAL;
}
int
tav_get_in_port(hdl)
void *hdl;
{
return -1;
}
int
tav_set_in_port(hdl, port)
void *hdl;
int port;
{
return EINVAL;
}
int
tav_get_out_port(hdl)
void *hdl;
{
return 0;
}
int
tav_set_out_port(hdl, port)
void *hdl;
int port;
{
if (port)
return EINVAL;
return 0;
}
int
tav_cont_input(hdl)
void *hdl;
{
return EINVAL;
}
int
tav_cont_output(hdl)
void *hdl;
{
return EINVAL;
}
int
tav_speaker_ctl(hdl, value)
void *hdl;
int value;
{
struct tav_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
sc = hdl;
iot = sc->sc_iot;
ioh = sc->sc_ioh;
tav_write_byte(iot, ioh, TAV_MUTE, !value);
return 0;
}

125
sys/dev/ic/tms320av110reg.h Normal file
View File

@ -0,0 +1,125 @@
/* $NetBSD: tms320av110reg.h,v 1.1 1997/10/16 23:58:10 is Exp $ */
/*-
* Copyright (c) 1997 Ignatios Souvatzis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Definitions for access to the TMS320AV110AV mpeg audio decoder.
* Based on the TMS320AV110 data sheet.
*
* Currently, only minimum support for audio output. For audio/video
* synchronization, more is needed.
*/
#ifndef _TMS320AV110_REG_H_
#define _TMS320AV110_REG_H_
/* symbolic registers and values */
#define TAV_ANC 0x06 /* RO, 4 bytes */
#define TAV_ANC_AV 0x6c /* RO */
#define TAV_ATTEN_L 0x1e
#define TAV_ATTEN_R 0x20
#define TAV_AUD_ID 0x22
#define TAV_AUD_ID_EN 0x24
#define TAV_BALE_LIM 0x68 /* 2 bytes */
#define TAV_BALF_LIM 0x6A /* 2 bytes */
#define TAV_BUFF 0x12 /* RO, 2 bytes */
#define TAV_CRC_ECM 0x2a
#define TAV_ECM_IGNORE 0 /* same for SYNC */
#define TAV_ECM_MUTE 1
#define TAV_ECM_REPEAT 2
#define TAV_ECM_SKIP 3
#define TAV_DATAIN 0x18 /* WO */
#define TAV_DIF 0x6f
#define TAV_DMPH 0x46
#define TAV_DRAM_EXT 0x3e /* RO */
#define TAV_DRAM_SIZE(ext) ((ext) ? 131072 : 256)
#define TAV_DRAM_HSIZE(ext) ((ext) ? 65536 : 128)
#define TAV_FREE_FORM 0x14 /* RW, 11 bit */
#define TAV_HEADER 0x5e /* RO, 4 bytes */
#define TAV_INTR 0x1a /* RO, 2 bytes */
#define TAV_INTR_EN 0x1c /* RW, 2 bytes */
#define TAV_INTR_SYNCCHANGE 0x0001
#define TAV_INTR_HEADERVALID 0x0002
#define TAV_INTR_PTSVALID 0x0004
#define TAV_INTR_LOWWATER 0x0008
#define TAV_INTR_HIGHWATER 0x0010
#define TAV_INTR_CRCERROR 0x0020
#define TAV_INTR_ANCILLARY_VALID 0x0040
#define TAV_INTR_ANCILLARY_FULL 0x0080
#define TAV_INTR_PCM_OUTPUT_UNDERFLOW 0x0100
#define TAV_INTR_SAMPLING_FREQ_CHANGE 0x0200
#define TAV_INTR_DEEMPH_CHANGE 0x0400
#define TAV_INTR_SRC_DETECT 0x0800
#define TAV_IRC 0x78 /* RO, 33 bit */
#define TAV_IRC_CNT 0x54 /* RO, 33 bit */
#define TAV_IRC_LOAD 0x7e
#define TAV_LATENCY 0x3c
#define TAV_MUTE 0x30
#define TAV_PCM_DIV 0x6e
#define TAV_PCM_18 0x16
#define TAV_PCM_FS 0x44 /* RO */
#define TAV_PCM_ORD 0x38
#define TAV_PLAY 0x2e
#define TAV_PTS 0x62 /* RO, 33 bits */
#define TAV_REPEAT 0x34
#define TAV_RESET 0x40
#define TAV_RESTART 0x42
#define TAV_SRC 0x72 /* RO, 33 bits */
#define TAV_SIN_EN 0x70
#define TAV_SKIP 0x32
#define TAV_STR_SEL 0x36
#define TAV_STR_SEL_MPEG_AUDIO_STREAM 0
#define TAV_STR_SEL_MPEG_AUDIO_PACKETS 1
#define TAV_STR_SEL_MPEG_SYSTEM_STREAM 2
#define TAV_STR_SEL_AUDIO_BYPASS 3
#define TAV_SYNC_ECM 0x2c /* see CRC_ECM */
#define TAV_SYNC_ST 0x28 /* 0..3 */
#define TAV_SYNC_ST_UNLOCKED 0
#define TAV_SYNC_ST_ATTEMPTING 2
#define TAV_SYNC_ST_LOCKED 3
#define TAV_VERSION 0x6d
#endif /* _TMS320AV110_REG_H_ */

111
sys/dev/ic/tms320av110var.h Normal file
View File

@ -0,0 +1,111 @@
/* $NetBSD: tms320av110var.h,v 1.1 1997/10/16 23:58:12 is Exp $ */
/*-
* Copyright (c) 1997 Ignatios Souvatzis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Machine independent definitions, declarations and data structures for
* access to the TMS320AV110 data sheet.
*
* Currently, only minimum support for audio output. For audio/video
* synchronization, more is needed.
*/
#ifndef _TMS320AV110_VAR_H_
#define _TMS320AV110_VAR_H_
#include <machine/bus.h>
/* softc */
struct tav_softc {
struct device sc_dev;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
/* above audio callback function */
void (*sc_intr) __P((void *));
void *sc_intrarg;
int sc_bsize;
/* below audio interupt acknowledge function. Ignored if NULL */
void (*sc_intack) __P((struct tav_softc *));
/* initialization from below */
u_int8_t sc_pcm_div; /* passed in */
u_int8_t sc_pcm_ord; /* passed in */
u_int8_t sc_pcm_18; /* passed in */
u_int8_t sc_dif; /* passed in */
};
/* prototypes */
void tms320av110_attach_mi __P((struct tav_softc *));
int tms320av110_intr __P((void *));
static void tav_write_short __P((bus_space_tag_t, bus_space_handle_t,
bus_size_t, u_int16_t));
/* access functions/macros: */
/* XXX shouldn't these be in the reg.h file? */
#define tav_read_byte(ioh, iot, off) bus_space_read_1(ioh, iot, off)
#define tav_read_short(ioh, iot, off) ( \
bus_space_read_1((ioh), (iot), (off)) | \
bus_space_read_1((ioh), (iot), (off)+1) << 8)
#define tav_read_long(ioh, iot, off) ( \
bus_space_read_1((ioh), (iot), (off)) | \
bus_space_read_1((ioh), (iot), (off)+1) << 8 | \
bus_space_read_1((ioh), (iot), (off)+2) << 16 | \
bus_space_read_1((ioh), (iot), (off)+3))
#define tav_read_time(ioh, iot, off) ( \
bus_space_read_1((ioh), (iot), (off)) | \
bus_space_read_1((ioh), (iot), (off)+1) << 8 | \
bus_space_read_1((ioh), (iot), (off)+2) << 16 | \
bus_space_read_1((ioh), (iot), (off)+3) << 24 | \
bus_space_read_1((ioh), (iot), (off)+4) << 32)
#define tav_write_byte(ioh, iot, off, v) bus_space_write_1(ioh, iot, off, v)
static __inline void
tav_write_short(iot, ioh, off, val)
bus_space_tag_t iot;
bus_space_handle_t ioh;
bus_size_t off;
u_int16_t val;
{
bus_space_write_1(iot, ioh, off+1, (val)>>8);
bus_space_write_1(iot, ioh, off, (u_int8_t)val);
}
#endif /* _TMS320AV110_VAR_H_ */