2 * HD audio interface patch for Conexant HDA audio codec
4 * Copyright (c) 2006 Pototskiy Akex <alex.pototskiy@gmail.com>
5 * Takashi Iwai <tiwai@suse.de>
6 * Tobin Davis <tdavis@dsl-only.net>
8 * This driver is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This driver is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <linux/init.h>
24 #include <linux/delay.h>
25 #include <linux/slab.h>
26 #include <linux/pci.h>
27 #include <sound/core.h>
28 #include <sound/jack.h>
30 #include "hda_codec.h"
31 #include "hda_local.h"
34 #define CXT_PIN_DIR_IN 0x00
35 #define CXT_PIN_DIR_OUT 0x01
36 #define CXT_PIN_DIR_INOUT 0x02
37 #define CXT_PIN_DIR_IN_NOMICBIAS 0x03
38 #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04
40 #define CONEXANT_HP_EVENT 0x37
41 #define CONEXANT_MIC_EVENT 0x38
43 /* Conexant 5051 specific */
45 #define CXT5051_SPDIF_OUT 0x12
46 #define CXT5051_PORTB_EVENT 0x38
47 #define CXT5051_PORTC_EVENT 0x39
49 #define AUTO_MIC_PORTB (1 << 1)
50 #define AUTO_MIC_PORTC (1 << 2)
58 struct conexant_spec
{
60 const struct snd_kcontrol_new
*mixers
[5];
62 hda_nid_t vmaster_nid
;
64 const struct hda_verb
*init_verbs
[5]; /* initialization verbs
68 unsigned int num_init_verbs
;
71 struct hda_multi_out multiout
; /* playback set-up
72 * max_channels, dacs must be set
73 * dig_out_nid and hp_nid are optional
75 unsigned int cur_eapd
;
76 unsigned int hp_present
;
77 unsigned int auto_mic
;
78 int auto_mic_ext
; /* autocfg.inputs[] index for ext mic */
79 unsigned int need_dac_fix
;
80 hda_nid_t slave_dig_outs
[2];
83 unsigned int num_adc_nids
;
84 const hda_nid_t
*adc_nids
;
85 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
87 unsigned int cur_adc_idx
;
89 unsigned int cur_adc_stream_tag
;
90 unsigned int cur_adc_format
;
92 const struct hda_pcm_stream
*capture_stream
;
95 const struct hda_input_mux
*input_mux
;
96 const hda_nid_t
*capsrc_nids
;
97 unsigned int cur_mux
[3];
100 const struct hda_channel_mode
*channel_mode
;
101 int num_channel_mode
;
103 /* PCM information */
104 struct hda_pcm pcm_rec
[2]; /* used in build_pcms() */
106 unsigned int spdif_route
;
108 /* dynamic controls, init_verbs and input_mux */
109 struct auto_pin_cfg autocfg
;
110 struct hda_input_mux private_imux
;
111 hda_nid_t imux_adcs
[HDA_MAX_NUM_INPUTS
];
112 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
113 struct pin_dac_pair dac_info
[8];
116 unsigned int port_d_mode
;
117 unsigned int auto_mute
:1; /* used in auto-parser */
118 unsigned int dell_automute
:1;
119 unsigned int dell_vostro
:1;
120 unsigned int ideapad
:1;
121 unsigned int thinkpad
:1;
122 unsigned int hp_laptop
:1;
125 unsigned int adc_switching
:1;
127 unsigned int ext_mic_present
;
128 unsigned int recording
;
129 void (*capture_prepare
)(struct hda_codec
*codec
);
130 void (*capture_cleanup
)(struct hda_codec
*codec
);
132 /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
133 * through the microphone jack.
134 * When the user enables this through a mixer switch, both internal and
135 * external microphones are disabled. Gain is fixed at 0dB. In this mode,
136 * we also allow the bias to be configured through a separate mixer
138 unsigned int dc_enable
;
139 unsigned int dc_input_bias
; /* offset into cxt5066_olpc_dc_bias */
140 unsigned int mic_boost
; /* offset into cxt5066_analog_mic_boost */
142 unsigned int beep_amp
;
145 static int conexant_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
146 struct hda_codec
*codec
,
147 struct snd_pcm_substream
*substream
)
149 struct conexant_spec
*spec
= codec
->spec
;
150 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
154 static int conexant_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
155 struct hda_codec
*codec
,
156 unsigned int stream_tag
,
158 struct snd_pcm_substream
*substream
)
160 struct conexant_spec
*spec
= codec
->spec
;
161 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
166 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
167 struct hda_codec
*codec
,
168 struct snd_pcm_substream
*substream
)
170 struct conexant_spec
*spec
= codec
->spec
;
171 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
177 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
178 struct hda_codec
*codec
,
179 struct snd_pcm_substream
*substream
)
181 struct conexant_spec
*spec
= codec
->spec
;
182 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
185 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
186 struct hda_codec
*codec
,
187 struct snd_pcm_substream
*substream
)
189 struct conexant_spec
*spec
= codec
->spec
;
190 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
193 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
194 struct hda_codec
*codec
,
195 unsigned int stream_tag
,
197 struct snd_pcm_substream
*substream
)
199 struct conexant_spec
*spec
= codec
->spec
;
200 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
208 static int conexant_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
209 struct hda_codec
*codec
,
210 unsigned int stream_tag
,
212 struct snd_pcm_substream
*substream
)
214 struct conexant_spec
*spec
= codec
->spec
;
215 if (spec
->capture_prepare
)
216 spec
->capture_prepare(codec
);
217 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
218 stream_tag
, 0, format
);
222 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
223 struct hda_codec
*codec
,
224 struct snd_pcm_substream
*substream
)
226 struct conexant_spec
*spec
= codec
->spec
;
227 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
228 if (spec
->capture_cleanup
)
229 spec
->capture_cleanup(codec
);
235 static const struct hda_pcm_stream conexant_pcm_analog_playback
= {
239 .nid
= 0, /* fill later */
241 .open
= conexant_playback_pcm_open
,
242 .prepare
= conexant_playback_pcm_prepare
,
243 .cleanup
= conexant_playback_pcm_cleanup
247 static const struct hda_pcm_stream conexant_pcm_analog_capture
= {
251 .nid
= 0, /* fill later */
253 .prepare
= conexant_capture_pcm_prepare
,
254 .cleanup
= conexant_capture_pcm_cleanup
259 static const struct hda_pcm_stream conexant_pcm_digital_playback
= {
263 .nid
= 0, /* fill later */
265 .open
= conexant_dig_playback_pcm_open
,
266 .close
= conexant_dig_playback_pcm_close
,
267 .prepare
= conexant_dig_playback_pcm_prepare
271 static const struct hda_pcm_stream conexant_pcm_digital_capture
= {
275 /* NID is set in alc_build_pcms */
278 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
279 struct hda_codec
*codec
,
280 unsigned int stream_tag
,
282 struct snd_pcm_substream
*substream
)
284 struct conexant_spec
*spec
= codec
->spec
;
285 spec
->cur_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
286 spec
->cur_adc_stream_tag
= stream_tag
;
287 spec
->cur_adc_format
= format
;
288 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
292 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
293 struct hda_codec
*codec
,
294 struct snd_pcm_substream
*substream
)
296 struct conexant_spec
*spec
= codec
->spec
;
297 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
302 static const struct hda_pcm_stream cx5051_pcm_analog_capture
= {
306 .nid
= 0, /* fill later */
308 .prepare
= cx5051_capture_pcm_prepare
,
309 .cleanup
= cx5051_capture_pcm_cleanup
313 static int conexant_build_pcms(struct hda_codec
*codec
)
315 struct conexant_spec
*spec
= codec
->spec
;
316 struct hda_pcm
*info
= spec
->pcm_rec
;
319 codec
->pcm_info
= info
;
321 info
->name
= "CONEXANT Analog";
322 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = conexant_pcm_analog_playback
;
323 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
=
324 spec
->multiout
.max_channels
;
325 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
326 spec
->multiout
.dac_nids
[0];
327 if (spec
->capture_stream
)
328 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *spec
->capture_stream
;
330 if (codec
->vendor_id
== 0x14f15051)
331 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
332 cx5051_pcm_analog_capture
;
334 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
335 conexant_pcm_analog_capture
;
336 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
=
340 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
342 if (spec
->multiout
.dig_out_nid
) {
345 info
->name
= "Conexant Digital";
346 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
347 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
348 conexant_pcm_digital_playback
;
349 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
350 spec
->multiout
.dig_out_nid
;
351 if (spec
->dig_in_nid
) {
352 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
353 conexant_pcm_digital_capture
;
354 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
357 if (spec
->slave_dig_outs
[0])
358 codec
->slave_dig_outs
= spec
->slave_dig_outs
;
364 static int conexant_mux_enum_info(struct snd_kcontrol
*kcontrol
,
365 struct snd_ctl_elem_info
*uinfo
)
367 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
368 struct conexant_spec
*spec
= codec
->spec
;
370 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
373 static int conexant_mux_enum_get(struct snd_kcontrol
*kcontrol
,
374 struct snd_ctl_elem_value
*ucontrol
)
376 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
377 struct conexant_spec
*spec
= codec
->spec
;
378 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
380 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
384 static int conexant_mux_enum_put(struct snd_kcontrol
*kcontrol
,
385 struct snd_ctl_elem_value
*ucontrol
)
387 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
388 struct conexant_spec
*spec
= codec
->spec
;
389 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
391 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
392 spec
->capsrc_nids
[adc_idx
],
393 &spec
->cur_mux
[adc_idx
]);
396 static int conexant_init_jacks(struct hda_codec
*codec
)
398 #ifdef CONFIG_SND_HDA_INPUT_JACK
399 struct conexant_spec
*spec
= codec
->spec
;
402 for (i
= 0; i
< spec
->num_init_verbs
; i
++) {
403 const struct hda_verb
*hv
;
405 hv
= spec
->init_verbs
[i
];
408 switch (hv
->param
^ AC_USRSP_EN
) {
409 case CONEXANT_HP_EVENT
:
410 err
= snd_hda_input_jack_add(codec
, hv
->nid
,
411 SND_JACK_HEADPHONE
, NULL
);
412 snd_hda_input_jack_report(codec
, hv
->nid
);
414 case CXT5051_PORTC_EVENT
:
415 case CONEXANT_MIC_EVENT
:
416 err
= snd_hda_input_jack_add(codec
, hv
->nid
,
417 SND_JACK_MICROPHONE
, NULL
);
418 snd_hda_input_jack_report(codec
, hv
->nid
);
426 #endif /* CONFIG_SND_HDA_INPUT_JACK */
430 static int conexant_init(struct hda_codec
*codec
)
432 struct conexant_spec
*spec
= codec
->spec
;
435 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
436 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
440 static void conexant_free(struct hda_codec
*codec
)
442 snd_hda_input_jack_free(codec
);
443 snd_hda_detach_beep_device(codec
);
447 static const struct snd_kcontrol_new cxt_capture_mixers
[] = {
449 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
450 .name
= "Capture Source",
451 .info
= conexant_mux_enum_info
,
452 .get
= conexant_mux_enum_get
,
453 .put
= conexant_mux_enum_put
458 #ifdef CONFIG_SND_HDA_INPUT_BEEP
459 /* additional beep mixers; the actual parameters are overwritten at build */
460 static const struct snd_kcontrol_new cxt_beep_mixer
[] = {
461 HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT
),
462 HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT
),
467 static const char * const slave_vols
[] = {
468 "Headphone Playback Volume",
469 "Speaker Playback Volume",
473 static const char * const slave_sws
[] = {
474 "Headphone Playback Switch",
475 "Speaker Playback Switch",
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
);
495 err
= snd_hda_create_spdif_share_sw(codec
,
499 spec
->multiout
.share_spdif
= 1;
501 if (spec
->dig_in_nid
) {
502 err
= snd_hda_create_spdif_in_ctls(codec
,spec
->dig_in_nid
);
507 /* if we have no master control, let's create it */
508 if (spec
->vmaster_nid
&&
509 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
510 unsigned int vmaster_tlv
[4];
511 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
512 HDA_OUTPUT
, vmaster_tlv
);
513 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
514 vmaster_tlv
, slave_vols
);
518 if (spec
->vmaster_nid
&&
519 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
520 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
526 if (spec
->input_mux
) {
527 err
= snd_hda_add_new_ctls(codec
, cxt_capture_mixers
);
532 #ifdef CONFIG_SND_HDA_INPUT_BEEP
533 /* create beep controls if needed */
534 if (spec
->beep_amp
) {
535 const struct snd_kcontrol_new
*knew
;
536 for (knew
= cxt_beep_mixer
; knew
->name
; knew
++) {
537 struct snd_kcontrol
*kctl
;
538 kctl
= snd_ctl_new1(knew
, codec
);
541 kctl
->private_value
= spec
->beep_amp
;
542 err
= snd_hda_ctl_add(codec
, 0, kctl
);
552 #ifdef CONFIG_SND_HDA_POWER_SAVE
553 static int conexant_suspend(struct hda_codec
*codec
, pm_message_t state
)
555 snd_hda_shutup_pins(codec
);
560 static const struct hda_codec_ops conexant_patch_ops
= {
561 .build_controls
= conexant_build_controls
,
562 .build_pcms
= conexant_build_pcms
,
563 .init
= conexant_init
,
564 .free
= conexant_free
,
565 #ifdef CONFIG_SND_HDA_POWER_SAVE
566 .suspend
= conexant_suspend
,
568 .reboot_notify
= snd_hda_shutup_pins
,
571 #ifdef CONFIG_SND_HDA_INPUT_BEEP
572 #define set_beep_amp(spec, nid, idx, dir) \
573 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir))
575 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
578 static int patch_conexant_auto(struct hda_codec
*codec
);
581 * the private value = nid | (invert << 8)
584 #define cxt_eapd_info snd_ctl_boolean_mono_info
586 static int cxt_eapd_get(struct snd_kcontrol
*kcontrol
,
587 struct snd_ctl_elem_value
*ucontrol
)
589 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
590 struct conexant_spec
*spec
= codec
->spec
;
591 int invert
= (kcontrol
->private_value
>> 8) & 1;
593 ucontrol
->value
.integer
.value
[0] = !spec
->cur_eapd
;
595 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
600 static int cxt_eapd_put(struct snd_kcontrol
*kcontrol
,
601 struct snd_ctl_elem_value
*ucontrol
)
603 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
604 struct conexant_spec
*spec
= codec
->spec
;
605 int invert
= (kcontrol
->private_value
>> 8) & 1;
606 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
609 eapd
= !!ucontrol
->value
.integer
.value
[0];
612 if (eapd
== spec
->cur_eapd
)
615 spec
->cur_eapd
= eapd
;
616 snd_hda_codec_write_cache(codec
, nid
,
617 0, AC_VERB_SET_EAPD_BTLENABLE
,
622 /* controls for test mode */
623 #ifdef CONFIG_SND_DEBUG
625 #define CXT_EAPD_SWITCH(xname, nid, mask) \
626 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
627 .info = cxt_eapd_info, \
628 .get = cxt_eapd_get, \
629 .put = cxt_eapd_put, \
630 .private_value = nid | (mask<<16) }
634 static int conexant_ch_mode_info(struct snd_kcontrol
*kcontrol
,
635 struct snd_ctl_elem_info
*uinfo
)
637 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
638 struct conexant_spec
*spec
= codec
->spec
;
639 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
640 spec
->num_channel_mode
);
643 static int conexant_ch_mode_get(struct snd_kcontrol
*kcontrol
,
644 struct snd_ctl_elem_value
*ucontrol
)
646 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
647 struct conexant_spec
*spec
= codec
->spec
;
648 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
649 spec
->num_channel_mode
,
650 spec
->multiout
.max_channels
);
653 static int conexant_ch_mode_put(struct snd_kcontrol
*kcontrol
,
654 struct snd_ctl_elem_value
*ucontrol
)
656 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
657 struct conexant_spec
*spec
= codec
->spec
;
658 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
659 spec
->num_channel_mode
,
660 &spec
->multiout
.max_channels
);
661 if (err
>= 0 && spec
->need_dac_fix
)
662 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
666 #define CXT_PIN_MODE(xname, nid, dir) \
667 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
668 .info = conexant_ch_mode_info, \
669 .get = conexant_ch_mode_get, \
670 .put = conexant_ch_mode_put, \
671 .private_value = nid | (dir<<16) }
673 #endif /* CONFIG_SND_DEBUG */
675 /* Conexant 5045 specific */
677 static const hda_nid_t cxt5045_dac_nids
[1] = { 0x19 };
678 static const hda_nid_t cxt5045_adc_nids
[1] = { 0x1a };
679 static const hda_nid_t cxt5045_capsrc_nids
[1] = { 0x1a };
680 #define CXT5045_SPDIF_OUT 0x18
682 static const struct hda_channel_mode cxt5045_modes
[1] = {
686 static const struct hda_input_mux cxt5045_capture_source
= {
694 static const struct hda_input_mux cxt5045_capture_source_benq
= {
705 static const struct hda_input_mux cxt5045_capture_source_hp530
= {
713 /* turn on/off EAPD (+ mute HP) as a master switch */
714 static int cxt5045_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
715 struct snd_ctl_elem_value
*ucontrol
)
717 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
718 struct conexant_spec
*spec
= codec
->spec
;
721 if (!cxt_eapd_put(kcontrol
, ucontrol
))
724 /* toggle internal speakers mute depending of presence of
727 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
728 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
731 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
732 snd_hda_codec_amp_stereo(codec
, 0x11, HDA_OUTPUT
, 0,
737 /* bind volumes of both NID 0x10 and 0x11 */
738 static const struct hda_bind_ctls cxt5045_hp_bind_master_vol
= {
739 .ops
= &snd_hda_bind_vol
,
741 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT
),
742 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT
),
747 /* toggle input of built-in and mic jack appropriately */
748 static void cxt5045_hp_automic(struct hda_codec
*codec
)
750 static const struct hda_verb mic_jack_on
[] = {
751 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
752 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
755 static const struct hda_verb mic_jack_off
[] = {
756 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
757 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
760 unsigned int present
;
762 present
= snd_hda_jack_detect(codec
, 0x12);
764 snd_hda_sequence_write(codec
, mic_jack_on
);
766 snd_hda_sequence_write(codec
, mic_jack_off
);
770 /* mute internal speaker if HP is plugged */
771 static void cxt5045_hp_automute(struct hda_codec
*codec
)
773 struct conexant_spec
*spec
= codec
->spec
;
776 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x11);
778 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
779 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
783 /* unsolicited event for HP jack sensing */
784 static void cxt5045_hp_unsol_event(struct hda_codec
*codec
,
789 case CONEXANT_HP_EVENT
:
790 cxt5045_hp_automute(codec
);
792 case CONEXANT_MIC_EVENT
:
793 cxt5045_hp_automic(codec
);
799 static const struct snd_kcontrol_new cxt5045_mixers
[] = {
800 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
801 HDA_CODEC_MUTE("Internal Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
802 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
803 HDA_CODEC_MUTE("Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
804 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
805 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
806 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
807 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
809 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
810 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
812 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
813 .name
= "Master Playback Switch",
814 .info
= cxt_eapd_info
,
816 .put
= cxt5045_hp_master_sw_put
,
817 .private_value
= 0x10,
823 static const struct snd_kcontrol_new cxt5045_benq_mixers
[] = {
824 HDA_CODEC_VOLUME("CD Capture Volume", 0x1a, 0x04, HDA_INPUT
),
825 HDA_CODEC_MUTE("CD Capture Switch", 0x1a, 0x04, HDA_INPUT
),
826 HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x4, HDA_INPUT
),
827 HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x4, HDA_INPUT
),
829 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT
),
830 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT
),
831 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT
),
832 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT
),
834 HDA_CODEC_VOLUME("Mixer Capture Volume", 0x1a, 0x0, HDA_INPUT
),
835 HDA_CODEC_MUTE("Mixer Capture Switch", 0x1a, 0x0, HDA_INPUT
),
840 static const struct snd_kcontrol_new cxt5045_mixers_hp530
[] = {
841 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
842 HDA_CODEC_MUTE("Internal Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
843 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
844 HDA_CODEC_MUTE("Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
845 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
846 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
847 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
848 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
849 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
850 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
851 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
853 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
854 .name
= "Master Playback Switch",
855 .info
= cxt_eapd_info
,
857 .put
= cxt5045_hp_master_sw_put
,
858 .private_value
= 0x10,
864 static const struct hda_verb cxt5045_init_verbs
[] = {
866 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
867 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
869 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
870 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
871 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
872 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
873 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
874 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
875 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
876 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
877 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
878 /* Record selector: Internal mic */
879 {0x1a, AC_VERB_SET_CONNECT_SEL
,0x1},
880 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
881 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
882 /* SPDIF route: PCM */
883 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
884 { 0x13, AC_VERB_SET_CONNECT_SEL
, 0x0 },
886 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2 }, /* default on */
890 static const struct hda_verb cxt5045_benq_init_verbs
[] = {
891 /* Internal Mic, Mic */
892 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
893 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
894 /* Line In,HP, Amp */
895 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
896 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
897 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
898 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
899 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
900 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
901 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
902 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
903 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
904 /* Record selector: Internal mic */
905 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x1},
906 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
907 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
908 /* SPDIF route: PCM */
909 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
910 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0},
912 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
916 static const struct hda_verb cxt5045_hp_sense_init_verbs
[] = {
917 /* pin sensing on HP jack */
918 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
922 static const struct hda_verb cxt5045_mic_sense_init_verbs
[] = {
923 /* pin sensing on HP jack */
924 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
928 #ifdef CONFIG_SND_DEBUG
929 /* Test configuration for debugging, modelled after the ALC260 test
932 static const struct hda_input_mux cxt5045_test_capture_source
= {
937 { "LINE1 pin", 0x2 },
938 { "HP-OUT pin", 0x3 },
943 static const struct snd_kcontrol_new cxt5045_test_mixer
[] = {
945 /* Output controls */
946 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
947 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
948 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
949 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
950 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
951 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
953 /* Modes for retasking pin widgets */
954 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT
),
955 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT
),
957 /* EAPD Switch Control */
958 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
960 /* Loopback mixer controls */
962 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT
),
963 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT
),
964 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT
),
965 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT
),
966 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT
),
967 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT
),
968 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT
),
969 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT
),
970 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT
),
971 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT
),
973 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
974 .name
= "Input Source",
975 .info
= conexant_mux_enum_info
,
976 .get
= conexant_mux_enum_get
,
977 .put
= conexant_mux_enum_put
,
979 /* Audio input controls */
980 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT
),
981 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT
),
982 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT
),
983 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT
),
984 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT
),
985 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT
),
986 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT
),
987 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT
),
988 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT
),
989 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT
),
993 static const struct hda_verb cxt5045_test_init_verbs
[] = {
994 /* Set connections */
995 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
996 { 0x11, AC_VERB_SET_CONNECT_SEL
, 0x0 },
997 { 0x12, AC_VERB_SET_CONNECT_SEL
, 0x0 },
998 /* Enable retasking pins as output, initially without power amp */
999 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1000 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1002 /* Disable digital (SPDIF) pins initially, but users can enable
1003 * them via a mixer switch. In the case of SPDIF-out, this initverb
1004 * payload also sets the generation to 0, output to be in "consumer"
1005 * PCM format, copyright asserted, no pre-emphasis and no validity
1008 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1009 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1011 /* Start with output sum widgets muted and their output gains at min */
1012 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1013 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1015 /* Unmute retasking pin widget output buffers since the default
1016 * state appears to be output. As the pin mode is changed by the
1017 * user the pin mode control will take care of enabling the pin's
1018 * input/output buffers as needed.
1020 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1021 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1023 /* Mute capture amp left and right */
1024 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1026 /* Set ADC connection select to match default mixer setting (mic1
1029 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1030 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x00},
1032 /* Mute all inputs to mixer widget (even unconnected ones) */
1033 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* Mixer pin */
1034 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* Mic1 pin */
1035 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* Line pin */
1036 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* HP pin */
1037 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1044 /* initialize jack-sensing, too */
1045 static int cxt5045_init(struct hda_codec
*codec
)
1047 conexant_init(codec
);
1048 cxt5045_hp_automute(codec
);
1054 CXT5045_LAPTOP_HPSENSE
,
1055 CXT5045_LAPTOP_MICSENSE
,
1056 CXT5045_LAPTOP_HPMICSENSE
,
1058 CXT5045_LAPTOP_HP530
,
1059 #ifdef CONFIG_SND_DEBUG
1066 static const char * const cxt5045_models
[CXT5045_MODELS
] = {
1067 [CXT5045_LAPTOP_HPSENSE
] = "laptop-hpsense",
1068 [CXT5045_LAPTOP_MICSENSE
] = "laptop-micsense",
1069 [CXT5045_LAPTOP_HPMICSENSE
] = "laptop-hpmicsense",
1070 [CXT5045_BENQ
] = "benq",
1071 [CXT5045_LAPTOP_HP530
] = "laptop-hp530",
1072 #ifdef CONFIG_SND_DEBUG
1073 [CXT5045_TEST
] = "test",
1075 [CXT5045_AUTO
] = "auto",
1078 static const struct snd_pci_quirk cxt5045_cfg_tbl
[] = {
1079 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530
),
1080 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1081 CXT5045_LAPTOP_HPSENSE
),
1082 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE
),
1083 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ
),
1084 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE
),
1085 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE
),
1086 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
1087 CXT5045_LAPTOP_HPMICSENSE
),
1088 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1089 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1090 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1091 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
1092 CXT5045_LAPTOP_HPMICSENSE
),
1093 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE
),
1097 static int patch_cxt5045(struct hda_codec
*codec
)
1099 struct conexant_spec
*spec
;
1102 board_config
= snd_hda_check_board_config(codec
, CXT5045_MODELS
,
1105 if (board_config
< 0)
1106 board_config
= CXT5045_AUTO
;
1107 if (board_config
== CXT5045_AUTO
)
1108 return patch_conexant_auto(codec
);
1110 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1114 codec
->pin_amp_workaround
= 1;
1116 spec
->multiout
.max_channels
= 2;
1117 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5045_dac_nids
);
1118 spec
->multiout
.dac_nids
= cxt5045_dac_nids
;
1119 spec
->multiout
.dig_out_nid
= CXT5045_SPDIF_OUT
;
1120 spec
->num_adc_nids
= 1;
1121 spec
->adc_nids
= cxt5045_adc_nids
;
1122 spec
->capsrc_nids
= cxt5045_capsrc_nids
;
1123 spec
->input_mux
= &cxt5045_capture_source
;
1124 spec
->num_mixers
= 1;
1125 spec
->mixers
[0] = cxt5045_mixers
;
1126 spec
->num_init_verbs
= 1;
1127 spec
->init_verbs
[0] = cxt5045_init_verbs
;
1128 spec
->spdif_route
= 0;
1129 spec
->num_channel_mode
= ARRAY_SIZE(cxt5045_modes
);
1130 spec
->channel_mode
= cxt5045_modes
;
1132 set_beep_amp(spec
, 0x16, 0, 1);
1134 codec
->patch_ops
= conexant_patch_ops
;
1136 switch (board_config
) {
1137 case CXT5045_LAPTOP_HPSENSE
:
1138 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1139 spec
->input_mux
= &cxt5045_capture_source
;
1140 spec
->num_init_verbs
= 2;
1141 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1142 spec
->mixers
[0] = cxt5045_mixers
;
1143 codec
->patch_ops
.init
= cxt5045_init
;
1145 case CXT5045_LAPTOP_MICSENSE
:
1146 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1147 spec
->input_mux
= &cxt5045_capture_source
;
1148 spec
->num_init_verbs
= 2;
1149 spec
->init_verbs
[1] = cxt5045_mic_sense_init_verbs
;
1150 spec
->mixers
[0] = cxt5045_mixers
;
1151 codec
->patch_ops
.init
= cxt5045_init
;
1154 case CXT5045_LAPTOP_HPMICSENSE
:
1155 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1156 spec
->input_mux
= &cxt5045_capture_source
;
1157 spec
->num_init_verbs
= 3;
1158 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1159 spec
->init_verbs
[2] = cxt5045_mic_sense_init_verbs
;
1160 spec
->mixers
[0] = cxt5045_mixers
;
1161 codec
->patch_ops
.init
= cxt5045_init
;
1164 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1165 spec
->input_mux
= &cxt5045_capture_source_benq
;
1166 spec
->num_init_verbs
= 1;
1167 spec
->init_verbs
[0] = cxt5045_benq_init_verbs
;
1168 spec
->mixers
[0] = cxt5045_mixers
;
1169 spec
->mixers
[1] = cxt5045_benq_mixers
;
1170 spec
->num_mixers
= 2;
1171 codec
->patch_ops
.init
= cxt5045_init
;
1173 case CXT5045_LAPTOP_HP530
:
1174 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1175 spec
->input_mux
= &cxt5045_capture_source_hp530
;
1176 spec
->num_init_verbs
= 2;
1177 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1178 spec
->mixers
[0] = cxt5045_mixers_hp530
;
1179 codec
->patch_ops
.init
= cxt5045_init
;
1181 #ifdef CONFIG_SND_DEBUG
1183 spec
->input_mux
= &cxt5045_test_capture_source
;
1184 spec
->mixers
[0] = cxt5045_test_mixer
;
1185 spec
->init_verbs
[0] = cxt5045_test_init_verbs
;
1191 switch (codec
->subsystem_id
>> 16) {
1196 /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have
1197 * really bad sound over 0dB on NID 0x17. Fix max PCM level to
1198 * 0 dB (originally it has 0x2b steps with 0dB offset 0x14)
1200 snd_hda_override_amp_caps(codec
, 0x17, HDA_INPUT
,
1201 (0x14 << AC_AMPCAP_OFFSET_SHIFT
) |
1202 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1203 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1204 (1 << AC_AMPCAP_MUTE_SHIFT
));
1209 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
1215 /* Conexant 5047 specific */
1216 #define CXT5047_SPDIF_OUT 0x11
1218 static const hda_nid_t cxt5047_dac_nids
[1] = { 0x10 }; /* 0x1c */
1219 static const hda_nid_t cxt5047_adc_nids
[1] = { 0x12 };
1220 static const hda_nid_t cxt5047_capsrc_nids
[1] = { 0x1a };
1222 static const struct hda_channel_mode cxt5047_modes
[1] = {
1226 static const struct hda_input_mux cxt5047_toshiba_capture_source
= {
1234 /* turn on/off EAPD (+ mute HP) as a master switch */
1235 static int cxt5047_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1236 struct snd_ctl_elem_value
*ucontrol
)
1238 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1239 struct conexant_spec
*spec
= codec
->spec
;
1242 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1245 /* toggle internal speakers mute depending of presence of
1246 * the headphone jack
1248 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
1249 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1250 * pin widgets unlike other codecs. In this case, we need to
1251 * set index 0x01 for the volume from the mixer amp 0x19.
1253 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1254 HDA_AMP_MUTE
, bits
);
1255 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
1256 snd_hda_codec_amp_stereo(codec
, 0x13, HDA_OUTPUT
, 0,
1257 HDA_AMP_MUTE
, bits
);
1261 /* mute internal speaker if HP is plugged */
1262 static void cxt5047_hp_automute(struct hda_codec
*codec
)
1264 struct conexant_spec
*spec
= codec
->spec
;
1267 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x13);
1269 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
1270 /* See the note in cxt5047_hp_master_sw_put */
1271 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1272 HDA_AMP_MUTE
, bits
);
1275 /* toggle input of built-in and mic jack appropriately */
1276 static void cxt5047_hp_automic(struct hda_codec
*codec
)
1278 static const struct hda_verb mic_jack_on
[] = {
1279 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1280 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1283 static const struct hda_verb mic_jack_off
[] = {
1284 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1285 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1288 unsigned int present
;
1290 present
= snd_hda_jack_detect(codec
, 0x15);
1292 snd_hda_sequence_write(codec
, mic_jack_on
);
1294 snd_hda_sequence_write(codec
, mic_jack_off
);
1297 /* unsolicited event for HP jack sensing */
1298 static void cxt5047_hp_unsol_event(struct hda_codec
*codec
,
1301 switch (res
>> 26) {
1302 case CONEXANT_HP_EVENT
:
1303 cxt5047_hp_automute(codec
);
1305 case CONEXANT_MIC_EVENT
:
1306 cxt5047_hp_automic(codec
);
1311 static const struct snd_kcontrol_new cxt5047_base_mixers
[] = {
1312 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT
),
1313 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT
),
1314 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1315 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT
),
1316 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT
),
1317 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT
),
1318 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT
),
1320 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1321 .name
= "Master Playback Switch",
1322 .info
= cxt_eapd_info
,
1323 .get
= cxt_eapd_get
,
1324 .put
= cxt5047_hp_master_sw_put
,
1325 .private_value
= 0x13,
1331 static const struct snd_kcontrol_new cxt5047_hp_spk_mixers
[] = {
1332 /* See the note in cxt5047_hp_master_sw_put */
1333 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT
),
1334 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1338 static const struct snd_kcontrol_new cxt5047_hp_only_mixers
[] = {
1339 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1343 static const struct hda_verb cxt5047_init_verbs
[] = {
1344 /* Line in, Mic, Built-in Mic */
1345 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1346 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1347 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1349 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1350 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* mixer(0x19) */
1351 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mixer(0x19) */
1352 /* Record selector: Mic */
1353 {0x12, AC_VERB_SET_CONNECT_SEL
,0x03},
1354 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
,
1355 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
1356 {0x1A, AC_VERB_SET_CONNECT_SEL
,0x02},
1357 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1358 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x00},
1359 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1360 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x03},
1361 /* SPDIF route: PCM */
1362 { 0x18, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1363 /* Enable unsolicited events */
1364 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
1365 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1369 /* configuration for Toshiba Laptops */
1370 static const struct hda_verb cxt5047_toshiba_init_verbs
[] = {
1371 {0x13, AC_VERB_SET_EAPD_BTLENABLE
, 0x0}, /* default off */
1375 /* Test configuration for debugging, modelled after the ALC260 test
1378 #ifdef CONFIG_SND_DEBUG
1379 static const struct hda_input_mux cxt5047_test_capture_source
= {
1382 { "LINE1 pin", 0x0 },
1383 { "MIC1 pin", 0x1 },
1384 { "MIC2 pin", 0x2 },
1389 static const struct snd_kcontrol_new cxt5047_test_mixer
[] = {
1391 /* Output only controls */
1392 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT
),
1393 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT
),
1394 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT
),
1395 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT
),
1396 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1397 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1398 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1399 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1400 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT
),
1401 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT
),
1402 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
1403 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
1405 /* Modes for retasking pin widgets */
1406 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT
),
1407 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT
),
1409 /* EAPD Switch Control */
1410 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1412 /* Loopback mixer controls */
1413 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT
),
1414 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT
),
1415 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT
),
1416 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT
),
1417 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT
),
1418 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT
),
1419 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT
),
1420 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT
),
1422 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT
),
1423 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT
),
1424 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT
),
1425 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT
),
1426 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT
),
1427 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT
),
1428 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT
),
1429 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT
),
1431 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1432 .name
= "Input Source",
1433 .info
= conexant_mux_enum_info
,
1434 .get
= conexant_mux_enum_get
,
1435 .put
= conexant_mux_enum_put
,
1437 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1442 static const struct hda_verb cxt5047_test_init_verbs
[] = {
1443 /* Enable retasking pins as output, initially without power amp */
1444 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1445 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1446 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1448 /* Disable digital (SPDIF) pins initially, but users can enable
1449 * them via a mixer switch. In the case of SPDIF-out, this initverb
1450 * payload also sets the generation to 0, output to be in "consumer"
1451 * PCM format, copyright asserted, no pre-emphasis and no validity
1454 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1456 /* Ensure mic1, mic2, line1 pin widgets take input from the
1457 * OUT1 sum bus when acting as an output.
1459 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0},
1460 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0},
1462 /* Start with output sum widgets muted and their output gains at min */
1463 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1464 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1466 /* Unmute retasking pin widget output buffers since the default
1467 * state appears to be output. As the pin mode is changed by the
1468 * user the pin mode control will take care of enabling the pin's
1469 * input/output buffers as needed.
1471 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1472 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1473 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1475 /* Mute capture amp left and right */
1476 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1478 /* Set ADC connection select to match default mixer setting (mic1
1481 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x00},
1483 /* Mute all inputs to mixer widget (even unconnected ones) */
1484 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* mic1 pin */
1485 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* mic2 pin */
1486 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* line1 pin */
1487 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* line2 pin */
1488 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1489 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1490 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)}, /* Line-out pin */
1491 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)}, /* HP-pin pin */
1498 /* initialize jack-sensing, too */
1499 static int cxt5047_hp_init(struct hda_codec
*codec
)
1501 conexant_init(codec
);
1502 cxt5047_hp_automute(codec
);
1508 CXT5047_LAPTOP
, /* Laptops w/o EAPD support */
1509 CXT5047_LAPTOP_HP
, /* Some HP laptops */
1510 CXT5047_LAPTOP_EAPD
, /* Laptops with EAPD support */
1511 #ifdef CONFIG_SND_DEBUG
1517 static const char * const cxt5047_models
[CXT5047_MODELS
] = {
1518 [CXT5047_LAPTOP
] = "laptop",
1519 [CXT5047_LAPTOP_HP
] = "laptop-hp",
1520 [CXT5047_LAPTOP_EAPD
] = "laptop-eapd",
1521 #ifdef CONFIG_SND_DEBUG
1522 [CXT5047_TEST
] = "test",
1526 static const struct snd_pci_quirk cxt5047_cfg_tbl
[] = {
1527 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP
),
1528 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1530 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD
),
1534 static int patch_cxt5047(struct hda_codec
*codec
)
1536 struct conexant_spec
*spec
;
1539 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1543 codec
->pin_amp_workaround
= 1;
1545 spec
->multiout
.max_channels
= 2;
1546 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5047_dac_nids
);
1547 spec
->multiout
.dac_nids
= cxt5047_dac_nids
;
1548 spec
->multiout
.dig_out_nid
= CXT5047_SPDIF_OUT
;
1549 spec
->num_adc_nids
= 1;
1550 spec
->adc_nids
= cxt5047_adc_nids
;
1551 spec
->capsrc_nids
= cxt5047_capsrc_nids
;
1552 spec
->num_mixers
= 1;
1553 spec
->mixers
[0] = cxt5047_base_mixers
;
1554 spec
->num_init_verbs
= 1;
1555 spec
->init_verbs
[0] = cxt5047_init_verbs
;
1556 spec
->spdif_route
= 0;
1557 spec
->num_channel_mode
= ARRAY_SIZE(cxt5047_modes
),
1558 spec
->channel_mode
= cxt5047_modes
,
1560 codec
->patch_ops
= conexant_patch_ops
;
1562 board_config
= snd_hda_check_board_config(codec
, CXT5047_MODELS
,
1565 switch (board_config
) {
1566 case CXT5047_LAPTOP
:
1567 spec
->num_mixers
= 2;
1568 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1569 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1571 case CXT5047_LAPTOP_HP
:
1572 spec
->num_mixers
= 2;
1573 spec
->mixers
[1] = cxt5047_hp_only_mixers
;
1574 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1575 codec
->patch_ops
.init
= cxt5047_hp_init
;
1577 case CXT5047_LAPTOP_EAPD
:
1578 spec
->input_mux
= &cxt5047_toshiba_capture_source
;
1579 spec
->num_mixers
= 2;
1580 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1581 spec
->num_init_verbs
= 2;
1582 spec
->init_verbs
[1] = cxt5047_toshiba_init_verbs
;
1583 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1585 #ifdef CONFIG_SND_DEBUG
1587 spec
->input_mux
= &cxt5047_test_capture_source
;
1588 spec
->mixers
[0] = cxt5047_test_mixer
;
1589 spec
->init_verbs
[0] = cxt5047_test_init_verbs
;
1590 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1593 spec
->vmaster_nid
= 0x13;
1595 switch (codec
->subsystem_id
>> 16) {
1597 /* HP laptops have really bad sound over 0 dB on NID 0x10.
1598 * Fix max PCM level to 0 dB (originally it has 0x1e steps
1599 * with 0 dB offset 0x17)
1601 snd_hda_override_amp_caps(codec
, 0x10, HDA_INPUT
,
1602 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
1603 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1604 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1605 (1 << AC_AMPCAP_MUTE_SHIFT
));
1612 /* Conexant 5051 specific */
1613 static const hda_nid_t cxt5051_dac_nids
[1] = { 0x10 };
1614 static const hda_nid_t cxt5051_adc_nids
[2] = { 0x14, 0x15 };
1616 static const struct hda_channel_mode cxt5051_modes
[1] = {
1620 static void cxt5051_update_speaker(struct hda_codec
*codec
)
1622 struct conexant_spec
*spec
= codec
->spec
;
1623 unsigned int pinctl
;
1625 pinctl
= (spec
->hp_present
&& spec
->cur_eapd
) ? PIN_HP
: 0;
1626 snd_hda_codec_write(codec
, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1629 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1630 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1632 /* on ideapad there is an aditional speaker (subwoofer) to mute */
1634 snd_hda_codec_write(codec
, 0x1b, 0,
1635 AC_VERB_SET_PIN_WIDGET_CONTROL
,
1639 /* turn on/off EAPD (+ mute HP) as a master switch */
1640 static int cxt5051_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1641 struct snd_ctl_elem_value
*ucontrol
)
1643 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1645 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1647 cxt5051_update_speaker(codec
);
1651 /* toggle input of built-in and mic jack appropriately */
1652 static void cxt5051_portb_automic(struct hda_codec
*codec
)
1654 struct conexant_spec
*spec
= codec
->spec
;
1655 unsigned int present
;
1657 if (!(spec
->auto_mic
& AUTO_MIC_PORTB
))
1659 present
= snd_hda_jack_detect(codec
, 0x17);
1660 snd_hda_codec_write(codec
, 0x14, 0,
1661 AC_VERB_SET_CONNECT_SEL
,
1662 present
? 0x01 : 0x00);
1665 /* switch the current ADC according to the jack state */
1666 static void cxt5051_portc_automic(struct hda_codec
*codec
)
1668 struct conexant_spec
*spec
= codec
->spec
;
1669 unsigned int present
;
1672 if (!(spec
->auto_mic
& AUTO_MIC_PORTC
))
1674 present
= snd_hda_jack_detect(codec
, 0x18);
1676 spec
->cur_adc_idx
= 1;
1678 spec
->cur_adc_idx
= 0;
1679 new_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
1680 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
1681 /* stream is running, let's swap the current ADC */
1682 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
1683 spec
->cur_adc
= new_adc
;
1684 snd_hda_codec_setup_stream(codec
, new_adc
,
1685 spec
->cur_adc_stream_tag
, 0,
1686 spec
->cur_adc_format
);
1690 /* mute internal speaker if HP is plugged */
1691 static void cxt5051_hp_automute(struct hda_codec
*codec
)
1693 struct conexant_spec
*spec
= codec
->spec
;
1695 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x16);
1696 cxt5051_update_speaker(codec
);
1699 /* unsolicited event for HP jack sensing */
1700 static void cxt5051_hp_unsol_event(struct hda_codec
*codec
,
1703 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
1704 switch (res
>> 26) {
1705 case CONEXANT_HP_EVENT
:
1706 cxt5051_hp_automute(codec
);
1708 case CXT5051_PORTB_EVENT
:
1709 cxt5051_portb_automic(codec
);
1711 case CXT5051_PORTC_EVENT
:
1712 cxt5051_portc_automic(codec
);
1715 snd_hda_input_jack_report(codec
, nid
);
1718 static const struct snd_kcontrol_new cxt5051_playback_mixers
[] = {
1719 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1721 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1722 .name
= "Master Playback Switch",
1723 .info
= cxt_eapd_info
,
1724 .get
= cxt_eapd_get
,
1725 .put
= cxt5051_hp_master_sw_put
,
1726 .private_value
= 0x1a,
1731 static const struct snd_kcontrol_new cxt5051_capture_mixers
[] = {
1732 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1733 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1734 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT
),
1735 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT
),
1736 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT
),
1737 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT
),
1741 static const struct snd_kcontrol_new cxt5051_hp_mixers
[] = {
1742 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1743 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1744 HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT
),
1745 HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT
),
1749 static const struct snd_kcontrol_new cxt5051_hp_dv6736_mixers
[] = {
1750 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT
),
1751 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT
),
1755 static const struct snd_kcontrol_new cxt5051_f700_mixers
[] = {
1756 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT
),
1757 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT
),
1761 static const struct snd_kcontrol_new cxt5051_toshiba_mixers
[] = {
1762 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1763 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1764 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT
),
1765 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT
),
1769 static const struct hda_verb cxt5051_init_verbs
[] = {
1771 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1772 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1773 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1774 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1775 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1776 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1778 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1779 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1781 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1782 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1784 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1785 /* Record selector: Internal mic */
1786 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1787 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1788 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1789 /* SPDIF route: PCM */
1790 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1791 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1793 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1794 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1798 static const struct hda_verb cxt5051_hp_dv6736_init_verbs
[] = {
1800 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1801 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1802 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1803 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1805 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1806 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1808 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1809 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1811 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1812 /* Record selector: Internal mic */
1813 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1814 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1815 /* SPDIF route: PCM */
1816 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1818 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1819 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1823 static const struct hda_verb cxt5051_lenovo_x200_init_verbs
[] = {
1825 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1826 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1827 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1828 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1829 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1830 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1832 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1833 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1835 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1836 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1838 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1839 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00},
1841 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1842 /* Record selector: Internal mic */
1843 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1844 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1845 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1846 /* SPDIF route: PCM */
1847 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
}, /* needed for W500 Advanced Mini Dock 250410 */
1848 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1850 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1851 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1852 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1856 static const struct hda_verb cxt5051_f700_init_verbs
[] = {
1858 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1859 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1860 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1861 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1863 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1864 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1866 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1867 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1869 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1870 /* Record selector: Internal mic */
1871 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1872 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1873 /* SPDIF route: PCM */
1874 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1876 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1877 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1881 static void cxt5051_init_mic_port(struct hda_codec
*codec
, hda_nid_t nid
,
1884 snd_hda_codec_write(codec
, nid
, 0,
1885 AC_VERB_SET_UNSOLICITED_ENABLE
,
1886 AC_USRSP_EN
| event
);
1887 snd_hda_input_jack_add(codec
, nid
, SND_JACK_MICROPHONE
, NULL
);
1888 snd_hda_input_jack_report(codec
, nid
);
1891 static const struct hda_verb cxt5051_ideapad_init_verbs
[] = {
1893 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1894 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0x00},
1898 /* initialize jack-sensing, too */
1899 static int cxt5051_init(struct hda_codec
*codec
)
1901 struct conexant_spec
*spec
= codec
->spec
;
1903 conexant_init(codec
);
1904 conexant_init_jacks(codec
);
1906 if (spec
->auto_mic
& AUTO_MIC_PORTB
)
1907 cxt5051_init_mic_port(codec
, 0x17, CXT5051_PORTB_EVENT
);
1908 if (spec
->auto_mic
& AUTO_MIC_PORTC
)
1909 cxt5051_init_mic_port(codec
, 0x18, CXT5051_PORTC_EVENT
);
1911 if (codec
->patch_ops
.unsol_event
) {
1912 cxt5051_hp_automute(codec
);
1913 cxt5051_portb_automic(codec
);
1914 cxt5051_portc_automic(codec
);
1921 CXT5051_LAPTOP
, /* Laptops w/ EAPD support */
1922 CXT5051_HP
, /* no docking */
1923 CXT5051_HP_DV6736
, /* HP without mic switch */
1924 CXT5051_LENOVO_X200
, /* Lenovo X200 laptop, also used for Advanced Mini Dock 250410 */
1925 CXT5051_F700
, /* HP Compaq Presario F700 */
1926 CXT5051_TOSHIBA
, /* Toshiba M300 & co */
1927 CXT5051_IDEAPAD
, /* Lenovo IdeaPad Y430 */
1928 CXT5051_AUTO
, /* auto-parser */
1932 static const char *const cxt5051_models
[CXT5051_MODELS
] = {
1933 [CXT5051_LAPTOP
] = "laptop",
1934 [CXT5051_HP
] = "hp",
1935 [CXT5051_HP_DV6736
] = "hp-dv6736",
1936 [CXT5051_LENOVO_X200
] = "lenovo-x200",
1937 [CXT5051_F700
] = "hp-700",
1938 [CXT5051_TOSHIBA
] = "toshiba",
1939 [CXT5051_IDEAPAD
] = "ideapad",
1940 [CXT5051_AUTO
] = "auto",
1943 static const struct snd_pci_quirk cxt5051_cfg_tbl
[] = {
1944 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736
),
1945 SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP
),
1946 SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700
),
1947 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA
),
1948 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1950 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP
),
1951 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200
),
1952 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD
),
1956 static int patch_cxt5051(struct hda_codec
*codec
)
1958 struct conexant_spec
*spec
;
1961 board_config
= snd_hda_check_board_config(codec
, CXT5051_MODELS
,
1964 if (board_config
< 0)
1965 board_config
= CXT5051_AUTO
;
1966 if (board_config
== CXT5051_AUTO
)
1967 return patch_conexant_auto(codec
);
1969 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1973 codec
->pin_amp_workaround
= 1;
1975 codec
->patch_ops
= conexant_patch_ops
;
1976 codec
->patch_ops
.init
= cxt5051_init
;
1978 spec
->multiout
.max_channels
= 2;
1979 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5051_dac_nids
);
1980 spec
->multiout
.dac_nids
= cxt5051_dac_nids
;
1981 spec
->multiout
.dig_out_nid
= CXT5051_SPDIF_OUT
;
1982 spec
->num_adc_nids
= 1; /* not 2; via auto-mic switch */
1983 spec
->adc_nids
= cxt5051_adc_nids
;
1984 spec
->num_mixers
= 2;
1985 spec
->mixers
[0] = cxt5051_capture_mixers
;
1986 spec
->mixers
[1] = cxt5051_playback_mixers
;
1987 spec
->num_init_verbs
= 1;
1988 spec
->init_verbs
[0] = cxt5051_init_verbs
;
1989 spec
->spdif_route
= 0;
1990 spec
->num_channel_mode
= ARRAY_SIZE(cxt5051_modes
);
1991 spec
->channel_mode
= cxt5051_modes
;
1993 spec
->cur_adc_idx
= 0;
1995 set_beep_amp(spec
, 0x13, 0, HDA_OUTPUT
);
1997 codec
->patch_ops
.unsol_event
= cxt5051_hp_unsol_event
;
1999 spec
->auto_mic
= AUTO_MIC_PORTB
| AUTO_MIC_PORTC
;
2000 switch (board_config
) {
2002 spec
->mixers
[0] = cxt5051_hp_mixers
;
2004 case CXT5051_HP_DV6736
:
2005 spec
->init_verbs
[0] = cxt5051_hp_dv6736_init_verbs
;
2006 spec
->mixers
[0] = cxt5051_hp_dv6736_mixers
;
2009 case CXT5051_LENOVO_X200
:
2010 spec
->init_verbs
[0] = cxt5051_lenovo_x200_init_verbs
;
2011 /* Thinkpad X301 does not have S/PDIF wired and no ability
2012 to use a docking station. */
2013 if (codec
->subsystem_id
== 0x17aa211f)
2014 spec
->multiout
.dig_out_nid
= 0;
2017 spec
->init_verbs
[0] = cxt5051_f700_init_verbs
;
2018 spec
->mixers
[0] = cxt5051_f700_mixers
;
2021 case CXT5051_TOSHIBA
:
2022 spec
->mixers
[0] = cxt5051_toshiba_mixers
;
2023 spec
->auto_mic
= AUTO_MIC_PORTB
;
2025 case CXT5051_IDEAPAD
:
2026 spec
->init_verbs
[spec
->num_init_verbs
++] =
2027 cxt5051_ideapad_init_verbs
;
2033 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
2038 /* Conexant 5066 specific */
2040 static const hda_nid_t cxt5066_dac_nids
[1] = { 0x10 };
2041 static const hda_nid_t cxt5066_adc_nids
[3] = { 0x14, 0x15, 0x16 };
2042 static const hda_nid_t cxt5066_capsrc_nids
[1] = { 0x17 };
2043 static const hda_nid_t cxt5066_digout_pin_nids
[2] = { 0x20, 0x22 };
2045 /* OLPC's microphone port is DC coupled for use with external sensors,
2046 * therefore we use a 50% mic bias in order to center the input signal with
2047 * the DC input range of the codec. */
2048 #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50
2050 static const struct hda_channel_mode cxt5066_modes
[1] = {
2054 #define HP_PRESENT_PORT_A (1 << 0)
2055 #define HP_PRESENT_PORT_D (1 << 1)
2056 #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A)
2057 #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D)
2059 static void cxt5066_update_speaker(struct hda_codec
*codec
)
2061 struct conexant_spec
*spec
= codec
->spec
;
2062 unsigned int pinctl
;
2064 snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n",
2065 spec
->hp_present
, spec
->cur_eapd
);
2068 pinctl
= (hp_port_a_present(spec
) && spec
->cur_eapd
) ? PIN_HP
: 0;
2069 snd_hda_codec_write(codec
, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2072 /* Port D (HP/LO) */
2073 pinctl
= spec
->cur_eapd
? spec
->port_d_mode
: 0;
2074 if (spec
->dell_automute
|| spec
->thinkpad
) {
2075 /* Mute if Port A is connected */
2076 if (hp_port_a_present(spec
))
2079 /* Thinkpad/Dell doesn't give pin-D status */
2080 if (!hp_port_d_present(spec
))
2083 snd_hda_codec_write(codec
, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2087 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
2088 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2092 /* turn on/off EAPD (+ mute HP) as a master switch */
2093 static int cxt5066_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
2094 struct snd_ctl_elem_value
*ucontrol
)
2096 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2098 if (!cxt_eapd_put(kcontrol
, ucontrol
))
2101 cxt5066_update_speaker(codec
);
2105 static const struct hda_input_mux cxt5066_olpc_dc_bias
= {
2109 { "50%", PIN_VREF50
},
2110 { "80%", PIN_VREF80
},
2114 static int cxt5066_set_olpc_dc_bias(struct hda_codec
*codec
)
2116 struct conexant_spec
*spec
= codec
->spec
;
2117 /* Even though port F is the DC input, the bias is controlled on port B.
2118 * we also leave that port as an active input (but unselected) in DC mode
2119 * just in case that is necessary to make the bias setting take effect. */
2120 return snd_hda_codec_write_cache(codec
, 0x1a, 0,
2121 AC_VERB_SET_PIN_WIDGET_CONTROL
,
2122 cxt5066_olpc_dc_bias
.items
[spec
->dc_input_bias
].index
);
2125 /* OLPC defers mic widget control until when capture is started because the
2126 * microphone LED comes on as soon as these settings are put in place. if we
2127 * did this before recording, it would give the false indication that recording
2128 * is happening when it is not. */
2129 static void cxt5066_olpc_select_mic(struct hda_codec
*codec
)
2131 struct conexant_spec
*spec
= codec
->spec
;
2132 if (!spec
->recording
)
2135 if (spec
->dc_enable
) {
2136 /* in DC mode we ignore presence detection and just use the jack
2137 * through our special DC port */
2138 const struct hda_verb enable_dc_mode
[] = {
2139 /* disble internal mic, port C */
2140 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2142 /* enable DC capture, port F */
2143 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2147 snd_hda_sequence_write(codec
, enable_dc_mode
);
2148 /* port B input disabled (and bias set) through the following call */
2149 cxt5066_set_olpc_dc_bias(codec
);
2153 /* disable DC (port F) */
2154 snd_hda_codec_write(codec
, 0x1e, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0);
2156 /* external mic, port B */
2157 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2158 spec
->ext_mic_present
? CXT5066_OLPC_EXT_MIC_BIAS
: 0);
2160 /* internal mic, port C */
2161 snd_hda_codec_write(codec
, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2162 spec
->ext_mic_present
? 0 : PIN_VREF80
);
2165 /* toggle input of built-in and mic jack appropriately */
2166 static void cxt5066_olpc_automic(struct hda_codec
*codec
)
2168 struct conexant_spec
*spec
= codec
->spec
;
2169 unsigned int present
;
2171 if (spec
->dc_enable
) /* don't do presence detection in DC mode */
2174 present
= snd_hda_codec_read(codec
, 0x1a, 0,
2175 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
2177 snd_printdd("CXT5066: external microphone detected\n");
2179 snd_printdd("CXT5066: external microphone absent\n");
2181 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2183 spec
->ext_mic_present
= !!present
;
2185 cxt5066_olpc_select_mic(codec
);
2188 /* toggle input of built-in digital mic and mic jack appropriately */
2189 static void cxt5066_vostro_automic(struct hda_codec
*codec
)
2191 unsigned int present
;
2193 struct hda_verb ext_mic_present
[] = {
2194 /* enable external mic, port B */
2195 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2197 /* switch to external mic input */
2198 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2199 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2201 /* disable internal digital mic */
2202 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2205 static const struct hda_verb ext_mic_absent
[] = {
2206 /* enable internal mic, port C */
2207 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2209 /* switch to internal mic input */
2210 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2212 /* disable external mic, port B */
2213 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2217 present
= snd_hda_jack_detect(codec
, 0x1a);
2219 snd_printdd("CXT5066: external microphone detected\n");
2220 snd_hda_sequence_write(codec
, ext_mic_present
);
2222 snd_printdd("CXT5066: external microphone absent\n");
2223 snd_hda_sequence_write(codec
, ext_mic_absent
);
2227 /* toggle input of built-in digital mic and mic jack appropriately */
2228 static void cxt5066_ideapad_automic(struct hda_codec
*codec
)
2230 unsigned int present
;
2232 struct hda_verb ext_mic_present
[] = {
2233 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2234 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2235 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2238 static const struct hda_verb ext_mic_absent
[] = {
2239 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2240 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2241 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2245 present
= snd_hda_jack_detect(codec
, 0x1b);
2247 snd_printdd("CXT5066: external microphone detected\n");
2248 snd_hda_sequence_write(codec
, ext_mic_present
);
2250 snd_printdd("CXT5066: external microphone absent\n");
2251 snd_hda_sequence_write(codec
, ext_mic_absent
);
2256 /* toggle input of built-in digital mic and mic jack appropriately */
2257 static void cxt5066_asus_automic(struct hda_codec
*codec
)
2259 unsigned int present
;
2261 present
= snd_hda_jack_detect(codec
, 0x1b);
2262 snd_printdd("CXT5066: external microphone present=%d\n", present
);
2263 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2268 /* toggle input of built-in digital mic and mic jack appropriately */
2269 static void cxt5066_hp_laptop_automic(struct hda_codec
*codec
)
2271 unsigned int present
;
2273 present
= snd_hda_jack_detect(codec
, 0x1b);
2274 snd_printdd("CXT5066: external microphone present=%d\n", present
);
2275 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2280 /* toggle input of built-in digital mic and mic jack appropriately
2281 order is: external mic -> dock mic -> interal mic */
2282 static void cxt5066_thinkpad_automic(struct hda_codec
*codec
)
2284 unsigned int ext_present
, dock_present
;
2286 static const struct hda_verb ext_mic_present
[] = {
2287 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2288 {0x17, AC_VERB_SET_CONNECT_SEL
, 1},
2289 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2290 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2291 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2294 static const struct hda_verb dock_mic_present
[] = {
2295 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2296 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2297 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2298 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2299 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2302 static const struct hda_verb ext_mic_absent
[] = {
2303 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2304 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2305 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2306 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2310 ext_present
= snd_hda_jack_detect(codec
, 0x1b);
2311 dock_present
= snd_hda_jack_detect(codec
, 0x1a);
2313 snd_printdd("CXT5066: external microphone detected\n");
2314 snd_hda_sequence_write(codec
, ext_mic_present
);
2315 } else if (dock_present
) {
2316 snd_printdd("CXT5066: dock microphone detected\n");
2317 snd_hda_sequence_write(codec
, dock_mic_present
);
2319 snd_printdd("CXT5066: external microphone absent\n");
2320 snd_hda_sequence_write(codec
, ext_mic_absent
);
2324 /* mute internal speaker if HP is plugged */
2325 static void cxt5066_hp_automute(struct hda_codec
*codec
)
2327 struct conexant_spec
*spec
= codec
->spec
;
2328 unsigned int portA
, portD
;
2331 portA
= snd_hda_jack_detect(codec
, 0x19);
2334 portD
= snd_hda_jack_detect(codec
, 0x1c);
2336 spec
->hp_present
= portA
? HP_PRESENT_PORT_A
: 0;
2337 spec
->hp_present
|= portD
? HP_PRESENT_PORT_D
: 0;
2338 snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
2339 portA
, portD
, spec
->hp_present
);
2340 cxt5066_update_speaker(codec
);
2343 /* Dispatch the right mic autoswitch function */
2344 static void cxt5066_automic(struct hda_codec
*codec
)
2346 struct conexant_spec
*spec
= codec
->spec
;
2348 if (spec
->dell_vostro
)
2349 cxt5066_vostro_automic(codec
);
2350 else if (spec
->ideapad
)
2351 cxt5066_ideapad_automic(codec
);
2352 else if (spec
->thinkpad
)
2353 cxt5066_thinkpad_automic(codec
);
2354 else if (spec
->hp_laptop
)
2355 cxt5066_hp_laptop_automic(codec
);
2356 else if (spec
->asus
)
2357 cxt5066_asus_automic(codec
);
2360 /* unsolicited event for jack sensing */
2361 static void cxt5066_olpc_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2363 struct conexant_spec
*spec
= codec
->spec
;
2364 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2365 switch (res
>> 26) {
2366 case CONEXANT_HP_EVENT
:
2367 cxt5066_hp_automute(codec
);
2369 case CONEXANT_MIC_EVENT
:
2370 /* ignore mic events in DC mode; we're always using the jack */
2371 if (!spec
->dc_enable
)
2372 cxt5066_olpc_automic(codec
);
2377 /* unsolicited event for jack sensing */
2378 static void cxt5066_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2380 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2381 switch (res
>> 26) {
2382 case CONEXANT_HP_EVENT
:
2383 cxt5066_hp_automute(codec
);
2385 case CONEXANT_MIC_EVENT
:
2386 cxt5066_automic(codec
);
2392 static const struct hda_input_mux cxt5066_analog_mic_boost
= {
2403 static void cxt5066_set_mic_boost(struct hda_codec
*codec
)
2405 struct conexant_spec
*spec
= codec
->spec
;
2406 snd_hda_codec_write_cache(codec
, 0x17, 0,
2407 AC_VERB_SET_AMP_GAIN_MUTE
,
2408 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_OUTPUT
|
2409 cxt5066_analog_mic_boost
.items
[spec
->mic_boost
].index
);
2410 if (spec
->ideapad
|| spec
->thinkpad
) {
2411 /* adjust the internal mic as well...it is not through 0x17 */
2412 snd_hda_codec_write_cache(codec
, 0x23, 0,
2413 AC_VERB_SET_AMP_GAIN_MUTE
,
2414 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_INPUT
|
2415 cxt5066_analog_mic_boost
.
2416 items
[spec
->mic_boost
].index
);
2420 static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol
*kcontrol
,
2421 struct snd_ctl_elem_info
*uinfo
)
2423 return snd_hda_input_mux_info(&cxt5066_analog_mic_boost
, uinfo
);
2426 static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol
*kcontrol
,
2427 struct snd_ctl_elem_value
*ucontrol
)
2429 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2430 struct conexant_spec
*spec
= codec
->spec
;
2431 ucontrol
->value
.enumerated
.item
[0] = spec
->mic_boost
;
2435 static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol
*kcontrol
,
2436 struct snd_ctl_elem_value
*ucontrol
)
2438 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2439 struct conexant_spec
*spec
= codec
->spec
;
2440 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2442 idx
= ucontrol
->value
.enumerated
.item
[0];
2443 if (idx
>= imux
->num_items
)
2444 idx
= imux
->num_items
- 1;
2446 spec
->mic_boost
= idx
;
2447 if (!spec
->dc_enable
)
2448 cxt5066_set_mic_boost(codec
);
2452 static void cxt5066_enable_dc(struct hda_codec
*codec
)
2454 const struct hda_verb enable_dc_mode
[] = {
2456 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2458 /* switch to DC input */
2459 {0x17, AC_VERB_SET_CONNECT_SEL
, 3},
2463 /* configure as input source */
2464 snd_hda_sequence_write(codec
, enable_dc_mode
);
2465 cxt5066_olpc_select_mic(codec
); /* also sets configured bias */
2468 static void cxt5066_disable_dc(struct hda_codec
*codec
)
2470 /* reconfigure input source */
2471 cxt5066_set_mic_boost(codec
);
2472 /* automic also selects the right mic if we're recording */
2473 cxt5066_olpc_automic(codec
);
2476 static int cxt5066_olpc_dc_get(struct snd_kcontrol
*kcontrol
,
2477 struct snd_ctl_elem_value
*ucontrol
)
2479 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2480 struct conexant_spec
*spec
= codec
->spec
;
2481 ucontrol
->value
.integer
.value
[0] = spec
->dc_enable
;
2485 static int cxt5066_olpc_dc_put(struct snd_kcontrol
*kcontrol
,
2486 struct snd_ctl_elem_value
*ucontrol
)
2488 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2489 struct conexant_spec
*spec
= codec
->spec
;
2490 int dc_enable
= !!ucontrol
->value
.integer
.value
[0];
2492 if (dc_enable
== spec
->dc_enable
)
2495 spec
->dc_enable
= dc_enable
;
2497 cxt5066_enable_dc(codec
);
2499 cxt5066_disable_dc(codec
);
2504 static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol
*kcontrol
,
2505 struct snd_ctl_elem_info
*uinfo
)
2507 return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias
, uinfo
);
2510 static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol
*kcontrol
,
2511 struct snd_ctl_elem_value
*ucontrol
)
2513 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2514 struct conexant_spec
*spec
= codec
->spec
;
2515 ucontrol
->value
.enumerated
.item
[0] = spec
->dc_input_bias
;
2519 static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol
*kcontrol
,
2520 struct snd_ctl_elem_value
*ucontrol
)
2522 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2523 struct conexant_spec
*spec
= codec
->spec
;
2524 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2527 idx
= ucontrol
->value
.enumerated
.item
[0];
2528 if (idx
>= imux
->num_items
)
2529 idx
= imux
->num_items
- 1;
2531 spec
->dc_input_bias
= idx
;
2532 if (spec
->dc_enable
)
2533 cxt5066_set_olpc_dc_bias(codec
);
2537 static void cxt5066_olpc_capture_prepare(struct hda_codec
*codec
)
2539 struct conexant_spec
*spec
= codec
->spec
;
2540 /* mark as recording and configure the microphone widget so that the
2541 * recording LED comes on. */
2542 spec
->recording
= 1;
2543 cxt5066_olpc_select_mic(codec
);
2546 static void cxt5066_olpc_capture_cleanup(struct hda_codec
*codec
)
2548 struct conexant_spec
*spec
= codec
->spec
;
2549 const struct hda_verb disable_mics
[] = {
2550 /* disable external mic, port B */
2551 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2553 /* disble internal mic, port C */
2554 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2556 /* disable DC capture, port F */
2557 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2561 snd_hda_sequence_write(codec
, disable_mics
);
2562 spec
->recording
= 0;
2565 static void conexant_check_dig_outs(struct hda_codec
*codec
,
2566 const hda_nid_t
*dig_pins
,
2569 struct conexant_spec
*spec
= codec
->spec
;
2570 hda_nid_t
*nid_loc
= &spec
->multiout
.dig_out_nid
;
2573 for (i
= 0; i
< num_pins
; i
++, dig_pins
++) {
2574 unsigned int cfg
= snd_hda_codec_get_pincfg(codec
, *dig_pins
);
2575 if (get_defcfg_connect(cfg
) == AC_JACK_PORT_NONE
)
2577 if (snd_hda_get_connections(codec
, *dig_pins
, nid_loc
, 1) != 1)
2579 if (spec
->slave_dig_outs
[0])
2582 nid_loc
= spec
->slave_dig_outs
;
2586 static const struct hda_input_mux cxt5066_capture_source
= {
2596 static const struct hda_bind_ctls cxt5066_bind_capture_vol_others
= {
2597 .ops
= &snd_hda_bind_vol
,
2599 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2600 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2605 static const struct hda_bind_ctls cxt5066_bind_capture_sw_others
= {
2606 .ops
= &snd_hda_bind_sw
,
2608 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2609 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2614 static const struct snd_kcontrol_new cxt5066_mixer_master
[] = {
2615 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
2619 static const struct snd_kcontrol_new cxt5066_mixer_master_olpc
[] = {
2621 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2622 .name
= "Master Playback Volume",
2623 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
|
2624 SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
2625 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
,
2626 .subdevice
= HDA_SUBDEV_AMP_FLAG
,
2627 .info
= snd_hda_mixer_amp_volume_info
,
2628 .get
= snd_hda_mixer_amp_volume_get
,
2629 .put
= snd_hda_mixer_amp_volume_put
,
2630 .tlv
= { .c
= snd_hda_mixer_amp_tlv
},
2631 /* offset by 28 volume steps to limit minimum gain to -46dB */
2633 HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT
, 28),
2638 static const struct snd_kcontrol_new cxt5066_mixer_olpc_dc
[] = {
2640 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2641 .name
= "DC Mode Enable Switch",
2642 .info
= snd_ctl_boolean_mono_info
,
2643 .get
= cxt5066_olpc_dc_get
,
2644 .put
= cxt5066_olpc_dc_put
,
2647 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2648 .name
= "DC Input Bias Enum",
2649 .info
= cxt5066_olpc_dc_bias_enum_info
,
2650 .get
= cxt5066_olpc_dc_bias_enum_get
,
2651 .put
= cxt5066_olpc_dc_bias_enum_put
,
2656 static const struct snd_kcontrol_new cxt5066_mixers
[] = {
2658 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2659 .name
= "Master Playback Switch",
2660 .info
= cxt_eapd_info
,
2661 .get
= cxt_eapd_get
,
2662 .put
= cxt5066_hp_master_sw_put
,
2663 .private_value
= 0x1d,
2667 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2668 .name
= "Analog Mic Boost Capture Enum",
2669 .info
= cxt5066_mic_boost_mux_enum_info
,
2670 .get
= cxt5066_mic_boost_mux_enum_get
,
2671 .put
= cxt5066_mic_boost_mux_enum_put
,
2674 HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others
),
2675 HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others
),
2679 static const struct snd_kcontrol_new cxt5066_vostro_mixers
[] = {
2681 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2682 .name
= "Internal Mic Boost Capture Enum",
2683 .info
= cxt5066_mic_boost_mux_enum_info
,
2684 .get
= cxt5066_mic_boost_mux_enum_get
,
2685 .put
= cxt5066_mic_boost_mux_enum_put
,
2686 .private_value
= 0x23 | 0x100,
2691 static const struct hda_verb cxt5066_init_verbs
[] = {
2692 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2693 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2694 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2695 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2698 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2699 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2702 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2703 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2705 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2706 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2709 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2711 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2712 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2713 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2714 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2715 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2716 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2718 /* no digital microphone support yet */
2719 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2721 /* Audio input selector */
2722 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2724 /* SPDIF route: PCM */
2725 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2726 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2728 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2729 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2732 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2734 /* not handling these yet */
2735 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2736 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2737 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2738 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2739 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2740 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2741 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2742 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2746 static const struct hda_verb cxt5066_init_verbs_olpc
[] = {
2747 /* Port A: headphones */
2748 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2749 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2751 /* Port B: external microphone */
2752 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2754 /* Port C: internal microphone */
2755 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2757 /* Port D: unused */
2758 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2760 /* Port E: unused, but has primary EAPD */
2761 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2762 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2764 /* Port F: external DC input through microphone port */
2765 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2767 /* Port G: internal speakers */
2768 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2769 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2772 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2775 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2777 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2778 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2779 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2780 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2781 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2782 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2783 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2784 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2785 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2786 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2787 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2788 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2790 /* Disable digital microphone port */
2791 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2793 /* Audio input selectors */
2794 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2795 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2798 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2799 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2801 /* enable unsolicited events for Port A and B */
2802 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2803 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2807 static const struct hda_verb cxt5066_init_verbs_vostro
[] = {
2808 /* Port A: headphones */
2809 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2810 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2812 /* Port B: external microphone */
2813 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2815 /* Port C: unused */
2816 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2818 /* Port D: unused */
2819 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2821 /* Port E: unused, but has primary EAPD */
2822 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2823 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2825 /* Port F: unused */
2826 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2828 /* Port G: internal speakers */
2829 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2830 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2833 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2836 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2838 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2839 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2840 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2841 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2842 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2843 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2844 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2845 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2846 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2847 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2848 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2849 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2851 /* Digital microphone port */
2852 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2854 /* Audio input selectors */
2855 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2856 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2859 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2860 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2862 /* enable unsolicited events for Port A and B */
2863 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2864 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2868 static const struct hda_verb cxt5066_init_verbs_ideapad
[] = {
2869 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2870 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2871 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2872 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2875 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2876 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2879 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2880 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2882 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2883 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2886 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2888 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2889 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2890 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2891 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2892 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2893 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2894 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2896 /* Audio input selector */
2897 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2898 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2900 /* SPDIF route: PCM */
2901 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2902 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2904 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2905 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2907 /* internal microphone */
2908 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable internal mic */
2911 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2913 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2914 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2918 static const struct hda_verb cxt5066_init_verbs_thinkpad
[] = {
2919 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2920 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2922 /* Port G: internal speakers */
2923 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2924 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2926 /* Port A: HP, Amp */
2927 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2928 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2930 /* Port B: Mic Dock */
2931 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2934 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2936 /* Port D: HP Dock, Amp */
2937 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2938 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2941 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2943 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2944 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2945 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2946 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2947 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2948 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2949 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2951 /* Audio input selector */
2952 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2953 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2955 /* SPDIF route: PCM */
2956 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2957 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2959 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2960 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2962 /* internal microphone */
2963 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable internal mic */
2966 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2968 /* enable unsolicited events for Port A, B, C and D */
2969 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2970 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2971 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2972 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2976 static const struct hda_verb cxt5066_init_verbs_portd_lo
[] = {
2977 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2982 static const struct hda_verb cxt5066_init_verbs_hp_laptop
[] = {
2983 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x0},
2984 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2985 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2989 /* initialize jack-sensing, too */
2990 static int cxt5066_init(struct hda_codec
*codec
)
2992 snd_printdd("CXT5066: init\n");
2993 conexant_init(codec
);
2994 if (codec
->patch_ops
.unsol_event
) {
2995 cxt5066_hp_automute(codec
);
2996 cxt5066_automic(codec
);
2998 cxt5066_set_mic_boost(codec
);
3002 static int cxt5066_olpc_init(struct hda_codec
*codec
)
3004 struct conexant_spec
*spec
= codec
->spec
;
3005 snd_printdd("CXT5066: init\n");
3006 conexant_init(codec
);
3007 cxt5066_hp_automute(codec
);
3008 if (!spec
->dc_enable
) {
3009 cxt5066_set_mic_boost(codec
);
3010 cxt5066_olpc_automic(codec
);
3012 cxt5066_enable_dc(codec
);
3018 CXT5066_LAPTOP
, /* Laptops w/ EAPD support */
3019 CXT5066_DELL_LAPTOP
, /* Dell Laptop */
3020 CXT5066_OLPC_XO_1_5
, /* OLPC XO 1.5 */
3021 CXT5066_DELL_VOSTRO
, /* Dell Vostro 1015i */
3022 CXT5066_IDEAPAD
, /* Lenovo IdeaPad U150 */
3023 CXT5066_THINKPAD
, /* Lenovo ThinkPad T410s, others? */
3024 CXT5066_ASUS
, /* Asus K52JU, Lenovo G560 - Int mic at 0x1a and Ext mic at 0x1b */
3025 CXT5066_HP_LAPTOP
, /* HP Laptop */
3029 static const char * const cxt5066_models
[CXT5066_MODELS
] = {
3030 [CXT5066_LAPTOP
] = "laptop",
3031 [CXT5066_DELL_LAPTOP
] = "dell-laptop",
3032 [CXT5066_OLPC_XO_1_5
] = "olpc-xo-1_5",
3033 [CXT5066_DELL_VOSTRO
] = "dell-vostro",
3034 [CXT5066_IDEAPAD
] = "ideapad",
3035 [CXT5066_THINKPAD
] = "thinkpad",
3036 [CXT5066_ASUS
] = "asus",
3037 [CXT5066_HP_LAPTOP
] = "hp-laptop",
3040 static const struct snd_pci_quirk cxt5066_cfg_tbl
[] = {
3041 SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD
),
3042 SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO
),
3043 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD
),
3044 SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO
),
3045 SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTRO
),
3046 SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD
),
3047 SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD
),
3048 SND_PCI_QUIRK(0x1028, 0x0510, "Dell Vostro", CXT5066_IDEAPAD
),
3049 SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP
),
3050 SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS
),
3051 SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS
),
3052 SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS
),
3053 SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD
),
3054 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5
),
3055 SND_PCI_QUIRK(0x1179, 0xffe0, "Toshiba Satellite Pro T130-15F", CXT5066_OLPC_XO_1_5
),
3056 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
3058 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5
),
3059 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD
),
3060 SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD
),
3061 SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS
),
3062 SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo Thinkpad", CXT5066_THINKPAD
),
3063 SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT5066_THINKPAD
),
3064 SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT5066_THINKPAD
),
3065 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS
),
3066 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", CXT5066_IDEAPAD
), /* Fallback for Lenovos without dock mic */
3070 static int patch_cxt5066(struct hda_codec
*codec
)
3072 struct conexant_spec
*spec
;
3075 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3080 codec
->patch_ops
= conexant_patch_ops
;
3081 codec
->patch_ops
.init
= conexant_init
;
3083 spec
->dell_automute
= 0;
3084 spec
->multiout
.max_channels
= 2;
3085 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5066_dac_nids
);
3086 spec
->multiout
.dac_nids
= cxt5066_dac_nids
;
3087 conexant_check_dig_outs(codec
, cxt5066_digout_pin_nids
,
3088 ARRAY_SIZE(cxt5066_digout_pin_nids
));
3089 spec
->num_adc_nids
= 1;
3090 spec
->adc_nids
= cxt5066_adc_nids
;
3091 spec
->capsrc_nids
= cxt5066_capsrc_nids
;
3092 spec
->input_mux
= &cxt5066_capture_source
;
3094 spec
->port_d_mode
= PIN_HP
;
3096 spec
->num_init_verbs
= 1;
3097 spec
->init_verbs
[0] = cxt5066_init_verbs
;
3098 spec
->num_channel_mode
= ARRAY_SIZE(cxt5066_modes
);
3099 spec
->channel_mode
= cxt5066_modes
;
3101 spec
->cur_adc_idx
= 0;
3103 set_beep_amp(spec
, 0x13, 0, HDA_OUTPUT
);
3105 board_config
= snd_hda_check_board_config(codec
, CXT5066_MODELS
,
3106 cxt5066_models
, cxt5066_cfg_tbl
);
3107 switch (board_config
) {
3109 case CXT5066_LAPTOP
:
3110 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3111 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3113 case CXT5066_DELL_LAPTOP
:
3114 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3115 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3117 spec
->port_d_mode
= PIN_OUT
;
3118 spec
->init_verbs
[spec
->num_init_verbs
] = cxt5066_init_verbs_portd_lo
;
3119 spec
->num_init_verbs
++;
3120 spec
->dell_automute
= 1;
3123 case CXT5066_HP_LAPTOP
:
3124 codec
->patch_ops
.init
= cxt5066_init
;
3125 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3126 spec
->init_verbs
[spec
->num_init_verbs
] =
3127 cxt5066_init_verbs_hp_laptop
;
3128 spec
->num_init_verbs
++;
3129 spec
->hp_laptop
= board_config
== CXT5066_HP_LAPTOP
;
3130 spec
->asus
= board_config
== CXT5066_ASUS
;
3131 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3132 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3134 if (board_config
== CXT5066_HP_LAPTOP
)
3135 spec
->multiout
.dig_out_nid
= 0;
3136 /* input source automatically selected */
3137 spec
->input_mux
= NULL
;
3138 spec
->port_d_mode
= 0;
3139 spec
->mic_boost
= 3; /* default 30dB gain */
3142 case CXT5066_OLPC_XO_1_5
:
3143 codec
->patch_ops
.init
= cxt5066_olpc_init
;
3144 codec
->patch_ops
.unsol_event
= cxt5066_olpc_unsol_event
;
3145 spec
->init_verbs
[0] = cxt5066_init_verbs_olpc
;
3146 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
3147 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_olpc_dc
;
3148 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3149 spec
->port_d_mode
= 0;
3150 spec
->mic_boost
= 3; /* default 30dB gain */
3153 spec
->multiout
.dig_out_nid
= 0;
3155 /* input source automatically selected */
3156 spec
->input_mux
= NULL
;
3158 /* our capture hooks which allow us to turn on the microphone LED
3159 * at the right time */
3160 spec
->capture_prepare
= cxt5066_olpc_capture_prepare
;
3161 spec
->capture_cleanup
= cxt5066_olpc_capture_cleanup
;
3163 case CXT5066_DELL_VOSTRO
:
3164 codec
->patch_ops
.init
= cxt5066_init
;
3165 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3166 spec
->init_verbs
[0] = cxt5066_init_verbs_vostro
;
3167 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
3168 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3169 spec
->mixers
[spec
->num_mixers
++] = cxt5066_vostro_mixers
;
3170 spec
->port_d_mode
= 0;
3171 spec
->dell_vostro
= 1;
3172 spec
->mic_boost
= 3; /* default 30dB gain */
3175 spec
->multiout
.dig_out_nid
= 0;
3177 /* input source automatically selected */
3178 spec
->input_mux
= NULL
;
3180 case CXT5066_IDEAPAD
:
3181 codec
->patch_ops
.init
= cxt5066_init
;
3182 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3183 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3184 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3185 spec
->init_verbs
[0] = cxt5066_init_verbs_ideapad
;
3186 spec
->port_d_mode
= 0;
3188 spec
->mic_boost
= 2; /* default 20dB gain */
3191 spec
->multiout
.dig_out_nid
= 0;
3193 /* input source automatically selected */
3194 spec
->input_mux
= NULL
;
3196 case CXT5066_THINKPAD
:
3197 codec
->patch_ops
.init
= cxt5066_init
;
3198 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3199 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3200 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3201 spec
->init_verbs
[0] = cxt5066_init_verbs_thinkpad
;
3203 spec
->port_d_mode
= PIN_OUT
;
3204 spec
->mic_boost
= 2; /* default 20dB gain */
3207 spec
->multiout
.dig_out_nid
= 0;
3209 /* input source automatically selected */
3210 spec
->input_mux
= NULL
;
3215 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
3221 * Automatic parser for CX20641 & co
3224 static int cx_auto_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
3225 struct hda_codec
*codec
,
3226 unsigned int stream_tag
,
3227 unsigned int format
,
3228 struct snd_pcm_substream
*substream
)
3230 struct conexant_spec
*spec
= codec
->spec
;
3231 hda_nid_t adc
= spec
->imux_adcs
[spec
->cur_mux
[0]];
3232 if (spec
->adc_switching
) {
3233 spec
->cur_adc
= adc
;
3234 spec
->cur_adc_stream_tag
= stream_tag
;
3235 spec
->cur_adc_format
= format
;
3237 snd_hda_codec_setup_stream(codec
, adc
, stream_tag
, 0, format
);
3241 static int cx_auto_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
3242 struct hda_codec
*codec
,
3243 struct snd_pcm_substream
*substream
)
3245 struct conexant_spec
*spec
= codec
->spec
;
3246 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
3251 static const struct hda_pcm_stream cx_auto_pcm_analog_capture
= {
3255 .nid
= 0, /* fill later */
3257 .prepare
= cx_auto_capture_pcm_prepare
,
3258 .cleanup
= cx_auto_capture_pcm_cleanup
3262 static const hda_nid_t cx_auto_adc_nids
[] = { 0x14 };
3264 /* get the connection index of @nid in the widget @mux */
3265 static int get_connection_index(struct hda_codec
*codec
, hda_nid_t mux
,
3268 hda_nid_t conn
[HDA_MAX_NUM_INPUTS
];
3271 nums
= snd_hda_get_connections(codec
, mux
, conn
, ARRAY_SIZE(conn
));
3272 for (i
= 0; i
< nums
; i
++)
3278 static int has_multi_connection(struct hda_codec
*codec
, hda_nid_t mux
)
3280 hda_nid_t conn
[HDA_MAX_NUM_INPUTS
];
3283 nums
= snd_hda_get_connections(codec
, mux
, conn
, ARRAY_SIZE(conn
));
3287 /* get an unassigned DAC from the given list.
3288 * Return the nid if found and reduce the DAC list, or return zero if
3291 static hda_nid_t
get_unassigned_dac(struct hda_codec
*codec
, hda_nid_t pin
,
3292 hda_nid_t
*dacs
, int *num_dacs
)
3294 int i
, nums
= *num_dacs
;
3297 for (i
= 0; i
< nums
; i
++) {
3298 if (get_connection_index(codec
, pin
, dacs
[i
]) >= 0) {
3306 memmove(dacs
, dacs
+ 1, nums
* sizeof(hda_nid_t
));
3311 #define MAX_AUTO_DACS 5
3313 /* fill analog DAC list from the widget tree */
3314 static int fill_cx_auto_dacs(struct hda_codec
*codec
, hda_nid_t
*dacs
)
3316 hda_nid_t nid
, end_nid
;
3319 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3320 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
3321 unsigned int wcaps
= get_wcaps(codec
, nid
);
3322 unsigned int type
= get_wcaps_type(wcaps
);
3323 if (type
== AC_WID_AUD_OUT
&& !(wcaps
& AC_WCAP_DIGITAL
)) {
3325 if (nums
>= MAX_AUTO_DACS
)
3332 /* fill pin_dac_pair list from the pin and dac list */
3333 static int fill_dacs_for_pins(struct hda_codec
*codec
, hda_nid_t
*pins
,
3334 int num_pins
, hda_nid_t
*dacs
, int *rest
,
3335 struct pin_dac_pair
*filled
, int type
)
3340 for (i
= 0; i
< num_pins
; i
++) {
3341 filled
[nums
].pin
= pins
[i
];
3342 filled
[nums
].type
= type
;
3343 filled
[nums
].dac
= get_unassigned_dac(codec
, pins
[i
], dacs
, rest
);
3349 /* parse analog output paths */
3350 static void cx_auto_parse_output(struct hda_codec
*codec
)
3352 struct conexant_spec
*spec
= codec
->spec
;
3353 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3354 hda_nid_t dacs
[MAX_AUTO_DACS
];
3355 int i
, j
, nums
, rest
;
3357 rest
= fill_cx_auto_dacs(codec
, dacs
);
3358 /* parse all analog output pins */
3359 nums
= fill_dacs_for_pins(codec
, cfg
->line_out_pins
, cfg
->line_outs
,
3360 dacs
, &rest
, spec
->dac_info
,
3362 nums
+= fill_dacs_for_pins(codec
, cfg
->hp_pins
, cfg
->hp_outs
,
3363 dacs
, &rest
, spec
->dac_info
+ nums
,
3365 nums
+= fill_dacs_for_pins(codec
, cfg
->speaker_pins
, cfg
->speaker_outs
,
3366 dacs
, &rest
, spec
->dac_info
+ nums
,
3367 AUTO_PIN_SPEAKER_OUT
);
3368 spec
->dac_info_filled
= nums
;
3369 /* fill multiout struct */
3370 for (i
= 0; i
< nums
; i
++) {
3371 hda_nid_t dac
= spec
->dac_info
[i
].dac
;
3374 switch (spec
->dac_info
[i
].type
) {
3375 case AUTO_PIN_LINE_OUT
:
3376 spec
->private_dac_nids
[spec
->multiout
.num_dacs
] = dac
;
3377 spec
->multiout
.num_dacs
++;
3379 case AUTO_PIN_HP_OUT
:
3380 case AUTO_PIN_SPEAKER_OUT
:
3381 if (!spec
->multiout
.hp_nid
) {
3382 spec
->multiout
.hp_nid
= dac
;
3385 for (j
= 0; j
< ARRAY_SIZE(spec
->multiout
.extra_out_nid
); j
++)
3386 if (!spec
->multiout
.extra_out_nid
[j
]) {
3387 spec
->multiout
.extra_out_nid
[j
] = dac
;
3393 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3394 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
3396 if (cfg
->hp_outs
> 0)
3397 spec
->auto_mute
= 1;
3398 spec
->vmaster_nid
= spec
->private_dac_nids
[0];
3401 static void cx_auto_turn_eapd(struct hda_codec
*codec
, int num_pins
,
3402 hda_nid_t
*pins
, bool on
);
3404 /* auto-mute/unmute speaker and line outs according to headphone jack */
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
;
3411 if (!spec
->auto_mute
)
3414 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3415 if (snd_hda_jack_detect(codec
, cfg
->hp_pins
[i
])) {
3420 cx_auto_turn_eapd(codec
, cfg
->hp_outs
, cfg
->hp_pins
, present
);
3421 for (i
= 0; i
< cfg
->line_outs
; i
++) {
3422 snd_hda_codec_write(codec
, cfg
->line_out_pins
[i
], 0,
3423 AC_VERB_SET_PIN_WIDGET_CONTROL
,
3424 present
? 0 : PIN_OUT
);
3426 cx_auto_turn_eapd(codec
, cfg
->line_outs
, cfg
->line_out_pins
, !present
);
3427 for (i
= 0; !present
&& i
< cfg
->line_outs
; i
++)
3428 if (snd_hda_jack_detect(codec
, cfg
->line_out_pins
[i
]))
3430 for (i
= 0; i
< cfg
->speaker_outs
; i
++) {
3431 snd_hda_codec_write(codec
, cfg
->speaker_pins
[i
], 0,
3432 AC_VERB_SET_PIN_WIDGET_CONTROL
,
3433 present
? 0 : PIN_OUT
);
3435 cx_auto_turn_eapd(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
, !present
);
3438 static int cx_auto_mux_enum_info(struct snd_kcontrol
*kcontrol
,
3439 struct snd_ctl_elem_info
*uinfo
)
3441 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3442 struct conexant_spec
*spec
= codec
->spec
;
3444 return snd_hda_input_mux_info(&spec
->private_imux
, uinfo
);
3447 static int cx_auto_mux_enum_get(struct snd_kcontrol
*kcontrol
,
3448 struct snd_ctl_elem_value
*ucontrol
)
3450 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3451 struct conexant_spec
*spec
= codec
->spec
;
3453 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[0];
3457 static int cx_auto_mux_enum_update(struct hda_codec
*codec
,
3458 const struct hda_input_mux
*imux
,
3461 struct conexant_spec
*spec
= codec
->spec
;
3464 if (!imux
->num_items
)
3466 if (idx
>= imux
->num_items
)
3467 idx
= imux
->num_items
- 1;
3468 if (spec
->cur_mux
[0] == idx
)
3470 adc
= spec
->imux_adcs
[idx
];
3471 if (has_multi_connection(codec
, adc
))
3472 snd_hda_codec_write(codec
, adc
, 0,
3473 AC_VERB_SET_CONNECT_SEL
,
3474 imux
->items
[idx
].index
);
3475 if (spec
->cur_adc
&& spec
->cur_adc
!= adc
) {
3476 /* stream is running, let's swap the current ADC */
3477 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
3478 spec
->cur_adc
= adc
;
3479 snd_hda_codec_setup_stream(codec
, adc
,
3480 spec
->cur_adc_stream_tag
, 0,
3481 spec
->cur_adc_format
);
3483 spec
->cur_mux
[0] = idx
;
3487 static int cx_auto_mux_enum_put(struct snd_kcontrol
*kcontrol
,
3488 struct snd_ctl_elem_value
*ucontrol
)
3490 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3491 struct conexant_spec
*spec
= codec
->spec
;
3493 return cx_auto_mux_enum_update(codec
, &spec
->private_imux
,
3494 ucontrol
->value
.enumerated
.item
[0]);
3497 static const struct snd_kcontrol_new cx_auto_capture_mixers
[] = {
3499 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3500 .name
= "Capture Source",
3501 .info
= cx_auto_mux_enum_info
,
3502 .get
= cx_auto_mux_enum_get
,
3503 .put
= cx_auto_mux_enum_put
3508 /* automatic switch internal and external mic */
3509 static void cx_auto_automic(struct hda_codec
*codec
)
3511 struct conexant_spec
*spec
= codec
->spec
;
3512 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3513 int ext_idx
= spec
->auto_mic_ext
;
3515 if (!spec
->auto_mic
)
3517 if (snd_hda_jack_detect(codec
, cfg
->inputs
[ext_idx
].pin
))
3518 cx_auto_mux_enum_update(codec
, &spec
->private_imux
, ext_idx
);
3520 cx_auto_mux_enum_update(codec
, &spec
->private_imux
, !ext_idx
);
3523 static void cx_auto_unsol_event(struct hda_codec
*codec
, unsigned int res
)
3525 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
3526 switch (res
>> 26) {
3527 case CONEXANT_HP_EVENT
:
3528 cx_auto_hp_automute(codec
);
3529 snd_hda_input_jack_report(codec
, nid
);
3531 case CONEXANT_MIC_EVENT
:
3532 cx_auto_automic(codec
);
3533 snd_hda_input_jack_report(codec
, nid
);
3538 /* return true if it's an internal-mic pin */
3539 static int is_int_mic(struct hda_codec
*codec
, hda_nid_t pin
)
3541 unsigned int def_conf
= snd_hda_codec_get_pincfg(codec
, pin
);
3542 return get_defcfg_device(def_conf
) == AC_JACK_MIC_IN
&&
3543 snd_hda_get_input_pin_attr(def_conf
) == INPUT_PIN_ATTR_INT
;
3546 /* return true if it's an external-mic pin */
3547 static int is_ext_mic(struct hda_codec
*codec
, hda_nid_t pin
)
3549 unsigned int def_conf
= snd_hda_codec_get_pincfg(codec
, pin
);
3550 return get_defcfg_device(def_conf
) == AC_JACK_MIC_IN
&&
3551 snd_hda_get_input_pin_attr(def_conf
) >= INPUT_PIN_ATTR_NORMAL
&&
3552 (snd_hda_query_pin_caps(codec
, pin
) & AC_PINCAP_PRES_DETECT
);
3555 /* check whether the pin config is suitable for auto-mic switching;
3556 * auto-mic is enabled only when one int-mic and one-ext mic exist
3558 static void cx_auto_check_auto_mic(struct hda_codec
*codec
)
3560 struct conexant_spec
*spec
= codec
->spec
;
3561 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3563 if (is_ext_mic(codec
, cfg
->inputs
[0].pin
) &&
3564 is_int_mic(codec
, cfg
->inputs
[1].pin
)) {
3566 spec
->auto_mic_ext
= 0;
3569 if (is_int_mic(codec
, cfg
->inputs
[0].pin
) &&
3570 is_ext_mic(codec
, cfg
->inputs
[1].pin
)) {
3572 spec
->auto_mic_ext
= 1;
3577 static void cx_auto_parse_input(struct hda_codec
*codec
)
3579 struct conexant_spec
*spec
= codec
->spec
;
3580 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3581 struct hda_input_mux
*imux
;
3584 imux
= &spec
->private_imux
;
3585 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3586 for (j
= 0; j
< spec
->num_adc_nids
; j
++) {
3587 hda_nid_t adc
= spec
->adc_nids
[j
];
3588 int idx
= get_connection_index(codec
, adc
,
3589 cfg
->inputs
[i
].pin
);
3592 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
3593 snd_hda_add_imux_item(imux
, label
, idx
, NULL
);
3594 spec
->imux_adcs
[i
] = adc
;
3599 if (imux
->num_items
== 2 && cfg
->num_inputs
== 2)
3600 cx_auto_check_auto_mic(codec
);
3601 if (imux
->num_items
> 1 && !spec
->auto_mic
) {
3602 for (i
= 1; i
< imux
->num_items
; i
++) {
3603 if (spec
->imux_adcs
[i
] != spec
->imux_adcs
[0]) {
3604 spec
->adc_switching
= 1;
3611 /* get digital-input audio widget corresponding to the given pin */
3612 static hda_nid_t
cx_auto_get_dig_in(struct hda_codec
*codec
, hda_nid_t pin
)
3614 hda_nid_t nid
, end_nid
;
3616 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3617 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
3618 unsigned int wcaps
= get_wcaps(codec
, nid
);
3619 unsigned int type
= get_wcaps_type(wcaps
);
3620 if (type
== AC_WID_AUD_IN
&& (wcaps
& AC_WCAP_DIGITAL
)) {
3621 if (get_connection_index(codec
, nid
, pin
) >= 0)
3628 static void cx_auto_parse_digital(struct hda_codec
*codec
)
3630 struct conexant_spec
*spec
= codec
->spec
;
3631 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3634 if (cfg
->dig_outs
&&
3635 snd_hda_get_connections(codec
, cfg
->dig_out_pins
[0], &nid
, 1) == 1)
3636 spec
->multiout
.dig_out_nid
= nid
;
3637 if (cfg
->dig_in_pin
)
3638 spec
->dig_in_nid
= cx_auto_get_dig_in(codec
, cfg
->dig_in_pin
);
3641 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3642 static void cx_auto_parse_beep(struct hda_codec
*codec
)
3644 struct conexant_spec
*spec
= codec
->spec
;
3645 hda_nid_t nid
, end_nid
;
3647 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3648 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++)
3649 if (get_wcaps_type(get_wcaps(codec
, nid
)) == AC_WID_BEEP
) {
3650 set_beep_amp(spec
, nid
, 0, HDA_OUTPUT
);
3655 #define cx_auto_parse_beep(codec)
3658 static int cx_auto_parse_auto_config(struct hda_codec
*codec
)
3660 struct conexant_spec
*spec
= codec
->spec
;
3663 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
3667 cx_auto_parse_output(codec
);
3668 cx_auto_parse_input(codec
);
3669 cx_auto_parse_digital(codec
);
3670 cx_auto_parse_beep(codec
);
3674 static void cx_auto_turn_eapd(struct hda_codec
*codec
, int num_pins
,
3675 hda_nid_t
*pins
, bool on
)
3678 for (i
= 0; i
< num_pins
; i
++) {
3679 if (snd_hda_query_pin_caps(codec
, pins
[i
]) & AC_PINCAP_EAPD
)
3680 snd_hda_codec_write(codec
, pins
[i
], 0,
3681 AC_VERB_SET_EAPD_BTLENABLE
,
3686 static void select_connection(struct hda_codec
*codec
, hda_nid_t pin
,
3689 int idx
= get_connection_index(codec
, pin
, src
);
3691 snd_hda_codec_write(codec
, pin
, 0,
3692 AC_VERB_SET_CONNECT_SEL
, idx
);
3695 static void mute_outputs(struct hda_codec
*codec
, int num_nids
,
3696 const hda_nid_t
*nids
)
3700 for (i
= 0; i
< num_nids
; i
++) {
3701 hda_nid_t nid
= nids
[i
];
3702 if (!(get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
))
3704 if (query_amp_caps(codec
, nid
, HDA_OUTPUT
) & AC_AMPCAP_MUTE
)
3708 snd_hda_codec_write(codec
, nid
, 0,
3709 AC_VERB_SET_AMP_GAIN_MUTE
, val
);
3713 static void cx_auto_init_output(struct hda_codec
*codec
)
3715 struct conexant_spec
*spec
= codec
->spec
;
3716 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3720 mute_outputs(codec
, spec
->multiout
.num_dacs
, spec
->multiout
.dac_nids
);
3721 for (i
= 0; i
< cfg
->hp_outs
; i
++)
3722 snd_hda_codec_write(codec
, cfg
->hp_pins
[i
], 0,
3723 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
);
3724 mute_outputs(codec
, cfg
->hp_outs
, cfg
->hp_pins
);
3725 mute_outputs(codec
, cfg
->line_outs
, cfg
->line_out_pins
);
3726 mute_outputs(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
);
3727 if (spec
->auto_mute
) {
3728 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3729 snd_hda_codec_write(codec
, cfg
->hp_pins
[i
], 0,
3730 AC_VERB_SET_UNSOLICITED_ENABLE
,
3731 AC_USRSP_EN
| CONEXANT_HP_EVENT
);
3733 cx_auto_hp_automute(codec
);
3735 for (i
= 0; i
< cfg
->line_outs
; i
++)
3736 snd_hda_codec_write(codec
, cfg
->line_out_pins
[i
], 0,
3737 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
3738 for (i
= 0; i
< cfg
->speaker_outs
; i
++)
3739 snd_hda_codec_write(codec
, cfg
->speaker_pins
[i
], 0,
3740 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
3742 cx_auto_turn_eapd(codec
, cfg
->line_outs
, cfg
->line_out_pins
,
3744 cx_auto_turn_eapd(codec
, cfg
->hp_outs
, cfg
->hp_pins
,
3746 cx_auto_turn_eapd(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
,
3750 for (i
= 0; i
< spec
->dac_info_filled
; i
++) {
3751 nid
= spec
->dac_info
[i
].dac
;
3753 nid
= spec
->multiout
.dac_nids
[0];
3754 select_connection(codec
, spec
->dac_info
[i
].pin
, nid
);
3758 static void cx_auto_init_input(struct hda_codec
*codec
)
3760 struct conexant_spec
*spec
= codec
->spec
;
3761 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3764 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
3765 hda_nid_t nid
= spec
->adc_nids
[i
];
3766 if (!(get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
))
3768 if (query_amp_caps(codec
, nid
, HDA_INPUT
) & AC_AMPCAP_MUTE
)
3769 val
= AMP_IN_MUTE(0);
3771 val
= AMP_IN_UNMUTE(0);
3772 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3776 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3778 if (cfg
->inputs
[i
].type
== AUTO_PIN_MIC
)
3782 snd_hda_codec_write(codec
, cfg
->inputs
[i
].pin
, 0,
3783 AC_VERB_SET_PIN_WIDGET_CONTROL
, type
);
3786 if (spec
->auto_mic
) {
3787 int ext_idx
= spec
->auto_mic_ext
;
3788 snd_hda_codec_write(codec
, cfg
->inputs
[ext_idx
].pin
, 0,
3789 AC_VERB_SET_UNSOLICITED_ENABLE
,
3790 AC_USRSP_EN
| CONEXANT_MIC_EVENT
);
3791 cx_auto_automic(codec
);
3793 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
3794 snd_hda_codec_write(codec
, spec
->adc_nids
[i
], 0,
3795 AC_VERB_SET_CONNECT_SEL
,
3796 spec
->private_imux
.items
[0].index
);
3801 static void cx_auto_init_digital(struct hda_codec
*codec
)
3803 struct conexant_spec
*spec
= codec
->spec
;
3804 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3806 if (spec
->multiout
.dig_out_nid
)
3807 snd_hda_codec_write(codec
, cfg
->dig_out_pins
[0], 0,
3808 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
3809 if (spec
->dig_in_nid
)
3810 snd_hda_codec_write(codec
, cfg
->dig_in_pin
, 0,
3811 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
);
3814 static int cx_auto_init(struct hda_codec
*codec
)
3816 /*snd_hda_sequence_write(codec, cx_auto_init_verbs);*/
3817 cx_auto_init_output(codec
);
3818 cx_auto_init_input(codec
);
3819 cx_auto_init_digital(codec
);
3823 static int cx_auto_add_volume_idx(struct hda_codec
*codec
, const char *basename
,
3824 const char *dir
, int cidx
,
3825 hda_nid_t nid
, int hda_dir
, int amp_idx
)
3827 static char name
[32];
3828 static struct snd_kcontrol_new knew
[] = {
3829 HDA_CODEC_VOLUME(name
, 0, 0, 0),
3830 HDA_CODEC_MUTE(name
, 0, 0, 0),
3832 static const char * const sfx
[2] = { "Volume", "Switch" };
3835 for (i
= 0; i
< 2; i
++) {
3836 struct snd_kcontrol
*kctl
;
3837 knew
[i
].private_value
= HDA_COMPOSE_AMP_VAL(nid
, 3, amp_idx
,
3839 knew
[i
].subdevice
= HDA_SUBDEV_AMP_FLAG
;
3840 knew
[i
].index
= cidx
;
3841 snprintf(name
, sizeof(name
), "%s%s %s", basename
, dir
, sfx
[i
]);
3842 kctl
= snd_ctl_new1(&knew
[i
], codec
);
3845 err
= snd_hda_ctl_add(codec
, nid
, kctl
);
3848 if (!(query_amp_caps(codec
, nid
, hda_dir
) & AC_AMPCAP_MUTE
))
3854 #define cx_auto_add_volume(codec, str, dir, cidx, nid, hda_dir) \
3855 cx_auto_add_volume_idx(codec, str, dir, cidx, nid, hda_dir, 0)
3857 #define cx_auto_add_pb_volume(codec, nid, str, idx) \
3858 cx_auto_add_volume(codec, str, " Playback", idx, nid, HDA_OUTPUT)
3860 static int try_add_pb_volume(struct hda_codec
*codec
, hda_nid_t dac
,
3861 hda_nid_t pin
, const char *name
, int idx
)
3864 caps
= query_amp_caps(codec
, dac
, HDA_OUTPUT
);
3865 if (caps
& AC_AMPCAP_NUM_STEPS
)
3866 return cx_auto_add_pb_volume(codec
, dac
, name
, idx
);
3867 caps
= query_amp_caps(codec
, pin
, HDA_OUTPUT
);
3868 if (caps
& AC_AMPCAP_NUM_STEPS
)
3869 return cx_auto_add_pb_volume(codec
, pin
, name
, idx
);
3873 static int cx_auto_build_output_controls(struct hda_codec
*codec
)
3875 struct conexant_spec
*spec
= codec
->spec
;
3877 int num_line
= 0, num_hp
= 0, num_spk
= 0;
3878 static const char * const texts
[3] = { "Front", "Surround", "CLFE" };
3880 if (spec
->dac_info_filled
== 1)
3881 return try_add_pb_volume(codec
, spec
->dac_info
[0].dac
,
3882 spec
->dac_info
[0].pin
,
3885 for (i
= 0; i
< spec
->dac_info_filled
; i
++) {
3888 if (!spec
->dac_info
[i
].dac
)
3890 type
= spec
->dac_info
[i
].type
;
3891 if (type
== AUTO_PIN_LINE_OUT
)
3892 type
= spec
->autocfg
.line_out_type
;
3894 case AUTO_PIN_LINE_OUT
:
3896 label
= texts
[num_line
++];
3899 case AUTO_PIN_HP_OUT
:
3900 label
= "Headphone";
3903 case AUTO_PIN_SPEAKER_OUT
:
3908 err
= try_add_pb_volume(codec
, spec
->dac_info
[i
].dac
,
3909 spec
->dac_info
[i
].pin
,
3917 static int cx_auto_add_capture_volume(struct hda_codec
*codec
, hda_nid_t nid
,
3918 const char *label
, const char *pfx
,
3921 struct conexant_spec
*spec
= codec
->spec
;
3924 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
3925 hda_nid_t adc_nid
= spec
->adc_nids
[i
];
3926 int idx
= get_connection_index(codec
, adc_nid
, nid
);
3929 return cx_auto_add_volume_idx(codec
, label
, pfx
,
3930 cidx
, adc_nid
, HDA_INPUT
, idx
);
3935 static int cx_auto_build_input_controls(struct hda_codec
*codec
)
3937 struct conexant_spec
*spec
= codec
->spec
;
3938 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3939 static const char *prev_label
;
3944 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3945 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
3947 int pin_amp
= get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
;
3949 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
3950 if (label
== prev_label
)
3957 err
= cx_auto_add_volume(codec
, label
, " Boost", cidx
,
3963 if (cfg
->num_inputs
== 1) {
3964 err
= cx_auto_add_capture_volume(codec
, nid
,
3965 "Capture", "", cidx
);
3967 err
= cx_auto_add_capture_volume(codec
, nid
,
3968 label
, " Capture", cidx
);
3974 if (spec
->private_imux
.num_items
> 1 && !spec
->auto_mic
) {
3975 err
= snd_hda_add_new_ctls(codec
, cx_auto_capture_mixers
);
3983 static int cx_auto_build_controls(struct hda_codec
*codec
)
3987 err
= cx_auto_build_output_controls(codec
);
3990 err
= cx_auto_build_input_controls(codec
);
3993 return conexant_build_controls(codec
);
3996 static const struct hda_codec_ops cx_auto_patch_ops
= {
3997 .build_controls
= cx_auto_build_controls
,
3998 .build_pcms
= conexant_build_pcms
,
3999 .init
= cx_auto_init
,
4000 .free
= conexant_free
,
4001 .unsol_event
= cx_auto_unsol_event
,
4002 #ifdef CONFIG_SND_HDA_POWER_SAVE
4003 .suspend
= conexant_suspend
,
4005 .reboot_notify
= snd_hda_shutup_pins
,
4008 static int patch_conexant_auto(struct hda_codec
*codec
)
4010 struct conexant_spec
*spec
;
4013 printk(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
4016 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4020 switch (codec
->vendor_id
) {
4022 codec
->pin_amp_workaround
= 1;
4023 spec
->adc_nids
= cxt5051_adc_nids
;
4024 spec
->num_adc_nids
= ARRAY_SIZE(cxt5051_adc_nids
);
4025 spec
->capsrc_nids
= spec
->adc_nids
;
4028 codec
->pin_amp_workaround
= 1;
4029 spec
->adc_nids
= cxt5045_adc_nids
;
4030 spec
->num_adc_nids
= ARRAY_SIZE(cxt5045_adc_nids
);
4031 spec
->capsrc_nids
= spec
->adc_nids
;
4034 spec
->adc_nids
= cx_auto_adc_nids
;
4035 spec
->num_adc_nids
= ARRAY_SIZE(cx_auto_adc_nids
);
4036 spec
->capsrc_nids
= spec
->adc_nids
;
4039 err
= cx_auto_parse_auto_config(codec
);
4045 spec
->capture_stream
= &cx_auto_pcm_analog_capture
;
4046 codec
->patch_ops
= cx_auto_patch_ops
;
4048 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
4055 static const struct hda_codec_preset snd_hda_preset_conexant
[] = {
4056 { .id
= 0x14f15045, .name
= "CX20549 (Venice)",
4057 .patch
= patch_cxt5045
},
4058 { .id
= 0x14f15047, .name
= "CX20551 (Waikiki)",
4059 .patch
= patch_cxt5047
},
4060 { .id
= 0x14f15051, .name
= "CX20561 (Hermosa)",
4061 .patch
= patch_cxt5051
},
4062 { .id
= 0x14f15066, .name
= "CX20582 (Pebble)",
4063 .patch
= patch_cxt5066
},
4064 { .id
= 0x14f15067, .name
= "CX20583 (Pebble HSF)",
4065 .patch
= patch_cxt5066
},
4066 { .id
= 0x14f15068, .name
= "CX20584",
4067 .patch
= patch_cxt5066
},
4068 { .id
= 0x14f15069, .name
= "CX20585",
4069 .patch
= patch_cxt5066
},
4070 { .id
= 0x14f1506e, .name
= "CX20590",
4071 .patch
= patch_cxt5066
},
4072 { .id
= 0x14f15097, .name
= "CX20631",
4073 .patch
= patch_conexant_auto
},
4074 { .id
= 0x14f15098, .name
= "CX20632",
4075 .patch
= patch_conexant_auto
},
4076 { .id
= 0x14f150a1, .name
= "CX20641",
4077 .patch
= patch_conexant_auto
},
4078 { .id
= 0x14f150a2, .name
= "CX20642",
4079 .patch
= patch_conexant_auto
},
4080 { .id
= 0x14f150ab, .name
= "CX20651",
4081 .patch
= patch_conexant_auto
},
4082 { .id
= 0x14f150ac, .name
= "CX20652",
4083 .patch
= patch_conexant_auto
},
4084 { .id
= 0x14f150b8, .name
= "CX20664",
4085 .patch
= patch_conexant_auto
},
4086 { .id
= 0x14f150b9, .name
= "CX20665",
4087 .patch
= patch_conexant_auto
},
4091 MODULE_ALIAS("snd-hda-codec-id:14f15045");
4092 MODULE_ALIAS("snd-hda-codec-id:14f15047");
4093 MODULE_ALIAS("snd-hda-codec-id:14f15051");
4094 MODULE_ALIAS("snd-hda-codec-id:14f15066");
4095 MODULE_ALIAS("snd-hda-codec-id:14f15067");
4096 MODULE_ALIAS("snd-hda-codec-id:14f15068");
4097 MODULE_ALIAS("snd-hda-codec-id:14f15069");
4098 MODULE_ALIAS("snd-hda-codec-id:14f1506e");
4099 MODULE_ALIAS("snd-hda-codec-id:14f15097");
4100 MODULE_ALIAS("snd-hda-codec-id:14f15098");
4101 MODULE_ALIAS("snd-hda-codec-id:14f150a1");
4102 MODULE_ALIAS("snd-hda-codec-id:14f150a2");
4103 MODULE_ALIAS("snd-hda-codec-id:14f150ab");
4104 MODULE_ALIAS("snd-hda-codec-id:14f150ac");
4105 MODULE_ALIAS("snd-hda-codec-id:14f150b8");
4106 MODULE_ALIAS("snd-hda-codec-id:14f150b9");
4108 MODULE_LICENSE("GPL");
4109 MODULE_DESCRIPTION("Conexant HD-audio codec");
4111 static struct hda_codec_preset_list conexant_list
= {
4112 .preset
= snd_hda_preset_conexant
,
4113 .owner
= THIS_MODULE
,
4116 static int __init
patch_conexant_init(void)
4118 return snd_hda_add_codec_preset(&conexant_list
);
4121 static void __exit
patch_conexant_exit(void)
4123 snd_hda_delete_codec_preset(&conexant_list
);
4126 module_init(patch_conexant_init
)
4127 module_exit(patch_conexant_exit
)