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 0x12
46 #define CXT5051_PORTB_EVENT 0x38
47 #define CXT5051_PORTC_EVENT 0x39
49 #define AUTO_MIC_PORTB (1 << 1)
50 #define AUTO_MIC_PORTC (1 << 2)
52 struct conexant_jack
{
56 struct snd_jack
*jack
;
60 struct conexant_spec
{
62 struct snd_kcontrol_new
*mixers
[5];
64 hda_nid_t vmaster_nid
;
66 const struct hda_verb
*init_verbs
[5]; /* initialization verbs
70 unsigned int num_init_verbs
;
73 struct hda_multi_out multiout
; /* playback set-up
74 * max_channels, dacs must be set
75 * dig_out_nid and hp_nid are optional
77 unsigned int cur_eapd
;
78 unsigned int hp_present
;
79 unsigned int auto_mic
;
80 unsigned int need_dac_fix
;
83 unsigned int num_adc_nids
;
85 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
87 unsigned int cur_adc_idx
;
89 unsigned int cur_adc_stream_tag
;
90 unsigned int cur_adc_format
;
93 const struct hda_input_mux
*input_mux
;
94 hda_nid_t
*capsrc_nids
;
95 unsigned int cur_mux
[3];
98 const struct hda_channel_mode
*channel_mode
;
101 /* PCM information */
102 struct hda_pcm pcm_rec
[2]; /* used in build_pcms() */
104 unsigned int spdif_route
;
107 struct snd_array jacks
;
109 /* dynamic controls, init_verbs and input_mux */
110 struct auto_pin_cfg autocfg
;
111 struct hda_input_mux private_imux
;
112 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
114 unsigned int dell_automute
;
115 unsigned int port_d_mode
;
116 unsigned int dell_vostro
:1;
117 unsigned int ideapad
:1;
118 unsigned int thinkpad
:1;
120 unsigned int ext_mic_present
;
121 unsigned int recording
;
122 void (*capture_prepare
)(struct hda_codec
*codec
);
123 void (*capture_cleanup
)(struct hda_codec
*codec
);
125 /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
126 * through the microphone jack.
127 * When the user enables this through a mixer switch, both internal and
128 * external microphones are disabled. Gain is fixed at 0dB. In this mode,
129 * we also allow the bias to be configured through a separate mixer
131 unsigned int dc_enable
;
132 unsigned int dc_input_bias
; /* offset into cxt5066_olpc_dc_bias */
133 unsigned int mic_boost
; /* offset into cxt5066_analog_mic_boost */
136 static int conexant_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
137 struct hda_codec
*codec
,
138 struct snd_pcm_substream
*substream
)
140 struct conexant_spec
*spec
= codec
->spec
;
141 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
145 static int conexant_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
146 struct hda_codec
*codec
,
147 unsigned int stream_tag
,
149 struct snd_pcm_substream
*substream
)
151 struct conexant_spec
*spec
= codec
->spec
;
152 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
157 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
158 struct hda_codec
*codec
,
159 struct snd_pcm_substream
*substream
)
161 struct conexant_spec
*spec
= codec
->spec
;
162 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
168 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
169 struct hda_codec
*codec
,
170 struct snd_pcm_substream
*substream
)
172 struct conexant_spec
*spec
= codec
->spec
;
173 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
176 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
177 struct hda_codec
*codec
,
178 struct snd_pcm_substream
*substream
)
180 struct conexant_spec
*spec
= codec
->spec
;
181 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
184 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
185 struct hda_codec
*codec
,
186 unsigned int stream_tag
,
188 struct snd_pcm_substream
*substream
)
190 struct conexant_spec
*spec
= codec
->spec
;
191 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
199 static int conexant_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
200 struct hda_codec
*codec
,
201 unsigned int stream_tag
,
203 struct snd_pcm_substream
*substream
)
205 struct conexant_spec
*spec
= codec
->spec
;
206 if (spec
->capture_prepare
)
207 spec
->capture_prepare(codec
);
208 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
209 stream_tag
, 0, format
);
213 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
214 struct hda_codec
*codec
,
215 struct snd_pcm_substream
*substream
)
217 struct conexant_spec
*spec
= codec
->spec
;
218 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
219 if (spec
->capture_cleanup
)
220 spec
->capture_cleanup(codec
);
226 static struct hda_pcm_stream conexant_pcm_analog_playback
= {
230 .nid
= 0, /* fill later */
232 .open
= conexant_playback_pcm_open
,
233 .prepare
= conexant_playback_pcm_prepare
,
234 .cleanup
= conexant_playback_pcm_cleanup
238 static struct hda_pcm_stream conexant_pcm_analog_capture
= {
242 .nid
= 0, /* fill later */
244 .prepare
= conexant_capture_pcm_prepare
,
245 .cleanup
= conexant_capture_pcm_cleanup
250 static struct hda_pcm_stream conexant_pcm_digital_playback
= {
254 .nid
= 0, /* fill later */
256 .open
= conexant_dig_playback_pcm_open
,
257 .close
= conexant_dig_playback_pcm_close
,
258 .prepare
= conexant_dig_playback_pcm_prepare
262 static struct hda_pcm_stream conexant_pcm_digital_capture
= {
266 /* NID is set in alc_build_pcms */
269 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
270 struct hda_codec
*codec
,
271 unsigned int stream_tag
,
273 struct snd_pcm_substream
*substream
)
275 struct conexant_spec
*spec
= codec
->spec
;
276 spec
->cur_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
277 spec
->cur_adc_stream_tag
= stream_tag
;
278 spec
->cur_adc_format
= format
;
279 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
283 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
284 struct hda_codec
*codec
,
285 struct snd_pcm_substream
*substream
)
287 struct conexant_spec
*spec
= codec
->spec
;
288 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
293 static struct hda_pcm_stream cx5051_pcm_analog_capture
= {
297 .nid
= 0, /* fill later */
299 .prepare
= cx5051_capture_pcm_prepare
,
300 .cleanup
= cx5051_capture_pcm_cleanup
304 static int conexant_build_pcms(struct hda_codec
*codec
)
306 struct conexant_spec
*spec
= codec
->spec
;
307 struct hda_pcm
*info
= spec
->pcm_rec
;
310 codec
->pcm_info
= info
;
312 info
->name
= "CONEXANT Analog";
313 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = conexant_pcm_analog_playback
;
314 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
=
315 spec
->multiout
.max_channels
;
316 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
317 spec
->multiout
.dac_nids
[0];
318 if (codec
->vendor_id
== 0x14f15051)
319 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
320 cx5051_pcm_analog_capture
;
322 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
323 conexant_pcm_analog_capture
;
324 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
= spec
->num_adc_nids
;
325 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
327 if (spec
->multiout
.dig_out_nid
) {
330 info
->name
= "Conexant Digital";
331 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
332 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
333 conexant_pcm_digital_playback
;
334 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
335 spec
->multiout
.dig_out_nid
;
336 if (spec
->dig_in_nid
) {
337 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
338 conexant_pcm_digital_capture
;
339 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
347 static int conexant_mux_enum_info(struct snd_kcontrol
*kcontrol
,
348 struct snd_ctl_elem_info
*uinfo
)
350 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
351 struct conexant_spec
*spec
= codec
->spec
;
353 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
356 static int conexant_mux_enum_get(struct snd_kcontrol
*kcontrol
,
357 struct snd_ctl_elem_value
*ucontrol
)
359 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
360 struct conexant_spec
*spec
= codec
->spec
;
361 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
363 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
367 static int conexant_mux_enum_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 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
374 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
375 spec
->capsrc_nids
[adc_idx
],
376 &spec
->cur_mux
[adc_idx
]);
379 #ifdef CONFIG_SND_HDA_INPUT_JACK
380 static void conexant_free_jack_priv(struct snd_jack
*jack
)
382 struct conexant_jack
*jacks
= jack
->private_data
;
387 static int conexant_add_jack(struct hda_codec
*codec
,
388 hda_nid_t nid
, int type
)
390 struct conexant_spec
*spec
;
391 struct conexant_jack
*jack
;
396 snd_array_init(&spec
->jacks
, sizeof(*jack
), 32);
397 jack
= snd_array_new(&spec
->jacks
);
398 name
= (type
== SND_JACK_HEADPHONE
) ? "Headphone" : "Mic" ;
406 err
= snd_jack_new(codec
->bus
->card
, name
, type
, &jack
->jack
);
409 jack
->jack
->private_data
= jack
;
410 jack
->jack
->private_free
= conexant_free_jack_priv
;
414 static void conexant_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
416 struct conexant_spec
*spec
= codec
->spec
;
417 struct conexant_jack
*jacks
= spec
->jacks
.list
;
421 for (i
= 0; i
< spec
->jacks
.used
; i
++) {
422 if (jacks
->nid
== nid
) {
423 unsigned int present
;
424 present
= snd_hda_jack_detect(codec
, nid
);
426 present
= (present
) ? jacks
->type
: 0 ;
428 snd_jack_report(jacks
->jack
,
436 static int conexant_init_jacks(struct hda_codec
*codec
)
438 struct conexant_spec
*spec
= codec
->spec
;
441 for (i
= 0; i
< spec
->num_init_verbs
; i
++) {
442 const struct hda_verb
*hv
;
444 hv
= spec
->init_verbs
[i
];
447 switch (hv
->param
^ AC_USRSP_EN
) {
448 case CONEXANT_HP_EVENT
:
449 err
= conexant_add_jack(codec
, hv
->nid
,
451 conexant_report_jack(codec
, hv
->nid
);
453 case CXT5051_PORTC_EVENT
:
454 case CONEXANT_MIC_EVENT
:
455 err
= conexant_add_jack(codec
, hv
->nid
,
456 SND_JACK_MICROPHONE
);
457 conexant_report_jack(codec
, hv
->nid
);
469 static inline void conexant_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
473 static inline int conexant_init_jacks(struct hda_codec
*codec
)
479 static int conexant_init(struct hda_codec
*codec
)
481 struct conexant_spec
*spec
= codec
->spec
;
484 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
485 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
489 static void conexant_free(struct hda_codec
*codec
)
491 #ifdef CONFIG_SND_HDA_INPUT_JACK
492 struct conexant_spec
*spec
= codec
->spec
;
493 if (spec
->jacks
.list
) {
494 struct conexant_jack
*jacks
= spec
->jacks
.list
;
496 for (i
= 0; i
< spec
->jacks
.used
; i
++, jacks
++) {
498 snd_device_free(codec
->bus
->card
, jacks
->jack
);
500 snd_array_free(&spec
->jacks
);
503 snd_hda_detach_beep_device(codec
);
507 static struct snd_kcontrol_new cxt_capture_mixers
[] = {
509 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
510 .name
= "Capture Source",
511 .info
= conexant_mux_enum_info
,
512 .get
= conexant_mux_enum_get
,
513 .put
= conexant_mux_enum_put
518 static const char *slave_vols
[] = {
519 "Headphone Playback Volume",
520 "Speaker Playback Volume",
524 static const char *slave_sws
[] = {
525 "Headphone Playback Switch",
526 "Speaker Playback Switch",
530 static int conexant_build_controls(struct hda_codec
*codec
)
532 struct conexant_spec
*spec
= codec
->spec
;
536 for (i
= 0; i
< spec
->num_mixers
; i
++) {
537 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
541 if (spec
->multiout
.dig_out_nid
) {
542 err
= snd_hda_create_spdif_out_ctls(codec
,
543 spec
->multiout
.dig_out_nid
);
546 err
= snd_hda_create_spdif_share_sw(codec
,
550 spec
->multiout
.share_spdif
= 1;
552 if (spec
->dig_in_nid
) {
553 err
= snd_hda_create_spdif_in_ctls(codec
,spec
->dig_in_nid
);
558 /* if we have no master control, let's create it */
559 if (spec
->vmaster_nid
&&
560 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
561 unsigned int vmaster_tlv
[4];
562 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
563 HDA_OUTPUT
, vmaster_tlv
);
564 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
565 vmaster_tlv
, slave_vols
);
569 if (spec
->vmaster_nid
&&
570 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
571 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
577 if (spec
->input_mux
) {
578 err
= snd_hda_add_new_ctls(codec
, cxt_capture_mixers
);
586 static struct hda_codec_ops conexant_patch_ops
= {
587 .build_controls
= conexant_build_controls
,
588 .build_pcms
= conexant_build_pcms
,
589 .init
= conexant_init
,
590 .free
= conexant_free
,
595 * the private value = nid | (invert << 8)
598 #define cxt_eapd_info snd_ctl_boolean_mono_info
600 static int cxt_eapd_get(struct snd_kcontrol
*kcontrol
,
601 struct snd_ctl_elem_value
*ucontrol
)
603 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
604 struct conexant_spec
*spec
= codec
->spec
;
605 int invert
= (kcontrol
->private_value
>> 8) & 1;
607 ucontrol
->value
.integer
.value
[0] = !spec
->cur_eapd
;
609 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
614 static int cxt_eapd_put(struct snd_kcontrol
*kcontrol
,
615 struct snd_ctl_elem_value
*ucontrol
)
617 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
618 struct conexant_spec
*spec
= codec
->spec
;
619 int invert
= (kcontrol
->private_value
>> 8) & 1;
620 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
623 eapd
= !!ucontrol
->value
.integer
.value
[0];
626 if (eapd
== spec
->cur_eapd
)
629 spec
->cur_eapd
= eapd
;
630 snd_hda_codec_write_cache(codec
, nid
,
631 0, AC_VERB_SET_EAPD_BTLENABLE
,
636 /* controls for test mode */
637 #ifdef CONFIG_SND_DEBUG
639 #define CXT_EAPD_SWITCH(xname, nid, mask) \
640 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
641 .info = cxt_eapd_info, \
642 .get = cxt_eapd_get, \
643 .put = cxt_eapd_put, \
644 .private_value = nid | (mask<<16) }
648 static int conexant_ch_mode_info(struct snd_kcontrol
*kcontrol
,
649 struct snd_ctl_elem_info
*uinfo
)
651 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
652 struct conexant_spec
*spec
= codec
->spec
;
653 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
654 spec
->num_channel_mode
);
657 static int conexant_ch_mode_get(struct snd_kcontrol
*kcontrol
,
658 struct snd_ctl_elem_value
*ucontrol
)
660 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
661 struct conexant_spec
*spec
= codec
->spec
;
662 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
663 spec
->num_channel_mode
,
664 spec
->multiout
.max_channels
);
667 static int conexant_ch_mode_put(struct snd_kcontrol
*kcontrol
,
668 struct snd_ctl_elem_value
*ucontrol
)
670 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
671 struct conexant_spec
*spec
= codec
->spec
;
672 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
673 spec
->num_channel_mode
,
674 &spec
->multiout
.max_channels
);
675 if (err
>= 0 && spec
->need_dac_fix
)
676 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
680 #define CXT_PIN_MODE(xname, nid, dir) \
681 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
682 .info = conexant_ch_mode_info, \
683 .get = conexant_ch_mode_get, \
684 .put = conexant_ch_mode_put, \
685 .private_value = nid | (dir<<16) }
687 #endif /* CONFIG_SND_DEBUG */
689 /* Conexant 5045 specific */
691 static hda_nid_t cxt5045_dac_nids
[1] = { 0x19 };
692 static hda_nid_t cxt5045_adc_nids
[1] = { 0x1a };
693 static hda_nid_t cxt5045_capsrc_nids
[1] = { 0x1a };
694 #define CXT5045_SPDIF_OUT 0x18
696 static struct hda_channel_mode cxt5045_modes
[1] = {
700 static struct hda_input_mux cxt5045_capture_source
= {
708 static struct hda_input_mux cxt5045_capture_source_benq
= {
719 static struct hda_input_mux cxt5045_capture_source_hp530
= {
727 /* turn on/off EAPD (+ mute HP) as a master switch */
728 static int cxt5045_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
729 struct snd_ctl_elem_value
*ucontrol
)
731 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
732 struct conexant_spec
*spec
= codec
->spec
;
735 if (!cxt_eapd_put(kcontrol
, ucontrol
))
738 /* toggle internal speakers mute depending of presence of
741 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
742 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
745 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
746 snd_hda_codec_amp_stereo(codec
, 0x11, HDA_OUTPUT
, 0,
751 /* bind volumes of both NID 0x10 and 0x11 */
752 static struct hda_bind_ctls cxt5045_hp_bind_master_vol
= {
753 .ops
= &snd_hda_bind_vol
,
755 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT
),
756 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT
),
761 /* toggle input of built-in and mic jack appropriately */
762 static void cxt5045_hp_automic(struct hda_codec
*codec
)
764 static struct hda_verb mic_jack_on
[] = {
765 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
766 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
769 static struct hda_verb mic_jack_off
[] = {
770 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
771 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
774 unsigned int present
;
776 present
= snd_hda_jack_detect(codec
, 0x12);
778 snd_hda_sequence_write(codec
, mic_jack_on
);
780 snd_hda_sequence_write(codec
, mic_jack_off
);
784 /* mute internal speaker if HP is plugged */
785 static void cxt5045_hp_automute(struct hda_codec
*codec
)
787 struct conexant_spec
*spec
= codec
->spec
;
790 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x11);
792 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
793 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
797 /* unsolicited event for HP jack sensing */
798 static void cxt5045_hp_unsol_event(struct hda_codec
*codec
,
803 case CONEXANT_HP_EVENT
:
804 cxt5045_hp_automute(codec
);
806 case CONEXANT_MIC_EVENT
:
807 cxt5045_hp_automic(codec
);
813 static struct snd_kcontrol_new cxt5045_mixers
[] = {
814 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
815 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
816 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
817 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
818 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
819 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
820 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
821 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
822 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
823 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
824 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
826 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
827 .name
= "Master Playback Switch",
828 .info
= cxt_eapd_info
,
830 .put
= cxt5045_hp_master_sw_put
,
831 .private_value
= 0x10,
837 static struct snd_kcontrol_new cxt5045_benq_mixers
[] = {
838 HDA_CODEC_VOLUME("CD Capture Volume", 0x1a, 0x04, HDA_INPUT
),
839 HDA_CODEC_MUTE("CD Capture Switch", 0x1a, 0x04, HDA_INPUT
),
840 HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x4, HDA_INPUT
),
841 HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x4, HDA_INPUT
),
843 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT
),
844 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT
),
845 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT
),
846 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT
),
848 HDA_CODEC_VOLUME("Mixer Capture Volume", 0x1a, 0x0, HDA_INPUT
),
849 HDA_CODEC_MUTE("Mixer Capture Switch", 0x1a, 0x0, HDA_INPUT
),
854 static struct snd_kcontrol_new cxt5045_mixers_hp530
[] = {
855 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
856 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
857 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
858 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
859 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
860 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
861 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
862 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
863 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
864 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
865 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
867 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
868 .name
= "Master Playback Switch",
869 .info
= cxt_eapd_info
,
871 .put
= cxt5045_hp_master_sw_put
,
872 .private_value
= 0x10,
878 static struct hda_verb cxt5045_init_verbs
[] = {
880 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
881 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
883 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
884 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
885 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
886 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
887 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
888 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
889 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
890 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
891 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
892 /* Record selector: Int mic */
893 {0x1a, AC_VERB_SET_CONNECT_SEL
,0x1},
894 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
895 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
896 /* SPDIF route: PCM */
897 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
898 { 0x13, AC_VERB_SET_CONNECT_SEL
, 0x0 },
900 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2 }, /* default on */
904 static struct hda_verb cxt5045_benq_init_verbs
[] = {
906 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
907 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
908 /* Line In,HP, Amp */
909 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
910 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
911 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
912 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
913 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
914 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
915 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
916 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
917 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
918 /* Record selector: Int mic */
919 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x1},
920 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
921 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
922 /* SPDIF route: PCM */
923 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
924 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0},
926 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
930 static struct hda_verb cxt5045_hp_sense_init_verbs
[] = {
931 /* pin sensing on HP jack */
932 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
936 static struct hda_verb cxt5045_mic_sense_init_verbs
[] = {
937 /* pin sensing on HP jack */
938 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
942 #ifdef CONFIG_SND_DEBUG
943 /* Test configuration for debugging, modelled after the ALC260 test
946 static struct hda_input_mux cxt5045_test_capture_source
= {
951 { "LINE1 pin", 0x2 },
952 { "HP-OUT pin", 0x3 },
957 static struct snd_kcontrol_new cxt5045_test_mixer
[] = {
959 /* Output controls */
960 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
961 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
962 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
963 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
964 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
965 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
967 /* Modes for retasking pin widgets */
968 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT
),
969 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT
),
971 /* EAPD Switch Control */
972 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
974 /* Loopback mixer controls */
976 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT
),
977 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT
),
978 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT
),
979 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT
),
980 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT
),
981 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT
),
982 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT
),
983 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT
),
984 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT
),
985 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT
),
987 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
988 .name
= "Input Source",
989 .info
= conexant_mux_enum_info
,
990 .get
= conexant_mux_enum_get
,
991 .put
= conexant_mux_enum_put
,
993 /* Audio input controls */
994 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT
),
995 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT
),
996 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT
),
997 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT
),
998 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT
),
999 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT
),
1000 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT
),
1001 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT
),
1002 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT
),
1003 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT
),
1007 static struct hda_verb cxt5045_test_init_verbs
[] = {
1008 /* Set connections */
1009 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1010 { 0x11, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1011 { 0x12, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1012 /* Enable retasking pins as output, initially without power amp */
1013 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1014 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1016 /* Disable digital (SPDIF) pins initially, but users can enable
1017 * them via a mixer switch. In the case of SPDIF-out, this initverb
1018 * payload also sets the generation to 0, output to be in "consumer"
1019 * PCM format, copyright asserted, no pre-emphasis and no validity
1022 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1023 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1025 /* Start with output sum widgets muted and their output gains at min */
1026 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1027 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1029 /* Unmute retasking pin widget output buffers since the default
1030 * state appears to be output. As the pin mode is changed by the
1031 * user the pin mode control will take care of enabling the pin's
1032 * input/output buffers as needed.
1034 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1035 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1037 /* Mute capture amp left and right */
1038 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1040 /* Set ADC connection select to match default mixer setting (mic1
1043 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1044 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x00},
1046 /* Mute all inputs to mixer widget (even unconnected ones) */
1047 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* Mixer pin */
1048 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* Mic1 pin */
1049 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* Line pin */
1050 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* HP pin */
1051 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1058 /* initialize jack-sensing, too */
1059 static int cxt5045_init(struct hda_codec
*codec
)
1061 conexant_init(codec
);
1062 cxt5045_hp_automute(codec
);
1068 CXT5045_LAPTOP_HPSENSE
,
1069 CXT5045_LAPTOP_MICSENSE
,
1070 CXT5045_LAPTOP_HPMICSENSE
,
1072 CXT5045_LAPTOP_HP530
,
1073 #ifdef CONFIG_SND_DEBUG
1079 static const char *cxt5045_models
[CXT5045_MODELS
] = {
1080 [CXT5045_LAPTOP_HPSENSE
] = "laptop-hpsense",
1081 [CXT5045_LAPTOP_MICSENSE
] = "laptop-micsense",
1082 [CXT5045_LAPTOP_HPMICSENSE
] = "laptop-hpmicsense",
1083 [CXT5045_BENQ
] = "benq",
1084 [CXT5045_LAPTOP_HP530
] = "laptop-hp530",
1085 #ifdef CONFIG_SND_DEBUG
1086 [CXT5045_TEST
] = "test",
1090 static struct snd_pci_quirk cxt5045_cfg_tbl
[] = {
1091 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530
),
1092 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1093 CXT5045_LAPTOP_HPSENSE
),
1094 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE
),
1095 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ
),
1096 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE
),
1097 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE
),
1098 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
1099 CXT5045_LAPTOP_HPMICSENSE
),
1100 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1101 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1102 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1103 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
1104 CXT5045_LAPTOP_HPMICSENSE
),
1105 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE
),
1109 static int patch_cxt5045(struct hda_codec
*codec
)
1111 struct conexant_spec
*spec
;
1114 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1118 codec
->pin_amp_workaround
= 1;
1120 spec
->multiout
.max_channels
= 2;
1121 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5045_dac_nids
);
1122 spec
->multiout
.dac_nids
= cxt5045_dac_nids
;
1123 spec
->multiout
.dig_out_nid
= CXT5045_SPDIF_OUT
;
1124 spec
->num_adc_nids
= 1;
1125 spec
->adc_nids
= cxt5045_adc_nids
;
1126 spec
->capsrc_nids
= cxt5045_capsrc_nids
;
1127 spec
->input_mux
= &cxt5045_capture_source
;
1128 spec
->num_mixers
= 1;
1129 spec
->mixers
[0] = cxt5045_mixers
;
1130 spec
->num_init_verbs
= 1;
1131 spec
->init_verbs
[0] = cxt5045_init_verbs
;
1132 spec
->spdif_route
= 0;
1133 spec
->num_channel_mode
= ARRAY_SIZE(cxt5045_modes
),
1134 spec
->channel_mode
= cxt5045_modes
,
1137 codec
->patch_ops
= conexant_patch_ops
;
1139 board_config
= snd_hda_check_board_config(codec
, CXT5045_MODELS
,
1142 switch (board_config
) {
1143 case CXT5045_LAPTOP_HPSENSE
:
1144 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1145 spec
->input_mux
= &cxt5045_capture_source
;
1146 spec
->num_init_verbs
= 2;
1147 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1148 spec
->mixers
[0] = cxt5045_mixers
;
1149 codec
->patch_ops
.init
= cxt5045_init
;
1151 case CXT5045_LAPTOP_MICSENSE
:
1152 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1153 spec
->input_mux
= &cxt5045_capture_source
;
1154 spec
->num_init_verbs
= 2;
1155 spec
->init_verbs
[1] = cxt5045_mic_sense_init_verbs
;
1156 spec
->mixers
[0] = cxt5045_mixers
;
1157 codec
->patch_ops
.init
= cxt5045_init
;
1160 case CXT5045_LAPTOP_HPMICSENSE
:
1161 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1162 spec
->input_mux
= &cxt5045_capture_source
;
1163 spec
->num_init_verbs
= 3;
1164 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1165 spec
->init_verbs
[2] = cxt5045_mic_sense_init_verbs
;
1166 spec
->mixers
[0] = cxt5045_mixers
;
1167 codec
->patch_ops
.init
= cxt5045_init
;
1170 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1171 spec
->input_mux
= &cxt5045_capture_source_benq
;
1172 spec
->num_init_verbs
= 1;
1173 spec
->init_verbs
[0] = cxt5045_benq_init_verbs
;
1174 spec
->mixers
[0] = cxt5045_mixers
;
1175 spec
->mixers
[1] = cxt5045_benq_mixers
;
1176 spec
->num_mixers
= 2;
1177 codec
->patch_ops
.init
= cxt5045_init
;
1179 case CXT5045_LAPTOP_HP530
:
1180 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1181 spec
->input_mux
= &cxt5045_capture_source_hp530
;
1182 spec
->num_init_verbs
= 2;
1183 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1184 spec
->mixers
[0] = cxt5045_mixers_hp530
;
1185 codec
->patch_ops
.init
= cxt5045_init
;
1187 #ifdef CONFIG_SND_DEBUG
1189 spec
->input_mux
= &cxt5045_test_capture_source
;
1190 spec
->mixers
[0] = cxt5045_test_mixer
;
1191 spec
->init_verbs
[0] = cxt5045_test_init_verbs
;
1197 switch (codec
->subsystem_id
>> 16) {
1202 /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have
1203 * really bad sound over 0dB on NID 0x17. Fix max PCM level to
1204 * 0 dB (originally it has 0x2b steps with 0dB offset 0x14)
1206 snd_hda_override_amp_caps(codec
, 0x17, HDA_INPUT
,
1207 (0x14 << AC_AMPCAP_OFFSET_SHIFT
) |
1208 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1209 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1210 (1 << AC_AMPCAP_MUTE_SHIFT
));
1218 /* Conexant 5047 specific */
1219 #define CXT5047_SPDIF_OUT 0x11
1221 static hda_nid_t cxt5047_dac_nids
[1] = { 0x10 }; /* 0x1c */
1222 static hda_nid_t cxt5047_adc_nids
[1] = { 0x12 };
1223 static hda_nid_t cxt5047_capsrc_nids
[1] = { 0x1a };
1225 static struct hda_channel_mode cxt5047_modes
[1] = {
1229 static struct hda_input_mux cxt5047_toshiba_capture_source
= {
1237 /* turn on/off EAPD (+ mute HP) as a master switch */
1238 static int cxt5047_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1239 struct snd_ctl_elem_value
*ucontrol
)
1241 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1242 struct conexant_spec
*spec
= codec
->spec
;
1245 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1248 /* toggle internal speakers mute depending of presence of
1249 * the headphone jack
1251 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
1252 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1253 * pin widgets unlike other codecs. In this case, we need to
1254 * set index 0x01 for the volume from the mixer amp 0x19.
1256 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1257 HDA_AMP_MUTE
, bits
);
1258 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
1259 snd_hda_codec_amp_stereo(codec
, 0x13, HDA_OUTPUT
, 0,
1260 HDA_AMP_MUTE
, bits
);
1264 /* mute internal speaker if HP is plugged */
1265 static void cxt5047_hp_automute(struct hda_codec
*codec
)
1267 struct conexant_spec
*spec
= codec
->spec
;
1270 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x13);
1272 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
1273 /* See the note in cxt5047_hp_master_sw_put */
1274 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1275 HDA_AMP_MUTE
, bits
);
1278 /* toggle input of built-in and mic jack appropriately */
1279 static void cxt5047_hp_automic(struct hda_codec
*codec
)
1281 static struct hda_verb mic_jack_on
[] = {
1282 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1283 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1286 static struct hda_verb mic_jack_off
[] = {
1287 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1288 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1291 unsigned int present
;
1293 present
= snd_hda_jack_detect(codec
, 0x15);
1295 snd_hda_sequence_write(codec
, mic_jack_on
);
1297 snd_hda_sequence_write(codec
, mic_jack_off
);
1300 /* unsolicited event for HP jack sensing */
1301 static void cxt5047_hp_unsol_event(struct hda_codec
*codec
,
1304 switch (res
>> 26) {
1305 case CONEXANT_HP_EVENT
:
1306 cxt5047_hp_automute(codec
);
1308 case CONEXANT_MIC_EVENT
:
1309 cxt5047_hp_automic(codec
);
1314 static struct snd_kcontrol_new cxt5047_base_mixers
[] = {
1315 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT
),
1316 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT
),
1317 HDA_CODEC_VOLUME("Mic Boost", 0x1a, 0x0, HDA_OUTPUT
),
1318 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT
),
1319 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT
),
1320 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT
),
1321 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT
),
1323 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1324 .name
= "Master Playback Switch",
1325 .info
= cxt_eapd_info
,
1326 .get
= cxt_eapd_get
,
1327 .put
= cxt5047_hp_master_sw_put
,
1328 .private_value
= 0x13,
1334 static struct snd_kcontrol_new cxt5047_hp_spk_mixers
[] = {
1335 /* See the note in cxt5047_hp_master_sw_put */
1336 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT
),
1337 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1341 static struct snd_kcontrol_new cxt5047_hp_only_mixers
[] = {
1342 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1346 static struct hda_verb cxt5047_init_verbs
[] = {
1347 /* Line in, Mic, Built-in Mic */
1348 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1349 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1350 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1352 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1353 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* mixer(0x19) */
1354 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mixer(0x19) */
1355 /* Record selector: Mic */
1356 {0x12, AC_VERB_SET_CONNECT_SEL
,0x03},
1357 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
,
1358 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
1359 {0x1A, AC_VERB_SET_CONNECT_SEL
,0x02},
1360 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1361 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x00},
1362 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1363 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x03},
1364 /* SPDIF route: PCM */
1365 { 0x18, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1366 /* Enable unsolicited events */
1367 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
1368 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1372 /* configuration for Toshiba Laptops */
1373 static struct hda_verb cxt5047_toshiba_init_verbs
[] = {
1374 {0x13, AC_VERB_SET_EAPD_BTLENABLE
, 0x0}, /* default off */
1378 /* Test configuration for debugging, modelled after the ALC260 test
1381 #ifdef CONFIG_SND_DEBUG
1382 static struct hda_input_mux cxt5047_test_capture_source
= {
1385 { "LINE1 pin", 0x0 },
1386 { "MIC1 pin", 0x1 },
1387 { "MIC2 pin", 0x2 },
1392 static struct snd_kcontrol_new cxt5047_test_mixer
[] = {
1394 /* Output only controls */
1395 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT
),
1396 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT
),
1397 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT
),
1398 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT
),
1399 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1400 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1401 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1402 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1403 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT
),
1404 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT
),
1405 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
1406 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
1408 /* Modes for retasking pin widgets */
1409 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT
),
1410 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT
),
1412 /* EAPD Switch Control */
1413 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1415 /* Loopback mixer controls */
1416 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT
),
1417 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT
),
1418 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT
),
1419 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT
),
1420 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT
),
1421 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT
),
1422 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT
),
1423 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT
),
1425 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT
),
1426 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT
),
1427 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT
),
1428 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT
),
1429 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT
),
1430 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT
),
1431 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT
),
1432 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT
),
1434 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1435 .name
= "Input Source",
1436 .info
= conexant_mux_enum_info
,
1437 .get
= conexant_mux_enum_get
,
1438 .put
= conexant_mux_enum_put
,
1440 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1445 static struct hda_verb cxt5047_test_init_verbs
[] = {
1446 /* Enable retasking pins as output, initially without power amp */
1447 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1448 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1449 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1451 /* Disable digital (SPDIF) pins initially, but users can enable
1452 * them via a mixer switch. In the case of SPDIF-out, this initverb
1453 * payload also sets the generation to 0, output to be in "consumer"
1454 * PCM format, copyright asserted, no pre-emphasis and no validity
1457 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1459 /* Ensure mic1, mic2, line1 pin widgets take input from the
1460 * OUT1 sum bus when acting as an output.
1462 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0},
1463 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0},
1465 /* Start with output sum widgets muted and their output gains at min */
1466 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1467 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1469 /* Unmute retasking pin widget output buffers since the default
1470 * state appears to be output. As the pin mode is changed by the
1471 * user the pin mode control will take care of enabling the pin's
1472 * input/output buffers as needed.
1474 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1475 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1476 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1478 /* Mute capture amp left and right */
1479 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1481 /* Set ADC connection select to match default mixer setting (mic1
1484 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x00},
1486 /* Mute all inputs to mixer widget (even unconnected ones) */
1487 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* mic1 pin */
1488 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* mic2 pin */
1489 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* line1 pin */
1490 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* line2 pin */
1491 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1492 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1493 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)}, /* Line-out pin */
1494 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)}, /* HP-pin pin */
1501 /* initialize jack-sensing, too */
1502 static int cxt5047_hp_init(struct hda_codec
*codec
)
1504 conexant_init(codec
);
1505 cxt5047_hp_automute(codec
);
1511 CXT5047_LAPTOP
, /* Laptops w/o EAPD support */
1512 CXT5047_LAPTOP_HP
, /* Some HP laptops */
1513 CXT5047_LAPTOP_EAPD
, /* Laptops with EAPD support */
1514 #ifdef CONFIG_SND_DEBUG
1520 static const char *cxt5047_models
[CXT5047_MODELS
] = {
1521 [CXT5047_LAPTOP
] = "laptop",
1522 [CXT5047_LAPTOP_HP
] = "laptop-hp",
1523 [CXT5047_LAPTOP_EAPD
] = "laptop-eapd",
1524 #ifdef CONFIG_SND_DEBUG
1525 [CXT5047_TEST
] = "test",
1529 static struct snd_pci_quirk cxt5047_cfg_tbl
[] = {
1530 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP
),
1531 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1533 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD
),
1537 static int patch_cxt5047(struct hda_codec
*codec
)
1539 struct conexant_spec
*spec
;
1542 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1546 codec
->pin_amp_workaround
= 1;
1548 spec
->multiout
.max_channels
= 2;
1549 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5047_dac_nids
);
1550 spec
->multiout
.dac_nids
= cxt5047_dac_nids
;
1551 spec
->multiout
.dig_out_nid
= CXT5047_SPDIF_OUT
;
1552 spec
->num_adc_nids
= 1;
1553 spec
->adc_nids
= cxt5047_adc_nids
;
1554 spec
->capsrc_nids
= cxt5047_capsrc_nids
;
1555 spec
->num_mixers
= 1;
1556 spec
->mixers
[0] = cxt5047_base_mixers
;
1557 spec
->num_init_verbs
= 1;
1558 spec
->init_verbs
[0] = cxt5047_init_verbs
;
1559 spec
->spdif_route
= 0;
1560 spec
->num_channel_mode
= ARRAY_SIZE(cxt5047_modes
),
1561 spec
->channel_mode
= cxt5047_modes
,
1563 codec
->patch_ops
= conexant_patch_ops
;
1565 board_config
= snd_hda_check_board_config(codec
, CXT5047_MODELS
,
1568 switch (board_config
) {
1569 case CXT5047_LAPTOP
:
1570 spec
->num_mixers
= 2;
1571 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1572 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1574 case CXT5047_LAPTOP_HP
:
1575 spec
->num_mixers
= 2;
1576 spec
->mixers
[1] = cxt5047_hp_only_mixers
;
1577 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1578 codec
->patch_ops
.init
= cxt5047_hp_init
;
1580 case CXT5047_LAPTOP_EAPD
:
1581 spec
->input_mux
= &cxt5047_toshiba_capture_source
;
1582 spec
->num_mixers
= 2;
1583 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1584 spec
->num_init_verbs
= 2;
1585 spec
->init_verbs
[1] = cxt5047_toshiba_init_verbs
;
1586 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1588 #ifdef CONFIG_SND_DEBUG
1590 spec
->input_mux
= &cxt5047_test_capture_source
;
1591 spec
->mixers
[0] = cxt5047_test_mixer
;
1592 spec
->init_verbs
[0] = cxt5047_test_init_verbs
;
1593 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1596 spec
->vmaster_nid
= 0x13;
1598 switch (codec
->subsystem_id
>> 16) {
1600 /* HP laptops have really bad sound over 0 dB on NID 0x10.
1601 * Fix max PCM level to 0 dB (originally it has 0x1e steps
1602 * with 0 dB offset 0x17)
1604 snd_hda_override_amp_caps(codec
, 0x10, HDA_INPUT
,
1605 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
1606 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1607 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1608 (1 << AC_AMPCAP_MUTE_SHIFT
));
1615 /* Conexant 5051 specific */
1616 static hda_nid_t cxt5051_dac_nids
[1] = { 0x10 };
1617 static hda_nid_t cxt5051_adc_nids
[2] = { 0x14, 0x15 };
1619 static struct hda_channel_mode cxt5051_modes
[1] = {
1623 static void cxt5051_update_speaker(struct hda_codec
*codec
)
1625 struct conexant_spec
*spec
= codec
->spec
;
1626 unsigned int pinctl
;
1628 pinctl
= (spec
->hp_present
&& spec
->cur_eapd
) ? PIN_HP
: 0;
1629 snd_hda_codec_write(codec
, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1632 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1633 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1637 /* turn on/off EAPD (+ mute HP) as a master switch */
1638 static int cxt5051_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1639 struct snd_ctl_elem_value
*ucontrol
)
1641 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1643 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1645 cxt5051_update_speaker(codec
);
1649 /* toggle input of built-in and mic jack appropriately */
1650 static void cxt5051_portb_automic(struct hda_codec
*codec
)
1652 struct conexant_spec
*spec
= codec
->spec
;
1653 unsigned int present
;
1655 if (!(spec
->auto_mic
& AUTO_MIC_PORTB
))
1657 present
= snd_hda_jack_detect(codec
, 0x17);
1658 snd_hda_codec_write(codec
, 0x14, 0,
1659 AC_VERB_SET_CONNECT_SEL
,
1660 present
? 0x01 : 0x00);
1663 /* switch the current ADC according to the jack state */
1664 static void cxt5051_portc_automic(struct hda_codec
*codec
)
1666 struct conexant_spec
*spec
= codec
->spec
;
1667 unsigned int present
;
1670 if (!(spec
->auto_mic
& AUTO_MIC_PORTC
))
1672 present
= snd_hda_jack_detect(codec
, 0x18);
1674 spec
->cur_adc_idx
= 1;
1676 spec
->cur_adc_idx
= 0;
1677 new_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
1678 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
1679 /* stream is running, let's swap the current ADC */
1680 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
1681 spec
->cur_adc
= new_adc
;
1682 snd_hda_codec_setup_stream(codec
, new_adc
,
1683 spec
->cur_adc_stream_tag
, 0,
1684 spec
->cur_adc_format
);
1688 /* mute internal speaker if HP is plugged */
1689 static void cxt5051_hp_automute(struct hda_codec
*codec
)
1691 struct conexant_spec
*spec
= codec
->spec
;
1693 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x16);
1694 cxt5051_update_speaker(codec
);
1697 /* unsolicited event for HP jack sensing */
1698 static void cxt5051_hp_unsol_event(struct hda_codec
*codec
,
1701 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
1702 switch (res
>> 26) {
1703 case CONEXANT_HP_EVENT
:
1704 cxt5051_hp_automute(codec
);
1706 case CXT5051_PORTB_EVENT
:
1707 cxt5051_portb_automic(codec
);
1709 case CXT5051_PORTC_EVENT
:
1710 cxt5051_portc_automic(codec
);
1713 conexant_report_jack(codec
, nid
);
1716 static struct snd_kcontrol_new cxt5051_playback_mixers
[] = {
1717 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1719 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1720 .name
= "Master Playback Switch",
1721 .info
= cxt_eapd_info
,
1722 .get
= cxt_eapd_get
,
1723 .put
= cxt5051_hp_master_sw_put
,
1724 .private_value
= 0x1a,
1729 static struct snd_kcontrol_new cxt5051_capture_mixers
[] = {
1730 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1731 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1732 HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT
),
1733 HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT
),
1734 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT
),
1735 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT
),
1739 static struct snd_kcontrol_new cxt5051_hp_mixers
[] = {
1740 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1741 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1742 HDA_CODEC_VOLUME("External Mic Volume", 0x15, 0x00, HDA_INPUT
),
1743 HDA_CODEC_MUTE("External Mic Switch", 0x15, 0x00, HDA_INPUT
),
1747 static struct snd_kcontrol_new cxt5051_hp_dv6736_mixers
[] = {
1748 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT
),
1749 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT
),
1753 static struct snd_kcontrol_new cxt5051_f700_mixers
[] = {
1754 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT
),
1755 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT
),
1759 static struct snd_kcontrol_new cxt5051_toshiba_mixers
[] = {
1760 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1761 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1762 HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT
),
1763 HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT
),
1767 static struct hda_verb cxt5051_init_verbs
[] = {
1769 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1770 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1771 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1772 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1773 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1774 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1776 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1777 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1779 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1780 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1782 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1783 /* Record selector: Int mic */
1784 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1785 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1786 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1787 /* SPDIF route: PCM */
1788 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1789 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1791 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1792 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1796 static struct hda_verb cxt5051_hp_dv6736_init_verbs
[] = {
1798 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1799 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1800 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1801 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1803 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1804 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1806 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1807 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1809 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1810 /* Record selector: Int mic */
1811 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1812 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1813 /* SPDIF route: PCM */
1814 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1816 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1817 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1821 static struct hda_verb cxt5051_lenovo_x200_init_verbs
[] = {
1823 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1824 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1825 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1826 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1827 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1828 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1830 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1831 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1833 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1834 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1836 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1837 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00},
1839 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1840 /* Record selector: Int mic */
1841 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1842 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1843 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1844 /* SPDIF route: PCM */
1845 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
}, /* needed for W500 Advanced Mini Dock 250410 */
1846 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1848 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1849 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1850 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1854 static struct hda_verb cxt5051_f700_init_verbs
[] = {
1856 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1857 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1858 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1859 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1861 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1862 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1864 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1865 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1867 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1868 /* Record selector: Int mic */
1869 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1870 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1871 /* SPDIF route: PCM */
1872 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1874 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1875 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1879 static void cxt5051_init_mic_port(struct hda_codec
*codec
, hda_nid_t nid
,
1882 snd_hda_codec_write(codec
, nid
, 0,
1883 AC_VERB_SET_UNSOLICITED_ENABLE
,
1884 AC_USRSP_EN
| event
);
1885 #ifdef CONFIG_SND_HDA_INPUT_JACK
1886 conexant_add_jack(codec
, nid
, SND_JACK_MICROPHONE
);
1887 conexant_report_jack(codec
, nid
);
1891 /* initialize jack-sensing, too */
1892 static int cxt5051_init(struct hda_codec
*codec
)
1894 struct conexant_spec
*spec
= codec
->spec
;
1896 conexant_init(codec
);
1897 conexant_init_jacks(codec
);
1899 if (spec
->auto_mic
& AUTO_MIC_PORTB
)
1900 cxt5051_init_mic_port(codec
, 0x17, CXT5051_PORTB_EVENT
);
1901 if (spec
->auto_mic
& AUTO_MIC_PORTC
)
1902 cxt5051_init_mic_port(codec
, 0x18, CXT5051_PORTC_EVENT
);
1904 if (codec
->patch_ops
.unsol_event
) {
1905 cxt5051_hp_automute(codec
);
1906 cxt5051_portb_automic(codec
);
1907 cxt5051_portc_automic(codec
);
1914 CXT5051_LAPTOP
, /* Laptops w/ EAPD support */
1915 CXT5051_HP
, /* no docking */
1916 CXT5051_HP_DV6736
, /* HP without mic switch */
1917 CXT5051_LENOVO_X200
, /* Lenovo X200 laptop, also used for Advanced Mini Dock 250410 */
1918 CXT5051_F700
, /* HP Compaq Presario F700 */
1919 CXT5051_TOSHIBA
, /* Toshiba M300 & co */
1923 static const char *cxt5051_models
[CXT5051_MODELS
] = {
1924 [CXT5051_LAPTOP
] = "laptop",
1925 [CXT5051_HP
] = "hp",
1926 [CXT5051_HP_DV6736
] = "hp-dv6736",
1927 [CXT5051_LENOVO_X200
] = "lenovo-x200",
1928 [CXT5051_F700
] = "hp-700",
1929 [CXT5051_TOSHIBA
] = "toshiba",
1932 static struct snd_pci_quirk cxt5051_cfg_tbl
[] = {
1933 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736
),
1934 SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP
),
1935 SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700
),
1936 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA
),
1937 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1939 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP
),
1940 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200
),
1944 static int patch_cxt5051(struct hda_codec
*codec
)
1946 struct conexant_spec
*spec
;
1949 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1953 codec
->pin_amp_workaround
= 1;
1955 codec
->patch_ops
= conexant_patch_ops
;
1956 codec
->patch_ops
.init
= cxt5051_init
;
1958 spec
->multiout
.max_channels
= 2;
1959 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5051_dac_nids
);
1960 spec
->multiout
.dac_nids
= cxt5051_dac_nids
;
1961 spec
->multiout
.dig_out_nid
= CXT5051_SPDIF_OUT
;
1962 spec
->num_adc_nids
= 1; /* not 2; via auto-mic switch */
1963 spec
->adc_nids
= cxt5051_adc_nids
;
1964 spec
->num_mixers
= 2;
1965 spec
->mixers
[0] = cxt5051_capture_mixers
;
1966 spec
->mixers
[1] = cxt5051_playback_mixers
;
1967 spec
->num_init_verbs
= 1;
1968 spec
->init_verbs
[0] = cxt5051_init_verbs
;
1969 spec
->spdif_route
= 0;
1970 spec
->num_channel_mode
= ARRAY_SIZE(cxt5051_modes
);
1971 spec
->channel_mode
= cxt5051_modes
;
1973 spec
->cur_adc_idx
= 0;
1975 codec
->patch_ops
.unsol_event
= cxt5051_hp_unsol_event
;
1977 board_config
= snd_hda_check_board_config(codec
, CXT5051_MODELS
,
1980 spec
->auto_mic
= AUTO_MIC_PORTB
| AUTO_MIC_PORTC
;
1981 switch (board_config
) {
1983 spec
->mixers
[0] = cxt5051_hp_mixers
;
1985 case CXT5051_HP_DV6736
:
1986 spec
->init_verbs
[0] = cxt5051_hp_dv6736_init_verbs
;
1987 spec
->mixers
[0] = cxt5051_hp_dv6736_mixers
;
1990 case CXT5051_LENOVO_X200
:
1991 spec
->init_verbs
[0] = cxt5051_lenovo_x200_init_verbs
;
1994 spec
->init_verbs
[0] = cxt5051_f700_init_verbs
;
1995 spec
->mixers
[0] = cxt5051_f700_mixers
;
1998 case CXT5051_TOSHIBA
:
1999 spec
->mixers
[0] = cxt5051_toshiba_mixers
;
2000 spec
->auto_mic
= AUTO_MIC_PORTB
;
2007 /* Conexant 5066 specific */
2009 static hda_nid_t cxt5066_dac_nids
[1] = { 0x10 };
2010 static hda_nid_t cxt5066_adc_nids
[3] = { 0x14, 0x15, 0x16 };
2011 static hda_nid_t cxt5066_capsrc_nids
[1] = { 0x17 };
2012 #define CXT5066_SPDIF_OUT 0x21
2014 /* OLPC's microphone port is DC coupled for use with external sensors,
2015 * therefore we use a 50% mic bias in order to center the input signal with
2016 * the DC input range of the codec. */
2017 #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50
2019 static struct hda_channel_mode cxt5066_modes
[1] = {
2023 static void cxt5066_update_speaker(struct hda_codec
*codec
)
2025 struct conexant_spec
*spec
= codec
->spec
;
2026 unsigned int pinctl
;
2028 snd_printdd("CXT5066: update speaker, hp_present=%d\n",
2032 pinctl
= ((spec
->hp_present
& 1) && spec
->cur_eapd
) ? PIN_HP
: 0;
2033 snd_hda_codec_write(codec
, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2036 /* Port D (HP/LO) */
2037 pinctl
= ((spec
->hp_present
& 2) && spec
->cur_eapd
)
2038 ? spec
->port_d_mode
: 0;
2039 /* Mute if Port A is connected on Thinkpad */
2040 if (spec
->thinkpad
&& (spec
->hp_present
& 1))
2042 snd_hda_codec_write(codec
, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2046 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
2047 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2050 if (spec
->dell_automute
) {
2051 /* DELL AIO Port Rule: PortA > PortD > IntSpk */
2052 pinctl
= (!(spec
->hp_present
& 1) && spec
->cur_eapd
)
2054 snd_hda_codec_write(codec
, 0x1c, 0,
2055 AC_VERB_SET_PIN_WIDGET_CONTROL
, pinctl
);
2059 /* turn on/off EAPD (+ mute HP) as a master switch */
2060 static int cxt5066_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
2061 struct snd_ctl_elem_value
*ucontrol
)
2063 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2065 if (!cxt_eapd_put(kcontrol
, ucontrol
))
2068 cxt5066_update_speaker(codec
);
2072 static const struct hda_input_mux cxt5066_olpc_dc_bias
= {
2076 { "50%", PIN_VREF50
},
2077 { "80%", PIN_VREF80
},
2081 static int cxt5066_set_olpc_dc_bias(struct hda_codec
*codec
)
2083 struct conexant_spec
*spec
= codec
->spec
;
2084 /* Even though port F is the DC input, the bias is controlled on port B.
2085 * we also leave that port as an active input (but unselected) in DC mode
2086 * just in case that is necessary to make the bias setting take effect. */
2087 return snd_hda_codec_write_cache(codec
, 0x1a, 0,
2088 AC_VERB_SET_PIN_WIDGET_CONTROL
,
2089 cxt5066_olpc_dc_bias
.items
[spec
->dc_input_bias
].index
);
2092 /* OLPC defers mic widget control until when capture is started because the
2093 * microphone LED comes on as soon as these settings are put in place. if we
2094 * did this before recording, it would give the false indication that recording
2095 * is happening when it is not. */
2096 static void cxt5066_olpc_select_mic(struct hda_codec
*codec
)
2098 struct conexant_spec
*spec
= codec
->spec
;
2099 if (!spec
->recording
)
2102 if (spec
->dc_enable
) {
2103 /* in DC mode we ignore presence detection and just use the jack
2104 * through our special DC port */
2105 const struct hda_verb enable_dc_mode
[] = {
2106 /* disble internal mic, port C */
2107 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2109 /* enable DC capture, port F */
2110 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2114 snd_hda_sequence_write(codec
, enable_dc_mode
);
2115 /* port B input disabled (and bias set) through the following call */
2116 cxt5066_set_olpc_dc_bias(codec
);
2120 /* disable DC (port F) */
2121 snd_hda_codec_write(codec
, 0x1e, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0);
2123 /* external mic, port B */
2124 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2125 spec
->ext_mic_present
? CXT5066_OLPC_EXT_MIC_BIAS
: 0);
2127 /* internal mic, port C */
2128 snd_hda_codec_write(codec
, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2129 spec
->ext_mic_present
? 0 : PIN_VREF80
);
2132 /* toggle input of built-in and mic jack appropriately */
2133 static void cxt5066_olpc_automic(struct hda_codec
*codec
)
2135 struct conexant_spec
*spec
= codec
->spec
;
2136 unsigned int present
;
2138 if (spec
->dc_enable
) /* don't do presence detection in DC mode */
2141 present
= snd_hda_codec_read(codec
, 0x1a, 0,
2142 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
2144 snd_printdd("CXT5066: external microphone detected\n");
2146 snd_printdd("CXT5066: external microphone absent\n");
2148 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2150 spec
->ext_mic_present
= !!present
;
2152 cxt5066_olpc_select_mic(codec
);
2155 /* toggle input of built-in digital mic and mic jack appropriately */
2156 static void cxt5066_vostro_automic(struct hda_codec
*codec
)
2158 unsigned int present
;
2160 struct hda_verb ext_mic_present
[] = {
2161 /* enable external mic, port B */
2162 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2164 /* switch to external mic input */
2165 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2166 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2168 /* disable internal digital mic */
2169 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2172 static struct hda_verb ext_mic_absent
[] = {
2173 /* enable internal mic, port C */
2174 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2176 /* switch to internal mic input */
2177 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2179 /* disable external mic, port B */
2180 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2184 present
= snd_hda_jack_detect(codec
, 0x1a);
2186 snd_printdd("CXT5066: external microphone detected\n");
2187 snd_hda_sequence_write(codec
, ext_mic_present
);
2189 snd_printdd("CXT5066: external microphone absent\n");
2190 snd_hda_sequence_write(codec
, ext_mic_absent
);
2194 /* toggle input of built-in digital mic and mic jack appropriately */
2195 static void cxt5066_ideapad_automic(struct hda_codec
*codec
)
2197 unsigned int present
;
2199 struct hda_verb ext_mic_present
[] = {
2200 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2201 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2202 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2205 static struct hda_verb ext_mic_absent
[] = {
2206 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2207 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2208 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2212 present
= snd_hda_jack_detect(codec
, 0x1b);
2214 snd_printdd("CXT5066: external microphone detected\n");
2215 snd_hda_sequence_write(codec
, ext_mic_present
);
2217 snd_printdd("CXT5066: external microphone absent\n");
2218 snd_hda_sequence_write(codec
, ext_mic_absent
);
2222 /* toggle input of built-in digital mic and mic jack appropriately
2223 order is: external mic -> dock mic -> interal mic */
2224 static void cxt5066_thinkpad_automic(struct hda_codec
*codec
)
2226 unsigned int ext_present
, dock_present
;
2228 static struct hda_verb ext_mic_present
[] = {
2229 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2230 {0x17, AC_VERB_SET_CONNECT_SEL
, 1},
2231 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2232 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2233 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2236 static struct hda_verb dock_mic_present
[] = {
2237 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2238 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2239 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2240 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2241 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2244 static struct hda_verb ext_mic_absent
[] = {
2245 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2246 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2247 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2248 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2252 ext_present
= snd_hda_jack_detect(codec
, 0x1b);
2253 dock_present
= snd_hda_jack_detect(codec
, 0x1a);
2255 snd_printdd("CXT5066: external microphone detected\n");
2256 snd_hda_sequence_write(codec
, ext_mic_present
);
2257 } else if (dock_present
) {
2258 snd_printdd("CXT5066: dock microphone detected\n");
2259 snd_hda_sequence_write(codec
, dock_mic_present
);
2261 snd_printdd("CXT5066: external microphone absent\n");
2262 snd_hda_sequence_write(codec
, ext_mic_absent
);
2266 /* mute internal speaker if HP is plugged */
2267 static void cxt5066_hp_automute(struct hda_codec
*codec
)
2269 struct conexant_spec
*spec
= codec
->spec
;
2270 unsigned int portA
, portD
;
2273 portA
= snd_hda_jack_detect(codec
, 0x19);
2276 portD
= snd_hda_jack_detect(codec
, 0x1c);
2278 spec
->hp_present
= !!(portA
);
2279 spec
->hp_present
|= portD
? 2 : 0;
2280 snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
2281 portA
, portD
, spec
->hp_present
);
2282 cxt5066_update_speaker(codec
);
2285 /* unsolicited event for jack sensing */
2286 static void cxt5066_olpc_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2288 struct conexant_spec
*spec
= codec
->spec
;
2289 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2290 switch (res
>> 26) {
2291 case CONEXANT_HP_EVENT
:
2292 cxt5066_hp_automute(codec
);
2294 case CONEXANT_MIC_EVENT
:
2295 /* ignore mic events in DC mode; we're always using the jack */
2296 if (!spec
->dc_enable
)
2297 cxt5066_olpc_automic(codec
);
2302 /* unsolicited event for jack sensing */
2303 static void cxt5066_vostro_event(struct hda_codec
*codec
, unsigned int res
)
2305 snd_printdd("CXT5066_vostro: unsol event %x (%x)\n", res
, res
>> 26);
2306 switch (res
>> 26) {
2307 case CONEXANT_HP_EVENT
:
2308 cxt5066_hp_automute(codec
);
2310 case CONEXANT_MIC_EVENT
:
2311 cxt5066_vostro_automic(codec
);
2316 /* unsolicited event for jack sensing */
2317 static void cxt5066_ideapad_event(struct hda_codec
*codec
, unsigned int res
)
2319 snd_printdd("CXT5066_ideapad: unsol event %x (%x)\n", res
, res
>> 26);
2320 switch (res
>> 26) {
2321 case CONEXANT_HP_EVENT
:
2322 cxt5066_hp_automute(codec
);
2324 case CONEXANT_MIC_EVENT
:
2325 cxt5066_ideapad_automic(codec
);
2330 /* unsolicited event for jack sensing */
2331 static void cxt5066_thinkpad_event(struct hda_codec
*codec
, unsigned int res
)
2333 snd_printdd("CXT5066_thinkpad: unsol event %x (%x)\n", res
, res
>> 26);
2334 switch (res
>> 26) {
2335 case CONEXANT_HP_EVENT
:
2336 cxt5066_hp_automute(codec
);
2338 case CONEXANT_MIC_EVENT
:
2339 cxt5066_thinkpad_automic(codec
);
2344 static const struct hda_input_mux cxt5066_analog_mic_boost
= {
2355 static void cxt5066_set_mic_boost(struct hda_codec
*codec
)
2357 struct conexant_spec
*spec
= codec
->spec
;
2358 snd_hda_codec_write_cache(codec
, 0x17, 0,
2359 AC_VERB_SET_AMP_GAIN_MUTE
,
2360 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_OUTPUT
|
2361 cxt5066_analog_mic_boost
.items
[spec
->mic_boost
].index
);
2362 if (spec
->ideapad
|| spec
->thinkpad
) {
2363 /* adjust the internal mic as well...it is not through 0x17 */
2364 snd_hda_codec_write_cache(codec
, 0x23, 0,
2365 AC_VERB_SET_AMP_GAIN_MUTE
,
2366 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_INPUT
|
2367 cxt5066_analog_mic_boost
.
2368 items
[spec
->mic_boost
].index
);
2372 static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol
*kcontrol
,
2373 struct snd_ctl_elem_info
*uinfo
)
2375 return snd_hda_input_mux_info(&cxt5066_analog_mic_boost
, uinfo
);
2378 static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol
*kcontrol
,
2379 struct snd_ctl_elem_value
*ucontrol
)
2381 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2382 struct conexant_spec
*spec
= codec
->spec
;
2383 ucontrol
->value
.enumerated
.item
[0] = spec
->mic_boost
;
2387 static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol
*kcontrol
,
2388 struct snd_ctl_elem_value
*ucontrol
)
2390 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2391 struct conexant_spec
*spec
= codec
->spec
;
2392 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2394 idx
= ucontrol
->value
.enumerated
.item
[0];
2395 if (idx
>= imux
->num_items
)
2396 idx
= imux
->num_items
- 1;
2398 spec
->mic_boost
= idx
;
2399 if (!spec
->dc_enable
)
2400 cxt5066_set_mic_boost(codec
);
2404 static void cxt5066_enable_dc(struct hda_codec
*codec
)
2406 const struct hda_verb enable_dc_mode
[] = {
2408 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2410 /* switch to DC input */
2411 {0x17, AC_VERB_SET_CONNECT_SEL
, 3},
2415 /* configure as input source */
2416 snd_hda_sequence_write(codec
, enable_dc_mode
);
2417 cxt5066_olpc_select_mic(codec
); /* also sets configured bias */
2420 static void cxt5066_disable_dc(struct hda_codec
*codec
)
2422 /* reconfigure input source */
2423 cxt5066_set_mic_boost(codec
);
2424 /* automic also selects the right mic if we're recording */
2425 cxt5066_olpc_automic(codec
);
2428 static int cxt5066_olpc_dc_get(struct snd_kcontrol
*kcontrol
,
2429 struct snd_ctl_elem_value
*ucontrol
)
2431 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2432 struct conexant_spec
*spec
= codec
->spec
;
2433 ucontrol
->value
.integer
.value
[0] = spec
->dc_enable
;
2437 static int cxt5066_olpc_dc_put(struct snd_kcontrol
*kcontrol
,
2438 struct snd_ctl_elem_value
*ucontrol
)
2440 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2441 struct conexant_spec
*spec
= codec
->spec
;
2442 int dc_enable
= !!ucontrol
->value
.integer
.value
[0];
2444 if (dc_enable
== spec
->dc_enable
)
2447 spec
->dc_enable
= dc_enable
;
2449 cxt5066_enable_dc(codec
);
2451 cxt5066_disable_dc(codec
);
2456 static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol
*kcontrol
,
2457 struct snd_ctl_elem_info
*uinfo
)
2459 return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias
, uinfo
);
2462 static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol
*kcontrol
,
2463 struct snd_ctl_elem_value
*ucontrol
)
2465 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2466 struct conexant_spec
*spec
= codec
->spec
;
2467 ucontrol
->value
.enumerated
.item
[0] = spec
->dc_input_bias
;
2471 static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol
*kcontrol
,
2472 struct snd_ctl_elem_value
*ucontrol
)
2474 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2475 struct conexant_spec
*spec
= codec
->spec
;
2476 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2479 idx
= ucontrol
->value
.enumerated
.item
[0];
2480 if (idx
>= imux
->num_items
)
2481 idx
= imux
->num_items
- 1;
2483 spec
->dc_input_bias
= idx
;
2484 if (spec
->dc_enable
)
2485 cxt5066_set_olpc_dc_bias(codec
);
2489 static void cxt5066_olpc_capture_prepare(struct hda_codec
*codec
)
2491 struct conexant_spec
*spec
= codec
->spec
;
2492 /* mark as recording and configure the microphone widget so that the
2493 * recording LED comes on. */
2494 spec
->recording
= 1;
2495 cxt5066_olpc_select_mic(codec
);
2498 static void cxt5066_olpc_capture_cleanup(struct hda_codec
*codec
)
2500 struct conexant_spec
*spec
= codec
->spec
;
2501 const struct hda_verb disable_mics
[] = {
2502 /* disable external mic, port B */
2503 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2505 /* disble internal mic, port C */
2506 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2508 /* disable DC capture, port F */
2509 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2513 snd_hda_sequence_write(codec
, disable_mics
);
2514 spec
->recording
= 0;
2517 static struct hda_input_mux cxt5066_capture_source
= {
2527 static struct hda_bind_ctls cxt5066_bind_capture_vol_others
= {
2528 .ops
= &snd_hda_bind_vol
,
2530 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2531 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2536 static struct hda_bind_ctls cxt5066_bind_capture_sw_others
= {
2537 .ops
= &snd_hda_bind_sw
,
2539 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2540 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2545 static struct snd_kcontrol_new cxt5066_mixer_master
[] = {
2546 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
2550 static struct snd_kcontrol_new cxt5066_mixer_master_olpc
[] = {
2552 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2553 .name
= "Master Playback Volume",
2554 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
|
2555 SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
2556 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
,
2557 .subdevice
= HDA_SUBDEV_AMP_FLAG
,
2558 .info
= snd_hda_mixer_amp_volume_info
,
2559 .get
= snd_hda_mixer_amp_volume_get
,
2560 .put
= snd_hda_mixer_amp_volume_put
,
2561 .tlv
= { .c
= snd_hda_mixer_amp_tlv
},
2562 /* offset by 28 volume steps to limit minimum gain to -46dB */
2564 HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT
, 28),
2569 static struct snd_kcontrol_new cxt5066_mixer_olpc_dc
[] = {
2571 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2572 .name
= "DC Mode Enable Switch",
2573 .info
= snd_ctl_boolean_mono_info
,
2574 .get
= cxt5066_olpc_dc_get
,
2575 .put
= cxt5066_olpc_dc_put
,
2578 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2579 .name
= "DC Input Bias Enum",
2580 .info
= cxt5066_olpc_dc_bias_enum_info
,
2581 .get
= cxt5066_olpc_dc_bias_enum_get
,
2582 .put
= cxt5066_olpc_dc_bias_enum_put
,
2587 static struct snd_kcontrol_new cxt5066_mixers
[] = {
2589 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2590 .name
= "Master Playback Switch",
2591 .info
= cxt_eapd_info
,
2592 .get
= cxt_eapd_get
,
2593 .put
= cxt5066_hp_master_sw_put
,
2594 .private_value
= 0x1d,
2598 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2599 .name
= "Analog Mic Boost Capture Enum",
2600 .info
= cxt5066_mic_boost_mux_enum_info
,
2601 .get
= cxt5066_mic_boost_mux_enum_get
,
2602 .put
= cxt5066_mic_boost_mux_enum_put
,
2605 HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others
),
2606 HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others
),
2610 static struct snd_kcontrol_new cxt5066_vostro_mixers
[] = {
2612 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2613 .name
= "Int Mic Boost Capture Enum",
2614 .info
= cxt5066_mic_boost_mux_enum_info
,
2615 .get
= cxt5066_mic_boost_mux_enum_get
,
2616 .put
= cxt5066_mic_boost_mux_enum_put
,
2617 .private_value
= 0x23 | 0x100,
2619 HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT
),
2623 static struct hda_verb cxt5066_init_verbs
[] = {
2624 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2625 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2626 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2627 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2630 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2631 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2634 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2635 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2637 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2638 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2641 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2643 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2644 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2645 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2646 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2647 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2648 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2650 /* no digital microphone support yet */
2651 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2653 /* Audio input selector */
2654 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2656 /* SPDIF route: PCM */
2657 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2658 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2660 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2661 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2664 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2666 /* not handling these yet */
2667 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2668 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2669 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2670 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2671 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2672 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2673 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2674 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2678 static struct hda_verb cxt5066_init_verbs_olpc
[] = {
2679 /* Port A: headphones */
2680 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2681 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2683 /* Port B: external microphone */
2684 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2686 /* Port C: internal microphone */
2687 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2689 /* Port D: unused */
2690 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2692 /* Port E: unused, but has primary EAPD */
2693 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2694 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2696 /* Port F: external DC input through microphone port */
2697 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2699 /* Port G: internal speakers */
2700 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2701 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2704 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2707 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2709 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2710 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2711 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2712 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2713 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2714 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2715 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2716 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2717 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2718 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2719 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2720 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2722 /* Disable digital microphone port */
2723 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2725 /* Audio input selectors */
2726 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2727 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2730 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2731 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2733 /* enable unsolicited events for Port A and B */
2734 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2735 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2739 static struct hda_verb cxt5066_init_verbs_vostro
[] = {
2740 /* Port A: headphones */
2741 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2742 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2744 /* Port B: external microphone */
2745 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2747 /* Port C: unused */
2748 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2750 /* Port D: unused */
2751 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2753 /* Port E: unused, but has primary EAPD */
2754 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2755 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2757 /* Port F: unused */
2758 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2760 /* Port G: internal speakers */
2761 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2762 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2765 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2768 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2770 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2771 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2772 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2773 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2774 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2775 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2776 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2777 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2778 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2779 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2780 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2781 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2783 /* Digital microphone port */
2784 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2786 /* Audio input selectors */
2787 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2788 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2791 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2792 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2794 /* enable unsolicited events for Port A and B */
2795 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2796 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2800 static struct hda_verb cxt5066_init_verbs_ideapad
[] = {
2801 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2802 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2803 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2804 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2807 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2808 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2811 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2812 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2814 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2815 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2818 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2820 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2821 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2822 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2823 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2824 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2825 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2826 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2828 /* Audio input selector */
2829 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2830 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2832 /* SPDIF route: PCM */
2833 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2834 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2836 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2837 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2839 /* internal microphone */
2840 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable int mic */
2843 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2845 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2846 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2850 static struct hda_verb cxt5066_init_verbs_thinkpad
[] = {
2851 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2852 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2854 /* Port G: internal speakers */
2855 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2856 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2858 /* Port A: HP, Amp */
2859 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2860 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2862 /* Port B: Mic Dock */
2863 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2866 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2868 /* Port D: HP Dock, Amp */
2869 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2870 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2873 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2875 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2876 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2877 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2878 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2879 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2880 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2881 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2883 /* Audio input selector */
2884 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2885 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2887 /* SPDIF route: PCM */
2888 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2889 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2891 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2892 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2894 /* internal microphone */
2895 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable int mic */
2898 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2900 /* enable unsolicited events for Port A, B, C and D */
2901 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2902 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2903 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2904 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2908 static struct hda_verb cxt5066_init_verbs_portd_lo
[] = {
2909 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2913 /* initialize jack-sensing, too */
2914 static int cxt5066_init(struct hda_codec
*codec
)
2916 struct conexant_spec
*spec
= codec
->spec
;
2918 snd_printdd("CXT5066: init\n");
2919 conexant_init(codec
);
2920 if (codec
->patch_ops
.unsol_event
) {
2921 cxt5066_hp_automute(codec
);
2922 if (spec
->dell_vostro
)
2923 cxt5066_vostro_automic(codec
);
2924 else if (spec
->ideapad
)
2925 cxt5066_ideapad_automic(codec
);
2926 else if (spec
->thinkpad
)
2927 cxt5066_thinkpad_automic(codec
);
2929 cxt5066_set_mic_boost(codec
);
2933 static int cxt5066_olpc_init(struct hda_codec
*codec
)
2935 struct conexant_spec
*spec
= codec
->spec
;
2936 snd_printdd("CXT5066: init\n");
2937 conexant_init(codec
);
2938 cxt5066_hp_automute(codec
);
2939 if (!spec
->dc_enable
) {
2940 cxt5066_set_mic_boost(codec
);
2941 cxt5066_olpc_automic(codec
);
2943 cxt5066_enable_dc(codec
);
2949 CXT5066_LAPTOP
, /* Laptops w/ EAPD support */
2950 CXT5066_DELL_LAPTOP
, /* Dell Laptop */
2951 CXT5066_OLPC_XO_1_5
, /* OLPC XO 1.5 */
2952 CXT5066_DELL_VOSTO
, /* Dell Vostro 1015i */
2953 CXT5066_IDEAPAD
, /* Lenovo IdeaPad U150 */
2954 CXT5066_THINKPAD
, /* Lenovo ThinkPad T410s, others? */
2958 static const char *cxt5066_models
[CXT5066_MODELS
] = {
2959 [CXT5066_LAPTOP
] = "laptop",
2960 [CXT5066_DELL_LAPTOP
] = "dell-laptop",
2961 [CXT5066_OLPC_XO_1_5
] = "olpc-xo-1_5",
2962 [CXT5066_DELL_VOSTO
] = "dell-vostro",
2963 [CXT5066_IDEAPAD
] = "ideapad",
2964 [CXT5066_THINKPAD
] = "thinkpad",
2967 static struct snd_pci_quirk cxt5066_cfg_tbl
[] = {
2968 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
2970 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell",
2971 CXT5066_DELL_LAPTOP
),
2972 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5
),
2973 SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTO
),
2974 SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD
),
2975 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5
),
2976 SND_PCI_QUIRK(0x1179, 0xffe0, "Toshiba Satellite Pro T130-15F", CXT5066_OLPC_XO_1_5
),
2977 SND_PCI_QUIRK(0x17aa, 0x21b2, "Thinkpad X100e", CXT5066_IDEAPAD
),
2978 SND_PCI_QUIRK(0x17aa, 0x21b3, "Thinkpad Edge 13 (197)", CXT5066_IDEAPAD
),
2979 SND_PCI_QUIRK(0x17aa, 0x21b4, "Thinkpad Edge", CXT5066_IDEAPAD
),
2980 SND_PCI_QUIRK(0x17aa, 0x3a0d, "ideapad", CXT5066_IDEAPAD
),
2981 SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo Thinkpad", CXT5066_THINKPAD
),
2985 static int patch_cxt5066(struct hda_codec
*codec
)
2987 struct conexant_spec
*spec
;
2990 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2995 codec
->patch_ops
= conexant_patch_ops
;
2996 codec
->patch_ops
.init
= conexant_init
;
2998 spec
->dell_automute
= 0;
2999 spec
->multiout
.max_channels
= 2;
3000 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5066_dac_nids
);
3001 spec
->multiout
.dac_nids
= cxt5066_dac_nids
;
3002 spec
->multiout
.dig_out_nid
= CXT5066_SPDIF_OUT
;
3003 spec
->num_adc_nids
= 1;
3004 spec
->adc_nids
= cxt5066_adc_nids
;
3005 spec
->capsrc_nids
= cxt5066_capsrc_nids
;
3006 spec
->input_mux
= &cxt5066_capture_source
;
3008 spec
->port_d_mode
= PIN_HP
;
3010 spec
->num_init_verbs
= 1;
3011 spec
->init_verbs
[0] = cxt5066_init_verbs
;
3012 spec
->num_channel_mode
= ARRAY_SIZE(cxt5066_modes
);
3013 spec
->channel_mode
= cxt5066_modes
;
3015 spec
->cur_adc_idx
= 0;
3017 board_config
= snd_hda_check_board_config(codec
, CXT5066_MODELS
,
3018 cxt5066_models
, cxt5066_cfg_tbl
);
3019 switch (board_config
) {
3021 case CXT5066_LAPTOP
:
3022 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3023 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3025 case CXT5066_DELL_LAPTOP
:
3026 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3027 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3029 spec
->port_d_mode
= PIN_OUT
;
3030 spec
->init_verbs
[spec
->num_init_verbs
] = cxt5066_init_verbs_portd_lo
;
3031 spec
->num_init_verbs
++;
3032 spec
->dell_automute
= 1;
3034 case CXT5066_OLPC_XO_1_5
:
3035 codec
->patch_ops
.init
= cxt5066_olpc_init
;
3036 codec
->patch_ops
.unsol_event
= cxt5066_olpc_unsol_event
;
3037 spec
->init_verbs
[0] = cxt5066_init_verbs_olpc
;
3038 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
3039 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_olpc_dc
;
3040 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3041 spec
->port_d_mode
= 0;
3042 spec
->mic_boost
= 3; /* default 30dB gain */
3045 spec
->multiout
.dig_out_nid
= 0;
3047 /* input source automatically selected */
3048 spec
->input_mux
= NULL
;
3050 /* our capture hooks which allow us to turn on the microphone LED
3051 * at the right time */
3052 spec
->capture_prepare
= cxt5066_olpc_capture_prepare
;
3053 spec
->capture_cleanup
= cxt5066_olpc_capture_cleanup
;
3055 case CXT5066_DELL_VOSTO
:
3056 codec
->patch_ops
.init
= cxt5066_init
;
3057 codec
->patch_ops
.unsol_event
= cxt5066_vostro_event
;
3058 spec
->init_verbs
[0] = cxt5066_init_verbs_vostro
;
3059 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
3060 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3061 spec
->mixers
[spec
->num_mixers
++] = cxt5066_vostro_mixers
;
3062 spec
->port_d_mode
= 0;
3063 spec
->dell_vostro
= 1;
3064 spec
->mic_boost
= 3; /* default 30dB gain */
3065 snd_hda_attach_beep_device(codec
, 0x13);
3068 spec
->multiout
.dig_out_nid
= 0;
3070 /* input source automatically selected */
3071 spec
->input_mux
= NULL
;
3073 case CXT5066_IDEAPAD
:
3074 codec
->patch_ops
.init
= cxt5066_init
;
3075 codec
->patch_ops
.unsol_event
= cxt5066_ideapad_event
;
3076 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3077 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3078 spec
->init_verbs
[0] = cxt5066_init_verbs_ideapad
;
3079 spec
->port_d_mode
= 0;
3081 spec
->mic_boost
= 2; /* default 20dB gain */
3084 spec
->multiout
.dig_out_nid
= 0;
3086 /* input source automatically selected */
3087 spec
->input_mux
= NULL
;
3089 case CXT5066_THINKPAD
:
3090 codec
->patch_ops
.init
= cxt5066_init
;
3091 codec
->patch_ops
.unsol_event
= cxt5066_thinkpad_event
;
3092 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3093 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3094 spec
->init_verbs
[0] = cxt5066_init_verbs_thinkpad
;
3096 spec
->port_d_mode
= PIN_OUT
;
3097 spec
->mic_boost
= 2; /* default 20dB gain */
3100 spec
->multiout
.dig_out_nid
= 0;
3102 /* input source automatically selected */
3103 spec
->input_mux
= NULL
;
3113 static struct hda_codec_preset snd_hda_preset_conexant
[] = {
3114 { .id
= 0x14f15045, .name
= "CX20549 (Venice)",
3115 .patch
= patch_cxt5045
},
3116 { .id
= 0x14f15047, .name
= "CX20551 (Waikiki)",
3117 .patch
= patch_cxt5047
},
3118 { .id
= 0x14f15051, .name
= "CX20561 (Hermosa)",
3119 .patch
= patch_cxt5051
},
3120 { .id
= 0x14f15066, .name
= "CX20582 (Pebble)",
3121 .patch
= patch_cxt5066
},
3122 { .id
= 0x14f15067, .name
= "CX20583 (Pebble HSF)",
3123 .patch
= patch_cxt5066
},
3124 { .id
= 0x14f15069, .name
= "CX20585",
3125 .patch
= patch_cxt5066
},
3129 MODULE_ALIAS("snd-hda-codec-id:14f15045");
3130 MODULE_ALIAS("snd-hda-codec-id:14f15047");
3131 MODULE_ALIAS("snd-hda-codec-id:14f15051");
3132 MODULE_ALIAS("snd-hda-codec-id:14f15066");
3133 MODULE_ALIAS("snd-hda-codec-id:14f15067");
3134 MODULE_ALIAS("snd-hda-codec-id:14f15069");
3136 MODULE_LICENSE("GPL");
3137 MODULE_DESCRIPTION("Conexant HD-audio codec");
3139 static struct hda_codec_preset_list conexant_list
= {
3140 .preset
= snd_hda_preset_conexant
,
3141 .owner
= THIS_MODULE
,
3144 static int __init
patch_conexant_init(void)
3146 return snd_hda_add_codec_preset(&conexant_list
);
3149 static void __exit
patch_conexant_exit(void)
3151 snd_hda_delete_codec_preset(&conexant_list
);
3154 module_init(patch_conexant_init
)
3155 module_exit(patch_conexant_exit
)