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