From c1e0bb92174dd16ffba5be0e4e5fbd366f61ff7f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 30 Aug 2010 13:05:30 +0200 Subject: ALSA: hda - Use new inputs[] field to parse input-pins for CirrusLogic codecs Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_cirrus.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'sound/pci/hda/patch_cirrus.c') diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index 4ef5efaaaef1..ee1aea7296eb 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c @@ -329,7 +329,7 @@ static int is_ext_mic(struct hda_codec *codec, unsigned int idx) { struct cs_spec *spec = codec->spec; struct auto_pin_cfg *cfg = &spec->autocfg; - hda_nid_t pin = cfg->input_pins[idx]; + hda_nid_t pin = cfg->inputs[idx].pin; unsigned int val = snd_hda_query_pin_caps(codec, pin); if (!(val & AC_PINCAP_PRES_DETECT)) return 0; @@ -424,10 +424,8 @@ static int parse_input(struct hda_codec *codec) struct auto_pin_cfg *cfg = &spec->autocfg; int i; - for (i = 0; i < AUTO_PIN_LAST; i++) { - hda_nid_t pin = cfg->input_pins[i]; - if (!pin) - continue; + for (i = 0; i < cfg->num_inputs; i++) { + hda_nid_t pin = cfg->inputs[i].pin; spec->input_idx[spec->num_inputs] = i; spec->capsrc_idx[i] = spec->num_inputs++; spec->cur_input = i; @@ -438,16 +436,17 @@ static int parse_input(struct hda_codec *codec) /* check whether the automatic mic switch is available */ if (spec->num_inputs == 2 && - spec->adc_nid[AUTO_PIN_MIC] && spec->adc_nid[AUTO_PIN_FRONT_MIC]) { - if (is_ext_mic(codec, cfg->input_pins[AUTO_PIN_FRONT_MIC])) { - if (!is_ext_mic(codec, cfg->input_pins[AUTO_PIN_MIC])) { + cfg->inputs[0].type <= AUTO_PIN_FRONT_MIC && + cfg->inputs[1].type == AUTO_PIN_FRONT_MIC) { + if (is_ext_mic(codec, cfg->inputs[0].pin)) { + if (!is_ext_mic(codec, cfg->inputs[1].pin)) { spec->mic_detect = 1; - spec->automic_idx = AUTO_PIN_FRONT_MIC; + spec->automic_idx = 0; } } else { - if (is_ext_mic(codec, cfg->input_pins[AUTO_PIN_MIC])) { + if (is_ext_mic(codec, cfg->inputs[1].pin)) { spec->mic_detect = 1; - spec->automic_idx = AUTO_PIN_MIC; + spec->automic_idx = 1; } } } @@ -853,15 +852,12 @@ static void cs_automic(struct hda_codec *codec) hda_nid_t nid; unsigned int present; - nid = cfg->input_pins[spec->automic_idx]; + nid = cfg->inputs[spec->automic_idx].pin; present = snd_hda_jack_detect(codec, nid); if (present) change_cur_input(codec, spec->automic_idx, 0); - else { - unsigned int imic = (spec->automic_idx == AUTO_PIN_MIC) ? - AUTO_PIN_FRONT_MIC : AUTO_PIN_MIC; - change_cur_input(codec, imic, 0); - } + else + change_cur_input(codec, !spec->automic_idx, 0); } /* @@ -918,14 +914,14 @@ static void init_input(struct hda_codec *codec) unsigned int coef; int i; - for (i = 0; i < AUTO_PIN_LAST; i++) { + for (i = 0; i < cfg->num_inputs; i++) { unsigned int ctl; - hda_nid_t pin = cfg->input_pins[i]; - if (!pin || !spec->adc_nid[i]) + hda_nid_t pin = cfg->inputs[i].pin; + if (!spec->adc_nid[i]) continue; /* set appropriate pin control and mute first */ ctl = PIN_IN; - if (i <= AUTO_PIN_FRONT_MIC) { + if (cfg->inputs[i].type <= AUTO_PIN_FRONT_MIC) { unsigned int caps = snd_hda_query_pin_caps(codec, pin); caps >>= AC_PINCAP_VREF_SHIFT; if (caps & AC_PINCAP_VREF_80) -- cgit v1.2.3-55-g7522 From 86e2959a10828dd2614e037fb2502bc833adca52 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 9 Sep 2010 14:50:17 +0200 Subject: ALSA: hda - Remove AUTO_PIN_FRONT_{MIC|LINE} We can assign multiple pins to a single role now, let's reduce the redundant FRONT_MIC and FRONT_LINE. Also, autocfg->input_pins[] is no longer used, so this is removed as well. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 50 +++++------------------------------------- sound/pci/hda/hda_local.h | 5 +---- sound/pci/hda/patch_analog.c | 4 ++-- sound/pci/hda/patch_cirrus.c | 6 ++--- sound/pci/hda/patch_realtek.c | 8 +++---- sound/pci/hda/patch_sigmatel.c | 20 ++++++----------- sound/pci/hda/patch_via.c | 16 +++++++------- 7 files changed, 31 insertions(+), 78 deletions(-) (limited to 'sound/pci/hda/patch_cirrus.c') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 4348c33c6b85..0ee4439c68ca 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -4396,7 +4396,7 @@ static void add_auto_cfg_input_pin(struct auto_pin_cfg *cfg, hda_nid_t nid, * output, i.e. to line_out_pins[0]. So, line_outs is always positive * if any analog output exists. * - * The analog input pins are assigned to input_pins array. + * The analog input pins are assigned to inputs array. * The digital input/output pins are assigned to dig_in_pin and dig_out_pin, * respectively. */ @@ -4480,39 +4480,16 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, sequences_hp[cfg->hp_outs] = (assoc << 4) | seq; cfg->hp_outs++; break; - case AC_JACK_MIC_IN: { - int preferred, alt; - if (loc == AC_JACK_LOC_FRONT || - (loc & 0x30) == AC_JACK_LOC_INTERNAL) { - preferred = AUTO_PIN_FRONT_MIC; - alt = AUTO_PIN_MIC; - } else { - preferred = AUTO_PIN_MIC; - alt = AUTO_PIN_FRONT_MIC; - } - if (!cfg->input_pins[preferred]) - cfg->input_pins[preferred] = nid; - else if (!cfg->input_pins[alt]) - cfg->input_pins[alt] = nid; - add_auto_cfg_input_pin(cfg, nid, preferred); + case AC_JACK_MIC_IN: + add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_MIC); break; - } - case AC_JACK_LINE_IN: { - int type; - if (loc == AC_JACK_LOC_FRONT) - type = AUTO_PIN_FRONT_LINE; - else - type = AUTO_PIN_LINE; - cfg->input_pins[type] = nid; - add_auto_cfg_input_pin(cfg, nid, type); + case AC_JACK_LINE_IN: + add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_LINE_IN); break; - } case AC_JACK_CD: - cfg->input_pins[AUTO_PIN_CD] = nid; add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_CD); break; case AC_JACK_AUX: - cfg->input_pins[AUTO_PIN_AUX] = nid; add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_AUX); break; case AC_JACK_SPDIF_OUT: @@ -4570,21 +4547,6 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, sort_pins_by_sequence(cfg->hp_pins, sequences_hp, cfg->hp_outs); - /* if we have only one mic, make it AUTO_PIN_MIC */ - if (!cfg->input_pins[AUTO_PIN_MIC] && - cfg->input_pins[AUTO_PIN_FRONT_MIC]) { - cfg->input_pins[AUTO_PIN_MIC] = - cfg->input_pins[AUTO_PIN_FRONT_MIC]; - cfg->input_pins[AUTO_PIN_FRONT_MIC] = 0; - } - /* ditto for line-in */ - if (!cfg->input_pins[AUTO_PIN_LINE] && - cfg->input_pins[AUTO_PIN_FRONT_LINE]) { - cfg->input_pins[AUTO_PIN_LINE] = - cfg->input_pins[AUTO_PIN_FRONT_LINE]; - cfg->input_pins[AUTO_PIN_FRONT_LINE] = 0; - } - /* * FIX-UP: if no line-outs are detected, try to use speaker or HP pin * as a primary output @@ -4658,7 +4620,7 @@ EXPORT_SYMBOL_HDA(snd_hda_parse_pin_def_config); /* labels for input pins - for obsoleted config stuff */ const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = { - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" + "Mic", "Line", "CD", "Aux" }; EXPORT_SYMBOL_HDA(auto_pin_cfg_labels); diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index b448b0a997b1..72e7b2f210ee 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -366,9 +366,7 @@ struct hda_bus_unsolicited { enum { AUTO_PIN_MIC, - AUTO_PIN_FRONT_MIC, - AUTO_PIN_LINE, - AUTO_PIN_FRONT_LINE, + AUTO_PIN_LINE_IN, AUTO_PIN_CD, AUTO_PIN_AUX, AUTO_PIN_LAST @@ -403,7 +401,6 @@ struct auto_pin_cfg { int hp_outs; int line_out_type; /* AUTO_PIN_XXX_OUT */ hda_nid_t hp_pins[AUTO_CFG_MAX_OUTS]; - hda_nid_t input_pins[AUTO_PIN_LAST]; /* old config; to be deprecated */ int num_inputs; struct auto_pin_cfg_item inputs[AUTO_CFG_MAX_INS]; int dig_outs; diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 8de3a0dc45e4..85fc0b954603 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -2923,7 +2923,7 @@ static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec, type_idx = 0; err = new_analog_input(spec, cfg->inputs[i].pin, auto_pin_cfg_labels[type], type_idx, - type <= AUTO_PIN_FRONT_MIC); + type == AUTO_PIN_MIC); if (err < 0) return err; snd_hda_get_input_pin_label(cfg, i, @@ -3015,7 +3015,7 @@ static void ad1988_auto_init_analog_input(struct hda_codec *codec) break; } snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, - i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); + i == AUTO_PIN_MIC ? PIN_VREF80 : PIN_IN); if (nid != AD1988_PIN_CD_NID) snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index 6adfc5625281..adb5ec50252a 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c @@ -436,8 +436,8 @@ static int parse_input(struct hda_codec *codec) /* check whether the automatic mic switch is available */ if (spec->num_inputs == 2 && - cfg->inputs[0].type <= AUTO_PIN_FRONT_MIC && - cfg->inputs[1].type == AUTO_PIN_FRONT_MIC) { + cfg->inputs[0].type == AUTO_PIN_MIC && + cfg->inputs[1].type == AUTO_PIN_MIC) { if (is_ext_mic(codec, cfg->inputs[0].pin)) { if (!is_ext_mic(codec, cfg->inputs[1].pin)) { spec->mic_detect = 1; @@ -921,7 +921,7 @@ static void init_input(struct hda_codec *codec) continue; /* set appropriate pin control and mute first */ ctl = PIN_IN; - if (cfg->inputs[i].type <= AUTO_PIN_FRONT_MIC) { + if (cfg->inputs[i].type == AUTO_PIN_MIC) { unsigned int caps = snd_hda_query_pin_caps(codec, pin); caps >>= AC_PINCAP_VREF_SHIFT; if (caps & AC_PINCAP_VREF_80) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 0a7d9d5ea40e..8ae30ccf537a 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -846,7 +846,7 @@ static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, { unsigned int val = PIN_IN; - if (auto_pin_type <= AUTO_PIN_FRONT_MIC) { + if (auto_pin_type == AUTO_PIN_MIC) { unsigned int pincap; unsigned int oldval; oldval = snd_hda_codec_read(codec, nid, 0, @@ -1298,7 +1298,7 @@ static void alc_init_auto_mic(struct hda_codec *codec) /* there must be only two mic inputs exclusively */ for (i = 0; i < cfg->num_inputs; i++) - if (cfg->inputs[i].type >= AUTO_PIN_LINE) + if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN) return; fixed = ext = 0; @@ -10622,7 +10622,7 @@ static int alc_auto_add_mic_boost(struct hda_codec *codec) hda_nid_t nid; for (i = 0; i < cfg->num_inputs; i++) { - if (cfg->inputs[i].type > AUTO_PIN_FRONT_MIC) + if (cfg->inputs[i].type > AUTO_PIN_MIC) break; nid = cfg->inputs[i].pin; if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { @@ -19270,7 +19270,7 @@ static void alc680_base_setup(struct hda_codec *codec) spec->autocfg.inputs[0].pin = 0x18; spec->autocfg.inputs[0].type = AUTO_PIN_MIC; spec->autocfg.inputs[1].pin = 0x19; - spec->autocfg.inputs[1].type = AUTO_PIN_LINE; + spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN; } static void alc680_unsol_event(struct hda_codec *codec, diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 852dae91edb1..d9c8b4d335d2 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -2834,7 +2834,7 @@ static hda_nid_t check_line_out_switch(struct hda_codec *codec) if (cfg->line_out_type != AUTO_PIN_LINE_OUT) return 0; for (i = 0; i < cfg->num_inputs; i++) { - if (cfg->inputs[i].type == AUTO_PIN_LINE) { + if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) { nid = cfg->inputs[i].pin; pincap = snd_hda_query_pin_caps(codec, nid); if (pincap & AC_PINCAP_OUT) @@ -2852,16 +2852,14 @@ static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac) struct sigmatel_spec *spec = codec->spec; struct auto_pin_cfg *cfg = &spec->autocfg; unsigned int def_conf, pincap; - int i, mic_type; + int i; *dac = 0; if (cfg->line_out_type != AUTO_PIN_LINE_OUT) return 0; - mic_type = AUTO_PIN_MIC; - again: for (i = 0; i < cfg->num_inputs; i++) { hda_nid_t nid = cfg->inputs[i].pin; - if (cfg->inputs[i].type != mic_type) + if (cfg->inputs[i].type != AUTO_PIN_MIC) continue; def_conf = snd_hda_codec_get_pincfg(codec, nid); /* some laptops have an internal analog microphone @@ -2875,10 +2873,6 @@ static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac) } } } - if (mic_type == AUTO_PIN_MIC) { - mic_type = AUTO_PIN_FRONT_MIC; - goto again; - } return 0; } @@ -3222,7 +3216,7 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, } for (idx = 0; idx < cfg->num_inputs; idx++) { - if (cfg->inputs[idx].type > AUTO_PIN_FRONT_LINE) + if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN) break; nid = cfg->inputs[idx].pin; err = stac92xx_add_jack_mode_control(codec, nid, idx); @@ -3621,7 +3615,7 @@ static int set_mic_route(struct hda_codec *codec, if (pin == cfg->inputs[i].pin) break; } - if (i < cfg->num_inputs && cfg->inputs[i].type <= AUTO_PIN_FRONT_MIC) { + if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) { /* analog pin */ i = get_connection_index(codec, spec->mux_nids[0], pin); if (i < 0) @@ -3656,7 +3650,7 @@ static int stac_check_auto_mic(struct hda_codec *codec) int i; for (i = 0; i < cfg->num_inputs; i++) { - if (cfg->inputs[i].type >= AUTO_PIN_LINE) + if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN) return 0; /* must be exclusively mics */ } fixed = ext = 0; @@ -4394,7 +4388,7 @@ static int stac92xx_init(struct hda_codec *codec) hda_nid_t nid = cfg->inputs[i].pin; int type = cfg->inputs[i].type; unsigned int pinctl, conf; - if (type == AUTO_PIN_MIC || type == AUTO_PIN_FRONT_MIC) { + if (type == AUTO_PIN_MIC) { /* for mic pins, force to initialize */ pinctl = stac92xx_get_default_vref(codec, nid); pinctl |= AC_PINCTL_IN_EN; diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 9c1909d398e3..de5f61d1b725 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -568,7 +568,7 @@ static void via_auto_init_analog_input(struct hda_codec *codec) hda_nid_t nid = cfg->inputs[i].pin; if (spec->smart51_enabled && is_smart51_pins(spec, nid)) ctl = PIN_OUT; - else if (i <= AUTO_PIN_FRONT_MIC) + else if (i == AUTO_PIN_MIC) ctl = PIN_VREF50; else ctl = PIN_IN; @@ -1328,7 +1328,7 @@ static int is_smart51_pins(struct via_spec *spec, hda_nid_t pin) for (i = 0; i < cfg->num_inputs; i++) { if (pin == cfg->inputs[i].pin) - return cfg->inputs[i].type < AUTO_PIN_FRONT_LINE; + return cfg->inputs[i].type <= AUTO_PIN_LINE_IN; } return 0; } @@ -1356,9 +1356,9 @@ static int via_smart51_get(struct snd_kcontrol *kcontrol, hda_nid_t nid = cfg->inputs[i].pin; int ctl = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0); - if (cfg->inputs[i].type >= AUTO_PIN_FRONT_LINE) + if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) continue; - if (cfg->inputs[i].type == AUTO_PIN_FRONT_MIC && + if (cfg->inputs[i].type == AUTO_PIN_MIC && spec->hp_independent_mode && spec->codec_type != VT1718S) continue; /* ignore FMic for independent HP */ if ((ctl & AC_PINCTL_IN_EN) && !(ctl & AC_PINCTL_OUT_EN)) @@ -1382,9 +1382,9 @@ static int via_smart51_put(struct snd_kcontrol *kcontrol, hda_nid_t nid = cfg->inputs[i].pin; unsigned int parm; - if (cfg->inputs[i].type >= AUTO_PIN_FRONT_LINE) + if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) continue; - if (cfg->inputs[i].type == AUTO_PIN_FRONT_MIC && + if (cfg->inputs[i].type == AUTO_PIN_MIC && spec->hp_independent_mode && spec->codec_type != VT1718S) continue; /* don't retask FMic for independent HP */ @@ -1404,7 +1404,7 @@ static int via_smart51_put(struct snd_kcontrol *kcontrol, codec, nid, HDA_OUTPUT, 0, HDA_AMP_MUTE, HDA_AMP_UNMUTE); } - if (cfg->inputs[i].type == AUTO_PIN_FRONT_MIC) { + if (cfg->inputs[i].type == AUTO_PIN_MIC) { if (spec->codec_type == VT1708S || spec->codec_type == VT1716S) { /* input = index 1 (AOW3) */ @@ -1450,7 +1450,7 @@ static int via_smart51_build(struct via_spec *spec) for (i = 0; i < cfg->num_inputs; i++) { nid = cfg->inputs[i].pin; - if (cfg->inputs[i].type < AUTO_PIN_FRONT_LINE) { + if (cfg->inputs[i].type <= AUTO_PIN_LINE_IN) { knew = via_clone_control(spec, &via_smart51_mixer[1]); if (knew == NULL) return -ENOMEM; -- cgit v1.2.3-55-g7522 From 10a20af7c944649dc6d1ffa06bc759f5f3a16cd9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 9 Sep 2010 16:28:02 +0200 Subject: ALSA: hda - Improve the input source name labels This patch improves the input-source label strings to be generated from the pin information instead of fixed strings per AUTO_PIN_* type. This gives more suitable labels, especially for mic and line-in pins. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 91 +++++++++++++++++++++----- sound/pci/hda/hda_generic.c | 41 ++---------- sound/pci/hda/hda_local.h | 11 ++-- sound/pci/hda/patch_analog.c | 27 ++++---- sound/pci/hda/patch_ca0110.c | 3 +- sound/pci/hda/patch_cirrus.c | 4 +- sound/pci/hda/patch_realtek.c | 20 +++--- sound/pci/hda/patch_sigmatel.c | 144 ++++++----------------------------------- sound/pci/hda/patch_via.c | 100 ++++++++++++---------------- 9 files changed, 174 insertions(+), 267 deletions(-) (limited to 'sound/pci/hda/patch_cirrus.c') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 0ee4439c68ca..e3284341c484 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -4607,7 +4607,7 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, snd_printd(" inputs:"); for (i = 0; i < cfg->num_inputs; i++) { snd_printdd(" %s=0x%x", - auto_pin_cfg_labels[cfg->inputs[i].type], + hda_get_autocfg_input_label(codec, cfg, i), cfg->inputs[i].pin); } snd_printd("\n"); @@ -4618,28 +4618,87 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, } EXPORT_SYMBOL_HDA(snd_hda_parse_pin_def_config); -/* labels for input pins - for obsoleted config stuff */ -const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = { - "Mic", "Line", "CD", "Aux" -}; -EXPORT_SYMBOL_HDA(auto_pin_cfg_labels); +const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin, + int check_location) +{ + unsigned int def_conf, loc; + + def_conf = snd_hda_codec_get_pincfg(codec, pin); + loc = get_defcfg_location(def_conf); + + switch (get_defcfg_device(def_conf)) { + case AC_JACK_MIC_IN: + if (!check_location) + return "Mic"; + if (get_defcfg_connect(def_conf) == AC_JACK_PORT_FIXED || + (loc & 0x30) == AC_JACK_LOC_INTERNAL) + return "Internal Mic"; + if ((loc & 0x30) == AC_JACK_LOC_SEPARATE) + return "Dock Mic"; + if (loc == AC_JACK_LOC_REAR) + return "Rear Mic"; + return "Mic"; + case AC_JACK_LINE_IN: + if (!check_location) + return "Line"; + if ((loc & 0xf0) == AC_JACK_LOC_SEPARATE) + return "Dock Line"; + return "Line"; + case AC_JACK_AUX: + return "Aux"; + case AC_JACK_CD: + return "CD"; + case AC_JACK_SPDIF_IN: + return "SPDIF In"; + case AC_JACK_DIG_OTHER_IN: + return "Digital In"; + default: + return "Misc"; + } +} +EXPORT_SYMBOL_HDA(hda_get_input_pin_label); -void snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg, - int input, char *str) +const char *hda_get_autocfg_input_label(struct hda_codec *codec, + const struct auto_pin_cfg *cfg, + int input) { int type = cfg->inputs[input].type; - int idx; + int has_multiple_pins = 0; - for (idx = 0; idx < 3 && --input >= 0; idx++) { - if (type != cfg->inputs[input].type) - break; + if ((input > 0 && cfg->inputs[input - 1].type == type) || + (input < cfg->num_inputs - 1 && cfg->inputs[input + 1].type == type)) + has_multiple_pins = 1; + return hda_get_input_pin_label(codec, cfg->inputs[input].pin, + has_multiple_pins); +} +EXPORT_SYMBOL_HDA(hda_get_autocfg_input_label); + +int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label, + int index, int *type_idx) +{ + int i, label_idx = 0; + if (imux->num_items >= HDA_MAX_NUM_INPUTS) { + snd_printd(KERN_ERR "hda_codec: Too many imux items!\n"); + return -EINVAL; + } + for (i = 0; i < imux->num_items; i++) { + if (!strncmp(label, imux->items[i].label, strlen(label))) + label_idx++; } - if (idx > 0) - sprintf(str, "%s %d", auto_pin_cfg_labels[type], idx); + if (type_idx) + *type_idx = label_idx; + if (label_idx > 0) + snprintf(imux->items[imux->num_items].label, + sizeof(imux->items[imux->num_items].label), + "%s %d", label, label_idx); else - strcpy(str, auto_pin_cfg_labels[type]); + strlcpy(imux->items[imux->num_items].label, label, + sizeof(imux->items[imux->num_items].label)); + imux->items[imux->num_items].index = index; + imux->num_items++; + return 0; } -EXPORT_SYMBOL_HDA(snd_hda_get_input_pin_label); +EXPORT_SYMBOL_HDA(snd_hda_add_imux_item); #ifdef CONFIG_PM diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index cce18ba8b5a1..fb0582f8d725 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -61,7 +61,6 @@ struct hda_gspec { struct hda_gnode *cap_vol_node; /* Node for capture volume */ unsigned int cur_cap_src; /* current capture source */ struct hda_input_mux input_mux; - char cap_labels[HDA_MAX_NUM_INPUTS][16]; unsigned int def_amp_in_caps; unsigned int def_amp_out_caps; @@ -506,11 +505,10 @@ static const char *get_input_type(struct hda_gnode *node, unsigned int *pinctl) * returns 0 if not found, 1 if found, or a negative error code. */ static int parse_adc_sub_nodes(struct hda_codec *codec, struct hda_gspec *spec, - struct hda_gnode *node) + struct hda_gnode *node, int idx) { int i, err; unsigned int pinctl; - char *label; const char *type; if (node->checked) @@ -523,7 +521,7 @@ static int parse_adc_sub_nodes(struct hda_codec *codec, struct hda_gspec *spec, child = hda_get_node(spec, node->conn_list[i]); if (! child) continue; - err = parse_adc_sub_nodes(codec, spec, child); + err = parse_adc_sub_nodes(codec, spec, child, idx); if (err < 0) return err; if (err > 0) { @@ -564,9 +562,7 @@ static int parse_adc_sub_nodes(struct hda_codec *codec, struct hda_gspec *spec, return 0; type = "Input"; } - label = spec->cap_labels[spec->input_mux.num_items]; - strcpy(label, type); - strcpy(spec->input_mux.items[spec->input_mux.num_items].label, label); + snd_hda_add_imux_item(&spec->input_mux, type, idx, NULL); /* unmute the PIN external input */ unmute_input(codec, node, 0); /* index = 0? */ @@ -577,29 +573,6 @@ static int parse_adc_sub_nodes(struct hda_codec *codec, struct hda_gspec *spec, return 1; /* found */ } -/* add a capture source element */ -static void add_cap_src(struct hda_gspec *spec, int idx) -{ - struct hda_input_mux_item *csrc; - char *buf; - int num, ocap; - - num = spec->input_mux.num_items; - csrc = &spec->input_mux.items[num]; - buf = spec->cap_labels[num]; - for (ocap = 0; ocap < num; ocap++) { - if (! strcmp(buf, spec->cap_labels[ocap])) { - /* same label already exists, - * put the index number to be unique - */ - sprintf(buf, "%s %d", spec->cap_labels[ocap], num); - break; - } - } - csrc->index = idx; - spec->input_mux.num_items++; -} - /* * parse input */ @@ -624,22 +597,18 @@ static int parse_input_path(struct hda_codec *codec, struct hda_gnode *adc_node) for (i = 0; i < adc_node->nconns; i++) { node = hda_get_node(spec, adc_node->conn_list[i]); if (node && node->type == AC_WID_PIN) { - err = parse_adc_sub_nodes(codec, spec, node); + err = parse_adc_sub_nodes(codec, spec, node, i); if (err < 0) return err; - else if (err > 0) - add_cap_src(spec, i); } } /* ... then check the rests, more complicated connections */ for (i = 0; i < adc_node->nconns; i++) { node = hda_get_node(spec, adc_node->conn_list[i]); if (node && node->type != AC_WID_PIN) { - err = parse_adc_sub_nodes(codec, spec, node); + err = parse_adc_sub_nodes(codec, spec, node, i); if (err < 0) return err; - else if (err > 0) - add_cap_src(spec, i); } } diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 72e7b2f210ee..6943efc78f66 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -378,8 +378,6 @@ enum { AUTO_PIN_HP_OUT }; -extern const char *auto_pin_cfg_labels[AUTO_PIN_LAST]; - #define AUTO_CFG_MAX_OUTS 5 #define AUTO_CFG_MAX_INS 8 @@ -389,8 +387,13 @@ struct auto_pin_cfg_item { }; struct auto_pin_cfg; -void snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg, - int input, char *label); +const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin, + int check_location); +const char *hda_get_autocfg_input_label(struct hda_codec *codec, + const struct auto_pin_cfg *cfg, + int input); +int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label, + int index, int *type_index_ret); struct auto_pin_cfg { int line_outs; diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 85fc0b954603..05db1cfcd8b8 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -2909,32 +2909,27 @@ static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin, } /* create playback/capture controls for input pins */ -static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec, +static int ad1988_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { + struct ad198x_spec *spec = codec->spec; struct hda_input_mux *imux = &spec->private_imux; - int i, err, type, type_idx = 0; + int i, err, type, type_idx; for (i = 0; i < cfg->num_inputs; i++) { + const char *label; type = cfg->inputs[i].type; - if (i > 0 && type != cfg->inputs[i - 1].type) - type_idx++; - else - type_idx = 0; + label = hda_get_autocfg_input_label(codec, cfg, i); + snd_hda_add_imux_item(imux, label, + ad1988_pin_to_adc_idx(cfg->inputs[i].pin), + &type_idx); err = new_analog_input(spec, cfg->inputs[i].pin, - auto_pin_cfg_labels[type], type_idx, + label, type_idx, type == AUTO_PIN_MIC); if (err < 0) return err; - snd_hda_get_input_pin_label(cfg, i, - imux->items[imux->num_items].label); - imux->items[imux->num_items].index = - ad1988_pin_to_adc_idx(cfg->inputs[i].pin); - imux->num_items++; } - strcpy(imux->items[imux->num_items].label, "Mix"); - imux->items[imux->num_items].index = 9; - imux->num_items++; + snd_hda_add_imux_item(imux, "Mix", 9, NULL); if ((err = add_control(spec, AD_CTL_WIDGET_VOL, "Analog Mix Playback Volume", @@ -3046,7 +3041,7 @@ static int ad1988_parse_auto_config(struct hda_codec *codec) "Speaker")) < 0 || (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pins[0], "Headphone")) < 0 || - (err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) + (err = ad1988_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) return err; spec->multiout.max_channels = spec->multiout.num_dacs * 2; diff --git a/sound/pci/hda/patch_ca0110.c b/sound/pci/hda/patch_ca0110.c index 42b3fb4cafc4..cca11fdd3d79 100644 --- a/sound/pci/hda/patch_ca0110.c +++ b/sound/pci/hda/patch_ca0110.c @@ -474,8 +474,7 @@ static void parse_input(struct hda_codec *codec) if (j >= cfg->num_inputs) continue; spec->input_pins[n] = pin; - spec->input_labels[n] = - auto_pin_cfg_labels[cfg->inputs[j].type]; + spec->input_labels[n] = hda_get_input_pin_label(codec, pin, 1); spec->adcs[n] = nid; n++; } diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index adb5ec50252a..ae75283a5583 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c @@ -673,6 +673,7 @@ static int cs_capture_source_info(struct snd_kcontrol *kcontrol, { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct cs_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; unsigned int idx; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; @@ -681,7 +682,8 @@ static int cs_capture_source_info(struct snd_kcontrol *kcontrol, if (uinfo->value.enumerated.item >= spec->num_inputs) uinfo->value.enumerated.item = spec->num_inputs - 1; idx = spec->input_idx[uinfo->value.enumerated.item]; - strcpy(uinfo->value.enumerated.name, auto_pin_cfg_labels[idx]); + strcpy(uinfo->value.enumerated.name, + hda_get_input_pin_label(codec, cfg->inputs[idx].pin, 1)); return 0; } diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 8ae30ccf537a..9c2c19c8b059 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -4947,6 +4947,7 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec, for (i = 0; i < cfg->num_inputs; i++) { hda_nid_t pin; + const char *label; pin = cfg->inputs[i].pin; if (!alc_is_input_pin(codec, pin)) @@ -4957,12 +4958,13 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec, type_idx++; else type_idx = 0; + label = hda_get_autocfg_input_label(codec, cfg, i); if (mixer) { idx = get_connection_index(codec, mixer, pin); if (idx >= 0) { err = new_analog_input(spec, pin, - auto_pin_cfg_labels[type], - type_idx, idx, mixer); + label, type_idx, + idx, mixer); if (err < 0) return err; } @@ -4973,12 +4975,8 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec, idx = get_connection_index(codec, cap1, pin); if (idx < 0 && cap2) idx = get_connection_index(codec, cap2, pin); - if (idx >= 0) { - snd_hda_get_input_pin_label(cfg, i, - imux->items[imux->num_items].label); - imux->items[imux->num_items].index = idx; - imux->num_items++; - } + if (idx >= 0) + snd_hda_add_imux_item(imux, label, idx, NULL); } return 0; } @@ -10626,9 +10624,9 @@ static int alc_auto_add_mic_boost(struct hda_codec *codec) break; nid = cfg->inputs[i].pin; if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { - char pinname[32], label[32]; - snd_hda_get_input_pin_label(cfg, i, pinname); - snprintf(label, sizeof(label), "%s Boost", pinname); + char label[32]; + snprintf(label, sizeof(label), "%s Boost", + hda_get_autocfg_input_label(codec, cfg, i)); err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0, HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); if (err < 0) diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index d9c8b4d335d2..e4e7d43f911e 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -191,11 +191,6 @@ struct sigmatel_mic_route { signed char dmux_idx; }; -struct unique_input_names { - int num; - char uname[HDA_MAX_NUM_INPUTS][32]; -}; - struct sigmatel_spec { struct snd_kcontrol_new *mixers[4]; unsigned int num_mixers; @@ -312,7 +307,6 @@ struct sigmatel_spec { struct hda_input_mux private_imux; struct hda_input_mux private_smux; struct hda_input_mux private_mono_mux; - struct unique_input_names private_u_inp_names; }; static hda_nid_t stac9200_adc_nids[1] = { @@ -1116,9 +1110,7 @@ static int stac92xx_build_controls(struct hda_codec *codec) struct hda_input_mux *smux = &spec->private_smux; /* check for mute support on SPDIF out */ if (wcaps & AC_WCAP_OUT_AMP) { - strcpy(smux->items[smux->num_items].label, "Off"); - smux->items[smux->num_items].index = 0; - smux->num_items++; + snd_hda_add_imux_item(smux, "Off", 0, NULL); spec->spdif_mute = 1; } stac_smux_mixer.count = spec->num_smuxes; @@ -2797,7 +2789,7 @@ static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec, } if (control) { - strcpy(name, auto_pin_cfg_labels[idx]); + strcpy(name, hda_get_input_pin_label(codec, nid, 1)); return stac92xx_add_control(codec->spec, control, strcat(name, " Jack Mode"), nid); } @@ -3267,12 +3259,9 @@ static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) return -EINVAL; - for (i = 0; i < num_cons; i++) { - strcpy(mono_mux->items[mono_mux->num_items].label, - stac92xx_mono_labels[i]); - mono_mux->items[mono_mux->num_items].index = i; - mono_mux->num_items++; - } + for (i = 0; i < num_cons; i++) + snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i, + NULL); return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX, "Mono Mux", spec->mono_nid); @@ -3397,11 +3386,8 @@ static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec) if (!labels) labels = stac92xx_spdif_labels; - for (i = 0; i < num_cons; i++) { - strcpy(spdif_mux->items[spdif_mux->num_items].label, labels[i]); - spdif_mux->items[spdif_mux->num_items].index = i; - spdif_mux->num_items++; - } + for (i = 0; i < num_cons; i++) + snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL); return 0; } @@ -3452,76 +3438,6 @@ static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid, return 1; } -static const char *get_input_src_label(struct hda_codec *codec, hda_nid_t nid) -{ - unsigned int def_conf; - - def_conf = snd_hda_codec_get_pincfg(codec, nid); - - switch (get_defcfg_device(def_conf)) { - case AC_JACK_MIC_IN: - if (get_defcfg_connect(def_conf) == AC_JACK_PORT_FIXED || - ((get_defcfg_location(def_conf) & 0xf0) - == AC_JACK_LOC_INTERNAL)) - return "Internal Mic"; - if ((get_defcfg_location(def_conf) & 0xf0) - == AC_JACK_LOC_SEPARATE) - return "Dock Mic"; - if (get_defcfg_location(def_conf) == AC_JACK_LOC_REAR) - return "Rear Mic"; - return "Mic"; - case AC_JACK_LINE_IN: - if ((get_defcfg_location(def_conf) & 0xf0) - == AC_JACK_LOC_SEPARATE) - return "Dock Line"; - return "Line"; - case AC_JACK_AUX: - return "Aux"; - case AC_JACK_CD: - return "CD"; - case AC_JACK_SPDIF_IN: - return "SPDIF In"; - case AC_JACK_DIG_OTHER_IN: - return "Digital In"; - } - - snd_printd("invalid inp pin %02x device config %08x", nid, def_conf); - return NULL; -} - -static const char *get_unique_inp_src_label(struct hda_codec *codec, - hda_nid_t nid) -{ - int i, n; - const char *label; - struct sigmatel_spec *spec = codec->spec; - struct hda_input_mux *imux = &spec->private_imux; - struct hda_input_mux *dimux = &spec->private_dimux; - struct unique_input_names *unames = &spec->private_u_inp_names; - - label = get_input_src_label(codec, nid); - n = 0; - - for (i = 0; i < imux->num_items; i++) { - if (!strncmp(label, imux->items[i].label, strlen(label))) - n++; - } - if (snd_hda_get_bool_hint(codec, "separate_dmux") == 1) { - for (i = 0; i < dimux->num_items; i++) { - if (!strncmp(label, dimux->items[i].label, - strlen(label))) - n++; - } - } - if (n > 0 && unames->num < HDA_MAX_NUM_INPUTS) { - sprintf(&unames->uname[unames->num][0], "%.28s %d", label, n); - label = &unames->uname[unames->num][0]; - unames->num++; - } - - return label; -} - /* create playback/capture controls for input pins on dmic capable codecs */ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) @@ -3532,13 +3448,11 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, int err, i; unsigned int def_conf; - strcpy(dimux->items[dimux->num_items].label, stac92xx_dmic_labels[0]); - dimux->items[dimux->num_items].index = 0; - dimux->num_items++; + snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL); for (i = 0; i < spec->num_dmics; i++) { hda_nid_t nid; - int index; + int index, type_idx; const char *label; nid = spec->dmic_nids[i]; @@ -3552,28 +3466,22 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, if (index < 0) continue; - label = get_unique_inp_src_label(codec, nid); - if (label == NULL) - return -EINVAL; + label = hda_get_input_pin_label(codec, nid, 1); + snd_hda_add_imux_item(dimux, label, index, &type_idx); - err = create_elem_capture_vol(codec, nid, label, 0, HDA_INPUT); + err = create_elem_capture_vol(codec, nid, label, type_idx, + HDA_INPUT); if (err < 0) return err; if (!err) { - err = create_elem_capture_vol(codec, nid, label, 0, - HDA_OUTPUT); + err = create_elem_capture_vol(codec, nid, label, + type_idx, HDA_OUTPUT); if (err < 0) return err; } - strcpy(dimux->items[dimux->num_items].label, label); - dimux->items[dimux->num_items].index = index; - dimux->num_items++; - if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) { - strcpy(imux->items[imux->num_items].label, label); - imux->items[imux->num_items].index = index; - imux->num_items++; - } + if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) + snd_hda_add_imux_item(imux, label, index, NULL); } return 0; @@ -3675,12 +3583,12 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const { struct sigmatel_spec *spec = codec->spec; struct hda_input_mux *imux = &spec->private_imux; - int i, j, type_idx = 0; + int i, j; const char *label; for (i = 0; i < cfg->num_inputs; i++) { hda_nid_t nid = cfg->inputs[i].pin; - int index, err; + int index, err, type_idx; index = -1; for (j = 0; j < spec->num_muxes; j++) { @@ -3692,24 +3600,14 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const if (index < 0) continue; - if (i > 0 && cfg->inputs[i].type == cfg->inputs[i - 1].type) - type_idx++; - else - type_idx = 0; - - label = get_unique_inp_src_label(codec, nid); - if (label == NULL) - return -EINVAL; + label = hda_get_autocfg_input_label(codec, cfg, i); + snd_hda_add_imux_item(imux, label, index, &type_idx); err = create_elem_capture_vol(codec, nid, label, type_idx, HDA_INPUT); if (err < 0) return err; - - strcpy(imux->items[imux->num_items].label, label); - imux->items[imux->num_items].index = index; - imux->num_items++; } spec->num_analog_muxes = imux->num_items; diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index de5f61d1b725..d1c3f8defc48 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -2374,13 +2374,8 @@ static void create_hp_imux(struct via_spec *spec) static const char *texts[] = { "OFF", "ON", NULL}; /* for hp mode select */ - i = 0; - while (texts[i] != NULL) { - strcpy(imux->items[imux->num_items].label, texts[i]); - imux->items[imux->num_items].index = i; - imux->num_items++; - i++; - } + for (i = 0; texts[i]; i++) + snd_hda_add_imux_item(imux, texts[i], i, NULL); spec->hp_mux = &spec->private_imux[1]; } @@ -2412,26 +2407,25 @@ static int vt1708_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) } /* create playback/capture controls for input pins */ -static int vt_auto_create_analog_input_ctls(struct via_spec *spec, +static int vt_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg, hda_nid_t cap_nid, hda_nid_t pin_idxs[], int num_idxs) { + struct via_spec *spec = codec->spec; struct hda_input_mux *imux = &spec->private_imux[0]; int i, err, idx, type, type_idx = 0; /* for internal loopback recording select */ for (idx = 0; idx < num_idxs; idx++) { if (pin_idxs[idx] == 0xff) { - strcpy(imux->items[imux->num_items].label, - "Stereo Mixer"); - imux->items[imux->num_items].index = idx; - imux->num_items++; + snd_hda_add_imux_item(imux, "Stereo Mixer", idx, NULL); break; } } for (i = 0; i < cfg->num_inputs; i++) { + const char *label; type = cfg->inputs[i].type; for (idx = 0; idx < num_idxs; idx++) if (pin_idxs[idx] == cfg->inputs[i].pin) @@ -2442,24 +2436,21 @@ static int vt_auto_create_analog_input_ctls(struct via_spec *spec, type_idx++; else type_idx = 0; - err = via_new_analog_input(spec, auto_pin_cfg_labels[type], - type_idx, idx, cap_nid); + label = hda_get_autocfg_input_label(codec, cfg, i); + err = via_new_analog_input(spec, label, type_idx, idx, cap_nid); if (err < 0) return err; - snd_hda_get_input_pin_label(cfg, i, - imux->items[imux->num_items].label); - imux->items[imux->num_items].index = idx; - imux->num_items++; + snd_hda_add_imux_item(imux, label, idx, NULL); } return 0; } /* create playback/capture controls for input pins */ -static int vt1708_auto_create_analog_input_ctls(struct via_spec *spec, +static int vt1708_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { static hda_nid_t pin_idxs[] = { 0xff, 0x24, 0x1d, 0x1e, 0x21 }; - return vt_auto_create_analog_input_ctls(spec, cfg, 0x17, pin_idxs, + return vt_auto_create_analog_input_ctls(codec, cfg, 0x17, pin_idxs, ARRAY_SIZE(pin_idxs)); } @@ -2559,7 +2550,7 @@ static int vt1708_parse_auto_config(struct hda_codec *codec) err = vt1708_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); if (err < 0) return err; - err = vt1708_auto_create_analog_input_ctls(spec, &spec->autocfg); + err = vt1708_auto_create_analog_input_ctls(codec, &spec->autocfg); if (err < 0) return err; /* add jack detect on/off control */ @@ -3026,11 +3017,11 @@ static int vt1709_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) } /* create playback/capture controls for input pins */ -static int vt1709_auto_create_analog_input_ctls(struct via_spec *spec, +static int vt1709_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { static hda_nid_t pin_idxs[] = { 0xff, 0x23, 0x1d, 0x1e, 0x21 }; - return vt_auto_create_analog_input_ctls(spec, cfg, 0x18, pin_idxs, + return vt_auto_create_analog_input_ctls(codec, cfg, 0x18, pin_idxs, ARRAY_SIZE(pin_idxs)); } @@ -3054,7 +3045,7 @@ static int vt1709_parse_auto_config(struct hda_codec *codec) err = vt1709_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); if (err < 0) return err; - err = vt1709_auto_create_analog_input_ctls(spec, &spec->autocfg); + err = vt1709_auto_create_analog_input_ctls(codec, &spec->autocfg); if (err < 0) return err; @@ -3556,11 +3547,11 @@ static int vt1708B_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) } /* create playback/capture controls for input pins */ -static int vt1708B_auto_create_analog_input_ctls(struct via_spec *spec, +static int vt1708B_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { static hda_nid_t pin_idxs[] = { 0xff, 0x1f, 0x1a, 0x1b, 0x1e }; - return vt_auto_create_analog_input_ctls(spec, cfg, 0x16, pin_idxs, + return vt_auto_create_analog_input_ctls(codec, cfg, 0x16, pin_idxs, ARRAY_SIZE(pin_idxs)); } @@ -3584,7 +3575,7 @@ static int vt1708B_parse_auto_config(struct hda_codec *codec) err = vt1708B_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); if (err < 0) return err; - err = vt1708B_auto_create_analog_input_ctls(spec, &spec->autocfg); + err = vt1708B_auto_create_analog_input_ctls(codec, &spec->autocfg); if (err < 0) return err; @@ -3992,11 +3983,11 @@ static int vt1708S_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) } /* create playback/capture controls for input pins */ -static int vt1708S_auto_create_analog_input_ctls(struct via_spec *spec, +static int vt1708S_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { static hda_nid_t pin_idxs[] = { 0x1f, 0x1a, 0x1b, 0x1e, 0, 0xff }; - return vt_auto_create_analog_input_ctls(spec, cfg, 0x16, pin_idxs, + return vt_auto_create_analog_input_ctls(codec, cfg, 0x16, pin_idxs, ARRAY_SIZE(pin_idxs)); } @@ -4045,7 +4036,7 @@ static int vt1708S_parse_auto_config(struct hda_codec *codec) err = vt1708S_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); if (err < 0) return err; - err = vt1708S_auto_create_analog_input_ctls(spec, &spec->autocfg); + err = vt1708S_auto_create_analog_input_ctls(codec, &spec->autocfg); if (err < 0) return err; @@ -4335,24 +4326,19 @@ static int vt1702_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) imux = &spec->private_imux[1]; /* for hp mode select */ - i = 0; - while (texts[i] != NULL) { - strcpy(imux->items[imux->num_items].label, texts[i]); - imux->items[imux->num_items].index = i; - imux->num_items++; - i++; - } + for (i = 0; texts[i]; i++) + snd_hda_add_imux_item(imux, texts[i], i, NULL); spec->hp_mux = &spec->private_imux[1]; return 0; } /* create playback/capture controls for input pins */ -static int vt1702_auto_create_analog_input_ctls(struct via_spec *spec, +static int vt1702_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { static hda_nid_t pin_idxs[] = { 0x14, 0x15, 0x18, 0xff }; - return vt_auto_create_analog_input_ctls(spec, cfg, 0x1a, pin_idxs, + return vt_auto_create_analog_input_ctls(codec, cfg, 0x1a, pin_idxs, ARRAY_SIZE(pin_idxs)); } @@ -4382,7 +4368,7 @@ static int vt1702_parse_auto_config(struct hda_codec *codec) (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | (0x5 << AC_AMPCAP_STEP_SIZE_SHIFT) | (1 << AC_AMPCAP_MUTE_SHIFT)); - err = vt1702_auto_create_analog_input_ctls(spec, &spec->autocfg); + err = vt1702_auto_create_analog_input_ctls(codec, &spec->autocfg); if (err < 0) return err; @@ -4733,11 +4719,11 @@ static int vt1718S_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) } /* create playback/capture controls for input pins */ -static int vt1718S_auto_create_analog_input_ctls(struct via_spec *spec, +static int vt1718S_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { static hda_nid_t pin_idxs[] = { 0x2c, 0x2b, 0x2a, 0x29, 0, 0xff }; - return vt_auto_create_analog_input_ctls(spec, cfg, 0x21, pin_idxs, + return vt_auto_create_analog_input_ctls(codec, cfg, 0x21, pin_idxs, ARRAY_SIZE(pin_idxs)); } @@ -4762,7 +4748,7 @@ static int vt1718S_parse_auto_config(struct hda_codec *codec) err = vt1718S_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); if (err < 0) return err; - err = vt1718S_auto_create_analog_input_ctls(spec, &spec->autocfg); + err = vt1718S_auto_create_analog_input_ctls(codec, &spec->autocfg); if (err < 0) return err; @@ -5195,11 +5181,11 @@ static int vt1716S_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) } /* create playback/capture controls for input pins */ -static int vt1716S_auto_create_analog_input_ctls(struct via_spec *spec, +static int vt1716S_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { static hda_nid_t pin_idxs[] = { 0x1f, 0x1a, 0x1b, 0x1e, 0, 0xff }; - return vt_auto_create_analog_input_ctls(spec, cfg, 0x16, pin_idxs, + return vt_auto_create_analog_input_ctls(codec, cfg, 0x16, pin_idxs, ARRAY_SIZE(pin_idxs)); } @@ -5223,7 +5209,7 @@ static int vt1716S_parse_auto_config(struct hda_codec *codec) err = vt1716S_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); if (err < 0) return err; - err = vt1716S_auto_create_analog_input_ctls(spec, &spec->autocfg); + err = vt1716S_auto_create_analog_input_ctls(codec, &spec->autocfg); if (err < 0) return err; @@ -5504,14 +5490,15 @@ static int vt2002P_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) } /* create playback/capture controls for input pins */ -static int vt2002P_auto_create_analog_input_ctls(struct via_spec *spec, +static int vt2002P_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { + struct via_spec *spec = codec->spec; struct hda_input_mux *imux = &spec->private_imux[0]; static hda_nid_t pin_idxs[] = { 0x2b, 0x2a, 0x29, 0xff }; int err; - err = vt_auto_create_analog_input_ctls(spec, cfg, 0x21, pin_idxs, + err = vt_auto_create_analog_input_ctls(codec, cfg, 0x21, pin_idxs, ARRAY_SIZE(pin_idxs)); if (err < 0) return err; @@ -5521,9 +5508,7 @@ static int vt2002P_auto_create_analog_input_ctls(struct via_spec *spec, return err; /* for digital mic select */ - strcpy(imux->items[imux->num_items].label, "Digital Mic"); - imux->items[imux->num_items].index = 4; - imux->num_items++; + snd_hda_add_imux_item(imux, "Digital Mic", 4, NULL); return 0; } @@ -5551,7 +5536,7 @@ static int vt2002P_parse_auto_config(struct hda_codec *codec) err = vt2002P_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); if (err < 0) return err; - err = vt2002P_auto_create_analog_input_ctls(spec, &spec->autocfg); + err = vt2002P_auto_create_analog_input_ctls(codec, &spec->autocfg); if (err < 0) return err; @@ -5826,14 +5811,15 @@ static int vt1812_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) } /* create playback/capture controls for input pins */ -static int vt1812_auto_create_analog_input_ctls(struct via_spec *spec, +static int vt1812_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { + struct via_spec *spec = codec->spec; struct hda_input_mux *imux = &spec->private_imux[0]; static hda_nid_t pin_idxs[] = { 0x2b, 0x2a, 0x29, 0, 0, 0xff }; int err; - err = vt_auto_create_analog_input_ctls(spec, cfg, 0x21, pin_idxs, + err = vt_auto_create_analog_input_ctls(codec, cfg, 0x21, pin_idxs, ARRAY_SIZE(pin_idxs)); if (err < 0) return err; @@ -5844,9 +5830,7 @@ static int vt1812_auto_create_analog_input_ctls(struct via_spec *spec, return err; /* for digital mic select */ - strcpy(imux->items[imux->num_items].label, "Digital Mic"); - imux->items[imux->num_items].index = 6; - imux->num_items++; + snd_hda_add_imux_item(imux, "Digital Mic", 6, NULL); return 0; } @@ -5874,7 +5858,7 @@ static int vt1812_parse_auto_config(struct hda_codec *codec) err = vt1812_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); if (err < 0) return err; - err = vt1812_auto_create_analog_input_ctls(spec, &spec->autocfg); + err = vt1812_auto_create_analog_input_ctls(codec, &spec->autocfg); if (err < 0) return err; -- cgit v1.2.3-55-g7522 From 99ae28bea984df4c38234eb6d2f29a552def6c1b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 17 Sep 2010 14:42:34 +0200 Subject: ALSA: hda - Make snd_hda_get_input_pin_attr() helper Make the helper function to give the input-pin attribute for jack connectivity and location. This simplifies checks of input-pin jacks a bit in some places. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 62 +++++++++++++++++------------------------- sound/pci/hda/hda_local.h | 11 ++++++++ sound/pci/hda/patch_cirrus.c | 2 +- sound/pci/hda/patch_conexant.c | 11 ++------ sound/pci/hda/patch_realtek.c | 10 +++---- sound/pci/hda/patch_sigmatel.c | 30 ++++++++++---------- 6 files changed, 59 insertions(+), 67 deletions(-) (limited to 'sound/pci/hda/patch_cirrus.c') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 9f668efbe420..e15a75751f57 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -4637,44 +4637,26 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, } EXPORT_SYMBOL_HDA(snd_hda_parse_pin_def_config); -enum { - MIC_ATTR_INT, - MIC_ATTR_DOCK, - MIC_ATTR_NORMAL, - MIC_ATTR_FRONT, - MIC_ATTR_REAR, -}; - -static int get_mic_pin_attr(unsigned int def_conf) +int snd_hda_get_input_pin_attr(unsigned int def_conf) { unsigned int loc = get_defcfg_location(def_conf); unsigned int conn = get_defcfg_connect(def_conf); + if (conn == AC_JACK_PORT_NONE) + return INPUT_PIN_ATTR_UNUSED; /* Windows may claim the internal mic to be BOTH, too */ if (conn == AC_JACK_PORT_FIXED || conn == AC_JACK_PORT_BOTH) - return MIC_ATTR_INT; + return INPUT_PIN_ATTR_INT; if ((loc & 0x30) == AC_JACK_LOC_INTERNAL) - return MIC_ATTR_INT; + return INPUT_PIN_ATTR_INT; if ((loc & 0x30) == AC_JACK_LOC_SEPARATE) - return MIC_ATTR_DOCK; + return INPUT_PIN_ATTR_DOCK; if (loc == AC_JACK_LOC_REAR) - return MIC_ATTR_REAR; + return INPUT_PIN_ATTR_REAR; if (loc == AC_JACK_LOC_FRONT) - return MIC_ATTR_FRONT; - return MIC_ATTR_NORMAL; -} - -enum { - LINE_ATTR_DOCK, - LINE_ATTR_NORMAL, -}; - -static int get_line_pin_attr(unsigned int def_conf) -{ - unsigned int loc = get_defcfg_location(def_conf); - if ((loc & 0xf0) == AC_JACK_LOC_SEPARATE) - return LINE_ATTR_DOCK; - return LINE_ATTR_NORMAL; + return INPUT_PIN_ATTR_FRONT; + return INPUT_PIN_ATTR_NORMAL; } +EXPORT_SYMBOL_HDA(snd_hda_get_input_pin_attr); /** * hda_get_input_pin_label - Give a label for the given input pin @@ -4691,9 +4673,7 @@ const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin, static const char *mic_names[] = { "Internal Mic", "Dock Mic", "Mic", "Front Mic", "Rear Mic", }; - static const char *line_names[] = { - "Dock Line", "Line", - }; + int attr; def_conf = snd_hda_codec_get_pincfg(codec, pin); @@ -4701,11 +4681,19 @@ const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin, case AC_JACK_MIC_IN: if (!check_location) return "Mic"; - return mic_names[get_mic_pin_attr(def_conf)]; + attr = snd_hda_get_input_pin_attr(def_conf); + if (!attr) + return "None"; + return mic_names[attr - 1]; case AC_JACK_LINE_IN: if (!check_location) return "Line"; - return line_names[get_line_pin_attr(def_conf)]; + attr = snd_hda_get_input_pin_attr(def_conf); + if (!attr) + return "None"; + if (attr == INPUT_PIN_ATTR_DOCK) + return "Dock Line"; + return "Line"; case AC_JACK_AUX: return "Aux"; case AC_JACK_CD: @@ -4732,16 +4720,16 @@ static int check_mic_location_need(struct hda_codec *codec, int i, attr, attr2; defc = snd_hda_codec_get_pincfg(codec, cfg->inputs[input].pin); - attr = get_mic_pin_attr(defc); + attr = snd_hda_get_input_pin_attr(defc); /* for internal or docking mics, we need locations */ - if (attr <= MIC_ATTR_NORMAL) + if (attr <= INPUT_PIN_ATTR_NORMAL) return 1; attr = 0; for (i = 0; i < cfg->num_inputs; i++) { defc = snd_hda_codec_get_pincfg(codec, cfg->inputs[i].pin); - attr2 = get_mic_pin_attr(defc); - if (attr2 >= MIC_ATTR_NORMAL) { + attr2 = snd_hda_get_input_pin_attr(defc); + if (attr2 >= INPUT_PIN_ATTR_NORMAL) { if (attr && attr != attr2) return 1; /* different locations found */ attr = attr2; diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 6943efc78f66..d7dfa547e2d8 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -395,6 +395,17 @@ const char *hda_get_autocfg_input_label(struct hda_codec *codec, int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label, int index, int *type_index_ret); +enum { + INPUT_PIN_ATTR_UNUSED, /* pin not connected */ + INPUT_PIN_ATTR_INT, /* internal mic/line-in */ + INPUT_PIN_ATTR_DOCK, /* docking mic/line-in */ + INPUT_PIN_ATTR_NORMAL, /* mic/line-in jack */ + INPUT_PIN_ATTR_FRONT, /* mic/line-in jack in front */ + INPUT_PIN_ATTR_REAR, /* mic/line-in jack in rear */ +}; + +int snd_hda_get_input_pin_attr(unsigned int def_conf); + struct auto_pin_cfg { int line_outs; /* sorted in the order of Front/Surr/CLFE/Side */ diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index ae75283a5583..483c3f2d8d39 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c @@ -334,7 +334,7 @@ static int is_ext_mic(struct hda_codec *codec, unsigned int idx) if (!(val & AC_PINCAP_PRES_DETECT)) return 0; val = snd_hda_codec_get_pincfg(codec, pin); - return (get_defcfg_connect(val) == AC_JACK_PORT_COMPLEX); + return (snd_hda_get_input_pin_attr(val) != INPUT_PIN_ATTR_INT); } static hda_nid_t get_adc(struct hda_codec *codec, hda_nid_t pin, diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index e501a85b5612..09d573c59bef 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -3462,19 +3462,12 @@ static void cx_auto_unsol_event(struct hda_codec *codec, unsigned int res) } } -static int is_int_mic_conn(unsigned int def_conf) -{ - unsigned int loc = get_defcfg_location(def_conf); - return get_defcfg_connect(def_conf) == AC_JACK_PORT_FIXED || - (loc & 0x30) == AC_JACK_LOC_INTERNAL; -} - /* return true if it's an internal-mic pin */ static int is_int_mic(struct hda_codec *codec, hda_nid_t pin) { unsigned int def_conf = snd_hda_codec_get_pincfg(codec, pin); return get_defcfg_device(def_conf) == AC_JACK_MIC_IN && - is_int_mic_conn(def_conf); + snd_hda_get_input_pin_attr(def_conf) == INPUT_PIN_ATTR_INT; } /* return true if it's an external-mic pin */ @@ -3482,7 +3475,7 @@ static int is_ext_mic(struct hda_codec *codec, hda_nid_t pin) { unsigned int def_conf = snd_hda_codec_get_pincfg(codec, pin); return get_defcfg_device(def_conf) == AC_JACK_MIC_IN && - !is_int_mic_conn(def_conf); + snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT; } /* check whether the pin config is suitable for auto-mic switching; diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 5df88798895b..6045f281b225 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -1403,19 +1403,19 @@ static void alc_init_auto_mic(struct hda_codec *codec) hda_nid_t nid = cfg->inputs[i].pin; unsigned int defcfg; defcfg = snd_hda_codec_get_pincfg(codec, nid); - switch (get_defcfg_connect(defcfg)) { - case AC_JACK_PORT_FIXED: + switch (snd_hda_get_input_pin_attr(defcfg)) { + case INPUT_PIN_ATTR_INT: if (fixed) return; /* already occupied */ fixed = nid; break; - case AC_JACK_PORT_COMPLEX: + case INPUT_PIN_ATTR_UNUSED: + return; /* invalid entry */ + default: if (ext) return; /* already occupied */ ext = nid; break; - default: - return; /* invalid entry */ } } if (!ext || !fixed) diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 7eb359a030de..6bfbc2fe46ed 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -2778,7 +2778,7 @@ static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec, struct sigmatel_spec *spec = codec->spec; char name[22]; - if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) { + if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) { if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD && nid == spec->line_switch) control = STAC_CTL_WIDGET_IO_SWITCH; @@ -2857,7 +2857,7 @@ static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac) def_conf = snd_hda_codec_get_pincfg(codec, nid); /* some laptops have an internal analog microphone * which can't be used as a output */ - if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { + if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) { pincap = snd_hda_query_pin_caps(codec, nid); if (pincap & AC_PINCAP_OUT) { *dac = get_unassigned_dac(codec, nid); @@ -3496,23 +3496,23 @@ static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid, if (!nid) return 0; cfg = snd_hda_codec_get_pincfg(codec, nid); - switch (get_defcfg_connect(cfg)) { - case AC_JACK_PORT_BOTH: - case AC_JACK_PORT_FIXED: + switch (snd_hda_get_input_pin_attr(cfg)) { + case INPUT_PIN_ATTR_INT: if (*fixed) return 1; /* already occupied */ *fixed = nid; break; - case AC_JACK_PORT_COMPLEX: - if ((get_defcfg_location(cfg) & 0xF0) == AC_JACK_LOC_SEPARATE) { - if (*dock) - return 1; /* already occupied */ - *dock = nid; - } else { - if (*ext) - return 1; /* already occupied */ - *ext = nid; - } + case INPUT_PIN_ATTR_UNUSED: + break; + case INPUT_PIN_ATTR_DOCK: + if (*dock) + return 1; /* already occupied */ + *dock = nid; + break; + default: + if (*ext) + return 1; /* already occupied */ + *ext = nid; break; } return 0; -- cgit v1.2.3-55-g7522 From 4e7d7c6018567fa03f387d06602d4145c75ebbe0 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Wed, 22 Sep 2010 17:31:37 -0400 Subject: ALSA: hda - MacBookPro 5,3 line-in support I've found the following patch is necessary to enable line-in on my MacBookPro 5,3 machine. With the patch applied I've successfully recorded audio from the line-in jack. This is based on the existing 5,5 support. Signed-off-by: Vince Weaver Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_cirrus.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'sound/pci/hda/patch_cirrus.c') diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index 483c3f2d8d39..5c00106cbc2e 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c @@ -65,6 +65,7 @@ struct cs_spec { /* available models */ enum { + CS420X_MBP53, CS420X_MBP55, CS420X_IMAC27, CS420X_AUTO, @@ -839,7 +840,8 @@ static void cs_automute(struct hda_codec *codec) AC_VERB_SET_PIN_WIDGET_CONTROL, hp_present ? 0 : PIN_OUT); } - if (spec->board_config == CS420X_MBP55 || + if (spec->board_config == CS420X_MBP53 || + spec->board_config == CS420X_MBP55 || spec->board_config == CS420X_IMAC27) { unsigned int gpio = hp_present ? 0x02 : 0x08; snd_hda_codec_write(codec, 0x01, 0, @@ -1128,6 +1130,7 @@ static int cs_parse_auto_config(struct hda_codec *codec) } static const char *cs420x_models[CS420X_MODELS] = { + [CS420X_MBP53] = "mbp53", [CS420X_MBP55] = "mbp55", [CS420X_IMAC27] = "imac27", [CS420X_AUTO] = "auto", @@ -1135,6 +1138,7 @@ static const char *cs420x_models[CS420X_MODELS] = { static struct snd_pci_quirk cs420x_cfg_tbl[] = { + SND_PCI_QUIRK(0x10de, 0x0ac0, "MacBookPro 5,3", CS420X_MBP53), SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55), SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27), {} /* terminator */ @@ -1145,6 +1149,20 @@ struct cs_pincfg { u32 val; }; +static struct cs_pincfg mbp53_pincfgs[] = { + { 0x09, 0x012b4050 }, + { 0x0a, 0x90100141 }, + { 0x0b, 0x90100140 }, + { 0x0c, 0x018b3020 }, + { 0x0d, 0x90a00110 }, + { 0x0e, 0x400000f0 }, + { 0x0f, 0x01cbe030 }, + { 0x10, 0x014be060 }, + { 0x12, 0x400000f0 }, + { 0x15, 0x400000f0 }, + {} /* terminator */ +}; + static struct cs_pincfg mbp55_pincfgs[] = { { 0x09, 0x012b4030 }, { 0x0a, 0x90100121 }, @@ -1174,6 +1192,7 @@ static struct cs_pincfg imac27_pincfgs[] = { }; static struct cs_pincfg *cs_pincfgs[CS420X_MODELS] = { + [CS420X_MBP53] = mbp53_pincfgs, [CS420X_MBP55] = mbp55_pincfgs, [CS420X_IMAC27] = imac27_pincfgs, }; @@ -1206,6 +1225,7 @@ static int patch_cs420x(struct hda_codec *codec) switch (spec->board_config) { case CS420X_IMAC27: + case CS420X_MBP53: case CS420X_MBP55: /* GPIO1 = headphones */ /* GPIO3 = speakers */ -- cgit v1.2.3-55-g7522 From f46119b73425df9d1e05c5d5e909a993d95b0218 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 11 Oct 2010 14:46:35 +0200 Subject: ALSA: hda - Add model=mbp55 entry for MacBookPro 7,1 Reference: Novell bnc#645066 https://bugzilla.novell.com/show_bug.cgi?id=645066 Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_cirrus.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound/pci/hda/patch_cirrus.c') diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index 5c00106cbc2e..d9a3dbcc9ba0 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c @@ -1140,6 +1140,7 @@ static const char *cs420x_models[CS420X_MODELS] = { static struct snd_pci_quirk cs420x_cfg_tbl[] = { SND_PCI_QUIRK(0x10de, 0x0ac0, "MacBookPro 5,3", CS420X_MBP53), SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55), + SND_PCI_QUIRK(0x10de, 0xcb89, "MacBookPro 7,1", CS420X_MBP55), SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27), {} /* terminator */ }; -- cgit v1.2.3-55-g7522 From 6a92934d9e987b6363db3e6a08e17bc0f2078c5d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 11 Oct 2010 15:16:20 +0200 Subject: ALSA: hda - Add input volume control for each mic/line-in pin The input pins on cirrus codecs have also input amps. Let's make control elemetns for them. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_cirrus.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'sound/pci/hda/patch_cirrus.c') diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index d9a3dbcc9ba0..460fb2ef7e39 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c @@ -742,6 +742,27 @@ static struct hda_bind_ctls *make_bind_capture(struct hda_codec *codec, return bind; } +/* add a (input-boost) volume control to the given input pin */ +static int add_input_volume_control(struct hda_codec *codec, + struct auto_pin_cfg *cfg, + int item) +{ + hda_nid_t pin = cfg->inputs[item].pin; + u32 caps; + const char *label; + struct snd_kcontrol *kctl; + + if (!(get_wcaps(codec, pin) & AC_WCAP_IN_AMP)) + return 0; + caps = query_amp_caps(codec, pin, HDA_INPUT); + caps = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; + if (caps <= 1) + return 0; + label = hda_get_autocfg_input_label(codec, cfg, item); + return add_volume(codec, label, 0, + HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_INPUT), 1, &kctl); +} + static int build_input(struct hda_codec *codec) { struct cs_spec *spec = codec->spec; @@ -781,6 +802,12 @@ static int build_input(struct hda_codec *codec) return err; } + for (i = 0; i < spec->num_inputs; i++) { + err = add_input_volume_control(codec, &spec->autocfg, i); + if (err < 0) + return err; + } + return 0; } -- cgit v1.2.3-55-g7522 From 87232dd49aeb6b7d1af291edca8bd129a82ef4b5 Mon Sep 17 00:00:00 2001 From: Edgar (gimli) Hucek Date: Wed, 3 Nov 2010 08:14:10 +0100 Subject: ALSA: hda - MacBookAir3,1(3,2) alsa support This patch add support for the MacBookAir3,1 and MacBookAir3,2 to the alsa sound system. Signed-off-by: Edgar (gimli) Hucek Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_cirrus.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound/pci/hda/patch_cirrus.c') diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index 460fb2ef7e39..18af38ebf757 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c @@ -1166,6 +1166,7 @@ static const char *cs420x_models[CS420X_MODELS] = { static struct snd_pci_quirk cs420x_cfg_tbl[] = { SND_PCI_QUIRK(0x10de, 0x0ac0, "MacBookPro 5,3", CS420X_MBP53), + SND_PCI_QUIRK(0x10de, 0x0d94, "MacBookAir 3,1(2)", CS420X_MBP55), SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55), SND_PCI_QUIRK(0x10de, 0xcb89, "MacBookPro 7,1", CS420X_MBP55), SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27), -- cgit v1.2.3-55-g7522