2 * HD audio interface patch for Conexant HDA audio codec
4 * Copyright (c) 2006 Pototskiy Akex <alex.pototskiy@gmail.com>
5 * Takashi Iwai <tiwai@suse.de>
6 * Tobin Davis <tdavis@dsl-only.net>
8 * This driver is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This driver is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <linux/init.h>
24 #include <linux/delay.h>
25 #include <linux/slab.h>
26 #include <linux/pci.h>
27 #include <sound/core.h>
28 #include <sound/jack.h>
30 #include "hda_codec.h"
31 #include "hda_local.h"
34 #define CXT_PIN_DIR_IN 0x00
35 #define CXT_PIN_DIR_OUT 0x01
36 #define CXT_PIN_DIR_INOUT 0x02
37 #define CXT_PIN_DIR_IN_NOMICBIAS 0x03
38 #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04
40 #define CONEXANT_HP_EVENT 0x37
41 #define CONEXANT_MIC_EVENT 0x38
43 /* Conexant 5051 specific */
45 #define CXT5051_SPDIF_OUT 0x1C
46 #define CXT5051_PORTB_EVENT 0x38
47 #define CXT5051_PORTC_EVENT 0x39
50 struct conexant_jack
{
54 struct snd_jack
*jack
;
58 struct conexant_spec
{
60 struct snd_kcontrol_new
*mixers
[5];
62 hda_nid_t vmaster_nid
;
64 const struct hda_verb
*init_verbs
[5]; /* initialization verbs
68 unsigned int num_init_verbs
;
71 struct hda_multi_out multiout
; /* playback set-up
72 * max_channels, dacs must be set
73 * dig_out_nid and hp_nid are optional
75 unsigned int cur_eapd
;
76 unsigned int hp_present
;
77 unsigned int no_auto_mic
;
78 unsigned int need_dac_fix
;
81 unsigned int num_adc_nids
;
83 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
85 unsigned int cur_adc_idx
;
87 unsigned int cur_adc_stream_tag
;
88 unsigned int cur_adc_format
;
91 const struct hda_input_mux
*input_mux
;
92 hda_nid_t
*capsrc_nids
;
93 unsigned int cur_mux
[3];
96 const struct hda_channel_mode
*channel_mode
;
100 struct hda_pcm pcm_rec
[2]; /* used in build_pcms() */
102 unsigned int spdif_route
;
105 struct snd_array jacks
;
107 /* dynamic controls, init_verbs and input_mux */
108 struct auto_pin_cfg autocfg
;
109 struct hda_input_mux private_imux
;
110 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
112 unsigned int dell_automute
;
113 unsigned int port_d_mode
;
114 unsigned char ext_mic_bias
;
115 unsigned int dell_vostro
;
118 static int conexant_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
119 struct hda_codec
*codec
,
120 struct snd_pcm_substream
*substream
)
122 struct conexant_spec
*spec
= codec
->spec
;
123 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
127 static int conexant_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
128 struct hda_codec
*codec
,
129 unsigned int stream_tag
,
131 struct snd_pcm_substream
*substream
)
133 struct conexant_spec
*spec
= codec
->spec
;
134 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
139 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
140 struct hda_codec
*codec
,
141 struct snd_pcm_substream
*substream
)
143 struct conexant_spec
*spec
= codec
->spec
;
144 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
150 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
151 struct hda_codec
*codec
,
152 struct snd_pcm_substream
*substream
)
154 struct conexant_spec
*spec
= codec
->spec
;
155 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
158 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
159 struct hda_codec
*codec
,
160 struct snd_pcm_substream
*substream
)
162 struct conexant_spec
*spec
= codec
->spec
;
163 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
166 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
167 struct hda_codec
*codec
,
168 unsigned int stream_tag
,
170 struct snd_pcm_substream
*substream
)
172 struct conexant_spec
*spec
= codec
->spec
;
173 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
181 static int conexant_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
182 struct hda_codec
*codec
,
183 unsigned int stream_tag
,
185 struct snd_pcm_substream
*substream
)
187 struct conexant_spec
*spec
= codec
->spec
;
188 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
189 stream_tag
, 0, format
);
193 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
194 struct hda_codec
*codec
,
195 struct snd_pcm_substream
*substream
)
197 struct conexant_spec
*spec
= codec
->spec
;
198 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
204 static struct hda_pcm_stream conexant_pcm_analog_playback
= {
208 .nid
= 0, /* fill later */
210 .open
= conexant_playback_pcm_open
,
211 .prepare
= conexant_playback_pcm_prepare
,
212 .cleanup
= conexant_playback_pcm_cleanup
216 static struct hda_pcm_stream conexant_pcm_analog_capture
= {
220 .nid
= 0, /* fill later */
222 .prepare
= conexant_capture_pcm_prepare
,
223 .cleanup
= conexant_capture_pcm_cleanup
228 static struct hda_pcm_stream conexant_pcm_digital_playback
= {
232 .nid
= 0, /* fill later */
234 .open
= conexant_dig_playback_pcm_open
,
235 .close
= conexant_dig_playback_pcm_close
,
236 .prepare
= conexant_dig_playback_pcm_prepare
240 static struct hda_pcm_stream conexant_pcm_digital_capture
= {
244 /* NID is set in alc_build_pcms */
247 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
248 struct hda_codec
*codec
,
249 unsigned int stream_tag
,
251 struct snd_pcm_substream
*substream
)
253 struct conexant_spec
*spec
= codec
->spec
;
254 spec
->cur_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
255 spec
->cur_adc_stream_tag
= stream_tag
;
256 spec
->cur_adc_format
= format
;
257 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
261 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
262 struct hda_codec
*codec
,
263 struct snd_pcm_substream
*substream
)
265 struct conexant_spec
*spec
= codec
->spec
;
266 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
271 static struct hda_pcm_stream cx5051_pcm_analog_capture
= {
275 .nid
= 0, /* fill later */
277 .prepare
= cx5051_capture_pcm_prepare
,
278 .cleanup
= cx5051_capture_pcm_cleanup
282 static int conexant_build_pcms(struct hda_codec
*codec
)
284 struct conexant_spec
*spec
= codec
->spec
;
285 struct hda_pcm
*info
= spec
->pcm_rec
;
288 codec
->pcm_info
= info
;
290 info
->name
= "CONEXANT Analog";
291 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = conexant_pcm_analog_playback
;
292 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
=
293 spec
->multiout
.max_channels
;
294 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
295 spec
->multiout
.dac_nids
[0];
296 if (codec
->vendor_id
== 0x14f15051)
297 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
298 cx5051_pcm_analog_capture
;
300 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
301 conexant_pcm_analog_capture
;
302 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
= spec
->num_adc_nids
;
303 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
305 if (spec
->multiout
.dig_out_nid
) {
308 info
->name
= "Conexant Digital";
309 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
310 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
311 conexant_pcm_digital_playback
;
312 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
313 spec
->multiout
.dig_out_nid
;
314 if (spec
->dig_in_nid
) {
315 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
316 conexant_pcm_digital_capture
;
317 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
325 static int conexant_mux_enum_info(struct snd_kcontrol
*kcontrol
,
326 struct snd_ctl_elem_info
*uinfo
)
328 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
329 struct conexant_spec
*spec
= codec
->spec
;
331 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
334 static int conexant_mux_enum_get(struct snd_kcontrol
*kcontrol
,
335 struct snd_ctl_elem_value
*ucontrol
)
337 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
338 struct conexant_spec
*spec
= codec
->spec
;
339 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
341 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
345 static int conexant_mux_enum_put(struct snd_kcontrol
*kcontrol
,
346 struct snd_ctl_elem_value
*ucontrol
)
348 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
349 struct conexant_spec
*spec
= codec
->spec
;
350 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
352 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
353 spec
->capsrc_nids
[adc_idx
],
354 &spec
->cur_mux
[adc_idx
]);
357 #ifdef CONFIG_SND_HDA_INPUT_JACK
358 static void conexant_free_jack_priv(struct snd_jack
*jack
)
360 struct conexant_jack
*jacks
= jack
->private_data
;
365 static int conexant_add_jack(struct hda_codec
*codec
,
366 hda_nid_t nid
, int type
)
368 struct conexant_spec
*spec
;
369 struct conexant_jack
*jack
;
374 snd_array_init(&spec
->jacks
, sizeof(*jack
), 32);
375 jack
= snd_array_new(&spec
->jacks
);
376 name
= (type
== SND_JACK_HEADPHONE
) ? "Headphone" : "Mic" ;
384 err
= snd_jack_new(codec
->bus
->card
, name
, type
, &jack
->jack
);
387 jack
->jack
->private_data
= jack
;
388 jack
->jack
->private_free
= conexant_free_jack_priv
;
392 static void conexant_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
394 struct conexant_spec
*spec
= codec
->spec
;
395 struct conexant_jack
*jacks
= spec
->jacks
.list
;
399 for (i
= 0; i
< spec
->jacks
.used
; i
++) {
400 if (jacks
->nid
== nid
) {
401 unsigned int present
;
402 present
= snd_hda_jack_detect(codec
, nid
);
404 present
= (present
) ? jacks
->type
: 0 ;
406 snd_jack_report(jacks
->jack
,
414 static int conexant_init_jacks(struct hda_codec
*codec
)
416 struct conexant_spec
*spec
= codec
->spec
;
419 for (i
= 0; i
< spec
->num_init_verbs
; i
++) {
420 const struct hda_verb
*hv
;
422 hv
= spec
->init_verbs
[i
];
425 switch (hv
->param
^ AC_USRSP_EN
) {
426 case CONEXANT_HP_EVENT
:
427 err
= conexant_add_jack(codec
, hv
->nid
,
429 conexant_report_jack(codec
, hv
->nid
);
431 case CXT5051_PORTC_EVENT
:
432 case CONEXANT_MIC_EVENT
:
433 err
= conexant_add_jack(codec
, hv
->nid
,
434 SND_JACK_MICROPHONE
);
435 conexant_report_jack(codec
, hv
->nid
);
447 static inline void conexant_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
451 static inline int conexant_init_jacks(struct hda_codec
*codec
)
457 static int conexant_init(struct hda_codec
*codec
)
459 struct conexant_spec
*spec
= codec
->spec
;
462 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
463 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
467 static void conexant_free(struct hda_codec
*codec
)
469 #ifdef CONFIG_SND_HDA_INPUT_JACK
470 struct conexant_spec
*spec
= codec
->spec
;
471 if (spec
->jacks
.list
) {
472 struct conexant_jack
*jacks
= spec
->jacks
.list
;
474 for (i
= 0; i
< spec
->jacks
.used
; i
++, jacks
++) {
476 snd_device_free(codec
->bus
->card
, jacks
->jack
);
478 snd_array_free(&spec
->jacks
);
481 snd_hda_detach_beep_device(codec
);
485 static struct snd_kcontrol_new cxt_capture_mixers
[] = {
487 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
488 .name
= "Capture Source",
489 .info
= conexant_mux_enum_info
,
490 .get
= conexant_mux_enum_get
,
491 .put
= conexant_mux_enum_put
496 static const char *slave_vols
[] = {
497 "Headphone Playback Volume",
498 "Speaker Playback Volume",
502 static const char *slave_sws
[] = {
503 "Headphone Playback Switch",
504 "Speaker Playback Switch",
508 static int conexant_build_controls(struct hda_codec
*codec
)
510 struct conexant_spec
*spec
= codec
->spec
;
514 for (i
= 0; i
< spec
->num_mixers
; i
++) {
515 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
519 if (spec
->multiout
.dig_out_nid
) {
520 err
= snd_hda_create_spdif_out_ctls(codec
,
521 spec
->multiout
.dig_out_nid
);
524 err
= snd_hda_create_spdif_share_sw(codec
,
528 spec
->multiout
.share_spdif
= 1;
530 if (spec
->dig_in_nid
) {
531 err
= snd_hda_create_spdif_in_ctls(codec
,spec
->dig_in_nid
);
536 /* if we have no master control, let's create it */
537 if (spec
->vmaster_nid
&&
538 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
539 unsigned int vmaster_tlv
[4];
540 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
541 HDA_OUTPUT
, vmaster_tlv
);
542 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
543 vmaster_tlv
, slave_vols
);
547 if (spec
->vmaster_nid
&&
548 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
549 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
555 if (spec
->input_mux
) {
556 err
= snd_hda_add_new_ctls(codec
, cxt_capture_mixers
);
564 static struct hda_codec_ops conexant_patch_ops
= {
565 .build_controls
= conexant_build_controls
,
566 .build_pcms
= conexant_build_pcms
,
567 .init
= conexant_init
,
568 .free
= conexant_free
,
573 * the private value = nid | (invert << 8)
576 #define cxt_eapd_info snd_ctl_boolean_mono_info
578 static int cxt_eapd_get(struct snd_kcontrol
*kcontrol
,
579 struct snd_ctl_elem_value
*ucontrol
)
581 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
582 struct conexant_spec
*spec
= codec
->spec
;
583 int invert
= (kcontrol
->private_value
>> 8) & 1;
585 ucontrol
->value
.integer
.value
[0] = !spec
->cur_eapd
;
587 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
592 static int cxt_eapd_put(struct snd_kcontrol
*kcontrol
,
593 struct snd_ctl_elem_value
*ucontrol
)
595 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
596 struct conexant_spec
*spec
= codec
->spec
;
597 int invert
= (kcontrol
->private_value
>> 8) & 1;
598 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
601 eapd
= !!ucontrol
->value
.integer
.value
[0];
604 if (eapd
== spec
->cur_eapd
)
607 spec
->cur_eapd
= eapd
;
608 snd_hda_codec_write_cache(codec
, nid
,
609 0, AC_VERB_SET_EAPD_BTLENABLE
,
614 /* controls for test mode */
615 #ifdef CONFIG_SND_DEBUG
617 #define CXT_EAPD_SWITCH(xname, nid, mask) \
618 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
619 .info = cxt_eapd_info, \
620 .get = cxt_eapd_get, \
621 .put = cxt_eapd_put, \
622 .private_value = nid | (mask<<16) }
626 static int conexant_ch_mode_info(struct snd_kcontrol
*kcontrol
,
627 struct snd_ctl_elem_info
*uinfo
)
629 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
630 struct conexant_spec
*spec
= codec
->spec
;
631 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
632 spec
->num_channel_mode
);
635 static int conexant_ch_mode_get(struct snd_kcontrol
*kcontrol
,
636 struct snd_ctl_elem_value
*ucontrol
)
638 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
639 struct conexant_spec
*spec
= codec
->spec
;
640 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
641 spec
->num_channel_mode
,
642 spec
->multiout
.max_channels
);
645 static int conexant_ch_mode_put(struct snd_kcontrol
*kcontrol
,
646 struct snd_ctl_elem_value
*ucontrol
)
648 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
649 struct conexant_spec
*spec
= codec
->spec
;
650 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
651 spec
->num_channel_mode
,
652 &spec
->multiout
.max_channels
);
653 if (err
>= 0 && spec
->need_dac_fix
)
654 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
658 #define CXT_PIN_MODE(xname, nid, dir) \
659 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
660 .info = conexant_ch_mode_info, \
661 .get = conexant_ch_mode_get, \
662 .put = conexant_ch_mode_put, \
663 .private_value = nid | (dir<<16) }
665 #endif /* CONFIG_SND_DEBUG */
667 /* Conexant 5045 specific */
669 static hda_nid_t cxt5045_dac_nids
[1] = { 0x19 };
670 static hda_nid_t cxt5045_adc_nids
[1] = { 0x1a };
671 static hda_nid_t cxt5045_capsrc_nids
[1] = { 0x1a };
672 #define CXT5045_SPDIF_OUT 0x18
674 static struct hda_channel_mode cxt5045_modes
[1] = {
678 static struct hda_input_mux cxt5045_capture_source
= {
686 static struct hda_input_mux cxt5045_capture_source_benq
= {
697 static struct hda_input_mux cxt5045_capture_source_hp530
= {
705 /* turn on/off EAPD (+ mute HP) as a master switch */
706 static int cxt5045_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
707 struct snd_ctl_elem_value
*ucontrol
)
709 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
710 struct conexant_spec
*spec
= codec
->spec
;
713 if (!cxt_eapd_put(kcontrol
, ucontrol
))
716 /* toggle internal speakers mute depending of presence of
719 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
720 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
723 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
724 snd_hda_codec_amp_stereo(codec
, 0x11, HDA_OUTPUT
, 0,
729 /* bind volumes of both NID 0x10 and 0x11 */
730 static struct hda_bind_ctls cxt5045_hp_bind_master_vol
= {
731 .ops
= &snd_hda_bind_vol
,
733 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT
),
734 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT
),
739 /* toggle input of built-in and mic jack appropriately */
740 static void cxt5045_hp_automic(struct hda_codec
*codec
)
742 static struct hda_verb mic_jack_on
[] = {
743 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
744 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
747 static struct hda_verb mic_jack_off
[] = {
748 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
749 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
752 unsigned int present
;
754 present
= snd_hda_jack_detect(codec
, 0x12);
756 snd_hda_sequence_write(codec
, mic_jack_on
);
758 snd_hda_sequence_write(codec
, mic_jack_off
);
762 /* mute internal speaker if HP is plugged */
763 static void cxt5045_hp_automute(struct hda_codec
*codec
)
765 struct conexant_spec
*spec
= codec
->spec
;
768 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x11);
770 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
771 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
775 /* unsolicited event for HP jack sensing */
776 static void cxt5045_hp_unsol_event(struct hda_codec
*codec
,
781 case CONEXANT_HP_EVENT
:
782 cxt5045_hp_automute(codec
);
784 case CONEXANT_MIC_EVENT
:
785 cxt5045_hp_automic(codec
);
791 static struct snd_kcontrol_new cxt5045_mixers
[] = {
792 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
793 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
794 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
795 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
796 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
797 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
798 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
799 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
800 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
801 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
802 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
804 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
805 .name
= "Master Playback Switch",
806 .info
= cxt_eapd_info
,
808 .put
= cxt5045_hp_master_sw_put
,
809 .private_value
= 0x10,
815 static struct snd_kcontrol_new cxt5045_benq_mixers
[] = {
816 HDA_CODEC_VOLUME("CD Capture Volume", 0x1a, 0x04, HDA_INPUT
),
817 HDA_CODEC_MUTE("CD Capture Switch", 0x1a, 0x04, HDA_INPUT
),
818 HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x4, HDA_INPUT
),
819 HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x4, HDA_INPUT
),
821 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT
),
822 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT
),
823 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT
),
824 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT
),
826 HDA_CODEC_VOLUME("Mixer Capture Volume", 0x1a, 0x0, HDA_INPUT
),
827 HDA_CODEC_MUTE("Mixer Capture Switch", 0x1a, 0x0, HDA_INPUT
),
832 static struct snd_kcontrol_new cxt5045_mixers_hp530
[] = {
833 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
834 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
835 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
836 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
837 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
838 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
839 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
840 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
841 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
842 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
843 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
845 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
846 .name
= "Master Playback Switch",
847 .info
= cxt_eapd_info
,
849 .put
= cxt5045_hp_master_sw_put
,
850 .private_value
= 0x10,
856 static struct hda_verb cxt5045_init_verbs
[] = {
858 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
859 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
861 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
862 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
863 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
864 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
865 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
866 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
867 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
868 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
869 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
870 /* Record selector: Int mic */
871 {0x1a, AC_VERB_SET_CONNECT_SEL
,0x1},
872 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
873 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
874 /* SPDIF route: PCM */
875 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
876 { 0x13, AC_VERB_SET_CONNECT_SEL
, 0x0 },
878 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2 }, /* default on */
882 static struct hda_verb cxt5045_benq_init_verbs
[] = {
884 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
885 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
886 /* Line In,HP, Amp */
887 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
888 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
889 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
890 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
891 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
892 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
893 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
894 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
895 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
896 /* Record selector: Int mic */
897 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x1},
898 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
899 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
900 /* SPDIF route: PCM */
901 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
902 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0},
904 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
908 static struct hda_verb cxt5045_hp_sense_init_verbs
[] = {
909 /* pin sensing on HP jack */
910 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
914 static struct hda_verb cxt5045_mic_sense_init_verbs
[] = {
915 /* pin sensing on HP jack */
916 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
920 #ifdef CONFIG_SND_DEBUG
921 /* Test configuration for debugging, modelled after the ALC260 test
924 static struct hda_input_mux cxt5045_test_capture_source
= {
929 { "LINE1 pin", 0x2 },
930 { "HP-OUT pin", 0x3 },
935 static struct snd_kcontrol_new cxt5045_test_mixer
[] = {
937 /* Output controls */
938 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
939 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
940 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
941 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
942 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
943 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
945 /* Modes for retasking pin widgets */
946 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT
),
947 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT
),
949 /* EAPD Switch Control */
950 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
952 /* Loopback mixer controls */
954 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT
),
955 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT
),
956 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT
),
957 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT
),
958 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT
),
959 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT
),
960 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT
),
961 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT
),
962 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT
),
963 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT
),
965 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
966 .name
= "Input Source",
967 .info
= conexant_mux_enum_info
,
968 .get
= conexant_mux_enum_get
,
969 .put
= conexant_mux_enum_put
,
971 /* Audio input controls */
972 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT
),
973 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT
),
974 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT
),
975 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT
),
976 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT
),
977 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT
),
978 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT
),
979 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT
),
980 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT
),
981 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT
),
985 static struct hda_verb cxt5045_test_init_verbs
[] = {
986 /* Set connections */
987 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
988 { 0x11, AC_VERB_SET_CONNECT_SEL
, 0x0 },
989 { 0x12, AC_VERB_SET_CONNECT_SEL
, 0x0 },
990 /* Enable retasking pins as output, initially without power amp */
991 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
992 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
994 /* Disable digital (SPDIF) pins initially, but users can enable
995 * them via a mixer switch. In the case of SPDIF-out, this initverb
996 * payload also sets the generation to 0, output to be in "consumer"
997 * PCM format, copyright asserted, no pre-emphasis and no validity
1000 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1001 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1003 /* Start with output sum widgets muted and their output gains at min */
1004 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1005 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1007 /* Unmute retasking pin widget output buffers since the default
1008 * state appears to be output. As the pin mode is changed by the
1009 * user the pin mode control will take care of enabling the pin's
1010 * input/output buffers as needed.
1012 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1013 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1015 /* Mute capture amp left and right */
1016 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1018 /* Set ADC connection select to match default mixer setting (mic1
1021 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1022 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x00},
1024 /* Mute all inputs to mixer widget (even unconnected ones) */
1025 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* Mixer pin */
1026 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* Mic1 pin */
1027 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* Line pin */
1028 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* HP pin */
1029 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1036 /* initialize jack-sensing, too */
1037 static int cxt5045_init(struct hda_codec
*codec
)
1039 conexant_init(codec
);
1040 cxt5045_hp_automute(codec
);
1046 CXT5045_LAPTOP_HPSENSE
,
1047 CXT5045_LAPTOP_MICSENSE
,
1048 CXT5045_LAPTOP_HPMICSENSE
,
1050 CXT5045_LAPTOP_HP530
,
1051 #ifdef CONFIG_SND_DEBUG
1057 static const char *cxt5045_models
[CXT5045_MODELS
] = {
1058 [CXT5045_LAPTOP_HPSENSE
] = "laptop-hpsense",
1059 [CXT5045_LAPTOP_MICSENSE
] = "laptop-micsense",
1060 [CXT5045_LAPTOP_HPMICSENSE
] = "laptop-hpmicsense",
1061 [CXT5045_BENQ
] = "benq",
1062 [CXT5045_LAPTOP_HP530
] = "laptop-hp530",
1063 #ifdef CONFIG_SND_DEBUG
1064 [CXT5045_TEST
] = "test",
1068 static struct snd_pci_quirk cxt5045_cfg_tbl
[] = {
1069 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530
),
1070 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1071 CXT5045_LAPTOP_HPSENSE
),
1072 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE
),
1073 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ
),
1074 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE
),
1075 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE
),
1076 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
1077 CXT5045_LAPTOP_HPMICSENSE
),
1078 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1079 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1080 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1081 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
1082 CXT5045_LAPTOP_HPMICSENSE
),
1083 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE
),
1087 static int patch_cxt5045(struct hda_codec
*codec
)
1089 struct conexant_spec
*spec
;
1092 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1096 codec
->pin_amp_workaround
= 1;
1098 spec
->multiout
.max_channels
= 2;
1099 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5045_dac_nids
);
1100 spec
->multiout
.dac_nids
= cxt5045_dac_nids
;
1101 spec
->multiout
.dig_out_nid
= CXT5045_SPDIF_OUT
;
1102 spec
->num_adc_nids
= 1;
1103 spec
->adc_nids
= cxt5045_adc_nids
;
1104 spec
->capsrc_nids
= cxt5045_capsrc_nids
;
1105 spec
->input_mux
= &cxt5045_capture_source
;
1106 spec
->num_mixers
= 1;
1107 spec
->mixers
[0] = cxt5045_mixers
;
1108 spec
->num_init_verbs
= 1;
1109 spec
->init_verbs
[0] = cxt5045_init_verbs
;
1110 spec
->spdif_route
= 0;
1111 spec
->num_channel_mode
= ARRAY_SIZE(cxt5045_modes
),
1112 spec
->channel_mode
= cxt5045_modes
,
1115 codec
->patch_ops
= conexant_patch_ops
;
1117 board_config
= snd_hda_check_board_config(codec
, CXT5045_MODELS
,
1120 switch (board_config
) {
1121 case CXT5045_LAPTOP_HPSENSE
:
1122 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1123 spec
->input_mux
= &cxt5045_capture_source
;
1124 spec
->num_init_verbs
= 2;
1125 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1126 spec
->mixers
[0] = cxt5045_mixers
;
1127 codec
->patch_ops
.init
= cxt5045_init
;
1129 case CXT5045_LAPTOP_MICSENSE
:
1130 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1131 spec
->input_mux
= &cxt5045_capture_source
;
1132 spec
->num_init_verbs
= 2;
1133 spec
->init_verbs
[1] = cxt5045_mic_sense_init_verbs
;
1134 spec
->mixers
[0] = cxt5045_mixers
;
1135 codec
->patch_ops
.init
= cxt5045_init
;
1138 case CXT5045_LAPTOP_HPMICSENSE
:
1139 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1140 spec
->input_mux
= &cxt5045_capture_source
;
1141 spec
->num_init_verbs
= 3;
1142 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1143 spec
->init_verbs
[2] = cxt5045_mic_sense_init_verbs
;
1144 spec
->mixers
[0] = cxt5045_mixers
;
1145 codec
->patch_ops
.init
= cxt5045_init
;
1148 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1149 spec
->input_mux
= &cxt5045_capture_source_benq
;
1150 spec
->num_init_verbs
= 1;
1151 spec
->init_verbs
[0] = cxt5045_benq_init_verbs
;
1152 spec
->mixers
[0] = cxt5045_mixers
;
1153 spec
->mixers
[1] = cxt5045_benq_mixers
;
1154 spec
->num_mixers
= 2;
1155 codec
->patch_ops
.init
= cxt5045_init
;
1157 case CXT5045_LAPTOP_HP530
:
1158 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1159 spec
->input_mux
= &cxt5045_capture_source_hp530
;
1160 spec
->num_init_verbs
= 2;
1161 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1162 spec
->mixers
[0] = cxt5045_mixers_hp530
;
1163 codec
->patch_ops
.init
= cxt5045_init
;
1165 #ifdef CONFIG_SND_DEBUG
1167 spec
->input_mux
= &cxt5045_test_capture_source
;
1168 spec
->mixers
[0] = cxt5045_test_mixer
;
1169 spec
->init_verbs
[0] = cxt5045_test_init_verbs
;
1175 switch (codec
->subsystem_id
>> 16) {
1179 /* HP, Packard Bell, & Fujitsu-Siemens laptops have really bad
1180 * sound over 0dB on NID 0x17. Fix max PCM level to 0 dB
1181 * (originally it has 0x2b steps with 0dB offset 0x14)
1183 snd_hda_override_amp_caps(codec
, 0x17, HDA_INPUT
,
1184 (0x14 << AC_AMPCAP_OFFSET_SHIFT
) |
1185 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1186 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1187 (1 << AC_AMPCAP_MUTE_SHIFT
));
1195 /* Conexant 5047 specific */
1196 #define CXT5047_SPDIF_OUT 0x11
1198 static hda_nid_t cxt5047_dac_nids
[1] = { 0x10 }; /* 0x1c */
1199 static hda_nid_t cxt5047_adc_nids
[1] = { 0x12 };
1200 static hda_nid_t cxt5047_capsrc_nids
[1] = { 0x1a };
1202 static struct hda_channel_mode cxt5047_modes
[1] = {
1206 static struct hda_input_mux cxt5047_toshiba_capture_source
= {
1214 /* turn on/off EAPD (+ mute HP) as a master switch */
1215 static int cxt5047_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1216 struct snd_ctl_elem_value
*ucontrol
)
1218 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1219 struct conexant_spec
*spec
= codec
->spec
;
1222 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1225 /* toggle internal speakers mute depending of presence of
1226 * the headphone jack
1228 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
1229 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1230 * pin widgets unlike other codecs. In this case, we need to
1231 * set index 0x01 for the volume from the mixer amp 0x19.
1233 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1234 HDA_AMP_MUTE
, bits
);
1235 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
1236 snd_hda_codec_amp_stereo(codec
, 0x13, HDA_OUTPUT
, 0,
1237 HDA_AMP_MUTE
, bits
);
1241 /* mute internal speaker if HP is plugged */
1242 static void cxt5047_hp_automute(struct hda_codec
*codec
)
1244 struct conexant_spec
*spec
= codec
->spec
;
1247 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x13);
1249 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
1250 /* See the note in cxt5047_hp_master_sw_put */
1251 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1252 HDA_AMP_MUTE
, bits
);
1255 /* toggle input of built-in and mic jack appropriately */
1256 static void cxt5047_hp_automic(struct hda_codec
*codec
)
1258 static struct hda_verb mic_jack_on
[] = {
1259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1260 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1263 static struct hda_verb mic_jack_off
[] = {
1264 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1265 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1268 unsigned int present
;
1270 present
= snd_hda_jack_detect(codec
, 0x15);
1272 snd_hda_sequence_write(codec
, mic_jack_on
);
1274 snd_hda_sequence_write(codec
, mic_jack_off
);
1277 /* unsolicited event for HP jack sensing */
1278 static void cxt5047_hp_unsol_event(struct hda_codec
*codec
,
1281 switch (res
>> 26) {
1282 case CONEXANT_HP_EVENT
:
1283 cxt5047_hp_automute(codec
);
1285 case CONEXANT_MIC_EVENT
:
1286 cxt5047_hp_automic(codec
);
1291 static struct snd_kcontrol_new cxt5047_base_mixers
[] = {
1292 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT
),
1293 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT
),
1294 HDA_CODEC_VOLUME("Mic Boost", 0x1a, 0x0, HDA_OUTPUT
),
1295 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT
),
1296 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT
),
1297 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT
),
1298 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT
),
1300 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1301 .name
= "Master Playback Switch",
1302 .info
= cxt_eapd_info
,
1303 .get
= cxt_eapd_get
,
1304 .put
= cxt5047_hp_master_sw_put
,
1305 .private_value
= 0x13,
1311 static struct snd_kcontrol_new cxt5047_hp_spk_mixers
[] = {
1312 /* See the note in cxt5047_hp_master_sw_put */
1313 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT
),
1314 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1318 static struct snd_kcontrol_new cxt5047_hp_only_mixers
[] = {
1319 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1323 static struct hda_verb cxt5047_init_verbs
[] = {
1324 /* Line in, Mic, Built-in Mic */
1325 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1326 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1327 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1329 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1330 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* mixer(0x19) */
1331 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mixer(0x19) */
1332 /* Record selector: Mic */
1333 {0x12, AC_VERB_SET_CONNECT_SEL
,0x03},
1334 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
,
1335 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
1336 {0x1A, AC_VERB_SET_CONNECT_SEL
,0x02},
1337 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1338 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x00},
1339 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1340 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x03},
1341 /* SPDIF route: PCM */
1342 { 0x18, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1343 /* Enable unsolicited events */
1344 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
1345 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1349 /* configuration for Toshiba Laptops */
1350 static struct hda_verb cxt5047_toshiba_init_verbs
[] = {
1351 {0x13, AC_VERB_SET_EAPD_BTLENABLE
, 0x0}, /* default off */
1355 /* Test configuration for debugging, modelled after the ALC260 test
1358 #ifdef CONFIG_SND_DEBUG
1359 static struct hda_input_mux cxt5047_test_capture_source
= {
1362 { "LINE1 pin", 0x0 },
1363 { "MIC1 pin", 0x1 },
1364 { "MIC2 pin", 0x2 },
1369 static struct snd_kcontrol_new cxt5047_test_mixer
[] = {
1371 /* Output only controls */
1372 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT
),
1373 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT
),
1374 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT
),
1375 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT
),
1376 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1377 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1378 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1379 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1380 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT
),
1381 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT
),
1382 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
1383 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
1385 /* Modes for retasking pin widgets */
1386 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT
),
1387 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT
),
1389 /* EAPD Switch Control */
1390 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1392 /* Loopback mixer controls */
1393 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT
),
1394 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT
),
1395 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT
),
1396 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT
),
1397 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT
),
1398 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT
),
1399 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT
),
1400 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT
),
1402 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT
),
1403 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT
),
1404 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT
),
1405 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT
),
1406 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT
),
1407 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT
),
1408 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT
),
1409 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT
),
1411 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1412 .name
= "Input Source",
1413 .info
= conexant_mux_enum_info
,
1414 .get
= conexant_mux_enum_get
,
1415 .put
= conexant_mux_enum_put
,
1417 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1422 static struct hda_verb cxt5047_test_init_verbs
[] = {
1423 /* Enable retasking pins as output, initially without power amp */
1424 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1425 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1426 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1428 /* Disable digital (SPDIF) pins initially, but users can enable
1429 * them via a mixer switch. In the case of SPDIF-out, this initverb
1430 * payload also sets the generation to 0, output to be in "consumer"
1431 * PCM format, copyright asserted, no pre-emphasis and no validity
1434 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1436 /* Ensure mic1, mic2, line1 pin widgets take input from the
1437 * OUT1 sum bus when acting as an output.
1439 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0},
1440 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0},
1442 /* Start with output sum widgets muted and their output gains at min */
1443 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1444 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1446 /* Unmute retasking pin widget output buffers since the default
1447 * state appears to be output. As the pin mode is changed by the
1448 * user the pin mode control will take care of enabling the pin's
1449 * input/output buffers as needed.
1451 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1452 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1453 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1455 /* Mute capture amp left and right */
1456 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1458 /* Set ADC connection select to match default mixer setting (mic1
1461 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x00},
1463 /* Mute all inputs to mixer widget (even unconnected ones) */
1464 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* mic1 pin */
1465 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* mic2 pin */
1466 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* line1 pin */
1467 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* line2 pin */
1468 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1469 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1470 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)}, /* Line-out pin */
1471 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)}, /* HP-pin pin */
1478 /* initialize jack-sensing, too */
1479 static int cxt5047_hp_init(struct hda_codec
*codec
)
1481 conexant_init(codec
);
1482 cxt5047_hp_automute(codec
);
1488 CXT5047_LAPTOP
, /* Laptops w/o EAPD support */
1489 CXT5047_LAPTOP_HP
, /* Some HP laptops */
1490 CXT5047_LAPTOP_EAPD
, /* Laptops with EAPD support */
1491 #ifdef CONFIG_SND_DEBUG
1497 static const char *cxt5047_models
[CXT5047_MODELS
] = {
1498 [CXT5047_LAPTOP
] = "laptop",
1499 [CXT5047_LAPTOP_HP
] = "laptop-hp",
1500 [CXT5047_LAPTOP_EAPD
] = "laptop-eapd",
1501 #ifdef CONFIG_SND_DEBUG
1502 [CXT5047_TEST
] = "test",
1506 static struct snd_pci_quirk cxt5047_cfg_tbl
[] = {
1507 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP
),
1508 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1510 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD
),
1514 static int patch_cxt5047(struct hda_codec
*codec
)
1516 struct conexant_spec
*spec
;
1519 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1523 codec
->pin_amp_workaround
= 1;
1525 spec
->multiout
.max_channels
= 2;
1526 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5047_dac_nids
);
1527 spec
->multiout
.dac_nids
= cxt5047_dac_nids
;
1528 spec
->multiout
.dig_out_nid
= CXT5047_SPDIF_OUT
;
1529 spec
->num_adc_nids
= 1;
1530 spec
->adc_nids
= cxt5047_adc_nids
;
1531 spec
->capsrc_nids
= cxt5047_capsrc_nids
;
1532 spec
->num_mixers
= 1;
1533 spec
->mixers
[0] = cxt5047_base_mixers
;
1534 spec
->num_init_verbs
= 1;
1535 spec
->init_verbs
[0] = cxt5047_init_verbs
;
1536 spec
->spdif_route
= 0;
1537 spec
->num_channel_mode
= ARRAY_SIZE(cxt5047_modes
),
1538 spec
->channel_mode
= cxt5047_modes
,
1540 codec
->patch_ops
= conexant_patch_ops
;
1542 board_config
= snd_hda_check_board_config(codec
, CXT5047_MODELS
,
1545 switch (board_config
) {
1546 case CXT5047_LAPTOP
:
1547 spec
->num_mixers
= 2;
1548 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1549 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1551 case CXT5047_LAPTOP_HP
:
1552 spec
->num_mixers
= 2;
1553 spec
->mixers
[1] = cxt5047_hp_only_mixers
;
1554 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1555 codec
->patch_ops
.init
= cxt5047_hp_init
;
1557 case CXT5047_LAPTOP_EAPD
:
1558 spec
->input_mux
= &cxt5047_toshiba_capture_source
;
1559 spec
->num_mixers
= 2;
1560 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1561 spec
->num_init_verbs
= 2;
1562 spec
->init_verbs
[1] = cxt5047_toshiba_init_verbs
;
1563 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1565 #ifdef CONFIG_SND_DEBUG
1567 spec
->input_mux
= &cxt5047_test_capture_source
;
1568 spec
->mixers
[0] = cxt5047_test_mixer
;
1569 spec
->init_verbs
[0] = cxt5047_test_init_verbs
;
1570 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1573 spec
->vmaster_nid
= 0x13;
1575 switch (codec
->subsystem_id
>> 16) {
1577 /* HP laptops have really bad sound over 0 dB on NID 0x10.
1578 * Fix max PCM level to 0 dB (originally it has 0x1e steps
1579 * with 0 dB offset 0x17)
1581 snd_hda_override_amp_caps(codec
, 0x10, HDA_INPUT
,
1582 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
1583 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1584 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1585 (1 << AC_AMPCAP_MUTE_SHIFT
));
1592 /* Conexant 5051 specific */
1593 static hda_nid_t cxt5051_dac_nids
[1] = { 0x10 };
1594 static hda_nid_t cxt5051_adc_nids
[2] = { 0x14, 0x15 };
1596 static struct hda_channel_mode cxt5051_modes
[1] = {
1600 static void cxt5051_update_speaker(struct hda_codec
*codec
)
1602 struct conexant_spec
*spec
= codec
->spec
;
1603 unsigned int pinctl
;
1604 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1605 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1609 /* turn on/off EAPD (+ mute HP) as a master switch */
1610 static int cxt5051_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1611 struct snd_ctl_elem_value
*ucontrol
)
1613 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1615 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1617 cxt5051_update_speaker(codec
);
1621 /* toggle input of built-in and mic jack appropriately */
1622 static void cxt5051_portb_automic(struct hda_codec
*codec
)
1624 struct conexant_spec
*spec
= codec
->spec
;
1625 unsigned int present
;
1627 if (spec
->no_auto_mic
)
1629 present
= snd_hda_jack_detect(codec
, 0x17);
1630 snd_hda_codec_write(codec
, 0x14, 0,
1631 AC_VERB_SET_CONNECT_SEL
,
1632 present
? 0x01 : 0x00);
1635 /* switch the current ADC according to the jack state */
1636 static void cxt5051_portc_automic(struct hda_codec
*codec
)
1638 struct conexant_spec
*spec
= codec
->spec
;
1639 unsigned int present
;
1642 if (spec
->no_auto_mic
)
1644 present
= snd_hda_jack_detect(codec
, 0x18);
1646 spec
->cur_adc_idx
= 1;
1648 spec
->cur_adc_idx
= 0;
1649 new_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
1650 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
1651 /* stream is running, let's swap the current ADC */
1652 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
1653 spec
->cur_adc
= new_adc
;
1654 snd_hda_codec_setup_stream(codec
, new_adc
,
1655 spec
->cur_adc_stream_tag
, 0,
1656 spec
->cur_adc_format
);
1660 /* mute internal speaker if HP is plugged */
1661 static void cxt5051_hp_automute(struct hda_codec
*codec
)
1663 struct conexant_spec
*spec
= codec
->spec
;
1665 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x16);
1666 cxt5051_update_speaker(codec
);
1669 /* unsolicited event for HP jack sensing */
1670 static void cxt5051_hp_unsol_event(struct hda_codec
*codec
,
1673 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
1674 switch (res
>> 26) {
1675 case CONEXANT_HP_EVENT
:
1676 cxt5051_hp_automute(codec
);
1678 case CXT5051_PORTB_EVENT
:
1679 cxt5051_portb_automic(codec
);
1681 case CXT5051_PORTC_EVENT
:
1682 cxt5051_portc_automic(codec
);
1685 conexant_report_jack(codec
, nid
);
1688 static struct snd_kcontrol_new cxt5051_mixers
[] = {
1689 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1690 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1691 HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT
),
1692 HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT
),
1693 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT
),
1694 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT
),
1695 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1697 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1698 .name
= "Master Playback Switch",
1699 .info
= cxt_eapd_info
,
1700 .get
= cxt_eapd_get
,
1701 .put
= cxt5051_hp_master_sw_put
,
1702 .private_value
= 0x1a,
1708 static struct snd_kcontrol_new cxt5051_hp_mixers
[] = {
1709 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1710 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1711 HDA_CODEC_VOLUME("External Mic Volume", 0x15, 0x00, HDA_INPUT
),
1712 HDA_CODEC_MUTE("External Mic Switch", 0x15, 0x00, HDA_INPUT
),
1713 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1715 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1716 .name
= "Master Playback Switch",
1717 .info
= cxt_eapd_info
,
1718 .get
= cxt_eapd_get
,
1719 .put
= cxt5051_hp_master_sw_put
,
1720 .private_value
= 0x1a,
1726 static struct snd_kcontrol_new cxt5051_hp_dv6736_mixers
[] = {
1727 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x00, HDA_INPUT
),
1728 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x00, HDA_INPUT
),
1729 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1731 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1732 .name
= "Master Playback Switch",
1733 .info
= cxt_eapd_info
,
1734 .get
= cxt_eapd_get
,
1735 .put
= cxt5051_hp_master_sw_put
,
1736 .private_value
= 0x1a,
1742 static struct hda_verb cxt5051_init_verbs
[] = {
1744 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1745 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1746 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1747 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1748 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1749 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1751 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1752 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1754 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1755 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1757 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1758 /* Record selector: Int mic */
1759 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1760 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1761 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1762 /* SPDIF route: PCM */
1763 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1765 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1766 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1767 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTB_EVENT
},
1768 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTC_EVENT
},
1772 static struct hda_verb cxt5051_hp_dv6736_init_verbs
[] = {
1774 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1775 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1776 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1777 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1779 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1780 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1782 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1783 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1785 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1786 /* Record selector: Int mic */
1787 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1788 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1789 /* SPDIF route: PCM */
1790 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1792 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1793 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1794 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTB_EVENT
},
1798 static struct hda_verb cxt5051_lenovo_x200_init_verbs
[] = {
1800 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1801 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1802 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1803 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1804 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1805 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1807 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1808 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1810 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1811 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1813 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1814 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00},
1816 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1817 /* Record selector: Int mic */
1818 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1819 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1820 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1821 /* SPDIF route: PCM */
1822 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1824 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1825 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1826 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTB_EVENT
},
1827 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTC_EVENT
},
1828 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1832 /* initialize jack-sensing, too */
1833 static int cxt5051_init(struct hda_codec
*codec
)
1835 conexant_init(codec
);
1836 conexant_init_jacks(codec
);
1837 if (codec
->patch_ops
.unsol_event
) {
1838 cxt5051_hp_automute(codec
);
1839 cxt5051_portb_automic(codec
);
1840 cxt5051_portc_automic(codec
);
1847 CXT5051_LAPTOP
, /* Laptops w/ EAPD support */
1848 CXT5051_HP
, /* no docking */
1849 CXT5051_HP_DV6736
, /* HP without mic switch */
1850 CXT5051_LENOVO_X200
, /* Lenovo X200 laptop */
1854 static const char *cxt5051_models
[CXT5051_MODELS
] = {
1855 [CXT5051_LAPTOP
] = "laptop",
1856 [CXT5051_HP
] = "hp",
1857 [CXT5051_HP_DV6736
] = "hp-dv6736",
1858 [CXT5051_LENOVO_X200
] = "lenovo-x200",
1861 static struct snd_pci_quirk cxt5051_cfg_tbl
[] = {
1862 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736
),
1863 SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP
),
1864 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1866 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP
),
1867 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200
),
1871 static int patch_cxt5051(struct hda_codec
*codec
)
1873 struct conexant_spec
*spec
;
1876 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1880 codec
->pin_amp_workaround
= 1;
1882 codec
->patch_ops
= conexant_patch_ops
;
1883 codec
->patch_ops
.init
= cxt5051_init
;
1885 spec
->multiout
.max_channels
= 2;
1886 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5051_dac_nids
);
1887 spec
->multiout
.dac_nids
= cxt5051_dac_nids
;
1888 spec
->multiout
.dig_out_nid
= CXT5051_SPDIF_OUT
;
1889 spec
->num_adc_nids
= 1; /* not 2; via auto-mic switch */
1890 spec
->adc_nids
= cxt5051_adc_nids
;
1891 spec
->num_mixers
= 1;
1892 spec
->mixers
[0] = cxt5051_mixers
;
1893 spec
->num_init_verbs
= 1;
1894 spec
->init_verbs
[0] = cxt5051_init_verbs
;
1895 spec
->spdif_route
= 0;
1896 spec
->num_channel_mode
= ARRAY_SIZE(cxt5051_modes
);
1897 spec
->channel_mode
= cxt5051_modes
;
1899 spec
->cur_adc_idx
= 0;
1901 codec
->patch_ops
.unsol_event
= cxt5051_hp_unsol_event
;
1903 board_config
= snd_hda_check_board_config(codec
, CXT5051_MODELS
,
1906 switch (board_config
) {
1908 spec
->mixers
[0] = cxt5051_hp_mixers
;
1910 case CXT5051_HP_DV6736
:
1911 spec
->init_verbs
[0] = cxt5051_hp_dv6736_init_verbs
;
1912 spec
->mixers
[0] = cxt5051_hp_dv6736_mixers
;
1913 spec
->no_auto_mic
= 1;
1915 case CXT5051_LENOVO_X200
:
1916 spec
->init_verbs
[0] = cxt5051_lenovo_x200_init_verbs
;
1923 /* Conexant 5066 specific */
1925 static hda_nid_t cxt5066_dac_nids
[1] = { 0x10 };
1926 static hda_nid_t cxt5066_adc_nids
[3] = { 0x14, 0x15, 0x16 };
1927 static hda_nid_t cxt5066_capsrc_nids
[1] = { 0x17 };
1928 #define CXT5066_SPDIF_OUT 0x21
1930 /* OLPC's microphone port is DC coupled for use with external sensors,
1931 * therefore we use a 50% mic bias in order to center the input signal with
1932 * the DC input range of the codec. */
1933 #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50
1935 static struct hda_channel_mode cxt5066_modes
[1] = {
1939 static void cxt5066_update_speaker(struct hda_codec
*codec
)
1941 struct conexant_spec
*spec
= codec
->spec
;
1942 unsigned int pinctl
;
1944 snd_printdd("CXT5066: update speaker, hp_present=%d\n",
1948 pinctl
= ((spec
->hp_present
& 1) && spec
->cur_eapd
) ? PIN_HP
: 0;
1949 snd_hda_codec_write(codec
, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1952 /* Port D (HP/LO) */
1953 pinctl
= ((spec
->hp_present
& 2) && spec
->cur_eapd
)
1954 ? spec
->port_d_mode
: 0;
1955 snd_hda_codec_write(codec
, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1959 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1960 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1963 if (spec
->dell_automute
) {
1964 /* DELL AIO Port Rule: PortA > PortD > IntSpk */
1965 pinctl
= (!(spec
->hp_present
& 1) && spec
->cur_eapd
)
1967 snd_hda_codec_write(codec
, 0x1c, 0,
1968 AC_VERB_SET_PIN_WIDGET_CONTROL
, pinctl
);
1972 /* turn on/off EAPD (+ mute HP) as a master switch */
1973 static int cxt5066_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1974 struct snd_ctl_elem_value
*ucontrol
)
1976 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1978 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1981 cxt5066_update_speaker(codec
);
1985 /* toggle input of built-in and mic jack appropriately */
1986 static void cxt5066_automic(struct hda_codec
*codec
)
1988 struct conexant_spec
*spec
= codec
->spec
;
1989 struct hda_verb ext_mic_present
[] = {
1990 /* enable external mic, port B */
1991 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, spec
->ext_mic_bias
},
1993 /* switch to external mic input */
1994 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
1996 /* disable internal mic, port C */
1997 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2000 static struct hda_verb ext_mic_absent
[] = {
2001 /* enable internal mic, port C */
2002 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2004 /* switch to internal mic input */
2005 {0x17, AC_VERB_SET_CONNECT_SEL
, 1},
2007 /* disable external mic, port B */
2008 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2011 unsigned int present
;
2013 present
= snd_hda_jack_detect(codec
, 0x1a);
2015 snd_printdd("CXT5066: external microphone detected\n");
2016 snd_hda_sequence_write(codec
, ext_mic_present
);
2018 snd_printdd("CXT5066: external microphone absent\n");
2019 snd_hda_sequence_write(codec
, ext_mic_absent
);
2023 /* toggle input of built-in digital mic and mic jack appropriately */
2024 static void cxt5066_vostro_automic(struct hda_codec
*codec
)
2026 struct conexant_spec
*spec
= codec
->spec
;
2027 unsigned int present
;
2029 struct hda_verb ext_mic_present
[] = {
2030 /* enable external mic, port B */
2031 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, spec
->ext_mic_bias
},
2033 /* switch to external mic input */
2034 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2035 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2037 /* disable internal digital mic */
2038 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2041 static struct hda_verb ext_mic_absent
[] = {
2042 /* enable internal mic, port C */
2043 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2045 /* switch to internal mic input */
2046 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2048 /* disable external mic, port B */
2049 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2053 present
= snd_hda_jack_detect(codec
, 0x1a);
2055 snd_printdd("CXT5066: external microphone detected\n");
2056 snd_hda_sequence_write(codec
, ext_mic_present
);
2058 snd_printdd("CXT5066: external microphone absent\n");
2059 snd_hda_sequence_write(codec
, ext_mic_absent
);
2063 /* mute internal speaker if HP is plugged */
2064 static void cxt5066_hp_automute(struct hda_codec
*codec
)
2066 struct conexant_spec
*spec
= codec
->spec
;
2067 unsigned int portA
, portD
;
2070 portA
= snd_hda_jack_detect(codec
, 0x19);
2073 portD
= snd_hda_jack_detect(codec
, 0x1c);
2075 spec
->hp_present
= !!(portA
| portD
);
2076 snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
2077 portA
, portD
, spec
->hp_present
);
2078 cxt5066_update_speaker(codec
);
2081 /* unsolicited event for jack sensing */
2082 static void cxt5066_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2084 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2085 switch (res
>> 26) {
2086 case CONEXANT_HP_EVENT
:
2087 cxt5066_hp_automute(codec
);
2089 case CONEXANT_MIC_EVENT
:
2090 cxt5066_automic(codec
);
2095 /* unsolicited event for jack sensing */
2096 static void cxt5066_vostro_event(struct hda_codec
*codec
, unsigned int res
)
2098 snd_printdd("CXT5066_vostro: unsol event %x (%x)\n", res
, res
>> 26);
2099 switch (res
>> 26) {
2100 case CONEXANT_HP_EVENT
:
2101 cxt5066_hp_automute(codec
);
2103 case CONEXANT_MIC_EVENT
:
2104 cxt5066_vostro_automic(codec
);
2109 static const struct hda_input_mux cxt5066_analog_mic_boost
= {
2120 static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol
*kcontrol
,
2121 struct snd_ctl_elem_info
*uinfo
)
2123 return snd_hda_input_mux_info(&cxt5066_analog_mic_boost
, uinfo
);
2126 static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol
*kcontrol
,
2127 struct snd_ctl_elem_value
*ucontrol
)
2129 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2131 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
2132 int inout
= (kcontrol
->private_value
& 0x100) ?
2133 AC_AMP_GET_INPUT
: AC_AMP_GET_OUTPUT
;
2135 val
= snd_hda_codec_read(codec
, nid
, 0,
2136 AC_VERB_GET_AMP_GAIN_MUTE
, inout
);
2138 ucontrol
->value
.enumerated
.item
[0] = val
& AC_AMP_GAIN
;
2142 static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol
*kcontrol
,
2143 struct snd_ctl_elem_value
*ucontrol
)
2145 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2146 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2148 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
2149 int inout
= (kcontrol
->private_value
& 0x100) ?
2150 AC_AMP_SET_INPUT
: AC_AMP_SET_OUTPUT
;
2152 if (!imux
->num_items
)
2154 idx
= ucontrol
->value
.enumerated
.item
[0];
2155 if (idx
>= imux
->num_items
)
2156 idx
= imux
->num_items
- 1;
2158 snd_hda_codec_write_cache(codec
, nid
, 0,
2159 AC_VERB_SET_AMP_GAIN_MUTE
,
2160 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| inout
|
2161 imux
->items
[idx
].index
);
2166 static struct hda_input_mux cxt5066_capture_source
= {
2176 static struct hda_bind_ctls cxt5066_bind_capture_vol_others
= {
2177 .ops
= &snd_hda_bind_vol
,
2179 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2180 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2185 static struct hda_bind_ctls cxt5066_bind_capture_sw_others
= {
2186 .ops
= &snd_hda_bind_sw
,
2188 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2189 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2194 static struct snd_kcontrol_new cxt5066_mixer_master
[] = {
2195 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
2199 static struct snd_kcontrol_new cxt5066_mixer_master_olpc
[] = {
2201 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2202 .name
= "Master Playback Volume",
2203 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
|
2204 SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
2205 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
,
2206 .info
= snd_hda_mixer_amp_volume_info
,
2207 .get
= snd_hda_mixer_amp_volume_get
,
2208 .put
= snd_hda_mixer_amp_volume_put
,
2209 .tlv
= { .c
= snd_hda_mixer_amp_tlv
},
2210 /* offset by 28 volume steps to limit minimum gain to -46dB */
2212 HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT
, 28),
2217 static struct snd_kcontrol_new cxt5066_mixers
[] = {
2219 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2220 .name
= "Master Playback Switch",
2221 .info
= cxt_eapd_info
,
2222 .get
= cxt_eapd_get
,
2223 .put
= cxt5066_hp_master_sw_put
,
2224 .private_value
= 0x1d,
2228 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2229 .name
= "Ext Mic Boost Capture Enum",
2230 .info
= cxt5066_mic_boost_mux_enum_info
,
2231 .get
= cxt5066_mic_boost_mux_enum_get
,
2232 .put
= cxt5066_mic_boost_mux_enum_put
,
2233 .private_value
= 0x17,
2236 HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others
),
2237 HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others
),
2241 static struct snd_kcontrol_new cxt5066_vostro_mixers
[] = {
2243 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2244 .name
= "Int Mic Boost Capture Enum",
2245 .info
= cxt5066_mic_boost_mux_enum_info
,
2246 .get
= cxt5066_mic_boost_mux_enum_get
,
2247 .put
= cxt5066_mic_boost_mux_enum_put
,
2248 .private_value
= 0x23 | 0x100,
2250 HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT
),
2254 static struct hda_verb cxt5066_init_verbs
[] = {
2255 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2256 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2257 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2258 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2261 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2262 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2265 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2266 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2268 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2269 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2272 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2274 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2275 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2276 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2277 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2278 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2279 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2281 /* no digital microphone support yet */
2282 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2284 /* Audio input selector */
2285 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2287 /* SPDIF route: PCM */
2288 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2289 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2291 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2292 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2295 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2297 /* not handling these yet */
2298 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2299 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2300 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2301 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2302 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2303 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2304 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2305 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2309 static struct hda_verb cxt5066_init_verbs_olpc
[] = {
2310 /* Port A: headphones */
2311 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2312 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2314 /* Port B: external microphone */
2315 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, CXT5066_OLPC_EXT_MIC_BIAS
},
2317 /* Port C: internal microphone */
2318 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2320 /* Port D: unused */
2321 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2323 /* Port E: unused, but has primary EAPD */
2324 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2325 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2327 /* Port F: unused */
2328 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2330 /* Port G: internal speakers */
2331 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2332 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2335 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2338 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2340 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2341 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2342 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2343 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2344 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2345 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2346 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2347 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2348 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2349 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2350 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2351 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2353 /* Disable digital microphone port */
2354 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2356 /* Audio input selectors */
2357 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2358 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2361 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2362 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2364 /* enable unsolicited events for Port A and B */
2365 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2366 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2370 static struct hda_verb cxt5066_init_verbs_vostro
[] = {
2371 /* Port A: headphones */
2372 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2373 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2375 /* Port B: external microphone */
2376 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2378 /* Port C: unused */
2379 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2381 /* Port D: unused */
2382 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2384 /* Port E: unused, but has primary EAPD */
2385 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2386 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2388 /* Port F: unused */
2389 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2391 /* Port G: internal speakers */
2392 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2393 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2396 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2399 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2401 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2402 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2403 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2404 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2405 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2406 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2407 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2408 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2409 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2410 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2411 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2412 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2414 /* Digital microphone port */
2415 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2417 /* Audio input selectors */
2418 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2419 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2422 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2423 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2425 /* enable unsolicited events for Port A and B */
2426 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2427 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2431 static struct hda_verb cxt5066_init_verbs_portd_lo
[] = {
2432 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2436 /* initialize jack-sensing, too */
2437 static int cxt5066_init(struct hda_codec
*codec
)
2439 struct conexant_spec
*spec
= codec
->spec
;
2441 snd_printdd("CXT5066: init\n");
2442 conexant_init(codec
);
2443 if (codec
->patch_ops
.unsol_event
) {
2444 cxt5066_hp_automute(codec
);
2445 if (spec
->dell_vostro
)
2446 cxt5066_vostro_automic(codec
);
2448 cxt5066_automic(codec
);
2454 CXT5066_LAPTOP
, /* Laptops w/ EAPD support */
2455 CXT5066_DELL_LAPTOP
, /* Dell Laptop */
2456 CXT5066_OLPC_XO_1_5
, /* OLPC XO 1.5 */
2457 CXT5066_DELL_VOSTO
, /* Dell Vostro 1015i */
2461 static const char *cxt5066_models
[CXT5066_MODELS
] = {
2462 [CXT5066_LAPTOP
] = "laptop",
2463 [CXT5066_DELL_LAPTOP
] = "dell-laptop",
2464 [CXT5066_OLPC_XO_1_5
] = "olpc-xo-1_5",
2465 [CXT5066_DELL_VOSTO
] = "dell-vostro"
2468 static struct snd_pci_quirk cxt5066_cfg_tbl
[] = {
2469 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
2471 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell",
2472 CXT5066_DELL_LAPTOP
),
2473 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5
),
2474 SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTO
),
2478 static int patch_cxt5066(struct hda_codec
*codec
)
2480 struct conexant_spec
*spec
;
2483 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2488 codec
->patch_ops
= conexant_patch_ops
;
2489 codec
->patch_ops
.init
= cxt5066_init
;
2491 spec
->dell_automute
= 0;
2492 spec
->multiout
.max_channels
= 2;
2493 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5066_dac_nids
);
2494 spec
->multiout
.dac_nids
= cxt5066_dac_nids
;
2495 spec
->multiout
.dig_out_nid
= CXT5066_SPDIF_OUT
;
2496 spec
->num_adc_nids
= 1;
2497 spec
->adc_nids
= cxt5066_adc_nids
;
2498 spec
->capsrc_nids
= cxt5066_capsrc_nids
;
2499 spec
->input_mux
= &cxt5066_capture_source
;
2501 spec
->port_d_mode
= PIN_HP
;
2502 spec
->ext_mic_bias
= PIN_VREF80
;
2504 spec
->num_init_verbs
= 1;
2505 spec
->init_verbs
[0] = cxt5066_init_verbs
;
2506 spec
->num_channel_mode
= ARRAY_SIZE(cxt5066_modes
);
2507 spec
->channel_mode
= cxt5066_modes
;
2509 spec
->cur_adc_idx
= 0;
2511 board_config
= snd_hda_check_board_config(codec
, CXT5066_MODELS
,
2512 cxt5066_models
, cxt5066_cfg_tbl
);
2513 switch (board_config
) {
2515 case CXT5066_LAPTOP
:
2516 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
2517 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2519 case CXT5066_DELL_LAPTOP
:
2520 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
2521 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2523 spec
->port_d_mode
= PIN_OUT
;
2524 spec
->init_verbs
[spec
->num_init_verbs
] = cxt5066_init_verbs_portd_lo
;
2525 spec
->num_init_verbs
++;
2526 spec
->dell_automute
= 1;
2528 case CXT5066_OLPC_XO_1_5
:
2529 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
2530 spec
->init_verbs
[0] = cxt5066_init_verbs_olpc
;
2531 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
2532 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2533 spec
->port_d_mode
= 0;
2534 spec
->ext_mic_bias
= CXT5066_OLPC_EXT_MIC_BIAS
;
2537 spec
->multiout
.dig_out_nid
= 0;
2539 /* input source automatically selected */
2540 spec
->input_mux
= NULL
;
2542 case CXT5066_DELL_VOSTO
:
2543 codec
->patch_ops
.unsol_event
= cxt5066_vostro_event
;
2544 spec
->init_verbs
[0] = cxt5066_init_verbs_vostro
;
2545 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
2546 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2547 spec
->mixers
[spec
->num_mixers
++] = cxt5066_vostro_mixers
;
2548 spec
->port_d_mode
= 0;
2549 spec
->dell_vostro
= 1;
2550 snd_hda_attach_beep_device(codec
, 0x13);
2553 spec
->multiout
.dig_out_nid
= 0;
2555 /* input source automatically selected */
2556 spec
->input_mux
= NULL
;
2566 static struct hda_codec_preset snd_hda_preset_conexant
[] = {
2567 { .id
= 0x14f15045, .name
= "CX20549 (Venice)",
2568 .patch
= patch_cxt5045
},
2569 { .id
= 0x14f15047, .name
= "CX20551 (Waikiki)",
2570 .patch
= patch_cxt5047
},
2571 { .id
= 0x14f15051, .name
= "CX20561 (Hermosa)",
2572 .patch
= patch_cxt5051
},
2573 { .id
= 0x14f15066, .name
= "CX20582 (Pebble)",
2574 .patch
= patch_cxt5066
},
2575 { .id
= 0x14f15067, .name
= "CX20583 (Pebble HSF)",
2576 .patch
= patch_cxt5066
},
2580 MODULE_ALIAS("snd-hda-codec-id:14f15045");
2581 MODULE_ALIAS("snd-hda-codec-id:14f15047");
2582 MODULE_ALIAS("snd-hda-codec-id:14f15051");
2583 MODULE_ALIAS("snd-hda-codec-id:14f15066");
2584 MODULE_ALIAS("snd-hda-codec-id:14f15067");
2586 MODULE_LICENSE("GPL");
2587 MODULE_DESCRIPTION("Conexant HD-audio codec");
2589 static struct hda_codec_preset_list conexant_list
= {
2590 .preset
= snd_hda_preset_conexant
,
2591 .owner
= THIS_MODULE
,
2594 static int __init
patch_conexant_init(void)
2596 return snd_hda_add_codec_preset(&conexant_list
);
2599 static void __exit
patch_conexant_exit(void)
2601 snd_hda_delete_codec_preset(&conexant_list
);
2604 module_init(patch_conexant_init
)
2605 module_exit(patch_conexant_exit
)