summaryrefslogtreecommitdiffstats
path: root/sys/dev/sound/pci
diff options
context:
space:
mode:
authorcg <cg@FreeBSD.org>2000-09-01 20:09:24 +0000
committercg <cg@FreeBSD.org>2000-09-01 20:09:24 +0000
commita6b7de97e3e709e699c0638c9ff07e8fc3477772 (patch)
treeba5ec2ebf628be720fad52ae78db04a46cc46680 /sys/dev/sound/pci
parente95936f6ddf2411361330abe8f44903c01b42fe5 (diff)
downloadFreeBSD-src-a6b7de97e3e709e699c0638c9ff07e8fc3477772.zip
FreeBSD-src-a6b7de97e3e709e699c0638c9ff07e8fc3477772.tar.gz
change mixer api slightly
change channel interface - kobj implementation coming soonish make pcm_makelinks not panic if modular add pcm_unregister() these changes support newpcm kld unloading, but this is only implemented by ds1.c
Diffstat (limited to 'sys/dev/sound/pci')
-rw-r--r--sys/dev/sound/pci/aureal.c11
-rw-r--r--sys/dev/sound/pci/csapcm.c12
-rw-r--r--sys/dev/sound/pci/ds1.c76
-rw-r--r--sys/dev/sound/pci/emu10k1.c36
-rw-r--r--sys/dev/sound/pci/es137x.c25
-rw-r--r--sys/dev/sound/pci/fm801.c156
-rw-r--r--sys/dev/sound/pci/neomagic.c23
-rw-r--r--sys/dev/sound/pci/solo.c20
-rw-r--r--sys/dev/sound/pci/t4dwave.c12
-rw-r--r--sys/dev/sound/pci/via82c686.c12
10 files changed, 262 insertions, 121 deletions
diff --git a/sys/dev/sound/pci/aureal.c b/sys/dev/sound/pci/aureal.c
index 5b5e47c..9a9dd0a 100644
--- a/sys/dev/sound/pci/aureal.c
+++ b/sys/dev/sound/pci/aureal.c
@@ -73,6 +73,14 @@ static pcm_channel au_chantemplate = {
auchan_trigger,
auchan_getptr,
auchan_getcaps,
+ NULL, /* free */
+ NULL, /* nop1 */
+ NULL, /* nop2 */
+ NULL, /* nop3 */
+ NULL, /* nop4 */
+ NULL, /* nop5 */
+ NULL, /* nop6 */
+ NULL, /* nop7 */
};
/* -------------------------------------------------------------------- */
@@ -551,7 +559,6 @@ au_pci_probe(device_t dev)
static int
au_pci_attach(device_t dev)
{
- snddev_info *d;
u_int32_t data;
struct au_info *au;
int type[10];
@@ -644,7 +651,7 @@ au_pci_attach(device_t dev)
codec = ac97_create(dev, au, NULL, au_rdcd, au_wrcd);
if (codec == NULL) goto bad;
- if (mixer_init(d, &ac97_mixer, codec) == -1) goto bad;
+ if (mixer_init(dev, &ac97_mixer, codec) == -1) goto bad;
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
diff --git a/sys/dev/sound/pci/csapcm.c b/sys/dev/sound/pci/csapcm.c
index f0ea0a3..2c9e5ca 100644
--- a/sys/dev/sound/pci/csapcm.c
+++ b/sys/dev/sound/pci/csapcm.c
@@ -125,6 +125,14 @@ static pcm_channel csa_chantemplate = {
csachan_trigger,
csachan_getptr,
csachan_getcaps,
+ NULL, /* free */
+ NULL, /* nop1 */
+ NULL, /* nop2 */
+ NULL, /* nop3 */
+ NULL, /* nop4 */
+ NULL, /* nop5 */
+ NULL, /* nop6 */
+ NULL, /* nop7 */
};
/* -------------------------------------------------------------------- */
@@ -780,7 +788,6 @@ pcmcsa_probe(device_t dev)
static int
pcmcsa_attach(device_t dev)
{
- snddev_info *devinfo;
struct csa_info *csa;
csa_res *resp;
int unit;
@@ -788,7 +795,6 @@ pcmcsa_attach(device_t dev)
struct ac97_info *codec;
struct sndcard_func *func;
- devinfo = device_get_softc(dev);
csa = malloc(sizeof(*csa), M_DEVBUF, M_NOWAIT);
if (csa == NULL)
return (ENOMEM);
@@ -820,7 +826,7 @@ pcmcsa_attach(device_t dev)
codec = ac97_create(dev, csa, NULL, csa_rdcd, csa_wrcd);
if (codec == NULL)
return (ENXIO);
- if (mixer_init(devinfo, &ac97_mixer, codec) == -1)
+ if (mixer_init(dev, &ac97_mixer, codec) == -1)
return (ENXIO);
snprintf(status, SND_STATUSLEN, "at irq %ld", rman_get_start(resp->irq));
diff --git a/sys/dev/sound/pci/ds1.c b/sys/dev/sound/pci/ds1.c
index 81ecaa7..1d21064 100644
--- a/sys/dev/sound/pci/ds1.c
+++ b/sys/dev/sound/pci/ds1.c
@@ -109,6 +109,7 @@ struct sc_info {
bus_space_tag_t st;
bus_space_handle_t sh;
bus_dma_tag_t parent_dmat;
+ bus_dmamap_t map;
struct resource *reg, *irq;
int regid, irqid;
@@ -216,6 +217,14 @@ static pcm_channel ds_pchantemplate = {
ds1pchan_trigger,
ds1pchan_getptr,
ds1pchan_getcaps,
+ NULL, /* free */
+ NULL, /* nop1 */
+ NULL, /* nop2 */
+ NULL, /* nop3 */
+ NULL, /* nop4 */
+ NULL, /* nop5 */
+ NULL, /* nop6 */
+ NULL, /* nop7 */
};
static pcm_channel ds_rchantemplate = {
@@ -227,6 +236,14 @@ static pcm_channel ds_rchantemplate = {
ds1rchan_trigger,
ds1rchan_getptr,
ds1rchan_getcaps,
+ NULL, /* free */
+ NULL, /* nop1 */
+ NULL, /* nop2 */
+ NULL, /* nop3 */
+ NULL, /* nop4 */
+ NULL, /* nop5 */
+ NULL, /* nop6 */
+ NULL, /* nop7 */
};
/* -------------------------------------------------------------------- */
@@ -778,7 +795,6 @@ ds_init(struct sc_info *sc)
u_int32_t *ci, r, pcs, rcs, ecs, ws, memsz, cb;
u_int8_t *t;
void *buf;
- bus_dmamap_t map;
ci = ds_devs[sc->type].mcode;
@@ -821,9 +837,9 @@ ds_init(struct sc_info *sc)
memsz += (64 + 1) * 4;
if (sc->regbase == NULL) {
- if (bus_dmamem_alloc(sc->parent_dmat, &buf, BUS_DMA_NOWAIT, &map))
+ if (bus_dmamem_alloc(sc->parent_dmat, &buf, BUS_DMA_NOWAIT, &sc->map))
return -1;
- if (bus_dmamap_load(sc->parent_dmat, map, buf, memsz, ds_setmap, sc, 0)
+ if (bus_dmamap_load(sc->parent_dmat, sc->map, buf, memsz, ds_setmap, sc, 0)
|| !sc->ctrlbase) {
device_printf(sc->dev, "pcs=%d, rcs=%d, ecs=%d, ws=%d, memsz=%d\n",
pcs, rcs, ecs, ws, memsz);
@@ -868,6 +884,27 @@ ds_init(struct sc_info *sc)
}
static int
+ds_uninit(struct sc_info *sc)
+{
+ ds_wr(sc, YDSXGR_NATIVEDACOUTVOL, 0x00000000, 4);
+ ds_wr(sc, YDSXGR_NATIVEADCINVOL, 0, 4);
+ ds_wr(sc, YDSXGR_NATIVEDACINVOL, 0, 4);
+ ds_enadsp(sc, 0);
+ ds_wr(sc, YDSXGR_MODE, 0x00010000, 4);
+ ds_wr(sc, YDSXGR_MAPOFREC, 0x00000000, 4);
+ ds_wr(sc, YDSXGR_MAPOFEFFECT, 0x00000000, 4);
+ ds_wr(sc, YDSXGR_PLAYCTRLBASE, 0x00000000, 4);
+ ds_wr(sc, YDSXGR_RECCTRLBASE, 0x00000000, 4);
+ ds_wr(sc, YDSXGR_EFFCTRLBASE, 0x00000000, 4);
+ ds_wr(sc, YDSXGR_GLOBALCTRL, 0, 2);
+
+ bus_dmamap_unload(sc->parent_dmat, sc->map);
+ bus_dmamem_free(sc->parent_dmat, sc->regbase, sc->map);
+
+ return 0;
+}
+
+static int
ds_finddev(u_int32_t dev, u_int32_t subdev)
{
int i;
@@ -898,14 +935,12 @@ ds_pci_probe(device_t dev)
static int
ds_pci_attach(device_t dev)
{
- snddev_info *d;
u_int32_t data;
u_int32_t subdev, i;
struct sc_info *sc;
struct ac97_info *codec;
char status[SND_STATUSLEN];
- d = device_get_softc(dev);
if ((sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT)) == NULL) {
device_printf(dev, "cannot allocate softc\n");
return ENXIO;
@@ -952,7 +987,7 @@ ds_pci_attach(device_t dev)
codec = ac97_create(dev, sc, ds_initcd, ds_rdcd, ds_wrcd);
if (codec == NULL)
goto bad;
- mixer_init(d, &ac97_mixer, codec);
+ mixer_init(dev, &ac97_mixer, codec);
sc->irqid = 0;
sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irqid,
@@ -990,28 +1025,49 @@ bad:
static int
ds_pci_resume(device_t dev)
{
- snddev_info *d;
struct sc_info *sc;
- d = device_get_softc(dev);
sc = pcm_getdevinfo(dev);
if (ds_init(sc) == -1) {
device_printf(dev, "unable to reinitialize the card\n");
return ENXIO;
}
- if (mixer_reinit(d) == -1) {
+ if (mixer_reinit(dev) == -1) {
device_printf(dev, "unable to reinitialize the mixer\n");
return ENXIO;
}
return 0;
}
+static int
+ds_pci_detach(device_t dev)
+{
+ int r;
+ struct sc_info *sc;
+
+ r = pcm_unregister(dev);
+ if (r)
+ return r;
+
+ sc = pcm_getdevinfo(dev);
+ ds_uninit(sc);
+ if (sc->reg)
+ bus_release_resource(dev, SYS_RES_MEMORY, sc->regid, sc->reg);
+ if (sc->ih)
+ bus_teardown_intr(dev, sc->irq, sc->ih);
+ if (sc->irq)
+ bus_release_resource(dev, SYS_RES_IRQ, sc->irqid, sc->irq);
+ free(sc, M_DEVBUF);
+ return 0;
+}
+
static device_method_t ds1_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, ds_pci_probe),
DEVMETHOD(device_attach, ds_pci_attach),
- DEVMETHOD(device_resume, ds_pci_resume),
+ DEVMETHOD(device_detach, ds_pci_detach),
+ DEVMETHOD(device_resume, ds_pci_resume),
{ 0, 0 }
};
diff --git a/sys/dev/sound/pci/emu10k1.c b/sys/dev/sound/pci/emu10k1.c
index 584c2a7..c9e0e0f 100644
--- a/sys/dev/sound/pci/emu10k1.c
+++ b/sys/dev/sound/pci/emu10k1.c
@@ -113,6 +113,7 @@ struct sc_info {
/* channel interface */
static void *emupchan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir);
+static int emupchan_free(void *data);
static int emupchan_setdir(void *data, int dir);
static int emupchan_setformat(void *data, u_int32_t format);
static int emupchan_setspeed(void *data, u_int32_t speed);
@@ -140,9 +141,7 @@ static int emu_init(struct sc_info *);
static void emu_intr(void *);
static void *emu_malloc(struct sc_info *sc, u_int32_t sz);
static void *emu_memalloc(struct sc_info *sc, u_int32_t sz);
-#ifdef notyet
static int emu_memfree(struct sc_info *sc, void *buf);
-#endif
static int emu_memstart(struct sc_info *sc, void *buf);
#ifdef EMUDEBUG
static void emu_vdump(struct sc_info *sc, struct emu_voice *v);
@@ -195,6 +194,14 @@ static pcm_channel emu_chantemplate = {
emupchan_trigger,
emupchan_getptr,
emupchan_getcaps,
+ emupchan_free, /* free */
+ NULL, /* nop1 */
+ NULL, /* nop2 */
+ NULL, /* nop3 */
+ NULL, /* nop4 */
+ NULL, /* nop5 */
+ NULL, /* nop6 */
+ NULL, /* nop7 */
};
static pcm_channel emur_chantemplate = {
@@ -206,6 +213,14 @@ static pcm_channel emur_chantemplate = {
emurchan_trigger,
emurchan_getptr,
emurchan_getcaps,
+ NULL, /* free */
+ NULL, /* nop1 */
+ NULL, /* nop2 */
+ NULL, /* nop3 */
+ NULL, /* nop4 */
+ NULL, /* nop5 */
+ NULL, /* nop6 */
+ NULL, /* nop7 */
};
static int adcspeed[8] = {48000, 44100, 32000, 24000, 22050, 16000, 11025, 8000};
@@ -676,6 +691,15 @@ emupchan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir)
}
static int
+emupchan_free(void *data)
+{
+ struct sc_pchinfo *ch = data;
+ struct sc_info *sc = ch->parent;
+
+ return emu_memfree(sc, ch->buffer->buf);
+}
+
+static int
emupchan_setdir(void *data, int dir)
{
return 0;
@@ -709,7 +733,7 @@ static int
emupchan_trigger(void *data, int go)
{
struct sc_pchinfo *ch = data;
- struct sc_info *sc = ch->parent;
+ struct sc_info *sc = ch->parent;
if (go == PCMTRIG_EMLDMAWR || go == PCMTRIG_EMLDMARD)
return 0;
@@ -1039,7 +1063,6 @@ emu_memalloc(struct sc_info *sc, u_int32_t sz)
return buf;
}
-#ifdef notyet
static int
emu_memfree(struct sc_info *sc, void *buf)
{
@@ -1064,7 +1087,6 @@ emu_memfree(struct sc_info *sc, void *buf)
free(blk, M_DEVBUF);
return 0;
}
-#endif
static int
emu_memstart(struct sc_info *sc, void *buf)
@@ -1341,14 +1363,12 @@ emu_pci_probe(device_t dev)
static int
emu_pci_attach(device_t dev)
{
- snddev_info *d;
u_int32_t data;
struct sc_info *sc;
struct ac97_info *codec;
int i, mapped;
char status[SND_STATUSLEN];
- d = device_get_softc(dev);
if ((sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT)) == NULL) {
device_printf(dev, "cannot allocate softc\n");
return ENXIO;
@@ -1405,7 +1425,7 @@ emu_pci_attach(device_t dev)
codec = ac97_create(dev, sc, NULL, emu_rdcd, emu_wrcd);
if (codec == NULL) goto bad;
- if (mixer_init(d, &ac97_mixer, codec) == -1) goto bad;
+ if (mixer_init(dev, &ac97_mixer, codec) == -1) goto bad;
sc->irqid = 0;
sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irqid,
diff --git a/sys/dev/sound/pci/es137x.c b/sys/dev/sound/pci/es137x.c
index b4ce4da..544ad83 100644
--- a/sys/dev/sound/pci/es137x.c
+++ b/sys/dev/sound/pci/es137x.c
@@ -149,6 +149,14 @@ static pcm_channel es1370_chantemplate = {
eschan_trigger,
eschan_getptr,
eschan_getcaps,
+ NULL, /* free */
+ NULL, /* nop1 */
+ NULL, /* nop2 */
+ NULL, /* nop3 */
+ NULL, /* nop4 */
+ NULL, /* nop5 */
+ NULL, /* nop6 */
+ NULL, /* nop7 */
};
static pcm_channel es1371_chantemplate = {
@@ -160,6 +168,14 @@ static pcm_channel es1371_chantemplate = {
eschan_trigger,
eschan_getptr,
eschan_getcaps,
+ NULL, /* free */
+ NULL, /* nop1 */
+ NULL, /* nop2 */
+ NULL, /* nop3 */
+ NULL, /* nop4 */
+ NULL, /* nop5 */
+ NULL, /* nop6 */
+ NULL, /* nop7 */
};
/* -------------------------------------------------------------------- */
@@ -173,6 +189,7 @@ static int es1370_mixsetrecsrc(snd_mixer *m, u_int32_t src);
static snd_mixer es1370_mixer = {
"AudioPCI 1370 mixer",
es1370_mixinit,
+ NULL,
es1370_mixset,
es1370_mixsetrecsrc,
};
@@ -742,7 +759,6 @@ es_pci_probe(device_t dev)
static int
es_pci_attach(device_t dev)
{
- snddev_info *d;
u_int32_t data;
struct es_info *es = 0;
int type = 0;
@@ -756,7 +772,6 @@ es_pci_attach(device_t dev)
struct ac97_info *codec;
pcm_channel *ct = NULL;
- d = device_get_softc(dev);
if ((es = malloc(sizeof *es, M_DEVBUF, M_NOWAIT)) == NULL) {
device_printf(dev, "cannot allocate softc\n");
return ENXIO;
@@ -797,7 +812,7 @@ es_pci_attach(device_t dev)
}
if (pci_get_devid(dev) == ES1371_PCI_ID ||
- pci_get_devid(dev) == ES1371_PCI_ID2 ||
+ pci_get_devid(dev) == ES1371_PCI_ID2 ||
pci_get_devid(dev) == ES1371_PCI_ID3) {
if(-1 == es1371_init(es, pci_get_revid(dev))) {
device_printf(dev, "unable to initialize the card\n");
@@ -808,14 +823,14 @@ es_pci_attach(device_t dev)
/* our init routine does everything for us */
/* set to NULL; flag mixer_init not to run the ac97_init */
/* ac97_mixer.init = NULL; */
- if (mixer_init(d, &ac97_mixer, codec) == -1) goto bad;
+ if (mixer_init(dev, &ac97_mixer, codec) == -1) goto bad;
ct = &es1371_chantemplate;
} else if (pci_get_devid(dev) == ES1370_PCI_ID) {
if (-1 == es1370_init(es)) {
device_printf(dev, "unable to initialize the card\n");
goto bad;
}
- mixer_init(d, &es1370_mixer, es);
+ mixer_init(dev, &es1370_mixer, es);
ct = &es1370_chantemplate;
} else goto bad;
diff --git a/sys/dev/sound/pci/fm801.c b/sys/dev/sound/pci/fm801.c
index 98ddfa2..8188a1d 100644
--- a/sys/dev/sound/pci/fm801.c
+++ b/sys/dev/sound/pci/fm801.c
@@ -139,6 +139,14 @@ static pcm_channel fm801_chantemplate = {
fm801ch_trigger,
fm801ch_getptr,
fm801ch_getcaps,
+ NULL, /* free */
+ NULL, /* nop1 */
+ NULL, /* nop2 */
+ NULL, /* nop3 */
+ NULL, /* nop4 */
+ NULL, /* nop5 */
+ NULL, /* nop6 */
+ NULL, /* nop7 */
};
struct fm801_info;
@@ -241,7 +249,7 @@ fm801_rdcd(void *devinfo, int regno)
{
struct fm801_info *fm801 = (struct fm801_info *)devinfo;
int i;
-
+
for (i = 0; i < TIMO && fm801_rd(fm801,FM_CODEC_CMD,2) & FM_CODEC_CMD_BUSY; i++) {
DELAY(10000);
DPRINT("fm801 rdcd: 1 - DELAY\n");
@@ -250,7 +258,7 @@ fm801_rdcd(void *devinfo, int regno)
printf("fm801 rdcd: codec busy\n");
return 0;
}
-
+
fm801_wr(fm801,FM_CODEC_CMD, regno|FM_CODEC_CMD_READ,2);
for (i = 0; i < TIMO && !(fm801_rd(fm801,FM_CODEC_CMD,2) & FM_CODEC_CMD_VALID); i++)
@@ -262,7 +270,7 @@ fm801_rdcd(void *devinfo, int regno)
printf("fm801 rdcd: write codec invalid\n");
return 0;
}
-
+
return fm801_rd(fm801,FM_CODEC_DATA,2);
}
@@ -271,11 +279,11 @@ fm801_wrcd(void *devinfo, int regno, u_int32_t data)
{
struct fm801_info *fm801 = (struct fm801_info *)devinfo;
int i;
-
+
DPRINT("fm801_wrcd reg 0x%x val 0x%x\n",regno, data);
-/*
+/*
if(regno == AC97_REG_RECSEL) return;
-*/
+*/
/* Poll until codec is ready */
for (i = 0; i < TIMO && fm801_rd(fm801,FM_CODEC_CMD,2) & FM_CODEC_CMD_BUSY; i++) {
DELAY(10000);
@@ -285,10 +293,10 @@ fm801_wrcd(void *devinfo, int regno, u_int32_t data)
printf("fm801 wrcd: read codec busy\n");
return;
}
-
+
fm801_wr(fm801,FM_CODEC_DATA,data, 2);
fm801_wr(fm801,FM_CODEC_CMD, regno,2);
-
+
/* wait until codec is ready */
for (i = 0; i < TIMO && fm801_rd(fm801,FM_CODEC_CMD,2) & FM_CODEC_CMD_BUSY; i++) {
DELAY(10000);
@@ -302,8 +310,8 @@ fm801_wrcd(void *devinfo, int regno, u_int32_t data)
return;
}
-/*
- * The interrupt handler
+/*
+ * The interrupt handler
*/
static void
fm801_intr(void *p)
@@ -312,11 +320,11 @@ fm801_intr(void *p)
u_int32_t intsrc = fm801_rd(fm801, FM_INTSTATUS, 2);
struct fm801_chinfo *ch = &(fm801->pch);
snd_dbuf *b = ch->buffer;
-
+
DPRINT("\nfm801_intr intsrc 0x%x ", intsrc);
DPRINT("rp %d, rl %d, fp %d fl %d, size=%d\n",
b->rp,b->rl, b->fp,b->fl, b->blksz);
-
+
if(intsrc & FM_INTSTATUS_PLAY) {
fm801->play_flip++;
if(fm801->play_flip & 1) {
@@ -325,7 +333,7 @@ fm801_intr(void *p)
fm801_wr(fm801, FM_PLAY_DMABUF2, fm801->play_nextblk,4);
chn_intr(fm801->pch.channel);
}
-
+
if(intsrc & FM_INTSTATUS_REC) {
fm801->rec_flip++;
if(fm801->rec_flip & 1) {
@@ -334,17 +342,17 @@ fm801_intr(void *p)
fm801_wr(fm801, FM_REC_DMABUF2, fm801->rec_nextblk,4);
chn_intr(fm801->rch.channel);
}
-
+
if ( intsrc & FM_INTSTATUS_MPU ) {
/* This is a TODOish thing... */
fm801_wr(fm801, FM_INTSTATUS, intsrc & FM_INTSTATUS_MPU,2);
}
-
+
if ( intsrc & FM_INTSTATUS_VOL ) {
/* This is a TODOish thing... */
fm801_wr(fm801, FM_INTSTATUS, intsrc & FM_INTSTATUS_VOL,2);
}
-
+
DPRINT("fm801_intr clear\n\n");
fm801_wr(fm801, FM_INTSTATUS, intsrc & (FM_INTSTATUS_PLAY | FM_INTSTATUS_REC), 2);
}
@@ -356,20 +364,20 @@ static int
fm801_init(struct fm801_info *fm801)
{
u_int32_t k1;
-
+
/* reset codec */
fm801_wr(fm801, FM_CODEC_CTL, 0x0020,2);
DELAY(100000);
fm801_wr(fm801, FM_CODEC_CTL, 0x0000,2);
DELAY(100000);
-
+
fm801_wr(fm801, FM_PCM_VOLUME, 0x0808,2);
fm801_wr(fm801, FM_FM_VOLUME, 0x0808,2);
fm801_wr(fm801, FM_I2S_VOLUME, 0x0808,2);
fm801_wr(fm801, 0x40,0x107f,2); /* enable legacy audio */
-
+
fm801_wr((void *)fm801, FM_RECORD_SOURCE, 0x0000,2);
-
+
/* Unmask playback, record and mpu interrupts, mask the rest */
k1 = fm801_rd((void *)fm801, FM_INTMASK,2);
fm801_wr(fm801, FM_INTMASK,
@@ -378,7 +386,7 @@ fm801_init(struct fm801_info *fm801)
fm801_wr(fm801, FM_INTSTATUS,
FM_INTSTATUS_PLAY | FM_INTSTATUS_REC | FM_INTSTATUS_MPU |
FM_INTSTATUS_VOL,2);
-
+
DPRINT("FM801 init Ok\n");
return 0;
}
@@ -386,28 +394,26 @@ fm801_init(struct fm801_info *fm801)
static int
fm801_pci_attach(device_t dev)
{
- snddev_info *d;
u_int32_t data;
struct ac97_info *codec;
struct fm801_info *fm801;
int i;
int mapped = 0;
char status[SND_STATUSLEN];
-
- d = device_get_softc(dev);
+
if ((fm801 = (struct fm801_info *)malloc(sizeof(*fm801),M_DEVBUF, M_NOWAIT)) == NULL) {
device_printf(dev, "cannot allocate softc\n");
return ENXIO;
}
-
+
bzero(fm801, sizeof(*fm801));
fm801->type = pci_get_devid(dev);
-
+
data = pci_read_config(dev, PCIR_COMMAND, 2);
data |= (PCIM_CMD_PORTEN|PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN);
pci_write_config(dev, PCIR_COMMAND, data, 2);
data = pci_read_config(dev, PCIR_COMMAND, 2);
-
+
for (i = 0; (mapped == 0) && (i < PCI_MAXMAPS_0); i++) {
fm801->regid = PCIR_MAPS + i*4;
fm801->regtype = SYS_RES_MEMORY;
@@ -419,7 +425,7 @@ fm801_pci_attach(device_t dev)
fm801->reg = bus_alloc_resource(dev, fm801->regtype, &fm801->regid,
0, ~0, 1, RF_ACTIVE);
}
-
+
if(fm801->reg) {
fm801->st = rman_get_bustag(fm801->reg);
fm801->sh = rman_get_bushandle(fm801->reg);
@@ -431,13 +437,13 @@ fm801_pci_attach(device_t dev)
device_printf(dev, "unable to map register space\n");
goto oops;
}
-
+
fm801_init(fm801);
-
+
codec = ac97_create(dev, (void *)fm801, NULL, fm801_rdcd, fm801_wrcd);
if (codec == NULL) goto oops;
- if (mixer_init(d, &ac97_mixer, codec) == -1) goto oops;
+ if (mixer_init(dev, &ac97_mixer, codec) == -1) goto oops;
fm801->irqid = 0;
fm801->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &fm801->irqid,
@@ -448,7 +454,7 @@ fm801_pci_attach(device_t dev)
device_printf(dev, "unable to map interrupt\n");
goto oops;
}
-
+
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
@@ -458,7 +464,7 @@ fm801_pci_attach(device_t dev)
device_printf(dev, "unable to create dma tag\n");
goto oops;
}
-
+
snprintf(status, 64, "at %s 0x%lx irq %ld",
(fm801->regtype == SYS_RES_IOPORT)? "io" : "memory",
rman_get_start(fm801->reg), rman_get_start(fm801->irq));
@@ -471,8 +477,8 @@ fm801_pci_attach(device_t dev)
fm801_save(fm801);
return 0;
-
-oops:
+
+oops:
printf("Forte Media FM801 initialization failed\n");
if (fm801->reg) bus_release_resource(dev, fm801->regtype, fm801->regid, fm801->reg);
if (fm801->ih) bus_teardown_intr(dev, fm801->irq, fm801->ih);
@@ -506,7 +512,7 @@ fm801ch_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir)
{
struct fm801_info *fm801 = (struct fm801_info *)devinfo;
struct fm801_chinfo *ch = (dir == PCMDIR_PLAY)? &fm801->pch : &fm801->rch;
-
+
DPRINT("fm801ch_init, direction = %d\n", dir);
ch->parent = fm801;
ch->channel = c;
@@ -530,25 +536,25 @@ fm801ch_setformat(void *data, u_int32_t format)
{
struct fm801_chinfo *ch = data;
struct fm801_info *fm801 = ch->parent;
-
+
DPRINT("fm801ch_setformat 0x%x : %s, %s, %s, %s\n", format,
(format & AFMT_STEREO)?"stereo":"mono",
(format & (AFMT_S16_LE | AFMT_S16_BE | AFMT_U16_LE | AFMT_U16_BE)) ? "16bit":"8bit",
(format & AFMT_SIGNED)? "signed":"unsigned",
(format & AFMT_BIGENDIAN)?"bigendiah":"littleendian" );
-
+
if(ch->dir == PCMDIR_PLAY) {
fm801->play_fmt = (format & AFMT_STEREO)? FM_PLAY_STEREO : 0;
fm801->play_fmt |= (format & AFMT_16BIT) ? FM_PLAY_16BIT : 0;
return 0;
}
-
+
if(ch->dir == PCMDIR_REC ) {
fm801->rec_fmt = (format & AFMT_STEREO)? FM_REC_STEREO:0;
fm801->rec_fmt |= (format & AFMT_16BIT) ? FM_PLAY_16BIT : 0;
return 0;
}
-
+
return 0;
}
@@ -556,17 +562,17 @@ struct {
int limit;
int rate;
} fm801_rates[11] = {
- { 6600, 5500 },
- { 8750, 8000 },
- { 10250, 9600 },
- { 13200, 11025 },
- { 17500, 16000 },
- { 20500, 19200 },
- { 26500, 22050 },
- { 35000, 32000 },
- { 41000, 38400 },
- { 46000, 44100 },
- { 48000, 48000 },
+ { 6600, 5500 },
+ { 8750, 8000 },
+ { 10250, 9600 },
+ { 13200, 11025 },
+ { 17500, 16000 },
+ { 20500, 19200 },
+ { 26500, 22050 },
+ { 35000, 32000 },
+ { 41000, 38400 },
+ { 46000, 44100 },
+ { 48000, 48000 },
/* anything above -> 48000 */
};
@@ -576,24 +582,24 @@ fm801ch_setspeed(void *data, u_int32_t speed)
struct fm801_chinfo *ch = data;
struct fm801_info *fm801 = ch->parent;
register int i;
-
-
+
+
for (i = 0; i < 10 && fm801_rates[i].limit <= speed; i++) ;
-
+
if(ch->dir == PCMDIR_PLAY) {
fm801->pch.spd = fm801_rates[i].rate;
fm801->play_shift = (i<<8);
fm801->play_shift &= FM_PLAY_RATE_MASK;
}
-
+
if(ch->dir == PCMDIR_REC ) {
fm801->rch.spd = fm801_rates[i].rate;
fm801->rec_shift = (i<<8);
fm801->rec_shift &= FM_REC_RATE_MASK;
}
-
+
ch->spd = fm801_rates[i].rate;
-
+
return fm801_rates[i].rate;
}
@@ -602,17 +608,17 @@ fm801ch_setblocksize(void *data, u_int32_t blocksize)
{
struct fm801_chinfo *ch = data;
struct fm801_info *fm801 = ch->parent;
-
+
if(ch->dir == PCMDIR_PLAY) {
if(fm801->play_flip) return fm801->play_blksize;
fm801->play_blksize = blocksize;
}
-
+
if(ch->dir == PCMDIR_REC) {
if(fm801->rec_flip) return fm801->rec_blksize;
fm801->rec_blksize = blocksize;
}
-
+
DPRINT("fm801ch_setblocksize %d (dir %d)\n",blocksize, ch->dir);
return blocksize;
@@ -626,18 +632,18 @@ fm801ch_trigger(void *data, int go)
u_int32_t baseaddr = vtophys(ch->buffer->buf);
snd_dbuf *b = ch->buffer;
u_int32_t k1;
-
+
DPRINT("fm801ch_trigger go %d , ", go);
DPRINT("rp %d, rl %d, fp %d fl %d, dl %d, blksize=%d\n",
b->rp,b->rl, b->fp,b->fl, b->dl, b->blksz);
-
+
if (go == PCMTRIG_EMLDMAWR || go == PCMTRIG_EMLDMARD) {
return 0;
}
-
+
if (ch->dir == PCMDIR_PLAY) {
if (go == PCMTRIG_START) {
-
+
fm801->play_start = baseaddr;
fm801->play_nextblk = fm801->play_start + fm801->play_blksize;
fm801->play_flip = 0;
@@ -645,7 +651,7 @@ fm801ch_trigger(void *data, int go)
fm801_wr(fm801, FM_PLAY_DMABUF1,fm801->play_start,4);
fm801_wr(fm801, FM_PLAY_DMABUF2,fm801->play_nextblk,4);
fm801_wr(fm801, FM_PLAY_CTL,
- FM_PLAY_START | FM_PLAY_STOPNOW | fm801->play_fmt | fm801->play_shift,
+ FM_PLAY_START | FM_PLAY_STOPNOW | fm801->play_fmt | fm801->play_shift,
2 );
} else {
fm801->play_flip = 0;
@@ -662,8 +668,8 @@ fm801ch_trigger(void *data, int go)
fm801_wr(fm801, FM_REC_DMALEN, fm801->rec_blksize - 1, 2);
fm801_wr(fm801, FM_REC_DMABUF1,fm801->rec_start,4);
fm801_wr(fm801, FM_REC_DMABUF2,fm801->rec_nextblk,4);
- fm801_wr(fm801, FM_REC_CTL,
- FM_REC_START | FM_REC_STOPNOW | fm801->rec_fmt | fm801->rec_shift,
+ fm801_wr(fm801, FM_REC_CTL,
+ FM_REC_START | FM_REC_STOPNOW | fm801->rec_fmt | fm801->rec_shift,
2 );
} else {
fm801->rec_flip = 0;
@@ -673,7 +679,7 @@ fm801ch_trigger(void *data, int go)
FM_REC_BUF1_LAST | FM_REC_BUF2_LAST, 2);
}
}
-
+
return 0;
}
@@ -685,21 +691,21 @@ fm801ch_getptr(void *data)
struct fm801_info *fm801 = ch->parent;
int result = 0;
snd_dbuf *b = ch->buffer;
-
+
if (ch->dir == PCMDIR_PLAY) {
- result = fm801_rd(fm801,
- (fm801->play_flip&1) ?
+ result = fm801_rd(fm801,
+ (fm801->play_flip&1) ?
FM_PLAY_DMABUF2:FM_PLAY_DMABUF1, 4) - fm801->play_start;
}
-
+
if (ch->dir == PCMDIR_REC) {
result = fm801_rd(fm801,
(fm801->rec_flip&1) ?
FM_REC_DMABUF2:FM_REC_DMABUF1, 4) - fm801->rec_start;
- }
-
+ }
+
DPRINT("fm801ch_getptr:%d, rp %d, rl %d, fp %d fl %d\n",
- result, b->rp,b->rl, b->fp,b->fl);
+ result, b->rp,b->rl, b->fp,b->fl);
return result;
}
diff --git a/sys/dev/sound/pci/neomagic.c b/sys/dev/sound/pci/neomagic.c
index f7a864f..99eece8 100644
--- a/sys/dev/sound/pci/neomagic.c
+++ b/sys/dev/sound/pci/neomagic.c
@@ -78,6 +78,7 @@ struct sc_info {
/* channel interface */
static void *nmchan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir);
+static int nmchan_free(void *data);
static int nmchan_setdir(void *data, int dir);
static int nmchan_setformat(void *data, u_int32_t format);
static int nmchan_setspeed(void *data, u_int32_t speed);
@@ -143,6 +144,14 @@ static pcm_channel nm_chantemplate = {
nmchan_trigger,
nmchan_getptr,
nmchan_getcaps,
+ nmchan_free, /* free */
+ NULL, /* nop1 */
+ NULL, /* nop2 */
+ NULL, /* nop3 */
+ NULL, /* nop4 */
+ NULL, /* nop5 */
+ NULL, /* nop6 */
+ NULL, /* nop7 */
};
/* -------------------------------------------------------------------- */
@@ -364,6 +373,12 @@ nmchan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir)
}
static int
+nmchan_free(void *data)
+{
+ return 0;
+}
+
+static int
nmchan_setdir(void *data, int dir)
{
return 0;
@@ -582,13 +597,11 @@ nm_pci_probe(device_t dev)
static int
nm_pci_attach(device_t dev)
{
- snddev_info *d;
u_int32_t data;
struct sc_info *sc;
struct ac97_info *codec;
char status[SND_STATUSLEN];
- d = device_get_softc(dev);
if ((sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT)) == NULL) {
device_printf(dev, "cannot allocate softc\n");
return ENXIO;
@@ -622,7 +635,7 @@ nm_pci_attach(device_t dev)
codec = ac97_create(dev, sc, nm_initcd, nm_rdcd, nm_wrcd);
if (codec == NULL) goto bad;
- if (mixer_init(d, &ac97_mixer, codec) == -1) goto bad;
+ if (mixer_init(dev, &ac97_mixer, codec) == -1) goto bad;
sc->irqid = 0;
sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irqid,
@@ -656,10 +669,8 @@ bad:
static int
nm_pci_resume(device_t dev)
{
- snddev_info *d;
struct sc_info *sc;
- d = device_get_softc(dev);
sc = pcm_getdevinfo(dev);
/* Reinit audio device */
@@ -668,7 +679,7 @@ nm_pci_resume(device_t dev)
return ENXIO;
}
/* Reinit mixer */
- if (mixer_reinit(d) == -1) {
+ if (mixer_reinit(dev) == -1) {
device_printf(dev, "unable to reinitialize the mixer\n");
return ENXIO;
}
diff --git a/sys/dev/sound/pci/solo.c b/sys/dev/sound/pci/solo.c
index cd69868..58161db 100644
--- a/sys/dev/sound/pci/solo.c
+++ b/sys/dev/sound/pci/solo.c
@@ -90,6 +90,14 @@ static pcm_channel ess_chantemplate = {
esschan_trigger,
esschan_getptr,
esschan_getcaps,
+ NULL, /* free */
+ NULL, /* nop1 */
+ NULL, /* nop2 */
+ NULL, /* nop3 */
+ NULL, /* nop4 */
+ NULL, /* nop5 */
+ NULL, /* nop6 */
+ NULL, /* nop7 */
};
struct ess_info;
@@ -138,10 +146,11 @@ static int essmix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right)
static int essmix_setrecsrc(snd_mixer *m, u_int32_t src);
static snd_mixer ess_mixer = {
- "ESS mixer",
- essmix_init,
- essmix_set,
- essmix_setrecsrc,
+ "ESS mixer",
+ essmix_init,
+ NULL,
+ essmix_set,
+ essmix_setrecsrc,
};
static devclass_t pcm_devclass;
@@ -908,7 +917,6 @@ ess_probe(device_t dev)
static int
ess_attach(device_t dev)
{
- snddev_info *d = device_get_softc(dev);
struct ess_info *sc;
void *ih;
char status[SND_STATUSLEN];
@@ -935,7 +943,7 @@ ess_attach(device_t dev)
if (ess_reset_dsp(sc))
goto no;
- mixer_init(d, &ess_mixer, sc);
+ mixer_init(dev, &ess_mixer, sc);
port_wr(sc->io, 0x7, 0xb0, 1); /* enable irqs */
#ifdef ESS18XX_DUPLEX
diff --git a/sys/dev/sound/pci/t4dwave.c b/sys/dev/sound/pci/t4dwave.c
index 83b38aa..f65bdb4 100644
--- a/sys/dev/sound/pci/t4dwave.c
+++ b/sys/dev/sound/pci/t4dwave.c
@@ -150,6 +150,14 @@ static pcm_channel tr_chantemplate = {
trchan_trigger,
trchan_getptr,
trchan_getcaps,
+ NULL, /* free */
+ NULL, /* nop1 */
+ NULL, /* nop2 */
+ NULL, /* nop3 */
+ NULL, /* nop4 */
+ NULL, /* nop5 */
+ NULL, /* nop6 */
+ NULL, /* nop7 */
};
/* -------------------------------------------------------------------- */
@@ -601,7 +609,6 @@ tr_pci_probe(device_t dev)
static int
tr_pci_attach(device_t dev)
{
- snddev_info *d;
u_int32_t data;
struct tr_info *tr;
struct ac97_info *codec;
@@ -609,7 +616,6 @@ tr_pci_attach(device_t dev)
int mapped;
char status[SND_STATUSLEN];
- d = device_get_softc(dev);
if ((tr = malloc(sizeof(*tr), M_DEVBUF, M_NOWAIT)) == NULL) {
device_printf(dev, "cannot allocate softc\n");
return ENXIO;
@@ -655,7 +661,7 @@ tr_pci_attach(device_t dev)
codec = ac97_create(dev, tr, NULL, tr_rdcd, tr_wrcd);
if (codec == NULL) goto bad;
- if (mixer_init(d, &ac97_mixer, codec) == -1) goto bad;
+ if (mixer_init(dev, &ac97_mixer, codec) == -1) goto bad;
tr->irqid = 0;
tr->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &tr->irqid,
diff --git a/sys/dev/sound/pci/via82c686.c b/sys/dev/sound/pci/via82c686.c
index 5c9c6c5..14fe9bf 100644
--- a/sys/dev/sound/pci/via82c686.c
+++ b/sys/dev/sound/pci/via82c686.c
@@ -112,6 +112,14 @@ static pcm_channel via_chantemplate = {
viachan_trigger,
viachan_getptr,
viachan_getcaps,
+ NULL, /* free */
+ NULL, /* nop1 */
+ NULL, /* nop2 */
+ NULL, /* nop3 */
+ NULL, /* nop4 */
+ NULL, /* nop5 */
+ NULL, /* nop6 */
+ NULL, /* nop7 */
};
@@ -137,7 +145,6 @@ void dma_cb(void *p, bus_dma_segment_t *bds, int a, int b)
static int
via_attach(device_t dev)
{
- snddev_info *d;
struct via_info *via = 0;
struct ac97_info *codec;
char status[SND_STATUSLEN];
@@ -152,7 +159,6 @@ via_attach(device_t dev)
u_int16_t v;
bus_dmamap_t sgd_dma_map;
- d = device_get_softc(dev);
if ((via = malloc(sizeof *via, M_DEVBUF, M_NOWAIT)) == NULL) {
device_printf(dev, "cannot allocate softc\n");
return ENXIO;
@@ -199,7 +205,7 @@ via_attach(device_t dev)
via_read_codec, via_write_codec);
if (!codec) goto bad;
- mixer_init(d, &ac97_mixer, codec);
+ mixer_init(dev, &ac97_mixer, codec);
/*
* The mixer init resets the codec. So enabling VRA must be done
OpenPOWER on IntegriCloud