Module Name: src Committed By: drochner Date: Tue Sep 8 18:33:24 UTC 2009
Modified Files: src/sys/dev/pci/hdaudio: hdaudio_afg.c Log Message: fix scaling of mixer gain values: the register can be smaller than 7 bits, this is told by some "step" parameter read from the hardware (fixes problems with a 5-bit register observed by Nicolas Joly and me) approved by Jared D. McNeill To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/hdaudio/hdaudio_afg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/hdaudio/hdaudio_afg.c diff -u src/sys/dev/pci/hdaudio/hdaudio_afg.c:1.7 src/sys/dev/pci/hdaudio/hdaudio_afg.c:1.8 --- src/sys/dev/pci/hdaudio/hdaudio_afg.c:1.7 Mon Sep 7 16:41:37 2009 +++ src/sys/dev/pci/hdaudio/hdaudio_afg.c Tue Sep 8 18:33:24 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: hdaudio_afg.c,v 1.7 2009/09/07 16:41:37 jmcneill Exp $ */ +/* $NetBSD: hdaudio_afg.c,v 1.8 2009/09/08 18:33:24 drochner Exp $ */ /* * Copyright (c) 2009 Precedence Technologies Ltd <supp...@precedence.co.uk> @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hdaudio_afg.c,v 1.7 2009/09/07 16:41:37 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hdaudio_afg.c,v 1.8 2009/09/08 18:33:24 drochner Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -3390,8 +3390,8 @@ } hdaudio_afg_control_amp_set(ctl, HDAUDIO_AMP_MUTE_NONE, - mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT] / 2, - mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] / 2); + mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT] / (255 / ctl->ctl_step), + mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] / (255 / ctl->ctl_step)); return 0; } @@ -3434,8 +3434,10 @@ return 0; } - mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = ctl->ctl_left * 2; - mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = ctl->ctl_right * 2; + mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = + ctl->ctl_left * (255 / ctl->ctl_step); + mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = + ctl->ctl_right * (255 / ctl->ctl_step); return 0; }