[alsa-devel] patch for Dell 1210 which using stac9221 codec

zhejiang zhe.jiang at intel.com
Thu Oct 25 09:44:42 CEST 2007


On Tue, 2007-10-23 at 11:11 +0200, Takashi Iwai wrote:
> At Mon, 22 Oct 2007 14:08:19 +0800,
> zhejiang wrote:

> > > Ah, then it's basically similar like 3-stack model but with two
> > > headphones instead of a pair of line-out and line-in.
> > > 
> > > Without your modification of pin config, how the driver detects?
> > > Do you have an output of kernel message with debug option about auto
> > > pin configs?
> > > 
> > I don't have the hardware.
> > I have asked the bug reporter to do the experiment,
> > I will post it here if i get any response.
> 
> Thanks.
> 

According to the response from the reporter,here is the pin config of
the original driver.

ALSA /tmp/alsa-driver-build/alsa-driver-1.0.15/pci/hda/hda_codec.c:2765:
autoconfig: line_outs=3 (0xd/0xc/0xf/0x0/0x0)
ALSA /tmp/alsa-driver-build/alsa-driver-1.0.15/pci/hda/hda_codec.c:2769:
speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
ALSA /tmp/alsa-driver-build/alsa-driver-1.0.15/pci/hda/hda_codec.c:2773:
hp_outs=1 (0xa/0x0/0x0/0x0/0x0)
ALSA /tmp/alsa-driver-build/alsa-driver-1.0.15/pci/hda/hda_codec.c:2781:
inputs: mic=0x0, fmic=0x0, line=0x0, fline=0x0, cd=0x0, aux=0x0
ALSA /tmp/alsa-driver-build/alsa-driver-1.0.15/pci/hda/../../alsa-kernel/pci/hda/patch_sigmatel.c:1652: stac92xx_add_dyn_out_pins: total dac count=4
ALSA /tmp/alsa-driver-build/alsa-driver-1.0.15/pci/hda/../../alsa-kernel/pci/hda/patch_sigmatel.c:1775: dac_nids=3 (0x2/0x3/0x5/0x0/0x0)


> > > Looking through the sigmatel code, we have several known use cases:
> > > 
> > > 1. desktop
> > > 1a. 3stack + front panel
> > >     front HP, front mic, rear line-out, rear line-in, rear mic
> > > 
> > > 1b. 6stack + front panel
> > >     front HP, front mic, rear line-out, rear surr, rear CLFE
> > >     rear side, rear line-in, rear mic
> > > and variants without front panel.
> > > 
> > > In the case 1a, rear line-in and rear mic can be used as surround
> > > outputs.
> > > 
> > > 2. laptop
> > > 2a. minimal
> > >     HP, speaker, mic, built-in mic
> > > 2b. a la desktop
> > >     HP, speaker, line-in, mic, built-in mic
> > > 2c. dell
> > >     HP x 2, speaker(s), mic, built-in mic
> > > 
> > > Now, the case 2c requires a similar hack.  But, before going more
> > > deeply, it's better to recheck patch_sigmatel.c again.  Basically, it
> > > has already the code to add output sharing using line-in/mic-in.  The
> > > problem is that it checks only limited use-cases (1a) and it adds
> > > cfg->line_outs and thus this influences on all other places.
> > > 
> > 
> > The call graph of stac92xx_parse_auto_config() :
> > 
> > 1.snd_hda_parse_pin_def_config()
> > 
> > 2.stac92xx_add_dyn_out_pins()
> > It check the cfg->line_outs and input_pins[] to add dynamic lineouts.
> > 
> > 3.stac92xx_auto_fill_dac_nids()
> > It only fills the dac_nids from the cfg->line_out_pins[],
> > 
> > 4.stac92xx_auto_create_multi_out_ctls()
> > It add controls according to the cfg->line_outs.
> > 
> > we can see that they heavily depend on the line_outs[] info.
> > 
> > How about this method?
> > 
> > In stac92xx_add_dyn_out_pins(),we check the cfg->hp_outs,IF IT IS 2,then
> > we switch the cfg->hp_pins[] with cfg->line_out_pins[].
> 
> Maybe better to check cfg->line_out_type.  I guess it's
> AUTO_PIN_SPEAKER_OUT in the case of this Dell laptop.  The driver
> takes speaker in prior to headphone as the primary line-out.
> 
> > The 2,3,4 may work without change.
> > At the end of the stac92xx_parse_auto_config(),we restore the
> > cfg->hp_pins[] and cfg->line_out_pins[].
> 
> Alternatively, instead of saving/restoring informatoin, we can fix
> snd_hda_parse_pin_def_config() itself to check cfg->hp_outs and
> cfg->speaker_outs to determine the primary output.  If one of them is
> greater, take it as the primary output.
> It's less hackish but *might* cause some regression in rare cases.
> 


I think that we need to restore the cfg->hp_pins and cfg->line_out_pins
for the rest code,because:

1. stac92xx_auto_init_hp_out() need to use the hp_pins to enable the
AC_PINCTL_HP_EN
2. stac92xx_hp_detect() need to use the hp_outs to detect jack presense
   and will disable line_out_pins and speaker_pins.
3. stac92xx_init() use the hp_pins to enable unsolicited response.

If we copy cfg->hp_outs to the line_out_pins, all these codes won't
work. ^-^


> > Another things to change :
> > 1.snd_hda_parse_pin_def_config()
> > 	Should sort the hp_pins[] by sequence.
> 
> Yeah, just missing right now.
> 
> > 2.stac92xx_auto_fill_dac_nids()
> > 	Support the "Front Mic" switch as well.
> > 3.stac92xx_io_switch_put()
> > 	If Mic work as output for laptop,enable pin detect too.
> 
> Well, I think the better fix is to fix the "Front Mic".  If there is
> only a front mic, it should be basically labelled as "Mic" because
> it's the only one.  So, again, snd_hda_parse_pin_def_config(), we can
> reassign input_pins[AUTO_PIN_FRONT_MIC] to input_pins[AUTO_PIN_MIC] if
> there is only one mic.  Then the rest wouldn't need changes.
> 

Great.

> Of course, another question is what to do when we have both rear and
> front mic and if we still want to handle them as outputs.  Well, we
> have no such hardware yet, though.
> 
> 
> thanks,
> 
> Takashi


More information about the Alsa-devel mailing list