diff options
author | Chih-Chung Chang <chihchung@chromium.org> | 2013-08-05 04:38:42 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-08-05 05:19:59 -0400 |
commit | bde7bc6014a0a6f63cff42211ccd9b7129ce2df9 (patch) | |
tree | e351f28d2c775384b0e7657333b2355a7e72627c /sound | |
parent | da96fb5b0185d27faab0746f872d22b0cee7b026 (diff) |
ALSA: hda - Fix jack gating when auto_{mute,mic} is suppressed.
The snd_hda_jack_set_gating_jack() call didn't work when
auto_{mute,mic} is suppressed because (1) am_entry is
not filled with nid of the mic pin. (2) The jacks are not
created (by snd_hda_jack_detect_enable_callback) before the
snd_hda_jack_set_gating_jack call.
Now we use the first input pin nid directly, and create the jack if it
doesn't exist yet.
Signed-off-by: Chih-Chung Chang <chihchung@chromium.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/pci/hda/hda_jack.c | 4 | ||||
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 31 |
2 files changed, 29 insertions, 6 deletions
diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c index dc93761a4bc5..05b3e3e9108f 100644 --- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c | |||
@@ -253,8 +253,8 @@ EXPORT_SYMBOL_HDA(snd_hda_jack_detect_enable); | |||
253 | int snd_hda_jack_set_gating_jack(struct hda_codec *codec, hda_nid_t gated_nid, | 253 | int snd_hda_jack_set_gating_jack(struct hda_codec *codec, hda_nid_t gated_nid, |
254 | hda_nid_t gating_nid) | 254 | hda_nid_t gating_nid) |
255 | { | 255 | { |
256 | struct hda_jack_tbl *gated = snd_hda_jack_tbl_get(codec, gated_nid); | 256 | struct hda_jack_tbl *gated = snd_hda_jack_tbl_new(codec, gated_nid); |
257 | struct hda_jack_tbl *gating = snd_hda_jack_tbl_get(codec, gating_nid); | 257 | struct hda_jack_tbl *gating = snd_hda_jack_tbl_new(codec, gating_nid); |
258 | 258 | ||
259 | if (!gated || !gating) | 259 | if (!gated || !gating) |
260 | return -EINVAL; | 260 | return -EINVAL; |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index ad7a0985edfe..6ac48101ecda 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -3260,6 +3260,28 @@ static void alc_fixup_headset_mode_alc668(struct hda_codec *codec, | |||
3260 | alc_fixup_headset_mode(codec, fix, action); | 3260 | alc_fixup_headset_mode(codec, fix, action); |
3261 | } | 3261 | } |
3262 | 3262 | ||
3263 | /* Returns the nid of the external mic input pin, or 0 if it cannot be found. */ | ||
3264 | static int find_ext_mic_pin(struct hda_codec *codec) | ||
3265 | { | ||
3266 | struct alc_spec *spec = codec->spec; | ||
3267 | struct auto_pin_cfg *cfg = &spec->gen.autocfg; | ||
3268 | hda_nid_t nid; | ||
3269 | unsigned int defcfg; | ||
3270 | int i; | ||
3271 | |||
3272 | for (i = 0; i < cfg->num_inputs; i++) { | ||
3273 | if (cfg->inputs[i].type != AUTO_PIN_MIC) | ||
3274 | continue; | ||
3275 | nid = cfg->inputs[i].pin; | ||
3276 | defcfg = snd_hda_codec_get_pincfg(codec, nid); | ||
3277 | if (snd_hda_get_input_pin_attr(defcfg) == INPUT_PIN_ATTR_INT) | ||
3278 | continue; | ||
3279 | return nid; | ||
3280 | } | ||
3281 | |||
3282 | return 0; | ||
3283 | } | ||
3284 | |||
3263 | static void alc271_hp_gate_mic_jack(struct hda_codec *codec, | 3285 | static void alc271_hp_gate_mic_jack(struct hda_codec *codec, |
3264 | const struct hda_fixup *fix, | 3286 | const struct hda_fixup *fix, |
3265 | int action) | 3287 | int action) |
@@ -3267,11 +3289,12 @@ static void alc271_hp_gate_mic_jack(struct hda_codec *codec, | |||
3267 | struct alc_spec *spec = codec->spec; | 3289 | struct alc_spec *spec = codec->spec; |
3268 | 3290 | ||
3269 | if (action == HDA_FIXUP_ACT_PROBE) { | 3291 | if (action == HDA_FIXUP_ACT_PROBE) { |
3270 | if (snd_BUG_ON(!spec->gen.am_entry[1].pin || | 3292 | int mic_pin = find_ext_mic_pin(codec); |
3271 | !spec->gen.autocfg.hp_pins[0])) | 3293 | int hp_pin = spec->gen.autocfg.hp_pins[0]; |
3294 | |||
3295 | if (snd_BUG_ON(!mic_pin || !hp_pin)) | ||
3272 | return; | 3296 | return; |
3273 | snd_hda_jack_set_gating_jack(codec, spec->gen.am_entry[1].pin, | 3297 | snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin); |
3274 | spec->gen.autocfg.hp_pins[0]); | ||
3275 | } | 3298 | } |
3276 | } | 3299 | } |
3277 | 3300 | ||