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);
104 static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
105 struct hda_codec *codec,
106 unsigned int stream_tag,
108 struct snd_pcm_substream *substream)
110 struct conexant_spec *spec = codec->spec;
111 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
116 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
117 struct hda_codec *codec,
118 struct snd_pcm_substream *substream)
120 struct conexant_spec *spec = codec->spec;
121 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
127 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
128 struct hda_codec *codec,
129 struct snd_pcm_substream *substream)
131 struct conexant_spec *spec = codec->spec;
132 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
135 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
136 struct hda_codec *codec,
137 struct snd_pcm_substream *substream)
139 struct conexant_spec *spec = codec->spec;
140 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
143 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
144 struct hda_codec *codec,
145 unsigned int stream_tag,
147 struct snd_pcm_substream *substream)
149 struct conexant_spec *spec = codec->spec;
150 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
158 static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
159 struct hda_codec *codec,
160 unsigned int stream_tag,
162 struct snd_pcm_substream *substream)
164 struct conexant_spec *spec = codec->spec;
165 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
166 stream_tag, 0, format);
170 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
171 struct hda_codec *codec,
172 struct snd_pcm_substream *substream)
174 struct conexant_spec *spec = codec->spec;
175 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
182 static struct hda_pcm_stream conexant_pcm_analog_playback = {
186 .nid = 0, /* fill later */
188 .open = conexant_playback_pcm_open,
189 .prepare = conexant_playback_pcm_prepare,
190 .cleanup = conexant_playback_pcm_cleanup
194 static struct hda_pcm_stream conexant_pcm_analog_capture = {
198 .nid = 0, /* fill later */
200 .prepare = conexant_capture_pcm_prepare,
201 .cleanup = conexant_capture_pcm_cleanup
206 static struct hda_pcm_stream conexant_pcm_digital_playback = {
210 .nid = 0, /* fill later */
212 .open = conexant_dig_playback_pcm_open,
213 .close = conexant_dig_playback_pcm_close,
214 .prepare = conexant_dig_playback_pcm_prepare
218 static struct hda_pcm_stream conexant_pcm_digital_capture = {
222 /* NID is set in alc_build_pcms */
225 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
226 struct hda_codec *codec,
227 unsigned int stream_tag,
229 struct snd_pcm_substream *substream)
231 struct conexant_spec *spec = codec->spec;
232 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
233 spec->cur_adc_stream_tag = stream_tag;
234 spec->cur_adc_format = format;
235 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
239 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
240 struct hda_codec *codec,
241 struct snd_pcm_substream *substream)
243 struct conexant_spec *spec = codec->spec;
244 snd_hda_codec_setup_stream(codec, spec->cur_adc, 0, 0, 0);
249 static struct hda_pcm_stream cx5051_pcm_analog_capture = {
253 .nid = 0, /* fill later */
255 .prepare = cx5051_capture_pcm_prepare,
256 .cleanup = cx5051_capture_pcm_cleanup
260 static int conexant_build_pcms(struct hda_codec *codec)
262 struct conexant_spec *spec = codec->spec;
263 struct hda_pcm *info = spec->pcm_rec;
266 codec->pcm_info = info;
268 info->name = "CONEXANT Analog";
269 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback;
270 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max =
271 spec->multiout.max_channels;
272 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
273 spec->multiout.dac_nids[0];
274 if (codec->vendor_id == 0x14f15051)
275 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
276 cx5051_pcm_analog_capture;
278 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
279 conexant_pcm_analog_capture;
280 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
281 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
283 if (spec->multiout.dig_out_nid) {
286 info->name = "Conexant Digital";
287 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
288 conexant_pcm_digital_playback;
289 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
290 spec->multiout.dig_out_nid;
291 if (spec->dig_in_nid) {
292 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
293 conexant_pcm_digital_capture;
294 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
302 static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol,
303 struct snd_ctl_elem_info *uinfo)
305 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
306 struct conexant_spec *spec = codec->spec;
308 return snd_hda_input_mux_info(spec->input_mux, uinfo);
311 static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol,
312 struct snd_ctl_elem_value *ucontrol)
314 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
315 struct conexant_spec *spec = codec->spec;
316 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
318 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
322 static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol,
323 struct snd_ctl_elem_value *ucontrol)
325 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
326 struct conexant_spec *spec = codec->spec;
327 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
329 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
330 spec->capsrc_nids[adc_idx],
331 &spec->cur_mux[adc_idx]);
334 static int conexant_init(struct hda_codec *codec)
336 struct conexant_spec *spec = codec->spec;
339 for (i = 0; i < spec->num_init_verbs; i++)
340 snd_hda_sequence_write(codec, spec->init_verbs[i]);
344 static void conexant_free(struct hda_codec *codec)
346 struct conexant_spec *spec = codec->spec;
349 if (spec->kctl_alloc) {
350 for (i = 0; i < spec->num_kctl_used; i++)
351 kfree(spec->kctl_alloc[i].name);
352 kfree(spec->kctl_alloc);
358 static int conexant_build_controls(struct hda_codec *codec)
360 struct conexant_spec *spec = codec->spec;
364 for (i = 0; i < spec->num_mixers; i++) {
365 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
369 if (spec->multiout.dig_out_nid) {
370 err = snd_hda_create_spdif_out_ctls(codec,
371 spec->multiout.dig_out_nid);
375 if (spec->dig_in_nid) {
376 err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid);
383 static struct hda_codec_ops conexant_patch_ops = {
384 .build_controls = conexant_build_controls,
385 .build_pcms = conexant_build_pcms,
386 .init = conexant_init,
387 .free = conexant_free,
392 * the private value = nid | (invert << 8)
395 #define cxt_eapd_info snd_ctl_boolean_mono_info
397 static int cxt_eapd_get(struct snd_kcontrol *kcontrol,
398 struct snd_ctl_elem_value *ucontrol)
400 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
401 struct conexant_spec *spec = codec->spec;
402 int invert = (kcontrol->private_value >> 8) & 1;
404 ucontrol->value.integer.value[0] = !spec->cur_eapd;
406 ucontrol->value.integer.value[0] = spec->cur_eapd;
411 static int cxt_eapd_put(struct snd_kcontrol *kcontrol,
412 struct snd_ctl_elem_value *ucontrol)
414 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
415 struct conexant_spec *spec = codec->spec;
416 int invert = (kcontrol->private_value >> 8) & 1;
417 hda_nid_t nid = kcontrol->private_value & 0xff;
420 eapd = !!ucontrol->value.integer.value[0];
423 if (eapd == spec->cur_eapd)
426 spec->cur_eapd = eapd;
427 snd_hda_codec_write_cache(codec, nid,
428 0, AC_VERB_SET_EAPD_BTLENABLE,
433 /* controls for test mode */
434 #ifdef CONFIG_SND_DEBUG
436 #define CXT_EAPD_SWITCH(xname, nid, mask) \
437 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
438 .info = cxt_eapd_info, \
439 .get = cxt_eapd_get, \
440 .put = cxt_eapd_put, \
441 .private_value = nid | (mask<<16) }
445 static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol,
446 struct snd_ctl_elem_info *uinfo)
448 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
449 struct conexant_spec *spec = codec->spec;
450 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
451 spec->num_channel_mode);
454 static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol,
455 struct snd_ctl_elem_value *ucontrol)
457 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
458 struct conexant_spec *spec = codec->spec;
459 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
460 spec->num_channel_mode,
461 spec->multiout.max_channels);
464 static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol,
465 struct snd_ctl_elem_value *ucontrol)
467 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
468 struct conexant_spec *spec = codec->spec;
469 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
470 spec->num_channel_mode,
471 &spec->multiout.max_channels);
472 if (err >= 0 && spec->need_dac_fix)
473 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
477 #define CXT_PIN_MODE(xname, nid, dir) \
478 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
479 .info = conexant_ch_mode_info, \
480 .get = conexant_ch_mode_get, \
481 .put = conexant_ch_mode_put, \
482 .private_value = nid | (dir<<16) }
484 #endif /* CONFIG_SND_DEBUG */
486 /* Conexant 5045 specific */
488 static hda_nid_t cxt5045_dac_nids[1] = { 0x19 };
489 static hda_nid_t cxt5045_adc_nids[1] = { 0x1a };
490 static hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a };
491 #define CXT5045_SPDIF_OUT 0x13
493 static struct hda_channel_mode cxt5045_modes[1] = {
497 static struct hda_input_mux cxt5045_capture_source = {
505 static struct hda_input_mux cxt5045_capture_source_benq = {
514 /* turn on/off EAPD (+ mute HP) as a master switch */
515 static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
516 struct snd_ctl_elem_value *ucontrol)
518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
519 struct conexant_spec *spec = codec->spec;
522 if (!cxt_eapd_put(kcontrol, ucontrol))
525 /* toggle internal speakers mute depending of presence of
528 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
529 snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
532 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
533 snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0,
538 /* bind volumes of both NID 0x10 and 0x11 */
539 static struct hda_bind_ctls cxt5045_hp_bind_master_vol = {
540 .ops = &snd_hda_bind_vol,
542 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT),
543 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
548 /* toggle input of built-in and mic jack appropriately */
549 static void cxt5045_hp_automic(struct hda_codec *codec)
551 static struct hda_verb mic_jack_on[] = {
552 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
553 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
556 static struct hda_verb mic_jack_off[] = {
557 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
558 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
561 unsigned int present;
563 present = snd_hda_codec_read(codec, 0x12, 0,
564 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
566 snd_hda_sequence_write(codec, mic_jack_on);
568 snd_hda_sequence_write(codec, mic_jack_off);
572 /* mute internal speaker if HP is plugged */
573 static void cxt5045_hp_automute(struct hda_codec *codec)
575 struct conexant_spec *spec = codec->spec;
578 spec->hp_present = snd_hda_codec_read(codec, 0x11, 0,
579 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
581 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
582 snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
586 /* unsolicited event for HP jack sensing */
587 static void cxt5045_hp_unsol_event(struct hda_codec *codec,
592 case CONEXANT_HP_EVENT:
593 cxt5045_hp_automute(codec);
595 case CONEXANT_MIC_EVENT:
596 cxt5045_hp_automic(codec);
602 static struct snd_kcontrol_new cxt5045_mixers[] = {
604 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
605 .name = "Capture Source",
606 .info = conexant_mux_enum_info,
607 .get = conexant_mux_enum_get,
608 .put = conexant_mux_enum_put
610 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
611 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
612 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
613 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
614 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
615 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
616 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
617 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
618 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
619 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
620 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
622 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
623 .name = "Master Playback Switch",
624 .info = cxt_eapd_info,
626 .put = cxt5045_hp_master_sw_put,
627 .private_value = 0x10,
633 static struct snd_kcontrol_new cxt5045_benq_mixers[] = {
634 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT),
635 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT),
636 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT),
637 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT),
642 static struct hda_verb cxt5045_init_verbs[] = {
644 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
645 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
647 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
648 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
649 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
650 {0x11, AC_VERB_SET_CONNECT_SEL, 0x1},
651 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
652 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
653 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
654 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
655 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
656 /* Record selector: Int mic */
657 {0x1a, AC_VERB_SET_CONNECT_SEL,0x1},
658 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
659 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
660 /* SPDIF route: PCM */
661 { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
663 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */
667 static struct hda_verb cxt5045_benq_init_verbs[] = {
669 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
670 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
671 /* Line In,HP, Amp */
672 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
673 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
674 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
675 {0x11, AC_VERB_SET_CONNECT_SEL, 0x1},
676 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
677 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
678 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
679 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
680 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
681 /* Record selector: Int mic */
682 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x1},
683 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
684 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
685 /* SPDIF route: PCM */
686 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
688 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
692 static struct hda_verb cxt5045_hp_sense_init_verbs[] = {
693 /* pin sensing on HP jack */
694 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
698 static struct hda_verb cxt5045_mic_sense_init_verbs[] = {
699 /* pin sensing on HP jack */
700 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
704 #ifdef CONFIG_SND_DEBUG
705 /* Test configuration for debugging, modelled after the ALC260 test
708 static struct hda_input_mux cxt5045_test_capture_source = {
713 { "LINE1 pin", 0x2 },
714 { "HP-OUT pin", 0x3 },
719 static struct snd_kcontrol_new cxt5045_test_mixer[] = {
721 /* Output controls */
722 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
723 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
724 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT),
725 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT),
726 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT),
727 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT),
729 /* Modes for retasking pin widgets */
730 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
731 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT),
733 /* EAPD Switch Control */
734 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
736 /* Loopback mixer controls */
738 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT),
739 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT),
740 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT),
741 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT),
742 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT),
743 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT),
744 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT),
745 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT),
746 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT),
747 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT),
749 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
750 .name = "Input Source",
751 .info = conexant_mux_enum_info,
752 .get = conexant_mux_enum_get,
753 .put = conexant_mux_enum_put,
755 /* Audio input controls */
756 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),
757 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),
758 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
759 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
760 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
761 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
762 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
763 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
764 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
765 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
769 static struct hda_verb cxt5045_test_init_verbs[] = {
770 /* Set connections */
771 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
772 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 },
773 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 },
774 /* Enable retasking pins as output, initially without power amp */
775 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
776 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
778 /* Disable digital (SPDIF) pins initially, but users can enable
779 * them via a mixer switch. In the case of SPDIF-out, this initverb
780 * payload also sets the generation to 0, output to be in "consumer"
781 * PCM format, copyright asserted, no pre-emphasis and no validity
784 {0x13, AC_VERB_SET_DIGI_CONVERT_1, 0},
786 /* Start with output sum widgets muted and their output gains at min */
787 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
788 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
790 /* Unmute retasking pin widget output buffers since the default
791 * state appears to be output. As the pin mode is changed by the
792 * user the pin mode control will take care of enabling the pin's
793 * input/output buffers as needed.
795 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
796 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
798 /* Mute capture amp left and right */
799 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
801 /* Set ADC connection select to match default mixer setting (mic1
804 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
805 {0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
807 /* Mute all inputs to mixer widget (even unconnected ones) */
808 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */
809 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */
810 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */
811 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */
812 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
819 /* initialize jack-sensing, too */
820 static int cxt5045_init(struct hda_codec *codec)
822 conexant_init(codec);
823 cxt5045_hp_automute(codec);
829 CXT5045_LAPTOP_HPSENSE,
830 CXT5045_LAPTOP_MICSENSE,
831 CXT5045_LAPTOP_HPMICSENSE,
833 #ifdef CONFIG_SND_DEBUG
839 static const char *cxt5045_models[CXT5045_MODELS] = {
840 [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense",
841 [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense",
842 [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense",
843 [CXT5045_BENQ] = "benq",
844 #ifdef CONFIG_SND_DEBUG
845 [CXT5045_TEST] = "test",
849 static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
850 SND_PCI_QUIRK(0x103c, 0x30a5, "HP", CXT5045_LAPTOP_HPSENSE),
851 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
852 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2120", CXT5045_LAPTOP_HPSENSE),
853 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP_HPSENSE),
854 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP_HPSENSE),
855 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
856 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV9533EG", CXT5045_LAPTOP_HPSENSE),
857 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HPSENSE),
858 SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP_HPSENSE),
859 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ),
860 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE),
861 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE),
862 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505", CXT5045_LAPTOP_HPSENSE),
863 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE),
864 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE),
865 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE),
866 SND_PCI_QUIRK(0x1631, 0xc106, "Packard Bell", CXT5045_LAPTOP_HPMICSENSE),
867 SND_PCI_QUIRK(0x1631, 0xc107, "Packard Bell", CXT5045_LAPTOP_HPMICSENSE),
868 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE),
872 static int patch_cxt5045(struct hda_codec *codec)
874 struct conexant_spec *spec;
877 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
880 mutex_init(&spec->amp_mutex);
883 spec->multiout.max_channels = 2;
884 spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids);
885 spec->multiout.dac_nids = cxt5045_dac_nids;
886 spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT;
887 spec->num_adc_nids = 1;
888 spec->adc_nids = cxt5045_adc_nids;
889 spec->capsrc_nids = cxt5045_capsrc_nids;
890 spec->input_mux = &cxt5045_capture_source;
891 spec->num_mixers = 1;
892 spec->mixers[0] = cxt5045_mixers;
893 spec->num_init_verbs = 1;
894 spec->init_verbs[0] = cxt5045_init_verbs;
895 spec->spdif_route = 0;
896 spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes),
897 spec->channel_mode = cxt5045_modes,
900 codec->patch_ops = conexant_patch_ops;
902 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
905 switch (board_config) {
906 case CXT5045_LAPTOP_HPSENSE:
907 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
908 spec->input_mux = &cxt5045_capture_source;
909 spec->num_init_verbs = 2;
910 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
911 spec->mixers[0] = cxt5045_mixers;
912 codec->patch_ops.init = cxt5045_init;
914 case CXT5045_LAPTOP_MICSENSE:
915 spec->input_mux = &cxt5045_capture_source;
916 spec->num_init_verbs = 2;
917 spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;
918 spec->mixers[0] = cxt5045_mixers;
919 codec->patch_ops.init = cxt5045_init;
922 case CXT5045_LAPTOP_HPMICSENSE:
923 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
924 spec->input_mux = &cxt5045_capture_source;
925 spec->num_init_verbs = 3;
926 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
927 spec->init_verbs[2] = cxt5045_mic_sense_init_verbs;
928 spec->mixers[0] = cxt5045_mixers;
929 codec->patch_ops.init = cxt5045_init;
932 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
933 spec->input_mux = &cxt5045_capture_source_benq;
934 spec->num_init_verbs = 1;
935 spec->init_verbs[0] = cxt5045_benq_init_verbs;
936 spec->mixers[0] = cxt5045_mixers;
937 spec->mixers[1] = cxt5045_benq_mixers;
938 spec->num_mixers = 2;
939 codec->patch_ops.init = cxt5045_init;
941 #ifdef CONFIG_SND_DEBUG
943 spec->input_mux = &cxt5045_test_capture_source;
944 spec->mixers[0] = cxt5045_test_mixer;
945 spec->init_verbs[0] = cxt5045_test_init_verbs;
952 * Fix max PCM level to 0 dB
953 * (originall it has 0x2b steps with 0dB offset 0x14)
955 snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT,
956 (0x14 << AC_AMPCAP_OFFSET_SHIFT) |
957 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) |
958 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
959 (1 << AC_AMPCAP_MUTE_SHIFT));
965 /* Conexant 5047 specific */
966 #define CXT5047_SPDIF_OUT 0x11
968 static hda_nid_t cxt5047_dac_nids[2] = { 0x10, 0x1c };
969 static hda_nid_t cxt5047_adc_nids[1] = { 0x12 };
970 static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a };
972 static struct hda_channel_mode cxt5047_modes[1] = {
976 static struct hda_input_mux cxt5047_capture_source = {
983 static struct hda_input_mux cxt5047_hp_capture_source = {
990 static struct hda_input_mux cxt5047_toshiba_capture_source = {
998 /* turn on/off EAPD (+ mute HP) as a master switch */
999 static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1000 struct snd_ctl_elem_value *ucontrol)
1002 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1003 struct conexant_spec *spec = codec->spec;
1006 if (!cxt_eapd_put(kcontrol, ucontrol))
1009 /* toggle internal speakers mute depending of presence of
1010 * the headphone jack
1012 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
1013 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
1014 HDA_AMP_MUTE, bits);
1015 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
1016 snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0,
1017 HDA_AMP_MUTE, bits);
1021 /* bind volumes of both NID 0x13 (Headphones) and 0x1d (Speakers) */
1022 static struct hda_bind_ctls cxt5047_bind_master_vol = {
1023 .ops = &snd_hda_bind_vol,
1025 HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
1026 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
1031 /* mute internal speaker if HP is plugged */
1032 static void cxt5047_hp_automute(struct hda_codec *codec)
1034 struct conexant_spec *spec = codec->spec;
1037 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
1038 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1040 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
1041 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
1042 HDA_AMP_MUTE, bits);
1043 /* Mute/Unmute PCM 2 for good measure - some systems need this */
1044 snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
1045 HDA_AMP_MUTE, bits);
1048 /* mute internal speaker if HP is plugged */
1049 static void cxt5047_hp2_automute(struct hda_codec *codec)
1051 struct conexant_spec *spec = codec->spec;
1054 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
1055 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1057 bits = spec->hp_present ? HDA_AMP_MUTE : 0;
1058 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
1059 HDA_AMP_MUTE, bits);
1060 /* Mute/Unmute PCM 2 for good measure - some systems need this */
1061 snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
1062 HDA_AMP_MUTE, bits);
1065 /* toggle input of built-in and mic jack appropriately */
1066 static void cxt5047_hp_automic(struct hda_codec *codec)
1068 static struct hda_verb mic_jack_on[] = {
1069 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1070 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1073 static struct hda_verb mic_jack_off[] = {
1074 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1075 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1078 unsigned int present;
1080 present = snd_hda_codec_read(codec, 0x15, 0,
1081 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1083 snd_hda_sequence_write(codec, mic_jack_on);
1085 snd_hda_sequence_write(codec, mic_jack_off);
1088 /* unsolicited event for HP jack sensing */
1089 static void cxt5047_hp_unsol_event(struct hda_codec *codec,
1092 switch (res >> 26) {
1093 case CONEXANT_HP_EVENT:
1094 cxt5047_hp_automute(codec);
1096 case CONEXANT_MIC_EVENT:
1097 cxt5047_hp_automic(codec);
1102 /* unsolicited event for HP jack sensing - non-EAPD systems */
1103 static void cxt5047_hp2_unsol_event(struct hda_codec *codec,
1108 case CONEXANT_HP_EVENT:
1109 cxt5047_hp2_automute(codec);
1111 case CONEXANT_MIC_EVENT:
1112 cxt5047_hp_automic(codec);
1117 static struct snd_kcontrol_new cxt5047_mixers[] = {
1118 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1119 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1120 HDA_CODEC_VOLUME("Mic Gain Volume", 0x1a, 0x0, HDA_OUTPUT),
1121 HDA_CODEC_MUTE("Mic Gain Switch", 0x1a, 0x0, HDA_OUTPUT),
1122 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1123 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1124 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1125 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1126 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT),
1127 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT),
1128 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x00, HDA_OUTPUT),
1129 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x00, HDA_OUTPUT),
1130 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1131 HDA_CODEC_MUTE("Headphone Playback Switch", 0x13, 0x00, HDA_OUTPUT),
1136 static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = {
1138 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1139 .name = "Capture Source",
1140 .info = conexant_mux_enum_info,
1141 .get = conexant_mux_enum_get,
1142 .put = conexant_mux_enum_put
1144 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1145 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1146 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1147 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1148 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1149 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1150 HDA_BIND_VOL("Master Playback Volume", &cxt5047_bind_master_vol),
1152 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1153 .name = "Master Playback Switch",
1154 .info = cxt_eapd_info,
1155 .get = cxt_eapd_get,
1156 .put = cxt5047_hp_master_sw_put,
1157 .private_value = 0x13,
1163 static struct snd_kcontrol_new cxt5047_hp_mixers[] = {
1165 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1166 .name = "Capture Source",
1167 .info = conexant_mux_enum_info,
1168 .get = conexant_mux_enum_get,
1169 .put = conexant_mux_enum_put
1171 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1172 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19,0x02,HDA_INPUT),
1173 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1174 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1175 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1176 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1177 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1179 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1180 .name = "Master Playback Switch",
1181 .info = cxt_eapd_info,
1182 .get = cxt_eapd_get,
1183 .put = cxt5047_hp_master_sw_put,
1184 .private_value = 0x13,
1189 static struct hda_verb cxt5047_init_verbs[] = {
1190 /* Line in, Mic, Built-in Mic */
1191 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1192 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1193 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1195 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1196 {0x13, AC_VERB_SET_CONNECT_SEL,0x1},
1197 {0x1d, AC_VERB_SET_CONNECT_SEL,0x0},
1198 /* Record selector: Mic */
1199 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1200 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1201 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1202 {0x1A, AC_VERB_SET_CONNECT_SEL,0x02},
1203 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1204 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1205 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1206 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
1207 /* SPDIF route: PCM */
1208 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
1209 /* Enable unsolicited events */
1210 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1211 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1215 /* configuration for Toshiba Laptops */
1216 static struct hda_verb cxt5047_toshiba_init_verbs[] = {
1217 {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0 }, /* default on */
1218 /* pin sensing on HP and Mic jacks */
1219 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1220 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1221 /* Speaker routing */
1222 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1226 /* configuration for HP Laptops */
1227 static struct hda_verb cxt5047_hp_init_verbs[] = {
1228 /* pin sensing on HP jack */
1229 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1230 /* Record selector: Ext Mic */
1231 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1232 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1233 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1234 /* Speaker routing */
1235 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1239 /* Test configuration for debugging, modelled after the ALC260 test
1242 #ifdef CONFIG_SND_DEBUG
1243 static struct hda_input_mux cxt5047_test_capture_source = {
1246 { "LINE1 pin", 0x0 },
1247 { "MIC1 pin", 0x1 },
1248 { "MIC2 pin", 0x2 },
1253 static struct snd_kcontrol_new cxt5047_test_mixer[] = {
1255 /* Output only controls */
1256 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT),
1257 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT),
1258 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT),
1259 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT),
1260 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1261 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1262 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1263 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1264 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT),
1265 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1266 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT),
1267 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT),
1269 /* Modes for retasking pin widgets */
1270 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT),
1271 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT),
1273 /* EAPD Switch Control */
1274 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1276 /* Loopback mixer controls */
1277 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT),
1278 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT),
1279 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT),
1280 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT),
1281 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT),
1282 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT),
1283 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT),
1284 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT),
1286 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT),
1287 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT),
1288 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT),
1289 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT),
1290 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT),
1291 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT),
1292 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT),
1293 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT),
1295 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1296 .name = "Input Source",
1297 .info = conexant_mux_enum_info,
1298 .get = conexant_mux_enum_get,
1299 .put = conexant_mux_enum_put,
1301 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),
1302 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),
1303 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
1304 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
1305 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
1306 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
1307 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
1308 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
1309 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
1310 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
1315 static struct hda_verb cxt5047_test_init_verbs[] = {
1316 /* Enable retasking pins as output, initially without power amp */
1317 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1318 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1319 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1321 /* Disable digital (SPDIF) pins initially, but users can enable
1322 * them via a mixer switch. In the case of SPDIF-out, this initverb
1323 * payload also sets the generation to 0, output to be in "consumer"
1324 * PCM format, copyright asserted, no pre-emphasis and no validity
1327 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
1329 /* Ensure mic1, mic2, line1 pin widgets take input from the
1330 * OUT1 sum bus when acting as an output.
1332 {0x1a, AC_VERB_SET_CONNECT_SEL, 0},
1333 {0x1b, AC_VERB_SET_CONNECT_SEL, 0},
1335 /* Start with output sum widgets muted and their output gains at min */
1336 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1337 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1339 /* Unmute retasking pin widget output buffers since the default
1340 * state appears to be output. As the pin mode is changed by the
1341 * user the pin mode control will take care of enabling the pin's
1342 * input/output buffers as needed.
1344 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1345 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1346 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1348 /* Mute capture amp left and right */
1349 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1351 /* Set ADC connection select to match default mixer setting (mic1
1354 {0x12, AC_VERB_SET_CONNECT_SEL, 0x00},
1356 /* Mute all inputs to mixer widget (even unconnected ones) */
1357 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
1358 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
1359 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
1360 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
1361 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
1362 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1363 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
1364 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
1371 /* initialize jack-sensing, too */
1372 static int cxt5047_hp_init(struct hda_codec *codec)
1374 conexant_init(codec);
1375 cxt5047_hp_automute(codec);
1381 CXT5047_LAPTOP, /* Laptops w/o EAPD support */
1382 CXT5047_LAPTOP_HP, /* Some HP laptops */
1383 CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */
1384 #ifdef CONFIG_SND_DEBUG
1390 static const char *cxt5047_models[CXT5047_MODELS] = {
1391 [CXT5047_LAPTOP] = "laptop",
1392 [CXT5047_LAPTOP_HP] = "laptop-hp",
1393 [CXT5047_LAPTOP_EAPD] = "laptop-eapd",
1394 #ifdef CONFIG_SND_DEBUG
1395 [CXT5047_TEST] = "test",
1399 static struct snd_pci_quirk cxt5047_cfg_tbl[] = {
1400 SND_PCI_QUIRK(0x103c, 0x30a0, "HP DV1000", CXT5047_LAPTOP),
1401 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
1402 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV2000T/DV3000T", CXT5047_LAPTOP),
1403 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2000Z", CXT5047_LAPTOP),
1404 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD),
1408 static int patch_cxt5047(struct hda_codec *codec)
1410 struct conexant_spec *spec;
1413 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1416 mutex_init(&spec->amp_mutex);
1419 spec->multiout.max_channels = 2;
1420 spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids);
1421 spec->multiout.dac_nids = cxt5047_dac_nids;
1422 spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT;
1423 spec->num_adc_nids = 1;
1424 spec->adc_nids = cxt5047_adc_nids;
1425 spec->capsrc_nids = cxt5047_capsrc_nids;
1426 spec->input_mux = &cxt5047_capture_source;
1427 spec->num_mixers = 1;
1428 spec->mixers[0] = cxt5047_mixers;
1429 spec->num_init_verbs = 1;
1430 spec->init_verbs[0] = cxt5047_init_verbs;
1431 spec->spdif_route = 0;
1432 spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes),
1433 spec->channel_mode = cxt5047_modes,
1435 codec->patch_ops = conexant_patch_ops;
1437 board_config = snd_hda_check_board_config(codec, CXT5047_MODELS,
1440 switch (board_config) {
1441 case CXT5047_LAPTOP:
1442 codec->patch_ops.unsol_event = cxt5047_hp2_unsol_event;
1444 case CXT5047_LAPTOP_HP:
1445 spec->input_mux = &cxt5047_hp_capture_source;
1446 spec->num_init_verbs = 2;
1447 spec->init_verbs[1] = cxt5047_hp_init_verbs;
1448 spec->mixers[0] = cxt5047_hp_mixers;
1449 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1450 codec->patch_ops.init = cxt5047_hp_init;
1452 case CXT5047_LAPTOP_EAPD:
1453 spec->input_mux = &cxt5047_toshiba_capture_source;
1454 spec->num_init_verbs = 2;
1455 spec->init_verbs[1] = cxt5047_toshiba_init_verbs;
1456 spec->mixers[0] = cxt5047_toshiba_mixers;
1457 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1459 #ifdef CONFIG_SND_DEBUG
1461 spec->input_mux = &cxt5047_test_capture_source;
1462 spec->mixers[0] = cxt5047_test_mixer;
1463 spec->init_verbs[0] = cxt5047_test_init_verbs;
1464 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1470 /* Conexant 5051 specific */
1471 static hda_nid_t cxt5051_dac_nids[1] = { 0x10 };
1472 static hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 };
1473 #define CXT5051_SPDIF_OUT 0x1C
1474 #define CXT5051_PORTB_EVENT 0x38
1475 #define CXT5051_PORTC_EVENT 0x39
1477 static struct hda_channel_mode cxt5051_modes[1] = {
1481 static void cxt5051_update_speaker(struct hda_codec *codec)
1483 struct conexant_spec *spec = codec->spec;
1484 unsigned int pinctl;
1485 pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0;
1486 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
1490 /* turn on/off EAPD (+ mute HP) as a master switch */
1491 static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1492 struct snd_ctl_elem_value *ucontrol)
1494 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1496 if (!cxt_eapd_put(kcontrol, ucontrol))
1498 cxt5051_update_speaker(codec);
1502 /* toggle input of built-in and mic jack appropriately */
1503 static void cxt5051_portb_automic(struct hda_codec *codec)
1505 unsigned int present;
1507 present = snd_hda_codec_read(codec, 0x17, 0,
1508 AC_VERB_GET_PIN_SENSE, 0) &
1509 AC_PINSENSE_PRESENCE;
1510 snd_hda_codec_write(codec, 0x14, 0,
1511 AC_VERB_SET_CONNECT_SEL,
1512 present ? 0x01 : 0x00);
1515 /* switch the current ADC according to the jack state */
1516 static void cxt5051_portc_automic(struct hda_codec *codec)
1518 struct conexant_spec *spec = codec->spec;
1519 unsigned int present;
1522 present = snd_hda_codec_read(codec, 0x18, 0,
1523 AC_VERB_GET_PIN_SENSE, 0) &
1524 AC_PINSENSE_PRESENCE;
1526 spec->cur_adc_idx = 1;
1528 spec->cur_adc_idx = 0;
1529 new_adc = spec->adc_nids[spec->cur_adc_idx];
1530 if (spec->cur_adc && spec->cur_adc != new_adc) {
1531 /* stream is running, let's swap the current ADC */
1532 snd_hda_codec_setup_stream(codec, spec->cur_adc, 0, 0, 0);
1533 spec->cur_adc = new_adc;
1534 snd_hda_codec_setup_stream(codec, new_adc,
1535 spec->cur_adc_stream_tag, 0,
1536 spec->cur_adc_format);
1540 /* mute internal speaker if HP is plugged */
1541 static void cxt5051_hp_automute(struct hda_codec *codec)
1543 struct conexant_spec *spec = codec->spec;
1545 spec->hp_present = snd_hda_codec_read(codec, 0x16, 0,
1546 AC_VERB_GET_PIN_SENSE, 0) &
1547 AC_PINSENSE_PRESENCE;
1548 cxt5051_update_speaker(codec);
1551 /* unsolicited event for HP jack sensing */
1552 static void cxt5051_hp_unsol_event(struct hda_codec *codec,
1555 switch (res >> 26) {
1556 case CONEXANT_HP_EVENT:
1557 cxt5051_hp_automute(codec);
1559 case CXT5051_PORTB_EVENT:
1560 cxt5051_portb_automic(codec);
1562 case CXT5051_PORTC_EVENT:
1563 cxt5051_portc_automic(codec);
1568 static struct snd_kcontrol_new cxt5051_mixers[] = {
1569 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
1570 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
1571 HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT),
1572 HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT),
1573 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT),
1574 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT),
1575 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1577 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1578 .name = "Master Playback Switch",
1579 .info = cxt_eapd_info,
1580 .get = cxt_eapd_get,
1581 .put = cxt5051_hp_master_sw_put,
1582 .private_value = 0x1a,
1588 static struct snd_kcontrol_new cxt5051_hp_mixers[] = {
1589 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
1590 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
1591 HDA_CODEC_VOLUME("External Mic Volume", 0x15, 0x00, HDA_INPUT),
1592 HDA_CODEC_MUTE("External Mic Switch", 0x15, 0x00, HDA_INPUT),
1593 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1595 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1596 .name = "Master Playback Switch",
1597 .info = cxt_eapd_info,
1598 .get = cxt_eapd_get,
1599 .put = cxt5051_hp_master_sw_put,
1600 .private_value = 0x1a,
1606 static struct hda_verb cxt5051_init_verbs[] = {
1608 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1609 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1610 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1611 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1612 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1613 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1615 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1616 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1618 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1619 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
1621 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1622 /* Record selector: Int mic */
1623 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1624 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
1625 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1626 /* SPDIF route: PCM */
1627 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
1629 {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
1630 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1631 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT},
1632 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTC_EVENT},
1636 /* initialize jack-sensing, too */
1637 static int cxt5051_init(struct hda_codec *codec)
1639 conexant_init(codec);
1640 if (codec->patch_ops.unsol_event) {
1641 cxt5051_hp_automute(codec);
1642 cxt5051_portb_automic(codec);
1643 cxt5051_portc_automic(codec);
1650 CXT5051_LAPTOP, /* Laptops w/ EAPD support */
1651 CXT5051_HP, /* no docking */
1655 static const char *cxt5051_models[CXT5051_MODELS] = {
1656 [CXT5051_LAPTOP] = "laptop",
1657 [CXT5051_HP] = "hp",
1660 static struct snd_pci_quirk cxt5051_cfg_tbl[] = {
1661 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1663 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP),
1667 static int patch_cxt5051(struct hda_codec *codec)
1669 struct conexant_spec *spec;
1672 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1675 mutex_init(&spec->amp_mutex);
1678 codec->patch_ops = conexant_patch_ops;
1679 codec->patch_ops.init = cxt5051_init;
1681 spec->multiout.max_channels = 2;
1682 spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids);
1683 spec->multiout.dac_nids = cxt5051_dac_nids;
1684 spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT;
1685 spec->num_adc_nids = 1; /* not 2; via auto-mic switch */
1686 spec->adc_nids = cxt5051_adc_nids;
1687 spec->num_mixers = 1;
1688 spec->mixers[0] = cxt5051_mixers;
1689 spec->num_init_verbs = 1;
1690 spec->init_verbs[0] = cxt5051_init_verbs;
1691 spec->spdif_route = 0;
1692 spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes);
1693 spec->channel_mode = cxt5051_modes;
1695 spec->cur_adc_idx = 0;
1697 board_config = snd_hda_check_board_config(codec, CXT5051_MODELS,
1700 switch (board_config) {
1702 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
1703 spec->mixers[0] = cxt5051_hp_mixers;
1706 case CXT5051_LAPTOP:
1707 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
1718 struct hda_codec_preset snd_hda_preset_conexant[] = {
1719 { .id = 0x14f15045, .name = "CX20549 (Venice)",
1720 .patch = patch_cxt5045 },
1721 { .id = 0x14f15047, .name = "CX20551 (Waikiki)",
1722 .patch = patch_cxt5047 },
1723 { .id = 0x14f15051, .name = "CX20561 (Hermosa)",
1724 .patch = patch_cxt5051 },