aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_realtek.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2009-08-25 07:10:18 -0400
committerTakashi Iwai <tiwai@suse.de>2009-08-25 07:10:18 -0400
commit05f5f477082f0b192dab5ac25ccc5d468d98ecbd (patch)
treeffd1f8b8d28af8e92ee81b1f4db1ba5c1b2d14ce /sound/pci/hda/patch_realtek.c
parent9d0b71b1cf7b7ff856d200841de3f3d7c64eb170 (diff)
ALSA: hda - Generalize input pin parsing in patch_realtek.c
Provide a standard parser for input pins to create the input mixer and input source controls instead of having a difference one for each Realtek codec. The new helper parses the codec connections dynamically isntead of fixed indicies. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/patch_realtek.c')
-rw-r--r--sound/pci/hda/patch_realtek.c356
1 files changed, 134 insertions, 222 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index dd25db936773..3c8773a7ac91 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -4311,8 +4311,6 @@ static int add_control(struct alc_spec *spec, int type, const char *name,
4311#define alc880_fixed_pin_idx(nid) ((nid) - 0x14) 4311#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4312#define alc880_is_multi_pin(nid) ((nid) >= 0x18) 4312#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4313#define alc880_multi_pin_idx(nid) ((nid) - 0x18) 4313#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4314#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4315#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4316#define alc880_idx_to_dac(nid) ((nid) + 0x02) 4314#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4317#define alc880_dac_to_idx(nid) ((nid) - 0x02) 4315#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4318#define alc880_idx_to_mixer(nid) ((nid) + 0x0c) 4316#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
@@ -4480,31 +4478,61 @@ static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4480 return 0; 4478 return 0;
4481} 4479}
4482 4480
4481static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
4482{
4483 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4484 return (pincap & AC_PINCAP_IN) != 0;
4485}
4486
4483/* create playback/capture controls for input pins */ 4487/* create playback/capture controls for input pins */
4484static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, 4488static int alc_auto_create_input_ctls(struct hda_codec *codec,
4485 const struct auto_pin_cfg *cfg) 4489 const struct auto_pin_cfg *cfg,
4490 hda_nid_t mixer,
4491 hda_nid_t cap1, hda_nid_t cap2)
4486{ 4492{
4493 struct alc_spec *spec = codec->spec;
4487 struct hda_input_mux *imux = &spec->private_imux[0]; 4494 struct hda_input_mux *imux = &spec->private_imux[0];
4488 int i, err, idx; 4495 int i, err, idx;
4489 4496
4490 for (i = 0; i < AUTO_PIN_LAST; i++) { 4497 for (i = 0; i < AUTO_PIN_LAST; i++) {
4491 if (alc880_is_input_pin(cfg->input_pins[i])) { 4498 hda_nid_t pin;
4492 idx = alc880_input_pin_idx(cfg->input_pins[i]); 4499
4493 err = new_analog_input(spec, cfg->input_pins[i], 4500 pin = cfg->input_pins[i];
4494 auto_pin_cfg_labels[i], 4501 if (!alc_is_input_pin(codec, pin))
4495 idx, 0x0b); 4502 continue;
4496 if (err < 0) 4503
4497 return err; 4504 if (mixer) {
4505 idx = get_connection_index(codec, mixer, pin);
4506 if (idx >= 0) {
4507 err = new_analog_input(spec, pin,
4508 auto_pin_cfg_labels[i],
4509 idx, mixer);
4510 if (err < 0)
4511 return err;
4512 }
4513 }
4514
4515 if (!cap1)
4516 continue;
4517 idx = get_connection_index(codec, cap1, pin);
4518 if (idx < 0 && cap2)
4519 idx = get_connection_index(codec, cap2, pin);
4520 if (idx >= 0) {
4498 imux->items[imux->num_items].label = 4521 imux->items[imux->num_items].label =
4499 auto_pin_cfg_labels[i]; 4522 auto_pin_cfg_labels[i];
4500 imux->items[imux->num_items].index = 4523 imux->items[imux->num_items].index = idx;
4501 alc880_input_pin_idx(cfg->input_pins[i]);
4502 imux->num_items++; 4524 imux->num_items++;
4503 } 4525 }
4504 } 4526 }
4505 return 0; 4527 return 0;
4506} 4528}
4507 4529
4530static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4531 const struct auto_pin_cfg *cfg)
4532{
4533 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4534}
4535
4508static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, 4536static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4509 unsigned int pin_type) 4537 unsigned int pin_type)
4510{ 4538{
@@ -4570,7 +4598,7 @@ static void alc880_auto_init_analog_input(struct hda_codec *codec)
4570 4598
4571 for (i = 0; i < AUTO_PIN_LAST; i++) { 4599 for (i = 0; i < AUTO_PIN_LAST; i++) {
4572 hda_nid_t nid = spec->autocfg.input_pins[i]; 4600 hda_nid_t nid = spec->autocfg.input_pins[i];
4573 if (alc880_is_input_pin(nid)) { 4601 if (alc_is_input_pin(codec, nid)) {
4574 alc_set_input_pin(codec, nid, i); 4602 alc_set_input_pin(codec, nid, i);
4575 if (nid != ALC880_PIN_CD_NID && 4603 if (nid != ALC880_PIN_CD_NID &&
4576 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) 4604 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
@@ -4613,7 +4641,7 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
4613 "Headphone"); 4641 "Headphone");
4614 if (err < 0) 4642 if (err < 0)
4615 return err; 4643 return err;
4616 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); 4644 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
4617 if (err < 0) 4645 if (err < 0)
4618 return err; 4646 return err;
4619 4647
@@ -6006,39 +6034,10 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6006} 6034}
6007 6035
6008/* create playback/capture controls for input pins */ 6036/* create playback/capture controls for input pins */
6009static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, 6037static int alc260_auto_create_input_ctls(struct hda_codec *codec,
6010 const struct auto_pin_cfg *cfg) 6038 const struct auto_pin_cfg *cfg)
6011{ 6039{
6012 struct hda_input_mux *imux = &spec->private_imux[0]; 6040 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
6013 int i, err, idx;
6014
6015 for (i = 0; i < AUTO_PIN_LAST; i++) {
6016 if (cfg->input_pins[i] >= 0x12) {
6017 idx = cfg->input_pins[i] - 0x12;
6018 err = new_analog_input(spec, cfg->input_pins[i],
6019 auto_pin_cfg_labels[i], idx,
6020 0x07);
6021 if (err < 0)
6022 return err;
6023 imux->items[imux->num_items].label =
6024 auto_pin_cfg_labels[i];
6025 imux->items[imux->num_items].index = idx;
6026 imux->num_items++;
6027 }
6028 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
6029 idx = cfg->input_pins[i] - 0x09;
6030 err = new_analog_input(spec, cfg->input_pins[i],
6031 auto_pin_cfg_labels[i], idx,
6032 0x07);
6033 if (err < 0)
6034 return err;
6035 imux->items[imux->num_items].label =
6036 auto_pin_cfg_labels[i];
6037 imux->items[imux->num_items].index = idx;
6038 imux->num_items++;
6039 }
6040 }
6041 return 0;
6042} 6041}
6043 6042
6044static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, 6043static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
@@ -6152,7 +6151,7 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
6152 return err; 6151 return err;
6153 if (!spec->kctls.list) 6152 if (!spec->kctls.list)
6154 return 0; /* can't find valid BIOS pin config */ 6153 return 0; /* can't find valid BIOS pin config */
6155 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg); 6154 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
6156 if (err < 0) 6155 if (err < 0)
6157 return err; 6156 return err;
6158 6157
@@ -9464,6 +9463,12 @@ static struct snd_pci_quirk alc882_pinfix_tbl[] = {
9464/* 9463/*
9465 * BIOS auto configuration 9464 * BIOS auto configuration
9466 */ 9465 */
9466static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9467 const struct auto_pin_cfg *cfg)
9468{
9469 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9470}
9471
9467static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, 9472static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
9468 hda_nid_t nid, int pin_type, 9473 hda_nid_t nid, int pin_type,
9469 int dac_idx) 9474 int dac_idx)
@@ -9604,44 +9609,73 @@ static int alc_auto_add_mic_boost(struct hda_codec *codec)
9604static int alc882_parse_auto_config(struct hda_codec *codec) 9609static int alc882_parse_auto_config(struct hda_codec *codec)
9605{ 9610{
9606 struct alc_spec *spec = codec->spec; 9611 struct alc_spec *spec = codec->spec;
9607 struct auto_pin_cfg *autocfg = &spec->autocfg; 9612 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
9608 unsigned int wcap; 9613 int i, err;
9609 int i;
9610 int err = alc880_parse_auto_config(codec);
9611 9614
9615 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9616 alc882_ignore);
9612 if (err < 0) 9617 if (err < 0)
9613 return err; 9618 return err;
9614 else if (!err) 9619 if (!spec->autocfg.line_outs)
9615 return 0; /* no config found */ 9620 return 0; /* can't find valid BIOS pin config */
9616 9621
9617 err = alc_auto_add_mic_boost(codec); 9622 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
9623 if (err < 0)
9624 return err;
9625 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
9626 if (err < 0)
9627 return err;
9628 err = alc880_auto_create_extra_out(spec,
9629 spec->autocfg.speaker_pins[0],
9630 "Speaker");
9631 if (err < 0)
9632 return err;
9633 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
9634 "Headphone");
9635 if (err < 0)
9636 return err;
9637 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
9618 if (err < 0) 9638 if (err < 0)
9619 return err; 9639 return err;
9620 9640
9621 /* hack - override the init verbs */ 9641 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9622 spec->init_verbs[0] = alc883_auto_init_verbs; 9642
9643 /* check multiple SPDIF-out (for recent codecs) */
9644 for (i = 0; i < spec->autocfg.dig_outs; i++) {
9645 hda_nid_t dig_nid;
9646 err = snd_hda_get_connections(codec,
9647 spec->autocfg.dig_out_pins[i],
9648 &dig_nid, 1);
9649 if (err < 0)
9650 continue;
9651 if (!i)
9652 spec->multiout.dig_out_nid = dig_nid;
9653 else {
9654 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
9655 spec->slave_dig_outs[i - 1] = dig_nid;
9656 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
9657 break;
9658 }
9659 }
9660 if (spec->autocfg.dig_in_pin)
9661 spec->dig_in_nid = ALC880_DIGIN_NID;
9662
9663 if (spec->kctls.list)
9664 add_mixer(spec, spec->kctls.list);
9665
9666 add_verb(spec, alc883_auto_init_verbs);
9623 /* if ADC 0x07 is available, initialize it, too */ 9667 /* if ADC 0x07 is available, initialize it, too */
9624 wcap = get_wcaps(codec, 0x07); 9668 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
9625 wcap = get_wcaps_type(wcap);
9626 if (wcap == AC_WID_AUD_IN)
9627 add_verb(spec, alc882_adc1_init_verbs); 9669 add_verb(spec, alc882_adc1_init_verbs);
9628 9670
9629 /* digital-mic input pin is excluded in alc880_auto_create..() 9671 spec->num_mux_defs = 1;
9630 * because it's under 0x18 9672 spec->input_mux = &spec->private_imux[0];
9631 */ 9673
9632 if (autocfg->input_pins[AUTO_PIN_MIC] == 0x12 || 9674 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
9633 autocfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) { 9675
9634 struct hda_input_mux *imux = &spec->private_imux[0]; 9676 err = alc_auto_add_mic_boost(codec);
9635 for (i = 1; i < 3; i++) 9677 if (err < 0)
9636 memcpy(&spec->private_imux[i], 9678 return err;
9637 &spec->private_imux[0],
9638 sizeof(spec->private_imux[0]));
9639 imux->items[imux->num_items].label = "Int DMic";
9640 imux->items[imux->num_items].index = 0x0b;
9641 imux->num_items++;
9642 spec->num_mux_defs = 3;
9643 spec->input_mux = spec->private_imux;
9644 }
9645 9679
9646 return 1; /* config found */ 9680 return 1; /* config found */
9647} 9681}
@@ -10820,27 +10854,8 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10820 return 0; 10854 return 0;
10821} 10855}
10822 10856
10823static int alc262_auto_create_analog_input_ctls(struct alc_spec *spec, 10857#define alc262_auto_create_input_ctls \
10824 const struct auto_pin_cfg *cfg) 10858 alc880_auto_create_input_ctls
10825{
10826 int err;
10827
10828 err = alc880_auto_create_analog_input_ctls(spec, cfg);
10829 if (err < 0)
10830 return err;
10831 /* digital-mic input pin is excluded in alc880_auto_create..()
10832 * because it's under 0x18
10833 */
10834 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
10835 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
10836 struct hda_input_mux *imux = &spec->private_imux[0];
10837 imux->items[imux->num_items].label = "Int Mic";
10838 imux->items[imux->num_items].index = 0x09;
10839 imux->num_items++;
10840 }
10841 return 0;
10842}
10843
10844 10859
10845/* 10860/*
10846 * generic initialization of ADC, input mixers and output mixers 10861 * generic initialization of ADC, input mixers and output mixers
@@ -11158,7 +11173,7 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
11158 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); 11173 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11159 if (err < 0) 11174 if (err < 0)
11160 return err; 11175 return err;
11161 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg); 11176 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
11162 if (err < 0) 11177 if (err < 0)
11163 return err; 11178 return err;
11164 11179
@@ -12212,46 +12227,10 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12212} 12227}
12213 12228
12214/* create playback/capture controls for input pins */ 12229/* create playback/capture controls for input pins */
12215static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec, 12230static int alc268_auto_create_input_ctls(struct hda_codec *codec,
12216 const struct auto_pin_cfg *cfg) 12231 const struct auto_pin_cfg *cfg)
12217{ 12232{
12218 struct hda_input_mux *imux = &spec->private_imux[0]; 12233 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
12219 int i, idx1, dmic_nid;
12220
12221 dmic_nid = 0x12;
12222 while (dmic_nid <= 0x13) {
12223 for (i = 0; i < AUTO_PIN_LAST; i++) {
12224 switch (cfg->input_pins[i]) {
12225 case 0x18:
12226 idx1 = 0; /* Mic 1 */
12227 break;
12228 case 0x19:
12229 idx1 = 1; /* Mic 2 */
12230 break;
12231 case 0x1a:
12232 idx1 = 2; /* Line In */
12233 break;
12234 case 0x1c:
12235 idx1 = 3; /* CD */
12236 break;
12237 case 0x12:
12238 case 0x13:
12239 if (cfg->input_pins[i] != dmic_nid)
12240 continue;
12241 idx1 = 6; /* digital mics */
12242 break;
12243 default:
12244 continue;
12245 }
12246 imux->items[imux->num_items].label =
12247 auto_pin_cfg_labels[i];
12248 imux->items[imux->num_items].index = idx1;
12249 imux->num_items++;
12250 }
12251 imux++;
12252 dmic_nid++;
12253 }
12254 return 0;
12255} 12234}
12256 12235
12257static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) 12236static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
@@ -12328,7 +12307,7 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
12328 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); 12307 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12329 if (err < 0) 12308 if (err < 0)
12330 return err; 12309 return err;
12331 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg); 12310 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
12332 if (err < 0) 12311 if (err < 0)
12333 return err; 12312 return err;
12334 12313
@@ -13088,8 +13067,8 @@ static struct hda_verb alc269_init_verbs[] = {
13088 13067
13089#define alc269_auto_create_multi_out_ctls \ 13068#define alc269_auto_create_multi_out_ctls \
13090 alc268_auto_create_multi_out_ctls 13069 alc268_auto_create_multi_out_ctls
13091#define alc269_auto_create_analog_input_ctls \ 13070#define alc269_auto_create_input_ctls \
13092 alc262_auto_create_analog_input_ctls 13071 alc268_auto_create_input_ctls
13093 13072
13094#ifdef CONFIG_SND_HDA_POWER_SAVE 13073#ifdef CONFIG_SND_HDA_POWER_SAVE
13095#define alc269_loopbacks alc880_loopbacks 13074#define alc269_loopbacks alc880_loopbacks
@@ -13139,7 +13118,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
13139 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg); 13118 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13140 if (err < 0) 13119 if (err < 0)
13141 return err; 13120 return err;
13142 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg); 13121 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
13143 if (err < 0) 13122 if (err < 0)
13144 return err; 13123 return err;
13145 13124
@@ -14120,49 +14099,10 @@ static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
14120} 14099}
14121 14100
14122/* create playback/capture controls for input pins */ 14101/* create playback/capture controls for input pins */
14123static int alc861_auto_create_analog_input_ctls(struct hda_codec *codec, 14102static int alc861_auto_create_input_ctls(struct hda_codec *codec,
14124 const struct auto_pin_cfg *cfg) 14103 const struct auto_pin_cfg *cfg)
14125{ 14104{
14126 struct alc_spec *spec = codec->spec; 14105 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
14127 struct hda_input_mux *imux = &spec->private_imux[0];
14128 int i, err, idx, idx1;
14129
14130 for (i = 0; i < AUTO_PIN_LAST; i++) {
14131 switch (cfg->input_pins[i]) {
14132 case 0x0c:
14133 idx1 = 1;
14134 idx = 2; /* Line In */
14135 break;
14136 case 0x0f:
14137 idx1 = 2;
14138 idx = 2; /* Line In */
14139 break;
14140 case 0x0d:
14141 idx1 = 0;
14142 idx = 1; /* Mic In */
14143 break;
14144 case 0x10:
14145 idx1 = 3;
14146 idx = 1; /* Mic In */
14147 break;
14148 case 0x11:
14149 idx1 = 4;
14150 idx = 0; /* CD */
14151 break;
14152 default:
14153 continue;
14154 }
14155
14156 err = new_analog_input(spec, cfg->input_pins[i],
14157 auto_pin_cfg_labels[i], idx, 0x15);
14158 if (err < 0)
14159 return err;
14160
14161 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
14162 imux->items[imux->num_items].index = idx1;
14163 imux->num_items++;
14164 }
14165 return 0;
14166} 14106}
14167 14107
14168static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, 14108static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
@@ -14259,7 +14199,7 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
14259 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]); 14199 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
14260 if (err < 0) 14200 if (err < 0)
14261 return err; 14201 return err;
14262 err = alc861_auto_create_analog_input_ctls(codec, &spec->autocfg); 14202 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
14263 if (err < 0) 14203 if (err < 0)
14264 return err; 14204 return err;
14265 14205
@@ -15140,6 +15080,13 @@ static struct alc_config_preset alc861vd_presets[] = {
15140/* 15080/*
15141 * BIOS auto configuration 15081 * BIOS auto configuration
15142 */ 15082 */
15083static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15084 const struct auto_pin_cfg *cfg)
15085{
15086 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
15087}
15088
15089
15143static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, 15090static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15144 hda_nid_t nid, int pin_type, int dac_idx) 15091 hda_nid_t nid, int pin_type, int dac_idx)
15145{ 15092{
@@ -15174,7 +15121,6 @@ static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15174 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 15121 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
15175} 15122}
15176 15123
15177#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15178#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID 15124#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15179 15125
15180static void alc861vd_auto_init_analog_input(struct hda_codec *codec) 15126static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
@@ -15184,7 +15130,7 @@ static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15184 15130
15185 for (i = 0; i < AUTO_PIN_LAST; i++) { 15131 for (i = 0; i < AUTO_PIN_LAST; i++) {
15186 hda_nid_t nid = spec->autocfg.input_pins[i]; 15132 hda_nid_t nid = spec->autocfg.input_pins[i];
15187 if (alc861vd_is_input_pin(nid)) { 15133 if (alc_is_input_pin(codec, nid)) {
15188 alc_set_input_pin(codec, nid, i); 15134 alc_set_input_pin(codec, nid, i);
15189 if (nid != ALC861VD_PIN_CD_NID && 15135 if (nid != ALC861VD_PIN_CD_NID &&
15190 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) 15136 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
@@ -15347,7 +15293,7 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
15347 "Headphone"); 15293 "Headphone");
15348 if (err < 0) 15294 if (err < 0)
15349 return err; 15295 return err;
15350 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); 15296 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
15351 if (err < 0) 15297 if (err < 0)
15352 return err; 15298 return err;
15353 15299
@@ -17089,43 +17035,9 @@ static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17089 return 0; 17035 return 0;
17090} 17036}
17091 17037
17092static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
17093{
17094 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
17095 return (pincap & AC_PINCAP_IN) != 0;
17096}
17097
17098/* create playback/capture controls for input pins */ 17038/* create playback/capture controls for input pins */
17099static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec, 17039#define alc662_auto_create_input_ctls \
17100 const struct auto_pin_cfg *cfg) 17040 alc880_auto_create_input_ctls
17101{
17102 struct alc_spec *spec = codec->spec;
17103 struct hda_input_mux *imux = &spec->private_imux[0];
17104 int i, err, idx;
17105
17106 for (i = 0; i < AUTO_PIN_LAST; i++) {
17107 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
17108 idx = get_connection_index(codec, 0x0b,
17109 cfg->input_pins[i]);
17110 if (idx >= 0) {
17111 err = new_analog_input(spec, cfg->input_pins[i],
17112 auto_pin_cfg_labels[i],
17113 idx, 0x0b);
17114 if (err < 0)
17115 return err;
17116 }
17117 idx = get_connection_index(codec, 0x22,
17118 cfg->input_pins[i]);
17119 if (idx >= 0) {
17120 imux->items[imux->num_items].label =
17121 auto_pin_cfg_labels[i];
17122 imux->items[imux->num_items].index = idx;
17123 imux->num_items++;
17124 }
17125 }
17126 }
17127 return 0;
17128}
17129 17041
17130static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, 17042static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17131 hda_nid_t nid, int pin_type, 17043 hda_nid_t nid, int pin_type,
@@ -17179,7 +17091,7 @@ static void alc662_auto_init_analog_input(struct hda_codec *codec)
17179 17091
17180 for (i = 0; i < AUTO_PIN_LAST; i++) { 17092 for (i = 0; i < AUTO_PIN_LAST; i++) {
17181 hda_nid_t nid = spec->autocfg.input_pins[i]; 17093 hda_nid_t nid = spec->autocfg.input_pins[i];
17182 if (alc662_is_input_pin(codec, nid)) { 17094 if (alc_is_input_pin(codec, nid)) {
17183 alc_set_input_pin(codec, nid, i); 17095 alc_set_input_pin(codec, nid, i);
17184 if (nid != ALC662_PIN_CD_NID && 17096 if (nid != ALC662_PIN_CD_NID &&
17185 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) 17097 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
@@ -17220,7 +17132,7 @@ static int alc662_parse_auto_config(struct hda_codec *codec)
17220 "Headphone"); 17132 "Headphone");
17221 if (err < 0) 17133 if (err < 0)
17222 return err; 17134 return err;
17223 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg); 17135 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
17224 if (err < 0) 17136 if (err < 0)
17225 return err; 17137 return err;
17226 17138