alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Raymond Yau <superquad.vortex2@gmail.com>
To: ALSA Development Mailing List <alsa-devel@alsa-project.org>
Subject: Re: [RFC] hda - is_jack_detectable()
Date: Tue, 27 Dec 2011 09:45:13 +0800	[thread overview]
Message-ID: <CAN8ccibh75HN0Des_4Vx7ozhsZsqqiFM7p2=oWRtQr-iXe0qYQ@mail.gmail.com> (raw)
In-Reply-To: <s5hhb0rod01.wl%tiwai@suse.de>

2011/12/23, Takashi Iwai <tiwai@suse.de>:
> At Fri, 23 Dec 2011 10:37:15 +0800,
> Raymond Yau wrote:
>>
>>
>> How can I add the new hda-jack detect to patch_analog.c ?
>>
>> Only ad1988 use  snd_hda_parse_pin_def_config() to parse the pin,
>> other ad198x codecs are used model since snd_hda_jack_add_ctls()
>> require those pin info from autocfg
>
> Not necessarily.  You can call snd_hda_jack_add_kctl() and enable the
> pin-detection via snd_hda_jack_detect_enable() directly.
>
>> The auto model of ad1988 use init_verbs ad1988_6stack_init which
>> cannot handle those 3 stack motherboard asus m2n
>>
>> What is the reason to call snd_hda_jack_report_sync() at the end of
>> unsol event handler ?
>
> To notify the jack-detection.
>


It seem that I need to add jack->dirty = 1 in ad1988_unsol_event to
force snd_hda_jack_detect() to call read_pin_sense() since
jack->jack_detect is set when calling snd_hda_jack_detect_enable()

Using snd_hda_jack_detect_enable(codec, pin, pin) instead of
snd_hda_jack_detect_enable(codec, pin, HP_EVENT) simiar to hdmi so
that all the detectable pins are assigned different tag

+static void ad1988_hp_automute(struct hda_codec *codec)
+{
+	int i, present;
+	struct ad198x_spec *spec = codec->spec;
+			
+	present = snd_hda_jack_detect(codec, 0x11);
+	if (spec->independent_hp)
+		return;
+	for (i=0; i < spec->multiout.num_dacs; i++)
+		snd_hda_codec_write(codec, spec->autocfg.line_out_pins[i],
+				0, AC_VERB_SET_AMP_GAIN_MUTE,
+				present ? AMP_OUT_MUTE : AMP_OUT_UNMUTE);		
+	
+	if (spec->autocfg.mono_out_pin)
+		snd_hda_codec_write(codec, spec->autocfg.mono_out_pin,
+			0, AC_VERB_SET_AMP_GAIN_MUTE,
+			present ? AMP_OUT_MUTE : AMP_OUT_UNMUTE);
+
+	for (i=0; i < spec->autocfg.speaker_outs; i++) {
+		snd_hda_codec_write(codec, spec->autocfg.speaker_pins[i],
+			0, AC_VERB_SET_AMP_GAIN_MUTE,
+			present ? AMP_OUT_MUTE : AMP_OUT_UNMUTE);
+	}
+}
+
+static void ad1988_unsol_event(struct hda_codec *codec, unsigned int res)
+{
+	struct hda_jack_tbl *jack = snd_hda_jack_tbl_get_from_tag(codec, res >> 26);
+	struct ad198x_spec *spec = codec->spec;
+	jack->jack_dirty = 1;
+	if (jack->nid == spec->autocfg.hp_pins[0])
+		ad1988_hp_automute(codec);
+	snd_hda_jack_report_sync(codec);
+}
+
+#define check_jack_detect(c, p) if (is_jack_detectable(c, p))
snd_hda_jack_detect_enable(c, p, p)
+
+void ad1988_auto_init_unsol_event(struct hda_codec *codec)
+{
+	int i;
+	struct ad198x_spec *spec = codec->spec;
+	check_jack_detect(codec, spec->autocfg.hp_pins[0]);
+	for (i=0; i<spec->autocfg.line_outs; i++)
+		check_jack_detect(codec, spec->autocfg.line_out_pins[0]);
+	for (i=0; i<spec->autocfg.num_inputs; i++)
+		check_jack_detect(codec, spec->autocfg.inputs[i].pin);
+	snd_hda_jack_add_kctls(codec, &spec->autocfg);
+	snd_hda_jack_report_sync(codec);
+}

static int ad1988_auto_init(struct hda_codec *codec)
{
	ad198x_init(codec);
	ad1988_auto_init_multi_out(codec);
	ad1988_auto_init_extra_out(codec);
	ad1988_auto_init_analog_input(codec);
+	ad1988_auto_init_unsol_event(codec);
	return 0;
}



	codec->patch_ops = ad198x_patch_ops;
	switch (board_config) {
	case AD1988_AUTO:
		codec->patch_ops.init = ad1988_auto_init;
+		codec->patch_ops.unsol_event = ad1988_unsol_event;
		break;

  reply	other threads:[~2011-12-27  1:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-25  3:02 [RFC] hda - is_jack_detectable() Raymond Yau
2011-10-25  3:31 ` Raymond Yau
2011-10-25 11:31   ` Takashi Iwai
2011-11-01 21:03   ` David Henningsson
2011-11-02  7:02     ` Takashi Iwai
2011-11-05  5:30       ` Raymond Yau
2011-11-06 13:12         ` Takashi Iwai
2011-11-09  4:06           ` Raymond Yau
2011-11-09  7:08             ` Takashi Iwai
2011-11-09  7:50               ` Takashi Iwai
     [not found]                 ` <CAN8ccibAoNQfDNWJ-zE_DGH6mc-ipmmdhBDQW+fjOMT8xHcD+Q@mail.gmail.com>
     [not found]                   ` <s5h4ny76naa.wl%tiwai@suse.de>
2011-11-16  7:14                     ` Raymond Yau
2011-11-17 15:17                       ` Takashi Iwai
2011-12-23  2:37                         ` Raymond Yau
2011-12-23  9:26                           ` Takashi Iwai
2011-12-27  1:45                             ` Raymond Yau [this message]
2011-11-06 11:46     ` Raymond Yau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAN8ccibh75HN0Des_4Vx7ozhsZsqqiFM7p2=oWRtQr-iXe0qYQ@mail.gmail.com' \
    --to=superquad.vortex2@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).