Subject: ac97 audio hack
To: None <tech-kern@netbsd.org>
From: Cliff Wright <cliff@snipe444.org>
List: tech-kern
Date: 10/17/2006 14:15:42
This is a multi-part message in MIME format.

--Multipart=_Tue__17_Oct_2006_14_15_42_-0700_bKWRGVyH6QtIb=Ip
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

A PC I use shares the Microphone, and LFE/Center speaker output.
On NetBsd 2.0 I used a hack to allow the micrphone input work, as the driver did
not support this. This is a hack as it hardcodes the microphone for
input. It looks like some structure changes would need to be made to
audio to support this in the kernel. Since I had to dig this old hack
up to support my upgrade to 3.1, I thought I would share this in case
someone else found it useful. Also found a minor bug where monaural is
taken from the right channel instead of left. Since most apps duplicate
left on right for monaural this will not normaly be seen, but maybe I should
sendpr this.


--Multipart=_Tue__17_Oct_2006_14_15_42_-0700_bKWRGVyH6QtIb=Ip
Content-Type: text/plain;
 name="ac97patch.txt"
Content-Disposition: attachment;
 filename="ac97patch.txt"
Content-Transfer-Encoding: 7bit

--- ac97.c.distrib	2005-01-10 14:01:37.000000000 -0800
+++ ac97.c	2006-10-17 14:05:15.000000000 -0700
@@ -1290,6 +1290,7 @@
 		if (deltar && or == r)
 			r += (deltar > 0) ? (r ? -1 : 0) : (r < mask ? 1 : 0);
 
+		if (value->num_channels == 1) r = l;/* mono from left. cliff */
 		newval = ((r & mask) << si->ofs);
 		if (value->num_channels == 2) {
 			newval = newval | ((l & mask) << (si->ofs+8));
@@ -1605,6 +1606,14 @@
 	ac97_write(as, AD1980_REG_MISC,
 		   misc | AD1980_MISC_LOSEL | AD1980_MISC_HPSEL);
 
+	/*
+	 * Microphone and LFE/Center speaker output are shared on this PC.
+	 * Setup to always select microphone, as I am not using output.
+	 * cliff
+	 */
+	ac97_read(as, 0x74, &misc);
+	ac97_write(as, 0x74, misc | 0x200); /* oms bit, serial config reg */
+
 	for (i = 0; i < as->num_source_info; i++) {
 		if (as->source_info[i].type != AUDIO_MIXER_VALUE)
 			continue;

--Multipart=_Tue__17_Oct_2006_14_15_42_-0700_bKWRGVyH6QtIb=Ip--