Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F167885453
D59070.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
8 KB
Referenced Files
None
Subscribers
None
D59070.diff
View Options
diff --git a/sys/dev/sound/pci/es137x.c b/sys/dev/sound/pci/es137x.c
--- a/sys/dev/sound/pci/es137x.c
+++ b/sys/dev/sound/pci/es137x.c
@@ -1516,8 +1516,7 @@
dev = oidp->oid_arg1;
d = device_get_softc(dev);
- if (!PCM_REGISTERED(d) || d->mixer_dev == NULL ||
- d->mixer_dev->si_drv1 == NULL)
+ if (!PCM_REGISTERED(d) || d->mixer_dev == NULL || d->mixer == NULL)
return (EINVAL);
es = d->devinfo;
if (es == NULL)
@@ -1535,7 +1534,7 @@
if (val == set)
return (0);
PCM_ACQUIRE_QUICK(d);
- m = (d->mixer_dev != NULL) ? d->mixer_dev->si_drv1 : NULL;
+ m = d->mixer;
if (m == NULL) {
PCM_RELEASE_QUICK(d);
return (ENODEV);
diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c
--- a/sys/dev/sound/pcm/channel.c
+++ b/sys/dev/sound/pcm/channel.c
@@ -2157,8 +2157,7 @@
struct snd_mixer *m;
d = (c != NULL) ? c->parentsnddev : NULL;
- m = (d != NULL && d->mixer_dev != NULL) ? d->mixer_dev->si_drv1 :
- NULL;
+ m = (d != NULL) ? d->mixer : NULL;
if (d == NULL || m == NULL)
return;
diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c
--- a/sys/dev/sound/pcm/dsp.c
+++ b/sys/dev/sound/pcm/dsp.c
@@ -915,7 +915,6 @@
{
snd_capabilities *p = (snd_capabilities *)arg;
struct pcmchan_caps *pcaps = NULL, *rcaps = NULL;
- struct cdev *pdev;
#ifdef COMPAT_FREEBSD32
snd_capabilities32 *p32 = (snd_capabilities32 *)arg;
snd_capabilities capabilities;
@@ -955,9 +954,8 @@
(pcm_getflags(d->dev) & SD_F_SIMPLEX) ? 0 :
AFMT_FULLDUPLEX;
}
- pdev = d->mixer_dev;
p->mixers = 1; /* default: one mixer */
- p->inputs = pdev->si_drv1? mix_getdevs(pdev->si_drv1) : 0;
+ p->inputs = d->mixer ? mix_getdevs(d->mixer) : 0;
p->left = p->right = 100;
if (wrch)
CHN_UNLOCK(wrch);
diff --git a/sys/dev/sound/pcm/feeder_volume.c b/sys/dev/sound/pcm/feeder_volume.c
--- a/sys/dev/sound/pcm/feeder_volume.c
+++ b/sys/dev/sound/pcm/feeder_volume.c
@@ -270,7 +270,7 @@
/* Check if any controls are muted. */
d = (c != NULL) ? c->parentsnddev : NULL;
- m = (d != NULL && d->mixer_dev != NULL) ? d->mixer_dev->si_drv1 : NULL;
+ m = (d != NULL) ? d->mixer : NULL;
if (m != NULL)
master_muted = (mix_getmutedevs(m) & (1 << SND_VOL_C_MASTER));
diff --git a/sys/dev/sound/pcm/mixer.h b/sys/dev/sound/pcm/mixer.h
--- a/sys/dev/sound/pcm/mixer.h
+++ b/sys/dev/sound/pcm/mixer.h
@@ -62,6 +62,7 @@
int mixer_init(device_t dev, kobj_class_t cls, void *devinfo);
int mixer_uninit(device_t dev);
int mixer_reinit(device_t dev);
+int mixer_make_dev(device_t dev);
int mixer_ioctl_cmd(struct cdev *i_dev, unsigned long cmd, caddr_t arg,
int mode, struct thread *td);
int mixer_oss_mixerinfo(struct cdev *i_dev, oss_mixerinfo *mi);
diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c
--- a/sys/dev/sound/pcm/mixer.c
+++ b/sys/dev/sound/pcm/mixer.c
@@ -75,14 +75,14 @@
static eventhandler_tag mixer_ehtag = NULL;
-static struct cdev *
+static struct snd_mixer *
mixer_get_devt(device_t dev)
{
struct snddev_info *snddev;
snddev = device_get_softc(dev);
- return snddev->mixer_dev;
+ return (snddev->mixer);
}
static int
@@ -616,7 +616,6 @@
struct snddev_info *snddev;
struct snd_mixer *m;
uint16_t v;
- struct cdev *pdev;
const char *name;
int i, unit, val;
@@ -646,10 +645,7 @@
mixer_setrecsrc(m, 0); /* Set default input. */
- pdev = make_dev(&mixer_cdevsw, 0, UID_ROOT, GID_AUDIO, 0660, "mixer%d",
- unit);
- pdev->si_drv1 = m;
- snddev->mixer_dev = pdev;
+ snddev->mixer = m;
if (bootverbose) {
for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
@@ -685,20 +681,23 @@
int i;
struct snddev_info *d;
struct snd_mixer *m;
- struct cdev *pdev;
d = device_get_softc(dev);
- pdev = mixer_get_devt(dev);
- if (d == NULL || pdev == NULL || pdev->si_drv1 == NULL)
+ if (d == NULL)
return EBADF;
+ m = d->mixer;
- m = pdev->si_drv1;
KASSERT(m != NULL, ("NULL snd_mixer"));
KASSERT(m->type == MIXER_TYPE_PRIMARY,
("%s(): illegal mixer type=%d", __func__, m->type));
- pdev->si_drv1 = NULL;
- destroy_dev(pdev);
+ /*
+ * snd_uaudio(4) in particular can call mixer_uninit() directly if
+ * attach failed prior to pcm_register(), in which case the cdev will
+ * not have been created. Do not call destroy_dev() unconditionally.
+ */
+ if (d->mixer_dev != NULL)
+ destroy_dev(d->mixer_dev);
mtx_lock(&m->lock);
@@ -717,6 +716,7 @@
kobj_delete((kobj_t)m, M_DEVBUF);
d->mixer_dev = NULL;
+ d->mixer = NULL;
return 0;
}
@@ -725,11 +725,9 @@
mixer_reinit(device_t dev)
{
struct snd_mixer *m;
- struct cdev *pdev;
int i;
- pdev = mixer_get_devt(dev);
- m = pdev->si_drv1;
+ m = mixer_get_devt(dev);
mtx_lock(&m->lock);
i = MIXER_REINIT(m);
@@ -751,6 +749,32 @@
return 0;
}
+int
+mixer_make_dev(device_t dev)
+{
+ struct make_dev_args devargs;
+ struct snddev_info *sc;
+ int err, unit;
+
+ sc = device_get_softc(dev);
+ unit = device_get_unit(dev);
+
+ make_dev_args_init(&devargs);
+ devargs.mda_devsw = &mixer_cdevsw;
+ devargs.mda_uid = UID_ROOT;
+ devargs.mda_gid = GID_AUDIO;
+ devargs.mda_mode = 0660;
+ devargs.mda_si_drv1 = sc->mixer;
+ err = make_dev_s(&devargs, &sc->mixer_dev, "mixer%d", unit);
+ if (err != 0) {
+ device_printf(dev, "failed to create mixer%d: error %d\n",
+ unit, err);
+ return (err);
+ }
+
+ return (0);
+}
+
static int
sysctl_hw_snd_hwvol_mixer(SYSCTL_HANDLER_ARGS)
{
@@ -781,10 +805,8 @@
mixer_hwvol_init(device_t dev)
{
struct snd_mixer *m;
- struct cdev *pdev;
- pdev = mixer_get_devt(dev);
- m = pdev->si_drv1;
+ m = mixer_get_devt(dev);
m->hwvol_mixer = SOUND_MIXER_VOLUME;
m->hwvol_step = 5;
@@ -808,10 +830,8 @@
mixer_hwvol_mute(device_t dev)
{
struct snd_mixer *m;
- struct cdev *pdev;
- pdev = mixer_get_devt(dev);
- m = pdev->si_drv1;
+ m = mixer_get_devt(dev);
mtx_lock(&m->lock);
mixer_hwvol_mute_locked(m);
mtx_unlock(&m->lock);
@@ -846,10 +866,8 @@
mixer_hwvol_step(device_t dev, int left_step, int right_step)
{
struct snd_mixer *m;
- struct cdev *pdev;
- pdev = mixer_get_devt(dev);
- m = pdev->si_drv1;
+ m = mixer_get_devt(dev);
mtx_lock(&m->lock);
mixer_hwvol_step_locked(m, left_step, right_step);
mtx_unlock(&m->lock);
@@ -927,10 +945,9 @@
struct snddev_info *d;
struct snd_mixer *m;
- if (i_dev == NULL || i_dev->si_drv1 == NULL)
- return (EBADF);
-
m = i_dev->si_drv1;
+ if (m == NULL)
+ return (EBADF);
d = device_get_softc(m->dev);
if (!PCM_REGISTERED(d))
return (EBADF);
@@ -944,10 +961,9 @@
struct snddev_info *d;
struct snd_mixer *m;
- if (i_dev == NULL || i_dev->si_drv1 == NULL)
- return (EBADF);
-
m = i_dev->si_drv1;
+ if (m == NULL)
+ return (EBADF);
d = device_get_softc(m->dev);
if (!PCM_REGISTERED(d))
return (EBADF);
@@ -960,12 +976,13 @@
struct thread *td)
{
struct snddev_info *d;
+ struct snd_mixer *m;
int ret;
- if (i_dev == NULL || i_dev->si_drv1 == NULL)
+ m = i_dev->si_drv1;
+ if (m == NULL)
return (EBADF);
-
- d = device_get_softc(((struct snd_mixer *)i_dev->si_drv1)->dev);
+ d = device_get_softc(m->dev);
if (!PCM_REGISTERED(d))
return (EBADF);
@@ -1235,14 +1252,14 @@
continue;
}
- if (d->mixer_dev->si_drv1 == NULL) {
+ if (d->mixer == NULL) {
mixer_oss_mixerinfo_unavail(mi, i);
PCM_UNLOCK(d);
bus_topo_unlock();
return (0);
}
- m = d->mixer_dev->si_drv1;
+ m = d->mixer;
mtx_lock(&m->lock);
/*
diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h
--- a/sys/dev/sound/pcm/sound.h
+++ b/sys/dev/sound/pcm/sound.h
@@ -191,6 +191,7 @@
struct mtx lock;
struct cdev *mixer_dev;
struct cdev *dsp_dev;
+ struct snd_mixer *mixer;
uint32_t pvchanrate, pvchanformat, pvchanmode;
uint32_t rvchanrate, rvchanformat, rvchanmode;
int32_t eqpreamp;
diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c
--- a/sys/dev/sound/pcm/sound.c
+++ b/sys/dev/sound/pcm/sound.c
@@ -332,7 +332,7 @@
mode |= PCM_MODE_PLAY;
if (d->reccount > 0)
mode |= PCM_MODE_REC;
- if (d->mixer_dev != NULL)
+ if (d->mixer != NULL)
mode |= PCM_MODE_MIXER;
PCM_UNLOCK(d);
@@ -433,6 +433,13 @@
err = dsp_make_dev(dev);
if (err)
return (err);
+ if (d->mixer != NULL) {
+ err = mixer_make_dev(dev);
+ if (err) {
+ dsp_destroy_dev(dev);
+ return (err);
+ }
+ }
bus_topo_lock();
if (snd_unit_auto < 0)
@@ -483,7 +490,8 @@
}
sndstat_unregister(dev);
- mixer_uninit(dev);
+ if (d->mixer != NULL)
+ mixer_uninit(dev);
dsp_destroy_dev(dev);
cv_destroy(&d->cv);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 26, 6:15 AM (10 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37195730
Default Alt Text
D59070.diff (8 KB)
Attached To
Mode
D59070: sound: Simplify how snd_mixer is fetched and how the cdev is created
Attached
Detach File
Event Timeline
Log In to Comment