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);
314 static int conexant_build_controls(struct hda_codec *codec)
316 struct conexant_spec *spec = codec->spec;
320 for (i = 0; i < spec->num_mixers; i++) {
321 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
325 if (spec->multiout.dig_out_nid) {
326 err = snd_hda_create_spdif_out_ctls(codec,
327 spec->multiout.dig_out_nid);
331 if (spec->dig_in_nid) {
332 err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid);
339 static struct hda_codec_ops conexant_patch_ops = {
340 .build_controls = conexant_build_controls,
341 .build_pcms = conexant_build_pcms,
342 .init = conexant_init,
343 .free = conexant_free,
348 * the private value = nid | (invert << 8)
351 #define cxt_eapd_info snd_ctl_boolean_mono_info
353 static int cxt_eapd_get(struct snd_kcontrol *kcontrol,
354 struct snd_ctl_elem_value *ucontrol)
356 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
357 struct conexant_spec *spec = codec->spec;
358 int invert = (kcontrol->private_value >> 8) & 1;
360 ucontrol->value.integer.value[0] = !spec->cur_eapd;
362 ucontrol->value.integer.value[0] = spec->cur_eapd;
367 static int cxt_eapd_put(struct snd_kcontrol *kcontrol,
368 struct snd_ctl_elem_value *ucontrol)
370 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
371 struct conexant_spec *spec = codec->spec;
372 int invert = (kcontrol->private_value >> 8) & 1;
373 hda_nid_t nid = kcontrol->private_value & 0xff;
376 eapd = ucontrol->value.integer.value[0];
379 if (eapd == spec->cur_eapd)
382 spec->cur_eapd = eapd;
383 snd_hda_codec_write_cache(codec, nid,
384 0, AC_VERB_SET_EAPD_BTLENABLE,
389 /* controls for test mode */
390 #ifdef CONFIG_SND_DEBUG
392 #define CXT_EAPD_SWITCH(xname, nid, mask) \
393 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
394 .info = cxt_eapd_info, \
395 .get = cxt_eapd_get, \
396 .put = cxt_eapd_put, \
397 .private_value = nid | (mask<<16) }
401 static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol,
402 struct snd_ctl_elem_info *uinfo)
404 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
405 struct conexant_spec *spec = codec->spec;
406 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
407 spec->num_channel_mode);
410 static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol,
411 struct snd_ctl_elem_value *ucontrol)
413 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
414 struct conexant_spec *spec = codec->spec;
415 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
416 spec->num_channel_mode,
417 spec->multiout.max_channels);
420 static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol,
421 struct snd_ctl_elem_value *ucontrol)
423 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
424 struct conexant_spec *spec = codec->spec;
425 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
426 spec->num_channel_mode,
427 &spec->multiout.max_channels);
428 if (err >= 0 && spec->need_dac_fix)
429 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
433 #define CXT_PIN_MODE(xname, nid, dir) \
434 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
435 .info = conexant_ch_mode_info, \
436 .get = conexant_ch_mode_get, \
437 .put = conexant_ch_mode_put, \
438 .private_value = nid | (dir<<16) }
440 #endif /* CONFIG_SND_DEBUG */
442 /* Conexant 5045 specific */
444 static hda_nid_t cxt5045_dac_nids[1] = { 0x19 };
445 static hda_nid_t cxt5045_adc_nids[1] = { 0x1a };
446 static hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a };
447 #define CXT5045_SPDIF_OUT 0x13
449 static struct hda_channel_mode cxt5045_modes[1] = {
453 static struct hda_input_mux cxt5045_capture_source = {
461 /* turn on/off EAPD (+ mute HP) as a master switch */
462 static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
463 struct snd_ctl_elem_value *ucontrol)
465 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
466 struct conexant_spec *spec = codec->spec;
469 if (!cxt_eapd_put(kcontrol, ucontrol))
472 /* toggle internal speakers mute depending of presence of
475 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
476 snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
479 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
480 snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0,
485 /* bind volumes of both NID 0x10 and 0x11 */
486 static struct hda_bind_ctls cxt5045_hp_bind_master_vol = {
487 .ops = &snd_hda_bind_vol,
489 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT),
490 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
495 /* toggle input of built-in and mic jack appropriately */
496 static void cxt5045_hp_automic(struct hda_codec *codec)
498 static struct hda_verb mic_jack_on[] = {
499 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
500 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
503 static struct hda_verb mic_jack_off[] = {
504 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
505 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
508 unsigned int present;
510 present = snd_hda_codec_read(codec, 0x12, 0,
511 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
513 snd_hda_sequence_write(codec, mic_jack_on);
515 snd_hda_sequence_write(codec, mic_jack_off);
519 /* mute internal speaker if HP is plugged */
520 static void cxt5045_hp_automute(struct hda_codec *codec)
522 struct conexant_spec *spec = codec->spec;
525 spec->hp_present = snd_hda_codec_read(codec, 0x11, 0,
526 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
528 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
529 snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
533 /* unsolicited event for HP jack sensing */
534 static void cxt5045_hp_unsol_event(struct hda_codec *codec,
539 case CONEXANT_HP_EVENT:
540 cxt5045_hp_automute(codec);
542 case CONEXANT_MIC_EVENT:
543 cxt5045_hp_automic(codec);
549 static struct snd_kcontrol_new cxt5045_mixers[] = {
551 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
552 .name = "Capture Source",
553 .info = conexant_mux_enum_info,
554 .get = conexant_mux_enum_get,
555 .put = conexant_mux_enum_put
557 HDA_CODEC_VOLUME("Int Mic Volume", 0x1a, 0x01, HDA_INPUT),
558 HDA_CODEC_MUTE("Int Mic Switch", 0x1a, 0x01, HDA_INPUT),
559 HDA_CODEC_VOLUME("Ext Mic Volume", 0x1a, 0x02, HDA_INPUT),
560 HDA_CODEC_MUTE("Ext Mic Switch", 0x1a, 0x02, HDA_INPUT),
561 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
563 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
564 .name = "Master Playback Switch",
565 .info = cxt_eapd_info,
567 .put = cxt5045_hp_master_sw_put,
568 .private_value = 0x10,
574 static struct hda_verb cxt5045_init_verbs[] = {
576 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
577 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
579 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
580 {0x17, AC_VERB_SET_CONNECT_SEL,0x01},
581 {0x17, AC_VERB_SET_AMP_GAIN_MUTE,
582 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x01},
583 {0x17, AC_VERB_SET_AMP_GAIN_MUTE,
584 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x02},
585 {0x17, AC_VERB_SET_AMP_GAIN_MUTE,
586 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
587 {0x17, AC_VERB_SET_AMP_GAIN_MUTE,
588 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x04},
589 /* Record selector: Int mic */
590 {0x1a, AC_VERB_SET_CONNECT_SEL,0x1},
591 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
592 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
593 /* SPDIF route: PCM */
594 { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
596 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */
601 static struct hda_verb cxt5045_hp_sense_init_verbs[] = {
602 /* pin sensing on HP jack */
603 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
607 static struct hda_verb cxt5045_mic_sense_init_verbs[] = {
608 /* pin sensing on HP jack */
609 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
613 #ifdef CONFIG_SND_DEBUG
614 /* Test configuration for debugging, modelled after the ALC260 test
617 static struct hda_input_mux cxt5045_test_capture_source = {
622 { "LINE1 pin", 0x2 },
623 { "HP-OUT pin", 0x3 },
628 static struct snd_kcontrol_new cxt5045_test_mixer[] = {
630 /* Output controls */
631 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
632 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
633 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT),
634 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT),
635 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT),
636 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT),
638 /* Modes for retasking pin widgets */
639 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
640 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT),
642 /* EAPD Switch Control */
643 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
645 /* Loopback mixer controls */
647 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT),
648 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT),
649 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT),
650 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT),
651 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT),
652 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT),
653 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT),
654 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT),
655 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT),
656 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT),
658 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
659 .name = "Input Source",
660 .info = conexant_mux_enum_info,
661 .get = conexant_mux_enum_get,
662 .put = conexant_mux_enum_put,
664 /* Audio input controls */
665 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),
666 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),
667 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
668 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
669 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
670 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
671 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
672 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
673 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
674 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
678 static struct hda_verb cxt5045_test_init_verbs[] = {
679 /* Set connections */
680 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
681 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 },
682 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 },
683 /* Enable retasking pins as output, initially without power amp */
684 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
685 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
687 /* Disable digital (SPDIF) pins initially, but users can enable
688 * them via a mixer switch. In the case of SPDIF-out, this initverb
689 * payload also sets the generation to 0, output to be in "consumer"
690 * PCM format, copyright asserted, no pre-emphasis and no validity
693 {0x13, AC_VERB_SET_DIGI_CONVERT_1, 0},
695 /* Start with output sum widgets muted and their output gains at min */
696 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
697 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
699 /* Unmute retasking pin widget output buffers since the default
700 * state appears to be output. As the pin mode is changed by the
701 * user the pin mode control will take care of enabling the pin's
702 * input/output buffers as needed.
704 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
705 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
707 /* Mute capture amp left and right */
708 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
710 /* Set ADC connection select to match default mixer setting (mic1
713 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
714 {0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
716 /* Mute all inputs to mixer widget (even unconnected ones) */
717 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */
718 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */
719 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */
720 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */
721 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
728 /* initialize jack-sensing, too */
729 static int cxt5045_init(struct hda_codec *codec)
731 conexant_init(codec);
732 cxt5045_hp_automute(codec);
738 CXT5045_LAPTOP, /* Laptops w/ EAPD support */
739 CXT5045_FUJITSU, /* Laptops w/ EAPD support */
740 #ifdef CONFIG_SND_DEBUG
746 static const char *cxt5045_models[CXT5045_MODELS] = {
747 [CXT5045_LAPTOP] = "laptop",
748 [CXT5045_FUJITSU] = "fujitsu",
749 #ifdef CONFIG_SND_DEBUG
750 [CXT5045_TEST] = "test",
754 static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
755 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP),
756 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP),
757 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV Series", CXT5045_LAPTOP),
758 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2120", CXT5045_LAPTOP),
759 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP),
760 SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP),
761 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_FUJITSU),
762 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP),
763 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP),
767 static int patch_cxt5045(struct hda_codec *codec)
769 struct conexant_spec *spec;
772 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
775 mutex_init(&spec->amp_mutex);
778 spec->multiout.max_channels = 2;
779 spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids);
780 spec->multiout.dac_nids = cxt5045_dac_nids;
781 spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT;
782 spec->num_adc_nids = 1;
783 spec->adc_nids = cxt5045_adc_nids;
784 spec->capsrc_nids = cxt5045_capsrc_nids;
785 spec->input_mux = &cxt5045_capture_source;
786 spec->num_mixers = 1;
787 spec->mixers[0] = cxt5045_mixers;
788 spec->num_init_verbs = 1;
789 spec->init_verbs[0] = cxt5045_init_verbs;
790 spec->spdif_route = 0;
791 spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes),
792 spec->channel_mode = cxt5045_modes,
795 codec->patch_ops = conexant_patch_ops;
797 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
800 switch (board_config) {
802 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
803 spec->input_mux = &cxt5045_capture_source;
804 spec->num_init_verbs = 2;
805 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
806 spec->mixers[0] = cxt5045_mixers;
807 codec->patch_ops.init = cxt5045_init;
809 case CXT5045_FUJITSU:
810 spec->input_mux = &cxt5045_capture_source;
811 spec->num_init_verbs = 2;
812 spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;
813 spec->mixers[0] = cxt5045_mixers;
814 codec->patch_ops.init = cxt5045_init;
816 #ifdef CONFIG_SND_DEBUG
818 spec->input_mux = &cxt5045_test_capture_source;
819 spec->mixers[0] = cxt5045_test_mixer;
820 spec->init_verbs[0] = cxt5045_test_init_verbs;
827 /* Conexant 5047 specific */
828 #define CXT5047_SPDIF_OUT 0x11
830 static hda_nid_t cxt5047_dac_nids[2] = { 0x10, 0x1c };
831 static hda_nid_t cxt5047_adc_nids[1] = { 0x12 };
832 static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a };
834 static struct hda_channel_mode cxt5047_modes[1] = {
838 static struct hda_input_mux cxt5047_capture_source = {
845 static struct hda_input_mux cxt5047_hp_capture_source = {
852 static struct hda_input_mux cxt5047_toshiba_capture_source = {
860 /* turn on/off EAPD (+ mute HP) as a master switch */
861 static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
862 struct snd_ctl_elem_value *ucontrol)
864 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
865 struct conexant_spec *spec = codec->spec;
868 if (!cxt_eapd_put(kcontrol, ucontrol))
871 /* toggle internal speakers mute depending of presence of
874 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
875 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
877 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
878 snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0,
883 /* bind volumes of both NID 0x13 (Headphones) and 0x1d (Speakers) */
884 static struct hda_bind_ctls cxt5047_bind_master_vol = {
885 .ops = &snd_hda_bind_vol,
887 HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
888 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
893 /* mute internal speaker if HP is plugged */
894 static void cxt5047_hp_automute(struct hda_codec *codec)
896 struct conexant_spec *spec = codec->spec;
899 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
900 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
902 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
903 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
905 /* Mute/Unmute PCM 2 for good measure - some systems need this */
906 snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
910 /* mute internal speaker if HP is plugged */
911 static void cxt5047_hp2_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 ? 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 /* toggle input of built-in and mic jack appropriately */
928 static void cxt5047_hp_automic(struct hda_codec *codec)
930 static struct hda_verb mic_jack_on[] = {
931 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
932 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
935 static struct hda_verb mic_jack_off[] = {
936 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
937 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
940 unsigned int present;
942 present = snd_hda_codec_read(codec, 0x15, 0,
943 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
945 snd_hda_sequence_write(codec, mic_jack_on);
947 snd_hda_sequence_write(codec, mic_jack_off);
950 /* unsolicited event for HP jack sensing */
951 static void cxt5047_hp_unsol_event(struct hda_codec *codec,
956 case CONEXANT_HP_EVENT:
957 cxt5047_hp_automute(codec);
959 case CONEXANT_MIC_EVENT:
960 cxt5047_hp_automic(codec);
965 /* unsolicited event for HP jack sensing - non-EAPD systems */
966 static void cxt5047_hp2_unsol_event(struct hda_codec *codec,
971 case CONEXANT_HP_EVENT:
972 cxt5047_hp2_automute(codec);
974 case CONEXANT_MIC_EVENT:
975 cxt5047_hp_automic(codec);
980 static struct snd_kcontrol_new cxt5047_mixers[] = {
981 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
982 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
983 HDA_CODEC_VOLUME("Mic Gain Volume", 0x1a, 0x0, HDA_OUTPUT),
984 HDA_CODEC_MUTE("Mic Gain Switch", 0x1a, 0x0, HDA_OUTPUT),
985 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
986 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
987 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
988 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
989 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT),
990 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT),
991 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x00, HDA_OUTPUT),
992 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x00, HDA_OUTPUT),
993 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
994 HDA_CODEC_MUTE("Headphone Playback Switch", 0x13, 0x00, HDA_OUTPUT),
999 static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = {
1001 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1002 .name = "Capture Source",
1003 .info = conexant_mux_enum_info,
1004 .get = conexant_mux_enum_get,
1005 .put = conexant_mux_enum_put
1007 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1008 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1009 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1010 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1011 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1012 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1013 HDA_BIND_VOL("Master Playback Volume", &cxt5047_bind_master_vol),
1015 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1016 .name = "Master Playback Switch",
1017 .info = cxt_eapd_info,
1018 .get = cxt_eapd_get,
1019 .put = cxt5047_hp_master_sw_put,
1020 .private_value = 0x13,
1026 static struct snd_kcontrol_new cxt5047_hp_mixers[] = {
1028 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1029 .name = "Capture Source",
1030 .info = conexant_mux_enum_info,
1031 .get = conexant_mux_enum_get,
1032 .put = conexant_mux_enum_put
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("Capture Volume", 0x12, 0x03, HDA_INPUT),
1037 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1038 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1039 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1040 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1042 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1043 .name = "Master Playback Switch",
1044 .info = cxt_eapd_info,
1045 .get = cxt_eapd_get,
1046 .put = cxt5047_hp_master_sw_put,
1047 .private_value = 0x13,
1052 static struct hda_verb cxt5047_init_verbs[] = {
1053 /* Line in, Mic, Built-in Mic */
1054 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1055 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1056 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1058 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1059 {0x13, AC_VERB_SET_CONNECT_SEL,0x1},
1060 {0x1d, AC_VERB_SET_CONNECT_SEL,0x0},
1061 /* Record selector: Mic */
1062 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1063 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1064 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1065 {0x1A, AC_VERB_SET_CONNECT_SEL,0x02},
1066 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1067 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1068 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1069 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
1070 /* SPDIF route: PCM */
1071 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
1072 /* Enable unsolicited events */
1073 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1074 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1078 /* configuration for Toshiba Laptops */
1079 static struct hda_verb cxt5047_toshiba_init_verbs[] = {
1080 {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0 }, /* default on */
1081 /* pin sensing on HP and Mic jacks */
1082 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1083 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1084 /* Speaker routing */
1085 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1089 /* configuration for HP Laptops */
1090 static struct hda_verb cxt5047_hp_init_verbs[] = {
1091 /* pin sensing on HP jack */
1092 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1093 /* Record selector: Ext Mic */
1094 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1095 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1096 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1097 /* Speaker routing */
1098 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1102 /* Test configuration for debugging, modelled after the ALC260 test
1105 #ifdef CONFIG_SND_DEBUG
1106 static struct hda_input_mux cxt5047_test_capture_source = {
1109 { "LINE1 pin", 0x0 },
1110 { "MIC1 pin", 0x1 },
1111 { "MIC2 pin", 0x2 },
1116 static struct snd_kcontrol_new cxt5047_test_mixer[] = {
1118 /* Output only controls */
1119 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT),
1120 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT),
1121 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT),
1122 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT),
1123 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1124 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1125 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1126 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1127 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT),
1128 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1129 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT),
1130 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT),
1132 /* Modes for retasking pin widgets */
1133 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT),
1134 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT),
1136 /* EAPD Switch Control */
1137 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1139 /* Loopback mixer controls */
1140 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT),
1141 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT),
1142 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT),
1143 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT),
1144 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT),
1145 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT),
1146 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT),
1147 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT),
1149 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT),
1150 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT),
1151 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT),
1152 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT),
1153 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT),
1154 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT),
1155 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT),
1156 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT),
1158 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1159 .name = "Input Source",
1160 .info = conexant_mux_enum_info,
1161 .get = conexant_mux_enum_get,
1162 .put = conexant_mux_enum_put,
1167 static struct hda_verb cxt5047_test_init_verbs[] = {
1168 /* Enable retasking pins as output, initially without power amp */
1169 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1170 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1171 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1173 /* Disable digital (SPDIF) pins initially, but users can enable
1174 * them via a mixer switch. In the case of SPDIF-out, this initverb
1175 * payload also sets the generation to 0, output to be in "consumer"
1176 * PCM format, copyright asserted, no pre-emphasis and no validity
1179 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
1181 /* Ensure mic1, mic2, line1 pin widgets take input from the
1182 * OUT1 sum bus when acting as an output.
1184 {0x1a, AC_VERB_SET_CONNECT_SEL, 0},
1185 {0x1b, AC_VERB_SET_CONNECT_SEL, 0},
1187 /* Start with output sum widgets muted and their output gains at min */
1188 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1189 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1191 /* Unmute retasking pin widget output buffers since the default
1192 * state appears to be output. As the pin mode is changed by the
1193 * user the pin mode control will take care of enabling the pin's
1194 * input/output buffers as needed.
1196 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1197 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1198 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1200 /* Mute capture amp left and right */
1201 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1203 /* Set ADC connection select to match default mixer setting (mic1
1206 {0x12, AC_VERB_SET_CONNECT_SEL, 0x00},
1208 /* Mute all inputs to mixer widget (even unconnected ones) */
1209 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
1210 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
1211 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
1212 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
1213 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
1214 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1215 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
1216 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
1223 /* initialize jack-sensing, too */
1224 static int cxt5047_hp_init(struct hda_codec *codec)
1226 conexant_init(codec);
1227 cxt5047_hp_automute(codec);
1233 CXT5047_LAPTOP, /* Laptops w/o EAPD support */
1234 CXT5047_LAPTOP_HP, /* Some HP laptops */
1235 CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */
1236 #ifdef CONFIG_SND_DEBUG
1242 static const char *cxt5047_models[CXT5047_MODELS] = {
1243 [CXT5047_LAPTOP] = "laptop",
1244 [CXT5047_LAPTOP_HP] = "laptop-hp",
1245 [CXT5047_LAPTOP_EAPD] = "laptop-eapd",
1246 #ifdef CONFIG_SND_DEBUG
1247 [CXT5047_TEST] = "test",
1251 static struct snd_pci_quirk cxt5047_cfg_tbl[] = {
1252 SND_PCI_QUIRK(0x103c, 0x30a0, "HP DV1000", CXT5047_LAPTOP),
1253 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV2000T/DV3000T", CXT5047_LAPTOP),
1254 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2000Z", CXT5047_LAPTOP),
1255 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
1256 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD),
1260 static int patch_cxt5047(struct hda_codec *codec)
1262 struct conexant_spec *spec;
1265 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1268 mutex_init(&spec->amp_mutex);
1271 spec->multiout.max_channels = 2;
1272 spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids);
1273 spec->multiout.dac_nids = cxt5047_dac_nids;
1274 spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT;
1275 spec->num_adc_nids = 1;
1276 spec->adc_nids = cxt5047_adc_nids;
1277 spec->capsrc_nids = cxt5047_capsrc_nids;
1278 spec->input_mux = &cxt5047_capture_source;
1279 spec->num_mixers = 1;
1280 spec->mixers[0] = cxt5047_mixers;
1281 spec->num_init_verbs = 1;
1282 spec->init_verbs[0] = cxt5047_init_verbs;
1283 spec->spdif_route = 0;
1284 spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes),
1285 spec->channel_mode = cxt5047_modes,
1287 codec->patch_ops = conexant_patch_ops;
1289 board_config = snd_hda_check_board_config(codec, CXT5047_MODELS,
1292 switch (board_config) {
1293 case CXT5047_LAPTOP:
1294 codec->patch_ops.unsol_event = cxt5047_hp2_unsol_event;
1296 case CXT5047_LAPTOP_HP:
1297 spec->input_mux = &cxt5047_hp_capture_source;
1298 spec->num_init_verbs = 2;
1299 spec->init_verbs[1] = cxt5047_hp_init_verbs;
1300 spec->mixers[0] = cxt5047_hp_mixers;
1301 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1302 codec->patch_ops.init = cxt5047_hp_init;
1304 case CXT5047_LAPTOP_EAPD:
1305 spec->input_mux = &cxt5047_toshiba_capture_source;
1306 spec->num_init_verbs = 2;
1307 spec->init_verbs[1] = cxt5047_toshiba_init_verbs;
1308 spec->mixers[0] = cxt5047_toshiba_mixers;
1309 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1311 #ifdef CONFIG_SND_DEBUG
1313 spec->input_mux = &cxt5047_test_capture_source;
1314 spec->mixers[0] = cxt5047_test_mixer;
1315 spec->init_verbs[0] = cxt5047_test_init_verbs;
1316 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1322 struct hda_codec_preset snd_hda_preset_conexant[] = {
1323 { .id = 0x14f15045, .name = "CX20549 (Venice)",
1324 .patch = patch_cxt5045 },
1325 { .id = 0x14f15047, .name = "CX20551 (Waikiki)",
1326 .patch = patch_cxt5047 },