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 Use fewer magic constants related to the...



details:   https://anonhg.NetBSD.org/src/rev/e2adf821c6c2
branches:  trunk
changeset: 756805:e2adf821c6c2
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Tue Aug 03 04:02:21 2010 +0000

description:
Use fewer magic constants related to the GCAP register.

diffstat:

 sys/dev/pci/hdaudio/hdaudio.c    |  14 +++++++-------
 sys/dev/pci/hdaudio/hdaudioreg.h |   7 ++++++-
 2 files changed, 13 insertions(+), 8 deletions(-)

diffs (62 lines):

diff -r 3f25ecc2c8dc -r e2adf821c6c2 sys/dev/pci/hdaudio/hdaudio.c
--- a/sys/dev/pci/hdaudio/hdaudio.c     Mon Aug 02 19:59:35 2010 +0000
+++ b/sys/dev/pci/hdaudio/hdaudio.c     Tue Aug 03 04:02:21 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hdaudio.c,v 1.5 2009/10/11 08:50:11 sborrill Exp $ */
+/* $NetBSD: hdaudio.c,v 1.6 2010/08/03 04:02:21 jakllsch Exp $ */
 
 /*
  * Copyright (c) 2009 Precedence Technologies Ltd <support%precedence.co.uk@localhost>
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.5 2009/10/11 08:50:11 sborrill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.6 2010/08/03 04:02:21 jakllsch Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -125,17 +125,17 @@
 #endif
 
        gcap = hda_read2(sc, HDAUDIO_MMIO_GCAP);
-       nis = (gcap >> 8) & 0xf;
-       nos = (gcap >> 12) & 0xf;
-       nbidir = (gcap >> 3) & 0x1f;
+       nis = HDAUDIO_GCAP_ISS(gcap);
+       nos = HDAUDIO_GCAP_OSS(gcap);
+       nbidir = HDAUDIO_GCAP_BSS(gcap);
 
        /* Initialize codecs and streams */
        hdaudio_codec_init(sc);
        hdaudio_stream_init(sc, nis, nos, nbidir);
 
 #if defined(HDAUDIO_DEBUG)
-       nsdo = (gcap >> 1) & 1;
-       addr64 = gcap & 1;
+       nsdo = HDAUDIO_GCAP_NSDO(gcap);
+       addr64 = HDAUDIO_GCAP_64OK(gcap);
 
        hda_print(sc, "OSS %d ISS %d BSS %d SDO %d%s\n",
            nos, nis, nbidir, nsdo, addr64 ? " 64-bit" : "");
diff -r 3f25ecc2c8dc -r e2adf821c6c2 sys/dev/pci/hdaudio/hdaudioreg.h
--- a/sys/dev/pci/hdaudio/hdaudioreg.h  Mon Aug 02 19:59:35 2010 +0000
+++ b/sys/dev/pci/hdaudio/hdaudioreg.h  Tue Aug 03 04:02:21 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hdaudioreg.h,v 1.3 2009/09/06 21:38:17 rmind Exp $ */
+/* $NetBSD: hdaudioreg.h,v 1.4 2010/08/03 04:02:21 jakllsch Exp $ */
 
 /*
  * Copyright (c) 2009 Precedence Technologies Ltd <support%precedence.co.uk@localhost>
@@ -44,6 +44,11 @@
  * High Definition Audio Memory Mapped Configuration Registers
  */
 #define        HDAUDIO_MMIO_GCAP       0x000
+#define         HDAUDIO_GCAP_64OK(x)           ((x) & 1)
+#define         HDAUDIO_GCAP_NSDO(x)           ((((x) & 6) != 0) ? ((x) & 6) : 1)
+#define         HDAUDIO_GCAP_BSS(x)            (((x) >>  3) & 0x1f)
+#define         HDAUDIO_GCAP_ISS(x)            (((x) >>  8) & 0x0f)
+#define         HDAUDIO_GCAP_OSS(x)            (((x) >> 12) & 0x0f)
 #define        HDAUDIO_MMIO_VMIN       0x002
 #define        HDAUDIO_MMIO_VMAJ       0x003
 #define        HDAUDIO_MMIO_OUTPAY     0x004



Home | Main Index | Thread Index | Old Index