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 */
68 const struct hda_input_mux *input_mux;
69 hda_nid_t *capsrc_nids;
70 unsigned int cur_mux[3];
73 const struct hda_channel_mode *channel_mode;
77 struct hda_pcm pcm_rec[2]; /* used in build_pcms() */
79 struct mutex amp_mutex; /* PCM volume/mute control mutex */
80 unsigned int spdif_route;
82 /* dynamic controls, init_verbs and input_mux */
83 struct auto_pin_cfg autocfg;
84 unsigned int num_kctl_alloc, num_kctl_used;
85 struct snd_kcontrol_new *kctl_alloc;
86 struct hda_input_mux private_imux;
87 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
91 static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo,
92 struct hda_codec *codec,
93 struct snd_pcm_substream *substream)
95 struct conexant_spec *spec = codec->spec;
96 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
99 static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
100 struct hda_codec *codec,
101 unsigned int stream_tag,
103 struct snd_pcm_substream *substream)
105 struct conexant_spec *spec = codec->spec;
106 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
111 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
112 struct hda_codec *codec,
113 struct snd_pcm_substream *substream)
115 struct conexant_spec *spec = codec->spec;
116 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
122 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
123 struct hda_codec *codec,
124 struct snd_pcm_substream *substream)
126 struct conexant_spec *spec = codec->spec;
127 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
130 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
131 struct hda_codec *codec,
132 struct snd_pcm_substream *substream)
134 struct conexant_spec *spec = codec->spec;
135 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
138 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
139 struct hda_codec *codec,
140 unsigned int stream_tag,
142 struct snd_pcm_substream *substream)
144 struct conexant_spec *spec = codec->spec;
145 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
153 static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
154 struct hda_codec *codec,
155 unsigned int stream_tag,
157 struct snd_pcm_substream *substream)
159 struct conexant_spec *spec = codec->spec;
160 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
161 stream_tag, 0, format);
165 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
166 struct hda_codec *codec,
167 struct snd_pcm_substream *substream)
169 struct conexant_spec *spec = codec->spec;
170 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
177 static struct hda_pcm_stream conexant_pcm_analog_playback = {
181 .nid = 0, /* fill later */
183 .open = conexant_playback_pcm_open,
184 .prepare = conexant_playback_pcm_prepare,
185 .cleanup = conexant_playback_pcm_cleanup
189 static struct hda_pcm_stream conexant_pcm_analog_capture = {
193 .nid = 0, /* fill later */
195 .prepare = conexant_capture_pcm_prepare,
196 .cleanup = conexant_capture_pcm_cleanup
201 static struct hda_pcm_stream conexant_pcm_digital_playback = {
205 .nid = 0, /* fill later */
207 .open = conexant_dig_playback_pcm_open,
208 .close = conexant_dig_playback_pcm_close,
209 .prepare = conexant_dig_playback_pcm_prepare
213 static struct hda_pcm_stream conexant_pcm_digital_capture = {
217 /* NID is set in alc_build_pcms */
220 static int conexant_build_pcms(struct hda_codec *codec)
222 struct conexant_spec *spec = codec->spec;
223 struct hda_pcm *info = spec->pcm_rec;
226 codec->pcm_info = info;
228 info->name = "CONEXANT Analog";
229 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback;
230 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max =
231 spec->multiout.max_channels;
232 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
233 spec->multiout.dac_nids[0];
234 info->stream[SNDRV_PCM_STREAM_CAPTURE] = conexant_pcm_analog_capture;
235 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
236 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
238 if (spec->multiout.dig_out_nid) {
241 info->name = "Conexant Digital";
242 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
243 conexant_pcm_digital_playback;
244 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
245 spec->multiout.dig_out_nid;
246 if (spec->dig_in_nid) {
247 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
248 conexant_pcm_digital_capture;
249 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
257 static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol,
258 struct snd_ctl_elem_info *uinfo)
260 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
261 struct conexant_spec *spec = codec->spec;
263 return snd_hda_input_mux_info(spec->input_mux, uinfo);
266 static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol,
267 struct snd_ctl_elem_value *ucontrol)
269 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
270 struct conexant_spec *spec = codec->spec;
271 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
273 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
277 static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol,
278 struct snd_ctl_elem_value *ucontrol)
280 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
281 struct conexant_spec *spec = codec->spec;
282 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
284 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
285 spec->capsrc_nids[adc_idx],
286 &spec->cur_mux[adc_idx]);
289 static int conexant_init(struct hda_codec *codec)
291 struct conexant_spec *spec = codec->spec;
294 for (i = 0; i < spec->num_init_verbs; i++)
295 snd_hda_sequence_write(codec, spec->init_verbs[i]);
299 static void conexant_free(struct hda_codec *codec)
301 struct conexant_spec *spec = codec->spec;
304 if (spec->kctl_alloc) {
305 for (i = 0; i < spec->num_kctl_used; i++)
306 kfree(spec->kctl_alloc[i].name);
307 kfree(spec->kctl_alloc);
313 static int conexant_build_controls(struct hda_codec *codec)
315 struct conexant_spec *spec = codec->spec;
319 for (i = 0; i < spec->num_mixers; i++) {
320 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
324 if (spec->multiout.dig_out_nid) {
325 err = snd_hda_create_spdif_out_ctls(codec,
326 spec->multiout.dig_out_nid);
330 if (spec->dig_in_nid) {
331 err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid);
338 static struct hda_codec_ops conexant_patch_ops = {
339 .build_controls = conexant_build_controls,
340 .build_pcms = conexant_build_pcms,
341 .init = conexant_init,
342 .free = conexant_free,
347 * the private value = nid | (invert << 8)
350 #define cxt_eapd_info snd_ctl_boolean_mono_info
352 static int cxt_eapd_get(struct snd_kcontrol *kcontrol,
353 struct snd_ctl_elem_value *ucontrol)
355 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
356 struct conexant_spec *spec = codec->spec;
357 int invert = (kcontrol->private_value >> 8) & 1;
359 ucontrol->value.integer.value[0] = !spec->cur_eapd;
361 ucontrol->value.integer.value[0] = spec->cur_eapd;
366 static int cxt_eapd_put(struct snd_kcontrol *kcontrol,
367 struct snd_ctl_elem_value *ucontrol)
369 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
370 struct conexant_spec *spec = codec->spec;
371 int invert = (kcontrol->private_value >> 8) & 1;
372 hda_nid_t nid = kcontrol->private_value & 0xff;
375 eapd = !!ucontrol->value.integer.value[0];
378 if (eapd == spec->cur_eapd)
381 spec->cur_eapd = eapd;
382 snd_hda_codec_write_cache(codec, nid,
383 0, AC_VERB_SET_EAPD_BTLENABLE,
388 /* controls for test mode */
389 #ifdef CONFIG_SND_DEBUG
391 #define CXT_EAPD_SWITCH(xname, nid, mask) \
392 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
393 .info = cxt_eapd_info, \
394 .get = cxt_eapd_get, \
395 .put = cxt_eapd_put, \
396 .private_value = nid | (mask<<16) }
400 static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol,
401 struct snd_ctl_elem_info *uinfo)
403 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
404 struct conexant_spec *spec = codec->spec;
405 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
406 spec->num_channel_mode);
409 static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol,
410 struct snd_ctl_elem_value *ucontrol)
412 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
413 struct conexant_spec *spec = codec->spec;
414 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
415 spec->num_channel_mode,
416 spec->multiout.max_channels);
419 static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol,
420 struct snd_ctl_elem_value *ucontrol)
422 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
423 struct conexant_spec *spec = codec->spec;
424 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
425 spec->num_channel_mode,
426 &spec->multiout.max_channels);
427 if (err >= 0 && spec->need_dac_fix)
428 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
432 #define CXT_PIN_MODE(xname, nid, dir) \
433 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
434 .info = conexant_ch_mode_info, \
435 .get = conexant_ch_mode_get, \
436 .put = conexant_ch_mode_put, \
437 .private_value = nid | (dir<<16) }
439 #endif /* CONFIG_SND_DEBUG */
441 /* Conexant 5045 specific */
443 static hda_nid_t cxt5045_dac_nids[1] = { 0x19 };
444 static hda_nid_t cxt5045_adc_nids[1] = { 0x1a };
445 static hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a };
446 #define CXT5045_SPDIF_OUT 0x13
448 static struct hda_channel_mode cxt5045_modes[1] = {
452 static struct hda_input_mux cxt5045_capture_source = {
460 /* turn on/off EAPD (+ mute HP) as a master switch */
461 static int cxt5045_hp_master_sw_put(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;
468 if (!cxt_eapd_put(kcontrol, ucontrol))
471 /* toggle internal speakers mute depending of presence of
474 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
475 snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
478 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
479 snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0,
484 /* bind volumes of both NID 0x10 and 0x11 */
485 static struct hda_bind_ctls cxt5045_hp_bind_master_vol = {
486 .ops = &snd_hda_bind_vol,
488 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT),
489 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
494 /* toggle input of built-in and mic jack appropriately */
495 static void cxt5045_hp_automic(struct hda_codec *codec)
497 static struct hda_verb mic_jack_on[] = {
498 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
499 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
502 static struct hda_verb mic_jack_off[] = {
503 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
504 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
507 unsigned int present;
509 present = snd_hda_codec_read(codec, 0x12, 0,
510 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
512 snd_hda_sequence_write(codec, mic_jack_on);
514 snd_hda_sequence_write(codec, mic_jack_off);
518 /* mute internal speaker if HP is plugged */
519 static void cxt5045_hp_automute(struct hda_codec *codec)
521 struct conexant_spec *spec = codec->spec;
524 spec->hp_present = snd_hda_codec_read(codec, 0x11, 0,
525 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
527 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
528 snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
532 /* unsolicited event for HP jack sensing */
533 static void cxt5045_hp_unsol_event(struct hda_codec *codec,
538 case CONEXANT_HP_EVENT:
539 cxt5045_hp_automute(codec);
541 case CONEXANT_MIC_EVENT:
542 cxt5045_hp_automic(codec);
548 static struct snd_kcontrol_new cxt5045_mixers[] = {
550 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
551 .name = "Capture Source",
552 .info = conexant_mux_enum_info,
553 .get = conexant_mux_enum_get,
554 .put = conexant_mux_enum_put
556 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
557 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
558 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
559 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
560 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
561 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
562 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
563 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
564 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
565 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
566 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
568 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
569 .name = "Master Playback Switch",
570 .info = cxt_eapd_info,
572 .put = cxt5045_hp_master_sw_put,
573 .private_value = 0x10,
579 static struct hda_verb cxt5045_init_verbs[] = {
581 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
582 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
584 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
585 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
586 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
587 {0x11, AC_VERB_SET_CONNECT_SEL, 0x1},
588 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
589 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
590 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
591 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
592 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
593 /* Record selector: Int mic */
594 {0x1a, AC_VERB_SET_CONNECT_SEL,0x1},
595 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
596 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
597 /* SPDIF route: PCM */
598 { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
600 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */
605 static struct hda_verb cxt5045_hp_sense_init_verbs[] = {
606 /* pin sensing on HP jack */
607 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
611 static struct hda_verb cxt5045_mic_sense_init_verbs[] = {
612 /* pin sensing on HP jack */
613 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
617 #ifdef CONFIG_SND_DEBUG
618 /* Test configuration for debugging, modelled after the ALC260 test
621 static struct hda_input_mux cxt5045_test_capture_source = {
626 { "LINE1 pin", 0x2 },
627 { "HP-OUT pin", 0x3 },
632 static struct snd_kcontrol_new cxt5045_test_mixer[] = {
634 /* Output controls */
635 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
636 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
637 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT),
638 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT),
639 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT),
640 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT),
642 /* Modes for retasking pin widgets */
643 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
644 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT),
646 /* EAPD Switch Control */
647 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
649 /* Loopback mixer controls */
651 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT),
652 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT),
653 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT),
654 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT),
655 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT),
656 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT),
657 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT),
658 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT),
659 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT),
660 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT),
662 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
663 .name = "Input Source",
664 .info = conexant_mux_enum_info,
665 .get = conexant_mux_enum_get,
666 .put = conexant_mux_enum_put,
668 /* Audio input controls */
669 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),
670 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),
671 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
672 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
673 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
674 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
675 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
676 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
677 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
678 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
682 static struct hda_verb cxt5045_test_init_verbs[] = {
683 /* Set connections */
684 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
685 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 },
686 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 },
687 /* Enable retasking pins as output, initially without power amp */
688 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
689 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
691 /* Disable digital (SPDIF) pins initially, but users can enable
692 * them via a mixer switch. In the case of SPDIF-out, this initverb
693 * payload also sets the generation to 0, output to be in "consumer"
694 * PCM format, copyright asserted, no pre-emphasis and no validity
697 {0x13, AC_VERB_SET_DIGI_CONVERT_1, 0},
699 /* Start with output sum widgets muted and their output gains at min */
700 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
701 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
703 /* Unmute retasking pin widget output buffers since the default
704 * state appears to be output. As the pin mode is changed by the
705 * user the pin mode control will take care of enabling the pin's
706 * input/output buffers as needed.
708 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
709 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
711 /* Mute capture amp left and right */
712 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
714 /* Set ADC connection select to match default mixer setting (mic1
717 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
718 {0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
720 /* Mute all inputs to mixer widget (even unconnected ones) */
721 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */
722 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */
723 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */
724 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */
725 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
732 /* initialize jack-sensing, too */
733 static int cxt5045_init(struct hda_codec *codec)
735 conexant_init(codec);
736 cxt5045_hp_automute(codec);
742 CXT5045_LAPTOP, /* Laptops w/ EAPD support */
743 CXT5045_FUJITSU, /* Laptops w/ EAPD support */
744 #ifdef CONFIG_SND_DEBUG
750 static const char *cxt5045_models[CXT5045_MODELS] = {
751 [CXT5045_LAPTOP] = "laptop",
752 [CXT5045_FUJITSU] = "fujitsu",
753 #ifdef CONFIG_SND_DEBUG
754 [CXT5045_TEST] = "test",
758 static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
759 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV Series", CXT5045_LAPTOP),
760 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2120", CXT5045_LAPTOP),
761 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP),
762 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP),
763 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP),
764 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP),
765 SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP),
766 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_FUJITSU),
767 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP),
768 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505", CXT5045_LAPTOP),
769 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP),
773 static int patch_cxt5045(struct hda_codec *codec)
775 struct conexant_spec *spec;
778 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
781 mutex_init(&spec->amp_mutex);
784 spec->multiout.max_channels = 2;
785 spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids);
786 spec->multiout.dac_nids = cxt5045_dac_nids;
787 spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT;
788 spec->num_adc_nids = 1;
789 spec->adc_nids = cxt5045_adc_nids;
790 spec->capsrc_nids = cxt5045_capsrc_nids;
791 spec->input_mux = &cxt5045_capture_source;
792 spec->num_mixers = 1;
793 spec->mixers[0] = cxt5045_mixers;
794 spec->num_init_verbs = 1;
795 spec->init_verbs[0] = cxt5045_init_verbs;
796 spec->spdif_route = 0;
797 spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes),
798 spec->channel_mode = cxt5045_modes,
801 codec->patch_ops = conexant_patch_ops;
803 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
806 switch (board_config) {
808 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
809 spec->input_mux = &cxt5045_capture_source;
810 spec->num_init_verbs = 2;
811 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
812 spec->mixers[0] = cxt5045_mixers;
813 codec->patch_ops.init = cxt5045_init;
815 case CXT5045_FUJITSU:
816 spec->input_mux = &cxt5045_capture_source;
817 spec->num_init_verbs = 2;
818 spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;
819 spec->mixers[0] = cxt5045_mixers;
820 codec->patch_ops.init = cxt5045_init;
822 #ifdef CONFIG_SND_DEBUG
824 spec->input_mux = &cxt5045_test_capture_source;
825 spec->mixers[0] = cxt5045_test_mixer;
826 spec->init_verbs[0] = cxt5045_test_init_verbs;
831 * Fix max PCM level to 0 dB
832 * (originall it has 0x2b steps with 0dB offset 0x14)
834 snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT,
835 (0x14 << AC_AMPCAP_OFFSET_SHIFT) |
836 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) |
837 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
838 (1 << AC_AMPCAP_MUTE_SHIFT));
844 /* Conexant 5047 specific */
845 #define CXT5047_SPDIF_OUT 0x11
847 static hda_nid_t cxt5047_dac_nids[2] = { 0x10, 0x1c };
848 static hda_nid_t cxt5047_adc_nids[1] = { 0x12 };
849 static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a };
851 static struct hda_channel_mode cxt5047_modes[1] = {
855 static struct hda_input_mux cxt5047_capture_source = {
862 static struct hda_input_mux cxt5047_hp_capture_source = {
869 static struct hda_input_mux cxt5047_toshiba_capture_source = {
877 /* turn on/off EAPD (+ mute HP) as a master switch */
878 static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
879 struct snd_ctl_elem_value *ucontrol)
881 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
882 struct conexant_spec *spec = codec->spec;
885 if (!cxt_eapd_put(kcontrol, ucontrol))
888 /* toggle internal speakers mute depending of presence of
891 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
892 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
894 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
895 snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0,
900 /* bind volumes of both NID 0x13 (Headphones) and 0x1d (Speakers) */
901 static struct hda_bind_ctls cxt5047_bind_master_vol = {
902 .ops = &snd_hda_bind_vol,
904 HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
905 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
910 /* mute internal speaker if HP is plugged */
911 static void cxt5047_hp_automute(struct hda_codec *codec)
913 struct conexant_spec *spec = codec->spec;
916 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
917 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
919 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
920 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
922 /* Mute/Unmute PCM 2 for good measure - some systems need this */
923 snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
927 /* mute internal speaker if HP is plugged */
928 static void cxt5047_hp2_automute(struct hda_codec *codec)
930 struct conexant_spec *spec = codec->spec;
933 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
934 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
936 bits = spec->hp_present ? HDA_AMP_MUTE : 0;
937 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
939 /* Mute/Unmute PCM 2 for good measure - some systems need this */
940 snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
944 /* toggle input of built-in and mic jack appropriately */
945 static void cxt5047_hp_automic(struct hda_codec *codec)
947 static struct hda_verb mic_jack_on[] = {
948 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
949 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
952 static struct hda_verb mic_jack_off[] = {
953 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
954 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
957 unsigned int present;
959 present = snd_hda_codec_read(codec, 0x15, 0,
960 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
962 snd_hda_sequence_write(codec, mic_jack_on);
964 snd_hda_sequence_write(codec, mic_jack_off);
967 /* unsolicited event for HP jack sensing */
968 static void cxt5047_hp_unsol_event(struct hda_codec *codec,
973 case CONEXANT_HP_EVENT:
974 cxt5047_hp_automute(codec);
976 case CONEXANT_MIC_EVENT:
977 cxt5047_hp_automic(codec);
982 /* unsolicited event for HP jack sensing - non-EAPD systems */
983 static void cxt5047_hp2_unsol_event(struct hda_codec *codec,
988 case CONEXANT_HP_EVENT:
989 cxt5047_hp2_automute(codec);
991 case CONEXANT_MIC_EVENT:
992 cxt5047_hp_automic(codec);
997 static struct snd_kcontrol_new cxt5047_mixers[] = {
998 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
999 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1000 HDA_CODEC_VOLUME("Mic Gain Volume", 0x1a, 0x0, HDA_OUTPUT),
1001 HDA_CODEC_MUTE("Mic Gain Switch", 0x1a, 0x0, HDA_OUTPUT),
1002 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1003 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1004 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1005 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1006 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT),
1007 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT),
1008 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x00, HDA_OUTPUT),
1009 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x00, HDA_OUTPUT),
1010 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1011 HDA_CODEC_MUTE("Headphone Playback Switch", 0x13, 0x00, HDA_OUTPUT),
1016 static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = {
1018 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1019 .name = "Capture Source",
1020 .info = conexant_mux_enum_info,
1021 .get = conexant_mux_enum_get,
1022 .put = conexant_mux_enum_put
1024 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1025 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1026 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1027 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1028 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1029 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1030 HDA_BIND_VOL("Master Playback Volume", &cxt5047_bind_master_vol),
1032 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1033 .name = "Master Playback Switch",
1034 .info = cxt_eapd_info,
1035 .get = cxt_eapd_get,
1036 .put = cxt5047_hp_master_sw_put,
1037 .private_value = 0x13,
1043 static struct snd_kcontrol_new cxt5047_hp_mixers[] = {
1045 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1046 .name = "Capture Source",
1047 .info = conexant_mux_enum_info,
1048 .get = conexant_mux_enum_get,
1049 .put = conexant_mux_enum_put
1051 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1052 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19,0x02,HDA_INPUT),
1053 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1054 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1055 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1056 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1057 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1059 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1060 .name = "Master Playback Switch",
1061 .info = cxt_eapd_info,
1062 .get = cxt_eapd_get,
1063 .put = cxt5047_hp_master_sw_put,
1064 .private_value = 0x13,
1069 static struct hda_verb cxt5047_init_verbs[] = {
1070 /* Line in, Mic, Built-in Mic */
1071 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1072 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1073 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1075 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1076 {0x13, AC_VERB_SET_CONNECT_SEL,0x1},
1077 {0x1d, AC_VERB_SET_CONNECT_SEL,0x0},
1078 /* Record selector: Mic */
1079 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1080 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1081 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1082 {0x1A, AC_VERB_SET_CONNECT_SEL,0x02},
1083 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1084 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1085 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1086 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
1087 /* SPDIF route: PCM */
1088 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
1089 /* Enable unsolicited events */
1090 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1091 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1095 /* configuration for Toshiba Laptops */
1096 static struct hda_verb cxt5047_toshiba_init_verbs[] = {
1097 {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0 }, /* default on */
1098 /* pin sensing on HP and Mic jacks */
1099 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1100 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1101 /* Speaker routing */
1102 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1106 /* configuration for HP Laptops */
1107 static struct hda_verb cxt5047_hp_init_verbs[] = {
1108 /* pin sensing on HP jack */
1109 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1110 /* Record selector: Ext Mic */
1111 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1112 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1113 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1114 /* Speaker routing */
1115 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1119 /* Test configuration for debugging, modelled after the ALC260 test
1122 #ifdef CONFIG_SND_DEBUG
1123 static struct hda_input_mux cxt5047_test_capture_source = {
1126 { "LINE1 pin", 0x0 },
1127 { "MIC1 pin", 0x1 },
1128 { "MIC2 pin", 0x2 },
1133 static struct snd_kcontrol_new cxt5047_test_mixer[] = {
1135 /* Output only controls */
1136 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT),
1137 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT),
1138 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT),
1139 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT),
1140 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1141 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1142 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1143 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1144 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT),
1145 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1146 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT),
1147 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT),
1149 /* Modes for retasking pin widgets */
1150 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT),
1151 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT),
1153 /* EAPD Switch Control */
1154 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1156 /* Loopback mixer controls */
1157 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT),
1158 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT),
1159 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT),
1160 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT),
1161 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT),
1162 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT),
1163 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT),
1164 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT),
1166 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT),
1167 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT),
1168 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT),
1169 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT),
1170 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT),
1171 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT),
1172 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT),
1173 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT),
1175 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1176 .name = "Input Source",
1177 .info = conexant_mux_enum_info,
1178 .get = conexant_mux_enum_get,
1179 .put = conexant_mux_enum_put,
1184 static struct hda_verb cxt5047_test_init_verbs[] = {
1185 /* Enable retasking pins as output, initially without power amp */
1186 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1187 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1188 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1190 /* Disable digital (SPDIF) pins initially, but users can enable
1191 * them via a mixer switch. In the case of SPDIF-out, this initverb
1192 * payload also sets the generation to 0, output to be in "consumer"
1193 * PCM format, copyright asserted, no pre-emphasis and no validity
1196 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
1198 /* Ensure mic1, mic2, line1 pin widgets take input from the
1199 * OUT1 sum bus when acting as an output.
1201 {0x1a, AC_VERB_SET_CONNECT_SEL, 0},
1202 {0x1b, AC_VERB_SET_CONNECT_SEL, 0},
1204 /* Start with output sum widgets muted and their output gains at min */
1205 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1206 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1208 /* Unmute retasking pin widget output buffers since the default
1209 * state appears to be output. As the pin mode is changed by the
1210 * user the pin mode control will take care of enabling the pin's
1211 * input/output buffers as needed.
1213 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1214 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1215 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1217 /* Mute capture amp left and right */
1218 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1220 /* Set ADC connection select to match default mixer setting (mic1
1223 {0x12, AC_VERB_SET_CONNECT_SEL, 0x00},
1225 /* Mute all inputs to mixer widget (even unconnected ones) */
1226 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
1227 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
1228 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
1229 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
1230 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
1231 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1232 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
1233 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
1240 /* initialize jack-sensing, too */
1241 static int cxt5047_hp_init(struct hda_codec *codec)
1243 conexant_init(codec);
1244 cxt5047_hp_automute(codec);
1250 CXT5047_LAPTOP, /* Laptops w/o EAPD support */
1251 CXT5047_LAPTOP_HP, /* Some HP laptops */
1252 CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */
1253 #ifdef CONFIG_SND_DEBUG
1259 static const char *cxt5047_models[CXT5047_MODELS] = {
1260 [CXT5047_LAPTOP] = "laptop",
1261 [CXT5047_LAPTOP_HP] = "laptop-hp",
1262 [CXT5047_LAPTOP_EAPD] = "laptop-eapd",
1263 #ifdef CONFIG_SND_DEBUG
1264 [CXT5047_TEST] = "test",
1268 static struct snd_pci_quirk cxt5047_cfg_tbl[] = {
1269 SND_PCI_QUIRK(0x103c, 0x30a0, "HP DV1000", CXT5047_LAPTOP),
1270 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
1271 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV2000T/DV3000T", CXT5047_LAPTOP),
1272 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2000Z", CXT5047_LAPTOP),
1273 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD),
1277 static int patch_cxt5047(struct hda_codec *codec)
1279 struct conexant_spec *spec;
1282 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1285 mutex_init(&spec->amp_mutex);
1288 spec->multiout.max_channels = 2;
1289 spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids);
1290 spec->multiout.dac_nids = cxt5047_dac_nids;
1291 spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT;
1292 spec->num_adc_nids = 1;
1293 spec->adc_nids = cxt5047_adc_nids;
1294 spec->capsrc_nids = cxt5047_capsrc_nids;
1295 spec->input_mux = &cxt5047_capture_source;
1296 spec->num_mixers = 1;
1297 spec->mixers[0] = cxt5047_mixers;
1298 spec->num_init_verbs = 1;
1299 spec->init_verbs[0] = cxt5047_init_verbs;
1300 spec->spdif_route = 0;
1301 spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes),
1302 spec->channel_mode = cxt5047_modes,
1304 codec->patch_ops = conexant_patch_ops;
1306 board_config = snd_hda_check_board_config(codec, CXT5047_MODELS,
1309 switch (board_config) {
1310 case CXT5047_LAPTOP:
1311 codec->patch_ops.unsol_event = cxt5047_hp2_unsol_event;
1313 case CXT5047_LAPTOP_HP:
1314 spec->input_mux = &cxt5047_hp_capture_source;
1315 spec->num_init_verbs = 2;
1316 spec->init_verbs[1] = cxt5047_hp_init_verbs;
1317 spec->mixers[0] = cxt5047_hp_mixers;
1318 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1319 codec->patch_ops.init = cxt5047_hp_init;
1321 case CXT5047_LAPTOP_EAPD:
1322 spec->input_mux = &cxt5047_toshiba_capture_source;
1323 spec->num_init_verbs = 2;
1324 spec->init_verbs[1] = cxt5047_toshiba_init_verbs;
1325 spec->mixers[0] = cxt5047_toshiba_mixers;
1326 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1328 #ifdef CONFIG_SND_DEBUG
1330 spec->input_mux = &cxt5047_test_capture_source;
1331 spec->mixers[0] = cxt5047_test_mixer;
1332 spec->init_verbs[0] = cxt5047_test_init_verbs;
1333 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1339 struct hda_codec_preset snd_hda_preset_conexant[] = {
1340 { .id = 0x14f15045, .name = "CX20549 (Venice)",
1341 .patch = patch_cxt5045 },
1342 { .id = 0x14f15047, .name = "CX20551 (Waikiki)",
1343 .patch = patch_cxt5047 },