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 <sound/core.h>
28 #include <sound/jack.h>
30 #include "hda_codec.h"
31 #include "hda_local.h"
33 #define CXT_PIN_DIR_IN 0x00
34 #define CXT_PIN_DIR_OUT 0x01
35 #define CXT_PIN_DIR_INOUT 0x02
36 #define CXT_PIN_DIR_IN_NOMICBIAS 0x03
37 #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04
39 #define CONEXANT_HP_EVENT 0x37
40 #define CONEXANT_MIC_EVENT 0x38
42 /* Conexant 5051 specific */
44 #define CXT5051_SPDIF_OUT 0x1C
45 #define CXT5051_PORTB_EVENT 0x38
46 #define CXT5051_PORTC_EVENT 0x39
49 struct conexant_jack {
53 struct snd_jack *jack;
57 struct conexant_spec {
59 struct snd_kcontrol_new *mixers[5];
61 hda_nid_t vmaster_nid;
63 const struct hda_verb *init_verbs[5]; /* initialization verbs
67 unsigned int num_init_verbs;
70 struct hda_multi_out multiout; /* playback set-up
71 * max_channels, dacs must be set
72 * dig_out_nid and hp_nid are optional
74 unsigned int cur_eapd;
75 unsigned int hp_present;
76 unsigned int no_auto_mic;
77 unsigned int need_dac_fix;
80 unsigned int num_adc_nids;
82 hda_nid_t dig_in_nid; /* digital-in NID; optional */
84 unsigned int cur_adc_idx;
86 unsigned int cur_adc_stream_tag;
87 unsigned int cur_adc_format;
90 const struct hda_input_mux *input_mux;
91 hda_nid_t *capsrc_nids;
92 unsigned int cur_mux[3];
95 const struct hda_channel_mode *channel_mode;
99 struct hda_pcm pcm_rec[2]; /* used in build_pcms() */
101 unsigned int spdif_route;
104 struct snd_array jacks;
106 /* dynamic controls, init_verbs and input_mux */
107 struct auto_pin_cfg autocfg;
108 struct hda_input_mux private_imux;
109 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
113 static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo,
114 struct hda_codec *codec,
115 struct snd_pcm_substream *substream)
117 struct conexant_spec *spec = codec->spec;
118 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
122 static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
123 struct hda_codec *codec,
124 unsigned int stream_tag,
126 struct snd_pcm_substream *substream)
128 struct conexant_spec *spec = codec->spec;
129 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
134 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
135 struct hda_codec *codec,
136 struct snd_pcm_substream *substream)
138 struct conexant_spec *spec = codec->spec;
139 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
145 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
146 struct hda_codec *codec,
147 struct snd_pcm_substream *substream)
149 struct conexant_spec *spec = codec->spec;
150 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
153 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
154 struct hda_codec *codec,
155 struct snd_pcm_substream *substream)
157 struct conexant_spec *spec = codec->spec;
158 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
161 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
162 struct hda_codec *codec,
163 unsigned int stream_tag,
165 struct snd_pcm_substream *substream)
167 struct conexant_spec *spec = codec->spec;
168 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
176 static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
177 struct hda_codec *codec,
178 unsigned int stream_tag,
180 struct snd_pcm_substream *substream)
182 struct conexant_spec *spec = codec->spec;
183 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
184 stream_tag, 0, format);
188 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
189 struct hda_codec *codec,
190 struct snd_pcm_substream *substream)
192 struct conexant_spec *spec = codec->spec;
193 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
199 static struct hda_pcm_stream conexant_pcm_analog_playback = {
203 .nid = 0, /* fill later */
205 .open = conexant_playback_pcm_open,
206 .prepare = conexant_playback_pcm_prepare,
207 .cleanup = conexant_playback_pcm_cleanup
211 static struct hda_pcm_stream conexant_pcm_analog_capture = {
215 .nid = 0, /* fill later */
217 .prepare = conexant_capture_pcm_prepare,
218 .cleanup = conexant_capture_pcm_cleanup
223 static struct hda_pcm_stream conexant_pcm_digital_playback = {
227 .nid = 0, /* fill later */
229 .open = conexant_dig_playback_pcm_open,
230 .close = conexant_dig_playback_pcm_close,
231 .prepare = conexant_dig_playback_pcm_prepare
235 static struct hda_pcm_stream conexant_pcm_digital_capture = {
239 /* NID is set in alc_build_pcms */
242 static int cx5051_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 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
250 spec->cur_adc_stream_tag = stream_tag;
251 spec->cur_adc_format = format;
252 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
256 static int cx5051_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->cur_adc);
266 static struct hda_pcm_stream cx5051_pcm_analog_capture = {
270 .nid = 0, /* fill later */
272 .prepare = cx5051_capture_pcm_prepare,
273 .cleanup = cx5051_capture_pcm_cleanup
277 static int conexant_build_pcms(struct hda_codec *codec)
279 struct conexant_spec *spec = codec->spec;
280 struct hda_pcm *info = spec->pcm_rec;
283 codec->pcm_info = info;
285 info->name = "CONEXANT Analog";
286 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback;
287 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max =
288 spec->multiout.max_channels;
289 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
290 spec->multiout.dac_nids[0];
291 if (codec->vendor_id == 0x14f15051)
292 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
293 cx5051_pcm_analog_capture;
295 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
296 conexant_pcm_analog_capture;
297 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
298 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
300 if (spec->multiout.dig_out_nid) {
303 info->name = "Conexant Digital";
304 info->pcm_type = HDA_PCM_TYPE_SPDIF;
305 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
306 conexant_pcm_digital_playback;
307 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
308 spec->multiout.dig_out_nid;
309 if (spec->dig_in_nid) {
310 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
311 conexant_pcm_digital_capture;
312 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
320 static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol,
321 struct snd_ctl_elem_info *uinfo)
323 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
324 struct conexant_spec *spec = codec->spec;
326 return snd_hda_input_mux_info(spec->input_mux, uinfo);
329 static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol,
330 struct snd_ctl_elem_value *ucontrol)
332 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
333 struct conexant_spec *spec = codec->spec;
334 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
336 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
340 static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol,
341 struct snd_ctl_elem_value *ucontrol)
343 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
344 struct conexant_spec *spec = codec->spec;
345 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
347 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
348 spec->capsrc_nids[adc_idx],
349 &spec->cur_mux[adc_idx]);
352 #ifdef CONFIG_SND_JACK
353 static void conexant_free_jack_priv(struct snd_jack *jack)
355 struct conexant_jack *jacks = jack->private_data;
360 static int conexant_add_jack(struct hda_codec *codec,
361 hda_nid_t nid, int type)
363 struct conexant_spec *spec;
364 struct conexant_jack *jack;
369 snd_array_init(&spec->jacks, sizeof(*jack), 32);
370 jack = snd_array_new(&spec->jacks);
371 name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
379 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
382 jack->jack->private_data = jack;
383 jack->jack->private_free = conexant_free_jack_priv;
387 static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid)
389 struct conexant_spec *spec = codec->spec;
390 struct conexant_jack *jacks = spec->jacks.list;
394 for (i = 0; i < spec->jacks.used; i++) {
395 if (jacks->nid == nid) {
396 unsigned int present;
397 present = snd_hda_codec_read(codec, nid, 0,
398 AC_VERB_GET_PIN_SENSE, 0) &
399 AC_PINSENSE_PRESENCE;
401 present = (present) ? jacks->type : 0 ;
403 snd_jack_report(jacks->jack,
411 static int conexant_init_jacks(struct hda_codec *codec)
413 struct conexant_spec *spec = codec->spec;
416 for (i = 0; i < spec->num_init_verbs; i++) {
417 const struct hda_verb *hv;
419 hv = spec->init_verbs[i];
422 switch (hv->param ^ AC_USRSP_EN) {
423 case CONEXANT_HP_EVENT:
424 err = conexant_add_jack(codec, hv->nid,
426 conexant_report_jack(codec, hv->nid);
428 case CXT5051_PORTC_EVENT:
429 case CONEXANT_MIC_EVENT:
430 err = conexant_add_jack(codec, hv->nid,
431 SND_JACK_MICROPHONE);
432 conexant_report_jack(codec, hv->nid);
444 static inline void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid)
448 static inline int conexant_init_jacks(struct hda_codec *codec)
454 static int conexant_init(struct hda_codec *codec)
456 struct conexant_spec *spec = codec->spec;
459 for (i = 0; i < spec->num_init_verbs; i++)
460 snd_hda_sequence_write(codec, spec->init_verbs[i]);
464 static void conexant_free(struct hda_codec *codec)
466 #ifdef CONFIG_SND_JACK
467 struct conexant_spec *spec = codec->spec;
468 if (spec->jacks.list) {
469 struct conexant_jack *jacks = spec->jacks.list;
471 for (i = 0; i < spec->jacks.used; i++, jacks++) {
473 snd_device_free(codec->bus->card, jacks->jack);
475 snd_array_free(&spec->jacks);
481 static struct snd_kcontrol_new cxt_capture_mixers[] = {
483 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
484 .name = "Capture Source",
485 .info = conexant_mux_enum_info,
486 .get = conexant_mux_enum_get,
487 .put = conexant_mux_enum_put
492 static const char *slave_vols[] = {
493 "Headphone Playback Volume",
494 "Speaker Playback Volume",
498 static const char *slave_sws[] = {
499 "Headphone Playback Switch",
500 "Speaker Playback Switch",
504 static int conexant_build_controls(struct hda_codec *codec)
506 struct conexant_spec *spec = codec->spec;
510 for (i = 0; i < spec->num_mixers; i++) {
511 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
515 if (spec->multiout.dig_out_nid) {
516 err = snd_hda_create_spdif_out_ctls(codec,
517 spec->multiout.dig_out_nid);
520 err = snd_hda_create_spdif_share_sw(codec,
524 spec->multiout.share_spdif = 1;
526 if (spec->dig_in_nid) {
527 err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid);
532 /* if we have no master control, let's create it */
533 if (spec->vmaster_nid &&
534 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
535 unsigned int vmaster_tlv[4];
536 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
537 HDA_OUTPUT, vmaster_tlv);
538 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
539 vmaster_tlv, slave_vols);
543 if (spec->vmaster_nid &&
544 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
545 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
551 if (spec->input_mux) {
552 err = snd_hda_add_new_ctls(codec, cxt_capture_mixers);
560 static struct hda_codec_ops conexant_patch_ops = {
561 .build_controls = conexant_build_controls,
562 .build_pcms = conexant_build_pcms,
563 .init = conexant_init,
564 .free = conexant_free,
569 * the private value = nid | (invert << 8)
572 #define cxt_eapd_info snd_ctl_boolean_mono_info
574 static int cxt_eapd_get(struct snd_kcontrol *kcontrol,
575 struct snd_ctl_elem_value *ucontrol)
577 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
578 struct conexant_spec *spec = codec->spec;
579 int invert = (kcontrol->private_value >> 8) & 1;
581 ucontrol->value.integer.value[0] = !spec->cur_eapd;
583 ucontrol->value.integer.value[0] = spec->cur_eapd;
588 static int cxt_eapd_put(struct snd_kcontrol *kcontrol,
589 struct snd_ctl_elem_value *ucontrol)
591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
592 struct conexant_spec *spec = codec->spec;
593 int invert = (kcontrol->private_value >> 8) & 1;
594 hda_nid_t nid = kcontrol->private_value & 0xff;
597 eapd = !!ucontrol->value.integer.value[0];
600 if (eapd == spec->cur_eapd)
603 spec->cur_eapd = eapd;
604 snd_hda_codec_write_cache(codec, nid,
605 0, AC_VERB_SET_EAPD_BTLENABLE,
610 /* controls for test mode */
611 #ifdef CONFIG_SND_DEBUG
613 #define CXT_EAPD_SWITCH(xname, nid, mask) \
614 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
615 .info = cxt_eapd_info, \
616 .get = cxt_eapd_get, \
617 .put = cxt_eapd_put, \
618 .private_value = nid | (mask<<16) }
622 static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol,
623 struct snd_ctl_elem_info *uinfo)
625 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
626 struct conexant_spec *spec = codec->spec;
627 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
628 spec->num_channel_mode);
631 static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol,
632 struct snd_ctl_elem_value *ucontrol)
634 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
635 struct conexant_spec *spec = codec->spec;
636 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
637 spec->num_channel_mode,
638 spec->multiout.max_channels);
641 static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol,
642 struct snd_ctl_elem_value *ucontrol)
644 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
645 struct conexant_spec *spec = codec->spec;
646 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
647 spec->num_channel_mode,
648 &spec->multiout.max_channels);
649 if (err >= 0 && spec->need_dac_fix)
650 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
654 #define CXT_PIN_MODE(xname, nid, dir) \
655 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
656 .info = conexant_ch_mode_info, \
657 .get = conexant_ch_mode_get, \
658 .put = conexant_ch_mode_put, \
659 .private_value = nid | (dir<<16) }
661 #endif /* CONFIG_SND_DEBUG */
663 /* Conexant 5045 specific */
665 static hda_nid_t cxt5045_dac_nids[1] = { 0x19 };
666 static hda_nid_t cxt5045_adc_nids[1] = { 0x1a };
667 static hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a };
668 #define CXT5045_SPDIF_OUT 0x18
670 static struct hda_channel_mode cxt5045_modes[1] = {
674 static struct hda_input_mux cxt5045_capture_source = {
682 static struct hda_input_mux cxt5045_capture_source_benq = {
691 static struct hda_input_mux cxt5045_capture_source_hp530 = {
699 /* turn on/off EAPD (+ mute HP) as a master switch */
700 static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
701 struct snd_ctl_elem_value *ucontrol)
703 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
704 struct conexant_spec *spec = codec->spec;
707 if (!cxt_eapd_put(kcontrol, ucontrol))
710 /* toggle internal speakers mute depending of presence of
713 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
714 snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
717 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
718 snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0,
723 /* bind volumes of both NID 0x10 and 0x11 */
724 static struct hda_bind_ctls cxt5045_hp_bind_master_vol = {
725 .ops = &snd_hda_bind_vol,
727 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT),
728 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
733 /* toggle input of built-in and mic jack appropriately */
734 static void cxt5045_hp_automic(struct hda_codec *codec)
736 static struct hda_verb mic_jack_on[] = {
737 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
738 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
741 static struct hda_verb mic_jack_off[] = {
742 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
743 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
746 unsigned int present;
748 present = snd_hda_codec_read(codec, 0x12, 0,
749 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
751 snd_hda_sequence_write(codec, mic_jack_on);
753 snd_hda_sequence_write(codec, mic_jack_off);
757 /* mute internal speaker if HP is plugged */
758 static void cxt5045_hp_automute(struct hda_codec *codec)
760 struct conexant_spec *spec = codec->spec;
763 spec->hp_present = snd_hda_codec_read(codec, 0x11, 0,
764 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
766 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
767 snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
771 /* unsolicited event for HP jack sensing */
772 static void cxt5045_hp_unsol_event(struct hda_codec *codec,
777 case CONEXANT_HP_EVENT:
778 cxt5045_hp_automute(codec);
780 case CONEXANT_MIC_EVENT:
781 cxt5045_hp_automic(codec);
787 static struct snd_kcontrol_new cxt5045_mixers[] = {
788 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
789 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
790 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
791 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
792 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
793 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
794 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
795 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
796 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
797 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
798 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
800 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
801 .name = "Master Playback Switch",
802 .info = cxt_eapd_info,
804 .put = cxt5045_hp_master_sw_put,
805 .private_value = 0x10,
811 static struct snd_kcontrol_new cxt5045_benq_mixers[] = {
812 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT),
813 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT),
814 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT),
815 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT),
820 static struct snd_kcontrol_new cxt5045_mixers_hp530[] = {
821 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
822 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
823 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
824 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
825 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
826 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
827 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
828 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
829 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
830 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
831 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
833 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
834 .name = "Master Playback Switch",
835 .info = cxt_eapd_info,
837 .put = cxt5045_hp_master_sw_put,
838 .private_value = 0x10,
844 static struct hda_verb cxt5045_init_verbs[] = {
846 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
847 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
849 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
850 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
851 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
852 {0x11, AC_VERB_SET_CONNECT_SEL, 0x1},
853 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
854 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
855 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
856 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
857 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
858 /* Record selector: Int mic */
859 {0x1a, AC_VERB_SET_CONNECT_SEL,0x1},
860 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
861 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
862 /* SPDIF route: PCM */
863 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
864 { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
866 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */
870 static struct hda_verb cxt5045_benq_init_verbs[] = {
872 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
873 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
874 /* Line In,HP, Amp */
875 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
876 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
877 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
878 {0x11, AC_VERB_SET_CONNECT_SEL, 0x1},
879 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
880 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
881 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
882 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
883 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
884 /* Record selector: Int mic */
885 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x1},
886 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
887 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
888 /* SPDIF route: PCM */
889 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
890 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
892 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
896 static struct hda_verb cxt5045_hp_sense_init_verbs[] = {
897 /* pin sensing on HP jack */
898 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
902 static struct hda_verb cxt5045_mic_sense_init_verbs[] = {
903 /* pin sensing on HP jack */
904 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
908 #ifdef CONFIG_SND_DEBUG
909 /* Test configuration for debugging, modelled after the ALC260 test
912 static struct hda_input_mux cxt5045_test_capture_source = {
917 { "LINE1 pin", 0x2 },
918 { "HP-OUT pin", 0x3 },
923 static struct snd_kcontrol_new cxt5045_test_mixer[] = {
925 /* Output controls */
926 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
927 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
928 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT),
929 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT),
930 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT),
931 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT),
933 /* Modes for retasking pin widgets */
934 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
935 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT),
937 /* EAPD Switch Control */
938 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
940 /* Loopback mixer controls */
942 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT),
943 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT),
944 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT),
945 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT),
946 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT),
947 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT),
948 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT),
949 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT),
950 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT),
951 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT),
953 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
954 .name = "Input Source",
955 .info = conexant_mux_enum_info,
956 .get = conexant_mux_enum_get,
957 .put = conexant_mux_enum_put,
959 /* Audio input controls */
960 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),
961 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),
962 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
963 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
964 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
965 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
966 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
967 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
968 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
969 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
973 static struct hda_verb cxt5045_test_init_verbs[] = {
974 /* Set connections */
975 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
976 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 },
977 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 },
978 /* Enable retasking pins as output, initially without power amp */
979 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
980 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
982 /* Disable digital (SPDIF) pins initially, but users can enable
983 * them via a mixer switch. In the case of SPDIF-out, this initverb
984 * payload also sets the generation to 0, output to be in "consumer"
985 * PCM format, copyright asserted, no pre-emphasis and no validity
988 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
989 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
991 /* Start with output sum widgets muted and their output gains at min */
992 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
993 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
995 /* Unmute retasking pin widget output buffers since the default
996 * state appears to be output. As the pin mode is changed by the
997 * user the pin mode control will take care of enabling the pin's
998 * input/output buffers as needed.
1000 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1001 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1003 /* Mute capture amp left and right */
1004 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1006 /* Set ADC connection select to match default mixer setting (mic1
1009 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1010 {0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1012 /* Mute all inputs to mixer widget (even unconnected ones) */
1013 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */
1014 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */
1015 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */
1016 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */
1017 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
1024 /* initialize jack-sensing, too */
1025 static int cxt5045_init(struct hda_codec *codec)
1027 conexant_init(codec);
1028 cxt5045_hp_automute(codec);
1034 CXT5045_LAPTOP_HPSENSE,
1035 CXT5045_LAPTOP_MICSENSE,
1036 CXT5045_LAPTOP_HPMICSENSE,
1038 CXT5045_LAPTOP_HP530,
1039 #ifdef CONFIG_SND_DEBUG
1045 static const char *cxt5045_models[CXT5045_MODELS] = {
1046 [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense",
1047 [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense",
1048 [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense",
1049 [CXT5045_BENQ] = "benq",
1050 [CXT5045_LAPTOP_HP530] = "laptop-hp530",
1051 #ifdef CONFIG_SND_DEBUG
1052 [CXT5045_TEST] = "test",
1056 static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
1057 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530),
1058 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1059 CXT5045_LAPTOP_HPSENSE),
1060 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE),
1061 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ),
1062 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE),
1063 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE),
1064 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
1065 CXT5045_LAPTOP_HPMICSENSE),
1066 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE),
1067 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE),
1068 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE),
1069 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
1070 CXT5045_LAPTOP_HPMICSENSE),
1071 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE),
1075 static int patch_cxt5045(struct hda_codec *codec)
1077 struct conexant_spec *spec;
1080 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1084 codec->pin_amp_workaround = 1;
1086 spec->multiout.max_channels = 2;
1087 spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids);
1088 spec->multiout.dac_nids = cxt5045_dac_nids;
1089 spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT;
1090 spec->num_adc_nids = 1;
1091 spec->adc_nids = cxt5045_adc_nids;
1092 spec->capsrc_nids = cxt5045_capsrc_nids;
1093 spec->input_mux = &cxt5045_capture_source;
1094 spec->num_mixers = 1;
1095 spec->mixers[0] = cxt5045_mixers;
1096 spec->num_init_verbs = 1;
1097 spec->init_verbs[0] = cxt5045_init_verbs;
1098 spec->spdif_route = 0;
1099 spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes),
1100 spec->channel_mode = cxt5045_modes,
1103 codec->patch_ops = conexant_patch_ops;
1105 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
1108 switch (board_config) {
1109 case CXT5045_LAPTOP_HPSENSE:
1110 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
1111 spec->input_mux = &cxt5045_capture_source;
1112 spec->num_init_verbs = 2;
1113 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
1114 spec->mixers[0] = cxt5045_mixers;
1115 codec->patch_ops.init = cxt5045_init;
1117 case CXT5045_LAPTOP_MICSENSE:
1118 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
1119 spec->input_mux = &cxt5045_capture_source;
1120 spec->num_init_verbs = 2;
1121 spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;
1122 spec->mixers[0] = cxt5045_mixers;
1123 codec->patch_ops.init = cxt5045_init;
1126 case CXT5045_LAPTOP_HPMICSENSE:
1127 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
1128 spec->input_mux = &cxt5045_capture_source;
1129 spec->num_init_verbs = 3;
1130 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
1131 spec->init_verbs[2] = cxt5045_mic_sense_init_verbs;
1132 spec->mixers[0] = cxt5045_mixers;
1133 codec->patch_ops.init = cxt5045_init;
1136 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
1137 spec->input_mux = &cxt5045_capture_source_benq;
1138 spec->num_init_verbs = 1;
1139 spec->init_verbs[0] = cxt5045_benq_init_verbs;
1140 spec->mixers[0] = cxt5045_mixers;
1141 spec->mixers[1] = cxt5045_benq_mixers;
1142 spec->num_mixers = 2;
1143 codec->patch_ops.init = cxt5045_init;
1145 case CXT5045_LAPTOP_HP530:
1146 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
1147 spec->input_mux = &cxt5045_capture_source_hp530;
1148 spec->num_init_verbs = 2;
1149 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
1150 spec->mixers[0] = cxt5045_mixers_hp530;
1151 codec->patch_ops.init = cxt5045_init;
1153 #ifdef CONFIG_SND_DEBUG
1155 spec->input_mux = &cxt5045_test_capture_source;
1156 spec->mixers[0] = cxt5045_test_mixer;
1157 spec->init_verbs[0] = cxt5045_test_init_verbs;
1163 switch (codec->subsystem_id >> 16) {
1165 /* HP laptop has a really bad sound over 0dB on NID 0x17.
1166 * Fix max PCM level to 0 dB
1167 * (originall it has 0x2b steps with 0dB offset 0x14)
1169 snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT,
1170 (0x14 << AC_AMPCAP_OFFSET_SHIFT) |
1171 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) |
1172 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
1173 (1 << AC_AMPCAP_MUTE_SHIFT));
1181 /* Conexant 5047 specific */
1182 #define CXT5047_SPDIF_OUT 0x11
1184 static hda_nid_t cxt5047_dac_nids[1] = { 0x10 }; /* 0x1c */
1185 static hda_nid_t cxt5047_adc_nids[1] = { 0x12 };
1186 static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a };
1188 static struct hda_channel_mode cxt5047_modes[1] = {
1192 static struct hda_input_mux cxt5047_toshiba_capture_source = {
1200 /* turn on/off EAPD (+ mute HP) as a master switch */
1201 static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1202 struct snd_ctl_elem_value *ucontrol)
1204 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1205 struct conexant_spec *spec = codec->spec;
1208 if (!cxt_eapd_put(kcontrol, ucontrol))
1211 /* toggle internal speakers mute depending of presence of
1212 * the headphone jack
1214 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
1215 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1216 * pin widgets unlike other codecs. In this case, we need to
1217 * set index 0x01 for the volume from the mixer amp 0x19.
1219 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01,
1220 HDA_AMP_MUTE, bits);
1221 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
1222 snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0,
1223 HDA_AMP_MUTE, bits);
1227 /* mute internal speaker if HP is plugged */
1228 static void cxt5047_hp_automute(struct hda_codec *codec)
1230 struct conexant_spec *spec = codec->spec;
1233 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
1234 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1236 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
1237 /* See the note in cxt5047_hp_master_sw_put */
1238 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01,
1239 HDA_AMP_MUTE, bits);
1242 /* toggle input of built-in and mic jack appropriately */
1243 static void cxt5047_hp_automic(struct hda_codec *codec)
1245 static struct hda_verb mic_jack_on[] = {
1246 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1247 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1250 static struct hda_verb mic_jack_off[] = {
1251 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1252 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1255 unsigned int present;
1257 present = snd_hda_codec_read(codec, 0x15, 0,
1258 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1260 snd_hda_sequence_write(codec, mic_jack_on);
1262 snd_hda_sequence_write(codec, mic_jack_off);
1265 /* unsolicited event for HP jack sensing */
1266 static void cxt5047_hp_unsol_event(struct hda_codec *codec,
1269 switch (res >> 26) {
1270 case CONEXANT_HP_EVENT:
1271 cxt5047_hp_automute(codec);
1273 case CONEXANT_MIC_EVENT:
1274 cxt5047_hp_automic(codec);
1279 static struct snd_kcontrol_new cxt5047_base_mixers[] = {
1280 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT),
1281 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT),
1282 HDA_CODEC_VOLUME("Mic Boost", 0x1a, 0x0, HDA_OUTPUT),
1283 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1284 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1285 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1286 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1288 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1289 .name = "Master Playback Switch",
1290 .info = cxt_eapd_info,
1291 .get = cxt_eapd_get,
1292 .put = cxt5047_hp_master_sw_put,
1293 .private_value = 0x13,
1299 static struct snd_kcontrol_new cxt5047_hp_spk_mixers[] = {
1300 /* See the note in cxt5047_hp_master_sw_put */
1301 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT),
1302 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1306 static struct snd_kcontrol_new cxt5047_hp_only_mixers[] = {
1307 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1311 static struct hda_verb cxt5047_init_verbs[] = {
1312 /* Line in, Mic, Built-in Mic */
1313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1314 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1315 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1317 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1318 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, /* mixer(0x19) */
1319 {0x1d, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mixer(0x19) */
1320 /* Record selector: Mic */
1321 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1322 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1323 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1324 {0x1A, AC_VERB_SET_CONNECT_SEL,0x02},
1325 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1326 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1327 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1328 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
1329 /* SPDIF route: PCM */
1330 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
1331 /* Enable unsolicited events */
1332 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1333 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1337 /* configuration for Toshiba Laptops */
1338 static struct hda_verb cxt5047_toshiba_init_verbs[] = {
1339 {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0}, /* default off */
1343 /* Test configuration for debugging, modelled after the ALC260 test
1346 #ifdef CONFIG_SND_DEBUG
1347 static struct hda_input_mux cxt5047_test_capture_source = {
1350 { "LINE1 pin", 0x0 },
1351 { "MIC1 pin", 0x1 },
1352 { "MIC2 pin", 0x2 },
1357 static struct snd_kcontrol_new cxt5047_test_mixer[] = {
1359 /* Output only controls */
1360 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT),
1361 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT),
1362 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT),
1363 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT),
1364 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1365 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1366 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1367 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1368 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT),
1369 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1370 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT),
1371 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT),
1373 /* Modes for retasking pin widgets */
1374 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT),
1375 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT),
1377 /* EAPD Switch Control */
1378 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1380 /* Loopback mixer controls */
1381 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT),
1382 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT),
1383 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT),
1384 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT),
1385 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT),
1386 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT),
1387 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT),
1388 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT),
1390 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT),
1391 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT),
1392 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT),
1393 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT),
1394 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT),
1395 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT),
1396 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT),
1397 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT),
1399 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1400 .name = "Input Source",
1401 .info = conexant_mux_enum_info,
1402 .get = conexant_mux_enum_get,
1403 .put = conexant_mux_enum_put,
1405 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),
1406 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),
1407 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
1408 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
1409 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
1410 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
1411 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
1412 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
1413 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
1414 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
1419 static struct hda_verb cxt5047_test_init_verbs[] = {
1420 /* Enable retasking pins as output, initially without power amp */
1421 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1422 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1423 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1425 /* Disable digital (SPDIF) pins initially, but users can enable
1426 * them via a mixer switch. In the case of SPDIF-out, this initverb
1427 * payload also sets the generation to 0, output to be in "consumer"
1428 * PCM format, copyright asserted, no pre-emphasis and no validity
1431 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
1433 /* Ensure mic1, mic2, line1 pin widgets take input from the
1434 * OUT1 sum bus when acting as an output.
1436 {0x1a, AC_VERB_SET_CONNECT_SEL, 0},
1437 {0x1b, AC_VERB_SET_CONNECT_SEL, 0},
1439 /* Start with output sum widgets muted and their output gains at min */
1440 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1441 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1443 /* Unmute retasking pin widget output buffers since the default
1444 * state appears to be output. As the pin mode is changed by the
1445 * user the pin mode control will take care of enabling the pin's
1446 * input/output buffers as needed.
1448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1449 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1450 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1452 /* Mute capture amp left and right */
1453 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1455 /* Set ADC connection select to match default mixer setting (mic1
1458 {0x12, AC_VERB_SET_CONNECT_SEL, 0x00},
1460 /* Mute all inputs to mixer widget (even unconnected ones) */
1461 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
1462 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
1463 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
1464 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
1465 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
1466 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1467 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
1468 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
1475 /* initialize jack-sensing, too */
1476 static int cxt5047_hp_init(struct hda_codec *codec)
1478 conexant_init(codec);
1479 cxt5047_hp_automute(codec);
1485 CXT5047_LAPTOP, /* Laptops w/o EAPD support */
1486 CXT5047_LAPTOP_HP, /* Some HP laptops */
1487 CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */
1488 #ifdef CONFIG_SND_DEBUG
1494 static const char *cxt5047_models[CXT5047_MODELS] = {
1495 [CXT5047_LAPTOP] = "laptop",
1496 [CXT5047_LAPTOP_HP] = "laptop-hp",
1497 [CXT5047_LAPTOP_EAPD] = "laptop-eapd",
1498 #ifdef CONFIG_SND_DEBUG
1499 [CXT5047_TEST] = "test",
1503 static struct snd_pci_quirk cxt5047_cfg_tbl[] = {
1504 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
1505 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1507 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD),
1511 static int patch_cxt5047(struct hda_codec *codec)
1513 struct conexant_spec *spec;
1516 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1520 codec->pin_amp_workaround = 1;
1522 spec->multiout.max_channels = 2;
1523 spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids);
1524 spec->multiout.dac_nids = cxt5047_dac_nids;
1525 spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT;
1526 spec->num_adc_nids = 1;
1527 spec->adc_nids = cxt5047_adc_nids;
1528 spec->capsrc_nids = cxt5047_capsrc_nids;
1529 spec->num_mixers = 1;
1530 spec->mixers[0] = cxt5047_base_mixers;
1531 spec->num_init_verbs = 1;
1532 spec->init_verbs[0] = cxt5047_init_verbs;
1533 spec->spdif_route = 0;
1534 spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes),
1535 spec->channel_mode = cxt5047_modes,
1537 codec->patch_ops = conexant_patch_ops;
1539 board_config = snd_hda_check_board_config(codec, CXT5047_MODELS,
1542 switch (board_config) {
1543 case CXT5047_LAPTOP:
1544 spec->num_mixers = 2;
1545 spec->mixers[1] = cxt5047_hp_spk_mixers;
1546 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1548 case CXT5047_LAPTOP_HP:
1549 spec->num_mixers = 2;
1550 spec->mixers[1] = cxt5047_hp_only_mixers;
1551 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1552 codec->patch_ops.init = cxt5047_hp_init;
1554 case CXT5047_LAPTOP_EAPD:
1555 spec->input_mux = &cxt5047_toshiba_capture_source;
1556 spec->num_mixers = 2;
1557 spec->mixers[1] = cxt5047_hp_spk_mixers;
1558 spec->num_init_verbs = 2;
1559 spec->init_verbs[1] = cxt5047_toshiba_init_verbs;
1560 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1562 #ifdef CONFIG_SND_DEBUG
1564 spec->input_mux = &cxt5047_test_capture_source;
1565 spec->mixers[0] = cxt5047_test_mixer;
1566 spec->init_verbs[0] = cxt5047_test_init_verbs;
1567 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1570 spec->vmaster_nid = 0x13;
1574 /* Conexant 5051 specific */
1575 static hda_nid_t cxt5051_dac_nids[1] = { 0x10 };
1576 static hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 };
1578 static struct hda_channel_mode cxt5051_modes[1] = {
1582 static void cxt5051_update_speaker(struct hda_codec *codec)
1584 struct conexant_spec *spec = codec->spec;
1585 unsigned int pinctl;
1586 pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0;
1587 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
1591 /* turn on/off EAPD (+ mute HP) as a master switch */
1592 static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1593 struct snd_ctl_elem_value *ucontrol)
1595 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1597 if (!cxt_eapd_put(kcontrol, ucontrol))
1599 cxt5051_update_speaker(codec);
1603 /* toggle input of built-in and mic jack appropriately */
1604 static void cxt5051_portb_automic(struct hda_codec *codec)
1606 struct conexant_spec *spec = codec->spec;
1607 unsigned int present;
1609 if (spec->no_auto_mic)
1611 present = snd_hda_codec_read(codec, 0x17, 0,
1612 AC_VERB_GET_PIN_SENSE, 0) &
1613 AC_PINSENSE_PRESENCE;
1614 snd_hda_codec_write(codec, 0x14, 0,
1615 AC_VERB_SET_CONNECT_SEL,
1616 present ? 0x01 : 0x00);
1619 /* switch the current ADC according to the jack state */
1620 static void cxt5051_portc_automic(struct hda_codec *codec)
1622 struct conexant_spec *spec = codec->spec;
1623 unsigned int present;
1626 if (spec->no_auto_mic)
1628 present = snd_hda_codec_read(codec, 0x18, 0,
1629 AC_VERB_GET_PIN_SENSE, 0) &
1630 AC_PINSENSE_PRESENCE;
1632 spec->cur_adc_idx = 1;
1634 spec->cur_adc_idx = 0;
1635 new_adc = spec->adc_nids[spec->cur_adc_idx];
1636 if (spec->cur_adc && spec->cur_adc != new_adc) {
1637 /* stream is running, let's swap the current ADC */
1638 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
1639 spec->cur_adc = new_adc;
1640 snd_hda_codec_setup_stream(codec, new_adc,
1641 spec->cur_adc_stream_tag, 0,
1642 spec->cur_adc_format);
1646 /* mute internal speaker if HP is plugged */
1647 static void cxt5051_hp_automute(struct hda_codec *codec)
1649 struct conexant_spec *spec = codec->spec;
1651 spec->hp_present = snd_hda_codec_read(codec, 0x16, 0,
1652 AC_VERB_GET_PIN_SENSE, 0) &
1653 AC_PINSENSE_PRESENCE;
1654 cxt5051_update_speaker(codec);
1657 /* unsolicited event for HP jack sensing */
1658 static void cxt5051_hp_unsol_event(struct hda_codec *codec,
1661 int nid = (res & AC_UNSOL_RES_SUBTAG) >> 20;
1662 switch (res >> 26) {
1663 case CONEXANT_HP_EVENT:
1664 cxt5051_hp_automute(codec);
1666 case CXT5051_PORTB_EVENT:
1667 cxt5051_portb_automic(codec);
1669 case CXT5051_PORTC_EVENT:
1670 cxt5051_portc_automic(codec);
1673 conexant_report_jack(codec, nid);
1676 static struct snd_kcontrol_new cxt5051_mixers[] = {
1677 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
1678 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
1679 HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT),
1680 HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT),
1681 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT),
1682 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT),
1683 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1685 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1686 .name = "Master Playback Switch",
1687 .info = cxt_eapd_info,
1688 .get = cxt_eapd_get,
1689 .put = cxt5051_hp_master_sw_put,
1690 .private_value = 0x1a,
1696 static struct snd_kcontrol_new cxt5051_hp_mixers[] = {
1697 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
1698 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
1699 HDA_CODEC_VOLUME("External Mic Volume", 0x15, 0x00, HDA_INPUT),
1700 HDA_CODEC_MUTE("External Mic Switch", 0x15, 0x00, HDA_INPUT),
1701 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1703 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1704 .name = "Master Playback Switch",
1705 .info = cxt_eapd_info,
1706 .get = cxt_eapd_get,
1707 .put = cxt5051_hp_master_sw_put,
1708 .private_value = 0x1a,
1714 static struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = {
1715 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x00, HDA_INPUT),
1716 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x00, HDA_INPUT),
1717 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1719 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1720 .name = "Master Playback Switch",
1721 .info = cxt_eapd_info,
1722 .get = cxt_eapd_get,
1723 .put = cxt5051_hp_master_sw_put,
1724 .private_value = 0x1a,
1730 static struct hda_verb cxt5051_init_verbs[] = {
1732 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1733 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1734 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1735 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1736 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1737 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1739 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1740 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1742 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1743 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
1745 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1746 /* Record selector: Int mic */
1747 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1748 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
1749 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1750 /* SPDIF route: PCM */
1751 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
1753 {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
1754 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1755 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT},
1756 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTC_EVENT},
1760 static struct hda_verb cxt5051_hp_dv6736_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: Int 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},
1782 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT},
1786 static struct hda_verb cxt5051_lenovo_x200_init_verbs[] = {
1788 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1789 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1790 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1791 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1792 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1793 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1795 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1796 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1798 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1799 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
1801 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1802 {0x19, AC_VERB_SET_CONNECT_SEL, 0x00},
1804 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1805 /* Record selector: Int mic */
1806 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1807 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
1808 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1809 /* SPDIF route: PCM */
1810 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
1812 {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
1813 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1814 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT},
1815 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTC_EVENT},
1816 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1820 /* initialize jack-sensing, too */
1821 static int cxt5051_init(struct hda_codec *codec)
1823 conexant_init(codec);
1824 conexant_init_jacks(codec);
1825 if (codec->patch_ops.unsol_event) {
1826 cxt5051_hp_automute(codec);
1827 cxt5051_portb_automic(codec);
1828 cxt5051_portc_automic(codec);
1835 CXT5051_LAPTOP, /* Laptops w/ EAPD support */
1836 CXT5051_HP, /* no docking */
1837 CXT5051_HP_DV6736, /* HP without mic switch */
1838 CXT5051_LENOVO_X200, /* Lenovo X200 laptop */
1842 static const char *cxt5051_models[CXT5051_MODELS] = {
1843 [CXT5051_LAPTOP] = "laptop",
1844 [CXT5051_HP] = "hp",
1845 [CXT5051_HP_DV6736] = "hp-dv6736",
1846 [CXT5051_LENOVO_X200] = "lenovo-x200",
1849 static struct snd_pci_quirk cxt5051_cfg_tbl[] = {
1850 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736),
1851 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1853 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP),
1854 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200),
1858 static int patch_cxt5051(struct hda_codec *codec)
1860 struct conexant_spec *spec;
1863 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1867 codec->pin_amp_workaround = 1;
1869 codec->patch_ops = conexant_patch_ops;
1870 codec->patch_ops.init = cxt5051_init;
1872 spec->multiout.max_channels = 2;
1873 spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids);
1874 spec->multiout.dac_nids = cxt5051_dac_nids;
1875 spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT;
1876 spec->num_adc_nids = 1; /* not 2; via auto-mic switch */
1877 spec->adc_nids = cxt5051_adc_nids;
1878 spec->num_mixers = 1;
1879 spec->mixers[0] = cxt5051_mixers;
1880 spec->num_init_verbs = 1;
1881 spec->init_verbs[0] = cxt5051_init_verbs;
1882 spec->spdif_route = 0;
1883 spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes);
1884 spec->channel_mode = cxt5051_modes;
1886 spec->cur_adc_idx = 0;
1888 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
1890 board_config = snd_hda_check_board_config(codec, CXT5051_MODELS,
1893 switch (board_config) {
1895 spec->mixers[0] = cxt5051_hp_mixers;
1897 case CXT5051_HP_DV6736:
1898 spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs;
1899 spec->mixers[0] = cxt5051_hp_dv6736_mixers;
1900 spec->no_auto_mic = 1;
1902 case CXT5051_LENOVO_X200:
1903 spec->init_verbs[0] = cxt5051_lenovo_x200_init_verbs;
1914 static struct hda_codec_preset snd_hda_preset_conexant[] = {
1915 { .id = 0x14f15045, .name = "CX20549 (Venice)",
1916 .patch = patch_cxt5045 },
1917 { .id = 0x14f15047, .name = "CX20551 (Waikiki)",
1918 .patch = patch_cxt5047 },
1919 { .id = 0x14f15051, .name = "CX20561 (Hermosa)",
1920 .patch = patch_cxt5051 },
1924 MODULE_ALIAS("snd-hda-codec-id:14f15045");
1925 MODULE_ALIAS("snd-hda-codec-id:14f15047");
1926 MODULE_ALIAS("snd-hda-codec-id:14f15051");
1928 MODULE_LICENSE("GPL");
1929 MODULE_DESCRIPTION("Conexant HD-audio codec");
1931 static struct hda_codec_preset_list conexant_list = {
1932 .preset = snd_hda_preset_conexant,
1933 .owner = THIS_MODULE,
1936 static int __init patch_conexant_init(void)
1938 return snd_hda_add_codec_preset(&conexant_list);
1941 static void __exit patch_conexant_exit(void)
1943 snd_hda_delete_codec_preset(&conexant_list);
1946 module_init(patch_conexant_init)
1947 module_exit(patch_conexant_exit)