aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/sound/pci/emu10kx-pcm.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/sound/pci/emu10kx-pcm.c')
-rw-r--r--sys/dev/sound/pci/emu10kx-pcm.c59
1 files changed, 30 insertions, 29 deletions
diff --git a/sys/dev/sound/pci/emu10kx-pcm.c b/sys/dev/sound/pci/emu10kx-pcm.c
index c280b64892f6..25b0006e4122 100644
--- a/sys/dev/sound/pci/emu10kx-pcm.c
+++ b/sys/dev/sound/pci/emu10kx-pcm.c
@@ -90,7 +90,7 @@ struct emu_pcm_rchinfo {
#endif
struct emu_pcm_info {
- struct mtx *lock;
+ struct mtx lock;
device_t dev; /* device information */
struct emu_sc_info *card;
struct emu_pcm_pchinfo pch[MAX_CHANNELS]; /* hardware channels */
@@ -771,10 +771,10 @@ emupchan_setblocksize(kobj_t obj __unused, void *c_devinfo, uint32_t blocksize)
if (blocksize > ch->pcm->bufsz)
blocksize = ch->pcm->bufsz;
- snd_mtxlock(sc->lock);
+ mtx_lock(&sc->lock);
ch->blksz = blocksize;
- emu_timer_set(sc->card, ch->timer, ch->blksz / sndbuf_getalign(ch->buffer));
- snd_mtxunlock(sc->lock);
+ emu_timer_set(sc->card, ch->timer, ch->blksz / ch->buffer->align);
+ mtx_unlock(&sc->lock);
return (ch->blksz);
}
@@ -787,7 +787,7 @@ emupchan_trigger(kobj_t obj __unused, void *c_devinfo, int go)
if (!PCMTRIG_COMMON(go))
return (0);
- snd_mtxlock(sc->lock); /* XXX can we trigger on parallel threads ? */
+ mtx_lock(&sc->lock); /* XXX can we trigger on parallel threads ? */
if (go == PCMTRIG_START) {
emu_vsetup(ch->master, ch->fmt, ch->spd);
if (AFMT_CHANNEL(ch->fmt) > 1)
@@ -795,13 +795,14 @@ emupchan_trigger(kobj_t obj __unused, void *c_devinfo, int go)
else
emu_vroute(sc->card, &(sc->rt_mono), ch->master);
emu_vwrite(sc->card, ch->master);
- emu_timer_set(sc->card, ch->timer, ch->blksz / sndbuf_getalign(ch->buffer));
+ emu_timer_set(sc->card, ch->timer, ch->blksz /
+ ch->buffer->align);
emu_timer_enable(sc->card, ch->timer, 1);
}
/* PCM interrupt handler will handle PCMTRIG_STOP event */
ch->run = (go == PCMTRIG_START) ? 1 : 0;
emu_vtrigger(sc->card, ch->master, ch->run);
- snd_mtxunlock(sc->lock);
+ mtx_unlock(&sc->lock);
return (0);
}
@@ -878,7 +879,7 @@ emurchan_init(kobj_t obj __unused, void *devinfo, struct snd_dbuf *b, struct pcm
return (NULL);
else {
ch->timer = emu_timer_create(sc->card);
- emu_wrptr(sc->card, 0, ch->basereg, sndbuf_getbufaddr(ch->buffer));
+ emu_wrptr(sc->card, 0, ch->basereg, ch->buffer->buf_addr);
emu_wrptr(sc->card, 0, ch->sizereg, 0); /* off */
return (ch);
}
@@ -930,7 +931,8 @@ emurchan_setblocksize(kobj_t obj __unused, void *c_devinfo, uint32_t blocksize)
* (and use) timer interrupts. Otherwise channel will be marked dead.
*/
if (ch->blksz < (ch->pcm->bufsz / 2)) {
- emu_timer_set(sc->card, ch->timer, ch->blksz / sndbuf_getalign(ch->buffer));
+ emu_timer_set(sc->card, ch->timer, ch->blksz /
+ ch->buffer->align);
emu_timer_enable(sc->card, ch->timer, 1);
} else {
emu_timer_enable(sc->card, ch->timer, 0);
@@ -968,7 +970,7 @@ emurchan_trigger(kobj_t obj __unused, void *c_devinfo, int go)
sz = EMU_RECBS_BUFSIZE_4096;
}
- snd_mtxlock(sc->lock);
+ mtx_lock(&sc->lock);
switch (go) {
case PCMTRIG_START:
ch->run = 1;
@@ -997,7 +999,7 @@ emurchan_trigger(kobj_t obj __unused, void *c_devinfo, int go)
default:
break;
}
- snd_mtxunlock(sc->lock);
+ mtx_unlock(&sc->lock);
return (0);
}
@@ -1059,7 +1061,7 @@ emufxrchan_init(kobj_t obj __unused, void *devinfo, struct snd_dbuf *b, struct p
if (sndbuf_alloc(ch->buffer, emu_gettag(sc->card), 0, sc->bufsz) != 0)
return (NULL);
else {
- emu_wrptr(sc->card, 0, ch->basereg, sndbuf_getbufaddr(ch->buffer));
+ emu_wrptr(sc->card, 0, ch->basereg, ch->buffer->buf_addr);
emu_wrptr(sc->card, 0, ch->sizereg, 0); /* off */
return (ch);
}
@@ -1128,7 +1130,7 @@ emufxrchan_trigger(kobj_t obj __unused, void *c_devinfo, int go)
sz = EMU_RECBS_BUFSIZE_4096;
}
- snd_mtxlock(sc->lock);
+ mtx_lock(&sc->lock);
switch (go) {
case PCMTRIG_START:
ch->run = 1;
@@ -1167,7 +1169,7 @@ emufxrchan_trigger(kobj_t obj __unused, void *c_devinfo, int go)
default:
break;
}
- snd_mtxunlock(sc->lock);
+ mtx_unlock(&sc->lock);
return (0);
}
@@ -1232,24 +1234,24 @@ emu_pcm_intr(void *pcm, uint32_t stat)
ack = 0;
- snd_mtxlock(sc->lock);
+ mtx_lock(&sc->lock);
if (stat & EMU_IPR_INTERVALTIMER) {
ack |= EMU_IPR_INTERVALTIMER;
for (i = 0; i < MAX_CHANNELS; i++)
if (sc->pch[i].channel) {
if (sc->pch[i].run == 1) {
- snd_mtxunlock(sc->lock);
+ mtx_unlock(&sc->lock);
chn_intr(sc->pch[i].channel);
- snd_mtxlock(sc->lock);
+ mtx_lock(&sc->lock);
} else
emu_timer_enable(sc->card, sc->pch[i].timer, 0);
}
/* ADC may install timer to get low-latency interrupts */
if ((sc->rch_adc.channel) && (sc->rch_adc.run)) {
- snd_mtxunlock(sc->lock);
+ mtx_unlock(&sc->lock);
chn_intr(sc->rch_adc.channel);
- snd_mtxlock(sc->lock);
+ mtx_lock(&sc->lock);
}
/*
* EFX does not use timer, because it will fill
@@ -1260,21 +1262,21 @@ emu_pcm_intr(void *pcm, uint32_t stat)
if (stat & (EMU_IPR_ADCBUFFULL | EMU_IPR_ADCBUFHALFFULL)) {
ack |= stat & (EMU_IPR_ADCBUFFULL | EMU_IPR_ADCBUFHALFFULL);
if (sc->rch_adc.channel) {
- snd_mtxunlock(sc->lock);
+ mtx_unlock(&sc->lock);
chn_intr(sc->rch_adc.channel);
- snd_mtxlock(sc->lock);
+ mtx_lock(&sc->lock);
}
}
if (stat & (EMU_IPR_EFXBUFFULL | EMU_IPR_EFXBUFHALFFULL)) {
ack |= stat & (EMU_IPR_EFXBUFFULL | EMU_IPR_EFXBUFHALFFULL);
if (sc->rch_efx.channel) {
- snd_mtxunlock(sc->lock);
+ mtx_unlock(&sc->lock);
chn_intr(sc->rch_efx.channel);
- snd_mtxlock(sc->lock);
+ mtx_lock(&sc->lock);
}
}
- snd_mtxunlock(sc->lock);
+ mtx_unlock(&sc->lock);
return (ack);
}
@@ -1347,7 +1349,8 @@ emu_pcm_attach(device_t dev)
return (ENXIO);
}
- sc->lock = snd_mtxcreate(device_get_nameunit(dev), "snd_emu10kx pcm softc");
+ mtx_init(&sc->lock, device_get_nameunit(dev), "snd_emu10kx pcm softc",
+ MTX_DEF);
sc->dev = dev;
BUS_READ_IVAR(device_get_parent(dev), dev, EMU_VAR_ISEMU10K1, &ivar);
@@ -1481,8 +1484,7 @@ emu_pcm_attach(device_t dev)
bad:
if (sc->codec)
ac97_destroy(sc->codec);
- if (sc->lock)
- snd_mtxfree(sc->lock);
+ mtx_destroy(&sc->lock);
free(sc, M_DEVBUF);
return (ENXIO);
}
@@ -1501,8 +1503,7 @@ emu_pcm_detach(device_t dev)
emu_pcm_uninit(sc);
- if (sc->lock)
- snd_mtxfree(sc->lock);
+ mtx_destroy(&sc->lock);
free(sc, M_DEVBUF);
return (0);