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 struct mutex amp_mutex; /* PCM volume/mute control mutex */
86 unsigned int spdif_route;
88 /* dynamic controls, init_verbs and input_mux */
89 struct auto_pin_cfg autocfg;
90 unsigned int num_kctl_alloc, num_kctl_used;
91 struct snd_kcontrol_new *kctl_alloc;
92 struct hda_input_mux private_imux;
93 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
97 static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo,
98 struct hda_codec *codec,
99 struct snd_pcm_substream *substream)
101 struct conexant_spec *spec = codec->spec;
102 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
106 static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
107 struct hda_codec *codec,
108 unsigned int stream_tag,
110 struct snd_pcm_substream *substream)
112 struct conexant_spec *spec = codec->spec;
113 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
118 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
119 struct hda_codec *codec,
120 struct snd_pcm_substream *substream)
122 struct conexant_spec *spec = codec->spec;
123 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
129 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
130 struct hda_codec *codec,
131 struct snd_pcm_substream *substream)
133 struct conexant_spec *spec = codec->spec;
134 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
137 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
138 struct hda_codec *codec,
139 struct snd_pcm_substream *substream)
141 struct conexant_spec *spec = codec->spec;
142 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
145 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
146 struct hda_codec *codec,
147 unsigned int stream_tag,
149 struct snd_pcm_substream *substream)
151 struct conexant_spec *spec = codec->spec;
152 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
160 static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
161 struct hda_codec *codec,
162 unsigned int stream_tag,
164 struct snd_pcm_substream *substream)
166 struct conexant_spec *spec = codec->spec;
167 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
168 stream_tag, 0, format);
172 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
173 struct hda_codec *codec,
174 struct snd_pcm_substream *substream)
176 struct conexant_spec *spec = codec->spec;
177 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
184 static struct hda_pcm_stream conexant_pcm_analog_playback = {
188 .nid = 0, /* fill later */
190 .open = conexant_playback_pcm_open,
191 .prepare = conexant_playback_pcm_prepare,
192 .cleanup = conexant_playback_pcm_cleanup
196 static struct hda_pcm_stream conexant_pcm_analog_capture = {
200 .nid = 0, /* fill later */
202 .prepare = conexant_capture_pcm_prepare,
203 .cleanup = conexant_capture_pcm_cleanup
208 static struct hda_pcm_stream conexant_pcm_digital_playback = {
212 .nid = 0, /* fill later */
214 .open = conexant_dig_playback_pcm_open,
215 .close = conexant_dig_playback_pcm_close,
216 .prepare = conexant_dig_playback_pcm_prepare
220 static struct hda_pcm_stream conexant_pcm_digital_capture = {
224 /* NID is set in alc_build_pcms */
227 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
228 struct hda_codec *codec,
229 unsigned int stream_tag,
231 struct snd_pcm_substream *substream)
233 struct conexant_spec *spec = codec->spec;
234 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
235 spec->cur_adc_stream_tag = stream_tag;
236 spec->cur_adc_format = format;
237 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
241 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
242 struct hda_codec *codec,
243 struct snd_pcm_substream *substream)
245 struct conexant_spec *spec = codec->spec;
246 snd_hda_codec_setup_stream(codec, spec->cur_adc, 0, 0, 0);
251 static struct hda_pcm_stream cx5051_pcm_analog_capture = {
255 .nid = 0, /* fill later */
257 .prepare = cx5051_capture_pcm_prepare,
258 .cleanup = cx5051_capture_pcm_cleanup
262 static int conexant_build_pcms(struct hda_codec *codec)
264 struct conexant_spec *spec = codec->spec;
265 struct hda_pcm *info = spec->pcm_rec;
268 codec->pcm_info = info;
270 info->name = "CONEXANT Analog";
271 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback;
272 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max =
273 spec->multiout.max_channels;
274 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
275 spec->multiout.dac_nids[0];
276 if (codec->vendor_id == 0x14f15051)
277 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
278 cx5051_pcm_analog_capture;
280 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
281 conexant_pcm_analog_capture;
282 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
283 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
285 if (spec->multiout.dig_out_nid) {
288 info->name = "Conexant Digital";
289 info->pcm_type = HDA_PCM_TYPE_SPDIF;
290 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
291 conexant_pcm_digital_playback;
292 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
293 spec->multiout.dig_out_nid;
294 if (spec->dig_in_nid) {
295 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
296 conexant_pcm_digital_capture;
297 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
305 static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol,
306 struct snd_ctl_elem_info *uinfo)
308 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
309 struct conexant_spec *spec = codec->spec;
311 return snd_hda_input_mux_info(spec->input_mux, uinfo);
314 static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol,
315 struct snd_ctl_elem_value *ucontrol)
317 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
318 struct conexant_spec *spec = codec->spec;
319 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
321 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
325 static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol,
326 struct snd_ctl_elem_value *ucontrol)
328 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
329 struct conexant_spec *spec = codec->spec;
330 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
332 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
333 spec->capsrc_nids[adc_idx],
334 &spec->cur_mux[adc_idx]);
337 static int conexant_init(struct hda_codec *codec)
339 struct conexant_spec *spec = codec->spec;
342 for (i = 0; i < spec->num_init_verbs; i++)
343 snd_hda_sequence_write(codec, spec->init_verbs[i]);
347 static void conexant_free(struct hda_codec *codec)
349 struct conexant_spec *spec = codec->spec;
352 if (spec->kctl_alloc) {
353 for (i = 0; i < spec->num_kctl_used; i++)
354 kfree(spec->kctl_alloc[i].name);
355 kfree(spec->kctl_alloc);
361 static int conexant_build_controls(struct hda_codec *codec)
363 struct conexant_spec *spec = codec->spec;
367 for (i = 0; i < spec->num_mixers; i++) {
368 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
372 if (spec->multiout.dig_out_nid) {
373 err = snd_hda_create_spdif_out_ctls(codec,
374 spec->multiout.dig_out_nid);
377 err = snd_hda_create_spdif_share_sw(codec,
381 spec->multiout.share_spdif = 1;
383 if (spec->dig_in_nid) {
384 err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid);
391 static struct hda_codec_ops conexant_patch_ops = {
392 .build_controls = conexant_build_controls,
393 .build_pcms = conexant_build_pcms,
394 .init = conexant_init,
395 .free = conexant_free,
400 * the private value = nid | (invert << 8)
403 #define cxt_eapd_info snd_ctl_boolean_mono_info
405 static int cxt_eapd_get(struct snd_kcontrol *kcontrol,
406 struct snd_ctl_elem_value *ucontrol)
408 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
409 struct conexant_spec *spec = codec->spec;
410 int invert = (kcontrol->private_value >> 8) & 1;
412 ucontrol->value.integer.value[0] = !spec->cur_eapd;
414 ucontrol->value.integer.value[0] = spec->cur_eapd;
419 static int cxt_eapd_put(struct snd_kcontrol *kcontrol,
420 struct snd_ctl_elem_value *ucontrol)
422 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
423 struct conexant_spec *spec = codec->spec;
424 int invert = (kcontrol->private_value >> 8) & 1;
425 hda_nid_t nid = kcontrol->private_value & 0xff;
428 eapd = !!ucontrol->value.integer.value[0];
431 if (eapd == spec->cur_eapd)
434 spec->cur_eapd = eapd;
435 snd_hda_codec_write_cache(codec, nid,
436 0, AC_VERB_SET_EAPD_BTLENABLE,
441 /* controls for test mode */
442 #ifdef CONFIG_SND_DEBUG
444 #define CXT_EAPD_SWITCH(xname, nid, mask) \
445 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
446 .info = cxt_eapd_info, \
447 .get = cxt_eapd_get, \
448 .put = cxt_eapd_put, \
449 .private_value = nid | (mask<<16) }
453 static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol,
454 struct snd_ctl_elem_info *uinfo)
456 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
457 struct conexant_spec *spec = codec->spec;
458 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
459 spec->num_channel_mode);
462 static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol,
463 struct snd_ctl_elem_value *ucontrol)
465 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
466 struct conexant_spec *spec = codec->spec;
467 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
468 spec->num_channel_mode,
469 spec->multiout.max_channels);
472 static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol,
473 struct snd_ctl_elem_value *ucontrol)
475 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
476 struct conexant_spec *spec = codec->spec;
477 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
478 spec->num_channel_mode,
479 &spec->multiout.max_channels);
480 if (err >= 0 && spec->need_dac_fix)
481 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
485 #define CXT_PIN_MODE(xname, nid, dir) \
486 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
487 .info = conexant_ch_mode_info, \
488 .get = conexant_ch_mode_get, \
489 .put = conexant_ch_mode_put, \
490 .private_value = nid | (dir<<16) }
492 #endif /* CONFIG_SND_DEBUG */
494 /* Conexant 5045 specific */
496 static hda_nid_t cxt5045_dac_nids[1] = { 0x19 };
497 static hda_nid_t cxt5045_adc_nids[1] = { 0x1a };
498 static hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a };
499 #define CXT5045_SPDIF_OUT 0x18
501 static struct hda_channel_mode cxt5045_modes[1] = {
505 static struct hda_input_mux cxt5045_capture_source = {
513 static struct hda_input_mux cxt5045_capture_source_benq = {
522 /* turn on/off EAPD (+ mute HP) as a master switch */
523 static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
524 struct snd_ctl_elem_value *ucontrol)
526 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
527 struct conexant_spec *spec = codec->spec;
530 if (!cxt_eapd_put(kcontrol, ucontrol))
533 /* toggle internal speakers mute depending of presence of
536 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
537 snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
540 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
541 snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0,
546 /* bind volumes of both NID 0x10 and 0x11 */
547 static struct hda_bind_ctls cxt5045_hp_bind_master_vol = {
548 .ops = &snd_hda_bind_vol,
550 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT),
551 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
556 /* toggle input of built-in and mic jack appropriately */
557 static void cxt5045_hp_automic(struct hda_codec *codec)
559 static struct hda_verb mic_jack_on[] = {
560 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
561 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
564 static struct hda_verb mic_jack_off[] = {
565 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
566 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
569 unsigned int present;
571 present = snd_hda_codec_read(codec, 0x12, 0,
572 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
574 snd_hda_sequence_write(codec, mic_jack_on);
576 snd_hda_sequence_write(codec, mic_jack_off);
580 /* mute internal speaker if HP is plugged */
581 static void cxt5045_hp_automute(struct hda_codec *codec)
583 struct conexant_spec *spec = codec->spec;
586 spec->hp_present = snd_hda_codec_read(codec, 0x11, 0,
587 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
589 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
590 snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
594 /* unsolicited event for HP jack sensing */
595 static void cxt5045_hp_unsol_event(struct hda_codec *codec,
600 case CONEXANT_HP_EVENT:
601 cxt5045_hp_automute(codec);
603 case CONEXANT_MIC_EVENT:
604 cxt5045_hp_automic(codec);
610 static struct snd_kcontrol_new cxt5045_mixers[] = {
612 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
613 .name = "Capture Source",
614 .info = conexant_mux_enum_info,
615 .get = conexant_mux_enum_get,
616 .put = conexant_mux_enum_put
618 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
619 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
620 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
621 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
622 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
623 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
624 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
625 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
626 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
627 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
628 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
630 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
631 .name = "Master Playback Switch",
632 .info = cxt_eapd_info,
634 .put = cxt5045_hp_master_sw_put,
635 .private_value = 0x10,
641 static struct snd_kcontrol_new cxt5045_benq_mixers[] = {
642 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT),
643 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT),
644 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT),
645 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT),
650 static struct hda_verb cxt5045_init_verbs[] = {
652 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
653 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
655 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
656 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
657 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
658 {0x11, AC_VERB_SET_CONNECT_SEL, 0x1},
659 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
660 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
661 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
662 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
663 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
664 /* Record selector: Int mic */
665 {0x1a, AC_VERB_SET_CONNECT_SEL,0x1},
666 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
667 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
668 /* SPDIF route: PCM */
669 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
670 { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
672 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */
676 static struct hda_verb cxt5045_benq_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 },
680 /* Line In,HP, Amp */
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_IN},
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_hp_sense_init_verbs[] = {
703 /* pin sensing on HP jack */
704 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
708 static struct hda_verb cxt5045_mic_sense_init_verbs[] = {
709 /* pin sensing on HP jack */
710 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
714 #ifdef CONFIG_SND_DEBUG
715 /* Test configuration for debugging, modelled after the ALC260 test
718 static struct hda_input_mux cxt5045_test_capture_source = {
723 { "LINE1 pin", 0x2 },
724 { "HP-OUT pin", 0x3 },
729 static struct snd_kcontrol_new cxt5045_test_mixer[] = {
731 /* Output controls */
732 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
733 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
734 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT),
735 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT),
736 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT),
737 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT),
739 /* Modes for retasking pin widgets */
740 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
741 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT),
743 /* EAPD Switch Control */
744 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
746 /* Loopback mixer controls */
748 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT),
749 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT),
750 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT),
751 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT),
752 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT),
753 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT),
754 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT),
755 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT),
756 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT),
757 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT),
759 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
760 .name = "Input Source",
761 .info = conexant_mux_enum_info,
762 .get = conexant_mux_enum_get,
763 .put = conexant_mux_enum_put,
765 /* Audio input controls */
766 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),
767 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),
768 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
769 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
770 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
771 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
772 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
773 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
774 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
775 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
779 static struct hda_verb cxt5045_test_init_verbs[] = {
780 /* Set connections */
781 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
782 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 },
783 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 },
784 /* Enable retasking pins as output, initially without power amp */
785 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
786 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
788 /* Disable digital (SPDIF) pins initially, but users can enable
789 * them via a mixer switch. In the case of SPDIF-out, this initverb
790 * payload also sets the generation to 0, output to be in "consumer"
791 * PCM format, copyright asserted, no pre-emphasis and no validity
794 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
795 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
797 /* Start with output sum widgets muted and their output gains at min */
798 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
799 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
801 /* Unmute retasking pin widget output buffers since the default
802 * state appears to be output. As the pin mode is changed by the
803 * user the pin mode control will take care of enabling the pin's
804 * input/output buffers as needed.
806 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
807 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
809 /* Mute capture amp left and right */
810 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
812 /* Set ADC connection select to match default mixer setting (mic1
815 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
816 {0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
818 /* Mute all inputs to mixer widget (even unconnected ones) */
819 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */
820 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */
821 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */
822 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */
823 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
830 /* initialize jack-sensing, too */
831 static int cxt5045_init(struct hda_codec *codec)
833 conexant_init(codec);
834 cxt5045_hp_automute(codec);
840 CXT5045_LAPTOP_HPSENSE,
841 CXT5045_LAPTOP_MICSENSE,
842 CXT5045_LAPTOP_HPMICSENSE,
844 #ifdef CONFIG_SND_DEBUG
850 static const char *cxt5045_models[CXT5045_MODELS] = {
851 [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense",
852 [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense",
853 [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense",
854 [CXT5045_BENQ] = "benq",
855 #ifdef CONFIG_SND_DEBUG
856 [CXT5045_TEST] = "test",
860 static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
861 SND_PCI_QUIRK(0x103c, 0x30a5, "HP", CXT5045_LAPTOP_HPSENSE),
862 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
863 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2120", CXT5045_LAPTOP_HPSENSE),
864 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP_HPSENSE),
865 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP_HPSENSE),
866 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
867 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV9533EG", CXT5045_LAPTOP_HPSENSE),
868 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HPSENSE),
869 SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP_HPSENSE),
870 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ),
871 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE),
872 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE),
873 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505", CXT5045_LAPTOP_HPSENSE),
874 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE),
875 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE),
876 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE),
877 SND_PCI_QUIRK(0x1631, 0xc106, "Packard Bell", CXT5045_LAPTOP_HPMICSENSE),
878 SND_PCI_QUIRK(0x1631, 0xc107, "Packard Bell", CXT5045_LAPTOP_HPMICSENSE),
879 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE),
883 static int patch_cxt5045(struct hda_codec *codec)
885 struct conexant_spec *spec;
888 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
891 mutex_init(&spec->amp_mutex);
894 spec->multiout.max_channels = 2;
895 spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids);
896 spec->multiout.dac_nids = cxt5045_dac_nids;
897 spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT;
898 spec->num_adc_nids = 1;
899 spec->adc_nids = cxt5045_adc_nids;
900 spec->capsrc_nids = cxt5045_capsrc_nids;
901 spec->input_mux = &cxt5045_capture_source;
902 spec->num_mixers = 1;
903 spec->mixers[0] = cxt5045_mixers;
904 spec->num_init_verbs = 1;
905 spec->init_verbs[0] = cxt5045_init_verbs;
906 spec->spdif_route = 0;
907 spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes),
908 spec->channel_mode = cxt5045_modes,
911 codec->patch_ops = conexant_patch_ops;
913 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
916 switch (board_config) {
917 case CXT5045_LAPTOP_HPSENSE:
918 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
919 spec->input_mux = &cxt5045_capture_source;
920 spec->num_init_verbs = 2;
921 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
922 spec->mixers[0] = cxt5045_mixers;
923 codec->patch_ops.init = cxt5045_init;
925 case CXT5045_LAPTOP_MICSENSE:
926 spec->input_mux = &cxt5045_capture_source;
927 spec->num_init_verbs = 2;
928 spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;
929 spec->mixers[0] = cxt5045_mixers;
930 codec->patch_ops.init = cxt5045_init;
933 case CXT5045_LAPTOP_HPMICSENSE:
934 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
935 spec->input_mux = &cxt5045_capture_source;
936 spec->num_init_verbs = 3;
937 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
938 spec->init_verbs[2] = cxt5045_mic_sense_init_verbs;
939 spec->mixers[0] = cxt5045_mixers;
940 codec->patch_ops.init = cxt5045_init;
943 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
944 spec->input_mux = &cxt5045_capture_source_benq;
945 spec->num_init_verbs = 1;
946 spec->init_verbs[0] = cxt5045_benq_init_verbs;
947 spec->mixers[0] = cxt5045_mixers;
948 spec->mixers[1] = cxt5045_benq_mixers;
949 spec->num_mixers = 2;
950 codec->patch_ops.init = cxt5045_init;
952 #ifdef CONFIG_SND_DEBUG
954 spec->input_mux = &cxt5045_test_capture_source;
955 spec->mixers[0] = cxt5045_test_mixer;
956 spec->init_verbs[0] = cxt5045_test_init_verbs;
963 * Fix max PCM level to 0 dB
964 * (originall it has 0x2b steps with 0dB offset 0x14)
966 snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT,
967 (0x14 << AC_AMPCAP_OFFSET_SHIFT) |
968 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) |
969 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
970 (1 << AC_AMPCAP_MUTE_SHIFT));
976 /* Conexant 5047 specific */
977 #define CXT5047_SPDIF_OUT 0x11
979 static hda_nid_t cxt5047_dac_nids[2] = { 0x10, 0x1c };
980 static hda_nid_t cxt5047_adc_nids[1] = { 0x12 };
981 static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a };
983 static struct hda_channel_mode cxt5047_modes[1] = {
987 static struct hda_input_mux cxt5047_capture_source = {
994 static struct hda_input_mux cxt5047_hp_capture_source = {
1001 static struct hda_input_mux cxt5047_toshiba_capture_source = {
1009 /* turn on/off EAPD (+ mute HP) as a master switch */
1010 static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1011 struct snd_ctl_elem_value *ucontrol)
1013 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1014 struct conexant_spec *spec = codec->spec;
1017 if (!cxt_eapd_put(kcontrol, ucontrol))
1020 /* toggle internal speakers mute depending of presence of
1021 * the headphone jack
1023 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
1024 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
1025 HDA_AMP_MUTE, bits);
1026 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
1027 snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0,
1028 HDA_AMP_MUTE, bits);
1032 /* bind volumes of both NID 0x13 (Headphones) and 0x1d (Speakers) */
1033 static struct hda_bind_ctls cxt5047_bind_master_vol = {
1034 .ops = &snd_hda_bind_vol,
1036 HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
1037 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
1042 /* mute internal speaker if HP is plugged */
1043 static void cxt5047_hp_automute(struct hda_codec *codec)
1045 struct conexant_spec *spec = codec->spec;
1048 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
1049 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1051 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
1052 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
1053 HDA_AMP_MUTE, bits);
1054 /* Mute/Unmute PCM 2 for good measure - some systems need this */
1055 snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
1056 HDA_AMP_MUTE, bits);
1059 /* mute internal speaker if HP is plugged */
1060 static void cxt5047_hp2_automute(struct hda_codec *codec)
1062 struct conexant_spec *spec = codec->spec;
1065 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
1066 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1068 bits = spec->hp_present ? HDA_AMP_MUTE : 0;
1069 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
1070 HDA_AMP_MUTE, bits);
1071 /* Mute/Unmute PCM 2 for good measure - some systems need this */
1072 snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
1073 HDA_AMP_MUTE, bits);
1076 /* toggle input of built-in and mic jack appropriately */
1077 static void cxt5047_hp_automic(struct hda_codec *codec)
1079 static struct hda_verb mic_jack_on[] = {
1080 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1081 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1084 static struct hda_verb mic_jack_off[] = {
1085 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1086 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1089 unsigned int present;
1091 present = snd_hda_codec_read(codec, 0x15, 0,
1092 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1094 snd_hda_sequence_write(codec, mic_jack_on);
1096 snd_hda_sequence_write(codec, mic_jack_off);
1099 /* unsolicited event for HP jack sensing */
1100 static void cxt5047_hp_unsol_event(struct hda_codec *codec,
1103 switch (res >> 26) {
1104 case CONEXANT_HP_EVENT:
1105 cxt5047_hp_automute(codec);
1107 case CONEXANT_MIC_EVENT:
1108 cxt5047_hp_automic(codec);
1113 /* unsolicited event for HP jack sensing - non-EAPD systems */
1114 static void cxt5047_hp2_unsol_event(struct hda_codec *codec,
1119 case CONEXANT_HP_EVENT:
1120 cxt5047_hp2_automute(codec);
1122 case CONEXANT_MIC_EVENT:
1123 cxt5047_hp_automic(codec);
1128 static struct snd_kcontrol_new cxt5047_mixers[] = {
1129 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1130 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1131 HDA_CODEC_VOLUME("Mic Gain Volume", 0x1a, 0x0, HDA_OUTPUT),
1132 HDA_CODEC_MUTE("Mic Gain Switch", 0x1a, 0x0, HDA_OUTPUT),
1133 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1134 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1135 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1136 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1137 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT),
1138 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT),
1139 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x00, HDA_OUTPUT),
1140 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x00, HDA_OUTPUT),
1141 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1142 HDA_CODEC_MUTE("Headphone Playback Switch", 0x13, 0x00, HDA_OUTPUT),
1147 static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = {
1149 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1150 .name = "Capture Source",
1151 .info = conexant_mux_enum_info,
1152 .get = conexant_mux_enum_get,
1153 .put = conexant_mux_enum_put
1155 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1156 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1157 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1158 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1159 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1160 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1161 HDA_BIND_VOL("Master Playback Volume", &cxt5047_bind_master_vol),
1163 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1164 .name = "Master Playback Switch",
1165 .info = cxt_eapd_info,
1166 .get = cxt_eapd_get,
1167 .put = cxt5047_hp_master_sw_put,
1168 .private_value = 0x13,
1174 static struct snd_kcontrol_new cxt5047_hp_mixers[] = {
1176 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1177 .name = "Capture Source",
1178 .info = conexant_mux_enum_info,
1179 .get = conexant_mux_enum_get,
1180 .put = conexant_mux_enum_put
1182 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1183 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19,0x02,HDA_INPUT),
1184 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1185 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1186 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1187 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1188 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1190 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1191 .name = "Master Playback Switch",
1192 .info = cxt_eapd_info,
1193 .get = cxt_eapd_get,
1194 .put = cxt5047_hp_master_sw_put,
1195 .private_value = 0x13,
1200 static struct hda_verb cxt5047_init_verbs[] = {
1201 /* Line in, Mic, Built-in Mic */
1202 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1203 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1204 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1206 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1207 {0x13, AC_VERB_SET_CONNECT_SEL,0x1},
1208 {0x1d, AC_VERB_SET_CONNECT_SEL,0x0},
1209 /* Record selector: Mic */
1210 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1211 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1212 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1213 {0x1A, AC_VERB_SET_CONNECT_SEL,0x02},
1214 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1215 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1216 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1217 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
1218 /* SPDIF route: PCM */
1219 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
1220 /* Enable unsolicited events */
1221 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1222 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1226 /* configuration for Toshiba Laptops */
1227 static struct hda_verb cxt5047_toshiba_init_verbs[] = {
1228 {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0 }, /* default on */
1229 /* pin sensing on HP and Mic jacks */
1230 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1231 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1232 /* Speaker routing */
1233 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1237 /* configuration for HP Laptops */
1238 static struct hda_verb cxt5047_hp_init_verbs[] = {
1239 /* pin sensing on HP jack */
1240 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1241 /* 0x13 is actually shared by both HP and speaker;
1242 * setting the connection to 0 (=0x19) makes the master volume control
1243 * working mysteriouslly...
1245 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1246 /* Record selector: Ext Mic */
1247 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1248 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1249 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1250 /* Speaker routing */
1251 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1255 /* Test configuration for debugging, modelled after the ALC260 test
1258 #ifdef CONFIG_SND_DEBUG
1259 static struct hda_input_mux cxt5047_test_capture_source = {
1262 { "LINE1 pin", 0x0 },
1263 { "MIC1 pin", 0x1 },
1264 { "MIC2 pin", 0x2 },
1269 static struct snd_kcontrol_new cxt5047_test_mixer[] = {
1271 /* Output only controls */
1272 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT),
1273 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT),
1274 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT),
1275 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT),
1276 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1277 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1278 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1279 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1280 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT),
1281 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1282 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT),
1283 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT),
1285 /* Modes for retasking pin widgets */
1286 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT),
1287 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT),
1289 /* EAPD Switch Control */
1290 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1292 /* Loopback mixer controls */
1293 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT),
1294 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT),
1295 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT),
1296 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT),
1297 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT),
1298 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT),
1299 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT),
1300 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT),
1302 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT),
1303 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT),
1304 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT),
1305 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT),
1306 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT),
1307 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT),
1308 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT),
1309 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT),
1311 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1312 .name = "Input Source",
1313 .info = conexant_mux_enum_info,
1314 .get = conexant_mux_enum_get,
1315 .put = conexant_mux_enum_put,
1317 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),
1318 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),
1319 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
1320 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
1321 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
1322 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
1323 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
1324 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
1325 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
1326 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
1331 static struct hda_verb cxt5047_test_init_verbs[] = {
1332 /* Enable retasking pins as output, initially without power amp */
1333 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1334 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1335 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1337 /* Disable digital (SPDIF) pins initially, but users can enable
1338 * them via a mixer switch. In the case of SPDIF-out, this initverb
1339 * payload also sets the generation to 0, output to be in "consumer"
1340 * PCM format, copyright asserted, no pre-emphasis and no validity
1343 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
1345 /* Ensure mic1, mic2, line1 pin widgets take input from the
1346 * OUT1 sum bus when acting as an output.
1348 {0x1a, AC_VERB_SET_CONNECT_SEL, 0},
1349 {0x1b, AC_VERB_SET_CONNECT_SEL, 0},
1351 /* Start with output sum widgets muted and their output gains at min */
1352 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1353 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1355 /* Unmute retasking pin widget output buffers since the default
1356 * state appears to be output. As the pin mode is changed by the
1357 * user the pin mode control will take care of enabling the pin's
1358 * input/output buffers as needed.
1360 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1361 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1362 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1364 /* Mute capture amp left and right */
1365 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1367 /* Set ADC connection select to match default mixer setting (mic1
1370 {0x12, AC_VERB_SET_CONNECT_SEL, 0x00},
1372 /* Mute all inputs to mixer widget (even unconnected ones) */
1373 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
1374 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
1375 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
1376 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
1377 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
1378 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1379 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
1380 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
1387 /* initialize jack-sensing, too */
1388 static int cxt5047_hp_init(struct hda_codec *codec)
1390 conexant_init(codec);
1391 cxt5047_hp_automute(codec);
1397 CXT5047_LAPTOP, /* Laptops w/o EAPD support */
1398 CXT5047_LAPTOP_HP, /* Some HP laptops */
1399 CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */
1400 #ifdef CONFIG_SND_DEBUG
1406 static const char *cxt5047_models[CXT5047_MODELS] = {
1407 [CXT5047_LAPTOP] = "laptop",
1408 [CXT5047_LAPTOP_HP] = "laptop-hp",
1409 [CXT5047_LAPTOP_EAPD] = "laptop-eapd",
1410 #ifdef CONFIG_SND_DEBUG
1411 [CXT5047_TEST] = "test",
1415 static struct snd_pci_quirk cxt5047_cfg_tbl[] = {
1416 SND_PCI_QUIRK(0x103c, 0x30a0, "HP DV1000", CXT5047_LAPTOP),
1417 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
1418 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV2000T/DV3000T", CXT5047_LAPTOP),
1419 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2000Z", CXT5047_LAPTOP),
1420 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD),
1424 static int patch_cxt5047(struct hda_codec *codec)
1426 struct conexant_spec *spec;
1429 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1432 mutex_init(&spec->amp_mutex);
1435 spec->multiout.max_channels = 2;
1436 spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids);
1437 spec->multiout.dac_nids = cxt5047_dac_nids;
1438 spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT;
1439 spec->num_adc_nids = 1;
1440 spec->adc_nids = cxt5047_adc_nids;
1441 spec->capsrc_nids = cxt5047_capsrc_nids;
1442 spec->input_mux = &cxt5047_capture_source;
1443 spec->num_mixers = 1;
1444 spec->mixers[0] = cxt5047_mixers;
1445 spec->num_init_verbs = 1;
1446 spec->init_verbs[0] = cxt5047_init_verbs;
1447 spec->spdif_route = 0;
1448 spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes),
1449 spec->channel_mode = cxt5047_modes,
1451 codec->patch_ops = conexant_patch_ops;
1453 board_config = snd_hda_check_board_config(codec, CXT5047_MODELS,
1456 switch (board_config) {
1457 case CXT5047_LAPTOP:
1458 codec->patch_ops.unsol_event = cxt5047_hp2_unsol_event;
1460 case CXT5047_LAPTOP_HP:
1461 spec->input_mux = &cxt5047_hp_capture_source;
1462 spec->num_init_verbs = 2;
1463 spec->init_verbs[1] = cxt5047_hp_init_verbs;
1464 spec->mixers[0] = cxt5047_hp_mixers;
1465 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1466 codec->patch_ops.init = cxt5047_hp_init;
1468 case CXT5047_LAPTOP_EAPD:
1469 spec->input_mux = &cxt5047_toshiba_capture_source;
1470 spec->num_init_verbs = 2;
1471 spec->init_verbs[1] = cxt5047_toshiba_init_verbs;
1472 spec->mixers[0] = cxt5047_toshiba_mixers;
1473 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1475 #ifdef CONFIG_SND_DEBUG
1477 spec->input_mux = &cxt5047_test_capture_source;
1478 spec->mixers[0] = cxt5047_test_mixer;
1479 spec->init_verbs[0] = cxt5047_test_init_verbs;
1480 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1486 /* Conexant 5051 specific */
1487 static hda_nid_t cxt5051_dac_nids[1] = { 0x10 };
1488 static hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 };
1489 #define CXT5051_SPDIF_OUT 0x1C
1490 #define CXT5051_PORTB_EVENT 0x38
1491 #define CXT5051_PORTC_EVENT 0x39
1493 static struct hda_channel_mode cxt5051_modes[1] = {
1497 static void cxt5051_update_speaker(struct hda_codec *codec)
1499 struct conexant_spec *spec = codec->spec;
1500 unsigned int pinctl;
1501 pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0;
1502 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
1506 /* turn on/off EAPD (+ mute HP) as a master switch */
1507 static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1508 struct snd_ctl_elem_value *ucontrol)
1510 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1512 if (!cxt_eapd_put(kcontrol, ucontrol))
1514 cxt5051_update_speaker(codec);
1518 /* toggle input of built-in and mic jack appropriately */
1519 static void cxt5051_portb_automic(struct hda_codec *codec)
1521 unsigned int present;
1523 present = snd_hda_codec_read(codec, 0x17, 0,
1524 AC_VERB_GET_PIN_SENSE, 0) &
1525 AC_PINSENSE_PRESENCE;
1526 snd_hda_codec_write(codec, 0x14, 0,
1527 AC_VERB_SET_CONNECT_SEL,
1528 present ? 0x01 : 0x00);
1531 /* switch the current ADC according to the jack state */
1532 static void cxt5051_portc_automic(struct hda_codec *codec)
1534 struct conexant_spec *spec = codec->spec;
1535 unsigned int present;
1538 present = snd_hda_codec_read(codec, 0x18, 0,
1539 AC_VERB_GET_PIN_SENSE, 0) &
1540 AC_PINSENSE_PRESENCE;
1542 spec->cur_adc_idx = 1;
1544 spec->cur_adc_idx = 0;
1545 new_adc = spec->adc_nids[spec->cur_adc_idx];
1546 if (spec->cur_adc && spec->cur_adc != new_adc) {
1547 /* stream is running, let's swap the current ADC */
1548 snd_hda_codec_setup_stream(codec, spec->cur_adc, 0, 0, 0);
1549 spec->cur_adc = new_adc;
1550 snd_hda_codec_setup_stream(codec, new_adc,
1551 spec->cur_adc_stream_tag, 0,
1552 spec->cur_adc_format);
1556 /* mute internal speaker if HP is plugged */
1557 static void cxt5051_hp_automute(struct hda_codec *codec)
1559 struct conexant_spec *spec = codec->spec;
1561 spec->hp_present = snd_hda_codec_read(codec, 0x16, 0,
1562 AC_VERB_GET_PIN_SENSE, 0) &
1563 AC_PINSENSE_PRESENCE;
1564 cxt5051_update_speaker(codec);
1567 /* unsolicited event for HP jack sensing */
1568 static void cxt5051_hp_unsol_event(struct hda_codec *codec,
1571 switch (res >> 26) {
1572 case CONEXANT_HP_EVENT:
1573 cxt5051_hp_automute(codec);
1575 case CXT5051_PORTB_EVENT:
1576 cxt5051_portb_automic(codec);
1578 case CXT5051_PORTC_EVENT:
1579 cxt5051_portc_automic(codec);
1584 static struct snd_kcontrol_new cxt5051_mixers[] = {
1585 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
1586 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
1587 HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT),
1588 HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT),
1589 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT),
1590 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT),
1591 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1593 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1594 .name = "Master Playback Switch",
1595 .info = cxt_eapd_info,
1596 .get = cxt_eapd_get,
1597 .put = cxt5051_hp_master_sw_put,
1598 .private_value = 0x1a,
1604 static struct snd_kcontrol_new cxt5051_hp_mixers[] = {
1605 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
1606 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
1607 HDA_CODEC_VOLUME("External Mic Volume", 0x15, 0x00, HDA_INPUT),
1608 HDA_CODEC_MUTE("External Mic Switch", 0x15, 0x00, HDA_INPUT),
1609 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1611 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1612 .name = "Master Playback Switch",
1613 .info = cxt_eapd_info,
1614 .get = cxt_eapd_get,
1615 .put = cxt5051_hp_master_sw_put,
1616 .private_value = 0x1a,
1622 static struct hda_verb cxt5051_init_verbs[] = {
1624 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1625 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1626 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1627 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1628 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1629 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1631 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1632 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1634 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1635 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
1637 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1638 /* Record selector: Int mic */
1639 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1640 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
1641 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1642 /* SPDIF route: PCM */
1643 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
1645 {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
1646 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1647 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT},
1648 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTC_EVENT},
1652 /* initialize jack-sensing, too */
1653 static int cxt5051_init(struct hda_codec *codec)
1655 conexant_init(codec);
1656 if (codec->patch_ops.unsol_event) {
1657 cxt5051_hp_automute(codec);
1658 cxt5051_portb_automic(codec);
1659 cxt5051_portc_automic(codec);
1666 CXT5051_LAPTOP, /* Laptops w/ EAPD support */
1667 CXT5051_HP, /* no docking */
1671 static const char *cxt5051_models[CXT5051_MODELS] = {
1672 [CXT5051_LAPTOP] = "laptop",
1673 [CXT5051_HP] = "hp",
1676 static struct snd_pci_quirk cxt5051_cfg_tbl[] = {
1677 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1679 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP),
1683 static int patch_cxt5051(struct hda_codec *codec)
1685 struct conexant_spec *spec;
1688 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1691 mutex_init(&spec->amp_mutex);
1694 codec->patch_ops = conexant_patch_ops;
1695 codec->patch_ops.init = cxt5051_init;
1697 spec->multiout.max_channels = 2;
1698 spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids);
1699 spec->multiout.dac_nids = cxt5051_dac_nids;
1700 spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT;
1701 spec->num_adc_nids = 1; /* not 2; via auto-mic switch */
1702 spec->adc_nids = cxt5051_adc_nids;
1703 spec->num_mixers = 1;
1704 spec->mixers[0] = cxt5051_mixers;
1705 spec->num_init_verbs = 1;
1706 spec->init_verbs[0] = cxt5051_init_verbs;
1707 spec->spdif_route = 0;
1708 spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes);
1709 spec->channel_mode = cxt5051_modes;
1711 spec->cur_adc_idx = 0;
1713 board_config = snd_hda_check_board_config(codec, CXT5051_MODELS,
1716 switch (board_config) {
1718 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
1719 spec->mixers[0] = cxt5051_hp_mixers;
1722 case CXT5051_LAPTOP:
1723 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
1734 struct hda_codec_preset snd_hda_preset_conexant[] = {
1735 { .id = 0x14f15045, .name = "CX20549 (Venice)",
1736 .patch = patch_cxt5045 },
1737 { .id = 0x14f15047, .name = "CX20551 (Waikiki)",
1738 .patch = patch_cxt5047 },
1739 { .id = 0x14f15051, .name = "CX20561 (Hermosa)",
1740 .patch = patch_cxt5051 },