Commit | Line | Data |
---|---|---|
c9b443d4 TD |
1 | /* |
2 | * HD audio interface patch for Conexant HDA audio codec | |
3 | * | |
4 | * Copyright (c) 2006 Pototskiy Akex <alex.pototskiy@gmail.com> | |
5 | * Takashi Iwai <tiwai@suse.de> | |
6 | * Tobin Davis <tdavis@dsl-only.net> | |
7 | * | |
8 | * This driver is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 2 of the License, or | |
11 | * (at your option) any later version. | |
12 | * | |
13 | * This driver is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | */ | |
22 | ||
c9b443d4 TD |
23 | #include <linux/init.h> |
24 | #include <linux/delay.h> | |
25 | #include <linux/slab.h> | |
26 | #include <linux/pci.h> | |
27 | #include <sound/core.h> | |
bc7a166d UD |
28 | #include <sound/jack.h> |
29 | ||
c9b443d4 TD |
30 | #include "hda_codec.h" |
31 | #include "hda_local.h" | |
c0f8faf0 | 32 | #include "hda_beep.h" |
c9b443d4 TD |
33 | |
34 | #define CXT_PIN_DIR_IN 0x00 | |
35 | #define CXT_PIN_DIR_OUT 0x01 | |
36 | #define CXT_PIN_DIR_INOUT 0x02 | |
37 | #define CXT_PIN_DIR_IN_NOMICBIAS 0x03 | |
38 | #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04 | |
39 | ||
40 | #define CONEXANT_HP_EVENT 0x37 | |
41 | #define CONEXANT_MIC_EVENT 0x38 | |
42 | ||
bc7a166d UD |
43 | /* Conexant 5051 specific */ |
44 | ||
ecda0cff | 45 | #define CXT5051_SPDIF_OUT 0x12 |
bc7a166d UD |
46 | #define CXT5051_PORTB_EVENT 0x38 |
47 | #define CXT5051_PORTC_EVENT 0x39 | |
c9b443d4 | 48 | |
faddaa5d TI |
49 | #define AUTO_MIC_PORTB (1 << 1) |
50 | #define AUTO_MIC_PORTC (1 << 2) | |
c9b443d4 | 51 | |
bc7a166d UD |
52 | struct conexant_jack { |
53 | ||
54 | hda_nid_t nid; | |
55 | int type; | |
56 | struct snd_jack *jack; | |
57 | ||
58 | }; | |
59 | ||
c9b443d4 TD |
60 | struct conexant_spec { |
61 | ||
62 | struct snd_kcontrol_new *mixers[5]; | |
63 | int num_mixers; | |
dd5746a8 | 64 | hda_nid_t vmaster_nid; |
c9b443d4 TD |
65 | |
66 | const struct hda_verb *init_verbs[5]; /* initialization verbs | |
67 | * don't forget NULL | |
68 | * termination! | |
69 | */ | |
70 | unsigned int num_init_verbs; | |
71 | ||
72 | /* playback */ | |
73 | struct hda_multi_out multiout; /* playback set-up | |
74 | * max_channels, dacs must be set | |
75 | * dig_out_nid and hp_nid are optional | |
76 | */ | |
77 | unsigned int cur_eapd; | |
82f30040 | 78 | unsigned int hp_present; |
faddaa5d | 79 | unsigned int auto_mic; |
c9b443d4 TD |
80 | unsigned int need_dac_fix; |
81 | ||
82 | /* capture */ | |
83 | unsigned int num_adc_nids; | |
84 | hda_nid_t *adc_nids; | |
85 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ | |
86 | ||
461e2c78 TI |
87 | unsigned int cur_adc_idx; |
88 | hda_nid_t cur_adc; | |
89 | unsigned int cur_adc_stream_tag; | |
90 | unsigned int cur_adc_format; | |
91 | ||
c9b443d4 TD |
92 | /* capture source */ |
93 | const struct hda_input_mux *input_mux; | |
94 | hda_nid_t *capsrc_nids; | |
95 | unsigned int cur_mux[3]; | |
96 | ||
97 | /* channel model */ | |
98 | const struct hda_channel_mode *channel_mode; | |
99 | int num_channel_mode; | |
100 | ||
101 | /* PCM information */ | |
102 | struct hda_pcm pcm_rec[2]; /* used in build_pcms() */ | |
103 | ||
c9b443d4 TD |
104 | unsigned int spdif_route; |
105 | ||
bc7a166d UD |
106 | /* jack detection */ |
107 | struct snd_array jacks; | |
108 | ||
c9b443d4 TD |
109 | /* dynamic controls, init_verbs and input_mux */ |
110 | struct auto_pin_cfg autocfg; | |
c9b443d4 | 111 | struct hda_input_mux private_imux; |
41923e44 | 112 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
c9b443d4 | 113 | |
0fb67e98 DD |
114 | unsigned int dell_automute; |
115 | unsigned int port_d_mode; | |
254bba6a | 116 | unsigned int dell_vostro; |
75f8991d DD |
117 | |
118 | unsigned int ext_mic_present; | |
119 | unsigned int recording; | |
120 | void (*capture_prepare)(struct hda_codec *codec); | |
121 | void (*capture_cleanup)(struct hda_codec *codec); | |
c4cfe66c DD |
122 | |
123 | /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors) | |
124 | * through the microphone jack. | |
125 | * When the user enables this through a mixer switch, both internal and | |
126 | * external microphones are disabled. Gain is fixed at 0dB. In this mode, | |
127 | * we also allow the bias to be configured through a separate mixer | |
128 | * control. */ | |
129 | unsigned int dc_enable; | |
130 | unsigned int dc_input_bias; /* offset into cxt5066_olpc_dc_bias */ | |
131 | unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */ | |
c9b443d4 TD |
132 | }; |
133 | ||
134 | static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
135 | struct hda_codec *codec, | |
136 | struct snd_pcm_substream *substream) | |
137 | { | |
138 | struct conexant_spec *spec = codec->spec; | |
9a08160b TI |
139 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
140 | hinfo); | |
c9b443d4 TD |
141 | } |
142 | ||
143 | static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |
144 | struct hda_codec *codec, | |
145 | unsigned int stream_tag, | |
146 | unsigned int format, | |
147 | struct snd_pcm_substream *substream) | |
148 | { | |
149 | struct conexant_spec *spec = codec->spec; | |
150 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, | |
151 | stream_tag, | |
152 | format, substream); | |
153 | } | |
154 | ||
155 | static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
156 | struct hda_codec *codec, | |
157 | struct snd_pcm_substream *substream) | |
158 | { | |
159 | struct conexant_spec *spec = codec->spec; | |
160 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | |
161 | } | |
162 | ||
163 | /* | |
164 | * Digital out | |
165 | */ | |
166 | static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
167 | struct hda_codec *codec, | |
168 | struct snd_pcm_substream *substream) | |
169 | { | |
170 | struct conexant_spec *spec = codec->spec; | |
171 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | |
172 | } | |
173 | ||
174 | static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, | |
175 | struct hda_codec *codec, | |
176 | struct snd_pcm_substream *substream) | |
177 | { | |
178 | struct conexant_spec *spec = codec->spec; | |
179 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | |
180 | } | |
181 | ||
6b97eb45 TI |
182 | static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
183 | struct hda_codec *codec, | |
184 | unsigned int stream_tag, | |
185 | unsigned int format, | |
186 | struct snd_pcm_substream *substream) | |
187 | { | |
188 | struct conexant_spec *spec = codec->spec; | |
189 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, | |
190 | stream_tag, | |
191 | format, substream); | |
192 | } | |
193 | ||
c9b443d4 TD |
194 | /* |
195 | * Analog capture | |
196 | */ | |
197 | static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo, | |
198 | struct hda_codec *codec, | |
199 | unsigned int stream_tag, | |
200 | unsigned int format, | |
201 | struct snd_pcm_substream *substream) | |
202 | { | |
203 | struct conexant_spec *spec = codec->spec; | |
75f8991d DD |
204 | if (spec->capture_prepare) |
205 | spec->capture_prepare(codec); | |
c9b443d4 TD |
206 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
207 | stream_tag, 0, format); | |
208 | return 0; | |
209 | } | |
210 | ||
211 | static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
212 | struct hda_codec *codec, | |
213 | struct snd_pcm_substream *substream) | |
214 | { | |
215 | struct conexant_spec *spec = codec->spec; | |
888afa15 | 216 | snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]); |
75f8991d DD |
217 | if (spec->capture_cleanup) |
218 | spec->capture_cleanup(codec); | |
c9b443d4 TD |
219 | return 0; |
220 | } | |
221 | ||
222 | ||
223 | ||
224 | static struct hda_pcm_stream conexant_pcm_analog_playback = { | |
225 | .substreams = 1, | |
226 | .channels_min = 2, | |
227 | .channels_max = 2, | |
228 | .nid = 0, /* fill later */ | |
229 | .ops = { | |
230 | .open = conexant_playback_pcm_open, | |
231 | .prepare = conexant_playback_pcm_prepare, | |
232 | .cleanup = conexant_playback_pcm_cleanup | |
233 | }, | |
234 | }; | |
235 | ||
236 | static struct hda_pcm_stream conexant_pcm_analog_capture = { | |
237 | .substreams = 1, | |
238 | .channels_min = 2, | |
239 | .channels_max = 2, | |
240 | .nid = 0, /* fill later */ | |
241 | .ops = { | |
242 | .prepare = conexant_capture_pcm_prepare, | |
243 | .cleanup = conexant_capture_pcm_cleanup | |
244 | }, | |
245 | }; | |
246 | ||
247 | ||
248 | static struct hda_pcm_stream conexant_pcm_digital_playback = { | |
249 | .substreams = 1, | |
250 | .channels_min = 2, | |
251 | .channels_max = 2, | |
252 | .nid = 0, /* fill later */ | |
253 | .ops = { | |
254 | .open = conexant_dig_playback_pcm_open, | |
6b97eb45 TI |
255 | .close = conexant_dig_playback_pcm_close, |
256 | .prepare = conexant_dig_playback_pcm_prepare | |
c9b443d4 TD |
257 | }, |
258 | }; | |
259 | ||
260 | static struct hda_pcm_stream conexant_pcm_digital_capture = { | |
261 | .substreams = 1, | |
262 | .channels_min = 2, | |
263 | .channels_max = 2, | |
264 | /* NID is set in alc_build_pcms */ | |
265 | }; | |
266 | ||
461e2c78 TI |
267 | static int cx5051_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
268 | struct hda_codec *codec, | |
269 | unsigned int stream_tag, | |
270 | unsigned int format, | |
271 | struct snd_pcm_substream *substream) | |
272 | { | |
273 | struct conexant_spec *spec = codec->spec; | |
274 | spec->cur_adc = spec->adc_nids[spec->cur_adc_idx]; | |
275 | spec->cur_adc_stream_tag = stream_tag; | |
276 | spec->cur_adc_format = format; | |
277 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); | |
278 | return 0; | |
279 | } | |
280 | ||
281 | static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
282 | struct hda_codec *codec, | |
283 | struct snd_pcm_substream *substream) | |
284 | { | |
285 | struct conexant_spec *spec = codec->spec; | |
888afa15 | 286 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
461e2c78 TI |
287 | spec->cur_adc = 0; |
288 | return 0; | |
289 | } | |
290 | ||
291 | static struct hda_pcm_stream cx5051_pcm_analog_capture = { | |
292 | .substreams = 1, | |
293 | .channels_min = 2, | |
294 | .channels_max = 2, | |
295 | .nid = 0, /* fill later */ | |
296 | .ops = { | |
297 | .prepare = cx5051_capture_pcm_prepare, | |
298 | .cleanup = cx5051_capture_pcm_cleanup | |
299 | }, | |
300 | }; | |
301 | ||
c9b443d4 TD |
302 | static int conexant_build_pcms(struct hda_codec *codec) |
303 | { | |
304 | struct conexant_spec *spec = codec->spec; | |
305 | struct hda_pcm *info = spec->pcm_rec; | |
306 | ||
307 | codec->num_pcms = 1; | |
308 | codec->pcm_info = info; | |
309 | ||
310 | info->name = "CONEXANT Analog"; | |
311 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback; | |
312 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = | |
313 | spec->multiout.max_channels; | |
314 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = | |
315 | spec->multiout.dac_nids[0]; | |
461e2c78 TI |
316 | if (codec->vendor_id == 0x14f15051) |
317 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
318 | cx5051_pcm_analog_capture; | |
319 | else | |
320 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
321 | conexant_pcm_analog_capture; | |
c9b443d4 TD |
322 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids; |
323 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; | |
324 | ||
325 | if (spec->multiout.dig_out_nid) { | |
326 | info++; | |
327 | codec->num_pcms++; | |
328 | info->name = "Conexant Digital"; | |
7ba72ba1 | 329 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
c9b443d4 TD |
330 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
331 | conexant_pcm_digital_playback; | |
332 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = | |
333 | spec->multiout.dig_out_nid; | |
334 | if (spec->dig_in_nid) { | |
335 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
336 | conexant_pcm_digital_capture; | |
337 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = | |
338 | spec->dig_in_nid; | |
339 | } | |
340 | } | |
341 | ||
342 | return 0; | |
343 | } | |
344 | ||
345 | static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol, | |
346 | struct snd_ctl_elem_info *uinfo) | |
347 | { | |
348 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
349 | struct conexant_spec *spec = codec->spec; | |
350 | ||
351 | return snd_hda_input_mux_info(spec->input_mux, uinfo); | |
352 | } | |
353 | ||
354 | static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol, | |
355 | struct snd_ctl_elem_value *ucontrol) | |
356 | { | |
357 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
358 | struct conexant_spec *spec = codec->spec; | |
359 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
360 | ||
361 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; | |
362 | return 0; | |
363 | } | |
364 | ||
365 | static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol, | |
366 | struct snd_ctl_elem_value *ucontrol) | |
367 | { | |
368 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
369 | struct conexant_spec *spec = codec->spec; | |
370 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
371 | ||
372 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, | |
373 | spec->capsrc_nids[adc_idx], | |
374 | &spec->cur_mux[adc_idx]); | |
375 | } | |
376 | ||
8c8145b8 | 377 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
95c09099 TI |
378 | static void conexant_free_jack_priv(struct snd_jack *jack) |
379 | { | |
380 | struct conexant_jack *jacks = jack->private_data; | |
381 | jacks->nid = 0; | |
382 | jacks->jack = NULL; | |
383 | } | |
384 | ||
bc7a166d UD |
385 | static int conexant_add_jack(struct hda_codec *codec, |
386 | hda_nid_t nid, int type) | |
387 | { | |
388 | struct conexant_spec *spec; | |
389 | struct conexant_jack *jack; | |
390 | const char *name; | |
95c09099 | 391 | int err; |
bc7a166d UD |
392 | |
393 | spec = codec->spec; | |
394 | snd_array_init(&spec->jacks, sizeof(*jack), 32); | |
395 | jack = snd_array_new(&spec->jacks); | |
396 | name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ; | |
397 | ||
398 | if (!jack) | |
399 | return -ENOMEM; | |
400 | ||
401 | jack->nid = nid; | |
402 | jack->type = type; | |
403 | ||
95c09099 TI |
404 | err = snd_jack_new(codec->bus->card, name, type, &jack->jack); |
405 | if (err < 0) | |
406 | return err; | |
407 | jack->jack->private_data = jack; | |
408 | jack->jack->private_free = conexant_free_jack_priv; | |
409 | return 0; | |
bc7a166d UD |
410 | } |
411 | ||
412 | static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid) | |
413 | { | |
414 | struct conexant_spec *spec = codec->spec; | |
415 | struct conexant_jack *jacks = spec->jacks.list; | |
416 | ||
417 | if (jacks) { | |
418 | int i; | |
419 | for (i = 0; i < spec->jacks.used; i++) { | |
420 | if (jacks->nid == nid) { | |
421 | unsigned int present; | |
d56757ab | 422 | present = snd_hda_jack_detect(codec, nid); |
bc7a166d UD |
423 | |
424 | present = (present) ? jacks->type : 0 ; | |
425 | ||
426 | snd_jack_report(jacks->jack, | |
427 | present); | |
428 | } | |
429 | jacks++; | |
430 | } | |
431 | } | |
432 | } | |
433 | ||
434 | static int conexant_init_jacks(struct hda_codec *codec) | |
435 | { | |
bc7a166d UD |
436 | struct conexant_spec *spec = codec->spec; |
437 | int i; | |
438 | ||
439 | for (i = 0; i < spec->num_init_verbs; i++) { | |
440 | const struct hda_verb *hv; | |
441 | ||
442 | hv = spec->init_verbs[i]; | |
443 | while (hv->nid) { | |
444 | int err = 0; | |
445 | switch (hv->param ^ AC_USRSP_EN) { | |
446 | case CONEXANT_HP_EVENT: | |
447 | err = conexant_add_jack(codec, hv->nid, | |
448 | SND_JACK_HEADPHONE); | |
449 | conexant_report_jack(codec, hv->nid); | |
450 | break; | |
451 | case CXT5051_PORTC_EVENT: | |
452 | case CONEXANT_MIC_EVENT: | |
453 | err = conexant_add_jack(codec, hv->nid, | |
454 | SND_JACK_MICROPHONE); | |
455 | conexant_report_jack(codec, hv->nid); | |
456 | break; | |
457 | } | |
458 | if (err < 0) | |
459 | return err; | |
460 | ++hv; | |
461 | } | |
462 | } | |
bc7a166d UD |
463 | return 0; |
464 | ||
465 | } | |
5801f992 TI |
466 | #else |
467 | static inline void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid) | |
468 | { | |
469 | } | |
470 | ||
471 | static inline int conexant_init_jacks(struct hda_codec *codec) | |
472 | { | |
473 | return 0; | |
474 | } | |
475 | #endif | |
bc7a166d | 476 | |
c9b443d4 TD |
477 | static int conexant_init(struct hda_codec *codec) |
478 | { | |
479 | struct conexant_spec *spec = codec->spec; | |
480 | int i; | |
481 | ||
482 | for (i = 0; i < spec->num_init_verbs; i++) | |
483 | snd_hda_sequence_write(codec, spec->init_verbs[i]); | |
484 | return 0; | |
485 | } | |
486 | ||
487 | static void conexant_free(struct hda_codec *codec) | |
488 | { | |
8c8145b8 | 489 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
bc7a166d UD |
490 | struct conexant_spec *spec = codec->spec; |
491 | if (spec->jacks.list) { | |
492 | struct conexant_jack *jacks = spec->jacks.list; | |
493 | int i; | |
95c09099 TI |
494 | for (i = 0; i < spec->jacks.used; i++, jacks++) { |
495 | if (jacks->jack) | |
496 | snd_device_free(codec->bus->card, jacks->jack); | |
497 | } | |
bc7a166d UD |
498 | snd_array_free(&spec->jacks); |
499 | } | |
500 | #endif | |
c0f8faf0 | 501 | snd_hda_detach_beep_device(codec); |
c9b443d4 TD |
502 | kfree(codec->spec); |
503 | } | |
504 | ||
b880c74a TI |
505 | static struct snd_kcontrol_new cxt_capture_mixers[] = { |
506 | { | |
507 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
508 | .name = "Capture Source", | |
509 | .info = conexant_mux_enum_info, | |
510 | .get = conexant_mux_enum_get, | |
511 | .put = conexant_mux_enum_put | |
512 | }, | |
513 | {} | |
514 | }; | |
515 | ||
dd5746a8 TI |
516 | static const char *slave_vols[] = { |
517 | "Headphone Playback Volume", | |
518 | "Speaker Playback Volume", | |
519 | NULL | |
520 | }; | |
521 | ||
522 | static const char *slave_sws[] = { | |
523 | "Headphone Playback Switch", | |
524 | "Speaker Playback Switch", | |
525 | NULL | |
526 | }; | |
527 | ||
c9b443d4 TD |
528 | static int conexant_build_controls(struct hda_codec *codec) |
529 | { | |
530 | struct conexant_spec *spec = codec->spec; | |
531 | unsigned int i; | |
532 | int err; | |
533 | ||
534 | for (i = 0; i < spec->num_mixers; i++) { | |
535 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | |
536 | if (err < 0) | |
537 | return err; | |
538 | } | |
539 | if (spec->multiout.dig_out_nid) { | |
540 | err = snd_hda_create_spdif_out_ctls(codec, | |
541 | spec->multiout.dig_out_nid); | |
542 | if (err < 0) | |
543 | return err; | |
9a08160b TI |
544 | err = snd_hda_create_spdif_share_sw(codec, |
545 | &spec->multiout); | |
546 | if (err < 0) | |
547 | return err; | |
548 | spec->multiout.share_spdif = 1; | |
c9b443d4 TD |
549 | } |
550 | if (spec->dig_in_nid) { | |
551 | err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid); | |
552 | if (err < 0) | |
553 | return err; | |
554 | } | |
dd5746a8 TI |
555 | |
556 | /* if we have no master control, let's create it */ | |
557 | if (spec->vmaster_nid && | |
558 | !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { | |
559 | unsigned int vmaster_tlv[4]; | |
560 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, | |
561 | HDA_OUTPUT, vmaster_tlv); | |
562 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", | |
563 | vmaster_tlv, slave_vols); | |
564 | if (err < 0) | |
565 | return err; | |
566 | } | |
567 | if (spec->vmaster_nid && | |
568 | !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { | |
569 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", | |
570 | NULL, slave_sws); | |
571 | if (err < 0) | |
572 | return err; | |
573 | } | |
574 | ||
b880c74a TI |
575 | if (spec->input_mux) { |
576 | err = snd_hda_add_new_ctls(codec, cxt_capture_mixers); | |
577 | if (err < 0) | |
578 | return err; | |
579 | } | |
580 | ||
c9b443d4 TD |
581 | return 0; |
582 | } | |
583 | ||
584 | static struct hda_codec_ops conexant_patch_ops = { | |
585 | .build_controls = conexant_build_controls, | |
586 | .build_pcms = conexant_build_pcms, | |
587 | .init = conexant_init, | |
588 | .free = conexant_free, | |
c9b443d4 TD |
589 | }; |
590 | ||
591 | /* | |
592 | * EAPD control | |
593 | * the private value = nid | (invert << 8) | |
594 | */ | |
595 | ||
a5ce8890 | 596 | #define cxt_eapd_info snd_ctl_boolean_mono_info |
c9b443d4 | 597 | |
82f30040 | 598 | static int cxt_eapd_get(struct snd_kcontrol *kcontrol, |
c9b443d4 TD |
599 | struct snd_ctl_elem_value *ucontrol) |
600 | { | |
601 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
602 | struct conexant_spec *spec = codec->spec; | |
603 | int invert = (kcontrol->private_value >> 8) & 1; | |
604 | if (invert) | |
605 | ucontrol->value.integer.value[0] = !spec->cur_eapd; | |
606 | else | |
607 | ucontrol->value.integer.value[0] = spec->cur_eapd; | |
608 | return 0; | |
82f30040 | 609 | |
c9b443d4 TD |
610 | } |
611 | ||
82f30040 | 612 | static int cxt_eapd_put(struct snd_kcontrol *kcontrol, |
c9b443d4 TD |
613 | struct snd_ctl_elem_value *ucontrol) |
614 | { | |
615 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
616 | struct conexant_spec *spec = codec->spec; | |
617 | int invert = (kcontrol->private_value >> 8) & 1; | |
618 | hda_nid_t nid = kcontrol->private_value & 0xff; | |
619 | unsigned int eapd; | |
82f30040 | 620 | |
68ea7b2f | 621 | eapd = !!ucontrol->value.integer.value[0]; |
c9b443d4 TD |
622 | if (invert) |
623 | eapd = !eapd; | |
82beb8fd | 624 | if (eapd == spec->cur_eapd) |
c9b443d4 | 625 | return 0; |
82f30040 | 626 | |
c9b443d4 | 627 | spec->cur_eapd = eapd; |
82beb8fd TI |
628 | snd_hda_codec_write_cache(codec, nid, |
629 | 0, AC_VERB_SET_EAPD_BTLENABLE, | |
630 | eapd ? 0x02 : 0x00); | |
c9b443d4 TD |
631 | return 1; |
632 | } | |
633 | ||
86d72bdf TI |
634 | /* controls for test mode */ |
635 | #ifdef CONFIG_SND_DEBUG | |
636 | ||
82f30040 TD |
637 | #define CXT_EAPD_SWITCH(xname, nid, mask) \ |
638 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
639 | .info = cxt_eapd_info, \ | |
640 | .get = cxt_eapd_get, \ | |
641 | .put = cxt_eapd_put, \ | |
642 | .private_value = nid | (mask<<16) } | |
643 | ||
644 | ||
645 | ||
c9b443d4 TD |
646 | static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol, |
647 | struct snd_ctl_elem_info *uinfo) | |
648 | { | |
649 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
650 | struct conexant_spec *spec = codec->spec; | |
651 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, | |
652 | spec->num_channel_mode); | |
653 | } | |
654 | ||
655 | static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol, | |
656 | struct snd_ctl_elem_value *ucontrol) | |
657 | { | |
658 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
659 | struct conexant_spec *spec = codec->spec; | |
660 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, | |
661 | spec->num_channel_mode, | |
662 | spec->multiout.max_channels); | |
663 | } | |
664 | ||
665 | static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol, | |
666 | struct snd_ctl_elem_value *ucontrol) | |
667 | { | |
668 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
669 | struct conexant_spec *spec = codec->spec; | |
670 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, | |
671 | spec->num_channel_mode, | |
672 | &spec->multiout.max_channels); | |
673 | if (err >= 0 && spec->need_dac_fix) | |
674 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; | |
675 | return err; | |
676 | } | |
677 | ||
678 | #define CXT_PIN_MODE(xname, nid, dir) \ | |
679 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
680 | .info = conexant_ch_mode_info, \ | |
681 | .get = conexant_ch_mode_get, \ | |
682 | .put = conexant_ch_mode_put, \ | |
683 | .private_value = nid | (dir<<16) } | |
684 | ||
86d72bdf TI |
685 | #endif /* CONFIG_SND_DEBUG */ |
686 | ||
c9b443d4 TD |
687 | /* Conexant 5045 specific */ |
688 | ||
689 | static hda_nid_t cxt5045_dac_nids[1] = { 0x19 }; | |
690 | static hda_nid_t cxt5045_adc_nids[1] = { 0x1a }; | |
691 | static hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a }; | |
cbef9789 | 692 | #define CXT5045_SPDIF_OUT 0x18 |
c9b443d4 | 693 | |
5cd57529 TD |
694 | static struct hda_channel_mode cxt5045_modes[1] = { |
695 | { 2, NULL }, | |
696 | }; | |
c9b443d4 TD |
697 | |
698 | static struct hda_input_mux cxt5045_capture_source = { | |
699 | .num_items = 2, | |
700 | .items = { | |
82f30040 | 701 | { "IntMic", 0x1 }, |
f4beee94 | 702 | { "ExtMic", 0x2 }, |
c9b443d4 TD |
703 | } |
704 | }; | |
705 | ||
5218c892 | 706 | static struct hda_input_mux cxt5045_capture_source_benq = { |
22e14130 | 707 | .num_items = 5, |
5218c892 JZ |
708 | .items = { |
709 | { "IntMic", 0x1 }, | |
710 | { "ExtMic", 0x2 }, | |
711 | { "LineIn", 0x3 }, | |
22e14130 LM |
712 | { "CD", 0x4 }, |
713 | { "Mixer", 0x0 }, | |
5218c892 JZ |
714 | } |
715 | }; | |
716 | ||
2de3c232 J |
717 | static struct hda_input_mux cxt5045_capture_source_hp530 = { |
718 | .num_items = 2, | |
719 | .items = { | |
720 | { "ExtMic", 0x1 }, | |
721 | { "IntMic", 0x2 }, | |
722 | } | |
723 | }; | |
724 | ||
c9b443d4 TD |
725 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
726 | static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
727 | struct snd_ctl_elem_value *ucontrol) | |
728 | { | |
729 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
730 | struct conexant_spec *spec = codec->spec; | |
82f30040 | 731 | unsigned int bits; |
c9b443d4 | 732 | |
82f30040 | 733 | if (!cxt_eapd_put(kcontrol, ucontrol)) |
c9b443d4 TD |
734 | return 0; |
735 | ||
82f30040 TD |
736 | /* toggle internal speakers mute depending of presence of |
737 | * the headphone jack | |
738 | */ | |
47fd830a TI |
739 | bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; |
740 | snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, | |
741 | HDA_AMP_MUTE, bits); | |
7f29673b | 742 | |
47fd830a TI |
743 | bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; |
744 | snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0, | |
745 | HDA_AMP_MUTE, bits); | |
c9b443d4 TD |
746 | return 1; |
747 | } | |
748 | ||
749 | /* bind volumes of both NID 0x10 and 0x11 */ | |
cca3b371 TI |
750 | static struct hda_bind_ctls cxt5045_hp_bind_master_vol = { |
751 | .ops = &snd_hda_bind_vol, | |
752 | .values = { | |
753 | HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT), | |
754 | HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT), | |
755 | 0 | |
756 | }, | |
757 | }; | |
c9b443d4 | 758 | |
7f29673b TD |
759 | /* toggle input of built-in and mic jack appropriately */ |
760 | static void cxt5045_hp_automic(struct hda_codec *codec) | |
761 | { | |
762 | static struct hda_verb mic_jack_on[] = { | |
763 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | |
764 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
765 | {} | |
766 | }; | |
767 | static struct hda_verb mic_jack_off[] = { | |
768 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | |
769 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
770 | {} | |
771 | }; | |
772 | unsigned int present; | |
773 | ||
d56757ab | 774 | present = snd_hda_jack_detect(codec, 0x12); |
7f29673b TD |
775 | if (present) |
776 | snd_hda_sequence_write(codec, mic_jack_on); | |
777 | else | |
778 | snd_hda_sequence_write(codec, mic_jack_off); | |
779 | } | |
780 | ||
c9b443d4 TD |
781 | |
782 | /* mute internal speaker if HP is plugged */ | |
783 | static void cxt5045_hp_automute(struct hda_codec *codec) | |
784 | { | |
82f30040 | 785 | struct conexant_spec *spec = codec->spec; |
dd87da1c | 786 | unsigned int bits; |
c9b443d4 | 787 | |
d56757ab | 788 | spec->hp_present = snd_hda_jack_detect(codec, 0x11); |
dd87da1c | 789 | |
47fd830a TI |
790 | bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; |
791 | snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, | |
792 | HDA_AMP_MUTE, bits); | |
c9b443d4 TD |
793 | } |
794 | ||
795 | /* unsolicited event for HP jack sensing */ | |
796 | static void cxt5045_hp_unsol_event(struct hda_codec *codec, | |
797 | unsigned int res) | |
798 | { | |
799 | res >>= 26; | |
800 | switch (res) { | |
801 | case CONEXANT_HP_EVENT: | |
802 | cxt5045_hp_automute(codec); | |
803 | break; | |
7f29673b TD |
804 | case CONEXANT_MIC_EVENT: |
805 | cxt5045_hp_automic(codec); | |
806 | break; | |
807 | ||
c9b443d4 TD |
808 | } |
809 | } | |
810 | ||
811 | static struct snd_kcontrol_new cxt5045_mixers[] = { | |
c8229c38 TI |
812 | HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT), |
813 | HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT), | |
814 | HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT), | |
815 | HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x02, HDA_INPUT), | |
816 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), | |
817 | HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), | |
818 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x1, HDA_INPUT), | |
819 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x1, HDA_INPUT), | |
820 | HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x2, HDA_INPUT), | |
821 | HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x2, HDA_INPUT), | |
cca3b371 | 822 | HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol), |
c9b443d4 TD |
823 | { |
824 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
825 | .name = "Master Playback Switch", | |
82f30040 TD |
826 | .info = cxt_eapd_info, |
827 | .get = cxt_eapd_get, | |
c9b443d4 | 828 | .put = cxt5045_hp_master_sw_put, |
82f30040 | 829 | .private_value = 0x10, |
c9b443d4 TD |
830 | }, |
831 | ||
832 | {} | |
833 | }; | |
834 | ||
5218c892 | 835 | static struct snd_kcontrol_new cxt5045_benq_mixers[] = { |
22e14130 LM |
836 | HDA_CODEC_VOLUME("CD Capture Volume", 0x1a, 0x04, HDA_INPUT), |
837 | HDA_CODEC_MUTE("CD Capture Switch", 0x1a, 0x04, HDA_INPUT), | |
838 | HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x4, HDA_INPUT), | |
839 | HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x4, HDA_INPUT), | |
840 | ||
5218c892 JZ |
841 | HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT), |
842 | HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT), | |
843 | HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT), | |
844 | HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT), | |
845 | ||
22e14130 LM |
846 | HDA_CODEC_VOLUME("Mixer Capture Volume", 0x1a, 0x0, HDA_INPUT), |
847 | HDA_CODEC_MUTE("Mixer Capture Switch", 0x1a, 0x0, HDA_INPUT), | |
848 | ||
5218c892 JZ |
849 | {} |
850 | }; | |
851 | ||
2de3c232 | 852 | static struct snd_kcontrol_new cxt5045_mixers_hp530[] = { |
2de3c232 J |
853 | HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT), |
854 | HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT), | |
855 | HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT), | |
856 | HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x01, HDA_INPUT), | |
857 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), | |
858 | HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), | |
859 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x2, HDA_INPUT), | |
860 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x2, HDA_INPUT), | |
861 | HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x1, HDA_INPUT), | |
862 | HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x1, HDA_INPUT), | |
863 | HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol), | |
864 | { | |
865 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
866 | .name = "Master Playback Switch", | |
867 | .info = cxt_eapd_info, | |
868 | .get = cxt_eapd_get, | |
869 | .put = cxt5045_hp_master_sw_put, | |
870 | .private_value = 0x10, | |
871 | }, | |
872 | ||
873 | {} | |
874 | }; | |
875 | ||
c9b443d4 TD |
876 | static struct hda_verb cxt5045_init_verbs[] = { |
877 | /* Line in, Mic */ | |
4090dffb | 878 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, |
7f29673b | 879 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, |
c9b443d4 | 880 | /* HP, Amp */ |
c8229c38 TI |
881 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
882 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, | |
883 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
884 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, | |
885 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
886 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
887 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
888 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
889 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
82f30040 | 890 | /* Record selector: Int mic */ |
7f29673b | 891 | {0x1a, AC_VERB_SET_CONNECT_SEL,0x1}, |
82f30040 | 892 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, |
c9b443d4 TD |
893 | AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, |
894 | /* SPDIF route: PCM */ | |
cbef9789 | 895 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
c9b443d4 | 896 | { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
c9b443d4 | 897 | /* EAPD */ |
82f30040 | 898 | {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */ |
c9b443d4 TD |
899 | { } /* end */ |
900 | }; | |
901 | ||
5218c892 JZ |
902 | static struct hda_verb cxt5045_benq_init_verbs[] = { |
903 | /* Int Mic, Mic */ | |
904 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, | |
905 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, | |
906 | /* Line In,HP, Amp */ | |
907 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
908 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, | |
909 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
910 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, | |
911 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
912 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
913 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
914 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
915 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
916 | /* Record selector: Int mic */ | |
917 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x1}, | |
918 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, | |
919 | AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, | |
920 | /* SPDIF route: PCM */ | |
cbef9789 | 921 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
5218c892 JZ |
922 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, |
923 | /* EAPD */ | |
924 | {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
925 | { } /* end */ | |
926 | }; | |
7f29673b TD |
927 | |
928 | static struct hda_verb cxt5045_hp_sense_init_verbs[] = { | |
929 | /* pin sensing on HP jack */ | |
930 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | |
d3091fad | 931 | { } /* end */ |
7f29673b TD |
932 | }; |
933 | ||
934 | static struct hda_verb cxt5045_mic_sense_init_verbs[] = { | |
935 | /* pin sensing on HP jack */ | |
936 | {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | |
d3091fad | 937 | { } /* end */ |
7f29673b TD |
938 | }; |
939 | ||
c9b443d4 TD |
940 | #ifdef CONFIG_SND_DEBUG |
941 | /* Test configuration for debugging, modelled after the ALC260 test | |
942 | * configuration. | |
943 | */ | |
944 | static struct hda_input_mux cxt5045_test_capture_source = { | |
945 | .num_items = 5, | |
946 | .items = { | |
947 | { "MIXER", 0x0 }, | |
948 | { "MIC1 pin", 0x1 }, | |
949 | { "LINE1 pin", 0x2 }, | |
950 | { "HP-OUT pin", 0x3 }, | |
951 | { "CD pin", 0x4 }, | |
952 | }, | |
953 | }; | |
954 | ||
955 | static struct snd_kcontrol_new cxt5045_test_mixer[] = { | |
956 | ||
957 | /* Output controls */ | |
c9b443d4 TD |
958 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT), |
959 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT), | |
7f29673b TD |
960 | HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
961 | HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT), | |
962 | HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT), | |
963 | HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT), | |
c9b443d4 TD |
964 | |
965 | /* Modes for retasking pin widgets */ | |
966 | CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT), | |
967 | CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT), | |
968 | ||
82f30040 TD |
969 | /* EAPD Switch Control */ |
970 | CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0), | |
971 | ||
c9b443d4 | 972 | /* Loopback mixer controls */ |
7f29673b TD |
973 | |
974 | HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT), | |
975 | HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT), | |
976 | HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT), | |
977 | HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT), | |
978 | HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT), | |
979 | HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT), | |
980 | HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT), | |
981 | HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT), | |
982 | HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT), | |
983 | HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT), | |
c9b443d4 TD |
984 | { |
985 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
986 | .name = "Input Source", | |
987 | .info = conexant_mux_enum_info, | |
988 | .get = conexant_mux_enum_get, | |
989 | .put = conexant_mux_enum_put, | |
990 | }, | |
fb3409e7 TD |
991 | /* Audio input controls */ |
992 | HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT), | |
993 | HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT), | |
994 | HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT), | |
995 | HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT), | |
996 | HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT), | |
997 | HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT), | |
998 | HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT), | |
999 | HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT), | |
1000 | HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT), | |
1001 | HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT), | |
c9b443d4 TD |
1002 | { } /* end */ |
1003 | }; | |
1004 | ||
1005 | static struct hda_verb cxt5045_test_init_verbs[] = { | |
7f29673b TD |
1006 | /* Set connections */ |
1007 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 }, | |
1008 | { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 }, | |
1009 | { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 }, | |
c9b443d4 TD |
1010 | /* Enable retasking pins as output, initially without power amp */ |
1011 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7f29673b | 1012 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
c9b443d4 TD |
1013 | |
1014 | /* Disable digital (SPDIF) pins initially, but users can enable | |
1015 | * them via a mixer switch. In the case of SPDIF-out, this initverb | |
1016 | * payload also sets the generation to 0, output to be in "consumer" | |
1017 | * PCM format, copyright asserted, no pre-emphasis and no validity | |
1018 | * control. | |
1019 | */ | |
cbef9789 TI |
1020 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1021 | {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
c9b443d4 TD |
1022 | |
1023 | /* Start with output sum widgets muted and their output gains at min */ | |
1024 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
1025 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1026 | ||
1027 | /* Unmute retasking pin widget output buffers since the default | |
1028 | * state appears to be output. As the pin mode is changed by the | |
1029 | * user the pin mode control will take care of enabling the pin's | |
1030 | * input/output buffers as needed. | |
1031 | */ | |
1032 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1033 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1034 | ||
1035 | /* Mute capture amp left and right */ | |
1036 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
1037 | ||
1038 | /* Set ADC connection select to match default mixer setting (mic1 | |
1039 | * pin) | |
1040 | */ | |
1041 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7f29673b | 1042 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x00}, |
c9b443d4 TD |
1043 | |
1044 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
1045 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */ | |
1046 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */ | |
1047 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */ | |
1048 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */ | |
1049 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
1050 | ||
1051 | { } | |
1052 | }; | |
1053 | #endif | |
1054 | ||
1055 | ||
1056 | /* initialize jack-sensing, too */ | |
1057 | static int cxt5045_init(struct hda_codec *codec) | |
1058 | { | |
1059 | conexant_init(codec); | |
1060 | cxt5045_hp_automute(codec); | |
1061 | return 0; | |
1062 | } | |
1063 | ||
1064 | ||
1065 | enum { | |
15908c36 MB |
1066 | CXT5045_LAPTOP_HPSENSE, |
1067 | CXT5045_LAPTOP_MICSENSE, | |
1068 | CXT5045_LAPTOP_HPMICSENSE, | |
5218c892 | 1069 | CXT5045_BENQ, |
2de3c232 | 1070 | CXT5045_LAPTOP_HP530, |
c9b443d4 TD |
1071 | #ifdef CONFIG_SND_DEBUG |
1072 | CXT5045_TEST, | |
1073 | #endif | |
f5fcc13c | 1074 | CXT5045_MODELS |
c9b443d4 TD |
1075 | }; |
1076 | ||
f5fcc13c | 1077 | static const char *cxt5045_models[CXT5045_MODELS] = { |
15908c36 MB |
1078 | [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense", |
1079 | [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense", | |
1080 | [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense", | |
1081 | [CXT5045_BENQ] = "benq", | |
2de3c232 | 1082 | [CXT5045_LAPTOP_HP530] = "laptop-hp530", |
c9b443d4 | 1083 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 1084 | [CXT5045_TEST] = "test", |
c9b443d4 | 1085 | #endif |
f5fcc13c TI |
1086 | }; |
1087 | ||
1088 | static struct snd_pci_quirk cxt5045_cfg_tbl[] = { | |
2de3c232 | 1089 | SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530), |
dea0a509 TI |
1090 | SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series", |
1091 | CXT5045_LAPTOP_HPSENSE), | |
6a9dccd6 | 1092 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE), |
5218c892 | 1093 | SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ), |
15908c36 MB |
1094 | SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE), |
1095 | SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE), | |
9e464154 TI |
1096 | SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505", |
1097 | CXT5045_LAPTOP_HPMICSENSE), | |
15908c36 MB |
1098 | SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE), |
1099 | SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE), | |
1100 | SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE), | |
dea0a509 TI |
1101 | SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell", |
1102 | CXT5045_LAPTOP_HPMICSENSE), | |
15908c36 | 1103 | SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE), |
c9b443d4 TD |
1104 | {} |
1105 | }; | |
1106 | ||
1107 | static int patch_cxt5045(struct hda_codec *codec) | |
1108 | { | |
1109 | struct conexant_spec *spec; | |
1110 | int board_config; | |
1111 | ||
1112 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
1113 | if (!spec) | |
1114 | return -ENOMEM; | |
c9b443d4 | 1115 | codec->spec = spec; |
9421f954 | 1116 | codec->pin_amp_workaround = 1; |
c9b443d4 TD |
1117 | |
1118 | spec->multiout.max_channels = 2; | |
1119 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids); | |
1120 | spec->multiout.dac_nids = cxt5045_dac_nids; | |
1121 | spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT; | |
1122 | spec->num_adc_nids = 1; | |
1123 | spec->adc_nids = cxt5045_adc_nids; | |
1124 | spec->capsrc_nids = cxt5045_capsrc_nids; | |
1125 | spec->input_mux = &cxt5045_capture_source; | |
1126 | spec->num_mixers = 1; | |
1127 | spec->mixers[0] = cxt5045_mixers; | |
1128 | spec->num_init_verbs = 1; | |
1129 | spec->init_verbs[0] = cxt5045_init_verbs; | |
1130 | spec->spdif_route = 0; | |
5cd57529 TD |
1131 | spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes), |
1132 | spec->channel_mode = cxt5045_modes, | |
1133 | ||
c9b443d4 TD |
1134 | |
1135 | codec->patch_ops = conexant_patch_ops; | |
c9b443d4 | 1136 | |
f5fcc13c TI |
1137 | board_config = snd_hda_check_board_config(codec, CXT5045_MODELS, |
1138 | cxt5045_models, | |
1139 | cxt5045_cfg_tbl); | |
c9b443d4 | 1140 | switch (board_config) { |
15908c36 | 1141 | case CXT5045_LAPTOP_HPSENSE: |
7f29673b TD |
1142 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; |
1143 | spec->input_mux = &cxt5045_capture_source; | |
1144 | spec->num_init_verbs = 2; | |
1145 | spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; | |
1146 | spec->mixers[0] = cxt5045_mixers; | |
1147 | codec->patch_ops.init = cxt5045_init; | |
1148 | break; | |
15908c36 | 1149 | case CXT5045_LAPTOP_MICSENSE: |
86376df6 | 1150 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; |
c9b443d4 TD |
1151 | spec->input_mux = &cxt5045_capture_source; |
1152 | spec->num_init_verbs = 2; | |
7f29673b | 1153 | spec->init_verbs[1] = cxt5045_mic_sense_init_verbs; |
c9b443d4 TD |
1154 | spec->mixers[0] = cxt5045_mixers; |
1155 | codec->patch_ops.init = cxt5045_init; | |
1156 | break; | |
15908c36 MB |
1157 | default: |
1158 | case CXT5045_LAPTOP_HPMICSENSE: | |
1159 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; | |
1160 | spec->input_mux = &cxt5045_capture_source; | |
1161 | spec->num_init_verbs = 3; | |
1162 | spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; | |
1163 | spec->init_verbs[2] = cxt5045_mic_sense_init_verbs; | |
1164 | spec->mixers[0] = cxt5045_mixers; | |
1165 | codec->patch_ops.init = cxt5045_init; | |
1166 | break; | |
5218c892 JZ |
1167 | case CXT5045_BENQ: |
1168 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; | |
1169 | spec->input_mux = &cxt5045_capture_source_benq; | |
1170 | spec->num_init_verbs = 1; | |
1171 | spec->init_verbs[0] = cxt5045_benq_init_verbs; | |
1172 | spec->mixers[0] = cxt5045_mixers; | |
1173 | spec->mixers[1] = cxt5045_benq_mixers; | |
1174 | spec->num_mixers = 2; | |
1175 | codec->patch_ops.init = cxt5045_init; | |
1176 | break; | |
2de3c232 J |
1177 | case CXT5045_LAPTOP_HP530: |
1178 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; | |
1179 | spec->input_mux = &cxt5045_capture_source_hp530; | |
1180 | spec->num_init_verbs = 2; | |
1181 | spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; | |
1182 | spec->mixers[0] = cxt5045_mixers_hp530; | |
1183 | codec->patch_ops.init = cxt5045_init; | |
1184 | break; | |
c9b443d4 TD |
1185 | #ifdef CONFIG_SND_DEBUG |
1186 | case CXT5045_TEST: | |
1187 | spec->input_mux = &cxt5045_test_capture_source; | |
1188 | spec->mixers[0] = cxt5045_test_mixer; | |
1189 | spec->init_verbs[0] = cxt5045_test_init_verbs; | |
15908c36 MB |
1190 | break; |
1191 | ||
c9b443d4 TD |
1192 | #endif |
1193 | } | |
48ecb7e8 | 1194 | |
031005f7 TI |
1195 | switch (codec->subsystem_id >> 16) { |
1196 | case 0x103c: | |
0b587fc4 DC |
1197 | case 0x1734: |
1198 | /* HP & Fujitsu-Siemens laptops have really bad sound over 0dB | |
1199 | * on NID 0x17. Fix max PCM level to 0 dB | |
1200 | * (originally it has 0x2b steps with 0dB offset 0x14) | |
031005f7 TI |
1201 | */ |
1202 | snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT, | |
1203 | (0x14 << AC_AMPCAP_OFFSET_SHIFT) | | |
1204 | (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) | | |
1205 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | | |
1206 | (1 << AC_AMPCAP_MUTE_SHIFT)); | |
1207 | break; | |
1208 | } | |
48ecb7e8 | 1209 | |
c9b443d4 TD |
1210 | return 0; |
1211 | } | |
1212 | ||
1213 | ||
1214 | /* Conexant 5047 specific */ | |
82f30040 | 1215 | #define CXT5047_SPDIF_OUT 0x11 |
c9b443d4 | 1216 | |
5b3a7440 | 1217 | static hda_nid_t cxt5047_dac_nids[1] = { 0x10 }; /* 0x1c */ |
c9b443d4 TD |
1218 | static hda_nid_t cxt5047_adc_nids[1] = { 0x12 }; |
1219 | static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a }; | |
c9b443d4 | 1220 | |
5cd57529 TD |
1221 | static struct hda_channel_mode cxt5047_modes[1] = { |
1222 | { 2, NULL }, | |
1223 | }; | |
c9b443d4 | 1224 | |
82f30040 TD |
1225 | static struct hda_input_mux cxt5047_toshiba_capture_source = { |
1226 | .num_items = 2, | |
1227 | .items = { | |
1228 | { "ExtMic", 0x2 }, | |
1229 | { "Line-In", 0x1 }, | |
c9b443d4 TD |
1230 | } |
1231 | }; | |
1232 | ||
1233 | /* turn on/off EAPD (+ mute HP) as a master switch */ | |
1234 | static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
1235 | struct snd_ctl_elem_value *ucontrol) | |
1236 | { | |
1237 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1238 | struct conexant_spec *spec = codec->spec; | |
82f30040 | 1239 | unsigned int bits; |
c9b443d4 | 1240 | |
82f30040 | 1241 | if (!cxt_eapd_put(kcontrol, ucontrol)) |
c9b443d4 TD |
1242 | return 0; |
1243 | ||
82f30040 TD |
1244 | /* toggle internal speakers mute depending of presence of |
1245 | * the headphone jack | |
1246 | */ | |
47fd830a | 1247 | bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; |
3b7523fc TI |
1248 | /* NOTE: Conexat codec needs the index for *OUTPUT* amp of |
1249 | * pin widgets unlike other codecs. In this case, we need to | |
1250 | * set index 0x01 for the volume from the mixer amp 0x19. | |
1251 | */ | |
5d75bc55 | 1252 | snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, |
47fd830a TI |
1253 | HDA_AMP_MUTE, bits); |
1254 | bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; | |
1255 | snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0, | |
1256 | HDA_AMP_MUTE, bits); | |
c9b443d4 TD |
1257 | return 1; |
1258 | } | |
1259 | ||
c9b443d4 TD |
1260 | /* mute internal speaker if HP is plugged */ |
1261 | static void cxt5047_hp_automute(struct hda_codec *codec) | |
1262 | { | |
82f30040 | 1263 | struct conexant_spec *spec = codec->spec; |
dd87da1c | 1264 | unsigned int bits; |
c9b443d4 | 1265 | |
d56757ab | 1266 | spec->hp_present = snd_hda_jack_detect(codec, 0x13); |
dd87da1c | 1267 | |
47fd830a | 1268 | bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; |
3b7523fc | 1269 | /* See the note in cxt5047_hp_master_sw_put */ |
5d75bc55 | 1270 | snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, |
47fd830a | 1271 | HDA_AMP_MUTE, bits); |
c9b443d4 TD |
1272 | } |
1273 | ||
1274 | /* toggle input of built-in and mic jack appropriately */ | |
1275 | static void cxt5047_hp_automic(struct hda_codec *codec) | |
1276 | { | |
1277 | static struct hda_verb mic_jack_on[] = { | |
9f113e0e MB |
1278 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1279 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
c9b443d4 TD |
1280 | {} |
1281 | }; | |
1282 | static struct hda_verb mic_jack_off[] = { | |
9f113e0e MB |
1283 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1284 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
c9b443d4 TD |
1285 | {} |
1286 | }; | |
1287 | unsigned int present; | |
1288 | ||
d56757ab | 1289 | present = snd_hda_jack_detect(codec, 0x15); |
c9b443d4 TD |
1290 | if (present) |
1291 | snd_hda_sequence_write(codec, mic_jack_on); | |
1292 | else | |
1293 | snd_hda_sequence_write(codec, mic_jack_off); | |
1294 | } | |
1295 | ||
1296 | /* unsolicited event for HP jack sensing */ | |
1297 | static void cxt5047_hp_unsol_event(struct hda_codec *codec, | |
1298 | unsigned int res) | |
1299 | { | |
9f113e0e | 1300 | switch (res >> 26) { |
c9b443d4 TD |
1301 | case CONEXANT_HP_EVENT: |
1302 | cxt5047_hp_automute(codec); | |
1303 | break; | |
1304 | case CONEXANT_MIC_EVENT: | |
1305 | cxt5047_hp_automic(codec); | |
1306 | break; | |
1307 | } | |
1308 | } | |
1309 | ||
df481e41 TI |
1310 | static struct snd_kcontrol_new cxt5047_base_mixers[] = { |
1311 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT), | |
1312 | HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT), | |
1313 | HDA_CODEC_VOLUME("Mic Boost", 0x1a, 0x0, HDA_OUTPUT), | |
c9b443d4 TD |
1314 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), |
1315 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), | |
1316 | HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), | |
1317 | HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), | |
82f30040 TD |
1318 | { |
1319 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1320 | .name = "Master Playback Switch", | |
1321 | .info = cxt_eapd_info, | |
1322 | .get = cxt_eapd_get, | |
c9b443d4 TD |
1323 | .put = cxt5047_hp_master_sw_put, |
1324 | .private_value = 0x13, | |
1325 | }, | |
1326 | ||
1327 | {} | |
1328 | }; | |
1329 | ||
df481e41 | 1330 | static struct snd_kcontrol_new cxt5047_hp_spk_mixers[] = { |
3b7523fc | 1331 | /* See the note in cxt5047_hp_master_sw_put */ |
5d75bc55 | 1332 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT), |
df481e41 TI |
1333 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT), |
1334 | {} | |
1335 | }; | |
1336 | ||
1337 | static struct snd_kcontrol_new cxt5047_hp_only_mixers[] = { | |
c9b443d4 | 1338 | HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT), |
c9b443d4 TD |
1339 | { } /* end */ |
1340 | }; | |
1341 | ||
1342 | static struct hda_verb cxt5047_init_verbs[] = { | |
1343 | /* Line in, Mic, Built-in Mic */ | |
1344 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1345 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, | |
1346 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, | |
7f29673b | 1347 | /* HP, Speaker */ |
b7589ceb | 1348 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
5b3a7440 TI |
1349 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, /* mixer(0x19) */ |
1350 | {0x1d, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mixer(0x19) */ | |
7f29673b | 1351 | /* Record selector: Mic */ |
c9b443d4 TD |
1352 | {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, |
1353 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, | |
1354 | AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, | |
7f29673b TD |
1355 | {0x1A, AC_VERB_SET_CONNECT_SEL,0x02}, |
1356 | {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, | |
1357 | AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00}, | |
1358 | {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, | |
1359 | AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03}, | |
c9b443d4 TD |
1360 | /* SPDIF route: PCM */ |
1361 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 }, | |
82f30040 TD |
1362 | /* Enable unsolicited events */ |
1363 | {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | |
1364 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | |
c9b443d4 TD |
1365 | { } /* end */ |
1366 | }; | |
1367 | ||
1368 | /* configuration for Toshiba Laptops */ | |
1369 | static struct hda_verb cxt5047_toshiba_init_verbs[] = { | |
3b628867 | 1370 | {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0}, /* default off */ |
c9b443d4 TD |
1371 | {} |
1372 | }; | |
1373 | ||
1374 | /* Test configuration for debugging, modelled after the ALC260 test | |
1375 | * configuration. | |
1376 | */ | |
1377 | #ifdef CONFIG_SND_DEBUG | |
1378 | static struct hda_input_mux cxt5047_test_capture_source = { | |
82f30040 | 1379 | .num_items = 4, |
c9b443d4 | 1380 | .items = { |
82f30040 TD |
1381 | { "LINE1 pin", 0x0 }, |
1382 | { "MIC1 pin", 0x1 }, | |
1383 | { "MIC2 pin", 0x2 }, | |
1384 | { "CD pin", 0x3 }, | |
c9b443d4 TD |
1385 | }, |
1386 | }; | |
1387 | ||
1388 | static struct snd_kcontrol_new cxt5047_test_mixer[] = { | |
1389 | ||
1390 | /* Output only controls */ | |
82f30040 TD |
1391 | HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT), |
1392 | HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT), | |
1393 | HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT), | |
1394 | HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT), | |
c9b443d4 TD |
1395 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT), |
1396 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT), | |
1397 | HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT), | |
1398 | HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT), | |
82f30040 TD |
1399 | HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT), |
1400 | HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
1401 | HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
1402 | HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
c9b443d4 TD |
1403 | |
1404 | /* Modes for retasking pin widgets */ | |
1405 | CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT), | |
1406 | CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT), | |
1407 | ||
82f30040 TD |
1408 | /* EAPD Switch Control */ |
1409 | CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0), | |
c9b443d4 | 1410 | |
82f30040 TD |
1411 | /* Loopback mixer controls */ |
1412 | HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT), | |
1413 | HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT), | |
1414 | HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT), | |
1415 | HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT), | |
1416 | HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT), | |
1417 | HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT), | |
1418 | HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT), | |
1419 | HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT), | |
1420 | ||
1421 | HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT), | |
1422 | HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT), | |
1423 | HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT), | |
1424 | HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT), | |
1425 | HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT), | |
1426 | HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT), | |
1427 | HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT), | |
1428 | HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT), | |
c9b443d4 TD |
1429 | { |
1430 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1431 | .name = "Input Source", | |
1432 | .info = conexant_mux_enum_info, | |
1433 | .get = conexant_mux_enum_get, | |
1434 | .put = conexant_mux_enum_put, | |
1435 | }, | |
854206b0 | 1436 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), |
9f113e0e | 1437 | |
c9b443d4 TD |
1438 | { } /* end */ |
1439 | }; | |
1440 | ||
1441 | static struct hda_verb cxt5047_test_init_verbs[] = { | |
c9b443d4 TD |
1442 | /* Enable retasking pins as output, initially without power amp */ |
1443 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1444 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1445 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1446 | ||
1447 | /* Disable digital (SPDIF) pins initially, but users can enable | |
1448 | * them via a mixer switch. In the case of SPDIF-out, this initverb | |
1449 | * payload also sets the generation to 0, output to be in "consumer" | |
1450 | * PCM format, copyright asserted, no pre-emphasis and no validity | |
1451 | * control. | |
1452 | */ | |
1453 | {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
1454 | ||
1455 | /* Ensure mic1, mic2, line1 pin widgets take input from the | |
1456 | * OUT1 sum bus when acting as an output. | |
1457 | */ | |
1458 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0}, | |
1459 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0}, | |
1460 | ||
1461 | /* Start with output sum widgets muted and their output gains at min */ | |
1462 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
1463 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1464 | ||
1465 | /* Unmute retasking pin widget output buffers since the default | |
1466 | * state appears to be output. As the pin mode is changed by the | |
1467 | * user the pin mode control will take care of enabling the pin's | |
1468 | * input/output buffers as needed. | |
1469 | */ | |
1470 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1471 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1472 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1473 | ||
1474 | /* Mute capture amp left and right */ | |
1475 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
1476 | ||
1477 | /* Set ADC connection select to match default mixer setting (mic1 | |
1478 | * pin) | |
1479 | */ | |
1480 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1481 | ||
1482 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
1483 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
1484 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
1485 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
1486 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
1487 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
1488 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
1489 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
1490 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
1491 | ||
1492 | { } | |
1493 | }; | |
1494 | #endif | |
1495 | ||
1496 | ||
1497 | /* initialize jack-sensing, too */ | |
1498 | static int cxt5047_hp_init(struct hda_codec *codec) | |
1499 | { | |
1500 | conexant_init(codec); | |
1501 | cxt5047_hp_automute(codec); | |
c9b443d4 TD |
1502 | return 0; |
1503 | } | |
1504 | ||
1505 | ||
1506 | enum { | |
f5fcc13c TI |
1507 | CXT5047_LAPTOP, /* Laptops w/o EAPD support */ |
1508 | CXT5047_LAPTOP_HP, /* Some HP laptops */ | |
1509 | CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */ | |
c9b443d4 TD |
1510 | #ifdef CONFIG_SND_DEBUG |
1511 | CXT5047_TEST, | |
1512 | #endif | |
f5fcc13c | 1513 | CXT5047_MODELS |
c9b443d4 TD |
1514 | }; |
1515 | ||
f5fcc13c TI |
1516 | static const char *cxt5047_models[CXT5047_MODELS] = { |
1517 | [CXT5047_LAPTOP] = "laptop", | |
1518 | [CXT5047_LAPTOP_HP] = "laptop-hp", | |
1519 | [CXT5047_LAPTOP_EAPD] = "laptop-eapd", | |
c9b443d4 | 1520 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 1521 | [CXT5047_TEST] = "test", |
c9b443d4 | 1522 | #endif |
f5fcc13c TI |
1523 | }; |
1524 | ||
1525 | static struct snd_pci_quirk cxt5047_cfg_tbl[] = { | |
ac3e3741 | 1526 | SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP), |
dea0a509 TI |
1527 | SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series", |
1528 | CXT5047_LAPTOP), | |
f5fcc13c | 1529 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD), |
c9b443d4 TD |
1530 | {} |
1531 | }; | |
1532 | ||
1533 | static int patch_cxt5047(struct hda_codec *codec) | |
1534 | { | |
1535 | struct conexant_spec *spec; | |
1536 | int board_config; | |
1537 | ||
1538 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
1539 | if (!spec) | |
1540 | return -ENOMEM; | |
c9b443d4 | 1541 | codec->spec = spec; |
9421f954 | 1542 | codec->pin_amp_workaround = 1; |
c9b443d4 TD |
1543 | |
1544 | spec->multiout.max_channels = 2; | |
1545 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids); | |
1546 | spec->multiout.dac_nids = cxt5047_dac_nids; | |
1547 | spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT; | |
1548 | spec->num_adc_nids = 1; | |
1549 | spec->adc_nids = cxt5047_adc_nids; | |
1550 | spec->capsrc_nids = cxt5047_capsrc_nids; | |
c9b443d4 | 1551 | spec->num_mixers = 1; |
df481e41 | 1552 | spec->mixers[0] = cxt5047_base_mixers; |
c9b443d4 TD |
1553 | spec->num_init_verbs = 1; |
1554 | spec->init_verbs[0] = cxt5047_init_verbs; | |
1555 | spec->spdif_route = 0; | |
5cd57529 TD |
1556 | spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes), |
1557 | spec->channel_mode = cxt5047_modes, | |
c9b443d4 TD |
1558 | |
1559 | codec->patch_ops = conexant_patch_ops; | |
c9b443d4 | 1560 | |
f5fcc13c TI |
1561 | board_config = snd_hda_check_board_config(codec, CXT5047_MODELS, |
1562 | cxt5047_models, | |
1563 | cxt5047_cfg_tbl); | |
c9b443d4 TD |
1564 | switch (board_config) { |
1565 | case CXT5047_LAPTOP: | |
df481e41 TI |
1566 | spec->num_mixers = 2; |
1567 | spec->mixers[1] = cxt5047_hp_spk_mixers; | |
1568 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; | |
c9b443d4 TD |
1569 | break; |
1570 | case CXT5047_LAPTOP_HP: | |
df481e41 TI |
1571 | spec->num_mixers = 2; |
1572 | spec->mixers[1] = cxt5047_hp_only_mixers; | |
fb3409e7 | 1573 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; |
c9b443d4 TD |
1574 | codec->patch_ops.init = cxt5047_hp_init; |
1575 | break; | |
1576 | case CXT5047_LAPTOP_EAPD: | |
82f30040 | 1577 | spec->input_mux = &cxt5047_toshiba_capture_source; |
df481e41 TI |
1578 | spec->num_mixers = 2; |
1579 | spec->mixers[1] = cxt5047_hp_spk_mixers; | |
c9b443d4 TD |
1580 | spec->num_init_verbs = 2; |
1581 | spec->init_verbs[1] = cxt5047_toshiba_init_verbs; | |
fb3409e7 | 1582 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; |
c9b443d4 TD |
1583 | break; |
1584 | #ifdef CONFIG_SND_DEBUG | |
1585 | case CXT5047_TEST: | |
1586 | spec->input_mux = &cxt5047_test_capture_source; | |
1587 | spec->mixers[0] = cxt5047_test_mixer; | |
1588 | spec->init_verbs[0] = cxt5047_test_init_verbs; | |
fb3409e7 | 1589 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; |
c9b443d4 TD |
1590 | #endif |
1591 | } | |
dd5746a8 | 1592 | spec->vmaster_nid = 0x13; |
c9b443d4 TD |
1593 | return 0; |
1594 | } | |
1595 | ||
461e2c78 TI |
1596 | /* Conexant 5051 specific */ |
1597 | static hda_nid_t cxt5051_dac_nids[1] = { 0x10 }; | |
1598 | static hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 }; | |
461e2c78 TI |
1599 | |
1600 | static struct hda_channel_mode cxt5051_modes[1] = { | |
1601 | { 2, NULL }, | |
1602 | }; | |
1603 | ||
1604 | static void cxt5051_update_speaker(struct hda_codec *codec) | |
1605 | { | |
1606 | struct conexant_spec *spec = codec->spec; | |
1607 | unsigned int pinctl; | |
23d2df5b TI |
1608 | /* headphone pin */ |
1609 | pinctl = (spec->hp_present && spec->cur_eapd) ? PIN_HP : 0; | |
1610 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
1611 | pinctl); | |
1612 | /* speaker pin */ | |
461e2c78 TI |
1613 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; |
1614 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
1615 | pinctl); | |
1616 | } | |
1617 | ||
1618 | /* turn on/off EAPD (+ mute HP) as a master switch */ | |
1619 | static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
1620 | struct snd_ctl_elem_value *ucontrol) | |
1621 | { | |
1622 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1623 | ||
1624 | if (!cxt_eapd_put(kcontrol, ucontrol)) | |
1625 | return 0; | |
1626 | cxt5051_update_speaker(codec); | |
1627 | return 1; | |
1628 | } | |
1629 | ||
1630 | /* toggle input of built-in and mic jack appropriately */ | |
1631 | static void cxt5051_portb_automic(struct hda_codec *codec) | |
1632 | { | |
79d7d533 | 1633 | struct conexant_spec *spec = codec->spec; |
461e2c78 TI |
1634 | unsigned int present; |
1635 | ||
faddaa5d | 1636 | if (!(spec->auto_mic & AUTO_MIC_PORTB)) |
79d7d533 | 1637 | return; |
d56757ab | 1638 | present = snd_hda_jack_detect(codec, 0x17); |
461e2c78 TI |
1639 | snd_hda_codec_write(codec, 0x14, 0, |
1640 | AC_VERB_SET_CONNECT_SEL, | |
1641 | present ? 0x01 : 0x00); | |
1642 | } | |
1643 | ||
1644 | /* switch the current ADC according to the jack state */ | |
1645 | static void cxt5051_portc_automic(struct hda_codec *codec) | |
1646 | { | |
1647 | struct conexant_spec *spec = codec->spec; | |
1648 | unsigned int present; | |
1649 | hda_nid_t new_adc; | |
1650 | ||
faddaa5d | 1651 | if (!(spec->auto_mic & AUTO_MIC_PORTC)) |
79d7d533 | 1652 | return; |
d56757ab | 1653 | present = snd_hda_jack_detect(codec, 0x18); |
461e2c78 TI |
1654 | if (present) |
1655 | spec->cur_adc_idx = 1; | |
1656 | else | |
1657 | spec->cur_adc_idx = 0; | |
1658 | new_adc = spec->adc_nids[spec->cur_adc_idx]; | |
1659 | if (spec->cur_adc && spec->cur_adc != new_adc) { | |
1660 | /* stream is running, let's swap the current ADC */ | |
888afa15 | 1661 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
461e2c78 TI |
1662 | spec->cur_adc = new_adc; |
1663 | snd_hda_codec_setup_stream(codec, new_adc, | |
1664 | spec->cur_adc_stream_tag, 0, | |
1665 | spec->cur_adc_format); | |
1666 | } | |
1667 | } | |
1668 | ||
1669 | /* mute internal speaker if HP is plugged */ | |
1670 | static void cxt5051_hp_automute(struct hda_codec *codec) | |
1671 | { | |
1672 | struct conexant_spec *spec = codec->spec; | |
1673 | ||
d56757ab | 1674 | spec->hp_present = snd_hda_jack_detect(codec, 0x16); |
461e2c78 TI |
1675 | cxt5051_update_speaker(codec); |
1676 | } | |
1677 | ||
1678 | /* unsolicited event for HP jack sensing */ | |
1679 | static void cxt5051_hp_unsol_event(struct hda_codec *codec, | |
1680 | unsigned int res) | |
1681 | { | |
acf26c0c | 1682 | int nid = (res & AC_UNSOL_RES_SUBTAG) >> 20; |
461e2c78 TI |
1683 | switch (res >> 26) { |
1684 | case CONEXANT_HP_EVENT: | |
1685 | cxt5051_hp_automute(codec); | |
1686 | break; | |
1687 | case CXT5051_PORTB_EVENT: | |
1688 | cxt5051_portb_automic(codec); | |
1689 | break; | |
1690 | case CXT5051_PORTC_EVENT: | |
1691 | cxt5051_portc_automic(codec); | |
1692 | break; | |
1693 | } | |
acf26c0c | 1694 | conexant_report_jack(codec, nid); |
461e2c78 TI |
1695 | } |
1696 | ||
2c7a3fb3 | 1697 | static struct snd_kcontrol_new cxt5051_playback_mixers[] = { |
461e2c78 TI |
1698 | HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), |
1699 | { | |
1700 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1701 | .name = "Master Playback Switch", | |
1702 | .info = cxt_eapd_info, | |
1703 | .get = cxt_eapd_get, | |
1704 | .put = cxt5051_hp_master_sw_put, | |
1705 | .private_value = 0x1a, | |
1706 | }, | |
2c7a3fb3 TI |
1707 | {} |
1708 | }; | |
461e2c78 | 1709 | |
2c7a3fb3 TI |
1710 | static struct snd_kcontrol_new cxt5051_capture_mixers[] = { |
1711 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), | |
1712 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), | |
1713 | HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT), | |
1714 | HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT), | |
1715 | HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT), | |
1716 | HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT), | |
461e2c78 TI |
1717 | {} |
1718 | }; | |
1719 | ||
1720 | static struct snd_kcontrol_new cxt5051_hp_mixers[] = { | |
1721 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), | |
1722 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), | |
1723 | HDA_CODEC_VOLUME("External Mic Volume", 0x15, 0x00, HDA_INPUT), | |
1724 | HDA_CODEC_MUTE("External Mic Switch", 0x15, 0x00, HDA_INPUT), | |
461e2c78 TI |
1725 | {} |
1726 | }; | |
1727 | ||
79d7d533 | 1728 | static struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = { |
4e4ac600 TI |
1729 | HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT), |
1730 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT), | |
79d7d533 TI |
1731 | {} |
1732 | }; | |
1733 | ||
cd9d95a5 | 1734 | static struct snd_kcontrol_new cxt5051_f700_mixers[] = { |
5f6c3de6 TI |
1735 | HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT), |
1736 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT), | |
cd9d95a5 KP |
1737 | {} |
1738 | }; | |
1739 | ||
faddaa5d TI |
1740 | static struct snd_kcontrol_new cxt5051_toshiba_mixers[] = { |
1741 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), | |
1742 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), | |
1743 | HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT), | |
1744 | HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT), | |
faddaa5d TI |
1745 | {} |
1746 | }; | |
1747 | ||
461e2c78 TI |
1748 | static struct hda_verb cxt5051_init_verbs[] = { |
1749 | /* Line in, Mic */ | |
1750 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, | |
1751 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1752 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, | |
1753 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1754 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1755 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, | |
1756 | /* SPK */ | |
1757 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1758 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1759 | /* HP, Amp */ | |
1760 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1761 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1762 | /* DAC1 */ | |
1763 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1764 | /* Record selector: Int mic */ | |
1765 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, | |
1766 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, | |
1767 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, | |
1768 | /* SPDIF route: PCM */ | |
1769 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
1770 | /* EAPD */ | |
1771 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
1772 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, | |
461e2c78 TI |
1773 | { } /* end */ |
1774 | }; | |
1775 | ||
79d7d533 TI |
1776 | static struct hda_verb cxt5051_hp_dv6736_init_verbs[] = { |
1777 | /* Line in, Mic */ | |
1778 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, | |
1779 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1780 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, | |
1781 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, | |
1782 | /* SPK */ | |
1783 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1784 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1785 | /* HP, Amp */ | |
1786 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1787 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1788 | /* DAC1 */ | |
1789 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1790 | /* Record selector: Int mic */ | |
1791 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, | |
1792 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, | |
1793 | /* SPDIF route: PCM */ | |
1794 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
1795 | /* EAPD */ | |
1796 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
1797 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, | |
79d7d533 TI |
1798 | { } /* end */ |
1799 | }; | |
1800 | ||
27e08988 ASRF |
1801 | static struct hda_verb cxt5051_lenovo_x200_init_verbs[] = { |
1802 | /* Line in, Mic */ | |
1803 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, | |
1804 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1805 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, | |
1806 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1807 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1808 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, | |
1809 | /* SPK */ | |
1810 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1811 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1812 | /* HP, Amp */ | |
1813 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1814 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1815 | /* Docking HP */ | |
1816 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1817 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1818 | /* DAC1 */ | |
1819 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1820 | /* Record selector: Int mic */ | |
1821 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, | |
1822 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, | |
1823 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, | |
1824 | /* SPDIF route: PCM */ | |
1825 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
1826 | /* EAPD */ | |
1827 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
1828 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, | |
27e08988 ASRF |
1829 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, |
1830 | { } /* end */ | |
1831 | }; | |
1832 | ||
cd9d95a5 KP |
1833 | static struct hda_verb cxt5051_f700_init_verbs[] = { |
1834 | /* Line in, Mic */ | |
1835 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x03}, | |
1836 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1837 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, | |
1838 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, | |
1839 | /* SPK */ | |
1840 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1841 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1842 | /* HP, Amp */ | |
1843 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1844 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1845 | /* DAC1 */ | |
1846 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1847 | /* Record selector: Int mic */ | |
1848 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, | |
1849 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, | |
1850 | /* SPDIF route: PCM */ | |
1851 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
1852 | /* EAPD */ | |
1853 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
1854 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, | |
cd9d95a5 KP |
1855 | { } /* end */ |
1856 | }; | |
1857 | ||
6953e552 TI |
1858 | static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid, |
1859 | unsigned int event) | |
1860 | { | |
1861 | snd_hda_codec_write(codec, nid, 0, | |
1862 | AC_VERB_SET_UNSOLICITED_ENABLE, | |
1863 | AC_USRSP_EN | event); | |
1864 | #ifdef CONFIG_SND_HDA_INPUT_JACK | |
1865 | conexant_add_jack(codec, nid, SND_JACK_MICROPHONE); | |
1866 | conexant_report_jack(codec, nid); | |
1867 | #endif | |
1868 | } | |
1869 | ||
461e2c78 TI |
1870 | /* initialize jack-sensing, too */ |
1871 | static int cxt5051_init(struct hda_codec *codec) | |
1872 | { | |
6953e552 TI |
1873 | struct conexant_spec *spec = codec->spec; |
1874 | ||
461e2c78 | 1875 | conexant_init(codec); |
acf26c0c | 1876 | conexant_init_jacks(codec); |
6953e552 TI |
1877 | |
1878 | if (spec->auto_mic & AUTO_MIC_PORTB) | |
1879 | cxt5051_init_mic_port(codec, 0x17, CXT5051_PORTB_EVENT); | |
1880 | if (spec->auto_mic & AUTO_MIC_PORTC) | |
1881 | cxt5051_init_mic_port(codec, 0x18, CXT5051_PORTC_EVENT); | |
1882 | ||
461e2c78 TI |
1883 | if (codec->patch_ops.unsol_event) { |
1884 | cxt5051_hp_automute(codec); | |
1885 | cxt5051_portb_automic(codec); | |
1886 | cxt5051_portc_automic(codec); | |
1887 | } | |
1888 | return 0; | |
1889 | } | |
1890 | ||
1891 | ||
1892 | enum { | |
1893 | CXT5051_LAPTOP, /* Laptops w/ EAPD support */ | |
1894 | CXT5051_HP, /* no docking */ | |
79d7d533 | 1895 | CXT5051_HP_DV6736, /* HP without mic switch */ |
27e08988 | 1896 | CXT5051_LENOVO_X200, /* Lenovo X200 laptop */ |
cd9d95a5 | 1897 | CXT5051_F700, /* HP Compaq Presario F700 */ |
faddaa5d | 1898 | CXT5051_TOSHIBA, /* Toshiba M300 & co */ |
461e2c78 TI |
1899 | CXT5051_MODELS |
1900 | }; | |
1901 | ||
1902 | static const char *cxt5051_models[CXT5051_MODELS] = { | |
1903 | [CXT5051_LAPTOP] = "laptop", | |
1904 | [CXT5051_HP] = "hp", | |
79d7d533 | 1905 | [CXT5051_HP_DV6736] = "hp-dv6736", |
27e08988 | 1906 | [CXT5051_LENOVO_X200] = "lenovo-x200", |
5f6c3de6 | 1907 | [CXT5051_F700] = "hp-700", |
faddaa5d | 1908 | [CXT5051_TOSHIBA] = "toshiba", |
461e2c78 TI |
1909 | }; |
1910 | ||
1911 | static struct snd_pci_quirk cxt5051_cfg_tbl[] = { | |
79d7d533 | 1912 | SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736), |
1812e67c | 1913 | SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP), |
5f6c3de6 | 1914 | SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700), |
faddaa5d | 1915 | SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA), |
461e2c78 TI |
1916 | SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", |
1917 | CXT5051_LAPTOP), | |
1918 | SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), | |
27e08988 | 1919 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200), |
461e2c78 TI |
1920 | {} |
1921 | }; | |
1922 | ||
1923 | static int patch_cxt5051(struct hda_codec *codec) | |
1924 | { | |
1925 | struct conexant_spec *spec; | |
1926 | int board_config; | |
1927 | ||
1928 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
1929 | if (!spec) | |
1930 | return -ENOMEM; | |
461e2c78 | 1931 | codec->spec = spec; |
9421f954 | 1932 | codec->pin_amp_workaround = 1; |
461e2c78 TI |
1933 | |
1934 | codec->patch_ops = conexant_patch_ops; | |
1935 | codec->patch_ops.init = cxt5051_init; | |
1936 | ||
1937 | spec->multiout.max_channels = 2; | |
1938 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids); | |
1939 | spec->multiout.dac_nids = cxt5051_dac_nids; | |
1940 | spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT; | |
1941 | spec->num_adc_nids = 1; /* not 2; via auto-mic switch */ | |
1942 | spec->adc_nids = cxt5051_adc_nids; | |
2c7a3fb3 TI |
1943 | spec->num_mixers = 2; |
1944 | spec->mixers[0] = cxt5051_capture_mixers; | |
1945 | spec->mixers[1] = cxt5051_playback_mixers; | |
461e2c78 TI |
1946 | spec->num_init_verbs = 1; |
1947 | spec->init_verbs[0] = cxt5051_init_verbs; | |
1948 | spec->spdif_route = 0; | |
1949 | spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes); | |
1950 | spec->channel_mode = cxt5051_modes; | |
1951 | spec->cur_adc = 0; | |
1952 | spec->cur_adc_idx = 0; | |
1953 | ||
79d7d533 TI |
1954 | codec->patch_ops.unsol_event = cxt5051_hp_unsol_event; |
1955 | ||
461e2c78 TI |
1956 | board_config = snd_hda_check_board_config(codec, CXT5051_MODELS, |
1957 | cxt5051_models, | |
1958 | cxt5051_cfg_tbl); | |
faddaa5d | 1959 | spec->auto_mic = AUTO_MIC_PORTB | AUTO_MIC_PORTC; |
461e2c78 TI |
1960 | switch (board_config) { |
1961 | case CXT5051_HP: | |
461e2c78 TI |
1962 | spec->mixers[0] = cxt5051_hp_mixers; |
1963 | break; | |
79d7d533 TI |
1964 | case CXT5051_HP_DV6736: |
1965 | spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs; | |
1966 | spec->mixers[0] = cxt5051_hp_dv6736_mixers; | |
faddaa5d | 1967 | spec->auto_mic = 0; |
79d7d533 | 1968 | break; |
27e08988 ASRF |
1969 | case CXT5051_LENOVO_X200: |
1970 | spec->init_verbs[0] = cxt5051_lenovo_x200_init_verbs; | |
461e2c78 | 1971 | break; |
cd9d95a5 KP |
1972 | case CXT5051_F700: |
1973 | spec->init_verbs[0] = cxt5051_f700_init_verbs; | |
1974 | spec->mixers[0] = cxt5051_f700_mixers; | |
faddaa5d TI |
1975 | spec->auto_mic = 0; |
1976 | break; | |
1977 | case CXT5051_TOSHIBA: | |
1978 | spec->mixers[0] = cxt5051_toshiba_mixers; | |
1979 | spec->auto_mic = AUTO_MIC_PORTB; | |
cd9d95a5 | 1980 | break; |
461e2c78 TI |
1981 | } |
1982 | ||
1983 | return 0; | |
1984 | } | |
1985 | ||
0fb67e98 DD |
1986 | /* Conexant 5066 specific */ |
1987 | ||
1988 | static hda_nid_t cxt5066_dac_nids[1] = { 0x10 }; | |
1989 | static hda_nid_t cxt5066_adc_nids[3] = { 0x14, 0x15, 0x16 }; | |
1990 | static hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 }; | |
1991 | #define CXT5066_SPDIF_OUT 0x21 | |
1992 | ||
dbaccc0c DD |
1993 | /* OLPC's microphone port is DC coupled for use with external sensors, |
1994 | * therefore we use a 50% mic bias in order to center the input signal with | |
1995 | * the DC input range of the codec. */ | |
1996 | #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50 | |
1997 | ||
0fb67e98 DD |
1998 | static struct hda_channel_mode cxt5066_modes[1] = { |
1999 | { 2, NULL }, | |
2000 | }; | |
2001 | ||
2002 | static void cxt5066_update_speaker(struct hda_codec *codec) | |
2003 | { | |
2004 | struct conexant_spec *spec = codec->spec; | |
2005 | unsigned int pinctl; | |
2006 | ||
2007 | snd_printdd("CXT5066: update speaker, hp_present=%d\n", | |
2008 | spec->hp_present); | |
2009 | ||
2010 | /* Port A (HP) */ | |
2011 | pinctl = ((spec->hp_present & 1) && spec->cur_eapd) ? PIN_HP : 0; | |
2012 | snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
2013 | pinctl); | |
2014 | ||
2015 | /* Port D (HP/LO) */ | |
2016 | pinctl = ((spec->hp_present & 2) && spec->cur_eapd) | |
2017 | ? spec->port_d_mode : 0; | |
2018 | snd_hda_codec_write(codec, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
2019 | pinctl); | |
2020 | ||
2021 | /* CLASS_D AMP */ | |
2022 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; | |
2023 | snd_hda_codec_write(codec, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
2024 | pinctl); | |
2025 | ||
2026 | if (spec->dell_automute) { | |
2027 | /* DELL AIO Port Rule: PortA > PortD > IntSpk */ | |
2028 | pinctl = (!(spec->hp_present & 1) && spec->cur_eapd) | |
2029 | ? PIN_OUT : 0; | |
2030 | snd_hda_codec_write(codec, 0x1c, 0, | |
2031 | AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl); | |
2032 | } | |
2033 | } | |
2034 | ||
2035 | /* turn on/off EAPD (+ mute HP) as a master switch */ | |
2036 | static int cxt5066_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
2037 | struct snd_ctl_elem_value *ucontrol) | |
2038 | { | |
2039 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2040 | ||
2041 | if (!cxt_eapd_put(kcontrol, ucontrol)) | |
2042 | return 0; | |
2043 | ||
2044 | cxt5066_update_speaker(codec); | |
2045 | return 1; | |
2046 | } | |
2047 | ||
c4cfe66c DD |
2048 | static const struct hda_input_mux cxt5066_olpc_dc_bias = { |
2049 | .num_items = 3, | |
2050 | .items = { | |
2051 | { "Off", PIN_IN }, | |
2052 | { "50%", PIN_VREF50 }, | |
2053 | { "80%", PIN_VREF80 }, | |
2054 | }, | |
2055 | }; | |
2056 | ||
2057 | static int cxt5066_set_olpc_dc_bias(struct hda_codec *codec) | |
2058 | { | |
2059 | struct conexant_spec *spec = codec->spec; | |
2060 | /* Even though port F is the DC input, the bias is controlled on port B. | |
2061 | * we also leave that port as an active input (but unselected) in DC mode | |
2062 | * just in case that is necessary to make the bias setting take effect. */ | |
2063 | return snd_hda_codec_write_cache(codec, 0x1a, 0, | |
2064 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
2065 | cxt5066_olpc_dc_bias.items[spec->dc_input_bias].index); | |
2066 | } | |
2067 | ||
75f8991d DD |
2068 | /* OLPC defers mic widget control until when capture is started because the |
2069 | * microphone LED comes on as soon as these settings are put in place. if we | |
2070 | * did this before recording, it would give the false indication that recording | |
2071 | * is happening when it is not. */ | |
2072 | static void cxt5066_olpc_select_mic(struct hda_codec *codec) | |
0fb67e98 | 2073 | { |
dbaccc0c | 2074 | struct conexant_spec *spec = codec->spec; |
75f8991d DD |
2075 | if (!spec->recording) |
2076 | return; | |
0fb67e98 | 2077 | |
c4cfe66c DD |
2078 | if (spec->dc_enable) { |
2079 | /* in DC mode we ignore presence detection and just use the jack | |
2080 | * through our special DC port */ | |
2081 | const struct hda_verb enable_dc_mode[] = { | |
2082 | /* disble internal mic, port C */ | |
2083 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2084 | ||
2085 | /* enable DC capture, port F */ | |
2086 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2087 | {}, | |
2088 | }; | |
2089 | ||
2090 | snd_hda_sequence_write(codec, enable_dc_mode); | |
2091 | /* port B input disabled (and bias set) through the following call */ | |
2092 | cxt5066_set_olpc_dc_bias(codec); | |
2093 | return; | |
2094 | } | |
2095 | ||
2096 | /* disable DC (port F) */ | |
2097 | snd_hda_codec_write(codec, 0x1e, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | |
2098 | ||
75f8991d DD |
2099 | /* external mic, port B */ |
2100 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
2101 | spec->ext_mic_present ? CXT5066_OLPC_EXT_MIC_BIAS : 0); | |
0fb67e98 | 2102 | |
75f8991d DD |
2103 | /* internal mic, port C */ |
2104 | snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
2105 | spec->ext_mic_present ? 0 : PIN_VREF80); | |
2106 | } | |
0fb67e98 | 2107 | |
75f8991d DD |
2108 | /* toggle input of built-in and mic jack appropriately */ |
2109 | static void cxt5066_olpc_automic(struct hda_codec *codec) | |
2110 | { | |
2111 | struct conexant_spec *spec = codec->spec; | |
0fb67e98 DD |
2112 | unsigned int present; |
2113 | ||
c4cfe66c DD |
2114 | if (spec->dc_enable) /* don't do presence detection in DC mode */ |
2115 | return; | |
2116 | ||
75f8991d DD |
2117 | present = snd_hda_codec_read(codec, 0x1a, 0, |
2118 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
2119 | if (present) | |
0fb67e98 | 2120 | snd_printdd("CXT5066: external microphone detected\n"); |
75f8991d | 2121 | else |
0fb67e98 | 2122 | snd_printdd("CXT5066: external microphone absent\n"); |
75f8991d DD |
2123 | |
2124 | snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, | |
2125 | present ? 0 : 1); | |
2126 | spec->ext_mic_present = !!present; | |
2127 | ||
2128 | cxt5066_olpc_select_mic(codec); | |
0fb67e98 DD |
2129 | } |
2130 | ||
95a618bd ER |
2131 | /* toggle input of built-in digital mic and mic jack appropriately */ |
2132 | static void cxt5066_vostro_automic(struct hda_codec *codec) | |
2133 | { | |
95a618bd ER |
2134 | unsigned int present; |
2135 | ||
2136 | struct hda_verb ext_mic_present[] = { | |
2137 | /* enable external mic, port B */ | |
75f8991d | 2138 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
95a618bd ER |
2139 | |
2140 | /* switch to external mic input */ | |
2141 | {0x17, AC_VERB_SET_CONNECT_SEL, 0}, | |
2142 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, | |
2143 | ||
2144 | /* disable internal digital mic */ | |
2145 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2146 | {} | |
2147 | }; | |
2148 | static struct hda_verb ext_mic_absent[] = { | |
2149 | /* enable internal mic, port C */ | |
2150 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2151 | ||
2152 | /* switch to internal mic input */ | |
2153 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, | |
2154 | ||
2155 | /* disable external mic, port B */ | |
2156 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2157 | {} | |
2158 | }; | |
2159 | ||
2160 | present = snd_hda_jack_detect(codec, 0x1a); | |
2161 | if (present) { | |
2162 | snd_printdd("CXT5066: external microphone detected\n"); | |
2163 | snd_hda_sequence_write(codec, ext_mic_present); | |
2164 | } else { | |
2165 | snd_printdd("CXT5066: external microphone absent\n"); | |
2166 | snd_hda_sequence_write(codec, ext_mic_absent); | |
2167 | } | |
2168 | } | |
2169 | ||
0fb67e98 DD |
2170 | /* mute internal speaker if HP is plugged */ |
2171 | static void cxt5066_hp_automute(struct hda_codec *codec) | |
2172 | { | |
2173 | struct conexant_spec *spec = codec->spec; | |
2174 | unsigned int portA, portD; | |
2175 | ||
2176 | /* Port A */ | |
d56757ab | 2177 | portA = snd_hda_jack_detect(codec, 0x19); |
0fb67e98 DD |
2178 | |
2179 | /* Port D */ | |
d56757ab | 2180 | portD = snd_hda_jack_detect(codec, 0x1c); |
0fb67e98 DD |
2181 | |
2182 | spec->hp_present = !!(portA | portD); | |
2183 | snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n", | |
2184 | portA, portD, spec->hp_present); | |
2185 | cxt5066_update_speaker(codec); | |
2186 | } | |
2187 | ||
2188 | /* unsolicited event for jack sensing */ | |
75f8991d | 2189 | static void cxt5066_olpc_unsol_event(struct hda_codec *codec, unsigned int res) |
0fb67e98 | 2190 | { |
c4cfe66c | 2191 | struct conexant_spec *spec = codec->spec; |
0fb67e98 DD |
2192 | snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); |
2193 | switch (res >> 26) { | |
2194 | case CONEXANT_HP_EVENT: | |
2195 | cxt5066_hp_automute(codec); | |
2196 | break; | |
2197 | case CONEXANT_MIC_EVENT: | |
c4cfe66c DD |
2198 | /* ignore mic events in DC mode; we're always using the jack */ |
2199 | if (!spec->dc_enable) | |
2200 | cxt5066_olpc_automic(codec); | |
0fb67e98 DD |
2201 | break; |
2202 | } | |
2203 | } | |
2204 | ||
95a618bd ER |
2205 | /* unsolicited event for jack sensing */ |
2206 | static void cxt5066_vostro_event(struct hda_codec *codec, unsigned int res) | |
2207 | { | |
2208 | snd_printdd("CXT5066_vostro: unsol event %x (%x)\n", res, res >> 26); | |
2209 | switch (res >> 26) { | |
2210 | case CONEXANT_HP_EVENT: | |
2211 | cxt5066_hp_automute(codec); | |
2212 | break; | |
2213 | case CONEXANT_MIC_EVENT: | |
2214 | cxt5066_vostro_automic(codec); | |
2215 | break; | |
2216 | } | |
2217 | } | |
2218 | ||
0fb67e98 DD |
2219 | static const struct hda_input_mux cxt5066_analog_mic_boost = { |
2220 | .num_items = 5, | |
2221 | .items = { | |
2222 | { "0dB", 0 }, | |
2223 | { "10dB", 1 }, | |
2224 | { "20dB", 2 }, | |
2225 | { "30dB", 3 }, | |
2226 | { "40dB", 4 }, | |
2227 | }, | |
2228 | }; | |
2229 | ||
c4cfe66c DD |
2230 | static int cxt5066_set_mic_boost(struct hda_codec *codec) |
2231 | { | |
2232 | struct conexant_spec *spec = codec->spec; | |
2233 | return snd_hda_codec_write_cache(codec, 0x17, 0, | |
2234 | AC_VERB_SET_AMP_GAIN_MUTE, | |
2235 | AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT | | |
2236 | cxt5066_analog_mic_boost.items[spec->mic_boost].index); | |
2237 | } | |
2238 | ||
0fb67e98 DD |
2239 | static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol *kcontrol, |
2240 | struct snd_ctl_elem_info *uinfo) | |
2241 | { | |
2242 | return snd_hda_input_mux_info(&cxt5066_analog_mic_boost, uinfo); | |
2243 | } | |
2244 | ||
2245 | static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol *kcontrol, | |
2246 | struct snd_ctl_elem_value *ucontrol) | |
2247 | { | |
2248 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
c4cfe66c DD |
2249 | struct conexant_spec *spec = codec->spec; |
2250 | ucontrol->value.enumerated.item[0] = spec->mic_boost; | |
0fb67e98 DD |
2251 | return 0; |
2252 | } | |
2253 | ||
2254 | static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol, | |
2255 | struct snd_ctl_elem_value *ucontrol) | |
2256 | { | |
2257 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
c4cfe66c | 2258 | struct conexant_spec *spec = codec->spec; |
0fb67e98 DD |
2259 | const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; |
2260 | unsigned int idx; | |
c4cfe66c DD |
2261 | idx = ucontrol->value.enumerated.item[0]; |
2262 | if (idx >= imux->num_items) | |
2263 | idx = imux->num_items - 1; | |
2264 | ||
2265 | spec->mic_boost = idx; | |
2266 | if (!spec->dc_enable) | |
2267 | cxt5066_set_mic_boost(codec); | |
2268 | return 1; | |
2269 | } | |
2270 | ||
2271 | static void cxt5066_enable_dc(struct hda_codec *codec) | |
2272 | { | |
2273 | const struct hda_verb enable_dc_mode[] = { | |
2274 | /* disable gain */ | |
2275 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2276 | ||
2277 | /* switch to DC input */ | |
2278 | {0x17, AC_VERB_SET_CONNECT_SEL, 3}, | |
2279 | {} | |
2280 | }; | |
2281 | ||
2282 | /* configure as input source */ | |
2283 | snd_hda_sequence_write(codec, enable_dc_mode); | |
2284 | cxt5066_olpc_select_mic(codec); /* also sets configured bias */ | |
2285 | } | |
2286 | ||
2287 | static void cxt5066_disable_dc(struct hda_codec *codec) | |
2288 | { | |
2289 | /* reconfigure input source */ | |
2290 | cxt5066_set_mic_boost(codec); | |
2291 | /* automic also selects the right mic if we're recording */ | |
2292 | cxt5066_olpc_automic(codec); | |
2293 | } | |
2294 | ||
2295 | static int cxt5066_olpc_dc_get(struct snd_kcontrol *kcontrol, | |
2296 | struct snd_ctl_elem_value *ucontrol) | |
2297 | { | |
2298 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2299 | struct conexant_spec *spec = codec->spec; | |
2300 | ucontrol->value.integer.value[0] = spec->dc_enable; | |
2301 | return 0; | |
2302 | } | |
0fb67e98 | 2303 | |
c4cfe66c DD |
2304 | static int cxt5066_olpc_dc_put(struct snd_kcontrol *kcontrol, |
2305 | struct snd_ctl_elem_value *ucontrol) | |
2306 | { | |
2307 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2308 | struct conexant_spec *spec = codec->spec; | |
2309 | int dc_enable = !!ucontrol->value.integer.value[0]; | |
2310 | ||
2311 | if (dc_enable == spec->dc_enable) | |
0fb67e98 | 2312 | return 0; |
c4cfe66c DD |
2313 | |
2314 | spec->dc_enable = dc_enable; | |
2315 | if (dc_enable) | |
2316 | cxt5066_enable_dc(codec); | |
2317 | else | |
2318 | cxt5066_disable_dc(codec); | |
2319 | ||
2320 | return 1; | |
2321 | } | |
2322 | ||
2323 | static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol *kcontrol, | |
2324 | struct snd_ctl_elem_info *uinfo) | |
2325 | { | |
2326 | return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias, uinfo); | |
2327 | } | |
2328 | ||
2329 | static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol *kcontrol, | |
2330 | struct snd_ctl_elem_value *ucontrol) | |
2331 | { | |
2332 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2333 | struct conexant_spec *spec = codec->spec; | |
2334 | ucontrol->value.enumerated.item[0] = spec->dc_input_bias; | |
2335 | return 0; | |
2336 | } | |
2337 | ||
2338 | static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol *kcontrol, | |
2339 | struct snd_ctl_elem_value *ucontrol) | |
2340 | { | |
2341 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2342 | struct conexant_spec *spec = codec->spec; | |
2343 | const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; | |
2344 | unsigned int idx; | |
2345 | ||
0fb67e98 DD |
2346 | idx = ucontrol->value.enumerated.item[0]; |
2347 | if (idx >= imux->num_items) | |
2348 | idx = imux->num_items - 1; | |
2349 | ||
c4cfe66c DD |
2350 | spec->dc_input_bias = idx; |
2351 | if (spec->dc_enable) | |
2352 | cxt5066_set_olpc_dc_bias(codec); | |
0fb67e98 DD |
2353 | return 1; |
2354 | } | |
2355 | ||
75f8991d DD |
2356 | static void cxt5066_olpc_capture_prepare(struct hda_codec *codec) |
2357 | { | |
2358 | struct conexant_spec *spec = codec->spec; | |
2359 | /* mark as recording and configure the microphone widget so that the | |
2360 | * recording LED comes on. */ | |
2361 | spec->recording = 1; | |
2362 | cxt5066_olpc_select_mic(codec); | |
2363 | } | |
2364 | ||
2365 | static void cxt5066_olpc_capture_cleanup(struct hda_codec *codec) | |
2366 | { | |
2367 | struct conexant_spec *spec = codec->spec; | |
2368 | const struct hda_verb disable_mics[] = { | |
2369 | /* disable external mic, port B */ | |
2370 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2371 | ||
2372 | /* disble internal mic, port C */ | |
2373 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
c4cfe66c DD |
2374 | |
2375 | /* disable DC capture, port F */ | |
2376 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
75f8991d DD |
2377 | {}, |
2378 | }; | |
2379 | ||
2380 | snd_hda_sequence_write(codec, disable_mics); | |
2381 | spec->recording = 0; | |
2382 | } | |
2383 | ||
0fb67e98 DD |
2384 | static struct hda_input_mux cxt5066_capture_source = { |
2385 | .num_items = 4, | |
2386 | .items = { | |
2387 | { "Mic B", 0 }, | |
2388 | { "Mic C", 1 }, | |
2389 | { "Mic E", 2 }, | |
2390 | { "Mic F", 3 }, | |
2391 | }, | |
2392 | }; | |
2393 | ||
2394 | static struct hda_bind_ctls cxt5066_bind_capture_vol_others = { | |
2395 | .ops = &snd_hda_bind_vol, | |
2396 | .values = { | |
2397 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), | |
2398 | HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), | |
2399 | 0 | |
2400 | }, | |
2401 | }; | |
2402 | ||
2403 | static struct hda_bind_ctls cxt5066_bind_capture_sw_others = { | |
2404 | .ops = &snd_hda_bind_sw, | |
2405 | .values = { | |
2406 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), | |
2407 | HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), | |
2408 | 0 | |
2409 | }, | |
2410 | }; | |
2411 | ||
2412 | static struct snd_kcontrol_new cxt5066_mixer_master[] = { | |
2413 | HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), | |
2414 | {} | |
2415 | }; | |
2416 | ||
2417 | static struct snd_kcontrol_new cxt5066_mixer_master_olpc[] = { | |
2418 | { | |
2419 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2420 | .name = "Master Playback Volume", | |
2421 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | | |
2422 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | | |
2423 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, | |
5e26dfd0 | 2424 | .subdevice = HDA_SUBDEV_AMP_FLAG, |
0fb67e98 DD |
2425 | .info = snd_hda_mixer_amp_volume_info, |
2426 | .get = snd_hda_mixer_amp_volume_get, | |
2427 | .put = snd_hda_mixer_amp_volume_put, | |
2428 | .tlv = { .c = snd_hda_mixer_amp_tlv }, | |
2429 | /* offset by 28 volume steps to limit minimum gain to -46dB */ | |
2430 | .private_value = | |
2431 | HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT, 28), | |
2432 | }, | |
2433 | {} | |
2434 | }; | |
2435 | ||
c4cfe66c DD |
2436 | static struct snd_kcontrol_new cxt5066_mixer_olpc_dc[] = { |
2437 | { | |
2438 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2439 | .name = "DC Mode Enable Switch", | |
2440 | .info = snd_ctl_boolean_mono_info, | |
2441 | .get = cxt5066_olpc_dc_get, | |
2442 | .put = cxt5066_olpc_dc_put, | |
2443 | }, | |
2444 | { | |
2445 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2446 | .name = "DC Input Bias Enum", | |
2447 | .info = cxt5066_olpc_dc_bias_enum_info, | |
2448 | .get = cxt5066_olpc_dc_bias_enum_get, | |
2449 | .put = cxt5066_olpc_dc_bias_enum_put, | |
2450 | }, | |
2451 | {} | |
2452 | }; | |
2453 | ||
0fb67e98 DD |
2454 | static struct snd_kcontrol_new cxt5066_mixers[] = { |
2455 | { | |
2456 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2457 | .name = "Master Playback Switch", | |
2458 | .info = cxt_eapd_info, | |
2459 | .get = cxt_eapd_get, | |
2460 | .put = cxt5066_hp_master_sw_put, | |
2461 | .private_value = 0x1d, | |
2462 | }, | |
2463 | ||
2464 | { | |
2465 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
c4cfe66c | 2466 | .name = "Analog Mic Boost Capture Enum", |
0fb67e98 DD |
2467 | .info = cxt5066_mic_boost_mux_enum_info, |
2468 | .get = cxt5066_mic_boost_mux_enum_get, | |
2469 | .put = cxt5066_mic_boost_mux_enum_put, | |
2470 | }, | |
2471 | ||
2472 | HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others), | |
2473 | HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others), | |
2474 | {} | |
2475 | }; | |
2476 | ||
254bba6a ER |
2477 | static struct snd_kcontrol_new cxt5066_vostro_mixers[] = { |
2478 | { | |
2479 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2480 | .name = "Int Mic Boost Capture Enum", | |
2481 | .info = cxt5066_mic_boost_mux_enum_info, | |
2482 | .get = cxt5066_mic_boost_mux_enum_get, | |
2483 | .put = cxt5066_mic_boost_mux_enum_put, | |
2484 | .private_value = 0x23 | 0x100, | |
2485 | }, | |
c0f8faf0 | 2486 | HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT), |
254bba6a ER |
2487 | {} |
2488 | }; | |
2489 | ||
0fb67e98 DD |
2490 | static struct hda_verb cxt5066_init_verbs[] = { |
2491 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ | |
2492 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ | |
2493 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ | |
2494 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ | |
2495 | ||
2496 | /* Speakers */ | |
2497 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2498 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2499 | ||
2500 | /* HP, Amp */ | |
2501 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2502 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2503 | ||
2504 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2505 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2506 | ||
2507 | /* DAC1 */ | |
2508 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2509 | ||
2510 | /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ | |
2511 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, | |
2512 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2513 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, | |
2514 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2515 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2516 | ||
2517 | /* no digital microphone support yet */ | |
2518 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2519 | ||
2520 | /* Audio input selector */ | |
2521 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, | |
2522 | ||
2523 | /* SPDIF route: PCM */ | |
2524 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
2525 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
2526 | ||
2527 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2528 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2529 | ||
2530 | /* EAPD */ | |
2531 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
2532 | ||
2533 | /* not handling these yet */ | |
2534 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2535 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2536 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2537 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2538 | {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2539 | {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2540 | {0x20, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2541 | {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2542 | { } /* end */ | |
2543 | }; | |
2544 | ||
2545 | static struct hda_verb cxt5066_init_verbs_olpc[] = { | |
2546 | /* Port A: headphones */ | |
2547 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2548 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2549 | ||
2550 | /* Port B: external microphone */ | |
75f8991d | 2551 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
0fb67e98 DD |
2552 | |
2553 | /* Port C: internal microphone */ | |
75f8991d | 2554 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
0fb67e98 DD |
2555 | |
2556 | /* Port D: unused */ | |
2557 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2558 | ||
2559 | /* Port E: unused, but has primary EAPD */ | |
2560 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2561 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
2562 | ||
c4cfe66c | 2563 | /* Port F: external DC input through microphone port */ |
0fb67e98 DD |
2564 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
2565 | ||
2566 | /* Port G: internal speakers */ | |
2567 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2568 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2569 | ||
2570 | /* DAC1 */ | |
2571 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2572 | ||
2573 | /* DAC2: unused */ | |
2574 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2575 | ||
2576 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, | |
2577 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2578 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2579 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2580 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
2581 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2582 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2583 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2584 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
2585 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2586 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2587 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2588 | ||
2589 | /* Disable digital microphone port */ | |
2590 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2591 | ||
2592 | /* Audio input selectors */ | |
2593 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, | |
2594 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
2595 | ||
2596 | /* Disable SPDIF */ | |
2597 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2598 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2599 | ||
2600 | /* enable unsolicited events for Port A and B */ | |
2601 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | |
2602 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | |
2603 | { } /* end */ | |
2604 | }; | |
2605 | ||
95a618bd ER |
2606 | static struct hda_verb cxt5066_init_verbs_vostro[] = { |
2607 | /* Port A: headphones */ | |
2608 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2609 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2610 | ||
2611 | /* Port B: external microphone */ | |
2612 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2613 | ||
2614 | /* Port C: unused */ | |
2615 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2616 | ||
2617 | /* Port D: unused */ | |
2618 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2619 | ||
2620 | /* Port E: unused, but has primary EAPD */ | |
2621 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2622 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
2623 | ||
2624 | /* Port F: unused */ | |
2625 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2626 | ||
2627 | /* Port G: internal speakers */ | |
2628 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2629 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2630 | ||
2631 | /* DAC1 */ | |
2632 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2633 | ||
2634 | /* DAC2: unused */ | |
2635 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2636 | ||
2637 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
2638 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2639 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2640 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2641 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
2642 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2643 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2644 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2645 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
2646 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2647 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2648 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2649 | ||
2650 | /* Digital microphone port */ | |
2651 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2652 | ||
2653 | /* Audio input selectors */ | |
2654 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, | |
2655 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
2656 | ||
2657 | /* Disable SPDIF */ | |
2658 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2659 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2660 | ||
2661 | /* enable unsolicited events for Port A and B */ | |
2662 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | |
2663 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | |
2664 | { } /* end */ | |
2665 | }; | |
2666 | ||
0fb67e98 DD |
2667 | static struct hda_verb cxt5066_init_verbs_portd_lo[] = { |
2668 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2669 | { } /* end */ | |
2670 | }; | |
2671 | ||
2672 | /* initialize jack-sensing, too */ | |
2673 | static int cxt5066_init(struct hda_codec *codec) | |
2674 | { | |
254bba6a ER |
2675 | struct conexant_spec *spec = codec->spec; |
2676 | ||
0fb67e98 DD |
2677 | snd_printdd("CXT5066: init\n"); |
2678 | conexant_init(codec); | |
2679 | if (codec->patch_ops.unsol_event) { | |
2680 | cxt5066_hp_automute(codec); | |
254bba6a ER |
2681 | if (spec->dell_vostro) |
2682 | cxt5066_vostro_automic(codec); | |
0fb67e98 | 2683 | } |
c4cfe66c | 2684 | cxt5066_set_mic_boost(codec); |
0fb67e98 DD |
2685 | return 0; |
2686 | } | |
2687 | ||
75f8991d DD |
2688 | static int cxt5066_olpc_init(struct hda_codec *codec) |
2689 | { | |
c4cfe66c | 2690 | struct conexant_spec *spec = codec->spec; |
75f8991d DD |
2691 | snd_printdd("CXT5066: init\n"); |
2692 | conexant_init(codec); | |
2693 | cxt5066_hp_automute(codec); | |
c4cfe66c DD |
2694 | if (!spec->dc_enable) { |
2695 | cxt5066_set_mic_boost(codec); | |
2696 | cxt5066_olpc_automic(codec); | |
2697 | } else { | |
2698 | cxt5066_enable_dc(codec); | |
2699 | } | |
75f8991d DD |
2700 | return 0; |
2701 | } | |
2702 | ||
0fb67e98 DD |
2703 | enum { |
2704 | CXT5066_LAPTOP, /* Laptops w/ EAPD support */ | |
2705 | CXT5066_DELL_LAPTOP, /* Dell Laptop */ | |
2706 | CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */ | |
95a618bd | 2707 | CXT5066_DELL_VOSTO, /* Dell Vostro 1015i */ |
0fb67e98 DD |
2708 | CXT5066_MODELS |
2709 | }; | |
2710 | ||
2711 | static const char *cxt5066_models[CXT5066_MODELS] = { | |
2712 | [CXT5066_LAPTOP] = "laptop", | |
2713 | [CXT5066_DELL_LAPTOP] = "dell-laptop", | |
2714 | [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5", | |
95a618bd | 2715 | [CXT5066_DELL_VOSTO] = "dell-vostro" |
0fb67e98 DD |
2716 | }; |
2717 | ||
2718 | static struct snd_pci_quirk cxt5066_cfg_tbl[] = { | |
2719 | SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", | |
2720 | CXT5066_LAPTOP), | |
2721 | SND_PCI_QUIRK(0x1028, 0x02f5, "Dell", | |
2722 | CXT5066_DELL_LAPTOP), | |
798a8a15 | 2723 | SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5), |
95a618bd | 2724 | SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTO), |
0fb67e98 DD |
2725 | {} |
2726 | }; | |
2727 | ||
2728 | static int patch_cxt5066(struct hda_codec *codec) | |
2729 | { | |
2730 | struct conexant_spec *spec; | |
2731 | int board_config; | |
2732 | ||
2733 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
2734 | if (!spec) | |
2735 | return -ENOMEM; | |
2736 | codec->spec = spec; | |
2737 | ||
2738 | codec->patch_ops = conexant_patch_ops; | |
75f8991d | 2739 | codec->patch_ops.init = conexant_init; |
0fb67e98 DD |
2740 | |
2741 | spec->dell_automute = 0; | |
2742 | spec->multiout.max_channels = 2; | |
2743 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5066_dac_nids); | |
2744 | spec->multiout.dac_nids = cxt5066_dac_nids; | |
2745 | spec->multiout.dig_out_nid = CXT5066_SPDIF_OUT; | |
2746 | spec->num_adc_nids = 1; | |
2747 | spec->adc_nids = cxt5066_adc_nids; | |
2748 | spec->capsrc_nids = cxt5066_capsrc_nids; | |
2749 | spec->input_mux = &cxt5066_capture_source; | |
2750 | ||
2751 | spec->port_d_mode = PIN_HP; | |
2752 | ||
2753 | spec->num_init_verbs = 1; | |
2754 | spec->init_verbs[0] = cxt5066_init_verbs; | |
2755 | spec->num_channel_mode = ARRAY_SIZE(cxt5066_modes); | |
2756 | spec->channel_mode = cxt5066_modes; | |
2757 | spec->cur_adc = 0; | |
2758 | spec->cur_adc_idx = 0; | |
2759 | ||
2760 | board_config = snd_hda_check_board_config(codec, CXT5066_MODELS, | |
2761 | cxt5066_models, cxt5066_cfg_tbl); | |
2762 | switch (board_config) { | |
2763 | default: | |
2764 | case CXT5066_LAPTOP: | |
2765 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; | |
2766 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | |
2767 | break; | |
2768 | case CXT5066_DELL_LAPTOP: | |
2769 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; | |
2770 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | |
2771 | ||
2772 | spec->port_d_mode = PIN_OUT; | |
2773 | spec->init_verbs[spec->num_init_verbs] = cxt5066_init_verbs_portd_lo; | |
2774 | spec->num_init_verbs++; | |
2775 | spec->dell_automute = 1; | |
2776 | break; | |
2777 | case CXT5066_OLPC_XO_1_5: | |
75f8991d DD |
2778 | codec->patch_ops.init = cxt5066_olpc_init; |
2779 | codec->patch_ops.unsol_event = cxt5066_olpc_unsol_event; | |
0fb67e98 DD |
2780 | spec->init_verbs[0] = cxt5066_init_verbs_olpc; |
2781 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; | |
c4cfe66c | 2782 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_olpc_dc; |
0fb67e98 DD |
2783 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
2784 | spec->port_d_mode = 0; | |
c4cfe66c | 2785 | spec->mic_boost = 3; /* default 30dB gain */ |
0fb67e98 DD |
2786 | |
2787 | /* no S/PDIF out */ | |
2788 | spec->multiout.dig_out_nid = 0; | |
2789 | ||
95a618bd ER |
2790 | /* input source automatically selected */ |
2791 | spec->input_mux = NULL; | |
75f8991d DD |
2792 | |
2793 | /* our capture hooks which allow us to turn on the microphone LED | |
2794 | * at the right time */ | |
2795 | spec->capture_prepare = cxt5066_olpc_capture_prepare; | |
2796 | spec->capture_cleanup = cxt5066_olpc_capture_cleanup; | |
95a618bd ER |
2797 | break; |
2798 | case CXT5066_DELL_VOSTO: | |
75f8991d | 2799 | codec->patch_ops.init = cxt5066_init; |
95a618bd ER |
2800 | codec->patch_ops.unsol_event = cxt5066_vostro_event; |
2801 | spec->init_verbs[0] = cxt5066_init_verbs_vostro; | |
2802 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; | |
2803 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | |
254bba6a | 2804 | spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers; |
95a618bd | 2805 | spec->port_d_mode = 0; |
254bba6a | 2806 | spec->dell_vostro = 1; |
c4cfe66c | 2807 | spec->mic_boost = 3; /* default 30dB gain */ |
c0f8faf0 | 2808 | snd_hda_attach_beep_device(codec, 0x13); |
95a618bd ER |
2809 | |
2810 | /* no S/PDIF out */ | |
2811 | spec->multiout.dig_out_nid = 0; | |
2812 | ||
0fb67e98 DD |
2813 | /* input source automatically selected */ |
2814 | spec->input_mux = NULL; | |
2815 | break; | |
2816 | } | |
2817 | ||
2818 | return 0; | |
2819 | } | |
461e2c78 TI |
2820 | |
2821 | /* | |
2822 | */ | |
2823 | ||
1289e9e8 | 2824 | static struct hda_codec_preset snd_hda_preset_conexant[] = { |
82f30040 TD |
2825 | { .id = 0x14f15045, .name = "CX20549 (Venice)", |
2826 | .patch = patch_cxt5045 }, | |
2827 | { .id = 0x14f15047, .name = "CX20551 (Waikiki)", | |
2828 | .patch = patch_cxt5047 }, | |
461e2c78 TI |
2829 | { .id = 0x14f15051, .name = "CX20561 (Hermosa)", |
2830 | .patch = patch_cxt5051 }, | |
0fb67e98 DD |
2831 | { .id = 0x14f15066, .name = "CX20582 (Pebble)", |
2832 | .patch = patch_cxt5066 }, | |
95a618bd ER |
2833 | { .id = 0x14f15067, .name = "CX20583 (Pebble HSF)", |
2834 | .patch = patch_cxt5066 }, | |
c9b443d4 TD |
2835 | {} /* terminator */ |
2836 | }; | |
1289e9e8 TI |
2837 | |
2838 | MODULE_ALIAS("snd-hda-codec-id:14f15045"); | |
2839 | MODULE_ALIAS("snd-hda-codec-id:14f15047"); | |
2840 | MODULE_ALIAS("snd-hda-codec-id:14f15051"); | |
0fb67e98 | 2841 | MODULE_ALIAS("snd-hda-codec-id:14f15066"); |
95a618bd | 2842 | MODULE_ALIAS("snd-hda-codec-id:14f15067"); |
1289e9e8 TI |
2843 | |
2844 | MODULE_LICENSE("GPL"); | |
2845 | MODULE_DESCRIPTION("Conexant HD-audio codec"); | |
2846 | ||
2847 | static struct hda_codec_preset_list conexant_list = { | |
2848 | .preset = snd_hda_preset_conexant, | |
2849 | .owner = THIS_MODULE, | |
2850 | }; | |
2851 | ||
2852 | static int __init patch_conexant_init(void) | |
2853 | { | |
2854 | return snd_hda_add_codec_preset(&conexant_list); | |
2855 | } | |
2856 | ||
2857 | static void __exit patch_conexant_exit(void) | |
2858 | { | |
2859 | snd_hda_delete_codec_preset(&conexant_list); | |
2860 | } | |
2861 | ||
2862 | module_init(patch_conexant_init) | |
2863 | module_exit(patch_conexant_exit) |