diff options
Diffstat (limited to 'sys/dev/sound/pcm/mixer.c')
-rw-r--r-- | sys/dev/sound/pcm/mixer.c | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c index eea11e6..8f9a5fb 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -893,14 +893,8 @@ mixer_hwvol_init(device_t dev) } void -mixer_hwvol_mute(device_t dev) +mixer_hwvol_mute_locked(struct snd_mixer *m) { - struct snd_mixer *m; - struct cdev *pdev; - - pdev = mixer_get_devt(dev); - m = pdev->si_drv1; - snd_mtxlock(m->lock); if (m->hwvol_muted) { m->hwvol_muted = 0; mixer_set(m, m->hwvol_mixer, m->hwvol_mute_level); @@ -909,19 +903,26 @@ mixer_hwvol_mute(device_t dev) m->hwvol_mute_level = mixer_get(m, m->hwvol_mixer); mixer_set(m, m->hwvol_mixer, 0); } - snd_mtxunlock(m->lock); } void -mixer_hwvol_step(device_t dev, int left_step, int right_step) +mixer_hwvol_mute(device_t dev) { struct snd_mixer *m; - int level, left, right; struct cdev *pdev; pdev = mixer_get_devt(dev); m = pdev->si_drv1; snd_mtxlock(m->lock); + mixer_hwvol_mute_locked(m); + snd_mtxunlock(m->lock); +} + +void +mixer_hwvol_step_locked(struct snd_mixer *m, int left_step, int right_step) +{ + int level, left, right; + if (m->hwvol_muted) { m->hwvol_muted = 0; level = m->hwvol_mute_level; @@ -929,15 +930,31 @@ mixer_hwvol_step(device_t dev, int left_step, int right_step) level = mixer_get(m, m->hwvol_mixer); if (level != -1) { left = level & 0xff; - right = level >> 8; + right = (level >> 8) & 0xff; left += left_step * m->hwvol_step; if (left < 0) left = 0; + else if (left > 100) + left = 100; right += right_step * m->hwvol_step; if (right < 0) right = 0; + else if (right > 100) + right = 100; mixer_set(m, m->hwvol_mixer, left | right << 8); } +} + +void +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; + snd_mtxlock(m->lock); + mixer_hwvol_step_locked(m, left_step, right_step); snd_mtxunlock(m->lock); } |