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