Commit | Line | Data |
---|---|---|
c9b443d4 TD |
1 | /* |
2 | * HD audio interface patch for Conexant HDA audio codec | |
3 | * | |
4 | * Copyright (c) 2006 Pototskiy Akex <alex.pototskiy@gmail.com> | |
5 | * Takashi Iwai <tiwai@suse.de> | |
6 | * Tobin Davis <tdavis@dsl-only.net> | |
7 | * | |
8 | * This driver is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 2 of the License, or | |
11 | * (at your option) any later version. | |
12 | * | |
13 | * This driver is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | */ | |
22 | ||
c9b443d4 TD |
23 | #include <linux/init.h> |
24 | #include <linux/delay.h> | |
25 | #include <linux/slab.h> | |
26 | #include <linux/pci.h> | |
da155d5b | 27 | #include <linux/module.h> |
c9b443d4 | 28 | #include <sound/core.h> |
bc7a166d UD |
29 | #include <sound/jack.h> |
30 | ||
c9b443d4 TD |
31 | #include "hda_codec.h" |
32 | #include "hda_local.h" | |
c0f8faf0 | 33 | #include "hda_beep.h" |
1835a0f9 | 34 | #include "hda_jack.h" |
c9b443d4 TD |
35 | |
36 | #define CXT_PIN_DIR_IN 0x00 | |
37 | #define CXT_PIN_DIR_OUT 0x01 | |
38 | #define CXT_PIN_DIR_INOUT 0x02 | |
39 | #define CXT_PIN_DIR_IN_NOMICBIAS 0x03 | |
40 | #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04 | |
41 | ||
42 | #define CONEXANT_HP_EVENT 0x37 | |
43 | #define CONEXANT_MIC_EVENT 0x38 | |
03697e2a | 44 | #define CONEXANT_LINE_EVENT 0x39 |
c9b443d4 | 45 | |
bc7a166d UD |
46 | /* Conexant 5051 specific */ |
47 | ||
ecda0cff | 48 | #define CXT5051_SPDIF_OUT 0x12 |
bc7a166d UD |
49 | #define CXT5051_PORTB_EVENT 0x38 |
50 | #define CXT5051_PORTC_EVENT 0x39 | |
c9b443d4 | 51 | |
faddaa5d TI |
52 | #define AUTO_MIC_PORTB (1 << 1) |
53 | #define AUTO_MIC_PORTC (1 << 2) | |
c9b443d4 | 54 | |
f2e5731d TI |
55 | struct pin_dac_pair { |
56 | hda_nid_t pin; | |
57 | hda_nid_t dac; | |
58 | int type; | |
59 | }; | |
60 | ||
47ad1f4e TI |
61 | struct imux_info { |
62 | hda_nid_t pin; /* input pin NID */ | |
63 | hda_nid_t adc; /* connected ADC NID */ | |
64 | hda_nid_t boost; /* optional boost volume NID */ | |
65 | int index; /* corresponding to autocfg.input */ | |
66 | }; | |
67 | ||
c9b443d4 TD |
68 | struct conexant_spec { |
69 | ||
34cbe3a6 | 70 | const struct snd_kcontrol_new *mixers[5]; |
c9b443d4 | 71 | int num_mixers; |
dd5746a8 | 72 | hda_nid_t vmaster_nid; |
c9b443d4 TD |
73 | |
74 | const struct hda_verb *init_verbs[5]; /* initialization verbs | |
75 | * don't forget NULL | |
76 | * termination! | |
77 | */ | |
78 | unsigned int num_init_verbs; | |
79 | ||
80 | /* playback */ | |
81 | struct hda_multi_out multiout; /* playback set-up | |
82 | * max_channels, dacs must be set | |
83 | * dig_out_nid and hp_nid are optional | |
84 | */ | |
85 | unsigned int cur_eapd; | |
82f30040 | 86 | unsigned int hp_present; |
03697e2a | 87 | unsigned int line_present; |
faddaa5d | 88 | unsigned int auto_mic; |
f6100bb4 | 89 | int auto_mic_ext; /* imux_pins[] index for ext mic */ |
43c1b2e9 TI |
90 | int auto_mic_dock; /* imux_pins[] index for dock mic */ |
91 | int auto_mic_int; /* imux_pins[] index for int mic */ | |
c9b443d4 | 92 | unsigned int need_dac_fix; |
f6a2491c | 93 | hda_nid_t slave_dig_outs[2]; |
c9b443d4 TD |
94 | |
95 | /* capture */ | |
96 | unsigned int num_adc_nids; | |
34cbe3a6 | 97 | const hda_nid_t *adc_nids; |
c9b443d4 TD |
98 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
99 | ||
461e2c78 TI |
100 | unsigned int cur_adc_idx; |
101 | hda_nid_t cur_adc; | |
102 | unsigned int cur_adc_stream_tag; | |
103 | unsigned int cur_adc_format; | |
104 | ||
6764bcef TI |
105 | const struct hda_pcm_stream *capture_stream; |
106 | ||
c9b443d4 TD |
107 | /* capture source */ |
108 | const struct hda_input_mux *input_mux; | |
34cbe3a6 | 109 | const hda_nid_t *capsrc_nids; |
c9b443d4 TD |
110 | unsigned int cur_mux[3]; |
111 | ||
112 | /* channel model */ | |
113 | const struct hda_channel_mode *channel_mode; | |
114 | int num_channel_mode; | |
115 | ||
116 | /* PCM information */ | |
117 | struct hda_pcm pcm_rec[2]; /* used in build_pcms() */ | |
118 | ||
c9b443d4 TD |
119 | unsigned int spdif_route; |
120 | ||
121 | /* dynamic controls, init_verbs and input_mux */ | |
122 | struct auto_pin_cfg autocfg; | |
c9b443d4 | 123 | struct hda_input_mux private_imux; |
47ad1f4e | 124 | struct imux_info imux_info[HDA_MAX_NUM_INPUTS]; |
22ce5f74 | 125 | hda_nid_t private_adc_nids[HDA_MAX_NUM_INPUTS]; |
41923e44 | 126 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
f2e5731d TI |
127 | struct pin_dac_pair dac_info[8]; |
128 | int dac_info_filled; | |
c9b443d4 | 129 | |
0fb67e98 | 130 | unsigned int port_d_mode; |
f2e5731d | 131 | unsigned int auto_mute:1; /* used in auto-parser */ |
03697e2a TI |
132 | unsigned int detect_line:1; /* Line-out detection enabled */ |
133 | unsigned int automute_lines:1; /* automute line-out as well */ | |
134 | unsigned int automute_hp_lo:1; /* both HP and LO available */ | |
f2e5731d | 135 | unsigned int dell_automute:1; |
cfd3d8dc GA |
136 | unsigned int dell_vostro:1; |
137 | unsigned int ideapad:1; | |
7b2bfdbc | 138 | unsigned int thinkpad:1; |
048e78a5 | 139 | unsigned int hp_laptop:1; |
a1d6906e | 140 | unsigned int asus:1; |
254f2968 | 141 | unsigned int pin_eapd_ctrls:1; |
6b452142 | 142 | unsigned int single_adc_amp:1; |
75f8991d | 143 | |
6764bcef TI |
144 | unsigned int adc_switching:1; |
145 | ||
75f8991d DD |
146 | unsigned int ext_mic_present; |
147 | unsigned int recording; | |
148 | void (*capture_prepare)(struct hda_codec *codec); | |
149 | void (*capture_cleanup)(struct hda_codec *codec); | |
c4cfe66c DD |
150 | |
151 | /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors) | |
152 | * through the microphone jack. | |
153 | * When the user enables this through a mixer switch, both internal and | |
154 | * external microphones are disabled. Gain is fixed at 0dB. In this mode, | |
155 | * we also allow the bias to be configured through a separate mixer | |
156 | * control. */ | |
157 | unsigned int dc_enable; | |
158 | unsigned int dc_input_bias; /* offset into cxt5066_olpc_dc_bias */ | |
159 | unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */ | |
3507e2a8 TI |
160 | |
161 | unsigned int beep_amp; | |
19110595 TI |
162 | |
163 | /* extra EAPD pins */ | |
164 | unsigned int num_eapds; | |
165 | hda_nid_t eapds[4]; | |
c9b443d4 TD |
166 | }; |
167 | ||
168 | static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
169 | struct hda_codec *codec, | |
170 | struct snd_pcm_substream *substream) | |
171 | { | |
172 | struct conexant_spec *spec = codec->spec; | |
9a08160b TI |
173 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
174 | hinfo); | |
c9b443d4 TD |
175 | } |
176 | ||
177 | static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |
178 | struct hda_codec *codec, | |
179 | unsigned int stream_tag, | |
180 | unsigned int format, | |
181 | struct snd_pcm_substream *substream) | |
182 | { | |
183 | struct conexant_spec *spec = codec->spec; | |
184 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, | |
185 | stream_tag, | |
186 | format, substream); | |
187 | } | |
188 | ||
189 | static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
190 | struct hda_codec *codec, | |
191 | struct snd_pcm_substream *substream) | |
192 | { | |
193 | struct conexant_spec *spec = codec->spec; | |
194 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | |
195 | } | |
196 | ||
197 | /* | |
198 | * Digital out | |
199 | */ | |
200 | static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
201 | struct hda_codec *codec, | |
202 | struct snd_pcm_substream *substream) | |
203 | { | |
204 | struct conexant_spec *spec = codec->spec; | |
205 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | |
206 | } | |
207 | ||
208 | static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, | |
209 | struct hda_codec *codec, | |
210 | struct snd_pcm_substream *substream) | |
211 | { | |
212 | struct conexant_spec *spec = codec->spec; | |
213 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | |
214 | } | |
215 | ||
6b97eb45 TI |
216 | static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
217 | struct hda_codec *codec, | |
218 | unsigned int stream_tag, | |
219 | unsigned int format, | |
220 | struct snd_pcm_substream *substream) | |
221 | { | |
222 | struct conexant_spec *spec = codec->spec; | |
223 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, | |
224 | stream_tag, | |
225 | format, substream); | |
226 | } | |
227 | ||
c9b443d4 TD |
228 | /* |
229 | * Analog capture | |
230 | */ | |
231 | static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo, | |
232 | struct hda_codec *codec, | |
233 | unsigned int stream_tag, | |
234 | unsigned int format, | |
235 | struct snd_pcm_substream *substream) | |
236 | { | |
237 | struct conexant_spec *spec = codec->spec; | |
75f8991d DD |
238 | if (spec->capture_prepare) |
239 | spec->capture_prepare(codec); | |
c9b443d4 TD |
240 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
241 | stream_tag, 0, format); | |
242 | return 0; | |
243 | } | |
244 | ||
245 | static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
246 | struct hda_codec *codec, | |
247 | struct snd_pcm_substream *substream) | |
248 | { | |
249 | struct conexant_spec *spec = codec->spec; | |
888afa15 | 250 | snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]); |
75f8991d DD |
251 | if (spec->capture_cleanup) |
252 | spec->capture_cleanup(codec); | |
c9b443d4 TD |
253 | return 0; |
254 | } | |
255 | ||
256 | ||
257 | ||
34cbe3a6 | 258 | static const struct hda_pcm_stream conexant_pcm_analog_playback = { |
c9b443d4 TD |
259 | .substreams = 1, |
260 | .channels_min = 2, | |
261 | .channels_max = 2, | |
262 | .nid = 0, /* fill later */ | |
263 | .ops = { | |
264 | .open = conexant_playback_pcm_open, | |
265 | .prepare = conexant_playback_pcm_prepare, | |
266 | .cleanup = conexant_playback_pcm_cleanup | |
267 | }, | |
268 | }; | |
269 | ||
34cbe3a6 | 270 | static const struct hda_pcm_stream conexant_pcm_analog_capture = { |
c9b443d4 TD |
271 | .substreams = 1, |
272 | .channels_min = 2, | |
273 | .channels_max = 2, | |
274 | .nid = 0, /* fill later */ | |
275 | .ops = { | |
276 | .prepare = conexant_capture_pcm_prepare, | |
277 | .cleanup = conexant_capture_pcm_cleanup | |
278 | }, | |
279 | }; | |
280 | ||
281 | ||
34cbe3a6 | 282 | static const struct hda_pcm_stream conexant_pcm_digital_playback = { |
c9b443d4 TD |
283 | .substreams = 1, |
284 | .channels_min = 2, | |
285 | .channels_max = 2, | |
286 | .nid = 0, /* fill later */ | |
287 | .ops = { | |
288 | .open = conexant_dig_playback_pcm_open, | |
6b97eb45 TI |
289 | .close = conexant_dig_playback_pcm_close, |
290 | .prepare = conexant_dig_playback_pcm_prepare | |
c9b443d4 TD |
291 | }, |
292 | }; | |
293 | ||
34cbe3a6 | 294 | static const struct hda_pcm_stream conexant_pcm_digital_capture = { |
c9b443d4 TD |
295 | .substreams = 1, |
296 | .channels_min = 2, | |
297 | .channels_max = 2, | |
298 | /* NID is set in alc_build_pcms */ | |
299 | }; | |
300 | ||
461e2c78 TI |
301 | static int cx5051_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
302 | struct hda_codec *codec, | |
303 | unsigned int stream_tag, | |
304 | unsigned int format, | |
305 | struct snd_pcm_substream *substream) | |
306 | { | |
307 | struct conexant_spec *spec = codec->spec; | |
308 | spec->cur_adc = spec->adc_nids[spec->cur_adc_idx]; | |
309 | spec->cur_adc_stream_tag = stream_tag; | |
310 | spec->cur_adc_format = format; | |
311 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); | |
312 | return 0; | |
313 | } | |
314 | ||
315 | static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
316 | struct hda_codec *codec, | |
317 | struct snd_pcm_substream *substream) | |
318 | { | |
319 | struct conexant_spec *spec = codec->spec; | |
888afa15 | 320 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
461e2c78 TI |
321 | spec->cur_adc = 0; |
322 | return 0; | |
323 | } | |
324 | ||
34cbe3a6 | 325 | static const struct hda_pcm_stream cx5051_pcm_analog_capture = { |
461e2c78 TI |
326 | .substreams = 1, |
327 | .channels_min = 2, | |
328 | .channels_max = 2, | |
329 | .nid = 0, /* fill later */ | |
330 | .ops = { | |
331 | .prepare = cx5051_capture_pcm_prepare, | |
332 | .cleanup = cx5051_capture_pcm_cleanup | |
333 | }, | |
334 | }; | |
335 | ||
c9b443d4 TD |
336 | static int conexant_build_pcms(struct hda_codec *codec) |
337 | { | |
338 | struct conexant_spec *spec = codec->spec; | |
339 | struct hda_pcm *info = spec->pcm_rec; | |
340 | ||
341 | codec->num_pcms = 1; | |
342 | codec->pcm_info = info; | |
343 | ||
344 | info->name = "CONEXANT Analog"; | |
345 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback; | |
346 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = | |
347 | spec->multiout.max_channels; | |
348 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = | |
349 | spec->multiout.dac_nids[0]; | |
6764bcef TI |
350 | if (spec->capture_stream) |
351 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *spec->capture_stream; | |
352 | else { | |
353 | if (codec->vendor_id == 0x14f15051) | |
354 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
355 | cx5051_pcm_analog_capture; | |
356 | else { | |
357 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
358 | conexant_pcm_analog_capture; | |
359 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = | |
360 | spec->num_adc_nids; | |
361 | } | |
362 | } | |
c9b443d4 TD |
363 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
364 | ||
365 | if (spec->multiout.dig_out_nid) { | |
366 | info++; | |
367 | codec->num_pcms++; | |
368 | info->name = "Conexant Digital"; | |
7ba72ba1 | 369 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
c9b443d4 TD |
370 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
371 | conexant_pcm_digital_playback; | |
372 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = | |
373 | spec->multiout.dig_out_nid; | |
374 | if (spec->dig_in_nid) { | |
375 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
376 | conexant_pcm_digital_capture; | |
377 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = | |
378 | spec->dig_in_nid; | |
379 | } | |
f6a2491c AR |
380 | if (spec->slave_dig_outs[0]) |
381 | codec->slave_dig_outs = spec->slave_dig_outs; | |
c9b443d4 TD |
382 | } |
383 | ||
384 | return 0; | |
385 | } | |
386 | ||
387 | static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol, | |
388 | struct snd_ctl_elem_info *uinfo) | |
389 | { | |
390 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
391 | struct conexant_spec *spec = codec->spec; | |
392 | ||
393 | return snd_hda_input_mux_info(spec->input_mux, uinfo); | |
394 | } | |
395 | ||
396 | static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol, | |
397 | struct snd_ctl_elem_value *ucontrol) | |
398 | { | |
399 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
400 | struct conexant_spec *spec = codec->spec; | |
401 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
402 | ||
403 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; | |
404 | return 0; | |
405 | } | |
406 | ||
407 | static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol, | |
408 | struct snd_ctl_elem_value *ucontrol) | |
409 | { | |
410 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
411 | struct conexant_spec *spec = codec->spec; | |
412 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
413 | ||
414 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, | |
415 | spec->capsrc_nids[adc_idx], | |
416 | &spec->cur_mux[adc_idx]); | |
417 | } | |
418 | ||
4d7fbdbc TI |
419 | static void conexant_set_power(struct hda_codec *codec, hda_nid_t fg, |
420 | unsigned int power_state) | |
421 | { | |
422 | if (power_state == AC_PWRST_D3) | |
423 | msleep(100); | |
424 | snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, | |
425 | power_state); | |
426 | /* partial workaround for "azx_get_response timeout" */ | |
427 | if (power_state == AC_PWRST_D0) | |
428 | msleep(10); | |
429 | snd_hda_codec_set_power_to_all(codec, fg, power_state, true); | |
430 | } | |
431 | ||
c9b443d4 TD |
432 | static int conexant_init(struct hda_codec *codec) |
433 | { | |
434 | struct conexant_spec *spec = codec->spec; | |
435 | int i; | |
436 | ||
437 | for (i = 0; i < spec->num_init_verbs; i++) | |
438 | snd_hda_sequence_write(codec, spec->init_verbs[i]); | |
439 | return 0; | |
440 | } | |
441 | ||
442 | static void conexant_free(struct hda_codec *codec) | |
443 | { | |
c0f8faf0 | 444 | snd_hda_detach_beep_device(codec); |
c9b443d4 TD |
445 | kfree(codec->spec); |
446 | } | |
447 | ||
34cbe3a6 | 448 | static const struct snd_kcontrol_new cxt_capture_mixers[] = { |
b880c74a TI |
449 | { |
450 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
451 | .name = "Capture Source", | |
452 | .info = conexant_mux_enum_info, | |
453 | .get = conexant_mux_enum_get, | |
454 | .put = conexant_mux_enum_put | |
455 | }, | |
456 | {} | |
457 | }; | |
458 | ||
3507e2a8 TI |
459 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
460 | /* additional beep mixers; the actual parameters are overwritten at build */ | |
34cbe3a6 | 461 | static const struct snd_kcontrol_new cxt_beep_mixer[] = { |
3507e2a8 TI |
462 | HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT), |
463 | HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT), | |
464 | { } /* end */ | |
465 | }; | |
466 | #endif | |
467 | ||
ea734963 | 468 | static const char * const slave_vols[] = { |
dd5746a8 TI |
469 | "Headphone Playback Volume", |
470 | "Speaker Playback Volume", | |
a3a85d39 TI |
471 | "Front Playback Volume", |
472 | "Surround Playback Volume", | |
473 | "CLFE Playback Volume", | |
dd5746a8 TI |
474 | NULL |
475 | }; | |
476 | ||
ea734963 | 477 | static const char * const slave_sws[] = { |
dd5746a8 TI |
478 | "Headphone Playback Switch", |
479 | "Speaker Playback Switch", | |
a3a85d39 TI |
480 | "Front Playback Switch", |
481 | "Surround Playback Switch", | |
482 | "CLFE Playback Switch", | |
dd5746a8 TI |
483 | NULL |
484 | }; | |
485 | ||
c9b443d4 TD |
486 | static int conexant_build_controls(struct hda_codec *codec) |
487 | { | |
488 | struct conexant_spec *spec = codec->spec; | |
489 | unsigned int i; | |
490 | int err; | |
491 | ||
492 | for (i = 0; i < spec->num_mixers; i++) { | |
493 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | |
494 | if (err < 0) | |
495 | return err; | |
496 | } | |
497 | if (spec->multiout.dig_out_nid) { | |
498 | err = snd_hda_create_spdif_out_ctls(codec, | |
74b654c9 | 499 | spec->multiout.dig_out_nid, |
c9b443d4 TD |
500 | spec->multiout.dig_out_nid); |
501 | if (err < 0) | |
502 | return err; | |
9a08160b TI |
503 | err = snd_hda_create_spdif_share_sw(codec, |
504 | &spec->multiout); | |
505 | if (err < 0) | |
506 | return err; | |
507 | spec->multiout.share_spdif = 1; | |
c9b443d4 TD |
508 | } |
509 | if (spec->dig_in_nid) { | |
510 | err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid); | |
511 | if (err < 0) | |
512 | return err; | |
513 | } | |
dd5746a8 TI |
514 | |
515 | /* if we have no master control, let's create it */ | |
516 | if (spec->vmaster_nid && | |
517 | !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { | |
518 | unsigned int vmaster_tlv[4]; | |
519 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, | |
520 | HDA_OUTPUT, vmaster_tlv); | |
521 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", | |
522 | vmaster_tlv, slave_vols); | |
523 | if (err < 0) | |
524 | return err; | |
525 | } | |
526 | if (spec->vmaster_nid && | |
527 | !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { | |
528 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", | |
529 | NULL, slave_sws); | |
530 | if (err < 0) | |
531 | return err; | |
532 | } | |
533 | ||
b880c74a TI |
534 | if (spec->input_mux) { |
535 | err = snd_hda_add_new_ctls(codec, cxt_capture_mixers); | |
536 | if (err < 0) | |
537 | return err; | |
538 | } | |
539 | ||
3507e2a8 TI |
540 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
541 | /* create beep controls if needed */ | |
542 | if (spec->beep_amp) { | |
34cbe3a6 | 543 | const struct snd_kcontrol_new *knew; |
3507e2a8 TI |
544 | for (knew = cxt_beep_mixer; knew->name; knew++) { |
545 | struct snd_kcontrol *kctl; | |
546 | kctl = snd_ctl_new1(knew, codec); | |
547 | if (!kctl) | |
548 | return -ENOMEM; | |
549 | kctl->private_value = spec->beep_amp; | |
550 | err = snd_hda_ctl_add(codec, 0, kctl); | |
551 | if (err < 0) | |
552 | return err; | |
553 | } | |
554 | } | |
555 | #endif | |
556 | ||
c9b443d4 TD |
557 | return 0; |
558 | } | |
559 | ||
697c373e TI |
560 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
561 | static int conexant_suspend(struct hda_codec *codec, pm_message_t state) | |
562 | { | |
563 | snd_hda_shutup_pins(codec); | |
564 | return 0; | |
565 | } | |
566 | #endif | |
567 | ||
34cbe3a6 | 568 | static const struct hda_codec_ops conexant_patch_ops = { |
c9b443d4 TD |
569 | .build_controls = conexant_build_controls, |
570 | .build_pcms = conexant_build_pcms, | |
571 | .init = conexant_init, | |
572 | .free = conexant_free, | |
4d7fbdbc | 573 | .set_power_state = conexant_set_power, |
697c373e TI |
574 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
575 | .suspend = conexant_suspend, | |
576 | #endif | |
577 | .reboot_notify = snd_hda_shutup_pins, | |
c9b443d4 TD |
578 | }; |
579 | ||
3507e2a8 TI |
580 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
581 | #define set_beep_amp(spec, nid, idx, dir) \ | |
582 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) | |
583 | #else | |
584 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ | |
585 | #endif | |
586 | ||
6764bcef | 587 | static int patch_conexant_auto(struct hda_codec *codec); |
c9b443d4 TD |
588 | /* |
589 | * EAPD control | |
590 | * the private value = nid | (invert << 8) | |
591 | */ | |
592 | ||
a5ce8890 | 593 | #define cxt_eapd_info snd_ctl_boolean_mono_info |
c9b443d4 | 594 | |
82f30040 | 595 | static int cxt_eapd_get(struct snd_kcontrol *kcontrol, |
c9b443d4 TD |
596 | struct snd_ctl_elem_value *ucontrol) |
597 | { | |
598 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
599 | struct conexant_spec *spec = codec->spec; | |
600 | int invert = (kcontrol->private_value >> 8) & 1; | |
601 | if (invert) | |
602 | ucontrol->value.integer.value[0] = !spec->cur_eapd; | |
603 | else | |
604 | ucontrol->value.integer.value[0] = spec->cur_eapd; | |
605 | return 0; | |
82f30040 | 606 | |
c9b443d4 TD |
607 | } |
608 | ||
82f30040 | 609 | static int cxt_eapd_put(struct snd_kcontrol *kcontrol, |
c9b443d4 TD |
610 | struct snd_ctl_elem_value *ucontrol) |
611 | { | |
612 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
613 | struct conexant_spec *spec = codec->spec; | |
614 | int invert = (kcontrol->private_value >> 8) & 1; | |
615 | hda_nid_t nid = kcontrol->private_value & 0xff; | |
616 | unsigned int eapd; | |
82f30040 | 617 | |
68ea7b2f | 618 | eapd = !!ucontrol->value.integer.value[0]; |
c9b443d4 TD |
619 | if (invert) |
620 | eapd = !eapd; | |
82beb8fd | 621 | if (eapd == spec->cur_eapd) |
c9b443d4 | 622 | return 0; |
82f30040 | 623 | |
c9b443d4 | 624 | spec->cur_eapd = eapd; |
82beb8fd TI |
625 | snd_hda_codec_write_cache(codec, nid, |
626 | 0, AC_VERB_SET_EAPD_BTLENABLE, | |
627 | eapd ? 0x02 : 0x00); | |
c9b443d4 TD |
628 | return 1; |
629 | } | |
630 | ||
86d72bdf TI |
631 | /* controls for test mode */ |
632 | #ifdef CONFIG_SND_DEBUG | |
633 | ||
82f30040 TD |
634 | #define CXT_EAPD_SWITCH(xname, nid, mask) \ |
635 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
636 | .info = cxt_eapd_info, \ | |
637 | .get = cxt_eapd_get, \ | |
638 | .put = cxt_eapd_put, \ | |
639 | .private_value = nid | (mask<<16) } | |
640 | ||
641 | ||
642 | ||
c9b443d4 TD |
643 | static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol, |
644 | struct snd_ctl_elem_info *uinfo) | |
645 | { | |
646 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
647 | struct conexant_spec *spec = codec->spec; | |
648 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, | |
649 | spec->num_channel_mode); | |
650 | } | |
651 | ||
652 | static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol, | |
653 | struct snd_ctl_elem_value *ucontrol) | |
654 | { | |
655 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
656 | struct conexant_spec *spec = codec->spec; | |
657 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, | |
658 | spec->num_channel_mode, | |
659 | spec->multiout.max_channels); | |
660 | } | |
661 | ||
662 | static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol, | |
663 | struct snd_ctl_elem_value *ucontrol) | |
664 | { | |
665 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
666 | struct conexant_spec *spec = codec->spec; | |
667 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, | |
668 | spec->num_channel_mode, | |
669 | &spec->multiout.max_channels); | |
670 | if (err >= 0 && spec->need_dac_fix) | |
671 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; | |
672 | return err; | |
673 | } | |
674 | ||
675 | #define CXT_PIN_MODE(xname, nid, dir) \ | |
676 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
677 | .info = conexant_ch_mode_info, \ | |
678 | .get = conexant_ch_mode_get, \ | |
679 | .put = conexant_ch_mode_put, \ | |
680 | .private_value = nid | (dir<<16) } | |
681 | ||
86d72bdf TI |
682 | #endif /* CONFIG_SND_DEBUG */ |
683 | ||
c9b443d4 TD |
684 | /* Conexant 5045 specific */ |
685 | ||
34cbe3a6 TI |
686 | static const hda_nid_t cxt5045_dac_nids[1] = { 0x19 }; |
687 | static const hda_nid_t cxt5045_adc_nids[1] = { 0x1a }; | |
688 | static const hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a }; | |
cbef9789 | 689 | #define CXT5045_SPDIF_OUT 0x18 |
c9b443d4 | 690 | |
34cbe3a6 | 691 | static const struct hda_channel_mode cxt5045_modes[1] = { |
5cd57529 TD |
692 | { 2, NULL }, |
693 | }; | |
c9b443d4 | 694 | |
34cbe3a6 | 695 | static const struct hda_input_mux cxt5045_capture_source = { |
c9b443d4 TD |
696 | .num_items = 2, |
697 | .items = { | |
82f30040 | 698 | { "IntMic", 0x1 }, |
f4beee94 | 699 | { "ExtMic", 0x2 }, |
c9b443d4 TD |
700 | } |
701 | }; | |
702 | ||
34cbe3a6 | 703 | static const struct hda_input_mux cxt5045_capture_source_benq = { |
22e14130 | 704 | .num_items = 5, |
5218c892 JZ |
705 | .items = { |
706 | { "IntMic", 0x1 }, | |
707 | { "ExtMic", 0x2 }, | |
708 | { "LineIn", 0x3 }, | |
22e14130 LM |
709 | { "CD", 0x4 }, |
710 | { "Mixer", 0x0 }, | |
5218c892 JZ |
711 | } |
712 | }; | |
713 | ||
34cbe3a6 | 714 | static const struct hda_input_mux cxt5045_capture_source_hp530 = { |
2de3c232 J |
715 | .num_items = 2, |
716 | .items = { | |
717 | { "ExtMic", 0x1 }, | |
718 | { "IntMic", 0x2 }, | |
719 | } | |
720 | }; | |
721 | ||
c9b443d4 TD |
722 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
723 | static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
724 | struct snd_ctl_elem_value *ucontrol) | |
725 | { | |
726 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
727 | struct conexant_spec *spec = codec->spec; | |
82f30040 | 728 | unsigned int bits; |
c9b443d4 | 729 | |
82f30040 | 730 | if (!cxt_eapd_put(kcontrol, ucontrol)) |
c9b443d4 TD |
731 | return 0; |
732 | ||
82f30040 TD |
733 | /* toggle internal speakers mute depending of presence of |
734 | * the headphone jack | |
735 | */ | |
47fd830a TI |
736 | bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; |
737 | snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, | |
738 | HDA_AMP_MUTE, bits); | |
7f29673b | 739 | |
47fd830a TI |
740 | bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; |
741 | snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0, | |
742 | HDA_AMP_MUTE, bits); | |
c9b443d4 TD |
743 | return 1; |
744 | } | |
745 | ||
746 | /* bind volumes of both NID 0x10 and 0x11 */ | |
34cbe3a6 | 747 | static const struct hda_bind_ctls cxt5045_hp_bind_master_vol = { |
cca3b371 TI |
748 | .ops = &snd_hda_bind_vol, |
749 | .values = { | |
750 | HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT), | |
751 | HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT), | |
752 | 0 | |
753 | }, | |
754 | }; | |
c9b443d4 | 755 | |
7f29673b TD |
756 | /* toggle input of built-in and mic jack appropriately */ |
757 | static void cxt5045_hp_automic(struct hda_codec *codec) | |
758 | { | |
34cbe3a6 | 759 | static const struct hda_verb mic_jack_on[] = { |
7f29673b TD |
760 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
761 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
762 | {} | |
763 | }; | |
34cbe3a6 | 764 | static const struct hda_verb mic_jack_off[] = { |
7f29673b TD |
765 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
766 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
767 | {} | |
768 | }; | |
769 | unsigned int present; | |
770 | ||
d56757ab | 771 | present = snd_hda_jack_detect(codec, 0x12); |
7f29673b TD |
772 | if (present) |
773 | snd_hda_sequence_write(codec, mic_jack_on); | |
774 | else | |
775 | snd_hda_sequence_write(codec, mic_jack_off); | |
776 | } | |
777 | ||
c9b443d4 TD |
778 | |
779 | /* mute internal speaker if HP is plugged */ | |
780 | static void cxt5045_hp_automute(struct hda_codec *codec) | |
781 | { | |
82f30040 | 782 | struct conexant_spec *spec = codec->spec; |
dd87da1c | 783 | unsigned int bits; |
c9b443d4 | 784 | |
d56757ab | 785 | spec->hp_present = snd_hda_jack_detect(codec, 0x11); |
dd87da1c | 786 | |
47fd830a TI |
787 | bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; |
788 | snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, | |
789 | HDA_AMP_MUTE, bits); | |
c9b443d4 TD |
790 | } |
791 | ||
792 | /* unsolicited event for HP jack sensing */ | |
793 | static void cxt5045_hp_unsol_event(struct hda_codec *codec, | |
794 | unsigned int res) | |
795 | { | |
796 | res >>= 26; | |
797 | switch (res) { | |
798 | case CONEXANT_HP_EVENT: | |
799 | cxt5045_hp_automute(codec); | |
800 | break; | |
7f29673b TD |
801 | case CONEXANT_MIC_EVENT: |
802 | cxt5045_hp_automic(codec); | |
803 | break; | |
804 | ||
c9b443d4 TD |
805 | } |
806 | } | |
807 | ||
34cbe3a6 | 808 | static const struct snd_kcontrol_new cxt5045_mixers[] = { |
28c4edb7 DH |
809 | HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x1a, 0x01, HDA_INPUT), |
810 | HDA_CODEC_MUTE("Internal Mic Capture Switch", 0x1a, 0x01, HDA_INPUT), | |
8607f7c4 DH |
811 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x1a, 0x02, HDA_INPUT), |
812 | HDA_CODEC_MUTE("Mic Capture Switch", 0x1a, 0x02, HDA_INPUT), | |
c8229c38 TI |
813 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), |
814 | HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), | |
28c4edb7 DH |
815 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT), |
816 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT), | |
8607f7c4 DH |
817 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT), |
818 | HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT), | |
cca3b371 | 819 | HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol), |
c9b443d4 TD |
820 | { |
821 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
822 | .name = "Master Playback Switch", | |
82f30040 TD |
823 | .info = cxt_eapd_info, |
824 | .get = cxt_eapd_get, | |
c9b443d4 | 825 | .put = cxt5045_hp_master_sw_put, |
82f30040 | 826 | .private_value = 0x10, |
c9b443d4 TD |
827 | }, |
828 | ||
829 | {} | |
830 | }; | |
831 | ||
34cbe3a6 | 832 | static const struct snd_kcontrol_new cxt5045_benq_mixers[] = { |
22e14130 LM |
833 | HDA_CODEC_VOLUME("CD Capture Volume", 0x1a, 0x04, HDA_INPUT), |
834 | HDA_CODEC_MUTE("CD Capture Switch", 0x1a, 0x04, HDA_INPUT), | |
835 | HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x4, HDA_INPUT), | |
836 | HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x4, HDA_INPUT), | |
837 | ||
5218c892 JZ |
838 | HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT), |
839 | HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT), | |
840 | HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT), | |
841 | HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT), | |
842 | ||
22e14130 LM |
843 | HDA_CODEC_VOLUME("Mixer Capture Volume", 0x1a, 0x0, HDA_INPUT), |
844 | HDA_CODEC_MUTE("Mixer Capture Switch", 0x1a, 0x0, HDA_INPUT), | |
845 | ||
5218c892 JZ |
846 | {} |
847 | }; | |
848 | ||
34cbe3a6 | 849 | static const struct snd_kcontrol_new cxt5045_mixers_hp530[] = { |
28c4edb7 DH |
850 | HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x1a, 0x02, HDA_INPUT), |
851 | HDA_CODEC_MUTE("Internal Mic Capture Switch", 0x1a, 0x02, HDA_INPUT), | |
8607f7c4 DH |
852 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x1a, 0x01, HDA_INPUT), |
853 | HDA_CODEC_MUTE("Mic Capture Switch", 0x1a, 0x01, HDA_INPUT), | |
2de3c232 J |
854 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), |
855 | HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), | |
28c4edb7 DH |
856 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT), |
857 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x2, HDA_INPUT), | |
8607f7c4 DH |
858 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x1, HDA_INPUT), |
859 | HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x1, HDA_INPUT), | |
2de3c232 J |
860 | HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol), |
861 | { | |
862 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
863 | .name = "Master Playback Switch", | |
864 | .info = cxt_eapd_info, | |
865 | .get = cxt_eapd_get, | |
866 | .put = cxt5045_hp_master_sw_put, | |
867 | .private_value = 0x10, | |
868 | }, | |
869 | ||
870 | {} | |
871 | }; | |
872 | ||
34cbe3a6 | 873 | static const struct hda_verb cxt5045_init_verbs[] = { |
c9b443d4 | 874 | /* Line in, Mic */ |
4090dffb | 875 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, |
7f29673b | 876 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, |
c9b443d4 | 877 | /* HP, Amp */ |
c8229c38 TI |
878 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
879 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, | |
880 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
881 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, | |
882 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
883 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
884 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
885 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
886 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
28c4edb7 | 887 | /* Record selector: Internal mic */ |
7f29673b | 888 | {0x1a, AC_VERB_SET_CONNECT_SEL,0x1}, |
82f30040 | 889 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, |
c9b443d4 TD |
890 | AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, |
891 | /* SPDIF route: PCM */ | |
cbef9789 | 892 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
c9b443d4 | 893 | { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
c9b443d4 | 894 | /* EAPD */ |
82f30040 | 895 | {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */ |
c9b443d4 TD |
896 | { } /* end */ |
897 | }; | |
898 | ||
34cbe3a6 | 899 | static const struct hda_verb cxt5045_benq_init_verbs[] = { |
28c4edb7 | 900 | /* Internal Mic, Mic */ |
5218c892 JZ |
901 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, |
902 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, | |
903 | /* Line In,HP, Amp */ | |
904 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
905 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, | |
906 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
907 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, | |
908 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
909 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
910 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
911 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
912 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
28c4edb7 | 913 | /* Record selector: Internal mic */ |
5218c892 JZ |
914 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x1}, |
915 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, | |
916 | AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, | |
917 | /* SPDIF route: PCM */ | |
cbef9789 | 918 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
5218c892 JZ |
919 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, |
920 | /* EAPD */ | |
921 | {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
922 | { } /* end */ | |
923 | }; | |
7f29673b | 924 | |
34cbe3a6 | 925 | static const struct hda_verb cxt5045_hp_sense_init_verbs[] = { |
7f29673b TD |
926 | /* pin sensing on HP jack */ |
927 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | |
d3091fad | 928 | { } /* end */ |
7f29673b TD |
929 | }; |
930 | ||
34cbe3a6 | 931 | static const struct hda_verb cxt5045_mic_sense_init_verbs[] = { |
7f29673b TD |
932 | /* pin sensing on HP jack */ |
933 | {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | |
d3091fad | 934 | { } /* end */ |
7f29673b TD |
935 | }; |
936 | ||
c9b443d4 TD |
937 | #ifdef CONFIG_SND_DEBUG |
938 | /* Test configuration for debugging, modelled after the ALC260 test | |
939 | * configuration. | |
940 | */ | |
34cbe3a6 | 941 | static const struct hda_input_mux cxt5045_test_capture_source = { |
c9b443d4 TD |
942 | .num_items = 5, |
943 | .items = { | |
944 | { "MIXER", 0x0 }, | |
945 | { "MIC1 pin", 0x1 }, | |
946 | { "LINE1 pin", 0x2 }, | |
947 | { "HP-OUT pin", 0x3 }, | |
948 | { "CD pin", 0x4 }, | |
949 | }, | |
950 | }; | |
951 | ||
34cbe3a6 | 952 | static const struct snd_kcontrol_new cxt5045_test_mixer[] = { |
c9b443d4 TD |
953 | |
954 | /* Output controls */ | |
c9b443d4 TD |
955 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT), |
956 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT), | |
7f29673b TD |
957 | HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
958 | HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT), | |
959 | HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT), | |
960 | HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT), | |
c9b443d4 TD |
961 | |
962 | /* Modes for retasking pin widgets */ | |
963 | CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT), | |
964 | CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT), | |
965 | ||
82f30040 TD |
966 | /* EAPD Switch Control */ |
967 | CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0), | |
968 | ||
c9b443d4 | 969 | /* Loopback mixer controls */ |
7f29673b TD |
970 | |
971 | HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT), | |
972 | HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT), | |
973 | HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT), | |
974 | HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT), | |
975 | HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT), | |
976 | HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT), | |
977 | HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT), | |
978 | HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT), | |
979 | HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT), | |
980 | HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT), | |
c9b443d4 TD |
981 | { |
982 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
983 | .name = "Input Source", | |
984 | .info = conexant_mux_enum_info, | |
985 | .get = conexant_mux_enum_get, | |
986 | .put = conexant_mux_enum_put, | |
987 | }, | |
fb3409e7 TD |
988 | /* Audio input controls */ |
989 | HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT), | |
990 | HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT), | |
991 | HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT), | |
992 | HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT), | |
993 | HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT), | |
994 | HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT), | |
995 | HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT), | |
996 | HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT), | |
997 | HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT), | |
998 | HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT), | |
c9b443d4 TD |
999 | { } /* end */ |
1000 | }; | |
1001 | ||
34cbe3a6 | 1002 | static const struct hda_verb cxt5045_test_init_verbs[] = { |
7f29673b TD |
1003 | /* Set connections */ |
1004 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 }, | |
1005 | { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 }, | |
1006 | { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 }, | |
c9b443d4 TD |
1007 | /* Enable retasking pins as output, initially without power amp */ |
1008 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7f29673b | 1009 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
c9b443d4 TD |
1010 | |
1011 | /* Disable digital (SPDIF) pins initially, but users can enable | |
1012 | * them via a mixer switch. In the case of SPDIF-out, this initverb | |
1013 | * payload also sets the generation to 0, output to be in "consumer" | |
1014 | * PCM format, copyright asserted, no pre-emphasis and no validity | |
1015 | * control. | |
1016 | */ | |
cbef9789 TI |
1017 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1018 | {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
c9b443d4 TD |
1019 | |
1020 | /* Start with output sum widgets muted and their output gains at min */ | |
1021 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
1022 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1023 | ||
1024 | /* Unmute retasking pin widget output buffers since the default | |
1025 | * state appears to be output. As the pin mode is changed by the | |
1026 | * user the pin mode control will take care of enabling the pin's | |
1027 | * input/output buffers as needed. | |
1028 | */ | |
1029 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1030 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1031 | ||
1032 | /* Mute capture amp left and right */ | |
1033 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
1034 | ||
1035 | /* Set ADC connection select to match default mixer setting (mic1 | |
1036 | * pin) | |
1037 | */ | |
1038 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7f29673b | 1039 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x00}, |
c9b443d4 TD |
1040 | |
1041 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
1042 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */ | |
1043 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */ | |
1044 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */ | |
1045 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */ | |
1046 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
1047 | ||
1048 | { } | |
1049 | }; | |
1050 | #endif | |
1051 | ||
1052 | ||
1053 | /* initialize jack-sensing, too */ | |
1054 | static int cxt5045_init(struct hda_codec *codec) | |
1055 | { | |
1056 | conexant_init(codec); | |
1057 | cxt5045_hp_automute(codec); | |
1058 | return 0; | |
1059 | } | |
1060 | ||
1061 | ||
1062 | enum { | |
15908c36 MB |
1063 | CXT5045_LAPTOP_HPSENSE, |
1064 | CXT5045_LAPTOP_MICSENSE, | |
1065 | CXT5045_LAPTOP_HPMICSENSE, | |
5218c892 | 1066 | CXT5045_BENQ, |
2de3c232 | 1067 | CXT5045_LAPTOP_HP530, |
c9b443d4 TD |
1068 | #ifdef CONFIG_SND_DEBUG |
1069 | CXT5045_TEST, | |
1070 | #endif | |
1f8458a2 | 1071 | CXT5045_AUTO, |
f5fcc13c | 1072 | CXT5045_MODELS |
c9b443d4 TD |
1073 | }; |
1074 | ||
ea734963 | 1075 | static const char * const cxt5045_models[CXT5045_MODELS] = { |
15908c36 MB |
1076 | [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense", |
1077 | [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense", | |
1078 | [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense", | |
1079 | [CXT5045_BENQ] = "benq", | |
2de3c232 | 1080 | [CXT5045_LAPTOP_HP530] = "laptop-hp530", |
c9b443d4 | 1081 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 1082 | [CXT5045_TEST] = "test", |
c9b443d4 | 1083 | #endif |
1f8458a2 | 1084 | [CXT5045_AUTO] = "auto", |
f5fcc13c TI |
1085 | }; |
1086 | ||
34cbe3a6 | 1087 | static const struct snd_pci_quirk cxt5045_cfg_tbl[] = { |
2de3c232 | 1088 | SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530), |
6a9dccd6 | 1089 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE), |
5218c892 | 1090 | SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ), |
15908c36 MB |
1091 | SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE), |
1092 | SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE), | |
9e464154 TI |
1093 | SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505", |
1094 | CXT5045_LAPTOP_HPMICSENSE), | |
15908c36 MB |
1095 | SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE), |
1096 | SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE), | |
1097 | SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE), | |
dea0a509 TI |
1098 | SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell", |
1099 | CXT5045_LAPTOP_HPMICSENSE), | |
15908c36 | 1100 | SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE), |
c9b443d4 TD |
1101 | {} |
1102 | }; | |
1103 | ||
1104 | static int patch_cxt5045(struct hda_codec *codec) | |
1105 | { | |
1106 | struct conexant_spec *spec; | |
1107 | int board_config; | |
1108 | ||
1f8458a2 TI |
1109 | board_config = snd_hda_check_board_config(codec, CXT5045_MODELS, |
1110 | cxt5045_models, | |
1111 | cxt5045_cfg_tbl); | |
1112 | if (board_config < 0) | |
c82693db | 1113 | board_config = CXT5045_AUTO; /* model=auto as default */ |
1f8458a2 TI |
1114 | if (board_config == CXT5045_AUTO) |
1115 | return patch_conexant_auto(codec); | |
1116 | ||
c9b443d4 TD |
1117 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1118 | if (!spec) | |
1119 | return -ENOMEM; | |
c9b443d4 | 1120 | codec->spec = spec; |
9421f954 | 1121 | codec->pin_amp_workaround = 1; |
c9b443d4 TD |
1122 | |
1123 | spec->multiout.max_channels = 2; | |
1124 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids); | |
1125 | spec->multiout.dac_nids = cxt5045_dac_nids; | |
1126 | spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT; | |
1127 | spec->num_adc_nids = 1; | |
1128 | spec->adc_nids = cxt5045_adc_nids; | |
1129 | spec->capsrc_nids = cxt5045_capsrc_nids; | |
1130 | spec->input_mux = &cxt5045_capture_source; | |
1131 | spec->num_mixers = 1; | |
1132 | spec->mixers[0] = cxt5045_mixers; | |
1133 | spec->num_init_verbs = 1; | |
1134 | spec->init_verbs[0] = cxt5045_init_verbs; | |
1135 | spec->spdif_route = 0; | |
3507e2a8 TI |
1136 | spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes); |
1137 | spec->channel_mode = cxt5045_modes; | |
5cd57529 | 1138 | |
3507e2a8 | 1139 | set_beep_amp(spec, 0x16, 0, 1); |
c9b443d4 TD |
1140 | |
1141 | codec->patch_ops = conexant_patch_ops; | |
c9b443d4 | 1142 | |
c9b443d4 | 1143 | switch (board_config) { |
15908c36 | 1144 | case CXT5045_LAPTOP_HPSENSE: |
7f29673b TD |
1145 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; |
1146 | spec->input_mux = &cxt5045_capture_source; | |
1147 | spec->num_init_verbs = 2; | |
1148 | spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; | |
1149 | spec->mixers[0] = cxt5045_mixers; | |
1150 | codec->patch_ops.init = cxt5045_init; | |
1151 | break; | |
15908c36 | 1152 | case CXT5045_LAPTOP_MICSENSE: |
86376df6 | 1153 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; |
c9b443d4 TD |
1154 | spec->input_mux = &cxt5045_capture_source; |
1155 | spec->num_init_verbs = 2; | |
7f29673b | 1156 | spec->init_verbs[1] = cxt5045_mic_sense_init_verbs; |
c9b443d4 TD |
1157 | spec->mixers[0] = cxt5045_mixers; |
1158 | codec->patch_ops.init = cxt5045_init; | |
1159 | break; | |
15908c36 MB |
1160 | default: |
1161 | case CXT5045_LAPTOP_HPMICSENSE: | |
1162 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; | |
1163 | spec->input_mux = &cxt5045_capture_source; | |
1164 | spec->num_init_verbs = 3; | |
1165 | spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; | |
1166 | spec->init_verbs[2] = cxt5045_mic_sense_init_verbs; | |
1167 | spec->mixers[0] = cxt5045_mixers; | |
1168 | codec->patch_ops.init = cxt5045_init; | |
1169 | break; | |
5218c892 JZ |
1170 | case CXT5045_BENQ: |
1171 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; | |
1172 | spec->input_mux = &cxt5045_capture_source_benq; | |
1173 | spec->num_init_verbs = 1; | |
1174 | spec->init_verbs[0] = cxt5045_benq_init_verbs; | |
1175 | spec->mixers[0] = cxt5045_mixers; | |
1176 | spec->mixers[1] = cxt5045_benq_mixers; | |
1177 | spec->num_mixers = 2; | |
1178 | codec->patch_ops.init = cxt5045_init; | |
1179 | break; | |
2de3c232 J |
1180 | case CXT5045_LAPTOP_HP530: |
1181 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; | |
1182 | spec->input_mux = &cxt5045_capture_source_hp530; | |
1183 | spec->num_init_verbs = 2; | |
1184 | spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; | |
1185 | spec->mixers[0] = cxt5045_mixers_hp530; | |
1186 | codec->patch_ops.init = cxt5045_init; | |
1187 | break; | |
c9b443d4 TD |
1188 | #ifdef CONFIG_SND_DEBUG |
1189 | case CXT5045_TEST: | |
1190 | spec->input_mux = &cxt5045_test_capture_source; | |
1191 | spec->mixers[0] = cxt5045_test_mixer; | |
1192 | spec->init_verbs[0] = cxt5045_test_init_verbs; | |
15908c36 MB |
1193 | break; |
1194 | ||
c9b443d4 TD |
1195 | #endif |
1196 | } | |
48ecb7e8 | 1197 | |
031005f7 TI |
1198 | switch (codec->subsystem_id >> 16) { |
1199 | case 0x103c: | |
8f0f5ff6 | 1200 | case 0x1631: |
0b587fc4 | 1201 | case 0x1734: |
0ebf9e36 DC |
1202 | case 0x17aa: |
1203 | /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have | |
1204 | * really bad sound over 0dB on NID 0x17. Fix max PCM level to | |
1205 | * 0 dB (originally it has 0x2b steps with 0dB offset 0x14) | |
031005f7 TI |
1206 | */ |
1207 | snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT, | |
1208 | (0x14 << AC_AMPCAP_OFFSET_SHIFT) | | |
1209 | (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) | | |
1210 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | | |
1211 | (1 << AC_AMPCAP_MUTE_SHIFT)); | |
1212 | break; | |
1213 | } | |
48ecb7e8 | 1214 | |
3507e2a8 TI |
1215 | if (spec->beep_amp) |
1216 | snd_hda_attach_beep_device(codec, spec->beep_amp); | |
1217 | ||
c9b443d4 TD |
1218 | return 0; |
1219 | } | |
1220 | ||
1221 | ||
1222 | /* Conexant 5047 specific */ | |
82f30040 | 1223 | #define CXT5047_SPDIF_OUT 0x11 |
c9b443d4 | 1224 | |
34cbe3a6 TI |
1225 | static const hda_nid_t cxt5047_dac_nids[1] = { 0x10 }; /* 0x1c */ |
1226 | static const hda_nid_t cxt5047_adc_nids[1] = { 0x12 }; | |
1227 | static const hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a }; | |
c9b443d4 | 1228 | |
34cbe3a6 | 1229 | static const struct hda_channel_mode cxt5047_modes[1] = { |
5cd57529 TD |
1230 | { 2, NULL }, |
1231 | }; | |
c9b443d4 | 1232 | |
34cbe3a6 | 1233 | static const struct hda_input_mux cxt5047_toshiba_capture_source = { |
82f30040 TD |
1234 | .num_items = 2, |
1235 | .items = { | |
1236 | { "ExtMic", 0x2 }, | |
1237 | { "Line-In", 0x1 }, | |
c9b443d4 TD |
1238 | } |
1239 | }; | |
1240 | ||
1241 | /* turn on/off EAPD (+ mute HP) as a master switch */ | |
1242 | static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
1243 | struct snd_ctl_elem_value *ucontrol) | |
1244 | { | |
1245 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1246 | struct conexant_spec *spec = codec->spec; | |
82f30040 | 1247 | unsigned int bits; |
c9b443d4 | 1248 | |
82f30040 | 1249 | if (!cxt_eapd_put(kcontrol, ucontrol)) |
c9b443d4 TD |
1250 | return 0; |
1251 | ||
82f30040 TD |
1252 | /* toggle internal speakers mute depending of presence of |
1253 | * the headphone jack | |
1254 | */ | |
47fd830a | 1255 | bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; |
3b7523fc TI |
1256 | /* NOTE: Conexat codec needs the index for *OUTPUT* amp of |
1257 | * pin widgets unlike other codecs. In this case, we need to | |
1258 | * set index 0x01 for the volume from the mixer amp 0x19. | |
1259 | */ | |
5d75bc55 | 1260 | snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, |
47fd830a TI |
1261 | HDA_AMP_MUTE, bits); |
1262 | bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; | |
1263 | snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0, | |
1264 | HDA_AMP_MUTE, bits); | |
c9b443d4 TD |
1265 | return 1; |
1266 | } | |
1267 | ||
c9b443d4 TD |
1268 | /* mute internal speaker if HP is plugged */ |
1269 | static void cxt5047_hp_automute(struct hda_codec *codec) | |
1270 | { | |
82f30040 | 1271 | struct conexant_spec *spec = codec->spec; |
dd87da1c | 1272 | unsigned int bits; |
c9b443d4 | 1273 | |
d56757ab | 1274 | spec->hp_present = snd_hda_jack_detect(codec, 0x13); |
dd87da1c | 1275 | |
47fd830a | 1276 | bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; |
3b7523fc | 1277 | /* See the note in cxt5047_hp_master_sw_put */ |
5d75bc55 | 1278 | snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, |
47fd830a | 1279 | HDA_AMP_MUTE, bits); |
c9b443d4 TD |
1280 | } |
1281 | ||
1282 | /* toggle input of built-in and mic jack appropriately */ | |
1283 | static void cxt5047_hp_automic(struct hda_codec *codec) | |
1284 | { | |
34cbe3a6 | 1285 | static const struct hda_verb mic_jack_on[] = { |
9f113e0e MB |
1286 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1287 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
c9b443d4 TD |
1288 | {} |
1289 | }; | |
34cbe3a6 | 1290 | static const struct hda_verb mic_jack_off[] = { |
9f113e0e MB |
1291 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1292 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
c9b443d4 TD |
1293 | {} |
1294 | }; | |
1295 | unsigned int present; | |
1296 | ||
d56757ab | 1297 | present = snd_hda_jack_detect(codec, 0x15); |
c9b443d4 TD |
1298 | if (present) |
1299 | snd_hda_sequence_write(codec, mic_jack_on); | |
1300 | else | |
1301 | snd_hda_sequence_write(codec, mic_jack_off); | |
1302 | } | |
1303 | ||
1304 | /* unsolicited event for HP jack sensing */ | |
1305 | static void cxt5047_hp_unsol_event(struct hda_codec *codec, | |
1306 | unsigned int res) | |
1307 | { | |
9f113e0e | 1308 | switch (res >> 26) { |
c9b443d4 TD |
1309 | case CONEXANT_HP_EVENT: |
1310 | cxt5047_hp_automute(codec); | |
1311 | break; | |
1312 | case CONEXANT_MIC_EVENT: | |
1313 | cxt5047_hp_automic(codec); | |
1314 | break; | |
1315 | } | |
1316 | } | |
1317 | ||
34cbe3a6 | 1318 | static const struct snd_kcontrol_new cxt5047_base_mixers[] = { |
df481e41 TI |
1319 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT), |
1320 | HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT), | |
5f99f86a | 1321 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), |
c9b443d4 TD |
1322 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), |
1323 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), | |
1324 | HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), | |
1325 | HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), | |
82f30040 TD |
1326 | { |
1327 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1328 | .name = "Master Playback Switch", | |
1329 | .info = cxt_eapd_info, | |
1330 | .get = cxt_eapd_get, | |
c9b443d4 TD |
1331 | .put = cxt5047_hp_master_sw_put, |
1332 | .private_value = 0x13, | |
1333 | }, | |
1334 | ||
1335 | {} | |
1336 | }; | |
1337 | ||
34cbe3a6 | 1338 | static const struct snd_kcontrol_new cxt5047_hp_spk_mixers[] = { |
3b7523fc | 1339 | /* See the note in cxt5047_hp_master_sw_put */ |
5d75bc55 | 1340 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT), |
df481e41 TI |
1341 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT), |
1342 | {} | |
1343 | }; | |
1344 | ||
34cbe3a6 | 1345 | static const struct snd_kcontrol_new cxt5047_hp_only_mixers[] = { |
c9b443d4 | 1346 | HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT), |
c9b443d4 TD |
1347 | { } /* end */ |
1348 | }; | |
1349 | ||
34cbe3a6 | 1350 | static const struct hda_verb cxt5047_init_verbs[] = { |
c9b443d4 TD |
1351 | /* Line in, Mic, Built-in Mic */ |
1352 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1353 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, | |
1354 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, | |
7f29673b | 1355 | /* HP, Speaker */ |
b7589ceb | 1356 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
5b3a7440 TI |
1357 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, /* mixer(0x19) */ |
1358 | {0x1d, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mixer(0x19) */ | |
7f29673b | 1359 | /* Record selector: Mic */ |
c9b443d4 TD |
1360 | {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, |
1361 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, | |
1362 | AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, | |
7f29673b TD |
1363 | {0x1A, AC_VERB_SET_CONNECT_SEL,0x02}, |
1364 | {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, | |
1365 | AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00}, | |
1366 | {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, | |
1367 | AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03}, | |
c9b443d4 TD |
1368 | /* SPDIF route: PCM */ |
1369 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 }, | |
82f30040 TD |
1370 | /* Enable unsolicited events */ |
1371 | {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | |
1372 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | |
c9b443d4 TD |
1373 | { } /* end */ |
1374 | }; | |
1375 | ||
1376 | /* configuration for Toshiba Laptops */ | |
34cbe3a6 | 1377 | static const struct hda_verb cxt5047_toshiba_init_verbs[] = { |
3b628867 | 1378 | {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0}, /* default off */ |
c9b443d4 TD |
1379 | {} |
1380 | }; | |
1381 | ||
1382 | /* Test configuration for debugging, modelled after the ALC260 test | |
1383 | * configuration. | |
1384 | */ | |
1385 | #ifdef CONFIG_SND_DEBUG | |
34cbe3a6 | 1386 | static const struct hda_input_mux cxt5047_test_capture_source = { |
82f30040 | 1387 | .num_items = 4, |
c9b443d4 | 1388 | .items = { |
82f30040 TD |
1389 | { "LINE1 pin", 0x0 }, |
1390 | { "MIC1 pin", 0x1 }, | |
1391 | { "MIC2 pin", 0x2 }, | |
1392 | { "CD pin", 0x3 }, | |
c9b443d4 TD |
1393 | }, |
1394 | }; | |
1395 | ||
34cbe3a6 | 1396 | static const struct snd_kcontrol_new cxt5047_test_mixer[] = { |
c9b443d4 TD |
1397 | |
1398 | /* Output only controls */ | |
82f30040 TD |
1399 | HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT), |
1400 | HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT), | |
1401 | HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT), | |
1402 | HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT), | |
c9b443d4 TD |
1403 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT), |
1404 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT), | |
1405 | HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT), | |
1406 | HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT), | |
82f30040 TD |
1407 | HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT), |
1408 | HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
1409 | HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
1410 | HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
c9b443d4 TD |
1411 | |
1412 | /* Modes for retasking pin widgets */ | |
1413 | CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT), | |
1414 | CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT), | |
1415 | ||
82f30040 TD |
1416 | /* EAPD Switch Control */ |
1417 | CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0), | |
c9b443d4 | 1418 | |
82f30040 TD |
1419 | /* Loopback mixer controls */ |
1420 | HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT), | |
1421 | HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT), | |
1422 | HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT), | |
1423 | HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT), | |
1424 | HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT), | |
1425 | HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT), | |
1426 | HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT), | |
1427 | HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT), | |
1428 | ||
1429 | HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT), | |
1430 | HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT), | |
1431 | HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT), | |
1432 | HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT), | |
1433 | HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT), | |
1434 | HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT), | |
1435 | HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT), | |
1436 | HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT), | |
c9b443d4 TD |
1437 | { |
1438 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1439 | .name = "Input Source", | |
1440 | .info = conexant_mux_enum_info, | |
1441 | .get = conexant_mux_enum_get, | |
1442 | .put = conexant_mux_enum_put, | |
1443 | }, | |
854206b0 | 1444 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), |
9f113e0e | 1445 | |
c9b443d4 TD |
1446 | { } /* end */ |
1447 | }; | |
1448 | ||
34cbe3a6 | 1449 | static const struct hda_verb cxt5047_test_init_verbs[] = { |
c9b443d4 TD |
1450 | /* Enable retasking pins as output, initially without power amp */ |
1451 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1452 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1453 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1454 | ||
1455 | /* Disable digital (SPDIF) pins initially, but users can enable | |
1456 | * them via a mixer switch. In the case of SPDIF-out, this initverb | |
1457 | * payload also sets the generation to 0, output to be in "consumer" | |
1458 | * PCM format, copyright asserted, no pre-emphasis and no validity | |
1459 | * control. | |
1460 | */ | |
1461 | {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
1462 | ||
1463 | /* Ensure mic1, mic2, line1 pin widgets take input from the | |
1464 | * OUT1 sum bus when acting as an output. | |
1465 | */ | |
1466 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0}, | |
1467 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0}, | |
1468 | ||
1469 | /* Start with output sum widgets muted and their output gains at min */ | |
1470 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
1471 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1472 | ||
1473 | /* Unmute retasking pin widget output buffers since the default | |
1474 | * state appears to be output. As the pin mode is changed by the | |
1475 | * user the pin mode control will take care of enabling the pin's | |
1476 | * input/output buffers as needed. | |
1477 | */ | |
1478 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1479 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1480 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1481 | ||
1482 | /* Mute capture amp left and right */ | |
1483 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
1484 | ||
1485 | /* Set ADC connection select to match default mixer setting (mic1 | |
1486 | * pin) | |
1487 | */ | |
1488 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1489 | ||
1490 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
1491 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
1492 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
1493 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
1494 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
1495 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
1496 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
1497 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
1498 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
1499 | ||
1500 | { } | |
1501 | }; | |
1502 | #endif | |
1503 | ||
1504 | ||
1505 | /* initialize jack-sensing, too */ | |
1506 | static int cxt5047_hp_init(struct hda_codec *codec) | |
1507 | { | |
1508 | conexant_init(codec); | |
1509 | cxt5047_hp_automute(codec); | |
c9b443d4 TD |
1510 | return 0; |
1511 | } | |
1512 | ||
1513 | ||
1514 | enum { | |
f5fcc13c TI |
1515 | CXT5047_LAPTOP, /* Laptops w/o EAPD support */ |
1516 | CXT5047_LAPTOP_HP, /* Some HP laptops */ | |
1517 | CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */ | |
c9b443d4 TD |
1518 | #ifdef CONFIG_SND_DEBUG |
1519 | CXT5047_TEST, | |
1520 | #endif | |
fa5dadcb | 1521 | CXT5047_AUTO, |
f5fcc13c | 1522 | CXT5047_MODELS |
c9b443d4 TD |
1523 | }; |
1524 | ||
ea734963 | 1525 | static const char * const cxt5047_models[CXT5047_MODELS] = { |
f5fcc13c TI |
1526 | [CXT5047_LAPTOP] = "laptop", |
1527 | [CXT5047_LAPTOP_HP] = "laptop-hp", | |
1528 | [CXT5047_LAPTOP_EAPD] = "laptop-eapd", | |
c9b443d4 | 1529 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 1530 | [CXT5047_TEST] = "test", |
c9b443d4 | 1531 | #endif |
fa5dadcb | 1532 | [CXT5047_AUTO] = "auto", |
f5fcc13c TI |
1533 | }; |
1534 | ||
34cbe3a6 | 1535 | static const struct snd_pci_quirk cxt5047_cfg_tbl[] = { |
ac3e3741 | 1536 | SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP), |
dea0a509 TI |
1537 | SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series", |
1538 | CXT5047_LAPTOP), | |
f5fcc13c | 1539 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD), |
c9b443d4 TD |
1540 | {} |
1541 | }; | |
1542 | ||
1543 | static int patch_cxt5047(struct hda_codec *codec) | |
1544 | { | |
1545 | struct conexant_spec *spec; | |
1546 | int board_config; | |
1547 | ||
fa5dadcb TI |
1548 | board_config = snd_hda_check_board_config(codec, CXT5047_MODELS, |
1549 | cxt5047_models, | |
1550 | cxt5047_cfg_tbl); | |
fa5dadcb | 1551 | if (board_config < 0) |
c82693db | 1552 | board_config = CXT5047_AUTO; /* model=auto as default */ |
fa5dadcb TI |
1553 | if (board_config == CXT5047_AUTO) |
1554 | return patch_conexant_auto(codec); | |
1555 | ||
c9b443d4 TD |
1556 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1557 | if (!spec) | |
1558 | return -ENOMEM; | |
c9b443d4 | 1559 | codec->spec = spec; |
9421f954 | 1560 | codec->pin_amp_workaround = 1; |
c9b443d4 TD |
1561 | |
1562 | spec->multiout.max_channels = 2; | |
1563 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids); | |
1564 | spec->multiout.dac_nids = cxt5047_dac_nids; | |
1565 | spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT; | |
1566 | spec->num_adc_nids = 1; | |
1567 | spec->adc_nids = cxt5047_adc_nids; | |
1568 | spec->capsrc_nids = cxt5047_capsrc_nids; | |
c9b443d4 | 1569 | spec->num_mixers = 1; |
df481e41 | 1570 | spec->mixers[0] = cxt5047_base_mixers; |
c9b443d4 TD |
1571 | spec->num_init_verbs = 1; |
1572 | spec->init_verbs[0] = cxt5047_init_verbs; | |
1573 | spec->spdif_route = 0; | |
5cd57529 TD |
1574 | spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes), |
1575 | spec->channel_mode = cxt5047_modes, | |
c9b443d4 TD |
1576 | |
1577 | codec->patch_ops = conexant_patch_ops; | |
c9b443d4 | 1578 | |
c9b443d4 TD |
1579 | switch (board_config) { |
1580 | case CXT5047_LAPTOP: | |
df481e41 TI |
1581 | spec->num_mixers = 2; |
1582 | spec->mixers[1] = cxt5047_hp_spk_mixers; | |
1583 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; | |
c9b443d4 TD |
1584 | break; |
1585 | case CXT5047_LAPTOP_HP: | |
df481e41 TI |
1586 | spec->num_mixers = 2; |
1587 | spec->mixers[1] = cxt5047_hp_only_mixers; | |
fb3409e7 | 1588 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; |
c9b443d4 TD |
1589 | codec->patch_ops.init = cxt5047_hp_init; |
1590 | break; | |
1591 | case CXT5047_LAPTOP_EAPD: | |
82f30040 | 1592 | spec->input_mux = &cxt5047_toshiba_capture_source; |
df481e41 TI |
1593 | spec->num_mixers = 2; |
1594 | spec->mixers[1] = cxt5047_hp_spk_mixers; | |
c9b443d4 TD |
1595 | spec->num_init_verbs = 2; |
1596 | spec->init_verbs[1] = cxt5047_toshiba_init_verbs; | |
fb3409e7 | 1597 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; |
c9b443d4 TD |
1598 | break; |
1599 | #ifdef CONFIG_SND_DEBUG | |
1600 | case CXT5047_TEST: | |
1601 | spec->input_mux = &cxt5047_test_capture_source; | |
1602 | spec->mixers[0] = cxt5047_test_mixer; | |
1603 | spec->init_verbs[0] = cxt5047_test_init_verbs; | |
fb3409e7 | 1604 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; |
c9b443d4 TD |
1605 | #endif |
1606 | } | |
dd5746a8 | 1607 | spec->vmaster_nid = 0x13; |
025f206c DC |
1608 | |
1609 | switch (codec->subsystem_id >> 16) { | |
1610 | case 0x103c: | |
1611 | /* HP laptops have really bad sound over 0 dB on NID 0x10. | |
1612 | * Fix max PCM level to 0 dB (originally it has 0x1e steps | |
1613 | * with 0 dB offset 0x17) | |
1614 | */ | |
1615 | snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT, | |
1616 | (0x17 << AC_AMPCAP_OFFSET_SHIFT) | | |
1617 | (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | | |
1618 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | | |
1619 | (1 << AC_AMPCAP_MUTE_SHIFT)); | |
1620 | break; | |
1621 | } | |
1622 | ||
c9b443d4 TD |
1623 | return 0; |
1624 | } | |
1625 | ||
461e2c78 | 1626 | /* Conexant 5051 specific */ |
34cbe3a6 TI |
1627 | static const hda_nid_t cxt5051_dac_nids[1] = { 0x10 }; |
1628 | static const hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 }; | |
461e2c78 | 1629 | |
34cbe3a6 | 1630 | static const struct hda_channel_mode cxt5051_modes[1] = { |
461e2c78 TI |
1631 | { 2, NULL }, |
1632 | }; | |
1633 | ||
1634 | static void cxt5051_update_speaker(struct hda_codec *codec) | |
1635 | { | |
1636 | struct conexant_spec *spec = codec->spec; | |
1637 | unsigned int pinctl; | |
23d2df5b TI |
1638 | /* headphone pin */ |
1639 | pinctl = (spec->hp_present && spec->cur_eapd) ? PIN_HP : 0; | |
1640 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
1641 | pinctl); | |
1642 | /* speaker pin */ | |
461e2c78 TI |
1643 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; |
1644 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
1645 | pinctl); | |
f7154de2 HRK |
1646 | /* on ideapad there is an aditional speaker (subwoofer) to mute */ |
1647 | if (spec->ideapad) | |
1648 | snd_hda_codec_write(codec, 0x1b, 0, | |
1649 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
1650 | pinctl); | |
461e2c78 TI |
1651 | } |
1652 | ||
1653 | /* turn on/off EAPD (+ mute HP) as a master switch */ | |
1654 | static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
1655 | struct snd_ctl_elem_value *ucontrol) | |
1656 | { | |
1657 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1658 | ||
1659 | if (!cxt_eapd_put(kcontrol, ucontrol)) | |
1660 | return 0; | |
1661 | cxt5051_update_speaker(codec); | |
1662 | return 1; | |
1663 | } | |
1664 | ||
1665 | /* toggle input of built-in and mic jack appropriately */ | |
1666 | static void cxt5051_portb_automic(struct hda_codec *codec) | |
1667 | { | |
79d7d533 | 1668 | struct conexant_spec *spec = codec->spec; |
461e2c78 TI |
1669 | unsigned int present; |
1670 | ||
faddaa5d | 1671 | if (!(spec->auto_mic & AUTO_MIC_PORTB)) |
79d7d533 | 1672 | return; |
d56757ab | 1673 | present = snd_hda_jack_detect(codec, 0x17); |
461e2c78 TI |
1674 | snd_hda_codec_write(codec, 0x14, 0, |
1675 | AC_VERB_SET_CONNECT_SEL, | |
1676 | present ? 0x01 : 0x00); | |
1677 | } | |
1678 | ||
1679 | /* switch the current ADC according to the jack state */ | |
1680 | static void cxt5051_portc_automic(struct hda_codec *codec) | |
1681 | { | |
1682 | struct conexant_spec *spec = codec->spec; | |
1683 | unsigned int present; | |
1684 | hda_nid_t new_adc; | |
1685 | ||
faddaa5d | 1686 | if (!(spec->auto_mic & AUTO_MIC_PORTC)) |
79d7d533 | 1687 | return; |
d56757ab | 1688 | present = snd_hda_jack_detect(codec, 0x18); |
461e2c78 TI |
1689 | if (present) |
1690 | spec->cur_adc_idx = 1; | |
1691 | else | |
1692 | spec->cur_adc_idx = 0; | |
1693 | new_adc = spec->adc_nids[spec->cur_adc_idx]; | |
1694 | if (spec->cur_adc && spec->cur_adc != new_adc) { | |
1695 | /* stream is running, let's swap the current ADC */ | |
f0cea797 | 1696 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
461e2c78 TI |
1697 | spec->cur_adc = new_adc; |
1698 | snd_hda_codec_setup_stream(codec, new_adc, | |
1699 | spec->cur_adc_stream_tag, 0, | |
1700 | spec->cur_adc_format); | |
1701 | } | |
1702 | } | |
1703 | ||
1704 | /* mute internal speaker if HP is plugged */ | |
1705 | static void cxt5051_hp_automute(struct hda_codec *codec) | |
1706 | { | |
1707 | struct conexant_spec *spec = codec->spec; | |
1708 | ||
d56757ab | 1709 | spec->hp_present = snd_hda_jack_detect(codec, 0x16); |
461e2c78 TI |
1710 | cxt5051_update_speaker(codec); |
1711 | } | |
1712 | ||
1713 | /* unsolicited event for HP jack sensing */ | |
1714 | static void cxt5051_hp_unsol_event(struct hda_codec *codec, | |
1715 | unsigned int res) | |
1716 | { | |
1717 | switch (res >> 26) { | |
1718 | case CONEXANT_HP_EVENT: | |
1719 | cxt5051_hp_automute(codec); | |
1720 | break; | |
1721 | case CXT5051_PORTB_EVENT: | |
1722 | cxt5051_portb_automic(codec); | |
1723 | break; | |
1724 | case CXT5051_PORTC_EVENT: | |
1725 | cxt5051_portc_automic(codec); | |
1726 | break; | |
1727 | } | |
1728 | } | |
1729 | ||
34cbe3a6 | 1730 | static const struct snd_kcontrol_new cxt5051_playback_mixers[] = { |
461e2c78 TI |
1731 | HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), |
1732 | { | |
1733 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1734 | .name = "Master Playback Switch", | |
1735 | .info = cxt_eapd_info, | |
1736 | .get = cxt_eapd_get, | |
1737 | .put = cxt5051_hp_master_sw_put, | |
1738 | .private_value = 0x1a, | |
1739 | }, | |
2c7a3fb3 TI |
1740 | {} |
1741 | }; | |
461e2c78 | 1742 | |
34cbe3a6 | 1743 | static const struct snd_kcontrol_new cxt5051_capture_mixers[] = { |
2c7a3fb3 TI |
1744 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), |
1745 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), | |
8607f7c4 DH |
1746 | HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), |
1747 | HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), | |
2c7a3fb3 TI |
1748 | HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT), |
1749 | HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT), | |
461e2c78 TI |
1750 | {} |
1751 | }; | |
1752 | ||
34cbe3a6 | 1753 | static const struct snd_kcontrol_new cxt5051_hp_mixers[] = { |
461e2c78 TI |
1754 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), |
1755 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), | |
8607f7c4 DH |
1756 | HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT), |
1757 | HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT), | |
461e2c78 TI |
1758 | {} |
1759 | }; | |
1760 | ||
34cbe3a6 | 1761 | static const struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = { |
4e4ac600 TI |
1762 | HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT), |
1763 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT), | |
79d7d533 TI |
1764 | {} |
1765 | }; | |
1766 | ||
34cbe3a6 | 1767 | static const struct snd_kcontrol_new cxt5051_f700_mixers[] = { |
5f6c3de6 TI |
1768 | HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT), |
1769 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT), | |
cd9d95a5 KP |
1770 | {} |
1771 | }; | |
1772 | ||
34cbe3a6 | 1773 | static const struct snd_kcontrol_new cxt5051_toshiba_mixers[] = { |
faddaa5d TI |
1774 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), |
1775 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), | |
8607f7c4 DH |
1776 | HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), |
1777 | HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), | |
faddaa5d TI |
1778 | {} |
1779 | }; | |
1780 | ||
34cbe3a6 | 1781 | static const struct hda_verb cxt5051_init_verbs[] = { |
461e2c78 TI |
1782 | /* Line in, Mic */ |
1783 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, | |
1784 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1785 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, | |
1786 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1787 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1788 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, | |
1789 | /* SPK */ | |
1790 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1791 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1792 | /* HP, Amp */ | |
1793 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1794 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1795 | /* DAC1 */ | |
1796 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
28c4edb7 | 1797 | /* Record selector: Internal mic */ |
461e2c78 TI |
1798 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, |
1799 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, | |
1800 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, | |
1801 | /* SPDIF route: PCM */ | |
1965c441 | 1802 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
461e2c78 TI |
1803 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
1804 | /* EAPD */ | |
1805 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
1806 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, | |
461e2c78 TI |
1807 | { } /* end */ |
1808 | }; | |
1809 | ||
34cbe3a6 | 1810 | static const struct hda_verb cxt5051_hp_dv6736_init_verbs[] = { |
79d7d533 TI |
1811 | /* Line in, Mic */ |
1812 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, | |
1813 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1814 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, | |
1815 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, | |
1816 | /* SPK */ | |
1817 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1818 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1819 | /* HP, Amp */ | |
1820 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1821 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1822 | /* DAC1 */ | |
1823 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
28c4edb7 | 1824 | /* Record selector: Internal mic */ |
79d7d533 TI |
1825 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, |
1826 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, | |
1827 | /* SPDIF route: PCM */ | |
1828 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
1829 | /* EAPD */ | |
1830 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
1831 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, | |
79d7d533 TI |
1832 | { } /* end */ |
1833 | }; | |
1834 | ||
34cbe3a6 | 1835 | static const struct hda_verb cxt5051_f700_init_verbs[] = { |
cd9d95a5 | 1836 | /* Line in, Mic */ |
30ed7ed1 | 1837 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, |
cd9d95a5 KP |
1838 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1839 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, | |
1840 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, | |
1841 | /* SPK */ | |
1842 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1843 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1844 | /* HP, Amp */ | |
1845 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1846 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1847 | /* DAC1 */ | |
1848 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
28c4edb7 | 1849 | /* Record selector: Internal mic */ |
cd9d95a5 KP |
1850 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, |
1851 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, | |
1852 | /* SPDIF route: PCM */ | |
1853 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
1854 | /* EAPD */ | |
1855 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
1856 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, | |
cd9d95a5 KP |
1857 | { } /* end */ |
1858 | }; | |
1859 | ||
6953e552 TI |
1860 | static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid, |
1861 | unsigned int event) | |
1862 | { | |
1863 | snd_hda_codec_write(codec, nid, 0, | |
1864 | AC_VERB_SET_UNSOLICITED_ENABLE, | |
1865 | AC_USRSP_EN | event); | |
6953e552 TI |
1866 | } |
1867 | ||
34cbe3a6 | 1868 | static const struct hda_verb cxt5051_ideapad_init_verbs[] = { |
f7154de2 HRK |
1869 | /* Subwoofer */ |
1870 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1871 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1872 | { } /* end */ | |
1873 | }; | |
1874 | ||
461e2c78 TI |
1875 | /* initialize jack-sensing, too */ |
1876 | static int cxt5051_init(struct hda_codec *codec) | |
1877 | { | |
6953e552 TI |
1878 | struct conexant_spec *spec = codec->spec; |
1879 | ||
461e2c78 | 1880 | conexant_init(codec); |
6953e552 TI |
1881 | |
1882 | if (spec->auto_mic & AUTO_MIC_PORTB) | |
1883 | cxt5051_init_mic_port(codec, 0x17, CXT5051_PORTB_EVENT); | |
1884 | if (spec->auto_mic & AUTO_MIC_PORTC) | |
1885 | cxt5051_init_mic_port(codec, 0x18, CXT5051_PORTC_EVENT); | |
1886 | ||
461e2c78 TI |
1887 | if (codec->patch_ops.unsol_event) { |
1888 | cxt5051_hp_automute(codec); | |
1889 | cxt5051_portb_automic(codec); | |
1890 | cxt5051_portc_automic(codec); | |
1891 | } | |
1892 | return 0; | |
1893 | } | |
1894 | ||
1895 | ||
1896 | enum { | |
1897 | CXT5051_LAPTOP, /* Laptops w/ EAPD support */ | |
1898 | CXT5051_HP, /* no docking */ | |
79d7d533 | 1899 | CXT5051_HP_DV6736, /* HP without mic switch */ |
cd9d95a5 | 1900 | CXT5051_F700, /* HP Compaq Presario F700 */ |
faddaa5d | 1901 | CXT5051_TOSHIBA, /* Toshiba M300 & co */ |
f7154de2 | 1902 | CXT5051_IDEAPAD, /* Lenovo IdeaPad Y430 */ |
6764bcef | 1903 | CXT5051_AUTO, /* auto-parser */ |
461e2c78 TI |
1904 | CXT5051_MODELS |
1905 | }; | |
1906 | ||
ea734963 | 1907 | static const char *const cxt5051_models[CXT5051_MODELS] = { |
461e2c78 TI |
1908 | [CXT5051_LAPTOP] = "laptop", |
1909 | [CXT5051_HP] = "hp", | |
79d7d533 | 1910 | [CXT5051_HP_DV6736] = "hp-dv6736", |
5f6c3de6 | 1911 | [CXT5051_F700] = "hp-700", |
faddaa5d | 1912 | [CXT5051_TOSHIBA] = "toshiba", |
f7154de2 | 1913 | [CXT5051_IDEAPAD] = "ideapad", |
6764bcef | 1914 | [CXT5051_AUTO] = "auto", |
461e2c78 TI |
1915 | }; |
1916 | ||
34cbe3a6 | 1917 | static const struct snd_pci_quirk cxt5051_cfg_tbl[] = { |
79d7d533 | 1918 | SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736), |
1812e67c | 1919 | SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP), |
5f6c3de6 | 1920 | SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700), |
faddaa5d | 1921 | SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA), |
461e2c78 TI |
1922 | SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", |
1923 | CXT5051_LAPTOP), | |
1924 | SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), | |
f7154de2 | 1925 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD), |
461e2c78 TI |
1926 | {} |
1927 | }; | |
1928 | ||
1929 | static int patch_cxt5051(struct hda_codec *codec) | |
1930 | { | |
1931 | struct conexant_spec *spec; | |
1932 | int board_config; | |
1933 | ||
6764bcef TI |
1934 | board_config = snd_hda_check_board_config(codec, CXT5051_MODELS, |
1935 | cxt5051_models, | |
1936 | cxt5051_cfg_tbl); | |
1937 | if (board_config < 0) | |
c82693db | 1938 | board_config = CXT5051_AUTO; /* model=auto as default */ |
1f8458a2 | 1939 | if (board_config == CXT5051_AUTO) |
6764bcef | 1940 | return patch_conexant_auto(codec); |
6764bcef | 1941 | |
461e2c78 TI |
1942 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1943 | if (!spec) | |
1944 | return -ENOMEM; | |
461e2c78 | 1945 | codec->spec = spec; |
9421f954 | 1946 | codec->pin_amp_workaround = 1; |
461e2c78 TI |
1947 | |
1948 | codec->patch_ops = conexant_patch_ops; | |
1949 | codec->patch_ops.init = cxt5051_init; | |
1950 | ||
1951 | spec->multiout.max_channels = 2; | |
1952 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids); | |
1953 | spec->multiout.dac_nids = cxt5051_dac_nids; | |
1954 | spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT; | |
1955 | spec->num_adc_nids = 1; /* not 2; via auto-mic switch */ | |
1956 | spec->adc_nids = cxt5051_adc_nids; | |
2c7a3fb3 TI |
1957 | spec->num_mixers = 2; |
1958 | spec->mixers[0] = cxt5051_capture_mixers; | |
1959 | spec->mixers[1] = cxt5051_playback_mixers; | |
461e2c78 TI |
1960 | spec->num_init_verbs = 1; |
1961 | spec->init_verbs[0] = cxt5051_init_verbs; | |
1962 | spec->spdif_route = 0; | |
1963 | spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes); | |
1964 | spec->channel_mode = cxt5051_modes; | |
1965 | spec->cur_adc = 0; | |
1966 | spec->cur_adc_idx = 0; | |
1967 | ||
3507e2a8 TI |
1968 | set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); |
1969 | ||
79d7d533 TI |
1970 | codec->patch_ops.unsol_event = cxt5051_hp_unsol_event; |
1971 | ||
faddaa5d | 1972 | spec->auto_mic = AUTO_MIC_PORTB | AUTO_MIC_PORTC; |
461e2c78 TI |
1973 | switch (board_config) { |
1974 | case CXT5051_HP: | |
461e2c78 TI |
1975 | spec->mixers[0] = cxt5051_hp_mixers; |
1976 | break; | |
79d7d533 TI |
1977 | case CXT5051_HP_DV6736: |
1978 | spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs; | |
1979 | spec->mixers[0] = cxt5051_hp_dv6736_mixers; | |
faddaa5d | 1980 | spec->auto_mic = 0; |
79d7d533 | 1981 | break; |
cd9d95a5 KP |
1982 | case CXT5051_F700: |
1983 | spec->init_verbs[0] = cxt5051_f700_init_verbs; | |
1984 | spec->mixers[0] = cxt5051_f700_mixers; | |
faddaa5d TI |
1985 | spec->auto_mic = 0; |
1986 | break; | |
1987 | case CXT5051_TOSHIBA: | |
1988 | spec->mixers[0] = cxt5051_toshiba_mixers; | |
1989 | spec->auto_mic = AUTO_MIC_PORTB; | |
cd9d95a5 | 1990 | break; |
f7154de2 HRK |
1991 | case CXT5051_IDEAPAD: |
1992 | spec->init_verbs[spec->num_init_verbs++] = | |
1993 | cxt5051_ideapad_init_verbs; | |
1994 | spec->ideapad = 1; | |
1995 | break; | |
461e2c78 TI |
1996 | } |
1997 | ||
3507e2a8 TI |
1998 | if (spec->beep_amp) |
1999 | snd_hda_attach_beep_device(codec, spec->beep_amp); | |
2000 | ||
461e2c78 TI |
2001 | return 0; |
2002 | } | |
2003 | ||
0fb67e98 DD |
2004 | /* Conexant 5066 specific */ |
2005 | ||
34cbe3a6 TI |
2006 | static const hda_nid_t cxt5066_dac_nids[1] = { 0x10 }; |
2007 | static const hda_nid_t cxt5066_adc_nids[3] = { 0x14, 0x15, 0x16 }; | |
2008 | static const hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 }; | |
2009 | static const hda_nid_t cxt5066_digout_pin_nids[2] = { 0x20, 0x22 }; | |
0fb67e98 | 2010 | |
dbaccc0c DD |
2011 | /* OLPC's microphone port is DC coupled for use with external sensors, |
2012 | * therefore we use a 50% mic bias in order to center the input signal with | |
2013 | * the DC input range of the codec. */ | |
2014 | #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50 | |
2015 | ||
34cbe3a6 | 2016 | static const struct hda_channel_mode cxt5066_modes[1] = { |
0fb67e98 DD |
2017 | { 2, NULL }, |
2018 | }; | |
2019 | ||
a3de8ab8 TI |
2020 | #define HP_PRESENT_PORT_A (1 << 0) |
2021 | #define HP_PRESENT_PORT_D (1 << 1) | |
2022 | #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A) | |
2023 | #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D) | |
2024 | ||
0fb67e98 DD |
2025 | static void cxt5066_update_speaker(struct hda_codec *codec) |
2026 | { | |
2027 | struct conexant_spec *spec = codec->spec; | |
2028 | unsigned int pinctl; | |
2029 | ||
3a253445 JB |
2030 | snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n", |
2031 | spec->hp_present, spec->cur_eapd); | |
0fb67e98 DD |
2032 | |
2033 | /* Port A (HP) */ | |
a3de8ab8 | 2034 | pinctl = (hp_port_a_present(spec) && spec->cur_eapd) ? PIN_HP : 0; |
0fb67e98 DD |
2035 | snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
2036 | pinctl); | |
2037 | ||
2038 | /* Port D (HP/LO) */ | |
a3de8ab8 TI |
2039 | pinctl = spec->cur_eapd ? spec->port_d_mode : 0; |
2040 | if (spec->dell_automute || spec->thinkpad) { | |
2041 | /* Mute if Port A is connected */ | |
2042 | if (hp_port_a_present(spec)) | |
3a253445 JB |
2043 | pinctl = 0; |
2044 | } else { | |
a3de8ab8 TI |
2045 | /* Thinkpad/Dell doesn't give pin-D status */ |
2046 | if (!hp_port_d_present(spec)) | |
2047 | pinctl = 0; | |
3a253445 | 2048 | } |
0fb67e98 DD |
2049 | snd_hda_codec_write(codec, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
2050 | pinctl); | |
2051 | ||
2052 | /* CLASS_D AMP */ | |
2053 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; | |
2054 | snd_hda_codec_write(codec, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
2055 | pinctl); | |
0fb67e98 DD |
2056 | } |
2057 | ||
2058 | /* turn on/off EAPD (+ mute HP) as a master switch */ | |
2059 | static int cxt5066_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
2060 | struct snd_ctl_elem_value *ucontrol) | |
2061 | { | |
2062 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2063 | ||
2064 | if (!cxt_eapd_put(kcontrol, ucontrol)) | |
2065 | return 0; | |
2066 | ||
2067 | cxt5066_update_speaker(codec); | |
2068 | return 1; | |
2069 | } | |
2070 | ||
c4cfe66c DD |
2071 | static const struct hda_input_mux cxt5066_olpc_dc_bias = { |
2072 | .num_items = 3, | |
2073 | .items = { | |
2074 | { "Off", PIN_IN }, | |
2075 | { "50%", PIN_VREF50 }, | |
2076 | { "80%", PIN_VREF80 }, | |
2077 | }, | |
2078 | }; | |
2079 | ||
2080 | static int cxt5066_set_olpc_dc_bias(struct hda_codec *codec) | |
2081 | { | |
2082 | struct conexant_spec *spec = codec->spec; | |
2083 | /* Even though port F is the DC input, the bias is controlled on port B. | |
2084 | * we also leave that port as an active input (but unselected) in DC mode | |
2085 | * just in case that is necessary to make the bias setting take effect. */ | |
2086 | return snd_hda_codec_write_cache(codec, 0x1a, 0, | |
2087 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
2088 | cxt5066_olpc_dc_bias.items[spec->dc_input_bias].index); | |
2089 | } | |
2090 | ||
75f8991d DD |
2091 | /* OLPC defers mic widget control until when capture is started because the |
2092 | * microphone LED comes on as soon as these settings are put in place. if we | |
2093 | * did this before recording, it would give the false indication that recording | |
2094 | * is happening when it is not. */ | |
2095 | static void cxt5066_olpc_select_mic(struct hda_codec *codec) | |
0fb67e98 | 2096 | { |
dbaccc0c | 2097 | struct conexant_spec *spec = codec->spec; |
75f8991d DD |
2098 | if (!spec->recording) |
2099 | return; | |
0fb67e98 | 2100 | |
c4cfe66c DD |
2101 | if (spec->dc_enable) { |
2102 | /* in DC mode we ignore presence detection and just use the jack | |
2103 | * through our special DC port */ | |
2104 | const struct hda_verb enable_dc_mode[] = { | |
2105 | /* disble internal mic, port C */ | |
2106 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2107 | ||
2108 | /* enable DC capture, port F */ | |
2109 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2110 | {}, | |
2111 | }; | |
2112 | ||
2113 | snd_hda_sequence_write(codec, enable_dc_mode); | |
2114 | /* port B input disabled (and bias set) through the following call */ | |
2115 | cxt5066_set_olpc_dc_bias(codec); | |
2116 | return; | |
2117 | } | |
2118 | ||
2119 | /* disable DC (port F) */ | |
2120 | snd_hda_codec_write(codec, 0x1e, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | |
2121 | ||
75f8991d DD |
2122 | /* external mic, port B */ |
2123 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
2124 | spec->ext_mic_present ? CXT5066_OLPC_EXT_MIC_BIAS : 0); | |
0fb67e98 | 2125 | |
75f8991d DD |
2126 | /* internal mic, port C */ |
2127 | snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
2128 | spec->ext_mic_present ? 0 : PIN_VREF80); | |
2129 | } | |
0fb67e98 | 2130 | |
75f8991d DD |
2131 | /* toggle input of built-in and mic jack appropriately */ |
2132 | static void cxt5066_olpc_automic(struct hda_codec *codec) | |
2133 | { | |
2134 | struct conexant_spec *spec = codec->spec; | |
0fb67e98 DD |
2135 | unsigned int present; |
2136 | ||
c4cfe66c DD |
2137 | if (spec->dc_enable) /* don't do presence detection in DC mode */ |
2138 | return; | |
2139 | ||
75f8991d DD |
2140 | present = snd_hda_codec_read(codec, 0x1a, 0, |
2141 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
2142 | if (present) | |
0fb67e98 | 2143 | snd_printdd("CXT5066: external microphone detected\n"); |
75f8991d | 2144 | else |
0fb67e98 | 2145 | snd_printdd("CXT5066: external microphone absent\n"); |
75f8991d DD |
2146 | |
2147 | snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, | |
2148 | present ? 0 : 1); | |
2149 | spec->ext_mic_present = !!present; | |
2150 | ||
2151 | cxt5066_olpc_select_mic(codec); | |
0fb67e98 DD |
2152 | } |
2153 | ||
95a618bd ER |
2154 | /* toggle input of built-in digital mic and mic jack appropriately */ |
2155 | static void cxt5066_vostro_automic(struct hda_codec *codec) | |
2156 | { | |
95a618bd ER |
2157 | unsigned int present; |
2158 | ||
2159 | struct hda_verb ext_mic_present[] = { | |
2160 | /* enable external mic, port B */ | |
75f8991d | 2161 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
95a618bd ER |
2162 | |
2163 | /* switch to external mic input */ | |
2164 | {0x17, AC_VERB_SET_CONNECT_SEL, 0}, | |
2165 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, | |
2166 | ||
2167 | /* disable internal digital mic */ | |
2168 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2169 | {} | |
2170 | }; | |
34cbe3a6 | 2171 | static const struct hda_verb ext_mic_absent[] = { |
95a618bd ER |
2172 | /* enable internal mic, port C */ |
2173 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2174 | ||
2175 | /* switch to internal mic input */ | |
2176 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, | |
2177 | ||
2178 | /* disable external mic, port B */ | |
2179 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2180 | {} | |
2181 | }; | |
2182 | ||
2183 | present = snd_hda_jack_detect(codec, 0x1a); | |
2184 | if (present) { | |
2185 | snd_printdd("CXT5066: external microphone detected\n"); | |
2186 | snd_hda_sequence_write(codec, ext_mic_present); | |
2187 | } else { | |
2188 | snd_printdd("CXT5066: external microphone absent\n"); | |
2189 | snd_hda_sequence_write(codec, ext_mic_absent); | |
2190 | } | |
2191 | } | |
2192 | ||
cfd3d8dc GA |
2193 | /* toggle input of built-in digital mic and mic jack appropriately */ |
2194 | static void cxt5066_ideapad_automic(struct hda_codec *codec) | |
2195 | { | |
2196 | unsigned int present; | |
2197 | ||
2198 | struct hda_verb ext_mic_present[] = { | |
2199 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, | |
2200 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2201 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2202 | {} | |
2203 | }; | |
34cbe3a6 | 2204 | static const struct hda_verb ext_mic_absent[] = { |
cfd3d8dc GA |
2205 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, |
2206 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2207 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2208 | {} | |
2209 | }; | |
2210 | ||
2211 | present = snd_hda_jack_detect(codec, 0x1b); | |
2212 | if (present) { | |
2213 | snd_printdd("CXT5066: external microphone detected\n"); | |
2214 | snd_hda_sequence_write(codec, ext_mic_present); | |
2215 | } else { | |
2216 | snd_printdd("CXT5066: external microphone absent\n"); | |
2217 | snd_hda_sequence_write(codec, ext_mic_absent); | |
2218 | } | |
2219 | } | |
2220 | ||
a1d6906e DH |
2221 | |
2222 | /* toggle input of built-in digital mic and mic jack appropriately */ | |
2223 | static void cxt5066_asus_automic(struct hda_codec *codec) | |
2224 | { | |
2225 | unsigned int present; | |
2226 | ||
2227 | present = snd_hda_jack_detect(codec, 0x1b); | |
2228 | snd_printdd("CXT5066: external microphone present=%d\n", present); | |
2229 | snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, | |
2230 | present ? 1 : 0); | |
2231 | } | |
2232 | ||
2233 | ||
048e78a5 DH |
2234 | /* toggle input of built-in digital mic and mic jack appropriately */ |
2235 | static void cxt5066_hp_laptop_automic(struct hda_codec *codec) | |
2236 | { | |
2237 | unsigned int present; | |
2238 | ||
2239 | present = snd_hda_jack_detect(codec, 0x1b); | |
2240 | snd_printdd("CXT5066: external microphone present=%d\n", present); | |
2241 | snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, | |
2242 | present ? 1 : 3); | |
2243 | } | |
2244 | ||
2245 | ||
7b2bfdbc JT |
2246 | /* toggle input of built-in digital mic and mic jack appropriately |
2247 | order is: external mic -> dock mic -> interal mic */ | |
2248 | static void cxt5066_thinkpad_automic(struct hda_codec *codec) | |
2249 | { | |
2250 | unsigned int ext_present, dock_present; | |
2251 | ||
34cbe3a6 | 2252 | static const struct hda_verb ext_mic_present[] = { |
7b2bfdbc JT |
2253 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, |
2254 | {0x17, AC_VERB_SET_CONNECT_SEL, 1}, | |
2255 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2256 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2257 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2258 | {} | |
2259 | }; | |
34cbe3a6 | 2260 | static const struct hda_verb dock_mic_present[] = { |
7b2bfdbc JT |
2261 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, |
2262 | {0x17, AC_VERB_SET_CONNECT_SEL, 0}, | |
2263 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2264 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2265 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2266 | {} | |
2267 | }; | |
34cbe3a6 | 2268 | static const struct hda_verb ext_mic_absent[] = { |
7b2bfdbc JT |
2269 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, |
2270 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2271 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2272 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2273 | {} | |
2274 | }; | |
2275 | ||
2276 | ext_present = snd_hda_jack_detect(codec, 0x1b); | |
2277 | dock_present = snd_hda_jack_detect(codec, 0x1a); | |
2278 | if (ext_present) { | |
2279 | snd_printdd("CXT5066: external microphone detected\n"); | |
2280 | snd_hda_sequence_write(codec, ext_mic_present); | |
2281 | } else if (dock_present) { | |
2282 | snd_printdd("CXT5066: dock microphone detected\n"); | |
2283 | snd_hda_sequence_write(codec, dock_mic_present); | |
2284 | } else { | |
2285 | snd_printdd("CXT5066: external microphone absent\n"); | |
2286 | snd_hda_sequence_write(codec, ext_mic_absent); | |
2287 | } | |
2288 | } | |
2289 | ||
0fb67e98 DD |
2290 | /* mute internal speaker if HP is plugged */ |
2291 | static void cxt5066_hp_automute(struct hda_codec *codec) | |
2292 | { | |
2293 | struct conexant_spec *spec = codec->spec; | |
2294 | unsigned int portA, portD; | |
2295 | ||
2296 | /* Port A */ | |
d56757ab | 2297 | portA = snd_hda_jack_detect(codec, 0x19); |
0fb67e98 DD |
2298 | |
2299 | /* Port D */ | |
d56757ab | 2300 | portD = snd_hda_jack_detect(codec, 0x1c); |
0fb67e98 | 2301 | |
a3de8ab8 TI |
2302 | spec->hp_present = portA ? HP_PRESENT_PORT_A : 0; |
2303 | spec->hp_present |= portD ? HP_PRESENT_PORT_D : 0; | |
0fb67e98 DD |
2304 | snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n", |
2305 | portA, portD, spec->hp_present); | |
2306 | cxt5066_update_speaker(codec); | |
2307 | } | |
2308 | ||
02b6b5b6 DH |
2309 | /* Dispatch the right mic autoswitch function */ |
2310 | static void cxt5066_automic(struct hda_codec *codec) | |
0fb67e98 | 2311 | { |
c4cfe66c | 2312 | struct conexant_spec *spec = codec->spec; |
0fb67e98 | 2313 | |
02b6b5b6 | 2314 | if (spec->dell_vostro) |
95a618bd | 2315 | cxt5066_vostro_automic(codec); |
02b6b5b6 | 2316 | else if (spec->ideapad) |
cfd3d8dc | 2317 | cxt5066_ideapad_automic(codec); |
02b6b5b6 DH |
2318 | else if (spec->thinkpad) |
2319 | cxt5066_thinkpad_automic(codec); | |
2320 | else if (spec->hp_laptop) | |
2321 | cxt5066_hp_laptop_automic(codec); | |
a1d6906e DH |
2322 | else if (spec->asus) |
2323 | cxt5066_asus_automic(codec); | |
cfd3d8dc GA |
2324 | } |
2325 | ||
048e78a5 | 2326 | /* unsolicited event for jack sensing */ |
02b6b5b6 | 2327 | static void cxt5066_olpc_unsol_event(struct hda_codec *codec, unsigned int res) |
048e78a5 | 2328 | { |
02b6b5b6 DH |
2329 | struct conexant_spec *spec = codec->spec; |
2330 | snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); | |
048e78a5 DH |
2331 | switch (res >> 26) { |
2332 | case CONEXANT_HP_EVENT: | |
2333 | cxt5066_hp_automute(codec); | |
2334 | break; | |
2335 | case CONEXANT_MIC_EVENT: | |
02b6b5b6 DH |
2336 | /* ignore mic events in DC mode; we're always using the jack */ |
2337 | if (!spec->dc_enable) | |
2338 | cxt5066_olpc_automic(codec); | |
048e78a5 DH |
2339 | break; |
2340 | } | |
2341 | } | |
2342 | ||
7b2bfdbc | 2343 | /* unsolicited event for jack sensing */ |
02b6b5b6 | 2344 | static void cxt5066_unsol_event(struct hda_codec *codec, unsigned int res) |
7b2bfdbc | 2345 | { |
02b6b5b6 | 2346 | snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); |
7b2bfdbc JT |
2347 | switch (res >> 26) { |
2348 | case CONEXANT_HP_EVENT: | |
2349 | cxt5066_hp_automute(codec); | |
2350 | break; | |
2351 | case CONEXANT_MIC_EVENT: | |
02b6b5b6 | 2352 | cxt5066_automic(codec); |
7b2bfdbc JT |
2353 | break; |
2354 | } | |
2355 | } | |
2356 | ||
02b6b5b6 | 2357 | |
0fb67e98 DD |
2358 | static const struct hda_input_mux cxt5066_analog_mic_boost = { |
2359 | .num_items = 5, | |
2360 | .items = { | |
2361 | { "0dB", 0 }, | |
2362 | { "10dB", 1 }, | |
2363 | { "20dB", 2 }, | |
2364 | { "30dB", 3 }, | |
2365 | { "40dB", 4 }, | |
2366 | }, | |
2367 | }; | |
2368 | ||
cfd3d8dc | 2369 | static void cxt5066_set_mic_boost(struct hda_codec *codec) |
c4cfe66c DD |
2370 | { |
2371 | struct conexant_spec *spec = codec->spec; | |
cfd3d8dc | 2372 | snd_hda_codec_write_cache(codec, 0x17, 0, |
c4cfe66c DD |
2373 | AC_VERB_SET_AMP_GAIN_MUTE, |
2374 | AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT | | |
2375 | cxt5066_analog_mic_boost.items[spec->mic_boost].index); | |
7b2bfdbc | 2376 | if (spec->ideapad || spec->thinkpad) { |
cfd3d8dc GA |
2377 | /* adjust the internal mic as well...it is not through 0x17 */ |
2378 | snd_hda_codec_write_cache(codec, 0x23, 0, | |
2379 | AC_VERB_SET_AMP_GAIN_MUTE, | |
2380 | AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_INPUT | | |
2381 | cxt5066_analog_mic_boost. | |
2382 | items[spec->mic_boost].index); | |
2383 | } | |
c4cfe66c DD |
2384 | } |
2385 | ||
0fb67e98 DD |
2386 | static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol *kcontrol, |
2387 | struct snd_ctl_elem_info *uinfo) | |
2388 | { | |
2389 | return snd_hda_input_mux_info(&cxt5066_analog_mic_boost, uinfo); | |
2390 | } | |
2391 | ||
2392 | static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol *kcontrol, | |
2393 | struct snd_ctl_elem_value *ucontrol) | |
2394 | { | |
2395 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
c4cfe66c DD |
2396 | struct conexant_spec *spec = codec->spec; |
2397 | ucontrol->value.enumerated.item[0] = spec->mic_boost; | |
0fb67e98 DD |
2398 | return 0; |
2399 | } | |
2400 | ||
2401 | static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol, | |
2402 | struct snd_ctl_elem_value *ucontrol) | |
2403 | { | |
2404 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
c4cfe66c | 2405 | struct conexant_spec *spec = codec->spec; |
0fb67e98 DD |
2406 | const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; |
2407 | unsigned int idx; | |
c4cfe66c DD |
2408 | idx = ucontrol->value.enumerated.item[0]; |
2409 | if (idx >= imux->num_items) | |
2410 | idx = imux->num_items - 1; | |
2411 | ||
2412 | spec->mic_boost = idx; | |
2413 | if (!spec->dc_enable) | |
2414 | cxt5066_set_mic_boost(codec); | |
2415 | return 1; | |
2416 | } | |
2417 | ||
2418 | static void cxt5066_enable_dc(struct hda_codec *codec) | |
2419 | { | |
2420 | const struct hda_verb enable_dc_mode[] = { | |
2421 | /* disable gain */ | |
2422 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2423 | ||
2424 | /* switch to DC input */ | |
2425 | {0x17, AC_VERB_SET_CONNECT_SEL, 3}, | |
2426 | {} | |
2427 | }; | |
2428 | ||
2429 | /* configure as input source */ | |
2430 | snd_hda_sequence_write(codec, enable_dc_mode); | |
2431 | cxt5066_olpc_select_mic(codec); /* also sets configured bias */ | |
2432 | } | |
2433 | ||
2434 | static void cxt5066_disable_dc(struct hda_codec *codec) | |
2435 | { | |
2436 | /* reconfigure input source */ | |
2437 | cxt5066_set_mic_boost(codec); | |
2438 | /* automic also selects the right mic if we're recording */ | |
2439 | cxt5066_olpc_automic(codec); | |
2440 | } | |
2441 | ||
2442 | static int cxt5066_olpc_dc_get(struct snd_kcontrol *kcontrol, | |
2443 | struct snd_ctl_elem_value *ucontrol) | |
2444 | { | |
2445 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2446 | struct conexant_spec *spec = codec->spec; | |
2447 | ucontrol->value.integer.value[0] = spec->dc_enable; | |
2448 | return 0; | |
2449 | } | |
0fb67e98 | 2450 | |
c4cfe66c DD |
2451 | static int cxt5066_olpc_dc_put(struct snd_kcontrol *kcontrol, |
2452 | struct snd_ctl_elem_value *ucontrol) | |
2453 | { | |
2454 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2455 | struct conexant_spec *spec = codec->spec; | |
2456 | int dc_enable = !!ucontrol->value.integer.value[0]; | |
2457 | ||
2458 | if (dc_enable == spec->dc_enable) | |
0fb67e98 | 2459 | return 0; |
c4cfe66c DD |
2460 | |
2461 | spec->dc_enable = dc_enable; | |
2462 | if (dc_enable) | |
2463 | cxt5066_enable_dc(codec); | |
2464 | else | |
2465 | cxt5066_disable_dc(codec); | |
2466 | ||
2467 | return 1; | |
2468 | } | |
2469 | ||
2470 | static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol *kcontrol, | |
2471 | struct snd_ctl_elem_info *uinfo) | |
2472 | { | |
2473 | return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias, uinfo); | |
2474 | } | |
2475 | ||
2476 | static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol *kcontrol, | |
2477 | struct snd_ctl_elem_value *ucontrol) | |
2478 | { | |
2479 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2480 | struct conexant_spec *spec = codec->spec; | |
2481 | ucontrol->value.enumerated.item[0] = spec->dc_input_bias; | |
2482 | return 0; | |
2483 | } | |
2484 | ||
2485 | static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol *kcontrol, | |
2486 | struct snd_ctl_elem_value *ucontrol) | |
2487 | { | |
2488 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2489 | struct conexant_spec *spec = codec->spec; | |
2490 | const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; | |
2491 | unsigned int idx; | |
2492 | ||
0fb67e98 DD |
2493 | idx = ucontrol->value.enumerated.item[0]; |
2494 | if (idx >= imux->num_items) | |
2495 | idx = imux->num_items - 1; | |
2496 | ||
c4cfe66c DD |
2497 | spec->dc_input_bias = idx; |
2498 | if (spec->dc_enable) | |
2499 | cxt5066_set_olpc_dc_bias(codec); | |
0fb67e98 DD |
2500 | return 1; |
2501 | } | |
2502 | ||
75f8991d DD |
2503 | static void cxt5066_olpc_capture_prepare(struct hda_codec *codec) |
2504 | { | |
2505 | struct conexant_spec *spec = codec->spec; | |
2506 | /* mark as recording and configure the microphone widget so that the | |
2507 | * recording LED comes on. */ | |
2508 | spec->recording = 1; | |
2509 | cxt5066_olpc_select_mic(codec); | |
2510 | } | |
2511 | ||
2512 | static void cxt5066_olpc_capture_cleanup(struct hda_codec *codec) | |
2513 | { | |
2514 | struct conexant_spec *spec = codec->spec; | |
2515 | const struct hda_verb disable_mics[] = { | |
2516 | /* disable external mic, port B */ | |
2517 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2518 | ||
2519 | /* disble internal mic, port C */ | |
2520 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
c4cfe66c DD |
2521 | |
2522 | /* disable DC capture, port F */ | |
2523 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
75f8991d DD |
2524 | {}, |
2525 | }; | |
2526 | ||
2527 | snd_hda_sequence_write(codec, disable_mics); | |
2528 | spec->recording = 0; | |
2529 | } | |
2530 | ||
f6a2491c | 2531 | static void conexant_check_dig_outs(struct hda_codec *codec, |
34cbe3a6 | 2532 | const hda_nid_t *dig_pins, |
f6a2491c AR |
2533 | int num_pins) |
2534 | { | |
2535 | struct conexant_spec *spec = codec->spec; | |
2536 | hda_nid_t *nid_loc = &spec->multiout.dig_out_nid; | |
2537 | int i; | |
2538 | ||
2539 | for (i = 0; i < num_pins; i++, dig_pins++) { | |
2540 | unsigned int cfg = snd_hda_codec_get_pincfg(codec, *dig_pins); | |
2541 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_NONE) | |
2542 | continue; | |
2543 | if (snd_hda_get_connections(codec, *dig_pins, nid_loc, 1) != 1) | |
2544 | continue; | |
2545 | if (spec->slave_dig_outs[0]) | |
2546 | nid_loc++; | |
2547 | else | |
2548 | nid_loc = spec->slave_dig_outs; | |
2549 | } | |
2550 | } | |
2551 | ||
34cbe3a6 | 2552 | static const struct hda_input_mux cxt5066_capture_source = { |
0fb67e98 DD |
2553 | .num_items = 4, |
2554 | .items = { | |
2555 | { "Mic B", 0 }, | |
2556 | { "Mic C", 1 }, | |
2557 | { "Mic E", 2 }, | |
2558 | { "Mic F", 3 }, | |
2559 | }, | |
2560 | }; | |
2561 | ||
34cbe3a6 | 2562 | static const struct hda_bind_ctls cxt5066_bind_capture_vol_others = { |
0fb67e98 DD |
2563 | .ops = &snd_hda_bind_vol, |
2564 | .values = { | |
2565 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), | |
2566 | HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), | |
2567 | 0 | |
2568 | }, | |
2569 | }; | |
2570 | ||
34cbe3a6 | 2571 | static const struct hda_bind_ctls cxt5066_bind_capture_sw_others = { |
0fb67e98 DD |
2572 | .ops = &snd_hda_bind_sw, |
2573 | .values = { | |
2574 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), | |
2575 | HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), | |
2576 | 0 | |
2577 | }, | |
2578 | }; | |
2579 | ||
34cbe3a6 | 2580 | static const struct snd_kcontrol_new cxt5066_mixer_master[] = { |
0fb67e98 DD |
2581 | HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), |
2582 | {} | |
2583 | }; | |
2584 | ||
34cbe3a6 | 2585 | static const struct snd_kcontrol_new cxt5066_mixer_master_olpc[] = { |
0fb67e98 DD |
2586 | { |
2587 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2588 | .name = "Master Playback Volume", | |
2589 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | | |
2590 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | | |
2591 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, | |
5e26dfd0 | 2592 | .subdevice = HDA_SUBDEV_AMP_FLAG, |
0fb67e98 DD |
2593 | .info = snd_hda_mixer_amp_volume_info, |
2594 | .get = snd_hda_mixer_amp_volume_get, | |
2595 | .put = snd_hda_mixer_amp_volume_put, | |
2596 | .tlv = { .c = snd_hda_mixer_amp_tlv }, | |
2597 | /* offset by 28 volume steps to limit minimum gain to -46dB */ | |
2598 | .private_value = | |
2599 | HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT, 28), | |
2600 | }, | |
2601 | {} | |
2602 | }; | |
2603 | ||
34cbe3a6 | 2604 | static const struct snd_kcontrol_new cxt5066_mixer_olpc_dc[] = { |
c4cfe66c DD |
2605 | { |
2606 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2607 | .name = "DC Mode Enable Switch", | |
2608 | .info = snd_ctl_boolean_mono_info, | |
2609 | .get = cxt5066_olpc_dc_get, | |
2610 | .put = cxt5066_olpc_dc_put, | |
2611 | }, | |
2612 | { | |
2613 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2614 | .name = "DC Input Bias Enum", | |
2615 | .info = cxt5066_olpc_dc_bias_enum_info, | |
2616 | .get = cxt5066_olpc_dc_bias_enum_get, | |
2617 | .put = cxt5066_olpc_dc_bias_enum_put, | |
2618 | }, | |
2619 | {} | |
2620 | }; | |
2621 | ||
34cbe3a6 | 2622 | static const struct snd_kcontrol_new cxt5066_mixers[] = { |
0fb67e98 DD |
2623 | { |
2624 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2625 | .name = "Master Playback Switch", | |
2626 | .info = cxt_eapd_info, | |
2627 | .get = cxt_eapd_get, | |
2628 | .put = cxt5066_hp_master_sw_put, | |
2629 | .private_value = 0x1d, | |
2630 | }, | |
2631 | ||
2632 | { | |
2633 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
c4cfe66c | 2634 | .name = "Analog Mic Boost Capture Enum", |
0fb67e98 DD |
2635 | .info = cxt5066_mic_boost_mux_enum_info, |
2636 | .get = cxt5066_mic_boost_mux_enum_get, | |
2637 | .put = cxt5066_mic_boost_mux_enum_put, | |
2638 | }, | |
2639 | ||
2640 | HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others), | |
2641 | HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others), | |
2642 | {} | |
2643 | }; | |
2644 | ||
34cbe3a6 | 2645 | static const struct snd_kcontrol_new cxt5066_vostro_mixers[] = { |
254bba6a ER |
2646 | { |
2647 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
28c4edb7 | 2648 | .name = "Internal Mic Boost Capture Enum", |
254bba6a ER |
2649 | .info = cxt5066_mic_boost_mux_enum_info, |
2650 | .get = cxt5066_mic_boost_mux_enum_get, | |
2651 | .put = cxt5066_mic_boost_mux_enum_put, | |
2652 | .private_value = 0x23 | 0x100, | |
2653 | }, | |
2654 | {} | |
2655 | }; | |
2656 | ||
34cbe3a6 | 2657 | static const struct hda_verb cxt5066_init_verbs[] = { |
0fb67e98 DD |
2658 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ |
2659 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ | |
2660 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ | |
2661 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ | |
2662 | ||
2663 | /* Speakers */ | |
2664 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2665 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2666 | ||
2667 | /* HP, Amp */ | |
2668 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2669 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2670 | ||
2671 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2672 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2673 | ||
2674 | /* DAC1 */ | |
2675 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2676 | ||
2677 | /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ | |
2678 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, | |
2679 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2680 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, | |
2681 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2682 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2683 | ||
2684 | /* no digital microphone support yet */ | |
2685 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2686 | ||
2687 | /* Audio input selector */ | |
2688 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, | |
2689 | ||
2690 | /* SPDIF route: PCM */ | |
2691 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
2692 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
2693 | ||
2694 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2695 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2696 | ||
2697 | /* EAPD */ | |
2698 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
2699 | ||
2700 | /* not handling these yet */ | |
2701 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2702 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2703 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2704 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2705 | {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2706 | {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2707 | {0x20, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2708 | {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | |
2709 | { } /* end */ | |
2710 | }; | |
2711 | ||
34cbe3a6 | 2712 | static const struct hda_verb cxt5066_init_verbs_olpc[] = { |
0fb67e98 DD |
2713 | /* Port A: headphones */ |
2714 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2715 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2716 | ||
2717 | /* Port B: external microphone */ | |
75f8991d | 2718 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
0fb67e98 DD |
2719 | |
2720 | /* Port C: internal microphone */ | |
75f8991d | 2721 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
0fb67e98 DD |
2722 | |
2723 | /* Port D: unused */ | |
2724 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2725 | ||
2726 | /* Port E: unused, but has primary EAPD */ | |
2727 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2728 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
2729 | ||
c4cfe66c | 2730 | /* Port F: external DC input through microphone port */ |
0fb67e98 DD |
2731 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
2732 | ||
2733 | /* Port G: internal speakers */ | |
2734 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2735 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2736 | ||
2737 | /* DAC1 */ | |
2738 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2739 | ||
2740 | /* DAC2: unused */ | |
2741 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2742 | ||
2743 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, | |
2744 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2745 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2746 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2747 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
2748 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2749 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2750 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2751 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
2752 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2753 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2754 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2755 | ||
2756 | /* Disable digital microphone port */ | |
2757 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2758 | ||
2759 | /* Audio input selectors */ | |
2760 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, | |
2761 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
2762 | ||
2763 | /* Disable SPDIF */ | |
2764 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2765 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2766 | ||
2767 | /* enable unsolicited events for Port A and B */ | |
2768 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | |
2769 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | |
2770 | { } /* end */ | |
2771 | }; | |
2772 | ||
34cbe3a6 | 2773 | static const struct hda_verb cxt5066_init_verbs_vostro[] = { |
95a618bd ER |
2774 | /* Port A: headphones */ |
2775 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2776 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2777 | ||
2778 | /* Port B: external microphone */ | |
2779 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2780 | ||
2781 | /* Port C: unused */ | |
2782 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2783 | ||
2784 | /* Port D: unused */ | |
2785 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2786 | ||
2787 | /* Port E: unused, but has primary EAPD */ | |
2788 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2789 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
2790 | ||
2791 | /* Port F: unused */ | |
2792 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2793 | ||
2794 | /* Port G: internal speakers */ | |
2795 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2796 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2797 | ||
2798 | /* DAC1 */ | |
2799 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2800 | ||
2801 | /* DAC2: unused */ | |
2802 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2803 | ||
2804 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
2805 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2806 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2807 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2808 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
2809 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2810 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2811 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2812 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
2813 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2814 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2815 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2816 | ||
2817 | /* Digital microphone port */ | |
2818 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2819 | ||
2820 | /* Audio input selectors */ | |
2821 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, | |
2822 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
2823 | ||
2824 | /* Disable SPDIF */ | |
2825 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2826 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2827 | ||
2828 | /* enable unsolicited events for Port A and B */ | |
2829 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | |
2830 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | |
2831 | { } /* end */ | |
2832 | }; | |
2833 | ||
34cbe3a6 | 2834 | static const struct hda_verb cxt5066_init_verbs_ideapad[] = { |
cfd3d8dc GA |
2835 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ |
2836 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ | |
2837 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ | |
2838 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ | |
2839 | ||
2840 | /* Speakers */ | |
2841 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2842 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2843 | ||
2844 | /* HP, Amp */ | |
2845 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2846 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2847 | ||
2848 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2849 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2850 | ||
2851 | /* DAC1 */ | |
2852 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2853 | ||
2854 | /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ | |
2855 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, | |
2856 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2857 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, | |
2858 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2859 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2860 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ | |
2861 | ||
2862 | /* Audio input selector */ | |
2863 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, | |
2864 | {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ | |
2865 | ||
2866 | /* SPDIF route: PCM */ | |
2867 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
2868 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
2869 | ||
2870 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2871 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2872 | ||
2873 | /* internal microphone */ | |
28c4edb7 | 2874 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */ |
cfd3d8dc GA |
2875 | |
2876 | /* EAPD */ | |
2877 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
2878 | ||
2879 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | |
2880 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | |
2881 | { } /* end */ | |
2882 | }; | |
2883 | ||
34cbe3a6 | 2884 | static const struct hda_verb cxt5066_init_verbs_thinkpad[] = { |
7b2bfdbc JT |
2885 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ |
2886 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ | |
2887 | ||
2888 | /* Port G: internal speakers */ | |
2889 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2890 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2891 | ||
2892 | /* Port A: HP, Amp */ | |
2893 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2894 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2895 | ||
2896 | /* Port B: Mic Dock */ | |
2897 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2898 | ||
2899 | /* Port C: Mic */ | |
2900 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2901 | ||
2902 | /* Port D: HP Dock, Amp */ | |
2903 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
2904 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | |
2905 | ||
2906 | /* DAC1 */ | |
2907 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2908 | ||
2909 | /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ | |
2910 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, | |
2911 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2912 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, | |
2913 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2914 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2915 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ | |
2916 | ||
2917 | /* Audio input selector */ | |
2918 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, | |
2919 | {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ | |
2920 | ||
2921 | /* SPDIF route: PCM */ | |
2922 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
2923 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
2924 | ||
2925 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2926 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2927 | ||
2928 | /* internal microphone */ | |
28c4edb7 | 2929 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */ |
7b2bfdbc JT |
2930 | |
2931 | /* EAPD */ | |
2932 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | |
2933 | ||
2934 | /* enable unsolicited events for Port A, B, C and D */ | |
2935 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | |
2936 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | |
2937 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | |
2938 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | |
2939 | { } /* end */ | |
2940 | }; | |
2941 | ||
34cbe3a6 | 2942 | static const struct hda_verb cxt5066_init_verbs_portd_lo[] = { |
0fb67e98 DD |
2943 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
2944 | { } /* end */ | |
2945 | }; | |
2946 | ||
048e78a5 | 2947 | |
34cbe3a6 | 2948 | static const struct hda_verb cxt5066_init_verbs_hp_laptop[] = { |
048e78a5 DH |
2949 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x0}, |
2950 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | |
2951 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | |
2952 | { } /* end */ | |
2953 | }; | |
2954 | ||
0fb67e98 DD |
2955 | /* initialize jack-sensing, too */ |
2956 | static int cxt5066_init(struct hda_codec *codec) | |
2957 | { | |
2958 | snd_printdd("CXT5066: init\n"); | |
2959 | conexant_init(codec); | |
2960 | if (codec->patch_ops.unsol_event) { | |
2961 | cxt5066_hp_automute(codec); | |
02b6b5b6 | 2962 | cxt5066_automic(codec); |
0fb67e98 | 2963 | } |
c4cfe66c | 2964 | cxt5066_set_mic_boost(codec); |
0fb67e98 DD |
2965 | return 0; |
2966 | } | |
2967 | ||
75f8991d DD |
2968 | static int cxt5066_olpc_init(struct hda_codec *codec) |
2969 | { | |
c4cfe66c | 2970 | struct conexant_spec *spec = codec->spec; |
75f8991d DD |
2971 | snd_printdd("CXT5066: init\n"); |
2972 | conexant_init(codec); | |
2973 | cxt5066_hp_automute(codec); | |
c4cfe66c DD |
2974 | if (!spec->dc_enable) { |
2975 | cxt5066_set_mic_boost(codec); | |
2976 | cxt5066_olpc_automic(codec); | |
2977 | } else { | |
2978 | cxt5066_enable_dc(codec); | |
2979 | } | |
75f8991d DD |
2980 | return 0; |
2981 | } | |
2982 | ||
0fb67e98 | 2983 | enum { |
7b2bfdbc | 2984 | CXT5066_LAPTOP, /* Laptops w/ EAPD support */ |
0fb67e98 DD |
2985 | CXT5066_DELL_LAPTOP, /* Dell Laptop */ |
2986 | CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */ | |
1feba3b7 | 2987 | CXT5066_DELL_VOSTRO, /* Dell Vostro 1015i */ |
cfd3d8dc | 2988 | CXT5066_IDEAPAD, /* Lenovo IdeaPad U150 */ |
7b2bfdbc | 2989 | CXT5066_THINKPAD, /* Lenovo ThinkPad T410s, others? */ |
a1d6906e | 2990 | CXT5066_ASUS, /* Asus K52JU, Lenovo G560 - Int mic at 0x1a and Ext mic at 0x1b */ |
048e78a5 | 2991 | CXT5066_HP_LAPTOP, /* HP Laptop */ |
fea4a4f9 | 2992 | CXT5066_AUTO, /* BIOS auto-parser */ |
0fb67e98 DD |
2993 | CXT5066_MODELS |
2994 | }; | |
2995 | ||
ea734963 | 2996 | static const char * const cxt5066_models[CXT5066_MODELS] = { |
7b2bfdbc | 2997 | [CXT5066_LAPTOP] = "laptop", |
0fb67e98 DD |
2998 | [CXT5066_DELL_LAPTOP] = "dell-laptop", |
2999 | [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5", | |
1feba3b7 | 3000 | [CXT5066_DELL_VOSTRO] = "dell-vostro", |
cfd3d8dc | 3001 | [CXT5066_IDEAPAD] = "ideapad", |
7b2bfdbc | 3002 | [CXT5066_THINKPAD] = "thinkpad", |
a1d6906e | 3003 | [CXT5066_ASUS] = "asus", |
048e78a5 | 3004 | [CXT5066_HP_LAPTOP] = "hp-laptop", |
fea4a4f9 | 3005 | [CXT5066_AUTO] = "auto", |
0fb67e98 DD |
3006 | }; |
3007 | ||
34cbe3a6 | 3008 | static const struct snd_pci_quirk cxt5066_cfg_tbl[] = { |
9966db22 | 3009 | SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT5066_AUTO), |
00cd0bb7 | 3010 | SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD), |
1feba3b7 | 3011 | SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO), |
8a96b1e0 | 3012 | SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD), |
ca6cd851 | 3013 | SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO), |
1feba3b7 | 3014 | SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTRO), |
231f50bc | 3015 | SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD), |
ebbd224c DH |
3016 | SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD), |
3017 | SND_PCI_QUIRK(0x1028, 0x0510, "Dell Vostro", CXT5066_IDEAPAD), | |
048e78a5 | 3018 | SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP), |
f6a2491c | 3019 | SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS), |
a1d6906e | 3020 | SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS), |
f6a2491c | 3021 | SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS), |
2ca9cac9 | 3022 | SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD), |
c5366681 | 3023 | SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5), |
5637edb2 DH |
3024 | SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", |
3025 | CXT5066_LAPTOP), | |
3026 | SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5), | |
4d155641 | 3027 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD), |
ef61d4e6 | 3028 | SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD), |
19593875 | 3029 | SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS), |
29c5fbbc | 3030 | SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T510", CXT5066_AUTO), |
ca201c09 | 3031 | SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520 & W520", CXT5066_AUTO), |
84012657 | 3032 | SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT5066_THINKPAD), |
b2cb1292 | 3033 | SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT5066_THINKPAD), |
d2859fd4 | 3034 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo U350", CXT5066_ASUS), |
a1d6906e | 3035 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS), |
af4ccf4f | 3036 | SND_PCI_QUIRK(0x17aa, 0x3938, "Lenovo G565", CXT5066_AUTO), |
22f21d51 | 3037 | SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", CXT5066_IDEAPAD), /* Fallback for Lenovos without dock mic */ |
7ab1fc0a | 3038 | SND_PCI_QUIRK(0x1b0a, 0x2092, "CyberpowerPC Gamer Xplorer N57001", CXT5066_AUTO), |
0fb67e98 DD |
3039 | {} |
3040 | }; | |
3041 | ||
3042 | static int patch_cxt5066(struct hda_codec *codec) | |
3043 | { | |
3044 | struct conexant_spec *spec; | |
3045 | int board_config; | |
3046 | ||
fea4a4f9 TI |
3047 | board_config = snd_hda_check_board_config(codec, CXT5066_MODELS, |
3048 | cxt5066_models, cxt5066_cfg_tbl); | |
fea4a4f9 | 3049 | if (board_config < 0) |
c82693db | 3050 | board_config = CXT5066_AUTO; /* model=auto as default */ |
fea4a4f9 TI |
3051 | if (board_config == CXT5066_AUTO) |
3052 | return patch_conexant_auto(codec); | |
3053 | ||
0fb67e98 DD |
3054 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
3055 | if (!spec) | |
3056 | return -ENOMEM; | |
3057 | codec->spec = spec; | |
3058 | ||
3059 | codec->patch_ops = conexant_patch_ops; | |
75f8991d | 3060 | codec->patch_ops.init = conexant_init; |
0fb67e98 DD |
3061 | |
3062 | spec->dell_automute = 0; | |
3063 | spec->multiout.max_channels = 2; | |
3064 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5066_dac_nids); | |
3065 | spec->multiout.dac_nids = cxt5066_dac_nids; | |
f6a2491c AR |
3066 | conexant_check_dig_outs(codec, cxt5066_digout_pin_nids, |
3067 | ARRAY_SIZE(cxt5066_digout_pin_nids)); | |
0fb67e98 DD |
3068 | spec->num_adc_nids = 1; |
3069 | spec->adc_nids = cxt5066_adc_nids; | |
3070 | spec->capsrc_nids = cxt5066_capsrc_nids; | |
3071 | spec->input_mux = &cxt5066_capture_source; | |
3072 | ||
3073 | spec->port_d_mode = PIN_HP; | |
3074 | ||
3075 | spec->num_init_verbs = 1; | |
3076 | spec->init_verbs[0] = cxt5066_init_verbs; | |
3077 | spec->num_channel_mode = ARRAY_SIZE(cxt5066_modes); | |
3078 | spec->channel_mode = cxt5066_modes; | |
3079 | spec->cur_adc = 0; | |
3080 | spec->cur_adc_idx = 0; | |
3081 | ||
3507e2a8 TI |
3082 | set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); |
3083 | ||
0fb67e98 DD |
3084 | switch (board_config) { |
3085 | default: | |
3086 | case CXT5066_LAPTOP: | |
3087 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; | |
3088 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | |
3089 | break; | |
3090 | case CXT5066_DELL_LAPTOP: | |
3091 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; | |
3092 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | |
3093 | ||
3094 | spec->port_d_mode = PIN_OUT; | |
3095 | spec->init_verbs[spec->num_init_verbs] = cxt5066_init_verbs_portd_lo; | |
3096 | spec->num_init_verbs++; | |
3097 | spec->dell_automute = 1; | |
3098 | break; | |
a1d6906e | 3099 | case CXT5066_ASUS: |
048e78a5 DH |
3100 | case CXT5066_HP_LAPTOP: |
3101 | codec->patch_ops.init = cxt5066_init; | |
02b6b5b6 | 3102 | codec->patch_ops.unsol_event = cxt5066_unsol_event; |
048e78a5 DH |
3103 | spec->init_verbs[spec->num_init_verbs] = |
3104 | cxt5066_init_verbs_hp_laptop; | |
3105 | spec->num_init_verbs++; | |
a1d6906e DH |
3106 | spec->hp_laptop = board_config == CXT5066_HP_LAPTOP; |
3107 | spec->asus = board_config == CXT5066_ASUS; | |
048e78a5 DH |
3108 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
3109 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | |
3110 | /* no S/PDIF out */ | |
f6a2491c AR |
3111 | if (board_config == CXT5066_HP_LAPTOP) |
3112 | spec->multiout.dig_out_nid = 0; | |
048e78a5 DH |
3113 | /* input source automatically selected */ |
3114 | spec->input_mux = NULL; | |
3115 | spec->port_d_mode = 0; | |
3116 | spec->mic_boost = 3; /* default 30dB gain */ | |
3117 | break; | |
3118 | ||
0fb67e98 | 3119 | case CXT5066_OLPC_XO_1_5: |
75f8991d DD |
3120 | codec->patch_ops.init = cxt5066_olpc_init; |
3121 | codec->patch_ops.unsol_event = cxt5066_olpc_unsol_event; | |
0fb67e98 DD |
3122 | spec->init_verbs[0] = cxt5066_init_verbs_olpc; |
3123 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; | |
c4cfe66c | 3124 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_olpc_dc; |
0fb67e98 DD |
3125 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
3126 | spec->port_d_mode = 0; | |
c4cfe66c | 3127 | spec->mic_boost = 3; /* default 30dB gain */ |
0fb67e98 DD |
3128 | |
3129 | /* no S/PDIF out */ | |
3130 | spec->multiout.dig_out_nid = 0; | |
3131 | ||
95a618bd ER |
3132 | /* input source automatically selected */ |
3133 | spec->input_mux = NULL; | |
75f8991d DD |
3134 | |
3135 | /* our capture hooks which allow us to turn on the microphone LED | |
3136 | * at the right time */ | |
3137 | spec->capture_prepare = cxt5066_olpc_capture_prepare; | |
3138 | spec->capture_cleanup = cxt5066_olpc_capture_cleanup; | |
95a618bd | 3139 | break; |
1feba3b7 | 3140 | case CXT5066_DELL_VOSTRO: |
75f8991d | 3141 | codec->patch_ops.init = cxt5066_init; |
02b6b5b6 | 3142 | codec->patch_ops.unsol_event = cxt5066_unsol_event; |
95a618bd ER |
3143 | spec->init_verbs[0] = cxt5066_init_verbs_vostro; |
3144 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; | |
3145 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | |
254bba6a | 3146 | spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers; |
95a618bd | 3147 | spec->port_d_mode = 0; |
254bba6a | 3148 | spec->dell_vostro = 1; |
c4cfe66c | 3149 | spec->mic_boost = 3; /* default 30dB gain */ |
95a618bd ER |
3150 | |
3151 | /* no S/PDIF out */ | |
3152 | spec->multiout.dig_out_nid = 0; | |
3153 | ||
cfd3d8dc GA |
3154 | /* input source automatically selected */ |
3155 | spec->input_mux = NULL; | |
3156 | break; | |
3157 | case CXT5066_IDEAPAD: | |
3158 | codec->patch_ops.init = cxt5066_init; | |
02b6b5b6 | 3159 | codec->patch_ops.unsol_event = cxt5066_unsol_event; |
cfd3d8dc GA |
3160 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
3161 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | |
3162 | spec->init_verbs[0] = cxt5066_init_verbs_ideapad; | |
3163 | spec->port_d_mode = 0; | |
3164 | spec->ideapad = 1; | |
3165 | spec->mic_boost = 2; /* default 20dB gain */ | |
3166 | ||
3167 | /* no S/PDIF out */ | |
3168 | spec->multiout.dig_out_nid = 0; | |
3169 | ||
7b2bfdbc JT |
3170 | /* input source automatically selected */ |
3171 | spec->input_mux = NULL; | |
3172 | break; | |
3173 | case CXT5066_THINKPAD: | |
3174 | codec->patch_ops.init = cxt5066_init; | |
02b6b5b6 | 3175 | codec->patch_ops.unsol_event = cxt5066_unsol_event; |
7b2bfdbc JT |
3176 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
3177 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | |
3178 | spec->init_verbs[0] = cxt5066_init_verbs_thinkpad; | |
3179 | spec->thinkpad = 1; | |
3180 | spec->port_d_mode = PIN_OUT; | |
3181 | spec->mic_boost = 2; /* default 20dB gain */ | |
3182 | ||
3183 | /* no S/PDIF out */ | |
3184 | spec->multiout.dig_out_nid = 0; | |
3185 | ||
0fb67e98 DD |
3186 | /* input source automatically selected */ |
3187 | spec->input_mux = NULL; | |
3188 | break; | |
3189 | } | |
3190 | ||
3507e2a8 TI |
3191 | if (spec->beep_amp) |
3192 | snd_hda_attach_beep_device(codec, spec->beep_amp); | |
3193 | ||
0fb67e98 DD |
3194 | return 0; |
3195 | } | |
461e2c78 | 3196 | |
f2e5731d TI |
3197 | /* |
3198 | * Automatic parser for CX20641 & co | |
3199 | */ | |
3200 | ||
6764bcef TI |
3201 | static int cx_auto_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
3202 | struct hda_codec *codec, | |
3203 | unsigned int stream_tag, | |
3204 | unsigned int format, | |
3205 | struct snd_pcm_substream *substream) | |
3206 | { | |
3207 | struct conexant_spec *spec = codec->spec; | |
47ad1f4e | 3208 | hda_nid_t adc = spec->imux_info[spec->cur_mux[0]].adc; |
6764bcef TI |
3209 | if (spec->adc_switching) { |
3210 | spec->cur_adc = adc; | |
3211 | spec->cur_adc_stream_tag = stream_tag; | |
3212 | spec->cur_adc_format = format; | |
3213 | } | |
3214 | snd_hda_codec_setup_stream(codec, adc, stream_tag, 0, format); | |
3215 | return 0; | |
3216 | } | |
3217 | ||
3218 | static int cx_auto_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
3219 | struct hda_codec *codec, | |
3220 | struct snd_pcm_substream *substream) | |
3221 | { | |
3222 | struct conexant_spec *spec = codec->spec; | |
3223 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); | |
3224 | spec->cur_adc = 0; | |
3225 | return 0; | |
3226 | } | |
3227 | ||
3228 | static const struct hda_pcm_stream cx_auto_pcm_analog_capture = { | |
3229 | .substreams = 1, | |
3230 | .channels_min = 2, | |
3231 | .channels_max = 2, | |
3232 | .nid = 0, /* fill later */ | |
3233 | .ops = { | |
3234 | .prepare = cx_auto_capture_pcm_prepare, | |
3235 | .cleanup = cx_auto_capture_pcm_cleanup | |
3236 | }, | |
3237 | }; | |
3238 | ||
34cbe3a6 | 3239 | static const hda_nid_t cx_auto_adc_nids[] = { 0x14 }; |
f2e5731d | 3240 | |
8d087c76 TI |
3241 | #define get_connection_index(codec, mux, nid)\ |
3242 | snd_hda_get_conn_index(codec, mux, nid, 0) | |
f2e5731d TI |
3243 | |
3244 | /* get an unassigned DAC from the given list. | |
3245 | * Return the nid if found and reduce the DAC list, or return zero if | |
3246 | * not found | |
3247 | */ | |
3248 | static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t pin, | |
3249 | hda_nid_t *dacs, int *num_dacs) | |
3250 | { | |
3251 | int i, nums = *num_dacs; | |
3252 | hda_nid_t ret = 0; | |
3253 | ||
3254 | for (i = 0; i < nums; i++) { | |
3255 | if (get_connection_index(codec, pin, dacs[i]) >= 0) { | |
3256 | ret = dacs[i]; | |
3257 | break; | |
3258 | } | |
3259 | } | |
3260 | if (!ret) | |
3261 | return 0; | |
3262 | if (--nums > 0) | |
3263 | memmove(dacs, dacs + 1, nums * sizeof(hda_nid_t)); | |
3264 | *num_dacs = nums; | |
3265 | return ret; | |
3266 | } | |
3267 | ||
3268 | #define MAX_AUTO_DACS 5 | |
3269 | ||
1f015f5f TI |
3270 | #define DAC_SLAVE_FLAG 0x8000 /* filled dac is a slave */ |
3271 | ||
f2e5731d TI |
3272 | /* fill analog DAC list from the widget tree */ |
3273 | static int fill_cx_auto_dacs(struct hda_codec *codec, hda_nid_t *dacs) | |
3274 | { | |
3275 | hda_nid_t nid, end_nid; | |
3276 | int nums = 0; | |
3277 | ||
3278 | end_nid = codec->start_nid + codec->num_nodes; | |
3279 | for (nid = codec->start_nid; nid < end_nid; nid++) { | |
3280 | unsigned int wcaps = get_wcaps(codec, nid); | |
3281 | unsigned int type = get_wcaps_type(wcaps); | |
3282 | if (type == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL)) { | |
3283 | dacs[nums++] = nid; | |
3284 | if (nums >= MAX_AUTO_DACS) | |
3285 | break; | |
3286 | } | |
3287 | } | |
3288 | return nums; | |
3289 | } | |
3290 | ||
3291 | /* fill pin_dac_pair list from the pin and dac list */ | |
3292 | static int fill_dacs_for_pins(struct hda_codec *codec, hda_nid_t *pins, | |
3293 | int num_pins, hda_nid_t *dacs, int *rest, | |
468c5458 DH |
3294 | struct pin_dac_pair *filled, int nums, |
3295 | int type) | |
f2e5731d | 3296 | { |
468c5458 | 3297 | int i, start = nums; |
f2e5731d | 3298 | |
468c5458 | 3299 | for (i = 0; i < num_pins; i++, nums++) { |
f2e5731d TI |
3300 | filled[nums].pin = pins[i]; |
3301 | filled[nums].type = type; | |
3302 | filled[nums].dac = get_unassigned_dac(codec, pins[i], dacs, rest); | |
468c5458 DH |
3303 | if (filled[nums].dac) |
3304 | continue; | |
3305 | if (filled[start].dac && get_connection_index(codec, pins[i], filled[start].dac) >= 0) { | |
3306 | filled[nums].dac = filled[start].dac | DAC_SLAVE_FLAG; | |
3307 | continue; | |
3308 | } | |
3309 | if (filled[0].dac && get_connection_index(codec, pins[i], filled[0].dac) >= 0) { | |
1f015f5f | 3310 | filled[nums].dac = filled[0].dac | DAC_SLAVE_FLAG; |
468c5458 DH |
3311 | continue; |
3312 | } | |
3313 | snd_printdd("Failed to find a DAC for pin 0x%x", pins[i]); | |
f2e5731d TI |
3314 | } |
3315 | return nums; | |
3316 | } | |
3317 | ||
3318 | /* parse analog output paths */ | |
3319 | static void cx_auto_parse_output(struct hda_codec *codec) | |
3320 | { | |
3321 | struct conexant_spec *spec = codec->spec; | |
3322 | struct auto_pin_cfg *cfg = &spec->autocfg; | |
3323 | hda_nid_t dacs[MAX_AUTO_DACS]; | |
3324 | int i, j, nums, rest; | |
3325 | ||
3326 | rest = fill_cx_auto_dacs(codec, dacs); | |
3327 | /* parse all analog output pins */ | |
3328 | nums = fill_dacs_for_pins(codec, cfg->line_out_pins, cfg->line_outs, | |
468c5458 DH |
3329 | dacs, &rest, spec->dac_info, 0, |
3330 | AUTO_PIN_LINE_OUT); | |
3331 | nums = fill_dacs_for_pins(codec, cfg->hp_pins, cfg->hp_outs, | |
3332 | dacs, &rest, spec->dac_info, nums, | |
3333 | AUTO_PIN_HP_OUT); | |
3334 | nums = fill_dacs_for_pins(codec, cfg->speaker_pins, cfg->speaker_outs, | |
3335 | dacs, &rest, spec->dac_info, nums, | |
3336 | AUTO_PIN_SPEAKER_OUT); | |
f2e5731d TI |
3337 | spec->dac_info_filled = nums; |
3338 | /* fill multiout struct */ | |
3339 | for (i = 0; i < nums; i++) { | |
3340 | hda_nid_t dac = spec->dac_info[i].dac; | |
1f015f5f | 3341 | if (!dac || (dac & DAC_SLAVE_FLAG)) |
f2e5731d TI |
3342 | continue; |
3343 | switch (spec->dac_info[i].type) { | |
3344 | case AUTO_PIN_LINE_OUT: | |
3345 | spec->private_dac_nids[spec->multiout.num_dacs] = dac; | |
3346 | spec->multiout.num_dacs++; | |
3347 | break; | |
3348 | case AUTO_PIN_HP_OUT: | |
3349 | case AUTO_PIN_SPEAKER_OUT: | |
3350 | if (!spec->multiout.hp_nid) { | |
3351 | spec->multiout.hp_nid = dac; | |
3352 | break; | |
3353 | } | |
3354 | for (j = 0; j < ARRAY_SIZE(spec->multiout.extra_out_nid); j++) | |
3355 | if (!spec->multiout.extra_out_nid[j]) { | |
3356 | spec->multiout.extra_out_nid[j] = dac; | |
3357 | break; | |
3358 | } | |
3359 | break; | |
3360 | } | |
3361 | } | |
3362 | spec->multiout.dac_nids = spec->private_dac_nids; | |
89724958 | 3363 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
f2e5731d | 3364 | |
03697e2a TI |
3365 | for (i = 0; i < cfg->hp_outs; i++) { |
3366 | if (is_jack_detectable(codec, cfg->hp_pins[i])) { | |
3367 | spec->auto_mute = 1; | |
3368 | break; | |
3369 | } | |
3370 | } | |
e2df82ff TI |
3371 | if (spec->auto_mute && |
3372 | cfg->line_out_pins[0] && | |
3373 | cfg->line_out_type != AUTO_PIN_SPEAKER_OUT && | |
03697e2a TI |
3374 | cfg->line_out_pins[0] != cfg->hp_pins[0] && |
3375 | cfg->line_out_pins[0] != cfg->speaker_pins[0]) { | |
3376 | for (i = 0; i < cfg->line_outs; i++) { | |
3377 | if (is_jack_detectable(codec, cfg->line_out_pins[i])) { | |
3378 | spec->detect_line = 1; | |
3379 | break; | |
3380 | } | |
3381 | } | |
3382 | spec->automute_lines = spec->detect_line; | |
3383 | } | |
3384 | ||
f2e5731d TI |
3385 | spec->vmaster_nid = spec->private_dac_nids[0]; |
3386 | } | |
3387 | ||
da339866 TI |
3388 | static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins, |
3389 | hda_nid_t *pins, bool on); | |
3390 | ||
03697e2a TI |
3391 | static void do_automute(struct hda_codec *codec, int num_pins, |
3392 | hda_nid_t *pins, bool on) | |
3393 | { | |
254f2968 | 3394 | struct conexant_spec *spec = codec->spec; |
03697e2a TI |
3395 | int i; |
3396 | for (i = 0; i < num_pins; i++) | |
3397 | snd_hda_codec_write(codec, pins[i], 0, | |
3398 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
3399 | on ? PIN_OUT : 0); | |
254f2968 TI |
3400 | if (spec->pin_eapd_ctrls) |
3401 | cx_auto_turn_eapd(codec, num_pins, pins, on); | |
03697e2a TI |
3402 | } |
3403 | ||
3404 | static int detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins) | |
3405 | { | |
3406 | int i, present = 0; | |
3407 | ||
3408 | for (i = 0; i < num_pins; i++) { | |
3409 | hda_nid_t nid = pins[i]; | |
3410 | if (!nid || !is_jack_detectable(codec, nid)) | |
3411 | break; | |
03697e2a TI |
3412 | present |= snd_hda_jack_detect(codec, nid); |
3413 | } | |
3414 | return present; | |
3415 | } | |
3416 | ||
f2e5731d | 3417 | /* auto-mute/unmute speaker and line outs according to headphone jack */ |
03697e2a TI |
3418 | static void cx_auto_update_speakers(struct hda_codec *codec) |
3419 | { | |
3420 | struct conexant_spec *spec = codec->spec; | |
3421 | struct auto_pin_cfg *cfg = &spec->autocfg; | |
e2df82ff | 3422 | int on = 1; |
03697e2a | 3423 | |
e2df82ff | 3424 | /* turn on HP EAPD when HP jacks are present */ |
254f2968 TI |
3425 | if (spec->pin_eapd_ctrls) { |
3426 | if (spec->auto_mute) | |
3427 | on = spec->hp_present; | |
3428 | cx_auto_turn_eapd(codec, cfg->hp_outs, cfg->hp_pins, on); | |
3429 | } | |
3430 | ||
e2df82ff TI |
3431 | /* mute speakers in auto-mode if HP or LO jacks are plugged */ |
3432 | if (spec->auto_mute) | |
3433 | on = !(spec->hp_present || | |
3434 | (spec->detect_line && spec->line_present)); | |
3435 | do_automute(codec, cfg->speaker_outs, cfg->speaker_pins, on); | |
03697e2a TI |
3436 | |
3437 | /* toggle line-out mutes if needed, too */ | |
3438 | /* if LO is a copy of either HP or Speaker, don't need to handle it */ | |
3439 | if (cfg->line_out_pins[0] == cfg->hp_pins[0] || | |
3440 | cfg->line_out_pins[0] == cfg->speaker_pins[0]) | |
3441 | return; | |
e2df82ff TI |
3442 | if (spec->auto_mute) { |
3443 | /* mute LO in auto-mode when HP jack is present */ | |
3444 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT || | |
3445 | spec->automute_lines) | |
3446 | on = !spec->hp_present; | |
3447 | else | |
3448 | on = 1; | |
3449 | } | |
3450 | do_automute(codec, cfg->line_outs, cfg->line_out_pins, on); | |
03697e2a TI |
3451 | } |
3452 | ||
f2e5731d TI |
3453 | static void cx_auto_hp_automute(struct hda_codec *codec) |
3454 | { | |
3455 | struct conexant_spec *spec = codec->spec; | |
3456 | struct auto_pin_cfg *cfg = &spec->autocfg; | |
f2e5731d TI |
3457 | |
3458 | if (!spec->auto_mute) | |
3459 | return; | |
03697e2a TI |
3460 | spec->hp_present = detect_jacks(codec, cfg->hp_outs, cfg->hp_pins); |
3461 | cx_auto_update_speakers(codec); | |
3462 | } | |
3463 | ||
3464 | static void cx_auto_line_automute(struct hda_codec *codec) | |
3465 | { | |
3466 | struct conexant_spec *spec = codec->spec; | |
3467 | struct auto_pin_cfg *cfg = &spec->autocfg; | |
3468 | ||
3469 | if (!spec->auto_mute || !spec->detect_line) | |
3470 | return; | |
3471 | spec->line_present = detect_jacks(codec, cfg->line_outs, | |
3472 | cfg->line_out_pins); | |
3473 | cx_auto_update_speakers(codec); | |
3474 | } | |
3475 | ||
3476 | static int cx_automute_mode_info(struct snd_kcontrol *kcontrol, | |
3477 | struct snd_ctl_elem_info *uinfo) | |
3478 | { | |
3479 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3480 | struct conexant_spec *spec = codec->spec; | |
3481 | static const char * const texts2[] = { | |
3482 | "Disabled", "Enabled" | |
3483 | }; | |
3484 | static const char * const texts3[] = { | |
3485 | "Disabled", "Speaker Only", "Line-Out+Speaker" | |
3486 | }; | |
3487 | const char * const *texts; | |
3488 | ||
3489 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
3490 | uinfo->count = 1; | |
3491 | if (spec->automute_hp_lo) { | |
3492 | uinfo->value.enumerated.items = 3; | |
3493 | texts = texts3; | |
3494 | } else { | |
3495 | uinfo->value.enumerated.items = 2; | |
3496 | texts = texts2; | |
f2e5731d | 3497 | } |
03697e2a TI |
3498 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) |
3499 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; | |
3500 | strcpy(uinfo->value.enumerated.name, | |
3501 | texts[uinfo->value.enumerated.item]); | |
3502 | return 0; | |
3503 | } | |
3504 | ||
3505 | static int cx_automute_mode_get(struct snd_kcontrol *kcontrol, | |
3506 | struct snd_ctl_elem_value *ucontrol) | |
3507 | { | |
3508 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3509 | struct conexant_spec *spec = codec->spec; | |
3510 | unsigned int val; | |
3511 | if (!spec->auto_mute) | |
3512 | val = 0; | |
3513 | else if (!spec->automute_lines) | |
3514 | val = 1; | |
3515 | else | |
3516 | val = 2; | |
3517 | ucontrol->value.enumerated.item[0] = val; | |
3518 | return 0; | |
3519 | } | |
3520 | ||
3521 | static int cx_automute_mode_put(struct snd_kcontrol *kcontrol, | |
3522 | struct snd_ctl_elem_value *ucontrol) | |
3523 | { | |
3524 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3525 | struct conexant_spec *spec = codec->spec; | |
3526 | ||
3527 | switch (ucontrol->value.enumerated.item[0]) { | |
3528 | case 0: | |
3529 | if (!spec->auto_mute) | |
3530 | return 0; | |
3531 | spec->auto_mute = 0; | |
3532 | break; | |
3533 | case 1: | |
3534 | if (spec->auto_mute && !spec->automute_lines) | |
3535 | return 0; | |
3536 | spec->auto_mute = 1; | |
3537 | spec->automute_lines = 0; | |
3538 | break; | |
3539 | case 2: | |
3540 | if (!spec->automute_hp_lo) | |
3541 | return -EINVAL; | |
3542 | if (spec->auto_mute && spec->automute_lines) | |
3543 | return 0; | |
3544 | spec->auto_mute = 1; | |
3545 | spec->automute_lines = 1; | |
3546 | break; | |
3547 | default: | |
3548 | return -EINVAL; | |
f2e5731d | 3549 | } |
03697e2a TI |
3550 | cx_auto_update_speakers(codec); |
3551 | return 1; | |
f2e5731d TI |
3552 | } |
3553 | ||
03697e2a TI |
3554 | static const struct snd_kcontrol_new cx_automute_mode_enum[] = { |
3555 | { | |
3556 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
3557 | .name = "Auto-Mute Mode", | |
3558 | .info = cx_automute_mode_info, | |
3559 | .get = cx_automute_mode_get, | |
3560 | .put = cx_automute_mode_put, | |
3561 | }, | |
3562 | { } | |
3563 | }; | |
3564 | ||
6764bcef TI |
3565 | static int cx_auto_mux_enum_info(struct snd_kcontrol *kcontrol, |
3566 | struct snd_ctl_elem_info *uinfo) | |
3567 | { | |
3568 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3569 | struct conexant_spec *spec = codec->spec; | |
3570 | ||
3571 | return snd_hda_input_mux_info(&spec->private_imux, uinfo); | |
3572 | } | |
3573 | ||
3574 | static int cx_auto_mux_enum_get(struct snd_kcontrol *kcontrol, | |
3575 | struct snd_ctl_elem_value *ucontrol) | |
3576 | { | |
3577 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3578 | struct conexant_spec *spec = codec->spec; | |
3579 | ||
3580 | ucontrol->value.enumerated.item[0] = spec->cur_mux[0]; | |
3581 | return 0; | |
3582 | } | |
3583 | ||
5c9887e0 TI |
3584 | /* look for the route the given pin from mux and return the index; |
3585 | * if do_select is set, actually select the route. | |
3586 | */ | |
3587 | static int __select_input_connection(struct hda_codec *codec, hda_nid_t mux, | |
cf27f29a TI |
3588 | hda_nid_t pin, hda_nid_t *srcp, |
3589 | bool do_select, int depth) | |
5c9887e0 TI |
3590 | { |
3591 | hda_nid_t conn[HDA_MAX_NUM_INPUTS]; | |
3592 | int i, nums; | |
3593 | ||
cf27f29a TI |
3594 | switch (get_wcaps_type(get_wcaps(codec, mux))) { |
3595 | case AC_WID_AUD_IN: | |
3596 | case AC_WID_AUD_SEL: | |
3597 | case AC_WID_AUD_MIX: | |
3598 | break; | |
3599 | default: | |
3600 | return -1; | |
3601 | } | |
3602 | ||
5c9887e0 TI |
3603 | nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn)); |
3604 | for (i = 0; i < nums; i++) | |
3605 | if (conn[i] == pin) { | |
3606 | if (do_select) | |
3607 | snd_hda_codec_write(codec, mux, 0, | |
3608 | AC_VERB_SET_CONNECT_SEL, i); | |
cf27f29a TI |
3609 | if (srcp) |
3610 | *srcp = mux; | |
5c9887e0 TI |
3611 | return i; |
3612 | } | |
3613 | depth++; | |
3614 | if (depth == 2) | |
3615 | return -1; | |
3616 | for (i = 0; i < nums; i++) { | |
cf27f29a | 3617 | int ret = __select_input_connection(codec, conn[i], pin, srcp, |
5c9887e0 TI |
3618 | do_select, depth); |
3619 | if (ret >= 0) { | |
3620 | if (do_select) | |
3621 | snd_hda_codec_write(codec, mux, 0, | |
3622 | AC_VERB_SET_CONNECT_SEL, i); | |
cf27f29a | 3623 | return i; |
5c9887e0 TI |
3624 | } |
3625 | } | |
3626 | return -1; | |
3627 | } | |
3628 | ||
3629 | static void select_input_connection(struct hda_codec *codec, hda_nid_t mux, | |
3630 | hda_nid_t pin) | |
3631 | { | |
cf27f29a | 3632 | __select_input_connection(codec, mux, pin, NULL, true, 0); |
5c9887e0 TI |
3633 | } |
3634 | ||
3635 | static int get_input_connection(struct hda_codec *codec, hda_nid_t mux, | |
3636 | hda_nid_t pin) | |
3637 | { | |
cf27f29a | 3638 | return __select_input_connection(codec, mux, pin, NULL, false, 0); |
5c9887e0 TI |
3639 | } |
3640 | ||
6764bcef TI |
3641 | static int cx_auto_mux_enum_update(struct hda_codec *codec, |
3642 | const struct hda_input_mux *imux, | |
3643 | unsigned int idx) | |
3644 | { | |
3645 | struct conexant_spec *spec = codec->spec; | |
3646 | hda_nid_t adc; | |
313d2c06 | 3647 | int changed = 1; |
6764bcef TI |
3648 | |
3649 | if (!imux->num_items) | |
3650 | return 0; | |
3651 | if (idx >= imux->num_items) | |
3652 | idx = imux->num_items - 1; | |
3653 | if (spec->cur_mux[0] == idx) | |
313d2c06 | 3654 | changed = 0; |
47ad1f4e TI |
3655 | adc = spec->imux_info[idx].adc; |
3656 | select_input_connection(codec, spec->imux_info[idx].adc, | |
3657 | spec->imux_info[idx].pin); | |
6764bcef TI |
3658 | if (spec->cur_adc && spec->cur_adc != adc) { |
3659 | /* stream is running, let's swap the current ADC */ | |
3660 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); | |
3661 | spec->cur_adc = adc; | |
3662 | snd_hda_codec_setup_stream(codec, adc, | |
3663 | spec->cur_adc_stream_tag, 0, | |
3664 | spec->cur_adc_format); | |
3665 | } | |
3666 | spec->cur_mux[0] = idx; | |
313d2c06 | 3667 | return changed; |
6764bcef TI |
3668 | } |
3669 | ||
3670 | static int cx_auto_mux_enum_put(struct snd_kcontrol *kcontrol, | |
3671 | struct snd_ctl_elem_value *ucontrol) | |
3672 | { | |
3673 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3674 | struct conexant_spec *spec = codec->spec; | |
3675 | ||
3676 | return cx_auto_mux_enum_update(codec, &spec->private_imux, | |
3677 | ucontrol->value.enumerated.item[0]); | |
3678 | } | |
3679 | ||
3680 | static const struct snd_kcontrol_new cx_auto_capture_mixers[] = { | |
3681 | { | |
3682 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
3683 | .name = "Capture Source", | |
3684 | .info = cx_auto_mux_enum_info, | |
3685 | .get = cx_auto_mux_enum_get, | |
3686 | .put = cx_auto_mux_enum_put | |
3687 | }, | |
3688 | {} | |
3689 | }; | |
3690 | ||
43c1b2e9 TI |
3691 | static bool select_automic(struct hda_codec *codec, int idx, bool detect) |
3692 | { | |
3693 | struct conexant_spec *spec = codec->spec; | |
3694 | if (idx < 0) | |
3695 | return false; | |
3696 | if (detect && !snd_hda_jack_detect(codec, spec->imux_info[idx].pin)) | |
3697 | return false; | |
3698 | cx_auto_mux_enum_update(codec, &spec->private_imux, idx); | |
3699 | return true; | |
3700 | } | |
3701 | ||
f2e5731d TI |
3702 | /* automatic switch internal and external mic */ |
3703 | static void cx_auto_automic(struct hda_codec *codec) | |
3704 | { | |
3705 | struct conexant_spec *spec = codec->spec; | |
f2e5731d TI |
3706 | |
3707 | if (!spec->auto_mic) | |
3708 | return; | |
43c1b2e9 TI |
3709 | if (!select_automic(codec, spec->auto_mic_ext, true)) |
3710 | if (!select_automic(codec, spec->auto_mic_dock, true)) | |
3711 | select_automic(codec, spec->auto_mic_int, false); | |
f2e5731d TI |
3712 | } |
3713 | ||
3714 | static void cx_auto_unsol_event(struct hda_codec *codec, unsigned int res) | |
3715 | { | |
3a93897e | 3716 | switch (snd_hda_jack_get_action(codec, res >> 26)) { |
f2e5731d TI |
3717 | case CONEXANT_HP_EVENT: |
3718 | cx_auto_hp_automute(codec); | |
03697e2a TI |
3719 | break; |
3720 | case CONEXANT_LINE_EVENT: | |
3721 | cx_auto_line_automute(codec); | |
f2e5731d TI |
3722 | break; |
3723 | case CONEXANT_MIC_EVENT: | |
3724 | cx_auto_automic(codec); | |
f2e5731d TI |
3725 | break; |
3726 | } | |
01a61e12 | 3727 | snd_hda_jack_report_sync(codec); |
f2e5731d TI |
3728 | } |
3729 | ||
f2e5731d | 3730 | /* check whether the pin config is suitable for auto-mic switching; |
43c1b2e9 TI |
3731 | * auto-mic is enabled only when one int-mic and one ext- and/or |
3732 | * one dock-mic exist | |
f2e5731d TI |
3733 | */ |
3734 | static void cx_auto_check_auto_mic(struct hda_codec *codec) | |
3735 | { | |
3736 | struct conexant_spec *spec = codec->spec; | |
43c1b2e9 TI |
3737 | int pset[INPUT_PIN_ATTR_NORMAL + 1]; |
3738 | int i; | |
f2e5731d | 3739 | |
506a4196 | 3740 | for (i = 0; i < ARRAY_SIZE(pset); i++) |
43c1b2e9 TI |
3741 | pset[i] = -1; |
3742 | for (i = 0; i < spec->private_imux.num_items; i++) { | |
3743 | hda_nid_t pin = spec->imux_info[i].pin; | |
3744 | unsigned int def_conf = snd_hda_codec_get_pincfg(codec, pin); | |
b55fcb50 | 3745 | int type, attr; |
43c1b2e9 TI |
3746 | attr = snd_hda_get_input_pin_attr(def_conf); |
3747 | if (attr == INPUT_PIN_ATTR_UNUSED) | |
b55fcb50 | 3748 | return; /* invalid entry */ |
43c1b2e9 TI |
3749 | if (attr > INPUT_PIN_ATTR_NORMAL) |
3750 | attr = INPUT_PIN_ATTR_NORMAL; | |
3751 | if (attr != INPUT_PIN_ATTR_INT && | |
3752 | !is_jack_detectable(codec, pin)) | |
b55fcb50 TI |
3753 | return; /* non-detectable pin */ |
3754 | type = get_defcfg_device(def_conf); | |
3755 | if (type != AC_JACK_MIC_IN && | |
3756 | (attr != INPUT_PIN_ATTR_DOCK || type != AC_JACK_LINE_IN)) | |
3757 | return; /* no valid input type */ | |
43c1b2e9 TI |
3758 | if (pset[attr] >= 0) |
3759 | return; /* already occupied */ | |
3760 | pset[attr] = i; | |
f2e5731d | 3761 | } |
43c1b2e9 TI |
3762 | if (pset[INPUT_PIN_ATTR_INT] < 0 || |
3763 | (pset[INPUT_PIN_ATTR_NORMAL] < 0 && pset[INPUT_PIN_ATTR_DOCK])) | |
3764 | return; /* no input to switch*/ | |
3765 | spec->auto_mic = 1; | |
3766 | spec->auto_mic_ext = pset[INPUT_PIN_ATTR_NORMAL]; | |
3767 | spec->auto_mic_dock = pset[INPUT_PIN_ATTR_DOCK]; | |
3768 | spec->auto_mic_int = pset[INPUT_PIN_ATTR_INT]; | |
f2e5731d TI |
3769 | } |
3770 | ||
3771 | static void cx_auto_parse_input(struct hda_codec *codec) | |
3772 | { | |
3773 | struct conexant_spec *spec = codec->spec; | |
3774 | struct auto_pin_cfg *cfg = &spec->autocfg; | |
3775 | struct hda_input_mux *imux; | |
6764bcef | 3776 | int i, j; |
f2e5731d TI |
3777 | |
3778 | imux = &spec->private_imux; | |
3779 | for (i = 0; i < cfg->num_inputs; i++) { | |
6764bcef TI |
3780 | for (j = 0; j < spec->num_adc_nids; j++) { |
3781 | hda_nid_t adc = spec->adc_nids[j]; | |
5c9887e0 TI |
3782 | int idx = get_input_connection(codec, adc, |
3783 | cfg->inputs[i].pin); | |
6764bcef TI |
3784 | if (idx >= 0) { |
3785 | const char *label; | |
3786 | label = hda_get_autocfg_input_label(codec, cfg, i); | |
47ad1f4e TI |
3787 | spec->imux_info[imux->num_items].index = i; |
3788 | spec->imux_info[imux->num_items].boost = 0; | |
3789 | spec->imux_info[imux->num_items].adc = adc; | |
3790 | spec->imux_info[imux->num_items].pin = | |
f6100bb4 | 3791 | cfg->inputs[i].pin; |
6764bcef | 3792 | snd_hda_add_imux_item(imux, label, idx, NULL); |
6764bcef TI |
3793 | break; |
3794 | } | |
f2e5731d TI |
3795 | } |
3796 | } | |
43c1b2e9 | 3797 | if (imux->num_items >= 2 && cfg->num_inputs == imux->num_items) |
f2e5731d | 3798 | cx_auto_check_auto_mic(codec); |
76755359 | 3799 | if (imux->num_items > 1) { |
6764bcef | 3800 | for (i = 1; i < imux->num_items; i++) { |
47ad1f4e | 3801 | if (spec->imux_info[i].adc != spec->imux_info[0].adc) { |
6764bcef TI |
3802 | spec->adc_switching = 1; |
3803 | break; | |
3804 | } | |
3805 | } | |
3806 | } | |
f2e5731d TI |
3807 | } |
3808 | ||
3809 | /* get digital-input audio widget corresponding to the given pin */ | |
3810 | static hda_nid_t cx_auto_get_dig_in(struct hda_codec *codec, hda_nid_t pin) | |
3811 | { | |
3812 | hda_nid_t nid, end_nid; | |
3813 | ||
3814 | end_nid = codec->start_nid + codec->num_nodes; | |
3815 | for (nid = codec->start_nid; nid < end_nid; nid++) { | |
3816 | unsigned int wcaps = get_wcaps(codec, nid); | |
3817 | unsigned int type = get_wcaps_type(wcaps); | |
3818 | if (type == AC_WID_AUD_IN && (wcaps & AC_WCAP_DIGITAL)) { | |
3819 | if (get_connection_index(codec, nid, pin) >= 0) | |
3820 | return nid; | |
3821 | } | |
3822 | } | |
3823 | return 0; | |
3824 | } | |
3825 | ||
3826 | static void cx_auto_parse_digital(struct hda_codec *codec) | |
3827 | { | |
3828 | struct conexant_spec *spec = codec->spec; | |
3829 | struct auto_pin_cfg *cfg = &spec->autocfg; | |
3830 | hda_nid_t nid; | |
3831 | ||
3832 | if (cfg->dig_outs && | |
3833 | snd_hda_get_connections(codec, cfg->dig_out_pins[0], &nid, 1) == 1) | |
3834 | spec->multiout.dig_out_nid = nid; | |
3835 | if (cfg->dig_in_pin) | |
3836 | spec->dig_in_nid = cx_auto_get_dig_in(codec, cfg->dig_in_pin); | |
3837 | } | |
3838 | ||
3839 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | |
3840 | static void cx_auto_parse_beep(struct hda_codec *codec) | |
3841 | { | |
3842 | struct conexant_spec *spec = codec->spec; | |
3843 | hda_nid_t nid, end_nid; | |
3844 | ||
3845 | end_nid = codec->start_nid + codec->num_nodes; | |
3846 | for (nid = codec->start_nid; nid < end_nid; nid++) | |
3847 | if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) { | |
3848 | set_beep_amp(spec, nid, 0, HDA_OUTPUT); | |
3849 | break; | |
3850 | } | |
3851 | } | |
3852 | #else | |
3853 | #define cx_auto_parse_beep(codec) | |
3854 | #endif | |
3855 | ||
254f2968 | 3856 | /* parse EAPDs */ |
19110595 TI |
3857 | static void cx_auto_parse_eapd(struct hda_codec *codec) |
3858 | { | |
3859 | struct conexant_spec *spec = codec->spec; | |
19110595 TI |
3860 | hda_nid_t nid, end_nid; |
3861 | ||
3862 | end_nid = codec->start_nid + codec->num_nodes; | |
3863 | for (nid = codec->start_nid; nid < end_nid; nid++) { | |
3864 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) | |
3865 | continue; | |
3866 | if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)) | |
3867 | continue; | |
19110595 TI |
3868 | spec->eapds[spec->num_eapds++] = nid; |
3869 | if (spec->num_eapds >= ARRAY_SIZE(spec->eapds)) | |
3870 | break; | |
3871 | } | |
254f2968 TI |
3872 | |
3873 | /* NOTE: below is a wild guess; if we have more than two EAPDs, | |
3874 | * it's a new chip, where EAPDs are supposed to be associated to | |
3875 | * pins, and we can control EAPD per pin. | |
3876 | * OTOH, if only one or two EAPDs are found, it's an old chip, | |
3877 | * thus it might control over all pins. | |
3878 | */ | |
3879 | spec->pin_eapd_ctrls = spec->num_eapds > 2; | |
19110595 TI |
3880 | } |
3881 | ||
f2e5731d TI |
3882 | static int cx_auto_parse_auto_config(struct hda_codec *codec) |
3883 | { | |
3884 | struct conexant_spec *spec = codec->spec; | |
3885 | int err; | |
3886 | ||
3887 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); | |
3888 | if (err < 0) | |
3889 | return err; | |
3890 | ||
3891 | cx_auto_parse_output(codec); | |
3892 | cx_auto_parse_input(codec); | |
3893 | cx_auto_parse_digital(codec); | |
3894 | cx_auto_parse_beep(codec); | |
19110595 | 3895 | cx_auto_parse_eapd(codec); |
f2e5731d TI |
3896 | return 0; |
3897 | } | |
3898 | ||
da339866 TI |
3899 | static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins, |
3900 | hda_nid_t *pins, bool on) | |
f2e5731d TI |
3901 | { |
3902 | int i; | |
3903 | for (i = 0; i < num_pins; i++) { | |
3904 | if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD) | |
3905 | snd_hda_codec_write(codec, pins[i], 0, | |
da339866 TI |
3906 | AC_VERB_SET_EAPD_BTLENABLE, |
3907 | on ? 0x02 : 0); | |
f2e5731d TI |
3908 | } |
3909 | } | |
3910 | ||
3911 | static void select_connection(struct hda_codec *codec, hda_nid_t pin, | |
3912 | hda_nid_t src) | |
3913 | { | |
3914 | int idx = get_connection_index(codec, pin, src); | |
3915 | if (idx >= 0) | |
3916 | snd_hda_codec_write(codec, pin, 0, | |
3917 | AC_VERB_SET_CONNECT_SEL, idx); | |
3918 | } | |
3919 | ||
1f8458a2 TI |
3920 | static void mute_outputs(struct hda_codec *codec, int num_nids, |
3921 | const hda_nid_t *nids) | |
f2e5731d | 3922 | { |
0ad1b5b6 | 3923 | int i, val; |
f2e5731d | 3924 | |
1f8458a2 TI |
3925 | for (i = 0; i < num_nids; i++) { |
3926 | hda_nid_t nid = nids[i]; | |
3927 | if (!(get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) | |
3928 | continue; | |
0ad1b5b6 TI |
3929 | if (query_amp_caps(codec, nid, HDA_OUTPUT) & AC_AMPCAP_MUTE) |
3930 | val = AMP_OUT_MUTE; | |
3931 | else | |
3932 | val = AMP_OUT_ZERO; | |
3933 | snd_hda_codec_write(codec, nid, 0, | |
3934 | AC_VERB_SET_AMP_GAIN_MUTE, val); | |
3935 | } | |
1f8458a2 | 3936 | } |
f2e5731d | 3937 | |
03697e2a | 3938 | static void enable_unsol_pins(struct hda_codec *codec, int num_pins, |
3a93897e | 3939 | hda_nid_t *pins, unsigned int action) |
03697e2a TI |
3940 | { |
3941 | int i; | |
3942 | for (i = 0; i < num_pins; i++) | |
3a93897e | 3943 | snd_hda_jack_detect_enable(codec, pins[i], action); |
03697e2a TI |
3944 | } |
3945 | ||
1f8458a2 TI |
3946 | static void cx_auto_init_output(struct hda_codec *codec) |
3947 | { | |
3948 | struct conexant_spec *spec = codec->spec; | |
3949 | struct auto_pin_cfg *cfg = &spec->autocfg; | |
3950 | hda_nid_t nid; | |
3951 | int i; | |
3952 | ||
3953 | mute_outputs(codec, spec->multiout.num_dacs, spec->multiout.dac_nids); | |
f2e5731d TI |
3954 | for (i = 0; i < cfg->hp_outs; i++) |
3955 | snd_hda_codec_write(codec, cfg->hp_pins[i], 0, | |
3956 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP); | |
1f8458a2 TI |
3957 | mute_outputs(codec, cfg->hp_outs, cfg->hp_pins); |
3958 | mute_outputs(codec, cfg->line_outs, cfg->line_out_pins); | |
3959 | mute_outputs(codec, cfg->speaker_outs, cfg->speaker_pins); | |
f2e5731d TI |
3960 | for (i = 0; i < spec->dac_info_filled; i++) { |
3961 | nid = spec->dac_info[i].dac; | |
3962 | if (!nid) | |
3963 | nid = spec->multiout.dac_nids[0]; | |
1f015f5f TI |
3964 | else if (nid & DAC_SLAVE_FLAG) |
3965 | nid &= ~DAC_SLAVE_FLAG; | |
f2e5731d TI |
3966 | select_connection(codec, spec->dac_info[i].pin, nid); |
3967 | } | |
03697e2a TI |
3968 | if (spec->auto_mute) { |
3969 | enable_unsol_pins(codec, cfg->hp_outs, cfg->hp_pins, | |
3970 | CONEXANT_HP_EVENT); | |
3971 | spec->hp_present = detect_jacks(codec, cfg->hp_outs, | |
3972 | cfg->hp_pins); | |
3973 | if (spec->detect_line) { | |
3974 | enable_unsol_pins(codec, cfg->line_outs, | |
3975 | cfg->line_out_pins, | |
3976 | CONEXANT_LINE_EVENT); | |
3977 | spec->line_present = | |
3978 | detect_jacks(codec, cfg->line_outs, | |
3979 | cfg->line_out_pins); | |
3980 | } | |
3981 | } | |
3982 | cx_auto_update_speakers(codec); | |
254f2968 TI |
3983 | /* turn on all EAPDs if no individual EAPD control is available */ |
3984 | if (!spec->pin_eapd_ctrls) | |
3985 | cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, true); | |
f2e5731d TI |
3986 | } |
3987 | ||
3988 | static void cx_auto_init_input(struct hda_codec *codec) | |
3989 | { | |
3990 | struct conexant_spec *spec = codec->spec; | |
3991 | struct auto_pin_cfg *cfg = &spec->autocfg; | |
0ad1b5b6 | 3992 | int i, val; |
f2e5731d | 3993 | |
0ad1b5b6 TI |
3994 | for (i = 0; i < spec->num_adc_nids; i++) { |
3995 | hda_nid_t nid = spec->adc_nids[i]; | |
1f8458a2 TI |
3996 | if (!(get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) |
3997 | continue; | |
0ad1b5b6 TI |
3998 | if (query_amp_caps(codec, nid, HDA_INPUT) & AC_AMPCAP_MUTE) |
3999 | val = AMP_IN_MUTE(0); | |
4000 | else | |
4001 | val = AMP_IN_UNMUTE(0); | |
4002 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
4003 | val); | |
4004 | } | |
f2e5731d TI |
4005 | |
4006 | for (i = 0; i < cfg->num_inputs; i++) { | |
4007 | unsigned int type; | |
4008 | if (cfg->inputs[i].type == AUTO_PIN_MIC) | |
4009 | type = PIN_VREF80; | |
4010 | else | |
4011 | type = PIN_IN; | |
4012 | snd_hda_codec_write(codec, cfg->inputs[i].pin, 0, | |
4013 | AC_VERB_SET_PIN_WIDGET_CONTROL, type); | |
4014 | } | |
4015 | ||
4016 | if (spec->auto_mic) { | |
43c1b2e9 | 4017 | if (spec->auto_mic_ext >= 0) { |
1835a0f9 TI |
4018 | snd_hda_jack_detect_enable(codec, |
4019 | cfg->inputs[spec->auto_mic_ext].pin, | |
4020 | CONEXANT_MIC_EVENT); | |
43c1b2e9 TI |
4021 | } |
4022 | if (spec->auto_mic_dock >= 0) { | |
1835a0f9 TI |
4023 | snd_hda_jack_detect_enable(codec, |
4024 | cfg->inputs[spec->auto_mic_dock].pin, | |
4025 | CONEXANT_MIC_EVENT); | |
43c1b2e9 | 4026 | } |
f2e5731d TI |
4027 | cx_auto_automic(codec); |
4028 | } else { | |
47ad1f4e TI |
4029 | select_input_connection(codec, spec->imux_info[0].adc, |
4030 | spec->imux_info[0].pin); | |
f2e5731d TI |
4031 | } |
4032 | } | |
4033 | ||
4034 | static void cx_auto_init_digital(struct hda_codec *codec) | |
4035 | { | |
4036 | struct conexant_spec *spec = codec->spec; | |
4037 | struct auto_pin_cfg *cfg = &spec->autocfg; | |
4038 | ||
4039 | if (spec->multiout.dig_out_nid) | |
4040 | snd_hda_codec_write(codec, cfg->dig_out_pins[0], 0, | |
4041 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | |
4042 | if (spec->dig_in_nid) | |
4043 | snd_hda_codec_write(codec, cfg->dig_in_pin, 0, | |
4044 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN); | |
4045 | } | |
4046 | ||
4047 | static int cx_auto_init(struct hda_codec *codec) | |
4048 | { | |
4049 | /*snd_hda_sequence_write(codec, cx_auto_init_verbs);*/ | |
4050 | cx_auto_init_output(codec); | |
4051 | cx_auto_init_input(codec); | |
4052 | cx_auto_init_digital(codec); | |
01a61e12 | 4053 | snd_hda_jack_report_sync(codec); |
f2e5731d TI |
4054 | return 0; |
4055 | } | |
4056 | ||
983345e5 | 4057 | static int cx_auto_add_volume_idx(struct hda_codec *codec, const char *basename, |
f2e5731d | 4058 | const char *dir, int cidx, |
983345e5 | 4059 | hda_nid_t nid, int hda_dir, int amp_idx) |
f2e5731d TI |
4060 | { |
4061 | static char name[32]; | |
4062 | static struct snd_kcontrol_new knew[] = { | |
4063 | HDA_CODEC_VOLUME(name, 0, 0, 0), | |
4064 | HDA_CODEC_MUTE(name, 0, 0, 0), | |
4065 | }; | |
34cbe3a6 | 4066 | static const char * const sfx[2] = { "Volume", "Switch" }; |
f2e5731d TI |
4067 | int i, err; |
4068 | ||
4069 | for (i = 0; i < 2; i++) { | |
4070 | struct snd_kcontrol *kctl; | |
983345e5 DH |
4071 | knew[i].private_value = HDA_COMPOSE_AMP_VAL(nid, 3, amp_idx, |
4072 | hda_dir); | |
f2e5731d TI |
4073 | knew[i].subdevice = HDA_SUBDEV_AMP_FLAG; |
4074 | knew[i].index = cidx; | |
4075 | snprintf(name, sizeof(name), "%s%s %s", basename, dir, sfx[i]); | |
4076 | kctl = snd_ctl_new1(&knew[i], codec); | |
4077 | if (!kctl) | |
4078 | return -ENOMEM; | |
4079 | err = snd_hda_ctl_add(codec, nid, kctl); | |
4080 | if (err < 0) | |
4081 | return err; | |
3868137e TI |
4082 | if (!(query_amp_caps(codec, nid, hda_dir) & |
4083 | (AC_AMPCAP_MUTE | AC_AMPCAP_MIN_MUTE))) | |
f2e5731d TI |
4084 | break; |
4085 | } | |
4086 | return 0; | |
4087 | } | |
4088 | ||
983345e5 DH |
4089 | #define cx_auto_add_volume(codec, str, dir, cidx, nid, hda_dir) \ |
4090 | cx_auto_add_volume_idx(codec, str, dir, cidx, nid, hda_dir, 0) | |
4091 | ||
f2e5731d TI |
4092 | #define cx_auto_add_pb_volume(codec, nid, str, idx) \ |
4093 | cx_auto_add_volume(codec, str, " Playback", idx, nid, HDA_OUTPUT) | |
4094 | ||
1f8458a2 TI |
4095 | static int try_add_pb_volume(struct hda_codec *codec, hda_nid_t dac, |
4096 | hda_nid_t pin, const char *name, int idx) | |
4097 | { | |
4098 | unsigned int caps; | |
468c5458 DH |
4099 | if (dac && !(dac & DAC_SLAVE_FLAG)) { |
4100 | caps = query_amp_caps(codec, dac, HDA_OUTPUT); | |
4101 | if (caps & AC_AMPCAP_NUM_STEPS) | |
4102 | return cx_auto_add_pb_volume(codec, dac, name, idx); | |
4103 | } | |
1f8458a2 TI |
4104 | caps = query_amp_caps(codec, pin, HDA_OUTPUT); |
4105 | if (caps & AC_AMPCAP_NUM_STEPS) | |
4106 | return cx_auto_add_pb_volume(codec, pin, name, idx); | |
4107 | return 0; | |
4108 | } | |
4109 | ||
f2e5731d TI |
4110 | static int cx_auto_build_output_controls(struct hda_codec *codec) |
4111 | { | |
4112 | struct conexant_spec *spec = codec->spec; | |
4113 | int i, err; | |
4114 | int num_line = 0, num_hp = 0, num_spk = 0; | |
ea734963 | 4115 | static const char * const texts[3] = { "Front", "Surround", "CLFE" }; |
f2e5731d TI |
4116 | |
4117 | if (spec->dac_info_filled == 1) | |
1f8458a2 TI |
4118 | return try_add_pb_volume(codec, spec->dac_info[0].dac, |
4119 | spec->dac_info[0].pin, | |
4120 | "Master", 0); | |
4121 | ||
f2e5731d TI |
4122 | for (i = 0; i < spec->dac_info_filled; i++) { |
4123 | const char *label; | |
4124 | int idx, type; | |
1f015f5f | 4125 | hda_nid_t dac = spec->dac_info[i].dac; |
f2e5731d TI |
4126 | type = spec->dac_info[i].type; |
4127 | if (type == AUTO_PIN_LINE_OUT) | |
4128 | type = spec->autocfg.line_out_type; | |
4129 | switch (type) { | |
4130 | case AUTO_PIN_LINE_OUT: | |
4131 | default: | |
4132 | label = texts[num_line++]; | |
4133 | idx = 0; | |
4134 | break; | |
4135 | case AUTO_PIN_HP_OUT: | |
4136 | label = "Headphone"; | |
4137 | idx = num_hp++; | |
4138 | break; | |
4139 | case AUTO_PIN_SPEAKER_OUT: | |
4140 | label = "Speaker"; | |
4141 | idx = num_spk++; | |
4142 | break; | |
4143 | } | |
1f015f5f | 4144 | err = try_add_pb_volume(codec, dac, |
1f8458a2 TI |
4145 | spec->dac_info[i].pin, |
4146 | label, idx); | |
f2e5731d TI |
4147 | if (err < 0) |
4148 | return err; | |
4149 | } | |
03697e2a TI |
4150 | |
4151 | if (spec->auto_mute) { | |
4152 | err = snd_hda_add_new_ctls(codec, cx_automute_mode_enum); | |
4153 | if (err < 0) | |
4154 | return err; | |
4155 | } | |
4156 | ||
f2e5731d TI |
4157 | return 0; |
4158 | } | |
4159 | ||
6764bcef TI |
4160 | static int cx_auto_add_capture_volume(struct hda_codec *codec, hda_nid_t nid, |
4161 | const char *label, const char *pfx, | |
4162 | int cidx) | |
4163 | { | |
4164 | struct conexant_spec *spec = codec->spec; | |
4165 | int i; | |
4166 | ||
4167 | for (i = 0; i < spec->num_adc_nids; i++) { | |
4168 | hda_nid_t adc_nid = spec->adc_nids[i]; | |
5c9887e0 | 4169 | int idx = get_input_connection(codec, adc_nid, nid); |
6764bcef TI |
4170 | if (idx < 0) |
4171 | continue; | |
6b452142 TI |
4172 | if (spec->single_adc_amp) |
4173 | idx = 0; | |
6764bcef TI |
4174 | return cx_auto_add_volume_idx(codec, label, pfx, |
4175 | cidx, adc_nid, HDA_INPUT, idx); | |
4176 | } | |
4177 | return 0; | |
4178 | } | |
4179 | ||
cf27f29a TI |
4180 | static int cx_auto_add_boost_volume(struct hda_codec *codec, int idx, |
4181 | const char *label, int cidx) | |
4182 | { | |
4183 | struct conexant_spec *spec = codec->spec; | |
4184 | hda_nid_t mux, nid; | |
f9759301 | 4185 | int i, con; |
cf27f29a | 4186 | |
47ad1f4e | 4187 | nid = spec->imux_info[idx].pin; |
cf27f29a TI |
4188 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) |
4189 | return cx_auto_add_volume(codec, label, " Boost", cidx, | |
4190 | nid, HDA_INPUT); | |
47ad1f4e TI |
4191 | con = __select_input_connection(codec, spec->imux_info[idx].adc, nid, |
4192 | &mux, false, 0); | |
cf27f29a TI |
4193 | if (con < 0) |
4194 | return 0; | |
f9759301 | 4195 | for (i = 0; i < idx; i++) { |
47ad1f4e | 4196 | if (spec->imux_info[i].boost == mux) |
f9759301 TI |
4197 | return 0; /* already present */ |
4198 | } | |
4199 | ||
4200 | if (get_wcaps(codec, mux) & AC_WCAP_OUT_AMP) { | |
47ad1f4e | 4201 | spec->imux_info[idx].boost = mux; |
cf27f29a TI |
4202 | return cx_auto_add_volume(codec, label, " Boost", 0, |
4203 | mux, HDA_OUTPUT); | |
f9759301 | 4204 | } |
cf27f29a TI |
4205 | return 0; |
4206 | } | |
4207 | ||
f2e5731d TI |
4208 | static int cx_auto_build_input_controls(struct hda_codec *codec) |
4209 | { | |
4210 | struct conexant_spec *spec = codec->spec; | |
cf27f29a TI |
4211 | struct hda_input_mux *imux = &spec->private_imux; |
4212 | const char *prev_label; | |
4213 | int input_conn[HDA_MAX_NUM_INPUTS]; | |
6b452142 | 4214 | int i, j, err, cidx; |
cf27f29a TI |
4215 | int multi_connection; |
4216 | ||
6b452142 TI |
4217 | if (!imux->num_items) |
4218 | return 0; | |
4219 | ||
cf27f29a TI |
4220 | multi_connection = 0; |
4221 | for (i = 0; i < imux->num_items; i++) { | |
47ad1f4e TI |
4222 | cidx = get_input_connection(codec, spec->imux_info[i].adc, |
4223 | spec->imux_info[i].pin); | |
6b452142 TI |
4224 | if (cidx < 0) |
4225 | continue; | |
4226 | input_conn[i] = spec->imux_info[i].adc; | |
4227 | if (!spec->single_adc_amp) | |
4228 | input_conn[i] |= cidx << 8; | |
cf27f29a TI |
4229 | if (i > 0 && input_conn[i] != input_conn[0]) |
4230 | multi_connection = 1; | |
4231 | } | |
f2e5731d | 4232 | |
f2e5731d TI |
4233 | prev_label = NULL; |
4234 | cidx = 0; | |
cf27f29a | 4235 | for (i = 0; i < imux->num_items; i++) { |
47ad1f4e | 4236 | hda_nid_t nid = spec->imux_info[i].pin; |
f2e5731d | 4237 | const char *label; |
983345e5 | 4238 | |
cf27f29a | 4239 | label = hda_get_autocfg_input_label(codec, &spec->autocfg, |
47ad1f4e | 4240 | spec->imux_info[i].index); |
f2e5731d TI |
4241 | if (label == prev_label) |
4242 | cidx++; | |
4243 | else | |
4244 | cidx = 0; | |
4245 | prev_label = label; | |
983345e5 | 4246 | |
cf27f29a TI |
4247 | err = cx_auto_add_boost_volume(codec, i, label, cidx); |
4248 | if (err < 0) | |
4249 | return err; | |
983345e5 | 4250 | |
cf27f29a | 4251 | if (!multi_connection) { |
f9759301 TI |
4252 | if (i > 0) |
4253 | continue; | |
6764bcef TI |
4254 | err = cx_auto_add_capture_volume(codec, nid, |
4255 | "Capture", "", cidx); | |
4256 | } else { | |
6b452142 TI |
4257 | bool dup_found = false; |
4258 | for (j = 0; j < i; j++) { | |
4259 | if (input_conn[j] == input_conn[i]) { | |
4260 | dup_found = true; | |
4261 | break; | |
4262 | } | |
4263 | } | |
4264 | if (dup_found) | |
4265 | continue; | |
6764bcef TI |
4266 | err = cx_auto_add_capture_volume(codec, nid, |
4267 | label, " Capture", cidx); | |
983345e5 | 4268 | } |
6764bcef TI |
4269 | if (err < 0) |
4270 | return err; | |
4271 | } | |
4272 | ||
4273 | if (spec->private_imux.num_items > 1 && !spec->auto_mic) { | |
4274 | err = snd_hda_add_new_ctls(codec, cx_auto_capture_mixers); | |
4275 | if (err < 0) | |
4276 | return err; | |
f2e5731d | 4277 | } |
6764bcef | 4278 | |
f2e5731d TI |
4279 | return 0; |
4280 | } | |
4281 | ||
4282 | static int cx_auto_build_controls(struct hda_codec *codec) | |
4283 | { | |
31ef2257 | 4284 | struct conexant_spec *spec = codec->spec; |
f2e5731d TI |
4285 | int err; |
4286 | ||
4287 | err = cx_auto_build_output_controls(codec); | |
4288 | if (err < 0) | |
4289 | return err; | |
4290 | err = cx_auto_build_input_controls(codec); | |
4291 | if (err < 0) | |
4292 | return err; | |
31ef2257 TI |
4293 | err = conexant_build_controls(codec); |
4294 | if (err < 0) | |
4295 | return err; | |
4296 | err = snd_hda_jack_add_kctls(codec, &spec->autocfg); | |
4297 | if (err < 0) | |
4298 | return err; | |
4299 | return 0; | |
f2e5731d TI |
4300 | } |
4301 | ||
22ce5f74 TI |
4302 | static int cx_auto_search_adcs(struct hda_codec *codec) |
4303 | { | |
4304 | struct conexant_spec *spec = codec->spec; | |
4305 | hda_nid_t nid, end_nid; | |
4306 | ||
4307 | end_nid = codec->start_nid + codec->num_nodes; | |
4308 | for (nid = codec->start_nid; nid < end_nid; nid++) { | |
4309 | unsigned int caps = get_wcaps(codec, nid); | |
4310 | if (get_wcaps_type(caps) != AC_WID_AUD_IN) | |
4311 | continue; | |
4312 | if (caps & AC_WCAP_DIGITAL) | |
4313 | continue; | |
4314 | if (snd_BUG_ON(spec->num_adc_nids >= | |
4315 | ARRAY_SIZE(spec->private_adc_nids))) | |
4316 | break; | |
4317 | spec->private_adc_nids[spec->num_adc_nids++] = nid; | |
4318 | } | |
4319 | spec->adc_nids = spec->private_adc_nids; | |
4320 | return 0; | |
4321 | } | |
4322 | ||
4323 | ||
34cbe3a6 | 4324 | static const struct hda_codec_ops cx_auto_patch_ops = { |
f2e5731d TI |
4325 | .build_controls = cx_auto_build_controls, |
4326 | .build_pcms = conexant_build_pcms, | |
4327 | .init = cx_auto_init, | |
4328 | .free = conexant_free, | |
4329 | .unsol_event = cx_auto_unsol_event, | |
4330 | #ifdef CONFIG_SND_HDA_POWER_SAVE | |
4331 | .suspend = conexant_suspend, | |
4332 | #endif | |
4333 | .reboot_notify = snd_hda_shutup_pins, | |
4334 | }; | |
4335 | ||
e92d4b08 TI |
4336 | /* |
4337 | * pin fix-up | |
4338 | */ | |
4339 | struct cxt_pincfg { | |
4340 | hda_nid_t nid; | |
4341 | u32 val; | |
4342 | }; | |
4343 | ||
4344 | static void apply_pincfg(struct hda_codec *codec, const struct cxt_pincfg *cfg) | |
4345 | { | |
4346 | for (; cfg->nid; cfg++) | |
4347 | snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val); | |
4348 | ||
4349 | } | |
4350 | ||
4351 | static void apply_pin_fixup(struct hda_codec *codec, | |
4352 | const struct snd_pci_quirk *quirk, | |
4353 | const struct cxt_pincfg **table) | |
4354 | { | |
4355 | quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); | |
4356 | if (quirk) { | |
4357 | snd_printdd(KERN_INFO "hda_codec: applying pincfg for %s\n", | |
4358 | quirk->name); | |
4359 | apply_pincfg(codec, table[quirk->value]); | |
4360 | } | |
4361 | } | |
4362 | ||
4363 | enum { | |
4364 | CXT_PINCFG_LENOVO_X200, | |
4365 | }; | |
4366 | ||
4367 | static const struct cxt_pincfg cxt_pincfg_lenovo_x200[] = { | |
4368 | { 0x16, 0x042140ff }, /* HP (seq# overridden) */ | |
4369 | { 0x17, 0x21a11000 }, /* dock-mic */ | |
4370 | { 0x19, 0x2121103f }, /* dock-HP */ | |
4371 | {} | |
4372 | }; | |
4373 | ||
4374 | static const struct cxt_pincfg *cxt_pincfg_tbl[] = { | |
4375 | [CXT_PINCFG_LENOVO_X200] = cxt_pincfg_lenovo_x200, | |
4376 | }; | |
4377 | ||
4378 | static const struct snd_pci_quirk cxt_fixups[] = { | |
4379 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200), | |
4380 | {} | |
4381 | }; | |
4382 | ||
3868137e TI |
4383 | /* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches |
4384 | * can be created (bko#42825) | |
4385 | */ | |
4386 | static void add_cx5051_fake_mutes(struct hda_codec *codec) | |
4387 | { | |
4388 | static hda_nid_t out_nids[] = { | |
4389 | 0x10, 0x11, 0 | |
4390 | }; | |
4391 | hda_nid_t *p; | |
4392 | ||
4393 | for (p = out_nids; *p; p++) | |
4394 | snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT, | |
4395 | AC_AMPCAP_MIN_MUTE | | |
4396 | query_amp_caps(codec, *p, HDA_OUTPUT)); | |
4397 | } | |
4398 | ||
f2e5731d TI |
4399 | static int patch_conexant_auto(struct hda_codec *codec) |
4400 | { | |
4401 | struct conexant_spec *spec; | |
4402 | int err; | |
4403 | ||
1f8458a2 TI |
4404 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
4405 | codec->chip_name); | |
4406 | ||
f2e5731d TI |
4407 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
4408 | if (!spec) | |
4409 | return -ENOMEM; | |
4410 | codec->spec = spec; | |
1387cde5 | 4411 | codec->pin_amp_workaround = 1; |
e92d4b08 | 4412 | |
6b452142 TI |
4413 | switch (codec->vendor_id) { |
4414 | case 0x14f15045: | |
4415 | spec->single_adc_amp = 1; | |
4416 | break; | |
3868137e TI |
4417 | case 0x14f15051: |
4418 | add_cx5051_fake_mutes(codec); | |
4419 | break; | |
6b452142 TI |
4420 | } |
4421 | ||
e92d4b08 TI |
4422 | apply_pin_fixup(codec, cxt_fixups, cxt_pincfg_tbl); |
4423 | ||
22ce5f74 TI |
4424 | err = cx_auto_search_adcs(codec); |
4425 | if (err < 0) | |
4426 | return err; | |
f2e5731d TI |
4427 | err = cx_auto_parse_auto_config(codec); |
4428 | if (err < 0) { | |
4429 | kfree(codec->spec); | |
4430 | codec->spec = NULL; | |
4431 | return err; | |
4432 | } | |
6764bcef | 4433 | spec->capture_stream = &cx_auto_pcm_analog_capture; |
f2e5731d TI |
4434 | codec->patch_ops = cx_auto_patch_ops; |
4435 | if (spec->beep_amp) | |
4436 | snd_hda_attach_beep_device(codec, spec->beep_amp); | |
4437 | return 0; | |
4438 | } | |
4439 | ||
461e2c78 TI |
4440 | /* |
4441 | */ | |
4442 | ||
34cbe3a6 | 4443 | static const struct hda_codec_preset snd_hda_preset_conexant[] = { |
82f30040 TD |
4444 | { .id = 0x14f15045, .name = "CX20549 (Venice)", |
4445 | .patch = patch_cxt5045 }, | |
4446 | { .id = 0x14f15047, .name = "CX20551 (Waikiki)", | |
4447 | .patch = patch_cxt5047 }, | |
461e2c78 TI |
4448 | { .id = 0x14f15051, .name = "CX20561 (Hermosa)", |
4449 | .patch = patch_cxt5051 }, | |
0fb67e98 DD |
4450 | { .id = 0x14f15066, .name = "CX20582 (Pebble)", |
4451 | .patch = patch_cxt5066 }, | |
95a618bd ER |
4452 | { .id = 0x14f15067, .name = "CX20583 (Pebble HSF)", |
4453 | .patch = patch_cxt5066 }, | |
850eab9d TI |
4454 | { .id = 0x14f15068, .name = "CX20584", |
4455 | .patch = patch_cxt5066 }, | |
7b2bfdbc JT |
4456 | { .id = 0x14f15069, .name = "CX20585", |
4457 | .patch = patch_cxt5066 }, | |
f0ca89b0 DH |
4458 | { .id = 0x14f1506c, .name = "CX20588", |
4459 | .patch = patch_cxt5066 }, | |
6da8b516 DH |
4460 | { .id = 0x14f1506e, .name = "CX20590", |
4461 | .patch = patch_cxt5066 }, | |
f2e5731d TI |
4462 | { .id = 0x14f15097, .name = "CX20631", |
4463 | .patch = patch_conexant_auto }, | |
4464 | { .id = 0x14f15098, .name = "CX20632", | |
4465 | .patch = patch_conexant_auto }, | |
4466 | { .id = 0x14f150a1, .name = "CX20641", | |
4467 | .patch = patch_conexant_auto }, | |
4468 | { .id = 0x14f150a2, .name = "CX20642", | |
4469 | .patch = patch_conexant_auto }, | |
4470 | { .id = 0x14f150ab, .name = "CX20651", | |
4471 | .patch = patch_conexant_auto }, | |
4472 | { .id = 0x14f150ac, .name = "CX20652", | |
4473 | .patch = patch_conexant_auto }, | |
4474 | { .id = 0x14f150b8, .name = "CX20664", | |
4475 | .patch = patch_conexant_auto }, | |
4476 | { .id = 0x14f150b9, .name = "CX20665", | |
4477 | .patch = patch_conexant_auto }, | |
c9b443d4 TD |
4478 | {} /* terminator */ |
4479 | }; | |
1289e9e8 TI |
4480 | |
4481 | MODULE_ALIAS("snd-hda-codec-id:14f15045"); | |
4482 | MODULE_ALIAS("snd-hda-codec-id:14f15047"); | |
4483 | MODULE_ALIAS("snd-hda-codec-id:14f15051"); | |
0fb67e98 | 4484 | MODULE_ALIAS("snd-hda-codec-id:14f15066"); |
95a618bd | 4485 | MODULE_ALIAS("snd-hda-codec-id:14f15067"); |
850eab9d | 4486 | MODULE_ALIAS("snd-hda-codec-id:14f15068"); |
7b2bfdbc | 4487 | MODULE_ALIAS("snd-hda-codec-id:14f15069"); |
f0ca89b0 | 4488 | MODULE_ALIAS("snd-hda-codec-id:14f1506c"); |
6da8b516 | 4489 | MODULE_ALIAS("snd-hda-codec-id:14f1506e"); |
f2e5731d TI |
4490 | MODULE_ALIAS("snd-hda-codec-id:14f15097"); |
4491 | MODULE_ALIAS("snd-hda-codec-id:14f15098"); | |
4492 | MODULE_ALIAS("snd-hda-codec-id:14f150a1"); | |
4493 | MODULE_ALIAS("snd-hda-codec-id:14f150a2"); | |
4494 | MODULE_ALIAS("snd-hda-codec-id:14f150ab"); | |
4495 | MODULE_ALIAS("snd-hda-codec-id:14f150ac"); | |
4496 | MODULE_ALIAS("snd-hda-codec-id:14f150b8"); | |
4497 | MODULE_ALIAS("snd-hda-codec-id:14f150b9"); | |
1289e9e8 TI |
4498 | |
4499 | MODULE_LICENSE("GPL"); | |
4500 | MODULE_DESCRIPTION("Conexant HD-audio codec"); | |
4501 | ||
4502 | static struct hda_codec_preset_list conexant_list = { | |
4503 | .preset = snd_hda_preset_conexant, | |
4504 | .owner = THIS_MODULE, | |
4505 | }; | |
4506 | ||
4507 | static int __init patch_conexant_init(void) | |
4508 | { | |
4509 | return snd_hda_add_codec_preset(&conexant_list); | |
4510 | } | |
4511 | ||
4512 | static void __exit patch_conexant_exit(void) | |
4513 | { | |
4514 | snd_hda_delete_codec_preset(&conexant_list); | |
4515 | } | |
4516 | ||
4517 | module_init(patch_conexant_init) | |
4518 | module_exit(patch_conexant_exit) |