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> | |
da155d5b | 26 | #include <linux/module.h> |
c9b443d4 | 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" | |
23d30f28 | 32 | #include "hda_auto_parser.h" |
c0f8faf0 | 33 | #include "hda_beep.h" |
1835a0f9 | 34 | #include "hda_jack.h" |
aed523f1 | 35 | #include "hda_generic.h" |
c9b443d4 | 36 | |
3760bc74 | 37 | #undef ENABLE_CXT_STATIC_QUIRKS |
c9b443d4 TD |
38 | |
39 | #define CXT_PIN_DIR_IN 0x00 | |
40 | #define CXT_PIN_DIR_OUT 0x01 | |
41 | #define CXT_PIN_DIR_INOUT 0x02 | |
42 | #define CXT_PIN_DIR_IN_NOMICBIAS 0x03 | |
43 | #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04 | |
44 | ||
45 | #define CONEXANT_HP_EVENT 0x37 | |
46 | #define CONEXANT_MIC_EVENT 0x38 | |
03697e2a | 47 | #define CONEXANT_LINE_EVENT 0x39 |
c9b443d4 | 48 | |
bc7a166d UD |
49 | /* Conexant 5051 specific */ |
50 | ||
ecda0cff | 51 | #define CXT5051_SPDIF_OUT 0x12 |
bc7a166d UD |
52 | #define CXT5051_PORTB_EVENT 0x38 |
53 | #define CXT5051_PORTC_EVENT 0x39 | |
c9b443d4 | 54 | |
faddaa5d TI |
55 | #define AUTO_MIC_PORTB (1 << 1) |
56 | #define AUTO_MIC_PORTC (1 << 2) | |
c9b443d4 TD |
57 | |
58 | struct conexant_spec { | |
23d30f28 | 59 | struct hda_gen_spec gen; |
c9b443d4 | 60 | |
bf92d1d5 TI |
61 | unsigned int beep_amp; |
62 | ||
63 | /* extra EAPD pins */ | |
64 | unsigned int num_eapds; | |
65 | hda_nid_t eapds[4]; | |
ff359b14 | 66 | bool dynamic_eapd; |
bf92d1d5 | 67 | |
e4c3bce2 DH |
68 | unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */ |
69 | ||
3a00c660 TI |
70 | /* OPLC XO specific */ |
71 | bool recording; | |
72 | bool dc_enable; | |
73 | unsigned int dc_input_bias; /* offset into olpc_xo_dc_bias */ | |
74 | struct nid_path *dc_mode_path; | |
75 | ||
bf92d1d5 | 76 | #ifdef ENABLE_CXT_STATIC_QUIRKS |
34cbe3a6 | 77 | const struct snd_kcontrol_new *mixers[5]; |
c9b443d4 | 78 | int num_mixers; |
dd5746a8 | 79 | hda_nid_t vmaster_nid; |
c9b443d4 TD |
80 | |
81 | const struct hda_verb *init_verbs[5]; /* initialization verbs | |
82 | * don't forget NULL | |
83 | * termination! | |
84 | */ | |
85 | unsigned int num_init_verbs; | |
86 | ||
87 | /* playback */ | |
88 | struct hda_multi_out multiout; /* playback set-up | |
89 | * max_channels, dacs must be set | |
90 | * dig_out_nid and hp_nid are optional | |
91 | */ | |
92 | unsigned int cur_eapd; | |
82f30040 | 93 | unsigned int hp_present; |
03697e2a | 94 | unsigned int line_present; |
faddaa5d | 95 | unsigned int auto_mic; |
c9b443d4 TD |
96 | |
97 | /* capture */ | |
98 | unsigned int num_adc_nids; | |
34cbe3a6 | 99 | const hda_nid_t *adc_nids; |
c9b443d4 TD |
100 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
101 | ||
461e2c78 TI |
102 | unsigned int cur_adc_idx; |
103 | hda_nid_t cur_adc; | |
104 | unsigned int cur_adc_stream_tag; | |
105 | unsigned int cur_adc_format; | |
106 | ||
6764bcef TI |
107 | const struct hda_pcm_stream *capture_stream; |
108 | ||
c9b443d4 TD |
109 | /* capture source */ |
110 | const struct hda_input_mux *input_mux; | |
34cbe3a6 | 111 | const hda_nid_t *capsrc_nids; |
c9b443d4 TD |
112 | unsigned int cur_mux[3]; |
113 | ||
114 | /* channel model */ | |
115 | const struct hda_channel_mode *channel_mode; | |
116 | int num_channel_mode; | |
117 | ||
118 | /* PCM information */ | |
119 | struct hda_pcm pcm_rec[2]; /* used in build_pcms() */ | |
120 | ||
c9b443d4 TD |
121 | unsigned int spdif_route; |
122 | ||
0fb67e98 | 123 | unsigned int port_d_mode; |
f2e5731d | 124 | unsigned int dell_automute:1; |
cfd3d8dc GA |
125 | unsigned int dell_vostro:1; |
126 | unsigned int ideapad:1; | |
7b2bfdbc | 127 | unsigned int thinkpad:1; |
048e78a5 | 128 | unsigned int hp_laptop:1; |
a1d6906e | 129 | unsigned int asus:1; |
6764bcef | 130 | |
c4cfe66c | 131 | unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */ |
bf92d1d5 TI |
132 | #endif /* ENABLE_CXT_STATIC_QUIRKS */ |
133 | }; | |
3507e2a8 | 134 | |
19110595 | 135 | |
bf92d1d5 | 136 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
7504b6cd TI |
137 | static inline void set_beep_amp(struct conexant_spec *spec, hda_nid_t nid, |
138 | int idx, int dir) | |
139 | { | |
140 | spec->gen.beep_nid = nid; | |
141 | spec->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir); | |
142 | } | |
bf92d1d5 TI |
143 | /* additional beep mixers; the actual parameters are overwritten at build */ |
144 | static const struct snd_kcontrol_new cxt_beep_mixer[] = { | |
145 | HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT), | |
146 | HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT), | |
147 | { } /* end */ | |
c9b443d4 TD |
148 | }; |
149 | ||
bf92d1d5 TI |
150 | /* create beep controls if needed */ |
151 | static int add_beep_ctls(struct hda_codec *codec) | |
152 | { | |
153 | struct conexant_spec *spec = codec->spec; | |
154 | int err; | |
155 | ||
156 | if (spec->beep_amp) { | |
157 | const struct snd_kcontrol_new *knew; | |
158 | for (knew = cxt_beep_mixer; knew->name; knew++) { | |
159 | struct snd_kcontrol *kctl; | |
160 | kctl = snd_ctl_new1(knew, codec); | |
161 | if (!kctl) | |
162 | return -ENOMEM; | |
163 | kctl->private_value = spec->beep_amp; | |
164 | err = snd_hda_ctl_add(codec, 0, kctl); | |
165 | if (err < 0) | |
166 | return err; | |
167 | } | |
168 | } | |
169 | return 0; | |
170 | } | |
171 | #else | |
172 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ | |
173 | #define add_beep_ctls(codec) 0 | |
174 | #endif | |
175 | ||
176 | ||
177 | #ifdef ENABLE_CXT_STATIC_QUIRKS | |
c9b443d4 TD |
178 | static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, |
179 | struct hda_codec *codec, | |
180 | struct snd_pcm_substream *substream) | |
181 | { | |
182 | struct conexant_spec *spec = codec->spec; | |
9a08160b TI |
183 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
184 | hinfo); | |
c9b443d4 TD |
185 | } |
186 | ||
187 | static int conexant_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_analog_prepare(codec, &spec->multiout, | |
195 | stream_tag, | |
196 | format, substream); | |
197 | } | |
198 | ||
199 | static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
200 | struct hda_codec *codec, | |
201 | struct snd_pcm_substream *substream) | |
202 | { | |
203 | struct conexant_spec *spec = codec->spec; | |
204 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | |
205 | } | |
206 | ||
207 | /* | |
208 | * Digital out | |
209 | */ | |
210 | static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
211 | struct hda_codec *codec, | |
212 | struct snd_pcm_substream *substream) | |
213 | { | |
214 | struct conexant_spec *spec = codec->spec; | |
215 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | |
216 | } | |
217 | ||
218 | static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, | |
219 | struct hda_codec *codec, | |
220 | struct snd_pcm_substream *substream) | |
221 | { | |
222 | struct conexant_spec *spec = codec->spec; | |
223 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | |
224 | } | |
225 | ||
6b97eb45 TI |
226 | static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
227 | struct hda_codec *codec, | |
228 | unsigned int stream_tag, | |
229 | unsigned int format, | |
230 | struct snd_pcm_substream *substream) | |
231 | { | |
232 | struct conexant_spec *spec = codec->spec; | |
233 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, | |
234 | stream_tag, | |
235 | format, substream); | |
236 | } | |
237 | ||
c9b443d4 TD |
238 | /* |
239 | * Analog capture | |
240 | */ | |
241 | static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo, | |
242 | struct hda_codec *codec, | |
243 | unsigned int stream_tag, | |
244 | unsigned int format, | |
245 | struct snd_pcm_substream *substream) | |
246 | { | |
247 | struct conexant_spec *spec = codec->spec; | |
248 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], | |
249 | stream_tag, 0, format); | |
250 | return 0; | |
251 | } | |
252 | ||
253 | static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
254 | struct hda_codec *codec, | |
255 | struct snd_pcm_substream *substream) | |
256 | { | |
257 | struct conexant_spec *spec = codec->spec; | |
888afa15 | 258 | snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]); |
c9b443d4 TD |
259 | return 0; |
260 | } | |
261 | ||
262 | ||
263 | ||
34cbe3a6 | 264 | static const struct hda_pcm_stream conexant_pcm_analog_playback = { |
c9b443d4 TD |
265 | .substreams = 1, |
266 | .channels_min = 2, | |
267 | .channels_max = 2, | |
268 | .nid = 0, /* fill later */ | |
269 | .ops = { | |
270 | .open = conexant_playback_pcm_open, | |
271 | .prepare = conexant_playback_pcm_prepare, | |
272 | .cleanup = conexant_playback_pcm_cleanup | |
273 | }, | |
274 | }; | |
275 | ||
34cbe3a6 | 276 | static const struct hda_pcm_stream conexant_pcm_analog_capture = { |
c9b443d4 TD |
277 | .substreams = 1, |
278 | .channels_min = 2, | |
279 | .channels_max = 2, | |
280 | .nid = 0, /* fill later */ | |
281 | .ops = { | |
282 | .prepare = conexant_capture_pcm_prepare, | |
283 | .cleanup = conexant_capture_pcm_cleanup | |
284 | }, | |
285 | }; | |
286 | ||
287 | ||
34cbe3a6 | 288 | static const struct hda_pcm_stream conexant_pcm_digital_playback = { |
c9b443d4 TD |
289 | .substreams = 1, |
290 | .channels_min = 2, | |
291 | .channels_max = 2, | |
292 | .nid = 0, /* fill later */ | |
293 | .ops = { | |
294 | .open = conexant_dig_playback_pcm_open, | |
6b97eb45 TI |
295 | .close = conexant_dig_playback_pcm_close, |
296 | .prepare = conexant_dig_playback_pcm_prepare | |
c9b443d4 TD |
297 | }, |
298 | }; | |
299 | ||
34cbe3a6 | 300 | static const struct hda_pcm_stream conexant_pcm_digital_capture = { |
c9b443d4 TD |
301 | .substreams = 1, |
302 | .channels_min = 2, | |
303 | .channels_max = 2, | |
304 | /* NID is set in alc_build_pcms */ | |
305 | }; | |
306 | ||
461e2c78 TI |
307 | static int cx5051_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
308 | struct hda_codec *codec, | |
309 | unsigned int stream_tag, | |
310 | unsigned int format, | |
311 | struct snd_pcm_substream *substream) | |
312 | { | |
313 | struct conexant_spec *spec = codec->spec; | |
314 | spec->cur_adc = spec->adc_nids[spec->cur_adc_idx]; | |
315 | spec->cur_adc_stream_tag = stream_tag; | |
316 | spec->cur_adc_format = format; | |
317 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); | |
318 | return 0; | |
319 | } | |
320 | ||
321 | static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
322 | struct hda_codec *codec, | |
323 | struct snd_pcm_substream *substream) | |
324 | { | |
325 | struct conexant_spec *spec = codec->spec; | |
888afa15 | 326 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
461e2c78 TI |
327 | spec->cur_adc = 0; |
328 | return 0; | |
329 | } | |
330 | ||
34cbe3a6 | 331 | static const struct hda_pcm_stream cx5051_pcm_analog_capture = { |
461e2c78 TI |
332 | .substreams = 1, |
333 | .channels_min = 2, | |
334 | .channels_max = 2, | |
335 | .nid = 0, /* fill later */ | |
336 | .ops = { | |
337 | .prepare = cx5051_capture_pcm_prepare, | |
338 | .cleanup = cx5051_capture_pcm_cleanup | |
339 | }, | |
340 | }; | |
341 | ||
c9b443d4 TD |
342 | static int conexant_build_pcms(struct hda_codec *codec) |
343 | { | |
344 | struct conexant_spec *spec = codec->spec; | |
345 | struct hda_pcm *info = spec->pcm_rec; | |
346 | ||
347 | codec->num_pcms = 1; | |
348 | codec->pcm_info = info; | |
349 | ||
350 | info->name = "CONEXANT Analog"; | |
351 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback; | |
352 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = | |
353 | spec->multiout.max_channels; | |
354 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = | |
355 | spec->multiout.dac_nids[0]; | |
6764bcef TI |
356 | if (spec->capture_stream) |
357 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *spec->capture_stream; | |
358 | else { | |
359 | if (codec->vendor_id == 0x14f15051) | |
360 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
361 | cx5051_pcm_analog_capture; | |
362 | else { | |
363 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
364 | conexant_pcm_analog_capture; | |
365 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = | |
366 | spec->num_adc_nids; | |
367 | } | |
368 | } | |
c9b443d4 TD |
369 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
370 | ||
371 | if (spec->multiout.dig_out_nid) { | |
372 | info++; | |
373 | codec->num_pcms++; | |
374 | info->name = "Conexant Digital"; | |
7ba72ba1 | 375 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
c9b443d4 TD |
376 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
377 | conexant_pcm_digital_playback; | |
378 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = | |
379 | spec->multiout.dig_out_nid; | |
380 | if (spec->dig_in_nid) { | |
381 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
382 | conexant_pcm_digital_capture; | |
383 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = | |
384 | spec->dig_in_nid; | |
385 | } | |
386 | } | |
387 | ||
388 | return 0; | |
389 | } | |
390 | ||
391 | static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol, | |
392 | struct snd_ctl_elem_info *uinfo) | |
393 | { | |
394 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
395 | struct conexant_spec *spec = codec->spec; | |
396 | ||
397 | return snd_hda_input_mux_info(spec->input_mux, uinfo); | |
398 | } | |
399 | ||
400 | static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol, | |
401 | struct snd_ctl_elem_value *ucontrol) | |
402 | { | |
403 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
404 | struct conexant_spec *spec = codec->spec; | |
405 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
406 | ||
407 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; | |
408 | return 0; | |
409 | } | |
410 | ||
411 | static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol, | |
412 | struct snd_ctl_elem_value *ucontrol) | |
413 | { | |
414 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
415 | struct conexant_spec *spec = codec->spec; | |
416 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
417 | ||
418 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, | |
419 | spec->capsrc_nids[adc_idx], | |
420 | &spec->cur_mux[adc_idx]); | |
421 | } | |
422 | ||
4d7fbdbc TI |
423 | static void conexant_set_power(struct hda_codec *codec, hda_nid_t fg, |
424 | unsigned int power_state) | |
425 | { | |
426 | if (power_state == AC_PWRST_D3) | |
427 | msleep(100); | |
428 | snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, | |
429 | power_state); | |
430 | /* partial workaround for "azx_get_response timeout" */ | |
431 | if (power_state == AC_PWRST_D0) | |
432 | msleep(10); | |
9419ab6b | 433 | snd_hda_codec_set_power_to_all(codec, fg, power_state); |
4d7fbdbc TI |
434 | } |
435 | ||
c9b443d4 TD |
436 | static int conexant_init(struct hda_codec *codec) |
437 | { | |
438 | struct conexant_spec *spec = codec->spec; | |
439 | int i; | |
440 | ||
441 | for (i = 0; i < spec->num_init_verbs; i++) | |
442 | snd_hda_sequence_write(codec, spec->init_verbs[i]); | |
443 | return 0; | |
444 | } | |
445 | ||
446 | static void conexant_free(struct hda_codec *codec) | |
447 | { | |
d604b399 | 448 | kfree(codec->spec); |
c9b443d4 TD |
449 | } |
450 | ||
34cbe3a6 | 451 | static const struct snd_kcontrol_new cxt_capture_mixers[] = { |
b880c74a TI |
452 | { |
453 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
454 | .name = "Capture Source", | |
455 | .info = conexant_mux_enum_info, | |
456 | .get = conexant_mux_enum_get, | |
457 | .put = conexant_mux_enum_put | |
458 | }, | |
459 | {} | |
460 | }; | |
461 | ||
9322ca54 | 462 | static const char * const slave_pfxs[] = { |
f37bc7a8 | 463 | "Headphone", "Speaker", "Bass Speaker", "Front", "Surround", "CLFE", |
dd5746a8 TI |
464 | NULL |
465 | }; | |
466 | ||
c9b443d4 TD |
467 | static int conexant_build_controls(struct hda_codec *codec) |
468 | { | |
469 | struct conexant_spec *spec = codec->spec; | |
470 | unsigned int i; | |
471 | int err; | |
472 | ||
473 | for (i = 0; i < spec->num_mixers; i++) { | |
474 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | |
475 | if (err < 0) | |
476 | return err; | |
477 | } | |
478 | if (spec->multiout.dig_out_nid) { | |
479 | err = snd_hda_create_spdif_out_ctls(codec, | |
74b654c9 | 480 | spec->multiout.dig_out_nid, |
c9b443d4 TD |
481 | spec->multiout.dig_out_nid); |
482 | if (err < 0) | |
483 | return err; | |
9a08160b TI |
484 | err = snd_hda_create_spdif_share_sw(codec, |
485 | &spec->multiout); | |
486 | if (err < 0) | |
487 | return err; | |
488 | spec->multiout.share_spdif = 1; | |
c9b443d4 TD |
489 | } |
490 | if (spec->dig_in_nid) { | |
491 | err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid); | |
492 | if (err < 0) | |
493 | return err; | |
494 | } | |
dd5746a8 TI |
495 | |
496 | /* if we have no master control, let's create it */ | |
497 | if (spec->vmaster_nid && | |
498 | !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { | |
499 | unsigned int vmaster_tlv[4]; | |
500 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, | |
501 | HDA_OUTPUT, vmaster_tlv); | |
502 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", | |
9322ca54 TI |
503 | vmaster_tlv, slave_pfxs, |
504 | "Playback Volume"); | |
dd5746a8 TI |
505 | if (err < 0) |
506 | return err; | |
507 | } | |
508 | if (spec->vmaster_nid && | |
509 | !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { | |
aed523f1 TI |
510 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", |
511 | NULL, slave_pfxs, | |
512 | "Playback Switch"); | |
dd5746a8 TI |
513 | if (err < 0) |
514 | return err; | |
515 | } | |
516 | ||
b880c74a TI |
517 | if (spec->input_mux) { |
518 | err = snd_hda_add_new_ctls(codec, cxt_capture_mixers); | |
519 | if (err < 0) | |
520 | return err; | |
521 | } | |
522 | ||
aed523f1 TI |
523 | err = add_beep_ctls(codec); |
524 | if (err < 0) | |
525 | return err; | |
3507e2a8 | 526 | |
c9b443d4 TD |
527 | return 0; |
528 | } | |
529 | ||
34cbe3a6 | 530 | static const struct hda_codec_ops conexant_patch_ops = { |
c9b443d4 TD |
531 | .build_controls = conexant_build_controls, |
532 | .build_pcms = conexant_build_pcms, | |
533 | .init = conexant_init, | |
534 | .free = conexant_free, | |
4d7fbdbc | 535 | .set_power_state = conexant_set_power, |
c9b443d4 TD |
536 | }; |
537 | ||
6764bcef | 538 | static int patch_conexant_auto(struct hda_codec *codec); |
c9b443d4 TD |
539 | /* |
540 | * EAPD control | |
541 | * the private value = nid | (invert << 8) | |
542 | */ | |
543 | ||
a5ce8890 | 544 | #define cxt_eapd_info snd_ctl_boolean_mono_info |
c9b443d4 | 545 | |
82f30040 | 546 | static int cxt_eapd_get(struct snd_kcontrol *kcontrol, |
c9b443d4 TD |
547 | struct snd_ctl_elem_value *ucontrol) |
548 | { | |
549 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
550 | struct conexant_spec *spec = codec->spec; | |
551 | int invert = (kcontrol->private_value >> 8) & 1; | |
552 | if (invert) | |
553 | ucontrol->value.integer.value[0] = !spec->cur_eapd; | |
554 | else | |
555 | ucontrol->value.integer.value[0] = spec->cur_eapd; | |
556 | return 0; | |
82f30040 | 557 | |
c9b443d4 TD |
558 | } |
559 | ||
82f30040 | 560 | static int cxt_eapd_put(struct snd_kcontrol *kcontrol, |
c9b443d4 TD |
561 | struct snd_ctl_elem_value *ucontrol) |
562 | { | |
563 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
564 | struct conexant_spec *spec = codec->spec; | |
565 | int invert = (kcontrol->private_value >> 8) & 1; | |
566 | hda_nid_t nid = kcontrol->private_value & 0xff; | |
567 | unsigned int eapd; | |
82f30040 | 568 | |
68ea7b2f | 569 | eapd = !!ucontrol->value.integer.value[0]; |
c9b443d4 TD |
570 | if (invert) |
571 | eapd = !eapd; | |
82beb8fd | 572 | if (eapd == spec->cur_eapd) |
c9b443d4 | 573 | return 0; |
82f30040 | 574 | |
c9b443d4 | 575 | spec->cur_eapd = eapd; |
82beb8fd TI |
576 | snd_hda_codec_write_cache(codec, nid, |
577 | 0, AC_VERB_SET_EAPD_BTLENABLE, | |
578 | eapd ? 0x02 : 0x00); | |
c9b443d4 TD |
579 | return 1; |
580 | } | |
581 | ||
86d72bdf TI |
582 | /* controls for test mode */ |
583 | #ifdef CONFIG_SND_DEBUG | |
584 | ||
82f30040 TD |
585 | #define CXT_EAPD_SWITCH(xname, nid, mask) \ |
586 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
587 | .info = cxt_eapd_info, \ | |
588 | .get = cxt_eapd_get, \ | |
589 | .put = cxt_eapd_put, \ | |
590 | .private_value = nid | (mask<<16) } | |
591 | ||
592 | ||
593 | ||
c9b443d4 TD |
594 | static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol, |
595 | struct snd_ctl_elem_info *uinfo) | |
596 | { | |
597 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
598 | struct conexant_spec *spec = codec->spec; | |
599 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, | |
600 | spec->num_channel_mode); | |
601 | } | |
602 | ||
603 | static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol, | |
604 | struct snd_ctl_elem_value *ucontrol) | |
605 | { | |
606 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
607 | struct conexant_spec *spec = codec->spec; | |
608 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, | |
609 | spec->num_channel_mode, | |
610 | spec->multiout.max_channels); | |
611 | } | |
612 | ||
613 | static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol, | |
614 | struct snd_ctl_elem_value *ucontrol) | |
615 | { | |
616 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
617 | struct conexant_spec *spec = codec->spec; | |
618 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, | |
619 | spec->num_channel_mode, | |
620 | &spec->multiout.max_channels); | |
c9b443d4 TD |
621 | return err; |
622 | } | |
623 | ||
624 | #define CXT_PIN_MODE(xname, nid, dir) \ | |
625 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
626 | .info = conexant_ch_mode_info, \ | |
627 | .get = conexant_ch_mode_get, \ | |
628 | .put = conexant_ch_mode_put, \ | |
629 | .private_value = nid | (dir<<16) } | |
630 | ||
86d72bdf TI |
631 | #endif /* CONFIG_SND_DEBUG */ |
632 | ||
c9b443d4 TD |
633 | /* Conexant 5045 specific */ |
634 | ||
34cbe3a6 TI |
635 | static const hda_nid_t cxt5045_dac_nids[1] = { 0x19 }; |
636 | static const hda_nid_t cxt5045_adc_nids[1] = { 0x1a }; | |
637 | static const hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a }; | |
cbef9789 | 638 | #define CXT5045_SPDIF_OUT 0x18 |
c9b443d4 | 639 | |
34cbe3a6 | 640 | static const struct hda_channel_mode cxt5045_modes[1] = { |
5cd57529 TD |
641 | { 2, NULL }, |
642 | }; | |
c9b443d4 | 643 | |
34cbe3a6 | 644 | static const struct hda_input_mux cxt5045_capture_source = { |
c9b443d4 TD |
645 | .num_items = 2, |
646 | .items = { | |
3edbbb9e MK |
647 | { "Internal Mic", 0x1 }, |
648 | { "Mic", 0x2 }, | |
c9b443d4 TD |
649 | } |
650 | }; | |
651 | ||
34cbe3a6 | 652 | static const struct hda_input_mux cxt5045_capture_source_benq = { |
e6e03dae | 653 | .num_items = 4, |
5218c892 | 654 | .items = { |
3edbbb9e MK |
655 | { "Internal Mic", 0x1 }, |
656 | { "Mic", 0x2 }, | |
657 | { "Line", 0x3 }, | |
658 | { "Mixer", 0x0 }, | |
5218c892 JZ |
659 | } |
660 | }; | |
661 | ||
c9b443d4 TD |
662 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
663 | static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
664 | struct snd_ctl_elem_value *ucontrol) | |
665 | { | |
666 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
667 | struct conexant_spec *spec = codec->spec; | |
82f30040 | 668 | unsigned int bits; |
c9b443d4 | 669 | |
82f30040 | 670 | if (!cxt_eapd_put(kcontrol, ucontrol)) |
c9b443d4 TD |
671 | return 0; |
672 | ||
82f30040 TD |
673 | /* toggle internal speakers mute depending of presence of |
674 | * the headphone jack | |
675 | */ | |
47fd830a TI |
676 | bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; |
677 | snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, | |
678 | HDA_AMP_MUTE, bits); | |
7f29673b | 679 | |
47fd830a TI |
680 | bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; |
681 | snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0, | |
682 | HDA_AMP_MUTE, bits); | |
c9b443d4 TD |
683 | return 1; |
684 | } | |
685 | ||
686 | /* bind volumes of both NID 0x10 and 0x11 */ | |
34cbe3a6 | 687 | static const struct hda_bind_ctls cxt5045_hp_bind_master_vol = { |
cca3b371 TI |
688 | .ops = &snd_hda_bind_vol, |
689 | .values = { | |
690 | HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT), | |
691 | HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT), | |
692 | 0 | |
693 | }, | |
694 | }; | |
c9b443d4 | 695 | |
7f29673b TD |
696 | /* toggle input of built-in and mic jack appropriately */ |
697 | static void cxt5045_hp_automic(struct hda_codec *codec) | |
698 | { | |
34cbe3a6 | 699 | static const struct hda_verb mic_jack_on[] = { |
7f29673b TD |
700 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
701 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
702 | {} | |
703 | }; | |
34cbe3a6 | 704 | static const struct hda_verb mic_jack_off[] = { |
7f29673b TD |
705 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
706 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
707 | {} | |
708 | }; | |
709 | unsigned int present; | |
710 | ||
d56757ab | 711 | present = snd_hda_jack_detect(codec, 0x12); |
7f29673b TD |
712 | if (present) |
713 | snd_hda_sequence_write(codec, mic_jack_on); | |
714 | else | |
715 | snd_hda_sequence_write(codec, mic_jack_off); | |
716 | } | |
717 | ||
c9b443d4 TD |
718 | |
719 | /* mute internal speaker if HP is plugged */ | |
720 | static void cxt5045_hp_automute(struct hda_codec *codec) | |
721 | { | |
82f30040 | 722 | struct conexant_spec *spec = codec->spec; |
dd87da1c | 723 | unsigned int bits; |
c9b443d4 | 724 | |
d56757ab | 725 | spec->hp_present = snd_hda_jack_detect(codec, 0x11); |
dd87da1c | 726 | |
47fd830a TI |
727 | bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; |
728 | snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, | |
729 | HDA_AMP_MUTE, bits); | |
c9b443d4 TD |
730 | } |
731 | ||
732 | /* unsolicited event for HP jack sensing */ | |
733 | static void cxt5045_hp_unsol_event(struct hda_codec *codec, | |
734 | unsigned int res) | |
735 | { | |
736 | res >>= 26; | |
737 | switch (res) { | |
738 | case CONEXANT_HP_EVENT: | |
739 | cxt5045_hp_automute(codec); | |
740 | break; | |
7f29673b TD |
741 | case CONEXANT_MIC_EVENT: |
742 | cxt5045_hp_automic(codec); | |
743 | break; | |
744 | ||
c9b443d4 TD |
745 | } |
746 | } | |
747 | ||
34cbe3a6 | 748 | static const struct snd_kcontrol_new cxt5045_mixers[] = { |
cbf2d28e MK |
749 | HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT), |
750 | HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), | |
c8229c38 TI |
751 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), |
752 | HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), | |
28c4edb7 DH |
753 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT), |
754 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT), | |
8607f7c4 DH |
755 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT), |
756 | HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT), | |
cca3b371 | 757 | HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol), |
c9b443d4 TD |
758 | { |
759 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
760 | .name = "Master Playback Switch", | |
82f30040 TD |
761 | .info = cxt_eapd_info, |
762 | .get = cxt_eapd_get, | |
c9b443d4 | 763 | .put = cxt5045_hp_master_sw_put, |
82f30040 | 764 | .private_value = 0x10, |
c9b443d4 TD |
765 | }, |
766 | ||
767 | {} | |
768 | }; | |
769 | ||
34cbe3a6 | 770 | static const struct snd_kcontrol_new cxt5045_benq_mixers[] = { |
3edbbb9e MK |
771 | HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x3, HDA_INPUT), |
772 | HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x3, HDA_INPUT), | |
22e14130 | 773 | |
5218c892 JZ |
774 | {} |
775 | }; | |
776 | ||
34cbe3a6 | 777 | static const struct hda_verb cxt5045_init_verbs[] = { |
c9b443d4 | 778 | /* Line in, Mic */ |
4090dffb | 779 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, |
7f29673b | 780 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, |
c9b443d4 | 781 | /* HP, Amp */ |
c8229c38 TI |
782 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
783 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, | |
784 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
785 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, | |
786 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
787 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
788 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
789 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
790 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
28c4edb7 | 791 | /* Record selector: Internal mic */ |
7f29673b | 792 | {0x1a, AC_VERB_SET_CONNECT_SEL,0x1}, |
82f30040 | 793 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, |
c9b443d4 TD |
794 | AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, |
795 | /* SPDIF route: PCM */ | |
cbef9789 | 796 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
c9b443d4 | 797 | { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
c9b443d4 | 798 | /* EAPD */ |
82f30040 | 799 | {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */ |
c9b443d4 TD |
800 | { } /* end */ |
801 | }; | |
802 | ||
34cbe3a6 | 803 | static const struct hda_verb cxt5045_benq_init_verbs[] = { |
28c4edb7 | 804 | /* Internal Mic, Mic */ |
5218c892 JZ |
805 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, |
806 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, | |
807 | /* Line In,HP, Amp */ | |
808 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
809 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, | |
810 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
811 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, | |
812 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
813 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
814 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
815 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
816 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
28c4edb7 | 817 | /* Record selector: Internal mic */ |
5218c892 JZ |
818 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x1}, |
819 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, | |
820 | AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, | |
821 | /* SPDIF route: PCM */ | |
cbef9789 | 822 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
5218c892 JZ |
823 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, |
824 | /* EAPD */ | |
825 | {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
826 | { } /* end */ | |
827 | }; | |
7f29673b | 828 | |
34cbe3a6 | 829 | static const struct hda_verb cxt5045_hp_sense_init_verbs[] = { |
7f29673b TD |
830 | /* pin sensing on HP jack */ |
831 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | |
d3091fad | 832 | { } /* end */ |
7f29673b TD |
833 | }; |
834 | ||
34cbe3a6 | 835 | static const struct hda_verb cxt5045_mic_sense_init_verbs[] = { |
7f29673b TD |
836 | /* pin sensing on HP jack */ |
837 | {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | |
d3091fad | 838 | { } /* end */ |
7f29673b TD |
839 | }; |
840 | ||
c9b443d4 TD |
841 | #ifdef CONFIG_SND_DEBUG |
842 | /* Test configuration for debugging, modelled after the ALC260 test | |
843 | * configuration. | |
844 | */ | |
34cbe3a6 | 845 | static const struct hda_input_mux cxt5045_test_capture_source = { |
c9b443d4 TD |
846 | .num_items = 5, |
847 | .items = { | |
848 | { "MIXER", 0x0 }, | |
849 | { "MIC1 pin", 0x1 }, | |
850 | { "LINE1 pin", 0x2 }, | |
851 | { "HP-OUT pin", 0x3 }, | |
852 | { "CD pin", 0x4 }, | |
853 | }, | |
854 | }; | |
855 | ||
34cbe3a6 | 856 | static const struct snd_kcontrol_new cxt5045_test_mixer[] = { |
c9b443d4 TD |
857 | |
858 | /* Output controls */ | |
c9b443d4 TD |
859 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT), |
860 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT), | |
250f3274 MK |
861 | HDA_CODEC_VOLUME("HP-OUT Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
862 | HDA_CODEC_MUTE("HP-OUT Playback Switch", 0x11, 0x0, HDA_OUTPUT), | |
863 | HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x12, 0x0, HDA_OUTPUT), | |
864 | HDA_CODEC_MUTE("LINE1 Playback Switch", 0x12, 0x0, HDA_OUTPUT), | |
c9b443d4 TD |
865 | |
866 | /* Modes for retasking pin widgets */ | |
867 | CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT), | |
868 | CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT), | |
869 | ||
82f30040 TD |
870 | /* EAPD Switch Control */ |
871 | CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0), | |
872 | ||
c9b443d4 | 873 | /* Loopback mixer controls */ |
7f29673b | 874 | |
250f3274 MK |
875 | HDA_CODEC_VOLUME("PCM Volume", 0x17, 0x0, HDA_INPUT), |
876 | HDA_CODEC_MUTE("PCM Switch", 0x17, 0x0, HDA_INPUT), | |
877 | HDA_CODEC_VOLUME("MIC1 pin Volume", 0x17, 0x1, HDA_INPUT), | |
878 | HDA_CODEC_MUTE("MIC1 pin Switch", 0x17, 0x1, HDA_INPUT), | |
879 | HDA_CODEC_VOLUME("LINE1 pin Volume", 0x17, 0x2, HDA_INPUT), | |
880 | HDA_CODEC_MUTE("LINE1 pin Switch", 0x17, 0x2, HDA_INPUT), | |
881 | HDA_CODEC_VOLUME("HP-OUT pin Volume", 0x17, 0x3, HDA_INPUT), | |
882 | HDA_CODEC_MUTE("HP-OUT pin Switch", 0x17, 0x3, HDA_INPUT), | |
883 | HDA_CODEC_VOLUME("CD pin Volume", 0x17, 0x4, HDA_INPUT), | |
884 | HDA_CODEC_MUTE("CD pin Switch", 0x17, 0x4, HDA_INPUT), | |
c9b443d4 TD |
885 | { |
886 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
887 | .name = "Input Source", | |
888 | .info = conexant_mux_enum_info, | |
889 | .get = conexant_mux_enum_get, | |
890 | .put = conexant_mux_enum_put, | |
891 | }, | |
fb3409e7 | 892 | /* Audio input controls */ |
cbf2d28e MK |
893 | HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x0, HDA_INPUT), |
894 | HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), | |
c9b443d4 TD |
895 | { } /* end */ |
896 | }; | |
897 | ||
34cbe3a6 | 898 | static const struct hda_verb cxt5045_test_init_verbs[] = { |
7f29673b TD |
899 | /* Set connections */ |
900 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 }, | |
901 | { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 }, | |
902 | { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 }, | |
c9b443d4 TD |
903 | /* Enable retasking pins as output, initially without power amp */ |
904 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7f29673b | 905 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
c9b443d4 TD |
906 | |
907 | /* Disable digital (SPDIF) pins initially, but users can enable | |
908 | * them via a mixer switch. In the case of SPDIF-out, this initverb | |
909 | * payload also sets the generation to 0, output to be in "consumer" | |
910 | * PCM format, copyright asserted, no pre-emphasis and no validity | |
911 | * control. | |
912 | */ | |
cbef9789 TI |
913 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
914 | {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
c9b443d4 | 915 | |
c9b443d4 TD |
916 | /* Unmute retasking pin widget output buffers since the default |
917 | * state appears to be output. As the pin mode is changed by the | |
918 | * user the pin mode control will take care of enabling the pin's | |
919 | * input/output buffers as needed. | |
920 | */ | |
921 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
922 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
923 | ||
924 | /* Mute capture amp left and right */ | |
925 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
926 | ||
927 | /* Set ADC connection select to match default mixer setting (mic1 | |
928 | * pin) | |
929 | */ | |
250f3274 MK |
930 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
931 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
c9b443d4 TD |
932 | |
933 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
250f3274 | 934 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer */ |
c9b443d4 TD |
935 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */ |
936 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */ | |
937 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */ | |
938 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
939 | ||
940 | { } | |
941 | }; | |
942 | #endif | |
943 | ||
944 | ||
945 | /* initialize jack-sensing, too */ | |
946 | static int cxt5045_init(struct hda_codec *codec) | |
947 | { | |
948 | conexant_init(codec); | |
949 | cxt5045_hp_automute(codec); | |
950 | return 0; | |
951 | } | |
952 | ||
953 | ||
954 | enum { | |
15908c36 MB |
955 | CXT5045_LAPTOP_HPSENSE, |
956 | CXT5045_LAPTOP_MICSENSE, | |
957 | CXT5045_LAPTOP_HPMICSENSE, | |
5218c892 | 958 | CXT5045_BENQ, |
c9b443d4 TD |
959 | #ifdef CONFIG_SND_DEBUG |
960 | CXT5045_TEST, | |
961 | #endif | |
1f8458a2 | 962 | CXT5045_AUTO, |
f5fcc13c | 963 | CXT5045_MODELS |
c9b443d4 TD |
964 | }; |
965 | ||
ea734963 | 966 | static const char * const cxt5045_models[CXT5045_MODELS] = { |
15908c36 MB |
967 | [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense", |
968 | [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense", | |
969 | [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense", | |
970 | [CXT5045_BENQ] = "benq", | |
c9b443d4 | 971 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 972 | [CXT5045_TEST] = "test", |
c9b443d4 | 973 | #endif |
1f8458a2 | 974 | [CXT5045_AUTO] = "auto", |
f5fcc13c TI |
975 | }; |
976 | ||
34cbe3a6 | 977 | static const struct snd_pci_quirk cxt5045_cfg_tbl[] = { |
5218c892 | 978 | SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ), |
15908c36 MB |
979 | SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE), |
980 | SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE), | |
9e464154 TI |
981 | SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505", |
982 | CXT5045_LAPTOP_HPMICSENSE), | |
15908c36 MB |
983 | SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE), |
984 | SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE), | |
985 | SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE), | |
dea0a509 TI |
986 | SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell", |
987 | CXT5045_LAPTOP_HPMICSENSE), | |
15908c36 | 988 | SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE), |
c9b443d4 TD |
989 | {} |
990 | }; | |
991 | ||
992 | static int patch_cxt5045(struct hda_codec *codec) | |
993 | { | |
994 | struct conexant_spec *spec; | |
995 | int board_config; | |
996 | ||
1f8458a2 TI |
997 | board_config = snd_hda_check_board_config(codec, CXT5045_MODELS, |
998 | cxt5045_models, | |
999 | cxt5045_cfg_tbl); | |
1000 | if (board_config < 0) | |
c82693db | 1001 | board_config = CXT5045_AUTO; /* model=auto as default */ |
1f8458a2 TI |
1002 | if (board_config == CXT5045_AUTO) |
1003 | return patch_conexant_auto(codec); | |
1004 | ||
c9b443d4 TD |
1005 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1006 | if (!spec) | |
1007 | return -ENOMEM; | |
c9b443d4 | 1008 | codec->spec = spec; |
4f32456e | 1009 | codec->single_adc_amp = 1; |
c9b443d4 TD |
1010 | |
1011 | spec->multiout.max_channels = 2; | |
1012 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids); | |
1013 | spec->multiout.dac_nids = cxt5045_dac_nids; | |
1014 | spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT; | |
1015 | spec->num_adc_nids = 1; | |
1016 | spec->adc_nids = cxt5045_adc_nids; | |
1017 | spec->capsrc_nids = cxt5045_capsrc_nids; | |
1018 | spec->input_mux = &cxt5045_capture_source; | |
1019 | spec->num_mixers = 1; | |
1020 | spec->mixers[0] = cxt5045_mixers; | |
1021 | spec->num_init_verbs = 1; | |
1022 | spec->init_verbs[0] = cxt5045_init_verbs; | |
1023 | spec->spdif_route = 0; | |
3507e2a8 TI |
1024 | spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes); |
1025 | spec->channel_mode = cxt5045_modes; | |
5cd57529 | 1026 | |
3507e2a8 | 1027 | set_beep_amp(spec, 0x16, 0, 1); |
c9b443d4 TD |
1028 | |
1029 | codec->patch_ops = conexant_patch_ops; | |
c9b443d4 | 1030 | |
c9b443d4 | 1031 | switch (board_config) { |
15908c36 | 1032 | case CXT5045_LAPTOP_HPSENSE: |
7f29673b TD |
1033 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; |
1034 | spec->input_mux = &cxt5045_capture_source; | |
1035 | spec->num_init_verbs = 2; | |
1036 | spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; | |
1037 | spec->mixers[0] = cxt5045_mixers; | |
1038 | codec->patch_ops.init = cxt5045_init; | |
1039 | break; | |
15908c36 | 1040 | case CXT5045_LAPTOP_MICSENSE: |
86376df6 | 1041 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; |
c9b443d4 TD |
1042 | spec->input_mux = &cxt5045_capture_source; |
1043 | spec->num_init_verbs = 2; | |
7f29673b | 1044 | spec->init_verbs[1] = cxt5045_mic_sense_init_verbs; |
c9b443d4 TD |
1045 | spec->mixers[0] = cxt5045_mixers; |
1046 | codec->patch_ops.init = cxt5045_init; | |
1047 | break; | |
15908c36 MB |
1048 | default: |
1049 | case CXT5045_LAPTOP_HPMICSENSE: | |
1050 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; | |
1051 | spec->input_mux = &cxt5045_capture_source; | |
1052 | spec->num_init_verbs = 3; | |
1053 | spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; | |
1054 | spec->init_verbs[2] = cxt5045_mic_sense_init_verbs; | |
1055 | spec->mixers[0] = cxt5045_mixers; | |
1056 | codec->patch_ops.init = cxt5045_init; | |
1057 | break; | |
5218c892 JZ |
1058 | case CXT5045_BENQ: |
1059 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; | |
1060 | spec->input_mux = &cxt5045_capture_source_benq; | |
1061 | spec->num_init_verbs = 1; | |
1062 | spec->init_verbs[0] = cxt5045_benq_init_verbs; | |
1063 | spec->mixers[0] = cxt5045_mixers; | |
1064 | spec->mixers[1] = cxt5045_benq_mixers; | |
1065 | spec->num_mixers = 2; | |
1066 | codec->patch_ops.init = cxt5045_init; | |
1067 | break; | |
c9b443d4 TD |
1068 | #ifdef CONFIG_SND_DEBUG |
1069 | case CXT5045_TEST: | |
1070 | spec->input_mux = &cxt5045_test_capture_source; | |
1071 | spec->mixers[0] = cxt5045_test_mixer; | |
1072 | spec->init_verbs[0] = cxt5045_test_init_verbs; | |
15908c36 MB |
1073 | break; |
1074 | ||
c9b443d4 TD |
1075 | #endif |
1076 | } | |
48ecb7e8 | 1077 | |
031005f7 TI |
1078 | switch (codec->subsystem_id >> 16) { |
1079 | case 0x103c: | |
8f0f5ff6 | 1080 | case 0x1631: |
0b587fc4 | 1081 | case 0x1734: |
0ebf9e36 DC |
1082 | case 0x17aa: |
1083 | /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have | |
1084 | * really bad sound over 0dB on NID 0x17. Fix max PCM level to | |
1085 | * 0 dB (originally it has 0x2b steps with 0dB offset 0x14) | |
031005f7 TI |
1086 | */ |
1087 | snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT, | |
1088 | (0x14 << AC_AMPCAP_OFFSET_SHIFT) | | |
1089 | (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) | | |
1090 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | | |
1091 | (1 << AC_AMPCAP_MUTE_SHIFT)); | |
1092 | break; | |
1093 | } | |
48ecb7e8 | 1094 | |
3507e2a8 | 1095 | if (spec->beep_amp) |
a86b1a2c | 1096 | snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); |
3507e2a8 | 1097 | |
c9b443d4 TD |
1098 | return 0; |
1099 | } | |
1100 | ||
1101 | ||
1102 | /* Conexant 5047 specific */ | |
82f30040 | 1103 | #define CXT5047_SPDIF_OUT 0x11 |
c9b443d4 | 1104 | |
34cbe3a6 TI |
1105 | static const hda_nid_t cxt5047_dac_nids[1] = { 0x10 }; /* 0x1c */ |
1106 | static const hda_nid_t cxt5047_adc_nids[1] = { 0x12 }; | |
1107 | static const hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a }; | |
c9b443d4 | 1108 | |
34cbe3a6 | 1109 | static const struct hda_channel_mode cxt5047_modes[1] = { |
5cd57529 TD |
1110 | { 2, NULL }, |
1111 | }; | |
c9b443d4 | 1112 | |
34cbe3a6 | 1113 | static const struct hda_input_mux cxt5047_toshiba_capture_source = { |
82f30040 TD |
1114 | .num_items = 2, |
1115 | .items = { | |
1116 | { "ExtMic", 0x2 }, | |
1117 | { "Line-In", 0x1 }, | |
c9b443d4 TD |
1118 | } |
1119 | }; | |
1120 | ||
1121 | /* turn on/off EAPD (+ mute HP) as a master switch */ | |
1122 | static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
1123 | struct snd_ctl_elem_value *ucontrol) | |
1124 | { | |
1125 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1126 | struct conexant_spec *spec = codec->spec; | |
82f30040 | 1127 | unsigned int bits; |
c9b443d4 | 1128 | |
82f30040 | 1129 | if (!cxt_eapd_put(kcontrol, ucontrol)) |
c9b443d4 TD |
1130 | return 0; |
1131 | ||
82f30040 TD |
1132 | /* toggle internal speakers mute depending of presence of |
1133 | * the headphone jack | |
1134 | */ | |
47fd830a | 1135 | bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; |
3b7523fc TI |
1136 | /* NOTE: Conexat codec needs the index for *OUTPUT* amp of |
1137 | * pin widgets unlike other codecs. In this case, we need to | |
1138 | * set index 0x01 for the volume from the mixer amp 0x19. | |
1139 | */ | |
5d75bc55 | 1140 | snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, |
47fd830a TI |
1141 | HDA_AMP_MUTE, bits); |
1142 | bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; | |
1143 | snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0, | |
1144 | HDA_AMP_MUTE, bits); | |
c9b443d4 TD |
1145 | return 1; |
1146 | } | |
1147 | ||
c9b443d4 TD |
1148 | /* mute internal speaker if HP is plugged */ |
1149 | static void cxt5047_hp_automute(struct hda_codec *codec) | |
1150 | { | |
82f30040 | 1151 | struct conexant_spec *spec = codec->spec; |
dd87da1c | 1152 | unsigned int bits; |
c9b443d4 | 1153 | |
d56757ab | 1154 | spec->hp_present = snd_hda_jack_detect(codec, 0x13); |
dd87da1c | 1155 | |
47fd830a | 1156 | bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; |
3b7523fc | 1157 | /* See the note in cxt5047_hp_master_sw_put */ |
5d75bc55 | 1158 | snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, |
47fd830a | 1159 | HDA_AMP_MUTE, bits); |
c9b443d4 TD |
1160 | } |
1161 | ||
1162 | /* toggle input of built-in and mic jack appropriately */ | |
1163 | static void cxt5047_hp_automic(struct hda_codec *codec) | |
1164 | { | |
34cbe3a6 | 1165 | static const struct hda_verb mic_jack_on[] = { |
9f113e0e MB |
1166 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1167 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
c9b443d4 TD |
1168 | {} |
1169 | }; | |
34cbe3a6 | 1170 | static const struct hda_verb mic_jack_off[] = { |
9f113e0e MB |
1171 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1172 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
c9b443d4 TD |
1173 | {} |
1174 | }; | |
1175 | unsigned int present; | |
1176 | ||
d56757ab | 1177 | present = snd_hda_jack_detect(codec, 0x15); |
c9b443d4 TD |
1178 | if (present) |
1179 | snd_hda_sequence_write(codec, mic_jack_on); | |
1180 | else | |
1181 | snd_hda_sequence_write(codec, mic_jack_off); | |
1182 | } | |
1183 | ||
1184 | /* unsolicited event for HP jack sensing */ | |
1185 | static void cxt5047_hp_unsol_event(struct hda_codec *codec, | |
1186 | unsigned int res) | |
1187 | { | |
9f113e0e | 1188 | switch (res >> 26) { |
c9b443d4 TD |
1189 | case CONEXANT_HP_EVENT: |
1190 | cxt5047_hp_automute(codec); | |
1191 | break; | |
1192 | case CONEXANT_MIC_EVENT: | |
1193 | cxt5047_hp_automic(codec); | |
1194 | break; | |
1195 | } | |
1196 | } | |
1197 | ||
34cbe3a6 | 1198 | static const struct snd_kcontrol_new cxt5047_base_mixers[] = { |
df481e41 TI |
1199 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT), |
1200 | HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT), | |
5f99f86a | 1201 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), |
c9b443d4 TD |
1202 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), |
1203 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), | |
1204 | HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), | |
1205 | HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), | |
82f30040 TD |
1206 | { |
1207 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1208 | .name = "Master Playback Switch", | |
1209 | .info = cxt_eapd_info, | |
1210 | .get = cxt_eapd_get, | |
c9b443d4 TD |
1211 | .put = cxt5047_hp_master_sw_put, |
1212 | .private_value = 0x13, | |
1213 | }, | |
1214 | ||
1215 | {} | |
1216 | }; | |
1217 | ||
34cbe3a6 | 1218 | static const struct snd_kcontrol_new cxt5047_hp_spk_mixers[] = { |
3b7523fc | 1219 | /* See the note in cxt5047_hp_master_sw_put */ |
5d75bc55 | 1220 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT), |
df481e41 TI |
1221 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT), |
1222 | {} | |
1223 | }; | |
1224 | ||
34cbe3a6 | 1225 | static const struct snd_kcontrol_new cxt5047_hp_only_mixers[] = { |
c9b443d4 | 1226 | HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT), |
c9b443d4 TD |
1227 | { } /* end */ |
1228 | }; | |
1229 | ||
34cbe3a6 | 1230 | static const struct hda_verb cxt5047_init_verbs[] = { |
c9b443d4 TD |
1231 | /* Line in, Mic, Built-in Mic */ |
1232 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1233 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, | |
1234 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, | |
7f29673b | 1235 | /* HP, Speaker */ |
b7589ceb | 1236 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
5b3a7440 TI |
1237 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, /* mixer(0x19) */ |
1238 | {0x1d, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mixer(0x19) */ | |
7f29673b | 1239 | /* Record selector: Mic */ |
c9b443d4 TD |
1240 | {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, |
1241 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, | |
1242 | AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, | |
7f29673b TD |
1243 | {0x1A, AC_VERB_SET_CONNECT_SEL,0x02}, |
1244 | {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, | |
1245 | AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00}, | |
1246 | {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, | |
1247 | AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03}, | |
c9b443d4 TD |
1248 | /* SPDIF route: PCM */ |
1249 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 }, | |
82f30040 TD |
1250 | /* Enable unsolicited events */ |
1251 | {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | |
1252 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | |
c9b443d4 TD |
1253 | { } /* end */ |
1254 | }; | |
1255 | ||
1256 | /* configuration for Toshiba Laptops */ | |
34cbe3a6 | 1257 | static const struct hda_verb cxt5047_toshiba_init_verbs[] = { |
3b628867 | 1258 | {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0}, /* default off */ |
c9b443d4 TD |
1259 | {} |
1260 | }; | |
1261 | ||
1262 | /* Test configuration for debugging, modelled after the ALC260 test | |
1263 | * configuration. | |
1264 | */ | |
1265 | #ifdef CONFIG_SND_DEBUG | |
34cbe3a6 | 1266 | static const struct hda_input_mux cxt5047_test_capture_source = { |
82f30040 | 1267 | .num_items = 4, |
c9b443d4 | 1268 | .items = { |
82f30040 TD |
1269 | { "LINE1 pin", 0x0 }, |
1270 | { "MIC1 pin", 0x1 }, | |
1271 | { "MIC2 pin", 0x2 }, | |
1272 | { "CD pin", 0x3 }, | |
c9b443d4 TD |
1273 | }, |
1274 | }; | |
1275 | ||
34cbe3a6 | 1276 | static const struct snd_kcontrol_new cxt5047_test_mixer[] = { |
c9b443d4 TD |
1277 | |
1278 | /* Output only controls */ | |
82f30040 TD |
1279 | HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT), |
1280 | HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT), | |
1281 | HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT), | |
1282 | HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT), | |
c9b443d4 TD |
1283 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT), |
1284 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT), | |
1285 | HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT), | |
1286 | HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT), | |
82f30040 TD |
1287 | HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT), |
1288 | HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
1289 | HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
1290 | HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
c9b443d4 TD |
1291 | |
1292 | /* Modes for retasking pin widgets */ | |
1293 | CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT), | |
1294 | CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT), | |
1295 | ||
82f30040 TD |
1296 | /* EAPD Switch Control */ |
1297 | CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0), | |
c9b443d4 | 1298 | |
82f30040 TD |
1299 | /* Loopback mixer controls */ |
1300 | HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT), | |
1301 | HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT), | |
1302 | HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT), | |
1303 | HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT), | |
1304 | HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT), | |
1305 | HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT), | |
1306 | HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT), | |
1307 | HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT), | |
1308 | ||
1309 | HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT), | |
1310 | HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT), | |
1311 | HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT), | |
1312 | HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT), | |
1313 | HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT), | |
1314 | HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT), | |
1315 | HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT), | |
1316 | HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT), | |
c9b443d4 TD |
1317 | { |
1318 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1319 | .name = "Input Source", | |
1320 | .info = conexant_mux_enum_info, | |
1321 | .get = conexant_mux_enum_get, | |
1322 | .put = conexant_mux_enum_put, | |
1323 | }, | |
854206b0 | 1324 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), |
9f113e0e | 1325 | |
c9b443d4 TD |
1326 | { } /* end */ |
1327 | }; | |
1328 | ||
34cbe3a6 | 1329 | static const struct hda_verb cxt5047_test_init_verbs[] = { |
c9b443d4 TD |
1330 | /* Enable retasking pins as output, initially without power amp */ |
1331 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1332 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1333 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1334 | ||
1335 | /* Disable digital (SPDIF) pins initially, but users can enable | |
1336 | * them via a mixer switch. In the case of SPDIF-out, this initverb | |
1337 | * payload also sets the generation to 0, output to be in "consumer" | |
1338 | * PCM format, copyright asserted, no pre-emphasis and no validity | |
1339 | * control. | |
1340 | */ | |
1341 | {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
1342 | ||
1343 | /* Ensure mic1, mic2, line1 pin widgets take input from the | |
1344 | * OUT1 sum bus when acting as an output. | |
1345 | */ | |
1346 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0}, | |
1347 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0}, | |
1348 | ||
1349 | /* Start with output sum widgets muted and their output gains at min */ | |
1350 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
1351 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1352 | ||
1353 | /* Unmute retasking pin widget output buffers since the default | |
1354 | * state appears to be output. As the pin mode is changed by the | |
1355 | * user the pin mode control will take care of enabling the pin's | |
1356 | * input/output buffers as needed. | |
1357 | */ | |
1358 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1359 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1360 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1361 | ||
1362 | /* Mute capture amp left and right */ | |
1363 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
1364 | ||
1365 | /* Set ADC connection select to match default mixer setting (mic1 | |
1366 | * pin) | |
1367 | */ | |
1368 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1369 | ||
1370 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
1371 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
1372 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
1373 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
1374 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
1375 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
1376 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
1377 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
1378 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
1379 | ||
1380 | { } | |
1381 | }; | |
1382 | #endif | |
1383 | ||
1384 | ||
1385 | /* initialize jack-sensing, too */ | |
1386 | static int cxt5047_hp_init(struct hda_codec *codec) | |
1387 | { | |
1388 | conexant_init(codec); | |
1389 | cxt5047_hp_automute(codec); | |
c9b443d4 TD |
1390 | return 0; |
1391 | } | |
1392 | ||
1393 | ||
1394 | enum { | |
f5fcc13c TI |
1395 | CXT5047_LAPTOP, /* Laptops w/o EAPD support */ |
1396 | CXT5047_LAPTOP_HP, /* Some HP laptops */ | |
1397 | CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */ | |
c9b443d4 TD |
1398 | #ifdef CONFIG_SND_DEBUG |
1399 | CXT5047_TEST, | |
1400 | #endif | |
fa5dadcb | 1401 | CXT5047_AUTO, |
f5fcc13c | 1402 | CXT5047_MODELS |
c9b443d4 TD |
1403 | }; |
1404 | ||
ea734963 | 1405 | static const char * const cxt5047_models[CXT5047_MODELS] = { |
f5fcc13c TI |
1406 | [CXT5047_LAPTOP] = "laptop", |
1407 | [CXT5047_LAPTOP_HP] = "laptop-hp", | |
1408 | [CXT5047_LAPTOP_EAPD] = "laptop-eapd", | |
c9b443d4 | 1409 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 1410 | [CXT5047_TEST] = "test", |
c9b443d4 | 1411 | #endif |
fa5dadcb | 1412 | [CXT5047_AUTO] = "auto", |
f5fcc13c TI |
1413 | }; |
1414 | ||
34cbe3a6 | 1415 | static const struct snd_pci_quirk cxt5047_cfg_tbl[] = { |
ac3e3741 | 1416 | SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP), |
dea0a509 TI |
1417 | SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series", |
1418 | CXT5047_LAPTOP), | |
f5fcc13c | 1419 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD), |
c9b443d4 TD |
1420 | {} |
1421 | }; | |
1422 | ||
1423 | static int patch_cxt5047(struct hda_codec *codec) | |
1424 | { | |
1425 | struct conexant_spec *spec; | |
1426 | int board_config; | |
1427 | ||
fa5dadcb TI |
1428 | board_config = snd_hda_check_board_config(codec, CXT5047_MODELS, |
1429 | cxt5047_models, | |
1430 | cxt5047_cfg_tbl); | |
fa5dadcb | 1431 | if (board_config < 0) |
c82693db | 1432 | board_config = CXT5047_AUTO; /* model=auto as default */ |
fa5dadcb TI |
1433 | if (board_config == CXT5047_AUTO) |
1434 | return patch_conexant_auto(codec); | |
1435 | ||
c9b443d4 TD |
1436 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1437 | if (!spec) | |
1438 | return -ENOMEM; | |
c9b443d4 | 1439 | codec->spec = spec; |
9421f954 | 1440 | codec->pin_amp_workaround = 1; |
c9b443d4 TD |
1441 | |
1442 | spec->multiout.max_channels = 2; | |
1443 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids); | |
1444 | spec->multiout.dac_nids = cxt5047_dac_nids; | |
1445 | spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT; | |
1446 | spec->num_adc_nids = 1; | |
1447 | spec->adc_nids = cxt5047_adc_nids; | |
1448 | spec->capsrc_nids = cxt5047_capsrc_nids; | |
c9b443d4 | 1449 | spec->num_mixers = 1; |
df481e41 | 1450 | spec->mixers[0] = cxt5047_base_mixers; |
c9b443d4 TD |
1451 | spec->num_init_verbs = 1; |
1452 | spec->init_verbs[0] = cxt5047_init_verbs; | |
1453 | spec->spdif_route = 0; | |
5cd57529 TD |
1454 | spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes), |
1455 | spec->channel_mode = cxt5047_modes, | |
c9b443d4 TD |
1456 | |
1457 | codec->patch_ops = conexant_patch_ops; | |
c9b443d4 | 1458 | |
c9b443d4 TD |
1459 | switch (board_config) { |
1460 | case CXT5047_LAPTOP: | |
df481e41 TI |
1461 | spec->num_mixers = 2; |
1462 | spec->mixers[1] = cxt5047_hp_spk_mixers; | |
1463 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; | |
c9b443d4 TD |
1464 | break; |
1465 | case CXT5047_LAPTOP_HP: | |
df481e41 TI |
1466 | spec->num_mixers = 2; |
1467 | spec->mixers[1] = cxt5047_hp_only_mixers; | |
fb3409e7 | 1468 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; |
c9b443d4 TD |
1469 | codec->patch_ops.init = cxt5047_hp_init; |
1470 | break; | |
1471 | case CXT5047_LAPTOP_EAPD: | |
82f30040 | 1472 | spec->input_mux = &cxt5047_toshiba_capture_source; |
df481e41 TI |
1473 | spec->num_mixers = 2; |
1474 | spec->mixers[1] = cxt5047_hp_spk_mixers; | |
c9b443d4 TD |
1475 | spec->num_init_verbs = 2; |
1476 | spec->init_verbs[1] = cxt5047_toshiba_init_verbs; | |
fb3409e7 | 1477 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; |
c9b443d4 TD |
1478 | break; |
1479 | #ifdef CONFIG_SND_DEBUG | |
1480 | case CXT5047_TEST: | |
1481 | spec->input_mux = &cxt5047_test_capture_source; | |
1482 | spec->mixers[0] = cxt5047_test_mixer; | |
1483 | spec->init_verbs[0] = cxt5047_test_init_verbs; | |
fb3409e7 | 1484 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; |
c9b443d4 TD |
1485 | #endif |
1486 | } | |
dd5746a8 | 1487 | spec->vmaster_nid = 0x13; |
025f206c DC |
1488 | |
1489 | switch (codec->subsystem_id >> 16) { | |
1490 | case 0x103c: | |
1491 | /* HP laptops have really bad sound over 0 dB on NID 0x10. | |
1492 | * Fix max PCM level to 0 dB (originally it has 0x1e steps | |
1493 | * with 0 dB offset 0x17) | |
1494 | */ | |
1495 | snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT, | |
1496 | (0x17 << AC_AMPCAP_OFFSET_SHIFT) | | |
1497 | (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | | |
1498 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | | |
1499 | (1 << AC_AMPCAP_MUTE_SHIFT)); | |
1500 | break; | |
1501 | } | |
1502 | ||
c9b443d4 TD |
1503 | return 0; |
1504 | } | |
1505 | ||
461e2c78 | 1506 | /* Conexant 5051 specific */ |
34cbe3a6 TI |
1507 | static const hda_nid_t cxt5051_dac_nids[1] = { 0x10 }; |
1508 | static const hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 }; | |
461e2c78 | 1509 | |
34cbe3a6 | 1510 | static const struct hda_channel_mode cxt5051_modes[1] = { |
461e2c78 TI |
1511 | { 2, NULL }, |
1512 | }; | |
1513 | ||
1514 | static void cxt5051_update_speaker(struct hda_codec *codec) | |
1515 | { | |
1516 | struct conexant_spec *spec = codec->spec; | |
1517 | unsigned int pinctl; | |
23d2df5b TI |
1518 | /* headphone pin */ |
1519 | pinctl = (spec->hp_present && spec->cur_eapd) ? PIN_HP : 0; | |
cdd03ced | 1520 | snd_hda_set_pin_ctl(codec, 0x16, pinctl); |
23d2df5b | 1521 | /* speaker pin */ |
461e2c78 | 1522 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; |
cdd03ced | 1523 | snd_hda_set_pin_ctl(codec, 0x1a, pinctl); |
a80581d0 | 1524 | /* on ideapad there is an additional speaker (subwoofer) to mute */ |
f7154de2 | 1525 | if (spec->ideapad) |
cdd03ced | 1526 | snd_hda_set_pin_ctl(codec, 0x1b, pinctl); |
461e2c78 TI |
1527 | } |
1528 | ||
1529 | /* turn on/off EAPD (+ mute HP) as a master switch */ | |
1530 | static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
1531 | struct snd_ctl_elem_value *ucontrol) | |
1532 | { | |
1533 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1534 | ||
1535 | if (!cxt_eapd_put(kcontrol, ucontrol)) | |
1536 | return 0; | |
1537 | cxt5051_update_speaker(codec); | |
1538 | return 1; | |
1539 | } | |
1540 | ||
1541 | /* toggle input of built-in and mic jack appropriately */ | |
1542 | static void cxt5051_portb_automic(struct hda_codec *codec) | |
1543 | { | |
79d7d533 | 1544 | struct conexant_spec *spec = codec->spec; |
461e2c78 TI |
1545 | unsigned int present; |
1546 | ||
faddaa5d | 1547 | if (!(spec->auto_mic & AUTO_MIC_PORTB)) |
79d7d533 | 1548 | return; |
d56757ab | 1549 | present = snd_hda_jack_detect(codec, 0x17); |
461e2c78 TI |
1550 | snd_hda_codec_write(codec, 0x14, 0, |
1551 | AC_VERB_SET_CONNECT_SEL, | |
1552 | present ? 0x01 : 0x00); | |
1553 | } | |
1554 | ||
1555 | /* switch the current ADC according to the jack state */ | |
1556 | static void cxt5051_portc_automic(struct hda_codec *codec) | |
1557 | { | |
1558 | struct conexant_spec *spec = codec->spec; | |
1559 | unsigned int present; | |
1560 | hda_nid_t new_adc; | |
1561 | ||
faddaa5d | 1562 | if (!(spec->auto_mic & AUTO_MIC_PORTC)) |
79d7d533 | 1563 | return; |
d56757ab | 1564 | present = snd_hda_jack_detect(codec, 0x18); |
461e2c78 TI |
1565 | if (present) |
1566 | spec->cur_adc_idx = 1; | |
1567 | else | |
1568 | spec->cur_adc_idx = 0; | |
1569 | new_adc = spec->adc_nids[spec->cur_adc_idx]; | |
1570 | if (spec->cur_adc && spec->cur_adc != new_adc) { | |
1571 | /* stream is running, let's swap the current ADC */ | |
f0cea797 | 1572 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
461e2c78 TI |
1573 | spec->cur_adc = new_adc; |
1574 | snd_hda_codec_setup_stream(codec, new_adc, | |
1575 | spec->cur_adc_stream_tag, 0, | |
1576 | spec->cur_adc_format); | |
1577 | } | |
1578 | } | |
1579 | ||
1580 | /* mute internal speaker if HP is plugged */ | |
1581 | static void cxt5051_hp_automute(struct hda_codec *codec) | |
1582 | { | |
1583 | struct conexant_spec *spec = codec->spec; | |
1584 | ||
d56757ab | 1585 | spec->hp_present = snd_hda_jack_detect(codec, 0x16); |
461e2c78 TI |
1586 | cxt5051_update_speaker(codec); |
1587 | } | |
1588 | ||
1589 | /* unsolicited event for HP jack sensing */ | |
1590 | static void cxt5051_hp_unsol_event(struct hda_codec *codec, | |
1591 | unsigned int res) | |
1592 | { | |
1593 | switch (res >> 26) { | |
1594 | case CONEXANT_HP_EVENT: | |
1595 | cxt5051_hp_automute(codec); | |
1596 | break; | |
1597 | case CXT5051_PORTB_EVENT: | |
1598 | cxt5051_portb_automic(codec); | |
1599 | break; | |
1600 | case CXT5051_PORTC_EVENT: | |
1601 | cxt5051_portc_automic(codec); | |
1602 | break; | |
1603 | } | |
1604 | } | |
1605 | ||
34cbe3a6 | 1606 | static const struct snd_kcontrol_new cxt5051_playback_mixers[] = { |
461e2c78 TI |
1607 | HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), |
1608 | { | |
1609 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1610 | .name = "Master Playback Switch", | |
1611 | .info = cxt_eapd_info, | |
1612 | .get = cxt_eapd_get, | |
1613 | .put = cxt5051_hp_master_sw_put, | |
1614 | .private_value = 0x1a, | |
1615 | }, | |
2c7a3fb3 TI |
1616 | {} |
1617 | }; | |
461e2c78 | 1618 | |
34cbe3a6 | 1619 | static const struct snd_kcontrol_new cxt5051_capture_mixers[] = { |
2c7a3fb3 TI |
1620 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), |
1621 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), | |
8607f7c4 DH |
1622 | HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), |
1623 | HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), | |
c40bd914 DH |
1624 | HDA_CODEC_VOLUME("Dock Mic Volume", 0x15, 0x00, HDA_INPUT), |
1625 | HDA_CODEC_MUTE("Dock Mic Switch", 0x15, 0x00, HDA_INPUT), | |
461e2c78 TI |
1626 | {} |
1627 | }; | |
1628 | ||
34cbe3a6 | 1629 | static const struct snd_kcontrol_new cxt5051_hp_mixers[] = { |
461e2c78 TI |
1630 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), |
1631 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), | |
8607f7c4 DH |
1632 | HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT), |
1633 | HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT), | |
461e2c78 TI |
1634 | {} |
1635 | }; | |
1636 | ||
34cbe3a6 | 1637 | static const struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = { |
4e4ac600 TI |
1638 | HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT), |
1639 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT), | |
79d7d533 TI |
1640 | {} |
1641 | }; | |
1642 | ||
34cbe3a6 | 1643 | static const struct snd_kcontrol_new cxt5051_f700_mixers[] = { |
5f6c3de6 TI |
1644 | HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT), |
1645 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT), | |
cd9d95a5 KP |
1646 | {} |
1647 | }; | |
1648 | ||
34cbe3a6 | 1649 | static const struct snd_kcontrol_new cxt5051_toshiba_mixers[] = { |
faddaa5d TI |
1650 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), |
1651 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), | |
8607f7c4 DH |
1652 | HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), |
1653 | HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), | |
faddaa5d TI |
1654 | {} |
1655 | }; | |
1656 | ||
34cbe3a6 | 1657 | static const struct hda_verb cxt5051_init_verbs[] = { |
461e2c78 TI |
1658 | /* Line in, Mic */ |
1659 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, | |
1660 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1661 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, | |
1662 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1663 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1664 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, | |
1665 | /* SPK */ | |
1666 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1667 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1668 | /* HP, Amp */ | |
1669 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1670 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1671 | /* DAC1 */ | |
1672 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
28c4edb7 | 1673 | /* Record selector: Internal mic */ |
461e2c78 TI |
1674 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, |
1675 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, | |
1676 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, | |
1677 | /* SPDIF route: PCM */ | |
1965c441 | 1678 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
461e2c78 TI |
1679 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
1680 | /* EAPD */ | |
1681 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
1682 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, | |
461e2c78 TI |
1683 | { } /* end */ |
1684 | }; | |
1685 | ||
34cbe3a6 | 1686 | static const struct hda_verb cxt5051_hp_dv6736_init_verbs[] = { |
79d7d533 TI |
1687 | /* Line in, Mic */ |
1688 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, | |
1689 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1690 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, | |
1691 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, | |
1692 | /* SPK */ | |
1693 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1694 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1695 | /* HP, Amp */ | |
1696 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1697 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1698 | /* DAC1 */ | |
1699 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
28c4edb7 | 1700 | /* Record selector: Internal mic */ |
79d7d533 TI |
1701 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, |
1702 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, | |
1703 | /* SPDIF route: PCM */ | |
1704 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
1705 | /* EAPD */ | |
1706 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
1707 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, | |
79d7d533 TI |
1708 | { } /* end */ |
1709 | }; | |
1710 | ||
34cbe3a6 | 1711 | static const struct hda_verb cxt5051_f700_init_verbs[] = { |
cd9d95a5 | 1712 | /* Line in, Mic */ |
30ed7ed1 | 1713 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, |
cd9d95a5 KP |
1714 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1715 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, | |
1716 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, | |
1717 | /* SPK */ | |
1718 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1719 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1720 | /* HP, Amp */ | |
1721 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1722 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1723 | /* DAC1 */ | |
1724 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
28c4edb7 | 1725 | /* Record selector: Internal mic */ |
cd9d95a5 KP |
1726 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, |
1727 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, | |
1728 | /* SPDIF route: PCM */ | |
1729 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
1730 | /* EAPD */ | |
1731 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
1732 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, | |
cd9d95a5 KP |
1733 | { } /* end */ |
1734 | }; | |
1735 | ||
6953e552 TI |
1736 | static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid, |
1737 | unsigned int event) | |
1738 | { | |
1739 | snd_hda_codec_write(codec, nid, 0, | |
1740 | AC_VERB_SET_UNSOLICITED_ENABLE, | |
1741 | AC_USRSP_EN | event); | |
6953e552 TI |
1742 | } |
1743 | ||
34cbe3a6 | 1744 | static const struct hda_verb cxt5051_ideapad_init_verbs[] = { |
f7154de2 HRK |
1745 | /* Subwoofer */ |
1746 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1747 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1748 | { } /* end */ | |
1749 | }; | |
1750 | ||
461e2c78 TI |
1751 | /* initialize jack-sensing, too */ |
1752 | static int cxt5051_init(struct hda_codec *codec) | |
1753 | { | |
6953e552 TI |
1754 | struct conexant_spec *spec = codec->spec; |
1755 | ||
461e2c78 | 1756 | conexant_init(codec); |
6953e552 TI |
1757 | |
1758 | if (spec->auto_mic & AUTO_MIC_PORTB) | |
1759 | cxt5051_init_mic_port(codec, 0x17, CXT5051_PORTB_EVENT); | |
1760 | if (spec->auto_mic & AUTO_MIC_PORTC) | |
1761 | cxt5051_init_mic_port(codec, 0x18, CXT5051_PORTC_EVENT); | |
1762 | ||
461e2c78 TI |
1763 | if (codec->patch_ops.unsol_event) { |
1764 | cxt5051_hp_automute(codec); | |
1765 | cxt5051_portb_automic(codec); | |
1766 | cxt5051_portc_automic(codec); | |
1767 | } | |
1768 | return 0; | |
1769 | } | |
1770 | ||
1771 | ||
1772 | enum { | |
1773 | CXT5051_LAPTOP, /* Laptops w/ EAPD support */ | |
1774 | CXT5051_HP, /* no docking */ | |
79d7d533 | 1775 | CXT5051_HP_DV6736, /* HP without mic switch */ |
cd9d95a5 | 1776 | CXT5051_F700, /* HP Compaq Presario F700 */ |
faddaa5d | 1777 | CXT5051_TOSHIBA, /* Toshiba M300 & co */ |
f7154de2 | 1778 | CXT5051_IDEAPAD, /* Lenovo IdeaPad Y430 */ |
6764bcef | 1779 | CXT5051_AUTO, /* auto-parser */ |
461e2c78 TI |
1780 | CXT5051_MODELS |
1781 | }; | |
1782 | ||
ea734963 | 1783 | static const char *const cxt5051_models[CXT5051_MODELS] = { |
461e2c78 TI |
1784 | [CXT5051_LAPTOP] = "laptop", |
1785 | [CXT5051_HP] = "hp", | |
79d7d533 | 1786 | [CXT5051_HP_DV6736] = "hp-dv6736", |
5f6c3de6 | 1787 | [CXT5051_F700] = "hp-700", |
faddaa5d | 1788 | [CXT5051_TOSHIBA] = "toshiba", |
f7154de2 | 1789 | [CXT5051_IDEAPAD] = "ideapad", |
6764bcef | 1790 | [CXT5051_AUTO] = "auto", |
461e2c78 TI |
1791 | }; |
1792 | ||
34cbe3a6 | 1793 | static const struct snd_pci_quirk cxt5051_cfg_tbl[] = { |
79d7d533 | 1794 | SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736), |
1812e67c | 1795 | SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP), |
5f6c3de6 | 1796 | SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700), |
faddaa5d | 1797 | SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA), |
461e2c78 TI |
1798 | SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", |
1799 | CXT5051_LAPTOP), | |
1800 | SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), | |
f7154de2 | 1801 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD), |
461e2c78 TI |
1802 | {} |
1803 | }; | |
1804 | ||
1805 | static int patch_cxt5051(struct hda_codec *codec) | |
1806 | { | |
1807 | struct conexant_spec *spec; | |
1808 | int board_config; | |
1809 | ||
6764bcef TI |
1810 | board_config = snd_hda_check_board_config(codec, CXT5051_MODELS, |
1811 | cxt5051_models, | |
1812 | cxt5051_cfg_tbl); | |
1813 | if (board_config < 0) | |
c82693db | 1814 | board_config = CXT5051_AUTO; /* model=auto as default */ |
1f8458a2 | 1815 | if (board_config == CXT5051_AUTO) |
6764bcef | 1816 | return patch_conexant_auto(codec); |
6764bcef | 1817 | |
461e2c78 TI |
1818 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1819 | if (!spec) | |
1820 | return -ENOMEM; | |
461e2c78 | 1821 | codec->spec = spec; |
9421f954 | 1822 | codec->pin_amp_workaround = 1; |
461e2c78 TI |
1823 | |
1824 | codec->patch_ops = conexant_patch_ops; | |
1825 | codec->patch_ops.init = cxt5051_init; | |
1826 | ||
1827 | spec->multiout.max_channels = 2; | |
1828 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids); | |
1829 | spec->multiout.dac_nids = cxt5051_dac_nids; | |
1830 | spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT; | |
1831 | spec->num_adc_nids = 1; /* not 2; via auto-mic switch */ | |
1832 | spec->adc_nids = cxt5051_adc_nids; | |
2c7a3fb3 TI |
1833 | spec->num_mixers = 2; |
1834 | spec->mixers[0] = cxt5051_capture_mixers; | |
1835 | spec->mixers[1] = cxt5051_playback_mixers; | |
461e2c78 TI |
1836 | spec->num_init_verbs = 1; |
1837 | spec->init_verbs[0] = cxt5051_init_verbs; | |
1838 | spec->spdif_route = 0; | |
1839 | spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes); | |
1840 | spec->channel_mode = cxt5051_modes; | |
1841 | spec->cur_adc = 0; | |
1842 | spec->cur_adc_idx = 0; | |
1843 | ||
3507e2a8 TI |
1844 | set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); |
1845 | ||
79d7d533 TI |
1846 | codec->patch_ops.unsol_event = cxt5051_hp_unsol_event; |
1847 | ||
faddaa5d | 1848 | spec->auto_mic = AUTO_MIC_PORTB | AUTO_MIC_PORTC; |
461e2c78 TI |
1849 | switch (board_config) { |
1850 | case CXT5051_HP: | |
461e2c78 TI |
1851 | spec->mixers[0] = cxt5051_hp_mixers; |
1852 | break; | |
79d7d533 TI |
1853 | case CXT5051_HP_DV6736: |
1854 | spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs; | |
1855 | spec->mixers[0] = cxt5051_hp_dv6736_mixers; | |
faddaa5d | 1856 | spec->auto_mic = 0; |
79d7d533 | 1857 | break; |
cd9d95a5 KP |
1858 | case CXT5051_F700: |
1859 | spec->init_verbs[0] = cxt5051_f700_init_verbs; | |
1860 | spec->mixers[0] = cxt5051_f700_mixers; | |
faddaa5d TI |
1861 | spec->auto_mic = 0; |
1862 | break; | |
1863 | case CXT5051_TOSHIBA: | |
1864 | spec->mixers[0] = cxt5051_toshiba_mixers; | |
1865 | spec->auto_mic = AUTO_MIC_PORTB; | |
cd9d95a5 | 1866 | break; |
f7154de2 HRK |
1867 | case CXT5051_IDEAPAD: |
1868 | spec->init_verbs[spec->num_init_verbs++] = | |
1869 | cxt5051_ideapad_init_verbs; | |
1870 | spec->ideapad = 1; | |
1871 | break; | |
461e2c78 TI |
1872 | } |
1873 | ||
3507e2a8 | 1874 | if (spec->beep_amp) |
a86b1a2c | 1875 | snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); |
3507e2a8 | 1876 | |
461e2c78 TI |
1877 | return 0; |
1878 | } | |
1879 | ||
0fb67e98 DD |
1880 | /* Conexant 5066 specific */ |
1881 | ||
34cbe3a6 TI |
1882 | static const hda_nid_t cxt5066_dac_nids[1] = { 0x10 }; |
1883 | static const hda_nid_t cxt5066_adc_nids[3] = { 0x14, 0x15, 0x16 }; | |
1884 | static const hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 }; | |
1885 | static const hda_nid_t cxt5066_digout_pin_nids[2] = { 0x20, 0x22 }; | |
0fb67e98 | 1886 | |
34cbe3a6 | 1887 | static const struct hda_channel_mode cxt5066_modes[1] = { |
0fb67e98 DD |
1888 | { 2, NULL }, |
1889 | }; | |
1890 | ||
a3de8ab8 TI |
1891 | #define HP_PRESENT_PORT_A (1 << 0) |
1892 | #define HP_PRESENT_PORT_D (1 << 1) | |
1893 | #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A) | |
1894 | #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D) | |
1895 | ||
0fb67e98 DD |
1896 | static void cxt5066_update_speaker(struct hda_codec *codec) |
1897 | { | |
1898 | struct conexant_spec *spec = codec->spec; | |
1899 | unsigned int pinctl; | |
1900 | ||
4e76a883 TI |
1901 | codec_dbg(codec, |
1902 | "CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n", | |
3a253445 | 1903 | spec->hp_present, spec->cur_eapd); |
0fb67e98 DD |
1904 | |
1905 | /* Port A (HP) */ | |
a3de8ab8 | 1906 | pinctl = (hp_port_a_present(spec) && spec->cur_eapd) ? PIN_HP : 0; |
cdd03ced | 1907 | snd_hda_set_pin_ctl(codec, 0x19, pinctl); |
0fb67e98 DD |
1908 | |
1909 | /* Port D (HP/LO) */ | |
a3de8ab8 TI |
1910 | pinctl = spec->cur_eapd ? spec->port_d_mode : 0; |
1911 | if (spec->dell_automute || spec->thinkpad) { | |
1912 | /* Mute if Port A is connected */ | |
1913 | if (hp_port_a_present(spec)) | |
3a253445 JB |
1914 | pinctl = 0; |
1915 | } else { | |
a3de8ab8 TI |
1916 | /* Thinkpad/Dell doesn't give pin-D status */ |
1917 | if (!hp_port_d_present(spec)) | |
1918 | pinctl = 0; | |
3a253445 | 1919 | } |
cdd03ced | 1920 | snd_hda_set_pin_ctl(codec, 0x1c, pinctl); |
0fb67e98 DD |
1921 | |
1922 | /* CLASS_D AMP */ | |
1923 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; | |
cdd03ced | 1924 | snd_hda_set_pin_ctl(codec, 0x1f, pinctl); |
0fb67e98 DD |
1925 | } |
1926 | ||
1927 | /* turn on/off EAPD (+ mute HP) as a master switch */ | |
1928 | static int cxt5066_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
1929 | struct snd_ctl_elem_value *ucontrol) | |
1930 | { | |
1931 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1932 | ||
1933 | if (!cxt_eapd_put(kcontrol, ucontrol)) | |
1934 | return 0; | |
1935 | ||
1936 | cxt5066_update_speaker(codec); | |
1937 | return 1; | |
1938 | } | |
1939 | ||
95a618bd ER |
1940 | /* toggle input of built-in digital mic and mic jack appropriately */ |
1941 | static void cxt5066_vostro_automic(struct hda_codec *codec) | |
1942 | { | |
95a618bd ER |
1943 | unsigned int present; |
1944 | ||
1945 | struct hda_verb ext_mic_present[] = { | |
1946 | /* enable external mic, port B */ | |
75f8991d | 1947 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
95a618bd ER |
1948 | |
1949 | /* switch to external mic input */ | |
1950 | {0x17, AC_VERB_SET_CONNECT_SEL, 0}, | |
1951 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, | |
1952 | ||
1953 | /* disable internal digital mic */ | |
1954 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
1955 | {} | |
1956 | }; | |
34cbe3a6 | 1957 | static const struct hda_verb ext_mic_absent[] = { |
95a618bd ER |
1958 | /* enable internal mic, port C */ |
1959 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1960 | ||
1961 | /* switch to internal mic input */ | |
1962 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, | |
1963 | ||
1964 | /* disable external mic, port B */ | |
1965 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
1966 | {} | |
1967 | }; | |
1968 | ||
1969 | present = snd_hda_jack_detect(codec, 0x1a); | |
1970 | if (present) { | |
4e76a883 | 1971 | codec_dbg(codec, "CXT5066: external microphone detected\n"); |
95a618bd ER |
1972 | snd_hda_sequence_write(codec, ext_mic_present); |
1973 | } else { | |
4e76a883 | 1974 | codec_dbg(codec, "CXT5066: external microphone absent\n"); |
95a618bd ER |
1975 | snd_hda_sequence_write(codec, ext_mic_absent); |
1976 | } | |
1977 | } | |
1978 | ||
cfd3d8dc GA |
1979 | /* toggle input of built-in digital mic and mic jack appropriately */ |
1980 | static void cxt5066_ideapad_automic(struct hda_codec *codec) | |
1981 | { | |
1982 | unsigned int present; | |
1983 | ||
1984 | struct hda_verb ext_mic_present[] = { | |
1985 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, | |
1986 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1987 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
1988 | {} | |
1989 | }; | |
34cbe3a6 | 1990 | static const struct hda_verb ext_mic_absent[] = { |
cfd3d8dc GA |
1991 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, |
1992 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1993 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
1994 | {} | |
1995 | }; | |
1996 | ||
1997 | present = snd_hda_jack_detect(codec, 0x1b); | |
1998 | if (present) { | |
4e76a883 | 1999 | codec_dbg(codec, "CXT5066: external microphone detected\n"); |
cfd3d8dc GA |
2000 | snd_hda_sequence_write(codec, ext_mic_present); |
2001 | } else { | |
4e76a883 | 2002 | codec_dbg(codec, "CXT5066: external microphone absent\n"); |
cfd3d8dc GA |
2003 | snd_hda_sequence_write(codec, ext_mic_absent); |
2004 | } | |
2005 | } | |
2006 | ||
a1d6906e DH |
2007 | |
2008 | /* toggle input of built-in digital mic and mic jack appropriately */ | |
2009 | static void cxt5066_asus_automic(struct hda_codec *codec) | |
2010 | { | |
2011 | unsigned int present; | |
2012 | ||
2013 | present = snd_hda_jack_detect(codec, 0x1b); | |
4e76a883 | 2014 | codec_dbg(codec, "CXT5066: external microphone present=%d\n", present); |
a1d6906e DH |
2015 | snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, |
2016 | present ? 1 : 0); | |
2017 | } | |
2018 | ||
2019 | ||
048e78a5 DH |
2020 | /* toggle input of built-in digital mic and mic jack appropriately */ |
2021 | static void cxt5066_hp_laptop_automic(struct hda_codec *codec) | |
2022 | { | |
2023 | unsigned int present; | |
2024 | ||
2025 | present = snd_hda_jack_detect(codec, 0x1b); | |
4e76a883 | 2026 | codec_dbg(codec, "CXT5066: external microphone present=%d\n", present); |
048e78a5 DH |
2027 | snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, |
2028 | present ? 1 : 3); | |
2029 | } | |
2030 | ||
2031 | ||
7b2bfdbc JT |
2032 | /* toggle input of built-in digital mic and mic jack appropriately |
2033 | order is: external mic -> dock mic -> interal mic */ | |
2034 | static void cxt5066_thinkpad_automic(struct hda_codec *codec) | |
2035 | { | |
2036 | unsigned int ext_present, dock_present; | |
2037 | ||
34cbe3a6 | 2038 | static const struct hda_verb ext_mic_present[] = { |
7b2bfdbc JT |
2039 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, |
2040 | {0x17, AC_VERB_SET_CONNECT_SEL, 1}, | |
2041 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2042 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2043 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2044 | {} | |
2045 | }; | |
34cbe3a6 | 2046 | static const struct hda_verb dock_mic_present[] = { |
7b2bfdbc JT |
2047 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, |
2048 | {0x17, AC_VERB_SET_CONNECT_SEL, 0}, | |
2049 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2050 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2051 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2052 | {} | |
2053 | }; | |
34cbe3a6 | 2054 | static const struct hda_verb ext_mic_absent[] = { |
7b2bfdbc JT |
2055 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, |
2056 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2057 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2058 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2059 | {} | |
2060 | }; | |
2061 | ||
2062 | ext_present = snd_hda_jack_detect(codec, 0x1b); | |
2063 | dock_present = snd_hda_jack_detect(codec, 0x1a); | |
2064 | if (ext_present) { | |
4e76a883 | 2065 | codec_dbg(codec, "CXT5066: external microphone detected\n"); |
7b2bfdbc JT |
2066 | snd_hda_sequence_write(codec, ext_mic_present); |
2067 | } else if (dock_present) { | |
4e76a883 | 2068 | codec_dbg(codec, "CXT5066: dock microphone detected\n"); |
7b2bfdbc JT |
2069 | snd_hda_sequence_write(codec, dock_mic_present); |
2070 | } else { | |
4e76a883 | 2071 | codec_dbg(codec, "CXT5066: external microphone absent\n"); |
7b2bfdbc JT |
2072 | snd_hda_sequence_write(codec, ext_mic_absent); |
2073 | } | |
2074 | } | |
2075 | ||
0fb67e98 DD |
2076 | /* mute internal speaker if HP is plugged */ |
2077 | static void cxt5066_hp_automute(struct hda_codec *codec) | |
2078 | { | |
2079 | struct conexant_spec *spec = codec->spec; | |
2080 | unsigned int portA, portD; | |
2081 | ||
2082 | /* Port A */ | |
d56757ab | 2083 | portA = snd_hda_jack_detect(codec, 0x19); |
0fb67e98 DD |
2084 | |
2085 | /* Port D */ | |
d56757ab | 2086 | portD = snd_hda_jack_detect(codec, 0x1c); |
0fb67e98 | 2087 | |
a3de8ab8 TI |
2088 | spec->hp_present = portA ? HP_PRESENT_PORT_A : 0; |
2089 | spec->hp_present |= portD ? HP_PRESENT_PORT_D : 0; | |
4e76a883 | 2090 | codec_dbg(codec, "CXT5066: hp automute portA=%x portD=%x present=%d\n", |
0fb67e98 DD |
2091 | portA, portD, spec->hp_present); |
2092 | cxt5066_update_speaker(codec); | |
2093 | } | |
2094 | ||
02b6b5b6 DH |
2095 | /* Dispatch the right mic autoswitch function */ |
2096 | static void cxt5066_automic(struct hda_codec *codec) | |
0fb67e98 | 2097 | { |
c4cfe66c | 2098 | struct conexant_spec *spec = codec->spec; |
0fb67e98 | 2099 | |
02b6b5b6 | 2100 | if (spec->dell_vostro) |
95a618bd | 2101 | cxt5066_vostro_automic(codec); |
02b6b5b6 | 2102 | else if (spec->ideapad) |
cfd3d8dc | 2103 | cxt5066_ideapad_automic(codec); |
02b6b5b6 DH |
2104 | else if (spec->thinkpad) |
2105 | cxt5066_thinkpad_automic(codec); | |
2106 | else if (spec->hp_laptop) | |
2107 | cxt5066_hp_laptop_automic(codec); | |
a1d6906e DH |
2108 | else if (spec->asus) |
2109 | cxt5066_asus_automic(codec); | |
cfd3d8dc GA |
2110 | } |
2111 | ||
7b2bfdbc | 2112 | /* unsolicited event for jack sensing */ |
02b6b5b6 | 2113 | static void cxt5066_unsol_event(struct hda_codec *codec, unsigned int res) |
7b2bfdbc | 2114 | { |
4e76a883 | 2115 | codec_dbg(codec, "CXT5066: unsol event %x (%x)\n", res, res >> 26); |
7b2bfdbc JT |
2116 | switch (res >> 26) { |
2117 | case CONEXANT_HP_EVENT: | |
2118 | cxt5066_hp_automute(codec); | |
2119 | break; | |
2120 | case CONEXANT_MIC_EVENT: | |
02b6b5b6 | 2121 | cxt5066_automic(codec); |
7b2bfdbc JT |
2122 | break; |
2123 | } | |
2124 | } | |
2125 | ||
02b6b5b6 | 2126 | |
0fb67e98 DD |
2127 | static const struct hda_input_mux cxt5066_analog_mic_boost = { |
2128 | .num_items = 5, | |
2129 | .items = { | |
2130 | { "0dB", 0 }, | |
2131 | { "10dB", 1 }, | |
2132 | { "20dB", 2 }, | |
2133 | { "30dB", 3 }, | |
2134 | { "40dB", 4 }, | |
2135 | }, | |
2136 | }; | |
2137 | ||
cfd3d8dc | 2138 | static void cxt5066_set_mic_boost(struct hda_codec *codec) |
c4cfe66c DD |
2139 | { |
2140 | struct conexant_spec *spec = codec->spec; | |
cfd3d8dc | 2141 | snd_hda_codec_write_cache(codec, 0x17, 0, |
c4cfe66c DD |
2142 | AC_VERB_SET_AMP_GAIN_MUTE, |
2143 | AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT | | |
2144 | cxt5066_analog_mic_boost.items[spec->mic_boost].index); | |
7b2bfdbc | 2145 | if (spec->ideapad || spec->thinkpad) { |
cfd3d8dc GA |
2146 | /* adjust the internal mic as well...it is not through 0x17 */ |
2147 | snd_hda_codec_write_cache(codec, 0x23, 0, | |
2148 | AC_VERB_SET_AMP_GAIN_MUTE, | |
2149 | AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_INPUT | | |
2150 | cxt5066_analog_mic_boost. | |
2151 | items[spec->mic_boost].index); | |
2152 | } | |
c4cfe66c DD |
2153 | } |
2154 | ||
0fb67e98 DD |
2155 | static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol *kcontrol, |
2156 | struct snd_ctl_elem_info *uinfo) | |
2157 | { | |
2158 | return snd_hda_input_mux_info(&cxt5066_analog_mic_boost, uinfo); | |
2159 | } | |
2160 | ||
2161 | static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol *kcontrol, | |
2162 | struct snd_ctl_elem_value *ucontrol) | |
2163 | { | |
2164 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
c4cfe66c DD |
2165 | struct conexant_spec *spec = codec->spec; |
2166 | ucontrol->value.enumerated.item[0] = spec->mic_boost; | |
0fb67e98 DD |
2167 | return 0; |
2168 | } | |
2169 | ||
2170 | static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol, | |
2171 | struct snd_ctl_elem_value *ucontrol) | |
2172 | { | |
2173 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
c4cfe66c | 2174 | struct conexant_spec *spec = codec->spec; |
0fb67e98 DD |
2175 | const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; |
2176 | unsigned int idx; | |
c4cfe66c DD |
2177 | idx = ucontrol->value.enumerated.item[0]; |
2178 | if (idx >= imux->num_items) | |
2179 | idx = imux->num_items - 1; | |
2180 | ||
2181 | spec->mic_boost = idx; | |
c4cfe66c | 2182 | cxt5066_set_mic_boost(codec); |
c4cfe66c DD |
2183 | return 1; |
2184 | } | |
2185 | ||
f6a2491c | 2186 | static void conexant_check_dig_outs(struct hda_codec *codec, |
34cbe3a6 | 2187 | const hda_nid_t *dig_pins, |
f6a2491c AR |
2188 | int num_pins) |
2189 | { | |
2190 | struct conexant_spec *spec = codec->spec; | |
2191 | hda_nid_t *nid_loc = &spec->multiout.dig_out_nid; | |
2192 | int i; | |
2193 | ||
2194 | for (i = 0; i < num_pins; i++, dig_pins++) { | |
2195 | unsigned int cfg = snd_hda_codec_get_pincfg(codec, *dig_pins); | |
2196 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_NONE) | |
2197 | continue; | |
2198 | if (snd_hda_get_connections(codec, *dig_pins, nid_loc, 1) != 1) | |
2199 | continue; | |
f6a2491c AR |
2200 | } |
2201 | } | |
2202 | ||
34cbe3a6 | 2203 | static const struct hda_input_mux cxt5066_capture_source = { |
0fb67e98 DD |
2204 | .num_items = 4, |
2205 | .items = { | |
2206 | { "Mic B", 0 }, | |
2207 | { "Mic C", 1 }, | |
2208 | { "Mic E", 2 }, | |
2209 | { "Mic F", 3 }, | |
2210 | }, | |
2211 | }; | |
2212 | ||
34cbe3a6 | 2213 | static const struct hda_bind_ctls cxt5066_bind_capture_vol_others = { |
0fb67e98 DD |
2214 | .ops = &snd_hda_bind_vol, |
2215 | .values = { | |
2216 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), | |
2217 | HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), | |
2218 | 0 | |
2219 | }, | |
2220 | }; | |
2221 | ||
34cbe3a6 | 2222 | static const struct hda_bind_ctls cxt5066_bind_capture_sw_others = { |
0fb67e98 DD |
2223 | .ops = &snd_hda_bind_sw, |
2224 | .values = { | |
2225 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), | |
2226 | HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), | |
2227 | 0 | |
2228 | }, | |
2229 | }; | |
2230 | ||
34cbe3a6 | 2231 | static const struct snd_kcontrol_new cxt5066_mixer_master[] = { |
0fb67e98 DD |
2232 | HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), |
2233 | {} | |
2234 | }; | |
2235 | ||
34cbe3a6 | 2236 | static const struct snd_kcontrol_new cxt5066_mixers[] = { |
0fb67e98 DD |
2237 | { |
2238 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2239 | .name = "Master Playback Switch", | |
2240 | .info = cxt_eapd_info, | |
2241 | .get = cxt_eapd_get, | |
2242 | .put = cxt5066_hp_master_sw_put, | |
2243 | .private_value = 0x1d, | |
2244 | }, | |
2245 | ||
2246 | { | |
2247 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
c4cfe66c | 2248 | .name = "Analog Mic Boost Capture Enum", |
0fb67e98 DD |
2249 | .info = cxt5066_mic_boost_mux_enum_info, |
2250 | .get = cxt5066_mic_boost_mux_enum_get, | |
2251 | .put = cxt5066_mic_boost_mux_enum_put, | |
2252 | }, | |
2253 | ||
2254 | HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others), | |
2255 | HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others), | |
2256 | {} | |
2257 | }; | |
2258 | ||
34cbe3a6 | 2259 | static const struct snd_kcontrol_new cxt5066_vostro_mixers[] = { |
254bba6a ER |
2260 | { |
2261 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
28c4edb7 | 2262 | .name = "Internal Mic Boost Capture Enum", |
254bba6a ER |
2263 | .info = cxt5066_mic_boost_mux_enum_info, |
2264 | .get = cxt5066_mic_boost_mux_enum_get, | |
2265 | .put = cxt5066_mic_boost_mux_enum_put, | |
2266 | .private_value = 0x23 | 0x100, | |
2267 | }, | |
2268 | {} | |
2269 | }; | |
2270 | ||
34cbe3a6 | 2271 | static const struct hda_verb cxt5066_init_verbs[] = { |
0fb67e98 DD |
2272 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ |
2273 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ | |
2274 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ | |
2275 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ | |
2276 | ||
2277 | /* Speakers */ | |
2278 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2279 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2280 | ||
2281 | /* HP, Amp */ | |
2282 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2283 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2284 | ||
2285 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2286 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2287 | ||
2288 | /* DAC1 */ | |
2289 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2290 | ||
2291 | /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ | |
2292 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, | |
2293 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2294 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, | |
2295 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2296 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2297 | ||
2298 | /* no digital microphone support yet */ | |
2299 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2300 | ||
2301 | /* Audio input selector */ | |
2302 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, | |
2303 | ||
2304 | /* SPDIF route: PCM */ | |
2305 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
2306 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
2307 | ||
2308 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2309 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2310 | ||
2311 | /* EAPD */ | |
2312 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
2313 | ||
2314 | /* not handling these yet */ | |
2315 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2316 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2317 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2318 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2319 | {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2320 | {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2321 | {0x20, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2322 | {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2323 | { } /* end */ | |
2324 | }; | |
2325 | ||
34cbe3a6 | 2326 | static const struct hda_verb cxt5066_init_verbs_vostro[] = { |
95a618bd ER |
2327 | /* Port A: headphones */ |
2328 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2329 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2330 | ||
2331 | /* Port B: external microphone */ | |
2332 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2333 | ||
2334 | /* Port C: unused */ | |
2335 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2336 | ||
2337 | /* Port D: unused */ | |
2338 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2339 | ||
2340 | /* Port E: unused, but has primary EAPD */ | |
2341 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2342 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
2343 | ||
2344 | /* Port F: unused */ | |
2345 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2346 | ||
2347 | /* Port G: internal speakers */ | |
2348 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2349 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2350 | ||
2351 | /* DAC1 */ | |
2352 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2353 | ||
2354 | /* DAC2: unused */ | |
2355 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2356 | ||
2357 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
2358 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2359 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2360 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2361 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
2362 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2363 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2364 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2365 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
2366 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2367 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2368 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2369 | ||
2370 | /* Digital microphone port */ | |
2371 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2372 | ||
2373 | /* Audio input selectors */ | |
2374 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, | |
2375 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
2376 | ||
2377 | /* Disable SPDIF */ | |
2378 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2379 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2380 | ||
2381 | /* enable unsolicited events for Port A and B */ | |
2382 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | |
2383 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | |
2384 | { } /* end */ | |
2385 | }; | |
2386 | ||
34cbe3a6 | 2387 | static const struct hda_verb cxt5066_init_verbs_ideapad[] = { |
cfd3d8dc GA |
2388 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ |
2389 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ | |
2390 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ | |
2391 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ | |
2392 | ||
2393 | /* Speakers */ | |
2394 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2395 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2396 | ||
2397 | /* HP, Amp */ | |
2398 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2399 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2400 | ||
2401 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2402 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2403 | ||
2404 | /* DAC1 */ | |
2405 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2406 | ||
2407 | /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ | |
2408 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, | |
2409 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2410 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, | |
2411 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2412 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2413 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ | |
2414 | ||
2415 | /* Audio input selector */ | |
2416 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, | |
2417 | {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ | |
2418 | ||
2419 | /* SPDIF route: PCM */ | |
2420 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
2421 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
2422 | ||
2423 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2424 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2425 | ||
2426 | /* internal microphone */ | |
28c4edb7 | 2427 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */ |
cfd3d8dc GA |
2428 | |
2429 | /* EAPD */ | |
2430 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
2431 | ||
2432 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | |
2433 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | |
2434 | { } /* end */ | |
2435 | }; | |
2436 | ||
34cbe3a6 | 2437 | static const struct hda_verb cxt5066_init_verbs_thinkpad[] = { |
7b2bfdbc JT |
2438 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ |
2439 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ | |
2440 | ||
2441 | /* Port G: internal speakers */ | |
2442 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2443 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2444 | ||
2445 | /* Port A: HP, Amp */ | |
2446 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2447 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2448 | ||
2449 | /* Port B: Mic Dock */ | |
2450 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2451 | ||
2452 | /* Port C: Mic */ | |
2453 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2454 | ||
2455 | /* Port D: HP Dock, Amp */ | |
2456 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2457 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2458 | ||
2459 | /* DAC1 */ | |
2460 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2461 | ||
2462 | /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ | |
2463 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, | |
2464 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2465 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, | |
2466 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2467 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2468 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ | |
2469 | ||
2470 | /* Audio input selector */ | |
2471 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, | |
2472 | {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ | |
2473 | ||
2474 | /* SPDIF route: PCM */ | |
2475 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
2476 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
2477 | ||
2478 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2479 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2480 | ||
2481 | /* internal microphone */ | |
28c4edb7 | 2482 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */ |
7b2bfdbc JT |
2483 | |
2484 | /* EAPD */ | |
2485 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
2486 | ||
2487 | /* enable unsolicited events for Port A, B, C and D */ | |
2488 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | |
2489 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | |
2490 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | |
2491 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | |
2492 | { } /* end */ | |
2493 | }; | |
2494 | ||
34cbe3a6 | 2495 | static const struct hda_verb cxt5066_init_verbs_portd_lo[] = { |
0fb67e98 DD |
2496 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
2497 | { } /* end */ | |
2498 | }; | |
2499 | ||
048e78a5 | 2500 | |
34cbe3a6 | 2501 | static const struct hda_verb cxt5066_init_verbs_hp_laptop[] = { |
048e78a5 DH |
2502 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x0}, |
2503 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | |
2504 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | |
2505 | { } /* end */ | |
2506 | }; | |
2507 | ||
0fb67e98 DD |
2508 | /* initialize jack-sensing, too */ |
2509 | static int cxt5066_init(struct hda_codec *codec) | |
2510 | { | |
4e76a883 | 2511 | codec_dbg(codec, "CXT5066: init\n"); |
0fb67e98 DD |
2512 | conexant_init(codec); |
2513 | if (codec->patch_ops.unsol_event) { | |
2514 | cxt5066_hp_automute(codec); | |
02b6b5b6 | 2515 | cxt5066_automic(codec); |
0fb67e98 | 2516 | } |
c4cfe66c | 2517 | cxt5066_set_mic_boost(codec); |
0fb67e98 DD |
2518 | return 0; |
2519 | } | |
2520 | ||
2521 | enum { | |
7b2bfdbc | 2522 | CXT5066_LAPTOP, /* Laptops w/ EAPD support */ |
0fb67e98 | 2523 | CXT5066_DELL_LAPTOP, /* Dell Laptop */ |
1feba3b7 | 2524 | CXT5066_DELL_VOSTRO, /* Dell Vostro 1015i */ |
cfd3d8dc | 2525 | CXT5066_IDEAPAD, /* Lenovo IdeaPad U150 */ |
7b2bfdbc | 2526 | CXT5066_THINKPAD, /* Lenovo ThinkPad T410s, others? */ |
a1d6906e | 2527 | CXT5066_ASUS, /* Asus K52JU, Lenovo G560 - Int mic at 0x1a and Ext mic at 0x1b */ |
048e78a5 | 2528 | CXT5066_HP_LAPTOP, /* HP Laptop */ |
fea4a4f9 | 2529 | CXT5066_AUTO, /* BIOS auto-parser */ |
0fb67e98 DD |
2530 | CXT5066_MODELS |
2531 | }; | |
2532 | ||
ea734963 | 2533 | static const char * const cxt5066_models[CXT5066_MODELS] = { |
7b2bfdbc | 2534 | [CXT5066_LAPTOP] = "laptop", |
0fb67e98 | 2535 | [CXT5066_DELL_LAPTOP] = "dell-laptop", |
1feba3b7 | 2536 | [CXT5066_DELL_VOSTRO] = "dell-vostro", |
cfd3d8dc | 2537 | [CXT5066_IDEAPAD] = "ideapad", |
7b2bfdbc | 2538 | [CXT5066_THINKPAD] = "thinkpad", |
a1d6906e | 2539 | [CXT5066_ASUS] = "asus", |
048e78a5 | 2540 | [CXT5066_HP_LAPTOP] = "hp-laptop", |
fea4a4f9 | 2541 | [CXT5066_AUTO] = "auto", |
0fb67e98 DD |
2542 | }; |
2543 | ||
34cbe3a6 | 2544 | static const struct snd_pci_quirk cxt5066_cfg_tbl[] = { |
00cd0bb7 | 2545 | SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD), |
1feba3b7 | 2546 | SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO), |
8a96b1e0 | 2547 | SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD), |
ca6cd851 | 2548 | SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO), |
231f50bc | 2549 | SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD), |
ebbd224c | 2550 | SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD), |
048e78a5 | 2551 | SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP), |
f6a2491c | 2552 | SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS), |
a1d6906e | 2553 | SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS), |
f6a2491c | 2554 | SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS), |
2ca9cac9 | 2555 | SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD), |
5637edb2 DH |
2556 | SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", |
2557 | CXT5066_LAPTOP), | |
4d155641 | 2558 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD), |
ef61d4e6 | 2559 | SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD), |
19593875 | 2560 | SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS), |
d2859fd4 | 2561 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo U350", CXT5066_ASUS), |
a1d6906e | 2562 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS), |
0fb67e98 DD |
2563 | {} |
2564 | }; | |
2565 | ||
2566 | static int patch_cxt5066(struct hda_codec *codec) | |
2567 | { | |
2568 | struct conexant_spec *spec; | |
2569 | int board_config; | |
2570 | ||
fea4a4f9 TI |
2571 | board_config = snd_hda_check_board_config(codec, CXT5066_MODELS, |
2572 | cxt5066_models, cxt5066_cfg_tbl); | |
fea4a4f9 | 2573 | if (board_config < 0) |
c82693db | 2574 | board_config = CXT5066_AUTO; /* model=auto as default */ |
fea4a4f9 TI |
2575 | if (board_config == CXT5066_AUTO) |
2576 | return patch_conexant_auto(codec); | |
2577 | ||
0fb67e98 DD |
2578 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
2579 | if (!spec) | |
2580 | return -ENOMEM; | |
2581 | codec->spec = spec; | |
2582 | ||
2583 | codec->patch_ops = conexant_patch_ops; | |
75f8991d | 2584 | codec->patch_ops.init = conexant_init; |
0fb67e98 DD |
2585 | |
2586 | spec->dell_automute = 0; | |
2587 | spec->multiout.max_channels = 2; | |
2588 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5066_dac_nids); | |
2589 | spec->multiout.dac_nids = cxt5066_dac_nids; | |
f6a2491c AR |
2590 | conexant_check_dig_outs(codec, cxt5066_digout_pin_nids, |
2591 | ARRAY_SIZE(cxt5066_digout_pin_nids)); | |
0fb67e98 DD |
2592 | spec->num_adc_nids = 1; |
2593 | spec->adc_nids = cxt5066_adc_nids; | |
2594 | spec->capsrc_nids = cxt5066_capsrc_nids; | |
2595 | spec->input_mux = &cxt5066_capture_source; | |
2596 | ||
2597 | spec->port_d_mode = PIN_HP; | |
2598 | ||
2599 | spec->num_init_verbs = 1; | |
2600 | spec->init_verbs[0] = cxt5066_init_verbs; | |
2601 | spec->num_channel_mode = ARRAY_SIZE(cxt5066_modes); | |
2602 | spec->channel_mode = cxt5066_modes; | |
2603 | spec->cur_adc = 0; | |
2604 | spec->cur_adc_idx = 0; | |
2605 | ||
3507e2a8 TI |
2606 | set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); |
2607 | ||
0fb67e98 DD |
2608 | switch (board_config) { |
2609 | default: | |
2610 | case CXT5066_LAPTOP: | |
2611 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; | |
2612 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | |
2613 | break; | |
2614 | case CXT5066_DELL_LAPTOP: | |
2615 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; | |
2616 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | |
2617 | ||
2618 | spec->port_d_mode = PIN_OUT; | |
2619 | spec->init_verbs[spec->num_init_verbs] = cxt5066_init_verbs_portd_lo; | |
2620 | spec->num_init_verbs++; | |
2621 | spec->dell_automute = 1; | |
2622 | break; | |
a1d6906e | 2623 | case CXT5066_ASUS: |
048e78a5 DH |
2624 | case CXT5066_HP_LAPTOP: |
2625 | codec->patch_ops.init = cxt5066_init; | |
02b6b5b6 | 2626 | codec->patch_ops.unsol_event = cxt5066_unsol_event; |
048e78a5 DH |
2627 | spec->init_verbs[spec->num_init_verbs] = |
2628 | cxt5066_init_verbs_hp_laptop; | |
2629 | spec->num_init_verbs++; | |
a1d6906e DH |
2630 | spec->hp_laptop = board_config == CXT5066_HP_LAPTOP; |
2631 | spec->asus = board_config == CXT5066_ASUS; | |
048e78a5 DH |
2632 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
2633 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | |
2634 | /* no S/PDIF out */ | |
f6a2491c AR |
2635 | if (board_config == CXT5066_HP_LAPTOP) |
2636 | spec->multiout.dig_out_nid = 0; | |
048e78a5 DH |
2637 | /* input source automatically selected */ |
2638 | spec->input_mux = NULL; | |
2639 | spec->port_d_mode = 0; | |
2640 | spec->mic_boost = 3; /* default 30dB gain */ | |
2641 | break; | |
2642 | ||
1feba3b7 | 2643 | case CXT5066_DELL_VOSTRO: |
75f8991d | 2644 | codec->patch_ops.init = cxt5066_init; |
02b6b5b6 | 2645 | codec->patch_ops.unsol_event = cxt5066_unsol_event; |
95a618bd | 2646 | spec->init_verbs[0] = cxt5066_init_verbs_vostro; |
3a00c660 | 2647 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
95a618bd | 2648 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
254bba6a | 2649 | spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers; |
95a618bd | 2650 | spec->port_d_mode = 0; |
254bba6a | 2651 | spec->dell_vostro = 1; |
c4cfe66c | 2652 | spec->mic_boost = 3; /* default 30dB gain */ |
95a618bd ER |
2653 | |
2654 | /* no S/PDIF out */ | |
2655 | spec->multiout.dig_out_nid = 0; | |
2656 | ||
cfd3d8dc GA |
2657 | /* input source automatically selected */ |
2658 | spec->input_mux = NULL; | |
2659 | break; | |
2660 | case CXT5066_IDEAPAD: | |
2661 | codec->patch_ops.init = cxt5066_init; | |
02b6b5b6 | 2662 | codec->patch_ops.unsol_event = cxt5066_unsol_event; |
cfd3d8dc GA |
2663 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
2664 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | |
2665 | spec->init_verbs[0] = cxt5066_init_verbs_ideapad; | |
2666 | spec->port_d_mode = 0; | |
2667 | spec->ideapad = 1; | |
2668 | spec->mic_boost = 2; /* default 20dB gain */ | |
2669 | ||
2670 | /* no S/PDIF out */ | |
2671 | spec->multiout.dig_out_nid = 0; | |
2672 | ||
7b2bfdbc JT |
2673 | /* input source automatically selected */ |
2674 | spec->input_mux = NULL; | |
2675 | break; | |
2676 | case CXT5066_THINKPAD: | |
2677 | codec->patch_ops.init = cxt5066_init; | |
02b6b5b6 | 2678 | codec->patch_ops.unsol_event = cxt5066_unsol_event; |
7b2bfdbc JT |
2679 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
2680 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | |
2681 | spec->init_verbs[0] = cxt5066_init_verbs_thinkpad; | |
2682 | spec->thinkpad = 1; | |
2683 | spec->port_d_mode = PIN_OUT; | |
2684 | spec->mic_boost = 2; /* default 20dB gain */ | |
2685 | ||
2686 | /* no S/PDIF out */ | |
2687 | spec->multiout.dig_out_nid = 0; | |
2688 | ||
0fb67e98 DD |
2689 | /* input source automatically selected */ |
2690 | spec->input_mux = NULL; | |
2691 | break; | |
2692 | } | |
2693 | ||
3507e2a8 | 2694 | if (spec->beep_amp) |
a86b1a2c | 2695 | snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); |
3507e2a8 | 2696 | |
0fb67e98 DD |
2697 | return 0; |
2698 | } | |
461e2c78 | 2699 | |
bf92d1d5 TI |
2700 | #endif /* ENABLE_CXT_STATIC_QUIRKS */ |
2701 | ||
2702 | ||
f2e5731d TI |
2703 | /* |
2704 | * Automatic parser for CX20641 & co | |
2705 | */ | |
2706 | ||
f2e5731d TI |
2707 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
2708 | static void cx_auto_parse_beep(struct hda_codec *codec) | |
6764bcef TI |
2709 | { |
2710 | struct conexant_spec *spec = codec->spec; | |
f2e5731d | 2711 | hda_nid_t nid, end_nid; |
f2e5731d | 2712 | |
f2e5731d TI |
2713 | end_nid = codec->start_nid + codec->num_nodes; |
2714 | for (nid = codec->start_nid; nid < end_nid; nid++) | |
2715 | if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) { | |
2716 | set_beep_amp(spec, nid, 0, HDA_OUTPUT); | |
f2e5731d TI |
2717 | break; |
2718 | } | |
f2e5731d | 2719 | } |
f2e5731d TI |
2720 | #else |
2721 | #define cx_auto_parse_beep(codec) | |
2722 | #endif | |
f2e5731d | 2723 | |
254f2968 | 2724 | /* parse EAPDs */ |
19110595 | 2725 | static void cx_auto_parse_eapd(struct hda_codec *codec) |
f2e5731d | 2726 | { |
19110595 | 2727 | struct conexant_spec *spec = codec->spec; |
f2e5731d | 2728 | hda_nid_t nid, end_nid; |
f2e5731d TI |
2729 | |
2730 | end_nid = codec->start_nid + codec->num_nodes; | |
2731 | for (nid = codec->start_nid; nid < end_nid; nid++) { | |
19110595 | 2732 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) |
468c5458 | 2733 | continue; |
19110595 | 2734 | if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)) |
f2e5731d | 2735 | continue; |
19110595 TI |
2736 | spec->eapds[spec->num_eapds++] = nid; |
2737 | if (spec->num_eapds >= ARRAY_SIZE(spec->eapds)) | |
03697e2a | 2738 | break; |
03697e2a TI |
2739 | } |
2740 | ||
254f2968 TI |
2741 | /* NOTE: below is a wild guess; if we have more than two EAPDs, |
2742 | * it's a new chip, where EAPDs are supposed to be associated to | |
2743 | * pins, and we can control EAPD per pin. | |
2744 | * OTOH, if only one or two EAPDs are found, it's an old chip, | |
2745 | * thus it might control over all pins. | |
2746 | */ | |
aed523f1 | 2747 | if (spec->num_eapds > 2) |
ff359b14 | 2748 | spec->dynamic_eapd = 1; |
f2e5731d TI |
2749 | } |
2750 | ||
da339866 | 2751 | static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins, |
da339866 | 2752 | hda_nid_t *pins, bool on) |
03697e2a TI |
2753 | { |
2754 | int i; | |
03697e2a | 2755 | for (i = 0; i < num_pins; i++) { |
f2e5731d TI |
2756 | if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD) |
2757 | snd_hda_codec_write(codec, pins[i], 0, | |
da339866 TI |
2758 | AC_VERB_SET_EAPD_BTLENABLE, |
2759 | on ? 0x02 : 0); | |
e2df82ff | 2760 | } |
03697e2a TI |
2761 | } |
2762 | ||
527c73ba TI |
2763 | /* turn on/off EAPD according to Master switch */ |
2764 | static void cx_auto_vmaster_hook(void *private_data, int enabled) | |
f2e5731d | 2765 | { |
527c73ba | 2766 | struct hda_codec *codec = private_data; |
f2e5731d | 2767 | struct conexant_spec *spec = codec->spec; |
f2e5731d | 2768 | |
527c73ba | 2769 | cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, enabled); |
03697e2a TI |
2770 | } |
2771 | ||
f2e5731d | 2772 | static int cx_auto_build_controls(struct hda_codec *codec) |
03697e2a | 2773 | { |
f2e5731d | 2774 | int err; |
03697e2a | 2775 | |
aed523f1 | 2776 | err = snd_hda_gen_build_controls(codec); |
f2e5731d TI |
2777 | if (err < 0) |
2778 | return err; | |
03697e2a | 2779 | |
aed523f1 | 2780 | err = add_beep_ctls(codec); |
31ef2257 TI |
2781 | if (err < 0) |
2782 | return err; | |
03697e2a | 2783 | |
03697e2a TI |
2784 | return 0; |
2785 | } | |
2786 | ||
ff359b14 TI |
2787 | static int cx_auto_init(struct hda_codec *codec) |
2788 | { | |
2789 | struct conexant_spec *spec = codec->spec; | |
2790 | snd_hda_gen_init(codec); | |
2791 | if (!spec->dynamic_eapd) | |
2792 | cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, true); | |
e4c3bce2 DH |
2793 | |
2794 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT); | |
2795 | ||
ff359b14 TI |
2796 | return 0; |
2797 | } | |
2798 | ||
8a02c0cc | 2799 | #define cx_auto_free snd_hda_gen_free |
08cf680c | 2800 | |
34cbe3a6 | 2801 | static const struct hda_codec_ops cx_auto_patch_ops = { |
f2e5731d | 2802 | .build_controls = cx_auto_build_controls, |
aed523f1 | 2803 | .build_pcms = snd_hda_gen_build_pcms, |
ff359b14 | 2804 | .init = cx_auto_init, |
08cf680c | 2805 | .free = cx_auto_free, |
29adc4b9 | 2806 | .unsol_event = snd_hda_jack_unsol_event, |
164a7ada TI |
2807 | #ifdef CONFIG_PM |
2808 | .check_power_status = snd_hda_gen_check_power_status, | |
2809 | #endif | |
f2e5731d | 2810 | }; |
f2e5731d | 2811 | |
e92d4b08 TI |
2812 | /* |
2813 | * pin fix-up | |
2814 | */ | |
18dcd304 DH |
2815 | enum { |
2816 | CXT_PINCFG_LENOVO_X200, | |
d3980110 | 2817 | CXT_PINCFG_LENOVO_TP410, |
239fb862 HC |
2818 | CXT_PINCFG_LEMOTE_A1004, |
2819 | CXT_PINCFG_LEMOTE_A1205, | |
18dcd304 | 2820 | CXT_FIXUP_STEREO_DMIC, |
239fb862 | 2821 | CXT_FIXUP_INC_MIC_BOOST, |
e4c3bce2 DH |
2822 | CXT_FIXUP_HEADPHONE_MIC_PIN, |
2823 | CXT_FIXUP_HEADPHONE_MIC, | |
4a437044 | 2824 | CXT_FIXUP_GPIO1, |
08cf680c | 2825 | CXT_FIXUP_THINKPAD_ACPI, |
3a00c660 | 2826 | CXT_FIXUP_OLPC_XO, |
ad7725d3 | 2827 | CXT_FIXUP_CAP_MIX_AMP, |
6dcbadef | 2828 | CXT_FIXUP_TOSHIBA_P105, |
e5eac90d | 2829 | CXT_FIXUP_HP_530, |
ea30e7df | 2830 | CXT_FIXUP_CAP_MIX_AMP_5047, |
03697e2a TI |
2831 | }; |
2832 | ||
b317b032 TI |
2833 | /* for hda_fixup_thinkpad_acpi() */ |
2834 | #include "thinkpad_helper.c" | |
08cf680c | 2835 | |
23d30f28 TI |
2836 | static void cxt_fixup_stereo_dmic(struct hda_codec *codec, |
2837 | const struct hda_fixup *fix, int action) | |
6764bcef | 2838 | { |
6764bcef | 2839 | struct conexant_spec *spec = codec->spec; |
aed523f1 | 2840 | spec->gen.inv_dmic_split = 1; |
6764bcef TI |
2841 | } |
2842 | ||
239fb862 HC |
2843 | static void cxt5066_increase_mic_boost(struct hda_codec *codec, |
2844 | const struct hda_fixup *fix, int action) | |
6764bcef | 2845 | { |
239fb862 HC |
2846 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
2847 | return; | |
6764bcef | 2848 | |
239fb862 HC |
2849 | snd_hda_override_amp_caps(codec, 0x17, HDA_OUTPUT, |
2850 | (0x3 << AC_AMPCAP_OFFSET_SHIFT) | | |
2851 | (0x4 << AC_AMPCAP_NUM_STEPS_SHIFT) | | |
2852 | (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | | |
2853 | (0 << AC_AMPCAP_MUTE_SHIFT)); | |
2854 | } | |
2855 | ||
e4c3bce2 DH |
2856 | static void cxt_update_headset_mode(struct hda_codec *codec) |
2857 | { | |
2858 | /* The verbs used in this function were tested on a Conexant CX20751/2 codec. */ | |
2859 | int i; | |
2860 | bool mic_mode = false; | |
2861 | struct conexant_spec *spec = codec->spec; | |
2862 | struct auto_pin_cfg *cfg = &spec->gen.autocfg; | |
2863 | ||
2864 | hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]]; | |
2865 | ||
2866 | for (i = 0; i < cfg->num_inputs; i++) | |
2867 | if (cfg->inputs[i].pin == mux_pin) { | |
2868 | mic_mode = !!cfg->inputs[i].is_headphone_mic; | |
2869 | break; | |
2870 | } | |
2871 | ||
2872 | if (mic_mode) { | |
2873 | snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x7c); /* enable merged mode for analog int-mic */ | |
2874 | spec->gen.hp_jack_present = false; | |
2875 | } else { | |
2876 | snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x54); /* disable merged mode for analog int-mic */ | |
2877 | spec->gen.hp_jack_present = snd_hda_jack_detect(codec, spec->gen.autocfg.hp_pins[0]); | |
2878 | } | |
2879 | ||
2880 | snd_hda_gen_update_outputs(codec); | |
2881 | } | |
2882 | ||
2883 | static void cxt_update_headset_mode_hook(struct hda_codec *codec, | |
7fe30711 TI |
2884 | struct snd_kcontrol *kcontrol, |
2885 | struct snd_ctl_elem_value *ucontrol) | |
e4c3bce2 DH |
2886 | { |
2887 | cxt_update_headset_mode(codec); | |
2888 | } | |
2889 | ||
2890 | static void cxt_fixup_headphone_mic(struct hda_codec *codec, | |
2891 | const struct hda_fixup *fix, int action) | |
2892 | { | |
2893 | struct conexant_spec *spec = codec->spec; | |
2894 | ||
2895 | switch (action) { | |
2896 | case HDA_FIXUP_ACT_PRE_PROBE: | |
2897 | spec->parse_flags |= HDA_PINCFG_HEADPHONE_MIC; | |
2898 | break; | |
2899 | case HDA_FIXUP_ACT_PROBE: | |
2900 | spec->gen.cap_sync_hook = cxt_update_headset_mode_hook; | |
2901 | spec->gen.automute_hook = cxt_update_headset_mode; | |
2902 | break; | |
2903 | case HDA_FIXUP_ACT_INIT: | |
2904 | cxt_update_headset_mode(codec); | |
2905 | break; | |
2906 | } | |
2907 | } | |
2908 | ||
3a00c660 TI |
2909 | /* OPLC XO 1.5 fixup */ |
2910 | ||
2911 | /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors) | |
2912 | * through the microphone jack. | |
2913 | * When the user enables this through a mixer switch, both internal and | |
2914 | * external microphones are disabled. Gain is fixed at 0dB. In this mode, | |
2915 | * we also allow the bias to be configured through a separate mixer | |
2916 | * control. */ | |
2917 | ||
2918 | #define update_mic_pin(codec, nid, val) \ | |
2919 | snd_hda_codec_update_cache(codec, nid, 0, \ | |
2920 | AC_VERB_SET_PIN_WIDGET_CONTROL, val) | |
2921 | ||
2922 | static const struct hda_input_mux olpc_xo_dc_bias = { | |
2923 | .num_items = 3, | |
2924 | .items = { | |
2925 | { "Off", PIN_IN }, | |
2926 | { "50%", PIN_VREF50 }, | |
2927 | { "80%", PIN_VREF80 }, | |
2928 | }, | |
2929 | }; | |
2930 | ||
2931 | static void olpc_xo_update_mic_boost(struct hda_codec *codec) | |
2932 | { | |
2933 | struct conexant_spec *spec = codec->spec; | |
2934 | int ch, val; | |
2935 | ||
2936 | for (ch = 0; ch < 2; ch++) { | |
2937 | val = AC_AMP_SET_OUTPUT | | |
2938 | (ch ? AC_AMP_SET_RIGHT : AC_AMP_SET_LEFT); | |
2939 | if (!spec->dc_enable) | |
2940 | val |= snd_hda_codec_amp_read(codec, 0x17, ch, HDA_OUTPUT, 0); | |
2941 | snd_hda_codec_write(codec, 0x17, 0, | |
2942 | AC_VERB_SET_AMP_GAIN_MUTE, val); | |
2943 | } | |
2944 | } | |
2945 | ||
2946 | static void olpc_xo_update_mic_pins(struct hda_codec *codec) | |
2947 | { | |
2948 | struct conexant_spec *spec = codec->spec; | |
2949 | int cur_input, val; | |
2950 | struct nid_path *path; | |
2951 | ||
2952 | cur_input = spec->gen.input_paths[0][spec->gen.cur_mux[0]]; | |
2953 | ||
2954 | /* Set up mic pins for port-B, C and F dynamically as the recording | |
2955 | * LED is turned on/off by these pin controls | |
2956 | */ | |
2957 | if (!spec->dc_enable) { | |
2958 | /* disable DC bias path and pin for port F */ | |
2959 | update_mic_pin(codec, 0x1e, 0); | |
2960 | snd_hda_activate_path(codec, spec->dc_mode_path, false, false); | |
2961 | ||
2962 | /* update port B (ext mic) and C (int mic) */ | |
2963 | /* OLPC defers mic widget control until when capture is | |
2964 | * started because the microphone LED comes on as soon as | |
2965 | * these settings are put in place. if we did this before | |
2966 | * recording, it would give the false indication that | |
2967 | * recording is happening when it is not. | |
2968 | */ | |
2969 | update_mic_pin(codec, 0x1a, spec->recording ? | |
2970 | snd_hda_codec_get_pin_target(codec, 0x1a) : 0); | |
2971 | update_mic_pin(codec, 0x1b, spec->recording ? | |
2972 | snd_hda_codec_get_pin_target(codec, 0x1b) : 0); | |
2973 | /* enable normal mic path */ | |
2974 | path = snd_hda_get_path_from_idx(codec, cur_input); | |
2975 | if (path) | |
2976 | snd_hda_activate_path(codec, path, true, false); | |
2977 | } else { | |
2978 | /* disable normal mic path */ | |
2979 | path = snd_hda_get_path_from_idx(codec, cur_input); | |
2980 | if (path) | |
2981 | snd_hda_activate_path(codec, path, false, false); | |
2982 | ||
2983 | /* Even though port F is the DC input, the bias is controlled | |
2984 | * on port B. We also leave that port as an active input (but | |
2985 | * unselected) in DC mode just in case that is necessary to | |
2986 | * make the bias setting take effect. | |
2987 | */ | |
2988 | if (spec->recording) | |
2989 | val = olpc_xo_dc_bias.items[spec->dc_input_bias].index; | |
2990 | else | |
2991 | val = 0; | |
2992 | update_mic_pin(codec, 0x1a, val); | |
2993 | update_mic_pin(codec, 0x1b, 0); | |
2994 | /* enable DC bias path and pin */ | |
2995 | update_mic_pin(codec, 0x1e, spec->recording ? PIN_IN : 0); | |
2996 | snd_hda_activate_path(codec, spec->dc_mode_path, true, false); | |
2997 | } | |
2998 | } | |
2999 | ||
3000 | /* mic_autoswitch hook */ | |
3001 | static void olpc_xo_automic(struct hda_codec *codec, struct hda_jack_tbl *jack) | |
3002 | { | |
3003 | struct conexant_spec *spec = codec->spec; | |
3004 | int saved_cached_write = codec->cached_write; | |
3005 | ||
3006 | codec->cached_write = 1; | |
3007 | /* in DC mode, we don't handle automic */ | |
3008 | if (!spec->dc_enable) | |
3009 | snd_hda_gen_mic_autoswitch(codec, jack); | |
3010 | olpc_xo_update_mic_pins(codec); | |
3011 | snd_hda_codec_flush_cache(codec); | |
3012 | codec->cached_write = saved_cached_write; | |
3013 | if (spec->dc_enable) | |
3014 | olpc_xo_update_mic_boost(codec); | |
3015 | } | |
3016 | ||
3017 | /* pcm_capture hook */ | |
3018 | static void olpc_xo_capture_hook(struct hda_pcm_stream *hinfo, | |
3019 | struct hda_codec *codec, | |
3020 | struct snd_pcm_substream *substream, | |
3021 | int action) | |
3022 | { | |
3023 | struct conexant_spec *spec = codec->spec; | |
3024 | ||
3025 | /* toggle spec->recording flag and update mic pins accordingly | |
3026 | * for turning on/off LED | |
3027 | */ | |
3028 | switch (action) { | |
3029 | case HDA_GEN_PCM_ACT_PREPARE: | |
3030 | spec->recording = 1; | |
3031 | olpc_xo_update_mic_pins(codec); | |
3032 | break; | |
3033 | case HDA_GEN_PCM_ACT_CLEANUP: | |
3034 | spec->recording = 0; | |
3035 | olpc_xo_update_mic_pins(codec); | |
3036 | break; | |
3037 | } | |
3038 | } | |
3039 | ||
3040 | static int olpc_xo_dc_mode_get(struct snd_kcontrol *kcontrol, | |
3041 | struct snd_ctl_elem_value *ucontrol) | |
3042 | { | |
3043 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3044 | struct conexant_spec *spec = codec->spec; | |
3045 | ucontrol->value.integer.value[0] = spec->dc_enable; | |
3046 | return 0; | |
3047 | } | |
3048 | ||
3049 | static int olpc_xo_dc_mode_put(struct snd_kcontrol *kcontrol, | |
3050 | struct snd_ctl_elem_value *ucontrol) | |
3051 | { | |
3052 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3053 | struct conexant_spec *spec = codec->spec; | |
3054 | int dc_enable = !!ucontrol->value.integer.value[0]; | |
3055 | ||
3056 | if (dc_enable == spec->dc_enable) | |
3057 | return 0; | |
3058 | ||
3059 | spec->dc_enable = dc_enable; | |
3060 | olpc_xo_update_mic_pins(codec); | |
3061 | olpc_xo_update_mic_boost(codec); | |
3062 | return 1; | |
3063 | } | |
3064 | ||
3065 | static int olpc_xo_dc_bias_enum_get(struct snd_kcontrol *kcontrol, | |
3066 | struct snd_ctl_elem_value *ucontrol) | |
3067 | { | |
3068 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3069 | struct conexant_spec *spec = codec->spec; | |
3070 | ucontrol->value.enumerated.item[0] = spec->dc_input_bias; | |
3071 | return 0; | |
3072 | } | |
3073 | ||
3074 | static int olpc_xo_dc_bias_enum_info(struct snd_kcontrol *kcontrol, | |
3075 | struct snd_ctl_elem_info *uinfo) | |
3076 | { | |
3077 | return snd_hda_input_mux_info(&olpc_xo_dc_bias, uinfo); | |
3078 | } | |
3079 | ||
3080 | static int olpc_xo_dc_bias_enum_put(struct snd_kcontrol *kcontrol, | |
3081 | struct snd_ctl_elem_value *ucontrol) | |
3082 | { | |
3083 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3084 | struct conexant_spec *spec = codec->spec; | |
3085 | const struct hda_input_mux *imux = &olpc_xo_dc_bias; | |
3086 | unsigned int idx; | |
3087 | ||
3088 | idx = ucontrol->value.enumerated.item[0]; | |
3089 | if (idx >= imux->num_items) | |
3090 | idx = imux->num_items - 1; | |
3091 | if (spec->dc_input_bias == idx) | |
3092 | return 0; | |
3093 | ||
3094 | spec->dc_input_bias = idx; | |
3095 | if (spec->dc_enable) | |
3096 | olpc_xo_update_mic_pins(codec); | |
3097 | return 1; | |
3098 | } | |
3099 | ||
3100 | static const struct snd_kcontrol_new olpc_xo_mixers[] = { | |
3101 | { | |
3102 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
3103 | .name = "DC Mode Enable Switch", | |
3104 | .info = snd_ctl_boolean_mono_info, | |
3105 | .get = olpc_xo_dc_mode_get, | |
3106 | .put = olpc_xo_dc_mode_put, | |
3107 | }, | |
3108 | { | |
3109 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
3110 | .name = "DC Input Bias Enum", | |
3111 | .info = olpc_xo_dc_bias_enum_info, | |
3112 | .get = olpc_xo_dc_bias_enum_get, | |
3113 | .put = olpc_xo_dc_bias_enum_put, | |
3114 | }, | |
3115 | {} | |
3116 | }; | |
3117 | ||
3118 | /* overriding mic boost put callback; update mic boost volume only when | |
3119 | * DC mode is disabled | |
3120 | */ | |
3121 | static int olpc_xo_mic_boost_put(struct snd_kcontrol *kcontrol, | |
3122 | struct snd_ctl_elem_value *ucontrol) | |
3123 | { | |
3124 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3125 | struct conexant_spec *spec = codec->spec; | |
3126 | int ret = snd_hda_mixer_amp_volume_put(kcontrol, ucontrol); | |
3127 | if (ret > 0 && spec->dc_enable) | |
3128 | olpc_xo_update_mic_boost(codec); | |
3129 | return ret; | |
3130 | } | |
3131 | ||
3132 | static void cxt_fixup_olpc_xo(struct hda_codec *codec, | |
3133 | const struct hda_fixup *fix, int action) | |
3134 | { | |
3135 | struct conexant_spec *spec = codec->spec; | |
3136 | int i; | |
3137 | ||
3138 | if (action != HDA_FIXUP_ACT_PROBE) | |
3139 | return; | |
3140 | ||
3141 | spec->gen.mic_autoswitch_hook = olpc_xo_automic; | |
3142 | spec->gen.pcm_capture_hook = olpc_xo_capture_hook; | |
3143 | spec->dc_mode_path = snd_hda_add_new_path(codec, 0x1e, 0x14, 0); | |
3144 | ||
3145 | snd_hda_add_new_ctls(codec, olpc_xo_mixers); | |
3146 | ||
3147 | /* OLPC's microphone port is DC coupled for use with external sensors, | |
3148 | * therefore we use a 50% mic bias in order to center the input signal | |
3149 | * with the DC input range of the codec. | |
3150 | */ | |
3151 | snd_hda_codec_set_pin_target(codec, 0x1a, PIN_VREF50); | |
3152 | ||
3153 | /* override mic boost control */ | |
3154 | for (i = 0; i < spec->gen.kctls.used; i++) { | |
3155 | struct snd_kcontrol_new *kctl = | |
3156 | snd_array_elem(&spec->gen.kctls, i); | |
3157 | if (!strcmp(kctl->name, "Mic Boost Volume")) { | |
3158 | kctl->put = olpc_xo_mic_boost_put; | |
3159 | break; | |
3160 | } | |
3161 | } | |
3162 | } | |
3163 | ||
ad7725d3 TI |
3164 | /* |
3165 | * Fix max input level on mixer widget to 0dB | |
3166 | * (originally it has 0x2b steps with 0dB offset 0x14) | |
3167 | */ | |
3168 | static void cxt_fixup_cap_mix_amp(struct hda_codec *codec, | |
3169 | const struct hda_fixup *fix, int action) | |
3170 | { | |
3171 | snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT, | |
3172 | (0x14 << AC_AMPCAP_OFFSET_SHIFT) | | |
3173 | (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) | | |
3174 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | | |
3175 | (1 << AC_AMPCAP_MUTE_SHIFT)); | |
3176 | } | |
e4c3bce2 | 3177 | |
ea30e7df TI |
3178 | /* |
3179 | * Fix max input level on mixer widget to 0dB | |
3180 | * (originally it has 0x1e steps with 0 dB offset 0x17) | |
3181 | */ | |
3182 | static void cxt_fixup_cap_mix_amp_5047(struct hda_codec *codec, | |
3183 | const struct hda_fixup *fix, int action) | |
3184 | { | |
3185 | snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT, | |
3186 | (0x17 << AC_AMPCAP_OFFSET_SHIFT) | | |
3187 | (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | | |
3188 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | | |
3189 | (1 << AC_AMPCAP_MUTE_SHIFT)); | |
3190 | } | |
3191 | ||
d70f3632 | 3192 | /* ThinkPad X200 & co with cxt5051 */ |
23d30f28 | 3193 | static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = { |
e92d4b08 TI |
3194 | { 0x16, 0x042140ff }, /* HP (seq# overridden) */ |
3195 | { 0x17, 0x21a11000 }, /* dock-mic */ | |
3196 | { 0x19, 0x2121103f }, /* dock-HP */ | |
3e93f5ef | 3197 | { 0x1c, 0x21440100 }, /* dock SPDIF out */ |
e92d4b08 TI |
3198 | {} |
3199 | }; | |
3200 | ||
d70f3632 | 3201 | /* ThinkPad 410/420/510/520, X201 & co with cxt5066 */ |
23d30f28 | 3202 | static const struct hda_pintbl cxt_pincfg_lenovo_tp410[] = { |
d70f3632 TI |
3203 | { 0x19, 0x042110ff }, /* HP (seq# overridden) */ |
3204 | { 0x1a, 0x21a190f0 }, /* dock-mic */ | |
3205 | { 0x1c, 0x212140ff }, /* dock-HP */ | |
3206 | {} | |
3207 | }; | |
3208 | ||
239fb862 HC |
3209 | /* Lemote A1004/A1205 with cxt5066 */ |
3210 | static const struct hda_pintbl cxt_pincfg_lemote[] = { | |
3211 | { 0x1a, 0x90a10020 }, /* Internal mic */ | |
3212 | { 0x1b, 0x03a11020 }, /* External mic */ | |
3213 | { 0x1d, 0x400101f0 }, /* Not used */ | |
3214 | { 0x1e, 0x40a701f0 }, /* Not used */ | |
3215 | { 0x20, 0x404501f0 }, /* Not used */ | |
3216 | { 0x22, 0x404401f0 }, /* Not used */ | |
3217 | { 0x23, 0x40a701f0 }, /* Not used */ | |
3218 | {} | |
3219 | }; | |
3220 | ||
23d30f28 TI |
3221 | static const struct hda_fixup cxt_fixups[] = { |
3222 | [CXT_PINCFG_LENOVO_X200] = { | |
3223 | .type = HDA_FIXUP_PINS, | |
3224 | .v.pins = cxt_pincfg_lenovo_x200, | |
3225 | }, | |
3226 | [CXT_PINCFG_LENOVO_TP410] = { | |
3227 | .type = HDA_FIXUP_PINS, | |
3228 | .v.pins = cxt_pincfg_lenovo_tp410, | |
08cf680c DH |
3229 | .chained = true, |
3230 | .chain_id = CXT_FIXUP_THINKPAD_ACPI, | |
23d30f28 | 3231 | }, |
239fb862 HC |
3232 | [CXT_PINCFG_LEMOTE_A1004] = { |
3233 | .type = HDA_FIXUP_PINS, | |
3234 | .chained = true, | |
3235 | .chain_id = CXT_FIXUP_INC_MIC_BOOST, | |
3236 | .v.pins = cxt_pincfg_lemote, | |
3237 | }, | |
3238 | [CXT_PINCFG_LEMOTE_A1205] = { | |
3239 | .type = HDA_FIXUP_PINS, | |
3240 | .v.pins = cxt_pincfg_lemote, | |
3241 | }, | |
23d30f28 TI |
3242 | [CXT_FIXUP_STEREO_DMIC] = { |
3243 | .type = HDA_FIXUP_FUNC, | |
3244 | .v.func = cxt_fixup_stereo_dmic, | |
3245 | }, | |
239fb862 HC |
3246 | [CXT_FIXUP_INC_MIC_BOOST] = { |
3247 | .type = HDA_FIXUP_FUNC, | |
3248 | .v.func = cxt5066_increase_mic_boost, | |
3249 | }, | |
e4c3bce2 DH |
3250 | [CXT_FIXUP_HEADPHONE_MIC_PIN] = { |
3251 | .type = HDA_FIXUP_PINS, | |
3252 | .chained = true, | |
3253 | .chain_id = CXT_FIXUP_HEADPHONE_MIC, | |
3254 | .v.pins = (const struct hda_pintbl[]) { | |
3255 | { 0x18, 0x03a1913d }, /* use as headphone mic, without its own jack detect */ | |
3256 | { } | |
3257 | } | |
3258 | }, | |
3259 | [CXT_FIXUP_HEADPHONE_MIC] = { | |
3260 | .type = HDA_FIXUP_FUNC, | |
3261 | .v.func = cxt_fixup_headphone_mic, | |
3262 | }, | |
4a437044 TI |
3263 | [CXT_FIXUP_GPIO1] = { |
3264 | .type = HDA_FIXUP_VERBS, | |
3265 | .v.verbs = (const struct hda_verb[]) { | |
3266 | { 0x01, AC_VERB_SET_GPIO_MASK, 0x01 }, | |
3267 | { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 }, | |
3268 | { 0x01, AC_VERB_SET_GPIO_DATA, 0x01 }, | |
3269 | { } | |
3270 | }, | |
3271 | }, | |
08cf680c DH |
3272 | [CXT_FIXUP_THINKPAD_ACPI] = { |
3273 | .type = HDA_FIXUP_FUNC, | |
b317b032 | 3274 | .v.func = hda_fixup_thinkpad_acpi, |
08cf680c | 3275 | }, |
3a00c660 TI |
3276 | [CXT_FIXUP_OLPC_XO] = { |
3277 | .type = HDA_FIXUP_FUNC, | |
3278 | .v.func = cxt_fixup_olpc_xo, | |
3279 | }, | |
ad7725d3 TI |
3280 | [CXT_FIXUP_CAP_MIX_AMP] = { |
3281 | .type = HDA_FIXUP_FUNC, | |
3282 | .v.func = cxt_fixup_cap_mix_amp, | |
3283 | }, | |
6dcbadef TI |
3284 | [CXT_FIXUP_TOSHIBA_P105] = { |
3285 | .type = HDA_FIXUP_PINS, | |
3286 | .v.pins = (const struct hda_pintbl[]) { | |
3287 | { 0x10, 0x961701f0 }, /* speaker/hp */ | |
3288 | { 0x12, 0x02a1901e }, /* ext mic */ | |
3289 | { 0x14, 0x95a70110 }, /* int mic */ | |
3290 | {} | |
3291 | }, | |
3292 | }, | |
e5eac90d TI |
3293 | [CXT_FIXUP_HP_530] = { |
3294 | .type = HDA_FIXUP_PINS, | |
3295 | .v.pins = (const struct hda_pintbl[]) { | |
3296 | { 0x12, 0x90a60160 }, /* int mic */ | |
3297 | {} | |
3298 | }, | |
3299 | .chained = true, | |
3300 | .chain_id = CXT_FIXUP_CAP_MIX_AMP, | |
3301 | }, | |
ea30e7df TI |
3302 | [CXT_FIXUP_CAP_MIX_AMP_5047] = { |
3303 | .type = HDA_FIXUP_FUNC, | |
3304 | .v.func = cxt_fixup_cap_mix_amp_5047, | |
3305 | }, | |
ad7725d3 TI |
3306 | }; |
3307 | ||
3308 | static const struct snd_pci_quirk cxt5045_fixups[] = { | |
e5eac90d | 3309 | SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT_FIXUP_HP_530), |
6dcbadef | 3310 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT_FIXUP_TOSHIBA_P105), |
ad7725d3 TI |
3311 | /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have |
3312 | * really bad sound over 0dB on NID 0x17. | |
3313 | */ | |
3314 | SND_PCI_QUIRK_VENDOR(0x103c, "HP", CXT_FIXUP_CAP_MIX_AMP), | |
3315 | SND_PCI_QUIRK_VENDOR(0x1631, "Packard Bell", CXT_FIXUP_CAP_MIX_AMP), | |
3316 | SND_PCI_QUIRK_VENDOR(0x1734, "Fujitsu", CXT_FIXUP_CAP_MIX_AMP), | |
3317 | SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", CXT_FIXUP_CAP_MIX_AMP), | |
3318 | {} | |
3319 | }; | |
3320 | ||
3321 | static const struct hda_model_fixup cxt5045_fixup_models[] = { | |
3322 | { .id = CXT_FIXUP_CAP_MIX_AMP, .name = "cap-mix-amp" }, | |
6dcbadef | 3323 | { .id = CXT_FIXUP_TOSHIBA_P105, .name = "toshiba-p105" }, |
e5eac90d | 3324 | { .id = CXT_FIXUP_HP_530, .name = "hp-530" }, |
ad7725d3 | 3325 | {} |
e92d4b08 TI |
3326 | }; |
3327 | ||
ea30e7df TI |
3328 | static const struct snd_pci_quirk cxt5047_fixups[] = { |
3329 | /* HP laptops have really bad sound over 0 dB on NID 0x10. | |
3330 | */ | |
3331 | SND_PCI_QUIRK_VENDOR(0x103c, "HP", CXT_FIXUP_CAP_MIX_AMP_5047), | |
3332 | {} | |
3333 | }; | |
3334 | ||
3335 | static const struct hda_model_fixup cxt5047_fixup_models[] = { | |
3336 | { .id = CXT_FIXUP_CAP_MIX_AMP_5047, .name = "cap-mix-amp" }, | |
3337 | {} | |
3338 | }; | |
3339 | ||
d70f3632 | 3340 | static const struct snd_pci_quirk cxt5051_fixups[] = { |
e92d4b08 TI |
3341 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200), |
3342 | {} | |
3343 | }; | |
3344 | ||
a2dd933d TI |
3345 | static const struct hda_model_fixup cxt5051_fixup_models[] = { |
3346 | { .id = CXT_PINCFG_LENOVO_X200, .name = "lenovo-x200" }, | |
3347 | {} | |
3348 | }; | |
3349 | ||
d70f3632 | 3350 | static const struct snd_pci_quirk cxt5066_fixups[] = { |
63a077e2 | 3351 | SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC), |
4a437044 | 3352 | SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT_FIXUP_GPIO1), |
e4c3bce2 | 3353 | SND_PCI_QUIRK(0x1043, 0x138d, "Asus", CXT_FIXUP_HEADPHONE_MIC_PIN), |
3a00c660 | 3354 | SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT_FIXUP_OLPC_XO), |
d70f3632 TI |
3355 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410), |
3356 | SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410), | |
3357 | SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410), | |
3358 | SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410), | |
3359 | SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410), | |
a555bb8c | 3360 | SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT_PINCFG_LENOVO_TP410), |
88d57606 | 3361 | SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT_PINCFG_LENOVO_TP410), |
18dcd304 | 3362 | SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC), |
e4db0952 | 3363 | SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC), |
b3c5dce8 | 3364 | SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC), |
2fd3f170 | 3365 | SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI), |
239fb862 HC |
3366 | SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004), |
3367 | SND_PCI_QUIRK(0x1c06, 0x2012, "Lemote A1205", CXT_PINCFG_LEMOTE_A1205), | |
e92d4b08 TI |
3368 | {} |
3369 | }; | |
3370 | ||
a2dd933d TI |
3371 | static const struct hda_model_fixup cxt5066_fixup_models[] = { |
3372 | { .id = CXT_FIXUP_STEREO_DMIC, .name = "stereo-dmic" }, | |
3373 | { .id = CXT_FIXUP_GPIO1, .name = "gpio1" }, | |
3374 | { .id = CXT_FIXUP_HEADPHONE_MIC_PIN, .name = "headphone-mic-pin" }, | |
3375 | { .id = CXT_PINCFG_LENOVO_TP410, .name = "tp410" }, | |
3376 | { .id = CXT_FIXUP_THINKPAD_ACPI, .name = "thinkpad" }, | |
3377 | { .id = CXT_PINCFG_LEMOTE_A1004, .name = "lemote-a1004" }, | |
3a00c660 | 3378 | { .id = CXT_FIXUP_OLPC_XO, .name = "olpc-xo" }, |
a2dd933d TI |
3379 | {} |
3380 | }; | |
3381 | ||
3868137e TI |
3382 | /* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches |
3383 | * can be created (bko#42825) | |
3384 | */ | |
3385 | static void add_cx5051_fake_mutes(struct hda_codec *codec) | |
3386 | { | |
3387 | static hda_nid_t out_nids[] = { | |
3388 | 0x10, 0x11, 0 | |
3389 | }; | |
3390 | hda_nid_t *p; | |
3391 | ||
3392 | for (p = out_nids; *p; p++) | |
3393 | snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT, | |
3394 | AC_AMPCAP_MIN_MUTE | | |
3395 | query_amp_caps(codec, *p, HDA_OUTPUT)); | |
3396 | } | |
3397 | ||
f2e5731d TI |
3398 | static int patch_conexant_auto(struct hda_codec *codec) |
3399 | { | |
3400 | struct conexant_spec *spec; | |
3401 | int err; | |
3402 | ||
4e76a883 | 3403 | codec_info(codec, "%s: BIOS auto-probing.\n", codec->chip_name); |
1f8458a2 | 3404 | |
f2e5731d TI |
3405 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
3406 | if (!spec) | |
3407 | return -ENOMEM; | |
aed523f1 | 3408 | snd_hda_gen_spec_init(&spec->gen); |
f2e5731d | 3409 | codec->spec = spec; |
e92d4b08 | 3410 | |
aed523f1 TI |
3411 | cx_auto_parse_beep(codec); |
3412 | cx_auto_parse_eapd(codec); | |
ff359b14 TI |
3413 | spec->gen.own_eapd_ctl = 1; |
3414 | if (spec->dynamic_eapd) | |
aed523f1 | 3415 | spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook; |
e92d4b08 | 3416 | |
6b452142 TI |
3417 | switch (codec->vendor_id) { |
3418 | case 0x14f15045: | |
4f32456e | 3419 | codec->single_adc_amp = 1; |
70540e24 | 3420 | spec->gen.mixer_nid = 0x17; |
d50ce6c0 | 3421 | spec->gen.add_stereo_mix_input = 1; |
ad7725d3 TI |
3422 | snd_hda_pick_fixup(codec, cxt5045_fixup_models, |
3423 | cxt5045_fixups, cxt_fixups); | |
6b452142 | 3424 | break; |
164a7ada TI |
3425 | case 0x14f15047: |
3426 | codec->pin_amp_workaround = 1; | |
3427 | spec->gen.mixer_nid = 0x19; | |
d50ce6c0 | 3428 | spec->gen.add_stereo_mix_input = 1; |
ea30e7df TI |
3429 | snd_hda_pick_fixup(codec, cxt5047_fixup_models, |
3430 | cxt5047_fixups, cxt_fixups); | |
164a7ada | 3431 | break; |
3868137e TI |
3432 | case 0x14f15051: |
3433 | add_cx5051_fake_mutes(codec); | |
51969d62 | 3434 | codec->pin_amp_workaround = 1; |
a2dd933d TI |
3435 | snd_hda_pick_fixup(codec, cxt5051_fixup_models, |
3436 | cxt5051_fixups, cxt_fixups); | |
3868137e | 3437 | break; |
51969d62 MK |
3438 | default: |
3439 | codec->pin_amp_workaround = 1; | |
a2dd933d TI |
3440 | snd_hda_pick_fixup(codec, cxt5066_fixup_models, |
3441 | cxt5066_fixups, cxt_fixups); | |
23d30f28 | 3442 | break; |
6b452142 TI |
3443 | } |
3444 | ||
f29735cb TI |
3445 | /* Show mute-led control only on HP laptops |
3446 | * This is a sort of white-list: on HP laptops, EAPD corresponds | |
3447 | * only to the mute-LED without actualy amp function. Meanwhile, | |
3448 | * others may use EAPD really as an amp switch, so it might be | |
3449 | * not good to expose it blindly. | |
527c73ba | 3450 | */ |
f29735cb TI |
3451 | switch (codec->subsystem_id >> 16) { |
3452 | case 0x103c: | |
aed523f1 | 3453 | spec->gen.vmaster_mute_enum = 1; |
f29735cb TI |
3454 | break; |
3455 | } | |
527c73ba | 3456 | |
aed523f1 TI |
3457 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
3458 | ||
e4c3bce2 DH |
3459 | err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, |
3460 | spec->parse_flags); | |
22ce5f74 | 3461 | if (err < 0) |
aed523f1 TI |
3462 | goto error; |
3463 | ||
3464 | err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); | |
3465 | if (err < 0) | |
3466 | goto error; | |
3467 | ||
f2e5731d | 3468 | codec->patch_ops = cx_auto_patch_ops; |
4f2864a4 TI |
3469 | |
3470 | /* Some laptops with Conexant chips show stalls in S3 resume, | |
3471 | * which falls into the single-cmd mode. | |
3472 | * Better to make reset, then. | |
3473 | */ | |
3474 | if (!codec->bus->sync_write) { | |
4e76a883 | 3475 | codec_info(codec, |
4f2864a4 TI |
3476 | "Enable sync_write for stable communication\n"); |
3477 | codec->bus->sync_write = 1; | |
3478 | codec->bus->allow_bus_reset = 1; | |
3479 | } | |
3480 | ||
e4c3bce2 DH |
3481 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
3482 | ||
f2e5731d | 3483 | return 0; |
aed523f1 TI |
3484 | |
3485 | error: | |
08cf680c | 3486 | cx_auto_free(codec); |
aed523f1 | 3487 | return err; |
f2e5731d TI |
3488 | } |
3489 | ||
bf92d1d5 TI |
3490 | #ifndef ENABLE_CXT_STATIC_QUIRKS |
3491 | #define patch_cxt5045 patch_conexant_auto | |
3492 | #define patch_cxt5047 patch_conexant_auto | |
3493 | #define patch_cxt5051 patch_conexant_auto | |
3494 | #define patch_cxt5066 patch_conexant_auto | |
3495 | #endif | |
3496 | ||
461e2c78 TI |
3497 | /* |
3498 | */ | |
3499 | ||
34cbe3a6 | 3500 | static const struct hda_codec_preset snd_hda_preset_conexant[] = { |
82f30040 TD |
3501 | { .id = 0x14f15045, .name = "CX20549 (Venice)", |
3502 | .patch = patch_cxt5045 }, | |
3503 | { .id = 0x14f15047, .name = "CX20551 (Waikiki)", | |
3504 | .patch = patch_cxt5047 }, | |
461e2c78 TI |
3505 | { .id = 0x14f15051, .name = "CX20561 (Hermosa)", |
3506 | .patch = patch_cxt5051 }, | |
0fb67e98 DD |
3507 | { .id = 0x14f15066, .name = "CX20582 (Pebble)", |
3508 | .patch = patch_cxt5066 }, | |
95a618bd ER |
3509 | { .id = 0x14f15067, .name = "CX20583 (Pebble HSF)", |
3510 | .patch = patch_cxt5066 }, | |
850eab9d TI |
3511 | { .id = 0x14f15068, .name = "CX20584", |
3512 | .patch = patch_cxt5066 }, | |
7b2bfdbc JT |
3513 | { .id = 0x14f15069, .name = "CX20585", |
3514 | .patch = patch_cxt5066 }, | |
f0ca89b0 DH |
3515 | { .id = 0x14f1506c, .name = "CX20588", |
3516 | .patch = patch_cxt5066 }, | |
6da8b516 DH |
3517 | { .id = 0x14f1506e, .name = "CX20590", |
3518 | .patch = patch_cxt5066 }, | |
f2e5731d TI |
3519 | { .id = 0x14f15097, .name = "CX20631", |
3520 | .patch = patch_conexant_auto }, | |
3521 | { .id = 0x14f15098, .name = "CX20632", | |
3522 | .patch = patch_conexant_auto }, | |
3523 | { .id = 0x14f150a1, .name = "CX20641", | |
3524 | .patch = patch_conexant_auto }, | |
3525 | { .id = 0x14f150a2, .name = "CX20642", | |
3526 | .patch = patch_conexant_auto }, | |
3527 | { .id = 0x14f150ab, .name = "CX20651", | |
3528 | .patch = patch_conexant_auto }, | |
3529 | { .id = 0x14f150ac, .name = "CX20652", | |
3530 | .patch = patch_conexant_auto }, | |
3531 | { .id = 0x14f150b8, .name = "CX20664", | |
3532 | .patch = patch_conexant_auto }, | |
3533 | { .id = 0x14f150b9, .name = "CX20665", | |
3534 | .patch = patch_conexant_auto }, | |
2d825fd8 TI |
3535 | { .id = 0x14f1510f, .name = "CX20751/2", |
3536 | .patch = patch_conexant_auto }, | |
3537 | { .id = 0x14f15110, .name = "CX20751/2", | |
3538 | .patch = patch_conexant_auto }, | |
3539 | { .id = 0x14f15111, .name = "CX20753/4", | |
3540 | .patch = patch_conexant_auto }, | |
42c364ac TI |
3541 | { .id = 0x14f15113, .name = "CX20755", |
3542 | .patch = patch_conexant_auto }, | |
3543 | { .id = 0x14f15114, .name = "CX20756", | |
3544 | .patch = patch_conexant_auto }, | |
3545 | { .id = 0x14f15115, .name = "CX20757", | |
3546 | .patch = patch_conexant_auto }, | |
8f42d769 TI |
3547 | { .id = 0x14f151d7, .name = "CX20952", |
3548 | .patch = patch_conexant_auto }, | |
c9b443d4 TD |
3549 | {} /* terminator */ |
3550 | }; | |
1289e9e8 TI |
3551 | |
3552 | MODULE_ALIAS("snd-hda-codec-id:14f15045"); | |
3553 | MODULE_ALIAS("snd-hda-codec-id:14f15047"); | |
3554 | MODULE_ALIAS("snd-hda-codec-id:14f15051"); | |
0fb67e98 | 3555 | MODULE_ALIAS("snd-hda-codec-id:14f15066"); |
95a618bd | 3556 | MODULE_ALIAS("snd-hda-codec-id:14f15067"); |
850eab9d | 3557 | MODULE_ALIAS("snd-hda-codec-id:14f15068"); |
7b2bfdbc | 3558 | MODULE_ALIAS("snd-hda-codec-id:14f15069"); |
f0ca89b0 | 3559 | MODULE_ALIAS("snd-hda-codec-id:14f1506c"); |
6da8b516 | 3560 | MODULE_ALIAS("snd-hda-codec-id:14f1506e"); |
f2e5731d TI |
3561 | MODULE_ALIAS("snd-hda-codec-id:14f15097"); |
3562 | MODULE_ALIAS("snd-hda-codec-id:14f15098"); | |
3563 | MODULE_ALIAS("snd-hda-codec-id:14f150a1"); | |
3564 | MODULE_ALIAS("snd-hda-codec-id:14f150a2"); | |
3565 | MODULE_ALIAS("snd-hda-codec-id:14f150ab"); | |
3566 | MODULE_ALIAS("snd-hda-codec-id:14f150ac"); | |
3567 | MODULE_ALIAS("snd-hda-codec-id:14f150b8"); | |
3568 | MODULE_ALIAS("snd-hda-codec-id:14f150b9"); | |
2d825fd8 TI |
3569 | MODULE_ALIAS("snd-hda-codec-id:14f1510f"); |
3570 | MODULE_ALIAS("snd-hda-codec-id:14f15110"); | |
3571 | MODULE_ALIAS("snd-hda-codec-id:14f15111"); | |
42c364ac TI |
3572 | MODULE_ALIAS("snd-hda-codec-id:14f15113"); |
3573 | MODULE_ALIAS("snd-hda-codec-id:14f15114"); | |
3574 | MODULE_ALIAS("snd-hda-codec-id:14f15115"); | |
8f42d769 | 3575 | MODULE_ALIAS("snd-hda-codec-id:14f151d7"); |
1289e9e8 TI |
3576 | |
3577 | MODULE_LICENSE("GPL"); | |
3578 | MODULE_DESCRIPTION("Conexant HD-audio codec"); | |
3579 | ||
3580 | static struct hda_codec_preset_list conexant_list = { | |
3581 | .preset = snd_hda_preset_conexant, | |
3582 | .owner = THIS_MODULE, | |
3583 | }; | |
3584 | ||
3585 | static int __init patch_conexant_init(void) | |
3586 | { | |
3587 | return snd_hda_add_codec_preset(&conexant_list); | |
3588 | } | |
3589 | ||
3590 | static void __exit patch_conexant_exit(void) | |
3591 | { | |
3592 | snd_hda_delete_codec_preset(&conexant_list); | |
3593 | } | |
3594 | ||
3595 | module_init(patch_conexant_init) | |
3596 | module_exit(patch_conexant_exit) |