Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Change the way of setting a port value so that a ...



details:   https://anonhg.NetBSD.org/src/rev/7be06dbb8b5d
branches:  trunk
changeset: 552634:7be06dbb8b5d
user:      cube <cube%NetBSD.org@localhost>
date:      Sun Sep 28 22:24:09 2003 +0000

description:
Change the way of setting a port value so that a change too small to
fit in the number of bits used for the port still does something.

This fixes PR pkg/18741 for ac97-based hardware. Other audio drivers
might need a similar fix.

diffstat:

 sys/dev/ic/ac97.c |  22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)

diffs (54 lines):

diff -r 730aeaa8eff6 -r 7be06dbb8b5d sys/dev/ic/ac97.c
--- a/sys/dev/ic/ac97.c Sun Sep 28 22:00:26 2003 +0000
+++ b/sys/dev/ic/ac97.c Sun Sep 28 22:24:09 2003 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: ac97.c,v 1.48 2003/09/28 15:39:09 kent Exp $ */
+/*      $NetBSD: ac97.c,v 1.49 2003/09/28 22:24:09 cube Exp $ */
 /*     $OpenBSD: ac97.c,v 1.8 2000/07/19 09:01:35 csapuntz Exp $       */
 
 /*
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ac97.c,v 1.48 2003/09/28 15:39:09 kent Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ac97.c,v 1.49 2003/09/28 22:24:09 cube Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1152,7 +1152,8 @@
        case AUDIO_MIXER_VALUE:
        {
                const struct audio_mixer_value *value = si->info;
-               u_int16_t  l, r;
+               u_int16_t  l, r, ol, or;
+               int deltal, deltar;
 
                if ((cp->un.value.num_channels <= 0) ||
                    (cp->un.value.num_channels > value->num_channels))
@@ -1176,12 +1177,23 @@
                        r = 255 - r;
                }
 
+               ol = (val >> (8+si->ofs)) & mask;
+               or = (val >> si->ofs) & mask;
+
+               deltal = (ol << (8 - si->bits)) - l;
+               deltar = (or << (8 - si->bits)) - r;
+
                l = l >> (8 - si->bits);
                r = r >> (8 - si->bits);
 
-               newval = ((l & mask) << si->ofs);
+               if (deltal && ol == l)
+                       l += (deltal > 0) ? (l ? -1 : 0) : (l < mask ? 1 : 0);
+               if (deltar && or == r)
+                       r += (deltar > 0) ? (r ? -1 : 0) : (r < mask ? 1 : 0);
+
+               newval = ((r & mask) << si->ofs);
                if (value->num_channels == 2) {
-                       newval = (newval << 8) | ((r & mask) << si->ofs);
+                       newval = newval | ((l & mask) << (si->ofs+8));
                        mask |= (mask << 8);
                }
                mask = mask << si->ofs;



Home | Main Index | Thread Index | Old Index