aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/sound/pcm/dsp.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/sound/pcm/dsp.c')
-rw-r--r--sys/dev/sound/pcm/dsp.c98
1 files changed, 12 insertions, 86 deletions
diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c
index df1482d6a97a..448ecb183298 100644
--- a/sys/dev/sound/pcm/dsp.c
+++ b/sys/dev/sound/pcm/dsp.c
@@ -444,7 +444,7 @@ dsp_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
if (DSP_F_READ(flags)) {
/* open for read */
rderror = pcm_chnalloc(d, &rdch, PCMDIR_REC,
- td->td_proc->p_pid, td->td_proc->p_comm, -1);
+ td->td_proc->p_pid, td->td_proc->p_comm);
if (rderror == 0 && chn_reset(rdch, fmt, spd) != 0)
rderror = ENXIO;
@@ -472,7 +472,7 @@ dsp_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
if (DSP_F_WRITE(flags)) {
/* open for write */
wrerror = pcm_chnalloc(d, &wrch, PCMDIR_PLAY,
- td->td_proc->p_pid, td->td_proc->p_comm, -1);
+ td->td_proc->p_pid, td->td_proc->p_comm);
if (wrerror == 0 && chn_reset(wrch, fmt, spd) != 0)
wrerror = ENXIO;
@@ -630,68 +630,12 @@ dsp_write(struct cdev *i_dev, struct uio *buf, int flag)
}
static int
-dsp_get_volume_channel(struct dsp_cdevpriv *priv, struct pcm_channel **volch)
-{
- struct snddev_info *d;
- struct pcm_channel *c;
- int unit;
-
- KASSERT(volch != NULL,
- ("%s(): NULL query priv=%p volch=%p", __func__, priv, volch));
-
- d = priv->sc;
- if (!PCM_REGISTERED(d)) {
- *volch = NULL;
- return (EINVAL);
- }
-
- PCM_UNLOCKASSERT(d);
-
- *volch = NULL;
-
- c = priv->volch;
- if (c != NULL) {
- if (!(c->feederflags & (1 << FEEDER_VOLUME)))
- return (-1);
- *volch = c;
- return (0);
- }
-
- PCM_LOCK(d);
- PCM_WAIT(d);
- PCM_ACQUIRE(d);
-
- unit = dev2unit(d->dsp_dev);
-
- CHN_FOREACH(c, d, channels.pcm) {
- CHN_LOCK(c);
- if (c->unit != unit) {
- CHN_UNLOCK(c);
- continue;
- }
- *volch = c;
- pcm_chnref(c, 1);
- priv->volch = c;
- CHN_UNLOCK(c);
- PCM_RELEASE(d);
- PCM_UNLOCK(d);
- return ((c->feederflags & (1 << FEEDER_VOLUME)) ? 0 : -1);
- }
-
- PCM_RELEASE(d);
- PCM_UNLOCK(d);
-
- return (EINVAL);
-}
-
-static int
dsp_ioctl_channel(struct dsp_cdevpriv *priv, struct pcm_channel *volch,
u_long cmd, caddr_t arg)
{
struct snddev_info *d;
struct pcm_channel *rdch, *wrch;
- int j, devtype, ret;
- int left, right, center, mute;
+ int j, left, right, center, mute;
d = priv->sc;
if (!PCM_REGISTERED(d) || !(pcm_getflags(d->dev) & SD_F_VPC))
@@ -716,19 +660,6 @@ dsp_ioctl_channel(struct dsp_cdevpriv *priv, struct pcm_channel *volch,
volch = wrch;
}
- devtype = PCMDEV(d->dsp_dev);
-
- /* Look super harder */
- if (volch == NULL &&
- (devtype == SND_DEV_DSPHW_PLAY || devtype == SND_DEV_DSPHW_VPLAY ||
- devtype == SND_DEV_DSPHW_REC || devtype == SND_DEV_DSPHW_VREC)) {
- ret = dsp_get_volume_channel(priv, &volch);
- if (ret != 0)
- return (ret);
- if (volch == NULL)
- return (EINVAL);
- }
-
/* Final validation */
if (volch == NULL)
return (EINVAL);
@@ -2105,8 +2036,6 @@ dsp_sysinit(void *p)
{
if (dsp_ehtag != NULL)
return;
- /* initialize unit numbering */
- snd_unit_init();
dsp_ehtag = EVENTHANDLER_REGISTER(dev_clone, dsp_clone, 0, 1000);
}
@@ -2123,20 +2052,19 @@ SYSINIT(dsp_sysinit, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, dsp_sysinit, NULL);
SYSUNINIT(dsp_sysuninit, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, dsp_sysuninit, NULL);
char *
-dsp_unit2name(char *buf, size_t len, int unit)
+dsp_unit2name(char *buf, size_t len, struct pcm_channel *ch)
{
- int i, dtype;
+ int i;
KASSERT(buf != NULL && len != 0,
("bogus buf=%p len=%ju", buf, (uintmax_t)len));
- dtype = snd_unit2d(unit);
-
for (i = 0; i < nitems(dsp_cdevs); i++) {
- if (dtype != dsp_cdevs[i].type || dsp_cdevs[i].alias != NULL)
+ if (ch->type != dsp_cdevs[i].type || dsp_cdevs[i].alias != NULL)
continue;
- snprintf(buf, len, "%s%d%s%d", dsp_cdevs[i].name,
- snd_unit2u(unit), dsp_cdevs[i].sep, snd_unit2c(unit));
+ snprintf(buf, len, "%s%d%s%d",
+ dsp_cdevs[i].name, device_get_unit(ch->dev),
+ dsp_cdevs[i].sep, ch->unit);
return (buf);
}
@@ -2224,12 +2152,10 @@ dsp_oss_audioinfo(struct cdev *i_dev, oss_audioinfo *ai)
if (devfs_foreach_cdevpriv(i_dev,
dsp_oss_audioinfo_cb, ch) != 0) {
devname = dsp_unit2name(buf,
- sizeof(buf), ch->unit);
+ sizeof(buf), ch);
}
- } else if (ai->dev == nchan) {
- devname = dsp_unit2name(buf, sizeof(buf),
- ch->unit);
- }
+ } else if (ai->dev == nchan)
+ devname = dsp_unit2name(buf, sizeof(buf), ch);
if (devname != NULL)
break;
CHN_UNLOCK(ch);