diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c index 8d71d7ebfb42..545c9a6b73f6 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -44,6 +44,45 @@ static u_int16_t snd_mixerdefaults[SOUND_MIXER_NRDEVICES] = { [SOUND_MIXER_OGAIN] = 50, }; +static int +mixer_set(snddev_info *d, unsigned dev, unsigned lev) +{ + if (d == NULL || d->mixer.set == NULL) return -1; + if ((dev < SOUND_MIXER_NRDEVICES) && (d->mixer.devs & (1 << dev))) { + unsigned l = min((lev & 0x00ff), 100); + unsigned r = min(((lev & 0xff00) >> 8), 100); + int v = d->mixer.set(&d->mixer, dev, l, r); + if (v >= 0) d->mixer.level[dev] = l | (r << 8); + return 0; + } else return -1; +} + +static int +mixer_get(snddev_info *d, int dev) +{ + if (d == NULL) return -1; + if (dev < SOUND_MIXER_NRDEVICES && (d->mixer.devs & (1 << dev))) + return d->mixer.level[dev]; + else return -1; +} + +static int +mixer_setrecsrc(snddev_info *d, u_int32_t src) +{ + if (d == NULL || d->mixer.setrecsrc == NULL) return -1; + src &= d->mixer.recdevs; + if (src == 0) src = SOUND_MASK_MIC; + d->mixer.recsrc = d->mixer.setrecsrc(&d->mixer, src); + return 0; +} + +static int +mixer_getrecsrc(snddev_info *d) +{ + if (d == NULL) return -1; + return d->mixer.recsrc; +} + int mixer_init(device_t dev, snd_mixer *m, void *devinfo) { @@ -90,45 +129,6 @@ mixer_reinit(device_t dev) } else return -1; } -static int -mixer_set(snddev_info *d, unsigned dev, unsigned lev) -{ - if (d == NULL || d->mixer.set == NULL) return -1; - if ((dev < SOUND_MIXER_NRDEVICES) && (d->mixer.devs & (1 << dev))) { - unsigned l = min((lev & 0x00ff), 100); - unsigned r = min(((lev & 0xff00) >> 8), 100); - int v = d->mixer.set(&d->mixer, dev, l, r); - if (v >= 0) d->mixer.level[dev] = l | (r << 8); - return 0; - } else return -1; -} - -static int -mixer_get(snddev_info *d, int dev) -{ - if (d == NULL) return -1; - if (dev < SOUND_MIXER_NRDEVICES && (d->mixer.devs & (1 << dev))) - return d->mixer.level[dev]; - else return -1; -} - -static int -mixer_setrecsrc(snddev_info *d, u_int32_t src) -{ - if (d == NULL || d->mixer.setrecsrc == NULL) return -1; - src &= d->mixer.recdevs; - if (src == 0) src = SOUND_MASK_MIC; - d->mixer.recsrc = d->mixer.setrecsrc(&d->mixer, src); - return 0; -} - -static int -mixer_getrecsrc(snddev_info *d) -{ - if (d == NULL) return -1; - return d->mixer.recsrc; -} - int mixer_ioctl(snddev_info *d, u_long cmd, caddr_t arg) {