diff options
Diffstat (limited to 'sound/pci/hda/patch_sigmatel.c')
-rw-r--r-- | sound/pci/hda/patch_sigmatel.c | 318 |
1 files changed, 162 insertions, 156 deletions
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index bd7b123f6440..05fcd60cc46f 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -180,18 +180,16 @@ struct sigmatel_event { | |||
180 | int data; | 180 | int data; |
181 | }; | 181 | }; |
182 | 182 | ||
183 | struct sigmatel_jack { | ||
184 | hda_nid_t nid; | ||
185 | int type; | ||
186 | struct snd_jack *jack; | ||
187 | }; | ||
188 | |||
189 | struct sigmatel_mic_route { | 183 | struct sigmatel_mic_route { |
190 | hda_nid_t pin; | 184 | hda_nid_t pin; |
191 | signed char mux_idx; | 185 | signed char mux_idx; |
192 | signed char dmux_idx; | 186 | signed char dmux_idx; |
193 | }; | 187 | }; |
194 | 188 | ||
189 | #define MAX_PINS_NUM 16 | ||
190 | #define MAX_ADCS_NUM 4 | ||
191 | #define MAX_DMICS_NUM 4 | ||
192 | |||
195 | struct sigmatel_spec { | 193 | struct sigmatel_spec { |
196 | struct snd_kcontrol_new *mixers[4]; | 194 | struct snd_kcontrol_new *mixers[4]; |
197 | unsigned int num_mixers; | 195 | unsigned int num_mixers; |
@@ -229,9 +227,6 @@ struct sigmatel_spec { | |||
229 | hda_nid_t *pwr_nids; | 227 | hda_nid_t *pwr_nids; |
230 | hda_nid_t *dac_list; | 228 | hda_nid_t *dac_list; |
231 | 229 | ||
232 | /* jack detection */ | ||
233 | struct snd_array jacks; | ||
234 | |||
235 | /* events */ | 230 | /* events */ |
236 | struct snd_array events; | 231 | struct snd_array events; |
237 | 232 | ||
@@ -309,6 +304,17 @@ struct sigmatel_spec { | |||
309 | struct hda_input_mux private_imux; | 304 | struct hda_input_mux private_imux; |
310 | struct hda_input_mux private_smux; | 305 | struct hda_input_mux private_smux; |
311 | struct hda_input_mux private_mono_mux; | 306 | struct hda_input_mux private_mono_mux; |
307 | |||
308 | /* auto spec */ | ||
309 | unsigned auto_pin_cnt; | ||
310 | hda_nid_t auto_pin_nids[MAX_PINS_NUM]; | ||
311 | unsigned auto_adc_cnt; | ||
312 | hda_nid_t auto_adc_nids[MAX_ADCS_NUM]; | ||
313 | hda_nid_t auto_mux_nids[MAX_ADCS_NUM]; | ||
314 | hda_nid_t auto_dmux_nids[MAX_ADCS_NUM]; | ||
315 | unsigned long auto_capvols[MAX_ADCS_NUM]; | ||
316 | unsigned auto_dmic_cnt; | ||
317 | hda_nid_t auto_dmic_nids[MAX_DMICS_NUM]; | ||
312 | }; | 318 | }; |
313 | 319 | ||
314 | static hda_nid_t stac9200_adc_nids[1] = { | 320 | static hda_nid_t stac9200_adc_nids[1] = { |
@@ -364,14 +370,6 @@ static unsigned long stac92hd73xx_capvols[] = { | |||
364 | 370 | ||
365 | #define STAC92HD83_DAC_COUNT 3 | 371 | #define STAC92HD83_DAC_COUNT 3 |
366 | 372 | ||
367 | static hda_nid_t stac92hd83xxx_mux_nids[2] = { | ||
368 | 0x17, 0x18, | ||
369 | }; | ||
370 | |||
371 | static hda_nid_t stac92hd83xxx_adc_nids[2] = { | ||
372 | 0x15, 0x16, | ||
373 | }; | ||
374 | |||
375 | static hda_nid_t stac92hd83xxx_pwr_nids[4] = { | 373 | static hda_nid_t stac92hd83xxx_pwr_nids[4] = { |
376 | 0xa, 0xb, 0xd, 0xe, | 374 | 0xa, 0xb, 0xd, 0xe, |
377 | }; | 375 | }; |
@@ -384,25 +382,9 @@ static unsigned int stac92hd83xxx_pwr_mapping[4] = { | |||
384 | 0x03, 0x0c, 0x20, 0x40, | 382 | 0x03, 0x0c, 0x20, 0x40, |
385 | }; | 383 | }; |
386 | 384 | ||
387 | #define STAC92HD83XXX_NUM_DMICS 2 | 385 | static hda_nid_t stac92hd83xxx_dmic_nids[] = { |
388 | static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = { | 386 | 0x11, 0x20, |
389 | 0x11, 0x20, 0 | ||
390 | }; | ||
391 | |||
392 | #define STAC92HD88XXX_NUM_DMICS STAC92HD83XXX_NUM_DMICS | ||
393 | #define stac92hd88xxx_dmic_nids stac92hd83xxx_dmic_nids | ||
394 | |||
395 | #define STAC92HD87B_NUM_DMICS 1 | ||
396 | static hda_nid_t stac92hd87b_dmic_nids[STAC92HD87B_NUM_DMICS + 1] = { | ||
397 | 0x11, 0 | ||
398 | }; | ||
399 | |||
400 | #define STAC92HD83XXX_NUM_CAPS 2 | ||
401 | static unsigned long stac92hd83xxx_capvols[] = { | ||
402 | HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT), | ||
403 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT), | ||
404 | }; | 387 | }; |
405 | #define stac92hd83xxx_capsws stac92hd83xxx_capvols | ||
406 | 388 | ||
407 | static hda_nid_t stac92hd71bxx_pwr_nids[3] = { | 389 | static hda_nid_t stac92hd71bxx_pwr_nids[3] = { |
408 | 0x0a, 0x0d, 0x0f | 390 | 0x0a, 0x0d, 0x0f |
@@ -581,21 +563,6 @@ static hda_nid_t stac92hd73xx_pin_nids[13] = { | |||
581 | 0x14, 0x22, 0x23 | 563 | 0x14, 0x22, 0x23 |
582 | }; | 564 | }; |
583 | 565 | ||
584 | static hda_nid_t stac92hd83xxx_pin_nids[10] = { | ||
585 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, | ||
586 | 0x0f, 0x10, 0x11, 0x1f, 0x20, | ||
587 | }; | ||
588 | |||
589 | static hda_nid_t stac92hd87xxx_pin_nids[6] = { | ||
590 | 0x0a, 0x0b, 0x0c, 0x0d, | ||
591 | 0x0f, 0x11, | ||
592 | }; | ||
593 | |||
594 | static hda_nid_t stac92hd88xxx_pin_nids[8] = { | ||
595 | 0x0a, 0x0b, 0x0c, 0x0d, | ||
596 | 0x0f, 0x11, 0x1f, 0x20, | ||
597 | }; | ||
598 | |||
599 | #define STAC92HD71BXX_NUM_PINS 13 | 566 | #define STAC92HD71BXX_NUM_PINS 13 |
600 | static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = { | 567 | static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = { |
601 | 0x0a, 0x0b, 0x0c, 0x0d, 0x00, | 568 | 0x0a, 0x0b, 0x0c, 0x0d, 0x00, |
@@ -757,7 +724,7 @@ static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e | |||
757 | struct sigmatel_spec *spec = codec->spec; | 724 | struct sigmatel_spec *spec = codec->spec; |
758 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 725 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
759 | const struct hda_input_mux *imux = spec->input_mux; | 726 | const struct hda_input_mux *imux = spec->input_mux; |
760 | unsigned int idx, prev_idx; | 727 | unsigned int idx, prev_idx, didx; |
761 | 728 | ||
762 | idx = ucontrol->value.enumerated.item[0]; | 729 | idx = ucontrol->value.enumerated.item[0]; |
763 | if (idx >= imux->num_items) | 730 | if (idx >= imux->num_items) |
@@ -769,7 +736,8 @@ static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e | |||
769 | snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0, | 736 | snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0, |
770 | AC_VERB_SET_CONNECT_SEL, | 737 | AC_VERB_SET_CONNECT_SEL, |
771 | imux->items[idx].index); | 738 | imux->items[idx].index); |
772 | if (prev_idx >= spec->num_analog_muxes) { | 739 | if (prev_idx >= spec->num_analog_muxes && |
740 | spec->mux_nids[adc_idx] != spec->dmux_nids[adc_idx]) { | ||
773 | imux = spec->dinput_mux; | 741 | imux = spec->dinput_mux; |
774 | /* 0 = analog */ | 742 | /* 0 = analog */ |
775 | snd_hda_codec_write_cache(codec, | 743 | snd_hda_codec_write_cache(codec, |
@@ -779,9 +747,13 @@ static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e | |||
779 | } | 747 | } |
780 | } else { | 748 | } else { |
781 | imux = spec->dinput_mux; | 749 | imux = spec->dinput_mux; |
750 | /* first dimux item is hardcoded to select analog imux, | ||
751 | * so lets skip it | ||
752 | */ | ||
753 | didx = idx - spec->num_analog_muxes + 1; | ||
782 | snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0, | 754 | snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0, |
783 | AC_VERB_SET_CONNECT_SEL, | 755 | AC_VERB_SET_CONNECT_SEL, |
784 | imux->items[idx - 1].index); | 756 | imux->items[didx].index); |
785 | } | 757 | } |
786 | spec->cur_mux[adc_idx] = idx; | 758 | spec->cur_mux[adc_idx] = idx; |
787 | return 1; | 759 | return 1; |
@@ -3419,6 +3391,17 @@ static const char * const stac92xx_dmic_labels[5] = { | |||
3419 | "Digital Mic 3", "Digital Mic 4" | 3391 | "Digital Mic 3", "Digital Mic 4" |
3420 | }; | 3392 | }; |
3421 | 3393 | ||
3394 | static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux, | ||
3395 | int idx) | ||
3396 | { | ||
3397 | hda_nid_t conn[HDA_MAX_NUM_INPUTS]; | ||
3398 | int nums; | ||
3399 | nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn)); | ||
3400 | if (idx >= 0 && idx < nums) | ||
3401 | return conn[idx]; | ||
3402 | return 0; | ||
3403 | } | ||
3404 | |||
3422 | static int get_connection_index(struct hda_codec *codec, hda_nid_t mux, | 3405 | static int get_connection_index(struct hda_codec *codec, hda_nid_t mux, |
3423 | hda_nid_t nid) | 3406 | hda_nid_t nid) |
3424 | { | 3407 | { |
@@ -3429,6 +3412,15 @@ static int get_connection_index(struct hda_codec *codec, hda_nid_t mux, | |||
3429 | for (i = 0; i < nums; i++) | 3412 | for (i = 0; i < nums; i++) |
3430 | if (conn[i] == nid) | 3413 | if (conn[i] == nid) |
3431 | return i; | 3414 | return i; |
3415 | |||
3416 | for (i = 0; i < nums; i++) { | ||
3417 | unsigned int wid_caps = get_wcaps(codec, conn[i]); | ||
3418 | unsigned int wid_type = get_wcaps_type(wid_caps); | ||
3419 | |||
3420 | if (wid_type != AC_WID_PIN && wid_type != AC_WID_AUD_MIX) | ||
3421 | if (get_connection_index(codec, conn[i], nid) >= 0) | ||
3422 | return i; | ||
3423 | } | ||
3432 | return -1; | 3424 | return -1; |
3433 | } | 3425 | } |
3434 | 3426 | ||
@@ -3501,6 +3493,16 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, | |||
3501 | type_idx, HDA_OUTPUT); | 3493 | type_idx, HDA_OUTPUT); |
3502 | if (err < 0) | 3494 | if (err < 0) |
3503 | return err; | 3495 | return err; |
3496 | if (!err) { | ||
3497 | nid = get_connected_node(codec, | ||
3498 | spec->dmux_nids[0], index); | ||
3499 | if (nid) | ||
3500 | err = create_elem_capture_vol(codec, | ||
3501 | nid, label, | ||
3502 | type_idx, HDA_INPUT); | ||
3503 | if (err < 0) | ||
3504 | return err; | ||
3505 | } | ||
3504 | } | 3506 | } |
3505 | } | 3507 | } |
3506 | 3508 | ||
@@ -4054,21 +4056,10 @@ static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, | |||
4054 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ | 4056 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ |
4055 | } | 4057 | } |
4056 | 4058 | ||
4057 | #ifdef CONFIG_SND_HDA_INPUT_JACK | ||
4058 | static void stac92xx_free_jack_priv(struct snd_jack *jack) | ||
4059 | { | ||
4060 | struct sigmatel_jack *jacks = jack->private_data; | ||
4061 | jacks->nid = 0; | ||
4062 | jacks->jack = NULL; | ||
4063 | } | ||
4064 | #endif | ||
4065 | |||
4066 | static int stac92xx_add_jack(struct hda_codec *codec, | 4059 | static int stac92xx_add_jack(struct hda_codec *codec, |
4067 | hda_nid_t nid, int type) | 4060 | hda_nid_t nid, int type) |
4068 | { | 4061 | { |
4069 | #ifdef CONFIG_SND_HDA_INPUT_JACK | 4062 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
4070 | struct sigmatel_spec *spec = codec->spec; | ||
4071 | struct sigmatel_jack *jack; | ||
4072 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); | 4063 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
4073 | int connectivity = get_defcfg_connect(def_conf); | 4064 | int connectivity = get_defcfg_connect(def_conf); |
4074 | char name[32]; | 4065 | char name[32]; |
@@ -4077,26 +4068,15 @@ static int stac92xx_add_jack(struct hda_codec *codec, | |||
4077 | if (connectivity && connectivity != AC_JACK_PORT_FIXED) | 4068 | if (connectivity && connectivity != AC_JACK_PORT_FIXED) |
4078 | return 0; | 4069 | return 0; |
4079 | 4070 | ||
4080 | snd_array_init(&spec->jacks, sizeof(*jack), 32); | ||
4081 | jack = snd_array_new(&spec->jacks); | ||
4082 | if (!jack) | ||
4083 | return -ENOMEM; | ||
4084 | jack->nid = nid; | ||
4085 | jack->type = type; | ||
4086 | |||
4087 | snprintf(name, sizeof(name), "%s at %s %s Jack", | 4071 | snprintf(name, sizeof(name), "%s at %s %s Jack", |
4088 | snd_hda_get_jack_type(def_conf), | 4072 | snd_hda_get_jack_type(def_conf), |
4089 | snd_hda_get_jack_connectivity(def_conf), | 4073 | snd_hda_get_jack_connectivity(def_conf), |
4090 | snd_hda_get_jack_location(def_conf)); | 4074 | snd_hda_get_jack_location(def_conf)); |
4091 | 4075 | ||
4092 | err = snd_jack_new(codec->bus->card, name, type, &jack->jack); | 4076 | err = snd_hda_input_jack_add(codec, nid, type, name); |
4093 | if (err < 0) { | 4077 | if (err < 0) |
4094 | jack->nid = 0; | ||
4095 | return err; | 4078 | return err; |
4096 | } | 4079 | #endif /* CONFIG_SND_HDA_INPUT_JACK */ |
4097 | jack->jack->private_data = jack; | ||
4098 | jack->jack->private_free = stac92xx_free_jack_priv; | ||
4099 | #endif | ||
4100 | return 0; | 4080 | return 0; |
4101 | } | 4081 | } |
4102 | 4082 | ||
@@ -4399,23 +4379,6 @@ static int stac92xx_init(struct hda_codec *codec) | |||
4399 | return 0; | 4379 | return 0; |
4400 | } | 4380 | } |
4401 | 4381 | ||
4402 | static void stac92xx_free_jacks(struct hda_codec *codec) | ||
4403 | { | ||
4404 | #ifdef CONFIG_SND_HDA_INPUT_JACK | ||
4405 | /* free jack instances manually when clearing/reconfiguring */ | ||
4406 | struct sigmatel_spec *spec = codec->spec; | ||
4407 | if (!codec->bus->shutdown && spec->jacks.list) { | ||
4408 | struct sigmatel_jack *jacks = spec->jacks.list; | ||
4409 | int i; | ||
4410 | for (i = 0; i < spec->jacks.used; i++, jacks++) { | ||
4411 | if (jacks->jack) | ||
4412 | snd_device_free(codec->bus->card, jacks->jack); | ||
4413 | } | ||
4414 | } | ||
4415 | snd_array_free(&spec->jacks); | ||
4416 | #endif | ||
4417 | } | ||
4418 | |||
4419 | static void stac92xx_free_kctls(struct hda_codec *codec) | 4382 | static void stac92xx_free_kctls(struct hda_codec *codec) |
4420 | { | 4383 | { |
4421 | struct sigmatel_spec *spec = codec->spec; | 4384 | struct sigmatel_spec *spec = codec->spec; |
@@ -4449,7 +4412,7 @@ static void stac92xx_free(struct hda_codec *codec) | |||
4449 | return; | 4412 | return; |
4450 | 4413 | ||
4451 | stac92xx_shutup(codec); | 4414 | stac92xx_shutup(codec); |
4452 | stac92xx_free_jacks(codec); | 4415 | snd_hda_input_jack_free(codec); |
4453 | snd_array_free(&spec->events); | 4416 | snd_array_free(&spec->events); |
4454 | 4417 | ||
4455 | kfree(spec); | 4418 | kfree(spec); |
@@ -4667,33 +4630,6 @@ static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid) | |||
4667 | stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid)); | 4630 | stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid)); |
4668 | } | 4631 | } |
4669 | 4632 | ||
4670 | static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid) | ||
4671 | { | ||
4672 | struct sigmatel_spec *spec = codec->spec; | ||
4673 | struct sigmatel_jack *jacks = spec->jacks.list; | ||
4674 | |||
4675 | if (jacks) { | ||
4676 | int i; | ||
4677 | for (i = 0; i < spec->jacks.used; i++) { | ||
4678 | if (jacks->nid == nid) { | ||
4679 | unsigned int pin_ctl = | ||
4680 | snd_hda_codec_read(codec, nid, | ||
4681 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, | ||
4682 | 0x00); | ||
4683 | int type = jacks->type; | ||
4684 | if (type == (SND_JACK_LINEOUT | ||
4685 | | SND_JACK_HEADPHONE)) | ||
4686 | type = (pin_ctl & AC_PINCTL_HP_EN) | ||
4687 | ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT; | ||
4688 | snd_jack_report(jacks->jack, | ||
4689 | get_pin_presence(codec, nid) | ||
4690 | ? type : 0); | ||
4691 | } | ||
4692 | jacks++; | ||
4693 | } | ||
4694 | } | ||
4695 | } | ||
4696 | |||
4697 | /* get the pin connection (fixed, none, etc) */ | 4633 | /* get the pin connection (fixed, none, etc) */ |
4698 | static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) | 4634 | static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) |
4699 | { | 4635 | { |
@@ -4782,7 +4718,7 @@ static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) | |||
4782 | case STAC_PWR_EVENT: | 4718 | case STAC_PWR_EVENT: |
4783 | if (spec->num_pwrs > 0) | 4719 | if (spec->num_pwrs > 0) |
4784 | stac92xx_pin_sense(codec, event->nid); | 4720 | stac92xx_pin_sense(codec, event->nid); |
4785 | stac92xx_report_jack(codec, event->nid); | 4721 | snd_hda_input_jack_report(codec, event->nid); |
4786 | 4722 | ||
4787 | switch (codec->subsystem_id) { | 4723 | switch (codec->subsystem_id) { |
4788 | case 0x103c308f: | 4724 | case 0x103c308f: |
@@ -5378,6 +5314,105 @@ static int hp_bnb2011_with_dock(struct hda_codec *codec) | |||
5378 | return 0; | 5314 | return 0; |
5379 | } | 5315 | } |
5380 | 5316 | ||
5317 | static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid) | ||
5318 | { | ||
5319 | struct sigmatel_spec *spec = codec->spec; | ||
5320 | unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); | ||
5321 | int i; | ||
5322 | |||
5323 | spec->auto_pin_nids[spec->auto_pin_cnt] = nid; | ||
5324 | spec->auto_pin_cnt++; | ||
5325 | |||
5326 | if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN && | ||
5327 | get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) { | ||
5328 | for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) { | ||
5329 | if (nid == stac92hd83xxx_dmic_nids[i]) { | ||
5330 | spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid; | ||
5331 | spec->auto_dmic_cnt++; | ||
5332 | } | ||
5333 | } | ||
5334 | } | ||
5335 | } | ||
5336 | |||
5337 | static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid) | ||
5338 | { | ||
5339 | struct sigmatel_spec *spec = codec->spec; | ||
5340 | |||
5341 | spec->auto_adc_nids[spec->auto_adc_cnt] = nid; | ||
5342 | spec->auto_adc_cnt++; | ||
5343 | } | ||
5344 | |||
5345 | static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid) | ||
5346 | { | ||
5347 | int i, j; | ||
5348 | struct sigmatel_spec *spec = codec->spec; | ||
5349 | |||
5350 | for (i = 0; i < spec->auto_adc_cnt; i++) { | ||
5351 | if (get_connection_index(codec, | ||
5352 | spec->auto_adc_nids[i], nid) >= 0) { | ||
5353 | /* mux and volume for adc_nids[i] */ | ||
5354 | if (!spec->auto_mux_nids[i]) { | ||
5355 | spec->auto_mux_nids[i] = nid; | ||
5356 | /* 92hd codecs capture volume is in mux */ | ||
5357 | spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid, | ||
5358 | 3, 0, HDA_OUTPUT); | ||
5359 | } | ||
5360 | for (j = 0; j < spec->auto_dmic_cnt; j++) { | ||
5361 | if (get_connection_index(codec, nid, | ||
5362 | spec->auto_dmic_nids[j]) >= 0) { | ||
5363 | /* dmux for adc_nids[i] */ | ||
5364 | if (!spec->auto_dmux_nids[i]) | ||
5365 | spec->auto_dmux_nids[i] = nid; | ||
5366 | break; | ||
5367 | } | ||
5368 | } | ||
5369 | break; | ||
5370 | } | ||
5371 | } | ||
5372 | } | ||
5373 | |||
5374 | static void stac92hd8x_fill_auto_spec(struct hda_codec *codec) | ||
5375 | { | ||
5376 | hda_nid_t nid, end_nid; | ||
5377 | unsigned int wid_caps, wid_type; | ||
5378 | struct sigmatel_spec *spec = codec->spec; | ||
5379 | |||
5380 | end_nid = codec->start_nid + codec->num_nodes; | ||
5381 | |||
5382 | for (nid = codec->start_nid; nid < end_nid; nid++) { | ||
5383 | wid_caps = get_wcaps(codec, nid); | ||
5384 | wid_type = get_wcaps_type(wid_caps); | ||
5385 | |||
5386 | if (wid_type == AC_WID_PIN) | ||
5387 | stac92hd8x_add_pin(codec, nid); | ||
5388 | |||
5389 | if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL)) | ||
5390 | stac92hd8x_add_adc(codec, nid); | ||
5391 | } | ||
5392 | |||
5393 | for (nid = codec->start_nid; nid < end_nid; nid++) { | ||
5394 | wid_caps = get_wcaps(codec, nid); | ||
5395 | wid_type = get_wcaps_type(wid_caps); | ||
5396 | |||
5397 | if (wid_type == AC_WID_AUD_SEL) | ||
5398 | stac92hd8x_add_mux(codec, nid); | ||
5399 | } | ||
5400 | |||
5401 | spec->pin_nids = spec->auto_pin_nids; | ||
5402 | spec->num_pins = spec->auto_pin_cnt; | ||
5403 | spec->adc_nids = spec->auto_adc_nids; | ||
5404 | spec->num_adcs = spec->auto_adc_cnt; | ||
5405 | spec->capvols = spec->auto_capvols; | ||
5406 | spec->capsws = spec->auto_capvols; | ||
5407 | spec->num_caps = spec->auto_adc_cnt; | ||
5408 | spec->mux_nids = spec->auto_mux_nids; | ||
5409 | spec->num_muxes = spec->auto_adc_cnt; | ||
5410 | spec->dmux_nids = spec->auto_dmux_nids; | ||
5411 | spec->num_dmuxes = spec->auto_adc_cnt; | ||
5412 | spec->dmic_nids = spec->auto_dmic_nids; | ||
5413 | spec->num_dmics = spec->auto_dmic_cnt; | ||
5414 | } | ||
5415 | |||
5381 | static int patch_stac92hd83xxx(struct hda_codec *codec) | 5416 | static int patch_stac92hd83xxx(struct hda_codec *codec) |
5382 | { | 5417 | { |
5383 | struct sigmatel_spec *spec; | 5418 | struct sigmatel_spec *spec; |
@@ -5399,26 +5434,17 @@ static int patch_stac92hd83xxx(struct hda_codec *codec) | |||
5399 | snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7ED, 0); | 5434 | snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7ED, 0); |
5400 | codec->no_trigger_sense = 1; | 5435 | codec->no_trigger_sense = 1; |
5401 | codec->spec = spec; | 5436 | codec->spec = spec; |
5437 | |||
5438 | stac92hd8x_fill_auto_spec(codec); | ||
5439 | |||
5402 | spec->linear_tone_beep = 0; | 5440 | spec->linear_tone_beep = 0; |
5403 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; | 5441 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; |
5404 | spec->digbeep_nid = 0x21; | 5442 | spec->digbeep_nid = 0x21; |
5405 | spec->dmic_nids = stac92hd83xxx_dmic_nids; | ||
5406 | spec->dmux_nids = stac92hd83xxx_mux_nids; | ||
5407 | spec->mux_nids = stac92hd83xxx_mux_nids; | ||
5408 | spec->num_muxes = ARRAY_SIZE(stac92hd83xxx_mux_nids); | ||
5409 | spec->adc_nids = stac92hd83xxx_adc_nids; | ||
5410 | spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids); | ||
5411 | spec->pwr_nids = stac92hd83xxx_pwr_nids; | 5443 | spec->pwr_nids = stac92hd83xxx_pwr_nids; |
5412 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; | 5444 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; |
5413 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); | 5445 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); |
5414 | spec->multiout.dac_nids = spec->dac_nids; | 5446 | spec->multiout.dac_nids = spec->dac_nids; |
5415 | |||
5416 | spec->init = stac92hd83xxx_core_init; | 5447 | spec->init = stac92hd83xxx_core_init; |
5417 | spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); | ||
5418 | spec->pin_nids = stac92hd83xxx_pin_nids; | ||
5419 | spec->num_caps = STAC92HD83XXX_NUM_CAPS; | ||
5420 | spec->capvols = stac92hd83xxx_capvols; | ||
5421 | spec->capsws = stac92hd83xxx_capsws; | ||
5422 | 5448 | ||
5423 | spec->board_config = snd_hda_check_board_config(codec, | 5449 | spec->board_config = snd_hda_check_board_config(codec, |
5424 | STAC_92HD83XXX_MODELS, | 5450 | STAC_92HD83XXX_MODELS, |
@@ -5436,28 +5462,11 @@ again: | |||
5436 | case 0x111d76d1: | 5462 | case 0x111d76d1: |
5437 | case 0x111d76d9: | 5463 | case 0x111d76d9: |
5438 | case 0x111d76e5: | 5464 | case 0x111d76e5: |
5439 | spec->dmic_nids = stac92hd87b_dmic_nids; | ||
5440 | spec->num_dmics = stac92xx_connected_ports(codec, | ||
5441 | stac92hd87b_dmic_nids, | ||
5442 | STAC92HD87B_NUM_DMICS); | ||
5443 | spec->num_pins = ARRAY_SIZE(stac92hd87xxx_pin_nids); | ||
5444 | spec->pin_nids = stac92hd87xxx_pin_nids; | ||
5445 | spec->mono_nid = 0; | ||
5446 | spec->num_pwrs = 0; | ||
5447 | break; | ||
5448 | case 0x111d7666: | 5465 | case 0x111d7666: |
5449 | case 0x111d7667: | 5466 | case 0x111d7667: |
5450 | case 0x111d7668: | 5467 | case 0x111d7668: |
5451 | case 0x111d7669: | 5468 | case 0x111d7669: |
5452 | case 0x111d76e3: | 5469 | case 0x111d76e3: |
5453 | spec->num_dmics = stac92xx_connected_ports(codec, | ||
5454 | stac92hd88xxx_dmic_nids, | ||
5455 | STAC92HD88XXX_NUM_DMICS); | ||
5456 | spec->num_pins = ARRAY_SIZE(stac92hd88xxx_pin_nids); | ||
5457 | spec->pin_nids = stac92hd88xxx_pin_nids; | ||
5458 | spec->mono_nid = 0; | ||
5459 | spec->num_pwrs = 0; | ||
5460 | break; | ||
5461 | case 0x111d7604: | 5470 | case 0x111d7604: |
5462 | case 0x111d76d4: | 5471 | case 0x111d76d4: |
5463 | case 0x111d7605: | 5472 | case 0x111d7605: |
@@ -5466,9 +5475,6 @@ again: | |||
5466 | if (spec->board_config == STAC_92HD83XXX_PWR_REF) | 5475 | if (spec->board_config == STAC_92HD83XXX_PWR_REF) |
5467 | break; | 5476 | break; |
5468 | spec->num_pwrs = 0; | 5477 | spec->num_pwrs = 0; |
5469 | spec->num_dmics = stac92xx_connected_ports(codec, | ||
5470 | stac92hd83xxx_dmic_nids, | ||
5471 | STAC92HD83XXX_NUM_DMICS); | ||
5472 | break; | 5478 | break; |
5473 | } | 5479 | } |
5474 | 5480 | ||