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);
142 static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
143 struct hda_codec *codec,
144 unsigned int stream_tag,
146 struct snd_pcm_substream *substream)
148 struct conexant_spec *spec = codec->spec;
149 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
150 stream_tag, 0, format);
154 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
155 struct hda_codec *codec,
156 struct snd_pcm_substream *substream)
158 struct conexant_spec *spec = codec->spec;
159 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
166 static struct hda_pcm_stream conexant_pcm_analog_playback = {
170 .nid = 0, /* fill later */
172 .open = conexant_playback_pcm_open,
173 .prepare = conexant_playback_pcm_prepare,
174 .cleanup = conexant_playback_pcm_cleanup
178 static struct hda_pcm_stream conexant_pcm_analog_capture = {
182 .nid = 0, /* fill later */
184 .prepare = conexant_capture_pcm_prepare,
185 .cleanup = conexant_capture_pcm_cleanup
190 static struct hda_pcm_stream conexant_pcm_digital_playback = {
194 .nid = 0, /* fill later */
196 .open = conexant_dig_playback_pcm_open,
197 .close = conexant_dig_playback_pcm_close
201 static struct hda_pcm_stream conexant_pcm_digital_capture = {
205 /* NID is set in alc_build_pcms */
208 static int conexant_build_pcms(struct hda_codec *codec)
210 struct conexant_spec *spec = codec->spec;
211 struct hda_pcm *info = spec->pcm_rec;
214 codec->pcm_info = info;
216 info->name = "CONEXANT Analog";
217 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback;
218 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max =
219 spec->multiout.max_channels;
220 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
221 spec->multiout.dac_nids[0];
222 info->stream[SNDRV_PCM_STREAM_CAPTURE] = conexant_pcm_analog_capture;
223 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
224 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
226 if (spec->multiout.dig_out_nid) {
229 info->name = "Conexant Digital";
230 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
231 conexant_pcm_digital_playback;
232 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
233 spec->multiout.dig_out_nid;
234 if (spec->dig_in_nid) {
235 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
236 conexant_pcm_digital_capture;
237 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
245 static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol,
246 struct snd_ctl_elem_info *uinfo)
248 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
249 struct conexant_spec *spec = codec->spec;
251 return snd_hda_input_mux_info(spec->input_mux, uinfo);
254 static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol,
255 struct snd_ctl_elem_value *ucontrol)
257 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
258 struct conexant_spec *spec = codec->spec;
259 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
261 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
265 static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol,
266 struct snd_ctl_elem_value *ucontrol)
268 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
269 struct conexant_spec *spec = codec->spec;
270 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
272 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
273 spec->capsrc_nids[adc_idx],
274 &spec->cur_mux[adc_idx]);
277 static int conexant_init(struct hda_codec *codec)
279 struct conexant_spec *spec = codec->spec;
282 for (i = 0; i < spec->num_init_verbs; i++)
283 snd_hda_sequence_write(codec, spec->init_verbs[i]);
287 static void conexant_free(struct hda_codec *codec)
289 struct conexant_spec *spec = codec->spec;
292 if (spec->kctl_alloc) {
293 for (i = 0; i < spec->num_kctl_used; i++)
294 kfree(spec->kctl_alloc[i].name);
295 kfree(spec->kctl_alloc);
302 static int conexant_resume(struct hda_codec *codec)
304 struct conexant_spec *spec = codec->spec;
307 codec->patch_ops.init(codec);
308 for (i = 0; i < spec->num_mixers; i++)
309 snd_hda_resume_ctls(codec, spec->mixers[i]);
310 if (spec->multiout.dig_out_nid)
311 snd_hda_resume_spdif_out(codec);
312 if (spec->dig_in_nid)
313 snd_hda_resume_spdif_in(codec);
318 static int conexant_build_controls(struct hda_codec *codec)
320 struct conexant_spec *spec = codec->spec;
324 for (i = 0; i < spec->num_mixers; i++) {
325 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
329 if (spec->multiout.dig_out_nid) {
330 err = snd_hda_create_spdif_out_ctls(codec,
331 spec->multiout.dig_out_nid);
335 if (spec->dig_in_nid) {
336 err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid);
343 static struct hda_codec_ops conexant_patch_ops = {
344 .build_controls = conexant_build_controls,
345 .build_pcms = conexant_build_pcms,
346 .init = conexant_init,
347 .free = conexant_free,
349 .resume = conexant_resume,
355 * the private value = nid | (invert << 8)
358 static int cxt_eapd_info(struct snd_kcontrol *kcontrol,
359 struct snd_ctl_elem_info *uinfo)
361 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
363 uinfo->value.integer.min = 0;
364 uinfo->value.integer.max = 1;
368 static int cxt_eapd_get(struct snd_kcontrol *kcontrol,
369 struct snd_ctl_elem_value *ucontrol)
371 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
372 struct conexant_spec *spec = codec->spec;
373 int invert = (kcontrol->private_value >> 8) & 1;
375 ucontrol->value.integer.value[0] = !spec->cur_eapd;
377 ucontrol->value.integer.value[0] = spec->cur_eapd;
382 static int cxt_eapd_put(struct snd_kcontrol *kcontrol,
383 struct snd_ctl_elem_value *ucontrol)
385 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
386 struct conexant_spec *spec = codec->spec;
387 int invert = (kcontrol->private_value >> 8) & 1;
388 hda_nid_t nid = kcontrol->private_value & 0xff;
391 eapd = ucontrol->value.integer.value[0];
394 if (eapd == spec->cur_eapd && !codec->in_resume)
397 spec->cur_eapd = eapd;
398 snd_hda_codec_write(codec, nid,
399 0, AC_VERB_SET_EAPD_BTLENABLE,
404 /* controls for test mode */
405 #ifdef CONFIG_SND_DEBUG
407 #define CXT_EAPD_SWITCH(xname, nid, mask) \
408 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
409 .info = cxt_eapd_info, \
410 .get = cxt_eapd_get, \
411 .put = cxt_eapd_put, \
412 .private_value = nid | (mask<<16) }
416 static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol,
417 struct snd_ctl_elem_info *uinfo)
419 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
420 struct conexant_spec *spec = codec->spec;
421 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
422 spec->num_channel_mode);
425 static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol,
426 struct snd_ctl_elem_value *ucontrol)
428 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
429 struct conexant_spec *spec = codec->spec;
430 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
431 spec->num_channel_mode,
432 spec->multiout.max_channels);
435 static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol,
436 struct snd_ctl_elem_value *ucontrol)
438 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
439 struct conexant_spec *spec = codec->spec;
440 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
441 spec->num_channel_mode,
442 &spec->multiout.max_channels);
443 if (err >= 0 && spec->need_dac_fix)
444 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
448 #define CXT_PIN_MODE(xname, nid, dir) \
449 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
450 .info = conexant_ch_mode_info, \
451 .get = conexant_ch_mode_get, \
452 .put = conexant_ch_mode_put, \
453 .private_value = nid | (dir<<16) }
455 #endif /* CONFIG_SND_DEBUG */
457 /* Conexant 5045 specific */
459 static hda_nid_t cxt5045_dac_nids[1] = { 0x19 };
460 static hda_nid_t cxt5045_adc_nids[1] = { 0x1a };
461 static hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a };
462 #define CXT5045_SPDIF_OUT 0x13
464 static struct hda_channel_mode cxt5045_modes[1] = {
468 static struct hda_input_mux cxt5045_capture_source = {
476 /* turn on/off EAPD (+ mute HP) as a master switch */
477 static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_value *ucontrol)
480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
481 struct conexant_spec *spec = codec->spec;
484 if (!cxt_eapd_put(kcontrol, ucontrol))
487 /* toggle internal speakers mute depending of presence of
490 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : 0x80;
491 snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits);
492 snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits);
494 bits = spec->cur_eapd ? 0 : 0x80;
495 snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0, 0x80, bits);
496 snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0, 0x80, bits);
500 /* bind volumes of both NID 0x10 and 0x11 */
501 static int cxt5045_hp_master_vol_put(struct snd_kcontrol *kcontrol,
502 struct snd_ctl_elem_value *ucontrol)
504 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
505 long *valp = ucontrol->value.integer.value;
508 change = snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0,
509 0x7f, valp[0] & 0x7f);
510 change |= snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0,
511 0x7f, valp[1] & 0x7f);
512 snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0,
513 0x7f, valp[0] & 0x7f);
514 snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0,
515 0x7f, valp[1] & 0x7f);
519 /* toggle input of built-in and mic jack appropriately */
520 static void cxt5045_hp_automic(struct hda_codec *codec)
522 static struct hda_verb mic_jack_on[] = {
523 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
524 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
527 static struct hda_verb mic_jack_off[] = {
528 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
529 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
532 unsigned int present;
534 present = snd_hda_codec_read(codec, 0x12, 0,
535 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
537 snd_hda_sequence_write(codec, mic_jack_on);
539 snd_hda_sequence_write(codec, mic_jack_off);
543 /* mute internal speaker if HP is plugged */
544 static void cxt5045_hp_automute(struct hda_codec *codec)
546 struct conexant_spec *spec = codec->spec;
549 spec->hp_present = snd_hda_codec_read(codec, 0x11, 0,
550 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
552 bits = (spec->hp_present || !spec->cur_eapd) ? 0x80 : 0;
553 snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits);
554 snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits);
557 /* unsolicited event for HP jack sensing */
558 static void cxt5045_hp_unsol_event(struct hda_codec *codec,
563 case CONEXANT_HP_EVENT:
564 cxt5045_hp_automute(codec);
566 case CONEXANT_MIC_EVENT:
567 cxt5045_hp_automic(codec);
573 static struct snd_kcontrol_new cxt5045_mixers[] = {
575 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
576 .name = "Capture Source",
577 .info = conexant_mux_enum_info,
578 .get = conexant_mux_enum_get,
579 .put = conexant_mux_enum_put
581 HDA_CODEC_VOLUME("Int Mic Volume", 0x1a, 0x01, HDA_INPUT),
582 HDA_CODEC_MUTE("Int Mic Switch", 0x1a, 0x01, HDA_INPUT),
583 HDA_CODEC_VOLUME("Ext Mic Volume", 0x1a, 0x02, HDA_INPUT),
584 HDA_CODEC_MUTE("Ext Mic Switch", 0x1a, 0x02, HDA_INPUT),
586 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
587 .name = "Master Playback Volume",
588 .info = snd_hda_mixer_amp_volume_info,
589 .get = snd_hda_mixer_amp_volume_get,
590 .put = cxt5045_hp_master_vol_put,
591 .private_value = HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT),
594 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
595 .name = "Master Playback Switch",
596 .info = cxt_eapd_info,
598 .put = cxt5045_hp_master_sw_put,
599 .private_value = 0x10,
605 static struct hda_verb cxt5045_init_verbs[] = {
607 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
608 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
610 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
611 {0x17, AC_VERB_SET_CONNECT_SEL,0x01},
612 {0x17, AC_VERB_SET_AMP_GAIN_MUTE,
613 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x01},
614 {0x17, AC_VERB_SET_AMP_GAIN_MUTE,
615 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x02},
616 {0x17, AC_VERB_SET_AMP_GAIN_MUTE,
617 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
618 {0x17, AC_VERB_SET_AMP_GAIN_MUTE,
619 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x04},
620 /* Record selector: Int mic */
621 {0x1a, AC_VERB_SET_CONNECT_SEL,0x1},
622 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
623 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
624 /* SPDIF route: PCM */
625 { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
627 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */
632 static struct hda_verb cxt5045_hp_sense_init_verbs[] = {
633 /* pin sensing on HP jack */
634 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
638 static struct hda_verb cxt5045_mic_sense_init_verbs[] = {
639 /* pin sensing on HP jack */
640 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
644 #ifdef CONFIG_SND_DEBUG
645 /* Test configuration for debugging, modelled after the ALC260 test
648 static struct hda_input_mux cxt5045_test_capture_source = {
653 { "LINE1 pin", 0x2 },
654 { "HP-OUT pin", 0x3 },
659 static struct snd_kcontrol_new cxt5045_test_mixer[] = {
661 /* Output controls */
662 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
663 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
664 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT),
665 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT),
666 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT),
667 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT),
669 /* Modes for retasking pin widgets */
670 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
671 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT),
673 /* EAPD Switch Control */
674 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
676 /* Loopback mixer controls */
678 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT),
679 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT),
680 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT),
681 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT),
682 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT),
683 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT),
684 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT),
685 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT),
686 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT),
687 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT),
689 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
690 .name = "Input Source",
691 .info = conexant_mux_enum_info,
692 .get = conexant_mux_enum_get,
693 .put = conexant_mux_enum_put,
698 static struct hda_verb cxt5045_test_init_verbs[] = {
699 /* Set connections */
700 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
701 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 },
702 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 },
703 /* Enable retasking pins as output, initially without power amp */
704 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
705 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
707 /* Disable digital (SPDIF) pins initially, but users can enable
708 * them via a mixer switch. In the case of SPDIF-out, this initverb
709 * payload also sets the generation to 0, output to be in "consumer"
710 * PCM format, copyright asserted, no pre-emphasis and no validity
713 {0x13, AC_VERB_SET_DIGI_CONVERT_1, 0},
715 /* Start with output sum widgets muted and their output gains at min */
716 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
717 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
719 /* Unmute retasking pin widget output buffers since the default
720 * state appears to be output. As the pin mode is changed by the
721 * user the pin mode control will take care of enabling the pin's
722 * input/output buffers as needed.
724 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
725 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
727 /* Mute capture amp left and right */
728 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
730 /* Set ADC connection select to match default mixer setting (mic1
733 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
734 {0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
736 /* Mute all inputs to mixer widget (even unconnected ones) */
737 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */
738 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */
739 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */
740 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */
741 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
748 /* initialize jack-sensing, too */
749 static int cxt5045_init(struct hda_codec *codec)
751 conexant_init(codec);
752 cxt5045_hp_automute(codec);
758 CXT5045_LAPTOP, /* Laptops w/ EAPD support */
759 CXT5045_FUJITSU, /* Laptops w/ EAPD support */
760 #ifdef CONFIG_SND_DEBUG
766 static const char *cxt5045_models[CXT5045_MODELS] = {
767 [CXT5045_LAPTOP] = "laptop",
768 [CXT5045_FUJITSU] = "fujitsu",
769 #ifdef CONFIG_SND_DEBUG
770 [CXT5045_TEST] = "test",
774 static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
775 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP),
776 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP),
777 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_FUJITSU),
778 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP),
782 static int patch_cxt5045(struct hda_codec *codec)
784 struct conexant_spec *spec;
787 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
790 mutex_init(&spec->amp_mutex);
793 spec->multiout.max_channels = 2;
794 spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids);
795 spec->multiout.dac_nids = cxt5045_dac_nids;
796 spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT;
797 spec->num_adc_nids = 1;
798 spec->adc_nids = cxt5045_adc_nids;
799 spec->capsrc_nids = cxt5045_capsrc_nids;
800 spec->input_mux = &cxt5045_capture_source;
801 spec->num_mixers = 1;
802 spec->mixers[0] = cxt5045_mixers;
803 spec->num_init_verbs = 1;
804 spec->init_verbs[0] = cxt5045_init_verbs;
805 spec->spdif_route = 0;
806 spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes),
807 spec->channel_mode = cxt5045_modes,
810 codec->patch_ops = conexant_patch_ops;
812 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
815 switch (board_config) {
817 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
818 spec->input_mux = &cxt5045_capture_source;
819 spec->num_init_verbs = 2;
820 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
821 spec->mixers[0] = cxt5045_mixers;
822 codec->patch_ops.init = cxt5045_init;
824 case CXT5045_FUJITSU:
825 spec->input_mux = &cxt5045_capture_source;
826 spec->num_init_verbs = 2;
827 spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;
828 spec->mixers[0] = cxt5045_mixers;
829 codec->patch_ops.init = cxt5045_init;
831 #ifdef CONFIG_SND_DEBUG
833 spec->input_mux = &cxt5045_test_capture_source;
834 spec->mixers[0] = cxt5045_test_mixer;
835 spec->init_verbs[0] = cxt5045_test_init_verbs;
842 /* Conexant 5047 specific */
843 #define CXT5047_SPDIF_OUT 0x11
845 static hda_nid_t cxt5047_dac_nids[2] = { 0x10, 0x1c };
846 static hda_nid_t cxt5047_adc_nids[1] = { 0x12 };
847 static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a };
849 static struct hda_channel_mode cxt5047_modes[1] = {
853 static struct hda_input_mux cxt5047_capture_source = {
860 static struct hda_input_mux cxt5047_hp_capture_source = {
867 static struct hda_input_mux cxt5047_toshiba_capture_source = {
875 /* turn on/off EAPD (+ mute HP) as a master switch */
876 static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
877 struct snd_ctl_elem_value *ucontrol)
879 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
880 struct conexant_spec *spec = codec->spec;
883 if (!cxt_eapd_put(kcontrol, ucontrol))
886 /* toggle internal speakers mute depending of presence of
889 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : 0x80;
890 snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0, 0x80, bits);
891 snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0, 0x80, bits);
892 bits = spec->cur_eapd ? 0 : 0x80;
893 snd_hda_codec_amp_update(codec, 0x13, 0, HDA_OUTPUT, 0, 0x80, bits);
894 snd_hda_codec_amp_update(codec, 0x13, 1, HDA_OUTPUT, 0, 0x80, bits);
898 /* bind volumes of both NID 0x13 (Headphones) and 0x1d (Speakers) */
899 static int cxt5047_hp_master_vol_put(struct snd_kcontrol *kcontrol,
900 struct snd_ctl_elem_value *ucontrol)
902 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
903 long *valp = ucontrol->value.integer.value;
906 change = snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0,
907 0x7f, valp[0] & 0x7f);
908 change |= snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0,
909 0x7f, valp[1] & 0x7f);
910 snd_hda_codec_amp_update(codec, 0x13, 0, HDA_OUTPUT, 0,
911 0x7f, valp[0] & 0x7f);
912 snd_hda_codec_amp_update(codec, 0x13, 1, HDA_OUTPUT, 0,
913 0x7f, valp[1] & 0x7f);
917 /* mute internal speaker if HP is plugged */
918 static void cxt5047_hp_automute(struct hda_codec *codec)
920 struct conexant_spec *spec = codec->spec;
923 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
924 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
926 bits = (spec->hp_present || !spec->cur_eapd) ? 0x80 : 0;
927 snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0, 0x80, bits);
928 snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0, 0x80, bits);
929 /* Mute/Unmute PCM 2 for good measure - some systems need this */
930 snd_hda_codec_amp_update(codec, 0x1c, 0, HDA_OUTPUT, 0, 0x80, bits);
931 snd_hda_codec_amp_update(codec, 0x1c, 1, HDA_OUTPUT, 0, 0x80, bits);
934 /* toggle input of built-in and mic jack appropriately */
935 static void cxt5047_hp_automic(struct hda_codec *codec)
937 static struct hda_verb mic_jack_on[] = {
938 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
939 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
942 static struct hda_verb mic_jack_off[] = {
943 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
944 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
947 unsigned int present;
949 present = snd_hda_codec_read(codec, 0x15, 0,
950 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
952 snd_hda_sequence_write(codec, mic_jack_on);
954 snd_hda_sequence_write(codec, mic_jack_off);
957 /* unsolicited event for HP jack sensing */
958 static void cxt5047_hp_unsol_event(struct hda_codec *codec,
963 case CONEXANT_HP_EVENT:
964 cxt5047_hp_automute(codec);
966 case CONEXANT_MIC_EVENT:
967 cxt5047_hp_automic(codec);
972 static struct snd_kcontrol_new cxt5047_mixers[] = {
973 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
974 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
975 HDA_CODEC_VOLUME("Mic Gain Volume", 0x1a, 0x0, HDA_OUTPUT),
976 HDA_CODEC_MUTE("Mic Gain Switch", 0x1a, 0x0, HDA_OUTPUT),
977 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
978 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
979 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
980 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
981 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT),
982 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT),
984 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
985 .name = "Master Playback Volume",
986 .info = snd_hda_mixer_amp_volume_info,
987 .get = snd_hda_mixer_amp_volume_get,
988 .put = cxt5047_hp_master_vol_put,
989 .private_value = HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
992 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
993 .name = "Master Playback Switch",
994 .info = cxt_eapd_info,
996 .put = cxt5047_hp_master_sw_put,
997 .private_value = 0x13,
1003 static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = {
1005 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1006 .name = "Capture Source",
1007 .info = conexant_mux_enum_info,
1008 .get = conexant_mux_enum_get,
1009 .put = conexant_mux_enum_put
1011 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1012 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1013 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1014 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1015 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1016 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1018 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1019 .name = "Master Playback Volume",
1020 .info = snd_hda_mixer_amp_volume_info,
1021 .get = snd_hda_mixer_amp_volume_get,
1022 .put = cxt5047_hp_master_vol_put,
1023 .private_value = HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
1026 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1027 .name = "Master Playback Switch",
1028 .info = cxt_eapd_info,
1029 .get = cxt_eapd_get,
1030 .put = cxt5047_hp_master_sw_put,
1031 .private_value = 0x13,
1037 static struct snd_kcontrol_new cxt5047_hp_mixers[] = {
1039 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1040 .name = "Capture Source",
1041 .info = conexant_mux_enum_info,
1042 .get = conexant_mux_enum_get,
1043 .put = conexant_mux_enum_put
1045 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1046 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19,0x02,HDA_INPUT),
1047 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1048 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1049 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1050 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1051 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1053 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1054 .name = "Master Playback Switch",
1055 .info = cxt_eapd_info,
1056 .get = cxt_eapd_get,
1057 .put = cxt5047_hp_master_sw_put,
1058 .private_value = 0x13,
1063 static struct hda_verb cxt5047_init_verbs[] = {
1064 /* Line in, Mic, Built-in Mic */
1065 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1066 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1067 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1069 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1070 {0x1d, AC_VERB_SET_CONNECT_SEL,0x0},
1071 /* Record selector: Mic */
1072 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1073 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1074 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1075 {0x1A, AC_VERB_SET_CONNECT_SEL,0x02},
1076 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1077 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1078 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1079 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
1080 /* SPDIF route: PCM */
1081 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
1082 /* Enable unsolicited events */
1083 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1084 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1088 /* configuration for Toshiba Laptops */
1089 static struct hda_verb cxt5047_toshiba_init_verbs[] = {
1090 {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0 }, /* default on */
1091 /* pin sensing on HP and Mic jacks */
1092 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1093 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1094 /* Speaker routing */
1095 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1099 /* configuration for HP Laptops */
1100 static struct hda_verb cxt5047_hp_init_verbs[] = {
1101 /* pin sensing on HP jack */
1102 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1103 /* Record selector: Ext Mic */
1104 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1105 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1106 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1107 /* Speaker routing */
1108 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1112 /* Test configuration for debugging, modelled after the ALC260 test
1115 #ifdef CONFIG_SND_DEBUG
1116 static struct hda_input_mux cxt5047_test_capture_source = {
1119 { "LINE1 pin", 0x0 },
1120 { "MIC1 pin", 0x1 },
1121 { "MIC2 pin", 0x2 },
1126 static struct snd_kcontrol_new cxt5047_test_mixer[] = {
1128 /* Output only controls */
1129 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT),
1130 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT),
1131 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT),
1132 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT),
1133 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1134 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1135 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1136 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1137 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT),
1138 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1139 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT),
1140 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT),
1142 /* Modes for retasking pin widgets */
1143 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT),
1144 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT),
1146 /* EAPD Switch Control */
1147 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1149 /* Loopback mixer controls */
1150 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT),
1151 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT),
1152 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT),
1153 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT),
1154 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT),
1155 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT),
1156 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT),
1157 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT),
1159 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT),
1160 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT),
1161 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT),
1162 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT),
1163 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT),
1164 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT),
1165 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT),
1166 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT),
1168 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1169 .name = "Input Source",
1170 .info = conexant_mux_enum_info,
1171 .get = conexant_mux_enum_get,
1172 .put = conexant_mux_enum_put,
1177 static struct hda_verb cxt5047_test_init_verbs[] = {
1178 /* Enable retasking pins as output, initially without power amp */
1179 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1181 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1183 /* Disable digital (SPDIF) pins initially, but users can enable
1184 * them via a mixer switch. In the case of SPDIF-out, this initverb
1185 * payload also sets the generation to 0, output to be in "consumer"
1186 * PCM format, copyright asserted, no pre-emphasis and no validity
1189 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
1191 /* Ensure mic1, mic2, line1 pin widgets take input from the
1192 * OUT1 sum bus when acting as an output.
1194 {0x1a, AC_VERB_SET_CONNECT_SEL, 0},
1195 {0x1b, AC_VERB_SET_CONNECT_SEL, 0},
1197 /* Start with output sum widgets muted and their output gains at min */
1198 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1199 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1201 /* Unmute retasking pin widget output buffers since the default
1202 * state appears to be output. As the pin mode is changed by the
1203 * user the pin mode control will take care of enabling the pin's
1204 * input/output buffers as needed.
1206 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1207 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1208 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1210 /* Mute capture amp left and right */
1211 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1213 /* Set ADC connection select to match default mixer setting (mic1
1216 {0x12, AC_VERB_SET_CONNECT_SEL, 0x00},
1218 /* Mute all inputs to mixer widget (even unconnected ones) */
1219 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
1220 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
1221 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
1222 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
1223 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
1224 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1225 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
1226 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
1233 /* initialize jack-sensing, too */
1234 static int cxt5047_hp_init(struct hda_codec *codec)
1236 conexant_init(codec);
1237 cxt5047_hp_automute(codec);
1243 CXT5047_LAPTOP, /* Laptops w/o EAPD support */
1244 CXT5047_LAPTOP_HP, /* Some HP laptops */
1245 CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */
1246 #ifdef CONFIG_SND_DEBUG
1252 static const char *cxt5047_models[CXT5047_MODELS] = {
1253 [CXT5047_LAPTOP] = "laptop",
1254 [CXT5047_LAPTOP_HP] = "laptop-hp",
1255 [CXT5047_LAPTOP_EAPD] = "laptop-eapd",
1256 #ifdef CONFIG_SND_DEBUG
1257 [CXT5047_TEST] = "test",
1261 static struct snd_pci_quirk cxt5047_cfg_tbl[] = {
1262 SND_PCI_QUIRK(0x103c, 0x30a0, "HP DV1000", CXT5047_LAPTOP),
1263 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV2000T/DV3000T", CXT5047_LAPTOP),
1264 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2000Z", CXT5047_LAPTOP),
1265 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
1266 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD),
1270 static int patch_cxt5047(struct hda_codec *codec)
1272 struct conexant_spec *spec;
1275 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1278 mutex_init(&spec->amp_mutex);
1281 spec->multiout.max_channels = 2;
1282 spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids);
1283 spec->multiout.dac_nids = cxt5047_dac_nids;
1284 spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT;
1285 spec->num_adc_nids = 1;
1286 spec->adc_nids = cxt5047_adc_nids;
1287 spec->capsrc_nids = cxt5047_capsrc_nids;
1288 spec->input_mux = &cxt5047_capture_source;
1289 spec->num_mixers = 1;
1290 spec->mixers[0] = cxt5047_mixers;
1291 spec->num_init_verbs = 1;
1292 spec->init_verbs[0] = cxt5047_init_verbs;
1293 spec->spdif_route = 0;
1294 spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes),
1295 spec->channel_mode = cxt5047_modes,
1297 codec->patch_ops = conexant_patch_ops;
1298 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1300 board_config = snd_hda_check_board_config(codec, CXT5047_MODELS,
1303 switch (board_config) {
1304 case CXT5047_LAPTOP:
1306 case CXT5047_LAPTOP_HP:
1307 spec->input_mux = &cxt5047_hp_capture_source;
1308 spec->num_init_verbs = 2;
1309 spec->init_verbs[1] = cxt5047_hp_init_verbs;
1310 spec->mixers[0] = cxt5047_hp_mixers;
1311 codec->patch_ops.init = cxt5047_hp_init;
1313 case CXT5047_LAPTOP_EAPD:
1314 spec->input_mux = &cxt5047_toshiba_capture_source;
1315 spec->num_init_verbs = 2;
1316 spec->init_verbs[1] = cxt5047_toshiba_init_verbs;
1317 spec->mixers[0] = cxt5047_toshiba_mixers;
1319 #ifdef CONFIG_SND_DEBUG
1321 spec->input_mux = &cxt5047_test_capture_source;
1322 spec->mixers[0] = cxt5047_test_mixer;
1323 spec->init_verbs[0] = cxt5047_test_init_verbs;
1329 struct hda_codec_preset snd_hda_preset_conexant[] = {
1330 { .id = 0x14f15045, .name = "CX20549 (Venice)",
1331 .patch = patch_cxt5045 },
1332 { .id = 0x14f15047, .name = "CX20551 (Waikiki)",
1333 .patch = patch_cxt5047 },