2 * HD audio interface patch for Conexant HDA audio codec
4 * Copyright (c) 2006 Pototskiy Akex <alex.pototskiy@gmail.com>
5 * Takashi Iwai <tiwai@suse.de>
6 * Tobin Davis <tdavis@dsl-only.net>
8 * This driver is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This driver is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <linux/init.h>
24 #include <linux/delay.h>
25 #include <linux/slab.h>
26 #include <linux/pci.h>
27 #include <linux/module.h>
28 #include <sound/core.h>
29 #include <sound/jack.h>
31 #include "hda_codec.h"
32 #include "hda_local.h"
33 #include "hda_auto_parser.h"
37 #define CXT_PIN_DIR_IN 0x00
38 #define CXT_PIN_DIR_OUT 0x01
39 #define CXT_PIN_DIR_INOUT 0x02
40 #define CXT_PIN_DIR_IN_NOMICBIAS 0x03
41 #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04
43 #define CONEXANT_HP_EVENT 0x37
44 #define CONEXANT_MIC_EVENT 0x38
45 #define CONEXANT_LINE_EVENT 0x39
47 /* Conexant 5051 specific */
49 #define CXT5051_SPDIF_OUT 0x12
50 #define CXT5051_PORTB_EVENT 0x38
51 #define CXT5051_PORTC_EVENT 0x39
53 #define AUTO_MIC_PORTB (1 << 1)
54 #define AUTO_MIC_PORTC (1 << 2)
63 hda_nid_t pin
; /* input pin NID */
64 hda_nid_t adc
; /* connected ADC NID */
65 hda_nid_t boost
; /* optional boost volume NID */
66 int index
; /* corresponding to autocfg.input */
69 struct conexant_spec
{
70 struct hda_gen_spec gen
;
72 const struct snd_kcontrol_new
*mixers
[5];
74 hda_nid_t vmaster_nid
;
75 struct hda_vmaster_mute_hook vmaster_mute
;
76 bool vmaster_mute_led
;
78 const struct hda_verb
*init_verbs
[5]; /* initialization verbs
82 unsigned int num_init_verbs
;
85 struct hda_multi_out multiout
; /* playback set-up
86 * max_channels, dacs must be set
87 * dig_out_nid and hp_nid are optional
89 unsigned int cur_eapd
;
90 unsigned int hp_present
;
91 unsigned int line_present
;
92 unsigned int auto_mic
;
93 int auto_mic_ext
; /* imux_pins[] index for ext mic */
94 int auto_mic_dock
; /* imux_pins[] index for dock mic */
95 int auto_mic_int
; /* imux_pins[] index for int mic */
96 unsigned int need_dac_fix
;
97 hda_nid_t slave_dig_outs
[2];
100 unsigned int num_adc_nids
;
101 const hda_nid_t
*adc_nids
;
102 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
104 unsigned int cur_adc_idx
;
106 unsigned int cur_adc_stream_tag
;
107 unsigned int cur_adc_format
;
109 const struct hda_pcm_stream
*capture_stream
;
112 const struct hda_input_mux
*input_mux
;
113 const hda_nid_t
*capsrc_nids
;
114 unsigned int cur_mux
[3];
117 const struct hda_channel_mode
*channel_mode
;
118 int num_channel_mode
;
120 /* PCM information */
121 struct hda_pcm pcm_rec
[2]; /* used in build_pcms() */
123 unsigned int spdif_route
;
125 /* dynamic controls, init_verbs and input_mux */
126 struct auto_pin_cfg autocfg
;
127 struct hda_input_mux private_imux
;
128 struct imux_info imux_info
[HDA_MAX_NUM_INPUTS
];
129 hda_nid_t private_adc_nids
[HDA_MAX_NUM_INPUTS
];
130 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
131 struct pin_dac_pair dac_info
[8];
134 unsigned int port_d_mode
;
135 unsigned int auto_mute
:1; /* used in auto-parser */
136 unsigned int detect_line
:1; /* Line-out detection enabled */
137 unsigned int automute_lines
:1; /* automute line-out as well */
138 unsigned int automute_hp_lo
:1; /* both HP and LO available */
139 unsigned int dell_automute
:1;
140 unsigned int dell_vostro
:1;
141 unsigned int ideapad
:1;
142 unsigned int thinkpad
:1;
143 unsigned int hp_laptop
:1;
145 unsigned int pin_eapd_ctrls
:1;
146 unsigned int fixup_stereo_dmic
:1;
148 unsigned int adc_switching
:1;
150 unsigned int ext_mic_present
;
151 unsigned int recording
;
152 void (*capture_prepare
)(struct hda_codec
*codec
);
153 void (*capture_cleanup
)(struct hda_codec
*codec
);
155 /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
156 * through the microphone jack.
157 * When the user enables this through a mixer switch, both internal and
158 * external microphones are disabled. Gain is fixed at 0dB. In this mode,
159 * we also allow the bias to be configured through a separate mixer
161 unsigned int dc_enable
;
162 unsigned int dc_input_bias
; /* offset into cxt5066_olpc_dc_bias */
163 unsigned int mic_boost
; /* offset into cxt5066_analog_mic_boost */
165 unsigned int beep_amp
;
167 /* extra EAPD pins */
168 unsigned int num_eapds
;
172 static int conexant_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
173 struct hda_codec
*codec
,
174 struct snd_pcm_substream
*substream
)
176 struct conexant_spec
*spec
= codec
->spec
;
177 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
181 static int conexant_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
182 struct hda_codec
*codec
,
183 unsigned int stream_tag
,
185 struct snd_pcm_substream
*substream
)
187 struct conexant_spec
*spec
= codec
->spec
;
188 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
193 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
194 struct hda_codec
*codec
,
195 struct snd_pcm_substream
*substream
)
197 struct conexant_spec
*spec
= codec
->spec
;
198 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
204 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
205 struct hda_codec
*codec
,
206 struct snd_pcm_substream
*substream
)
208 struct conexant_spec
*spec
= codec
->spec
;
209 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
212 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
213 struct hda_codec
*codec
,
214 struct snd_pcm_substream
*substream
)
216 struct conexant_spec
*spec
= codec
->spec
;
217 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
220 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
221 struct hda_codec
*codec
,
222 unsigned int stream_tag
,
224 struct snd_pcm_substream
*substream
)
226 struct conexant_spec
*spec
= codec
->spec
;
227 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
235 static int conexant_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
236 struct hda_codec
*codec
,
237 unsigned int stream_tag
,
239 struct snd_pcm_substream
*substream
)
241 struct conexant_spec
*spec
= codec
->spec
;
242 if (spec
->capture_prepare
)
243 spec
->capture_prepare(codec
);
244 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
245 stream_tag
, 0, format
);
249 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
250 struct hda_codec
*codec
,
251 struct snd_pcm_substream
*substream
)
253 struct conexant_spec
*spec
= codec
->spec
;
254 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
255 if (spec
->capture_cleanup
)
256 spec
->capture_cleanup(codec
);
262 static const struct hda_pcm_stream conexant_pcm_analog_playback
= {
266 .nid
= 0, /* fill later */
268 .open
= conexant_playback_pcm_open
,
269 .prepare
= conexant_playback_pcm_prepare
,
270 .cleanup
= conexant_playback_pcm_cleanup
274 static const struct hda_pcm_stream conexant_pcm_analog_capture
= {
278 .nid
= 0, /* fill later */
280 .prepare
= conexant_capture_pcm_prepare
,
281 .cleanup
= conexant_capture_pcm_cleanup
286 static const struct hda_pcm_stream conexant_pcm_digital_playback
= {
290 .nid
= 0, /* fill later */
292 .open
= conexant_dig_playback_pcm_open
,
293 .close
= conexant_dig_playback_pcm_close
,
294 .prepare
= conexant_dig_playback_pcm_prepare
298 static const struct hda_pcm_stream conexant_pcm_digital_capture
= {
302 /* NID is set in alc_build_pcms */
305 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
306 struct hda_codec
*codec
,
307 unsigned int stream_tag
,
309 struct snd_pcm_substream
*substream
)
311 struct conexant_spec
*spec
= codec
->spec
;
312 spec
->cur_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
313 spec
->cur_adc_stream_tag
= stream_tag
;
314 spec
->cur_adc_format
= format
;
315 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
319 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
320 struct hda_codec
*codec
,
321 struct snd_pcm_substream
*substream
)
323 struct conexant_spec
*spec
= codec
->spec
;
324 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
329 static const struct hda_pcm_stream cx5051_pcm_analog_capture
= {
333 .nid
= 0, /* fill later */
335 .prepare
= cx5051_capture_pcm_prepare
,
336 .cleanup
= cx5051_capture_pcm_cleanup
340 static int conexant_build_pcms(struct hda_codec
*codec
)
342 struct conexant_spec
*spec
= codec
->spec
;
343 struct hda_pcm
*info
= spec
->pcm_rec
;
346 codec
->pcm_info
= info
;
348 info
->name
= "CONEXANT Analog";
349 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = conexant_pcm_analog_playback
;
350 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
=
351 spec
->multiout
.max_channels
;
352 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
353 spec
->multiout
.dac_nids
[0];
354 if (spec
->capture_stream
)
355 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *spec
->capture_stream
;
357 if (codec
->vendor_id
== 0x14f15051)
358 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
359 cx5051_pcm_analog_capture
;
361 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
362 conexant_pcm_analog_capture
;
363 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
=
367 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
369 if (spec
->multiout
.dig_out_nid
) {
372 info
->name
= "Conexant Digital";
373 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
374 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
375 conexant_pcm_digital_playback
;
376 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
377 spec
->multiout
.dig_out_nid
;
378 if (spec
->dig_in_nid
) {
379 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
380 conexant_pcm_digital_capture
;
381 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
384 if (spec
->slave_dig_outs
[0])
385 codec
->slave_dig_outs
= spec
->slave_dig_outs
;
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
, true);
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
)
448 struct conexant_spec
*spec
= codec
->spec
;
449 snd_hda_gen_free(&spec
->gen
);
450 snd_hda_detach_beep_device(codec
);
454 static const struct snd_kcontrol_new cxt_capture_mixers
[] = {
456 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
457 .name
= "Capture Source",
458 .info
= conexant_mux_enum_info
,
459 .get
= conexant_mux_enum_get
,
460 .put
= conexant_mux_enum_put
465 #ifdef CONFIG_SND_HDA_INPUT_BEEP
466 /* additional beep mixers; the actual parameters are overwritten at build */
467 static const struct snd_kcontrol_new cxt_beep_mixer
[] = {
468 HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT
),
469 HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT
),
474 static const char * const slave_pfxs
[] = {
475 "Headphone", "Speaker", "Front", "Surround", "CLFE",
479 static int conexant_build_controls(struct hda_codec
*codec
)
481 struct conexant_spec
*spec
= codec
->spec
;
485 for (i
= 0; i
< spec
->num_mixers
; i
++) {
486 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
490 if (spec
->multiout
.dig_out_nid
) {
491 err
= snd_hda_create_spdif_out_ctls(codec
,
492 spec
->multiout
.dig_out_nid
,
493 spec
->multiout
.dig_out_nid
);
496 err
= snd_hda_create_spdif_share_sw(codec
,
500 spec
->multiout
.share_spdif
= 1;
502 if (spec
->dig_in_nid
) {
503 err
= snd_hda_create_spdif_in_ctls(codec
,spec
->dig_in_nid
);
508 /* if we have no master control, let's create it */
509 if (spec
->vmaster_nid
&&
510 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
511 unsigned int vmaster_tlv
[4];
512 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
513 HDA_OUTPUT
, vmaster_tlv
);
514 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
515 vmaster_tlv
, slave_pfxs
,
520 if (spec
->vmaster_nid
&&
521 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
522 err
= __snd_hda_add_vmaster(codec
, "Master Playback Switch",
524 "Playback Switch", true,
525 &spec
->vmaster_mute
.sw_kctl
);
530 if (spec
->input_mux
) {
531 err
= snd_hda_add_new_ctls(codec
, cxt_capture_mixers
);
536 #ifdef CONFIG_SND_HDA_INPUT_BEEP
537 /* create beep controls if needed */
538 if (spec
->beep_amp
) {
539 const struct snd_kcontrol_new
*knew
;
540 for (knew
= cxt_beep_mixer
; knew
->name
; knew
++) {
541 struct snd_kcontrol
*kctl
;
542 kctl
= snd_ctl_new1(knew
, codec
);
545 kctl
->private_value
= spec
->beep_amp
;
546 err
= snd_hda_ctl_add(codec
, 0, kctl
);
556 #ifdef CONFIG_SND_HDA_POWER_SAVE
557 static int conexant_suspend(struct hda_codec
*codec
)
559 snd_hda_shutup_pins(codec
);
564 static const struct hda_codec_ops conexant_patch_ops
= {
565 .build_controls
= conexant_build_controls
,
566 .build_pcms
= conexant_build_pcms
,
567 .init
= conexant_init
,
568 .free
= conexant_free
,
569 .set_power_state
= conexant_set_power
,
570 #ifdef CONFIG_SND_HDA_POWER_SAVE
571 .suspend
= conexant_suspend
,
573 .reboot_notify
= snd_hda_shutup_pins
,
576 #ifdef CONFIG_SND_HDA_INPUT_BEEP
577 #define set_beep_amp(spec, nid, idx, dir) \
578 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir))
580 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
583 static int patch_conexant_auto(struct hda_codec
*codec
);
586 * the private value = nid | (invert << 8)
589 #define cxt_eapd_info snd_ctl_boolean_mono_info
591 static int cxt_eapd_get(struct snd_kcontrol
*kcontrol
,
592 struct snd_ctl_elem_value
*ucontrol
)
594 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
595 struct conexant_spec
*spec
= codec
->spec
;
596 int invert
= (kcontrol
->private_value
>> 8) & 1;
598 ucontrol
->value
.integer
.value
[0] = !spec
->cur_eapd
;
600 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
605 static int cxt_eapd_put(struct snd_kcontrol
*kcontrol
,
606 struct snd_ctl_elem_value
*ucontrol
)
608 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
609 struct conexant_spec
*spec
= codec
->spec
;
610 int invert
= (kcontrol
->private_value
>> 8) & 1;
611 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
614 eapd
= !!ucontrol
->value
.integer
.value
[0];
617 if (eapd
== spec
->cur_eapd
)
620 spec
->cur_eapd
= eapd
;
621 snd_hda_codec_write_cache(codec
, nid
,
622 0, AC_VERB_SET_EAPD_BTLENABLE
,
627 /* controls for test mode */
628 #ifdef CONFIG_SND_DEBUG
630 #define CXT_EAPD_SWITCH(xname, nid, mask) \
631 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
632 .info = cxt_eapd_info, \
633 .get = cxt_eapd_get, \
634 .put = cxt_eapd_put, \
635 .private_value = nid | (mask<<16) }
639 static int conexant_ch_mode_info(struct snd_kcontrol
*kcontrol
,
640 struct snd_ctl_elem_info
*uinfo
)
642 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
643 struct conexant_spec
*spec
= codec
->spec
;
644 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
645 spec
->num_channel_mode
);
648 static int conexant_ch_mode_get(struct snd_kcontrol
*kcontrol
,
649 struct snd_ctl_elem_value
*ucontrol
)
651 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
652 struct conexant_spec
*spec
= codec
->spec
;
653 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
654 spec
->num_channel_mode
,
655 spec
->multiout
.max_channels
);
658 static int conexant_ch_mode_put(struct snd_kcontrol
*kcontrol
,
659 struct snd_ctl_elem_value
*ucontrol
)
661 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
662 struct conexant_spec
*spec
= codec
->spec
;
663 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
664 spec
->num_channel_mode
,
665 &spec
->multiout
.max_channels
);
666 if (err
>= 0 && spec
->need_dac_fix
)
667 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
671 #define CXT_PIN_MODE(xname, nid, dir) \
672 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
673 .info = conexant_ch_mode_info, \
674 .get = conexant_ch_mode_get, \
675 .put = conexant_ch_mode_put, \
676 .private_value = nid | (dir<<16) }
678 #endif /* CONFIG_SND_DEBUG */
680 /* Conexant 5045 specific */
682 static const hda_nid_t cxt5045_dac_nids
[1] = { 0x19 };
683 static const hda_nid_t cxt5045_adc_nids
[1] = { 0x1a };
684 static const hda_nid_t cxt5045_capsrc_nids
[1] = { 0x1a };
685 #define CXT5045_SPDIF_OUT 0x18
687 static const struct hda_channel_mode cxt5045_modes
[1] = {
691 static const struct hda_input_mux cxt5045_capture_source
= {
694 { "Internal Mic", 0x1 },
699 static const struct hda_input_mux cxt5045_capture_source_benq
= {
702 { "Internal Mic", 0x1 },
709 static const struct hda_input_mux cxt5045_capture_source_hp530
= {
713 { "Internal Mic", 0x2 },
717 /* turn on/off EAPD (+ mute HP) as a master switch */
718 static int cxt5045_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
719 struct snd_ctl_elem_value
*ucontrol
)
721 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
722 struct conexant_spec
*spec
= codec
->spec
;
725 if (!cxt_eapd_put(kcontrol
, ucontrol
))
728 /* toggle internal speakers mute depending of presence of
731 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
732 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
735 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
736 snd_hda_codec_amp_stereo(codec
, 0x11, HDA_OUTPUT
, 0,
741 /* bind volumes of both NID 0x10 and 0x11 */
742 static const struct hda_bind_ctls cxt5045_hp_bind_master_vol
= {
743 .ops
= &snd_hda_bind_vol
,
745 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT
),
746 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT
),
751 /* toggle input of built-in and mic jack appropriately */
752 static void cxt5045_hp_automic(struct hda_codec
*codec
)
754 static const struct hda_verb mic_jack_on
[] = {
755 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
756 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
759 static const struct hda_verb mic_jack_off
[] = {
760 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
761 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
764 unsigned int present
;
766 present
= snd_hda_jack_detect(codec
, 0x12);
768 snd_hda_sequence_write(codec
, mic_jack_on
);
770 snd_hda_sequence_write(codec
, mic_jack_off
);
774 /* mute internal speaker if HP is plugged */
775 static void cxt5045_hp_automute(struct hda_codec
*codec
)
777 struct conexant_spec
*spec
= codec
->spec
;
780 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x11);
782 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
783 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
787 /* unsolicited event for HP jack sensing */
788 static void cxt5045_hp_unsol_event(struct hda_codec
*codec
,
793 case CONEXANT_HP_EVENT
:
794 cxt5045_hp_automute(codec
);
796 case CONEXANT_MIC_EVENT
:
797 cxt5045_hp_automic(codec
);
803 static const struct snd_kcontrol_new cxt5045_mixers
[] = {
804 HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT
),
805 HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT
),
806 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
807 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
808 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
809 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
811 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
812 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
814 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
815 .name
= "Master Playback Switch",
816 .info
= cxt_eapd_info
,
818 .put
= cxt5045_hp_master_sw_put
,
819 .private_value
= 0x10,
825 static const struct snd_kcontrol_new cxt5045_benq_mixers
[] = {
826 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x3, HDA_INPUT
),
827 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x3, HDA_INPUT
),
832 static const struct snd_kcontrol_new cxt5045_mixers_hp530
[] = {
833 HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT
),
834 HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT
),
835 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
836 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
837 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
838 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
839 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
840 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
841 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
843 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
844 .name
= "Master Playback Switch",
845 .info
= cxt_eapd_info
,
847 .put
= cxt5045_hp_master_sw_put
,
848 .private_value
= 0x10,
854 static const struct hda_verb cxt5045_init_verbs
[] = {
856 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
857 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
859 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
860 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
861 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
862 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
863 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
864 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
865 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
866 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
867 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
868 /* Record selector: Internal mic */
869 {0x1a, AC_VERB_SET_CONNECT_SEL
,0x1},
870 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
871 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
872 /* SPDIF route: PCM */
873 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
874 { 0x13, AC_VERB_SET_CONNECT_SEL
, 0x0 },
876 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2 }, /* default on */
880 static const struct hda_verb cxt5045_benq_init_verbs
[] = {
881 /* Internal Mic, Mic */
882 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
883 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
884 /* Line In,HP, Amp */
885 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
886 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
887 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
888 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
889 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
890 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
891 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
892 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
893 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
894 /* Record selector: Internal mic */
895 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x1},
896 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
897 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
898 /* SPDIF route: PCM */
899 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
900 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0},
902 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
906 static const struct hda_verb cxt5045_hp_sense_init_verbs
[] = {
907 /* pin sensing on HP jack */
908 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
912 static const struct hda_verb cxt5045_mic_sense_init_verbs
[] = {
913 /* pin sensing on HP jack */
914 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
918 #ifdef CONFIG_SND_DEBUG
919 /* Test configuration for debugging, modelled after the ALC260 test
922 static const struct hda_input_mux cxt5045_test_capture_source
= {
927 { "LINE1 pin", 0x2 },
928 { "HP-OUT pin", 0x3 },
933 static const struct snd_kcontrol_new cxt5045_test_mixer
[] = {
935 /* Output controls */
936 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
937 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
938 HDA_CODEC_VOLUME("HP-OUT Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
939 HDA_CODEC_MUTE("HP-OUT Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
940 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
941 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
943 /* Modes for retasking pin widgets */
944 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT
),
945 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT
),
947 /* EAPD Switch Control */
948 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
950 /* Loopback mixer controls */
952 HDA_CODEC_VOLUME("PCM Volume", 0x17, 0x0, HDA_INPUT
),
953 HDA_CODEC_MUTE("PCM Switch", 0x17, 0x0, HDA_INPUT
),
954 HDA_CODEC_VOLUME("MIC1 pin Volume", 0x17, 0x1, HDA_INPUT
),
955 HDA_CODEC_MUTE("MIC1 pin Switch", 0x17, 0x1, HDA_INPUT
),
956 HDA_CODEC_VOLUME("LINE1 pin Volume", 0x17, 0x2, HDA_INPUT
),
957 HDA_CODEC_MUTE("LINE1 pin Switch", 0x17, 0x2, HDA_INPUT
),
958 HDA_CODEC_VOLUME("HP-OUT pin Volume", 0x17, 0x3, HDA_INPUT
),
959 HDA_CODEC_MUTE("HP-OUT pin Switch", 0x17, 0x3, HDA_INPUT
),
960 HDA_CODEC_VOLUME("CD pin Volume", 0x17, 0x4, HDA_INPUT
),
961 HDA_CODEC_MUTE("CD pin Switch", 0x17, 0x4, HDA_INPUT
),
963 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
964 .name
= "Input Source",
965 .info
= conexant_mux_enum_info
,
966 .get
= conexant_mux_enum_get
,
967 .put
= conexant_mux_enum_put
,
969 /* Audio input controls */
970 HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x0, HDA_INPUT
),
971 HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT
),
975 static const struct hda_verb cxt5045_test_init_verbs
[] = {
976 /* Set connections */
977 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
978 { 0x11, AC_VERB_SET_CONNECT_SEL
, 0x0 },
979 { 0x12, AC_VERB_SET_CONNECT_SEL
, 0x0 },
980 /* Enable retasking pins as output, initially without power amp */
981 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
982 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
984 /* Disable digital (SPDIF) pins initially, but users can enable
985 * them via a mixer switch. In the case of SPDIF-out, this initverb
986 * payload also sets the generation to 0, output to be in "consumer"
987 * PCM format, copyright asserted, no pre-emphasis and no validity
990 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
991 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
993 /* Unmute retasking pin widget output buffers since the default
994 * state appears to be output. As the pin mode is changed by the
995 * user the pin mode control will take care of enabling the pin's
996 * input/output buffers as needed.
998 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
999 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1001 /* Mute capture amp left and right */
1002 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1004 /* Set ADC connection select to match default mixer setting (mic1
1007 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x01},
1008 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x01},
1010 /* Mute all inputs to mixer widget (even unconnected ones) */
1011 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* Mixer */
1012 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* Mic1 pin */
1013 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* Line pin */
1014 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* HP pin */
1015 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1022 /* initialize jack-sensing, too */
1023 static int cxt5045_init(struct hda_codec
*codec
)
1025 conexant_init(codec
);
1026 cxt5045_hp_automute(codec
);
1032 CXT5045_LAPTOP_HPSENSE
,
1033 CXT5045_LAPTOP_MICSENSE
,
1034 CXT5045_LAPTOP_HPMICSENSE
,
1036 CXT5045_LAPTOP_HP530
,
1037 #ifdef CONFIG_SND_DEBUG
1044 static const char * const cxt5045_models
[CXT5045_MODELS
] = {
1045 [CXT5045_LAPTOP_HPSENSE
] = "laptop-hpsense",
1046 [CXT5045_LAPTOP_MICSENSE
] = "laptop-micsense",
1047 [CXT5045_LAPTOP_HPMICSENSE
] = "laptop-hpmicsense",
1048 [CXT5045_BENQ
] = "benq",
1049 [CXT5045_LAPTOP_HP530
] = "laptop-hp530",
1050 #ifdef CONFIG_SND_DEBUG
1051 [CXT5045_TEST
] = "test",
1053 [CXT5045_AUTO
] = "auto",
1056 static const struct snd_pci_quirk cxt5045_cfg_tbl
[] = {
1057 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530
),
1058 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE
),
1059 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ
),
1060 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE
),
1061 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE
),
1062 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
1063 CXT5045_LAPTOP_HPMICSENSE
),
1064 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1065 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1066 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1067 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
1068 CXT5045_LAPTOP_HPMICSENSE
),
1069 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE
),
1073 static int patch_cxt5045(struct hda_codec
*codec
)
1075 struct conexant_spec
*spec
;
1078 board_config
= snd_hda_check_board_config(codec
, CXT5045_MODELS
,
1081 if (board_config
< 0)
1082 board_config
= CXT5045_AUTO
; /* model=auto as default */
1083 if (board_config
== CXT5045_AUTO
)
1084 return patch_conexant_auto(codec
);
1086 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1090 codec
->single_adc_amp
= 1;
1092 spec
->multiout
.max_channels
= 2;
1093 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5045_dac_nids
);
1094 spec
->multiout
.dac_nids
= cxt5045_dac_nids
;
1095 spec
->multiout
.dig_out_nid
= CXT5045_SPDIF_OUT
;
1096 spec
->num_adc_nids
= 1;
1097 spec
->adc_nids
= cxt5045_adc_nids
;
1098 spec
->capsrc_nids
= cxt5045_capsrc_nids
;
1099 spec
->input_mux
= &cxt5045_capture_source
;
1100 spec
->num_mixers
= 1;
1101 spec
->mixers
[0] = cxt5045_mixers
;
1102 spec
->num_init_verbs
= 1;
1103 spec
->init_verbs
[0] = cxt5045_init_verbs
;
1104 spec
->spdif_route
= 0;
1105 spec
->num_channel_mode
= ARRAY_SIZE(cxt5045_modes
);
1106 spec
->channel_mode
= cxt5045_modes
;
1108 set_beep_amp(spec
, 0x16, 0, 1);
1110 codec
->patch_ops
= conexant_patch_ops
;
1112 switch (board_config
) {
1113 case CXT5045_LAPTOP_HPSENSE
:
1114 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1115 spec
->input_mux
= &cxt5045_capture_source
;
1116 spec
->num_init_verbs
= 2;
1117 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1118 spec
->mixers
[0] = cxt5045_mixers
;
1119 codec
->patch_ops
.init
= cxt5045_init
;
1121 case CXT5045_LAPTOP_MICSENSE
:
1122 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1123 spec
->input_mux
= &cxt5045_capture_source
;
1124 spec
->num_init_verbs
= 2;
1125 spec
->init_verbs
[1] = cxt5045_mic_sense_init_verbs
;
1126 spec
->mixers
[0] = cxt5045_mixers
;
1127 codec
->patch_ops
.init
= cxt5045_init
;
1130 case CXT5045_LAPTOP_HPMICSENSE
:
1131 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1132 spec
->input_mux
= &cxt5045_capture_source
;
1133 spec
->num_init_verbs
= 3;
1134 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1135 spec
->init_verbs
[2] = cxt5045_mic_sense_init_verbs
;
1136 spec
->mixers
[0] = cxt5045_mixers
;
1137 codec
->patch_ops
.init
= cxt5045_init
;
1140 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1141 spec
->input_mux
= &cxt5045_capture_source_benq
;
1142 spec
->num_init_verbs
= 1;
1143 spec
->init_verbs
[0] = cxt5045_benq_init_verbs
;
1144 spec
->mixers
[0] = cxt5045_mixers
;
1145 spec
->mixers
[1] = cxt5045_benq_mixers
;
1146 spec
->num_mixers
= 2;
1147 codec
->patch_ops
.init
= cxt5045_init
;
1149 case CXT5045_LAPTOP_HP530
:
1150 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1151 spec
->input_mux
= &cxt5045_capture_source_hp530
;
1152 spec
->num_init_verbs
= 2;
1153 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1154 spec
->mixers
[0] = cxt5045_mixers_hp530
;
1155 codec
->patch_ops
.init
= cxt5045_init
;
1157 #ifdef CONFIG_SND_DEBUG
1159 spec
->input_mux
= &cxt5045_test_capture_source
;
1160 spec
->mixers
[0] = cxt5045_test_mixer
;
1161 spec
->init_verbs
[0] = cxt5045_test_init_verbs
;
1167 switch (codec
->subsystem_id
>> 16) {
1172 /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have
1173 * really bad sound over 0dB on NID 0x17. Fix max PCM level to
1174 * 0 dB (originally it has 0x2b steps with 0dB offset 0x14)
1176 snd_hda_override_amp_caps(codec
, 0x17, HDA_INPUT
,
1177 (0x14 << AC_AMPCAP_OFFSET_SHIFT
) |
1178 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1179 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1180 (1 << AC_AMPCAP_MUTE_SHIFT
));
1185 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
1191 /* Conexant 5047 specific */
1192 #define CXT5047_SPDIF_OUT 0x11
1194 static const hda_nid_t cxt5047_dac_nids
[1] = { 0x10 }; /* 0x1c */
1195 static const hda_nid_t cxt5047_adc_nids
[1] = { 0x12 };
1196 static const hda_nid_t cxt5047_capsrc_nids
[1] = { 0x1a };
1198 static const struct hda_channel_mode cxt5047_modes
[1] = {
1202 static const struct hda_input_mux cxt5047_toshiba_capture_source
= {
1210 /* turn on/off EAPD (+ mute HP) as a master switch */
1211 static int cxt5047_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1212 struct snd_ctl_elem_value
*ucontrol
)
1214 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1215 struct conexant_spec
*spec
= codec
->spec
;
1218 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1221 /* toggle internal speakers mute depending of presence of
1222 * the headphone jack
1224 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
1225 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1226 * pin widgets unlike other codecs. In this case, we need to
1227 * set index 0x01 for the volume from the mixer amp 0x19.
1229 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1230 HDA_AMP_MUTE
, bits
);
1231 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
1232 snd_hda_codec_amp_stereo(codec
, 0x13, HDA_OUTPUT
, 0,
1233 HDA_AMP_MUTE
, bits
);
1237 /* mute internal speaker if HP is plugged */
1238 static void cxt5047_hp_automute(struct hda_codec
*codec
)
1240 struct conexant_spec
*spec
= codec
->spec
;
1243 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x13);
1245 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
1246 /* See the note in cxt5047_hp_master_sw_put */
1247 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1248 HDA_AMP_MUTE
, bits
);
1251 /* toggle input of built-in and mic jack appropriately */
1252 static void cxt5047_hp_automic(struct hda_codec
*codec
)
1254 static const struct hda_verb mic_jack_on
[] = {
1255 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1256 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1259 static const struct hda_verb mic_jack_off
[] = {
1260 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1261 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1264 unsigned int present
;
1266 present
= snd_hda_jack_detect(codec
, 0x15);
1268 snd_hda_sequence_write(codec
, mic_jack_on
);
1270 snd_hda_sequence_write(codec
, mic_jack_off
);
1273 /* unsolicited event for HP jack sensing */
1274 static void cxt5047_hp_unsol_event(struct hda_codec
*codec
,
1277 switch (res
>> 26) {
1278 case CONEXANT_HP_EVENT
:
1279 cxt5047_hp_automute(codec
);
1281 case CONEXANT_MIC_EVENT
:
1282 cxt5047_hp_automic(codec
);
1287 static const struct snd_kcontrol_new cxt5047_base_mixers
[] = {
1288 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT
),
1289 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT
),
1290 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1291 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT
),
1292 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT
),
1293 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT
),
1294 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT
),
1296 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1297 .name
= "Master Playback Switch",
1298 .info
= cxt_eapd_info
,
1299 .get
= cxt_eapd_get
,
1300 .put
= cxt5047_hp_master_sw_put
,
1301 .private_value
= 0x13,
1307 static const struct snd_kcontrol_new cxt5047_hp_spk_mixers
[] = {
1308 /* See the note in cxt5047_hp_master_sw_put */
1309 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT
),
1310 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1314 static const struct snd_kcontrol_new cxt5047_hp_only_mixers
[] = {
1315 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1319 static const struct hda_verb cxt5047_init_verbs
[] = {
1320 /* Line in, Mic, Built-in Mic */
1321 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1322 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1323 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1325 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1326 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* mixer(0x19) */
1327 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mixer(0x19) */
1328 /* Record selector: Mic */
1329 {0x12, AC_VERB_SET_CONNECT_SEL
,0x03},
1330 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
,
1331 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
1332 {0x1A, AC_VERB_SET_CONNECT_SEL
,0x02},
1333 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1334 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x00},
1335 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1336 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x03},
1337 /* SPDIF route: PCM */
1338 { 0x18, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1339 /* Enable unsolicited events */
1340 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
1341 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1345 /* configuration for Toshiba Laptops */
1346 static const struct hda_verb cxt5047_toshiba_init_verbs
[] = {
1347 {0x13, AC_VERB_SET_EAPD_BTLENABLE
, 0x0}, /* default off */
1351 /* Test configuration for debugging, modelled after the ALC260 test
1354 #ifdef CONFIG_SND_DEBUG
1355 static const struct hda_input_mux cxt5047_test_capture_source
= {
1358 { "LINE1 pin", 0x0 },
1359 { "MIC1 pin", 0x1 },
1360 { "MIC2 pin", 0x2 },
1365 static const struct snd_kcontrol_new cxt5047_test_mixer
[] = {
1367 /* Output only controls */
1368 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT
),
1369 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT
),
1370 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT
),
1371 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT
),
1372 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1373 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1374 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1375 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1376 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT
),
1377 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT
),
1378 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
1379 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
1381 /* Modes for retasking pin widgets */
1382 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT
),
1383 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT
),
1385 /* EAPD Switch Control */
1386 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1388 /* Loopback mixer controls */
1389 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT
),
1390 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT
),
1391 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT
),
1392 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT
),
1393 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT
),
1394 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT
),
1395 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT
),
1396 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT
),
1398 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT
),
1399 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT
),
1400 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT
),
1401 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT
),
1402 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT
),
1403 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT
),
1404 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT
),
1405 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT
),
1407 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1408 .name
= "Input Source",
1409 .info
= conexant_mux_enum_info
,
1410 .get
= conexant_mux_enum_get
,
1411 .put
= conexant_mux_enum_put
,
1413 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1418 static const struct hda_verb cxt5047_test_init_verbs
[] = {
1419 /* Enable retasking pins as output, initially without power amp */
1420 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1421 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1422 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1424 /* Disable digital (SPDIF) pins initially, but users can enable
1425 * them via a mixer switch. In the case of SPDIF-out, this initverb
1426 * payload also sets the generation to 0, output to be in "consumer"
1427 * PCM format, copyright asserted, no pre-emphasis and no validity
1430 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1432 /* Ensure mic1, mic2, line1 pin widgets take input from the
1433 * OUT1 sum bus when acting as an output.
1435 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0},
1436 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0},
1438 /* Start with output sum widgets muted and their output gains at min */
1439 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1440 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1442 /* Unmute retasking pin widget output buffers since the default
1443 * state appears to be output. As the pin mode is changed by the
1444 * user the pin mode control will take care of enabling the pin's
1445 * input/output buffers as needed.
1447 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1448 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1449 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1451 /* Mute capture amp left and right */
1452 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1454 /* Set ADC connection select to match default mixer setting (mic1
1457 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x00},
1459 /* Mute all inputs to mixer widget (even unconnected ones) */
1460 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* mic1 pin */
1461 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* mic2 pin */
1462 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* line1 pin */
1463 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* line2 pin */
1464 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1465 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1466 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)}, /* Line-out pin */
1467 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)}, /* HP-pin pin */
1474 /* initialize jack-sensing, too */
1475 static int cxt5047_hp_init(struct hda_codec
*codec
)
1477 conexant_init(codec
);
1478 cxt5047_hp_automute(codec
);
1484 CXT5047_LAPTOP
, /* Laptops w/o EAPD support */
1485 CXT5047_LAPTOP_HP
, /* Some HP laptops */
1486 CXT5047_LAPTOP_EAPD
, /* Laptops with EAPD support */
1487 #ifdef CONFIG_SND_DEBUG
1494 static const char * const cxt5047_models
[CXT5047_MODELS
] = {
1495 [CXT5047_LAPTOP
] = "laptop",
1496 [CXT5047_LAPTOP_HP
] = "laptop-hp",
1497 [CXT5047_LAPTOP_EAPD
] = "laptop-eapd",
1498 #ifdef CONFIG_SND_DEBUG
1499 [CXT5047_TEST
] = "test",
1501 [CXT5047_AUTO
] = "auto",
1504 static const struct snd_pci_quirk cxt5047_cfg_tbl
[] = {
1505 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP
),
1506 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1508 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD
),
1512 static int patch_cxt5047(struct hda_codec
*codec
)
1514 struct conexant_spec
*spec
;
1517 board_config
= snd_hda_check_board_config(codec
, CXT5047_MODELS
,
1520 if (board_config
< 0)
1521 board_config
= CXT5047_AUTO
; /* model=auto as default */
1522 if (board_config
== CXT5047_AUTO
)
1523 return patch_conexant_auto(codec
);
1525 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1529 codec
->pin_amp_workaround
= 1;
1531 spec
->multiout
.max_channels
= 2;
1532 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5047_dac_nids
);
1533 spec
->multiout
.dac_nids
= cxt5047_dac_nids
;
1534 spec
->multiout
.dig_out_nid
= CXT5047_SPDIF_OUT
;
1535 spec
->num_adc_nids
= 1;
1536 spec
->adc_nids
= cxt5047_adc_nids
;
1537 spec
->capsrc_nids
= cxt5047_capsrc_nids
;
1538 spec
->num_mixers
= 1;
1539 spec
->mixers
[0] = cxt5047_base_mixers
;
1540 spec
->num_init_verbs
= 1;
1541 spec
->init_verbs
[0] = cxt5047_init_verbs
;
1542 spec
->spdif_route
= 0;
1543 spec
->num_channel_mode
= ARRAY_SIZE(cxt5047_modes
),
1544 spec
->channel_mode
= cxt5047_modes
,
1546 codec
->patch_ops
= conexant_patch_ops
;
1548 switch (board_config
) {
1549 case CXT5047_LAPTOP
:
1550 spec
->num_mixers
= 2;
1551 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1552 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1554 case CXT5047_LAPTOP_HP
:
1555 spec
->num_mixers
= 2;
1556 spec
->mixers
[1] = cxt5047_hp_only_mixers
;
1557 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1558 codec
->patch_ops
.init
= cxt5047_hp_init
;
1560 case CXT5047_LAPTOP_EAPD
:
1561 spec
->input_mux
= &cxt5047_toshiba_capture_source
;
1562 spec
->num_mixers
= 2;
1563 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1564 spec
->num_init_verbs
= 2;
1565 spec
->init_verbs
[1] = cxt5047_toshiba_init_verbs
;
1566 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1568 #ifdef CONFIG_SND_DEBUG
1570 spec
->input_mux
= &cxt5047_test_capture_source
;
1571 spec
->mixers
[0] = cxt5047_test_mixer
;
1572 spec
->init_verbs
[0] = cxt5047_test_init_verbs
;
1573 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1576 spec
->vmaster_nid
= 0x13;
1578 switch (codec
->subsystem_id
>> 16) {
1580 /* HP laptops have really bad sound over 0 dB on NID 0x10.
1581 * Fix max PCM level to 0 dB (originally it has 0x1e steps
1582 * with 0 dB offset 0x17)
1584 snd_hda_override_amp_caps(codec
, 0x10, HDA_INPUT
,
1585 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
1586 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1587 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1588 (1 << AC_AMPCAP_MUTE_SHIFT
));
1595 /* Conexant 5051 specific */
1596 static const hda_nid_t cxt5051_dac_nids
[1] = { 0x10 };
1597 static const hda_nid_t cxt5051_adc_nids
[2] = { 0x14, 0x15 };
1599 static const struct hda_channel_mode cxt5051_modes
[1] = {
1603 static void cxt5051_update_speaker(struct hda_codec
*codec
)
1605 struct conexant_spec
*spec
= codec
->spec
;
1606 unsigned int pinctl
;
1608 pinctl
= (spec
->hp_present
&& spec
->cur_eapd
) ? PIN_HP
: 0;
1609 snd_hda_set_pin_ctl(codec
, 0x16, pinctl
);
1611 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1612 snd_hda_set_pin_ctl(codec
, 0x1a, pinctl
);
1613 /* on ideapad there is an additional speaker (subwoofer) to mute */
1615 snd_hda_set_pin_ctl(codec
, 0x1b, pinctl
);
1618 /* turn on/off EAPD (+ mute HP) as a master switch */
1619 static int cxt5051_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1620 struct snd_ctl_elem_value
*ucontrol
)
1622 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1624 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1626 cxt5051_update_speaker(codec
);
1630 /* toggle input of built-in and mic jack appropriately */
1631 static void cxt5051_portb_automic(struct hda_codec
*codec
)
1633 struct conexant_spec
*spec
= codec
->spec
;
1634 unsigned int present
;
1636 if (!(spec
->auto_mic
& AUTO_MIC_PORTB
))
1638 present
= snd_hda_jack_detect(codec
, 0x17);
1639 snd_hda_codec_write(codec
, 0x14, 0,
1640 AC_VERB_SET_CONNECT_SEL
,
1641 present
? 0x01 : 0x00);
1644 /* switch the current ADC according to the jack state */
1645 static void cxt5051_portc_automic(struct hda_codec
*codec
)
1647 struct conexant_spec
*spec
= codec
->spec
;
1648 unsigned int present
;
1651 if (!(spec
->auto_mic
& AUTO_MIC_PORTC
))
1653 present
= snd_hda_jack_detect(codec
, 0x18);
1655 spec
->cur_adc_idx
= 1;
1657 spec
->cur_adc_idx
= 0;
1658 new_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
1659 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
1660 /* stream is running, let's swap the current ADC */
1661 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
1662 spec
->cur_adc
= new_adc
;
1663 snd_hda_codec_setup_stream(codec
, new_adc
,
1664 spec
->cur_adc_stream_tag
, 0,
1665 spec
->cur_adc_format
);
1669 /* mute internal speaker if HP is plugged */
1670 static void cxt5051_hp_automute(struct hda_codec
*codec
)
1672 struct conexant_spec
*spec
= codec
->spec
;
1674 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x16);
1675 cxt5051_update_speaker(codec
);
1678 /* unsolicited event for HP jack sensing */
1679 static void cxt5051_hp_unsol_event(struct hda_codec
*codec
,
1682 switch (res
>> 26) {
1683 case CONEXANT_HP_EVENT
:
1684 cxt5051_hp_automute(codec
);
1686 case CXT5051_PORTB_EVENT
:
1687 cxt5051_portb_automic(codec
);
1689 case CXT5051_PORTC_EVENT
:
1690 cxt5051_portc_automic(codec
);
1695 static const struct snd_kcontrol_new cxt5051_playback_mixers
[] = {
1696 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1698 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1699 .name
= "Master Playback Switch",
1700 .info
= cxt_eapd_info
,
1701 .get
= cxt_eapd_get
,
1702 .put
= cxt5051_hp_master_sw_put
,
1703 .private_value
= 0x1a,
1708 static const struct snd_kcontrol_new cxt5051_capture_mixers
[] = {
1709 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1710 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1711 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT
),
1712 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT
),
1713 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT
),
1714 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT
),
1718 static const struct snd_kcontrol_new cxt5051_hp_mixers
[] = {
1719 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1720 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1721 HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT
),
1722 HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT
),
1726 static const struct snd_kcontrol_new cxt5051_hp_dv6736_mixers
[] = {
1727 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT
),
1728 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT
),
1732 static const struct snd_kcontrol_new cxt5051_f700_mixers
[] = {
1733 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT
),
1734 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT
),
1738 static const struct snd_kcontrol_new cxt5051_toshiba_mixers
[] = {
1739 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1740 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1741 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT
),
1742 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT
),
1746 static const struct hda_verb cxt5051_init_verbs
[] = {
1748 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1749 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1750 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1751 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1752 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1753 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1755 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1756 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1758 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1759 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1761 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1762 /* Record selector: Internal mic */
1763 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1764 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1765 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1766 /* SPDIF route: PCM */
1767 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1768 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1770 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1771 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1775 static const struct hda_verb cxt5051_hp_dv6736_init_verbs
[] = {
1777 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1778 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1779 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1780 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1782 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1783 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1785 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1786 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1788 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1789 /* Record selector: Internal mic */
1790 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1791 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1792 /* SPDIF route: PCM */
1793 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1795 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1796 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1800 static const struct hda_verb cxt5051_f700_init_verbs
[] = {
1802 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1803 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1804 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1805 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1807 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1808 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1810 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1811 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1813 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1814 /* Record selector: Internal mic */
1815 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1816 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1817 /* SPDIF route: PCM */
1818 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1820 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1821 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1825 static void cxt5051_init_mic_port(struct hda_codec
*codec
, hda_nid_t nid
,
1828 snd_hda_codec_write(codec
, nid
, 0,
1829 AC_VERB_SET_UNSOLICITED_ENABLE
,
1830 AC_USRSP_EN
| event
);
1833 static const struct hda_verb cxt5051_ideapad_init_verbs
[] = {
1835 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1836 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0x00},
1840 /* initialize jack-sensing, too */
1841 static int cxt5051_init(struct hda_codec
*codec
)
1843 struct conexant_spec
*spec
= codec
->spec
;
1845 conexant_init(codec
);
1847 if (spec
->auto_mic
& AUTO_MIC_PORTB
)
1848 cxt5051_init_mic_port(codec
, 0x17, CXT5051_PORTB_EVENT
);
1849 if (spec
->auto_mic
& AUTO_MIC_PORTC
)
1850 cxt5051_init_mic_port(codec
, 0x18, CXT5051_PORTC_EVENT
);
1852 if (codec
->patch_ops
.unsol_event
) {
1853 cxt5051_hp_automute(codec
);
1854 cxt5051_portb_automic(codec
);
1855 cxt5051_portc_automic(codec
);
1862 CXT5051_LAPTOP
, /* Laptops w/ EAPD support */
1863 CXT5051_HP
, /* no docking */
1864 CXT5051_HP_DV6736
, /* HP without mic switch */
1865 CXT5051_F700
, /* HP Compaq Presario F700 */
1866 CXT5051_TOSHIBA
, /* Toshiba M300 & co */
1867 CXT5051_IDEAPAD
, /* Lenovo IdeaPad Y430 */
1868 CXT5051_AUTO
, /* auto-parser */
1872 static const char *const cxt5051_models
[CXT5051_MODELS
] = {
1873 [CXT5051_LAPTOP
] = "laptop",
1874 [CXT5051_HP
] = "hp",
1875 [CXT5051_HP_DV6736
] = "hp-dv6736",
1876 [CXT5051_F700
] = "hp-700",
1877 [CXT5051_TOSHIBA
] = "toshiba",
1878 [CXT5051_IDEAPAD
] = "ideapad",
1879 [CXT5051_AUTO
] = "auto",
1882 static const struct snd_pci_quirk cxt5051_cfg_tbl
[] = {
1883 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736
),
1884 SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP
),
1885 SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700
),
1886 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA
),
1887 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1889 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP
),
1890 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD
),
1894 static int patch_cxt5051(struct hda_codec
*codec
)
1896 struct conexant_spec
*spec
;
1899 board_config
= snd_hda_check_board_config(codec
, CXT5051_MODELS
,
1902 if (board_config
< 0)
1903 board_config
= CXT5051_AUTO
; /* model=auto as default */
1904 if (board_config
== CXT5051_AUTO
)
1905 return patch_conexant_auto(codec
);
1907 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1911 codec
->pin_amp_workaround
= 1;
1913 codec
->patch_ops
= conexant_patch_ops
;
1914 codec
->patch_ops
.init
= cxt5051_init
;
1916 spec
->multiout
.max_channels
= 2;
1917 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5051_dac_nids
);
1918 spec
->multiout
.dac_nids
= cxt5051_dac_nids
;
1919 spec
->multiout
.dig_out_nid
= CXT5051_SPDIF_OUT
;
1920 spec
->num_adc_nids
= 1; /* not 2; via auto-mic switch */
1921 spec
->adc_nids
= cxt5051_adc_nids
;
1922 spec
->num_mixers
= 2;
1923 spec
->mixers
[0] = cxt5051_capture_mixers
;
1924 spec
->mixers
[1] = cxt5051_playback_mixers
;
1925 spec
->num_init_verbs
= 1;
1926 spec
->init_verbs
[0] = cxt5051_init_verbs
;
1927 spec
->spdif_route
= 0;
1928 spec
->num_channel_mode
= ARRAY_SIZE(cxt5051_modes
);
1929 spec
->channel_mode
= cxt5051_modes
;
1931 spec
->cur_adc_idx
= 0;
1933 set_beep_amp(spec
, 0x13, 0, HDA_OUTPUT
);
1935 codec
->patch_ops
.unsol_event
= cxt5051_hp_unsol_event
;
1937 spec
->auto_mic
= AUTO_MIC_PORTB
| AUTO_MIC_PORTC
;
1938 switch (board_config
) {
1940 spec
->mixers
[0] = cxt5051_hp_mixers
;
1942 case CXT5051_HP_DV6736
:
1943 spec
->init_verbs
[0] = cxt5051_hp_dv6736_init_verbs
;
1944 spec
->mixers
[0] = cxt5051_hp_dv6736_mixers
;
1948 spec
->init_verbs
[0] = cxt5051_f700_init_verbs
;
1949 spec
->mixers
[0] = cxt5051_f700_mixers
;
1952 case CXT5051_TOSHIBA
:
1953 spec
->mixers
[0] = cxt5051_toshiba_mixers
;
1954 spec
->auto_mic
= AUTO_MIC_PORTB
;
1956 case CXT5051_IDEAPAD
:
1957 spec
->init_verbs
[spec
->num_init_verbs
++] =
1958 cxt5051_ideapad_init_verbs
;
1964 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
1969 /* Conexant 5066 specific */
1971 static const hda_nid_t cxt5066_dac_nids
[1] = { 0x10 };
1972 static const hda_nid_t cxt5066_adc_nids
[3] = { 0x14, 0x15, 0x16 };
1973 static const hda_nid_t cxt5066_capsrc_nids
[1] = { 0x17 };
1974 static const hda_nid_t cxt5066_digout_pin_nids
[2] = { 0x20, 0x22 };
1976 /* OLPC's microphone port is DC coupled for use with external sensors,
1977 * therefore we use a 50% mic bias in order to center the input signal with
1978 * the DC input range of the codec. */
1979 #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50
1981 static const struct hda_channel_mode cxt5066_modes
[1] = {
1985 #define HP_PRESENT_PORT_A (1 << 0)
1986 #define HP_PRESENT_PORT_D (1 << 1)
1987 #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A)
1988 #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D)
1990 static void cxt5066_update_speaker(struct hda_codec
*codec
)
1992 struct conexant_spec
*spec
= codec
->spec
;
1993 unsigned int pinctl
;
1995 snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n",
1996 spec
->hp_present
, spec
->cur_eapd
);
1999 pinctl
= (hp_port_a_present(spec
) && spec
->cur_eapd
) ? PIN_HP
: 0;
2000 snd_hda_set_pin_ctl(codec
, 0x19, pinctl
);
2002 /* Port D (HP/LO) */
2003 pinctl
= spec
->cur_eapd
? spec
->port_d_mode
: 0;
2004 if (spec
->dell_automute
|| spec
->thinkpad
) {
2005 /* Mute if Port A is connected */
2006 if (hp_port_a_present(spec
))
2009 /* Thinkpad/Dell doesn't give pin-D status */
2010 if (!hp_port_d_present(spec
))
2013 snd_hda_set_pin_ctl(codec
, 0x1c, pinctl
);
2016 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
2017 snd_hda_set_pin_ctl(codec
, 0x1f, pinctl
);
2020 /* turn on/off EAPD (+ mute HP) as a master switch */
2021 static int cxt5066_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
2022 struct snd_ctl_elem_value
*ucontrol
)
2024 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2026 if (!cxt_eapd_put(kcontrol
, ucontrol
))
2029 cxt5066_update_speaker(codec
);
2033 static const struct hda_input_mux cxt5066_olpc_dc_bias
= {
2037 { "50%", PIN_VREF50
},
2038 { "80%", PIN_VREF80
},
2042 static int cxt5066_set_olpc_dc_bias(struct hda_codec
*codec
)
2044 struct conexant_spec
*spec
= codec
->spec
;
2045 /* Even though port F is the DC input, the bias is controlled on port B.
2046 * we also leave that port as an active input (but unselected) in DC mode
2047 * just in case that is necessary to make the bias setting take effect. */
2048 return snd_hda_set_pin_ctl_cache(codec
, 0x1a,
2049 cxt5066_olpc_dc_bias
.items
[spec
->dc_input_bias
].index
);
2052 /* OLPC defers mic widget control until when capture is started because the
2053 * microphone LED comes on as soon as these settings are put in place. if we
2054 * did this before recording, it would give the false indication that recording
2055 * is happening when it is not. */
2056 static void cxt5066_olpc_select_mic(struct hda_codec
*codec
)
2058 struct conexant_spec
*spec
= codec
->spec
;
2059 if (!spec
->recording
)
2062 if (spec
->dc_enable
) {
2063 /* in DC mode we ignore presence detection and just use the jack
2064 * through our special DC port */
2065 const struct hda_verb enable_dc_mode
[] = {
2066 /* disble internal mic, port C */
2067 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2069 /* enable DC capture, port F */
2070 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2074 snd_hda_sequence_write(codec
, enable_dc_mode
);
2075 /* port B input disabled (and bias set) through the following call */
2076 cxt5066_set_olpc_dc_bias(codec
);
2080 /* disable DC (port F) */
2081 snd_hda_set_pin_ctl(codec
, 0x1e, 0);
2083 /* external mic, port B */
2084 snd_hda_set_pin_ctl(codec
, 0x1a,
2085 spec
->ext_mic_present
? CXT5066_OLPC_EXT_MIC_BIAS
: 0);
2087 /* internal mic, port C */
2088 snd_hda_set_pin_ctl(codec
, 0x1b,
2089 spec
->ext_mic_present
? 0 : PIN_VREF80
);
2092 /* toggle input of built-in and mic jack appropriately */
2093 static void cxt5066_olpc_automic(struct hda_codec
*codec
)
2095 struct conexant_spec
*spec
= codec
->spec
;
2096 unsigned int present
;
2098 if (spec
->dc_enable
) /* don't do presence detection in DC mode */
2101 present
= snd_hda_codec_read(codec
, 0x1a, 0,
2102 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
2104 snd_printdd("CXT5066: external microphone detected\n");
2106 snd_printdd("CXT5066: external microphone absent\n");
2108 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2110 spec
->ext_mic_present
= !!present
;
2112 cxt5066_olpc_select_mic(codec
);
2115 /* toggle input of built-in digital mic and mic jack appropriately */
2116 static void cxt5066_vostro_automic(struct hda_codec
*codec
)
2118 unsigned int present
;
2120 struct hda_verb ext_mic_present
[] = {
2121 /* enable external mic, port B */
2122 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2124 /* switch to external mic input */
2125 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2126 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2128 /* disable internal digital mic */
2129 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2132 static const struct hda_verb ext_mic_absent
[] = {
2133 /* enable internal mic, port C */
2134 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2136 /* switch to internal mic input */
2137 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2139 /* disable external mic, port B */
2140 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2144 present
= snd_hda_jack_detect(codec
, 0x1a);
2146 snd_printdd("CXT5066: external microphone detected\n");
2147 snd_hda_sequence_write(codec
, ext_mic_present
);
2149 snd_printdd("CXT5066: external microphone absent\n");
2150 snd_hda_sequence_write(codec
, ext_mic_absent
);
2154 /* toggle input of built-in digital mic and mic jack appropriately */
2155 static void cxt5066_ideapad_automic(struct hda_codec
*codec
)
2157 unsigned int present
;
2159 struct hda_verb ext_mic_present
[] = {
2160 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2161 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2162 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2165 static const struct hda_verb ext_mic_absent
[] = {
2166 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2167 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2168 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2172 present
= snd_hda_jack_detect(codec
, 0x1b);
2174 snd_printdd("CXT5066: external microphone detected\n");
2175 snd_hda_sequence_write(codec
, ext_mic_present
);
2177 snd_printdd("CXT5066: external microphone absent\n");
2178 snd_hda_sequence_write(codec
, ext_mic_absent
);
2183 /* toggle input of built-in digital mic and mic jack appropriately */
2184 static void cxt5066_asus_automic(struct hda_codec
*codec
)
2186 unsigned int present
;
2188 present
= snd_hda_jack_detect(codec
, 0x1b);
2189 snd_printdd("CXT5066: external microphone present=%d\n", present
);
2190 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2195 /* toggle input of built-in digital mic and mic jack appropriately */
2196 static void cxt5066_hp_laptop_automic(struct hda_codec
*codec
)
2198 unsigned int present
;
2200 present
= snd_hda_jack_detect(codec
, 0x1b);
2201 snd_printdd("CXT5066: external microphone present=%d\n", present
);
2202 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2207 /* toggle input of built-in digital mic and mic jack appropriately
2208 order is: external mic -> dock mic -> interal mic */
2209 static void cxt5066_thinkpad_automic(struct hda_codec
*codec
)
2211 unsigned int ext_present
, dock_present
;
2213 static const struct hda_verb ext_mic_present
[] = {
2214 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2215 {0x17, AC_VERB_SET_CONNECT_SEL
, 1},
2216 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2217 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2218 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2221 static const struct hda_verb dock_mic_present
[] = {
2222 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2223 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2224 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2225 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2226 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2229 static const struct hda_verb ext_mic_absent
[] = {
2230 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2231 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2232 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2233 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2237 ext_present
= snd_hda_jack_detect(codec
, 0x1b);
2238 dock_present
= snd_hda_jack_detect(codec
, 0x1a);
2240 snd_printdd("CXT5066: external microphone detected\n");
2241 snd_hda_sequence_write(codec
, ext_mic_present
);
2242 } else if (dock_present
) {
2243 snd_printdd("CXT5066: dock microphone detected\n");
2244 snd_hda_sequence_write(codec
, dock_mic_present
);
2246 snd_printdd("CXT5066: external microphone absent\n");
2247 snd_hda_sequence_write(codec
, ext_mic_absent
);
2251 /* mute internal speaker if HP is plugged */
2252 static void cxt5066_hp_automute(struct hda_codec
*codec
)
2254 struct conexant_spec
*spec
= codec
->spec
;
2255 unsigned int portA
, portD
;
2258 portA
= snd_hda_jack_detect(codec
, 0x19);
2261 portD
= snd_hda_jack_detect(codec
, 0x1c);
2263 spec
->hp_present
= portA
? HP_PRESENT_PORT_A
: 0;
2264 spec
->hp_present
|= portD
? HP_PRESENT_PORT_D
: 0;
2265 snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
2266 portA
, portD
, spec
->hp_present
);
2267 cxt5066_update_speaker(codec
);
2270 /* Dispatch the right mic autoswitch function */
2271 static void cxt5066_automic(struct hda_codec
*codec
)
2273 struct conexant_spec
*spec
= codec
->spec
;
2275 if (spec
->dell_vostro
)
2276 cxt5066_vostro_automic(codec
);
2277 else if (spec
->ideapad
)
2278 cxt5066_ideapad_automic(codec
);
2279 else if (spec
->thinkpad
)
2280 cxt5066_thinkpad_automic(codec
);
2281 else if (spec
->hp_laptop
)
2282 cxt5066_hp_laptop_automic(codec
);
2283 else if (spec
->asus
)
2284 cxt5066_asus_automic(codec
);
2287 /* unsolicited event for jack sensing */
2288 static void cxt5066_olpc_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2290 struct conexant_spec
*spec
= codec
->spec
;
2291 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2292 switch (res
>> 26) {
2293 case CONEXANT_HP_EVENT
:
2294 cxt5066_hp_automute(codec
);
2296 case CONEXANT_MIC_EVENT
:
2297 /* ignore mic events in DC mode; we're always using the jack */
2298 if (!spec
->dc_enable
)
2299 cxt5066_olpc_automic(codec
);
2304 /* unsolicited event for jack sensing */
2305 static void cxt5066_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2307 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2308 switch (res
>> 26) {
2309 case CONEXANT_HP_EVENT
:
2310 cxt5066_hp_automute(codec
);
2312 case CONEXANT_MIC_EVENT
:
2313 cxt5066_automic(codec
);
2319 static const struct hda_input_mux cxt5066_analog_mic_boost
= {
2330 static void cxt5066_set_mic_boost(struct hda_codec
*codec
)
2332 struct conexant_spec
*spec
= codec
->spec
;
2333 snd_hda_codec_write_cache(codec
, 0x17, 0,
2334 AC_VERB_SET_AMP_GAIN_MUTE
,
2335 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_OUTPUT
|
2336 cxt5066_analog_mic_boost
.items
[spec
->mic_boost
].index
);
2337 if (spec
->ideapad
|| spec
->thinkpad
) {
2338 /* adjust the internal mic as well...it is not through 0x17 */
2339 snd_hda_codec_write_cache(codec
, 0x23, 0,
2340 AC_VERB_SET_AMP_GAIN_MUTE
,
2341 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_INPUT
|
2342 cxt5066_analog_mic_boost
.
2343 items
[spec
->mic_boost
].index
);
2347 static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol
*kcontrol
,
2348 struct snd_ctl_elem_info
*uinfo
)
2350 return snd_hda_input_mux_info(&cxt5066_analog_mic_boost
, uinfo
);
2353 static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol
*kcontrol
,
2354 struct snd_ctl_elem_value
*ucontrol
)
2356 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2357 struct conexant_spec
*spec
= codec
->spec
;
2358 ucontrol
->value
.enumerated
.item
[0] = spec
->mic_boost
;
2362 static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol
*kcontrol
,
2363 struct snd_ctl_elem_value
*ucontrol
)
2365 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2366 struct conexant_spec
*spec
= codec
->spec
;
2367 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2369 idx
= ucontrol
->value
.enumerated
.item
[0];
2370 if (idx
>= imux
->num_items
)
2371 idx
= imux
->num_items
- 1;
2373 spec
->mic_boost
= idx
;
2374 if (!spec
->dc_enable
)
2375 cxt5066_set_mic_boost(codec
);
2379 static void cxt5066_enable_dc(struct hda_codec
*codec
)
2381 const struct hda_verb enable_dc_mode
[] = {
2383 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2385 /* switch to DC input */
2386 {0x17, AC_VERB_SET_CONNECT_SEL
, 3},
2390 /* configure as input source */
2391 snd_hda_sequence_write(codec
, enable_dc_mode
);
2392 cxt5066_olpc_select_mic(codec
); /* also sets configured bias */
2395 static void cxt5066_disable_dc(struct hda_codec
*codec
)
2397 /* reconfigure input source */
2398 cxt5066_set_mic_boost(codec
);
2399 /* automic also selects the right mic if we're recording */
2400 cxt5066_olpc_automic(codec
);
2403 static int cxt5066_olpc_dc_get(struct snd_kcontrol
*kcontrol
,
2404 struct snd_ctl_elem_value
*ucontrol
)
2406 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2407 struct conexant_spec
*spec
= codec
->spec
;
2408 ucontrol
->value
.integer
.value
[0] = spec
->dc_enable
;
2412 static int cxt5066_olpc_dc_put(struct snd_kcontrol
*kcontrol
,
2413 struct snd_ctl_elem_value
*ucontrol
)
2415 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2416 struct conexant_spec
*spec
= codec
->spec
;
2417 int dc_enable
= !!ucontrol
->value
.integer
.value
[0];
2419 if (dc_enable
== spec
->dc_enable
)
2422 spec
->dc_enable
= dc_enable
;
2424 cxt5066_enable_dc(codec
);
2426 cxt5066_disable_dc(codec
);
2431 static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol
*kcontrol
,
2432 struct snd_ctl_elem_info
*uinfo
)
2434 return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias
, uinfo
);
2437 static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol
*kcontrol
,
2438 struct snd_ctl_elem_value
*ucontrol
)
2440 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2441 struct conexant_spec
*spec
= codec
->spec
;
2442 ucontrol
->value
.enumerated
.item
[0] = spec
->dc_input_bias
;
2446 static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol
*kcontrol
,
2447 struct snd_ctl_elem_value
*ucontrol
)
2449 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2450 struct conexant_spec
*spec
= codec
->spec
;
2451 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2454 idx
= ucontrol
->value
.enumerated
.item
[0];
2455 if (idx
>= imux
->num_items
)
2456 idx
= imux
->num_items
- 1;
2458 spec
->dc_input_bias
= idx
;
2459 if (spec
->dc_enable
)
2460 cxt5066_set_olpc_dc_bias(codec
);
2464 static void cxt5066_olpc_capture_prepare(struct hda_codec
*codec
)
2466 struct conexant_spec
*spec
= codec
->spec
;
2467 /* mark as recording and configure the microphone widget so that the
2468 * recording LED comes on. */
2469 spec
->recording
= 1;
2470 cxt5066_olpc_select_mic(codec
);
2473 static void cxt5066_olpc_capture_cleanup(struct hda_codec
*codec
)
2475 struct conexant_spec
*spec
= codec
->spec
;
2476 const struct hda_verb disable_mics
[] = {
2477 /* disable external mic, port B */
2478 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2480 /* disble internal mic, port C */
2481 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2483 /* disable DC capture, port F */
2484 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2488 snd_hda_sequence_write(codec
, disable_mics
);
2489 spec
->recording
= 0;
2492 static void conexant_check_dig_outs(struct hda_codec
*codec
,
2493 const hda_nid_t
*dig_pins
,
2496 struct conexant_spec
*spec
= codec
->spec
;
2497 hda_nid_t
*nid_loc
= &spec
->multiout
.dig_out_nid
;
2500 for (i
= 0; i
< num_pins
; i
++, dig_pins
++) {
2501 unsigned int cfg
= snd_hda_codec_get_pincfg(codec
, *dig_pins
);
2502 if (get_defcfg_connect(cfg
) == AC_JACK_PORT_NONE
)
2504 if (snd_hda_get_connections(codec
, *dig_pins
, nid_loc
, 1) != 1)
2506 if (spec
->slave_dig_outs
[0])
2509 nid_loc
= spec
->slave_dig_outs
;
2513 static const struct hda_input_mux cxt5066_capture_source
= {
2523 static const struct hda_bind_ctls cxt5066_bind_capture_vol_others
= {
2524 .ops
= &snd_hda_bind_vol
,
2526 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2527 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2532 static const struct hda_bind_ctls cxt5066_bind_capture_sw_others
= {
2533 .ops
= &snd_hda_bind_sw
,
2535 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2536 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2541 static const struct snd_kcontrol_new cxt5066_mixer_master
[] = {
2542 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
2546 static const struct snd_kcontrol_new cxt5066_mixer_master_olpc
[] = {
2548 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2549 .name
= "Master Playback Volume",
2550 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
|
2551 SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
2552 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
,
2553 .subdevice
= HDA_SUBDEV_AMP_FLAG
,
2554 .info
= snd_hda_mixer_amp_volume_info
,
2555 .get
= snd_hda_mixer_amp_volume_get
,
2556 .put
= snd_hda_mixer_amp_volume_put
,
2557 .tlv
= { .c
= snd_hda_mixer_amp_tlv
},
2558 /* offset by 28 volume steps to limit minimum gain to -46dB */
2560 HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT
, 28),
2565 static const struct snd_kcontrol_new cxt5066_mixer_olpc_dc
[] = {
2567 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2568 .name
= "DC Mode Enable Switch",
2569 .info
= snd_ctl_boolean_mono_info
,
2570 .get
= cxt5066_olpc_dc_get
,
2571 .put
= cxt5066_olpc_dc_put
,
2574 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2575 .name
= "DC Input Bias Enum",
2576 .info
= cxt5066_olpc_dc_bias_enum_info
,
2577 .get
= cxt5066_olpc_dc_bias_enum_get
,
2578 .put
= cxt5066_olpc_dc_bias_enum_put
,
2583 static const struct snd_kcontrol_new cxt5066_mixers
[] = {
2585 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2586 .name
= "Master Playback Switch",
2587 .info
= cxt_eapd_info
,
2588 .get
= cxt_eapd_get
,
2589 .put
= cxt5066_hp_master_sw_put
,
2590 .private_value
= 0x1d,
2594 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2595 .name
= "Analog Mic Boost Capture Enum",
2596 .info
= cxt5066_mic_boost_mux_enum_info
,
2597 .get
= cxt5066_mic_boost_mux_enum_get
,
2598 .put
= cxt5066_mic_boost_mux_enum_put
,
2601 HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others
),
2602 HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others
),
2606 static const struct snd_kcontrol_new cxt5066_vostro_mixers
[] = {
2608 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2609 .name
= "Internal Mic Boost Capture Enum",
2610 .info
= cxt5066_mic_boost_mux_enum_info
,
2611 .get
= cxt5066_mic_boost_mux_enum_get
,
2612 .put
= cxt5066_mic_boost_mux_enum_put
,
2613 .private_value
= 0x23 | 0x100,
2618 static const struct hda_verb cxt5066_init_verbs
[] = {
2619 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2620 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2621 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2622 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2625 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2626 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2629 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2630 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2632 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2633 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2636 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2638 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2639 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2640 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2641 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2642 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2643 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2645 /* no digital microphone support yet */
2646 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2648 /* Audio input selector */
2649 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2651 /* SPDIF route: PCM */
2652 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2653 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2655 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2656 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2659 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2661 /* not handling these yet */
2662 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2663 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2664 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2665 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2666 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2667 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2668 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2669 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2673 static const struct hda_verb cxt5066_init_verbs_olpc
[] = {
2674 /* Port A: headphones */
2675 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2676 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2678 /* Port B: external microphone */
2679 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2681 /* Port C: internal microphone */
2682 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2684 /* Port D: unused */
2685 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2687 /* Port E: unused, but has primary EAPD */
2688 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2689 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2691 /* Port F: external DC input through microphone port */
2692 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2694 /* Port G: internal speakers */
2695 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2696 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2699 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2702 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2704 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2705 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2706 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2707 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2708 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2709 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2710 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2712 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2713 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2714 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2715 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2717 /* Disable digital microphone port */
2718 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2720 /* Audio input selectors */
2721 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2722 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2725 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2726 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2728 /* enable unsolicited events for Port A and B */
2729 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2730 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2734 static const struct hda_verb cxt5066_init_verbs_vostro
[] = {
2735 /* Port A: headphones */
2736 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2737 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2739 /* Port B: external microphone */
2740 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2742 /* Port C: unused */
2743 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2745 /* Port D: unused */
2746 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2748 /* Port E: unused, but has primary EAPD */
2749 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2750 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2752 /* Port F: unused */
2753 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2755 /* Port G: internal speakers */
2756 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2757 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2760 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2763 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2765 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2766 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2767 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2768 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2769 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2770 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2771 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2772 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2773 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2774 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2775 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2776 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2778 /* Digital microphone port */
2779 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2781 /* Audio input selectors */
2782 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2783 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2786 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2787 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2789 /* enable unsolicited events for Port A and B */
2790 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2791 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2795 static const struct hda_verb cxt5066_init_verbs_ideapad
[] = {
2796 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2797 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2798 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2799 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2802 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2803 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2806 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2807 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2809 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2810 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2813 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2815 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2816 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2817 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2818 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2819 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2820 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2821 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2823 /* Audio input selector */
2824 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2825 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2827 /* SPDIF route: PCM */
2828 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2829 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2831 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2832 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2834 /* internal microphone */
2835 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable internal mic */
2838 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2840 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2841 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2845 static const struct hda_verb cxt5066_init_verbs_thinkpad
[] = {
2846 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2847 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2849 /* Port G: internal speakers */
2850 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2851 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2853 /* Port A: HP, Amp */
2854 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2855 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2857 /* Port B: Mic Dock */
2858 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2861 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2863 /* Port D: HP Dock, Amp */
2864 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2865 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2868 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2870 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2871 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2872 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2873 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2874 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2875 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2876 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2878 /* Audio input selector */
2879 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2880 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2882 /* SPDIF route: PCM */
2883 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2884 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2886 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2887 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2889 /* internal microphone */
2890 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable internal mic */
2893 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2895 /* enable unsolicited events for Port A, B, C and D */
2896 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2897 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2898 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2899 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2903 static const struct hda_verb cxt5066_init_verbs_portd_lo
[] = {
2904 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2909 static const struct hda_verb cxt5066_init_verbs_hp_laptop
[] = {
2910 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x0},
2911 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2912 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2916 /* initialize jack-sensing, too */
2917 static int cxt5066_init(struct hda_codec
*codec
)
2919 snd_printdd("CXT5066: init\n");
2920 conexant_init(codec
);
2921 if (codec
->patch_ops
.unsol_event
) {
2922 cxt5066_hp_automute(codec
);
2923 cxt5066_automic(codec
);
2925 cxt5066_set_mic_boost(codec
);
2929 static int cxt5066_olpc_init(struct hda_codec
*codec
)
2931 struct conexant_spec
*spec
= codec
->spec
;
2932 snd_printdd("CXT5066: init\n");
2933 conexant_init(codec
);
2934 cxt5066_hp_automute(codec
);
2935 if (!spec
->dc_enable
) {
2936 cxt5066_set_mic_boost(codec
);
2937 cxt5066_olpc_automic(codec
);
2939 cxt5066_enable_dc(codec
);
2945 CXT5066_LAPTOP
, /* Laptops w/ EAPD support */
2946 CXT5066_DELL_LAPTOP
, /* Dell Laptop */
2947 CXT5066_OLPC_XO_1_5
, /* OLPC XO 1.5 */
2948 CXT5066_DELL_VOSTRO
, /* Dell Vostro 1015i */
2949 CXT5066_IDEAPAD
, /* Lenovo IdeaPad U150 */
2950 CXT5066_THINKPAD
, /* Lenovo ThinkPad T410s, others? */
2951 CXT5066_ASUS
, /* Asus K52JU, Lenovo G560 - Int mic at 0x1a and Ext mic at 0x1b */
2952 CXT5066_HP_LAPTOP
, /* HP Laptop */
2953 CXT5066_AUTO
, /* BIOS auto-parser */
2957 static const char * const cxt5066_models
[CXT5066_MODELS
] = {
2958 [CXT5066_LAPTOP
] = "laptop",
2959 [CXT5066_DELL_LAPTOP
] = "dell-laptop",
2960 [CXT5066_OLPC_XO_1_5
] = "olpc-xo-1_5",
2961 [CXT5066_DELL_VOSTRO
] = "dell-vostro",
2962 [CXT5066_IDEAPAD
] = "ideapad",
2963 [CXT5066_THINKPAD
] = "thinkpad",
2964 [CXT5066_ASUS
] = "asus",
2965 [CXT5066_HP_LAPTOP
] = "hp-laptop",
2966 [CXT5066_AUTO
] = "auto",
2969 static const struct snd_pci_quirk cxt5066_cfg_tbl
[] = {
2970 SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD
),
2971 SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO
),
2972 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD
),
2973 SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO
),
2974 SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD
),
2975 SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD
),
2976 SND_PCI_QUIRK(0x1028, 0x0510, "Dell Vostro", CXT5066_IDEAPAD
),
2977 SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP
),
2978 SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS
),
2979 SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS
),
2980 SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS
),
2981 SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD
),
2982 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5
),
2983 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
2985 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5
),
2986 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD
),
2987 SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD
),
2988 SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS
),
2989 SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT5066_THINKPAD
),
2990 SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT5066_THINKPAD
),
2991 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo U350", CXT5066_ASUS
),
2992 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS
),
2996 static int patch_cxt5066(struct hda_codec
*codec
)
2998 struct conexant_spec
*spec
;
3001 board_config
= snd_hda_check_board_config(codec
, CXT5066_MODELS
,
3002 cxt5066_models
, cxt5066_cfg_tbl
);
3003 if (board_config
< 0)
3004 board_config
= CXT5066_AUTO
; /* model=auto as default */
3005 if (board_config
== CXT5066_AUTO
)
3006 return patch_conexant_auto(codec
);
3008 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3013 codec
->patch_ops
= conexant_patch_ops
;
3014 codec
->patch_ops
.init
= conexant_init
;
3016 spec
->dell_automute
= 0;
3017 spec
->multiout
.max_channels
= 2;
3018 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5066_dac_nids
);
3019 spec
->multiout
.dac_nids
= cxt5066_dac_nids
;
3020 conexant_check_dig_outs(codec
, cxt5066_digout_pin_nids
,
3021 ARRAY_SIZE(cxt5066_digout_pin_nids
));
3022 spec
->num_adc_nids
= 1;
3023 spec
->adc_nids
= cxt5066_adc_nids
;
3024 spec
->capsrc_nids
= cxt5066_capsrc_nids
;
3025 spec
->input_mux
= &cxt5066_capture_source
;
3027 spec
->port_d_mode
= PIN_HP
;
3029 spec
->num_init_verbs
= 1;
3030 spec
->init_verbs
[0] = cxt5066_init_verbs
;
3031 spec
->num_channel_mode
= ARRAY_SIZE(cxt5066_modes
);
3032 spec
->channel_mode
= cxt5066_modes
;
3034 spec
->cur_adc_idx
= 0;
3036 set_beep_amp(spec
, 0x13, 0, HDA_OUTPUT
);
3038 switch (board_config
) {
3040 case CXT5066_LAPTOP
:
3041 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3042 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3044 case CXT5066_DELL_LAPTOP
:
3045 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3046 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3048 spec
->port_d_mode
= PIN_OUT
;
3049 spec
->init_verbs
[spec
->num_init_verbs
] = cxt5066_init_verbs_portd_lo
;
3050 spec
->num_init_verbs
++;
3051 spec
->dell_automute
= 1;
3054 case CXT5066_HP_LAPTOP
:
3055 codec
->patch_ops
.init
= cxt5066_init
;
3056 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3057 spec
->init_verbs
[spec
->num_init_verbs
] =
3058 cxt5066_init_verbs_hp_laptop
;
3059 spec
->num_init_verbs
++;
3060 spec
->hp_laptop
= board_config
== CXT5066_HP_LAPTOP
;
3061 spec
->asus
= board_config
== CXT5066_ASUS
;
3062 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3063 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3065 if (board_config
== CXT5066_HP_LAPTOP
)
3066 spec
->multiout
.dig_out_nid
= 0;
3067 /* input source automatically selected */
3068 spec
->input_mux
= NULL
;
3069 spec
->port_d_mode
= 0;
3070 spec
->mic_boost
= 3; /* default 30dB gain */
3073 case CXT5066_OLPC_XO_1_5
:
3074 codec
->patch_ops
.init
= cxt5066_olpc_init
;
3075 codec
->patch_ops
.unsol_event
= cxt5066_olpc_unsol_event
;
3076 spec
->init_verbs
[0] = cxt5066_init_verbs_olpc
;
3077 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
3078 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_olpc_dc
;
3079 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3080 spec
->port_d_mode
= 0;
3081 spec
->mic_boost
= 3; /* default 30dB gain */
3084 spec
->multiout
.dig_out_nid
= 0;
3086 /* input source automatically selected */
3087 spec
->input_mux
= NULL
;
3089 /* our capture hooks which allow us to turn on the microphone LED
3090 * at the right time */
3091 spec
->capture_prepare
= cxt5066_olpc_capture_prepare
;
3092 spec
->capture_cleanup
= cxt5066_olpc_capture_cleanup
;
3094 case CXT5066_DELL_VOSTRO
:
3095 codec
->patch_ops
.init
= cxt5066_init
;
3096 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3097 spec
->init_verbs
[0] = cxt5066_init_verbs_vostro
;
3098 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
3099 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3100 spec
->mixers
[spec
->num_mixers
++] = cxt5066_vostro_mixers
;
3101 spec
->port_d_mode
= 0;
3102 spec
->dell_vostro
= 1;
3103 spec
->mic_boost
= 3; /* default 30dB gain */
3106 spec
->multiout
.dig_out_nid
= 0;
3108 /* input source automatically selected */
3109 spec
->input_mux
= NULL
;
3111 case CXT5066_IDEAPAD
:
3112 codec
->patch_ops
.init
= cxt5066_init
;
3113 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3114 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3115 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3116 spec
->init_verbs
[0] = cxt5066_init_verbs_ideapad
;
3117 spec
->port_d_mode
= 0;
3119 spec
->mic_boost
= 2; /* default 20dB gain */
3122 spec
->multiout
.dig_out_nid
= 0;
3124 /* input source automatically selected */
3125 spec
->input_mux
= NULL
;
3127 case CXT5066_THINKPAD
:
3128 codec
->patch_ops
.init
= cxt5066_init
;
3129 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3130 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3131 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3132 spec
->init_verbs
[0] = cxt5066_init_verbs_thinkpad
;
3134 spec
->port_d_mode
= PIN_OUT
;
3135 spec
->mic_boost
= 2; /* default 20dB gain */
3138 spec
->multiout
.dig_out_nid
= 0;
3140 /* input source automatically selected */
3141 spec
->input_mux
= NULL
;
3146 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
3152 * Automatic parser for CX20641 & co
3155 static int cx_auto_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
3156 struct hda_codec
*codec
,
3157 unsigned int stream_tag
,
3158 unsigned int format
,
3159 struct snd_pcm_substream
*substream
)
3161 struct conexant_spec
*spec
= codec
->spec
;
3162 hda_nid_t adc
= spec
->imux_info
[spec
->cur_mux
[0]].adc
;
3163 if (spec
->adc_switching
) {
3164 spec
->cur_adc
= adc
;
3165 spec
->cur_adc_stream_tag
= stream_tag
;
3166 spec
->cur_adc_format
= format
;
3168 snd_hda_codec_setup_stream(codec
, adc
, stream_tag
, 0, format
);
3172 static int cx_auto_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
3173 struct hda_codec
*codec
,
3174 struct snd_pcm_substream
*substream
)
3176 struct conexant_spec
*spec
= codec
->spec
;
3177 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
3182 static const struct hda_pcm_stream cx_auto_pcm_analog_capture
= {
3186 .nid
= 0, /* fill later */
3188 .prepare
= cx_auto_capture_pcm_prepare
,
3189 .cleanup
= cx_auto_capture_pcm_cleanup
3193 static const hda_nid_t cx_auto_adc_nids
[] = { 0x14 };
3195 #define get_connection_index(codec, mux, nid)\
3196 snd_hda_get_conn_index(codec, mux, nid, 0)
3198 /* get an unassigned DAC from the given list.
3199 * Return the nid if found and reduce the DAC list, or return zero if
3202 static hda_nid_t
get_unassigned_dac(struct hda_codec
*codec
, hda_nid_t pin
,
3203 hda_nid_t
*dacs
, int *num_dacs
)
3205 int i
, nums
= *num_dacs
;
3208 for (i
= 0; i
< nums
; i
++) {
3209 if (get_connection_index(codec
, pin
, dacs
[i
]) >= 0) {
3217 memmove(dacs
, dacs
+ 1, nums
* sizeof(hda_nid_t
));
3222 #define MAX_AUTO_DACS 5
3224 #define DAC_SLAVE_FLAG 0x8000 /* filled dac is a slave */
3226 /* fill analog DAC list from the widget tree */
3227 static int fill_cx_auto_dacs(struct hda_codec
*codec
, hda_nid_t
*dacs
)
3229 hda_nid_t nid
, end_nid
;
3232 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3233 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
3234 unsigned int wcaps
= get_wcaps(codec
, nid
);
3235 unsigned int type
= get_wcaps_type(wcaps
);
3236 if (type
== AC_WID_AUD_OUT
&& !(wcaps
& AC_WCAP_DIGITAL
)) {
3238 if (nums
>= MAX_AUTO_DACS
)
3245 /* fill pin_dac_pair list from the pin and dac list */
3246 static int fill_dacs_for_pins(struct hda_codec
*codec
, hda_nid_t
*pins
,
3247 int num_pins
, hda_nid_t
*dacs
, int *rest
,
3248 struct pin_dac_pair
*filled
, int nums
,
3251 int i
, start
= nums
;
3253 for (i
= 0; i
< num_pins
; i
++, nums
++) {
3254 filled
[nums
].pin
= pins
[i
];
3255 filled
[nums
].type
= type
;
3256 filled
[nums
].dac
= get_unassigned_dac(codec
, pins
[i
], dacs
, rest
);
3257 if (filled
[nums
].dac
)
3259 if (filled
[start
].dac
&& get_connection_index(codec
, pins
[i
], filled
[start
].dac
) >= 0) {
3260 filled
[nums
].dac
= filled
[start
].dac
| DAC_SLAVE_FLAG
;
3263 if (filled
[0].dac
&& get_connection_index(codec
, pins
[i
], filled
[0].dac
) >= 0) {
3264 filled
[nums
].dac
= filled
[0].dac
| DAC_SLAVE_FLAG
;
3267 snd_printdd("Failed to find a DAC for pin 0x%x", pins
[i
]);
3272 /* parse analog output paths */
3273 static void cx_auto_parse_output(struct hda_codec
*codec
)
3275 struct conexant_spec
*spec
= codec
->spec
;
3276 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3277 hda_nid_t dacs
[MAX_AUTO_DACS
];
3278 int i
, j
, nums
, rest
;
3280 rest
= fill_cx_auto_dacs(codec
, dacs
);
3281 /* parse all analog output pins */
3282 nums
= fill_dacs_for_pins(codec
, cfg
->line_out_pins
, cfg
->line_outs
,
3283 dacs
, &rest
, spec
->dac_info
, 0,
3285 nums
= fill_dacs_for_pins(codec
, cfg
->hp_pins
, cfg
->hp_outs
,
3286 dacs
, &rest
, spec
->dac_info
, nums
,
3288 nums
= fill_dacs_for_pins(codec
, cfg
->speaker_pins
, cfg
->speaker_outs
,
3289 dacs
, &rest
, spec
->dac_info
, nums
,
3290 AUTO_PIN_SPEAKER_OUT
);
3291 spec
->dac_info_filled
= nums
;
3292 /* fill multiout struct */
3293 for (i
= 0; i
< nums
; i
++) {
3294 hda_nid_t dac
= spec
->dac_info
[i
].dac
;
3295 if (!dac
|| (dac
& DAC_SLAVE_FLAG
))
3297 switch (spec
->dac_info
[i
].type
) {
3298 case AUTO_PIN_LINE_OUT
:
3299 spec
->private_dac_nids
[spec
->multiout
.num_dacs
] = dac
;
3300 spec
->multiout
.num_dacs
++;
3302 case AUTO_PIN_HP_OUT
:
3303 case AUTO_PIN_SPEAKER_OUT
:
3304 if (!spec
->multiout
.hp_nid
) {
3305 spec
->multiout
.hp_nid
= dac
;
3308 for (j
= 0; j
< ARRAY_SIZE(spec
->multiout
.extra_out_nid
); j
++)
3309 if (!spec
->multiout
.extra_out_nid
[j
]) {
3310 spec
->multiout
.extra_out_nid
[j
] = dac
;
3316 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3317 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
3319 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3320 if (is_jack_detectable(codec
, cfg
->hp_pins
[i
])) {
3321 spec
->auto_mute
= 1;
3325 if (spec
->auto_mute
&&
3326 cfg
->line_out_pins
[0] &&
3327 cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
&&
3328 cfg
->line_out_pins
[0] != cfg
->hp_pins
[0] &&
3329 cfg
->line_out_pins
[0] != cfg
->speaker_pins
[0]) {
3330 for (i
= 0; i
< cfg
->line_outs
; i
++) {
3331 if (is_jack_detectable(codec
, cfg
->line_out_pins
[i
])) {
3332 spec
->detect_line
= 1;
3336 spec
->automute_lines
= spec
->detect_line
;
3339 spec
->vmaster_nid
= spec
->private_dac_nids
[0];
3342 static void cx_auto_turn_eapd(struct hda_codec
*codec
, int num_pins
,
3343 hda_nid_t
*pins
, bool on
);
3345 static void do_automute(struct hda_codec
*codec
, int num_pins
,
3346 hda_nid_t
*pins
, bool on
)
3348 struct conexant_spec
*spec
= codec
->spec
;
3350 for (i
= 0; i
< num_pins
; i
++)
3351 snd_hda_set_pin_ctl(codec
, pins
[i
], on
? PIN_OUT
: 0);
3352 if (spec
->pin_eapd_ctrls
)
3353 cx_auto_turn_eapd(codec
, num_pins
, pins
, on
);
3356 static int detect_jacks(struct hda_codec
*codec
, int num_pins
, hda_nid_t
*pins
)
3360 for (i
= 0; i
< num_pins
; i
++) {
3361 hda_nid_t nid
= pins
[i
];
3362 if (!nid
|| !is_jack_detectable(codec
, nid
))
3364 present
|= snd_hda_jack_detect(codec
, nid
);
3369 /* auto-mute/unmute speaker and line outs according to headphone jack */
3370 static void cx_auto_update_speakers(struct hda_codec
*codec
)
3372 struct conexant_spec
*spec
= codec
->spec
;
3373 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3376 /* turn on HP EAPD when HP jacks are present */
3377 if (spec
->pin_eapd_ctrls
) {
3378 if (spec
->auto_mute
)
3379 on
= spec
->hp_present
;
3380 cx_auto_turn_eapd(codec
, cfg
->hp_outs
, cfg
->hp_pins
, on
);
3383 /* mute speakers in auto-mode if HP or LO jacks are plugged */
3384 if (spec
->auto_mute
)
3385 on
= !(spec
->hp_present
||
3386 (spec
->detect_line
&& spec
->line_present
));
3387 do_automute(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
, on
);
3389 /* toggle line-out mutes if needed, too */
3390 /* if LO is a copy of either HP or Speaker, don't need to handle it */
3391 if (cfg
->line_out_pins
[0] == cfg
->hp_pins
[0] ||
3392 cfg
->line_out_pins
[0] == cfg
->speaker_pins
[0])
3394 if (spec
->auto_mute
) {
3395 /* mute LO in auto-mode when HP jack is present */
3396 if (cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
||
3397 spec
->automute_lines
)
3398 on
= !spec
->hp_present
;
3402 do_automute(codec
, cfg
->line_outs
, cfg
->line_out_pins
, on
);
3405 static void cx_auto_hp_automute(struct hda_codec
*codec
)
3407 struct conexant_spec
*spec
= codec
->spec
;
3408 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3410 if (!spec
->auto_mute
)
3412 spec
->hp_present
= detect_jacks(codec
, cfg
->hp_outs
, cfg
->hp_pins
);
3413 cx_auto_update_speakers(codec
);
3416 static void cx_auto_line_automute(struct hda_codec
*codec
)
3418 struct conexant_spec
*spec
= codec
->spec
;
3419 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3421 if (!spec
->auto_mute
|| !spec
->detect_line
)
3423 spec
->line_present
= detect_jacks(codec
, cfg
->line_outs
,
3424 cfg
->line_out_pins
);
3425 cx_auto_update_speakers(codec
);
3428 static int cx_automute_mode_info(struct snd_kcontrol
*kcontrol
,
3429 struct snd_ctl_elem_info
*uinfo
)
3431 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3432 struct conexant_spec
*spec
= codec
->spec
;
3433 static const char * const texts2
[] = {
3434 "Disabled", "Enabled"
3436 static const char * const texts3
[] = {
3437 "Disabled", "Speaker Only", "Line Out+Speaker"
3439 const char * const *texts
;
3441 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
3443 if (spec
->automute_hp_lo
) {
3444 uinfo
->value
.enumerated
.items
= 3;
3447 uinfo
->value
.enumerated
.items
= 2;
3450 if (uinfo
->value
.enumerated
.item
>= uinfo
->value
.enumerated
.items
)
3451 uinfo
->value
.enumerated
.item
= uinfo
->value
.enumerated
.items
- 1;
3452 strcpy(uinfo
->value
.enumerated
.name
,
3453 texts
[uinfo
->value
.enumerated
.item
]);
3457 static int cx_automute_mode_get(struct snd_kcontrol
*kcontrol
,
3458 struct snd_ctl_elem_value
*ucontrol
)
3460 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3461 struct conexant_spec
*spec
= codec
->spec
;
3463 if (!spec
->auto_mute
)
3465 else if (!spec
->automute_lines
)
3469 ucontrol
->value
.enumerated
.item
[0] = val
;
3473 static int cx_automute_mode_put(struct snd_kcontrol
*kcontrol
,
3474 struct snd_ctl_elem_value
*ucontrol
)
3476 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3477 struct conexant_spec
*spec
= codec
->spec
;
3479 switch (ucontrol
->value
.enumerated
.item
[0]) {
3481 if (!spec
->auto_mute
)
3483 spec
->auto_mute
= 0;
3486 if (spec
->auto_mute
&& !spec
->automute_lines
)
3488 spec
->auto_mute
= 1;
3489 spec
->automute_lines
= 0;
3492 if (!spec
->automute_hp_lo
)
3494 if (spec
->auto_mute
&& spec
->automute_lines
)
3496 spec
->auto_mute
= 1;
3497 spec
->automute_lines
= 1;
3502 cx_auto_update_speakers(codec
);
3506 static const struct snd_kcontrol_new cx_automute_mode_enum
[] = {
3508 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3509 .name
= "Auto-Mute Mode",
3510 .info
= cx_automute_mode_info
,
3511 .get
= cx_automute_mode_get
,
3512 .put
= cx_automute_mode_put
,
3517 static int cx_auto_mux_enum_info(struct snd_kcontrol
*kcontrol
,
3518 struct snd_ctl_elem_info
*uinfo
)
3520 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3521 struct conexant_spec
*spec
= codec
->spec
;
3523 return snd_hda_input_mux_info(&spec
->private_imux
, uinfo
);
3526 static int cx_auto_mux_enum_get(struct snd_kcontrol
*kcontrol
,
3527 struct snd_ctl_elem_value
*ucontrol
)
3529 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3530 struct conexant_spec
*spec
= codec
->spec
;
3532 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[0];
3536 /* look for the route the given pin from mux and return the index;
3537 * if do_select is set, actually select the route.
3539 static int __select_input_connection(struct hda_codec
*codec
, hda_nid_t mux
,
3540 hda_nid_t pin
, hda_nid_t
*srcp
,
3541 bool do_select
, int depth
)
3543 hda_nid_t conn
[HDA_MAX_NUM_INPUTS
];
3546 switch (get_wcaps_type(get_wcaps(codec
, mux
))) {
3548 case AC_WID_AUD_SEL
:
3549 case AC_WID_AUD_MIX
:
3555 nums
= snd_hda_get_connections(codec
, mux
, conn
, ARRAY_SIZE(conn
));
3556 for (i
= 0; i
< nums
; i
++)
3557 if (conn
[i
] == pin
) {
3559 snd_hda_codec_write(codec
, mux
, 0,
3560 AC_VERB_SET_CONNECT_SEL
, i
);
3568 for (i
= 0; i
< nums
; i
++) {
3569 int ret
= __select_input_connection(codec
, conn
[i
], pin
, srcp
,
3573 snd_hda_codec_write(codec
, mux
, 0,
3574 AC_VERB_SET_CONNECT_SEL
, i
);
3581 static void select_input_connection(struct hda_codec
*codec
, hda_nid_t mux
,
3584 __select_input_connection(codec
, mux
, pin
, NULL
, true, 0);
3587 static int get_input_connection(struct hda_codec
*codec
, hda_nid_t mux
,
3590 return __select_input_connection(codec
, mux
, pin
, NULL
, false, 0);
3593 static int cx_auto_mux_enum_update(struct hda_codec
*codec
,
3594 const struct hda_input_mux
*imux
,
3597 struct conexant_spec
*spec
= codec
->spec
;
3601 if (!imux
->num_items
)
3603 if (idx
>= imux
->num_items
)
3604 idx
= imux
->num_items
- 1;
3605 if (spec
->cur_mux
[0] == idx
)
3607 adc
= spec
->imux_info
[idx
].adc
;
3608 select_input_connection(codec
, spec
->imux_info
[idx
].adc
,
3609 spec
->imux_info
[idx
].pin
);
3610 if (spec
->cur_adc
&& spec
->cur_adc
!= adc
) {
3611 /* stream is running, let's swap the current ADC */
3612 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
3613 spec
->cur_adc
= adc
;
3614 snd_hda_codec_setup_stream(codec
, adc
,
3615 spec
->cur_adc_stream_tag
, 0,
3616 spec
->cur_adc_format
);
3618 spec
->cur_mux
[0] = idx
;
3622 static int cx_auto_mux_enum_put(struct snd_kcontrol
*kcontrol
,
3623 struct snd_ctl_elem_value
*ucontrol
)
3625 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3626 struct conexant_spec
*spec
= codec
->spec
;
3628 return cx_auto_mux_enum_update(codec
, &spec
->private_imux
,
3629 ucontrol
->value
.enumerated
.item
[0]);
3632 static const struct snd_kcontrol_new cx_auto_capture_mixers
[] = {
3634 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3635 .name
= "Capture Source",
3636 .info
= cx_auto_mux_enum_info
,
3637 .get
= cx_auto_mux_enum_get
,
3638 .put
= cx_auto_mux_enum_put
3643 static bool select_automic(struct hda_codec
*codec
, int idx
, bool detect
)
3645 struct conexant_spec
*spec
= codec
->spec
;
3648 if (detect
&& !snd_hda_jack_detect(codec
, spec
->imux_info
[idx
].pin
))
3650 cx_auto_mux_enum_update(codec
, &spec
->private_imux
, idx
);
3654 /* automatic switch internal and external mic */
3655 static void cx_auto_automic(struct hda_codec
*codec
)
3657 struct conexant_spec
*spec
= codec
->spec
;
3659 if (!spec
->auto_mic
)
3661 if (!select_automic(codec
, spec
->auto_mic_ext
, true))
3662 if (!select_automic(codec
, spec
->auto_mic_dock
, true))
3663 select_automic(codec
, spec
->auto_mic_int
, false);
3666 static void cx_auto_unsol_event(struct hda_codec
*codec
, unsigned int res
)
3668 switch (snd_hda_jack_get_action(codec
, res
>> 26)) {
3669 case CONEXANT_HP_EVENT
:
3670 cx_auto_hp_automute(codec
);
3672 case CONEXANT_LINE_EVENT
:
3673 cx_auto_line_automute(codec
);
3675 case CONEXANT_MIC_EVENT
:
3676 cx_auto_automic(codec
);
3679 snd_hda_jack_report_sync(codec
);
3682 /* check whether the pin config is suitable for auto-mic switching;
3683 * auto-mic is enabled only when one int-mic and one ext- and/or
3684 * one dock-mic exist
3686 static void cx_auto_check_auto_mic(struct hda_codec
*codec
)
3688 struct conexant_spec
*spec
= codec
->spec
;
3689 int pset
[INPUT_PIN_ATTR_NORMAL
+ 1];
3692 for (i
= 0; i
< ARRAY_SIZE(pset
); i
++)
3694 for (i
= 0; i
< spec
->private_imux
.num_items
; i
++) {
3695 hda_nid_t pin
= spec
->imux_info
[i
].pin
;
3696 unsigned int def_conf
= snd_hda_codec_get_pincfg(codec
, pin
);
3698 attr
= snd_hda_get_input_pin_attr(def_conf
);
3699 if (attr
== INPUT_PIN_ATTR_UNUSED
)
3700 return; /* invalid entry */
3701 if (attr
> INPUT_PIN_ATTR_NORMAL
)
3702 attr
= INPUT_PIN_ATTR_NORMAL
;
3703 if (attr
!= INPUT_PIN_ATTR_INT
&&
3704 !is_jack_detectable(codec
, pin
))
3705 return; /* non-detectable pin */
3706 type
= get_defcfg_device(def_conf
);
3707 if (type
!= AC_JACK_MIC_IN
&&
3708 (attr
!= INPUT_PIN_ATTR_DOCK
|| type
!= AC_JACK_LINE_IN
))
3709 return; /* no valid input type */
3710 if (pset
[attr
] >= 0)
3711 return; /* already occupied */
3714 if (pset
[INPUT_PIN_ATTR_INT
] < 0 ||
3715 (pset
[INPUT_PIN_ATTR_NORMAL
] < 0 && pset
[INPUT_PIN_ATTR_DOCK
]))
3716 return; /* no input to switch*/
3718 spec
->auto_mic_ext
= pset
[INPUT_PIN_ATTR_NORMAL
];
3719 spec
->auto_mic_dock
= pset
[INPUT_PIN_ATTR_DOCK
];
3720 spec
->auto_mic_int
= pset
[INPUT_PIN_ATTR_INT
];
3723 static void cx_auto_parse_input(struct hda_codec
*codec
)
3725 struct conexant_spec
*spec
= codec
->spec
;
3726 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3727 struct hda_input_mux
*imux
;
3730 imux
= &spec
->private_imux
;
3731 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3732 for (j
= 0; j
< spec
->num_adc_nids
; j
++) {
3733 hda_nid_t adc
= spec
->adc_nids
[j
];
3734 int idx
= get_input_connection(codec
, adc
,
3735 cfg
->inputs
[i
].pin
);
3738 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
3739 spec
->imux_info
[imux
->num_items
].index
= i
;
3740 spec
->imux_info
[imux
->num_items
].boost
= 0;
3741 spec
->imux_info
[imux
->num_items
].adc
= adc
;
3742 spec
->imux_info
[imux
->num_items
].pin
=
3744 snd_hda_add_imux_item(imux
, label
, idx
, NULL
);
3749 if (imux
->num_items
>= 2 && cfg
->num_inputs
== imux
->num_items
)
3750 cx_auto_check_auto_mic(codec
);
3751 if (imux
->num_items
> 1) {
3752 for (i
= 1; i
< imux
->num_items
; i
++) {
3753 if (spec
->imux_info
[i
].adc
!= spec
->imux_info
[0].adc
) {
3754 spec
->adc_switching
= 1;
3761 /* get digital-input audio widget corresponding to the given pin */
3762 static hda_nid_t
cx_auto_get_dig_in(struct hda_codec
*codec
, hda_nid_t pin
)
3764 hda_nid_t nid
, end_nid
;
3766 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3767 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
3768 unsigned int wcaps
= get_wcaps(codec
, nid
);
3769 unsigned int type
= get_wcaps_type(wcaps
);
3770 if (type
== AC_WID_AUD_IN
&& (wcaps
& AC_WCAP_DIGITAL
)) {
3771 if (get_connection_index(codec
, nid
, pin
) >= 0)
3778 static void cx_auto_parse_digital(struct hda_codec
*codec
)
3780 struct conexant_spec
*spec
= codec
->spec
;
3781 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3784 if (cfg
->dig_outs
&&
3785 snd_hda_get_connections(codec
, cfg
->dig_out_pins
[0], &nid
, 1) == 1)
3786 spec
->multiout
.dig_out_nid
= nid
;
3787 if (cfg
->dig_in_pin
)
3788 spec
->dig_in_nid
= cx_auto_get_dig_in(codec
, cfg
->dig_in_pin
);
3791 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3792 static void cx_auto_parse_beep(struct hda_codec
*codec
)
3794 struct conexant_spec
*spec
= codec
->spec
;
3795 hda_nid_t nid
, end_nid
;
3797 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3798 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++)
3799 if (get_wcaps_type(get_wcaps(codec
, nid
)) == AC_WID_BEEP
) {
3800 set_beep_amp(spec
, nid
, 0, HDA_OUTPUT
);
3805 #define cx_auto_parse_beep(codec)
3809 static void cx_auto_parse_eapd(struct hda_codec
*codec
)
3811 struct conexant_spec
*spec
= codec
->spec
;
3812 hda_nid_t nid
, end_nid
;
3814 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3815 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
3816 if (get_wcaps_type(get_wcaps(codec
, nid
)) != AC_WID_PIN
)
3818 if (!(snd_hda_query_pin_caps(codec
, nid
) & AC_PINCAP_EAPD
))
3820 spec
->eapds
[spec
->num_eapds
++] = nid
;
3821 if (spec
->num_eapds
>= ARRAY_SIZE(spec
->eapds
))
3825 /* NOTE: below is a wild guess; if we have more than two EAPDs,
3826 * it's a new chip, where EAPDs are supposed to be associated to
3827 * pins, and we can control EAPD per pin.
3828 * OTOH, if only one or two EAPDs are found, it's an old chip,
3829 * thus it might control over all pins.
3831 spec
->pin_eapd_ctrls
= spec
->num_eapds
> 2;
3834 static int cx_auto_parse_auto_config(struct hda_codec
*codec
)
3836 struct conexant_spec
*spec
= codec
->spec
;
3839 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
3843 cx_auto_parse_output(codec
);
3844 cx_auto_parse_input(codec
);
3845 cx_auto_parse_digital(codec
);
3846 cx_auto_parse_beep(codec
);
3847 cx_auto_parse_eapd(codec
);
3851 static void cx_auto_turn_eapd(struct hda_codec
*codec
, int num_pins
,
3852 hda_nid_t
*pins
, bool on
)
3855 for (i
= 0; i
< num_pins
; i
++) {
3856 if (snd_hda_query_pin_caps(codec
, pins
[i
]) & AC_PINCAP_EAPD
)
3857 snd_hda_codec_write(codec
, pins
[i
], 0,
3858 AC_VERB_SET_EAPD_BTLENABLE
,
3863 static void select_connection(struct hda_codec
*codec
, hda_nid_t pin
,
3866 int idx
= get_connection_index(codec
, pin
, src
);
3868 snd_hda_codec_write(codec
, pin
, 0,
3869 AC_VERB_SET_CONNECT_SEL
, idx
);
3872 static void mute_outputs(struct hda_codec
*codec
, int num_nids
,
3873 const hda_nid_t
*nids
)
3877 for (i
= 0; i
< num_nids
; i
++) {
3878 hda_nid_t nid
= nids
[i
];
3879 if (!(get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
))
3881 if (query_amp_caps(codec
, nid
, HDA_OUTPUT
) & AC_AMPCAP_MUTE
)
3885 snd_hda_codec_write(codec
, nid
, 0,
3886 AC_VERB_SET_AMP_GAIN_MUTE
, val
);
3890 static void enable_unsol_pins(struct hda_codec
*codec
, int num_pins
,
3891 hda_nid_t
*pins
, unsigned int action
)
3894 for (i
= 0; i
< num_pins
; i
++)
3895 snd_hda_jack_detect_enable(codec
, pins
[i
], action
);
3898 static bool found_in_nid_list(hda_nid_t nid
, const hda_nid_t
*list
, int nums
)
3901 for (i
= 0; i
< nums
; i
++)
3907 /* is the given NID found in any of autocfg items? */
3908 static bool found_in_autocfg(struct auto_pin_cfg
*cfg
, hda_nid_t nid
)
3912 if (found_in_nid_list(nid
, cfg
->line_out_pins
, cfg
->line_outs
) ||
3913 found_in_nid_list(nid
, cfg
->hp_pins
, cfg
->hp_outs
) ||
3914 found_in_nid_list(nid
, cfg
->speaker_pins
, cfg
->speaker_outs
) ||
3915 found_in_nid_list(nid
, cfg
->dig_out_pins
, cfg
->dig_outs
))
3917 for (i
= 0; i
< cfg
->num_inputs
; i
++)
3918 if (cfg
->inputs
[i
].pin
== nid
)
3920 if (cfg
->dig_in_pin
== nid
)
3925 /* clear unsol-event tags on unused pins; Conexant codecs seem to leave
3926 * invalid unsol tags by some reason
3928 static void clear_unsol_on_unused_pins(struct hda_codec
*codec
)
3930 struct conexant_spec
*spec
= codec
->spec
;
3931 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3934 for (i
= 0; i
< codec
->init_pins
.used
; i
++) {
3935 struct hda_pincfg
*pin
= snd_array_elem(&codec
->init_pins
, i
);
3936 if (!found_in_autocfg(cfg
, pin
->nid
))
3937 snd_hda_codec_write(codec
, pin
->nid
, 0,
3938 AC_VERB_SET_UNSOLICITED_ENABLE
, 0);
3942 /* turn on/off EAPD according to Master switch */
3943 static void cx_auto_vmaster_hook(void *private_data
, int enabled
)
3945 struct hda_codec
*codec
= private_data
;
3946 struct conexant_spec
*spec
= codec
->spec
;
3948 if (enabled
&& spec
->pin_eapd_ctrls
) {
3949 cx_auto_update_speakers(codec
);
3952 cx_auto_turn_eapd(codec
, spec
->num_eapds
, spec
->eapds
, enabled
);
3955 static void cx_auto_init_output(struct hda_codec
*codec
)
3957 struct conexant_spec
*spec
= codec
->spec
;
3958 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3962 mute_outputs(codec
, spec
->multiout
.num_dacs
, spec
->multiout
.dac_nids
);
3963 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3964 unsigned int val
= PIN_OUT
;
3965 if (snd_hda_query_pin_caps(codec
, cfg
->hp_pins
[i
]) &
3967 val
|= AC_PINCTL_HP_EN
;
3968 snd_hda_set_pin_ctl(codec
, cfg
->hp_pins
[i
], val
);
3970 mute_outputs(codec
, cfg
->hp_outs
, cfg
->hp_pins
);
3971 mute_outputs(codec
, cfg
->line_outs
, cfg
->line_out_pins
);
3972 mute_outputs(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
);
3973 for (i
= 0; i
< spec
->dac_info_filled
; i
++) {
3974 nid
= spec
->dac_info
[i
].dac
;
3976 nid
= spec
->multiout
.dac_nids
[0];
3977 else if (nid
& DAC_SLAVE_FLAG
)
3978 nid
&= ~DAC_SLAVE_FLAG
;
3979 select_connection(codec
, spec
->dac_info
[i
].pin
, nid
);
3981 if (spec
->auto_mute
) {
3982 enable_unsol_pins(codec
, cfg
->hp_outs
, cfg
->hp_pins
,
3984 spec
->hp_present
= detect_jacks(codec
, cfg
->hp_outs
,
3986 if (spec
->detect_line
) {
3987 enable_unsol_pins(codec
, cfg
->line_outs
,
3989 CONEXANT_LINE_EVENT
);
3990 spec
->line_present
=
3991 detect_jacks(codec
, cfg
->line_outs
,
3992 cfg
->line_out_pins
);
3995 cx_auto_update_speakers(codec
);
3996 /* turn on all EAPDs if no individual EAPD control is available */
3997 if (!spec
->pin_eapd_ctrls
)
3998 cx_auto_turn_eapd(codec
, spec
->num_eapds
, spec
->eapds
, true);
3999 clear_unsol_on_unused_pins(codec
);
4002 static void cx_auto_init_input(struct hda_codec
*codec
)
4004 struct conexant_spec
*spec
= codec
->spec
;
4005 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4008 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
4009 hda_nid_t nid
= spec
->adc_nids
[i
];
4010 if (!(get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
))
4012 if (query_amp_caps(codec
, nid
, HDA_INPUT
) & AC_AMPCAP_MUTE
)
4013 val
= AMP_IN_MUTE(0);
4015 val
= AMP_IN_UNMUTE(0);
4016 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
4020 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
4021 hda_nid_t pin
= cfg
->inputs
[i
].pin
;
4022 unsigned int type
= PIN_IN
;
4023 if (cfg
->inputs
[i
].type
== AUTO_PIN_MIC
)
4024 type
|= snd_hda_get_default_vref(codec
, pin
);
4025 snd_hda_set_pin_ctl(codec
, pin
, type
);
4028 if (spec
->auto_mic
) {
4029 if (spec
->auto_mic_ext
>= 0) {
4030 snd_hda_jack_detect_enable(codec
,
4031 cfg
->inputs
[spec
->auto_mic_ext
].pin
,
4032 CONEXANT_MIC_EVENT
);
4034 if (spec
->auto_mic_dock
>= 0) {
4035 snd_hda_jack_detect_enable(codec
,
4036 cfg
->inputs
[spec
->auto_mic_dock
].pin
,
4037 CONEXANT_MIC_EVENT
);
4039 cx_auto_automic(codec
);
4041 select_input_connection(codec
, spec
->imux_info
[0].adc
,
4042 spec
->imux_info
[0].pin
);
4046 static void cx_auto_init_digital(struct hda_codec
*codec
)
4048 struct conexant_spec
*spec
= codec
->spec
;
4049 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4051 if (spec
->multiout
.dig_out_nid
)
4052 snd_hda_set_pin_ctl(codec
, cfg
->dig_out_pins
[0], PIN_OUT
);
4053 if (spec
->dig_in_nid
)
4054 snd_hda_set_pin_ctl(codec
, cfg
->dig_in_pin
, PIN_IN
);
4057 static int cx_auto_init(struct hda_codec
*codec
)
4059 struct conexant_spec
*spec
= codec
->spec
;
4060 snd_hda_gen_apply_verbs(codec
);
4061 cx_auto_init_output(codec
);
4062 cx_auto_init_input(codec
);
4063 cx_auto_init_digital(codec
);
4064 snd_hda_jack_report_sync(codec
);
4065 snd_hda_sync_vmaster_hook(&spec
->vmaster_mute
);
4069 static int cx_auto_add_volume_idx(struct hda_codec
*codec
, const char *basename
,
4070 const char *dir
, int cidx
,
4071 hda_nid_t nid
, int hda_dir
, int amp_idx
, int chs
)
4073 static char name
[44];
4074 static struct snd_kcontrol_new knew
[] = {
4075 HDA_CODEC_VOLUME(name
, 0, 0, 0),
4076 HDA_CODEC_MUTE(name
, 0, 0, 0),
4078 static const char * const sfx
[2] = { "Volume", "Switch" };
4081 for (i
= 0; i
< 2; i
++) {
4082 struct snd_kcontrol
*kctl
;
4083 knew
[i
].private_value
= HDA_COMPOSE_AMP_VAL(nid
, chs
, amp_idx
,
4085 knew
[i
].subdevice
= HDA_SUBDEV_AMP_FLAG
;
4086 knew
[i
].index
= cidx
;
4087 snprintf(name
, sizeof(name
), "%s%s %s", basename
, dir
, sfx
[i
]);
4088 kctl
= snd_ctl_new1(&knew
[i
], codec
);
4091 err
= snd_hda_ctl_add(codec
, nid
, kctl
);
4094 if (!(query_amp_caps(codec
, nid
, hda_dir
) &
4095 (AC_AMPCAP_MUTE
| AC_AMPCAP_MIN_MUTE
)))
4101 #define cx_auto_add_volume(codec, str, dir, cidx, nid, hda_dir) \
4102 cx_auto_add_volume_idx(codec, str, dir, cidx, nid, hda_dir, 0, 3)
4104 #define cx_auto_add_pb_volume(codec, nid, str, idx) \
4105 cx_auto_add_volume(codec, str, " Playback", idx, nid, HDA_OUTPUT)
4107 static int try_add_pb_volume(struct hda_codec
*codec
, hda_nid_t dac
,
4108 hda_nid_t pin
, const char *name
, int idx
)
4111 if (dac
&& !(dac
& DAC_SLAVE_FLAG
)) {
4112 caps
= query_amp_caps(codec
, dac
, HDA_OUTPUT
);
4113 if (caps
& AC_AMPCAP_NUM_STEPS
)
4114 return cx_auto_add_pb_volume(codec
, dac
, name
, idx
);
4116 caps
= query_amp_caps(codec
, pin
, HDA_OUTPUT
);
4117 if (caps
& AC_AMPCAP_NUM_STEPS
)
4118 return cx_auto_add_pb_volume(codec
, pin
, name
, idx
);
4122 static int cx_auto_build_output_controls(struct hda_codec
*codec
)
4124 struct conexant_spec
*spec
= codec
->spec
;
4126 int num_line
= 0, num_hp
= 0, num_spk
= 0;
4127 static const char * const texts
[3] = { "Front", "Surround", "CLFE" };
4129 if (spec
->dac_info_filled
== 1)
4130 return try_add_pb_volume(codec
, spec
->dac_info
[0].dac
,
4131 spec
->dac_info
[0].pin
,
4134 for (i
= 0; i
< spec
->dac_info_filled
; i
++) {
4137 hda_nid_t dac
= spec
->dac_info
[i
].dac
;
4138 type
= spec
->dac_info
[i
].type
;
4139 if (type
== AUTO_PIN_LINE_OUT
)
4140 type
= spec
->autocfg
.line_out_type
;
4142 case AUTO_PIN_LINE_OUT
:
4144 label
= texts
[num_line
++];
4147 case AUTO_PIN_HP_OUT
:
4148 label
= "Headphone";
4151 case AUTO_PIN_SPEAKER_OUT
:
4156 err
= try_add_pb_volume(codec
, dac
,
4157 spec
->dac_info
[i
].pin
,
4163 if (spec
->auto_mute
) {
4164 err
= snd_hda_add_new_ctls(codec
, cx_automute_mode_enum
);
4172 /* Returns zero if this is a normal stereo channel, and non-zero if it should
4173 be split in two independent channels.
4174 dest_label must be at least 44 characters. */
4175 static int cx_auto_get_rightch_label(struct hda_codec
*codec
, const char *label
,
4176 char *dest_label
, int nid
)
4178 struct conexant_spec
*spec
= codec
->spec
;
4181 if (!spec
->fixup_stereo_dmic
)
4184 for (i
= 0; i
< AUTO_CFG_MAX_INS
; i
++) {
4186 if (spec
->autocfg
.inputs
[i
].pin
!= nid
)
4189 if (spec
->autocfg
.inputs
[i
].type
!= AUTO_PIN_MIC
)
4191 def_conf
= snd_hda_codec_get_pincfg(codec
, nid
);
4192 if (snd_hda_get_input_pin_attr(def_conf
) != INPUT_PIN_ATTR_INT
)
4195 /* Finally found the inverted internal mic! */
4196 snprintf(dest_label
, 44, "Inverted %s", label
);
4202 static int cx_auto_add_capture_volume(struct hda_codec
*codec
, hda_nid_t nid
,
4203 const char *label
, const char *pfx
,
4206 struct conexant_spec
*spec
= codec
->spec
;
4209 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
4210 char rightch_label
[44];
4211 hda_nid_t adc_nid
= spec
->adc_nids
[i
];
4212 int idx
= get_input_connection(codec
, adc_nid
, nid
);
4215 if (codec
->single_adc_amp
)
4218 if (cx_auto_get_rightch_label(codec
, label
, rightch_label
, nid
)) {
4219 /* Make two independent kcontrols for left and right */
4220 int err
= cx_auto_add_volume_idx(codec
, label
, pfx
,
4221 cidx
, adc_nid
, HDA_INPUT
, idx
, 1);
4224 return cx_auto_add_volume_idx(codec
, rightch_label
, pfx
,
4225 cidx
, adc_nid
, HDA_INPUT
, idx
, 2);
4227 return cx_auto_add_volume_idx(codec
, label
, pfx
,
4228 cidx
, adc_nid
, HDA_INPUT
, idx
, 3);
4233 static int cx_auto_add_boost_volume(struct hda_codec
*codec
, int idx
,
4234 const char *label
, int cidx
)
4236 struct conexant_spec
*spec
= codec
->spec
;
4240 nid
= spec
->imux_info
[idx
].pin
;
4241 if (get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
) {
4242 char rightch_label
[44];
4243 if (cx_auto_get_rightch_label(codec
, label
, rightch_label
, nid
)) {
4244 int err
= cx_auto_add_volume_idx(codec
, label
, " Boost",
4245 cidx
, nid
, HDA_INPUT
, 0, 1);
4248 return cx_auto_add_volume_idx(codec
, rightch_label
, " Boost",
4249 cidx
, nid
, HDA_INPUT
, 0, 2);
4251 return cx_auto_add_volume(codec
, label
, " Boost", cidx
,
4254 con
= __select_input_connection(codec
, spec
->imux_info
[idx
].adc
, nid
,
4258 for (i
= 0; i
< idx
; i
++) {
4259 if (spec
->imux_info
[i
].boost
== mux
)
4260 return 0; /* already present */
4263 if (get_wcaps(codec
, mux
) & AC_WCAP_OUT_AMP
) {
4264 spec
->imux_info
[idx
].boost
= mux
;
4265 return cx_auto_add_volume(codec
, label
, " Boost", 0,
4271 static int cx_auto_build_input_controls(struct hda_codec
*codec
)
4273 struct conexant_spec
*spec
= codec
->spec
;
4274 struct hda_input_mux
*imux
= &spec
->private_imux
;
4275 const char *prev_label
;
4276 int input_conn
[HDA_MAX_NUM_INPUTS
];
4277 int i
, j
, err
, cidx
;
4278 int multi_connection
;
4280 if (!imux
->num_items
)
4283 multi_connection
= 0;
4284 for (i
= 0; i
< imux
->num_items
; i
++) {
4285 cidx
= get_input_connection(codec
, spec
->imux_info
[i
].adc
,
4286 spec
->imux_info
[i
].pin
);
4289 input_conn
[i
] = spec
->imux_info
[i
].adc
;
4290 if (!codec
->single_adc_amp
)
4291 input_conn
[i
] |= cidx
<< 8;
4292 if (i
> 0 && input_conn
[i
] != input_conn
[0])
4293 multi_connection
= 1;
4298 for (i
= 0; i
< imux
->num_items
; i
++) {
4299 hda_nid_t nid
= spec
->imux_info
[i
].pin
;
4302 label
= hda_get_autocfg_input_label(codec
, &spec
->autocfg
,
4303 spec
->imux_info
[i
].index
);
4304 if (label
== prev_label
)
4310 err
= cx_auto_add_boost_volume(codec
, i
, label
, cidx
);
4314 if (!multi_connection
) {
4317 err
= cx_auto_add_capture_volume(codec
, nid
,
4318 "Capture", "", cidx
);
4320 bool dup_found
= false;
4321 for (j
= 0; j
< i
; j
++) {
4322 if (input_conn
[j
] == input_conn
[i
]) {
4329 err
= cx_auto_add_capture_volume(codec
, nid
,
4330 label
, " Capture", cidx
);
4336 if (spec
->private_imux
.num_items
> 1 && !spec
->auto_mic
) {
4337 err
= snd_hda_add_new_ctls(codec
, cx_auto_capture_mixers
);
4345 static int cx_auto_build_controls(struct hda_codec
*codec
)
4347 struct conexant_spec
*spec
= codec
->spec
;
4350 err
= cx_auto_build_output_controls(codec
);
4353 err
= cx_auto_build_input_controls(codec
);
4356 err
= conexant_build_controls(codec
);
4359 err
= snd_hda_jack_add_kctls(codec
, &spec
->autocfg
);
4362 if (spec
->vmaster_mute
.sw_kctl
) {
4363 spec
->vmaster_mute
.hook
= cx_auto_vmaster_hook
;
4364 err
= snd_hda_add_vmaster_hook(codec
, &spec
->vmaster_mute
,
4365 spec
->vmaster_mute_led
);
4372 static int cx_auto_search_adcs(struct hda_codec
*codec
)
4374 struct conexant_spec
*spec
= codec
->spec
;
4375 hda_nid_t nid
, end_nid
;
4377 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
4378 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
4379 unsigned int caps
= get_wcaps(codec
, nid
);
4380 if (get_wcaps_type(caps
) != AC_WID_AUD_IN
)
4382 if (caps
& AC_WCAP_DIGITAL
)
4384 if (snd_BUG_ON(spec
->num_adc_nids
>=
4385 ARRAY_SIZE(spec
->private_adc_nids
)))
4387 spec
->private_adc_nids
[spec
->num_adc_nids
++] = nid
;
4389 spec
->adc_nids
= spec
->private_adc_nids
;
4393 static const struct hda_codec_ops cx_auto_patch_ops
= {
4394 .build_controls
= cx_auto_build_controls
,
4395 .build_pcms
= conexant_build_pcms
,
4396 .init
= cx_auto_init
,
4397 .free
= conexant_free
,
4398 .unsol_event
= cx_auto_unsol_event
,
4399 #ifdef CONFIG_SND_HDA_POWER_SAVE
4400 .suspend
= conexant_suspend
,
4402 .reboot_notify
= snd_hda_shutup_pins
,
4409 CXT_PINCFG_LENOVO_X200
,
4410 CXT_PINCFG_LENOVO_TP410
,
4411 CXT_FIXUP_STEREO_DMIC
,
4414 static void cxt_fixup_stereo_dmic(struct hda_codec
*codec
,
4415 const struct hda_fixup
*fix
, int action
)
4417 struct conexant_spec
*spec
= codec
->spec
;
4418 spec
->fixup_stereo_dmic
= 1;
4421 /* ThinkPad X200 & co with cxt5051 */
4422 static const struct hda_pintbl cxt_pincfg_lenovo_x200
[] = {
4423 { 0x16, 0x042140ff }, /* HP (seq# overridden) */
4424 { 0x17, 0x21a11000 }, /* dock-mic */
4425 { 0x19, 0x2121103f }, /* dock-HP */
4426 { 0x1c, 0x21440100 }, /* dock SPDIF out */
4430 /* ThinkPad 410/420/510/520, X201 & co with cxt5066 */
4431 static const struct hda_pintbl cxt_pincfg_lenovo_tp410
[] = {
4432 { 0x19, 0x042110ff }, /* HP (seq# overridden) */
4433 { 0x1a, 0x21a190f0 }, /* dock-mic */
4434 { 0x1c, 0x212140ff }, /* dock-HP */
4438 static const struct hda_fixup cxt_fixups
[] = {
4439 [CXT_PINCFG_LENOVO_X200
] = {
4440 .type
= HDA_FIXUP_PINS
,
4441 .v
.pins
= cxt_pincfg_lenovo_x200
,
4443 [CXT_PINCFG_LENOVO_TP410
] = {
4444 .type
= HDA_FIXUP_PINS
,
4445 .v
.pins
= cxt_pincfg_lenovo_tp410
,
4447 [CXT_FIXUP_STEREO_DMIC
] = {
4448 .type
= HDA_FIXUP_FUNC
,
4449 .v
.func
= cxt_fixup_stereo_dmic
,
4453 static const struct snd_pci_quirk cxt5051_fixups
[] = {
4454 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200
),
4458 static const struct snd_pci_quirk cxt5066_fixups
[] = {
4459 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410
),
4460 SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410
),
4461 SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410
),
4462 SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410
),
4463 SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410
),
4464 SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC
),
4465 SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC
),
4466 SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC
),
4470 /* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches
4471 * can be created (bko#42825)
4473 static void add_cx5051_fake_mutes(struct hda_codec
*codec
)
4475 static hda_nid_t out_nids
[] = {
4480 for (p
= out_nids
; *p
; p
++)
4481 snd_hda_override_amp_caps(codec
, *p
, HDA_OUTPUT
,
4482 AC_AMPCAP_MIN_MUTE
|
4483 query_amp_caps(codec
, *p
, HDA_OUTPUT
));
4486 static int patch_conexant_auto(struct hda_codec
*codec
)
4488 struct conexant_spec
*spec
;
4491 printk(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
4494 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4498 snd_hda_gen_init(&spec
->gen
);
4500 switch (codec
->vendor_id
) {
4502 codec
->single_adc_amp
= 1;
4505 add_cx5051_fake_mutes(codec
);
4506 codec
->pin_amp_workaround
= 1;
4507 snd_hda_pick_fixup(codec
, NULL
, cxt5051_fixups
, cxt_fixups
);
4510 codec
->pin_amp_workaround
= 1;
4511 snd_hda_pick_fixup(codec
, NULL
, cxt5066_fixups
, cxt_fixups
);
4515 snd_hda_apply_fixup(codec
, HDA_FIXUP_ACT_PRE_PROBE
);
4517 /* Show mute-led control only on HP laptops
4518 * This is a sort of white-list: on HP laptops, EAPD corresponds
4519 * only to the mute-LED without actualy amp function. Meanwhile,
4520 * others may use EAPD really as an amp switch, so it might be
4521 * not good to expose it blindly.
4523 switch (codec
->subsystem_id
>> 16) {
4525 spec
->vmaster_mute_led
= 1;
4529 err
= cx_auto_search_adcs(codec
);
4532 err
= cx_auto_parse_auto_config(codec
);
4538 spec
->capture_stream
= &cx_auto_pcm_analog_capture
;
4539 codec
->patch_ops
= cx_auto_patch_ops
;
4541 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
4543 /* Some laptops with Conexant chips show stalls in S3 resume,
4544 * which falls into the single-cmd mode.
4545 * Better to make reset, then.
4547 if (!codec
->bus
->sync_write
) {
4548 snd_printd("hda_codec: "
4549 "Enable sync_write for stable communication\n");
4550 codec
->bus
->sync_write
= 1;
4551 codec
->bus
->allow_bus_reset
= 1;
4560 static const struct hda_codec_preset snd_hda_preset_conexant
[] = {
4561 { .id
= 0x14f15045, .name
= "CX20549 (Venice)",
4562 .patch
= patch_cxt5045
},
4563 { .id
= 0x14f15047, .name
= "CX20551 (Waikiki)",
4564 .patch
= patch_cxt5047
},
4565 { .id
= 0x14f15051, .name
= "CX20561 (Hermosa)",
4566 .patch
= patch_cxt5051
},
4567 { .id
= 0x14f15066, .name
= "CX20582 (Pebble)",
4568 .patch
= patch_cxt5066
},
4569 { .id
= 0x14f15067, .name
= "CX20583 (Pebble HSF)",
4570 .patch
= patch_cxt5066
},
4571 { .id
= 0x14f15068, .name
= "CX20584",
4572 .patch
= patch_cxt5066
},
4573 { .id
= 0x14f15069, .name
= "CX20585",
4574 .patch
= patch_cxt5066
},
4575 { .id
= 0x14f1506c, .name
= "CX20588",
4576 .patch
= patch_cxt5066
},
4577 { .id
= 0x14f1506e, .name
= "CX20590",
4578 .patch
= patch_cxt5066
},
4579 { .id
= 0x14f15097, .name
= "CX20631",
4580 .patch
= patch_conexant_auto
},
4581 { .id
= 0x14f15098, .name
= "CX20632",
4582 .patch
= patch_conexant_auto
},
4583 { .id
= 0x14f150a1, .name
= "CX20641",
4584 .patch
= patch_conexant_auto
},
4585 { .id
= 0x14f150a2, .name
= "CX20642",
4586 .patch
= patch_conexant_auto
},
4587 { .id
= 0x14f150ab, .name
= "CX20651",
4588 .patch
= patch_conexant_auto
},
4589 { .id
= 0x14f150ac, .name
= "CX20652",
4590 .patch
= patch_conexant_auto
},
4591 { .id
= 0x14f150b8, .name
= "CX20664",
4592 .patch
= patch_conexant_auto
},
4593 { .id
= 0x14f150b9, .name
= "CX20665",
4594 .patch
= patch_conexant_auto
},
4595 { .id
= 0x14f1510f, .name
= "CX20751/2",
4596 .patch
= patch_conexant_auto
},
4597 { .id
= 0x14f15110, .name
= "CX20751/2",
4598 .patch
= patch_conexant_auto
},
4599 { .id
= 0x14f15111, .name
= "CX20753/4",
4600 .patch
= patch_conexant_auto
},
4604 MODULE_ALIAS("snd-hda-codec-id:14f15045");
4605 MODULE_ALIAS("snd-hda-codec-id:14f15047");
4606 MODULE_ALIAS("snd-hda-codec-id:14f15051");
4607 MODULE_ALIAS("snd-hda-codec-id:14f15066");
4608 MODULE_ALIAS("snd-hda-codec-id:14f15067");
4609 MODULE_ALIAS("snd-hda-codec-id:14f15068");
4610 MODULE_ALIAS("snd-hda-codec-id:14f15069");
4611 MODULE_ALIAS("snd-hda-codec-id:14f1506c");
4612 MODULE_ALIAS("snd-hda-codec-id:14f1506e");
4613 MODULE_ALIAS("snd-hda-codec-id:14f15097");
4614 MODULE_ALIAS("snd-hda-codec-id:14f15098");
4615 MODULE_ALIAS("snd-hda-codec-id:14f150a1");
4616 MODULE_ALIAS("snd-hda-codec-id:14f150a2");
4617 MODULE_ALIAS("snd-hda-codec-id:14f150ab");
4618 MODULE_ALIAS("snd-hda-codec-id:14f150ac");
4619 MODULE_ALIAS("snd-hda-codec-id:14f150b8");
4620 MODULE_ALIAS("snd-hda-codec-id:14f150b9");
4621 MODULE_ALIAS("snd-hda-codec-id:14f1510f");
4622 MODULE_ALIAS("snd-hda-codec-id:14f15110");
4623 MODULE_ALIAS("snd-hda-codec-id:14f15111");
4625 MODULE_LICENSE("GPL");
4626 MODULE_DESCRIPTION("Conexant HD-audio codec");
4628 static struct hda_codec_preset_list conexant_list
= {
4629 .preset
= snd_hda_preset_conexant
,
4630 .owner
= THIS_MODULE
,
4633 static int __init
patch_conexant_init(void)
4635 return snd_hda_add_codec_preset(&conexant_list
);
4638 static void __exit
patch_conexant_exit(void)
4640 snd_hda_delete_codec_preset(&conexant_list
);
4643 module_init(patch_conexant_init
)
4644 module_exit(patch_conexant_exit
)