summaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_codec.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2011-10-27 20:47:07 +0200
committerTakashi Iwai <tiwai@suse.de>2011-11-16 11:10:16 +0100
commit04f5ade6afc4326dc6cd10d235500972fba548eb (patch)
tree14704ec6572b915e3516a9e2d038567448579342 /sound/pci/hda/hda_codec.c
parent8b940fc457fbf883053caf397586a61bd3cae23e (diff)
downloadop-kernel-dev-04f5ade6afc4326dc6cd10d235500972fba548eb.zip
op-kernel-dev-04f5ade6afc4326dc6cd10d235500972fba548eb.tar.gz
ALSA: hda - Introduce snd_hda_get_pin_label()
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>
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r--sound/pci/hda/hda_codec.c63
1 files changed, 60 insertions, 3 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index e44b107..c6ff9b9 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);
* "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
@@ -5102,6 +5101,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
*
* When the same label is used already in the existing items, the number
OpenPOWER on IntegriCloud