aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Ranostay <mranostay@embeddedalley.com>2008-07-27 04:30:30 -0400
committerJaroslav Kysela <perex@perex.cz>2008-07-28 06:19:33 -0400
commitd0513fc6c37b009004cf5c7a8e90af0adb3755bc (patch)
treecd2a6fb61031759c20194bcc5cfd2b47c8e5b0f5
parentb38addb2da26c0eeab5b538cfbd9d306c50a4726 (diff)
ALSA: hda: added 92HD81/83 support
Added support for 92HD81/83 family of codecs. This also includes a pwr_mapping array for pins that have more than one amp to power down. Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r--sound/pci/hda/hda_codec.h1
-rw-r--r--sound/pci/hda/patch_sigmatel.c248
2 files changed, 227 insertions, 22 deletions
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 3a63c445d36b..2f112626f244 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -121,6 +121,7 @@ enum {
121#define AC_VERB_SET_CONFIG_DEFAULT_BYTES_1 0x71d 121#define AC_VERB_SET_CONFIG_DEFAULT_BYTES_1 0x71d
122#define AC_VERB_SET_CONFIG_DEFAULT_BYTES_2 0x71e 122#define AC_VERB_SET_CONFIG_DEFAULT_BYTES_2 0x71e
123#define AC_VERB_SET_CONFIG_DEFAULT_BYTES_3 0x71f 123#define AC_VERB_SET_CONFIG_DEFAULT_BYTES_3 0x71f
124#define AC_VERB_SET_EAPD 0x788
124#define AC_VERB_SET_CODEC_RESET 0x7ff 125#define AC_VERB_SET_CODEC_RESET 0x7ff
125 126
126/* 127/*
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 6ee73ed23ddd..23a7b2228e3c 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -72,6 +72,11 @@ enum {
72}; 72};
73 73
74enum { 74enum {
75 STAC_92HD83XXX_REF,
76 STAC_92HD83XXX_MODELS
77};
78
79enum {
75 STAC_92HD71BXX_REF, 80 STAC_92HD71BXX_REF,
76 STAC_DELL_M4_1, 81 STAC_DELL_M4_1,
77 STAC_DELL_M4_2, 82 STAC_DELL_M4_2,
@@ -145,6 +150,7 @@ struct sigmatel_spec {
145 150
146 /* power management */ 151 /* power management */
147 unsigned int num_pwrs; 152 unsigned int num_pwrs;
153 unsigned int *pwr_mapping;
148 hda_nid_t *pwr_nids; 154 hda_nid_t *pwr_nids;
149 hda_nid_t *dac_list; 155 hda_nid_t *dac_list;
150 156
@@ -240,6 +246,33 @@ static hda_nid_t stac92hd73xx_dmux_nids[2] = {
240 0x20, 0x21, 246 0x20, 0x21,
241}; 247};
242 248
249#define STAC92HD83XXX_NUM_DMICS 2
250static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
251 0x11, 0x12, 0
252};
253
254#define STAC92HD81_DAC_COUNT 2
255#define STAC92HD83_DAC_COUNT 3
256static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
257 0x13, 0x14, 0x22,
258};
259
260static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
261 0x17, 0x18,
262};
263
264static hda_nid_t stac92hd83xxx_adc_nids[2] = {
265 0x15, 0x16,
266};
267
268static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
269 0xa, 0xb, 0xd, 0xe,
270};
271
272static unsigned int stac92hd83xxx_pwr_mapping[4] = {
273 0x03, 0x0c, 0x10, 0x40,
274};
275
243static hda_nid_t stac92hd71bxx_pwr_nids[3] = { 276static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
244 0x0a, 0x0d, 0x0f 277 0x0a, 0x0d, 0x0f
245}; 278};
@@ -353,6 +386,11 @@ static hda_nid_t stac92hd73xx_pin_nids[13] = {
353 0x14, 0x1e, 0x22 386 0x14, 0x1e, 0x22
354}; 387};
355 388
389static hda_nid_t stac92hd83xxx_pin_nids[14] = {
390 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
391 0x0f, 0x10, 0x11, 0x12, 0x13,
392 0x1d, 0x1e, 0x1f, 0x20
393};
356static hda_nid_t stac92hd71bxx_pin_nids[10] = { 394static hda_nid_t stac92hd71bxx_pin_nids[10] = {
357 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 395 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
358 0x0f, 0x14, 0x18, 0x19, 0x1e, 396 0x0f, 0x14, 0x18, 0x19, 0x1e,
@@ -631,6 +669,19 @@ static struct hda_verb stac92hd73xx_10ch_core_init[] = {
631 {} 669 {}
632}; 670};
633 671
672static struct hda_verb stac92hd83xxx_core_init[] = {
673 /* start of config #1 */
674 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
675
676 /* start of config #2 */
677 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
678 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
679 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
680
681 /* power state controls amps */
682 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
683};
684
634static struct hda_verb stac92hd71bxx_core_init[] = { 685static struct hda_verb stac92hd71bxx_core_init[] = {
635 /* set master volume and direct control */ 686 /* set master volume and direct control */
636 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, 687 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
@@ -701,6 +752,8 @@ static struct hda_verb stac927x_core_init[] = {
701static struct hda_verb stac9205_core_init[] = { 752static struct hda_verb stac9205_core_init[] = {
702 /* set master volume and direct control */ 753 /* set master volume and direct control */
703 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, 754 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
755 /* enable analog pc beep path */
756 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
704 {} 757 {}
705}; 758};
706 759
@@ -823,6 +876,33 @@ static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
823 { } /* end */ 876 { } /* end */
824}; 877};
825 878
879
880static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
881 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
882 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
883
884 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
885 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
886
887 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
888 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
889
890 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
891 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
892
893 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
894 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
895
896 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
897 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
898
899 /*
900 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
901 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
902 */
903 { } /* end */
904};
905
826static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = { 906static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
827 STAC_INPUT_SOURCE(2), 907 STAC_INPUT_SOURCE(2),
828 908
@@ -1333,6 +1413,27 @@ static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1333 {} /* terminator */ 1413 {} /* terminator */
1334}; 1414};
1335 1415
1416static unsigned int ref92hd83xxx_pin_configs[14] = {
1417 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1418 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1419 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1420 0x01451160, 0x98560170,
1421};
1422
1423static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1424 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1425};
1426
1427static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1428 [STAC_92HD83XXX_REF] = "ref",
1429};
1430
1431static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1432 /* SigmaTel reference board */
1433 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1434 "DFI LanParty", STAC_92HD71BXX_REF),
1435};
1436
1336static unsigned int ref92hd71bxx_pin_configs[10] = { 1437static unsigned int ref92hd71bxx_pin_configs[10] = {
1337 0x02214030, 0x02a19040, 0x01a19020, 0x01014010, 1438 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1338 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0, 1439 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
@@ -2587,8 +2688,8 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2587} 2688}
2588 2689
2589/* labels for mono mux outputs */ 2690/* labels for mono mux outputs */
2590static const char *stac92xx_mono_labels[3] = { 2691static const char *stac92xx_mono_labels[4] = {
2591 "DAC0", "DAC1", "Mixer" 2692 "DAC0", "DAC1", "Mixer", "DAC2"
2592}; 2693};
2593 2694
2594/* create mono mux for mono out on capable codecs */ 2695/* create mono mux for mono out on capable codecs */
@@ -2692,16 +2793,19 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
2692 } 2793 }
2693 continue; 2794 continue;
2694found: 2795found:
2695 wcaps = get_wcaps(codec, nid); 2796 wcaps = get_wcaps(codec, nid) &
2797 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
2696 2798
2697 if (wcaps & AC_WCAP_OUT_AMP) { 2799 if (wcaps) {
2698 sprintf(name, "%s Capture Volume", 2800 sprintf(name, "%s Capture Volume",
2699 stac92xx_dmic_labels[dimux->num_items]); 2801 stac92xx_dmic_labels[dimux->num_items]);
2700 2802
2701 err = stac92xx_add_control(spec, 2803 err = stac92xx_add_control(spec,
2702 STAC_CTL_WIDGET_VOL, 2804 STAC_CTL_WIDGET_VOL,
2703 name, 2805 name,
2704 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 2806 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
2807 (wcaps & AC_WCAP_OUT_AMP) ?
2808 HDA_OUTPUT : HDA_INPUT));
2705 if (err < 0) 2809 if (err < 0)
2706 return err; 2810 return err;
2707 } 2811 }
@@ -2825,8 +2929,8 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
2825 hp_speaker_swap = 1; 2929 hp_speaker_swap = 1;
2826 } 2930 }
2827 if (spec->autocfg.mono_out_pin) { 2931 if (spec->autocfg.mono_out_pin) {
2828 int dir = (get_wcaps(codec, spec->autocfg.mono_out_pin) 2932 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
2829 & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT; 2933 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
2830 u32 caps = query_amp_caps(codec, 2934 u32 caps = query_amp_caps(codec,
2831 spec->autocfg.mono_out_pin, dir); 2935 spec->autocfg.mono_out_pin, dir);
2832 hda_nid_t conn_list[1]; 2936 hda_nid_t conn_list[1];
@@ -2848,21 +2952,26 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
2848 !(wcaps & AC_WCAP_LR_SWAP)) 2952 !(wcaps & AC_WCAP_LR_SWAP))
2849 spec->mono_nid = conn_list[0]; 2953 spec->mono_nid = conn_list[0];
2850 } 2954 }
2851 /* all mono outs have a least a mute/unmute switch */ 2955 if (dir) {
2852 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, 2956 hda_nid_t nid = spec->autocfg.mono_out_pin;
2853 "Mono Playback Switch", 2957
2854 HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin, 2958 /* most mono outs have a least a mute/unmute switch */
2855 1, 0, dir)); 2959 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
2856 if (err < 0) 2960 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
2857 return err; 2961 "Mono Playback Switch",
2858 /* check to see if there is volume support for the amp */ 2962 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
2859 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
2860 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
2861 "Mono Playback Volume",
2862 HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
2863 1, 0, dir));
2864 if (err < 0) 2963 if (err < 0)
2865 return err; 2964 return err;
2965 /* check for volume support for the amp */
2966 if ((caps & AC_AMPCAP_NUM_STEPS)
2967 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
2968 err = stac92xx_add_control(spec,
2969 STAC_CTL_WIDGET_VOL,
2970 "Mono Playback Volume",
2971 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
2972 if (err < 0)
2973 return err;
2974 }
2866 } 2975 }
2867 2976
2868 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin, 2977 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
@@ -2942,7 +3051,7 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
2942 3051
2943 if (spec->autocfg.dig_out_pin) 3052 if (spec->autocfg.dig_out_pin)
2944 spec->multiout.dig_out_nid = dig_out; 3053 spec->multiout.dig_out_nid = dig_out;
2945 if (spec->autocfg.dig_in_pin) 3054 if (dig_in && spec->autocfg.dig_in_pin)
2946 spec->dig_in_nid = dig_in; 3055 spec->dig_in_nid = dig_in;
2947 3056
2948 if (spec->kctl_alloc) 3057 if (spec->kctl_alloc)
@@ -3338,7 +3447,12 @@ static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3338 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) 3447 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3339 & 0x000000ff; 3448 & 0x000000ff;
3340 presence = get_hp_pin_presence(codec, nid); 3449 presence = get_hp_pin_presence(codec, nid);
3341 idx = 1 << idx; 3450
3451 /* several codecs have two power down bits */
3452 if (spec->pwr_mapping)
3453 idx = spec->pwr_mapping[idx];
3454 else
3455 idx = 1 << idx;
3342 3456
3343 if (presence) 3457 if (presence)
3344 val &= ~idx; 3458 val &= ~idx;
@@ -3674,6 +3788,94 @@ again:
3674 return 0; 3788 return 0;
3675} 3789}
3676 3790
3791static struct hda_input_mux stac92hd83xxx_dmux = {
3792 .num_items = 3,
3793 .items = {
3794 { "Analog Inputs", 0x03 },
3795 { "Digital Mic 1", 0x04 },
3796 { "Digital Mic 2", 0x05 },
3797 }
3798};
3799
3800static int patch_stac92hd83xxx(struct hda_codec *codec)
3801{
3802 struct sigmatel_spec *spec;
3803 int err;
3804
3805 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3806 if (spec == NULL)
3807 return -ENOMEM;
3808
3809 codec->spec = spec;
3810 spec->mono_nid = 0x19;
3811 spec->digbeep_nid = 0x21;
3812 spec->dmic_nids = stac92hd83xxx_dmic_nids;
3813 spec->dmux_nids = stac92hd83xxx_dmux_nids;
3814 spec->adc_nids = stac92hd83xxx_adc_nids;
3815 spec->pwr_nids = stac92hd83xxx_pwr_nids;
3816 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
3817 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
3818 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
3819
3820 spec->init = stac92hd83xxx_core_init;
3821 switch (codec->vendor_id) {
3822 case 0x111d7605:
3823 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
3824 break;
3825 default:
3826 spec->num_pwrs--;
3827 spec->init++; /* switch to config #2 */
3828 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
3829 }
3830
3831 spec->mixer = stac92hd83xxx_mixer;
3832 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
3833 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
3834 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
3835 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
3836 spec->dinput_mux = &stac92hd83xxx_dmux;
3837 spec->pin_nids = stac92hd83xxx_pin_nids;
3838 spec->board_config = snd_hda_check_board_config(codec,
3839 STAC_92HD83XXX_MODELS,
3840 stac92hd83xxx_models,
3841 stac92hd83xxx_cfg_tbl);
3842again:
3843 if (spec->board_config < 0) {
3844 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3845 " STAC92HD83XXX, using BIOS defaults\n");
3846 err = stac92xx_save_bios_config_regs(codec);
3847 if (err < 0) {
3848 stac92xx_free(codec);
3849 return err;
3850 }
3851 spec->pin_configs = spec->bios_pin_configs;
3852 } else {
3853 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
3854 stac92xx_set_config_regs(codec);
3855 }
3856
3857 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
3858 if (!err) {
3859 if (spec->board_config < 0) {
3860 printk(KERN_WARNING "hda_codec: No auto-config is "
3861 "available, default to model=ref\n");
3862 spec->board_config = STAC_92HD83XXX_REF;
3863 goto again;
3864 }
3865 err = -EINVAL;
3866 }
3867
3868 if (err < 0) {
3869 stac92xx_free(codec);
3870 return err;
3871 }
3872
3873 codec->patch_ops = stac92xx_patch_ops;
3874
3875 return 0;
3876}
3877
3878
3677static int patch_stac92hd71bxx(struct hda_codec *codec) 3879static int patch_stac92hd71bxx(struct hda_codec *codec)
3678{ 3880{
3679 struct sigmatel_spec *spec; 3881 struct sigmatel_spec *spec;
@@ -4395,6 +4597,8 @@ struct hda_codec_preset snd_hda_preset_sigmatel[] = {
4395 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 }, 4597 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
4396 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, 4598 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
4397 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx}, 4599 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
4600 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
4601 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
4398 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx}, 4602 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
4399 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx }, 4603 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
4400 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx }, 4604 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },