[alsa-devel] [PATCH RFC 0/2] Yet more patches for HD-audio generic parser
Hi,
these two patches have slipped from the previous patch series.
Takashi
Add a hook for the capture mixer switch. This will be used by IDT codecs for controlling the mic-mute LED.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/hda/hda_generic.c | 16 +++++++++++++++- sound/pci/hda/hda_generic.h | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 4bc4cd9..932e6a1 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -2517,9 +2517,23 @@ static const struct snd_kcontrol_new cap_vol_temp = { static int cap_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - return cap_put_caller(kcontrol, ucontrol, + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct hda_gen_spec *spec = codec->spec; + int ret; + + ret = cap_put_caller(kcontrol, ucontrol, snd_hda_mixer_amp_switch_put, NID_PATH_MUTE_CTL); + if (ret < 0) + return ret; + + if (spec->capture_switch_hook) { + bool enable = (ucontrol->value.integer.value[0] || + ucontrol->value.integer.value[1]); + spec->capture_switch_hook(codec, enable); + } + + return ret; }
static const struct snd_kcontrol_new cap_sw_temp = { diff --git a/sound/pci/hda/hda_generic.h b/sound/pci/hda/hda_generic.h index bfa2d97..1ceaacd 100644 --- a/sound/pci/hda/hda_generic.h +++ b/sound/pci/hda/hda_generic.h @@ -227,6 +227,9 @@ struct hda_gen_spec { struct hda_jack_tbl *tbl); void (*mic_autoswitch_hook)(struct hda_codec *codec, struct hda_jack_tbl *tbl); + + /* capture switch hook (for mic-mute LED) */ + void (*capture_switch_hook)(struct hda_codec *codec, bool enable); };
int snd_hda_gen_spec_init(struct hda_gen_spec *spec);
Sometimes (or rather often) BIOS sets the pin default configurations obviously wrongly. Looking through these failures, one common pattern is to enable some dead pins that are usually marked as speaker pins. In such a case, we can skip them if the pins don't have the output capability.
In this patch, add a check for the valid pin cap bit for each parsed pin, and filter out when it's invalid.
The fix was originally suggested by Raymond Yau.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/hda/hda_auto_parser.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c index 33b3ece..a4810c7 100644 --- a/sound/pci/hda/hda_auto_parser.c +++ b/sound/pci/hda/hda_auto_parser.c @@ -97,6 +97,28 @@ static void reorder_outputs(unsigned int nums, hda_nid_t *pins) } }
+/* check whether the given pin has a proper pin I/O capability bit */ +static bool check_pincap_validity(struct hda_codec *codec, hda_nid_t pin, + unsigned int dev) +{ + unsigned int pincap = snd_hda_query_pin_caps(codec, pin); + + /* some old hardware don't return the proper pincaps */ + if (!pincap) + return true; + + switch (dev) { + case AC_JACK_LINE_OUT: + case AC_JACK_SPEAKER: + case AC_JACK_HP_OUT: + case AC_JACK_SPDIF_OUT: + case AC_JACK_DIG_OTHER_OUT: + return !!(pincap & AC_PINCAP_OUT); + default: + return !!(pincap & AC_PINCAP_IN); + } +} + /* * Parse all pin widgets and store the useful pin nids to cfg * @@ -164,6 +186,9 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec, dev = AC_JACK_SPEAKER; }
+ if (!check_pincap_validity(codec, nid, dev)) + continue; + switch (dev) { case AC_JACK_LINE_OUT: seq = get_defcfg_sequence(def_conf);
participants (1)
-
Takashi Iwai