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/module.h>
27 #include <sound/core.h>
28 #include <sound/jack.h>
30 #include "hda_codec.h"
31 #include "hda_local.h"
32 #include "hda_auto_parser.h"
35 #include "hda_generic.h"
37 #undef ENABLE_CXT_STATIC_QUIRKS
39 #define CXT_PIN_DIR_IN 0x00
40 #define CXT_PIN_DIR_OUT 0x01
41 #define CXT_PIN_DIR_INOUT 0x02
42 #define CXT_PIN_DIR_IN_NOMICBIAS 0x03
43 #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04
45 #define CONEXANT_HP_EVENT 0x37
46 #define CONEXANT_MIC_EVENT 0x38
47 #define CONEXANT_LINE_EVENT 0x39
49 /* Conexant 5051 specific */
51 #define CXT5051_SPDIF_OUT 0x12
52 #define CXT5051_PORTB_EVENT 0x38
53 #define CXT5051_PORTC_EVENT 0x39
55 #define AUTO_MIC_PORTB (1 << 1)
56 #define AUTO_MIC_PORTC (1 << 2)
58 struct conexant_spec
{
59 struct hda_gen_spec gen
;
61 unsigned int beep_amp
;
64 unsigned int num_eapds
;
68 unsigned int parse_flags
; /* flag for snd_hda_parse_pin_defcfg() */
70 /* OPLC XO specific */
73 unsigned int dc_input_bias
; /* offset into olpc_xo_dc_bias */
74 struct nid_path
*dc_mode_path
;
76 #ifdef ENABLE_CXT_STATIC_QUIRKS
77 const struct snd_kcontrol_new
*mixers
[5];
79 hda_nid_t vmaster_nid
;
81 const struct hda_verb
*init_verbs
[5]; /* initialization verbs
85 unsigned int num_init_verbs
;
88 struct hda_multi_out multiout
; /* playback set-up
89 * max_channels, dacs must be set
90 * dig_out_nid and hp_nid are optional
92 unsigned int cur_eapd
;
93 unsigned int hp_present
;
94 unsigned int line_present
;
95 unsigned int auto_mic
;
98 unsigned int num_adc_nids
;
99 const hda_nid_t
*adc_nids
;
100 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
102 unsigned int cur_adc_idx
;
104 unsigned int cur_adc_stream_tag
;
105 unsigned int cur_adc_format
;
107 const struct hda_pcm_stream
*capture_stream
;
110 const struct hda_input_mux
*input_mux
;
111 const hda_nid_t
*capsrc_nids
;
112 unsigned int cur_mux
[3];
115 const struct hda_channel_mode
*channel_mode
;
116 int num_channel_mode
;
118 /* PCM information */
119 struct hda_pcm pcm_rec
[2]; /* used in build_pcms() */
121 unsigned int spdif_route
;
123 unsigned int port_d_mode
;
124 unsigned int dell_automute
:1;
125 unsigned int dell_vostro
:1;
126 unsigned int ideapad
:1;
127 unsigned int thinkpad
:1;
128 unsigned int hp_laptop
:1;
131 unsigned int mic_boost
; /* offset into cxt5066_analog_mic_boost */
132 #endif /* ENABLE_CXT_STATIC_QUIRKS */
136 #ifdef CONFIG_SND_HDA_INPUT_BEEP
137 static inline void set_beep_amp(struct conexant_spec
*spec
, hda_nid_t nid
,
140 spec
->gen
.beep_nid
= nid
;
141 spec
->beep_amp
= HDA_COMPOSE_AMP_VAL(nid
, 1, idx
, dir
);
143 /* additional beep mixers; the actual parameters are overwritten at build */
144 static const struct snd_kcontrol_new cxt_beep_mixer
[] = {
145 HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT
),
146 HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT
),
150 /* create beep controls if needed */
151 static int add_beep_ctls(struct hda_codec
*codec
)
153 struct conexant_spec
*spec
= codec
->spec
;
156 if (spec
->beep_amp
) {
157 const struct snd_kcontrol_new
*knew
;
158 for (knew
= cxt_beep_mixer
; knew
->name
; knew
++) {
159 struct snd_kcontrol
*kctl
;
160 kctl
= snd_ctl_new1(knew
, codec
);
163 kctl
->private_value
= spec
->beep_amp
;
164 err
= snd_hda_ctl_add(codec
, 0, kctl
);
172 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
173 #define add_beep_ctls(codec) 0
177 #ifdef ENABLE_CXT_STATIC_QUIRKS
178 static int conexant_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
179 struct hda_codec
*codec
,
180 struct snd_pcm_substream
*substream
)
182 struct conexant_spec
*spec
= codec
->spec
;
183 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
187 static int conexant_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
188 struct hda_codec
*codec
,
189 unsigned int stream_tag
,
191 struct snd_pcm_substream
*substream
)
193 struct conexant_spec
*spec
= codec
->spec
;
194 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
199 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
200 struct hda_codec
*codec
,
201 struct snd_pcm_substream
*substream
)
203 struct conexant_spec
*spec
= codec
->spec
;
204 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
210 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
211 struct hda_codec
*codec
,
212 struct snd_pcm_substream
*substream
)
214 struct conexant_spec
*spec
= codec
->spec
;
215 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
218 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
219 struct hda_codec
*codec
,
220 struct snd_pcm_substream
*substream
)
222 struct conexant_spec
*spec
= codec
->spec
;
223 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
226 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
227 struct hda_codec
*codec
,
228 unsigned int stream_tag
,
230 struct snd_pcm_substream
*substream
)
232 struct conexant_spec
*spec
= codec
->spec
;
233 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
241 static int conexant_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
242 struct hda_codec
*codec
,
243 unsigned int stream_tag
,
245 struct snd_pcm_substream
*substream
)
247 struct conexant_spec
*spec
= codec
->spec
;
248 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
249 stream_tag
, 0, format
);
253 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
254 struct hda_codec
*codec
,
255 struct snd_pcm_substream
*substream
)
257 struct conexant_spec
*spec
= codec
->spec
;
258 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
264 static const struct hda_pcm_stream conexant_pcm_analog_playback
= {
268 .nid
= 0, /* fill later */
270 .open
= conexant_playback_pcm_open
,
271 .prepare
= conexant_playback_pcm_prepare
,
272 .cleanup
= conexant_playback_pcm_cleanup
276 static const struct hda_pcm_stream conexant_pcm_analog_capture
= {
280 .nid
= 0, /* fill later */
282 .prepare
= conexant_capture_pcm_prepare
,
283 .cleanup
= conexant_capture_pcm_cleanup
288 static const struct hda_pcm_stream conexant_pcm_digital_playback
= {
292 .nid
= 0, /* fill later */
294 .open
= conexant_dig_playback_pcm_open
,
295 .close
= conexant_dig_playback_pcm_close
,
296 .prepare
= conexant_dig_playback_pcm_prepare
300 static const struct hda_pcm_stream conexant_pcm_digital_capture
= {
304 /* NID is set in alc_build_pcms */
307 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
308 struct hda_codec
*codec
,
309 unsigned int stream_tag
,
311 struct snd_pcm_substream
*substream
)
313 struct conexant_spec
*spec
= codec
->spec
;
314 spec
->cur_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
315 spec
->cur_adc_stream_tag
= stream_tag
;
316 spec
->cur_adc_format
= format
;
317 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
321 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
322 struct hda_codec
*codec
,
323 struct snd_pcm_substream
*substream
)
325 struct conexant_spec
*spec
= codec
->spec
;
326 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
331 static const struct hda_pcm_stream cx5051_pcm_analog_capture
= {
335 .nid
= 0, /* fill later */
337 .prepare
= cx5051_capture_pcm_prepare
,
338 .cleanup
= cx5051_capture_pcm_cleanup
342 static int conexant_build_pcms(struct hda_codec
*codec
)
344 struct conexant_spec
*spec
= codec
->spec
;
345 struct hda_pcm
*info
= spec
->pcm_rec
;
348 codec
->pcm_info
= info
;
350 info
->name
= "CONEXANT Analog";
351 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = conexant_pcm_analog_playback
;
352 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
=
353 spec
->multiout
.max_channels
;
354 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
355 spec
->multiout
.dac_nids
[0];
356 if (spec
->capture_stream
)
357 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *spec
->capture_stream
;
359 if (codec
->vendor_id
== 0x14f15051)
360 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
361 cx5051_pcm_analog_capture
;
363 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
364 conexant_pcm_analog_capture
;
365 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
=
369 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
371 if (spec
->multiout
.dig_out_nid
) {
374 info
->name
= "Conexant Digital";
375 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
376 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
377 conexant_pcm_digital_playback
;
378 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
379 spec
->multiout
.dig_out_nid
;
380 if (spec
->dig_in_nid
) {
381 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
382 conexant_pcm_digital_capture
;
383 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
391 static int conexant_mux_enum_info(struct snd_kcontrol
*kcontrol
,
392 struct snd_ctl_elem_info
*uinfo
)
394 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
395 struct conexant_spec
*spec
= codec
->spec
;
397 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
400 static int conexant_mux_enum_get(struct snd_kcontrol
*kcontrol
,
401 struct snd_ctl_elem_value
*ucontrol
)
403 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
404 struct conexant_spec
*spec
= codec
->spec
;
405 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
407 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
411 static int conexant_mux_enum_put(struct snd_kcontrol
*kcontrol
,
412 struct snd_ctl_elem_value
*ucontrol
)
414 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
415 struct conexant_spec
*spec
= codec
->spec
;
416 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
418 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
419 spec
->capsrc_nids
[adc_idx
],
420 &spec
->cur_mux
[adc_idx
]);
423 static void conexant_set_power(struct hda_codec
*codec
, hda_nid_t fg
,
424 unsigned int power_state
)
426 if (power_state
== AC_PWRST_D3
)
428 snd_hda_codec_read(codec
, fg
, 0, AC_VERB_SET_POWER_STATE
,
430 /* partial workaround for "azx_get_response timeout" */
431 if (power_state
== AC_PWRST_D0
)
433 snd_hda_codec_set_power_to_all(codec
, fg
, power_state
);
436 static int conexant_init(struct hda_codec
*codec
)
438 struct conexant_spec
*spec
= codec
->spec
;
441 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
442 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
446 static void conexant_free(struct hda_codec
*codec
)
451 static const struct snd_kcontrol_new cxt_capture_mixers
[] = {
453 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
454 .name
= "Capture Source",
455 .info
= conexant_mux_enum_info
,
456 .get
= conexant_mux_enum_get
,
457 .put
= conexant_mux_enum_put
462 static const char * const slave_pfxs
[] = {
463 "Headphone", "Speaker", "Bass Speaker", "Front", "Surround", "CLFE",
467 static int conexant_build_controls(struct hda_codec
*codec
)
469 struct conexant_spec
*spec
= codec
->spec
;
473 for (i
= 0; i
< spec
->num_mixers
; i
++) {
474 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
478 if (spec
->multiout
.dig_out_nid
) {
479 err
= snd_hda_create_spdif_out_ctls(codec
,
480 spec
->multiout
.dig_out_nid
,
481 spec
->multiout
.dig_out_nid
);
484 err
= snd_hda_create_spdif_share_sw(codec
,
488 spec
->multiout
.share_spdif
= 1;
490 if (spec
->dig_in_nid
) {
491 err
= snd_hda_create_spdif_in_ctls(codec
,spec
->dig_in_nid
);
496 /* if we have no master control, let's create it */
497 if (spec
->vmaster_nid
&&
498 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
499 unsigned int vmaster_tlv
[4];
500 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
501 HDA_OUTPUT
, vmaster_tlv
);
502 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
503 vmaster_tlv
, slave_pfxs
,
508 if (spec
->vmaster_nid
&&
509 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
510 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
517 if (spec
->input_mux
) {
518 err
= snd_hda_add_new_ctls(codec
, cxt_capture_mixers
);
523 err
= add_beep_ctls(codec
);
530 static const struct hda_codec_ops conexant_patch_ops
= {
531 .build_controls
= conexant_build_controls
,
532 .build_pcms
= conexant_build_pcms
,
533 .init
= conexant_init
,
534 .free
= conexant_free
,
535 .set_power_state
= conexant_set_power
,
538 static int patch_conexant_auto(struct hda_codec
*codec
);
541 * the private value = nid | (invert << 8)
544 #define cxt_eapd_info snd_ctl_boolean_mono_info
546 static int cxt_eapd_get(struct snd_kcontrol
*kcontrol
,
547 struct snd_ctl_elem_value
*ucontrol
)
549 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
550 struct conexant_spec
*spec
= codec
->spec
;
551 int invert
= (kcontrol
->private_value
>> 8) & 1;
553 ucontrol
->value
.integer
.value
[0] = !spec
->cur_eapd
;
555 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
560 static int cxt_eapd_put(struct snd_kcontrol
*kcontrol
,
561 struct snd_ctl_elem_value
*ucontrol
)
563 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
564 struct conexant_spec
*spec
= codec
->spec
;
565 int invert
= (kcontrol
->private_value
>> 8) & 1;
566 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
569 eapd
= !!ucontrol
->value
.integer
.value
[0];
572 if (eapd
== spec
->cur_eapd
)
575 spec
->cur_eapd
= eapd
;
576 snd_hda_codec_write_cache(codec
, nid
,
577 0, AC_VERB_SET_EAPD_BTLENABLE
,
582 /* controls for test mode */
583 #ifdef CONFIG_SND_DEBUG
585 #define CXT_EAPD_SWITCH(xname, nid, mask) \
586 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
587 .info = cxt_eapd_info, \
588 .get = cxt_eapd_get, \
589 .put = cxt_eapd_put, \
590 .private_value = nid | (mask<<16) }
594 static int conexant_ch_mode_info(struct snd_kcontrol
*kcontrol
,
595 struct snd_ctl_elem_info
*uinfo
)
597 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
598 struct conexant_spec
*spec
= codec
->spec
;
599 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
600 spec
->num_channel_mode
);
603 static int conexant_ch_mode_get(struct snd_kcontrol
*kcontrol
,
604 struct snd_ctl_elem_value
*ucontrol
)
606 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
607 struct conexant_spec
*spec
= codec
->spec
;
608 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
609 spec
->num_channel_mode
,
610 spec
->multiout
.max_channels
);
613 static int conexant_ch_mode_put(struct snd_kcontrol
*kcontrol
,
614 struct snd_ctl_elem_value
*ucontrol
)
616 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
617 struct conexant_spec
*spec
= codec
->spec
;
618 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
619 spec
->num_channel_mode
,
620 &spec
->multiout
.max_channels
);
624 #define CXT_PIN_MODE(xname, nid, dir) \
625 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
626 .info = conexant_ch_mode_info, \
627 .get = conexant_ch_mode_get, \
628 .put = conexant_ch_mode_put, \
629 .private_value = nid | (dir<<16) }
631 #endif /* CONFIG_SND_DEBUG */
633 /* Conexant 5045 specific */
635 static const hda_nid_t cxt5045_dac_nids
[1] = { 0x19 };
636 static const hda_nid_t cxt5045_adc_nids
[1] = { 0x1a };
637 static const hda_nid_t cxt5045_capsrc_nids
[1] = { 0x1a };
638 #define CXT5045_SPDIF_OUT 0x18
640 static const struct hda_channel_mode cxt5045_modes
[1] = {
644 static const struct hda_input_mux cxt5045_capture_source
= {
647 { "Internal Mic", 0x1 },
652 static const struct hda_input_mux cxt5045_capture_source_benq
= {
655 { "Internal Mic", 0x1 },
662 /* turn on/off EAPD (+ mute HP) as a master switch */
663 static int cxt5045_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
664 struct snd_ctl_elem_value
*ucontrol
)
666 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
667 struct conexant_spec
*spec
= codec
->spec
;
670 if (!cxt_eapd_put(kcontrol
, ucontrol
))
673 /* toggle internal speakers mute depending of presence of
676 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
677 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
680 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
681 snd_hda_codec_amp_stereo(codec
, 0x11, HDA_OUTPUT
, 0,
686 /* bind volumes of both NID 0x10 and 0x11 */
687 static const struct hda_bind_ctls cxt5045_hp_bind_master_vol
= {
688 .ops
= &snd_hda_bind_vol
,
690 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT
),
691 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT
),
696 /* toggle input of built-in and mic jack appropriately */
697 static void cxt5045_hp_automic(struct hda_codec
*codec
)
699 static const struct hda_verb mic_jack_on
[] = {
700 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
701 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
704 static const struct hda_verb mic_jack_off
[] = {
705 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
706 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
709 unsigned int present
;
711 present
= snd_hda_jack_detect(codec
, 0x12);
713 snd_hda_sequence_write(codec
, mic_jack_on
);
715 snd_hda_sequence_write(codec
, mic_jack_off
);
719 /* mute internal speaker if HP is plugged */
720 static void cxt5045_hp_automute(struct hda_codec
*codec
)
722 struct conexant_spec
*spec
= codec
->spec
;
725 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x11);
727 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
728 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
732 /* unsolicited event for HP jack sensing */
733 static void cxt5045_hp_unsol_event(struct hda_codec
*codec
,
738 case CONEXANT_HP_EVENT
:
739 cxt5045_hp_automute(codec
);
741 case CONEXANT_MIC_EVENT
:
742 cxt5045_hp_automic(codec
);
748 static const struct snd_kcontrol_new cxt5045_mixers
[] = {
749 HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT
),
750 HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT
),
751 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
752 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
753 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
754 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
755 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
756 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
757 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
759 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
760 .name
= "Master Playback Switch",
761 .info
= cxt_eapd_info
,
763 .put
= cxt5045_hp_master_sw_put
,
764 .private_value
= 0x10,
770 static const struct snd_kcontrol_new cxt5045_benq_mixers
[] = {
771 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x3, HDA_INPUT
),
772 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x3, HDA_INPUT
),
777 static const struct hda_verb cxt5045_init_verbs
[] = {
779 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
780 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
782 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
783 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
784 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
785 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
786 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
787 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
788 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
789 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
790 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
791 /* Record selector: Internal mic */
792 {0x1a, AC_VERB_SET_CONNECT_SEL
,0x1},
793 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
794 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
795 /* SPDIF route: PCM */
796 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
797 { 0x13, AC_VERB_SET_CONNECT_SEL
, 0x0 },
799 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2 }, /* default on */
803 static const struct hda_verb cxt5045_benq_init_verbs
[] = {
804 /* Internal Mic, Mic */
805 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
806 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
807 /* Line In,HP, Amp */
808 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
809 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
810 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
811 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
812 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
813 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
814 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
815 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
816 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
817 /* Record selector: Internal mic */
818 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x1},
819 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
820 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
821 /* SPDIF route: PCM */
822 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
823 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0},
825 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
829 static const struct hda_verb cxt5045_hp_sense_init_verbs
[] = {
830 /* pin sensing on HP jack */
831 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
835 static const struct hda_verb cxt5045_mic_sense_init_verbs
[] = {
836 /* pin sensing on HP jack */
837 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
841 #ifdef CONFIG_SND_DEBUG
842 /* Test configuration for debugging, modelled after the ALC260 test
845 static const struct hda_input_mux cxt5045_test_capture_source
= {
850 { "LINE1 pin", 0x2 },
851 { "HP-OUT pin", 0x3 },
856 static const struct snd_kcontrol_new cxt5045_test_mixer
[] = {
858 /* Output controls */
859 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
860 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
861 HDA_CODEC_VOLUME("HP-OUT Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
862 HDA_CODEC_MUTE("HP-OUT Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
863 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
864 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
866 /* Modes for retasking pin widgets */
867 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT
),
868 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT
),
870 /* EAPD Switch Control */
871 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
873 /* Loopback mixer controls */
875 HDA_CODEC_VOLUME("PCM Volume", 0x17, 0x0, HDA_INPUT
),
876 HDA_CODEC_MUTE("PCM Switch", 0x17, 0x0, HDA_INPUT
),
877 HDA_CODEC_VOLUME("MIC1 pin Volume", 0x17, 0x1, HDA_INPUT
),
878 HDA_CODEC_MUTE("MIC1 pin Switch", 0x17, 0x1, HDA_INPUT
),
879 HDA_CODEC_VOLUME("LINE1 pin Volume", 0x17, 0x2, HDA_INPUT
),
880 HDA_CODEC_MUTE("LINE1 pin Switch", 0x17, 0x2, HDA_INPUT
),
881 HDA_CODEC_VOLUME("HP-OUT pin Volume", 0x17, 0x3, HDA_INPUT
),
882 HDA_CODEC_MUTE("HP-OUT pin Switch", 0x17, 0x3, HDA_INPUT
),
883 HDA_CODEC_VOLUME("CD pin Volume", 0x17, 0x4, HDA_INPUT
),
884 HDA_CODEC_MUTE("CD pin Switch", 0x17, 0x4, HDA_INPUT
),
886 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
887 .name
= "Input Source",
888 .info
= conexant_mux_enum_info
,
889 .get
= conexant_mux_enum_get
,
890 .put
= conexant_mux_enum_put
,
892 /* Audio input controls */
893 HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x0, HDA_INPUT
),
894 HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT
),
898 static const struct hda_verb cxt5045_test_init_verbs
[] = {
899 /* Set connections */
900 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
901 { 0x11, AC_VERB_SET_CONNECT_SEL
, 0x0 },
902 { 0x12, AC_VERB_SET_CONNECT_SEL
, 0x0 },
903 /* Enable retasking pins as output, initially without power amp */
904 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
905 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
907 /* Disable digital (SPDIF) pins initially, but users can enable
908 * them via a mixer switch. In the case of SPDIF-out, this initverb
909 * payload also sets the generation to 0, output to be in "consumer"
910 * PCM format, copyright asserted, no pre-emphasis and no validity
913 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
914 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
916 /* Unmute retasking pin widget output buffers since the default
917 * state appears to be output. As the pin mode is changed by the
918 * user the pin mode control will take care of enabling the pin's
919 * input/output buffers as needed.
921 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
922 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
924 /* Mute capture amp left and right */
925 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
927 /* Set ADC connection select to match default mixer setting (mic1
930 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x01},
931 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x01},
933 /* Mute all inputs to mixer widget (even unconnected ones) */
934 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* Mixer */
935 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* Mic1 pin */
936 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* Line pin */
937 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* HP pin */
938 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
945 /* initialize jack-sensing, too */
946 static int cxt5045_init(struct hda_codec
*codec
)
948 conexant_init(codec
);
949 cxt5045_hp_automute(codec
);
955 CXT5045_LAPTOP_HPSENSE
,
956 CXT5045_LAPTOP_MICSENSE
,
957 CXT5045_LAPTOP_HPMICSENSE
,
959 #ifdef CONFIG_SND_DEBUG
966 static const char * const cxt5045_models
[CXT5045_MODELS
] = {
967 [CXT5045_LAPTOP_HPSENSE
] = "laptop-hpsense",
968 [CXT5045_LAPTOP_MICSENSE
] = "laptop-micsense",
969 [CXT5045_LAPTOP_HPMICSENSE
] = "laptop-hpmicsense",
970 [CXT5045_BENQ
] = "benq",
971 #ifdef CONFIG_SND_DEBUG
972 [CXT5045_TEST
] = "test",
974 [CXT5045_AUTO
] = "auto",
977 static const struct snd_pci_quirk cxt5045_cfg_tbl
[] = {
978 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ
),
979 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE
),
980 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE
),
981 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
982 CXT5045_LAPTOP_HPMICSENSE
),
983 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
984 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
985 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
986 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
987 CXT5045_LAPTOP_HPMICSENSE
),
988 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE
),
992 static int patch_cxt5045(struct hda_codec
*codec
)
994 struct conexant_spec
*spec
;
997 board_config
= snd_hda_check_board_config(codec
, CXT5045_MODELS
,
1000 if (board_config
< 0)
1001 board_config
= CXT5045_AUTO
; /* model=auto as default */
1002 if (board_config
== CXT5045_AUTO
)
1003 return patch_conexant_auto(codec
);
1005 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1009 codec
->single_adc_amp
= 1;
1011 spec
->multiout
.max_channels
= 2;
1012 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5045_dac_nids
);
1013 spec
->multiout
.dac_nids
= cxt5045_dac_nids
;
1014 spec
->multiout
.dig_out_nid
= CXT5045_SPDIF_OUT
;
1015 spec
->num_adc_nids
= 1;
1016 spec
->adc_nids
= cxt5045_adc_nids
;
1017 spec
->capsrc_nids
= cxt5045_capsrc_nids
;
1018 spec
->input_mux
= &cxt5045_capture_source
;
1019 spec
->num_mixers
= 1;
1020 spec
->mixers
[0] = cxt5045_mixers
;
1021 spec
->num_init_verbs
= 1;
1022 spec
->init_verbs
[0] = cxt5045_init_verbs
;
1023 spec
->spdif_route
= 0;
1024 spec
->num_channel_mode
= ARRAY_SIZE(cxt5045_modes
);
1025 spec
->channel_mode
= cxt5045_modes
;
1027 set_beep_amp(spec
, 0x16, 0, 1);
1029 codec
->patch_ops
= conexant_patch_ops
;
1031 switch (board_config
) {
1032 case CXT5045_LAPTOP_HPSENSE
:
1033 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1034 spec
->input_mux
= &cxt5045_capture_source
;
1035 spec
->num_init_verbs
= 2;
1036 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1037 spec
->mixers
[0] = cxt5045_mixers
;
1038 codec
->patch_ops
.init
= cxt5045_init
;
1040 case CXT5045_LAPTOP_MICSENSE
:
1041 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1042 spec
->input_mux
= &cxt5045_capture_source
;
1043 spec
->num_init_verbs
= 2;
1044 spec
->init_verbs
[1] = cxt5045_mic_sense_init_verbs
;
1045 spec
->mixers
[0] = cxt5045_mixers
;
1046 codec
->patch_ops
.init
= cxt5045_init
;
1049 case CXT5045_LAPTOP_HPMICSENSE
:
1050 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1051 spec
->input_mux
= &cxt5045_capture_source
;
1052 spec
->num_init_verbs
= 3;
1053 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1054 spec
->init_verbs
[2] = cxt5045_mic_sense_init_verbs
;
1055 spec
->mixers
[0] = cxt5045_mixers
;
1056 codec
->patch_ops
.init
= cxt5045_init
;
1059 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1060 spec
->input_mux
= &cxt5045_capture_source_benq
;
1061 spec
->num_init_verbs
= 1;
1062 spec
->init_verbs
[0] = cxt5045_benq_init_verbs
;
1063 spec
->mixers
[0] = cxt5045_mixers
;
1064 spec
->mixers
[1] = cxt5045_benq_mixers
;
1065 spec
->num_mixers
= 2;
1066 codec
->patch_ops
.init
= cxt5045_init
;
1068 #ifdef CONFIG_SND_DEBUG
1070 spec
->input_mux
= &cxt5045_test_capture_source
;
1071 spec
->mixers
[0] = cxt5045_test_mixer
;
1072 spec
->init_verbs
[0] = cxt5045_test_init_verbs
;
1078 switch (codec
->subsystem_id
>> 16) {
1083 /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have
1084 * really bad sound over 0dB on NID 0x17. Fix max PCM level to
1085 * 0 dB (originally it has 0x2b steps with 0dB offset 0x14)
1087 snd_hda_override_amp_caps(codec
, 0x17, HDA_INPUT
,
1088 (0x14 << AC_AMPCAP_OFFSET_SHIFT
) |
1089 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1090 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1091 (1 << AC_AMPCAP_MUTE_SHIFT
));
1096 snd_hda_attach_beep_device(codec
, get_amp_nid_(spec
->beep_amp
));
1102 /* Conexant 5047 specific */
1103 #define CXT5047_SPDIF_OUT 0x11
1105 static const hda_nid_t cxt5047_dac_nids
[1] = { 0x10 }; /* 0x1c */
1106 static const hda_nid_t cxt5047_adc_nids
[1] = { 0x12 };
1107 static const hda_nid_t cxt5047_capsrc_nids
[1] = { 0x1a };
1109 static const struct hda_channel_mode cxt5047_modes
[1] = {
1113 static const struct hda_input_mux cxt5047_toshiba_capture_source
= {
1121 /* turn on/off EAPD (+ mute HP) as a master switch */
1122 static int cxt5047_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1123 struct snd_ctl_elem_value
*ucontrol
)
1125 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1126 struct conexant_spec
*spec
= codec
->spec
;
1129 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1132 /* toggle internal speakers mute depending of presence of
1133 * the headphone jack
1135 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
1136 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1137 * pin widgets unlike other codecs. In this case, we need to
1138 * set index 0x01 for the volume from the mixer amp 0x19.
1140 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1141 HDA_AMP_MUTE
, bits
);
1142 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
1143 snd_hda_codec_amp_stereo(codec
, 0x13, HDA_OUTPUT
, 0,
1144 HDA_AMP_MUTE
, bits
);
1148 /* mute internal speaker if HP is plugged */
1149 static void cxt5047_hp_automute(struct hda_codec
*codec
)
1151 struct conexant_spec
*spec
= codec
->spec
;
1154 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x13);
1156 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
1157 /* See the note in cxt5047_hp_master_sw_put */
1158 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1159 HDA_AMP_MUTE
, bits
);
1162 /* toggle input of built-in and mic jack appropriately */
1163 static void cxt5047_hp_automic(struct hda_codec
*codec
)
1165 static const struct hda_verb mic_jack_on
[] = {
1166 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1167 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1170 static const struct hda_verb mic_jack_off
[] = {
1171 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1172 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1175 unsigned int present
;
1177 present
= snd_hda_jack_detect(codec
, 0x15);
1179 snd_hda_sequence_write(codec
, mic_jack_on
);
1181 snd_hda_sequence_write(codec
, mic_jack_off
);
1184 /* unsolicited event for HP jack sensing */
1185 static void cxt5047_hp_unsol_event(struct hda_codec
*codec
,
1188 switch (res
>> 26) {
1189 case CONEXANT_HP_EVENT
:
1190 cxt5047_hp_automute(codec
);
1192 case CONEXANT_MIC_EVENT
:
1193 cxt5047_hp_automic(codec
);
1198 static const struct snd_kcontrol_new cxt5047_base_mixers
[] = {
1199 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT
),
1200 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT
),
1201 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1202 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT
),
1203 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT
),
1204 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT
),
1205 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT
),
1207 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1208 .name
= "Master Playback Switch",
1209 .info
= cxt_eapd_info
,
1210 .get
= cxt_eapd_get
,
1211 .put
= cxt5047_hp_master_sw_put
,
1212 .private_value
= 0x13,
1218 static const struct snd_kcontrol_new cxt5047_hp_spk_mixers
[] = {
1219 /* See the note in cxt5047_hp_master_sw_put */
1220 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT
),
1221 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1225 static const struct snd_kcontrol_new cxt5047_hp_only_mixers
[] = {
1226 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1230 static const struct hda_verb cxt5047_init_verbs
[] = {
1231 /* Line in, Mic, Built-in Mic */
1232 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1233 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1234 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1236 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1237 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* mixer(0x19) */
1238 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mixer(0x19) */
1239 /* Record selector: Mic */
1240 {0x12, AC_VERB_SET_CONNECT_SEL
,0x03},
1241 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
,
1242 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
1243 {0x1A, AC_VERB_SET_CONNECT_SEL
,0x02},
1244 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1245 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x00},
1246 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1247 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x03},
1248 /* SPDIF route: PCM */
1249 { 0x18, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1250 /* Enable unsolicited events */
1251 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
1252 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1256 /* configuration for Toshiba Laptops */
1257 static const struct hda_verb cxt5047_toshiba_init_verbs
[] = {
1258 {0x13, AC_VERB_SET_EAPD_BTLENABLE
, 0x0}, /* default off */
1262 /* Test configuration for debugging, modelled after the ALC260 test
1265 #ifdef CONFIG_SND_DEBUG
1266 static const struct hda_input_mux cxt5047_test_capture_source
= {
1269 { "LINE1 pin", 0x0 },
1270 { "MIC1 pin", 0x1 },
1271 { "MIC2 pin", 0x2 },
1276 static const struct snd_kcontrol_new cxt5047_test_mixer
[] = {
1278 /* Output only controls */
1279 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT
),
1280 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT
),
1281 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT
),
1282 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT
),
1283 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1284 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1285 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1286 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1287 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT
),
1288 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT
),
1289 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
1290 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
1292 /* Modes for retasking pin widgets */
1293 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT
),
1294 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT
),
1296 /* EAPD Switch Control */
1297 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1299 /* Loopback mixer controls */
1300 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT
),
1301 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT
),
1302 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT
),
1303 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT
),
1304 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT
),
1305 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT
),
1306 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT
),
1307 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT
),
1309 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT
),
1310 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT
),
1311 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT
),
1312 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT
),
1313 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT
),
1314 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT
),
1315 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT
),
1316 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT
),
1318 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1319 .name
= "Input Source",
1320 .info
= conexant_mux_enum_info
,
1321 .get
= conexant_mux_enum_get
,
1322 .put
= conexant_mux_enum_put
,
1324 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1329 static const struct hda_verb cxt5047_test_init_verbs
[] = {
1330 /* Enable retasking pins as output, initially without power amp */
1331 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1332 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1333 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1335 /* Disable digital (SPDIF) pins initially, but users can enable
1336 * them via a mixer switch. In the case of SPDIF-out, this initverb
1337 * payload also sets the generation to 0, output to be in "consumer"
1338 * PCM format, copyright asserted, no pre-emphasis and no validity
1341 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1343 /* Ensure mic1, mic2, line1 pin widgets take input from the
1344 * OUT1 sum bus when acting as an output.
1346 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0},
1347 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0},
1349 /* Start with output sum widgets muted and their output gains at min */
1350 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1351 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1353 /* Unmute retasking pin widget output buffers since the default
1354 * state appears to be output. As the pin mode is changed by the
1355 * user the pin mode control will take care of enabling the pin's
1356 * input/output buffers as needed.
1358 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1359 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1360 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1362 /* Mute capture amp left and right */
1363 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1365 /* Set ADC connection select to match default mixer setting (mic1
1368 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x00},
1370 /* Mute all inputs to mixer widget (even unconnected ones) */
1371 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* mic1 pin */
1372 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* mic2 pin */
1373 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* line1 pin */
1374 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* line2 pin */
1375 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1376 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1377 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)}, /* Line-out pin */
1378 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)}, /* HP-pin pin */
1385 /* initialize jack-sensing, too */
1386 static int cxt5047_hp_init(struct hda_codec
*codec
)
1388 conexant_init(codec
);
1389 cxt5047_hp_automute(codec
);
1395 CXT5047_LAPTOP
, /* Laptops w/o EAPD support */
1396 CXT5047_LAPTOP_HP
, /* Some HP laptops */
1397 CXT5047_LAPTOP_EAPD
, /* Laptops with EAPD support */
1398 #ifdef CONFIG_SND_DEBUG
1405 static const char * const cxt5047_models
[CXT5047_MODELS
] = {
1406 [CXT5047_LAPTOP
] = "laptop",
1407 [CXT5047_LAPTOP_HP
] = "laptop-hp",
1408 [CXT5047_LAPTOP_EAPD
] = "laptop-eapd",
1409 #ifdef CONFIG_SND_DEBUG
1410 [CXT5047_TEST
] = "test",
1412 [CXT5047_AUTO
] = "auto",
1415 static const struct snd_pci_quirk cxt5047_cfg_tbl
[] = {
1416 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP
),
1417 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1419 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD
),
1423 static int patch_cxt5047(struct hda_codec
*codec
)
1425 struct conexant_spec
*spec
;
1428 board_config
= snd_hda_check_board_config(codec
, CXT5047_MODELS
,
1431 if (board_config
< 0)
1432 board_config
= CXT5047_AUTO
; /* model=auto as default */
1433 if (board_config
== CXT5047_AUTO
)
1434 return patch_conexant_auto(codec
);
1436 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1440 codec
->pin_amp_workaround
= 1;
1442 spec
->multiout
.max_channels
= 2;
1443 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5047_dac_nids
);
1444 spec
->multiout
.dac_nids
= cxt5047_dac_nids
;
1445 spec
->multiout
.dig_out_nid
= CXT5047_SPDIF_OUT
;
1446 spec
->num_adc_nids
= 1;
1447 spec
->adc_nids
= cxt5047_adc_nids
;
1448 spec
->capsrc_nids
= cxt5047_capsrc_nids
;
1449 spec
->num_mixers
= 1;
1450 spec
->mixers
[0] = cxt5047_base_mixers
;
1451 spec
->num_init_verbs
= 1;
1452 spec
->init_verbs
[0] = cxt5047_init_verbs
;
1453 spec
->spdif_route
= 0;
1454 spec
->num_channel_mode
= ARRAY_SIZE(cxt5047_modes
),
1455 spec
->channel_mode
= cxt5047_modes
,
1457 codec
->patch_ops
= conexant_patch_ops
;
1459 switch (board_config
) {
1460 case CXT5047_LAPTOP
:
1461 spec
->num_mixers
= 2;
1462 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1463 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1465 case CXT5047_LAPTOP_HP
:
1466 spec
->num_mixers
= 2;
1467 spec
->mixers
[1] = cxt5047_hp_only_mixers
;
1468 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1469 codec
->patch_ops
.init
= cxt5047_hp_init
;
1471 case CXT5047_LAPTOP_EAPD
:
1472 spec
->input_mux
= &cxt5047_toshiba_capture_source
;
1473 spec
->num_mixers
= 2;
1474 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1475 spec
->num_init_verbs
= 2;
1476 spec
->init_verbs
[1] = cxt5047_toshiba_init_verbs
;
1477 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1479 #ifdef CONFIG_SND_DEBUG
1481 spec
->input_mux
= &cxt5047_test_capture_source
;
1482 spec
->mixers
[0] = cxt5047_test_mixer
;
1483 spec
->init_verbs
[0] = cxt5047_test_init_verbs
;
1484 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1487 spec
->vmaster_nid
= 0x13;
1489 switch (codec
->subsystem_id
>> 16) {
1491 /* HP laptops have really bad sound over 0 dB on NID 0x10.
1492 * Fix max PCM level to 0 dB (originally it has 0x1e steps
1493 * with 0 dB offset 0x17)
1495 snd_hda_override_amp_caps(codec
, 0x10, HDA_INPUT
,
1496 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
1497 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1498 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1499 (1 << AC_AMPCAP_MUTE_SHIFT
));
1506 /* Conexant 5051 specific */
1507 static const hda_nid_t cxt5051_dac_nids
[1] = { 0x10 };
1508 static const hda_nid_t cxt5051_adc_nids
[2] = { 0x14, 0x15 };
1510 static const struct hda_channel_mode cxt5051_modes
[1] = {
1514 static void cxt5051_update_speaker(struct hda_codec
*codec
)
1516 struct conexant_spec
*spec
= codec
->spec
;
1517 unsigned int pinctl
;
1519 pinctl
= (spec
->hp_present
&& spec
->cur_eapd
) ? PIN_HP
: 0;
1520 snd_hda_set_pin_ctl(codec
, 0x16, pinctl
);
1522 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1523 snd_hda_set_pin_ctl(codec
, 0x1a, pinctl
);
1524 /* on ideapad there is an additional speaker (subwoofer) to mute */
1526 snd_hda_set_pin_ctl(codec
, 0x1b, pinctl
);
1529 /* turn on/off EAPD (+ mute HP) as a master switch */
1530 static int cxt5051_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1531 struct snd_ctl_elem_value
*ucontrol
)
1533 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1535 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1537 cxt5051_update_speaker(codec
);
1541 /* toggle input of built-in and mic jack appropriately */
1542 static void cxt5051_portb_automic(struct hda_codec
*codec
)
1544 struct conexant_spec
*spec
= codec
->spec
;
1545 unsigned int present
;
1547 if (!(spec
->auto_mic
& AUTO_MIC_PORTB
))
1549 present
= snd_hda_jack_detect(codec
, 0x17);
1550 snd_hda_codec_write(codec
, 0x14, 0,
1551 AC_VERB_SET_CONNECT_SEL
,
1552 present
? 0x01 : 0x00);
1555 /* switch the current ADC according to the jack state */
1556 static void cxt5051_portc_automic(struct hda_codec
*codec
)
1558 struct conexant_spec
*spec
= codec
->spec
;
1559 unsigned int present
;
1562 if (!(spec
->auto_mic
& AUTO_MIC_PORTC
))
1564 present
= snd_hda_jack_detect(codec
, 0x18);
1566 spec
->cur_adc_idx
= 1;
1568 spec
->cur_adc_idx
= 0;
1569 new_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
1570 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
1571 /* stream is running, let's swap the current ADC */
1572 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
1573 spec
->cur_adc
= new_adc
;
1574 snd_hda_codec_setup_stream(codec
, new_adc
,
1575 spec
->cur_adc_stream_tag
, 0,
1576 spec
->cur_adc_format
);
1580 /* mute internal speaker if HP is plugged */
1581 static void cxt5051_hp_automute(struct hda_codec
*codec
)
1583 struct conexant_spec
*spec
= codec
->spec
;
1585 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x16);
1586 cxt5051_update_speaker(codec
);
1589 /* unsolicited event for HP jack sensing */
1590 static void cxt5051_hp_unsol_event(struct hda_codec
*codec
,
1593 switch (res
>> 26) {
1594 case CONEXANT_HP_EVENT
:
1595 cxt5051_hp_automute(codec
);
1597 case CXT5051_PORTB_EVENT
:
1598 cxt5051_portb_automic(codec
);
1600 case CXT5051_PORTC_EVENT
:
1601 cxt5051_portc_automic(codec
);
1606 static const struct snd_kcontrol_new cxt5051_playback_mixers
[] = {
1607 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1609 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1610 .name
= "Master Playback Switch",
1611 .info
= cxt_eapd_info
,
1612 .get
= cxt_eapd_get
,
1613 .put
= cxt5051_hp_master_sw_put
,
1614 .private_value
= 0x1a,
1619 static const struct snd_kcontrol_new cxt5051_capture_mixers
[] = {
1620 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1621 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1622 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT
),
1623 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT
),
1624 HDA_CODEC_VOLUME("Dock Mic Volume", 0x15, 0x00, HDA_INPUT
),
1625 HDA_CODEC_MUTE("Dock Mic Switch", 0x15, 0x00, HDA_INPUT
),
1629 static const struct snd_kcontrol_new cxt5051_hp_mixers
[] = {
1630 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1631 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1632 HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT
),
1633 HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT
),
1637 static const struct snd_kcontrol_new cxt5051_hp_dv6736_mixers
[] = {
1638 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT
),
1639 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT
),
1643 static const struct snd_kcontrol_new cxt5051_f700_mixers
[] = {
1644 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT
),
1645 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT
),
1649 static const struct snd_kcontrol_new cxt5051_toshiba_mixers
[] = {
1650 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1651 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1652 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT
),
1653 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT
),
1657 static const struct hda_verb cxt5051_init_verbs
[] = {
1659 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1660 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1661 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1662 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1663 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1664 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1666 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1667 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1669 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1670 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1672 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1673 /* Record selector: Internal mic */
1674 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1675 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1676 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1677 /* SPDIF route: PCM */
1678 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1679 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1681 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1682 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1686 static const struct hda_verb cxt5051_hp_dv6736_init_verbs
[] = {
1688 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1689 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1690 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1691 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1693 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1694 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1696 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1697 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1699 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1700 /* Record selector: Internal mic */
1701 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1702 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1703 /* SPDIF route: PCM */
1704 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1706 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1707 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1711 static const struct hda_verb cxt5051_f700_init_verbs
[] = {
1713 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1714 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1715 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1716 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1718 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1719 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1721 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1722 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1724 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1725 /* Record selector: Internal mic */
1726 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1727 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1728 /* SPDIF route: PCM */
1729 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1731 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1732 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1736 static void cxt5051_init_mic_port(struct hda_codec
*codec
, hda_nid_t nid
,
1739 snd_hda_codec_write(codec
, nid
, 0,
1740 AC_VERB_SET_UNSOLICITED_ENABLE
,
1741 AC_USRSP_EN
| event
);
1744 static const struct hda_verb cxt5051_ideapad_init_verbs
[] = {
1746 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1747 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0x00},
1751 /* initialize jack-sensing, too */
1752 static int cxt5051_init(struct hda_codec
*codec
)
1754 struct conexant_spec
*spec
= codec
->spec
;
1756 conexant_init(codec
);
1758 if (spec
->auto_mic
& AUTO_MIC_PORTB
)
1759 cxt5051_init_mic_port(codec
, 0x17, CXT5051_PORTB_EVENT
);
1760 if (spec
->auto_mic
& AUTO_MIC_PORTC
)
1761 cxt5051_init_mic_port(codec
, 0x18, CXT5051_PORTC_EVENT
);
1763 if (codec
->patch_ops
.unsol_event
) {
1764 cxt5051_hp_automute(codec
);
1765 cxt5051_portb_automic(codec
);
1766 cxt5051_portc_automic(codec
);
1773 CXT5051_LAPTOP
, /* Laptops w/ EAPD support */
1774 CXT5051_HP
, /* no docking */
1775 CXT5051_HP_DV6736
, /* HP without mic switch */
1776 CXT5051_F700
, /* HP Compaq Presario F700 */
1777 CXT5051_TOSHIBA
, /* Toshiba M300 & co */
1778 CXT5051_IDEAPAD
, /* Lenovo IdeaPad Y430 */
1779 CXT5051_AUTO
, /* auto-parser */
1783 static const char *const cxt5051_models
[CXT5051_MODELS
] = {
1784 [CXT5051_LAPTOP
] = "laptop",
1785 [CXT5051_HP
] = "hp",
1786 [CXT5051_HP_DV6736
] = "hp-dv6736",
1787 [CXT5051_F700
] = "hp-700",
1788 [CXT5051_TOSHIBA
] = "toshiba",
1789 [CXT5051_IDEAPAD
] = "ideapad",
1790 [CXT5051_AUTO
] = "auto",
1793 static const struct snd_pci_quirk cxt5051_cfg_tbl
[] = {
1794 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736
),
1795 SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP
),
1796 SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700
),
1797 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA
),
1798 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1800 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP
),
1801 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD
),
1805 static int patch_cxt5051(struct hda_codec
*codec
)
1807 struct conexant_spec
*spec
;
1810 board_config
= snd_hda_check_board_config(codec
, CXT5051_MODELS
,
1813 if (board_config
< 0)
1814 board_config
= CXT5051_AUTO
; /* model=auto as default */
1815 if (board_config
== CXT5051_AUTO
)
1816 return patch_conexant_auto(codec
);
1818 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1822 codec
->pin_amp_workaround
= 1;
1824 codec
->patch_ops
= conexant_patch_ops
;
1825 codec
->patch_ops
.init
= cxt5051_init
;
1827 spec
->multiout
.max_channels
= 2;
1828 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5051_dac_nids
);
1829 spec
->multiout
.dac_nids
= cxt5051_dac_nids
;
1830 spec
->multiout
.dig_out_nid
= CXT5051_SPDIF_OUT
;
1831 spec
->num_adc_nids
= 1; /* not 2; via auto-mic switch */
1832 spec
->adc_nids
= cxt5051_adc_nids
;
1833 spec
->num_mixers
= 2;
1834 spec
->mixers
[0] = cxt5051_capture_mixers
;
1835 spec
->mixers
[1] = cxt5051_playback_mixers
;
1836 spec
->num_init_verbs
= 1;
1837 spec
->init_verbs
[0] = cxt5051_init_verbs
;
1838 spec
->spdif_route
= 0;
1839 spec
->num_channel_mode
= ARRAY_SIZE(cxt5051_modes
);
1840 spec
->channel_mode
= cxt5051_modes
;
1842 spec
->cur_adc_idx
= 0;
1844 set_beep_amp(spec
, 0x13, 0, HDA_OUTPUT
);
1846 codec
->patch_ops
.unsol_event
= cxt5051_hp_unsol_event
;
1848 spec
->auto_mic
= AUTO_MIC_PORTB
| AUTO_MIC_PORTC
;
1849 switch (board_config
) {
1851 spec
->mixers
[0] = cxt5051_hp_mixers
;
1853 case CXT5051_HP_DV6736
:
1854 spec
->init_verbs
[0] = cxt5051_hp_dv6736_init_verbs
;
1855 spec
->mixers
[0] = cxt5051_hp_dv6736_mixers
;
1859 spec
->init_verbs
[0] = cxt5051_f700_init_verbs
;
1860 spec
->mixers
[0] = cxt5051_f700_mixers
;
1863 case CXT5051_TOSHIBA
:
1864 spec
->mixers
[0] = cxt5051_toshiba_mixers
;
1865 spec
->auto_mic
= AUTO_MIC_PORTB
;
1867 case CXT5051_IDEAPAD
:
1868 spec
->init_verbs
[spec
->num_init_verbs
++] =
1869 cxt5051_ideapad_init_verbs
;
1875 snd_hda_attach_beep_device(codec
, get_amp_nid_(spec
->beep_amp
));
1880 /* Conexant 5066 specific */
1882 static const hda_nid_t cxt5066_dac_nids
[1] = { 0x10 };
1883 static const hda_nid_t cxt5066_adc_nids
[3] = { 0x14, 0x15, 0x16 };
1884 static const hda_nid_t cxt5066_capsrc_nids
[1] = { 0x17 };
1885 static const hda_nid_t cxt5066_digout_pin_nids
[2] = { 0x20, 0x22 };
1887 static const struct hda_channel_mode cxt5066_modes
[1] = {
1891 #define HP_PRESENT_PORT_A (1 << 0)
1892 #define HP_PRESENT_PORT_D (1 << 1)
1893 #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A)
1894 #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D)
1896 static void cxt5066_update_speaker(struct hda_codec
*codec
)
1898 struct conexant_spec
*spec
= codec
->spec
;
1899 unsigned int pinctl
;
1902 "CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n",
1903 spec
->hp_present
, spec
->cur_eapd
);
1906 pinctl
= (hp_port_a_present(spec
) && spec
->cur_eapd
) ? PIN_HP
: 0;
1907 snd_hda_set_pin_ctl(codec
, 0x19, pinctl
);
1909 /* Port D (HP/LO) */
1910 pinctl
= spec
->cur_eapd
? spec
->port_d_mode
: 0;
1911 if (spec
->dell_automute
|| spec
->thinkpad
) {
1912 /* Mute if Port A is connected */
1913 if (hp_port_a_present(spec
))
1916 /* Thinkpad/Dell doesn't give pin-D status */
1917 if (!hp_port_d_present(spec
))
1920 snd_hda_set_pin_ctl(codec
, 0x1c, pinctl
);
1923 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1924 snd_hda_set_pin_ctl(codec
, 0x1f, pinctl
);
1927 /* turn on/off EAPD (+ mute HP) as a master switch */
1928 static int cxt5066_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1929 struct snd_ctl_elem_value
*ucontrol
)
1931 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1933 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1936 cxt5066_update_speaker(codec
);
1940 /* toggle input of built-in digital mic and mic jack appropriately */
1941 static void cxt5066_vostro_automic(struct hda_codec
*codec
)
1943 unsigned int present
;
1945 struct hda_verb ext_mic_present
[] = {
1946 /* enable external mic, port B */
1947 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1949 /* switch to external mic input */
1950 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
1951 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
1953 /* disable internal digital mic */
1954 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
1957 static const struct hda_verb ext_mic_absent
[] = {
1958 /* enable internal mic, port C */
1959 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1961 /* switch to internal mic input */
1962 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
1964 /* disable external mic, port B */
1965 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
1969 present
= snd_hda_jack_detect(codec
, 0x1a);
1971 codec_dbg(codec
, "CXT5066: external microphone detected\n");
1972 snd_hda_sequence_write(codec
, ext_mic_present
);
1974 codec_dbg(codec
, "CXT5066: external microphone absent\n");
1975 snd_hda_sequence_write(codec
, ext_mic_absent
);
1979 /* toggle input of built-in digital mic and mic jack appropriately */
1980 static void cxt5066_ideapad_automic(struct hda_codec
*codec
)
1982 unsigned int present
;
1984 struct hda_verb ext_mic_present
[] = {
1985 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
1986 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1987 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
1990 static const struct hda_verb ext_mic_absent
[] = {
1991 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
1992 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1993 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
1997 present
= snd_hda_jack_detect(codec
, 0x1b);
1999 codec_dbg(codec
, "CXT5066: external microphone detected\n");
2000 snd_hda_sequence_write(codec
, ext_mic_present
);
2002 codec_dbg(codec
, "CXT5066: external microphone absent\n");
2003 snd_hda_sequence_write(codec
, ext_mic_absent
);
2008 /* toggle input of built-in digital mic and mic jack appropriately */
2009 static void cxt5066_asus_automic(struct hda_codec
*codec
)
2011 unsigned int present
;
2013 present
= snd_hda_jack_detect(codec
, 0x1b);
2014 codec_dbg(codec
, "CXT5066: external microphone present=%d\n", present
);
2015 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2020 /* toggle input of built-in digital mic and mic jack appropriately */
2021 static void cxt5066_hp_laptop_automic(struct hda_codec
*codec
)
2023 unsigned int present
;
2025 present
= snd_hda_jack_detect(codec
, 0x1b);
2026 codec_dbg(codec
, "CXT5066: external microphone present=%d\n", present
);
2027 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2032 /* toggle input of built-in digital mic and mic jack appropriately
2033 order is: external mic -> dock mic -> interal mic */
2034 static void cxt5066_thinkpad_automic(struct hda_codec
*codec
)
2036 unsigned int ext_present
, dock_present
;
2038 static const struct hda_verb ext_mic_present
[] = {
2039 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2040 {0x17, AC_VERB_SET_CONNECT_SEL
, 1},
2041 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2042 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2043 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2046 static const struct hda_verb dock_mic_present
[] = {
2047 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2048 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2049 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2050 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2051 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2054 static const struct hda_verb ext_mic_absent
[] = {
2055 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2056 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2057 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2058 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2062 ext_present
= snd_hda_jack_detect(codec
, 0x1b);
2063 dock_present
= snd_hda_jack_detect(codec
, 0x1a);
2065 codec_dbg(codec
, "CXT5066: external microphone detected\n");
2066 snd_hda_sequence_write(codec
, ext_mic_present
);
2067 } else if (dock_present
) {
2068 codec_dbg(codec
, "CXT5066: dock microphone detected\n");
2069 snd_hda_sequence_write(codec
, dock_mic_present
);
2071 codec_dbg(codec
, "CXT5066: external microphone absent\n");
2072 snd_hda_sequence_write(codec
, ext_mic_absent
);
2076 /* mute internal speaker if HP is plugged */
2077 static void cxt5066_hp_automute(struct hda_codec
*codec
)
2079 struct conexant_spec
*spec
= codec
->spec
;
2080 unsigned int portA
, portD
;
2083 portA
= snd_hda_jack_detect(codec
, 0x19);
2086 portD
= snd_hda_jack_detect(codec
, 0x1c);
2088 spec
->hp_present
= portA
? HP_PRESENT_PORT_A
: 0;
2089 spec
->hp_present
|= portD
? HP_PRESENT_PORT_D
: 0;
2090 codec_dbg(codec
, "CXT5066: hp automute portA=%x portD=%x present=%d\n",
2091 portA
, portD
, spec
->hp_present
);
2092 cxt5066_update_speaker(codec
);
2095 /* Dispatch the right mic autoswitch function */
2096 static void cxt5066_automic(struct hda_codec
*codec
)
2098 struct conexant_spec
*spec
= codec
->spec
;
2100 if (spec
->dell_vostro
)
2101 cxt5066_vostro_automic(codec
);
2102 else if (spec
->ideapad
)
2103 cxt5066_ideapad_automic(codec
);
2104 else if (spec
->thinkpad
)
2105 cxt5066_thinkpad_automic(codec
);
2106 else if (spec
->hp_laptop
)
2107 cxt5066_hp_laptop_automic(codec
);
2108 else if (spec
->asus
)
2109 cxt5066_asus_automic(codec
);
2112 /* unsolicited event for jack sensing */
2113 static void cxt5066_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2115 codec_dbg(codec
, "CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2116 switch (res
>> 26) {
2117 case CONEXANT_HP_EVENT
:
2118 cxt5066_hp_automute(codec
);
2120 case CONEXANT_MIC_EVENT
:
2121 cxt5066_automic(codec
);
2127 static const struct hda_input_mux cxt5066_analog_mic_boost
= {
2138 static void cxt5066_set_mic_boost(struct hda_codec
*codec
)
2140 struct conexant_spec
*spec
= codec
->spec
;
2141 snd_hda_codec_write_cache(codec
, 0x17, 0,
2142 AC_VERB_SET_AMP_GAIN_MUTE
,
2143 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_OUTPUT
|
2144 cxt5066_analog_mic_boost
.items
[spec
->mic_boost
].index
);
2145 if (spec
->ideapad
|| spec
->thinkpad
) {
2146 /* adjust the internal mic as well...it is not through 0x17 */
2147 snd_hda_codec_write_cache(codec
, 0x23, 0,
2148 AC_VERB_SET_AMP_GAIN_MUTE
,
2149 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_INPUT
|
2150 cxt5066_analog_mic_boost
.
2151 items
[spec
->mic_boost
].index
);
2155 static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol
*kcontrol
,
2156 struct snd_ctl_elem_info
*uinfo
)
2158 return snd_hda_input_mux_info(&cxt5066_analog_mic_boost
, uinfo
);
2161 static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol
*kcontrol
,
2162 struct snd_ctl_elem_value
*ucontrol
)
2164 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2165 struct conexant_spec
*spec
= codec
->spec
;
2166 ucontrol
->value
.enumerated
.item
[0] = spec
->mic_boost
;
2170 static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol
*kcontrol
,
2171 struct snd_ctl_elem_value
*ucontrol
)
2173 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2174 struct conexant_spec
*spec
= codec
->spec
;
2175 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2177 idx
= ucontrol
->value
.enumerated
.item
[0];
2178 if (idx
>= imux
->num_items
)
2179 idx
= imux
->num_items
- 1;
2181 spec
->mic_boost
= idx
;
2182 cxt5066_set_mic_boost(codec
);
2186 static void conexant_check_dig_outs(struct hda_codec
*codec
,
2187 const hda_nid_t
*dig_pins
,
2190 struct conexant_spec
*spec
= codec
->spec
;
2191 hda_nid_t
*nid_loc
= &spec
->multiout
.dig_out_nid
;
2194 for (i
= 0; i
< num_pins
; i
++, dig_pins
++) {
2195 unsigned int cfg
= snd_hda_codec_get_pincfg(codec
, *dig_pins
);
2196 if (get_defcfg_connect(cfg
) == AC_JACK_PORT_NONE
)
2198 if (snd_hda_get_connections(codec
, *dig_pins
, nid_loc
, 1) != 1)
2203 static const struct hda_input_mux cxt5066_capture_source
= {
2213 static const struct hda_bind_ctls cxt5066_bind_capture_vol_others
= {
2214 .ops
= &snd_hda_bind_vol
,
2216 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2217 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2222 static const struct hda_bind_ctls cxt5066_bind_capture_sw_others
= {
2223 .ops
= &snd_hda_bind_sw
,
2225 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2226 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2231 static const struct snd_kcontrol_new cxt5066_mixer_master
[] = {
2232 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
2236 static const struct snd_kcontrol_new cxt5066_mixers
[] = {
2238 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2239 .name
= "Master Playback Switch",
2240 .info
= cxt_eapd_info
,
2241 .get
= cxt_eapd_get
,
2242 .put
= cxt5066_hp_master_sw_put
,
2243 .private_value
= 0x1d,
2247 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2248 .name
= "Analog Mic Boost Capture Enum",
2249 .info
= cxt5066_mic_boost_mux_enum_info
,
2250 .get
= cxt5066_mic_boost_mux_enum_get
,
2251 .put
= cxt5066_mic_boost_mux_enum_put
,
2254 HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others
),
2255 HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others
),
2259 static const struct snd_kcontrol_new cxt5066_vostro_mixers
[] = {
2261 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2262 .name
= "Internal Mic Boost Capture Enum",
2263 .info
= cxt5066_mic_boost_mux_enum_info
,
2264 .get
= cxt5066_mic_boost_mux_enum_get
,
2265 .put
= cxt5066_mic_boost_mux_enum_put
,
2266 .private_value
= 0x23 | 0x100,
2271 static const struct hda_verb cxt5066_init_verbs
[] = {
2272 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2273 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2274 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2275 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2278 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2279 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2282 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2283 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2285 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2286 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2289 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2291 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2292 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2293 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2294 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2295 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2296 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2298 /* no digital microphone support yet */
2299 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2301 /* Audio input selector */
2302 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2304 /* SPDIF route: PCM */
2305 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2306 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2308 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2309 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2312 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2314 /* not handling these yet */
2315 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2316 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2317 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2318 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2319 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2320 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2321 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2322 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2326 static const struct hda_verb cxt5066_init_verbs_vostro
[] = {
2327 /* Port A: headphones */
2328 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2329 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2331 /* Port B: external microphone */
2332 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2334 /* Port C: unused */
2335 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2337 /* Port D: unused */
2338 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2340 /* Port E: unused, but has primary EAPD */
2341 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2342 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2344 /* Port F: unused */
2345 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2347 /* Port G: internal speakers */
2348 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2349 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2352 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2355 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2357 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2358 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2359 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2360 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2361 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2362 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2363 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2364 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2365 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2366 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2367 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2368 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2370 /* Digital microphone port */
2371 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2373 /* Audio input selectors */
2374 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2375 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2378 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2379 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2381 /* enable unsolicited events for Port A and B */
2382 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2383 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2387 static const struct hda_verb cxt5066_init_verbs_ideapad
[] = {
2388 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2389 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2390 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2391 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2394 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2395 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2398 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2399 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2401 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2402 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2405 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2407 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2408 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2409 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2410 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2411 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2412 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2413 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2415 /* Audio input selector */
2416 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2417 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2419 /* SPDIF route: PCM */
2420 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2421 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2423 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2424 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2426 /* internal microphone */
2427 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable internal mic */
2430 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2432 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2433 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2437 static const struct hda_verb cxt5066_init_verbs_thinkpad
[] = {
2438 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2439 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2441 /* Port G: internal speakers */
2442 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2443 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2445 /* Port A: HP, Amp */
2446 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2447 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2449 /* Port B: Mic Dock */
2450 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2453 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2455 /* Port D: HP Dock, Amp */
2456 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2457 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2460 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2462 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2463 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2464 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2465 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2466 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2467 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2468 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2470 /* Audio input selector */
2471 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2472 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2474 /* SPDIF route: PCM */
2475 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2476 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2478 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2479 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2481 /* internal microphone */
2482 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable internal mic */
2485 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2487 /* enable unsolicited events for Port A, B, C and D */
2488 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2489 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2490 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2491 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2495 static const struct hda_verb cxt5066_init_verbs_portd_lo
[] = {
2496 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2501 static const struct hda_verb cxt5066_init_verbs_hp_laptop
[] = {
2502 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x0},
2503 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2504 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2508 /* initialize jack-sensing, too */
2509 static int cxt5066_init(struct hda_codec
*codec
)
2511 codec_dbg(codec
, "CXT5066: init\n");
2512 conexant_init(codec
);
2513 if (codec
->patch_ops
.unsol_event
) {
2514 cxt5066_hp_automute(codec
);
2515 cxt5066_automic(codec
);
2517 cxt5066_set_mic_boost(codec
);
2522 CXT5066_LAPTOP
, /* Laptops w/ EAPD support */
2523 CXT5066_DELL_LAPTOP
, /* Dell Laptop */
2524 CXT5066_DELL_VOSTRO
, /* Dell Vostro 1015i */
2525 CXT5066_IDEAPAD
, /* Lenovo IdeaPad U150 */
2526 CXT5066_THINKPAD
, /* Lenovo ThinkPad T410s, others? */
2527 CXT5066_ASUS
, /* Asus K52JU, Lenovo G560 - Int mic at 0x1a and Ext mic at 0x1b */
2528 CXT5066_HP_LAPTOP
, /* HP Laptop */
2529 CXT5066_AUTO
, /* BIOS auto-parser */
2533 static const char * const cxt5066_models
[CXT5066_MODELS
] = {
2534 [CXT5066_LAPTOP
] = "laptop",
2535 [CXT5066_DELL_LAPTOP
] = "dell-laptop",
2536 [CXT5066_DELL_VOSTRO
] = "dell-vostro",
2537 [CXT5066_IDEAPAD
] = "ideapad",
2538 [CXT5066_THINKPAD
] = "thinkpad",
2539 [CXT5066_ASUS
] = "asus",
2540 [CXT5066_HP_LAPTOP
] = "hp-laptop",
2541 [CXT5066_AUTO
] = "auto",
2544 static const struct snd_pci_quirk cxt5066_cfg_tbl
[] = {
2545 SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD
),
2546 SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO
),
2547 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD
),
2548 SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO
),
2549 SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD
),
2550 SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD
),
2551 SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP
),
2552 SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS
),
2553 SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS
),
2554 SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS
),
2555 SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD
),
2556 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
2558 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD
),
2559 SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD
),
2560 SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS
),
2561 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo U350", CXT5066_ASUS
),
2562 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS
),
2566 static int patch_cxt5066(struct hda_codec
*codec
)
2568 struct conexant_spec
*spec
;
2571 board_config
= snd_hda_check_board_config(codec
, CXT5066_MODELS
,
2572 cxt5066_models
, cxt5066_cfg_tbl
);
2573 if (board_config
< 0)
2574 board_config
= CXT5066_AUTO
; /* model=auto as default */
2575 if (board_config
== CXT5066_AUTO
)
2576 return patch_conexant_auto(codec
);
2578 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2583 codec
->patch_ops
= conexant_patch_ops
;
2584 codec
->patch_ops
.init
= conexant_init
;
2586 spec
->dell_automute
= 0;
2587 spec
->multiout
.max_channels
= 2;
2588 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5066_dac_nids
);
2589 spec
->multiout
.dac_nids
= cxt5066_dac_nids
;
2590 conexant_check_dig_outs(codec
, cxt5066_digout_pin_nids
,
2591 ARRAY_SIZE(cxt5066_digout_pin_nids
));
2592 spec
->num_adc_nids
= 1;
2593 spec
->adc_nids
= cxt5066_adc_nids
;
2594 spec
->capsrc_nids
= cxt5066_capsrc_nids
;
2595 spec
->input_mux
= &cxt5066_capture_source
;
2597 spec
->port_d_mode
= PIN_HP
;
2599 spec
->num_init_verbs
= 1;
2600 spec
->init_verbs
[0] = cxt5066_init_verbs
;
2601 spec
->num_channel_mode
= ARRAY_SIZE(cxt5066_modes
);
2602 spec
->channel_mode
= cxt5066_modes
;
2604 spec
->cur_adc_idx
= 0;
2606 set_beep_amp(spec
, 0x13, 0, HDA_OUTPUT
);
2608 switch (board_config
) {
2610 case CXT5066_LAPTOP
:
2611 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
2612 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2614 case CXT5066_DELL_LAPTOP
:
2615 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
2616 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2618 spec
->port_d_mode
= PIN_OUT
;
2619 spec
->init_verbs
[spec
->num_init_verbs
] = cxt5066_init_verbs_portd_lo
;
2620 spec
->num_init_verbs
++;
2621 spec
->dell_automute
= 1;
2624 case CXT5066_HP_LAPTOP
:
2625 codec
->patch_ops
.init
= cxt5066_init
;
2626 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
2627 spec
->init_verbs
[spec
->num_init_verbs
] =
2628 cxt5066_init_verbs_hp_laptop
;
2629 spec
->num_init_verbs
++;
2630 spec
->hp_laptop
= board_config
== CXT5066_HP_LAPTOP
;
2631 spec
->asus
= board_config
== CXT5066_ASUS
;
2632 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
2633 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2635 if (board_config
== CXT5066_HP_LAPTOP
)
2636 spec
->multiout
.dig_out_nid
= 0;
2637 /* input source automatically selected */
2638 spec
->input_mux
= NULL
;
2639 spec
->port_d_mode
= 0;
2640 spec
->mic_boost
= 3; /* default 30dB gain */
2643 case CXT5066_DELL_VOSTRO
:
2644 codec
->patch_ops
.init
= cxt5066_init
;
2645 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
2646 spec
->init_verbs
[0] = cxt5066_init_verbs_vostro
;
2647 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
2648 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2649 spec
->mixers
[spec
->num_mixers
++] = cxt5066_vostro_mixers
;
2650 spec
->port_d_mode
= 0;
2651 spec
->dell_vostro
= 1;
2652 spec
->mic_boost
= 3; /* default 30dB gain */
2655 spec
->multiout
.dig_out_nid
= 0;
2657 /* input source automatically selected */
2658 spec
->input_mux
= NULL
;
2660 case CXT5066_IDEAPAD
:
2661 codec
->patch_ops
.init
= cxt5066_init
;
2662 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
2663 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
2664 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2665 spec
->init_verbs
[0] = cxt5066_init_verbs_ideapad
;
2666 spec
->port_d_mode
= 0;
2668 spec
->mic_boost
= 2; /* default 20dB gain */
2671 spec
->multiout
.dig_out_nid
= 0;
2673 /* input source automatically selected */
2674 spec
->input_mux
= NULL
;
2676 case CXT5066_THINKPAD
:
2677 codec
->patch_ops
.init
= cxt5066_init
;
2678 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
2679 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
2680 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2681 spec
->init_verbs
[0] = cxt5066_init_verbs_thinkpad
;
2683 spec
->port_d_mode
= PIN_OUT
;
2684 spec
->mic_boost
= 2; /* default 20dB gain */
2687 spec
->multiout
.dig_out_nid
= 0;
2689 /* input source automatically selected */
2690 spec
->input_mux
= NULL
;
2695 snd_hda_attach_beep_device(codec
, get_amp_nid_(spec
->beep_amp
));
2700 #endif /* ENABLE_CXT_STATIC_QUIRKS */
2704 * Automatic parser for CX20641 & co
2707 #ifdef CONFIG_SND_HDA_INPUT_BEEP
2708 static void cx_auto_parse_beep(struct hda_codec
*codec
)
2710 struct conexant_spec
*spec
= codec
->spec
;
2711 hda_nid_t nid
, end_nid
;
2713 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
2714 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++)
2715 if (get_wcaps_type(get_wcaps(codec
, nid
)) == AC_WID_BEEP
) {
2716 set_beep_amp(spec
, nid
, 0, HDA_OUTPUT
);
2721 #define cx_auto_parse_beep(codec)
2725 static void cx_auto_parse_eapd(struct hda_codec
*codec
)
2727 struct conexant_spec
*spec
= codec
->spec
;
2728 hda_nid_t nid
, end_nid
;
2730 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
2731 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
2732 if (get_wcaps_type(get_wcaps(codec
, nid
)) != AC_WID_PIN
)
2734 if (!(snd_hda_query_pin_caps(codec
, nid
) & AC_PINCAP_EAPD
))
2736 spec
->eapds
[spec
->num_eapds
++] = nid
;
2737 if (spec
->num_eapds
>= ARRAY_SIZE(spec
->eapds
))
2741 /* NOTE: below is a wild guess; if we have more than two EAPDs,
2742 * it's a new chip, where EAPDs are supposed to be associated to
2743 * pins, and we can control EAPD per pin.
2744 * OTOH, if only one or two EAPDs are found, it's an old chip,
2745 * thus it might control over all pins.
2747 if (spec
->num_eapds
> 2)
2748 spec
->dynamic_eapd
= 1;
2751 static void cx_auto_turn_eapd(struct hda_codec
*codec
, int num_pins
,
2752 hda_nid_t
*pins
, bool on
)
2755 for (i
= 0; i
< num_pins
; i
++) {
2756 if (snd_hda_query_pin_caps(codec
, pins
[i
]) & AC_PINCAP_EAPD
)
2757 snd_hda_codec_write(codec
, pins
[i
], 0,
2758 AC_VERB_SET_EAPD_BTLENABLE
,
2763 /* turn on/off EAPD according to Master switch */
2764 static void cx_auto_vmaster_hook(void *private_data
, int enabled
)
2766 struct hda_codec
*codec
= private_data
;
2767 struct conexant_spec
*spec
= codec
->spec
;
2769 cx_auto_turn_eapd(codec
, spec
->num_eapds
, spec
->eapds
, enabled
);
2772 static int cx_auto_build_controls(struct hda_codec
*codec
)
2776 err
= snd_hda_gen_build_controls(codec
);
2780 err
= add_beep_ctls(codec
);
2787 static int cx_auto_init(struct hda_codec
*codec
)
2789 struct conexant_spec
*spec
= codec
->spec
;
2790 snd_hda_gen_init(codec
);
2791 if (!spec
->dynamic_eapd
)
2792 cx_auto_turn_eapd(codec
, spec
->num_eapds
, spec
->eapds
, true);
2794 snd_hda_apply_fixup(codec
, HDA_FIXUP_ACT_INIT
);
2799 #define cx_auto_free snd_hda_gen_free
2801 static const struct hda_codec_ops cx_auto_patch_ops
= {
2802 .build_controls
= cx_auto_build_controls
,
2803 .build_pcms
= snd_hda_gen_build_pcms
,
2804 .init
= cx_auto_init
,
2805 .free
= cx_auto_free
,
2806 .unsol_event
= snd_hda_jack_unsol_event
,
2808 .check_power_status
= snd_hda_gen_check_power_status
,
2816 CXT_PINCFG_LENOVO_X200
,
2817 CXT_PINCFG_LENOVO_TP410
,
2818 CXT_PINCFG_LEMOTE_A1004
,
2819 CXT_PINCFG_LEMOTE_A1205
,
2820 CXT_FIXUP_STEREO_DMIC
,
2821 CXT_FIXUP_INC_MIC_BOOST
,
2822 CXT_FIXUP_HEADPHONE_MIC_PIN
,
2823 CXT_FIXUP_HEADPHONE_MIC
,
2825 CXT_FIXUP_THINKPAD_ACPI
,
2827 CXT_FIXUP_CAP_MIX_AMP
,
2828 CXT_FIXUP_TOSHIBA_P105
,
2830 CXT_FIXUP_CAP_MIX_AMP_5047
,
2833 /* for hda_fixup_thinkpad_acpi() */
2834 #include "thinkpad_helper.c"
2836 static void cxt_fixup_stereo_dmic(struct hda_codec
*codec
,
2837 const struct hda_fixup
*fix
, int action
)
2839 struct conexant_spec
*spec
= codec
->spec
;
2840 spec
->gen
.inv_dmic_split
= 1;
2843 static void cxt5066_increase_mic_boost(struct hda_codec
*codec
,
2844 const struct hda_fixup
*fix
, int action
)
2846 if (action
!= HDA_FIXUP_ACT_PRE_PROBE
)
2849 snd_hda_override_amp_caps(codec
, 0x17, HDA_OUTPUT
,
2850 (0x3 << AC_AMPCAP_OFFSET_SHIFT
) |
2851 (0x4 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
2852 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
2853 (0 << AC_AMPCAP_MUTE_SHIFT
));
2856 static void cxt_update_headset_mode(struct hda_codec
*codec
)
2858 /* The verbs used in this function were tested on a Conexant CX20751/2 codec. */
2860 bool mic_mode
= false;
2861 struct conexant_spec
*spec
= codec
->spec
;
2862 struct auto_pin_cfg
*cfg
= &spec
->gen
.autocfg
;
2864 hda_nid_t mux_pin
= spec
->gen
.imux_pins
[spec
->gen
.cur_mux
[0]];
2866 for (i
= 0; i
< cfg
->num_inputs
; i
++)
2867 if (cfg
->inputs
[i
].pin
== mux_pin
) {
2868 mic_mode
= !!cfg
->inputs
[i
].is_headphone_mic
;
2873 snd_hda_codec_write_cache(codec
, 0x1c, 0, 0x410, 0x7c); /* enable merged mode for analog int-mic */
2874 spec
->gen
.hp_jack_present
= false;
2876 snd_hda_codec_write_cache(codec
, 0x1c, 0, 0x410, 0x54); /* disable merged mode for analog int-mic */
2877 spec
->gen
.hp_jack_present
= snd_hda_jack_detect(codec
, spec
->gen
.autocfg
.hp_pins
[0]);
2880 snd_hda_gen_update_outputs(codec
);
2883 static void cxt_update_headset_mode_hook(struct hda_codec
*codec
,
2884 struct snd_kcontrol
*kcontrol
,
2885 struct snd_ctl_elem_value
*ucontrol
)
2887 cxt_update_headset_mode(codec
);
2890 static void cxt_fixup_headphone_mic(struct hda_codec
*codec
,
2891 const struct hda_fixup
*fix
, int action
)
2893 struct conexant_spec
*spec
= codec
->spec
;
2896 case HDA_FIXUP_ACT_PRE_PROBE
:
2897 spec
->parse_flags
|= HDA_PINCFG_HEADPHONE_MIC
;
2899 case HDA_FIXUP_ACT_PROBE
:
2900 spec
->gen
.cap_sync_hook
= cxt_update_headset_mode_hook
;
2901 spec
->gen
.automute_hook
= cxt_update_headset_mode
;
2903 case HDA_FIXUP_ACT_INIT
:
2904 cxt_update_headset_mode(codec
);
2909 /* OPLC XO 1.5 fixup */
2911 /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
2912 * through the microphone jack.
2913 * When the user enables this through a mixer switch, both internal and
2914 * external microphones are disabled. Gain is fixed at 0dB. In this mode,
2915 * we also allow the bias to be configured through a separate mixer
2918 #define update_mic_pin(codec, nid, val) \
2919 snd_hda_codec_update_cache(codec, nid, 0, \
2920 AC_VERB_SET_PIN_WIDGET_CONTROL, val)
2922 static const struct hda_input_mux olpc_xo_dc_bias
= {
2926 { "50%", PIN_VREF50
},
2927 { "80%", PIN_VREF80
},
2931 static void olpc_xo_update_mic_boost(struct hda_codec
*codec
)
2933 struct conexant_spec
*spec
= codec
->spec
;
2936 for (ch
= 0; ch
< 2; ch
++) {
2937 val
= AC_AMP_SET_OUTPUT
|
2938 (ch
? AC_AMP_SET_RIGHT
: AC_AMP_SET_LEFT
);
2939 if (!spec
->dc_enable
)
2940 val
|= snd_hda_codec_amp_read(codec
, 0x17, ch
, HDA_OUTPUT
, 0);
2941 snd_hda_codec_write(codec
, 0x17, 0,
2942 AC_VERB_SET_AMP_GAIN_MUTE
, val
);
2946 static void olpc_xo_update_mic_pins(struct hda_codec
*codec
)
2948 struct conexant_spec
*spec
= codec
->spec
;
2950 struct nid_path
*path
;
2952 cur_input
= spec
->gen
.input_paths
[0][spec
->gen
.cur_mux
[0]];
2954 /* Set up mic pins for port-B, C and F dynamically as the recording
2955 * LED is turned on/off by these pin controls
2957 if (!spec
->dc_enable
) {
2958 /* disable DC bias path and pin for port F */
2959 update_mic_pin(codec
, 0x1e, 0);
2960 snd_hda_activate_path(codec
, spec
->dc_mode_path
, false, false);
2962 /* update port B (ext mic) and C (int mic) */
2963 /* OLPC defers mic widget control until when capture is
2964 * started because the microphone LED comes on as soon as
2965 * these settings are put in place. if we did this before
2966 * recording, it would give the false indication that
2967 * recording is happening when it is not.
2969 update_mic_pin(codec
, 0x1a, spec
->recording
?
2970 snd_hda_codec_get_pin_target(codec
, 0x1a) : 0);
2971 update_mic_pin(codec
, 0x1b, spec
->recording
?
2972 snd_hda_codec_get_pin_target(codec
, 0x1b) : 0);
2973 /* enable normal mic path */
2974 path
= snd_hda_get_path_from_idx(codec
, cur_input
);
2976 snd_hda_activate_path(codec
, path
, true, false);
2978 /* disable normal mic path */
2979 path
= snd_hda_get_path_from_idx(codec
, cur_input
);
2981 snd_hda_activate_path(codec
, path
, false, false);
2983 /* Even though port F is the DC input, the bias is controlled
2984 * on port B. We also leave that port as an active input (but
2985 * unselected) in DC mode just in case that is necessary to
2986 * make the bias setting take effect.
2988 if (spec
->recording
)
2989 val
= olpc_xo_dc_bias
.items
[spec
->dc_input_bias
].index
;
2992 update_mic_pin(codec
, 0x1a, val
);
2993 update_mic_pin(codec
, 0x1b, 0);
2994 /* enable DC bias path and pin */
2995 update_mic_pin(codec
, 0x1e, spec
->recording
? PIN_IN
: 0);
2996 snd_hda_activate_path(codec
, spec
->dc_mode_path
, true, false);
3000 /* mic_autoswitch hook */
3001 static void olpc_xo_automic(struct hda_codec
*codec
, struct hda_jack_tbl
*jack
)
3003 struct conexant_spec
*spec
= codec
->spec
;
3004 int saved_cached_write
= codec
->cached_write
;
3006 codec
->cached_write
= 1;
3007 /* in DC mode, we don't handle automic */
3008 if (!spec
->dc_enable
)
3009 snd_hda_gen_mic_autoswitch(codec
, jack
);
3010 olpc_xo_update_mic_pins(codec
);
3011 snd_hda_codec_flush_cache(codec
);
3012 codec
->cached_write
= saved_cached_write
;
3013 if (spec
->dc_enable
)
3014 olpc_xo_update_mic_boost(codec
);
3017 /* pcm_capture hook */
3018 static void olpc_xo_capture_hook(struct hda_pcm_stream
*hinfo
,
3019 struct hda_codec
*codec
,
3020 struct snd_pcm_substream
*substream
,
3023 struct conexant_spec
*spec
= codec
->spec
;
3025 /* toggle spec->recording flag and update mic pins accordingly
3026 * for turning on/off LED
3029 case HDA_GEN_PCM_ACT_PREPARE
:
3030 spec
->recording
= 1;
3031 olpc_xo_update_mic_pins(codec
);
3033 case HDA_GEN_PCM_ACT_CLEANUP
:
3034 spec
->recording
= 0;
3035 olpc_xo_update_mic_pins(codec
);
3040 static int olpc_xo_dc_mode_get(struct snd_kcontrol
*kcontrol
,
3041 struct snd_ctl_elem_value
*ucontrol
)
3043 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3044 struct conexant_spec
*spec
= codec
->spec
;
3045 ucontrol
->value
.integer
.value
[0] = spec
->dc_enable
;
3049 static int olpc_xo_dc_mode_put(struct snd_kcontrol
*kcontrol
,
3050 struct snd_ctl_elem_value
*ucontrol
)
3052 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3053 struct conexant_spec
*spec
= codec
->spec
;
3054 int dc_enable
= !!ucontrol
->value
.integer
.value
[0];
3056 if (dc_enable
== spec
->dc_enable
)
3059 spec
->dc_enable
= dc_enable
;
3060 olpc_xo_update_mic_pins(codec
);
3061 olpc_xo_update_mic_boost(codec
);
3065 static int olpc_xo_dc_bias_enum_get(struct snd_kcontrol
*kcontrol
,
3066 struct snd_ctl_elem_value
*ucontrol
)
3068 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3069 struct conexant_spec
*spec
= codec
->spec
;
3070 ucontrol
->value
.enumerated
.item
[0] = spec
->dc_input_bias
;
3074 static int olpc_xo_dc_bias_enum_info(struct snd_kcontrol
*kcontrol
,
3075 struct snd_ctl_elem_info
*uinfo
)
3077 return snd_hda_input_mux_info(&olpc_xo_dc_bias
, uinfo
);
3080 static int olpc_xo_dc_bias_enum_put(struct snd_kcontrol
*kcontrol
,
3081 struct snd_ctl_elem_value
*ucontrol
)
3083 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3084 struct conexant_spec
*spec
= codec
->spec
;
3085 const struct hda_input_mux
*imux
= &olpc_xo_dc_bias
;
3088 idx
= ucontrol
->value
.enumerated
.item
[0];
3089 if (idx
>= imux
->num_items
)
3090 idx
= imux
->num_items
- 1;
3091 if (spec
->dc_input_bias
== idx
)
3094 spec
->dc_input_bias
= idx
;
3095 if (spec
->dc_enable
)
3096 olpc_xo_update_mic_pins(codec
);
3100 static const struct snd_kcontrol_new olpc_xo_mixers
[] = {
3102 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3103 .name
= "DC Mode Enable Switch",
3104 .info
= snd_ctl_boolean_mono_info
,
3105 .get
= olpc_xo_dc_mode_get
,
3106 .put
= olpc_xo_dc_mode_put
,
3109 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3110 .name
= "DC Input Bias Enum",
3111 .info
= olpc_xo_dc_bias_enum_info
,
3112 .get
= olpc_xo_dc_bias_enum_get
,
3113 .put
= olpc_xo_dc_bias_enum_put
,
3118 /* overriding mic boost put callback; update mic boost volume only when
3119 * DC mode is disabled
3121 static int olpc_xo_mic_boost_put(struct snd_kcontrol
*kcontrol
,
3122 struct snd_ctl_elem_value
*ucontrol
)
3124 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3125 struct conexant_spec
*spec
= codec
->spec
;
3126 int ret
= snd_hda_mixer_amp_volume_put(kcontrol
, ucontrol
);
3127 if (ret
> 0 && spec
->dc_enable
)
3128 olpc_xo_update_mic_boost(codec
);
3132 static void cxt_fixup_olpc_xo(struct hda_codec
*codec
,
3133 const struct hda_fixup
*fix
, int action
)
3135 struct conexant_spec
*spec
= codec
->spec
;
3138 if (action
!= HDA_FIXUP_ACT_PROBE
)
3141 spec
->gen
.mic_autoswitch_hook
= olpc_xo_automic
;
3142 spec
->gen
.pcm_capture_hook
= olpc_xo_capture_hook
;
3143 spec
->dc_mode_path
= snd_hda_add_new_path(codec
, 0x1e, 0x14, 0);
3145 snd_hda_add_new_ctls(codec
, olpc_xo_mixers
);
3147 /* OLPC's microphone port is DC coupled for use with external sensors,
3148 * therefore we use a 50% mic bias in order to center the input signal
3149 * with the DC input range of the codec.
3151 snd_hda_codec_set_pin_target(codec
, 0x1a, PIN_VREF50
);
3153 /* override mic boost control */
3154 for (i
= 0; i
< spec
->gen
.kctls
.used
; i
++) {
3155 struct snd_kcontrol_new
*kctl
=
3156 snd_array_elem(&spec
->gen
.kctls
, i
);
3157 if (!strcmp(kctl
->name
, "Mic Boost Volume")) {
3158 kctl
->put
= olpc_xo_mic_boost_put
;
3165 * Fix max input level on mixer widget to 0dB
3166 * (originally it has 0x2b steps with 0dB offset 0x14)
3168 static void cxt_fixup_cap_mix_amp(struct hda_codec
*codec
,
3169 const struct hda_fixup
*fix
, int action
)
3171 snd_hda_override_amp_caps(codec
, 0x17, HDA_INPUT
,
3172 (0x14 << AC_AMPCAP_OFFSET_SHIFT
) |
3173 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
3174 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
3175 (1 << AC_AMPCAP_MUTE_SHIFT
));
3179 * Fix max input level on mixer widget to 0dB
3180 * (originally it has 0x1e steps with 0 dB offset 0x17)
3182 static void cxt_fixup_cap_mix_amp_5047(struct hda_codec
*codec
,
3183 const struct hda_fixup
*fix
, int action
)
3185 snd_hda_override_amp_caps(codec
, 0x10, HDA_INPUT
,
3186 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
3187 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
3188 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
3189 (1 << AC_AMPCAP_MUTE_SHIFT
));
3192 /* ThinkPad X200 & co with cxt5051 */
3193 static const struct hda_pintbl cxt_pincfg_lenovo_x200
[] = {
3194 { 0x16, 0x042140ff }, /* HP (seq# overridden) */
3195 { 0x17, 0x21a11000 }, /* dock-mic */
3196 { 0x19, 0x2121103f }, /* dock-HP */
3197 { 0x1c, 0x21440100 }, /* dock SPDIF out */
3201 /* ThinkPad 410/420/510/520, X201 & co with cxt5066 */
3202 static const struct hda_pintbl cxt_pincfg_lenovo_tp410
[] = {
3203 { 0x19, 0x042110ff }, /* HP (seq# overridden) */
3204 { 0x1a, 0x21a190f0 }, /* dock-mic */
3205 { 0x1c, 0x212140ff }, /* dock-HP */
3209 /* Lemote A1004/A1205 with cxt5066 */
3210 static const struct hda_pintbl cxt_pincfg_lemote
[] = {
3211 { 0x1a, 0x90a10020 }, /* Internal mic */
3212 { 0x1b, 0x03a11020 }, /* External mic */
3213 { 0x1d, 0x400101f0 }, /* Not used */
3214 { 0x1e, 0x40a701f0 }, /* Not used */
3215 { 0x20, 0x404501f0 }, /* Not used */
3216 { 0x22, 0x404401f0 }, /* Not used */
3217 { 0x23, 0x40a701f0 }, /* Not used */
3221 static const struct hda_fixup cxt_fixups
[] = {
3222 [CXT_PINCFG_LENOVO_X200
] = {
3223 .type
= HDA_FIXUP_PINS
,
3224 .v
.pins
= cxt_pincfg_lenovo_x200
,
3226 [CXT_PINCFG_LENOVO_TP410
] = {
3227 .type
= HDA_FIXUP_PINS
,
3228 .v
.pins
= cxt_pincfg_lenovo_tp410
,
3230 .chain_id
= CXT_FIXUP_THINKPAD_ACPI
,
3232 [CXT_PINCFG_LEMOTE_A1004
] = {
3233 .type
= HDA_FIXUP_PINS
,
3235 .chain_id
= CXT_FIXUP_INC_MIC_BOOST
,
3236 .v
.pins
= cxt_pincfg_lemote
,
3238 [CXT_PINCFG_LEMOTE_A1205
] = {
3239 .type
= HDA_FIXUP_PINS
,
3240 .v
.pins
= cxt_pincfg_lemote
,
3242 [CXT_FIXUP_STEREO_DMIC
] = {
3243 .type
= HDA_FIXUP_FUNC
,
3244 .v
.func
= cxt_fixup_stereo_dmic
,
3246 [CXT_FIXUP_INC_MIC_BOOST
] = {
3247 .type
= HDA_FIXUP_FUNC
,
3248 .v
.func
= cxt5066_increase_mic_boost
,
3250 [CXT_FIXUP_HEADPHONE_MIC_PIN
] = {
3251 .type
= HDA_FIXUP_PINS
,
3253 .chain_id
= CXT_FIXUP_HEADPHONE_MIC
,
3254 .v
.pins
= (const struct hda_pintbl
[]) {
3255 { 0x18, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
3259 [CXT_FIXUP_HEADPHONE_MIC
] = {
3260 .type
= HDA_FIXUP_FUNC
,
3261 .v
.func
= cxt_fixup_headphone_mic
,
3263 [CXT_FIXUP_GPIO1
] = {
3264 .type
= HDA_FIXUP_VERBS
,
3265 .v
.verbs
= (const struct hda_verb
[]) {
3266 { 0x01, AC_VERB_SET_GPIO_MASK
, 0x01 },
3267 { 0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x01 },
3268 { 0x01, AC_VERB_SET_GPIO_DATA
, 0x01 },
3272 [CXT_FIXUP_THINKPAD_ACPI
] = {
3273 .type
= HDA_FIXUP_FUNC
,
3274 .v
.func
= hda_fixup_thinkpad_acpi
,
3276 [CXT_FIXUP_OLPC_XO
] = {
3277 .type
= HDA_FIXUP_FUNC
,
3278 .v
.func
= cxt_fixup_olpc_xo
,
3280 [CXT_FIXUP_CAP_MIX_AMP
] = {
3281 .type
= HDA_FIXUP_FUNC
,
3282 .v
.func
= cxt_fixup_cap_mix_amp
,
3284 [CXT_FIXUP_TOSHIBA_P105
] = {
3285 .type
= HDA_FIXUP_PINS
,
3286 .v
.pins
= (const struct hda_pintbl
[]) {
3287 { 0x10, 0x961701f0 }, /* speaker/hp */
3288 { 0x12, 0x02a1901e }, /* ext mic */
3289 { 0x14, 0x95a70110 }, /* int mic */
3293 [CXT_FIXUP_HP_530
] = {
3294 .type
= HDA_FIXUP_PINS
,
3295 .v
.pins
= (const struct hda_pintbl
[]) {
3296 { 0x12, 0x90a60160 }, /* int mic */
3300 .chain_id
= CXT_FIXUP_CAP_MIX_AMP
,
3302 [CXT_FIXUP_CAP_MIX_AMP_5047
] = {
3303 .type
= HDA_FIXUP_FUNC
,
3304 .v
.func
= cxt_fixup_cap_mix_amp_5047
,
3308 static const struct snd_pci_quirk cxt5045_fixups
[] = {
3309 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT_FIXUP_HP_530
),
3310 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT_FIXUP_TOSHIBA_P105
),
3311 /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have
3312 * really bad sound over 0dB on NID 0x17.
3314 SND_PCI_QUIRK_VENDOR(0x103c, "HP", CXT_FIXUP_CAP_MIX_AMP
),
3315 SND_PCI_QUIRK_VENDOR(0x1631, "Packard Bell", CXT_FIXUP_CAP_MIX_AMP
),
3316 SND_PCI_QUIRK_VENDOR(0x1734, "Fujitsu", CXT_FIXUP_CAP_MIX_AMP
),
3317 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", CXT_FIXUP_CAP_MIX_AMP
),
3321 static const struct hda_model_fixup cxt5045_fixup_models
[] = {
3322 { .id
= CXT_FIXUP_CAP_MIX_AMP
, .name
= "cap-mix-amp" },
3323 { .id
= CXT_FIXUP_TOSHIBA_P105
, .name
= "toshiba-p105" },
3324 { .id
= CXT_FIXUP_HP_530
, .name
= "hp-530" },
3328 static const struct snd_pci_quirk cxt5047_fixups
[] = {
3329 /* HP laptops have really bad sound over 0 dB on NID 0x10.
3331 SND_PCI_QUIRK_VENDOR(0x103c, "HP", CXT_FIXUP_CAP_MIX_AMP_5047
),
3335 static const struct hda_model_fixup cxt5047_fixup_models
[] = {
3336 { .id
= CXT_FIXUP_CAP_MIX_AMP_5047
, .name
= "cap-mix-amp" },
3340 static const struct snd_pci_quirk cxt5051_fixups
[] = {
3341 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200
),
3345 static const struct hda_model_fixup cxt5051_fixup_models
[] = {
3346 { .id
= CXT_PINCFG_LENOVO_X200
, .name
= "lenovo-x200" },
3350 static const struct snd_pci_quirk cxt5066_fixups
[] = {
3351 SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC
),
3352 SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT_FIXUP_GPIO1
),
3353 SND_PCI_QUIRK(0x1043, 0x138d, "Asus", CXT_FIXUP_HEADPHONE_MIC_PIN
),
3354 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT_FIXUP_OLPC_XO
),
3355 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410
),
3356 SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410
),
3357 SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410
),
3358 SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410
),
3359 SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410
),
3360 SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT_PINCFG_LENOVO_TP410
),
3361 SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT_PINCFG_LENOVO_TP410
),
3362 SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC
),
3363 SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC
),
3364 SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC
),
3365 SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI
),
3366 SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004
),
3367 SND_PCI_QUIRK(0x1c06, 0x2012, "Lemote A1205", CXT_PINCFG_LEMOTE_A1205
),
3371 static const struct hda_model_fixup cxt5066_fixup_models
[] = {
3372 { .id
= CXT_FIXUP_STEREO_DMIC
, .name
= "stereo-dmic" },
3373 { .id
= CXT_FIXUP_GPIO1
, .name
= "gpio1" },
3374 { .id
= CXT_FIXUP_HEADPHONE_MIC_PIN
, .name
= "headphone-mic-pin" },
3375 { .id
= CXT_PINCFG_LENOVO_TP410
, .name
= "tp410" },
3376 { .id
= CXT_FIXUP_THINKPAD_ACPI
, .name
= "thinkpad" },
3377 { .id
= CXT_PINCFG_LEMOTE_A1004
, .name
= "lemote-a1004" },
3378 { .id
= CXT_FIXUP_OLPC_XO
, .name
= "olpc-xo" },
3382 /* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches
3383 * can be created (bko#42825)
3385 static void add_cx5051_fake_mutes(struct hda_codec
*codec
)
3387 static hda_nid_t out_nids
[] = {
3392 for (p
= out_nids
; *p
; p
++)
3393 snd_hda_override_amp_caps(codec
, *p
, HDA_OUTPUT
,
3394 AC_AMPCAP_MIN_MUTE
|
3395 query_amp_caps(codec
, *p
, HDA_OUTPUT
));
3398 static int patch_conexant_auto(struct hda_codec
*codec
)
3400 struct conexant_spec
*spec
;
3403 codec_info(codec
, "%s: BIOS auto-probing.\n", codec
->chip_name
);
3405 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3408 snd_hda_gen_spec_init(&spec
->gen
);
3411 cx_auto_parse_beep(codec
);
3412 cx_auto_parse_eapd(codec
);
3413 spec
->gen
.own_eapd_ctl
= 1;
3414 if (spec
->dynamic_eapd
)
3415 spec
->gen
.vmaster_mute
.hook
= cx_auto_vmaster_hook
;
3417 switch (codec
->vendor_id
) {
3419 codec
->single_adc_amp
= 1;
3420 spec
->gen
.mixer_nid
= 0x17;
3421 spec
->gen
.add_stereo_mix_input
= 1;
3422 snd_hda_pick_fixup(codec
, cxt5045_fixup_models
,
3423 cxt5045_fixups
, cxt_fixups
);
3426 codec
->pin_amp_workaround
= 1;
3427 spec
->gen
.mixer_nid
= 0x19;
3428 spec
->gen
.add_stereo_mix_input
= 1;
3429 snd_hda_pick_fixup(codec
, cxt5047_fixup_models
,
3430 cxt5047_fixups
, cxt_fixups
);
3433 add_cx5051_fake_mutes(codec
);
3434 codec
->pin_amp_workaround
= 1;
3435 snd_hda_pick_fixup(codec
, cxt5051_fixup_models
,
3436 cxt5051_fixups
, cxt_fixups
);
3439 codec
->pin_amp_workaround
= 1;
3440 snd_hda_pick_fixup(codec
, cxt5066_fixup_models
,
3441 cxt5066_fixups
, cxt_fixups
);
3445 /* Show mute-led control only on HP laptops
3446 * This is a sort of white-list: on HP laptops, EAPD corresponds
3447 * only to the mute-LED without actualy amp function. Meanwhile,
3448 * others may use EAPD really as an amp switch, so it might be
3449 * not good to expose it blindly.
3451 switch (codec
->subsystem_id
>> 16) {
3453 spec
->gen
.vmaster_mute_enum
= 1;
3457 snd_hda_apply_fixup(codec
, HDA_FIXUP_ACT_PRE_PROBE
);
3459 err
= snd_hda_parse_pin_defcfg(codec
, &spec
->gen
.autocfg
, NULL
,
3464 err
= snd_hda_gen_parse_auto_config(codec
, &spec
->gen
.autocfg
);
3468 codec
->patch_ops
= cx_auto_patch_ops
;
3470 /* Some laptops with Conexant chips show stalls in S3 resume,
3471 * which falls into the single-cmd mode.
3472 * Better to make reset, then.
3474 if (!codec
->bus
->sync_write
) {
3476 "Enable sync_write for stable communication\n");
3477 codec
->bus
->sync_write
= 1;
3478 codec
->bus
->allow_bus_reset
= 1;
3481 snd_hda_apply_fixup(codec
, HDA_FIXUP_ACT_PROBE
);
3486 cx_auto_free(codec
);
3490 #ifndef ENABLE_CXT_STATIC_QUIRKS
3491 #define patch_cxt5045 patch_conexant_auto
3492 #define patch_cxt5047 patch_conexant_auto
3493 #define patch_cxt5051 patch_conexant_auto
3494 #define patch_cxt5066 patch_conexant_auto
3500 static const struct hda_codec_preset snd_hda_preset_conexant
[] = {
3501 { .id
= 0x14f15045, .name
= "CX20549 (Venice)",
3502 .patch
= patch_cxt5045
},
3503 { .id
= 0x14f15047, .name
= "CX20551 (Waikiki)",
3504 .patch
= patch_cxt5047
},
3505 { .id
= 0x14f15051, .name
= "CX20561 (Hermosa)",
3506 .patch
= patch_cxt5051
},
3507 { .id
= 0x14f15066, .name
= "CX20582 (Pebble)",
3508 .patch
= patch_cxt5066
},
3509 { .id
= 0x14f15067, .name
= "CX20583 (Pebble HSF)",
3510 .patch
= patch_cxt5066
},
3511 { .id
= 0x14f15068, .name
= "CX20584",
3512 .patch
= patch_cxt5066
},
3513 { .id
= 0x14f15069, .name
= "CX20585",
3514 .patch
= patch_cxt5066
},
3515 { .id
= 0x14f1506c, .name
= "CX20588",
3516 .patch
= patch_cxt5066
},
3517 { .id
= 0x14f1506e, .name
= "CX20590",
3518 .patch
= patch_cxt5066
},
3519 { .id
= 0x14f15097, .name
= "CX20631",
3520 .patch
= patch_conexant_auto
},
3521 { .id
= 0x14f15098, .name
= "CX20632",
3522 .patch
= patch_conexant_auto
},
3523 { .id
= 0x14f150a1, .name
= "CX20641",
3524 .patch
= patch_conexant_auto
},
3525 { .id
= 0x14f150a2, .name
= "CX20642",
3526 .patch
= patch_conexant_auto
},
3527 { .id
= 0x14f150ab, .name
= "CX20651",
3528 .patch
= patch_conexant_auto
},
3529 { .id
= 0x14f150ac, .name
= "CX20652",
3530 .patch
= patch_conexant_auto
},
3531 { .id
= 0x14f150b8, .name
= "CX20664",
3532 .patch
= patch_conexant_auto
},
3533 { .id
= 0x14f150b9, .name
= "CX20665",
3534 .patch
= patch_conexant_auto
},
3535 { .id
= 0x14f1510f, .name
= "CX20751/2",
3536 .patch
= patch_conexant_auto
},
3537 { .id
= 0x14f15110, .name
= "CX20751/2",
3538 .patch
= patch_conexant_auto
},
3539 { .id
= 0x14f15111, .name
= "CX20753/4",
3540 .patch
= patch_conexant_auto
},
3541 { .id
= 0x14f15113, .name
= "CX20755",
3542 .patch
= patch_conexant_auto
},
3543 { .id
= 0x14f15114, .name
= "CX20756",
3544 .patch
= patch_conexant_auto
},
3545 { .id
= 0x14f15115, .name
= "CX20757",
3546 .patch
= patch_conexant_auto
},
3547 { .id
= 0x14f151d7, .name
= "CX20952",
3548 .patch
= patch_conexant_auto
},
3552 MODULE_ALIAS("snd-hda-codec-id:14f15045");
3553 MODULE_ALIAS("snd-hda-codec-id:14f15047");
3554 MODULE_ALIAS("snd-hda-codec-id:14f15051");
3555 MODULE_ALIAS("snd-hda-codec-id:14f15066");
3556 MODULE_ALIAS("snd-hda-codec-id:14f15067");
3557 MODULE_ALIAS("snd-hda-codec-id:14f15068");
3558 MODULE_ALIAS("snd-hda-codec-id:14f15069");
3559 MODULE_ALIAS("snd-hda-codec-id:14f1506c");
3560 MODULE_ALIAS("snd-hda-codec-id:14f1506e");
3561 MODULE_ALIAS("snd-hda-codec-id:14f15097");
3562 MODULE_ALIAS("snd-hda-codec-id:14f15098");
3563 MODULE_ALIAS("snd-hda-codec-id:14f150a1");
3564 MODULE_ALIAS("snd-hda-codec-id:14f150a2");
3565 MODULE_ALIAS("snd-hda-codec-id:14f150ab");
3566 MODULE_ALIAS("snd-hda-codec-id:14f150ac");
3567 MODULE_ALIAS("snd-hda-codec-id:14f150b8");
3568 MODULE_ALIAS("snd-hda-codec-id:14f150b9");
3569 MODULE_ALIAS("snd-hda-codec-id:14f1510f");
3570 MODULE_ALIAS("snd-hda-codec-id:14f15110");
3571 MODULE_ALIAS("snd-hda-codec-id:14f15111");
3572 MODULE_ALIAS("snd-hda-codec-id:14f15113");
3573 MODULE_ALIAS("snd-hda-codec-id:14f15114");
3574 MODULE_ALIAS("snd-hda-codec-id:14f15115");
3575 MODULE_ALIAS("snd-hda-codec-id:14f151d7");
3577 MODULE_LICENSE("GPL");
3578 MODULE_DESCRIPTION("Conexant HD-audio codec");
3580 static struct hda_codec_preset_list conexant_list
= {
3581 .preset
= snd_hda_preset_conexant
,
3582 .owner
= THIS_MODULE
,
3585 static int __init
patch_conexant_init(void)
3587 return snd_hda_add_codec_preset(&conexant_list
);
3590 static void __exit
patch_conexant_exit(void)
3592 snd_hda_delete_codec_preset(&conexant_list
);
3595 module_init(patch_conexant_init
)
3596 module_exit(patch_conexant_exit
)