]> Pileus Git - ~andy/linux/commitdiff
ALSA: hda - Introduce snd_hda_get_pin_label()
authorTakashi Iwai <tiwai@suse.de>
Thu, 27 Oct 2011 18:47:07 +0000 (20:47 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 16 Nov 2011 10:10:16 +0000 (11:10 +0100)
Create a new helper function snd_hda_get_pin_label() for getting a label
string for both input and output pins.  hda_get_input_pin_label() is
obsoleted by this function, and the callers are replaced appropriately
now by this patch.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_local.h
sound/pci/hda/patch_ca0110.c
sound/pci/hda/patch_cirrus.c
sound/pci/hda/patch_sigmatel.c

index e44b107fdc7594c47df5458b7acc0c6440454561..c6ff9b9de5536078646e01727895324db8a56929 100644 (file)
@@ -5004,8 +5004,8 @@ EXPORT_SYMBOL_HDA(snd_hda_get_input_pin_attr);
  * "Rear", "Internal".
  */
 
-const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin,
-                                       int check_location)
+static const char *hda_get_input_pin_label(struct hda_codec *codec,
+                                          hda_nid_t pin, bool check_location)
 {
        unsigned int def_conf;
        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,
                return "Misc";
        }
 }
-EXPORT_SYMBOL_HDA(hda_get_input_pin_label);
 
 /* Check whether the location prefix needs to be added to the label.
  * If all mic-jacks are in the same location (e.g. rear panel), we don't
@@ -5101,6 +5100,64 @@ const char *hda_get_autocfg_input_label(struct hda_codec *codec,
 }
 EXPORT_SYMBOL_HDA(hda_get_autocfg_input_label);
 
+/**
+ * snd_hda_get_pin_label - Get a label for the given I/O pin
+ *
+ * Get a label for the given pin.  This function works for both input and
+ * output pins.  When @cfg is given as non-NULL, the function tries to get
+ * an optimized label using hda_get_autocfg_input_label().
+ */
+const char *snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid,
+                                 const struct auto_pin_cfg *cfg)
+{
+       unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
+       int attr;
+       int i;
+
+       if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
+               return NULL;
+
+       attr = snd_hda_get_input_pin_attr(def_conf);
+       switch (get_defcfg_device(def_conf)) {
+       case AC_JACK_LINE_OUT:
+               switch (attr) {
+               case INPUT_PIN_ATTR_INT:
+                       return "Speaker";
+               case INPUT_PIN_ATTR_DOCK:
+                       return "Dock Line-Out";
+               case INPUT_PIN_ATTR_FRONT:
+                       return "Front Line-Out";
+               default:
+                       return "Line-Out";
+               }
+       case AC_JACK_SPEAKER:
+               return "Speaker";
+       case AC_JACK_HP_OUT:
+               switch (attr) {
+               case INPUT_PIN_ATTR_DOCK:
+                       return "Dock Headphone";
+               case INPUT_PIN_ATTR_FRONT:
+                       return "Front Headphone";
+               default:
+                       return "Headphone";
+               }
+       case AC_JACK_SPDIF_OUT:
+       case AC_JACK_DIG_OTHER_OUT:
+               if (get_defcfg_location(def_conf) == AC_JACK_LOC_HDMI)
+                       return "HDMI";
+               else
+                       return "SPDIF";
+       }
+
+       if (cfg) {
+               for (i = 0; i < cfg->num_inputs; i++)
+                       if (cfg->inputs[i].pin == nid)
+                               return hda_get_autocfg_input_label(codec, cfg, i);
+       }
+       return hda_get_input_pin_label(codec, nid, true);
+}
+EXPORT_SYMBOL_HDA(snd_hda_get_pin_label);
+
 /**
  * snd_hda_add_imux_item - Add an item to input_mux
  *
index 618ddad172369b22062ad97114dd783841ccde43..7a10fe95211ef6481632e41d696f1f959b1ff56a 100644 (file)
@@ -394,11 +394,11 @@ struct auto_pin_cfg_item {
 };
 
 struct auto_pin_cfg;
-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);
+const char *snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid,
+                                 const struct auto_pin_cfg *cfg);
 int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label,
                          int index, int *type_index_ret);
 
index 993757b65736a01687c571ce3003e18507e861f4..6bd602bfe0fe5f76c18946b5e12b868805e854d9 100644 (file)
@@ -476,7 +476,7 @@ static void parse_input(struct hda_codec *codec)
                if (j >= cfg->num_inputs)
                        continue;
                spec->input_pins[n] = pin;
-               spec->input_labels[n] = hda_get_input_pin_label(codec, pin, 1);
+               spec->input_labels[n] = snd_hda_get_pin_label(codec, pin, NULL);
                spec->adcs[n] = nid;
                n++;
        }
index 2a2d8645ba0933e8e9e20ef3bd33a656f1bb69c5..34a460bd27bb161dc8465b15d5a389fb8b5b3902 100644 (file)
@@ -711,7 +711,7 @@ static int cs_capture_source_info(struct snd_kcontrol *kcontrol,
                uinfo->value.enumerated.item = spec->num_inputs - 1;
        idx = spec->input_idx[uinfo->value.enumerated.item];
        strcpy(uinfo->value.enumerated.name,
-              hda_get_input_pin_label(codec, cfg->inputs[idx].pin, 1));
+              snd_hda_get_pin_label(codec, cfg->inputs[idx].pin, NULL));
        return 0;
 }
 
index 470f6f286e8144f4f7a8282b2dc126239c69f765..3b4ef0cba0e7ef1b6f52af6e659103b3b7c49b67 100644 (file)
@@ -2872,7 +2872,7 @@ static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
        }
 
        if (control) {
-               strcpy(name, hda_get_input_pin_label(codec, nid, 1));
+               strcpy(name, snd_hda_get_pin_label(codec, nid, NULL));
                return stac92xx_add_control(codec->spec, control,
                                        strcat(name, " Jack Mode"), nid);
        }
@@ -3563,7 +3563,7 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
                if (index < 0)
                        continue;
 
-               label = hda_get_input_pin_label(codec, nid, 1);
+               label = snd_hda_get_pin_label(codec, nid, NULL);
                snd_hda_add_imux_item(dimux, label, index, &type_idx);
                if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
                        snd_hda_add_imux_item(imux, label, index, &type_idx);