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 "hda_codec.h"
29 #include "hda_local.h"
30 #include "hda_patch.h"
32 #define CXT_PIN_DIR_IN 0x00
33 #define CXT_PIN_DIR_OUT 0x01
34 #define CXT_PIN_DIR_INOUT 0x02
35 #define CXT_PIN_DIR_IN_NOMICBIAS 0x03
36 #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04
38 #define CONEXANT_HP_EVENT 0x37
39 #define CONEXANT_MIC_EVENT 0x38
43 struct conexant_spec {
45 struct snd_kcontrol_new *mixers[5];
48 const struct hda_verb *init_verbs[5]; /* initialization verbs
52 unsigned int num_init_verbs;
55 struct hda_multi_out multiout; /* playback set-up
56 * max_channels, dacs must be set
57 * dig_out_nid and hp_nid are optional
59 unsigned int cur_eapd;
60 unsigned int hp_present;
61 unsigned int need_dac_fix;
64 unsigned int num_adc_nids;
66 hda_nid_t dig_in_nid; /* digital-in NID; optional */
68 unsigned int cur_adc_idx;
70 unsigned int cur_adc_stream_tag;
71 unsigned int cur_adc_format;
74 const struct hda_input_mux *input_mux;
75 hda_nid_t *capsrc_nids;
76 unsigned int cur_mux[3];
79 const struct hda_channel_mode *channel_mode;
83 struct hda_pcm pcm_rec[2]; /* used in build_pcms() */
85 unsigned int spdif_route;
87 /* dynamic controls, init_verbs and input_mux */
88 struct auto_pin_cfg autocfg;
89 struct hda_input_mux private_imux;
90 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
94 static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo,
95 struct hda_codec *codec,
96 struct snd_pcm_substream *substream)
98 struct conexant_spec *spec = codec->spec;
99 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
103 static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
104 struct hda_codec *codec,
105 unsigned int stream_tag,
107 struct snd_pcm_substream *substream)
109 struct conexant_spec *spec = codec->spec;
110 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
115 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
116 struct hda_codec *codec,
117 struct snd_pcm_substream *substream)
119 struct conexant_spec *spec = codec->spec;
120 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
126 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
127 struct hda_codec *codec,
128 struct snd_pcm_substream *substream)
130 struct conexant_spec *spec = codec->spec;
131 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
134 static int conexant_dig_playback_pcm_close(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_dig_close(codec, &spec->multiout);
142 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
143 struct hda_codec *codec,
144 unsigned int stream_tag,
146 struct snd_pcm_substream *substream)
148 struct conexant_spec *spec = codec->spec;
149 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
157 static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
158 struct hda_codec *codec,
159 unsigned int stream_tag,
161 struct snd_pcm_substream *substream)
163 struct conexant_spec *spec = codec->spec;
164 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
165 stream_tag, 0, format);
169 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
170 struct hda_codec *codec,
171 struct snd_pcm_substream *substream)
173 struct conexant_spec *spec = codec->spec;
174 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
180 static struct hda_pcm_stream conexant_pcm_analog_playback = {
184 .nid = 0, /* fill later */
186 .open = conexant_playback_pcm_open,
187 .prepare = conexant_playback_pcm_prepare,
188 .cleanup = conexant_playback_pcm_cleanup
192 static struct hda_pcm_stream conexant_pcm_analog_capture = {
196 .nid = 0, /* fill later */
198 .prepare = conexant_capture_pcm_prepare,
199 .cleanup = conexant_capture_pcm_cleanup
204 static struct hda_pcm_stream conexant_pcm_digital_playback = {
208 .nid = 0, /* fill later */
210 .open = conexant_dig_playback_pcm_open,
211 .close = conexant_dig_playback_pcm_close,
212 .prepare = conexant_dig_playback_pcm_prepare
216 static struct hda_pcm_stream conexant_pcm_digital_capture = {
220 /* NID is set in alc_build_pcms */
223 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
224 struct hda_codec *codec,
225 unsigned int stream_tag,
227 struct snd_pcm_substream *substream)
229 struct conexant_spec *spec = codec->spec;
230 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
231 spec->cur_adc_stream_tag = stream_tag;
232 spec->cur_adc_format = format;
233 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
237 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
238 struct hda_codec *codec,
239 struct snd_pcm_substream *substream)
241 struct conexant_spec *spec = codec->spec;
242 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
247 static struct hda_pcm_stream cx5051_pcm_analog_capture = {
251 .nid = 0, /* fill later */
253 .prepare = cx5051_capture_pcm_prepare,
254 .cleanup = cx5051_capture_pcm_cleanup
258 static int conexant_build_pcms(struct hda_codec *codec)
260 struct conexant_spec *spec = codec->spec;
261 struct hda_pcm *info = spec->pcm_rec;
264 codec->pcm_info = info;
266 info->name = "CONEXANT Analog";
267 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback;
268 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max =
269 spec->multiout.max_channels;
270 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
271 spec->multiout.dac_nids[0];
272 if (codec->vendor_id == 0x14f15051)
273 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
274 cx5051_pcm_analog_capture;
276 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
277 conexant_pcm_analog_capture;
278 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
279 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
281 if (spec->multiout.dig_out_nid) {
284 info->name = "Conexant Digital";
285 info->pcm_type = HDA_PCM_TYPE_SPDIF;
286 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
287 conexant_pcm_digital_playback;
288 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
289 spec->multiout.dig_out_nid;
290 if (spec->dig_in_nid) {
291 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
292 conexant_pcm_digital_capture;
293 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
301 static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol,
302 struct snd_ctl_elem_info *uinfo)
304 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
305 struct conexant_spec *spec = codec->spec;
307 return snd_hda_input_mux_info(spec->input_mux, uinfo);
310 static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol,
311 struct snd_ctl_elem_value *ucontrol)
313 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
314 struct conexant_spec *spec = codec->spec;
315 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
317 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
321 static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol,
322 struct snd_ctl_elem_value *ucontrol)
324 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
325 struct conexant_spec *spec = codec->spec;
326 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
328 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
329 spec->capsrc_nids[adc_idx],
330 &spec->cur_mux[adc_idx]);
333 static int conexant_init(struct hda_codec *codec)
335 struct conexant_spec *spec = codec->spec;
338 for (i = 0; i < spec->num_init_verbs; i++)
339 snd_hda_sequence_write(codec, spec->init_verbs[i]);
343 static void conexant_free(struct hda_codec *codec)
348 static int conexant_build_controls(struct hda_codec *codec)
350 struct conexant_spec *spec = codec->spec;
354 for (i = 0; i < spec->num_mixers; i++) {
355 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
359 if (spec->multiout.dig_out_nid) {
360 err = snd_hda_create_spdif_out_ctls(codec,
361 spec->multiout.dig_out_nid);
364 err = snd_hda_create_spdif_share_sw(codec,
368 spec->multiout.share_spdif = 1;
370 if (spec->dig_in_nid) {
371 err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid);
378 static struct hda_codec_ops conexant_patch_ops = {
379 .build_controls = conexant_build_controls,
380 .build_pcms = conexant_build_pcms,
381 .init = conexant_init,
382 .free = conexant_free,
387 * the private value = nid | (invert << 8)
390 #define cxt_eapd_info snd_ctl_boolean_mono_info
392 static int cxt_eapd_get(struct snd_kcontrol *kcontrol,
393 struct snd_ctl_elem_value *ucontrol)
395 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
396 struct conexant_spec *spec = codec->spec;
397 int invert = (kcontrol->private_value >> 8) & 1;
399 ucontrol->value.integer.value[0] = !spec->cur_eapd;
401 ucontrol->value.integer.value[0] = spec->cur_eapd;
406 static int cxt_eapd_put(struct snd_kcontrol *kcontrol,
407 struct snd_ctl_elem_value *ucontrol)
409 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
410 struct conexant_spec *spec = codec->spec;
411 int invert = (kcontrol->private_value >> 8) & 1;
412 hda_nid_t nid = kcontrol->private_value & 0xff;
415 eapd = !!ucontrol->value.integer.value[0];
418 if (eapd == spec->cur_eapd)
421 spec->cur_eapd = eapd;
422 snd_hda_codec_write_cache(codec, nid,
423 0, AC_VERB_SET_EAPD_BTLENABLE,
428 /* controls for test mode */
429 #ifdef CONFIG_SND_DEBUG
431 #define CXT_EAPD_SWITCH(xname, nid, mask) \
432 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
433 .info = cxt_eapd_info, \
434 .get = cxt_eapd_get, \
435 .put = cxt_eapd_put, \
436 .private_value = nid | (mask<<16) }
440 static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol,
441 struct snd_ctl_elem_info *uinfo)
443 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
444 struct conexant_spec *spec = codec->spec;
445 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
446 spec->num_channel_mode);
449 static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol,
450 struct snd_ctl_elem_value *ucontrol)
452 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
453 struct conexant_spec *spec = codec->spec;
454 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
455 spec->num_channel_mode,
456 spec->multiout.max_channels);
459 static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol,
460 struct snd_ctl_elem_value *ucontrol)
462 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
463 struct conexant_spec *spec = codec->spec;
464 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
465 spec->num_channel_mode,
466 &spec->multiout.max_channels);
467 if (err >= 0 && spec->need_dac_fix)
468 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
472 #define CXT_PIN_MODE(xname, nid, dir) \
473 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
474 .info = conexant_ch_mode_info, \
475 .get = conexant_ch_mode_get, \
476 .put = conexant_ch_mode_put, \
477 .private_value = nid | (dir<<16) }
479 #endif /* CONFIG_SND_DEBUG */
481 /* Conexant 5045 specific */
483 static hda_nid_t cxt5045_dac_nids[1] = { 0x19 };
484 static hda_nid_t cxt5045_adc_nids[1] = { 0x1a };
485 static hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a };
486 #define CXT5045_SPDIF_OUT 0x18
488 static struct hda_channel_mode cxt5045_modes[1] = {
492 static struct hda_input_mux cxt5045_capture_source = {
500 static struct hda_input_mux cxt5045_capture_source_benq = {
509 static struct hda_input_mux cxt5045_capture_source_hp530 = {
517 /* turn on/off EAPD (+ mute HP) as a master switch */
518 static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
519 struct snd_ctl_elem_value *ucontrol)
521 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
522 struct conexant_spec *spec = codec->spec;
525 if (!cxt_eapd_put(kcontrol, ucontrol))
528 /* toggle internal speakers mute depending of presence of
531 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
532 snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
535 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
536 snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0,
541 /* bind volumes of both NID 0x10 and 0x11 */
542 static struct hda_bind_ctls cxt5045_hp_bind_master_vol = {
543 .ops = &snd_hda_bind_vol,
545 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT),
546 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
551 /* toggle input of built-in and mic jack appropriately */
552 static void cxt5045_hp_automic(struct hda_codec *codec)
554 static struct hda_verb mic_jack_on[] = {
555 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
556 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
559 static struct hda_verb mic_jack_off[] = {
560 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
561 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
564 unsigned int present;
566 present = snd_hda_codec_read(codec, 0x12, 0,
567 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
569 snd_hda_sequence_write(codec, mic_jack_on);
571 snd_hda_sequence_write(codec, mic_jack_off);
575 /* mute internal speaker if HP is plugged */
576 static void cxt5045_hp_automute(struct hda_codec *codec)
578 struct conexant_spec *spec = codec->spec;
581 spec->hp_present = snd_hda_codec_read(codec, 0x11, 0,
582 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
584 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
585 snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
589 /* unsolicited event for HP jack sensing */
590 static void cxt5045_hp_unsol_event(struct hda_codec *codec,
595 case CONEXANT_HP_EVENT:
596 cxt5045_hp_automute(codec);
598 case CONEXANT_MIC_EVENT:
599 cxt5045_hp_automic(codec);
605 static struct snd_kcontrol_new cxt5045_mixers[] = {
607 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
608 .name = "Capture Source",
609 .info = conexant_mux_enum_info,
610 .get = conexant_mux_enum_get,
611 .put = conexant_mux_enum_put
613 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
614 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
615 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
616 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
617 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
618 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
619 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
620 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
621 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
622 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
623 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
626 .name = "Master Playback Switch",
627 .info = cxt_eapd_info,
629 .put = cxt5045_hp_master_sw_put,
630 .private_value = 0x10,
636 static struct snd_kcontrol_new cxt5045_benq_mixers[] = {
637 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT),
638 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT),
639 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT),
640 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT),
645 static struct snd_kcontrol_new cxt5045_mixers_hp530[] = {
647 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
648 .name = "Capture Source",
649 .info = conexant_mux_enum_info,
650 .get = conexant_mux_enum_get,
651 .put = conexant_mux_enum_put
653 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
654 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
655 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
656 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
657 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
658 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
659 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
660 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
661 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
662 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
663 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
665 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
666 .name = "Master Playback Switch",
667 .info = cxt_eapd_info,
669 .put = cxt5045_hp_master_sw_put,
670 .private_value = 0x10,
676 static struct hda_verb cxt5045_init_verbs[] = {
678 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
679 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
681 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
682 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
683 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
684 {0x11, AC_VERB_SET_CONNECT_SEL, 0x1},
685 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
686 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
687 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
688 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
689 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
690 /* Record selector: Int mic */
691 {0x1a, AC_VERB_SET_CONNECT_SEL,0x1},
692 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
693 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
694 /* SPDIF route: PCM */
695 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
696 { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
698 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */
702 static struct hda_verb cxt5045_benq_init_verbs[] = {
704 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
705 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
706 /* Line In,HP, Amp */
707 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
708 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
709 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
710 {0x11, AC_VERB_SET_CONNECT_SEL, 0x1},
711 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
712 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
713 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
714 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
715 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
716 /* Record selector: Int mic */
717 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x1},
718 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
719 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
720 /* SPDIF route: PCM */
721 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
722 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
724 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
728 static struct hda_verb cxt5045_hp_sense_init_verbs[] = {
729 /* pin sensing on HP jack */
730 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
734 static struct hda_verb cxt5045_mic_sense_init_verbs[] = {
735 /* pin sensing on HP jack */
736 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
740 #ifdef CONFIG_SND_DEBUG
741 /* Test configuration for debugging, modelled after the ALC260 test
744 static struct hda_input_mux cxt5045_test_capture_source = {
749 { "LINE1 pin", 0x2 },
750 { "HP-OUT pin", 0x3 },
755 static struct snd_kcontrol_new cxt5045_test_mixer[] = {
757 /* Output controls */
758 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
759 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
760 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT),
761 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT),
762 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT),
763 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT),
765 /* Modes for retasking pin widgets */
766 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
767 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT),
769 /* EAPD Switch Control */
770 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
772 /* Loopback mixer controls */
774 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT),
775 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT),
776 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT),
777 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT),
778 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT),
779 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT),
780 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT),
781 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT),
782 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT),
783 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT),
785 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
786 .name = "Input Source",
787 .info = conexant_mux_enum_info,
788 .get = conexant_mux_enum_get,
789 .put = conexant_mux_enum_put,
791 /* Audio input controls */
792 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),
793 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),
794 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
795 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
796 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
797 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
798 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
799 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
800 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
801 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
805 static struct hda_verb cxt5045_test_init_verbs[] = {
806 /* Set connections */
807 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
808 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 },
809 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 },
810 /* Enable retasking pins as output, initially without power amp */
811 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
812 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
814 /* Disable digital (SPDIF) pins initially, but users can enable
815 * them via a mixer switch. In the case of SPDIF-out, this initverb
816 * payload also sets the generation to 0, output to be in "consumer"
817 * PCM format, copyright asserted, no pre-emphasis and no validity
820 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
821 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
823 /* Start with output sum widgets muted and their output gains at min */
824 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
825 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
827 /* Unmute retasking pin widget output buffers since the default
828 * state appears to be output. As the pin mode is changed by the
829 * user the pin mode control will take care of enabling the pin's
830 * input/output buffers as needed.
832 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
833 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
835 /* Mute capture amp left and right */
836 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
838 /* Set ADC connection select to match default mixer setting (mic1
841 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
842 {0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
844 /* Mute all inputs to mixer widget (even unconnected ones) */
845 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */
846 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */
847 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */
848 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */
849 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
856 /* initialize jack-sensing, too */
857 static int cxt5045_init(struct hda_codec *codec)
859 conexant_init(codec);
860 cxt5045_hp_automute(codec);
866 CXT5045_LAPTOP_HPSENSE,
867 CXT5045_LAPTOP_MICSENSE,
868 CXT5045_LAPTOP_HPMICSENSE,
870 CXT5045_LAPTOP_HP530,
871 #ifdef CONFIG_SND_DEBUG
877 static const char *cxt5045_models[CXT5045_MODELS] = {
878 [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense",
879 [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense",
880 [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense",
881 [CXT5045_BENQ] = "benq",
882 [CXT5045_LAPTOP_HP530] = "laptop-hp530",
883 #ifdef CONFIG_SND_DEBUG
884 [CXT5045_TEST] = "test",
888 static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
889 SND_PCI_QUIRK(0x103c, 0x30a5, "HP", CXT5045_LAPTOP_HPSENSE),
890 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
891 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2120", CXT5045_LAPTOP_HPSENSE),
892 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP_HPSENSE),
893 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP_HPSENSE),
894 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
895 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV9533EG", CXT5045_LAPTOP_HPSENSE),
896 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530),
897 SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP_HPSENSE),
898 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE),
899 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ),
900 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE),
901 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE),
902 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
903 CXT5045_LAPTOP_HPMICSENSE),
904 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE),
905 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE),
906 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE),
907 SND_PCI_QUIRK(0x1631, 0xc106, "Packard Bell", CXT5045_LAPTOP_HPMICSENSE),
908 SND_PCI_QUIRK(0x1631, 0xc107, "Packard Bell", CXT5045_LAPTOP_HPMICSENSE),
909 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE),
913 static int patch_cxt5045(struct hda_codec *codec)
915 struct conexant_spec *spec;
918 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
923 spec->multiout.max_channels = 2;
924 spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids);
925 spec->multiout.dac_nids = cxt5045_dac_nids;
926 spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT;
927 spec->num_adc_nids = 1;
928 spec->adc_nids = cxt5045_adc_nids;
929 spec->capsrc_nids = cxt5045_capsrc_nids;
930 spec->input_mux = &cxt5045_capture_source;
931 spec->num_mixers = 1;
932 spec->mixers[0] = cxt5045_mixers;
933 spec->num_init_verbs = 1;
934 spec->init_verbs[0] = cxt5045_init_verbs;
935 spec->spdif_route = 0;
936 spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes),
937 spec->channel_mode = cxt5045_modes,
940 codec->patch_ops = conexant_patch_ops;
942 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
945 switch (board_config) {
946 case CXT5045_LAPTOP_HPSENSE:
947 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
948 spec->input_mux = &cxt5045_capture_source;
949 spec->num_init_verbs = 2;
950 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
951 spec->mixers[0] = cxt5045_mixers;
952 codec->patch_ops.init = cxt5045_init;
954 case CXT5045_LAPTOP_MICSENSE:
955 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
956 spec->input_mux = &cxt5045_capture_source;
957 spec->num_init_verbs = 2;
958 spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;
959 spec->mixers[0] = cxt5045_mixers;
960 codec->patch_ops.init = cxt5045_init;
963 case CXT5045_LAPTOP_HPMICSENSE:
964 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
965 spec->input_mux = &cxt5045_capture_source;
966 spec->num_init_verbs = 3;
967 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
968 spec->init_verbs[2] = cxt5045_mic_sense_init_verbs;
969 spec->mixers[0] = cxt5045_mixers;
970 codec->patch_ops.init = cxt5045_init;
973 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
974 spec->input_mux = &cxt5045_capture_source_benq;
975 spec->num_init_verbs = 1;
976 spec->init_verbs[0] = cxt5045_benq_init_verbs;
977 spec->mixers[0] = cxt5045_mixers;
978 spec->mixers[1] = cxt5045_benq_mixers;
979 spec->num_mixers = 2;
980 codec->patch_ops.init = cxt5045_init;
982 case CXT5045_LAPTOP_HP530:
983 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
984 spec->input_mux = &cxt5045_capture_source_hp530;
985 spec->num_init_verbs = 2;
986 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
987 spec->mixers[0] = cxt5045_mixers_hp530;
988 codec->patch_ops.init = cxt5045_init;
990 #ifdef CONFIG_SND_DEBUG
992 spec->input_mux = &cxt5045_test_capture_source;
993 spec->mixers[0] = cxt5045_test_mixer;
994 spec->init_verbs[0] = cxt5045_test_init_verbs;
1000 switch (codec->subsystem_id >> 16) {
1002 /* HP laptop has a really bad sound over 0dB on NID 0x17.
1003 * Fix max PCM level to 0 dB
1004 * (originall it has 0x2b steps with 0dB offset 0x14)
1006 snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT,
1007 (0x14 << AC_AMPCAP_OFFSET_SHIFT) |
1008 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) |
1009 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
1010 (1 << AC_AMPCAP_MUTE_SHIFT));
1018 /* Conexant 5047 specific */
1019 #define CXT5047_SPDIF_OUT 0x11
1021 static hda_nid_t cxt5047_dac_nids[2] = { 0x10, 0x1c };
1022 static hda_nid_t cxt5047_adc_nids[1] = { 0x12 };
1023 static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a };
1025 static struct hda_channel_mode cxt5047_modes[1] = {
1029 static struct hda_input_mux cxt5047_capture_source = {
1036 static struct hda_input_mux cxt5047_hp_capture_source = {
1043 static struct hda_input_mux cxt5047_toshiba_capture_source = {
1051 /* turn on/off EAPD (+ mute HP) as a master switch */
1052 static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1053 struct snd_ctl_elem_value *ucontrol)
1055 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1056 struct conexant_spec *spec = codec->spec;
1059 if (!cxt_eapd_put(kcontrol, ucontrol))
1062 /* toggle internal speakers mute depending of presence of
1063 * the headphone jack
1065 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
1066 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
1067 HDA_AMP_MUTE, bits);
1068 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
1069 snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0,
1070 HDA_AMP_MUTE, bits);
1074 /* bind volumes of both NID 0x13 (Headphones) and 0x1d (Speakers) */
1075 static struct hda_bind_ctls cxt5047_bind_master_vol = {
1076 .ops = &snd_hda_bind_vol,
1078 HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
1079 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
1084 /* mute internal speaker if HP is plugged */
1085 static void cxt5047_hp_automute(struct hda_codec *codec)
1087 struct conexant_spec *spec = codec->spec;
1090 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
1091 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1093 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
1094 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
1095 HDA_AMP_MUTE, bits);
1096 /* Mute/Unmute PCM 2 for good measure - some systems need this */
1097 snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
1098 HDA_AMP_MUTE, bits);
1101 /* mute internal speaker if HP is plugged */
1102 static void cxt5047_hp2_automute(struct hda_codec *codec)
1104 struct conexant_spec *spec = codec->spec;
1107 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
1108 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1110 bits = spec->hp_present ? HDA_AMP_MUTE : 0;
1111 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
1112 HDA_AMP_MUTE, bits);
1113 /* Mute/Unmute PCM 2 for good measure - some systems need this */
1114 snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
1115 HDA_AMP_MUTE, bits);
1118 /* toggle input of built-in and mic jack appropriately */
1119 static void cxt5047_hp_automic(struct hda_codec *codec)
1121 static struct hda_verb mic_jack_on[] = {
1122 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1123 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1126 static struct hda_verb mic_jack_off[] = {
1127 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1128 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1131 unsigned int present;
1133 present = snd_hda_codec_read(codec, 0x15, 0,
1134 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1136 snd_hda_sequence_write(codec, mic_jack_on);
1138 snd_hda_sequence_write(codec, mic_jack_off);
1141 /* unsolicited event for HP jack sensing */
1142 static void cxt5047_hp_unsol_event(struct hda_codec *codec,
1145 switch (res >> 26) {
1146 case CONEXANT_HP_EVENT:
1147 cxt5047_hp_automute(codec);
1149 case CONEXANT_MIC_EVENT:
1150 cxt5047_hp_automic(codec);
1155 /* unsolicited event for HP jack sensing - non-EAPD systems */
1156 static void cxt5047_hp2_unsol_event(struct hda_codec *codec,
1161 case CONEXANT_HP_EVENT:
1162 cxt5047_hp2_automute(codec);
1164 case CONEXANT_MIC_EVENT:
1165 cxt5047_hp_automic(codec);
1170 static struct snd_kcontrol_new cxt5047_mixers[] = {
1171 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1172 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1173 HDA_CODEC_VOLUME("Mic Gain Volume", 0x1a, 0x0, HDA_OUTPUT),
1174 HDA_CODEC_MUTE("Mic Gain Switch", 0x1a, 0x0, HDA_OUTPUT),
1175 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1176 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1177 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1178 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1179 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT),
1180 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT),
1181 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x00, HDA_OUTPUT),
1182 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x00, HDA_OUTPUT),
1183 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1184 HDA_CODEC_MUTE("Headphone Playback Switch", 0x13, 0x00, HDA_OUTPUT),
1189 static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = {
1191 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1192 .name = "Capture Source",
1193 .info = conexant_mux_enum_info,
1194 .get = conexant_mux_enum_get,
1195 .put = conexant_mux_enum_put
1197 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1198 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1199 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1200 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1201 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1202 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1203 HDA_BIND_VOL("Master Playback Volume", &cxt5047_bind_master_vol),
1205 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1206 .name = "Master Playback Switch",
1207 .info = cxt_eapd_info,
1208 .get = cxt_eapd_get,
1209 .put = cxt5047_hp_master_sw_put,
1210 .private_value = 0x13,
1216 static struct snd_kcontrol_new cxt5047_hp_mixers[] = {
1218 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1219 .name = "Capture Source",
1220 .info = conexant_mux_enum_info,
1221 .get = conexant_mux_enum_get,
1222 .put = conexant_mux_enum_put
1224 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1225 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19,0x02,HDA_INPUT),
1226 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1227 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1228 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1229 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1230 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1232 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1233 .name = "Master Playback Switch",
1234 .info = cxt_eapd_info,
1235 .get = cxt_eapd_get,
1236 .put = cxt5047_hp_master_sw_put,
1237 .private_value = 0x13,
1242 static struct hda_verb cxt5047_init_verbs[] = {
1243 /* Line in, Mic, Built-in Mic */
1244 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1245 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1246 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1248 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1249 {0x13, AC_VERB_SET_CONNECT_SEL,0x1},
1250 {0x1d, AC_VERB_SET_CONNECT_SEL,0x0},
1251 /* Record selector: Mic */
1252 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1253 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1254 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1255 {0x1A, AC_VERB_SET_CONNECT_SEL,0x02},
1256 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1257 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1258 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1259 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
1260 /* SPDIF route: PCM */
1261 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
1262 /* Enable unsolicited events */
1263 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1264 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1268 /* configuration for Toshiba Laptops */
1269 static struct hda_verb cxt5047_toshiba_init_verbs[] = {
1270 {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0 }, /* default on */
1271 /* pin sensing on HP and Mic jacks */
1272 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1273 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1274 /* Speaker routing */
1275 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1279 /* configuration for HP Laptops */
1280 static struct hda_verb cxt5047_hp_init_verbs[] = {
1281 /* pin sensing on HP jack */
1282 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1283 /* 0x13 is actually shared by both HP and speaker;
1284 * setting the connection to 0 (=0x19) makes the master volume control
1285 * working mysteriouslly...
1287 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1288 /* Record selector: Ext 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 /* Speaker routing */
1293 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1297 /* Test configuration for debugging, modelled after the ALC260 test
1300 #ifdef CONFIG_SND_DEBUG
1301 static struct hda_input_mux cxt5047_test_capture_source = {
1304 { "LINE1 pin", 0x0 },
1305 { "MIC1 pin", 0x1 },
1306 { "MIC2 pin", 0x2 },
1311 static struct snd_kcontrol_new cxt5047_test_mixer[] = {
1313 /* Output only controls */
1314 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT),
1315 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT),
1316 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT),
1317 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT),
1318 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1319 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1320 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1321 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1322 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT),
1323 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1324 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT),
1325 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT),
1327 /* Modes for retasking pin widgets */
1328 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT),
1329 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT),
1331 /* EAPD Switch Control */
1332 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1334 /* Loopback mixer controls */
1335 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT),
1336 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT),
1337 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT),
1338 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT),
1339 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT),
1340 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT),
1341 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT),
1342 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT),
1344 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT),
1345 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT),
1346 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT),
1347 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT),
1348 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT),
1349 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT),
1350 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT),
1351 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT),
1353 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1354 .name = "Input Source",
1355 .info = conexant_mux_enum_info,
1356 .get = conexant_mux_enum_get,
1357 .put = conexant_mux_enum_put,
1359 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),
1360 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),
1361 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
1362 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
1363 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
1364 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
1365 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
1366 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
1367 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
1368 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
1373 static struct hda_verb cxt5047_test_init_verbs[] = {
1374 /* Enable retasking pins as output, initially without power amp */
1375 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1376 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1377 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1379 /* Disable digital (SPDIF) pins initially, but users can enable
1380 * them via a mixer switch. In the case of SPDIF-out, this initverb
1381 * payload also sets the generation to 0, output to be in "consumer"
1382 * PCM format, copyright asserted, no pre-emphasis and no validity
1385 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
1387 /* Ensure mic1, mic2, line1 pin widgets take input from the
1388 * OUT1 sum bus when acting as an output.
1390 {0x1a, AC_VERB_SET_CONNECT_SEL, 0},
1391 {0x1b, AC_VERB_SET_CONNECT_SEL, 0},
1393 /* Start with output sum widgets muted and their output gains at min */
1394 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1395 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1397 /* Unmute retasking pin widget output buffers since the default
1398 * state appears to be output. As the pin mode is changed by the
1399 * user the pin mode control will take care of enabling the pin's
1400 * input/output buffers as needed.
1402 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1403 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1404 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1406 /* Mute capture amp left and right */
1407 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1409 /* Set ADC connection select to match default mixer setting (mic1
1412 {0x12, AC_VERB_SET_CONNECT_SEL, 0x00},
1414 /* Mute all inputs to mixer widget (even unconnected ones) */
1415 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
1416 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
1417 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
1418 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
1419 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
1420 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1421 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
1422 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
1429 /* initialize jack-sensing, too */
1430 static int cxt5047_hp_init(struct hda_codec *codec)
1432 conexant_init(codec);
1433 cxt5047_hp_automute(codec);
1439 CXT5047_LAPTOP, /* Laptops w/o EAPD support */
1440 CXT5047_LAPTOP_HP, /* Some HP laptops */
1441 CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */
1442 #ifdef CONFIG_SND_DEBUG
1448 static const char *cxt5047_models[CXT5047_MODELS] = {
1449 [CXT5047_LAPTOP] = "laptop",
1450 [CXT5047_LAPTOP_HP] = "laptop-hp",
1451 [CXT5047_LAPTOP_EAPD] = "laptop-eapd",
1452 #ifdef CONFIG_SND_DEBUG
1453 [CXT5047_TEST] = "test",
1457 static struct snd_pci_quirk cxt5047_cfg_tbl[] = {
1458 SND_PCI_QUIRK(0x103c, 0x30a0, "HP DV1000", CXT5047_LAPTOP),
1459 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
1460 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV2000T/DV3000T", CXT5047_LAPTOP),
1461 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2000Z", CXT5047_LAPTOP),
1462 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD),
1466 static int patch_cxt5047(struct hda_codec *codec)
1468 struct conexant_spec *spec;
1471 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1476 spec->multiout.max_channels = 2;
1477 spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids);
1478 spec->multiout.dac_nids = cxt5047_dac_nids;
1479 spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT;
1480 spec->num_adc_nids = 1;
1481 spec->adc_nids = cxt5047_adc_nids;
1482 spec->capsrc_nids = cxt5047_capsrc_nids;
1483 spec->input_mux = &cxt5047_capture_source;
1484 spec->num_mixers = 1;
1485 spec->mixers[0] = cxt5047_mixers;
1486 spec->num_init_verbs = 1;
1487 spec->init_verbs[0] = cxt5047_init_verbs;
1488 spec->spdif_route = 0;
1489 spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes),
1490 spec->channel_mode = cxt5047_modes,
1492 codec->patch_ops = conexant_patch_ops;
1494 board_config = snd_hda_check_board_config(codec, CXT5047_MODELS,
1497 switch (board_config) {
1498 case CXT5047_LAPTOP:
1499 codec->patch_ops.unsol_event = cxt5047_hp2_unsol_event;
1501 case CXT5047_LAPTOP_HP:
1502 spec->input_mux = &cxt5047_hp_capture_source;
1503 spec->num_init_verbs = 2;
1504 spec->init_verbs[1] = cxt5047_hp_init_verbs;
1505 spec->mixers[0] = cxt5047_hp_mixers;
1506 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1507 codec->patch_ops.init = cxt5047_hp_init;
1509 case CXT5047_LAPTOP_EAPD:
1510 spec->input_mux = &cxt5047_toshiba_capture_source;
1511 spec->num_init_verbs = 2;
1512 spec->init_verbs[1] = cxt5047_toshiba_init_verbs;
1513 spec->mixers[0] = cxt5047_toshiba_mixers;
1514 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1516 #ifdef CONFIG_SND_DEBUG
1518 spec->input_mux = &cxt5047_test_capture_source;
1519 spec->mixers[0] = cxt5047_test_mixer;
1520 spec->init_verbs[0] = cxt5047_test_init_verbs;
1521 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1527 /* Conexant 5051 specific */
1528 static hda_nid_t cxt5051_dac_nids[1] = { 0x10 };
1529 static hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 };
1530 #define CXT5051_SPDIF_OUT 0x1C
1531 #define CXT5051_PORTB_EVENT 0x38
1532 #define CXT5051_PORTC_EVENT 0x39
1534 static struct hda_channel_mode cxt5051_modes[1] = {
1538 static void cxt5051_update_speaker(struct hda_codec *codec)
1540 struct conexant_spec *spec = codec->spec;
1541 unsigned int pinctl;
1542 pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0;
1543 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
1547 /* turn on/off EAPD (+ mute HP) as a master switch */
1548 static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1549 struct snd_ctl_elem_value *ucontrol)
1551 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1553 if (!cxt_eapd_put(kcontrol, ucontrol))
1555 cxt5051_update_speaker(codec);
1559 /* toggle input of built-in and mic jack appropriately */
1560 static void cxt5051_portb_automic(struct hda_codec *codec)
1562 unsigned int present;
1564 present = snd_hda_codec_read(codec, 0x17, 0,
1565 AC_VERB_GET_PIN_SENSE, 0) &
1566 AC_PINSENSE_PRESENCE;
1567 snd_hda_codec_write(codec, 0x14, 0,
1568 AC_VERB_SET_CONNECT_SEL,
1569 present ? 0x01 : 0x00);
1572 /* switch the current ADC according to the jack state */
1573 static void cxt5051_portc_automic(struct hda_codec *codec)
1575 struct conexant_spec *spec = codec->spec;
1576 unsigned int present;
1579 present = snd_hda_codec_read(codec, 0x18, 0,
1580 AC_VERB_GET_PIN_SENSE, 0) &
1581 AC_PINSENSE_PRESENCE;
1583 spec->cur_adc_idx = 1;
1585 spec->cur_adc_idx = 0;
1586 new_adc = spec->adc_nids[spec->cur_adc_idx];
1587 if (spec->cur_adc && spec->cur_adc != new_adc) {
1588 /* stream is running, let's swap the current ADC */
1589 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
1590 spec->cur_adc = new_adc;
1591 snd_hda_codec_setup_stream(codec, new_adc,
1592 spec->cur_adc_stream_tag, 0,
1593 spec->cur_adc_format);
1597 /* mute internal speaker if HP is plugged */
1598 static void cxt5051_hp_automute(struct hda_codec *codec)
1600 struct conexant_spec *spec = codec->spec;
1602 spec->hp_present = snd_hda_codec_read(codec, 0x16, 0,
1603 AC_VERB_GET_PIN_SENSE, 0) &
1604 AC_PINSENSE_PRESENCE;
1605 cxt5051_update_speaker(codec);
1608 /* unsolicited event for HP jack sensing */
1609 static void cxt5051_hp_unsol_event(struct hda_codec *codec,
1612 switch (res >> 26) {
1613 case CONEXANT_HP_EVENT:
1614 cxt5051_hp_automute(codec);
1616 case CXT5051_PORTB_EVENT:
1617 cxt5051_portb_automic(codec);
1619 case CXT5051_PORTC_EVENT:
1620 cxt5051_portc_automic(codec);
1625 static struct snd_kcontrol_new cxt5051_mixers[] = {
1626 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
1627 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
1628 HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT),
1629 HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT),
1630 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT),
1631 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT),
1632 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1634 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1635 .name = "Master Playback Switch",
1636 .info = cxt_eapd_info,
1637 .get = cxt_eapd_get,
1638 .put = cxt5051_hp_master_sw_put,
1639 .private_value = 0x1a,
1645 static struct snd_kcontrol_new cxt5051_hp_mixers[] = {
1646 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
1647 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
1648 HDA_CODEC_VOLUME("External Mic Volume", 0x15, 0x00, HDA_INPUT),
1649 HDA_CODEC_MUTE("External Mic Switch", 0x15, 0x00, HDA_INPUT),
1650 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1652 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1653 .name = "Master Playback Switch",
1654 .info = cxt_eapd_info,
1655 .get = cxt_eapd_get,
1656 .put = cxt5051_hp_master_sw_put,
1657 .private_value = 0x1a,
1663 static struct hda_verb cxt5051_init_verbs[] = {
1665 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1666 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1667 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1668 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1669 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1670 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1672 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1673 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1675 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1676 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
1678 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1679 /* Record selector: Int mic */
1680 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1681 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
1682 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1683 /* SPDIF route: PCM */
1684 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
1686 {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
1687 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1688 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT},
1689 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTC_EVENT},
1693 /* initialize jack-sensing, too */
1694 static int cxt5051_init(struct hda_codec *codec)
1696 conexant_init(codec);
1697 if (codec->patch_ops.unsol_event) {
1698 cxt5051_hp_automute(codec);
1699 cxt5051_portb_automic(codec);
1700 cxt5051_portc_automic(codec);
1707 CXT5051_LAPTOP, /* Laptops w/ EAPD support */
1708 CXT5051_HP, /* no docking */
1712 static const char *cxt5051_models[CXT5051_MODELS] = {
1713 [CXT5051_LAPTOP] = "laptop",
1714 [CXT5051_HP] = "hp",
1717 static struct snd_pci_quirk cxt5051_cfg_tbl[] = {
1718 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1720 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP),
1724 static int patch_cxt5051(struct hda_codec *codec)
1726 struct conexant_spec *spec;
1729 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1734 codec->patch_ops = conexant_patch_ops;
1735 codec->patch_ops.init = cxt5051_init;
1737 spec->multiout.max_channels = 2;
1738 spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids);
1739 spec->multiout.dac_nids = cxt5051_dac_nids;
1740 spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT;
1741 spec->num_adc_nids = 1; /* not 2; via auto-mic switch */
1742 spec->adc_nids = cxt5051_adc_nids;
1743 spec->num_mixers = 1;
1744 spec->mixers[0] = cxt5051_mixers;
1745 spec->num_init_verbs = 1;
1746 spec->init_verbs[0] = cxt5051_init_verbs;
1747 spec->spdif_route = 0;
1748 spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes);
1749 spec->channel_mode = cxt5051_modes;
1751 spec->cur_adc_idx = 0;
1753 board_config = snd_hda_check_board_config(codec, CXT5051_MODELS,
1756 switch (board_config) {
1758 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
1759 spec->mixers[0] = cxt5051_hp_mixers;
1762 case CXT5051_LAPTOP:
1763 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
1774 struct hda_codec_preset snd_hda_preset_conexant[] = {
1775 { .id = 0x14f15045, .name = "CX20549 (Venice)",
1776 .patch = patch_cxt5045 },
1777 { .id = 0x14f15047, .name = "CX20551 (Waikiki)",
1778 .patch = patch_cxt5047 },
1779 { .id = 0x14f15051, .name = "CX20561 (Hermosa)",
1780 .patch = patch_cxt5051 },