aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2010-09-09 10:28:02 -0400
committerTakashi Iwai <tiwai@suse.de>2010-09-09 10:46:03 -0400
commit10a20af7c944649dc6d1ffa06bc759f5f3a16cd9 (patch)
tree322ad916b8d909e3bdc3c51eb63ccecbdd1ae16a /sound/pci
parent86e2959a10828dd2614e037fb2502bc833adca52 (diff)
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 <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/hda_codec.c91
-rw-r--r--sound/pci/hda/hda_generic.c41
-rw-r--r--sound/pci/hda/hda_local.h11
-rw-r--r--sound/pci/hda/patch_analog.c27
-rw-r--r--sound/pci/hda/patch_ca0110.c3
-rw-r--r--sound/pci/hda/patch_cirrus.c4
-rw-r--r--sound/pci/hda/patch_realtek.c20
-rw-r--r--sound/pci/hda/patch_sigmatel.c144
-rw-r--r--sound/pci/hda/patch_via.c100
9 files changed, 174 insertions, 267 deletions
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,
4607 snd_printd(" inputs:"); 4607 snd_printd(" inputs:");
4608 for (i = 0; i < cfg->num_inputs; i++) { 4608 for (i = 0; i < cfg->num_inputs; i++) {
4609 snd_printdd(" %s=0x%x", 4609 snd_printdd(" %s=0x%x",
4610 auto_pin_cfg_labels[cfg->inputs[i].type], 4610 hda_get_autocfg_input_label(codec, cfg, i),
4611 cfg->inputs[i].pin); 4611 cfg->inputs[i].pin);
4612 } 4612 }
4613 snd_printd("\n"); 4613 snd_printd("\n");
@@ -4618,28 +4618,87 @@ 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
4621/* labels for input pins - for obsoleted config stuff */ 4621const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin,
4622const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = { 4622 int check_location)
4623 "Mic", "Line", "CD", "Aux" 4623{
4624}; 4624 unsigned int def_conf, loc;
4625EXPORT_SYMBOL_HDA(auto_pin_cfg_labels); 4625
4626 def_conf = snd_hda_codec_get_pincfg(codec, pin);
4627 loc = get_defcfg_location(def_conf);
4628
4629 switch (get_defcfg_device(def_conf)) {
4630 case AC_JACK_MIC_IN:
4631 if (!check_location)
4632 return "Mic";
4633 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_FIXED ||
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:
4642 if (!check_location)
4643 return "Line";
4644 if ((loc & 0xf0) == AC_JACK_LOC_SEPARATE)
4645 return "Dock Line";
4646 return "Line";
4647 case AC_JACK_AUX:
4648 return "Aux";
4649 case AC_JACK_CD:
4650 return "CD";
4651 case AC_JACK_SPDIF_IN:
4652 return "SPDIF In";
4653 case AC_JACK_DIG_OTHER_IN:
4654 return "Digital In";
4655 default:
4656 return "Misc";
4657 }
4658}
4659EXPORT_SYMBOL_HDA(hda_get_input_pin_label);
4626 4660
4627void snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg, 4661const char *hda_get_autocfg_input_label(struct hda_codec *codec,
4628 int input, char *str) 4662 const struct auto_pin_cfg *cfg,
4663 int input)
4629{ 4664{
4630 int type = cfg->inputs[input].type; 4665 int type = cfg->inputs[input].type;
4631 int idx; 4666 int has_multiple_pins = 0;
4632 4667
4633 for (idx = 0; idx < 3 && --input >= 0; idx++) { 4668 if ((input > 0 && cfg->inputs[input - 1].type == type) ||
4634 if (type != cfg->inputs[input].type) 4669 (input < cfg->num_inputs - 1 && cfg->inputs[input + 1].type == type))
4635 break; 4670 has_multiple_pins = 1;
4671 return hda_get_input_pin_label(codec, cfg->inputs[input].pin,
4672 has_multiple_pins);
4673}
4674EXPORT_SYMBOL_HDA(hda_get_autocfg_input_label);
4675
4676int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label,
4677 int index, int *type_idx)
4678{
4679 int i, label_idx = 0;
4680 if (imux->num_items >= HDA_MAX_NUM_INPUTS) {
4681 snd_printd(KERN_ERR "hda_codec: Too many imux items!\n");
4682 return -EINVAL;
4683 }
4684 for (i = 0; i < imux->num_items; i++) {
4685 if (!strncmp(label, imux->items[i].label, strlen(label)))
4686 label_idx++;
4636 } 4687 }
4637 if (idx > 0) 4688 if (type_idx)
4638 sprintf(str, "%s %d", auto_pin_cfg_labels[type], idx); 4689 *type_idx = label_idx;
4690 if (label_idx > 0)
4691 snprintf(imux->items[imux->num_items].label,
4692 sizeof(imux->items[imux->num_items].label),
4693 "%s %d", label, label_idx);
4639 else 4694 else
4640 strcpy(str, auto_pin_cfg_labels[type]); 4695 strlcpy(imux->items[imux->num_items].label, label,
4696 sizeof(imux->items[imux->num_items].label));
4697 imux->items[imux->num_items].index = index;
4698 imux->num_items++;
4699 return 0;
4641} 4700}
4642EXPORT_SYMBOL_HDA(snd_hda_get_input_pin_label); 4701EXPORT_SYMBOL_HDA(snd_hda_add_imux_item);
4643 4702
4644 4703
4645#ifdef CONFIG_PM 4704#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 {
61 struct hda_gnode *cap_vol_node; /* Node for capture volume */ 61 struct hda_gnode *cap_vol_node; /* Node for capture volume */
62 unsigned int cur_cap_src; /* current capture source */ 62 unsigned int cur_cap_src; /* current capture source */
63 struct hda_input_mux input_mux; 63 struct hda_input_mux input_mux;
64 char cap_labels[HDA_MAX_NUM_INPUTS][16];
65 64
66 unsigned int def_amp_in_caps; 65 unsigned int def_amp_in_caps;
67 unsigned int def_amp_out_caps; 66 unsigned int def_amp_out_caps;
@@ -506,11 +505,10 @@ static const char *get_input_type(struct hda_gnode *node, unsigned int *pinctl)
506 * returns 0 if not found, 1 if found, or a negative error code. 505 * returns 0 if not found, 1 if found, or a negative error code.
507 */ 506 */
508static int parse_adc_sub_nodes(struct hda_codec *codec, struct hda_gspec *spec, 507static int parse_adc_sub_nodes(struct hda_codec *codec, struct hda_gspec *spec,
509 struct hda_gnode *node) 508 struct hda_gnode *node, int idx)
510{ 509{
511 int i, err; 510 int i, err;
512 unsigned int pinctl; 511 unsigned int pinctl;
513 char *label;
514 const char *type; 512 const char *type;
515 513
516 if (node->checked) 514 if (node->checked)
@@ -523,7 +521,7 @@ static int parse_adc_sub_nodes(struct hda_codec *codec, struct hda_gspec *spec,
523 child = hda_get_node(spec, node->conn_list[i]); 521 child = hda_get_node(spec, node->conn_list[i]);
524 if (! child) 522 if (! child)
525 continue; 523 continue;
526 err = parse_adc_sub_nodes(codec, spec, child); 524 err = parse_adc_sub_nodes(codec, spec, child, idx);
527 if (err < 0) 525 if (err < 0)
528 return err; 526 return err;
529 if (err > 0) { 527 if (err > 0) {
@@ -564,9 +562,7 @@ static int parse_adc_sub_nodes(struct hda_codec *codec, struct hda_gspec *spec,
564 return 0; 562 return 0;
565 type = "Input"; 563 type = "Input";
566 } 564 }
567 label = spec->cap_labels[spec->input_mux.num_items]; 565 snd_hda_add_imux_item(&spec->input_mux, type, idx, NULL);
568 strcpy(label, type);
569 strcpy(spec->input_mux.items[spec->input_mux.num_items].label, label);
570 566
571 /* unmute the PIN external input */ 567 /* unmute the PIN external input */
572 unmute_input(codec, node, 0); /* index = 0? */ 568 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,
577 return 1; /* found */ 573 return 1; /* found */
578} 574}
579 575
580/* add a capture source element */
581static void add_cap_src(struct hda_gspec *spec, int idx)
582{
583 struct hda_input_mux_item *csrc;
584 char *buf;
585 int num, ocap;
586
587 num = spec->input_mux.num_items;
588 csrc = &spec->input_mux.items[num];
589 buf = spec->cap_labels[num];
590 for (ocap = 0; ocap < num; ocap++) {
591 if (! strcmp(buf, spec->cap_labels[ocap])) {
592 /* same label already exists,
593 * put the index number to be unique
594 */
595 sprintf(buf, "%s %d", spec->cap_labels[ocap], num);
596 break;
597 }
598 }
599 csrc->index = idx;
600 spec->input_mux.num_items++;
601}
602
603/* 576/*
604 * parse input 577 * parse input
605 */ 578 */
@@ -624,22 +597,18 @@ static int parse_input_path(struct hda_codec *codec, struct hda_gnode *adc_node)
624 for (i = 0; i < adc_node->nconns; i++) { 597 for (i = 0; i < adc_node->nconns; i++) {
625 node = hda_get_node(spec, adc_node->conn_list[i]); 598 node = hda_get_node(spec, adc_node->conn_list[i]);
626 if (node && node->type == AC_WID_PIN) { 599 if (node && node->type == AC_WID_PIN) {
627 err = parse_adc_sub_nodes(codec, spec, node); 600 err = parse_adc_sub_nodes(codec, spec, node, i);
628 if (err < 0) 601 if (err < 0)
629 return err; 602 return err;
630 else if (err > 0)
631 add_cap_src(spec, i);
632 } 603 }
633 } 604 }
634 /* ... then check the rests, more complicated connections */ 605 /* ... then check the rests, more complicated connections */
635 for (i = 0; i < adc_node->nconns; i++) { 606 for (i = 0; i < adc_node->nconns; i++) {
636 node = hda_get_node(spec, adc_node->conn_list[i]); 607 node = hda_get_node(spec, adc_node->conn_list[i]);
637 if (node && node->type != AC_WID_PIN) { 608 if (node && node->type != AC_WID_PIN) {
638 err = parse_adc_sub_nodes(codec, spec, node); 609 err = parse_adc_sub_nodes(codec, spec, node, i);
639 if (err < 0) 610 if (err < 0)
640 return err; 611 return err;
641 else if (err > 0)
642 add_cap_src(spec, i);
643 } 612 }
644 } 613 }
645 614
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 {
378 AUTO_PIN_HP_OUT 378 AUTO_PIN_HP_OUT
379}; 379};
380 380
381extern const char *auto_pin_cfg_labels[AUTO_PIN_LAST];
382
383#define AUTO_CFG_MAX_OUTS 5 381#define AUTO_CFG_MAX_OUTS 5
384#define AUTO_CFG_MAX_INS 8 382#define AUTO_CFG_MAX_INS 8
385 383
@@ -389,8 +387,13 @@ struct auto_pin_cfg_item {
389}; 387};
390 388
391struct auto_pin_cfg; 389struct auto_pin_cfg;
392void snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg, 390const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin,
393 int input, char *label); 391 int check_location);
392const char *hda_get_autocfg_input_label(struct hda_codec *codec,
393 const struct auto_pin_cfg *cfg,
394 int input);
395int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label,
396 int index, int *type_index_ret);
394 397
395struct auto_pin_cfg { 398struct auto_pin_cfg {
396 int line_outs; 399 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,
2909} 2909}
2910 2910
2911/* create playback/capture controls for input pins */ 2911/* create playback/capture controls for input pins */
2912static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec, 2912static int ad1988_auto_create_analog_input_ctls(struct hda_codec *codec,
2913 const struct auto_pin_cfg *cfg) 2913 const struct auto_pin_cfg *cfg)
2914{ 2914{
2915 struct ad198x_spec *spec = codec->spec;
2915 struct hda_input_mux *imux = &spec->private_imux; 2916 struct hda_input_mux *imux = &spec->private_imux;
2916 int i, err, type, type_idx = 0; 2917 int i, err, type, type_idx;
2917 2918
2918 for (i = 0; i < cfg->num_inputs; i++) { 2919 for (i = 0; i < cfg->num_inputs; i++) {
2920 const char *label;
2919 type = cfg->inputs[i].type; 2921 type = cfg->inputs[i].type;
2920 if (i > 0 && type != cfg->inputs[i - 1].type) 2922 label = hda_get_autocfg_input_label(codec, cfg, i);
2921 type_idx++; 2923 snd_hda_add_imux_item(imux, label,
2922 else 2924 ad1988_pin_to_adc_idx(cfg->inputs[i].pin),
2923 type_idx = 0; 2925 &type_idx);
2924 err = new_analog_input(spec, cfg->inputs[i].pin, 2926 err = new_analog_input(spec, cfg->inputs[i].pin,
2925 auto_pin_cfg_labels[type], type_idx, 2927 label, type_idx,
2926 type == AUTO_PIN_MIC); 2928 type == AUTO_PIN_MIC);
2927 if (err < 0) 2929 if (err < 0)
2928 return err; 2930 return err;
2929 snd_hda_get_input_pin_label(cfg, i,
2930 imux->items[imux->num_items].label);
2931 imux->items[imux->num_items].index =
2932 ad1988_pin_to_adc_idx(cfg->inputs[i].pin);
2933 imux->num_items++;
2934 } 2931 }
2935 strcpy(imux->items[imux->num_items].label, "Mix"); 2932 snd_hda_add_imux_item(imux, "Mix", 9, NULL);
2936 imux->items[imux->num_items].index = 9;
2937 imux->num_items++;
2938 2933
2939 if ((err = add_control(spec, AD_CTL_WIDGET_VOL, 2934 if ((err = add_control(spec, AD_CTL_WIDGET_VOL,
2940 "Analog Mix Playback Volume", 2935 "Analog Mix Playback Volume",
@@ -3046,7 +3041,7 @@ static int ad1988_parse_auto_config(struct hda_codec *codec)
3046 "Speaker")) < 0 || 3041 "Speaker")) < 0 ||
3047 (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pins[0], 3042 (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
3048 "Headphone")) < 0 || 3043 "Headphone")) < 0 ||
3049 (err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 3044 (err = ad1988_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3050 return err; 3045 return err;
3051 3046
3052 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 3047 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)
474 if (j >= cfg->num_inputs) 474 if (j >= cfg->num_inputs)
475 continue; 475 continue;
476 spec->input_pins[n] = pin; 476 spec->input_pins[n] = pin;
477 spec->input_labels[n] = 477 spec->input_labels[n] = hda_get_input_pin_label(codec, pin, 1);
478 auto_pin_cfg_labels[cfg->inputs[j].type];
479 spec->adcs[n] = nid; 478 spec->adcs[n] = nid;
480 n++; 479 n++;
481 } 480 }
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,
673{ 673{
674 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 674 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
675 struct cs_spec *spec = codec->spec; 675 struct cs_spec *spec = codec->spec;
676 struct auto_pin_cfg *cfg = &spec->autocfg;
676 unsigned int idx; 677 unsigned int idx;
677 678
678 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 679 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
@@ -681,7 +682,8 @@ static int cs_capture_source_info(struct snd_kcontrol *kcontrol,
681 if (uinfo->value.enumerated.item >= spec->num_inputs) 682 if (uinfo->value.enumerated.item >= spec->num_inputs)
682 uinfo->value.enumerated.item = spec->num_inputs - 1; 683 uinfo->value.enumerated.item = spec->num_inputs - 1;
683 idx = spec->input_idx[uinfo->value.enumerated.item]; 684 idx = spec->input_idx[uinfo->value.enumerated.item];
684 strcpy(uinfo->value.enumerated.name, auto_pin_cfg_labels[idx]); 685 strcpy(uinfo->value.enumerated.name,
686 hda_get_input_pin_label(codec, cfg->inputs[idx].pin, 1));
685 return 0; 687 return 0;
686} 688}
687 689
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,
4947 4947
4948 for (i = 0; i < cfg->num_inputs; i++) { 4948 for (i = 0; i < cfg->num_inputs; i++) {
4949 hda_nid_t pin; 4949 hda_nid_t pin;
4950 const char *label;
4950 4951
4951 pin = cfg->inputs[i].pin; 4952 pin = cfg->inputs[i].pin;
4952 if (!alc_is_input_pin(codec, pin)) 4953 if (!alc_is_input_pin(codec, pin))
@@ -4957,12 +4958,13 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec,
4957 type_idx++; 4958 type_idx++;
4958 else 4959 else
4959 type_idx = 0; 4960 type_idx = 0;
4961 label = hda_get_autocfg_input_label(codec, cfg, i);
4960 if (mixer) { 4962 if (mixer) {
4961 idx = get_connection_index(codec, mixer, pin); 4963 idx = get_connection_index(codec, mixer, pin);
4962 if (idx >= 0) { 4964 if (idx >= 0) {
4963 err = new_analog_input(spec, pin, 4965 err = new_analog_input(spec, pin,
4964 auto_pin_cfg_labels[type], 4966 label, type_idx,
4965 type_idx, idx, mixer); 4967 idx, mixer);
4966 if (err < 0) 4968 if (err < 0)
4967 return err; 4969 return err;
4968 } 4970 }
@@ -4973,12 +4975,8 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec,
4973 idx = get_connection_index(codec, cap1, pin); 4975 idx = get_connection_index(codec, cap1, pin);
4974 if (idx < 0 && cap2) 4976 if (idx < 0 && cap2)
4975 idx = get_connection_index(codec, cap2, pin); 4977 idx = get_connection_index(codec, cap2, pin);
4976 if (idx >= 0) { 4978 if (idx >= 0)
4977 snd_hda_get_input_pin_label(cfg, i, 4979 snd_hda_add_imux_item(imux, label, idx, NULL);
4978 imux->items[imux->num_items].label);
4979 imux->items[imux->num_items].index = idx;
4980 imux->num_items++;
4981 }
4982 } 4980 }
4983 return 0; 4981 return 0;
4984} 4982}
@@ -10626,9 +10624,9 @@ static int alc_auto_add_mic_boost(struct hda_codec *codec)
10626 break; 10624 break;
10627 nid = cfg->inputs[i].pin; 10625 nid = cfg->inputs[i].pin;
10628 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { 10626 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
10629 char pinname[32], label[32]; 10627 char label[32];
10630 snd_hda_get_input_pin_label(cfg, i, pinname); 10628 snprintf(label, sizeof(label), "%s Boost",
10631 snprintf(label, sizeof(label), "%s Boost", pinname); 10629 hda_get_autocfg_input_label(codec, cfg, i));
10632 err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0, 10630 err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0,
10633 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); 10631 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10634 if (err < 0) 10632 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 {
191 signed char dmux_idx; 191 signed char dmux_idx;
192}; 192};
193 193
194struct unique_input_names {
195 int num;
196 char uname[HDA_MAX_NUM_INPUTS][32];
197};
198
199struct sigmatel_spec { 194struct sigmatel_spec {
200 struct snd_kcontrol_new *mixers[4]; 195 struct snd_kcontrol_new *mixers[4];
201 unsigned int num_mixers; 196 unsigned int num_mixers;
@@ -312,7 +307,6 @@ struct sigmatel_spec {
312 struct hda_input_mux private_imux; 307 struct hda_input_mux private_imux;
313 struct hda_input_mux private_smux; 308 struct hda_input_mux private_smux;
314 struct hda_input_mux private_mono_mux; 309 struct hda_input_mux private_mono_mux;
315 struct unique_input_names private_u_inp_names;
316}; 310};
317 311
318static hda_nid_t stac9200_adc_nids[1] = { 312static hda_nid_t stac9200_adc_nids[1] = {
@@ -1116,9 +1110,7 @@ static int stac92xx_build_controls(struct hda_codec *codec)
1116 struct hda_input_mux *smux = &spec->private_smux; 1110 struct hda_input_mux *smux = &spec->private_smux;
1117 /* check for mute support on SPDIF out */ 1111 /* check for mute support on SPDIF out */
1118 if (wcaps & AC_WCAP_OUT_AMP) { 1112 if (wcaps & AC_WCAP_OUT_AMP) {
1119 strcpy(smux->items[smux->num_items].label, "Off"); 1113 snd_hda_add_imux_item(smux, "Off", 0, NULL);
1120 smux->items[smux->num_items].index = 0;
1121 smux->num_items++;
1122 spec->spdif_mute = 1; 1114 spec->spdif_mute = 1;
1123 } 1115 }
1124 stac_smux_mixer.count = spec->num_smuxes; 1116 stac_smux_mixer.count = spec->num_smuxes;
@@ -2797,7 +2789,7 @@ static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2797 } 2789 }
2798 2790
2799 if (control) { 2791 if (control) {
2800 strcpy(name, auto_pin_cfg_labels[idx]); 2792 strcpy(name, hda_get_input_pin_label(codec, nid, 1));
2801 return stac92xx_add_control(codec->spec, control, 2793 return stac92xx_add_control(codec->spec, control,
2802 strcat(name, " Jack Mode"), nid); 2794 strcat(name, " Jack Mode"), nid);
2803 } 2795 }
@@ -3267,12 +3259,9 @@ static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3267 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) 3259 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3268 return -EINVAL; 3260 return -EINVAL;
3269 3261
3270 for (i = 0; i < num_cons; i++) { 3262 for (i = 0; i < num_cons; i++)
3271 strcpy(mono_mux->items[mono_mux->num_items].label, 3263 snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
3272 stac92xx_mono_labels[i]); 3264 NULL);
3273 mono_mux->items[mono_mux->num_items].index = i;
3274 mono_mux->num_items++;
3275 }
3276 3265
3277 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX, 3266 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3278 "Mono Mux", spec->mono_nid); 3267 "Mono Mux", spec->mono_nid);
@@ -3397,11 +3386,8 @@ static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3397 if (!labels) 3386 if (!labels)
3398 labels = stac92xx_spdif_labels; 3387 labels = stac92xx_spdif_labels;
3399 3388
3400 for (i = 0; i < num_cons; i++) { 3389 for (i = 0; i < num_cons; i++)
3401 strcpy(spdif_mux->items[spdif_mux->num_items].label, labels[i]); 3390 snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
3402 spdif_mux->items[spdif_mux->num_items].index = i;
3403 spdif_mux->num_items++;
3404 }
3405 3391
3406 return 0; 3392 return 0;
3407} 3393}
@@ -3452,76 +3438,6 @@ static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
3452 return 1; 3438 return 1;
3453} 3439}
3454 3440
3455static const char *get_input_src_label(struct hda_codec *codec, hda_nid_t nid)
3456{
3457 unsigned int def_conf;
3458
3459 def_conf = snd_hda_codec_get_pincfg(codec, nid);
3460
3461 switch (get_defcfg_device(def_conf)) {
3462 case AC_JACK_MIC_IN:
3463 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_FIXED ||
3464 ((get_defcfg_location(def_conf) & 0xf0)
3465 == AC_JACK_LOC_INTERNAL))
3466 return "Internal Mic";
3467 if ((get_defcfg_location(def_conf) & 0xf0)
3468 == AC_JACK_LOC_SEPARATE)
3469 return "Dock Mic";
3470 if (get_defcfg_location(def_conf) == AC_JACK_LOC_REAR)
3471 return "Rear Mic";
3472 return "Mic";
3473 case AC_JACK_LINE_IN:
3474 if ((get_defcfg_location(def_conf) & 0xf0)
3475 == AC_JACK_LOC_SEPARATE)
3476 return "Dock Line";
3477 return "Line";
3478 case AC_JACK_AUX:
3479 return "Aux";
3480 case AC_JACK_CD:
3481 return "CD";
3482 case AC_JACK_SPDIF_IN:
3483 return "SPDIF In";
3484 case AC_JACK_DIG_OTHER_IN:
3485 return "Digital In";
3486 }
3487
3488 snd_printd("invalid inp pin %02x device config %08x", nid, def_conf);
3489 return NULL;
3490}
3491
3492static const char *get_unique_inp_src_label(struct hda_codec *codec,
3493 hda_nid_t nid)
3494{
3495 int i, n;
3496 const char *label;
3497 struct sigmatel_spec *spec = codec->spec;
3498 struct hda_input_mux *imux = &spec->private_imux;
3499 struct hda_input_mux *dimux = &spec->private_dimux;
3500 struct unique_input_names *unames = &spec->private_u_inp_names;
3501
3502 label = get_input_src_label(codec, nid);
3503 n = 0;
3504
3505 for (i = 0; i < imux->num_items; i++) {
3506 if (!strncmp(label, imux->items[i].label, strlen(label)))
3507 n++;
3508 }
3509 if (snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
3510 for (i = 0; i < dimux->num_items; i++) {
3511 if (!strncmp(label, dimux->items[i].label,
3512 strlen(label)))
3513 n++;
3514 }
3515 }
3516 if (n > 0 && unames->num < HDA_MAX_NUM_INPUTS) {
3517 sprintf(&unames->uname[unames->num][0], "%.28s %d", label, n);
3518 label = &unames->uname[unames->num][0];
3519 unames->num++;
3520 }
3521
3522 return label;
3523}
3524
3525/* create playback/capture controls for input pins on dmic capable codecs */ 3441/* create playback/capture controls for input pins on dmic capable codecs */
3526static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, 3442static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3527 const struct auto_pin_cfg *cfg) 3443 const struct auto_pin_cfg *cfg)
@@ -3532,13 +3448,11 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3532 int err, i; 3448 int err, i;
3533 unsigned int def_conf; 3449 unsigned int def_conf;
3534 3450
3535 strcpy(dimux->items[dimux->num_items].label, stac92xx_dmic_labels[0]); 3451 snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
3536 dimux->items[dimux->num_items].index = 0;
3537 dimux->num_items++;
3538 3452
3539 for (i = 0; i < spec->num_dmics; i++) { 3453 for (i = 0; i < spec->num_dmics; i++) {
3540 hda_nid_t nid; 3454 hda_nid_t nid;
3541 int index; 3455 int index, type_idx;
3542 const char *label; 3456 const char *label;
3543 3457
3544 nid = spec->dmic_nids[i]; 3458 nid = spec->dmic_nids[i];
@@ -3552,28 +3466,22 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3552 if (index < 0) 3466 if (index < 0)
3553 continue; 3467 continue;
3554 3468
3555 label = get_unique_inp_src_label(codec, nid); 3469 label = hda_get_input_pin_label(codec, nid, 1);
3556 if (label == NULL) 3470 snd_hda_add_imux_item(dimux, label, index, &type_idx);
3557 return -EINVAL;
3558 3471
3559 err = create_elem_capture_vol(codec, nid, label, 0, HDA_INPUT); 3472 err = create_elem_capture_vol(codec, nid, label, type_idx,
3473 HDA_INPUT);
3560 if (err < 0) 3474 if (err < 0)
3561 return err; 3475 return err;
3562 if (!err) { 3476 if (!err) {
3563 err = create_elem_capture_vol(codec, nid, label, 0, 3477 err = create_elem_capture_vol(codec, nid, label,
3564 HDA_OUTPUT); 3478 type_idx, HDA_OUTPUT);
3565 if (err < 0) 3479 if (err < 0)
3566 return err; 3480 return err;
3567 } 3481 }
3568 3482
3569 strcpy(dimux->items[dimux->num_items].label, label); 3483 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
3570 dimux->items[dimux->num_items].index = index; 3484 snd_hda_add_imux_item(imux, label, index, NULL);
3571 dimux->num_items++;
3572 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) {
3573 strcpy(imux->items[imux->num_items].label, label);
3574 imux->items[imux->num_items].index = index;
3575 imux->num_items++;
3576 }
3577 } 3485 }
3578 3486
3579 return 0; 3487 return 0;
@@ -3675,12 +3583,12 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const
3675{ 3583{
3676 struct sigmatel_spec *spec = codec->spec; 3584 struct sigmatel_spec *spec = codec->spec;
3677 struct hda_input_mux *imux = &spec->private_imux; 3585 struct hda_input_mux *imux = &spec->private_imux;
3678 int i, j, type_idx = 0; 3586 int i, j;
3679 const char *label; 3587 const char *label;
3680 3588
3681 for (i = 0; i < cfg->num_inputs; i++) { 3589 for (i = 0; i < cfg->num_inputs; i++) {
3682 hda_nid_t nid = cfg->inputs[i].pin; 3590 hda_nid_t nid = cfg->inputs[i].pin;
3683 int index, err; 3591 int index, err, type_idx;
3684 3592
3685 index = -1; 3593 index = -1;
3686 for (j = 0; j < spec->num_muxes; j++) { 3594 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
3692 if (index < 0) 3600 if (index < 0)
3693 continue; 3601 continue;
3694 3602
3695 if (i > 0 && cfg->inputs[i].type == cfg->inputs[i - 1].type) 3603 label = hda_get_autocfg_input_label(codec, cfg, i);
3696 type_idx++; 3604 snd_hda_add_imux_item(imux, label, index, &type_idx);
3697 else
3698 type_idx = 0;
3699
3700 label = get_unique_inp_src_label(codec, nid);
3701 if (label == NULL)
3702 return -EINVAL;
3703 3605
3704 err = create_elem_capture_vol(codec, nid, 3606 err = create_elem_capture_vol(codec, nid,
3705 label, type_idx, 3607 label, type_idx,
3706 HDA_INPUT); 3608 HDA_INPUT);
3707 if (err < 0) 3609 if (err < 0)
3708 return err; 3610 return err;
3709
3710 strcpy(imux->items[imux->num_items].label, label);
3711 imux->items[imux->num_items].index = index;
3712 imux->num_items++;
3713 } 3611 }
3714 spec->num_analog_muxes = imux->num_items; 3612 spec->num_analog_muxes = imux->num_items;
3715 3613
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)
2374 static const char *texts[] = { "OFF", "ON", NULL}; 2374 static const char *texts[] = { "OFF", "ON", NULL};
2375 2375
2376 /* for hp mode select */ 2376 /* for hp mode select */
2377 i = 0; 2377 for (i = 0; texts[i]; i++)
2378 while (texts[i] != NULL) { 2378 snd_hda_add_imux_item(imux, texts[i], i, NULL);
2379 strcpy(imux->items[imux->num_items].label, texts[i]);
2380 imux->items[imux->num_items].index = i;
2381 imux->num_items++;
2382 i++;
2383 }
2384 2379
2385 spec->hp_mux = &spec->private_imux[1]; 2380 spec->hp_mux = &spec->private_imux[1];
2386} 2381}
@@ -2412,26 +2407,25 @@ static int vt1708_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin)
2412} 2407}
2413 2408
2414/* create playback/capture controls for input pins */ 2409/* create playback/capture controls for input pins */
2415static int vt_auto_create_analog_input_ctls(struct via_spec *spec, 2410static int vt_auto_create_analog_input_ctls(struct hda_codec *codec,
2416 const struct auto_pin_cfg *cfg, 2411 const struct auto_pin_cfg *cfg,
2417 hda_nid_t cap_nid, 2412 hda_nid_t cap_nid,
2418 hda_nid_t pin_idxs[], int num_idxs) 2413 hda_nid_t pin_idxs[], int num_idxs)
2419{ 2414{
2415 struct via_spec *spec = codec->spec;
2420 struct hda_input_mux *imux = &spec->private_imux[0]; 2416 struct hda_input_mux *imux = &spec->private_imux[0];
2421 int i, err, idx, type, type_idx = 0; 2417 int i, err, idx, type, type_idx = 0;
2422 2418
2423 /* for internal loopback recording select */ 2419 /* for internal loopback recording select */
2424 for (idx = 0; idx < num_idxs; idx++) { 2420 for (idx = 0; idx < num_idxs; idx++) {
2425 if (pin_idxs[idx] == 0xff) { 2421 if (pin_idxs[idx] == 0xff) {
2426 strcpy(imux->items[imux->num_items].label, 2422 snd_hda_add_imux_item(imux, "Stereo Mixer", idx, NULL);
2427 "Stereo Mixer");
2428 imux->items[imux->num_items].index = idx;
2429 imux->num_items++;
2430 break; 2423 break;
2431 } 2424 }
2432 } 2425 }
2433 2426
2434 for (i = 0; i < cfg->num_inputs; i++) { 2427 for (i = 0; i < cfg->num_inputs; i++) {
2428 const char *label;
2435 type = cfg->inputs[i].type; 2429 type = cfg->inputs[i].type;
2436 for (idx = 0; idx < num_idxs; idx++) 2430 for (idx = 0; idx < num_idxs; idx++)
2437 if (pin_idxs[idx] == cfg->inputs[i].pin) 2431 if (pin_idxs[idx] == cfg->inputs[i].pin)
@@ -2442,24 +2436,21 @@ static int vt_auto_create_analog_input_ctls(struct via_spec *spec,
2442 type_idx++; 2436 type_idx++;
2443 else 2437 else
2444 type_idx = 0; 2438 type_idx = 0;
2445 err = via_new_analog_input(spec, auto_pin_cfg_labels[type], 2439 label = hda_get_autocfg_input_label(codec, cfg, i);
2446 type_idx, idx, cap_nid); 2440 err = via_new_analog_input(spec, label, type_idx, idx, cap_nid);
2447 if (err < 0) 2441 if (err < 0)
2448 return err; 2442 return err;
2449 snd_hda_get_input_pin_label(cfg, i, 2443 snd_hda_add_imux_item(imux, label, idx, NULL);
2450 imux->items[imux->num_items].label);
2451 imux->items[imux->num_items].index = idx;
2452 imux->num_items++;
2453 } 2444 }
2454 return 0; 2445 return 0;
2455} 2446}
2456 2447
2457/* create playback/capture controls for input pins */ 2448/* create playback/capture controls for input pins */
2458static int vt1708_auto_create_analog_input_ctls(struct via_spec *spec, 2449static int vt1708_auto_create_analog_input_ctls(struct hda_codec *codec,
2459 const struct auto_pin_cfg *cfg) 2450 const struct auto_pin_cfg *cfg)
2460{ 2451{
2461 static hda_nid_t pin_idxs[] = { 0xff, 0x24, 0x1d, 0x1e, 0x21 }; 2452 static hda_nid_t pin_idxs[] = { 0xff, 0x24, 0x1d, 0x1e, 0x21 };
2462 return vt_auto_create_analog_input_ctls(spec, cfg, 0x17, pin_idxs, 2453 return vt_auto_create_analog_input_ctls(codec, cfg, 0x17, pin_idxs,
2463 ARRAY_SIZE(pin_idxs)); 2454 ARRAY_SIZE(pin_idxs));
2464} 2455}
2465 2456
@@ -2559,7 +2550,7 @@ static int vt1708_parse_auto_config(struct hda_codec *codec)
2559 err = vt1708_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 2550 err = vt1708_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
2560 if (err < 0) 2551 if (err < 0)
2561 return err; 2552 return err;
2562 err = vt1708_auto_create_analog_input_ctls(spec, &spec->autocfg); 2553 err = vt1708_auto_create_analog_input_ctls(codec, &spec->autocfg);
2563 if (err < 0) 2554 if (err < 0)
2564 return err; 2555 return err;
2565 /* add jack detect on/off control */ 2556 /* 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)
3026} 3017}
3027 3018
3028/* create playback/capture controls for input pins */ 3019/* create playback/capture controls for input pins */
3029static int vt1709_auto_create_analog_input_ctls(struct via_spec *spec, 3020static int vt1709_auto_create_analog_input_ctls(struct hda_codec *codec,
3030 const struct auto_pin_cfg *cfg) 3021 const struct auto_pin_cfg *cfg)
3031{ 3022{
3032 static hda_nid_t pin_idxs[] = { 0xff, 0x23, 0x1d, 0x1e, 0x21 }; 3023 static hda_nid_t pin_idxs[] = { 0xff, 0x23, 0x1d, 0x1e, 0x21 };
3033 return vt_auto_create_analog_input_ctls(spec, cfg, 0x18, pin_idxs, 3024 return vt_auto_create_analog_input_ctls(codec, cfg, 0x18, pin_idxs,
3034 ARRAY_SIZE(pin_idxs)); 3025 ARRAY_SIZE(pin_idxs));
3035} 3026}
3036 3027
@@ -3054,7 +3045,7 @@ static int vt1709_parse_auto_config(struct hda_codec *codec)
3054 err = vt1709_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 3045 err = vt1709_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
3055 if (err < 0) 3046 if (err < 0)
3056 return err; 3047 return err;
3057 err = vt1709_auto_create_analog_input_ctls(spec, &spec->autocfg); 3048 err = vt1709_auto_create_analog_input_ctls(codec, &spec->autocfg);
3058 if (err < 0) 3049 if (err < 0)
3059 return err; 3050 return err;
3060 3051
@@ -3556,11 +3547,11 @@ static int vt1708B_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin)
3556} 3547}
3557 3548
3558/* create playback/capture controls for input pins */ 3549/* create playback/capture controls for input pins */
3559static int vt1708B_auto_create_analog_input_ctls(struct via_spec *spec, 3550static int vt1708B_auto_create_analog_input_ctls(struct hda_codec *codec,
3560 const struct auto_pin_cfg *cfg) 3551 const struct auto_pin_cfg *cfg)
3561{ 3552{
3562 static hda_nid_t pin_idxs[] = { 0xff, 0x1f, 0x1a, 0x1b, 0x1e }; 3553 static hda_nid_t pin_idxs[] = { 0xff, 0x1f, 0x1a, 0x1b, 0x1e };
3563 return vt_auto_create_analog_input_ctls(spec, cfg, 0x16, pin_idxs, 3554 return vt_auto_create_analog_input_ctls(codec, cfg, 0x16, pin_idxs,
3564 ARRAY_SIZE(pin_idxs)); 3555 ARRAY_SIZE(pin_idxs));
3565} 3556}
3566 3557
@@ -3584,7 +3575,7 @@ static int vt1708B_parse_auto_config(struct hda_codec *codec)
3584 err = vt1708B_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 3575 err = vt1708B_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
3585 if (err < 0) 3576 if (err < 0)
3586 return err; 3577 return err;
3587 err = vt1708B_auto_create_analog_input_ctls(spec, &spec->autocfg); 3578 err = vt1708B_auto_create_analog_input_ctls(codec, &spec->autocfg);
3588 if (err < 0) 3579 if (err < 0)
3589 return err; 3580 return err;
3590 3581
@@ -3992,11 +3983,11 @@ static int vt1708S_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin)
3992} 3983}
3993 3984
3994/* create playback/capture controls for input pins */ 3985/* create playback/capture controls for input pins */
3995static int vt1708S_auto_create_analog_input_ctls(struct via_spec *spec, 3986static int vt1708S_auto_create_analog_input_ctls(struct hda_codec *codec,
3996 const struct auto_pin_cfg *cfg) 3987 const struct auto_pin_cfg *cfg)
3997{ 3988{
3998 static hda_nid_t pin_idxs[] = { 0x1f, 0x1a, 0x1b, 0x1e, 0, 0xff }; 3989 static hda_nid_t pin_idxs[] = { 0x1f, 0x1a, 0x1b, 0x1e, 0, 0xff };
3999 return vt_auto_create_analog_input_ctls(spec, cfg, 0x16, pin_idxs, 3990 return vt_auto_create_analog_input_ctls(codec, cfg, 0x16, pin_idxs,
4000 ARRAY_SIZE(pin_idxs)); 3991 ARRAY_SIZE(pin_idxs));
4001} 3992}
4002 3993
@@ -4045,7 +4036,7 @@ static int vt1708S_parse_auto_config(struct hda_codec *codec)
4045 err = vt1708S_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 4036 err = vt1708S_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
4046 if (err < 0) 4037 if (err < 0)
4047 return err; 4038 return err;
4048 err = vt1708S_auto_create_analog_input_ctls(spec, &spec->autocfg); 4039 err = vt1708S_auto_create_analog_input_ctls(codec, &spec->autocfg);
4049 if (err < 0) 4040 if (err < 0)
4050 return err; 4041 return err;
4051 4042
@@ -4335,24 +4326,19 @@ static int vt1702_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin)
4335 imux = &spec->private_imux[1]; 4326 imux = &spec->private_imux[1];
4336 4327
4337 /* for hp mode select */ 4328 /* for hp mode select */
4338 i = 0; 4329 for (i = 0; texts[i]; i++)
4339 while (texts[i] != NULL) { 4330 snd_hda_add_imux_item(imux, texts[i], i, NULL);
4340 strcpy(imux->items[imux->num_items].label, texts[i]);
4341 imux->items[imux->num_items].index = i;
4342 imux->num_items++;
4343 i++;
4344 }
4345 4331
4346 spec->hp_mux = &spec->private_imux[1]; 4332 spec->hp_mux = &spec->private_imux[1];
4347 return 0; 4333 return 0;
4348} 4334}
4349 4335
4350/* create playback/capture controls for input pins */ 4336/* create playback/capture controls for input pins */
4351static int vt1702_auto_create_analog_input_ctls(struct via_spec *spec, 4337static int vt1702_auto_create_analog_input_ctls(struct hda_codec *codec,
4352 const struct auto_pin_cfg *cfg) 4338 const struct auto_pin_cfg *cfg)
4353{ 4339{
4354 static hda_nid_t pin_idxs[] = { 0x14, 0x15, 0x18, 0xff }; 4340 static hda_nid_t pin_idxs[] = { 0x14, 0x15, 0x18, 0xff };
4355 return vt_auto_create_analog_input_ctls(spec, cfg, 0x1a, pin_idxs, 4341 return vt_auto_create_analog_input_ctls(codec, cfg, 0x1a, pin_idxs,
4356 ARRAY_SIZE(pin_idxs)); 4342 ARRAY_SIZE(pin_idxs));
4357} 4343}
4358 4344
@@ -4382,7 +4368,7 @@ static int vt1702_parse_auto_config(struct hda_codec *codec)
4382 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | 4368 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4383 (0x5 << AC_AMPCAP_STEP_SIZE_SHIFT) | 4369 (0x5 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4384 (1 << AC_AMPCAP_MUTE_SHIFT)); 4370 (1 << AC_AMPCAP_MUTE_SHIFT));
4385 err = vt1702_auto_create_analog_input_ctls(spec, &spec->autocfg); 4371 err = vt1702_auto_create_analog_input_ctls(codec, &spec->autocfg);
4386 if (err < 0) 4372 if (err < 0)
4387 return err; 4373 return err;
4388 4374
@@ -4733,11 +4719,11 @@ static int vt1718S_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin)
4733} 4719}
4734 4720
4735/* create playback/capture controls for input pins */ 4721/* create playback/capture controls for input pins */
4736static int vt1718S_auto_create_analog_input_ctls(struct via_spec *spec, 4722static int vt1718S_auto_create_analog_input_ctls(struct hda_codec *codec,
4737 const struct auto_pin_cfg *cfg) 4723 const struct auto_pin_cfg *cfg)
4738{ 4724{
4739 static hda_nid_t pin_idxs[] = { 0x2c, 0x2b, 0x2a, 0x29, 0, 0xff }; 4725 static hda_nid_t pin_idxs[] = { 0x2c, 0x2b, 0x2a, 0x29, 0, 0xff };
4740 return vt_auto_create_analog_input_ctls(spec, cfg, 0x21, pin_idxs, 4726 return vt_auto_create_analog_input_ctls(codec, cfg, 0x21, pin_idxs,
4741 ARRAY_SIZE(pin_idxs)); 4727 ARRAY_SIZE(pin_idxs));
4742} 4728}
4743 4729
@@ -4762,7 +4748,7 @@ static int vt1718S_parse_auto_config(struct hda_codec *codec)
4762 err = vt1718S_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 4748 err = vt1718S_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
4763 if (err < 0) 4749 if (err < 0)
4764 return err; 4750 return err;
4765 err = vt1718S_auto_create_analog_input_ctls(spec, &spec->autocfg); 4751 err = vt1718S_auto_create_analog_input_ctls(codec, &spec->autocfg);
4766 if (err < 0) 4752 if (err < 0)
4767 return err; 4753 return err;
4768 4754
@@ -5195,11 +5181,11 @@ static int vt1716S_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin)
5195} 5181}
5196 5182
5197/* create playback/capture controls for input pins */ 5183/* create playback/capture controls for input pins */
5198static int vt1716S_auto_create_analog_input_ctls(struct via_spec *spec, 5184static int vt1716S_auto_create_analog_input_ctls(struct hda_codec *codec,
5199 const struct auto_pin_cfg *cfg) 5185 const struct auto_pin_cfg *cfg)
5200{ 5186{
5201 static hda_nid_t pin_idxs[] = { 0x1f, 0x1a, 0x1b, 0x1e, 0, 0xff }; 5187 static hda_nid_t pin_idxs[] = { 0x1f, 0x1a, 0x1b, 0x1e, 0, 0xff };
5202 return vt_auto_create_analog_input_ctls(spec, cfg, 0x16, pin_idxs, 5188 return vt_auto_create_analog_input_ctls(codec, cfg, 0x16, pin_idxs,
5203 ARRAY_SIZE(pin_idxs)); 5189 ARRAY_SIZE(pin_idxs));
5204} 5190}
5205 5191
@@ -5223,7 +5209,7 @@ static int vt1716S_parse_auto_config(struct hda_codec *codec)
5223 err = vt1716S_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 5209 err = vt1716S_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
5224 if (err < 0) 5210 if (err < 0)
5225 return err; 5211 return err;
5226 err = vt1716S_auto_create_analog_input_ctls(spec, &spec->autocfg); 5212 err = vt1716S_auto_create_analog_input_ctls(codec, &spec->autocfg);
5227 if (err < 0) 5213 if (err < 0)
5228 return err; 5214 return err;
5229 5215
@@ -5504,14 +5490,15 @@ static int vt2002P_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin)
5504} 5490}
5505 5491
5506/* create playback/capture controls for input pins */ 5492/* create playback/capture controls for input pins */
5507static int vt2002P_auto_create_analog_input_ctls(struct via_spec *spec, 5493static int vt2002P_auto_create_analog_input_ctls(struct hda_codec *codec,
5508 const struct auto_pin_cfg *cfg) 5494 const struct auto_pin_cfg *cfg)
5509{ 5495{
5496 struct via_spec *spec = codec->spec;
5510 struct hda_input_mux *imux = &spec->private_imux[0]; 5497 struct hda_input_mux *imux = &spec->private_imux[0];
5511 static hda_nid_t pin_idxs[] = { 0x2b, 0x2a, 0x29, 0xff }; 5498 static hda_nid_t pin_idxs[] = { 0x2b, 0x2a, 0x29, 0xff };
5512 int err; 5499 int err;
5513 5500
5514 err = vt_auto_create_analog_input_ctls(spec, cfg, 0x21, pin_idxs, 5501 err = vt_auto_create_analog_input_ctls(codec, cfg, 0x21, pin_idxs,
5515 ARRAY_SIZE(pin_idxs)); 5502 ARRAY_SIZE(pin_idxs));
5516 if (err < 0) 5503 if (err < 0)
5517 return err; 5504 return err;
@@ -5521,9 +5508,7 @@ static int vt2002P_auto_create_analog_input_ctls(struct via_spec *spec,
5521 return err; 5508 return err;
5522 5509
5523 /* for digital mic select */ 5510 /* for digital mic select */
5524 strcpy(imux->items[imux->num_items].label, "Digital Mic"); 5511 snd_hda_add_imux_item(imux, "Digital Mic", 4, NULL);
5525 imux->items[imux->num_items].index = 4;
5526 imux->num_items++;
5527 5512
5528 return 0; 5513 return 0;
5529} 5514}
@@ -5551,7 +5536,7 @@ static int vt2002P_parse_auto_config(struct hda_codec *codec)
5551 err = vt2002P_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 5536 err = vt2002P_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
5552 if (err < 0) 5537 if (err < 0)
5553 return err; 5538 return err;
5554 err = vt2002P_auto_create_analog_input_ctls(spec, &spec->autocfg); 5539 err = vt2002P_auto_create_analog_input_ctls(codec, &spec->autocfg);
5555 if (err < 0) 5540 if (err < 0)
5556 return err; 5541 return err;
5557 5542
@@ -5826,14 +5811,15 @@ static int vt1812_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin)
5826} 5811}
5827 5812
5828/* create playback/capture controls for input pins */ 5813/* create playback/capture controls for input pins */
5829static int vt1812_auto_create_analog_input_ctls(struct via_spec *spec, 5814static int vt1812_auto_create_analog_input_ctls(struct hda_codec *codec,
5830 const struct auto_pin_cfg *cfg) 5815 const struct auto_pin_cfg *cfg)
5831{ 5816{
5817 struct via_spec *spec = codec->spec;
5832 struct hda_input_mux *imux = &spec->private_imux[0]; 5818 struct hda_input_mux *imux = &spec->private_imux[0];
5833 static hda_nid_t pin_idxs[] = { 0x2b, 0x2a, 0x29, 0, 0, 0xff }; 5819 static hda_nid_t pin_idxs[] = { 0x2b, 0x2a, 0x29, 0, 0, 0xff };
5834 int err; 5820 int err;
5835 5821
5836 err = vt_auto_create_analog_input_ctls(spec, cfg, 0x21, pin_idxs, 5822 err = vt_auto_create_analog_input_ctls(codec, cfg, 0x21, pin_idxs,
5837 ARRAY_SIZE(pin_idxs)); 5823 ARRAY_SIZE(pin_idxs));
5838 if (err < 0) 5824 if (err < 0)
5839 return err; 5825 return err;
@@ -5844,9 +5830,7 @@ static int vt1812_auto_create_analog_input_ctls(struct via_spec *spec,
5844 return err; 5830 return err;
5845 5831
5846 /* for digital mic select */ 5832 /* for digital mic select */
5847 strcpy(imux->items[imux->num_items].label, "Digital Mic"); 5833 snd_hda_add_imux_item(imux, "Digital Mic", 6, NULL);
5848 imux->items[imux->num_items].index = 6;
5849 imux->num_items++;
5850 5834
5851 return 0; 5835 return 0;
5852} 5836}
@@ -5874,7 +5858,7 @@ static int vt1812_parse_auto_config(struct hda_codec *codec)
5874 err = vt1812_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 5858 err = vt1812_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
5875 if (err < 0) 5859 if (err < 0)
5876 return err; 5860 return err;
5877 err = vt1812_auto_create_analog_input_ctls(spec, &spec->autocfg); 5861 err = vt1812_auto_create_analog_input_ctls(codec, &spec->autocfg);
5878 if (err < 0) 5862 if (err < 0)
5879 return err; 5863 return err;
5880 5864