diff options
author | Matt <matt@embeddedalley.com> | 2005-06-27 08:59:41 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2005-07-28 06:09:29 -0400 |
commit | c7d4b2fa3169a1206450bc445d1997a17479644f (patch) | |
tree | 8da458daf2b22b1ac706d8c7632f0ba674cb9c85 | |
parent | b4d3f9d452ec574e0ffb292267427f69bb470631 (diff) |
[ALSA] hda-codec - SigmaTel HDA multichannel support
HDA Codec driver
Adds 6/8 channel support to the SigmaTel HDA patch. Please apply.
Signed-off-by: Matt <matt@embeddedalley.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/pci/hda/patch_sigmatel.c | 733 |
1 files changed, 496 insertions, 237 deletions
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 013be2ea513a..fad825677e7c 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -30,32 +30,33 @@ | |||
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <linux/pci.h> | 31 | #include <linux/pci.h> |
32 | #include <sound/core.h> | 32 | #include <sound/core.h> |
33 | #include <sound/asoundef.h> | ||
33 | #include "hda_codec.h" | 34 | #include "hda_codec.h" |
34 | #include "hda_local.h" | 35 | #include "hda_local.h" |
35 | 36 | ||
36 | #undef STAC_TEST | 37 | #undef STAC_TEST |
37 | 38 | ||
38 | struct sigmatel_spec { | 39 | struct sigmatel_spec { |
40 | snd_kcontrol_new_t *mixers[4]; | ||
41 | unsigned int num_mixers; | ||
42 | |||
43 | unsigned int surr_switch: 1; | ||
44 | |||
39 | /* playback */ | 45 | /* playback */ |
40 | struct hda_multi_out multiout; | 46 | struct hda_multi_out multiout; |
41 | hda_nid_t playback_nid; | 47 | hda_nid_t dac_nids[4]; |
42 | 48 | ||
43 | /* capture */ | 49 | /* capture */ |
44 | hda_nid_t *adc_nids; | 50 | hda_nid_t *adc_nids; |
45 | unsigned int num_adcs; | 51 | unsigned int num_adcs; |
46 | hda_nid_t *mux_nids; | 52 | hda_nid_t *mux_nids; |
47 | unsigned int num_muxes; | 53 | unsigned int num_muxes; |
48 | hda_nid_t capture_nid; | ||
49 | hda_nid_t dig_in_nid; | 54 | hda_nid_t dig_in_nid; |
50 | 55 | ||
51 | /* power management*/ | 56 | #ifdef STAC_TEST |
52 | hda_nid_t *pstate_nids; | ||
53 | unsigned int num_pstates; | ||
54 | |||
55 | /* pin widgets */ | 57 | /* pin widgets */ |
56 | hda_nid_t *pin_nids; | 58 | hda_nid_t *pin_nids; |
57 | unsigned int num_pins; | 59 | unsigned int num_pins; |
58 | #ifdef STAC_TEST | ||
59 | unsigned int *pin_configs; | 60 | unsigned int *pin_configs; |
60 | #endif | 61 | #endif |
61 | 62 | ||
@@ -64,16 +65,20 @@ struct sigmatel_spec { | |||
64 | snd_kcontrol_new_t *mixer; | 65 | snd_kcontrol_new_t *mixer; |
65 | 66 | ||
66 | /* capture source */ | 67 | /* capture source */ |
67 | struct hda_input_mux input_mux; | 68 | struct hda_input_mux *input_mux; |
68 | char input_labels[HDA_MAX_NUM_INPUTS][16]; | ||
69 | unsigned int cur_mux[2]; | 69 | unsigned int cur_mux[2]; |
70 | 70 | ||
71 | /* channel mode */ | 71 | /* channel mode */ |
72 | unsigned int num_ch_modes; | 72 | unsigned int num_ch_modes; |
73 | unsigned int cur_ch_mode; | 73 | unsigned int cur_ch_mode; |
74 | const struct sigmatel_channel_mode *channel_modes; | ||
75 | 74 | ||
76 | struct hda_pcm pcm_rec[1]; /* PCM information */ | 75 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
76 | |||
77 | /* dynamic controls and input_mux */ | ||
78 | struct auto_pin_cfg autocfg; | ||
79 | unsigned int num_kctl_alloc, num_kctl_used; | ||
80 | snd_kcontrol_new_t *kctl_alloc; | ||
81 | struct hda_input_mux private_imux; | ||
77 | }; | 82 | }; |
78 | 83 | ||
79 | static hda_nid_t stac9200_adc_nids[1] = { | 84 | static hda_nid_t stac9200_adc_nids[1] = { |
@@ -88,14 +93,6 @@ static hda_nid_t stac9200_dac_nids[1] = { | |||
88 | 0x02, | 93 | 0x02, |
89 | }; | 94 | }; |
90 | 95 | ||
91 | static hda_nid_t stac9200_pstate_nids[3] = { | ||
92 | 0x01, 0x02, 0x03, | ||
93 | }; | ||
94 | |||
95 | static hda_nid_t stac9200_pin_nids[8] = { | ||
96 | 0x08, 0x09, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, | ||
97 | }; | ||
98 | |||
99 | static hda_nid_t stac922x_adc_nids[2] = { | 96 | static hda_nid_t stac922x_adc_nids[2] = { |
100 | 0x06, 0x07, | 97 | 0x06, 0x07, |
101 | }; | 98 | }; |
@@ -104,24 +101,22 @@ static hda_nid_t stac922x_mux_nids[2] = { | |||
104 | 0x12, 0x13, | 101 | 0x12, 0x13, |
105 | }; | 102 | }; |
106 | 103 | ||
107 | static hda_nid_t stac922x_dac_nids[4] = { | 104 | #ifdef STAC_TEST |
108 | 0x02, 0x03, 0x04, 0x05, | 105 | static hda_nid_t stac9200_pin_nids[8] = { |
109 | }; | 106 | 0x08, 0x09, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, |
110 | |||
111 | static hda_nid_t stac922x_pstate_nids[8] = { | ||
112 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x11, | ||
113 | }; | 107 | }; |
114 | 108 | ||
115 | static hda_nid_t stac922x_pin_nids[10] = { | 109 | static hda_nid_t stac922x_pin_nids[10] = { |
116 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, | 110 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
117 | 0x0f, 0x10, 0x11, 0x15, 0x1b, | 111 | 0x0f, 0x10, 0x11, 0x15, 0x1b, |
118 | }; | 112 | }; |
113 | #endif | ||
119 | 114 | ||
120 | static int stac92xx_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) | 115 | static int stac92xx_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) |
121 | { | 116 | { |
122 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 117 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
123 | struct sigmatel_spec *spec = codec->spec; | 118 | struct sigmatel_spec *spec = codec->spec; |
124 | return snd_hda_input_mux_info(&spec->input_mux, uinfo); | 119 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
125 | } | 120 | } |
126 | 121 | ||
127 | static int stac92xx_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | 122 | static int stac92xx_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) |
@@ -140,26 +135,64 @@ static int stac92xx_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t | |||
140 | struct sigmatel_spec *spec = codec->spec; | 135 | struct sigmatel_spec *spec = codec->spec; |
141 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 136 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
142 | 137 | ||
143 | return snd_hda_input_mux_put(codec, &spec->input_mux, ucontrol, | 138 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
144 | spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); | 139 | spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); |
145 | } | 140 | } |
146 | 141 | ||
147 | static struct hda_verb stac9200_ch2_init[] = { | 142 | static struct hda_verb stac9200_core_init[] = { |
148 | /* set dac0mux for dac converter */ | 143 | /* set dac0mux for dac converter */ |
149 | { 0x07, 0x701, 0x00}, | 144 | { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
150 | {} | 145 | {} |
151 | }; | 146 | }; |
152 | 147 | ||
153 | static struct hda_verb stac922x_ch2_init[] = { | 148 | static struct hda_verb stac922x_core_init[] = { |
154 | /* set master volume and direct control */ | 149 | /* set master volume and direct control */ |
155 | { 0x16, 0x70f, 0xff}, | 150 | { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
156 | {} | 151 | {} |
157 | }; | 152 | }; |
158 | 153 | ||
159 | struct sigmatel_channel_mode { | 154 | static int stac922x_channel_modes[3] = {2, 6, 8}; |
160 | unsigned int channels; | 155 | |
161 | const struct hda_verb *sequence; | 156 | static int stac922x_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) |
162 | }; | 157 | { |
158 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
159 | struct sigmatel_spec *spec = codec->spec; | ||
160 | |||
161 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
162 | uinfo->count = 1; | ||
163 | uinfo->value.enumerated.items = spec->num_ch_modes; | ||
164 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
165 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; | ||
166 | sprintf(uinfo->value.enumerated.name, "%dch", | ||
167 | stac922x_channel_modes[uinfo->value.enumerated.item]); | ||
168 | return 0; | ||
169 | } | ||
170 | |||
171 | static int stac922x_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
172 | { | ||
173 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
174 | struct sigmatel_spec *spec = codec->spec; | ||
175 | |||
176 | ucontrol->value.enumerated.item[0] = spec->cur_ch_mode; | ||
177 | return 0; | ||
178 | } | ||
179 | |||
180 | static int stac922x_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
181 | { | ||
182 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
183 | struct sigmatel_spec *spec = codec->spec; | ||
184 | |||
185 | if (ucontrol->value.enumerated.item[0] >= spec->num_ch_modes) | ||
186 | ucontrol->value.enumerated.item[0] = spec->num_ch_modes; | ||
187 | if (ucontrol->value.enumerated.item[0] == spec->cur_ch_mode && | ||
188 | ! codec->in_resume) | ||
189 | return 0; | ||
190 | |||
191 | spec->cur_ch_mode = ucontrol->value.enumerated.item[0]; | ||
192 | spec->multiout.max_channels = stac922x_channel_modes[spec->cur_ch_mode]; | ||
193 | |||
194 | return 1; | ||
195 | } | ||
163 | 196 | ||
164 | static snd_kcontrol_new_t stac9200_mixer[] = { | 197 | static snd_kcontrol_new_t stac9200_mixer[] = { |
165 | HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), | 198 | HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), |
@@ -174,13 +207,12 @@ static snd_kcontrol_new_t stac9200_mixer[] = { | |||
174 | }, | 207 | }, |
175 | HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), | 208 | HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), |
176 | HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), | 209 | HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), |
177 | HDA_CODEC_VOLUME("Input Mux Volume", 0x0c, 0, HDA_OUTPUT), | 210 | HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT), |
178 | { } /* end */ | 211 | { } /* end */ |
179 | }; | 212 | }; |
180 | 213 | ||
214 | /* This needs to be generated dynamically based on sequence */ | ||
181 | static snd_kcontrol_new_t stac922x_mixer[] = { | 215 | static snd_kcontrol_new_t stac922x_mixer[] = { |
182 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x2, 0x0, HDA_OUTPUT), | ||
183 | HDA_CODEC_MUTE("PCM Playback Switch", 0x2, 0x0, HDA_OUTPUT), | ||
184 | { | 216 | { |
185 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 217 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
186 | .name = "Input Source", | 218 | .name = "Input Source", |
@@ -195,14 +227,38 @@ static snd_kcontrol_new_t stac922x_mixer[] = { | |||
195 | { } /* end */ | 227 | { } /* end */ |
196 | }; | 228 | }; |
197 | 229 | ||
230 | static snd_kcontrol_new_t stac922x_ch_mode_mixer[] = { | ||
231 | { | ||
232 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
233 | .name = "Channel Mode", | ||
234 | .info = stac922x_ch_mode_info, | ||
235 | .get = stac922x_ch_mode_get, | ||
236 | .put = stac922x_ch_mode_put, | ||
237 | }, | ||
238 | { } /* end */ | ||
239 | }; | ||
240 | |||
198 | static int stac92xx_build_controls(struct hda_codec *codec) | 241 | static int stac92xx_build_controls(struct hda_codec *codec) |
199 | { | 242 | { |
200 | struct sigmatel_spec *spec = codec->spec; | 243 | struct sigmatel_spec *spec = codec->spec; |
201 | int err; | 244 | int err; |
245 | int i; | ||
202 | 246 | ||
203 | err = snd_hda_add_new_ctls(codec, spec->mixer); | 247 | err = snd_hda_add_new_ctls(codec, spec->mixer); |
204 | if (err < 0) | 248 | if (err < 0) |
205 | return err; | 249 | return err; |
250 | |||
251 | for (i = 0; i < spec->num_mixers; i++) { | ||
252 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | ||
253 | if (err < 0) | ||
254 | return err; | ||
255 | } | ||
256 | |||
257 | if (spec->surr_switch) { | ||
258 | err = snd_hda_add_new_ctls(codec, stac922x_ch_mode_mixer); | ||
259 | if (err < 0) | ||
260 | return err; | ||
261 | } | ||
206 | if (spec->multiout.dig_out_nid) { | 262 | if (spec->multiout.dig_out_nid) { |
207 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); | 263 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); |
208 | if (err < 0) | 264 | if (err < 0) |
@@ -222,9 +278,9 @@ static unsigned int stac9200_pin_configs[8] = { | |||
222 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, | 278 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
223 | }; | 279 | }; |
224 | 280 | ||
225 | static unsigned int stac922x_pin_configs[14] = { | 281 | static unsigned int stac922x_pin_configs[10] = { |
226 | 0x40000100, 0x40000100, 0x40000100, 0x01114010, | 282 | 0x01014010, 0x01014011, 0x01014012, 0x0221401f, |
227 | 0x01813122, 0x40000100, 0x01447010, 0x01c47010, | 283 | 0x01813122, 0x01014014, 0x01441030, 0x01c41030, |
228 | 0x40000100, 0x40000100, | 284 | 0x40000100, 0x40000100, |
229 | }; | 285 | }; |
230 | 286 | ||
@@ -255,180 +311,66 @@ static void stac92xx_set_config_regs(struct hda_codec *codec) | |||
255 | } | 311 | } |
256 | #endif | 312 | #endif |
257 | 313 | ||
258 | static int stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, unsigned int value) | ||
259 | { | ||
260 | unsigned int pin_ctl; | ||
261 | |||
262 | pin_ctl = snd_hda_codec_read(codec, nid, 0, | ||
263 | AC_VERB_GET_PIN_WIDGET_CONTROL, | ||
264 | 0x00); | ||
265 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
266 | pin_ctl | value); | ||
267 | |||
268 | return 0; | ||
269 | } | ||
270 | |||
271 | static int stac92xx_set_vref(struct hda_codec *codec, hda_nid_t nid) | ||
272 | { | ||
273 | unsigned int vref_caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP) >> AC_PINCAP_VREF_SHIFT; | ||
274 | unsigned int vref_ctl = AC_PINCTL_VREF_HIZ; | ||
275 | |||
276 | if (vref_caps & AC_PINCAP_VREF_100) | ||
277 | vref_ctl = AC_PINCTL_VREF_100; | ||
278 | else if (vref_caps & AC_PINCAP_VREF_80) | ||
279 | vref_ctl = AC_PINCTL_VREF_80; | ||
280 | else if (vref_caps & AC_PINCAP_VREF_50) | ||
281 | vref_ctl = AC_PINCTL_VREF_50; | ||
282 | else if (vref_caps & AC_PINCAP_VREF_GRD) | ||
283 | vref_ctl = AC_PINCTL_VREF_GRD; | ||
284 | |||
285 | stac92xx_set_pinctl(codec, nid, vref_ctl); | ||
286 | |||
287 | return 0; | ||
288 | } | ||
289 | |||
290 | /* | 314 | /* |
291 | * retrieve the default device type from the default config value | 315 | * Analog playback callbacks |
292 | */ | 316 | */ |
293 | #define get_defcfg_type(cfg) ((cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT) | 317 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, |
294 | #define get_defcfg_location(cfg) ((cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT) | 318 | struct hda_codec *codec, |
295 | 319 | snd_pcm_substream_t *substream) | |
296 | static int stac92xx_config_pin(struct hda_codec *codec, hda_nid_t nid, unsigned int pin_cfg) | ||
297 | { | 320 | { |
298 | struct sigmatel_spec *spec = codec->spec; | 321 | struct sigmatel_spec *spec = codec->spec; |
299 | u32 location = get_defcfg_location(pin_cfg); | 322 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); |
300 | char *label; | ||
301 | const char *type = NULL; | ||
302 | int ainput = 0; | ||
303 | |||
304 | switch(get_defcfg_type(pin_cfg)) { | ||
305 | case AC_JACK_HP_OUT: | ||
306 | /* Enable HP amp */ | ||
307 | stac92xx_set_pinctl(codec, nid, AC_PINCTL_HP_EN); | ||
308 | /* Fall through */ | ||
309 | case AC_JACK_SPDIF_OUT: | ||
310 | case AC_JACK_LINE_OUT: | ||
311 | case AC_JACK_SPEAKER: | ||
312 | /* Enable output */ | ||
313 | stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); | ||
314 | break; | ||
315 | case AC_JACK_SPDIF_IN: | ||
316 | stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN); | ||
317 | break; | ||
318 | case AC_JACK_MIC_IN: | ||
319 | if ((location & 0x0f) == AC_JACK_LOC_FRONT) | ||
320 | type = "Front Mic"; | ||
321 | else | ||
322 | type = "Mic"; | ||
323 | ainput = 1; | ||
324 | /* Set vref */ | ||
325 | stac92xx_set_vref(codec, nid); | ||
326 | stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN); | ||
327 | break; | ||
328 | case AC_JACK_CD: | ||
329 | type = "CD"; | ||
330 | ainput = 1; | ||
331 | stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN); | ||
332 | break; | ||
333 | case AC_JACK_LINE_IN: | ||
334 | if ((location & 0x0f) == AC_JACK_LOC_FRONT) | ||
335 | type = "Front Line"; | ||
336 | else | ||
337 | type = "Line"; | ||
338 | ainput = 1; | ||
339 | stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN); | ||
340 | break; | ||
341 | case AC_JACK_AUX: | ||
342 | if ((location & 0x0f) == AC_JACK_LOC_FRONT) | ||
343 | type = "Front Aux"; | ||
344 | else | ||
345 | type = "Aux"; | ||
346 | ainput = 1; | ||
347 | stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN); | ||
348 | break; | ||
349 | } | ||
350 | |||
351 | if (ainput) { | ||
352 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; | ||
353 | int i, j, num_cons, index = -1; | ||
354 | if (!type) | ||
355 | type = "Input"; | ||
356 | label = spec->input_labels[spec->input_mux.num_items]; | ||
357 | strcpy(label, type); | ||
358 | spec->input_mux.items[spec->input_mux.num_items].label = label; | ||
359 | for (i=0; i<spec->num_muxes; i++) { | ||
360 | num_cons = snd_hda_get_connections(codec, spec->mux_nids[i], con_lst, HDA_MAX_NUM_INPUTS); | ||
361 | for (j=0; j<num_cons; j++) | ||
362 | if (con_lst[j] == nid) { | ||
363 | index = j; | ||
364 | break; | ||
365 | } | ||
366 | if (index >= 0) | ||
367 | break; | ||
368 | } | ||
369 | spec->input_mux.items[spec->input_mux.num_items].index = index; | ||
370 | spec->input_mux.num_items++; | ||
371 | } | ||
372 | |||
373 | return 0; | ||
374 | } | 323 | } |
375 | 324 | ||
376 | static int stac92xx_config_pins(struct hda_codec *codec) | 325 | /* |
326 | * set up the i/o for analog out | ||
327 | * when the digital out is available, copy the front out to digital out, too. | ||
328 | */ | ||
329 | static int stac92xx_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_out *mout, | ||
330 | unsigned int stream_tag, | ||
331 | unsigned int format, | ||
332 | snd_pcm_substream_t *substream) | ||
377 | { | 333 | { |
378 | struct sigmatel_spec *spec = codec->spec; | 334 | hda_nid_t *nids = mout->dac_nids; |
335 | int chs = substream->runtime->channels; | ||
379 | int i; | 336 | int i; |
380 | unsigned int pin_cfg; | ||
381 | |||
382 | for (i=0; i < spec->num_pins; i++) { | ||
383 | /* Default to disabled */ | ||
384 | snd_hda_codec_write(codec, spec->pin_nids[i], 0, | ||
385 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
386 | 0x00); | ||
387 | |||
388 | pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0, | ||
389 | AC_VERB_GET_CONFIG_DEFAULT, | ||
390 | 0x00); | ||
391 | if (((pin_cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT) == AC_JACK_PORT_NONE) | ||
392 | continue; /* Move on */ | ||
393 | 337 | ||
394 | stac92xx_config_pin(codec, spec->pin_nids[i], pin_cfg); | 338 | down(&codec->spdif_mutex); |
339 | if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) { | ||
340 | if (chs == 2 && | ||
341 | snd_hda_is_supported_format(codec, mout->dig_out_nid, format) && | ||
342 | ! (codec->spdif_status & IEC958_AES0_NONAUDIO)) { | ||
343 | mout->dig_out_used = HDA_DIG_ANALOG_DUP; | ||
344 | /* setup digital receiver */ | ||
345 | snd_hda_codec_setup_stream(codec, mout->dig_out_nid, | ||
346 | stream_tag, 0, format); | ||
347 | } else { | ||
348 | mout->dig_out_used = 0; | ||
349 | snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0); | ||
350 | } | ||
395 | } | 351 | } |
396 | 352 | up(&codec->spdif_mutex); | |
397 | return 0; | 353 | |
398 | } | 354 | /* front */ |
399 | 355 | snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag, 0, format); | |
400 | static int stac92xx_init(struct hda_codec *codec) | 356 | if (mout->hp_nid) |
401 | { | 357 | /* headphone out will just decode front left/right (stereo) */ |
402 | struct sigmatel_spec *spec = codec->spec; | 358 | snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, 0, format); |
403 | int i; | 359 | /* surrounds */ |
404 | 360 | if (mout->max_channels > 2) | |
405 | for (i=0; i < spec->num_pstates; i++) | 361 | for (i = 1; i < mout->num_dacs; i++) { |
406 | snd_hda_codec_write(codec, spec->pstate_nids[i], 0, | 362 | if ((mout->max_channels == 6) && (i == 3)) |
407 | AC_VERB_SET_POWER_STATE, 0x00); | 363 | break; |
408 | 364 | if (chs >= (i + 1) * 2) /* independent out */ | |
409 | mdelay(100); | 365 | snd_hda_codec_setup_stream(codec, nids[i], stream_tag, i * 2, |
410 | 366 | format); | |
411 | snd_hda_sequence_write(codec, spec->init); | 367 | else /* copy front */ |
412 | 368 | snd_hda_codec_setup_stream(codec, nids[i], stream_tag, 0, | |
413 | #ifdef STAC_TEST | 369 | format); |
414 | stac92xx_set_config_regs(codec); | 370 | } |
415 | #endif | ||
416 | |||
417 | stac92xx_config_pins(codec); | ||
418 | |||
419 | return 0; | 371 | return 0; |
420 | } | 372 | } |
421 | 373 | ||
422 | /* | ||
423 | * Analog playback callbacks | ||
424 | */ | ||
425 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, | ||
426 | struct hda_codec *codec, | ||
427 | snd_pcm_substream_t *substream) | ||
428 | { | ||
429 | struct sigmatel_spec *spec = codec->spec; | ||
430 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); | ||
431 | } | ||
432 | 374 | ||
433 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | 375 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
434 | struct hda_codec *codec, | 376 | struct hda_codec *codec, |
@@ -437,7 +379,7 @@ static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |||
437 | snd_pcm_substream_t *substream) | 379 | snd_pcm_substream_t *substream) |
438 | { | 380 | { |
439 | struct sigmatel_spec *spec = codec->spec; | 381 | struct sigmatel_spec *spec = codec->spec; |
440 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, | 382 | return stac92xx_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, |
441 | format, substream); | 383 | format, substream); |
442 | } | 384 | } |
443 | 385 | ||
@@ -516,7 +458,7 @@ static struct hda_pcm_stream stac92xx_pcm_digital_capture = { | |||
516 | static struct hda_pcm_stream stac92xx_pcm_analog_playback = { | 458 | static struct hda_pcm_stream stac92xx_pcm_analog_playback = { |
517 | .substreams = 1, | 459 | .substreams = 1, |
518 | .channels_min = 2, | 460 | .channels_min = 2, |
519 | .channels_max = 2, | 461 | .channels_max = 8, |
520 | .nid = 0x02, /* NID to query formats and rates */ | 462 | .nid = 0x02, /* NID to query formats and rates */ |
521 | .ops = { | 463 | .ops = { |
522 | .open = stac92xx_playback_pcm_open, | 464 | .open = stac92xx_playback_pcm_open, |
@@ -544,11 +486,9 @@ static int stac92xx_build_pcms(struct hda_codec *codec) | |||
544 | codec->num_pcms = 1; | 486 | codec->num_pcms = 1; |
545 | codec->pcm_info = info; | 487 | codec->pcm_info = info; |
546 | 488 | ||
547 | info->name = "STAC92xx"; | 489 | info->name = "STAC92xx Analog"; |
548 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; | 490 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; |
549 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->playback_nid; | ||
550 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; | 491 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; |
551 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->capture_nid; | ||
552 | 492 | ||
553 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { | 493 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
554 | codec->num_pcms++; | 494 | codec->num_pcms++; |
@@ -567,9 +507,325 @@ static int stac92xx_build_pcms(struct hda_codec *codec) | |||
567 | return 0; | 507 | return 0; |
568 | } | 508 | } |
569 | 509 | ||
510 | #define NUM_CONTROL_ALLOC 32 | ||
511 | |||
512 | enum { | ||
513 | STAC_CTL_WIDGET_VOL, | ||
514 | STAC_CTL_WIDGET_MUTE, | ||
515 | }; | ||
516 | |||
517 | static snd_kcontrol_new_t stac92xx_control_templates[] = { | ||
518 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), | ||
519 | HDA_CODEC_MUTE(NULL, 0, 0, 0), | ||
520 | }; | ||
521 | |||
522 | /* add dynamic controls */ | ||
523 | static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val) | ||
524 | { | ||
525 | snd_kcontrol_new_t *knew; | ||
526 | |||
527 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { | ||
528 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; | ||
529 | |||
530 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ | ||
531 | if (! knew) | ||
532 | return -ENOMEM; | ||
533 | if (spec->kctl_alloc) { | ||
534 | memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); | ||
535 | kfree(spec->kctl_alloc); | ||
536 | } | ||
537 | spec->kctl_alloc = knew; | ||
538 | spec->num_kctl_alloc = num; | ||
539 | } | ||
540 | |||
541 | knew = &spec->kctl_alloc[spec->num_kctl_used]; | ||
542 | *knew = stac92xx_control_templates[type]; | ||
543 | knew->name = snd_kmalloc_strdup(name, GFP_KERNEL); | ||
544 | if (! knew->name) | ||
545 | return -ENOMEM; | ||
546 | knew->private_value = val; | ||
547 | spec->num_kctl_used++; | ||
548 | return 0; | ||
549 | } | ||
550 | |||
551 | /* fill in the dac_nids table from the parsed pin configuration */ | ||
552 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, const struct auto_pin_cfg *cfg) | ||
553 | { | ||
554 | struct sigmatel_spec *spec = codec->spec; | ||
555 | hda_nid_t nid; | ||
556 | int i; | ||
557 | |||
558 | /* check the pins hardwired to audio widget */ | ||
559 | for (i = 0; i < cfg->line_outs; i++) { | ||
560 | nid = cfg->line_out_pins[i]; | ||
561 | spec->multiout.dac_nids[i] = snd_hda_codec_read(codec, nid, 0, | ||
562 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; | ||
563 | } | ||
564 | |||
565 | spec->multiout.num_dacs = cfg->line_outs; | ||
566 | |||
567 | return 0; | ||
568 | } | ||
569 | |||
570 | /* add playback controls from the parsed DAC table */ | ||
571 | static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec, const struct auto_pin_cfg *cfg) | ||
572 | { | ||
573 | char name[32]; | ||
574 | static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; | ||
575 | hda_nid_t nid; | ||
576 | int i, err; | ||
577 | |||
578 | for (i = 0; i < cfg->line_outs; i++) { | ||
579 | if (! spec->multiout.dac_nids[i]) | ||
580 | continue; | ||
581 | |||
582 | nid = spec->multiout.dac_nids[i]; | ||
583 | |||
584 | if (i == 2) { | ||
585 | /* Center/LFE */ | ||
586 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Center Playback Volume", | ||
587 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) | ||
588 | return err; | ||
589 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "LFE Playback Volume", | ||
590 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) | ||
591 | return err; | ||
592 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Center Playback Switch", | ||
593 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) | ||
594 | return err; | ||
595 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "LFE Playback Switch", | ||
596 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) | ||
597 | return err; | ||
598 | } else { | ||
599 | sprintf(name, "%s Playback Volume", chname[i]); | ||
600 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name, | ||
601 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) | ||
602 | return err; | ||
603 | sprintf(name, "%s Playback Switch", chname[i]); | ||
604 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name, | ||
605 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) | ||
606 | return err; | ||
607 | } | ||
608 | } | ||
609 | |||
610 | return 0; | ||
611 | } | ||
612 | |||
613 | /* add playback controls for HP output */ | ||
614 | static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, struct auto_pin_cfg *cfg) | ||
615 | { | ||
616 | struct sigmatel_spec *spec = codec->spec; | ||
617 | hda_nid_t pin = cfg->hp_pin; | ||
618 | hda_nid_t nid; | ||
619 | int i, err; | ||
620 | |||
621 | if (! pin) | ||
622 | return 0; | ||
623 | |||
624 | nid = snd_hda_codec_read(codec, pin, 0, AC_VERB_GET_CONNECT_LIST, 0) & 0xff; | ||
625 | for (i = 0; i < cfg->line_outs; i++) { | ||
626 | if (! spec->multiout.dac_nids[i]) | ||
627 | continue; | ||
628 | if (spec->multiout.dac_nids[i] == nid) | ||
629 | return 0; | ||
630 | } | ||
631 | |||
632 | spec->multiout.hp_nid = nid; | ||
633 | |||
634 | /* control HP volume/switch on the output mixer amp */ | ||
635 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Headphone Playback Volume", | ||
636 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) | ||
637 | return err; | ||
638 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Headphone Playback Switch", | ||
639 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) | ||
640 | return err; | ||
641 | |||
642 | return 0; | ||
643 | } | ||
644 | |||
645 | /* create playback/capture controls for input pins */ | ||
646 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) | ||
647 | { | ||
648 | struct sigmatel_spec *spec = codec->spec; | ||
649 | static char *labels[AUTO_PIN_LAST] = { | ||
650 | "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" | ||
651 | }; | ||
652 | struct hda_input_mux *imux = &spec->private_imux; | ||
653 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; | ||
654 | int i, j, k; | ||
655 | |||
656 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
657 | int index = -1; | ||
658 | if (cfg->input_pins[i]) { | ||
659 | imux->items[imux->num_items].label = labels[i]; | ||
660 | |||
661 | for (j=0; j<spec->num_muxes; j++) { | ||
662 | int num_cons = snd_hda_get_connections(codec, spec->mux_nids[j], con_lst, HDA_MAX_NUM_INPUTS); | ||
663 | for (k=0; k<num_cons; k++) | ||
664 | if (con_lst[k] == cfg->input_pins[i]) { | ||
665 | index = k; | ||
666 | break; | ||
667 | } | ||
668 | if (index >= 0) | ||
669 | break; | ||
670 | } | ||
671 | imux->items[imux->num_items].index = index; | ||
672 | imux->num_items++; | ||
673 | } | ||
674 | } | ||
675 | |||
676 | return 0; | ||
677 | } | ||
678 | |||
679 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) | ||
680 | |||
681 | { | ||
682 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | ||
683 | } | ||
684 | |||
685 | static void stac92xx_auto_init_multi_out(struct hda_codec *codec) | ||
686 | { | ||
687 | struct sigmatel_spec *spec = codec->spec; | ||
688 | int i; | ||
689 | |||
690 | for (i = 0; i < spec->autocfg.line_outs; i++) { | ||
691 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | ||
692 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); | ||
693 | } | ||
694 | } | ||
695 | |||
696 | static void stac92xx_auto_init_hp_out(struct hda_codec *codec) | ||
697 | { | ||
698 | struct sigmatel_spec *spec = codec->spec; | ||
699 | hda_nid_t pin; | ||
700 | |||
701 | pin = spec->autocfg.hp_pin; | ||
702 | if (pin) /* connect to front */ | ||
703 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); | ||
704 | } | ||
705 | |||
706 | static int stac922x_parse_auto_config(struct hda_codec *codec) | ||
707 | { | ||
708 | struct sigmatel_spec *spec = codec->spec; | ||
709 | int err; | ||
710 | |||
711 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg)) < 0) | ||
712 | return err; | ||
713 | if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) | ||
714 | return err; | ||
715 | if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin) | ||
716 | return 0; /* can't find valid pin config */ | ||
717 | |||
718 | if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || | ||
719 | (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 || | ||
720 | (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) | ||
721 | return err; | ||
722 | |||
723 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | ||
724 | if (spec->multiout.max_channels > 2) { | ||
725 | spec->surr_switch = 1; | ||
726 | spec->cur_ch_mode = 1; | ||
727 | spec->num_ch_modes = 2; | ||
728 | if (spec->multiout.max_channels == 8) { | ||
729 | spec->cur_ch_mode++; | ||
730 | spec->num_ch_modes++; | ||
731 | } | ||
732 | } | ||
733 | |||
734 | if (spec->autocfg.dig_out_pin) { | ||
735 | spec->multiout.dig_out_nid = 0x08; | ||
736 | stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_out_pin, AC_PINCTL_OUT_EN); | ||
737 | } | ||
738 | if (spec->autocfg.dig_in_pin) { | ||
739 | spec->dig_in_nid = 0x09; | ||
740 | stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_in_pin, AC_PINCTL_IN_EN); | ||
741 | } | ||
742 | |||
743 | if (spec->kctl_alloc) | ||
744 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | ||
745 | |||
746 | spec->input_mux = &spec->private_imux; | ||
747 | |||
748 | return 1; | ||
749 | } | ||
750 | |||
751 | static int stac9200_parse_auto_config(struct hda_codec *codec) | ||
752 | { | ||
753 | struct sigmatel_spec *spec = codec->spec; | ||
754 | int err; | ||
755 | |||
756 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg)) < 0) | ||
757 | return err; | ||
758 | |||
759 | if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) | ||
760 | return err; | ||
761 | |||
762 | if (spec->autocfg.dig_out_pin) { | ||
763 | spec->multiout.dig_out_nid = 0x05; | ||
764 | stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_out_pin, AC_PINCTL_OUT_EN); | ||
765 | } | ||
766 | if (spec->autocfg.dig_in_pin) { | ||
767 | spec->dig_in_nid = 0x04; | ||
768 | stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_in_pin, AC_PINCTL_IN_EN); | ||
769 | } | ||
770 | |||
771 | if (spec->kctl_alloc) | ||
772 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | ||
773 | |||
774 | spec->input_mux = &spec->private_imux; | ||
775 | |||
776 | return 1; | ||
777 | } | ||
778 | |||
779 | static int stac92xx_init_pstate(struct hda_codec *codec) | ||
780 | { | ||
781 | hda_nid_t nid, nid_start; | ||
782 | int nodes; | ||
783 | |||
784 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_POWER_STATE, 0x00); | ||
785 | |||
786 | nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid_start); | ||
787 | for (nid = nid_start; nid < nodes + nid_start; nid++) { | ||
788 | unsigned int wid_caps = snd_hda_param_read(codec, nid, | ||
789 | AC_PAR_AUDIO_WIDGET_CAP); | ||
790 | if (wid_caps & AC_WCAP_POWER) | ||
791 | snd_hda_codec_write(codec, nid, 0, | ||
792 | AC_VERB_SET_POWER_STATE, 0x00); | ||
793 | } | ||
794 | |||
795 | mdelay(100); | ||
796 | |||
797 | return 0; | ||
798 | } | ||
799 | |||
800 | static int stac92xx_init(struct hda_codec *codec) | ||
801 | { | ||
802 | struct sigmatel_spec *spec = codec->spec; | ||
803 | |||
804 | stac92xx_init_pstate(codec); | ||
805 | |||
806 | snd_hda_sequence_write(codec, spec->init); | ||
807 | |||
808 | stac92xx_auto_init_multi_out(codec); | ||
809 | stac92xx_auto_init_hp_out(codec); | ||
810 | |||
811 | return 0; | ||
812 | } | ||
813 | |||
570 | static void stac92xx_free(struct hda_codec *codec) | 814 | static void stac92xx_free(struct hda_codec *codec) |
571 | { | 815 | { |
572 | kfree(codec->spec); | 816 | struct sigmatel_spec *spec = codec->spec; |
817 | int i; | ||
818 | |||
819 | if (! spec) | ||
820 | return; | ||
821 | |||
822 | if (spec->kctl_alloc) { | ||
823 | for (i = 0; i < spec->num_kctl_used; i++) | ||
824 | kfree(spec->kctl_alloc[i].name); | ||
825 | kfree(spec->kctl_alloc); | ||
826 | } | ||
827 | |||
828 | kfree(spec); | ||
573 | } | 829 | } |
574 | 830 | ||
575 | static struct hda_codec_ops stac92xx_patch_ops = { | 831 | static struct hda_codec_ops stac92xx_patch_ops = { |
@@ -582,6 +838,7 @@ static struct hda_codec_ops stac92xx_patch_ops = { | |||
582 | static int patch_stac9200(struct hda_codec *codec) | 838 | static int patch_stac9200(struct hda_codec *codec) |
583 | { | 839 | { |
584 | struct sigmatel_spec *spec; | 840 | struct sigmatel_spec *spec; |
841 | int err; | ||
585 | 842 | ||
586 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | 843 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); |
587 | if (spec == NULL) | 844 | if (spec == NULL) |
@@ -589,26 +846,27 @@ static int patch_stac9200(struct hda_codec *codec) | |||
589 | 846 | ||
590 | codec->spec = spec; | 847 | codec->spec = spec; |
591 | 848 | ||
849 | #ifdef STAC_TEST | ||
850 | spec->pin_nids = stac9200_pin_nids; | ||
851 | spec->num_pins = 8; | ||
852 | spec->pin_configs = stac9200_pin_configs; | ||
853 | stac92xx_set_config_regs(codec); | ||
854 | #endif | ||
592 | spec->multiout.max_channels = 2; | 855 | spec->multiout.max_channels = 2; |
593 | spec->multiout.num_dacs = 1; | 856 | spec->multiout.num_dacs = 1; |
594 | spec->multiout.dac_nids = stac9200_dac_nids; | 857 | spec->multiout.dac_nids = stac9200_dac_nids; |
595 | spec->multiout.dig_out_nid = 0x05; | ||
596 | spec->dig_in_nid = 0x04; | ||
597 | spec->adc_nids = stac9200_adc_nids; | 858 | spec->adc_nids = stac9200_adc_nids; |
598 | spec->mux_nids = stac9200_mux_nids; | 859 | spec->mux_nids = stac9200_mux_nids; |
599 | spec->num_muxes = 1; | 860 | spec->num_muxes = 1; |
600 | spec->input_mux.num_items = 0; | 861 | |
601 | spec->pstate_nids = stac9200_pstate_nids; | 862 | spec->init = stac9200_core_init; |
602 | spec->num_pstates = 3; | ||
603 | spec->pin_nids = stac9200_pin_nids; | ||
604 | #ifdef STAC_TEST | ||
605 | spec->pin_configs = stac9200_pin_configs; | ||
606 | #endif | ||
607 | spec->num_pins = 8; | ||
608 | spec->init = stac9200_ch2_init; | ||
609 | spec->mixer = stac9200_mixer; | 863 | spec->mixer = stac9200_mixer; |
610 | spec->playback_nid = 0x02; | 864 | |
611 | spec->capture_nid = 0x03; | 865 | err = stac9200_parse_auto_config(codec); |
866 | if (err < 0) { | ||
867 | stac92xx_free(codec); | ||
868 | return err; | ||
869 | } | ||
612 | 870 | ||
613 | codec->patch_ops = stac92xx_patch_ops; | 871 | codec->patch_ops = stac92xx_patch_ops; |
614 | 872 | ||
@@ -618,6 +876,7 @@ static int patch_stac9200(struct hda_codec *codec) | |||
618 | static int patch_stac922x(struct hda_codec *codec) | 876 | static int patch_stac922x(struct hda_codec *codec) |
619 | { | 877 | { |
620 | struct sigmatel_spec *spec; | 878 | struct sigmatel_spec *spec; |
879 | int err; | ||
621 | 880 | ||
622 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | 881 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); |
623 | if (spec == NULL) | 882 | if (spec == NULL) |
@@ -625,26 +884,26 @@ static int patch_stac922x(struct hda_codec *codec) | |||
625 | 884 | ||
626 | codec->spec = spec; | 885 | codec->spec = spec; |
627 | 886 | ||
628 | spec->multiout.max_channels = 2; | ||
629 | spec->multiout.num_dacs = 4; | ||
630 | spec->multiout.dac_nids = stac922x_dac_nids; | ||
631 | spec->multiout.dig_out_nid = 0x08; | ||
632 | spec->dig_in_nid = 0x09; | ||
633 | spec->adc_nids = stac922x_adc_nids; | ||
634 | spec->mux_nids = stac922x_mux_nids; | ||
635 | spec->num_muxes = 2; | ||
636 | spec->input_mux.num_items = 0; | ||
637 | spec->pstate_nids = stac922x_pstate_nids; | ||
638 | spec->num_pstates = 8; | ||
639 | spec->pin_nids = stac922x_pin_nids; | ||
640 | #ifdef STAC_TEST | 887 | #ifdef STAC_TEST |
888 | spec->num_pins = 10; | ||
889 | spec->pin_nids = stac922x_pin_nids; | ||
641 | spec->pin_configs = stac922x_pin_configs; | 890 | spec->pin_configs = stac922x_pin_configs; |
891 | stac92xx_set_config_regs(codec); | ||
642 | #endif | 892 | #endif |
643 | spec->num_pins = 10; | 893 | spec->adc_nids = stac922x_adc_nids; |
644 | spec->init = stac922x_ch2_init; | 894 | spec->mux_nids = stac922x_mux_nids; |
895 | spec->num_muxes = 2; | ||
896 | |||
897 | spec->init = stac922x_core_init; | ||
645 | spec->mixer = stac922x_mixer; | 898 | spec->mixer = stac922x_mixer; |
646 | spec->playback_nid = 0x02; | 899 | |
647 | spec->capture_nid = 0x06; | 900 | spec->multiout.dac_nids = spec->dac_nids; |
901 | |||
902 | err = stac922x_parse_auto_config(codec); | ||
903 | if (err < 0) { | ||
904 | stac92xx_free(codec); | ||
905 | return err; | ||
906 | } | ||
648 | 907 | ||
649 | codec->patch_ops = stac92xx_patch_ops; | 908 | codec->patch_ops = stac92xx_patch_ops; |
650 | 909 | ||