2 * HD audio interface patch for Conexant HDA audio codec
4 * Copyright (c) 2006 Pototskiy Akex <alex.pototskiy@gmail.com>
5 * Takashi Iwai <tiwai@suse.de>
6 * Tobin Davis <tdavis@dsl-only.net>
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.
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.
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
23 #include <linux/init.h>
24 #include <linux/delay.h>
25 #include <linux/slab.h>
26 #include <linux/pci.h>
27 #include <linux/module.h>
28 #include <sound/core.h>
29 #include <sound/jack.h>
31 #include "hda_codec.h"
32 #include "hda_local.h"
33 #include "hda_auto_parser.h"
36 #include "hda_generic.h"
38 #define ENABLE_CXT_STATIC_QUIRKS
40 #define CXT_PIN_DIR_IN 0x00
41 #define CXT_PIN_DIR_OUT 0x01
42 #define CXT_PIN_DIR_INOUT 0x02
43 #define CXT_PIN_DIR_IN_NOMICBIAS 0x03
44 #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04
46 #define CONEXANT_HP_EVENT 0x37
47 #define CONEXANT_MIC_EVENT 0x38
48 #define CONEXANT_LINE_EVENT 0x39
50 /* Conexant 5051 specific */
52 #define CXT5051_SPDIF_OUT 0x12
53 #define CXT5051_PORTB_EVENT 0x38
54 #define CXT5051_PORTC_EVENT 0x39
56 #define AUTO_MIC_PORTB (1 << 1)
57 #define AUTO_MIC_PORTC (1 << 2)
59 struct conexant_spec {
60 struct hda_gen_spec gen;
62 unsigned int beep_amp;
65 unsigned int num_eapds;
68 #ifdef ENABLE_CXT_STATIC_QUIRKS
69 const struct snd_kcontrol_new *mixers[5];
71 hda_nid_t vmaster_nid;
73 const struct hda_verb *init_verbs[5]; /* initialization verbs
77 unsigned int num_init_verbs;
80 struct hda_multi_out multiout; /* playback set-up
81 * max_channels, dacs must be set
82 * dig_out_nid and hp_nid are optional
84 unsigned int cur_eapd;
85 unsigned int hp_present;
86 unsigned int line_present;
87 unsigned int auto_mic;
90 unsigned int num_adc_nids;
91 const hda_nid_t *adc_nids;
92 hda_nid_t dig_in_nid; /* digital-in NID; optional */
94 unsigned int cur_adc_idx;
96 unsigned int cur_adc_stream_tag;
97 unsigned int cur_adc_format;
99 const struct hda_pcm_stream *capture_stream;
102 const struct hda_input_mux *input_mux;
103 const hda_nid_t *capsrc_nids;
104 unsigned int cur_mux[3];
107 const struct hda_channel_mode *channel_mode;
108 int num_channel_mode;
110 /* PCM information */
111 struct hda_pcm pcm_rec[2]; /* used in build_pcms() */
113 unsigned int spdif_route;
115 unsigned int port_d_mode;
116 unsigned int dell_automute:1;
117 unsigned int dell_vostro:1;
118 unsigned int ideapad:1;
119 unsigned int thinkpad:1;
120 unsigned int hp_laptop:1;
123 unsigned int ext_mic_present;
124 unsigned int recording;
125 void (*capture_prepare)(struct hda_codec *codec);
126 void (*capture_cleanup)(struct hda_codec *codec);
128 /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
129 * through the microphone jack.
130 * When the user enables this through a mixer switch, both internal and
131 * external microphones are disabled. Gain is fixed at 0dB. In this mode,
132 * we also allow the bias to be configured through a separate mixer
134 unsigned int dc_enable;
135 unsigned int dc_input_bias; /* offset into cxt5066_olpc_dc_bias */
136 unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */
137 #endif /* ENABLE_CXT_STATIC_QUIRKS */
141 #ifdef CONFIG_SND_HDA_INPUT_BEEP
142 #define set_beep_amp(spec, nid, idx, dir) \
143 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir))
144 /* additional beep mixers; the actual parameters are overwritten at build */
145 static const struct snd_kcontrol_new cxt_beep_mixer[] = {
146 HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT),
147 HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT),
151 /* create beep controls if needed */
152 static int add_beep_ctls(struct hda_codec *codec)
154 struct conexant_spec *spec = codec->spec;
157 if (spec->beep_amp) {
158 const struct snd_kcontrol_new *knew;
159 for (knew = cxt_beep_mixer; knew->name; knew++) {
160 struct snd_kcontrol *kctl;
161 kctl = snd_ctl_new1(knew, codec);
164 kctl->private_value = spec->beep_amp;
165 err = snd_hda_ctl_add(codec, 0, kctl);
173 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
174 #define add_beep_ctls(codec) 0
178 #ifdef ENABLE_CXT_STATIC_QUIRKS
179 static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo,
180 struct hda_codec *codec,
181 struct snd_pcm_substream *substream)
183 struct conexant_spec *spec = codec->spec;
184 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
188 static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
189 struct hda_codec *codec,
190 unsigned int stream_tag,
192 struct snd_pcm_substream *substream)
194 struct conexant_spec *spec = codec->spec;
195 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
200 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
201 struct hda_codec *codec,
202 struct snd_pcm_substream *substream)
204 struct conexant_spec *spec = codec->spec;
205 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
211 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
212 struct hda_codec *codec,
213 struct snd_pcm_substream *substream)
215 struct conexant_spec *spec = codec->spec;
216 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
219 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
220 struct hda_codec *codec,
221 struct snd_pcm_substream *substream)
223 struct conexant_spec *spec = codec->spec;
224 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
227 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
228 struct hda_codec *codec,
229 unsigned int stream_tag,
231 struct snd_pcm_substream *substream)
233 struct conexant_spec *spec = codec->spec;
234 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
242 static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
243 struct hda_codec *codec,
244 unsigned int stream_tag,
246 struct snd_pcm_substream *substream)
248 struct conexant_spec *spec = codec->spec;
249 if (spec->capture_prepare)
250 spec->capture_prepare(codec);
251 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
252 stream_tag, 0, format);
256 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
257 struct hda_codec *codec,
258 struct snd_pcm_substream *substream)
260 struct conexant_spec *spec = codec->spec;
261 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
262 if (spec->capture_cleanup)
263 spec->capture_cleanup(codec);
269 static const struct hda_pcm_stream conexant_pcm_analog_playback = {
273 .nid = 0, /* fill later */
275 .open = conexant_playback_pcm_open,
276 .prepare = conexant_playback_pcm_prepare,
277 .cleanup = conexant_playback_pcm_cleanup
281 static const struct hda_pcm_stream conexant_pcm_analog_capture = {
285 .nid = 0, /* fill later */
287 .prepare = conexant_capture_pcm_prepare,
288 .cleanup = conexant_capture_pcm_cleanup
293 static const struct hda_pcm_stream conexant_pcm_digital_playback = {
297 .nid = 0, /* fill later */
299 .open = conexant_dig_playback_pcm_open,
300 .close = conexant_dig_playback_pcm_close,
301 .prepare = conexant_dig_playback_pcm_prepare
305 static const struct hda_pcm_stream conexant_pcm_digital_capture = {
309 /* NID is set in alc_build_pcms */
312 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
313 struct hda_codec *codec,
314 unsigned int stream_tag,
316 struct snd_pcm_substream *substream)
318 struct conexant_spec *spec = codec->spec;
319 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
320 spec->cur_adc_stream_tag = stream_tag;
321 spec->cur_adc_format = format;
322 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
326 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
327 struct hda_codec *codec,
328 struct snd_pcm_substream *substream)
330 struct conexant_spec *spec = codec->spec;
331 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
336 static const struct hda_pcm_stream cx5051_pcm_analog_capture = {
340 .nid = 0, /* fill later */
342 .prepare = cx5051_capture_pcm_prepare,
343 .cleanup = cx5051_capture_pcm_cleanup
347 static int conexant_build_pcms(struct hda_codec *codec)
349 struct conexant_spec *spec = codec->spec;
350 struct hda_pcm *info = spec->pcm_rec;
353 codec->pcm_info = info;
355 info->name = "CONEXANT Analog";
356 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback;
357 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max =
358 spec->multiout.max_channels;
359 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
360 spec->multiout.dac_nids[0];
361 if (spec->capture_stream)
362 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *spec->capture_stream;
364 if (codec->vendor_id == 0x14f15051)
365 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
366 cx5051_pcm_analog_capture;
368 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
369 conexant_pcm_analog_capture;
370 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
374 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
376 if (spec->multiout.dig_out_nid) {
379 info->name = "Conexant Digital";
380 info->pcm_type = HDA_PCM_TYPE_SPDIF;
381 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
382 conexant_pcm_digital_playback;
383 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
384 spec->multiout.dig_out_nid;
385 if (spec->dig_in_nid) {
386 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
387 conexant_pcm_digital_capture;
388 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
396 static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol,
397 struct snd_ctl_elem_info *uinfo)
399 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
400 struct conexant_spec *spec = codec->spec;
402 return snd_hda_input_mux_info(spec->input_mux, uinfo);
405 static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol,
406 struct snd_ctl_elem_value *ucontrol)
408 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
409 struct conexant_spec *spec = codec->spec;
410 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
412 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
416 static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol,
417 struct snd_ctl_elem_value *ucontrol)
419 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
420 struct conexant_spec *spec = codec->spec;
421 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
423 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
424 spec->capsrc_nids[adc_idx],
425 &spec->cur_mux[adc_idx]);
428 static void conexant_set_power(struct hda_codec *codec, hda_nid_t fg,
429 unsigned int power_state)
431 if (power_state == AC_PWRST_D3)
433 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
435 /* partial workaround for "azx_get_response timeout" */
436 if (power_state == AC_PWRST_D0)
438 snd_hda_codec_set_power_to_all(codec, fg, power_state);
441 static int conexant_init(struct hda_codec *codec)
443 struct conexant_spec *spec = codec->spec;
446 for (i = 0; i < spec->num_init_verbs; i++)
447 snd_hda_sequence_write(codec, spec->init_verbs[i]);
451 static void conexant_free(struct hda_codec *codec)
453 struct conexant_spec *spec = codec->spec;
454 snd_hda_detach_beep_device(codec);
458 static const struct snd_kcontrol_new cxt_capture_mixers[] = {
460 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
461 .name = "Capture Source",
462 .info = conexant_mux_enum_info,
463 .get = conexant_mux_enum_get,
464 .put = conexant_mux_enum_put
469 static const char * const slave_pfxs[] = {
470 "Headphone", "Speaker", "Bass Speaker", "Front", "Surround", "CLFE",
474 static int conexant_build_controls(struct hda_codec *codec)
476 struct conexant_spec *spec = codec->spec;
480 for (i = 0; i < spec->num_mixers; i++) {
481 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
485 if (spec->multiout.dig_out_nid) {
486 err = snd_hda_create_spdif_out_ctls(codec,
487 spec->multiout.dig_out_nid,
488 spec->multiout.dig_out_nid);
491 err = snd_hda_create_spdif_share_sw(codec,
495 spec->multiout.share_spdif = 1;
497 if (spec->dig_in_nid) {
498 err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid);
503 /* if we have no master control, let's create it */
504 if (spec->vmaster_nid &&
505 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
506 unsigned int vmaster_tlv[4];
507 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
508 HDA_OUTPUT, vmaster_tlv);
509 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
510 vmaster_tlv, slave_pfxs,
515 if (spec->vmaster_nid &&
516 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
517 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
524 if (spec->input_mux) {
525 err = snd_hda_add_new_ctls(codec, cxt_capture_mixers);
530 err = add_beep_ctls(codec);
537 static const struct hda_codec_ops conexant_patch_ops = {
538 .build_controls = conexant_build_controls,
539 .build_pcms = conexant_build_pcms,
540 .init = conexant_init,
541 .free = conexant_free,
542 .set_power_state = conexant_set_power,
545 static int patch_conexant_auto(struct hda_codec *codec);
548 * the private value = nid | (invert << 8)
551 #define cxt_eapd_info snd_ctl_boolean_mono_info
553 static int cxt_eapd_get(struct snd_kcontrol *kcontrol,
554 struct snd_ctl_elem_value *ucontrol)
556 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
557 struct conexant_spec *spec = codec->spec;
558 int invert = (kcontrol->private_value >> 8) & 1;
560 ucontrol->value.integer.value[0] = !spec->cur_eapd;
562 ucontrol->value.integer.value[0] = spec->cur_eapd;
567 static int cxt_eapd_put(struct snd_kcontrol *kcontrol,
568 struct snd_ctl_elem_value *ucontrol)
570 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
571 struct conexant_spec *spec = codec->spec;
572 int invert = (kcontrol->private_value >> 8) & 1;
573 hda_nid_t nid = kcontrol->private_value & 0xff;
576 eapd = !!ucontrol->value.integer.value[0];
579 if (eapd == spec->cur_eapd)
582 spec->cur_eapd = eapd;
583 snd_hda_codec_write_cache(codec, nid,
584 0, AC_VERB_SET_EAPD_BTLENABLE,
589 /* controls for test mode */
590 #ifdef CONFIG_SND_DEBUG
592 #define CXT_EAPD_SWITCH(xname, nid, mask) \
593 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
594 .info = cxt_eapd_info, \
595 .get = cxt_eapd_get, \
596 .put = cxt_eapd_put, \
597 .private_value = nid | (mask<<16) }
601 static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol,
602 struct snd_ctl_elem_info *uinfo)
604 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
605 struct conexant_spec *spec = codec->spec;
606 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
607 spec->num_channel_mode);
610 static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol,
611 struct snd_ctl_elem_value *ucontrol)
613 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
614 struct conexant_spec *spec = codec->spec;
615 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
616 spec->num_channel_mode,
617 spec->multiout.max_channels);
620 static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol,
621 struct snd_ctl_elem_value *ucontrol)
623 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
624 struct conexant_spec *spec = codec->spec;
625 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
626 spec->num_channel_mode,
627 &spec->multiout.max_channels);
631 #define CXT_PIN_MODE(xname, nid, dir) \
632 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
633 .info = conexant_ch_mode_info, \
634 .get = conexant_ch_mode_get, \
635 .put = conexant_ch_mode_put, \
636 .private_value = nid | (dir<<16) }
638 #endif /* CONFIG_SND_DEBUG */
640 /* Conexant 5045 specific */
642 static const hda_nid_t cxt5045_dac_nids[1] = { 0x19 };
643 static const hda_nid_t cxt5045_adc_nids[1] = { 0x1a };
644 static const hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a };
645 #define CXT5045_SPDIF_OUT 0x18
647 static const struct hda_channel_mode cxt5045_modes[1] = {
651 static const struct hda_input_mux cxt5045_capture_source = {
654 { "Internal Mic", 0x1 },
659 static const struct hda_input_mux cxt5045_capture_source_benq = {
662 { "Internal Mic", 0x1 },
669 static const struct hda_input_mux cxt5045_capture_source_hp530 = {
673 { "Internal Mic", 0x2 },
677 /* turn on/off EAPD (+ mute HP) as a master switch */
678 static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
679 struct snd_ctl_elem_value *ucontrol)
681 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
682 struct conexant_spec *spec = codec->spec;
685 if (!cxt_eapd_put(kcontrol, ucontrol))
688 /* toggle internal speakers mute depending of presence of
691 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
692 snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
695 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
696 snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0,
701 /* bind volumes of both NID 0x10 and 0x11 */
702 static const struct hda_bind_ctls cxt5045_hp_bind_master_vol = {
703 .ops = &snd_hda_bind_vol,
705 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT),
706 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
711 /* toggle input of built-in and mic jack appropriately */
712 static void cxt5045_hp_automic(struct hda_codec *codec)
714 static const struct hda_verb mic_jack_on[] = {
715 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
716 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
719 static const struct hda_verb mic_jack_off[] = {
720 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
721 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
724 unsigned int present;
726 present = snd_hda_jack_detect(codec, 0x12);
728 snd_hda_sequence_write(codec, mic_jack_on);
730 snd_hda_sequence_write(codec, mic_jack_off);
734 /* mute internal speaker if HP is plugged */
735 static void cxt5045_hp_automute(struct hda_codec *codec)
737 struct conexant_spec *spec = codec->spec;
740 spec->hp_present = snd_hda_jack_detect(codec, 0x11);
742 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
743 snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
747 /* unsolicited event for HP jack sensing */
748 static void cxt5045_hp_unsol_event(struct hda_codec *codec,
753 case CONEXANT_HP_EVENT:
754 cxt5045_hp_automute(codec);
756 case CONEXANT_MIC_EVENT:
757 cxt5045_hp_automic(codec);
763 static const struct snd_kcontrol_new cxt5045_mixers[] = {
764 HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT),
765 HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT),
766 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
767 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
768 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
769 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
770 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
771 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
772 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
774 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
775 .name = "Master Playback Switch",
776 .info = cxt_eapd_info,
778 .put = cxt5045_hp_master_sw_put,
779 .private_value = 0x10,
785 static const struct snd_kcontrol_new cxt5045_benq_mixers[] = {
786 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x3, HDA_INPUT),
787 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x3, HDA_INPUT),
792 static const struct snd_kcontrol_new cxt5045_mixers_hp530[] = {
793 HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT),
794 HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT),
795 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
796 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
797 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
798 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
799 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
800 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
801 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
803 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
804 .name = "Master Playback Switch",
805 .info = cxt_eapd_info,
807 .put = cxt5045_hp_master_sw_put,
808 .private_value = 0x10,
814 static const struct hda_verb cxt5045_init_verbs[] = {
816 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
817 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
819 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
820 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
821 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
822 {0x11, AC_VERB_SET_CONNECT_SEL, 0x1},
823 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
824 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
825 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
826 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
827 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
828 /* Record selector: Internal mic */
829 {0x1a, AC_VERB_SET_CONNECT_SEL,0x1},
830 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
831 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
832 /* SPDIF route: PCM */
833 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
834 { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
836 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */
840 static const struct hda_verb cxt5045_benq_init_verbs[] = {
841 /* Internal Mic, Mic */
842 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
843 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
844 /* Line In,HP, Amp */
845 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
846 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
847 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
848 {0x11, AC_VERB_SET_CONNECT_SEL, 0x1},
849 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
850 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
851 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
852 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
853 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
854 /* Record selector: Internal mic */
855 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x1},
856 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
857 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
858 /* SPDIF route: PCM */
859 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
860 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
862 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
866 static const struct hda_verb cxt5045_hp_sense_init_verbs[] = {
867 /* pin sensing on HP jack */
868 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
872 static const struct hda_verb cxt5045_mic_sense_init_verbs[] = {
873 /* pin sensing on HP jack */
874 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
878 #ifdef CONFIG_SND_DEBUG
879 /* Test configuration for debugging, modelled after the ALC260 test
882 static const struct hda_input_mux cxt5045_test_capture_source = {
887 { "LINE1 pin", 0x2 },
888 { "HP-OUT pin", 0x3 },
893 static const struct snd_kcontrol_new cxt5045_test_mixer[] = {
895 /* Output controls */
896 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
897 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
898 HDA_CODEC_VOLUME("HP-OUT Playback Volume", 0x11, 0x0, HDA_OUTPUT),
899 HDA_CODEC_MUTE("HP-OUT Playback Switch", 0x11, 0x0, HDA_OUTPUT),
900 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x12, 0x0, HDA_OUTPUT),
901 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x12, 0x0, HDA_OUTPUT),
903 /* Modes for retasking pin widgets */
904 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
905 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT),
907 /* EAPD Switch Control */
908 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
910 /* Loopback mixer controls */
912 HDA_CODEC_VOLUME("PCM Volume", 0x17, 0x0, HDA_INPUT),
913 HDA_CODEC_MUTE("PCM Switch", 0x17, 0x0, HDA_INPUT),
914 HDA_CODEC_VOLUME("MIC1 pin Volume", 0x17, 0x1, HDA_INPUT),
915 HDA_CODEC_MUTE("MIC1 pin Switch", 0x17, 0x1, HDA_INPUT),
916 HDA_CODEC_VOLUME("LINE1 pin Volume", 0x17, 0x2, HDA_INPUT),
917 HDA_CODEC_MUTE("LINE1 pin Switch", 0x17, 0x2, HDA_INPUT),
918 HDA_CODEC_VOLUME("HP-OUT pin Volume", 0x17, 0x3, HDA_INPUT),
919 HDA_CODEC_MUTE("HP-OUT pin Switch", 0x17, 0x3, HDA_INPUT),
920 HDA_CODEC_VOLUME("CD pin Volume", 0x17, 0x4, HDA_INPUT),
921 HDA_CODEC_MUTE("CD pin Switch", 0x17, 0x4, HDA_INPUT),
923 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
924 .name = "Input Source",
925 .info = conexant_mux_enum_info,
926 .get = conexant_mux_enum_get,
927 .put = conexant_mux_enum_put,
929 /* Audio input controls */
930 HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x0, HDA_INPUT),
931 HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT),
935 static const struct hda_verb cxt5045_test_init_verbs[] = {
936 /* Set connections */
937 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
938 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 },
939 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 },
940 /* Enable retasking pins as output, initially without power amp */
941 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
942 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
944 /* Disable digital (SPDIF) pins initially, but users can enable
945 * them via a mixer switch. In the case of SPDIF-out, this initverb
946 * payload also sets the generation to 0, output to be in "consumer"
947 * PCM format, copyright asserted, no pre-emphasis and no validity
950 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
951 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
953 /* Unmute retasking pin widget output buffers since the default
954 * state appears to be output. As the pin mode is changed by the
955 * user the pin mode control will take care of enabling the pin's
956 * input/output buffers as needed.
958 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
959 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
961 /* Mute capture amp left and right */
962 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
964 /* Set ADC connection select to match default mixer setting (mic1
967 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
968 {0x17, AC_VERB_SET_CONNECT_SEL, 0x01},
970 /* Mute all inputs to mixer widget (even unconnected ones) */
971 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer */
972 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */
973 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */
974 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */
975 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
982 /* initialize jack-sensing, too */
983 static int cxt5045_init(struct hda_codec *codec)
985 conexant_init(codec);
986 cxt5045_hp_automute(codec);
992 CXT5045_LAPTOP_HPSENSE,
993 CXT5045_LAPTOP_MICSENSE,
994 CXT5045_LAPTOP_HPMICSENSE,
996 CXT5045_LAPTOP_HP530,
997 #ifdef CONFIG_SND_DEBUG
1004 static const char * const cxt5045_models[CXT5045_MODELS] = {
1005 [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense",
1006 [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense",
1007 [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense",
1008 [CXT5045_BENQ] = "benq",
1009 [CXT5045_LAPTOP_HP530] = "laptop-hp530",
1010 #ifdef CONFIG_SND_DEBUG
1011 [CXT5045_TEST] = "test",
1013 [CXT5045_AUTO] = "auto",
1016 static const struct snd_pci_quirk cxt5045_cfg_tbl[] = {
1017 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530),
1018 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE),
1019 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ),
1020 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE),
1021 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE),
1022 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
1023 CXT5045_LAPTOP_HPMICSENSE),
1024 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE),
1025 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE),
1026 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE),
1027 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
1028 CXT5045_LAPTOP_HPMICSENSE),
1029 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE),
1033 static int patch_cxt5045(struct hda_codec *codec)
1035 struct conexant_spec *spec;
1038 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
1041 if (board_config < 0)
1042 board_config = CXT5045_AUTO; /* model=auto as default */
1043 if (board_config == CXT5045_AUTO)
1044 return patch_conexant_auto(codec);
1046 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1050 codec->single_adc_amp = 1;
1052 spec->multiout.max_channels = 2;
1053 spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids);
1054 spec->multiout.dac_nids = cxt5045_dac_nids;
1055 spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT;
1056 spec->num_adc_nids = 1;
1057 spec->adc_nids = cxt5045_adc_nids;
1058 spec->capsrc_nids = cxt5045_capsrc_nids;
1059 spec->input_mux = &cxt5045_capture_source;
1060 spec->num_mixers = 1;
1061 spec->mixers[0] = cxt5045_mixers;
1062 spec->num_init_verbs = 1;
1063 spec->init_verbs[0] = cxt5045_init_verbs;
1064 spec->spdif_route = 0;
1065 spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes);
1066 spec->channel_mode = cxt5045_modes;
1068 set_beep_amp(spec, 0x16, 0, 1);
1070 codec->patch_ops = conexant_patch_ops;
1072 switch (board_config) {
1073 case CXT5045_LAPTOP_HPSENSE:
1074 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
1075 spec->input_mux = &cxt5045_capture_source;
1076 spec->num_init_verbs = 2;
1077 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
1078 spec->mixers[0] = cxt5045_mixers;
1079 codec->patch_ops.init = cxt5045_init;
1081 case CXT5045_LAPTOP_MICSENSE:
1082 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
1083 spec->input_mux = &cxt5045_capture_source;
1084 spec->num_init_verbs = 2;
1085 spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;
1086 spec->mixers[0] = cxt5045_mixers;
1087 codec->patch_ops.init = cxt5045_init;
1090 case CXT5045_LAPTOP_HPMICSENSE:
1091 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
1092 spec->input_mux = &cxt5045_capture_source;
1093 spec->num_init_verbs = 3;
1094 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
1095 spec->init_verbs[2] = cxt5045_mic_sense_init_verbs;
1096 spec->mixers[0] = cxt5045_mixers;
1097 codec->patch_ops.init = cxt5045_init;
1100 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
1101 spec->input_mux = &cxt5045_capture_source_benq;
1102 spec->num_init_verbs = 1;
1103 spec->init_verbs[0] = cxt5045_benq_init_verbs;
1104 spec->mixers[0] = cxt5045_mixers;
1105 spec->mixers[1] = cxt5045_benq_mixers;
1106 spec->num_mixers = 2;
1107 codec->patch_ops.init = cxt5045_init;
1109 case CXT5045_LAPTOP_HP530:
1110 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
1111 spec->input_mux = &cxt5045_capture_source_hp530;
1112 spec->num_init_verbs = 2;
1113 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
1114 spec->mixers[0] = cxt5045_mixers_hp530;
1115 codec->patch_ops.init = cxt5045_init;
1117 #ifdef CONFIG_SND_DEBUG
1119 spec->input_mux = &cxt5045_test_capture_source;
1120 spec->mixers[0] = cxt5045_test_mixer;
1121 spec->init_verbs[0] = cxt5045_test_init_verbs;
1127 switch (codec->subsystem_id >> 16) {
1132 /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have
1133 * really bad sound over 0dB on NID 0x17. Fix max PCM level to
1134 * 0 dB (originally it has 0x2b steps with 0dB offset 0x14)
1136 snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT,
1137 (0x14 << AC_AMPCAP_OFFSET_SHIFT) |
1138 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) |
1139 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
1140 (1 << AC_AMPCAP_MUTE_SHIFT));
1145 snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp));
1151 /* Conexant 5047 specific */
1152 #define CXT5047_SPDIF_OUT 0x11
1154 static const hda_nid_t cxt5047_dac_nids[1] = { 0x10 }; /* 0x1c */
1155 static const hda_nid_t cxt5047_adc_nids[1] = { 0x12 };
1156 static const hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a };
1158 static const struct hda_channel_mode cxt5047_modes[1] = {
1162 static const struct hda_input_mux cxt5047_toshiba_capture_source = {
1170 /* turn on/off EAPD (+ mute HP) as a master switch */
1171 static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1172 struct snd_ctl_elem_value *ucontrol)
1174 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1175 struct conexant_spec *spec = codec->spec;
1178 if (!cxt_eapd_put(kcontrol, ucontrol))
1181 /* toggle internal speakers mute depending of presence of
1182 * the headphone jack
1184 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
1185 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1186 * pin widgets unlike other codecs. In this case, we need to
1187 * set index 0x01 for the volume from the mixer amp 0x19.
1189 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01,
1190 HDA_AMP_MUTE, bits);
1191 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
1192 snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0,
1193 HDA_AMP_MUTE, bits);
1197 /* mute internal speaker if HP is plugged */
1198 static void cxt5047_hp_automute(struct hda_codec *codec)
1200 struct conexant_spec *spec = codec->spec;
1203 spec->hp_present = snd_hda_jack_detect(codec, 0x13);
1205 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
1206 /* See the note in cxt5047_hp_master_sw_put */
1207 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01,
1208 HDA_AMP_MUTE, bits);
1211 /* toggle input of built-in and mic jack appropriately */
1212 static void cxt5047_hp_automic(struct hda_codec *codec)
1214 static const struct hda_verb mic_jack_on[] = {
1215 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1216 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1219 static const struct hda_verb mic_jack_off[] = {
1220 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1221 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1224 unsigned int present;
1226 present = snd_hda_jack_detect(codec, 0x15);
1228 snd_hda_sequence_write(codec, mic_jack_on);
1230 snd_hda_sequence_write(codec, mic_jack_off);
1233 /* unsolicited event for HP jack sensing */
1234 static void cxt5047_hp_unsol_event(struct hda_codec *codec,
1237 switch (res >> 26) {
1238 case CONEXANT_HP_EVENT:
1239 cxt5047_hp_automute(codec);
1241 case CONEXANT_MIC_EVENT:
1242 cxt5047_hp_automic(codec);
1247 static const struct snd_kcontrol_new cxt5047_base_mixers[] = {
1248 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT),
1249 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT),
1250 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT),
1251 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1252 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1253 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1254 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1256 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1257 .name = "Master Playback Switch",
1258 .info = cxt_eapd_info,
1259 .get = cxt_eapd_get,
1260 .put = cxt5047_hp_master_sw_put,
1261 .private_value = 0x13,
1267 static const struct snd_kcontrol_new cxt5047_hp_spk_mixers[] = {
1268 /* See the note in cxt5047_hp_master_sw_put */
1269 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT),
1270 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1274 static const struct snd_kcontrol_new cxt5047_hp_only_mixers[] = {
1275 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1279 static const struct hda_verb cxt5047_init_verbs[] = {
1280 /* Line in, Mic, Built-in Mic */
1281 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1282 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1283 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1285 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1286 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, /* mixer(0x19) */
1287 {0x1d, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mixer(0x19) */
1288 /* Record selector: Mic */
1289 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1290 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1291 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1292 {0x1A, AC_VERB_SET_CONNECT_SEL,0x02},
1293 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1294 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1295 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1296 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
1297 /* SPDIF route: PCM */
1298 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
1299 /* Enable unsolicited events */
1300 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1301 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1305 /* configuration for Toshiba Laptops */
1306 static const struct hda_verb cxt5047_toshiba_init_verbs[] = {
1307 {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0}, /* default off */
1311 /* Test configuration for debugging, modelled after the ALC260 test
1314 #ifdef CONFIG_SND_DEBUG
1315 static const struct hda_input_mux cxt5047_test_capture_source = {
1318 { "LINE1 pin", 0x0 },
1319 { "MIC1 pin", 0x1 },
1320 { "MIC2 pin", 0x2 },
1325 static const struct snd_kcontrol_new cxt5047_test_mixer[] = {
1327 /* Output only controls */
1328 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT),
1329 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT),
1330 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT),
1331 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT),
1332 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1333 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1334 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1335 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1336 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT),
1337 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1338 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT),
1339 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT),
1341 /* Modes for retasking pin widgets */
1342 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT),
1343 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT),
1345 /* EAPD Switch Control */
1346 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1348 /* Loopback mixer controls */
1349 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT),
1350 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT),
1351 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT),
1352 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT),
1353 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT),
1354 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT),
1355 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT),
1356 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT),
1358 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT),
1359 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT),
1360 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT),
1361 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT),
1362 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT),
1363 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT),
1364 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT),
1365 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT),
1367 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1368 .name = "Input Source",
1369 .info = conexant_mux_enum_info,
1370 .get = conexant_mux_enum_get,
1371 .put = conexant_mux_enum_put,
1373 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT),
1378 static const struct hda_verb cxt5047_test_init_verbs[] = {
1379 /* Enable retasking pins as output, initially without power amp */
1380 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1381 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1382 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1384 /* Disable digital (SPDIF) pins initially, but users can enable
1385 * them via a mixer switch. In the case of SPDIF-out, this initverb
1386 * payload also sets the generation to 0, output to be in "consumer"
1387 * PCM format, copyright asserted, no pre-emphasis and no validity
1390 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
1392 /* Ensure mic1, mic2, line1 pin widgets take input from the
1393 * OUT1 sum bus when acting as an output.
1395 {0x1a, AC_VERB_SET_CONNECT_SEL, 0},
1396 {0x1b, AC_VERB_SET_CONNECT_SEL, 0},
1398 /* Start with output sum widgets muted and their output gains at min */
1399 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1400 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1402 /* Unmute retasking pin widget output buffers since the default
1403 * state appears to be output. As the pin mode is changed by the
1404 * user the pin mode control will take care of enabling the pin's
1405 * input/output buffers as needed.
1407 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1408 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1409 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1411 /* Mute capture amp left and right */
1412 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1414 /* Set ADC connection select to match default mixer setting (mic1
1417 {0x12, AC_VERB_SET_CONNECT_SEL, 0x00},
1419 /* Mute all inputs to mixer widget (even unconnected ones) */
1420 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
1421 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
1422 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
1423 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
1424 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
1425 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1426 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
1427 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
1434 /* initialize jack-sensing, too */
1435 static int cxt5047_hp_init(struct hda_codec *codec)
1437 conexant_init(codec);
1438 cxt5047_hp_automute(codec);
1444 CXT5047_LAPTOP, /* Laptops w/o EAPD support */
1445 CXT5047_LAPTOP_HP, /* Some HP laptops */
1446 CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */
1447 #ifdef CONFIG_SND_DEBUG
1454 static const char * const cxt5047_models[CXT5047_MODELS] = {
1455 [CXT5047_LAPTOP] = "laptop",
1456 [CXT5047_LAPTOP_HP] = "laptop-hp",
1457 [CXT5047_LAPTOP_EAPD] = "laptop-eapd",
1458 #ifdef CONFIG_SND_DEBUG
1459 [CXT5047_TEST] = "test",
1461 [CXT5047_AUTO] = "auto",
1464 static const struct snd_pci_quirk cxt5047_cfg_tbl[] = {
1465 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
1466 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1468 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD),
1472 static int patch_cxt5047(struct hda_codec *codec)
1474 struct conexant_spec *spec;
1477 board_config = snd_hda_check_board_config(codec, CXT5047_MODELS,
1480 if (board_config < 0)
1481 board_config = CXT5047_AUTO; /* model=auto as default */
1482 if (board_config == CXT5047_AUTO)
1483 return patch_conexant_auto(codec);
1485 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1489 codec->pin_amp_workaround = 1;
1491 spec->multiout.max_channels = 2;
1492 spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids);
1493 spec->multiout.dac_nids = cxt5047_dac_nids;
1494 spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT;
1495 spec->num_adc_nids = 1;
1496 spec->adc_nids = cxt5047_adc_nids;
1497 spec->capsrc_nids = cxt5047_capsrc_nids;
1498 spec->num_mixers = 1;
1499 spec->mixers[0] = cxt5047_base_mixers;
1500 spec->num_init_verbs = 1;
1501 spec->init_verbs[0] = cxt5047_init_verbs;
1502 spec->spdif_route = 0;
1503 spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes),
1504 spec->channel_mode = cxt5047_modes,
1506 codec->patch_ops = conexant_patch_ops;
1508 switch (board_config) {
1509 case CXT5047_LAPTOP:
1510 spec->num_mixers = 2;
1511 spec->mixers[1] = cxt5047_hp_spk_mixers;
1512 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1514 case CXT5047_LAPTOP_HP:
1515 spec->num_mixers = 2;
1516 spec->mixers[1] = cxt5047_hp_only_mixers;
1517 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1518 codec->patch_ops.init = cxt5047_hp_init;
1520 case CXT5047_LAPTOP_EAPD:
1521 spec->input_mux = &cxt5047_toshiba_capture_source;
1522 spec->num_mixers = 2;
1523 spec->mixers[1] = cxt5047_hp_spk_mixers;
1524 spec->num_init_verbs = 2;
1525 spec->init_verbs[1] = cxt5047_toshiba_init_verbs;
1526 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1528 #ifdef CONFIG_SND_DEBUG
1530 spec->input_mux = &cxt5047_test_capture_source;
1531 spec->mixers[0] = cxt5047_test_mixer;
1532 spec->init_verbs[0] = cxt5047_test_init_verbs;
1533 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1536 spec->vmaster_nid = 0x13;
1538 switch (codec->subsystem_id >> 16) {
1540 /* HP laptops have really bad sound over 0 dB on NID 0x10.
1541 * Fix max PCM level to 0 dB (originally it has 0x1e steps
1542 * with 0 dB offset 0x17)
1544 snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT,
1545 (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
1546 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
1547 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
1548 (1 << AC_AMPCAP_MUTE_SHIFT));
1555 /* Conexant 5051 specific */
1556 static const hda_nid_t cxt5051_dac_nids[1] = { 0x10 };
1557 static const hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 };
1559 static const struct hda_channel_mode cxt5051_modes[1] = {
1563 static void cxt5051_update_speaker(struct hda_codec *codec)
1565 struct conexant_spec *spec = codec->spec;
1566 unsigned int pinctl;
1568 pinctl = (spec->hp_present && spec->cur_eapd) ? PIN_HP : 0;
1569 snd_hda_set_pin_ctl(codec, 0x16, pinctl);
1571 pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0;
1572 snd_hda_set_pin_ctl(codec, 0x1a, pinctl);
1573 /* on ideapad there is an additional speaker (subwoofer) to mute */
1575 snd_hda_set_pin_ctl(codec, 0x1b, pinctl);
1578 /* turn on/off EAPD (+ mute HP) as a master switch */
1579 static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1580 struct snd_ctl_elem_value *ucontrol)
1582 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1584 if (!cxt_eapd_put(kcontrol, ucontrol))
1586 cxt5051_update_speaker(codec);
1590 /* toggle input of built-in and mic jack appropriately */
1591 static void cxt5051_portb_automic(struct hda_codec *codec)
1593 struct conexant_spec *spec = codec->spec;
1594 unsigned int present;
1596 if (!(spec->auto_mic & AUTO_MIC_PORTB))
1598 present = snd_hda_jack_detect(codec, 0x17);
1599 snd_hda_codec_write(codec, 0x14, 0,
1600 AC_VERB_SET_CONNECT_SEL,
1601 present ? 0x01 : 0x00);
1604 /* switch the current ADC according to the jack state */
1605 static void cxt5051_portc_automic(struct hda_codec *codec)
1607 struct conexant_spec *spec = codec->spec;
1608 unsigned int present;
1611 if (!(spec->auto_mic & AUTO_MIC_PORTC))
1613 present = snd_hda_jack_detect(codec, 0x18);
1615 spec->cur_adc_idx = 1;
1617 spec->cur_adc_idx = 0;
1618 new_adc = spec->adc_nids[spec->cur_adc_idx];
1619 if (spec->cur_adc && spec->cur_adc != new_adc) {
1620 /* stream is running, let's swap the current ADC */
1621 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
1622 spec->cur_adc = new_adc;
1623 snd_hda_codec_setup_stream(codec, new_adc,
1624 spec->cur_adc_stream_tag, 0,
1625 spec->cur_adc_format);
1629 /* mute internal speaker if HP is plugged */
1630 static void cxt5051_hp_automute(struct hda_codec *codec)
1632 struct conexant_spec *spec = codec->spec;
1634 spec->hp_present = snd_hda_jack_detect(codec, 0x16);
1635 cxt5051_update_speaker(codec);
1638 /* unsolicited event for HP jack sensing */
1639 static void cxt5051_hp_unsol_event(struct hda_codec *codec,
1642 switch (res >> 26) {
1643 case CONEXANT_HP_EVENT:
1644 cxt5051_hp_automute(codec);
1646 case CXT5051_PORTB_EVENT:
1647 cxt5051_portb_automic(codec);
1649 case CXT5051_PORTC_EVENT:
1650 cxt5051_portc_automic(codec);
1655 static const struct snd_kcontrol_new cxt5051_playback_mixers[] = {
1656 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1658 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1659 .name = "Master Playback Switch",
1660 .info = cxt_eapd_info,
1661 .get = cxt_eapd_get,
1662 .put = cxt5051_hp_master_sw_put,
1663 .private_value = 0x1a,
1668 static const struct snd_kcontrol_new cxt5051_capture_mixers[] = {
1669 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
1670 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
1671 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT),
1672 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT),
1673 HDA_CODEC_VOLUME("Dock Mic Volume", 0x15, 0x00, HDA_INPUT),
1674 HDA_CODEC_MUTE("Dock Mic Switch", 0x15, 0x00, HDA_INPUT),
1678 static const struct snd_kcontrol_new cxt5051_hp_mixers[] = {
1679 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
1680 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
1681 HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT),
1682 HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT),
1686 static const struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = {
1687 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT),
1688 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT),
1692 static const struct snd_kcontrol_new cxt5051_f700_mixers[] = {
1693 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT),
1694 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT),
1698 static const struct snd_kcontrol_new cxt5051_toshiba_mixers[] = {
1699 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
1700 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
1701 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT),
1702 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT),
1706 static const struct hda_verb cxt5051_init_verbs[] = {
1708 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1709 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1710 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1711 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1712 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1713 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1715 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1716 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1718 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1719 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
1721 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1722 /* Record selector: Internal mic */
1723 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1724 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
1725 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1726 /* SPDIF route: PCM */
1727 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1728 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
1730 {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
1731 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1735 static const struct hda_verb cxt5051_hp_dv6736_init_verbs[] = {
1737 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1738 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1739 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0},
1740 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0},
1742 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1743 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1745 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1746 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
1748 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1749 /* Record selector: Internal mic */
1750 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
1751 {0x14, AC_VERB_SET_CONNECT_SEL, 0x1},
1752 /* SPDIF route: PCM */
1753 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
1755 {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
1756 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1760 static const struct hda_verb cxt5051_f700_init_verbs[] = {
1762 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1763 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1764 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0},
1765 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0},
1767 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1768 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1770 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1771 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
1773 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1774 /* Record selector: Internal mic */
1775 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
1776 {0x14, AC_VERB_SET_CONNECT_SEL, 0x1},
1777 /* SPDIF route: PCM */
1778 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
1780 {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
1781 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1785 static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid,
1788 snd_hda_codec_write(codec, nid, 0,
1789 AC_VERB_SET_UNSOLICITED_ENABLE,
1790 AC_USRSP_EN | event);
1793 static const struct hda_verb cxt5051_ideapad_init_verbs[] = {
1795 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1796 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1800 /* initialize jack-sensing, too */
1801 static int cxt5051_init(struct hda_codec *codec)
1803 struct conexant_spec *spec = codec->spec;
1805 conexant_init(codec);
1807 if (spec->auto_mic & AUTO_MIC_PORTB)
1808 cxt5051_init_mic_port(codec, 0x17, CXT5051_PORTB_EVENT);
1809 if (spec->auto_mic & AUTO_MIC_PORTC)
1810 cxt5051_init_mic_port(codec, 0x18, CXT5051_PORTC_EVENT);
1812 if (codec->patch_ops.unsol_event) {
1813 cxt5051_hp_automute(codec);
1814 cxt5051_portb_automic(codec);
1815 cxt5051_portc_automic(codec);
1822 CXT5051_LAPTOP, /* Laptops w/ EAPD support */
1823 CXT5051_HP, /* no docking */
1824 CXT5051_HP_DV6736, /* HP without mic switch */
1825 CXT5051_F700, /* HP Compaq Presario F700 */
1826 CXT5051_TOSHIBA, /* Toshiba M300 & co */
1827 CXT5051_IDEAPAD, /* Lenovo IdeaPad Y430 */
1828 CXT5051_AUTO, /* auto-parser */
1832 static const char *const cxt5051_models[CXT5051_MODELS] = {
1833 [CXT5051_LAPTOP] = "laptop",
1834 [CXT5051_HP] = "hp",
1835 [CXT5051_HP_DV6736] = "hp-dv6736",
1836 [CXT5051_F700] = "hp-700",
1837 [CXT5051_TOSHIBA] = "toshiba",
1838 [CXT5051_IDEAPAD] = "ideapad",
1839 [CXT5051_AUTO] = "auto",
1842 static const struct snd_pci_quirk cxt5051_cfg_tbl[] = {
1843 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736),
1844 SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP),
1845 SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700),
1846 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA),
1847 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1849 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP),
1850 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD),
1854 static int patch_cxt5051(struct hda_codec *codec)
1856 struct conexant_spec *spec;
1859 board_config = snd_hda_check_board_config(codec, CXT5051_MODELS,
1862 if (board_config < 0)
1863 board_config = CXT5051_AUTO; /* model=auto as default */
1864 if (board_config == CXT5051_AUTO)
1865 return patch_conexant_auto(codec);
1867 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1871 codec->pin_amp_workaround = 1;
1873 codec->patch_ops = conexant_patch_ops;
1874 codec->patch_ops.init = cxt5051_init;
1876 spec->multiout.max_channels = 2;
1877 spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids);
1878 spec->multiout.dac_nids = cxt5051_dac_nids;
1879 spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT;
1880 spec->num_adc_nids = 1; /* not 2; via auto-mic switch */
1881 spec->adc_nids = cxt5051_adc_nids;
1882 spec->num_mixers = 2;
1883 spec->mixers[0] = cxt5051_capture_mixers;
1884 spec->mixers[1] = cxt5051_playback_mixers;
1885 spec->num_init_verbs = 1;
1886 spec->init_verbs[0] = cxt5051_init_verbs;
1887 spec->spdif_route = 0;
1888 spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes);
1889 spec->channel_mode = cxt5051_modes;
1891 spec->cur_adc_idx = 0;
1893 set_beep_amp(spec, 0x13, 0, HDA_OUTPUT);
1895 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
1897 spec->auto_mic = AUTO_MIC_PORTB | AUTO_MIC_PORTC;
1898 switch (board_config) {
1900 spec->mixers[0] = cxt5051_hp_mixers;
1902 case CXT5051_HP_DV6736:
1903 spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs;
1904 spec->mixers[0] = cxt5051_hp_dv6736_mixers;
1908 spec->init_verbs[0] = cxt5051_f700_init_verbs;
1909 spec->mixers[0] = cxt5051_f700_mixers;
1912 case CXT5051_TOSHIBA:
1913 spec->mixers[0] = cxt5051_toshiba_mixers;
1914 spec->auto_mic = AUTO_MIC_PORTB;
1916 case CXT5051_IDEAPAD:
1917 spec->init_verbs[spec->num_init_verbs++] =
1918 cxt5051_ideapad_init_verbs;
1924 snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp));
1929 /* Conexant 5066 specific */
1931 static const hda_nid_t cxt5066_dac_nids[1] = { 0x10 };
1932 static const hda_nid_t cxt5066_adc_nids[3] = { 0x14, 0x15, 0x16 };
1933 static const hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 };
1934 static const hda_nid_t cxt5066_digout_pin_nids[2] = { 0x20, 0x22 };
1936 /* OLPC's microphone port is DC coupled for use with external sensors,
1937 * therefore we use a 50% mic bias in order to center the input signal with
1938 * the DC input range of the codec. */
1939 #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50
1941 static const struct hda_channel_mode cxt5066_modes[1] = {
1945 #define HP_PRESENT_PORT_A (1 << 0)
1946 #define HP_PRESENT_PORT_D (1 << 1)
1947 #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A)
1948 #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D)
1950 static void cxt5066_update_speaker(struct hda_codec *codec)
1952 struct conexant_spec *spec = codec->spec;
1953 unsigned int pinctl;
1955 snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n",
1956 spec->hp_present, spec->cur_eapd);
1959 pinctl = (hp_port_a_present(spec) && spec->cur_eapd) ? PIN_HP : 0;
1960 snd_hda_set_pin_ctl(codec, 0x19, pinctl);
1962 /* Port D (HP/LO) */
1963 pinctl = spec->cur_eapd ? spec->port_d_mode : 0;
1964 if (spec->dell_automute || spec->thinkpad) {
1965 /* Mute if Port A is connected */
1966 if (hp_port_a_present(spec))
1969 /* Thinkpad/Dell doesn't give pin-D status */
1970 if (!hp_port_d_present(spec))
1973 snd_hda_set_pin_ctl(codec, 0x1c, pinctl);
1976 pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0;
1977 snd_hda_set_pin_ctl(codec, 0x1f, pinctl);
1980 /* turn on/off EAPD (+ mute HP) as a master switch */
1981 static int cxt5066_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1982 struct snd_ctl_elem_value *ucontrol)
1984 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1986 if (!cxt_eapd_put(kcontrol, ucontrol))
1989 cxt5066_update_speaker(codec);
1993 static const struct hda_input_mux cxt5066_olpc_dc_bias = {
1997 { "50%", PIN_VREF50 },
1998 { "80%", PIN_VREF80 },
2002 static int cxt5066_set_olpc_dc_bias(struct hda_codec *codec)
2004 struct conexant_spec *spec = codec->spec;
2005 /* Even though port F is the DC input, the bias is controlled on port B.
2006 * we also leave that port as an active input (but unselected) in DC mode
2007 * just in case that is necessary to make the bias setting take effect. */
2008 return snd_hda_set_pin_ctl_cache(codec, 0x1a,
2009 cxt5066_olpc_dc_bias.items[spec->dc_input_bias].index);
2012 /* OLPC defers mic widget control until when capture is started because the
2013 * microphone LED comes on as soon as these settings are put in place. if we
2014 * did this before recording, it would give the false indication that recording
2015 * is happening when it is not. */
2016 static void cxt5066_olpc_select_mic(struct hda_codec *codec)
2018 struct conexant_spec *spec = codec->spec;
2019 if (!spec->recording)
2022 if (spec->dc_enable) {
2023 /* in DC mode we ignore presence detection and just use the jack
2024 * through our special DC port */
2025 const struct hda_verb enable_dc_mode[] = {
2026 /* disble internal mic, port C */
2027 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2029 /* enable DC capture, port F */
2030 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2034 snd_hda_sequence_write(codec, enable_dc_mode);
2035 /* port B input disabled (and bias set) through the following call */
2036 cxt5066_set_olpc_dc_bias(codec);
2040 /* disable DC (port F) */
2041 snd_hda_set_pin_ctl(codec, 0x1e, 0);
2043 /* external mic, port B */
2044 snd_hda_set_pin_ctl(codec, 0x1a,
2045 spec->ext_mic_present ? CXT5066_OLPC_EXT_MIC_BIAS : 0);
2047 /* internal mic, port C */
2048 snd_hda_set_pin_ctl(codec, 0x1b,
2049 spec->ext_mic_present ? 0 : PIN_VREF80);
2052 /* toggle input of built-in and mic jack appropriately */
2053 static void cxt5066_olpc_automic(struct hda_codec *codec)
2055 struct conexant_spec *spec = codec->spec;
2056 unsigned int present;
2058 if (spec->dc_enable) /* don't do presence detection in DC mode */
2061 present = snd_hda_codec_read(codec, 0x1a, 0,
2062 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2064 snd_printdd("CXT5066: external microphone detected\n");
2066 snd_printdd("CXT5066: external microphone absent\n");
2068 snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL,
2070 spec->ext_mic_present = !!present;
2072 cxt5066_olpc_select_mic(codec);
2075 /* toggle input of built-in digital mic and mic jack appropriately */
2076 static void cxt5066_vostro_automic(struct hda_codec *codec)
2078 unsigned int present;
2080 struct hda_verb ext_mic_present[] = {
2081 /* enable external mic, port B */
2082 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2084 /* switch to external mic input */
2085 {0x17, AC_VERB_SET_CONNECT_SEL, 0},
2086 {0x14, AC_VERB_SET_CONNECT_SEL, 0},
2088 /* disable internal digital mic */
2089 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2092 static const struct hda_verb ext_mic_absent[] = {
2093 /* enable internal mic, port C */
2094 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2096 /* switch to internal mic input */
2097 {0x14, AC_VERB_SET_CONNECT_SEL, 2},
2099 /* disable external mic, port B */
2100 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2104 present = snd_hda_jack_detect(codec, 0x1a);
2106 snd_printdd("CXT5066: external microphone detected\n");
2107 snd_hda_sequence_write(codec, ext_mic_present);
2109 snd_printdd("CXT5066: external microphone absent\n");
2110 snd_hda_sequence_write(codec, ext_mic_absent);
2114 /* toggle input of built-in digital mic and mic jack appropriately */
2115 static void cxt5066_ideapad_automic(struct hda_codec *codec)
2117 unsigned int present;
2119 struct hda_verb ext_mic_present[] = {
2120 {0x14, AC_VERB_SET_CONNECT_SEL, 0},
2121 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2122 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2125 static const struct hda_verb ext_mic_absent[] = {
2126 {0x14, AC_VERB_SET_CONNECT_SEL, 2},
2127 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2128 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2132 present = snd_hda_jack_detect(codec, 0x1b);
2134 snd_printdd("CXT5066: external microphone detected\n");
2135 snd_hda_sequence_write(codec, ext_mic_present);
2137 snd_printdd("CXT5066: external microphone absent\n");
2138 snd_hda_sequence_write(codec, ext_mic_absent);
2143 /* toggle input of built-in digital mic and mic jack appropriately */
2144 static void cxt5066_asus_automic(struct hda_codec *codec)
2146 unsigned int present;
2148 present = snd_hda_jack_detect(codec, 0x1b);
2149 snd_printdd("CXT5066: external microphone present=%d\n", present);
2150 snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL,
2155 /* toggle input of built-in digital mic and mic jack appropriately */
2156 static void cxt5066_hp_laptop_automic(struct hda_codec *codec)
2158 unsigned int present;
2160 present = snd_hda_jack_detect(codec, 0x1b);
2161 snd_printdd("CXT5066: external microphone present=%d\n", present);
2162 snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL,
2167 /* toggle input of built-in digital mic and mic jack appropriately
2168 order is: external mic -> dock mic -> interal mic */
2169 static void cxt5066_thinkpad_automic(struct hda_codec *codec)
2171 unsigned int ext_present, dock_present;
2173 static const struct hda_verb ext_mic_present[] = {
2174 {0x14, AC_VERB_SET_CONNECT_SEL, 0},
2175 {0x17, AC_VERB_SET_CONNECT_SEL, 1},
2176 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2177 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2178 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2181 static const struct hda_verb dock_mic_present[] = {
2182 {0x14, AC_VERB_SET_CONNECT_SEL, 0},
2183 {0x17, AC_VERB_SET_CONNECT_SEL, 0},
2184 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2185 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2186 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2189 static const struct hda_verb ext_mic_absent[] = {
2190 {0x14, AC_VERB_SET_CONNECT_SEL, 2},
2191 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2192 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2193 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2197 ext_present = snd_hda_jack_detect(codec, 0x1b);
2198 dock_present = snd_hda_jack_detect(codec, 0x1a);
2200 snd_printdd("CXT5066: external microphone detected\n");
2201 snd_hda_sequence_write(codec, ext_mic_present);
2202 } else if (dock_present) {
2203 snd_printdd("CXT5066: dock microphone detected\n");
2204 snd_hda_sequence_write(codec, dock_mic_present);
2206 snd_printdd("CXT5066: external microphone absent\n");
2207 snd_hda_sequence_write(codec, ext_mic_absent);
2211 /* mute internal speaker if HP is plugged */
2212 static void cxt5066_hp_automute(struct hda_codec *codec)
2214 struct conexant_spec *spec = codec->spec;
2215 unsigned int portA, portD;
2218 portA = snd_hda_jack_detect(codec, 0x19);
2221 portD = snd_hda_jack_detect(codec, 0x1c);
2223 spec->hp_present = portA ? HP_PRESENT_PORT_A : 0;
2224 spec->hp_present |= portD ? HP_PRESENT_PORT_D : 0;
2225 snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
2226 portA, portD, spec->hp_present);
2227 cxt5066_update_speaker(codec);
2230 /* Dispatch the right mic autoswitch function */
2231 static void cxt5066_automic(struct hda_codec *codec)
2233 struct conexant_spec *spec = codec->spec;
2235 if (spec->dell_vostro)
2236 cxt5066_vostro_automic(codec);
2237 else if (spec->ideapad)
2238 cxt5066_ideapad_automic(codec);
2239 else if (spec->thinkpad)
2240 cxt5066_thinkpad_automic(codec);
2241 else if (spec->hp_laptop)
2242 cxt5066_hp_laptop_automic(codec);
2243 else if (spec->asus)
2244 cxt5066_asus_automic(codec);
2247 /* unsolicited event for jack sensing */
2248 static void cxt5066_olpc_unsol_event(struct hda_codec *codec, unsigned int res)
2250 struct conexant_spec *spec = codec->spec;
2251 snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26);
2252 switch (res >> 26) {
2253 case CONEXANT_HP_EVENT:
2254 cxt5066_hp_automute(codec);
2256 case CONEXANT_MIC_EVENT:
2257 /* ignore mic events in DC mode; we're always using the jack */
2258 if (!spec->dc_enable)
2259 cxt5066_olpc_automic(codec);
2264 /* unsolicited event for jack sensing */
2265 static void cxt5066_unsol_event(struct hda_codec *codec, unsigned int res)
2267 snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26);
2268 switch (res >> 26) {
2269 case CONEXANT_HP_EVENT:
2270 cxt5066_hp_automute(codec);
2272 case CONEXANT_MIC_EVENT:
2273 cxt5066_automic(codec);
2279 static const struct hda_input_mux cxt5066_analog_mic_boost = {
2290 static void cxt5066_set_mic_boost(struct hda_codec *codec)
2292 struct conexant_spec *spec = codec->spec;
2293 snd_hda_codec_write_cache(codec, 0x17, 0,
2294 AC_VERB_SET_AMP_GAIN_MUTE,
2295 AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT |
2296 cxt5066_analog_mic_boost.items[spec->mic_boost].index);
2297 if (spec->ideapad || spec->thinkpad) {
2298 /* adjust the internal mic as well...it is not through 0x17 */
2299 snd_hda_codec_write_cache(codec, 0x23, 0,
2300 AC_VERB_SET_AMP_GAIN_MUTE,
2301 AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_INPUT |
2302 cxt5066_analog_mic_boost.
2303 items[spec->mic_boost].index);
2307 static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol *kcontrol,
2308 struct snd_ctl_elem_info *uinfo)
2310 return snd_hda_input_mux_info(&cxt5066_analog_mic_boost, uinfo);
2313 static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol *kcontrol,
2314 struct snd_ctl_elem_value *ucontrol)
2316 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2317 struct conexant_spec *spec = codec->spec;
2318 ucontrol->value.enumerated.item[0] = spec->mic_boost;
2322 static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol,
2323 struct snd_ctl_elem_value *ucontrol)
2325 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2326 struct conexant_spec *spec = codec->spec;
2327 const struct hda_input_mux *imux = &cxt5066_analog_mic_boost;
2329 idx = ucontrol->value.enumerated.item[0];
2330 if (idx >= imux->num_items)
2331 idx = imux->num_items - 1;
2333 spec->mic_boost = idx;
2334 if (!spec->dc_enable)
2335 cxt5066_set_mic_boost(codec);
2339 static void cxt5066_enable_dc(struct hda_codec *codec)
2341 const struct hda_verb enable_dc_mode[] = {
2343 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2345 /* switch to DC input */
2346 {0x17, AC_VERB_SET_CONNECT_SEL, 3},
2350 /* configure as input source */
2351 snd_hda_sequence_write(codec, enable_dc_mode);
2352 cxt5066_olpc_select_mic(codec); /* also sets configured bias */
2355 static void cxt5066_disable_dc(struct hda_codec *codec)
2357 /* reconfigure input source */
2358 cxt5066_set_mic_boost(codec);
2359 /* automic also selects the right mic if we're recording */
2360 cxt5066_olpc_automic(codec);
2363 static int cxt5066_olpc_dc_get(struct snd_kcontrol *kcontrol,
2364 struct snd_ctl_elem_value *ucontrol)
2366 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2367 struct conexant_spec *spec = codec->spec;
2368 ucontrol->value.integer.value[0] = spec->dc_enable;
2372 static int cxt5066_olpc_dc_put(struct snd_kcontrol *kcontrol,
2373 struct snd_ctl_elem_value *ucontrol)
2375 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2376 struct conexant_spec *spec = codec->spec;
2377 int dc_enable = !!ucontrol->value.integer.value[0];
2379 if (dc_enable == spec->dc_enable)
2382 spec->dc_enable = dc_enable;
2384 cxt5066_enable_dc(codec);
2386 cxt5066_disable_dc(codec);
2391 static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol *kcontrol,
2392 struct snd_ctl_elem_info *uinfo)
2394 return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias, uinfo);
2397 static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol *kcontrol,
2398 struct snd_ctl_elem_value *ucontrol)
2400 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2401 struct conexant_spec *spec = codec->spec;
2402 ucontrol->value.enumerated.item[0] = spec->dc_input_bias;
2406 static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol *kcontrol,
2407 struct snd_ctl_elem_value *ucontrol)
2409 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2410 struct conexant_spec *spec = codec->spec;
2411 const struct hda_input_mux *imux = &cxt5066_analog_mic_boost;
2414 idx = ucontrol->value.enumerated.item[0];
2415 if (idx >= imux->num_items)
2416 idx = imux->num_items - 1;
2418 spec->dc_input_bias = idx;
2419 if (spec->dc_enable)
2420 cxt5066_set_olpc_dc_bias(codec);
2424 static void cxt5066_olpc_capture_prepare(struct hda_codec *codec)
2426 struct conexant_spec *spec = codec->spec;
2427 /* mark as recording and configure the microphone widget so that the
2428 * recording LED comes on. */
2429 spec->recording = 1;
2430 cxt5066_olpc_select_mic(codec);
2433 static void cxt5066_olpc_capture_cleanup(struct hda_codec *codec)
2435 struct conexant_spec *spec = codec->spec;
2436 const struct hda_verb disable_mics[] = {
2437 /* disable external mic, port B */
2438 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2440 /* disble internal mic, port C */
2441 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2443 /* disable DC capture, port F */
2444 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2448 snd_hda_sequence_write(codec, disable_mics);
2449 spec->recording = 0;
2452 static void conexant_check_dig_outs(struct hda_codec *codec,
2453 const hda_nid_t *dig_pins,
2456 struct conexant_spec *spec = codec->spec;
2457 hda_nid_t *nid_loc = &spec->multiout.dig_out_nid;
2460 for (i = 0; i < num_pins; i++, dig_pins++) {
2461 unsigned int cfg = snd_hda_codec_get_pincfg(codec, *dig_pins);
2462 if (get_defcfg_connect(cfg) == AC_JACK_PORT_NONE)
2464 if (snd_hda_get_connections(codec, *dig_pins, nid_loc, 1) != 1)
2469 static const struct hda_input_mux cxt5066_capture_source = {
2479 static const struct hda_bind_ctls cxt5066_bind_capture_vol_others = {
2480 .ops = &snd_hda_bind_vol,
2482 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT),
2483 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT),
2488 static const struct hda_bind_ctls cxt5066_bind_capture_sw_others = {
2489 .ops = &snd_hda_bind_sw,
2491 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT),
2492 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT),
2497 static const struct snd_kcontrol_new cxt5066_mixer_master[] = {
2498 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
2502 static const struct snd_kcontrol_new cxt5066_mixer_master_olpc[] = {
2504 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2505 .name = "Master Playback Volume",
2506 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
2507 SNDRV_CTL_ELEM_ACCESS_TLV_READ |
2508 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK,
2509 .subdevice = HDA_SUBDEV_AMP_FLAG,
2510 .info = snd_hda_mixer_amp_volume_info,
2511 .get = snd_hda_mixer_amp_volume_get,
2512 .put = snd_hda_mixer_amp_volume_put,
2513 .tlv = { .c = snd_hda_mixer_amp_tlv },
2514 /* offset by 28 volume steps to limit minimum gain to -46dB */
2516 HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT, 28),
2521 static const struct snd_kcontrol_new cxt5066_mixer_olpc_dc[] = {
2523 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2524 .name = "DC Mode Enable Switch",
2525 .info = snd_ctl_boolean_mono_info,
2526 .get = cxt5066_olpc_dc_get,
2527 .put = cxt5066_olpc_dc_put,
2530 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2531 .name = "DC Input Bias Enum",
2532 .info = cxt5066_olpc_dc_bias_enum_info,
2533 .get = cxt5066_olpc_dc_bias_enum_get,
2534 .put = cxt5066_olpc_dc_bias_enum_put,
2539 static const struct snd_kcontrol_new cxt5066_mixers[] = {
2541 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2542 .name = "Master Playback Switch",
2543 .info = cxt_eapd_info,
2544 .get = cxt_eapd_get,
2545 .put = cxt5066_hp_master_sw_put,
2546 .private_value = 0x1d,
2550 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2551 .name = "Analog Mic Boost Capture Enum",
2552 .info = cxt5066_mic_boost_mux_enum_info,
2553 .get = cxt5066_mic_boost_mux_enum_get,
2554 .put = cxt5066_mic_boost_mux_enum_put,
2557 HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others),
2558 HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others),
2562 static const struct snd_kcontrol_new cxt5066_vostro_mixers[] = {
2564 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2565 .name = "Internal Mic Boost Capture Enum",
2566 .info = cxt5066_mic_boost_mux_enum_info,
2567 .get = cxt5066_mic_boost_mux_enum_get,
2568 .put = cxt5066_mic_boost_mux_enum_put,
2569 .private_value = 0x23 | 0x100,
2574 static const struct hda_verb cxt5066_init_verbs[] = {
2575 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */
2576 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */
2577 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */
2578 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */
2581 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2582 {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2585 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2586 {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2588 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2589 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2592 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2594 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2595 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50},
2596 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2597 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50},
2598 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2599 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2601 /* no digital microphone support yet */
2602 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2604 /* Audio input selector */
2605 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3},
2607 /* SPDIF route: PCM */
2608 {0x20, AC_VERB_SET_CONNECT_SEL, 0x0},
2609 {0x22, AC_VERB_SET_CONNECT_SEL, 0x0},
2611 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2612 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2615 {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
2617 /* not handling these yet */
2618 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
2619 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
2620 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
2621 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
2622 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
2623 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
2624 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
2625 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
2629 static const struct hda_verb cxt5066_init_verbs_olpc[] = {
2630 /* Port A: headphones */
2631 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2632 {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2634 /* Port B: external microphone */
2635 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2637 /* Port C: internal microphone */
2638 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2640 /* Port D: unused */
2641 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2643 /* Port E: unused, but has primary EAPD */
2644 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2645 {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
2647 /* Port F: external DC input through microphone port */
2648 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2650 /* Port G: internal speakers */
2651 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2652 {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2655 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2658 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2660 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50},
2661 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2662 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2663 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2664 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2665 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2666 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2667 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2668 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2669 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2670 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2671 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2673 /* Disable digital microphone port */
2674 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2676 /* Audio input selectors */
2677 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3},
2678 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2681 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2682 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2684 /* enable unsolicited events for Port A and B */
2685 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
2686 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
2690 static const struct hda_verb cxt5066_init_verbs_vostro[] = {
2691 /* Port A: headphones */
2692 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2693 {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2695 /* Port B: external microphone */
2696 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2698 /* Port C: unused */
2699 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2701 /* Port D: unused */
2702 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2704 /* Port E: unused, but has primary EAPD */
2705 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2706 {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
2708 /* Port F: unused */
2709 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2711 /* Port G: internal speakers */
2712 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2713 {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2716 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2719 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2721 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2722 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2723 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2724 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2725 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2726 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2727 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2728 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2729 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2730 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2731 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2732 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2734 /* Digital microphone port */
2735 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2737 /* Audio input selectors */
2738 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3},
2739 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2742 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2743 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2745 /* enable unsolicited events for Port A and B */
2746 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
2747 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
2751 static const struct hda_verb cxt5066_init_verbs_ideapad[] = {
2752 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */
2753 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */
2754 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */
2755 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */
2758 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2759 {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2762 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2763 {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2765 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2766 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2769 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2771 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2772 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50},
2773 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2774 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50},
2775 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2776 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2777 {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */
2779 /* Audio input selector */
2780 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2},
2781 {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */
2783 /* SPDIF route: PCM */
2784 {0x20, AC_VERB_SET_CONNECT_SEL, 0x0},
2785 {0x22, AC_VERB_SET_CONNECT_SEL, 0x0},
2787 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2788 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2790 /* internal microphone */
2791 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */
2794 {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
2796 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
2797 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
2801 static const struct hda_verb cxt5066_init_verbs_thinkpad[] = {
2802 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */
2803 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */
2805 /* Port G: internal speakers */
2806 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2807 {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2809 /* Port A: HP, Amp */
2810 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2811 {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2813 /* Port B: Mic Dock */
2814 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2817 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2819 /* Port D: HP Dock, Amp */
2820 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2821 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2824 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2826 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2827 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50},
2828 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2829 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50},
2830 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2831 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2832 {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */
2834 /* Audio input selector */
2835 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2},
2836 {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */
2838 /* SPDIF route: PCM */
2839 {0x20, AC_VERB_SET_CONNECT_SEL, 0x0},
2840 {0x22, AC_VERB_SET_CONNECT_SEL, 0x0},
2842 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2843 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2845 /* internal microphone */
2846 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */
2849 {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
2851 /* enable unsolicited events for Port A, B, C and D */
2852 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
2853 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
2854 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
2855 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
2859 static const struct hda_verb cxt5066_init_verbs_portd_lo[] = {
2860 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2865 static const struct hda_verb cxt5066_init_verbs_hp_laptop[] = {
2866 {0x14, AC_VERB_SET_CONNECT_SEL, 0x0},
2867 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
2868 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
2872 /* initialize jack-sensing, too */
2873 static int cxt5066_init(struct hda_codec *codec)
2875 snd_printdd("CXT5066: init\n");
2876 conexant_init(codec);
2877 if (codec->patch_ops.unsol_event) {
2878 cxt5066_hp_automute(codec);
2879 cxt5066_automic(codec);
2881 cxt5066_set_mic_boost(codec);
2885 static int cxt5066_olpc_init(struct hda_codec *codec)
2887 struct conexant_spec *spec = codec->spec;
2888 snd_printdd("CXT5066: init\n");
2889 conexant_init(codec);
2890 cxt5066_hp_automute(codec);
2891 if (!spec->dc_enable) {
2892 cxt5066_set_mic_boost(codec);
2893 cxt5066_olpc_automic(codec);
2895 cxt5066_enable_dc(codec);
2901 CXT5066_LAPTOP, /* Laptops w/ EAPD support */
2902 CXT5066_DELL_LAPTOP, /* Dell Laptop */
2903 CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */
2904 CXT5066_DELL_VOSTRO, /* Dell Vostro 1015i */
2905 CXT5066_IDEAPAD, /* Lenovo IdeaPad U150 */
2906 CXT5066_THINKPAD, /* Lenovo ThinkPad T410s, others? */
2907 CXT5066_ASUS, /* Asus K52JU, Lenovo G560 - Int mic at 0x1a and Ext mic at 0x1b */
2908 CXT5066_HP_LAPTOP, /* HP Laptop */
2909 CXT5066_AUTO, /* BIOS auto-parser */
2913 static const char * const cxt5066_models[CXT5066_MODELS] = {
2914 [CXT5066_LAPTOP] = "laptop",
2915 [CXT5066_DELL_LAPTOP] = "dell-laptop",
2916 [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5",
2917 [CXT5066_DELL_VOSTRO] = "dell-vostro",
2918 [CXT5066_IDEAPAD] = "ideapad",
2919 [CXT5066_THINKPAD] = "thinkpad",
2920 [CXT5066_ASUS] = "asus",
2921 [CXT5066_HP_LAPTOP] = "hp-laptop",
2922 [CXT5066_AUTO] = "auto",
2925 static const struct snd_pci_quirk cxt5066_cfg_tbl[] = {
2926 SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD),
2927 SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO),
2928 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD),
2929 SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO),
2930 SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD),
2931 SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD),
2932 SND_PCI_QUIRK(0x1028, 0x0510, "Dell Vostro", CXT5066_IDEAPAD),
2933 SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP),
2934 SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS),
2935 SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS),
2936 SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS),
2937 SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD),
2938 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5),
2939 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
2941 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5),
2942 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD),
2943 SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD),
2944 SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS),
2945 SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT5066_THINKPAD),
2946 SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT5066_THINKPAD),
2947 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo U350", CXT5066_ASUS),
2948 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS),
2952 static int patch_cxt5066(struct hda_codec *codec)
2954 struct conexant_spec *spec;
2957 board_config = snd_hda_check_board_config(codec, CXT5066_MODELS,
2958 cxt5066_models, cxt5066_cfg_tbl);
2959 if (board_config < 0)
2960 board_config = CXT5066_AUTO; /* model=auto as default */
2961 if (board_config == CXT5066_AUTO)
2962 return patch_conexant_auto(codec);
2964 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2969 codec->patch_ops = conexant_patch_ops;
2970 codec->patch_ops.init = conexant_init;
2972 spec->dell_automute = 0;
2973 spec->multiout.max_channels = 2;
2974 spec->multiout.num_dacs = ARRAY_SIZE(cxt5066_dac_nids);
2975 spec->multiout.dac_nids = cxt5066_dac_nids;
2976 conexant_check_dig_outs(codec, cxt5066_digout_pin_nids,
2977 ARRAY_SIZE(cxt5066_digout_pin_nids));
2978 spec->num_adc_nids = 1;
2979 spec->adc_nids = cxt5066_adc_nids;
2980 spec->capsrc_nids = cxt5066_capsrc_nids;
2981 spec->input_mux = &cxt5066_capture_source;
2983 spec->port_d_mode = PIN_HP;
2985 spec->num_init_verbs = 1;
2986 spec->init_verbs[0] = cxt5066_init_verbs;
2987 spec->num_channel_mode = ARRAY_SIZE(cxt5066_modes);
2988 spec->channel_mode = cxt5066_modes;
2990 spec->cur_adc_idx = 0;
2992 set_beep_amp(spec, 0x13, 0, HDA_OUTPUT);
2994 switch (board_config) {
2996 case CXT5066_LAPTOP:
2997 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master;
2998 spec->mixers[spec->num_mixers++] = cxt5066_mixers;
3000 case CXT5066_DELL_LAPTOP:
3001 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master;
3002 spec->mixers[spec->num_mixers++] = cxt5066_mixers;
3004 spec->port_d_mode = PIN_OUT;
3005 spec->init_verbs[spec->num_init_verbs] = cxt5066_init_verbs_portd_lo;
3006 spec->num_init_verbs++;
3007 spec->dell_automute = 1;
3010 case CXT5066_HP_LAPTOP:
3011 codec->patch_ops.init = cxt5066_init;
3012 codec->patch_ops.unsol_event = cxt5066_unsol_event;
3013 spec->init_verbs[spec->num_init_verbs] =
3014 cxt5066_init_verbs_hp_laptop;
3015 spec->num_init_verbs++;
3016 spec->hp_laptop = board_config == CXT5066_HP_LAPTOP;
3017 spec->asus = board_config == CXT5066_ASUS;
3018 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master;
3019 spec->mixers[spec->num_mixers++] = cxt5066_mixers;
3021 if (board_config == CXT5066_HP_LAPTOP)
3022 spec->multiout.dig_out_nid = 0;
3023 /* input source automatically selected */
3024 spec->input_mux = NULL;
3025 spec->port_d_mode = 0;
3026 spec->mic_boost = 3; /* default 30dB gain */
3029 case CXT5066_OLPC_XO_1_5:
3030 codec->patch_ops.init = cxt5066_olpc_init;
3031 codec->patch_ops.unsol_event = cxt5066_olpc_unsol_event;
3032 spec->init_verbs[0] = cxt5066_init_verbs_olpc;
3033 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc;
3034 spec->mixers[spec->num_mixers++] = cxt5066_mixer_olpc_dc;
3035 spec->mixers[spec->num_mixers++] = cxt5066_mixers;
3036 spec->port_d_mode = 0;
3037 spec->mic_boost = 3; /* default 30dB gain */
3040 spec->multiout.dig_out_nid = 0;
3042 /* input source automatically selected */
3043 spec->input_mux = NULL;
3045 /* our capture hooks which allow us to turn on the microphone LED
3046 * at the right time */
3047 spec->capture_prepare = cxt5066_olpc_capture_prepare;
3048 spec->capture_cleanup = cxt5066_olpc_capture_cleanup;
3050 case CXT5066_DELL_VOSTRO:
3051 codec->patch_ops.init = cxt5066_init;
3052 codec->patch_ops.unsol_event = cxt5066_unsol_event;
3053 spec->init_verbs[0] = cxt5066_init_verbs_vostro;
3054 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc;
3055 spec->mixers[spec->num_mixers++] = cxt5066_mixers;
3056 spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers;
3057 spec->port_d_mode = 0;
3058 spec->dell_vostro = 1;
3059 spec->mic_boost = 3; /* default 30dB gain */
3062 spec->multiout.dig_out_nid = 0;
3064 /* input source automatically selected */
3065 spec->input_mux = NULL;
3067 case CXT5066_IDEAPAD:
3068 codec->patch_ops.init = cxt5066_init;
3069 codec->patch_ops.unsol_event = cxt5066_unsol_event;
3070 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master;
3071 spec->mixers[spec->num_mixers++] = cxt5066_mixers;
3072 spec->init_verbs[0] = cxt5066_init_verbs_ideapad;
3073 spec->port_d_mode = 0;
3075 spec->mic_boost = 2; /* default 20dB gain */
3078 spec->multiout.dig_out_nid = 0;
3080 /* input source automatically selected */
3081 spec->input_mux = NULL;
3083 case CXT5066_THINKPAD:
3084 codec->patch_ops.init = cxt5066_init;
3085 codec->patch_ops.unsol_event = cxt5066_unsol_event;
3086 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master;
3087 spec->mixers[spec->num_mixers++] = cxt5066_mixers;
3088 spec->init_verbs[0] = cxt5066_init_verbs_thinkpad;
3090 spec->port_d_mode = PIN_OUT;
3091 spec->mic_boost = 2; /* default 20dB gain */
3094 spec->multiout.dig_out_nid = 0;
3096 /* input source automatically selected */
3097 spec->input_mux = NULL;
3102 snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp));
3107 #endif /* ENABLE_CXT_STATIC_QUIRKS */
3111 * Automatic parser for CX20641 & co
3114 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3115 static void cx_auto_parse_beep(struct hda_codec *codec)
3117 struct conexant_spec *spec = codec->spec;
3118 hda_nid_t nid, end_nid;
3120 end_nid = codec->start_nid + codec->num_nodes;
3121 for (nid = codec->start_nid; nid < end_nid; nid++)
3122 if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) {
3123 set_beep_amp(spec, nid, 0, HDA_OUTPUT);
3128 #define cx_auto_parse_beep(codec)
3132 static void cx_auto_parse_eapd(struct hda_codec *codec)
3134 struct conexant_spec *spec = codec->spec;
3135 hda_nid_t nid, end_nid;
3137 end_nid = codec->start_nid + codec->num_nodes;
3138 for (nid = codec->start_nid; nid < end_nid; nid++) {
3139 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3141 if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD))
3143 spec->eapds[spec->num_eapds++] = nid;
3144 if (spec->num_eapds >= ARRAY_SIZE(spec->eapds))
3148 /* NOTE: below is a wild guess; if we have more than two EAPDs,
3149 * it's a new chip, where EAPDs are supposed to be associated to
3150 * pins, and we can control EAPD per pin.
3151 * OTOH, if only one or two EAPDs are found, it's an old chip,
3152 * thus it might control over all pins.
3154 if (spec->num_eapds > 2)
3155 spec->gen.own_eapd_ctl = 1;
3158 static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins,
3159 hda_nid_t *pins, bool on)
3162 for (i = 0; i < num_pins; i++) {
3163 if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD)
3164 snd_hda_codec_write(codec, pins[i], 0,
3165 AC_VERB_SET_EAPD_BTLENABLE,
3170 /* turn on/off EAPD according to Master switch */
3171 static void cx_auto_vmaster_hook(void *private_data, int enabled)
3173 struct hda_codec *codec = private_data;
3174 struct conexant_spec *spec = codec->spec;
3176 cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, enabled);
3179 static int cx_auto_build_controls(struct hda_codec *codec)
3183 err = snd_hda_gen_build_controls(codec);
3187 err = add_beep_ctls(codec);
3194 static void cx_auto_free(struct hda_codec *codec)
3196 snd_hda_detach_beep_device(codec);
3197 snd_hda_gen_free(codec);
3200 static const struct hda_codec_ops cx_auto_patch_ops = {
3201 .build_controls = cx_auto_build_controls,
3202 .build_pcms = snd_hda_gen_build_pcms,
3203 .init = snd_hda_gen_init,
3204 .free = cx_auto_free,
3205 .unsol_event = snd_hda_jack_unsol_event,
3207 .check_power_status = snd_hda_gen_check_power_status,
3215 CXT_PINCFG_LENOVO_X200,
3216 CXT_PINCFG_LENOVO_TP410,
3217 CXT_PINCFG_LEMOTE_A1004,
3218 CXT_PINCFG_LEMOTE_A1205,
3219 CXT_FIXUP_STEREO_DMIC,
3220 CXT_FIXUP_INC_MIC_BOOST,
3223 static void cxt_fixup_stereo_dmic(struct hda_codec *codec,
3224 const struct hda_fixup *fix, int action)
3226 struct conexant_spec *spec = codec->spec;
3227 spec->gen.inv_dmic_split = 1;
3230 static void cxt5066_increase_mic_boost(struct hda_codec *codec,
3231 const struct hda_fixup *fix, int action)
3233 if (action != HDA_FIXUP_ACT_PRE_PROBE)
3236 snd_hda_override_amp_caps(codec, 0x17, HDA_OUTPUT,
3237 (0x3 << AC_AMPCAP_OFFSET_SHIFT) |
3238 (0x4 << AC_AMPCAP_NUM_STEPS_SHIFT) |
3239 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3240 (0 << AC_AMPCAP_MUTE_SHIFT));
3243 /* ThinkPad X200 & co with cxt5051 */
3244 static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = {
3245 { 0x16, 0x042140ff }, /* HP (seq# overridden) */
3246 { 0x17, 0x21a11000 }, /* dock-mic */
3247 { 0x19, 0x2121103f }, /* dock-HP */
3248 { 0x1c, 0x21440100 }, /* dock SPDIF out */
3252 /* ThinkPad 410/420/510/520, X201 & co with cxt5066 */
3253 static const struct hda_pintbl cxt_pincfg_lenovo_tp410[] = {
3254 { 0x19, 0x042110ff }, /* HP (seq# overridden) */
3255 { 0x1a, 0x21a190f0 }, /* dock-mic */
3256 { 0x1c, 0x212140ff }, /* dock-HP */
3260 /* Lemote A1004/A1205 with cxt5066 */
3261 static const struct hda_pintbl cxt_pincfg_lemote[] = {
3262 { 0x1a, 0x90a10020 }, /* Internal mic */
3263 { 0x1b, 0x03a11020 }, /* External mic */
3264 { 0x1d, 0x400101f0 }, /* Not used */
3265 { 0x1e, 0x40a701f0 }, /* Not used */
3266 { 0x20, 0x404501f0 }, /* Not used */
3267 { 0x22, 0x404401f0 }, /* Not used */
3268 { 0x23, 0x40a701f0 }, /* Not used */
3272 static const struct hda_fixup cxt_fixups[] = {
3273 [CXT_PINCFG_LENOVO_X200] = {
3274 .type = HDA_FIXUP_PINS,
3275 .v.pins = cxt_pincfg_lenovo_x200,
3277 [CXT_PINCFG_LENOVO_TP410] = {
3278 .type = HDA_FIXUP_PINS,
3279 .v.pins = cxt_pincfg_lenovo_tp410,
3281 [CXT_PINCFG_LEMOTE_A1004] = {
3282 .type = HDA_FIXUP_PINS,
3284 .chain_id = CXT_FIXUP_INC_MIC_BOOST,
3285 .v.pins = cxt_pincfg_lemote,
3287 [CXT_PINCFG_LEMOTE_A1205] = {
3288 .type = HDA_FIXUP_PINS,
3289 .v.pins = cxt_pincfg_lemote,
3291 [CXT_FIXUP_STEREO_DMIC] = {
3292 .type = HDA_FIXUP_FUNC,
3293 .v.func = cxt_fixup_stereo_dmic,
3295 [CXT_FIXUP_INC_MIC_BOOST] = {
3296 .type = HDA_FIXUP_FUNC,
3297 .v.func = cxt5066_increase_mic_boost,
3301 static const struct snd_pci_quirk cxt5051_fixups[] = {
3302 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200),
3306 static const struct snd_pci_quirk cxt5066_fixups[] = {
3307 SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC),
3308 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410),
3309 SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410),
3310 SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410),
3311 SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410),
3312 SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410),
3313 SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC),
3314 SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC),
3315 SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC),
3316 SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004),
3317 SND_PCI_QUIRK(0x1c06, 0x2012, "Lemote A1205", CXT_PINCFG_LEMOTE_A1205),
3321 /* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches
3322 * can be created (bko#42825)
3324 static void add_cx5051_fake_mutes(struct hda_codec *codec)
3326 static hda_nid_t out_nids[] = {
3331 for (p = out_nids; *p; p++)
3332 snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT,
3333 AC_AMPCAP_MIN_MUTE |
3334 query_amp_caps(codec, *p, HDA_OUTPUT));
3337 static int patch_conexant_auto(struct hda_codec *codec)
3339 struct conexant_spec *spec;
3342 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
3345 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3348 snd_hda_gen_spec_init(&spec->gen);
3351 cx_auto_parse_beep(codec);
3352 cx_auto_parse_eapd(codec);
3353 if (spec->gen.own_eapd_ctl)
3354 spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook;
3356 switch (codec->vendor_id) {
3358 codec->single_adc_amp = 1;
3359 codec->power_filter = NULL; /* Needs speaker amp to D3 to avoid click */
3362 codec->pin_amp_workaround = 1;
3363 spec->gen.mixer_nid = 0x19;
3366 add_cx5051_fake_mutes(codec);
3367 codec->pin_amp_workaround = 1;
3368 snd_hda_pick_fixup(codec, NULL, cxt5051_fixups, cxt_fixups);
3371 codec->pin_amp_workaround = 1;
3372 snd_hda_pick_fixup(codec, NULL, cxt5066_fixups, cxt_fixups);
3376 /* Show mute-led control only on HP laptops
3377 * This is a sort of white-list: on HP laptops, EAPD corresponds
3378 * only to the mute-LED without actualy amp function. Meanwhile,
3379 * others may use EAPD really as an amp switch, so it might be
3380 * not good to expose it blindly.
3382 switch (codec->subsystem_id >> 16) {
3384 spec->gen.vmaster_mute_enum = 1;
3388 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3390 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0);
3394 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
3398 codec->patch_ops = cx_auto_patch_ops;
3400 snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp));
3402 /* Some laptops with Conexant chips show stalls in S3 resume,
3403 * which falls into the single-cmd mode.
3404 * Better to make reset, then.
3406 if (!codec->bus->sync_write) {
3407 snd_printd("hda_codec: "
3408 "Enable sync_write for stable communication\n");
3409 codec->bus->sync_write = 1;
3410 codec->bus->allow_bus_reset = 1;
3416 snd_hda_gen_free(codec);
3420 #ifndef ENABLE_CXT_STATIC_QUIRKS
3421 #define patch_cxt5045 patch_conexant_auto
3422 #define patch_cxt5047 patch_conexant_auto
3423 #define patch_cxt5051 patch_conexant_auto
3424 #define patch_cxt5066 patch_conexant_auto
3430 static const struct hda_codec_preset snd_hda_preset_conexant[] = {
3431 { .id = 0x14f15045, .name = "CX20549 (Venice)",
3432 .patch = patch_cxt5045 },
3433 { .id = 0x14f15047, .name = "CX20551 (Waikiki)",
3434 .patch = patch_cxt5047 },
3435 { .id = 0x14f15051, .name = "CX20561 (Hermosa)",
3436 .patch = patch_cxt5051 },
3437 { .id = 0x14f15066, .name = "CX20582 (Pebble)",
3438 .patch = patch_cxt5066 },
3439 { .id = 0x14f15067, .name = "CX20583 (Pebble HSF)",
3440 .patch = patch_cxt5066 },
3441 { .id = 0x14f15068, .name = "CX20584",
3442 .patch = patch_cxt5066 },
3443 { .id = 0x14f15069, .name = "CX20585",
3444 .patch = patch_cxt5066 },
3445 { .id = 0x14f1506c, .name = "CX20588",
3446 .patch = patch_cxt5066 },
3447 { .id = 0x14f1506e, .name = "CX20590",
3448 .patch = patch_cxt5066 },
3449 { .id = 0x14f15097, .name = "CX20631",
3450 .patch = patch_conexant_auto },
3451 { .id = 0x14f15098, .name = "CX20632",
3452 .patch = patch_conexant_auto },
3453 { .id = 0x14f150a1, .name = "CX20641",
3454 .patch = patch_conexant_auto },
3455 { .id = 0x14f150a2, .name = "CX20642",
3456 .patch = patch_conexant_auto },
3457 { .id = 0x14f150ab, .name = "CX20651",
3458 .patch = patch_conexant_auto },
3459 { .id = 0x14f150ac, .name = "CX20652",
3460 .patch = patch_conexant_auto },
3461 { .id = 0x14f150b8, .name = "CX20664",
3462 .patch = patch_conexant_auto },
3463 { .id = 0x14f150b9, .name = "CX20665",
3464 .patch = patch_conexant_auto },
3465 { .id = 0x14f1510f, .name = "CX20751/2",
3466 .patch = patch_conexant_auto },
3467 { .id = 0x14f15110, .name = "CX20751/2",
3468 .patch = patch_conexant_auto },
3469 { .id = 0x14f15111, .name = "CX20753/4",
3470 .patch = patch_conexant_auto },
3471 { .id = 0x14f15113, .name = "CX20755",
3472 .patch = patch_conexant_auto },
3473 { .id = 0x14f15114, .name = "CX20756",
3474 .patch = patch_conexant_auto },
3475 { .id = 0x14f15115, .name = "CX20757",
3476 .patch = patch_conexant_auto },
3480 MODULE_ALIAS("snd-hda-codec-id:14f15045");
3481 MODULE_ALIAS("snd-hda-codec-id:14f15047");
3482 MODULE_ALIAS("snd-hda-codec-id:14f15051");
3483 MODULE_ALIAS("snd-hda-codec-id:14f15066");
3484 MODULE_ALIAS("snd-hda-codec-id:14f15067");
3485 MODULE_ALIAS("snd-hda-codec-id:14f15068");
3486 MODULE_ALIAS("snd-hda-codec-id:14f15069");
3487 MODULE_ALIAS("snd-hda-codec-id:14f1506c");
3488 MODULE_ALIAS("snd-hda-codec-id:14f1506e");
3489 MODULE_ALIAS("snd-hda-codec-id:14f15097");
3490 MODULE_ALIAS("snd-hda-codec-id:14f15098");
3491 MODULE_ALIAS("snd-hda-codec-id:14f150a1");
3492 MODULE_ALIAS("snd-hda-codec-id:14f150a2");
3493 MODULE_ALIAS("snd-hda-codec-id:14f150ab");
3494 MODULE_ALIAS("snd-hda-codec-id:14f150ac");
3495 MODULE_ALIAS("snd-hda-codec-id:14f150b8");
3496 MODULE_ALIAS("snd-hda-codec-id:14f150b9");
3497 MODULE_ALIAS("snd-hda-codec-id:14f1510f");
3498 MODULE_ALIAS("snd-hda-codec-id:14f15110");
3499 MODULE_ALIAS("snd-hda-codec-id:14f15111");
3500 MODULE_ALIAS("snd-hda-codec-id:14f15113");
3501 MODULE_ALIAS("snd-hda-codec-id:14f15114");
3502 MODULE_ALIAS("snd-hda-codec-id:14f15115");
3504 MODULE_LICENSE("GPL");
3505 MODULE_DESCRIPTION("Conexant HD-audio codec");
3507 static struct hda_codec_preset_list conexant_list = {
3508 .preset = snd_hda_preset_conexant,
3509 .owner = THIS_MODULE,
3512 static int __init patch_conexant_init(void)
3514 return snd_hda_add_codec_preset(&conexant_list);
3517 static void __exit patch_conexant_exit(void)
3519 snd_hda_delete_codec_preset(&conexant_list);
3522 module_init(patch_conexant_init)
3523 module_exit(patch_conexant_exit)