Module Name:    src
Committed By:   jakllsch
Date:           Tue Aug  3 04:02:21 UTC 2010

Modified Files:
        src/sys/dev/pci/hdaudio: hdaudio.c hdaudioreg.h

Log Message:
Use fewer magic constants related to the GCAP register.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/hdaudio/hdaudio.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pci/hdaudio/hdaudioreg.h

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.c
diff -u src/sys/dev/pci/hdaudio/hdaudio.c:1.5 src/sys/dev/pci/hdaudio/hdaudio.c:1.6
--- src/sys/dev/pci/hdaudio/hdaudio.c:1.5	Sun Oct 11 08:50:11 2009
+++ src/sys/dev/pci/hdaudio/hdaudio.c	Tue Aug  3 04:02:21 2010
@@ -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 <[email protected]>
@@ -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" : "");

Index: src/sys/dev/pci/hdaudio/hdaudioreg.h
diff -u src/sys/dev/pci/hdaudio/hdaudioreg.h:1.3 src/sys/dev/pci/hdaudio/hdaudioreg.h:1.4
--- src/sys/dev/pci/hdaudio/hdaudioreg.h:1.3	Sun Sep  6 21:38:17 2009
+++ src/sys/dev/pci/hdaudio/hdaudioreg.h	Tue Aug  3 04:02:21 2010
@@ -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 <[email protected]>
@@ -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

Reply via email to