aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2011-07-06 09:12:46 -0400
committerTakashi Iwai <tiwai@suse.de>2011-07-07 03:31:21 -0400
commitb78217096bcf60f2248fe2a5449a7e4f7fb29105 (patch)
treec8658c273b98657ec5081b19a8b58a2985c14542 /sound/pci
parent343a04be376a3733514e4eca7a8c8adb2493ea23 (diff)
ALSA: hda - Parse ADCs in alc_auto_create_input_ctls()
Parse ADCs and cap-srcs in alc_auto_create_input_ctls() by itself instead of passing explicitly from the caller. By this change, all alc*_auto_create_input_ctls() can be unified to the same calls. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/patch_realtek.c141
1 files changed, 67 insertions, 74 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index a0ed9e524d84..45532eb37cba 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -5381,17 +5381,63 @@ static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
5381 return (pincap & AC_PINCAP_IN) != 0; 5381 return (pincap & AC_PINCAP_IN) != 0;
5382} 5382}
5383 5383
5384static int alc_auto_fill_adc_caps(struct hda_codec *codec, hda_nid_t *adc_nids,
5385 hda_nid_t *cap_nids, int max_nums)
5386{
5387 hda_nid_t nid;
5388 int i, nums = 0;
5389
5390 nid = codec->start_nid;
5391 for (i = 0; i < codec->num_nodes; i++, nid++) {
5392 hda_nid_t src;
5393 const hda_nid_t *list;
5394 unsigned int caps = get_wcaps(codec, nid);
5395 int type = get_wcaps_type(caps);
5396
5397 if (type != AC_WID_AUD_IN || (caps & AC_WCAP_DIGITAL))
5398 continue;
5399 adc_nids[nums] = nid;
5400 cap_nids[nums] = nid;
5401 src = nid;
5402 for (;;) {
5403 int n;
5404 type = get_wcaps_type(get_wcaps(codec, src));
5405 if (type == AC_WID_PIN)
5406 break;
5407 if (type == AC_WID_AUD_SEL) {
5408 cap_nids[nums] = src;
5409 break;
5410 }
5411 n = snd_hda_get_conn_list(codec, src, &list);
5412 if (n > 1) {
5413 cap_nids[nums] = src;
5414 break;
5415 } else if (n != 1)
5416 break;
5417 src = *list;
5418 }
5419 if (++nums >= max_nums)
5420 break;
5421 }
5422 return nums;
5423}
5424
5384/* create playback/capture controls for input pins */ 5425/* create playback/capture controls for input pins */
5385static int alc_auto_create_input_ctls(struct hda_codec *codec, 5426static int alc_auto_create_input_ctls(struct hda_codec *codec)
5386 const struct auto_pin_cfg *cfg,
5387 hda_nid_t mixer,
5388 hda_nid_t cap1, hda_nid_t cap2)
5389{ 5427{
5390 struct alc_spec *spec = codec->spec; 5428 struct alc_spec *spec = codec->spec;
5429 const struct auto_pin_cfg *cfg = &spec->autocfg;
5430 hda_nid_t mixer = spec->mixer_nid;
5391 struct hda_input_mux *imux = &spec->private_imux[0]; 5431 struct hda_input_mux *imux = &spec->private_imux[0];
5392 int i, err, idx, type_idx = 0; 5432 int num_adcs;
5433 hda_nid_t caps[5], adcs[5];
5434 int i, c, err, idx, type_idx = 0;
5393 const char *prev_label = NULL; 5435 const char *prev_label = NULL;
5394 5436
5437 num_adcs = alc_auto_fill_adc_caps(codec, adcs, caps, ARRAY_SIZE(adcs));
5438 if (num_adcs < 0)
5439 return 0;
5440
5395 for (i = 0; i < cfg->num_inputs; i++) { 5441 for (i = 0; i < cfg->num_inputs; i++) {
5396 hda_nid_t pin; 5442 hda_nid_t pin;
5397 const char *label; 5443 const char *label;
@@ -5418,13 +5464,13 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec,
5418 } 5464 }
5419 } 5465 }
5420 5466
5421 if (!cap1) 5467 for (c = 0; c < num_adcs; c++) {
5422 continue; 5468 idx = get_connection_index(codec, caps[c], pin);
5423 idx = get_connection_index(codec, cap1, pin); 5469 if (idx >= 0) {
5424 if (idx < 0 && cap2) 5470 snd_hda_add_imux_item(imux, label, idx, NULL);
5425 idx = get_connection_index(codec, cap2, pin); 5471 break;
5426 if (idx >= 0) 5472 }
5427 snd_hda_add_imux_item(imux, label, idx, NULL); 5473 }
5428 } 5474 }
5429 return 0; 5475 return 0;
5430} 5476}
@@ -5437,12 +5483,6 @@ static int alc_auto_create_speaker_out(struct hda_codec *codec);
5437static void alc_auto_init_multi_out(struct hda_codec *codec); 5483static void alc_auto_init_multi_out(struct hda_codec *codec);
5438static void alc_auto_init_extra_out(struct hda_codec *codec); 5484static void alc_auto_init_extra_out(struct hda_codec *codec);
5439 5485
5440static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5441 const struct auto_pin_cfg *cfg)
5442{
5443 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5444}
5445
5446static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, 5486static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5447 unsigned int pin_type) 5487 unsigned int pin_type)
5448{ 5488{
@@ -5545,7 +5585,7 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
5545 err = alc_auto_create_speaker_out(codec); 5585 err = alc_auto_create_speaker_out(codec);
5546 if (err < 0) 5586 if (err < 0)
5547 return err; 5587 return err;
5548 err = alc880_auto_create_input_ctls(codec, &spec->autocfg); 5588 err = alc_auto_create_input_ctls(codec);
5549 if (err < 0) 5589 if (err < 0)
5550 return err; 5590 return err;
5551 5591
@@ -7057,13 +7097,6 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
7057 return 0; 7097 return 0;
7058} 7098}
7059 7099
7060/* create playback/capture controls for input pins */
7061static int alc260_auto_create_input_ctls(struct hda_codec *codec,
7062 const struct auto_pin_cfg *cfg)
7063{
7064 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
7065}
7066
7067static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, 7100static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
7068 hda_nid_t nid, int pin_type, 7101 hda_nid_t nid, int pin_type,
7069 int sel_idx) 7102 int sel_idx)
@@ -7127,7 +7160,7 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
7127 return err; 7160 return err;
7128 if (!spec->kctls.list) 7161 if (!spec->kctls.list)
7129 return 0; /* can't find valid BIOS pin config */ 7162 return 0; /* can't find valid BIOS pin config */
7130 err = alc260_auto_create_input_ctls(codec, &spec->autocfg); 7163 err = alc_auto_create_input_ctls(codec);
7131 if (err < 0) 7164 if (err < 0)
7132 return err; 7165 return err;
7133 7166
@@ -10777,12 +10810,6 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
10777/* 10810/*
10778 * BIOS auto configuration 10811 * BIOS auto configuration
10779 */ 10812 */
10780static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10781 const struct auto_pin_cfg *cfg)
10782{
10783 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10784}
10785
10786#define alc882_auto_init_analog_input alc880_auto_init_analog_input 10813#define alc882_auto_init_analog_input alc880_auto_init_analog_input
10787 10814
10788static void alc882_auto_init_input_src(struct hda_codec *codec) 10815static void alc882_auto_init_input_src(struct hda_codec *codec)
@@ -10909,7 +10936,7 @@ static int alc882_parse_auto_config(struct hda_codec *codec)
10909 err = alc_auto_create_speaker_out(codec); 10936 err = alc_auto_create_speaker_out(codec);
10910 if (err < 0) 10937 if (err < 0)
10911 return err; 10938 return err;
10912 err = alc882_auto_create_input_ctls(codec, &spec->autocfg); 10939 err = alc_auto_create_input_ctls(codec);
10913 if (err < 0) 10940 if (err < 0)
10914 return err; 10941 return err;
10915 10942
@@ -11984,9 +12011,6 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11984 return 0; 12011 return 0;
11985} 12012}
11986 12013
11987#define alc262_auto_create_input_ctls \
11988 alc882_auto_create_input_ctls
11989
11990static const struct hda_verb alc262_HP_BPC_init_verbs[] = { 12014static const struct hda_verb alc262_HP_BPC_init_verbs[] = {
11991 /* 12015 /*
11992 * Unmute ADC0-2 and set the default input to mic-in 12016 * Unmute ADC0-2 and set the default input to mic-in
@@ -12272,7 +12296,7 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
12272 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); 12296 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12273 if (err < 0) 12297 if (err < 0)
12274 return err; 12298 return err;
12275 err = alc262_auto_create_input_ctls(codec, &spec->autocfg); 12299 err = alc_auto_create_input_ctls(codec);
12276 if (err < 0) 12300 if (err < 0)
12277 return err; 12301 return err;
12278 12302
@@ -13285,13 +13309,6 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13285 return 0; 13309 return 0;
13286} 13310}
13287 13311
13288/* create playback/capture controls for input pins */
13289static int alc268_auto_create_input_ctls(struct hda_codec *codec,
13290 const struct auto_pin_cfg *cfg)
13291{
13292 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
13293}
13294
13295static void alc268_auto_set_output_and_unmute(struct hda_codec *codec, 13312static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13296 hda_nid_t nid, int pin_type) 13313 hda_nid_t nid, int pin_type)
13297{ 13314{
@@ -13429,7 +13446,7 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
13429 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); 13446 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13430 if (err < 0) 13447 if (err < 0)
13431 return err; 13448 return err;
13432 err = alc268_auto_create_input_ctls(codec, &spec->autocfg); 13449 err = alc_auto_create_input_ctls(codec);
13433 if (err < 0) 13450 if (err < 0)
13434 return err; 13451 return err;
13435 13452
@@ -14276,8 +14293,6 @@ static const struct hda_verb alc269vb_init_verbs[] = {
14276 14293
14277#define alc269_auto_create_multi_out_ctls \ 14294#define alc269_auto_create_multi_out_ctls \
14278 alc268_auto_create_multi_out_ctls 14295 alc268_auto_create_multi_out_ctls
14279#define alc269_auto_create_input_ctls \
14280 alc268_auto_create_input_ctls
14281 14296
14282#ifdef CONFIG_SND_HDA_POWER_SAVE 14297#ifdef CONFIG_SND_HDA_POWER_SAVE
14283#define alc269_loopbacks alc880_loopbacks 14298#define alc269_loopbacks alc880_loopbacks
@@ -14393,11 +14408,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
14393 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg); 14408 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14394 if (err < 0) 14409 if (err < 0)
14395 return err; 14410 return err;
14396 if (spec->codec_variant == ALC269_TYPE_ALC269VA) 14411 err = alc_auto_create_input_ctls(codec);
14397 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14398 else
14399 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14400 0x22, 0);
14401 if (err < 0) 14412 if (err < 0)
14402 return err; 14413 return err;
14403 14414
@@ -15671,13 +15682,6 @@ static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
15671 return 0; 15682 return 0;
15672} 15683}
15673 15684
15674/* create playback/capture controls for input pins */
15675static int alc861_auto_create_input_ctls(struct hda_codec *codec,
15676 const struct auto_pin_cfg *cfg)
15677{
15678 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
15679}
15680
15681static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, 15685static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15682 hda_nid_t nid, 15686 hda_nid_t nid,
15683 int pin_type, hda_nid_t dac) 15687 int pin_type, hda_nid_t dac)
@@ -15766,7 +15770,7 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
15766 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]); 15770 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
15767 if (err < 0) 15771 if (err < 0)
15768 return err; 15772 return err;
15769 err = alc861_auto_create_input_ctls(codec, &spec->autocfg); 15773 err = alc_auto_create_input_ctls(codec);
15770 if (err < 0) 15774 if (err < 0)
15771 return err; 15775 return err;
15772 15776
@@ -16671,13 +16675,6 @@ static const struct alc_config_preset alc861vd_presets[] = {
16671/* 16675/*
16672 * BIOS auto configuration 16676 * BIOS auto configuration
16673 */ 16677 */
16674static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16675 const struct auto_pin_cfg *cfg)
16676{
16677 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x22, 0);
16678}
16679
16680
16681#define alc861vd_auto_init_analog_input alc882_auto_init_analog_input 16678#define alc861vd_auto_init_analog_input alc882_auto_init_analog_input
16682#define alc861vd_auto_init_input_src alc882_auto_init_input_src 16679#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16683 16680
@@ -16835,7 +16832,7 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
16835 "Headphone"); 16832 "Headphone");
16836 if (err < 0) 16833 if (err < 0)
16837 return err; 16834 return err;
16838 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg); 16835 err = alc_auto_create_input_ctls(codec);
16839 if (err < 0) 16836 if (err < 0)
16840 return err; 16837 return err;
16841 16838
@@ -18693,10 +18690,6 @@ static int alc_auto_create_speaker_out(struct hda_codec *codec)
18693 "Speaker"); 18690 "Speaker");
18694} 18691}
18695 18692
18696/* create playback/capture controls for input pins */
18697#define alc662_auto_create_input_ctls \
18698 alc882_auto_create_input_ctls
18699
18700static void alc_auto_set_output_and_unmute(struct hda_codec *codec, 18693static void alc_auto_set_output_and_unmute(struct hda_codec *codec,
18701 hda_nid_t nid, int pin_type, 18694 hda_nid_t nid, int pin_type,
18702 hda_nid_t dac) 18695 hda_nid_t dac)
@@ -18968,7 +18961,7 @@ static int alc662_parse_auto_config(struct hda_codec *codec)
18968 "Headphone"); 18961 "Headphone");
18969 if (err < 0) 18962 if (err < 0)
18970 return err; 18963 return err;
18971 err = alc662_auto_create_input_ctls(codec, &spec->autocfg); 18964 err = alc_auto_create_input_ctls(codec);
18972 if (err < 0) 18965 if (err < 0)
18973 return err; 18966 return err;
18974 18967