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"
31 #define CXT_PIN_DIR_IN 0x00
32 #define CXT_PIN_DIR_OUT 0x01
33 #define CXT_PIN_DIR_INOUT 0x02
34 #define CXT_PIN_DIR_IN_NOMICBIAS 0x03
35 #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04
37 #define CONEXANT_HP_EVENT 0x37
38 #define CONEXANT_MIC_EVENT 0x38
42 struct conexant_spec {
44 struct snd_kcontrol_new *mixers[5];
47 const struct hda_verb *init_verbs[5]; /* initialization verbs
51 unsigned int num_init_verbs;
54 struct hda_multi_out multiout; /* playback set-up
55 * max_channels, dacs must be set
56 * dig_out_nid and hp_nid are optional
58 unsigned int cur_eapd;
59 unsigned int hp_present;
60 unsigned int need_dac_fix;
63 unsigned int num_adc_nids;
65 hda_nid_t dig_in_nid; /* digital-in NID; optional */
67 unsigned int cur_adc_idx;
69 unsigned int cur_adc_stream_tag;
70 unsigned int cur_adc_format;
73 const struct hda_input_mux *input_mux;
74 hda_nid_t *capsrc_nids;
75 unsigned int cur_mux[3];
78 const struct hda_channel_mode *channel_mode;
82 struct hda_pcm pcm_rec[2]; /* used in build_pcms() */
84 struct mutex amp_mutex; /* PCM volume/mute control mutex */
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_setup_stream(codec, spec->adc_nids[substream->number],
183 static struct hda_pcm_stream conexant_pcm_analog_playback = {
187 .nid = 0, /* fill later */
189 .open = conexant_playback_pcm_open,
190 .prepare = conexant_playback_pcm_prepare,
191 .cleanup = conexant_playback_pcm_cleanup
195 static struct hda_pcm_stream conexant_pcm_analog_capture = {
199 .nid = 0, /* fill later */
201 .prepare = conexant_capture_pcm_prepare,
202 .cleanup = conexant_capture_pcm_cleanup
207 static struct hda_pcm_stream conexant_pcm_digital_playback = {
211 .nid = 0, /* fill later */
213 .open = conexant_dig_playback_pcm_open,
214 .close = conexant_dig_playback_pcm_close,
215 .prepare = conexant_dig_playback_pcm_prepare
219 static struct hda_pcm_stream conexant_pcm_digital_capture = {
223 /* NID is set in alc_build_pcms */
226 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
227 struct hda_codec *codec,
228 unsigned int stream_tag,
230 struct snd_pcm_substream *substream)
232 struct conexant_spec *spec = codec->spec;
233 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
234 spec->cur_adc_stream_tag = stream_tag;
235 spec->cur_adc_format = format;
236 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
240 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
241 struct hda_codec *codec,
242 struct snd_pcm_substream *substream)
244 struct conexant_spec *spec = codec->spec;
245 snd_hda_codec_setup_stream(codec, spec->cur_adc, 0, 0, 0);
250 static struct hda_pcm_stream cx5051_pcm_analog_capture = {
254 .nid = 0, /* fill later */
256 .prepare = cx5051_capture_pcm_prepare,
257 .cleanup = cx5051_capture_pcm_cleanup
261 static int conexant_build_pcms(struct hda_codec *codec)
263 struct conexant_spec *spec = codec->spec;
264 struct hda_pcm *info = spec->pcm_rec;
267 codec->pcm_info = info;
269 info->name = "CONEXANT Analog";
270 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback;
271 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max =
272 spec->multiout.max_channels;
273 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
274 spec->multiout.dac_nids[0];
275 if (codec->vendor_id == 0x14f15051)
276 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
277 cx5051_pcm_analog_capture;
279 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
280 conexant_pcm_analog_capture;
281 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
282 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
284 if (spec->multiout.dig_out_nid) {
287 info->name = "Conexant Digital";
288 info->pcm_type = HDA_PCM_TYPE_SPDIF;
289 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
290 conexant_pcm_digital_playback;
291 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
292 spec->multiout.dig_out_nid;
293 if (spec->dig_in_nid) {
294 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
295 conexant_pcm_digital_capture;
296 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
304 static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol,
305 struct snd_ctl_elem_info *uinfo)
307 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
308 struct conexant_spec *spec = codec->spec;
310 return snd_hda_input_mux_info(spec->input_mux, uinfo);
313 static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol,
314 struct snd_ctl_elem_value *ucontrol)
316 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
317 struct conexant_spec *spec = codec->spec;
318 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
320 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
324 static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol,
325 struct snd_ctl_elem_value *ucontrol)
327 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
328 struct conexant_spec *spec = codec->spec;
329 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
331 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
332 spec->capsrc_nids[adc_idx],
333 &spec->cur_mux[adc_idx]);
336 static int conexant_init(struct hda_codec *codec)
338 struct conexant_spec *spec = codec->spec;
341 for (i = 0; i < spec->num_init_verbs; i++)
342 snd_hda_sequence_write(codec, spec->init_verbs[i]);
346 static void conexant_free(struct hda_codec *codec)
348 struct conexant_spec *spec = codec->spec;
351 if (spec->kctl_alloc) {
352 for (i = 0; i < spec->num_kctl_used; i++)
353 kfree(spec->kctl_alloc[i].name);
354 kfree(spec->kctl_alloc);
360 static int conexant_build_controls(struct hda_codec *codec)
362 struct conexant_spec *spec = codec->spec;
366 for (i = 0; i < spec->num_mixers; i++) {
367 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
371 if (spec->multiout.dig_out_nid) {
372 err = snd_hda_create_spdif_out_ctls(codec,
373 spec->multiout.dig_out_nid);
376 err = snd_hda_create_spdif_share_sw(codec,
380 spec->multiout.share_spdif = 1;
382 if (spec->dig_in_nid) {
383 err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid);
390 static struct hda_codec_ops conexant_patch_ops = {
391 .build_controls = conexant_build_controls,
392 .build_pcms = conexant_build_pcms,
393 .init = conexant_init,
394 .free = conexant_free,
399 * the private value = nid | (invert << 8)
402 #define cxt_eapd_info snd_ctl_boolean_mono_info
404 static int cxt_eapd_get(struct snd_kcontrol *kcontrol,
405 struct snd_ctl_elem_value *ucontrol)
407 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
408 struct conexant_spec *spec = codec->spec;
409 int invert = (kcontrol->private_value >> 8) & 1;
411 ucontrol->value.integer.value[0] = !spec->cur_eapd;
413 ucontrol->value.integer.value[0] = spec->cur_eapd;
418 static int cxt_eapd_put(struct snd_kcontrol *kcontrol,
419 struct snd_ctl_elem_value *ucontrol)
421 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
422 struct conexant_spec *spec = codec->spec;
423 int invert = (kcontrol->private_value >> 8) & 1;
424 hda_nid_t nid = kcontrol->private_value & 0xff;
427 eapd = !!ucontrol->value.integer.value[0];
430 if (eapd == spec->cur_eapd)
433 spec->cur_eapd = eapd;
434 snd_hda_codec_write_cache(codec, nid,
435 0, AC_VERB_SET_EAPD_BTLENABLE,
440 /* controls for test mode */
441 #ifdef CONFIG_SND_DEBUG
443 #define CXT_EAPD_SWITCH(xname, nid, mask) \
444 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
445 .info = cxt_eapd_info, \
446 .get = cxt_eapd_get, \
447 .put = cxt_eapd_put, \
448 .private_value = nid | (mask<<16) }
452 static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol,
453 struct snd_ctl_elem_info *uinfo)
455 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
456 struct conexant_spec *spec = codec->spec;
457 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
458 spec->num_channel_mode);
461 static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol,
462 struct snd_ctl_elem_value *ucontrol)
464 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
465 struct conexant_spec *spec = codec->spec;
466 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
467 spec->num_channel_mode,
468 spec->multiout.max_channels);
471 static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol,
472 struct snd_ctl_elem_value *ucontrol)
474 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
475 struct conexant_spec *spec = codec->spec;
476 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
477 spec->num_channel_mode,
478 &spec->multiout.max_channels);
479 if (err >= 0 && spec->need_dac_fix)
480 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
484 #define CXT_PIN_MODE(xname, nid, dir) \
485 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
486 .info = conexant_ch_mode_info, \
487 .get = conexant_ch_mode_get, \
488 .put = conexant_ch_mode_put, \
489 .private_value = nid | (dir<<16) }
491 #endif /* CONFIG_SND_DEBUG */
493 /* Conexant 5045 specific */
495 static hda_nid_t cxt5045_dac_nids[1] = { 0x19 };
496 static hda_nid_t cxt5045_adc_nids[1] = { 0x1a };
497 static hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a };
498 #define CXT5045_SPDIF_OUT 0x18
500 static struct hda_channel_mode cxt5045_modes[1] = {
504 static struct hda_input_mux cxt5045_capture_source = {
512 static struct hda_input_mux cxt5045_capture_source_benq = {
521 /* turn on/off EAPD (+ mute HP) as a master switch */
522 static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
523 struct snd_ctl_elem_value *ucontrol)
525 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
526 struct conexant_spec *spec = codec->spec;
529 if (!cxt_eapd_put(kcontrol, ucontrol))
532 /* toggle internal speakers mute depending of presence of
535 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
536 snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
539 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
540 snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0,
545 /* bind volumes of both NID 0x10 and 0x11 */
546 static struct hda_bind_ctls cxt5045_hp_bind_master_vol = {
547 .ops = &snd_hda_bind_vol,
549 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT),
550 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
555 /* toggle input of built-in and mic jack appropriately */
556 static void cxt5045_hp_automic(struct hda_codec *codec)
558 static struct hda_verb mic_jack_on[] = {
559 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
560 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
563 static struct hda_verb mic_jack_off[] = {
564 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
565 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
568 unsigned int present;
570 present = snd_hda_codec_read(codec, 0x12, 0,
571 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
573 snd_hda_sequence_write(codec, mic_jack_on);
575 snd_hda_sequence_write(codec, mic_jack_off);
579 /* mute internal speaker if HP is plugged */
580 static void cxt5045_hp_automute(struct hda_codec *codec)
582 struct conexant_spec *spec = codec->spec;
585 spec->hp_present = snd_hda_codec_read(codec, 0x11, 0,
586 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
588 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
589 snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
593 /* unsolicited event for HP jack sensing */
594 static void cxt5045_hp_unsol_event(struct hda_codec *codec,
599 case CONEXANT_HP_EVENT:
600 cxt5045_hp_automute(codec);
602 case CONEXANT_MIC_EVENT:
603 cxt5045_hp_automic(codec);
609 static struct snd_kcontrol_new cxt5045_mixers[] = {
611 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
612 .name = "Capture Source",
613 .info = conexant_mux_enum_info,
614 .get = conexant_mux_enum_get,
615 .put = conexant_mux_enum_put
617 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
618 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
619 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
620 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
621 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
622 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
623 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
624 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
625 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
626 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
627 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
629 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
630 .name = "Master Playback Switch",
631 .info = cxt_eapd_info,
633 .put = cxt5045_hp_master_sw_put,
634 .private_value = 0x10,
640 static struct snd_kcontrol_new cxt5045_benq_mixers[] = {
641 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT),
642 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT),
643 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT),
644 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT),
649 static struct hda_verb cxt5045_init_verbs[] = {
651 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
652 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
654 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
655 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
656 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
657 {0x11, AC_VERB_SET_CONNECT_SEL, 0x1},
658 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
659 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
660 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
661 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
662 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
663 /* Record selector: Int mic */
664 {0x1a, AC_VERB_SET_CONNECT_SEL,0x1},
665 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
666 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
667 /* SPDIF route: PCM */
668 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
669 { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
671 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */
675 static struct hda_verb cxt5045_benq_init_verbs[] = {
677 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
678 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
679 /* Line In,HP, Amp */
680 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
681 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
682 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
683 {0x11, AC_VERB_SET_CONNECT_SEL, 0x1},
684 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
685 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
686 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
687 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
688 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
689 /* Record selector: Int mic */
690 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x1},
691 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
692 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
693 /* SPDIF route: PCM */
694 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
695 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
697 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
701 static struct hda_verb cxt5045_hp_sense_init_verbs[] = {
702 /* pin sensing on HP jack */
703 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
707 static struct hda_verb cxt5045_mic_sense_init_verbs[] = {
708 /* pin sensing on HP jack */
709 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
713 #ifdef CONFIG_SND_DEBUG
714 /* Test configuration for debugging, modelled after the ALC260 test
717 static struct hda_input_mux cxt5045_test_capture_source = {
722 { "LINE1 pin", 0x2 },
723 { "HP-OUT pin", 0x3 },
728 static struct snd_kcontrol_new cxt5045_test_mixer[] = {
730 /* Output controls */
731 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
732 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
733 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT),
734 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT),
735 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT),
736 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT),
738 /* Modes for retasking pin widgets */
739 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
740 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT),
742 /* EAPD Switch Control */
743 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
745 /* Loopback mixer controls */
747 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT),
748 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT),
749 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT),
750 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT),
751 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT),
752 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT),
753 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT),
754 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT),
755 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT),
756 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT),
758 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
759 .name = "Input Source",
760 .info = conexant_mux_enum_info,
761 .get = conexant_mux_enum_get,
762 .put = conexant_mux_enum_put,
764 /* Audio input controls */
765 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),
766 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),
767 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
768 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
769 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
770 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
771 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
772 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
773 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
774 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
778 static struct hda_verb cxt5045_test_init_verbs[] = {
779 /* Set connections */
780 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
781 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 },
782 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 },
783 /* Enable retasking pins as output, initially without power amp */
784 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
785 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
787 /* Disable digital (SPDIF) pins initially, but users can enable
788 * them via a mixer switch. In the case of SPDIF-out, this initverb
789 * payload also sets the generation to 0, output to be in "consumer"
790 * PCM format, copyright asserted, no pre-emphasis and no validity
793 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
794 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
796 /* Start with output sum widgets muted and their output gains at min */
797 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
798 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
800 /* Unmute retasking pin widget output buffers since the default
801 * state appears to be output. As the pin mode is changed by the
802 * user the pin mode control will take care of enabling the pin's
803 * input/output buffers as needed.
805 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
806 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
808 /* Mute capture amp left and right */
809 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
811 /* Set ADC connection select to match default mixer setting (mic1
814 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
815 {0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
817 /* Mute all inputs to mixer widget (even unconnected ones) */
818 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */
819 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */
820 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */
821 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */
822 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
829 /* initialize jack-sensing, too */
830 static int cxt5045_init(struct hda_codec *codec)
832 conexant_init(codec);
833 cxt5045_hp_automute(codec);
839 CXT5045_LAPTOP_HPSENSE,
840 CXT5045_LAPTOP_MICSENSE,
841 CXT5045_LAPTOP_HPMICSENSE,
843 #ifdef CONFIG_SND_DEBUG
849 static const char *cxt5045_models[CXT5045_MODELS] = {
850 [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense",
851 [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense",
852 [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense",
853 [CXT5045_BENQ] = "benq",
854 #ifdef CONFIG_SND_DEBUG
855 [CXT5045_TEST] = "test",
859 static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
860 SND_PCI_QUIRK(0x103c, 0x30a5, "HP", CXT5045_LAPTOP_HPSENSE),
861 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
862 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2120", CXT5045_LAPTOP_HPSENSE),
863 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP_HPSENSE),
864 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP_HPSENSE),
865 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
866 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV9533EG", CXT5045_LAPTOP_HPSENSE),
867 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HPSENSE),
868 SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP_HPSENSE),
869 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ),
870 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE),
871 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE),
872 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505", CXT5045_LAPTOP_HPSENSE),
873 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE),
874 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE),
875 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE),
876 SND_PCI_QUIRK(0x1631, 0xc106, "Packard Bell", CXT5045_LAPTOP_HPMICSENSE),
877 SND_PCI_QUIRK(0x1631, 0xc107, "Packard Bell", CXT5045_LAPTOP_HPMICSENSE),
878 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE),
882 static int patch_cxt5045(struct hda_codec *codec)
884 struct conexant_spec *spec;
887 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
890 mutex_init(&spec->amp_mutex);
893 spec->multiout.max_channels = 2;
894 spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids);
895 spec->multiout.dac_nids = cxt5045_dac_nids;
896 spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT;
897 spec->num_adc_nids = 1;
898 spec->adc_nids = cxt5045_adc_nids;
899 spec->capsrc_nids = cxt5045_capsrc_nids;
900 spec->input_mux = &cxt5045_capture_source;
901 spec->num_mixers = 1;
902 spec->mixers[0] = cxt5045_mixers;
903 spec->num_init_verbs = 1;
904 spec->init_verbs[0] = cxt5045_init_verbs;
905 spec->spdif_route = 0;
906 spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes),
907 spec->channel_mode = cxt5045_modes,
910 codec->patch_ops = conexant_patch_ops;
912 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
915 switch (board_config) {
916 case CXT5045_LAPTOP_HPSENSE:
917 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
918 spec->input_mux = &cxt5045_capture_source;
919 spec->num_init_verbs = 2;
920 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
921 spec->mixers[0] = cxt5045_mixers;
922 codec->patch_ops.init = cxt5045_init;
924 case CXT5045_LAPTOP_MICSENSE:
925 spec->input_mux = &cxt5045_capture_source;
926 spec->num_init_verbs = 2;
927 spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;
928 spec->mixers[0] = cxt5045_mixers;
929 codec->patch_ops.init = cxt5045_init;
932 case CXT5045_LAPTOP_HPMICSENSE:
933 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
934 spec->input_mux = &cxt5045_capture_source;
935 spec->num_init_verbs = 3;
936 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
937 spec->init_verbs[2] = cxt5045_mic_sense_init_verbs;
938 spec->mixers[0] = cxt5045_mixers;
939 codec->patch_ops.init = cxt5045_init;
942 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
943 spec->input_mux = &cxt5045_capture_source_benq;
944 spec->num_init_verbs = 1;
945 spec->init_verbs[0] = cxt5045_benq_init_verbs;
946 spec->mixers[0] = cxt5045_mixers;
947 spec->mixers[1] = cxt5045_benq_mixers;
948 spec->num_mixers = 2;
949 codec->patch_ops.init = cxt5045_init;
951 #ifdef CONFIG_SND_DEBUG
953 spec->input_mux = &cxt5045_test_capture_source;
954 spec->mixers[0] = cxt5045_test_mixer;
955 spec->init_verbs[0] = cxt5045_test_init_verbs;
962 * Fix max PCM level to 0 dB
963 * (originall it has 0x2b steps with 0dB offset 0x14)
965 snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT,
966 (0x14 << AC_AMPCAP_OFFSET_SHIFT) |
967 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) |
968 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
969 (1 << AC_AMPCAP_MUTE_SHIFT));
975 /* Conexant 5047 specific */
976 #define CXT5047_SPDIF_OUT 0x11
978 static hda_nid_t cxt5047_dac_nids[2] = { 0x10, 0x1c };
979 static hda_nid_t cxt5047_adc_nids[1] = { 0x12 };
980 static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a };
982 static struct hda_channel_mode cxt5047_modes[1] = {
986 static struct hda_input_mux cxt5047_capture_source = {
993 static struct hda_input_mux cxt5047_hp_capture_source = {
1000 static struct hda_input_mux cxt5047_toshiba_capture_source = {
1008 /* turn on/off EAPD (+ mute HP) as a master switch */
1009 static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1010 struct snd_ctl_elem_value *ucontrol)
1012 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1013 struct conexant_spec *spec = codec->spec;
1016 if (!cxt_eapd_put(kcontrol, ucontrol))
1019 /* toggle internal speakers mute depending of presence of
1020 * the headphone jack
1022 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
1023 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
1024 HDA_AMP_MUTE, bits);
1025 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
1026 snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0,
1027 HDA_AMP_MUTE, bits);
1031 /* bind volumes of both NID 0x13 (Headphones) and 0x1d (Speakers) */
1032 static struct hda_bind_ctls cxt5047_bind_master_vol = {
1033 .ops = &snd_hda_bind_vol,
1035 HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
1036 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
1041 /* mute internal speaker if HP is plugged */
1042 static void cxt5047_hp_automute(struct hda_codec *codec)
1044 struct conexant_spec *spec = codec->spec;
1047 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
1048 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1050 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
1051 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
1052 HDA_AMP_MUTE, bits);
1053 /* Mute/Unmute PCM 2 for good measure - some systems need this */
1054 snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
1055 HDA_AMP_MUTE, bits);
1058 /* mute internal speaker if HP is plugged */
1059 static void cxt5047_hp2_automute(struct hda_codec *codec)
1061 struct conexant_spec *spec = codec->spec;
1064 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
1065 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1067 bits = spec->hp_present ? HDA_AMP_MUTE : 0;
1068 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
1069 HDA_AMP_MUTE, bits);
1070 /* Mute/Unmute PCM 2 for good measure - some systems need this */
1071 snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
1072 HDA_AMP_MUTE, bits);
1075 /* toggle input of built-in and mic jack appropriately */
1076 static void cxt5047_hp_automic(struct hda_codec *codec)
1078 static struct hda_verb mic_jack_on[] = {
1079 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1080 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1083 static struct hda_verb mic_jack_off[] = {
1084 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1085 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1088 unsigned int present;
1090 present = snd_hda_codec_read(codec, 0x15, 0,
1091 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1093 snd_hda_sequence_write(codec, mic_jack_on);
1095 snd_hda_sequence_write(codec, mic_jack_off);
1098 /* unsolicited event for HP jack sensing */
1099 static void cxt5047_hp_unsol_event(struct hda_codec *codec,
1102 switch (res >> 26) {
1103 case CONEXANT_HP_EVENT:
1104 cxt5047_hp_automute(codec);
1106 case CONEXANT_MIC_EVENT:
1107 cxt5047_hp_automic(codec);
1112 /* unsolicited event for HP jack sensing - non-EAPD systems */
1113 static void cxt5047_hp2_unsol_event(struct hda_codec *codec,
1118 case CONEXANT_HP_EVENT:
1119 cxt5047_hp2_automute(codec);
1121 case CONEXANT_MIC_EVENT:
1122 cxt5047_hp_automic(codec);
1127 static struct snd_kcontrol_new cxt5047_mixers[] = {
1128 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1129 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1130 HDA_CODEC_VOLUME("Mic Gain Volume", 0x1a, 0x0, HDA_OUTPUT),
1131 HDA_CODEC_MUTE("Mic Gain Switch", 0x1a, 0x0, HDA_OUTPUT),
1132 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1133 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1134 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1135 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1136 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT),
1137 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT),
1138 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x00, HDA_OUTPUT),
1139 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x00, HDA_OUTPUT),
1140 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1141 HDA_CODEC_MUTE("Headphone Playback Switch", 0x13, 0x00, HDA_OUTPUT),
1146 static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = {
1148 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1149 .name = "Capture Source",
1150 .info = conexant_mux_enum_info,
1151 .get = conexant_mux_enum_get,
1152 .put = conexant_mux_enum_put
1154 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1155 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1156 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1157 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1158 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1159 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1160 HDA_BIND_VOL("Master Playback Volume", &cxt5047_bind_master_vol),
1162 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1163 .name = "Master Playback Switch",
1164 .info = cxt_eapd_info,
1165 .get = cxt_eapd_get,
1166 .put = cxt5047_hp_master_sw_put,
1167 .private_value = 0x13,
1173 static struct snd_kcontrol_new cxt5047_hp_mixers[] = {
1175 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1176 .name = "Capture Source",
1177 .info = conexant_mux_enum_info,
1178 .get = conexant_mux_enum_get,
1179 .put = conexant_mux_enum_put
1181 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1182 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19,0x02,HDA_INPUT),
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("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1190 .name = "Master Playback Switch",
1191 .info = cxt_eapd_info,
1192 .get = cxt_eapd_get,
1193 .put = cxt5047_hp_master_sw_put,
1194 .private_value = 0x13,
1199 static struct hda_verb cxt5047_init_verbs[] = {
1200 /* Line in, Mic, Built-in Mic */
1201 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1202 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1203 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1205 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1206 {0x13, AC_VERB_SET_CONNECT_SEL,0x1},
1207 {0x1d, AC_VERB_SET_CONNECT_SEL,0x0},
1208 /* Record selector: Mic */
1209 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1210 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1211 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1212 {0x1A, AC_VERB_SET_CONNECT_SEL,0x02},
1213 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1214 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1215 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1216 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
1217 /* SPDIF route: PCM */
1218 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
1219 /* Enable unsolicited events */
1220 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1221 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1225 /* configuration for Toshiba Laptops */
1226 static struct hda_verb cxt5047_toshiba_init_verbs[] = {
1227 {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0 }, /* default on */
1228 /* pin sensing on HP and Mic jacks */
1229 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1230 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1231 /* Speaker routing */
1232 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1236 /* configuration for HP Laptops */
1237 static struct hda_verb cxt5047_hp_init_verbs[] = {
1238 /* pin sensing on HP jack */
1239 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1240 /* 0x13 is actually shared by both HP and speaker;
1241 * setting the connection to 0 (=0x19) makes the master volume control
1242 * working mysteriouslly...
1244 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1245 /* Record selector: Ext Mic */
1246 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1247 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1248 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1249 /* Speaker routing */
1250 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1254 /* Test configuration for debugging, modelled after the ALC260 test
1257 #ifdef CONFIG_SND_DEBUG
1258 static struct hda_input_mux cxt5047_test_capture_source = {
1261 { "LINE1 pin", 0x0 },
1262 { "MIC1 pin", 0x1 },
1263 { "MIC2 pin", 0x2 },
1268 static struct snd_kcontrol_new cxt5047_test_mixer[] = {
1270 /* Output only controls */
1271 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT),
1272 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT),
1273 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT),
1274 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT),
1275 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1276 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1277 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1278 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1279 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT),
1280 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1281 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT),
1282 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT),
1284 /* Modes for retasking pin widgets */
1285 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT),
1286 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT),
1288 /* EAPD Switch Control */
1289 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1291 /* Loopback mixer controls */
1292 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT),
1293 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT),
1294 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT),
1295 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT),
1296 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT),
1297 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT),
1298 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT),
1299 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT),
1301 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT),
1302 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT),
1303 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT),
1304 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT),
1305 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT),
1306 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT),
1307 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT),
1308 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT),
1310 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1311 .name = "Input Source",
1312 .info = conexant_mux_enum_info,
1313 .get = conexant_mux_enum_get,
1314 .put = conexant_mux_enum_put,
1316 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),
1317 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),
1318 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
1319 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
1320 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
1321 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
1322 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
1323 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
1324 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
1325 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
1330 static struct hda_verb cxt5047_test_init_verbs[] = {
1331 /* Enable retasking pins as output, initially without power amp */
1332 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1333 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1334 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1336 /* Disable digital (SPDIF) pins initially, but users can enable
1337 * them via a mixer switch. In the case of SPDIF-out, this initverb
1338 * payload also sets the generation to 0, output to be in "consumer"
1339 * PCM format, copyright asserted, no pre-emphasis and no validity
1342 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
1344 /* Ensure mic1, mic2, line1 pin widgets take input from the
1345 * OUT1 sum bus when acting as an output.
1347 {0x1a, AC_VERB_SET_CONNECT_SEL, 0},
1348 {0x1b, AC_VERB_SET_CONNECT_SEL, 0},
1350 /* Start with output sum widgets muted and their output gains at min */
1351 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1352 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1354 /* Unmute retasking pin widget output buffers since the default
1355 * state appears to be output. As the pin mode is changed by the
1356 * user the pin mode control will take care of enabling the pin's
1357 * input/output buffers as needed.
1359 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1360 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1361 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1363 /* Mute capture amp left and right */
1364 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1366 /* Set ADC connection select to match default mixer setting (mic1
1369 {0x12, AC_VERB_SET_CONNECT_SEL, 0x00},
1371 /* Mute all inputs to mixer widget (even unconnected ones) */
1372 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
1373 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
1374 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
1375 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
1376 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
1377 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1378 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
1379 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
1386 /* initialize jack-sensing, too */
1387 static int cxt5047_hp_init(struct hda_codec *codec)
1389 conexant_init(codec);
1390 cxt5047_hp_automute(codec);
1396 CXT5047_LAPTOP, /* Laptops w/o EAPD support */
1397 CXT5047_LAPTOP_HP, /* Some HP laptops */
1398 CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */
1399 #ifdef CONFIG_SND_DEBUG
1405 static const char *cxt5047_models[CXT5047_MODELS] = {
1406 [CXT5047_LAPTOP] = "laptop",
1407 [CXT5047_LAPTOP_HP] = "laptop-hp",
1408 [CXT5047_LAPTOP_EAPD] = "laptop-eapd",
1409 #ifdef CONFIG_SND_DEBUG
1410 [CXT5047_TEST] = "test",
1414 static struct snd_pci_quirk cxt5047_cfg_tbl[] = {
1415 SND_PCI_QUIRK(0x103c, 0x30a0, "HP DV1000", CXT5047_LAPTOP),
1416 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
1417 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV2000T/DV3000T", CXT5047_LAPTOP),
1418 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2000Z", CXT5047_LAPTOP),
1419 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD),
1423 static int patch_cxt5047(struct hda_codec *codec)
1425 struct conexant_spec *spec;
1428 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1431 mutex_init(&spec->amp_mutex);
1434 spec->multiout.max_channels = 2;
1435 spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids);
1436 spec->multiout.dac_nids = cxt5047_dac_nids;
1437 spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT;
1438 spec->num_adc_nids = 1;
1439 spec->adc_nids = cxt5047_adc_nids;
1440 spec->capsrc_nids = cxt5047_capsrc_nids;
1441 spec->input_mux = &cxt5047_capture_source;
1442 spec->num_mixers = 1;
1443 spec->mixers[0] = cxt5047_mixers;
1444 spec->num_init_verbs = 1;
1445 spec->init_verbs[0] = cxt5047_init_verbs;
1446 spec->spdif_route = 0;
1447 spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes),
1448 spec->channel_mode = cxt5047_modes,
1450 codec->patch_ops = conexant_patch_ops;
1452 board_config = snd_hda_check_board_config(codec, CXT5047_MODELS,
1455 switch (board_config) {
1456 case CXT5047_LAPTOP:
1457 codec->patch_ops.unsol_event = cxt5047_hp2_unsol_event;
1459 case CXT5047_LAPTOP_HP:
1460 spec->input_mux = &cxt5047_hp_capture_source;
1461 spec->num_init_verbs = 2;
1462 spec->init_verbs[1] = cxt5047_hp_init_verbs;
1463 spec->mixers[0] = cxt5047_hp_mixers;
1464 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1465 codec->patch_ops.init = cxt5047_hp_init;
1467 case CXT5047_LAPTOP_EAPD:
1468 spec->input_mux = &cxt5047_toshiba_capture_source;
1469 spec->num_init_verbs = 2;
1470 spec->init_verbs[1] = cxt5047_toshiba_init_verbs;
1471 spec->mixers[0] = cxt5047_toshiba_mixers;
1472 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1474 #ifdef CONFIG_SND_DEBUG
1476 spec->input_mux = &cxt5047_test_capture_source;
1477 spec->mixers[0] = cxt5047_test_mixer;
1478 spec->init_verbs[0] = cxt5047_test_init_verbs;
1479 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1485 /* Conexant 5051 specific */
1486 static hda_nid_t cxt5051_dac_nids[1] = { 0x10 };
1487 static hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 };
1488 #define CXT5051_SPDIF_OUT 0x1C
1489 #define CXT5051_PORTB_EVENT 0x38
1490 #define CXT5051_PORTC_EVENT 0x39
1492 static struct hda_channel_mode cxt5051_modes[1] = {
1496 static void cxt5051_update_speaker(struct hda_codec *codec)
1498 struct conexant_spec *spec = codec->spec;
1499 unsigned int pinctl;
1500 pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0;
1501 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
1505 /* turn on/off EAPD (+ mute HP) as a master switch */
1506 static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1507 struct snd_ctl_elem_value *ucontrol)
1509 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1511 if (!cxt_eapd_put(kcontrol, ucontrol))
1513 cxt5051_update_speaker(codec);
1517 /* toggle input of built-in and mic jack appropriately */
1518 static void cxt5051_portb_automic(struct hda_codec *codec)
1520 unsigned int present;
1522 present = snd_hda_codec_read(codec, 0x17, 0,
1523 AC_VERB_GET_PIN_SENSE, 0) &
1524 AC_PINSENSE_PRESENCE;
1525 snd_hda_codec_write(codec, 0x14, 0,
1526 AC_VERB_SET_CONNECT_SEL,
1527 present ? 0x01 : 0x00);
1530 /* switch the current ADC according to the jack state */
1531 static void cxt5051_portc_automic(struct hda_codec *codec)
1533 struct conexant_spec *spec = codec->spec;
1534 unsigned int present;
1537 present = snd_hda_codec_read(codec, 0x18, 0,
1538 AC_VERB_GET_PIN_SENSE, 0) &
1539 AC_PINSENSE_PRESENCE;
1541 spec->cur_adc_idx = 1;
1543 spec->cur_adc_idx = 0;
1544 new_adc = spec->adc_nids[spec->cur_adc_idx];
1545 if (spec->cur_adc && spec->cur_adc != new_adc) {
1546 /* stream is running, let's swap the current ADC */
1547 snd_hda_codec_setup_stream(codec, spec->cur_adc, 0, 0, 0);
1548 spec->cur_adc = new_adc;
1549 snd_hda_codec_setup_stream(codec, new_adc,
1550 spec->cur_adc_stream_tag, 0,
1551 spec->cur_adc_format);
1555 /* mute internal speaker if HP is plugged */
1556 static void cxt5051_hp_automute(struct hda_codec *codec)
1558 struct conexant_spec *spec = codec->spec;
1560 spec->hp_present = snd_hda_codec_read(codec, 0x16, 0,
1561 AC_VERB_GET_PIN_SENSE, 0) &
1562 AC_PINSENSE_PRESENCE;
1563 cxt5051_update_speaker(codec);
1566 /* unsolicited event for HP jack sensing */
1567 static void cxt5051_hp_unsol_event(struct hda_codec *codec,
1570 switch (res >> 26) {
1571 case CONEXANT_HP_EVENT:
1572 cxt5051_hp_automute(codec);
1574 case CXT5051_PORTB_EVENT:
1575 cxt5051_portb_automic(codec);
1577 case CXT5051_PORTC_EVENT:
1578 cxt5051_portc_automic(codec);
1583 static struct snd_kcontrol_new cxt5051_mixers[] = {
1584 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
1585 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
1586 HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT),
1587 HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT),
1588 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT),
1589 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT),
1590 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1592 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1593 .name = "Master Playback Switch",
1594 .info = cxt_eapd_info,
1595 .get = cxt_eapd_get,
1596 .put = cxt5051_hp_master_sw_put,
1597 .private_value = 0x1a,
1603 static struct snd_kcontrol_new cxt5051_hp_mixers[] = {
1604 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
1605 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
1606 HDA_CODEC_VOLUME("External Mic Volume", 0x15, 0x00, HDA_INPUT),
1607 HDA_CODEC_MUTE("External Mic Switch", 0x15, 0x00, HDA_INPUT),
1608 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1610 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1611 .name = "Master Playback Switch",
1612 .info = cxt_eapd_info,
1613 .get = cxt_eapd_get,
1614 .put = cxt5051_hp_master_sw_put,
1615 .private_value = 0x1a,
1621 static struct hda_verb cxt5051_init_verbs[] = {
1623 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1624 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1625 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1626 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1627 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1628 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1630 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1631 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1633 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1634 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
1636 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1637 /* Record selector: Int mic */
1638 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1639 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
1640 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1641 /* SPDIF route: PCM */
1642 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
1644 {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
1645 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1646 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT},
1647 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTC_EVENT},
1651 /* initialize jack-sensing, too */
1652 static int cxt5051_init(struct hda_codec *codec)
1654 conexant_init(codec);
1655 if (codec->patch_ops.unsol_event) {
1656 cxt5051_hp_automute(codec);
1657 cxt5051_portb_automic(codec);
1658 cxt5051_portc_automic(codec);
1665 CXT5051_LAPTOP, /* Laptops w/ EAPD support */
1666 CXT5051_HP, /* no docking */
1670 static const char *cxt5051_models[CXT5051_MODELS] = {
1671 [CXT5051_LAPTOP] = "laptop",
1672 [CXT5051_HP] = "hp",
1675 static struct snd_pci_quirk cxt5051_cfg_tbl[] = {
1676 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1678 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP),
1682 static int patch_cxt5051(struct hda_codec *codec)
1684 struct conexant_spec *spec;
1687 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1690 mutex_init(&spec->amp_mutex);
1693 codec->patch_ops = conexant_patch_ops;
1694 codec->patch_ops.init = cxt5051_init;
1696 spec->multiout.max_channels = 2;
1697 spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids);
1698 spec->multiout.dac_nids = cxt5051_dac_nids;
1699 spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT;
1700 spec->num_adc_nids = 1; /* not 2; via auto-mic switch */
1701 spec->adc_nids = cxt5051_adc_nids;
1702 spec->num_mixers = 1;
1703 spec->mixers[0] = cxt5051_mixers;
1704 spec->num_init_verbs = 1;
1705 spec->init_verbs[0] = cxt5051_init_verbs;
1706 spec->spdif_route = 0;
1707 spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes);
1708 spec->channel_mode = cxt5051_modes;
1710 spec->cur_adc_idx = 0;
1712 board_config = snd_hda_check_board_config(codec, CXT5051_MODELS,
1715 switch (board_config) {
1717 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
1718 spec->mixers[0] = cxt5051_hp_mixers;
1721 case CXT5051_LAPTOP:
1722 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
1733 struct hda_codec_preset snd_hda_preset_conexant[] = {
1734 { .id = 0x14f15045, .name = "CX20549 (Venice)",
1735 .patch = patch_cxt5045 },
1736 { .id = 0x14f15047, .name = "CX20551 (Waikiki)",
1737 .patch = patch_cxt5047 },
1738 { .id = 0x14f15051, .name = "CX20561 (Hermosa)",
1739 .patch = patch_cxt5051 },