[alsa-devel] Got microphone working with SigmaTel STAC 9221 A1 on a Dell XPS M1210

Eran Guendelman erang at stanford.edu
Sun Jun 10 01:37:11 CEST 2007

I installed SuSE 10.2 on my new XPS M1210 laptop and found that the 
microphone was not working (headphones and internal speakers worked 
fine).  I eventually got it working, and wanted to write an email 
describing how I did this.

The two main important steps (which I will describe in more detail 
below) were:
- Changing the default pin configurations ref922x_pin_configs in 
patch_sigmatel.c to values that were based on the windows driver's INI 
file but with one important tweak.
- Running the driver using the "model=ref" parameter so that the above 
modified pin configurations are used.

Note that it could be that my solution is overkill and there's actually 
a way to get this working with the unmodified alsa drivers...  But I did 
not find any such solutions (e.g. I've tried setting "model=ref", 
"model=3stack", "model=5stack", but none of those fixed the microphone). 
  In general, it seems that the solutions proposed on the internet to 
getting the SigmaTel codec working are very dependent on the exact type 
of system you've got...  So this will likely only work for a Dell XPS 
M1210.  Here is some more system info:

"lspci -v" gives this as my audio card:

00:1b.0 Audio device: Intel Corporation 82801G (ICH7 Family) High 
Definition Audio Controller (rev 01)
	Subsystem: Dell Unknown device 01d7
	Flags: bus master, fast devsel, latency 0, IRQ 233
	Memory at efffc000 (64-bit, non-prefetchable) [size=16K]
	Capabilities: [50] Power Management version 2
	Capabilities: [60] Message Signalled Interrupts: Mask- 64bit+ Queue=0/0 
	Capabilities: [70] Express Unknown type IRQ 0
	Capabilities: [100] Virtual Channel
	Capabilities: [130] Unknown (5)

My card uses the snd_hda_intel module, and the codec type (given by "cat 
/proc/asound/card0/codec#0") gives this information at the top:

Codec: SigmaTel STAC9221 A1
Address: 0
Vendor Id: 0x83847680
Subsystem Id: 0x102801d7
Revision Id: 0x103601

So here's what I did (taking many days and many wrong steps before 
arriving at this solution):

- I have a dual-boot system and installed the official DELL drivers for 
the sound card in Windows XP.  My goal was to find which INI file 
corresponded to my installed sound card, so I did the following:

	- Using Windows device manager, I looked at the properties for the 
SigmaTel codec driver and found that one of the property items had a 
string that included the substring


	- The self-extracting DELL driver extracted files into 
c:\dell\drivers\r122161, and in the wdm subdirectory I searched for the 
above string and found that the files 92xxM.INI, Sthda.ini, and 
sthda64.ini all contained the above string and also had the suffix 
=92xxM8-2.ini appended to it.  This led me to deduce that the relevant 
file was 92xxm8-2.ini

	- This is an excerpt from 92xxm8-2.ini:

CfgDflt = dword: 0x0221121E
AltCfg = hex: 20,12,11,02
Action = hex: 80,00,87,00,81,0D
CfgDflt = dword: 0x408103FF
CfgDflt = dword: 0x0281123E
AltCfg = hex: 22,12,11,02,30,12,A1,02
Bias = hex: FF,04,02
Action: hex: 0A, 0C
CfgDflt = dword: 0x90100310
CfgDflt = dword: 0x408003F1
CfgDflt = dword: 0x0221122F
AltCfg = hex: 21,12,11,02
Action = hex: 80,00,87,00,81,0D
CfgDflt = dword: 0x03451340
CfgDflt = dword: 0x40C003F2
CfgDflt = dword: 0x50A003F3
CfgDflt = dword: 0x405003F4

	- This will be useful later...  Now back to linux.

- I downloaded latest alsa-driver package (version 1.0.14).

- I edited alsa-kernel/pci/hda/patch_sigmatel.c, and replaced the 
contents of the ref922x_pin_configs array with the default pin 
configurations found in the INI file above WITH ONE IMPORTANT TWEAK. 
Specifically, this is my new array:

static unsigned int ref922x_pin_configs[10] = {
     0x0221121E, 0x408103FF, 0x02A1123E, 0x90100310,
     0x408003F1, 0x0221122F, 0x03451340, 0x40C003F2,
     0x50A003F3, 0x405003F4

- If you compare these numbers to the CfgDflt values from the Windows 
INI file above, you'll see that they match except that for the third 
value, instead of
I use

Here's why:  I figured out that pin complex 0x0c was my microphone jack 
(the right-most of the three jacks in the front of my laptop).  The 
0x281123E configuration indicates a "Line In at Ext Front" jack... 
Indeed, this jack can serve as a line in or mic in or even I believe as 
output to rear speakers.  But designating it as Line In by default seems 
to confuse the patch_sigmatel.c routines that set up the codec...  They 
assume it's just a line in jack and do not mark it as potential 
microphone input.  Changing the 8 to an A in the value designates it as 
"Mic at Ext Front", so the codec recognizes it as the microphone input 
for the card.  What ends up happening is that as a microphone input, the 
Pin-ctls for the pin gets assigned to 0x24, whereas when it just thinks 
it's a Line In the Pin-ctls gets set to 0x20.  Both designate an input, 
but the 4 in 0x24 seems to also give it a Voltage Reference Signal which 
I guess is important for microphone inputs.  (I don't fully understand 
most of this stuff... I've just been reading up about the HD Audio specs 
over the last few days).

- Build and install drivers using
	"./configure --with-cards=hda-intel --with-sequencer=yes; make; make 

- Make sure the snd_hda_intel gets loaded with model=ref option.  You 
need to specify the ref model so that the pin configurations set up 
above are used.  Of course, the right way to do this would be to make a 
whole new model, but I didn't bother doing that in my quick hack. 
Anyway, in SuSE 10.2 you can set the model through YaST, or you can 
manually edit /etc/modprobe.d/sound and make sure model=ref is listed as 
one of the options in the "options snd-hda-intel  . . ." line

- Reset sound drivers.  (Best to just reset computer, but on SuSE 10.2 
it usually works if I do "/etc/init.d/alsasound reset")

- And that's basically it...  In the mixer (e.g. alsamixer) it's 
important to make sure the Capture channel has "CAPTUR" on and that it's 
at a high value, and that the Mux is at its max too.  It does not allow 
me to change "Input Source", but that's fine because the above 
essentially hard codes it to be Front Mic which is what I wanted.

I've attached the contents of /proc/asound/card0/codec#0 in its good 
(mic working) state.  The final path is
	0x0c (mic)
	-> 0x12 (audio selector, stereo amp-out; Mux in the mixer)
	-> 0x17 (audio selector, stereo amp-in; Capture in the mixer)
	-> 0x06 (audio input)

After searching on the internet, reading about HD Audio, and poking 
around the driver code, I do have a number of lingering questions I 
would be happy to have answered:

- Why does patch_sigmatel.c "fix" mux capture levels to 2?  The Mux 
(0x12) ends up in the path from the mic in jack to the audio in, so is 
it supposed to act as a Mic Boost or something?

- I noticed my headphone jacks (0x0a, 0x0f) have Pin-ctls set at 0xc0 
which is OUT HP (i.e. uses a low impedance amplifier for headphone 
output).  Would it damage my sound card or speakers if I connected these 
jacks to powered speakers or to an audio receiver (i.e. more 
traditionally connected to a Line Out)?

- Does the snd_hda_intel driver currently (or will it eventually) 
support dynamic switching so I can switch from the Mic In to Line In or 
to Rear Speakers Out, etc, just like in the Windows driver?

- Some solutions on the internet talked about creating an .asoundrc file 
to get the codec working...  I don't understand what that file is for 
and whether I need to tweak it at all...  But since I have a working 
solution without the file I guess I'm fine?



P.S. Not subscribed, so please respond by email...

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: codec
Url: http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20070609/9e12d050/attachment.bat 

More information about the Alsa-devel mailing list