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 unsigned int num_kctl_alloc, num_kctl_used;
90 struct snd_kcontrol_new *kctl_alloc;
91 struct hda_input_mux private_imux;
92 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
96 static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo,
97 struct hda_codec *codec,
98 struct snd_pcm_substream *substream)
100 struct conexant_spec *spec = codec->spec;
101 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
105 static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
106 struct hda_codec *codec,
107 unsigned int stream_tag,
109 struct snd_pcm_substream *substream)
111 struct conexant_spec *spec = codec->spec;
112 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
117 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
118 struct hda_codec *codec,
119 struct snd_pcm_substream *substream)
121 struct conexant_spec *spec = codec->spec;
122 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
128 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
129 struct hda_codec *codec,
130 struct snd_pcm_substream *substream)
132 struct conexant_spec *spec = codec->spec;
133 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
136 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
137 struct hda_codec *codec,
138 struct snd_pcm_substream *substream)
140 struct conexant_spec *spec = codec->spec;
141 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
144 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
145 struct hda_codec *codec,
146 unsigned int stream_tag,
148 struct snd_pcm_substream *substream)
150 struct conexant_spec *spec = codec->spec;
151 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
159 static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
160 struct hda_codec *codec,
161 unsigned int stream_tag,
163 struct snd_pcm_substream *substream)
165 struct conexant_spec *spec = codec->spec;
166 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
167 stream_tag, 0, format);
171 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
172 struct hda_codec *codec,
173 struct snd_pcm_substream *substream)
175 struct conexant_spec *spec = codec->spec;
176 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
182 static struct hda_pcm_stream conexant_pcm_analog_playback = {
186 .nid = 0, /* fill later */
188 .open = conexant_playback_pcm_open,
189 .prepare = conexant_playback_pcm_prepare,
190 .cleanup = conexant_playback_pcm_cleanup
194 static struct hda_pcm_stream conexant_pcm_analog_capture = {
198 .nid = 0, /* fill later */
200 .prepare = conexant_capture_pcm_prepare,
201 .cleanup = conexant_capture_pcm_cleanup
206 static struct hda_pcm_stream conexant_pcm_digital_playback = {
210 .nid = 0, /* fill later */
212 .open = conexant_dig_playback_pcm_open,
213 .close = conexant_dig_playback_pcm_close,
214 .prepare = conexant_dig_playback_pcm_prepare
218 static struct hda_pcm_stream conexant_pcm_digital_capture = {
222 /* NID is set in alc_build_pcms */
225 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
226 struct hda_codec *codec,
227 unsigned int stream_tag,
229 struct snd_pcm_substream *substream)
231 struct conexant_spec *spec = codec->spec;
232 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
233 spec->cur_adc_stream_tag = stream_tag;
234 spec->cur_adc_format = format;
235 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
239 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
240 struct hda_codec *codec,
241 struct snd_pcm_substream *substream)
243 struct conexant_spec *spec = codec->spec;
244 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
249 static struct hda_pcm_stream cx5051_pcm_analog_capture = {
253 .nid = 0, /* fill later */
255 .prepare = cx5051_capture_pcm_prepare,
256 .cleanup = cx5051_capture_pcm_cleanup
260 static int conexant_build_pcms(struct hda_codec *codec)
262 struct conexant_spec *spec = codec->spec;
263 struct hda_pcm *info = spec->pcm_rec;
266 codec->pcm_info = info;
268 info->name = "CONEXANT Analog";
269 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback;
270 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max =
271 spec->multiout.max_channels;
272 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
273 spec->multiout.dac_nids[0];
274 if (codec->vendor_id == 0x14f15051)
275 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
276 cx5051_pcm_analog_capture;
278 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
279 conexant_pcm_analog_capture;
280 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
281 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
283 if (spec->multiout.dig_out_nid) {
286 info->name = "Conexant Digital";
287 info->pcm_type = HDA_PCM_TYPE_SPDIF;
288 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
289 conexant_pcm_digital_playback;
290 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
291 spec->multiout.dig_out_nid;
292 if (spec->dig_in_nid) {
293 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
294 conexant_pcm_digital_capture;
295 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
303 static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol,
304 struct snd_ctl_elem_info *uinfo)
306 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
307 struct conexant_spec *spec = codec->spec;
309 return snd_hda_input_mux_info(spec->input_mux, uinfo);
312 static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol,
313 struct snd_ctl_elem_value *ucontrol)
315 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
316 struct conexant_spec *spec = codec->spec;
317 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
319 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
323 static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol,
324 struct snd_ctl_elem_value *ucontrol)
326 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
327 struct conexant_spec *spec = codec->spec;
328 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
330 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
331 spec->capsrc_nids[adc_idx],
332 &spec->cur_mux[adc_idx]);
335 static int conexant_init(struct hda_codec *codec)
337 struct conexant_spec *spec = codec->spec;
340 for (i = 0; i < spec->num_init_verbs; i++)
341 snd_hda_sequence_write(codec, spec->init_verbs[i]);
345 static void conexant_free(struct hda_codec *codec)
347 struct conexant_spec *spec = codec->spec;
350 if (spec->kctl_alloc) {
351 for (i = 0; i < spec->num_kctl_used; i++)
352 kfree(spec->kctl_alloc[i].name);
353 kfree(spec->kctl_alloc);
359 static int conexant_build_controls(struct hda_codec *codec)
361 struct conexant_spec *spec = codec->spec;
365 for (i = 0; i < spec->num_mixers; i++) {
366 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
370 if (spec->multiout.dig_out_nid) {
371 err = snd_hda_create_spdif_out_ctls(codec,
372 spec->multiout.dig_out_nid);
375 err = snd_hda_create_spdif_share_sw(codec,
379 spec->multiout.share_spdif = 1;
381 if (spec->dig_in_nid) {
382 err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid);
389 static struct hda_codec_ops conexant_patch_ops = {
390 .build_controls = conexant_build_controls,
391 .build_pcms = conexant_build_pcms,
392 .init = conexant_init,
393 .free = conexant_free,
398 * the private value = nid | (invert << 8)
401 #define cxt_eapd_info snd_ctl_boolean_mono_info
403 static int cxt_eapd_get(struct snd_kcontrol *kcontrol,
404 struct snd_ctl_elem_value *ucontrol)
406 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
407 struct conexant_spec *spec = codec->spec;
408 int invert = (kcontrol->private_value >> 8) & 1;
410 ucontrol->value.integer.value[0] = !spec->cur_eapd;
412 ucontrol->value.integer.value[0] = spec->cur_eapd;
417 static int cxt_eapd_put(struct snd_kcontrol *kcontrol,
418 struct snd_ctl_elem_value *ucontrol)
420 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
421 struct conexant_spec *spec = codec->spec;
422 int invert = (kcontrol->private_value >> 8) & 1;
423 hda_nid_t nid = kcontrol->private_value & 0xff;
426 eapd = !!ucontrol->value.integer.value[0];
429 if (eapd == spec->cur_eapd)
432 spec->cur_eapd = eapd;
433 snd_hda_codec_write_cache(codec, nid,
434 0, AC_VERB_SET_EAPD_BTLENABLE,
439 /* controls for test mode */
440 #ifdef CONFIG_SND_DEBUG
442 #define CXT_EAPD_SWITCH(xname, nid, mask) \
443 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
444 .info = cxt_eapd_info, \
445 .get = cxt_eapd_get, \
446 .put = cxt_eapd_put, \
447 .private_value = nid | (mask<<16) }
451 static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol,
452 struct snd_ctl_elem_info *uinfo)
454 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
455 struct conexant_spec *spec = codec->spec;
456 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
457 spec->num_channel_mode);
460 static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol,
461 struct snd_ctl_elem_value *ucontrol)
463 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
464 struct conexant_spec *spec = codec->spec;
465 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
466 spec->num_channel_mode,
467 spec->multiout.max_channels);
470 static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol,
471 struct snd_ctl_elem_value *ucontrol)
473 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
474 struct conexant_spec *spec = codec->spec;
475 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
476 spec->num_channel_mode,
477 &spec->multiout.max_channels);
478 if (err >= 0 && spec->need_dac_fix)
479 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
483 #define CXT_PIN_MODE(xname, nid, dir) \
484 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
485 .info = conexant_ch_mode_info, \
486 .get = conexant_ch_mode_get, \
487 .put = conexant_ch_mode_put, \
488 .private_value = nid | (dir<<16) }
490 #endif /* CONFIG_SND_DEBUG */
492 /* Conexant 5045 specific */
494 static hda_nid_t cxt5045_dac_nids[1] = { 0x19 };
495 static hda_nid_t cxt5045_adc_nids[1] = { 0x1a };
496 static hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a };
497 #define CXT5045_SPDIF_OUT 0x18
499 static struct hda_channel_mode cxt5045_modes[1] = {
503 static struct hda_input_mux cxt5045_capture_source = {
511 static struct hda_input_mux cxt5045_capture_source_benq = {
520 static struct hda_input_mux cxt5045_capture_source_hp530 = {
528 /* turn on/off EAPD (+ mute HP) as a master switch */
529 static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
530 struct snd_ctl_elem_value *ucontrol)
532 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
533 struct conexant_spec *spec = codec->spec;
536 if (!cxt_eapd_put(kcontrol, ucontrol))
539 /* toggle internal speakers mute depending of presence of
542 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
543 snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
546 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
547 snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0,
552 /* bind volumes of both NID 0x10 and 0x11 */
553 static struct hda_bind_ctls cxt5045_hp_bind_master_vol = {
554 .ops = &snd_hda_bind_vol,
556 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT),
557 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
562 /* toggle input of built-in and mic jack appropriately */
563 static void cxt5045_hp_automic(struct hda_codec *codec)
565 static struct hda_verb mic_jack_on[] = {
566 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
567 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
570 static struct hda_verb mic_jack_off[] = {
571 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
572 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
575 unsigned int present;
577 present = snd_hda_codec_read(codec, 0x12, 0,
578 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
580 snd_hda_sequence_write(codec, mic_jack_on);
582 snd_hda_sequence_write(codec, mic_jack_off);
586 /* mute internal speaker if HP is plugged */
587 static void cxt5045_hp_automute(struct hda_codec *codec)
589 struct conexant_spec *spec = codec->spec;
592 spec->hp_present = snd_hda_codec_read(codec, 0x11, 0,
593 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
595 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
596 snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
600 /* unsolicited event for HP jack sensing */
601 static void cxt5045_hp_unsol_event(struct hda_codec *codec,
606 case CONEXANT_HP_EVENT:
607 cxt5045_hp_automute(codec);
609 case CONEXANT_MIC_EVENT:
610 cxt5045_hp_automic(codec);
616 static struct snd_kcontrol_new cxt5045_mixers[] = {
618 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
619 .name = "Capture Source",
620 .info = conexant_mux_enum_info,
621 .get = conexant_mux_enum_get,
622 .put = conexant_mux_enum_put
624 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
625 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
626 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
627 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
628 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
629 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
630 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
631 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
632 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
633 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
634 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
636 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
637 .name = "Master Playback Switch",
638 .info = cxt_eapd_info,
640 .put = cxt5045_hp_master_sw_put,
641 .private_value = 0x10,
647 static struct snd_kcontrol_new cxt5045_benq_mixers[] = {
648 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT),
649 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT),
650 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT),
651 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT),
656 static struct snd_kcontrol_new cxt5045_mixers_hp530[] = {
658 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
659 .name = "Capture Source",
660 .info = conexant_mux_enum_info,
661 .get = conexant_mux_enum_get,
662 .put = conexant_mux_enum_put
664 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
665 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
666 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
667 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
668 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
669 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
670 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
671 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
672 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
673 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
674 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
676 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
677 .name = "Master Playback Switch",
678 .info = cxt_eapd_info,
680 .put = cxt5045_hp_master_sw_put,
681 .private_value = 0x10,
687 static struct hda_verb cxt5045_init_verbs[] = {
689 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
692 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
693 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
694 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
695 {0x11, AC_VERB_SET_CONNECT_SEL, 0x1},
696 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
697 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
698 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
699 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
700 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
701 /* Record selector: Int mic */
702 {0x1a, AC_VERB_SET_CONNECT_SEL,0x1},
703 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
704 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
705 /* SPDIF route: PCM */
706 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
707 { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
709 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */
713 static struct hda_verb cxt5045_benq_init_verbs[] = {
715 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
716 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
717 /* Line In,HP, Amp */
718 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
719 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
720 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
721 {0x11, AC_VERB_SET_CONNECT_SEL, 0x1},
722 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
723 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
724 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
725 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
726 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
727 /* Record selector: Int mic */
728 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x1},
729 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
730 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
731 /* SPDIF route: PCM */
732 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
733 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
735 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
739 static struct hda_verb cxt5045_hp_sense_init_verbs[] = {
740 /* pin sensing on HP jack */
741 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
745 static struct hda_verb cxt5045_mic_sense_init_verbs[] = {
746 /* pin sensing on HP jack */
747 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
751 #ifdef CONFIG_SND_DEBUG
752 /* Test configuration for debugging, modelled after the ALC260 test
755 static struct hda_input_mux cxt5045_test_capture_source = {
760 { "LINE1 pin", 0x2 },
761 { "HP-OUT pin", 0x3 },
766 static struct snd_kcontrol_new cxt5045_test_mixer[] = {
768 /* Output controls */
769 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
770 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
771 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT),
772 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT),
773 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT),
774 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT),
776 /* Modes for retasking pin widgets */
777 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
778 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT),
780 /* EAPD Switch Control */
781 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
783 /* Loopback mixer controls */
785 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT),
786 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT),
787 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT),
788 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT),
789 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT),
790 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT),
791 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT),
792 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT),
793 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT),
794 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT),
796 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
797 .name = "Input Source",
798 .info = conexant_mux_enum_info,
799 .get = conexant_mux_enum_get,
800 .put = conexant_mux_enum_put,
802 /* Audio input controls */
803 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),
804 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),
805 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
806 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
807 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
808 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
809 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
810 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
811 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
812 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
816 static struct hda_verb cxt5045_test_init_verbs[] = {
817 /* Set connections */
818 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
819 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 },
820 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 },
821 /* Enable retasking pins as output, initially without power amp */
822 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
823 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
825 /* Disable digital (SPDIF) pins initially, but users can enable
826 * them via a mixer switch. In the case of SPDIF-out, this initverb
827 * payload also sets the generation to 0, output to be in "consumer"
828 * PCM format, copyright asserted, no pre-emphasis and no validity
831 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
832 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
834 /* Start with output sum widgets muted and their output gains at min */
835 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
836 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
838 /* Unmute retasking pin widget output buffers since the default
839 * state appears to be output. As the pin mode is changed by the
840 * user the pin mode control will take care of enabling the pin's
841 * input/output buffers as needed.
843 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
844 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
846 /* Mute capture amp left and right */
847 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
849 /* Set ADC connection select to match default mixer setting (mic1
852 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
853 {0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
855 /* Mute all inputs to mixer widget (even unconnected ones) */
856 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */
857 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */
858 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */
859 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */
860 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
867 /* initialize jack-sensing, too */
868 static int cxt5045_init(struct hda_codec *codec)
870 conexant_init(codec);
871 cxt5045_hp_automute(codec);
877 CXT5045_LAPTOP_HPSENSE,
878 CXT5045_LAPTOP_MICSENSE,
879 CXT5045_LAPTOP_HPMICSENSE,
881 CXT5045_LAPTOP_HP530,
882 #ifdef CONFIG_SND_DEBUG
888 static const char *cxt5045_models[CXT5045_MODELS] = {
889 [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense",
890 [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense",
891 [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense",
892 [CXT5045_BENQ] = "benq",
893 [CXT5045_LAPTOP_HP530] = "laptop-hp530",
894 #ifdef CONFIG_SND_DEBUG
895 [CXT5045_TEST] = "test",
899 static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
900 SND_PCI_QUIRK(0x103c, 0x30a5, "HP", CXT5045_LAPTOP_HPSENSE),
901 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
902 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2120", CXT5045_LAPTOP_HPSENSE),
903 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP_HPSENSE),
904 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP_HPSENSE),
905 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
906 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV9533EG", CXT5045_LAPTOP_HPSENSE),
907 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530),
908 SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP_HPSENSE),
909 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ),
910 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE),
911 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE),
912 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505", CXT5045_LAPTOP_HPSENSE),
913 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE),
914 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE),
915 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE),
916 SND_PCI_QUIRK(0x1631, 0xc106, "Packard Bell", CXT5045_LAPTOP_HPMICSENSE),
917 SND_PCI_QUIRK(0x1631, 0xc107, "Packard Bell", CXT5045_LAPTOP_HPMICSENSE),
918 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE),
922 static int patch_cxt5045(struct hda_codec *codec)
924 struct conexant_spec *spec;
927 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
932 spec->multiout.max_channels = 2;
933 spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids);
934 spec->multiout.dac_nids = cxt5045_dac_nids;
935 spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT;
936 spec->num_adc_nids = 1;
937 spec->adc_nids = cxt5045_adc_nids;
938 spec->capsrc_nids = cxt5045_capsrc_nids;
939 spec->input_mux = &cxt5045_capture_source;
940 spec->num_mixers = 1;
941 spec->mixers[0] = cxt5045_mixers;
942 spec->num_init_verbs = 1;
943 spec->init_verbs[0] = cxt5045_init_verbs;
944 spec->spdif_route = 0;
945 spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes),
946 spec->channel_mode = cxt5045_modes,
949 codec->patch_ops = conexant_patch_ops;
951 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
954 switch (board_config) {
955 case CXT5045_LAPTOP_HPSENSE:
956 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
957 spec->input_mux = &cxt5045_capture_source;
958 spec->num_init_verbs = 2;
959 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
960 spec->mixers[0] = cxt5045_mixers;
961 codec->patch_ops.init = cxt5045_init;
963 case CXT5045_LAPTOP_MICSENSE:
964 spec->input_mux = &cxt5045_capture_source;
965 spec->num_init_verbs = 2;
966 spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;
967 spec->mixers[0] = cxt5045_mixers;
968 codec->patch_ops.init = cxt5045_init;
971 case CXT5045_LAPTOP_HPMICSENSE:
972 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
973 spec->input_mux = &cxt5045_capture_source;
974 spec->num_init_verbs = 3;
975 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
976 spec->init_verbs[2] = cxt5045_mic_sense_init_verbs;
977 spec->mixers[0] = cxt5045_mixers;
978 codec->patch_ops.init = cxt5045_init;
981 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
982 spec->input_mux = &cxt5045_capture_source_benq;
983 spec->num_init_verbs = 1;
984 spec->init_verbs[0] = cxt5045_benq_init_verbs;
985 spec->mixers[0] = cxt5045_mixers;
986 spec->mixers[1] = cxt5045_benq_mixers;
987 spec->num_mixers = 2;
988 codec->patch_ops.init = cxt5045_init;
990 case CXT5045_LAPTOP_HP530:
991 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
992 spec->input_mux = &cxt5045_capture_source_hp530;
993 spec->num_init_verbs = 2;
994 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
995 spec->mixers[0] = cxt5045_mixers_hp530;
996 codec->patch_ops.init = cxt5045_init;
998 #ifdef CONFIG_SND_DEBUG
1000 spec->input_mux = &cxt5045_test_capture_source;
1001 spec->mixers[0] = cxt5045_test_mixer;
1002 spec->init_verbs[0] = cxt5045_test_init_verbs;
1008 switch (codec->subsystem_id >> 16) {
1010 /* HP laptop has a really bad sound over 0dB on NID 0x17.
1011 * Fix max PCM level to 0 dB
1012 * (originall it has 0x2b steps with 0dB offset 0x14)
1014 snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT,
1015 (0x14 << AC_AMPCAP_OFFSET_SHIFT) |
1016 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) |
1017 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
1018 (1 << AC_AMPCAP_MUTE_SHIFT));
1026 /* Conexant 5047 specific */
1027 #define CXT5047_SPDIF_OUT 0x11
1029 static hda_nid_t cxt5047_dac_nids[2] = { 0x10, 0x1c };
1030 static hda_nid_t cxt5047_adc_nids[1] = { 0x12 };
1031 static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a };
1033 static struct hda_channel_mode cxt5047_modes[1] = {
1037 static struct hda_input_mux cxt5047_capture_source = {
1044 static struct hda_input_mux cxt5047_hp_capture_source = {
1051 static struct hda_input_mux cxt5047_toshiba_capture_source = {
1059 /* turn on/off EAPD (+ mute HP) as a master switch */
1060 static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1061 struct snd_ctl_elem_value *ucontrol)
1063 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1064 struct conexant_spec *spec = codec->spec;
1067 if (!cxt_eapd_put(kcontrol, ucontrol))
1070 /* toggle internal speakers mute depending of presence of
1071 * the headphone jack
1073 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
1074 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
1075 HDA_AMP_MUTE, bits);
1076 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
1077 snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0,
1078 HDA_AMP_MUTE, bits);
1082 /* bind volumes of both NID 0x13 (Headphones) and 0x1d (Speakers) */
1083 static struct hda_bind_ctls cxt5047_bind_master_vol = {
1084 .ops = &snd_hda_bind_vol,
1086 HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
1087 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
1092 /* mute internal speaker if HP is plugged */
1093 static void cxt5047_hp_automute(struct hda_codec *codec)
1095 struct conexant_spec *spec = codec->spec;
1098 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
1099 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1101 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
1102 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
1103 HDA_AMP_MUTE, bits);
1104 /* Mute/Unmute PCM 2 for good measure - some systems need this */
1105 snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
1106 HDA_AMP_MUTE, bits);
1109 /* mute internal speaker if HP is plugged */
1110 static void cxt5047_hp2_automute(struct hda_codec *codec)
1112 struct conexant_spec *spec = codec->spec;
1115 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
1116 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1118 bits = spec->hp_present ? HDA_AMP_MUTE : 0;
1119 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
1120 HDA_AMP_MUTE, bits);
1121 /* Mute/Unmute PCM 2 for good measure - some systems need this */
1122 snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
1123 HDA_AMP_MUTE, bits);
1126 /* toggle input of built-in and mic jack appropriately */
1127 static void cxt5047_hp_automic(struct hda_codec *codec)
1129 static struct hda_verb mic_jack_on[] = {
1130 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1131 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1134 static struct hda_verb mic_jack_off[] = {
1135 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1136 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1139 unsigned int present;
1141 present = snd_hda_codec_read(codec, 0x15, 0,
1142 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1144 snd_hda_sequence_write(codec, mic_jack_on);
1146 snd_hda_sequence_write(codec, mic_jack_off);
1149 /* unsolicited event for HP jack sensing */
1150 static void cxt5047_hp_unsol_event(struct hda_codec *codec,
1153 switch (res >> 26) {
1154 case CONEXANT_HP_EVENT:
1155 cxt5047_hp_automute(codec);
1157 case CONEXANT_MIC_EVENT:
1158 cxt5047_hp_automic(codec);
1163 /* unsolicited event for HP jack sensing - non-EAPD systems */
1164 static void cxt5047_hp2_unsol_event(struct hda_codec *codec,
1169 case CONEXANT_HP_EVENT:
1170 cxt5047_hp2_automute(codec);
1172 case CONEXANT_MIC_EVENT:
1173 cxt5047_hp_automic(codec);
1178 static struct snd_kcontrol_new cxt5047_mixers[] = {
1179 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1180 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1181 HDA_CODEC_VOLUME("Mic Gain Volume", 0x1a, 0x0, HDA_OUTPUT),
1182 HDA_CODEC_MUTE("Mic Gain Switch", 0x1a, 0x0, HDA_OUTPUT),
1183 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1184 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1185 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1186 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1187 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT),
1188 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT),
1189 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x00, HDA_OUTPUT),
1190 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x00, HDA_OUTPUT),
1191 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1192 HDA_CODEC_MUTE("Headphone Playback Switch", 0x13, 0x00, HDA_OUTPUT),
1197 static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = {
1199 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1200 .name = "Capture Source",
1201 .info = conexant_mux_enum_info,
1202 .get = conexant_mux_enum_get,
1203 .put = conexant_mux_enum_put
1205 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1206 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1207 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1208 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1209 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1210 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1211 HDA_BIND_VOL("Master Playback Volume", &cxt5047_bind_master_vol),
1213 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1214 .name = "Master Playback Switch",
1215 .info = cxt_eapd_info,
1216 .get = cxt_eapd_get,
1217 .put = cxt5047_hp_master_sw_put,
1218 .private_value = 0x13,
1224 static struct snd_kcontrol_new cxt5047_hp_mixers[] = {
1226 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1227 .name = "Capture Source",
1228 .info = conexant_mux_enum_info,
1229 .get = conexant_mux_enum_get,
1230 .put = conexant_mux_enum_put
1232 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1233 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19,0x02,HDA_INPUT),
1234 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1235 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1236 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1237 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1238 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1240 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1241 .name = "Master Playback Switch",
1242 .info = cxt_eapd_info,
1243 .get = cxt_eapd_get,
1244 .put = cxt5047_hp_master_sw_put,
1245 .private_value = 0x13,
1250 static struct hda_verb cxt5047_init_verbs[] = {
1251 /* Line in, Mic, Built-in Mic */
1252 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1253 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1254 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1256 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1257 {0x13, AC_VERB_SET_CONNECT_SEL,0x1},
1258 {0x1d, AC_VERB_SET_CONNECT_SEL,0x0},
1259 /* Record selector: Mic */
1260 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1261 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1262 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1263 {0x1A, AC_VERB_SET_CONNECT_SEL,0x02},
1264 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1265 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1266 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1267 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
1268 /* SPDIF route: PCM */
1269 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
1270 /* Enable unsolicited events */
1271 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1272 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1276 /* configuration for Toshiba Laptops */
1277 static struct hda_verb cxt5047_toshiba_init_verbs[] = {
1278 {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0 }, /* default on */
1279 /* pin sensing on HP and Mic jacks */
1280 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1281 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1282 /* Speaker routing */
1283 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1287 /* configuration for HP Laptops */
1288 static struct hda_verb cxt5047_hp_init_verbs[] = {
1289 /* pin sensing on HP jack */
1290 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1291 /* 0x13 is actually shared by both HP and speaker;
1292 * setting the connection to 0 (=0x19) makes the master volume control
1293 * working mysteriouslly...
1295 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1296 /* Record selector: Ext Mic */
1297 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1298 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1299 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1300 /* Speaker routing */
1301 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1305 /* Test configuration for debugging, modelled after the ALC260 test
1308 #ifdef CONFIG_SND_DEBUG
1309 static struct hda_input_mux cxt5047_test_capture_source = {
1312 { "LINE1 pin", 0x0 },
1313 { "MIC1 pin", 0x1 },
1314 { "MIC2 pin", 0x2 },
1319 static struct snd_kcontrol_new cxt5047_test_mixer[] = {
1321 /* Output only controls */
1322 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT),
1323 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT),
1324 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT),
1325 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT),
1326 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1327 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1328 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1329 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1330 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT),
1331 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1332 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT),
1333 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT),
1335 /* Modes for retasking pin widgets */
1336 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT),
1337 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT),
1339 /* EAPD Switch Control */
1340 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1342 /* Loopback mixer controls */
1343 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT),
1344 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT),
1345 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT),
1346 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT),
1347 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT),
1348 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT),
1349 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT),
1350 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT),
1352 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT),
1353 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT),
1354 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT),
1355 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT),
1356 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT),
1357 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT),
1358 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT),
1359 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT),
1361 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1362 .name = "Input Source",
1363 .info = conexant_mux_enum_info,
1364 .get = conexant_mux_enum_get,
1365 .put = conexant_mux_enum_put,
1367 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),
1368 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),
1369 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
1370 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
1371 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
1372 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
1373 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
1374 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
1375 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
1376 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
1381 static struct hda_verb cxt5047_test_init_verbs[] = {
1382 /* Enable retasking pins as output, initially without power amp */
1383 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1384 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1385 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1387 /* Disable digital (SPDIF) pins initially, but users can enable
1388 * them via a mixer switch. In the case of SPDIF-out, this initverb
1389 * payload also sets the generation to 0, output to be in "consumer"
1390 * PCM format, copyright asserted, no pre-emphasis and no validity
1393 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
1395 /* Ensure mic1, mic2, line1 pin widgets take input from the
1396 * OUT1 sum bus when acting as an output.
1398 {0x1a, AC_VERB_SET_CONNECT_SEL, 0},
1399 {0x1b, AC_VERB_SET_CONNECT_SEL, 0},
1401 /* Start with output sum widgets muted and their output gains at min */
1402 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1403 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1405 /* Unmute retasking pin widget output buffers since the default
1406 * state appears to be output. As the pin mode is changed by the
1407 * user the pin mode control will take care of enabling the pin's
1408 * input/output buffers as needed.
1410 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1411 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1412 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1414 /* Mute capture amp left and right */
1415 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1417 /* Set ADC connection select to match default mixer setting (mic1
1420 {0x12, AC_VERB_SET_CONNECT_SEL, 0x00},
1422 /* Mute all inputs to mixer widget (even unconnected ones) */
1423 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
1424 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
1425 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
1426 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
1427 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
1428 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1429 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
1430 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
1437 /* initialize jack-sensing, too */
1438 static int cxt5047_hp_init(struct hda_codec *codec)
1440 conexant_init(codec);
1441 cxt5047_hp_automute(codec);
1447 CXT5047_LAPTOP, /* Laptops w/o EAPD support */
1448 CXT5047_LAPTOP_HP, /* Some HP laptops */
1449 CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */
1450 #ifdef CONFIG_SND_DEBUG
1456 static const char *cxt5047_models[CXT5047_MODELS] = {
1457 [CXT5047_LAPTOP] = "laptop",
1458 [CXT5047_LAPTOP_HP] = "laptop-hp",
1459 [CXT5047_LAPTOP_EAPD] = "laptop-eapd",
1460 #ifdef CONFIG_SND_DEBUG
1461 [CXT5047_TEST] = "test",
1465 static struct snd_pci_quirk cxt5047_cfg_tbl[] = {
1466 SND_PCI_QUIRK(0x103c, 0x30a0, "HP DV1000", CXT5047_LAPTOP),
1467 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
1468 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV2000T/DV3000T", CXT5047_LAPTOP),
1469 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2000Z", CXT5047_LAPTOP),
1470 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD),
1474 static int patch_cxt5047(struct hda_codec *codec)
1476 struct conexant_spec *spec;
1479 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1484 spec->multiout.max_channels = 2;
1485 spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids);
1486 spec->multiout.dac_nids = cxt5047_dac_nids;
1487 spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT;
1488 spec->num_adc_nids = 1;
1489 spec->adc_nids = cxt5047_adc_nids;
1490 spec->capsrc_nids = cxt5047_capsrc_nids;
1491 spec->input_mux = &cxt5047_capture_source;
1492 spec->num_mixers = 1;
1493 spec->mixers[0] = cxt5047_mixers;
1494 spec->num_init_verbs = 1;
1495 spec->init_verbs[0] = cxt5047_init_verbs;
1496 spec->spdif_route = 0;
1497 spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes),
1498 spec->channel_mode = cxt5047_modes,
1500 codec->patch_ops = conexant_patch_ops;
1502 board_config = snd_hda_check_board_config(codec, CXT5047_MODELS,
1505 switch (board_config) {
1506 case CXT5047_LAPTOP:
1507 codec->patch_ops.unsol_event = cxt5047_hp2_unsol_event;
1509 case CXT5047_LAPTOP_HP:
1510 spec->input_mux = &cxt5047_hp_capture_source;
1511 spec->num_init_verbs = 2;
1512 spec->init_verbs[1] = cxt5047_hp_init_verbs;
1513 spec->mixers[0] = cxt5047_hp_mixers;
1514 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1515 codec->patch_ops.init = cxt5047_hp_init;
1517 case CXT5047_LAPTOP_EAPD:
1518 spec->input_mux = &cxt5047_toshiba_capture_source;
1519 spec->num_init_verbs = 2;
1520 spec->init_verbs[1] = cxt5047_toshiba_init_verbs;
1521 spec->mixers[0] = cxt5047_toshiba_mixers;
1522 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1524 #ifdef CONFIG_SND_DEBUG
1526 spec->input_mux = &cxt5047_test_capture_source;
1527 spec->mixers[0] = cxt5047_test_mixer;
1528 spec->init_verbs[0] = cxt5047_test_init_verbs;
1529 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1535 /* Conexant 5051 specific */
1536 static hda_nid_t cxt5051_dac_nids[1] = { 0x10 };
1537 static hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 };
1538 #define CXT5051_SPDIF_OUT 0x1C
1539 #define CXT5051_PORTB_EVENT 0x38
1540 #define CXT5051_PORTC_EVENT 0x39
1542 static struct hda_channel_mode cxt5051_modes[1] = {
1546 static void cxt5051_update_speaker(struct hda_codec *codec)
1548 struct conexant_spec *spec = codec->spec;
1549 unsigned int pinctl;
1550 pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0;
1551 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
1555 /* turn on/off EAPD (+ mute HP) as a master switch */
1556 static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1557 struct snd_ctl_elem_value *ucontrol)
1559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1561 if (!cxt_eapd_put(kcontrol, ucontrol))
1563 cxt5051_update_speaker(codec);
1567 /* toggle input of built-in and mic jack appropriately */
1568 static void cxt5051_portb_automic(struct hda_codec *codec)
1570 unsigned int present;
1572 present = snd_hda_codec_read(codec, 0x17, 0,
1573 AC_VERB_GET_PIN_SENSE, 0) &
1574 AC_PINSENSE_PRESENCE;
1575 snd_hda_codec_write(codec, 0x14, 0,
1576 AC_VERB_SET_CONNECT_SEL,
1577 present ? 0x01 : 0x00);
1580 /* switch the current ADC according to the jack state */
1581 static void cxt5051_portc_automic(struct hda_codec *codec)
1583 struct conexant_spec *spec = codec->spec;
1584 unsigned int present;
1587 present = snd_hda_codec_read(codec, 0x18, 0,
1588 AC_VERB_GET_PIN_SENSE, 0) &
1589 AC_PINSENSE_PRESENCE;
1591 spec->cur_adc_idx = 1;
1593 spec->cur_adc_idx = 0;
1594 new_adc = spec->adc_nids[spec->cur_adc_idx];
1595 if (spec->cur_adc && spec->cur_adc != new_adc) {
1596 /* stream is running, let's swap the current ADC */
1597 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
1598 spec->cur_adc = new_adc;
1599 snd_hda_codec_setup_stream(codec, new_adc,
1600 spec->cur_adc_stream_tag, 0,
1601 spec->cur_adc_format);
1605 /* mute internal speaker if HP is plugged */
1606 static void cxt5051_hp_automute(struct hda_codec *codec)
1608 struct conexant_spec *spec = codec->spec;
1610 spec->hp_present = snd_hda_codec_read(codec, 0x16, 0,
1611 AC_VERB_GET_PIN_SENSE, 0) &
1612 AC_PINSENSE_PRESENCE;
1613 cxt5051_update_speaker(codec);
1616 /* unsolicited event for HP jack sensing */
1617 static void cxt5051_hp_unsol_event(struct hda_codec *codec,
1620 switch (res >> 26) {
1621 case CONEXANT_HP_EVENT:
1622 cxt5051_hp_automute(codec);
1624 case CXT5051_PORTB_EVENT:
1625 cxt5051_portb_automic(codec);
1627 case CXT5051_PORTC_EVENT:
1628 cxt5051_portc_automic(codec);
1633 static struct snd_kcontrol_new cxt5051_mixers[] = {
1634 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
1635 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
1636 HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT),
1637 HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT),
1638 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT),
1639 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT),
1640 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1642 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1643 .name = "Master Playback Switch",
1644 .info = cxt_eapd_info,
1645 .get = cxt_eapd_get,
1646 .put = cxt5051_hp_master_sw_put,
1647 .private_value = 0x1a,
1653 static struct snd_kcontrol_new cxt5051_hp_mixers[] = {
1654 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
1655 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
1656 HDA_CODEC_VOLUME("External Mic Volume", 0x15, 0x00, HDA_INPUT),
1657 HDA_CODEC_MUTE("External Mic Switch", 0x15, 0x00, HDA_INPUT),
1658 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1660 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1661 .name = "Master Playback Switch",
1662 .info = cxt_eapd_info,
1663 .get = cxt_eapd_get,
1664 .put = cxt5051_hp_master_sw_put,
1665 .private_value = 0x1a,
1671 static struct hda_verb cxt5051_init_verbs[] = {
1673 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1674 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1675 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1676 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1677 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1678 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1680 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1681 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1683 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1684 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
1686 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1687 /* Record selector: Int mic */
1688 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1689 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
1690 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1691 /* SPDIF route: PCM */
1692 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
1694 {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
1695 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1696 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT},
1697 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTC_EVENT},
1701 /* initialize jack-sensing, too */
1702 static int cxt5051_init(struct hda_codec *codec)
1704 conexant_init(codec);
1705 if (codec->patch_ops.unsol_event) {
1706 cxt5051_hp_automute(codec);
1707 cxt5051_portb_automic(codec);
1708 cxt5051_portc_automic(codec);
1715 CXT5051_LAPTOP, /* Laptops w/ EAPD support */
1716 CXT5051_HP, /* no docking */
1720 static const char *cxt5051_models[CXT5051_MODELS] = {
1721 [CXT5051_LAPTOP] = "laptop",
1722 [CXT5051_HP] = "hp",
1725 static struct snd_pci_quirk cxt5051_cfg_tbl[] = {
1726 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1728 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP),
1732 static int patch_cxt5051(struct hda_codec *codec)
1734 struct conexant_spec *spec;
1737 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1742 codec->patch_ops = conexant_patch_ops;
1743 codec->patch_ops.init = cxt5051_init;
1745 spec->multiout.max_channels = 2;
1746 spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids);
1747 spec->multiout.dac_nids = cxt5051_dac_nids;
1748 spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT;
1749 spec->num_adc_nids = 1; /* not 2; via auto-mic switch */
1750 spec->adc_nids = cxt5051_adc_nids;
1751 spec->num_mixers = 1;
1752 spec->mixers[0] = cxt5051_mixers;
1753 spec->num_init_verbs = 1;
1754 spec->init_verbs[0] = cxt5051_init_verbs;
1755 spec->spdif_route = 0;
1756 spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes);
1757 spec->channel_mode = cxt5051_modes;
1759 spec->cur_adc_idx = 0;
1761 board_config = snd_hda_check_board_config(codec, CXT5051_MODELS,
1764 switch (board_config) {
1766 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
1767 spec->mixers[0] = cxt5051_hp_mixers;
1770 case CXT5051_LAPTOP:
1771 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
1782 struct hda_codec_preset snd_hda_preset_conexant[] = {
1783 { .id = 0x14f15045, .name = "CX20549 (Venice)",
1784 .patch = patch_cxt5045 },
1785 { .id = 0x14f15047, .name = "CX20551 (Waikiki)",
1786 .patch = patch_cxt5047 },
1787 { .id = 0x14f15051, .name = "CX20561 (Hermosa)",
1788 .patch = patch_cxt5051 },