[alsa-devel] Digital-Out (Toslink) on HDA-Intal (AD1986A)?
Takashi Iwai
tiwai at suse.de
Mon Feb 11 16:35:08 CET 2008
At Sat, 9 Feb 2008 13:01:18 +0100,
Martin Egge wrote:
>
> Hi,
>
> Am Freitag, 8. Februar 2008 schrieb Takashi Iwai:
> > At Fri, 08 Feb 2008 11:59:48 +0100,
> > I wrote:
> > > At Thu, 7 Feb 2008 22:55:40 +0100,
> > > Martin Egge wrote:
> > > > Am Donnerstag, 7. Februar 2008 schrieb Takashi Iwai:
> > > > > The patch below adds the automatic mic switch for Samsung.
> > > > > Give it a try.
> > > >
> > > > I gave it a try on the latest HG. You almost got the hang on it. The
> > > > internal mic works for the first time with model=laptop-eapd. But the
> > > > jack sense (autmatic switch to external mic when connected) does not
> > > > work. Both mics are recorded at the same time.
> > >
> > > Do you see any difference in codec# proc file between mic-plugged and
> > > unplugged states?
>
> Yes there is a difference:
>
> With mic plugged I get the following in lines 161 to 172 of codec#0:
> ------------------------------------------------------------
> Node 0x1d [Pin Complex] wcaps 0x400985: Stereo Amp-Out R/L
> Amp-Out caps: ofs=0x1f, nsteps=0x1f, stepsize=0x05, mute=1
> Amp-Out vals: [0x80 0x80]
> Pincap 0x081737: IN OUT Detect Trigger ImpSense
> Vref caps: HIZ 50 GRD 80
> Pin Default 0x01019015: [Jack] Line Out at Ext Rear
> Conn = 1/8, Color = Pink
> DefAssociation = 0x1, Sequence = 0x5
> Pin-ctls: 0x00: VREF_HIZ
> Unsolicited: tag=00, enabled=0
> Connection: 1
> 0x0d
> ------------------------------------------------------------
>
> With mic unplugged I get the following in lines 161 to 172 of codec#0:
> ------------------------------------------------------------
> Node 0x1d [Pin Complex] wcaps 0x400985: Stereo Amp-Out R/L
> Amp-Out caps: ofs=0x1f, nsteps=0x1f, stepsize=0x05, mute=1
> Amp-Out vals: [0x80 0x80]
> Pincap 0x081737: IN OUT Detect Trigger ImpSense
> Vref caps: HIZ 50 GRD 80
> Pin Default 0x01019015: [Jack] Line Out at Ext Rear
> Conn = 1/8, Color = Pink
> DefAssociation = 0x1, Sequence = 0x5
> Pin-ctls: 0x24: IN VREF_80
> Unsolicited: tag=00, enabled=0
> Connection: 1
> 0x0d
> ------------------------------------------------------------
Interesting. So, the pin ctl of the widget 0x1d plays no role,
apparently.
How about the patch below? If it still doesn't work, please show the
whole codec#* proc file again.
Also, what about another spdif-share-switch patch?
Takashi
---
diff -r 6db3c028922a pci/hda/patch_analog.c
--- a/pci/hda/patch_analog.c Mon Feb 11 16:19:58 2008 +0100
+++ b/pci/hda/patch_analog.c Mon Feb 11 16:35:02 2008 +0100
@@ -612,13 +612,19 @@ static struct hda_input_mux ad1986a_lapt
},
};
+static struct hda_input_mux ad1986a_automic_capture_source = {
+ .num_items = 2,
+ .items = {
+ { "Mic", 0x0 },
+ { "Mix", 0x5 },
+ },
+};
+
static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
- HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT),
- HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT),
HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
@@ -641,6 +647,33 @@ static struct snd_kcontrol_new ad1986a_l
},
{ } /* end */
};
+
+/* re-connect the mic boost input according to the jack sensing */
+static void ad1986a_automic(struct hda_codec *codec)
+{
+ unsigned int present;
+ present = snd_hda_codec_read(codec, 0x1f, 0, AC_VERB_GET_PIN_SENSE, 0);
+ /* 0 = 0x1f, 2 = 0x1d, 4 = mixed */
+ snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_CONNECT_SEL,
+ (present & AC_PINSENSE_PRESENCE) ? 0 : 2);
+}
+
+#define AD1986A_MIC_EVENT 0x36
+
+static void ad1986a_automic_unsol_event(struct hda_codec *codec,
+ unsigned int res)
+{
+ if ((res >> 26) != AD1986A_MIC_EVENT)
+ return;
+ ad1986a_automic(codec);
+}
+
+static int ad1986a_automic_init(struct hda_codec *codec)
+{
+ ad198x_init(codec);
+ ad1986a_automic(codec);
+ return 0;
+}
/* laptop-automute - 2ch only */
@@ -845,6 +878,15 @@ static struct hda_verb ad1986a_eapd_init
{}
};
+static struct hda_verb ad1986a_automic_verbs[] = {
+ {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+ {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+ /*{0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},*/
+ {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0},
+ {0x1f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1986A_MIC_EVENT},
+ {}
+};
+
/* Ultra initialization */
static struct hda_verb ad1986a_ultra_init[] = {
/* eapd initialization */
@@ -987,14 +1029,17 @@ static int patch_ad1986a(struct hda_code
break;
case AD1986A_LAPTOP_EAPD:
spec->mixers[0] = ad1986a_laptop_eapd_mixers;
- spec->num_init_verbs = 2;
+ spec->num_init_verbs = 3;
spec->init_verbs[1] = ad1986a_eapd_init_verbs;
+ spec->init_verbs[2] = ad1986a_automic_verbs;
spec->multiout.max_channels = 2;
spec->multiout.num_dacs = 1;
spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
if (!is_jack_available(codec, 0x25))
spec->multiout.dig_out_nid = 0;
- spec->input_mux = &ad1986a_laptop_eapd_capture_source;
+ spec->input_mux = &ad1986a_automic_capture_source;
+ codec->patch_ops.unsol_event = ad1986a_automic_unsol_event;
+ codec->patch_ops.init = ad1986a_automic_init;
break;
case AD1986A_LAPTOP_AUTOMUTE:
spec->mixers[0] = ad1986a_laptop_automute_mixers;
More information about the Alsa-devel
mailing list