aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_sigmatel.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2007-12-18 12:05:52 -0500
committerJaroslav Kysela <perex@perex.cz>2008-01-31 11:29:42 -0500
commit1697055e6c82ee5e99f459c15619605782eb7fcc (patch)
tree2eb918aed82bb7ecdc6408bc7695f35ddc905365 /sound/pci/hda/patch_sigmatel.c
parent8432395fd9124aa9408f61c94aa743878b4ddaf9 (diff)
[ALSA] hda-codec - Fix invalid access to non-existing dmux on STAC
The digital mux on STAC codecs doesn't always exist although the driver builds dmux enum mixer elements unconditionally. Now the driver creates 'digital input source' mixer elements only when dmux is available. Also, the patch adds the missing dmux definition for STAC925x. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/hda/patch_sigmatel.c')
-rw-r--r--sound/pci/hda/patch_sigmatel.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 1e2d3bfe4a62..a074155dd8d5 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -139,6 +139,7 @@ struct sigmatel_spec {
139 hda_nid_t *dmic_nids; 139 hda_nid_t *dmic_nids;
140 unsigned int num_dmics; 140 unsigned int num_dmics;
141 hda_nid_t *dmux_nids; 141 hda_nid_t *dmux_nids;
142 unsigned int num_dmuxes;
142 hda_nid_t dig_in_nid; 143 hda_nid_t dig_in_nid;
143 144
144 /* pin widgets */ 145 /* pin widgets */
@@ -244,6 +245,10 @@ static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
244 0x15, 0 245 0x15, 0
245}; 246};
246 247
248static hda_nid_t stac925x_dmux_nids[1] = {
249 0x14,
250};
251
247static hda_nid_t stac922x_adc_nids[2] = { 252static hda_nid_t stac922x_adc_nids[2] = {
248 0x06, 0x07, 253 0x06, 0x07,
249}; 254};
@@ -278,7 +283,7 @@ static hda_nid_t stac9205_mux_nids[2] = {
278}; 283};
279 284
280static hda_nid_t stac9205_dmux_nids[1] = { 285static hda_nid_t stac9205_dmux_nids[1] = {
281 0x1d, 286 0x1d,
282}; 287};
283 288
284#define STAC9205_NUM_DMICS 2 289#define STAC9205_NUM_DMICS 2
@@ -596,16 +601,6 @@ static struct hda_verb stac9205_core_init[] = {
596 {} 601 {}
597}; 602};
598 603
599#define STAC_DIGITAL_INPUT_SOURCE(cnt) \
600 { \
601 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
602 .name = "Digital Input Source", \
603 .count = cnt, \
604 .info = stac92xx_dmux_enum_info, \
605 .get = stac92xx_dmux_enum_get, \
606 .put = stac92xx_dmux_enum_put,\
607 }
608
609#define STAC_INPUT_SOURCE(cnt) \ 604#define STAC_INPUT_SOURCE(cnt) \
610 { \ 605 { \
611 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 606 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
@@ -638,7 +633,6 @@ static struct snd_kcontrol_new stac9200_mixer[] = {
638}; 633};
639 634
640static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = { 635static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
641 STAC_DIGITAL_INPUT_SOURCE(2),
642 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), 636 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
643 637
644 /* hardware gain controls */ 638 /* hardware gain controls */
@@ -669,7 +663,6 @@ static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
669}; 663};
670 664
671static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = { 665static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
672 STAC_DIGITAL_INPUT_SOURCE(2),
673 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4), 666 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
674 667
675 /* hardware gain controls */ 668 /* hardware gain controls */
@@ -700,7 +693,6 @@ static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
700}; 693};
701 694
702static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = { 695static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
703 STAC_DIGITAL_INPUT_SOURCE(2),
704 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5), 696 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
705 697
706 /* hardware gain controls */ 698 /* hardware gain controls */
@@ -731,7 +723,6 @@ static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
731}; 723};
732 724
733static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = { 725static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
734 STAC_DIGITAL_INPUT_SOURCE(1),
735 STAC_INPUT_SOURCE(2), 726 STAC_INPUT_SOURCE(2),
736 727
737 /* hardware gain controls */ 728 /* hardware gain controls */
@@ -752,7 +743,6 @@ static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
752}; 743};
753 744
754static struct snd_kcontrol_new stac92hd71bxx_mixer[] = { 745static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
755 STAC_DIGITAL_INPUT_SOURCE(1),
756 STAC_INPUT_SOURCE(2), 746 STAC_INPUT_SOURCE(2),
757 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2), 747 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
758 748
@@ -779,7 +769,6 @@ static struct snd_kcontrol_new stac925x_mixer[] = {
779}; 769};
780 770
781static struct snd_kcontrol_new stac9205_mixer[] = { 771static struct snd_kcontrol_new stac9205_mixer[] = {
782 STAC_DIGITAL_INPUT_SOURCE(1),
783 STAC_INPUT_SOURCE(2), 772 STAC_INPUT_SOURCE(2),
784 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1), 773 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
785 774
@@ -809,7 +798,6 @@ static struct snd_kcontrol_new stac922x_mixer[] = {
809 798
810 799
811static struct snd_kcontrol_new stac927x_mixer[] = { 800static struct snd_kcontrol_new stac927x_mixer[] = {
812 STAC_DIGITAL_INPUT_SOURCE(1),
813 STAC_INPUT_SOURCE(3), 801 STAC_INPUT_SOURCE(3),
814 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), 802 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
815 803
@@ -827,6 +815,15 @@ static struct snd_kcontrol_new stac927x_mixer[] = {
827 { } /* end */ 815 { } /* end */
828}; 816};
829 817
818static struct snd_kcontrol_new stac_dmux_mixer = {
819 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
820 .name = "Digital Input Source",
821 /* count set later */
822 .info = stac92xx_dmux_enum_info,
823 .get = stac92xx_dmux_enum_get,
824 .put = stac92xx_dmux_enum_put,
825};
826
830static int stac92xx_build_controls(struct hda_codec *codec) 827static int stac92xx_build_controls(struct hda_codec *codec)
831{ 828{
832 struct sigmatel_spec *spec = codec->spec; 829 struct sigmatel_spec *spec = codec->spec;
@@ -842,6 +839,13 @@ static int stac92xx_build_controls(struct hda_codec *codec)
842 if (err < 0) 839 if (err < 0)
843 return err; 840 return err;
844 } 841 }
842 if (spec->num_dmuxes > 0) {
843 stac_dmux_mixer.count = spec->num_dmuxes;
844 err = snd_ctl_add(codec->bus->card,
845 snd_ctl_new1(&stac_dmux_mixer, codec));
846 if (err < 0)
847 return err;
848 }
845 849
846 if (spec->multiout.dig_out_nid) { 850 if (spec->multiout.dig_out_nid) {
847 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); 851 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
@@ -2967,6 +2971,8 @@ static int patch_stac925x(struct hda_codec *codec)
2967 case 0x83847637: /* STAC9251D */ 2971 case 0x83847637: /* STAC9251D */
2968 spec->num_dmics = STAC925X_NUM_DMICS; 2972 spec->num_dmics = STAC925X_NUM_DMICS;
2969 spec->dmic_nids = stac925x_dmic_nids; 2973 spec->dmic_nids = stac925x_dmic_nids;
2974 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
2975 spec->dmux_nids = stac925x_dmux_nids;
2970 break; 2976 break;
2971 default: 2977 default:
2972 spec->num_dmics = 0; 2978 spec->num_dmics = 0;
@@ -3075,6 +3081,7 @@ again:
3075 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); 3081 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
3076 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); 3082 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
3077 spec->num_dmics = STAC92HD73XX_NUM_DMICS; 3083 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
3084 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
3078 spec->dinput_mux = &stac92hd73xx_dmux; 3085 spec->dinput_mux = &stac92hd73xx_dmux;
3079 /* GPIO0 High = Enable EAPD */ 3086 /* GPIO0 High = Enable EAPD */
3080 spec->gpio_mask = spec->gpio_data = 0x000001; 3087 spec->gpio_mask = spec->gpio_data = 0x000001;
@@ -3160,6 +3167,7 @@ again:
3160 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); 3167 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
3161 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); 3168 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
3162 spec->num_dmics = STAC92HD71BXX_NUM_DMICS; 3169 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
3170 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
3163 3171
3164 spec->multiout.num_dacs = 2; 3172 spec->multiout.num_dacs = 2;
3165 spec->multiout.hp_nid = 0x11; 3173 spec->multiout.hp_nid = 0x11;
@@ -3345,6 +3353,7 @@ static int patch_stac927x(struct hda_codec *codec)
3345 spec->init = d965_core_init; 3353 spec->init = d965_core_init;
3346 spec->mixer = stac927x_mixer; 3354 spec->mixer = stac927x_mixer;
3347 spec->dmux_nids = stac927x_dmux_nids; 3355 spec->dmux_nids = stac927x_dmux_nids;
3356 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
3348 break; 3357 break;
3349 default: 3358 default:
3350 /* GPIO0 High = Enable EAPD */ 3359 /* GPIO0 High = Enable EAPD */
@@ -3415,6 +3424,7 @@ static int patch_stac9205(struct hda_codec *codec)
3415 spec->dmic_nids = stac9205_dmic_nids; 3424 spec->dmic_nids = stac9205_dmic_nids;
3416 spec->num_dmics = STAC9205_NUM_DMICS; 3425 spec->num_dmics = STAC9205_NUM_DMICS;
3417 spec->dmux_nids = stac9205_dmux_nids; 3426 spec->dmux_nids = stac9205_dmux_nids;
3427 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
3418 3428
3419 spec->init = stac9205_core_init; 3429 spec->init = stac9205_core_init;
3420 spec->mixer = stac9205_mixer; 3430 spec->mixer = stac9205_mixer;