Module Name:    src
Committed By:   riz
Date:           Sun Nov 21 20:18:41 UTC 2010

Modified Files:
        src/sys/dev/pci/hdaudio [netbsd-5]: hdaudio.c hdaudio_afg.c
            hdaudio_pci.c
Added Files:
        src/sys/dev/pci/hdaudio [netbsd-5]: hdaudio_pci.h

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #1441):
        sys/dev/pci/hdaudio/hdaudio_afg.c: revision 1.23
        sys/dev/pci/hdaudio/hdaudio.c: revision 1.7
        sys/dev/pci/hdaudio/hdaudio_pci.h: revision 1.1
        sys/dev/pci/hdaudio/hdaudio_pci.c: revision 1.6
Reject invalid vendor IDs (say if there was a RIRB timeout while reading the
VID registers)
add support for nvidia hdaudio controllers
properly round block and buffer sizes -- nvidia HDA controllers work now


To generate a diff of this commit:
cvs rdiff -u -r1.4.4.3 -r1.4.4.4 src/sys/dev/pci/hdaudio/hdaudio.c
cvs rdiff -u -r1.14.2.6 -r1.14.2.7 src/sys/dev/pci/hdaudio/hdaudio_afg.c
cvs rdiff -u -r1.2.4.2 -r1.2.4.3 src/sys/dev/pci/hdaudio/hdaudio_pci.c
cvs rdiff -u -r0 -r1.1.6.2 src/sys/dev/pci/hdaudio/hdaudio_pci.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.4.4.3 src/sys/dev/pci/hdaudio/hdaudio.c:1.4.4.4
--- src/sys/dev/pci/hdaudio/hdaudio.c:1.4.4.3	Sun Oct 18 16:50:13 2009
+++ src/sys/dev/pci/hdaudio/hdaudio.c	Sun Nov 21 20:18:41 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: hdaudio.c,v 1.4.4.3 2009/10/18 16:50:13 bouyer Exp $ */
+/* $NetBSD: hdaudio.c,v 1.4.4.4 2010/11/21 20:18:41 riz 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.4.4.3 2009/10/18 16:50:13 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.4.4.4 2010/11/21 20:18:41 riz Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -668,6 +668,10 @@
 	snc = hdaudio_command(co, 0, CORB_GET_PARAMETER,
 	    COP_SUBORDINATE_NODE_COUNT);
 
+	/* make sure the vendor and product IDs are valid */
+	if (vid == 0xffffffff || vid == 0x00000000)
+		return;
+
 #ifdef HDAUDIO_DEBUG
 	hda_print(sc, "Codec%02X: %04X:%04X HDA %d.%d rev %d stepping %d\n",
 	    co->co_addr, vid >> 16, vid & 0xffff,

Index: src/sys/dev/pci/hdaudio/hdaudio_afg.c
diff -u src/sys/dev/pci/hdaudio/hdaudio_afg.c:1.14.2.6 src/sys/dev/pci/hdaudio/hdaudio_afg.c:1.14.2.7
--- src/sys/dev/pci/hdaudio/hdaudio_afg.c:1.14.2.6	Thu Jan 21 08:38:45 2010
+++ src/sys/dev/pci/hdaudio/hdaudio_afg.c	Sun Nov 21 20:18:41 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: hdaudio_afg.c,v 1.14.2.6 2010/01/21 08:38:45 snj Exp $ */
+/* $NetBSD: hdaudio_afg.c,v 1.14.2.7 2010/11/21 20:18:41 riz Exp $ */
 
 /*
  * Copyright (c) 2009 Precedence Technologies Ltd <[email protected]>
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hdaudio_afg.c,v 1.14.2.6 2010/01/21 08:38:45 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdaudio_afg.c,v 1.14.2.7 2010/11/21 20:18:41 riz Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -3330,7 +3330,7 @@
 	}
 
 	/* Multiple of 128 */
-	blksize &= ~128;
+	blksize &= ~127;
 	if (blksize <= 0)
 		blksize = 128;
 
@@ -3338,7 +3338,7 @@
 	if (bufsize > HDAUDIO_BDL_MAX * blksize) {
 		blksize = bufsize / HDAUDIO_BDL_MAX;
 		if (blksize & 128)
-			blksize = (blksize + 128) & ~128;
+			blksize = (blksize + 128) & ~127;
 	}
 
 	return blksize;
@@ -3552,7 +3552,7 @@
 hdaudio_afg_round_buffersize(void *opaque, int direction, size_t bufsize)
 {
 	/* Multiple of 128 */
-	bufsize &= ~128;
+	bufsize &= ~127;
 	if (bufsize <= 0)
 		bufsize = 128;
 	return bufsize;

Index: src/sys/dev/pci/hdaudio/hdaudio_pci.c
diff -u src/sys/dev/pci/hdaudio/hdaudio_pci.c:1.2.4.2 src/sys/dev/pci/hdaudio/hdaudio_pci.c:1.2.4.3
--- src/sys/dev/pci/hdaudio/hdaudio_pci.c:1.2.4.2	Sat Sep 26 19:52:10 2009
+++ src/sys/dev/pci/hdaudio/hdaudio_pci.c	Sun Nov 21 20:18:41 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: hdaudio_pci.c,v 1.2.4.2 2009/09/26 19:52:10 snj Exp $ */
+/* $NetBSD: hdaudio_pci.c,v 1.2.4.3 2010/11/21 20:18:41 riz Exp $ */
 
 /*
  * Copyright (c) 2009 Precedence Technologies Ltd <[email protected]>
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hdaudio_pci.c,v 1.2.4.2 2009/09/26 19:52:10 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdaudio_pci.c,v 1.2.4.3 2010/11/21 20:18:41 riz Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -49,6 +49,7 @@
 
 #include <dev/pci/hdaudio/hdaudioreg.h>
 #include <dev/pci/hdaudio/hdaudiovar.h>
+#include <dev/pci/hdaudio/hdaudio_pci.h>
 
 struct hdaudio_pci_softc {
 	struct hdaudio_softc	sc_hdaudio;	/* must be first */
@@ -153,6 +154,18 @@
 	if (!pmf_device_register(self, NULL, hdaudio_pci_resume))
 		aprint_error_dev(self, "couldn't establish power handler\n");
 
+	switch (PCI_VENDOR(pa->pa_id)) {
+	case PCI_VENDOR_NVIDIA:
+		/* enable snooping */
+		csr = pci_conf_read(sc->sc_pc, sc->sc_tag,
+		    HDAUDIO_NV_REG_SNOOP);
+		csr &= ~HDAUDIO_NV_SNOOP_MASK;
+		csr |= HDAUDIO_NV_SNOOP_ENABLE;
+		pci_conf_write(sc->sc_pc, sc->sc_tag,
+		    HDAUDIO_NV_REG_SNOOP, csr);
+		break;
+	}
+
 	/* Attach bus-independent HD audio layer */
 	hdaudio_attach(self, &sc->sc_hdaudio);
 }

Added files:

Index: src/sys/dev/pci/hdaudio/hdaudio_pci.h
diff -u /dev/null src/sys/dev/pci/hdaudio/hdaudio_pci.h:1.1.6.2
--- /dev/null	Sun Nov 21 20:18:41 2010
+++ src/sys/dev/pci/hdaudio/hdaudio_pci.h	Sun Nov 21 20:18:41 2010
@@ -0,0 +1,38 @@
+/* $NetBSD: hdaudio_pci.h,v 1.1.6.2 2010/11/21 20:18:41 riz Exp $ */
+
+/*
+ * Copyright (c) 2010 Jared D. McNeill <[email protected]>
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Precedence Technologies Ltd
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _HDAUDIO_PCI_H
+#define _HDAUDIO_PCI_H
+
+#define	HDAUDIO_NV_REG_SNOOP	0x4c
+#define	  HDAUDIO_NV_SNOOP_MASK		0x00ff0000
+#define	  HDAUDIO_NV_SNOOP_ENABLE	0x000f0000
+
+#endif /* !_HDAUDIO_PCI_H */

Reply via email to