aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2010-09-09 15:36:27 -0400
committerTakashi Iwai <tiwai@suse.de>2010-09-09 15:36:27 -0400
commita1c985158382cbce0b58b3264f771b3b153668a6 (patch)
tree32f6c7fd764f0d3b85fc22ec553175c94aff6f5c /sound/pci
parent10a20af7c944649dc6d1ffa06bc759f5f3a16cd9 (diff)
ALSA: hda - Reduce redundant mic location prefix in input source labels
When the mic pins are assigned to the same location, we can omit the redundant location prefix like "Front" or "Rear". Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/hda_codec.c90
1 files changed, 77 insertions, 13 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index e3284341c484..affb4607c6da 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -4618,32 +4618,64 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
4618} 4618}
4619EXPORT_SYMBOL_HDA(snd_hda_parse_pin_def_config); 4619EXPORT_SYMBOL_HDA(snd_hda_parse_pin_def_config);
4620 4620
4621enum {
4622 MIC_ATTR_INT,
4623 MIC_ATTR_DOCK,
4624 MIC_ATTR_NORMAL,
4625 MIC_ATTR_FRONT,
4626 MIC_ATTR_REAR,
4627};
4628
4629static int get_mic_pin_attr(unsigned int def_conf)
4630{
4631 unsigned int loc = get_defcfg_location(def_conf);
4632 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_FIXED ||
4633 (loc & 0x30) == AC_JACK_LOC_INTERNAL)
4634 return MIC_ATTR_INT;
4635 if ((loc & 0x30) == AC_JACK_LOC_SEPARATE)
4636 return MIC_ATTR_DOCK;
4637 if (loc == AC_JACK_LOC_REAR)
4638 return MIC_ATTR_REAR;
4639 if (loc == AC_JACK_LOC_FRONT)
4640 return MIC_ATTR_FRONT;
4641 return MIC_ATTR_NORMAL;
4642}
4643
4644enum {
4645 LINE_ATTR_DOCK,
4646 LINE_ATTR_NORMAL,
4647};
4648
4649static int get_line_pin_attr(unsigned int def_conf)
4650{
4651 unsigned int loc = get_defcfg_location(def_conf);
4652 if ((loc & 0xf0) == AC_JACK_LOC_SEPARATE)
4653 return LINE_ATTR_DOCK;
4654 return LINE_ATTR_NORMAL;
4655}
4656
4621const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin, 4657const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin,
4622 int check_location) 4658 int check_location)
4623{ 4659{
4624 unsigned int def_conf, loc; 4660 unsigned int def_conf;
4661 static const char *mic_names[] = {
4662 "Internal Mic", "Dock Mic", "Mic", "Front Mic", "Rear Mic",
4663 };
4664 static const char *line_names[] = {
4665 "Dock Line", "Line",
4666 };
4625 4667
4626 def_conf = snd_hda_codec_get_pincfg(codec, pin); 4668 def_conf = snd_hda_codec_get_pincfg(codec, pin);
4627 loc = get_defcfg_location(def_conf);
4628 4669
4629 switch (get_defcfg_device(def_conf)) { 4670 switch (get_defcfg_device(def_conf)) {
4630 case AC_JACK_MIC_IN: 4671 case AC_JACK_MIC_IN:
4631 if (!check_location) 4672 if (!check_location)
4632 return "Mic"; 4673 return "Mic";
4633 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_FIXED || 4674 return mic_names[get_mic_pin_attr(def_conf)];
4634 (loc & 0x30) == AC_JACK_LOC_INTERNAL)
4635 return "Internal Mic";
4636 if ((loc & 0x30) == AC_JACK_LOC_SEPARATE)
4637 return "Dock Mic";
4638 if (loc == AC_JACK_LOC_REAR)
4639 return "Rear Mic";
4640 return "Mic";
4641 case AC_JACK_LINE_IN: 4675 case AC_JACK_LINE_IN:
4642 if (!check_location) 4676 if (!check_location)
4643 return "Line"; 4677 return "Line";
4644 if ((loc & 0xf0) == AC_JACK_LOC_SEPARATE) 4678 return line_names[get_line_pin_attr(def_conf)];
4645 return "Dock Line";
4646 return "Line";
4647 case AC_JACK_AUX: 4679 case AC_JACK_AUX:
4648 return "Aux"; 4680 return "Aux";
4649 case AC_JACK_CD: 4681 case AC_JACK_CD:
@@ -4658,6 +4690,36 @@ const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin,
4658} 4690}
4659EXPORT_SYMBOL_HDA(hda_get_input_pin_label); 4691EXPORT_SYMBOL_HDA(hda_get_input_pin_label);
4660 4692
4693/* Check whether the location prefix needs to be added to the label.
4694 * If all mic-jacks are in the same location (e.g. rear panel), we don't
4695 * have to put "Front" prefix to each label. In such a case, returns false.
4696 */
4697static int check_mic_location_need(struct hda_codec *codec,
4698 const struct auto_pin_cfg *cfg,
4699 int input)
4700{
4701 unsigned int defc;
4702 int i, attr, attr2;
4703
4704 defc = snd_hda_codec_get_pincfg(codec, cfg->inputs[input].pin);
4705 attr = get_mic_pin_attr(defc);
4706 /* for internal or docking mics, we need locations */
4707 if (attr <= MIC_ATTR_NORMAL)
4708 return 1;
4709
4710 attr = 0;
4711 for (i = 0; i < cfg->num_inputs; i++) {
4712 defc = snd_hda_codec_get_pincfg(codec, cfg->inputs[i].pin);
4713 attr2 = get_mic_pin_attr(defc);
4714 if (attr2 >= MIC_ATTR_NORMAL) {
4715 if (attr && attr != attr2)
4716 return 1; /* different locations found */
4717 attr = attr2;
4718 }
4719 }
4720 return 0;
4721}
4722
4661const char *hda_get_autocfg_input_label(struct hda_codec *codec, 4723const char *hda_get_autocfg_input_label(struct hda_codec *codec,
4662 const struct auto_pin_cfg *cfg, 4724 const struct auto_pin_cfg *cfg,
4663 int input) 4725 int input)
@@ -4668,6 +4730,8 @@ const char *hda_get_autocfg_input_label(struct hda_codec *codec,
4668 if ((input > 0 && cfg->inputs[input - 1].type == type) || 4730 if ((input > 0 && cfg->inputs[input - 1].type == type) ||
4669 (input < cfg->num_inputs - 1 && cfg->inputs[input + 1].type == type)) 4731 (input < cfg->num_inputs - 1 && cfg->inputs[input + 1].type == type))
4670 has_multiple_pins = 1; 4732 has_multiple_pins = 1;
4733 if (has_multiple_pins && type == AUTO_PIN_MIC)
4734 has_multiple_pins &= check_mic_location_need(codec, cfg, input);
4671 return hda_get_input_pin_label(codec, cfg->inputs[input].pin, 4735 return hda_get_input_pin_label(codec, cfg->inputs[input].pin,
4672 has_multiple_pins); 4736 has_multiple_pins);
4673} 4737}