NetBSD hdaudio jack detection

Submitted by Fekete Zoltán on

If you have an Analog Devices AD1984A audio chip, and could not have headphones jack working, apply the attached patch, and recompile the kernel.

For more information, read the mailing list conversation on the link below.

The patch:

Index: hdafg.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/hdaudio/Attic/hdafg.c,v
retrieving revision 1.21.2.1
diff -u -r1.21.2.1 hdafg.c
--- hdafg.c	4 Sep 2015 15:07:08 -0000	1.21.2.1
+++ hdafg.c	18 Mar 2017 14:11:57 -0000
@@ -656,7 +656,44 @@
 		w->w_pin.config |= 0xe0;
 	}
 #endif
-
+   
+        /* XXX ADI AD1984A */
+        if (sc->sc_vendor == HDA_VENDOR_ANALOG_DEVICES && sc->sc_product == 0x194A) {
+	    if ((COP_CFG_DEFAULT_DEVICE(w->w_pin.config) == COP_DEVICE_SPEAKER)) {
+	        /* nid 22 Speaker */ 
+	        if (w->w_nid == 0x16) {
+		  /* set assoc=1 */
+		  w->w_pin.config &= ~0xf0;
+		  w->w_pin.config |= 0x10;
+		  /* set sequence=0 */
+		  w->w_pin.config &= ~0xf;
+		  w->w_pin.config |= 0x0;
+		}
+	   
+		/* nid 18 Line-out */ 
+		if (w->w_nid == 0x12) {
+		  /* set assoc=2 */
+		  w->w_pin.config &= ~0xf0;
+		  w->w_pin.config |= 0x20;
+		  /* set sequence=0 */ 
+		  w->w_pin.config &= ~0xf;
+		  w->w_pin.config |= 0x0; 
+		}
+	    }
+      
+	    if (COP_CFG_PORT_CONNECTIVITY(w->w_pin.config) == COP_PORT_JACK) {
+	        /* nid 17 */ 
+	        if (w->w_nid == 0x11) {
+		  /* set assoc=1 */
+		  w->w_pin.config &= ~0xf0;
+		  w->w_pin.config |= 0x10;
+		  /* set seq=15 */		
+		  w->w_pin.config &= ~0x0f;
+		  w->w_pin.config |= 0x0f;
+		}
+	    }
+	}
+   
 	conn = COP_CFG_PORT_CONNECTIVITY(w->w_pin.config);
 	color = COP_CFG_COLOR(w->w_pin.config);
 	defdev = COP_CFG_DEFAULT_DEVICE(w->w_pin.config);