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 <sound/driver.h>
24 #include <linux/init.h>
25 #include <linux/delay.h>
26 #include <linux/slab.h>
27 #include <linux/pci.h>
28 #include <sound/core.h>
29 #include "hda_codec.h"
30 #include "hda_local.h"
32 #define CXT_PIN_DIR_IN 0x00
33 #define CXT_PIN_DIR_OUT 0x01
34 #define CXT_PIN_DIR_INOUT 0x02
35 #define CXT_PIN_DIR_IN_NOMICBIAS 0x03
36 #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04
38 #define CONEXANT_HP_EVENT 0x37
39 #define CONEXANT_MIC_EVENT 0x38
43 struct conexant_spec {
45 struct snd_kcontrol_new *mixers[5];
48 const struct hda_verb *init_verbs[5]; /* initialization verbs
52 unsigned int num_init_verbs;
55 struct hda_multi_out multiout; /* playback set-up
56 * max_channels, dacs must be set
57 * dig_out_nid and hp_nid are optional
59 unsigned int cur_eapd;
60 unsigned int hp_present;
61 unsigned int need_dac_fix;
64 unsigned int num_adc_nids;
66 hda_nid_t dig_in_nid; /* digital-in NID; optional */
69 const struct hda_input_mux *input_mux;
70 hda_nid_t *capsrc_nids;
71 unsigned int cur_mux[3];
74 const struct hda_channel_mode *channel_mode;
78 struct hda_pcm pcm_rec[2]; /* used in build_pcms() */
80 struct mutex amp_mutex; /* PCM volume/mute control mutex */
81 unsigned int spdif_route;
83 /* dynamic controls, init_verbs and input_mux */
84 struct auto_pin_cfg autocfg;
85 unsigned int num_kctl_alloc, num_kctl_used;
86 struct snd_kcontrol_new *kctl_alloc;
87 struct hda_input_mux private_imux;
88 hda_nid_t private_dac_nids[4];
92 static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo,
93 struct hda_codec *codec,
94 struct snd_pcm_substream *substream)
96 struct conexant_spec *spec = codec->spec;
97 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
100 static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
101 struct hda_codec *codec,
102 unsigned int stream_tag,
104 struct snd_pcm_substream *substream)
106 struct conexant_spec *spec = codec->spec;
107 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
112 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
113 struct hda_codec *codec,
114 struct snd_pcm_substream *substream)
116 struct conexant_spec *spec = codec->spec;
117 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
123 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
124 struct hda_codec *codec,
125 struct snd_pcm_substream *substream)
127 struct conexant_spec *spec = codec->spec;
128 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
131 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
132 struct hda_codec *codec,
133 struct snd_pcm_substream *substream)
135 struct conexant_spec *spec = codec->spec;
136 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
139 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
140 struct hda_codec *codec,
141 unsigned int stream_tag,
143 struct snd_pcm_substream *substream)
145 struct conexant_spec *spec = codec->spec;
146 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
154 static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
155 struct hda_codec *codec,
156 unsigned int stream_tag,
158 struct snd_pcm_substream *substream)
160 struct conexant_spec *spec = codec->spec;
161 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
162 stream_tag, 0, format);
166 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
167 struct hda_codec *codec,
168 struct snd_pcm_substream *substream)
170 struct conexant_spec *spec = codec->spec;
171 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
178 static struct hda_pcm_stream conexant_pcm_analog_playback = {
182 .nid = 0, /* fill later */
184 .open = conexant_playback_pcm_open,
185 .prepare = conexant_playback_pcm_prepare,
186 .cleanup = conexant_playback_pcm_cleanup
190 static struct hda_pcm_stream conexant_pcm_analog_capture = {
194 .nid = 0, /* fill later */
196 .prepare = conexant_capture_pcm_prepare,
197 .cleanup = conexant_capture_pcm_cleanup
202 static struct hda_pcm_stream conexant_pcm_digital_playback = {
206 .nid = 0, /* fill later */
208 .open = conexant_dig_playback_pcm_open,
209 .close = conexant_dig_playback_pcm_close,
210 .prepare = conexant_dig_playback_pcm_prepare
214 static struct hda_pcm_stream conexant_pcm_digital_capture = {
218 /* NID is set in alc_build_pcms */
221 static int conexant_build_pcms(struct hda_codec *codec)
223 struct conexant_spec *spec = codec->spec;
224 struct hda_pcm *info = spec->pcm_rec;
227 codec->pcm_info = info;
229 info->name = "CONEXANT Analog";
230 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback;
231 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max =
232 spec->multiout.max_channels;
233 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
234 spec->multiout.dac_nids[0];
235 info->stream[SNDRV_PCM_STREAM_CAPTURE] = conexant_pcm_analog_capture;
236 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
237 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
239 if (spec->multiout.dig_out_nid) {
242 info->name = "Conexant Digital";
243 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
244 conexant_pcm_digital_playback;
245 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
246 spec->multiout.dig_out_nid;
247 if (spec->dig_in_nid) {
248 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
249 conexant_pcm_digital_capture;
250 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
258 static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol,
259 struct snd_ctl_elem_info *uinfo)
261 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
262 struct conexant_spec *spec = codec->spec;
264 return snd_hda_input_mux_info(spec->input_mux, uinfo);
267 static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol,
268 struct snd_ctl_elem_value *ucontrol)
270 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
271 struct conexant_spec *spec = codec->spec;
272 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
274 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
278 static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol,
279 struct snd_ctl_elem_value *ucontrol)
281 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
282 struct conexant_spec *spec = codec->spec;
283 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
285 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
286 spec->capsrc_nids[adc_idx],
287 &spec->cur_mux[adc_idx]);
290 static int conexant_init(struct hda_codec *codec)
292 struct conexant_spec *spec = codec->spec;
295 for (i = 0; i < spec->num_init_verbs; i++)
296 snd_hda_sequence_write(codec, spec->init_verbs[i]);
300 static void conexant_free(struct hda_codec *codec)
302 struct conexant_spec *spec = codec->spec;
305 if (spec->kctl_alloc) {
306 for (i = 0; i < spec->num_kctl_used; i++)
307 kfree(spec->kctl_alloc[i].name);
308 kfree(spec->kctl_alloc);
315 static int conexant_resume(struct hda_codec *codec)
317 struct conexant_spec *spec = codec->spec;
320 codec->patch_ops.init(codec);
321 for (i = 0; i < spec->num_mixers; i++)
322 snd_hda_resume_ctls(codec, spec->mixers[i]);
323 if (spec->multiout.dig_out_nid)
324 snd_hda_resume_spdif_out(codec);
325 if (spec->dig_in_nid)
326 snd_hda_resume_spdif_in(codec);
331 static int conexant_build_controls(struct hda_codec *codec)
333 struct conexant_spec *spec = codec->spec;
337 for (i = 0; i < spec->num_mixers; i++) {
338 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
342 if (spec->multiout.dig_out_nid) {
343 err = snd_hda_create_spdif_out_ctls(codec,
344 spec->multiout.dig_out_nid);
348 if (spec->dig_in_nid) {
349 err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid);
356 static struct hda_codec_ops conexant_patch_ops = {
357 .build_controls = conexant_build_controls,
358 .build_pcms = conexant_build_pcms,
359 .init = conexant_init,
360 .free = conexant_free,
362 .resume = conexant_resume,
368 * the private value = nid | (invert << 8)
371 static int cxt_eapd_info(struct snd_kcontrol *kcontrol,
372 struct snd_ctl_elem_info *uinfo)
374 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
376 uinfo->value.integer.min = 0;
377 uinfo->value.integer.max = 1;
381 static int cxt_eapd_get(struct snd_kcontrol *kcontrol,
382 struct snd_ctl_elem_value *ucontrol)
384 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
385 struct conexant_spec *spec = codec->spec;
386 int invert = (kcontrol->private_value >> 8) & 1;
388 ucontrol->value.integer.value[0] = !spec->cur_eapd;
390 ucontrol->value.integer.value[0] = spec->cur_eapd;
395 static int cxt_eapd_put(struct snd_kcontrol *kcontrol,
396 struct snd_ctl_elem_value *ucontrol)
398 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
399 struct conexant_spec *spec = codec->spec;
400 int invert = (kcontrol->private_value >> 8) & 1;
401 hda_nid_t nid = kcontrol->private_value & 0xff;
404 eapd = ucontrol->value.integer.value[0];
407 if (eapd == spec->cur_eapd && !codec->in_resume)
410 spec->cur_eapd = eapd;
411 snd_hda_codec_write(codec, nid,
412 0, AC_VERB_SET_EAPD_BTLENABLE,
417 /* controls for test mode */
418 #ifdef CONFIG_SND_DEBUG
420 #define CXT_EAPD_SWITCH(xname, nid, mask) \
421 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
422 .info = cxt_eapd_info, \
423 .get = cxt_eapd_get, \
424 .put = cxt_eapd_put, \
425 .private_value = nid | (mask<<16) }
429 static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol,
430 struct snd_ctl_elem_info *uinfo)
432 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
433 struct conexant_spec *spec = codec->spec;
434 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
435 spec->num_channel_mode);
438 static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol,
439 struct snd_ctl_elem_value *ucontrol)
441 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
442 struct conexant_spec *spec = codec->spec;
443 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
444 spec->num_channel_mode,
445 spec->multiout.max_channels);
448 static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol,
449 struct snd_ctl_elem_value *ucontrol)
451 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
452 struct conexant_spec *spec = codec->spec;
453 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
454 spec->num_channel_mode,
455 &spec->multiout.max_channels);
456 if (err >= 0 && spec->need_dac_fix)
457 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
461 #define CXT_PIN_MODE(xname, nid, dir) \
462 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
463 .info = conexant_ch_mode_info, \
464 .get = conexant_ch_mode_get, \
465 .put = conexant_ch_mode_put, \
466 .private_value = nid | (dir<<16) }
468 #endif /* CONFIG_SND_DEBUG */
470 /* Conexant 5045 specific */
472 static hda_nid_t cxt5045_dac_nids[1] = { 0x19 };
473 static hda_nid_t cxt5045_adc_nids[1] = { 0x1a };
474 static hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a };
475 #define CXT5045_SPDIF_OUT 0x13
477 static struct hda_channel_mode cxt5045_modes[1] = {
481 static struct hda_input_mux cxt5045_capture_source = {
489 /* turn on/off EAPD (+ mute HP) as a master switch */
490 static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
491 struct snd_ctl_elem_value *ucontrol)
493 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
494 struct conexant_spec *spec = codec->spec;
497 if (!cxt_eapd_put(kcontrol, ucontrol))
500 /* toggle internal speakers mute depending of presence of
503 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : 0x80;
504 snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits);
505 snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits);
507 bits = spec->cur_eapd ? 0 : 0x80;
508 snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0, 0x80, bits);
509 snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0, 0x80, bits);
513 /* bind volumes of both NID 0x10 and 0x11 */
514 static int cxt5045_hp_master_vol_put(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_value *ucontrol)
517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
518 long *valp = ucontrol->value.integer.value;
521 change = snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0,
522 0x7f, valp[0] & 0x7f);
523 change |= snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0,
524 0x7f, valp[1] & 0x7f);
525 snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0,
526 0x7f, valp[0] & 0x7f);
527 snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0,
528 0x7f, valp[1] & 0x7f);
532 /* toggle input of built-in and mic jack appropriately */
533 static void cxt5045_hp_automic(struct hda_codec *codec)
535 static struct hda_verb mic_jack_on[] = {
536 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
537 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
540 static struct hda_verb mic_jack_off[] = {
541 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
542 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
545 unsigned int present;
547 present = snd_hda_codec_read(codec, 0x12, 0,
548 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
550 snd_hda_sequence_write(codec, mic_jack_on);
552 snd_hda_sequence_write(codec, mic_jack_off);
556 /* mute internal speaker if HP is plugged */
557 static void cxt5045_hp_automute(struct hda_codec *codec)
559 struct conexant_spec *spec = codec->spec;
562 spec->hp_present = snd_hda_codec_read(codec, 0x11, 0,
563 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
565 bits = (spec->hp_present || !spec->cur_eapd) ? 0x80 : 0;
566 snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits);
567 snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits);
570 /* unsolicited event for HP jack sensing */
571 static void cxt5045_hp_unsol_event(struct hda_codec *codec,
576 case CONEXANT_HP_EVENT:
577 cxt5045_hp_automute(codec);
579 case CONEXANT_MIC_EVENT:
580 cxt5045_hp_automic(codec);
586 static struct snd_kcontrol_new cxt5045_mixers[] = {
588 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
589 .name = "Capture Source",
590 .info = conexant_mux_enum_info,
591 .get = conexant_mux_enum_get,
592 .put = conexant_mux_enum_put
594 HDA_CODEC_VOLUME("Int Mic Volume", 0x1a, 0x01, HDA_INPUT),
595 HDA_CODEC_MUTE("Int Mic Switch", 0x1a, 0x01, HDA_INPUT),
596 HDA_CODEC_VOLUME("Ext Mic Volume", 0x1a, 0x02, HDA_INPUT),
597 HDA_CODEC_MUTE("Ext Mic Switch", 0x1a, 0x02, HDA_INPUT),
599 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
600 .name = "Master Playback Volume",
601 .info = snd_hda_mixer_amp_volume_info,
602 .get = snd_hda_mixer_amp_volume_get,
603 .put = cxt5045_hp_master_vol_put,
604 .private_value = HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT),
607 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
608 .name = "Master Playback Switch",
609 .info = cxt_eapd_info,
611 .put = cxt5045_hp_master_sw_put,
612 .private_value = 0x10,
618 static struct hda_verb cxt5045_init_verbs[] = {
620 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
621 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
623 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
624 {0x17, AC_VERB_SET_CONNECT_SEL,0x01},
625 {0x17, AC_VERB_SET_AMP_GAIN_MUTE,
626 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x01},
627 {0x17, AC_VERB_SET_AMP_GAIN_MUTE,
628 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x02},
629 {0x17, AC_VERB_SET_AMP_GAIN_MUTE,
630 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
631 {0x17, AC_VERB_SET_AMP_GAIN_MUTE,
632 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x04},
633 /* Record selector: Int mic */
634 {0x1a, AC_VERB_SET_CONNECT_SEL,0x1},
635 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
636 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
637 /* SPDIF route: PCM */
638 { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
640 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */
645 static struct hda_verb cxt5045_hp_sense_init_verbs[] = {
646 /* pin sensing on HP jack */
647 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
651 static struct hda_verb cxt5045_mic_sense_init_verbs[] = {
652 /* pin sensing on HP jack */
653 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
657 #ifdef CONFIG_SND_DEBUG
658 /* Test configuration for debugging, modelled after the ALC260 test
661 static struct hda_input_mux cxt5045_test_capture_source = {
666 { "LINE1 pin", 0x2 },
667 { "HP-OUT pin", 0x3 },
672 static struct snd_kcontrol_new cxt5045_test_mixer[] = {
674 /* Output controls */
675 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
676 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
677 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT),
678 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT),
679 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT),
680 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT),
682 /* Modes for retasking pin widgets */
683 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
684 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT),
686 /* EAPD Switch Control */
687 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
689 /* Loopback mixer controls */
691 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT),
692 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT),
693 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT),
694 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT),
695 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT),
696 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT),
697 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT),
698 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT),
699 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT),
700 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT),
702 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
703 .name = "Input Source",
704 .info = conexant_mux_enum_info,
705 .get = conexant_mux_enum_get,
706 .put = conexant_mux_enum_put,
708 /* Audio input controls */
709 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),
710 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),
711 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
712 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
713 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
714 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
715 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
716 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
717 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
718 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
722 static struct hda_verb cxt5045_test_init_verbs[] = {
723 /* Set connections */
724 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
725 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 },
726 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 },
727 /* Enable retasking pins as output, initially without power amp */
728 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
729 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
731 /* Disable digital (SPDIF) pins initially, but users can enable
732 * them via a mixer switch. In the case of SPDIF-out, this initverb
733 * payload also sets the generation to 0, output to be in "consumer"
734 * PCM format, copyright asserted, no pre-emphasis and no validity
737 {0x13, AC_VERB_SET_DIGI_CONVERT_1, 0},
739 /* Start with output sum widgets muted and their output gains at min */
740 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
741 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
743 /* Unmute retasking pin widget output buffers since the default
744 * state appears to be output. As the pin mode is changed by the
745 * user the pin mode control will take care of enabling the pin's
746 * input/output buffers as needed.
748 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
749 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
751 /* Mute capture amp left and right */
752 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
754 /* Set ADC connection select to match default mixer setting (mic1
757 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
758 {0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
760 /* Mute all inputs to mixer widget (even unconnected ones) */
761 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */
762 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */
763 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */
764 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */
765 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
772 /* initialize jack-sensing, too */
773 static int cxt5045_init(struct hda_codec *codec)
775 conexant_init(codec);
776 cxt5045_hp_automute(codec);
782 CXT5045_LAPTOP, /* Laptops w/ EAPD support */
783 CXT5045_FUJITSU, /* Laptops w/ EAPD support */
784 #ifdef CONFIG_SND_DEBUG
790 static const char *cxt5045_models[CXT5045_MODELS] = {
791 [CXT5045_LAPTOP] = "laptop",
792 [CXT5045_FUJITSU] = "fujitsu",
793 #ifdef CONFIG_SND_DEBUG
794 [CXT5045_TEST] = "test",
798 static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
799 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP),
800 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP),
801 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV Series", CXT5045_LAPTOP),
802 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2120", CXT5045_LAPTOP),
803 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP),
804 SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP),
805 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_FUJITSU),
806 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP),
807 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP),
811 static int patch_cxt5045(struct hda_codec *codec)
813 struct conexant_spec *spec;
816 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
819 mutex_init(&spec->amp_mutex);
822 spec->multiout.max_channels = 2;
823 spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids);
824 spec->multiout.dac_nids = cxt5045_dac_nids;
825 spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT;
826 spec->num_adc_nids = 1;
827 spec->adc_nids = cxt5045_adc_nids;
828 spec->capsrc_nids = cxt5045_capsrc_nids;
829 spec->input_mux = &cxt5045_capture_source;
830 spec->num_mixers = 1;
831 spec->mixers[0] = cxt5045_mixers;
832 spec->num_init_verbs = 1;
833 spec->init_verbs[0] = cxt5045_init_verbs;
834 spec->spdif_route = 0;
835 spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes),
836 spec->channel_mode = cxt5045_modes,
839 codec->patch_ops = conexant_patch_ops;
841 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
844 switch (board_config) {
846 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
847 spec->input_mux = &cxt5045_capture_source;
848 spec->num_init_verbs = 2;
849 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
850 spec->mixers[0] = cxt5045_mixers;
851 codec->patch_ops.init = cxt5045_init;
853 case CXT5045_FUJITSU:
854 spec->input_mux = &cxt5045_capture_source;
855 spec->num_init_verbs = 2;
856 spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;
857 spec->mixers[0] = cxt5045_mixers;
858 codec->patch_ops.init = cxt5045_init;
860 #ifdef CONFIG_SND_DEBUG
862 spec->input_mux = &cxt5045_test_capture_source;
863 spec->mixers[0] = cxt5045_test_mixer;
864 spec->init_verbs[0] = cxt5045_test_init_verbs;
871 /* Conexant 5047 specific */
872 #define CXT5047_SPDIF_OUT 0x11
874 static hda_nid_t cxt5047_dac_nids[2] = { 0x10, 0x1c };
875 static hda_nid_t cxt5047_adc_nids[1] = { 0x12 };
876 static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a };
878 static struct hda_channel_mode cxt5047_modes[1] = {
882 static struct hda_input_mux cxt5047_capture_source = {
889 static struct hda_input_mux cxt5047_hp_capture_source = {
896 static struct hda_input_mux cxt5047_toshiba_capture_source = {
904 /* turn on/off EAPD (+ mute HP) as a master switch */
905 static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
906 struct snd_ctl_elem_value *ucontrol)
908 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
909 struct conexant_spec *spec = codec->spec;
912 if (!cxt_eapd_put(kcontrol, ucontrol))
915 /* toggle internal speakers mute depending of presence of
918 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : 0x80;
919 snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0, 0x80, bits);
920 snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0, 0x80, bits);
921 bits = spec->cur_eapd ? 0 : 0x80;
922 snd_hda_codec_amp_update(codec, 0x13, 0, HDA_OUTPUT, 0, 0x80, bits);
923 snd_hda_codec_amp_update(codec, 0x13, 1, HDA_OUTPUT, 0, 0x80, bits);
927 /* bind volumes of both NID 0x13 (Headphones) and 0x1d (Speakers) */
928 static int cxt5047_hp_master_vol_put(struct snd_kcontrol *kcontrol,
929 struct snd_ctl_elem_value *ucontrol)
931 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
932 long *valp = ucontrol->value.integer.value;
935 change = snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0,
936 0x7f, valp[0] & 0x7f);
937 change |= snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0,
938 0x7f, valp[1] & 0x7f);
939 snd_hda_codec_amp_update(codec, 0x13, 0, HDA_OUTPUT, 0,
940 0x7f, valp[0] & 0x7f);
941 snd_hda_codec_amp_update(codec, 0x13, 1, HDA_OUTPUT, 0,
942 0x7f, valp[1] & 0x7f);
946 /* mute internal speaker if HP is plugged */
947 static void cxt5047_hp_automute(struct hda_codec *codec)
949 struct conexant_spec *spec = codec->spec;
952 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
953 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
955 bits = (spec->hp_present || !spec->cur_eapd) ? 0x80 : 0;
956 snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0, 0x80, bits);
957 snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0, 0x80, bits);
958 /* Mute/Unmute PCM 2 for good measure - some systems need this */
959 snd_hda_codec_amp_update(codec, 0x1c, 0, HDA_OUTPUT, 0, 0x80, bits);
960 snd_hda_codec_amp_update(codec, 0x1c, 1, HDA_OUTPUT, 0, 0x80, bits);
963 /* mute internal speaker if HP is plugged */
964 static void cxt5047_hp2_automute(struct hda_codec *codec)
966 struct conexant_spec *spec = codec->spec;
969 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
970 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
972 bits = spec->hp_present ? 0x80 : 0;
973 snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0, 0x80, bits);
974 snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0, 0x80, bits);
975 /* Mute/Unmute PCM 2 for good measure - some systems need this */
976 snd_hda_codec_amp_update(codec, 0x1c, 0, HDA_OUTPUT, 0, 0x80, bits);
977 snd_hda_codec_amp_update(codec, 0x1c, 1, HDA_OUTPUT, 0, 0x80, bits);
980 /* toggle input of built-in and mic jack appropriately */
981 static void cxt5047_hp_automic(struct hda_codec *codec)
983 static struct hda_verb mic_jack_on[] = {
984 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
985 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
988 static struct hda_verb mic_jack_off[] = {
989 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
990 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
993 unsigned int present;
995 present = snd_hda_codec_read(codec, 0x15, 0,
996 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
998 snd_hda_sequence_write(codec, mic_jack_on);
1000 snd_hda_sequence_write(codec, mic_jack_off);
1003 /* unsolicited event for HP jack sensing */
1004 static void cxt5047_hp_unsol_event(struct hda_codec *codec,
1009 case CONEXANT_HP_EVENT:
1010 cxt5047_hp_automute(codec);
1012 case CONEXANT_MIC_EVENT:
1013 cxt5047_hp_automic(codec);
1018 /* unsolicited event for HP jack sensing - non-EAPD systems */
1019 static void cxt5047_hp2_unsol_event(struct hda_codec *codec,
1024 case CONEXANT_HP_EVENT:
1025 cxt5047_hp2_automute(codec);
1027 case CONEXANT_MIC_EVENT:
1028 cxt5047_hp_automic(codec);
1033 static struct snd_kcontrol_new cxt5047_mixers[] = {
1034 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1035 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1036 HDA_CODEC_VOLUME("Mic Gain Volume", 0x1a, 0x0, HDA_OUTPUT),
1037 HDA_CODEC_MUTE("Mic Gain Switch", 0x1a, 0x0, HDA_OUTPUT),
1038 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1039 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1040 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1041 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1042 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT),
1043 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT),
1044 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x00, HDA_OUTPUT),
1045 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x00, HDA_OUTPUT),
1046 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1047 HDA_CODEC_MUTE("Headphone Playback Switch", 0x13, 0x00, HDA_OUTPUT),
1052 static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = {
1054 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1055 .name = "Capture Source",
1056 .info = conexant_mux_enum_info,
1057 .get = conexant_mux_enum_get,
1058 .put = conexant_mux_enum_put
1060 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1061 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1062 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1063 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1064 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1065 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1067 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1068 .name = "Master Playback Volume",
1069 .info = snd_hda_mixer_amp_volume_info,
1070 .get = snd_hda_mixer_amp_volume_get,
1071 .put = cxt5047_hp_master_vol_put,
1072 .private_value = HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
1075 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1076 .name = "Master Playback Switch",
1077 .info = cxt_eapd_info,
1078 .get = cxt_eapd_get,
1079 .put = cxt5047_hp_master_sw_put,
1080 .private_value = 0x13,
1086 static struct snd_kcontrol_new cxt5047_hp_mixers[] = {
1088 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1089 .name = "Capture Source",
1090 .info = conexant_mux_enum_info,
1091 .get = conexant_mux_enum_get,
1092 .put = conexant_mux_enum_put
1094 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1095 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19,0x02,HDA_INPUT),
1096 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1097 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1098 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1099 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1100 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1102 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1103 .name = "Master Playback Switch",
1104 .info = cxt_eapd_info,
1105 .get = cxt_eapd_get,
1106 .put = cxt5047_hp_master_sw_put,
1107 .private_value = 0x13,
1112 static struct hda_verb cxt5047_init_verbs[] = {
1113 /* Line in, Mic, Built-in Mic */
1114 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1115 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1116 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1118 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1119 {0x13, AC_VERB_SET_CONNECT_SEL,0x1},
1120 {0x1d, AC_VERB_SET_CONNECT_SEL,0x0},
1121 /* Record selector: Mic */
1122 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1123 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1124 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1125 {0x1A, AC_VERB_SET_CONNECT_SEL,0x02},
1126 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1127 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1128 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1129 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
1130 /* SPDIF route: PCM */
1131 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
1132 /* Enable unsolicited events */
1133 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1134 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1138 /* configuration for Toshiba Laptops */
1139 static struct hda_verb cxt5047_toshiba_init_verbs[] = {
1140 {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0 }, /* default on */
1141 /* pin sensing on HP and Mic jacks */
1142 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1143 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1144 /* Speaker routing */
1145 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1149 /* configuration for HP Laptops */
1150 static struct hda_verb cxt5047_hp_init_verbs[] = {
1151 /* pin sensing on HP jack */
1152 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1153 /* Record selector: Ext Mic */
1154 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1155 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1156 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1157 /* Speaker routing */
1158 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1162 /* Test configuration for debugging, modelled after the ALC260 test
1165 #ifdef CONFIG_SND_DEBUG
1166 static struct hda_input_mux cxt5047_test_capture_source = {
1169 { "LINE1 pin", 0x0 },
1170 { "MIC1 pin", 0x1 },
1171 { "MIC2 pin", 0x2 },
1176 static struct snd_kcontrol_new cxt5047_test_mixer[] = {
1178 /* Output only controls */
1179 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT),
1180 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT),
1181 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT),
1182 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT),
1183 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1184 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1185 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1186 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1187 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT),
1188 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1189 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT),
1190 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT),
1192 /* Modes for retasking pin widgets */
1193 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT),
1194 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT),
1196 /* EAPD Switch Control */
1197 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1199 /* Loopback mixer controls */
1200 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT),
1201 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT),
1202 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT),
1203 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT),
1204 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT),
1205 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT),
1206 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT),
1207 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT),
1209 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT),
1210 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT),
1211 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT),
1212 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT),
1213 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT),
1214 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT),
1215 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT),
1216 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT),
1218 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1219 .name = "Input Source",
1220 .info = conexant_mux_enum_info,
1221 .get = conexant_mux_enum_get,
1222 .put = conexant_mux_enum_put,
1227 static struct hda_verb cxt5047_test_init_verbs[] = {
1228 /* Enable retasking pins as output, initially without power amp */
1229 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1230 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1231 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1233 /* Disable digital (SPDIF) pins initially, but users can enable
1234 * them via a mixer switch. In the case of SPDIF-out, this initverb
1235 * payload also sets the generation to 0, output to be in "consumer"
1236 * PCM format, copyright asserted, no pre-emphasis and no validity
1239 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
1241 /* Ensure mic1, mic2, line1 pin widgets take input from the
1242 * OUT1 sum bus when acting as an output.
1244 {0x1a, AC_VERB_SET_CONNECT_SEL, 0},
1245 {0x1b, AC_VERB_SET_CONNECT_SEL, 0},
1247 /* Start with output sum widgets muted and their output gains at min */
1248 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1249 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1251 /* Unmute retasking pin widget output buffers since the default
1252 * state appears to be output. As the pin mode is changed by the
1253 * user the pin mode control will take care of enabling the pin's
1254 * input/output buffers as needed.
1256 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1257 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1258 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1260 /* Mute capture amp left and right */
1261 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1263 /* Set ADC connection select to match default mixer setting (mic1
1266 {0x12, AC_VERB_SET_CONNECT_SEL, 0x00},
1268 /* Mute all inputs to mixer widget (even unconnected ones) */
1269 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
1270 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
1271 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
1272 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
1273 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
1274 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1275 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
1276 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
1283 /* initialize jack-sensing, too */
1284 static int cxt5047_hp_init(struct hda_codec *codec)
1286 conexant_init(codec);
1287 cxt5047_hp_automute(codec);
1293 CXT5047_LAPTOP, /* Laptops w/o EAPD support */
1294 CXT5047_LAPTOP_HP, /* Some HP laptops */
1295 CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */
1296 #ifdef CONFIG_SND_DEBUG
1302 static const char *cxt5047_models[CXT5047_MODELS] = {
1303 [CXT5047_LAPTOP] = "laptop",
1304 [CXT5047_LAPTOP_HP] = "laptop-hp",
1305 [CXT5047_LAPTOP_EAPD] = "laptop-eapd",
1306 #ifdef CONFIG_SND_DEBUG
1307 [CXT5047_TEST] = "test",
1311 static struct snd_pci_quirk cxt5047_cfg_tbl[] = {
1312 SND_PCI_QUIRK(0x103c, 0x30a0, "HP DV1000", CXT5047_LAPTOP),
1313 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV2000T/DV3000T", CXT5047_LAPTOP),
1314 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2000Z", CXT5047_LAPTOP),
1315 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
1316 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD),
1320 static int patch_cxt5047(struct hda_codec *codec)
1322 struct conexant_spec *spec;
1325 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1328 mutex_init(&spec->amp_mutex);
1331 spec->multiout.max_channels = 2;
1332 spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids);
1333 spec->multiout.dac_nids = cxt5047_dac_nids;
1334 spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT;
1335 spec->num_adc_nids = 1;
1336 spec->adc_nids = cxt5047_adc_nids;
1337 spec->capsrc_nids = cxt5047_capsrc_nids;
1338 spec->input_mux = &cxt5047_capture_source;
1339 spec->num_mixers = 1;
1340 spec->mixers[0] = cxt5047_mixers;
1341 spec->num_init_verbs = 1;
1342 spec->init_verbs[0] = cxt5047_init_verbs;
1343 spec->spdif_route = 0;
1344 spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes),
1345 spec->channel_mode = cxt5047_modes,
1347 codec->patch_ops = conexant_patch_ops;
1349 board_config = snd_hda_check_board_config(codec, CXT5047_MODELS,
1352 switch (board_config) {
1353 case CXT5047_LAPTOP:
1354 codec->patch_ops.unsol_event = cxt5047_hp2_unsol_event;
1356 case CXT5047_LAPTOP_HP:
1357 spec->input_mux = &cxt5047_hp_capture_source;
1358 spec->num_init_verbs = 2;
1359 spec->init_verbs[1] = cxt5047_hp_init_verbs;
1360 spec->mixers[0] = cxt5047_hp_mixers;
1361 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1362 codec->patch_ops.init = cxt5047_hp_init;
1364 case CXT5047_LAPTOP_EAPD:
1365 spec->input_mux = &cxt5047_toshiba_capture_source;
1366 spec->num_init_verbs = 2;
1367 spec->init_verbs[1] = cxt5047_toshiba_init_verbs;
1368 spec->mixers[0] = cxt5047_toshiba_mixers;
1369 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1371 #ifdef CONFIG_SND_DEBUG
1373 spec->input_mux = &cxt5047_test_capture_source;
1374 spec->mixers[0] = cxt5047_test_mixer;
1375 spec->init_verbs[0] = cxt5047_test_init_verbs;
1376 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1382 struct hda_codec_preset snd_hda_preset_conexant[] = {
1383 { .id = 0x14f15045, .name = "CX20549 (Venice)",
1384 .patch = patch_cxt5045 },
1385 { .id = 0x14f15047, .name = "CX20551 (Waikiki)",
1386 .patch = patch_cxt5047 },