aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/hda/hda_codec.c63
-rw-r--r--sound/pci/hda/hda_local.h4
-rw-r--r--sound/pci/hda/patch_ca0110.c2
-rw-r--r--sound/pci/hda/patch_cirrus.c2
-rw-r--r--sound/pci/hda/patch_sigmatel.c4
5 files changed, 66 insertions, 9 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index e44b107fdc75..c6ff9b9de553 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -5004,8 +5004,8 @@ EXPORT_SYMBOL_HDA(snd_hda_get_input_pin_attr);
5004 * "Rear", "Internal". 5004 * "Rear", "Internal".
5005 */ 5005 */
5006 5006
5007const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin, 5007static const char *hda_get_input_pin_label(struct hda_codec *codec,
5008 int check_location) 5008 hda_nid_t pin, bool check_location)
5009{ 5009{
5010 unsigned int def_conf; 5010 unsigned int def_conf;
5011 static const char * const mic_names[] = { 5011 static const char * const mic_names[] = {
@@ -5044,7 +5044,6 @@ const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin,
5044 return "Misc"; 5044 return "Misc";
5045 } 5045 }
5046} 5046}
5047EXPORT_SYMBOL_HDA(hda_get_input_pin_label);
5048 5047
5049/* Check whether the location prefix needs to be added to the label. 5048/* Check whether the location prefix needs to be added to the label.
5050 * If all mic-jacks are in the same location (e.g. rear panel), we don't 5049 * If all mic-jacks are in the same location (e.g. rear panel), we don't
@@ -5102,6 +5101,64 @@ const char *hda_get_autocfg_input_label(struct hda_codec *codec,
5102EXPORT_SYMBOL_HDA(hda_get_autocfg_input_label); 5101EXPORT_SYMBOL_HDA(hda_get_autocfg_input_label);
5103 5102
5104/** 5103/**
5104 * snd_hda_get_pin_label - Get a label for the given I/O pin
5105 *
5106 * Get a label for the given pin. This function works for both input and
5107 * output pins. When @cfg is given as non-NULL, the function tries to get
5108 * an optimized label using hda_get_autocfg_input_label().
5109 */
5110const char *snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid,
5111 const struct auto_pin_cfg *cfg)
5112{
5113 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
5114 int attr;
5115 int i;
5116
5117 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
5118 return NULL;
5119
5120 attr = snd_hda_get_input_pin_attr(def_conf);
5121 switch (get_defcfg_device(def_conf)) {
5122 case AC_JACK_LINE_OUT:
5123 switch (attr) {
5124 case INPUT_PIN_ATTR_INT:
5125 return "Speaker";
5126 case INPUT_PIN_ATTR_DOCK:
5127 return "Dock Line-Out";
5128 case INPUT_PIN_ATTR_FRONT:
5129 return "Front Line-Out";
5130 default:
5131 return "Line-Out";
5132 }
5133 case AC_JACK_SPEAKER:
5134 return "Speaker";
5135 case AC_JACK_HP_OUT:
5136 switch (attr) {
5137 case INPUT_PIN_ATTR_DOCK:
5138 return "Dock Headphone";
5139 case INPUT_PIN_ATTR_FRONT:
5140 return "Front Headphone";
5141 default:
5142 return "Headphone";
5143 }
5144 case AC_JACK_SPDIF_OUT:
5145 case AC_JACK_DIG_OTHER_OUT:
5146 if (get_defcfg_location(def_conf) == AC_JACK_LOC_HDMI)
5147 return "HDMI";
5148 else
5149 return "SPDIF";
5150 }
5151
5152 if (cfg) {
5153 for (i = 0; i < cfg->num_inputs; i++)
5154 if (cfg->inputs[i].pin == nid)
5155 return hda_get_autocfg_input_label(codec, cfg, i);
5156 }
5157 return hda_get_input_pin_label(codec, nid, true);
5158}
5159EXPORT_SYMBOL_HDA(snd_hda_get_pin_label);
5160
5161/**
5105 * snd_hda_add_imux_item - Add an item to input_mux 5162 * snd_hda_add_imux_item - Add an item to input_mux
5106 * 5163 *
5107 * When the same label is used already in the existing items, the number 5164 * When the same label is used already in the existing items, the number
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 618ddad17236..7a10fe95211e 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -394,11 +394,11 @@ struct auto_pin_cfg_item {
394}; 394};
395 395
396struct auto_pin_cfg; 396struct auto_pin_cfg;
397const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin,
398 int check_location);
399const char *hda_get_autocfg_input_label(struct hda_codec *codec, 397const char *hda_get_autocfg_input_label(struct hda_codec *codec,
400 const struct auto_pin_cfg *cfg, 398 const struct auto_pin_cfg *cfg,
401 int input); 399 int input);
400const char *snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid,
401 const struct auto_pin_cfg *cfg);
402int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label, 402int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label,
403 int index, int *type_index_ret); 403 int index, int *type_index_ret);
404 404
diff --git a/sound/pci/hda/patch_ca0110.c b/sound/pci/hda/patch_ca0110.c
index 993757b65736..6bd602bfe0fe 100644
--- a/sound/pci/hda/patch_ca0110.c
+++ b/sound/pci/hda/patch_ca0110.c
@@ -476,7 +476,7 @@ static void parse_input(struct hda_codec *codec)
476 if (j >= cfg->num_inputs) 476 if (j >= cfg->num_inputs)
477 continue; 477 continue;
478 spec->input_pins[n] = pin; 478 spec->input_pins[n] = pin;
479 spec->input_labels[n] = hda_get_input_pin_label(codec, pin, 1); 479 spec->input_labels[n] = snd_hda_get_pin_label(codec, pin, NULL);
480 spec->adcs[n] = nid; 480 spec->adcs[n] = nid;
481 n++; 481 n++;
482 } 482 }
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
index 2a2d8645ba09..34a460bd27bb 100644
--- a/sound/pci/hda/patch_cirrus.c
+++ b/sound/pci/hda/patch_cirrus.c
@@ -711,7 +711,7 @@ static int cs_capture_source_info(struct snd_kcontrol *kcontrol,
711 uinfo->value.enumerated.item = spec->num_inputs - 1; 711 uinfo->value.enumerated.item = spec->num_inputs - 1;
712 idx = spec->input_idx[uinfo->value.enumerated.item]; 712 idx = spec->input_idx[uinfo->value.enumerated.item];
713 strcpy(uinfo->value.enumerated.name, 713 strcpy(uinfo->value.enumerated.name,
714 hda_get_input_pin_label(codec, cfg->inputs[idx].pin, 1)); 714 snd_hda_get_pin_label(codec, cfg->inputs[idx].pin, NULL));
715 return 0; 715 return 0;
716} 716}
717 717
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 470f6f286e81..3b4ef0cba0e7 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -2872,7 +2872,7 @@ static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2872 } 2872 }
2873 2873
2874 if (control) { 2874 if (control) {
2875 strcpy(name, hda_get_input_pin_label(codec, nid, 1)); 2875 strcpy(name, snd_hda_get_pin_label(codec, nid, NULL));
2876 return stac92xx_add_control(codec->spec, control, 2876 return stac92xx_add_control(codec->spec, control,
2877 strcat(name, " Jack Mode"), nid); 2877 strcat(name, " Jack Mode"), nid);
2878 } 2878 }
@@ -3563,7 +3563,7 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3563 if (index < 0) 3563 if (index < 0)
3564 continue; 3564 continue;
3565 3565
3566 label = hda_get_input_pin_label(codec, nid, 1); 3566 label = snd_hda_get_pin_label(codec, nid, NULL);
3567 snd_hda_add_imux_item(dimux, label, index, &type_idx); 3567 snd_hda_add_imux_item(dimux, label, index, &type_idx);
3568 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) 3568 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
3569 snd_hda_add_imux_item(imux, label, index, &type_idx); 3569 snd_hda_add_imux_item(imux, label, index, &type_idx);