Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci/hdaudio fix scaling of mixer gain values: the re...



details:   https://anonhg.NetBSD.org/src/rev/0f9a372d7bb3
branches:  trunk
changeset: 747289:0f9a372d7bb3
user:      drochner <drochner%NetBSD.org@localhost>
date:      Tue Sep 08 18:33:24 2009 +0000

description:
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

diffstat:

 sys/dev/pci/hdaudio/hdaudio_afg.c |  14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diffs (42 lines):

diff -r 41083e92b743 -r 0f9a372d7bb3 sys/dev/pci/hdaudio/hdaudio_afg.c
--- a/sys/dev/pci/hdaudio/hdaudio_afg.c Tue Sep 08 18:31:36 2009 +0000
+++ b/sys/dev/pci/hdaudio/hdaudio_afg.c Tue Sep 08 18:33:24 2009 +0000
@@ -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 <support%precedence.co.uk@localhost>
@@ -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;
 }
 



Home | Main Index | Thread Index | Old Index