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
; /* imux_pins[] 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 int imux_cfg_idx
[HDA_MAX_NUM_INPUTS
]; /* corresponding autocfg.input */
112 hda_nid_t imux_boost_nid
[HDA_MAX_NUM_INPUTS
]; /* boost widget */
113 hda_nid_t imux_adcs
[HDA_MAX_NUM_INPUTS
];
114 hda_nid_t imux_pins
[HDA_MAX_NUM_INPUTS
];
115 hda_nid_t private_adc_nids
[HDA_MAX_NUM_INPUTS
];
116 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
117 struct pin_dac_pair dac_info
[8];
120 unsigned int port_d_mode
;
121 unsigned int auto_mute
:1; /* used in auto-parser */
122 unsigned int dell_automute
:1;
123 unsigned int dell_vostro
:1;
124 unsigned int ideapad
:1;
125 unsigned int thinkpad
:1;
126 unsigned int hp_laptop
:1;
129 unsigned int adc_switching
:1;
131 unsigned int ext_mic_present
;
132 unsigned int recording
;
133 void (*capture_prepare
)(struct hda_codec
*codec
);
134 void (*capture_cleanup
)(struct hda_codec
*codec
);
136 /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
137 * through the microphone jack.
138 * When the user enables this through a mixer switch, both internal and
139 * external microphones are disabled. Gain is fixed at 0dB. In this mode,
140 * we also allow the bias to be configured through a separate mixer
142 unsigned int dc_enable
;
143 unsigned int dc_input_bias
; /* offset into cxt5066_olpc_dc_bias */
144 unsigned int mic_boost
; /* offset into cxt5066_analog_mic_boost */
146 unsigned int beep_amp
;
149 static int conexant_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
150 struct hda_codec
*codec
,
151 struct snd_pcm_substream
*substream
)
153 struct conexant_spec
*spec
= codec
->spec
;
154 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
158 static int conexant_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
159 struct hda_codec
*codec
,
160 unsigned int stream_tag
,
162 struct snd_pcm_substream
*substream
)
164 struct conexant_spec
*spec
= codec
->spec
;
165 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
170 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
171 struct hda_codec
*codec
,
172 struct snd_pcm_substream
*substream
)
174 struct conexant_spec
*spec
= codec
->spec
;
175 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
181 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
182 struct hda_codec
*codec
,
183 struct snd_pcm_substream
*substream
)
185 struct conexant_spec
*spec
= codec
->spec
;
186 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
189 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
190 struct hda_codec
*codec
,
191 struct snd_pcm_substream
*substream
)
193 struct conexant_spec
*spec
= codec
->spec
;
194 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
197 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
198 struct hda_codec
*codec
,
199 unsigned int stream_tag
,
201 struct snd_pcm_substream
*substream
)
203 struct conexant_spec
*spec
= codec
->spec
;
204 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
212 static int conexant_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
213 struct hda_codec
*codec
,
214 unsigned int stream_tag
,
216 struct snd_pcm_substream
*substream
)
218 struct conexant_spec
*spec
= codec
->spec
;
219 if (spec
->capture_prepare
)
220 spec
->capture_prepare(codec
);
221 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
222 stream_tag
, 0, format
);
226 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
227 struct hda_codec
*codec
,
228 struct snd_pcm_substream
*substream
)
230 struct conexant_spec
*spec
= codec
->spec
;
231 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
232 if (spec
->capture_cleanup
)
233 spec
->capture_cleanup(codec
);
239 static const struct hda_pcm_stream conexant_pcm_analog_playback
= {
243 .nid
= 0, /* fill later */
245 .open
= conexant_playback_pcm_open
,
246 .prepare
= conexant_playback_pcm_prepare
,
247 .cleanup
= conexant_playback_pcm_cleanup
251 static const struct hda_pcm_stream conexant_pcm_analog_capture
= {
255 .nid
= 0, /* fill later */
257 .prepare
= conexant_capture_pcm_prepare
,
258 .cleanup
= conexant_capture_pcm_cleanup
263 static const struct hda_pcm_stream conexant_pcm_digital_playback
= {
267 .nid
= 0, /* fill later */
269 .open
= conexant_dig_playback_pcm_open
,
270 .close
= conexant_dig_playback_pcm_close
,
271 .prepare
= conexant_dig_playback_pcm_prepare
275 static const struct hda_pcm_stream conexant_pcm_digital_capture
= {
279 /* NID is set in alc_build_pcms */
282 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
283 struct hda_codec
*codec
,
284 unsigned int stream_tag
,
286 struct snd_pcm_substream
*substream
)
288 struct conexant_spec
*spec
= codec
->spec
;
289 spec
->cur_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
290 spec
->cur_adc_stream_tag
= stream_tag
;
291 spec
->cur_adc_format
= format
;
292 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
296 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
297 struct hda_codec
*codec
,
298 struct snd_pcm_substream
*substream
)
300 struct conexant_spec
*spec
= codec
->spec
;
301 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
306 static const struct hda_pcm_stream cx5051_pcm_analog_capture
= {
310 .nid
= 0, /* fill later */
312 .prepare
= cx5051_capture_pcm_prepare
,
313 .cleanup
= cx5051_capture_pcm_cleanup
317 static int conexant_build_pcms(struct hda_codec
*codec
)
319 struct conexant_spec
*spec
= codec
->spec
;
320 struct hda_pcm
*info
= spec
->pcm_rec
;
323 codec
->pcm_info
= info
;
325 info
->name
= "CONEXANT Analog";
326 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = conexant_pcm_analog_playback
;
327 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
=
328 spec
->multiout
.max_channels
;
329 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
330 spec
->multiout
.dac_nids
[0];
331 if (spec
->capture_stream
)
332 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *spec
->capture_stream
;
334 if (codec
->vendor_id
== 0x14f15051)
335 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
336 cx5051_pcm_analog_capture
;
338 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
339 conexant_pcm_analog_capture
;
340 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
=
344 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
346 if (spec
->multiout
.dig_out_nid
) {
349 info
->name
= "Conexant Digital";
350 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
351 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
352 conexant_pcm_digital_playback
;
353 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
354 spec
->multiout
.dig_out_nid
;
355 if (spec
->dig_in_nid
) {
356 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
357 conexant_pcm_digital_capture
;
358 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
361 if (spec
->slave_dig_outs
[0])
362 codec
->slave_dig_outs
= spec
->slave_dig_outs
;
368 static int conexant_mux_enum_info(struct snd_kcontrol
*kcontrol
,
369 struct snd_ctl_elem_info
*uinfo
)
371 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
372 struct conexant_spec
*spec
= codec
->spec
;
374 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
377 static int conexant_mux_enum_get(struct snd_kcontrol
*kcontrol
,
378 struct snd_ctl_elem_value
*ucontrol
)
380 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
381 struct conexant_spec
*spec
= codec
->spec
;
382 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
384 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
388 static int conexant_mux_enum_put(struct snd_kcontrol
*kcontrol
,
389 struct snd_ctl_elem_value
*ucontrol
)
391 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
392 struct conexant_spec
*spec
= codec
->spec
;
393 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
395 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
396 spec
->capsrc_nids
[adc_idx
],
397 &spec
->cur_mux
[adc_idx
]);
400 static int conexant_init_jacks(struct hda_codec
*codec
)
402 #ifdef CONFIG_SND_HDA_INPUT_JACK
403 struct conexant_spec
*spec
= codec
->spec
;
406 for (i
= 0; i
< spec
->num_init_verbs
; i
++) {
407 const struct hda_verb
*hv
;
409 hv
= spec
->init_verbs
[i
];
412 switch (hv
->param
^ AC_USRSP_EN
) {
413 case CONEXANT_HP_EVENT
:
414 err
= snd_hda_input_jack_add(codec
, hv
->nid
,
415 SND_JACK_HEADPHONE
, NULL
);
416 snd_hda_input_jack_report(codec
, hv
->nid
);
418 case CXT5051_PORTC_EVENT
:
419 case CONEXANT_MIC_EVENT
:
420 err
= snd_hda_input_jack_add(codec
, hv
->nid
,
421 SND_JACK_MICROPHONE
, NULL
);
422 snd_hda_input_jack_report(codec
, hv
->nid
);
430 #endif /* CONFIG_SND_HDA_INPUT_JACK */
434 static int conexant_init(struct hda_codec
*codec
)
436 struct conexant_spec
*spec
= codec
->spec
;
439 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
440 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
444 static void conexant_free(struct hda_codec
*codec
)
446 snd_hda_input_jack_free(codec
);
447 snd_hda_detach_beep_device(codec
);
451 static const struct snd_kcontrol_new cxt_capture_mixers
[] = {
453 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
454 .name
= "Capture Source",
455 .info
= conexant_mux_enum_info
,
456 .get
= conexant_mux_enum_get
,
457 .put
= conexant_mux_enum_put
462 #ifdef CONFIG_SND_HDA_INPUT_BEEP
463 /* additional beep mixers; the actual parameters are overwritten at build */
464 static const struct snd_kcontrol_new cxt_beep_mixer
[] = {
465 HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT
),
466 HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT
),
471 static const char * const slave_vols
[] = {
472 "Headphone Playback Volume",
473 "Speaker Playback Volume",
477 static const char * const slave_sws
[] = {
478 "Headphone Playback Switch",
479 "Speaker Playback Switch",
483 static int conexant_build_controls(struct hda_codec
*codec
)
485 struct conexant_spec
*spec
= codec
->spec
;
489 for (i
= 0; i
< spec
->num_mixers
; i
++) {
490 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
494 if (spec
->multiout
.dig_out_nid
) {
495 err
= snd_hda_create_spdif_out_ctls(codec
,
496 spec
->multiout
.dig_out_nid
);
499 err
= snd_hda_create_spdif_share_sw(codec
,
503 spec
->multiout
.share_spdif
= 1;
505 if (spec
->dig_in_nid
) {
506 err
= snd_hda_create_spdif_in_ctls(codec
,spec
->dig_in_nid
);
511 /* if we have no master control, let's create it */
512 if (spec
->vmaster_nid
&&
513 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
514 unsigned int vmaster_tlv
[4];
515 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
516 HDA_OUTPUT
, vmaster_tlv
);
517 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
518 vmaster_tlv
, slave_vols
);
522 if (spec
->vmaster_nid
&&
523 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
524 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
530 if (spec
->input_mux
) {
531 err
= snd_hda_add_new_ctls(codec
, cxt_capture_mixers
);
536 #ifdef CONFIG_SND_HDA_INPUT_BEEP
537 /* create beep controls if needed */
538 if (spec
->beep_amp
) {
539 const struct snd_kcontrol_new
*knew
;
540 for (knew
= cxt_beep_mixer
; knew
->name
; knew
++) {
541 struct snd_kcontrol
*kctl
;
542 kctl
= snd_ctl_new1(knew
, codec
);
545 kctl
->private_value
= spec
->beep_amp
;
546 err
= snd_hda_ctl_add(codec
, 0, kctl
);
556 #ifdef CONFIG_SND_HDA_POWER_SAVE
557 static int conexant_suspend(struct hda_codec
*codec
, pm_message_t state
)
559 snd_hda_shutup_pins(codec
);
564 static const struct hda_codec_ops conexant_patch_ops
= {
565 .build_controls
= conexant_build_controls
,
566 .build_pcms
= conexant_build_pcms
,
567 .init
= conexant_init
,
568 .free
= conexant_free
,
569 #ifdef CONFIG_SND_HDA_POWER_SAVE
570 .suspend
= conexant_suspend
,
572 .reboot_notify
= snd_hda_shutup_pins
,
575 #ifdef CONFIG_SND_HDA_INPUT_BEEP
576 #define set_beep_amp(spec, nid, idx, dir) \
577 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir))
579 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
582 static int patch_conexant_auto(struct hda_codec
*codec
);
585 * the private value = nid | (invert << 8)
588 #define cxt_eapd_info snd_ctl_boolean_mono_info
590 static int cxt_eapd_get(struct snd_kcontrol
*kcontrol
,
591 struct snd_ctl_elem_value
*ucontrol
)
593 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
594 struct conexant_spec
*spec
= codec
->spec
;
595 int invert
= (kcontrol
->private_value
>> 8) & 1;
597 ucontrol
->value
.integer
.value
[0] = !spec
->cur_eapd
;
599 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
604 static int cxt_eapd_put(struct snd_kcontrol
*kcontrol
,
605 struct snd_ctl_elem_value
*ucontrol
)
607 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
608 struct conexant_spec
*spec
= codec
->spec
;
609 int invert
= (kcontrol
->private_value
>> 8) & 1;
610 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
613 eapd
= !!ucontrol
->value
.integer
.value
[0];
616 if (eapd
== spec
->cur_eapd
)
619 spec
->cur_eapd
= eapd
;
620 snd_hda_codec_write_cache(codec
, nid
,
621 0, AC_VERB_SET_EAPD_BTLENABLE
,
626 /* controls for test mode */
627 #ifdef CONFIG_SND_DEBUG
629 #define CXT_EAPD_SWITCH(xname, nid, mask) \
630 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
631 .info = cxt_eapd_info, \
632 .get = cxt_eapd_get, \
633 .put = cxt_eapd_put, \
634 .private_value = nid | (mask<<16) }
638 static int conexant_ch_mode_info(struct snd_kcontrol
*kcontrol
,
639 struct snd_ctl_elem_info
*uinfo
)
641 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
642 struct conexant_spec
*spec
= codec
->spec
;
643 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
644 spec
->num_channel_mode
);
647 static int conexant_ch_mode_get(struct snd_kcontrol
*kcontrol
,
648 struct snd_ctl_elem_value
*ucontrol
)
650 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
651 struct conexant_spec
*spec
= codec
->spec
;
652 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
653 spec
->num_channel_mode
,
654 spec
->multiout
.max_channels
);
657 static int conexant_ch_mode_put(struct snd_kcontrol
*kcontrol
,
658 struct snd_ctl_elem_value
*ucontrol
)
660 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
661 struct conexant_spec
*spec
= codec
->spec
;
662 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
663 spec
->num_channel_mode
,
664 &spec
->multiout
.max_channels
);
665 if (err
>= 0 && spec
->need_dac_fix
)
666 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
670 #define CXT_PIN_MODE(xname, nid, dir) \
671 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
672 .info = conexant_ch_mode_info, \
673 .get = conexant_ch_mode_get, \
674 .put = conexant_ch_mode_put, \
675 .private_value = nid | (dir<<16) }
677 #endif /* CONFIG_SND_DEBUG */
679 /* Conexant 5045 specific */
681 static const hda_nid_t cxt5045_dac_nids
[1] = { 0x19 };
682 static const hda_nid_t cxt5045_adc_nids
[1] = { 0x1a };
683 static const hda_nid_t cxt5045_capsrc_nids
[1] = { 0x1a };
684 #define CXT5045_SPDIF_OUT 0x18
686 static const struct hda_channel_mode cxt5045_modes
[1] = {
690 static const struct hda_input_mux cxt5045_capture_source
= {
698 static const struct hda_input_mux cxt5045_capture_source_benq
= {
709 static const struct hda_input_mux cxt5045_capture_source_hp530
= {
717 /* turn on/off EAPD (+ mute HP) as a master switch */
718 static int cxt5045_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
719 struct snd_ctl_elem_value
*ucontrol
)
721 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
722 struct conexant_spec
*spec
= codec
->spec
;
725 if (!cxt_eapd_put(kcontrol
, ucontrol
))
728 /* toggle internal speakers mute depending of presence of
731 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
732 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
735 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
736 snd_hda_codec_amp_stereo(codec
, 0x11, HDA_OUTPUT
, 0,
741 /* bind volumes of both NID 0x10 and 0x11 */
742 static const struct hda_bind_ctls cxt5045_hp_bind_master_vol
= {
743 .ops
= &snd_hda_bind_vol
,
745 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT
),
746 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT
),
751 /* toggle input of built-in and mic jack appropriately */
752 static void cxt5045_hp_automic(struct hda_codec
*codec
)
754 static const struct hda_verb mic_jack_on
[] = {
755 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
756 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
759 static const struct hda_verb mic_jack_off
[] = {
760 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
761 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
764 unsigned int present
;
766 present
= snd_hda_jack_detect(codec
, 0x12);
768 snd_hda_sequence_write(codec
, mic_jack_on
);
770 snd_hda_sequence_write(codec
, mic_jack_off
);
774 /* mute internal speaker if HP is plugged */
775 static void cxt5045_hp_automute(struct hda_codec
*codec
)
777 struct conexant_spec
*spec
= codec
->spec
;
780 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x11);
782 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
783 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
787 /* unsolicited event for HP jack sensing */
788 static void cxt5045_hp_unsol_event(struct hda_codec
*codec
,
793 case CONEXANT_HP_EVENT
:
794 cxt5045_hp_automute(codec
);
796 case CONEXANT_MIC_EVENT
:
797 cxt5045_hp_automic(codec
);
803 static const struct snd_kcontrol_new cxt5045_mixers
[] = {
804 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
805 HDA_CODEC_MUTE("Internal Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
806 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
807 HDA_CODEC_MUTE("Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
808 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
809 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
810 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
811 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
812 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
813 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
814 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
816 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
817 .name
= "Master Playback Switch",
818 .info
= cxt_eapd_info
,
820 .put
= cxt5045_hp_master_sw_put
,
821 .private_value
= 0x10,
827 static const struct snd_kcontrol_new cxt5045_benq_mixers
[] = {
828 HDA_CODEC_VOLUME("CD Capture Volume", 0x1a, 0x04, HDA_INPUT
),
829 HDA_CODEC_MUTE("CD Capture Switch", 0x1a, 0x04, HDA_INPUT
),
830 HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x4, HDA_INPUT
),
831 HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x4, HDA_INPUT
),
833 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT
),
834 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT
),
835 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT
),
836 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT
),
838 HDA_CODEC_VOLUME("Mixer Capture Volume", 0x1a, 0x0, HDA_INPUT
),
839 HDA_CODEC_MUTE("Mixer Capture Switch", 0x1a, 0x0, HDA_INPUT
),
844 static const struct snd_kcontrol_new cxt5045_mixers_hp530
[] = {
845 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
846 HDA_CODEC_MUTE("Internal Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
847 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
848 HDA_CODEC_MUTE("Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
849 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
850 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
851 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
852 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
853 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
854 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
855 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
857 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
858 .name
= "Master Playback Switch",
859 .info
= cxt_eapd_info
,
861 .put
= cxt5045_hp_master_sw_put
,
862 .private_value
= 0x10,
868 static const struct hda_verb cxt5045_init_verbs
[] = {
870 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
871 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
873 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
874 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
875 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
876 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
877 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
878 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
879 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
880 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
881 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
882 /* Record selector: Internal mic */
883 {0x1a, AC_VERB_SET_CONNECT_SEL
,0x1},
884 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
885 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
886 /* SPDIF route: PCM */
887 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
888 { 0x13, AC_VERB_SET_CONNECT_SEL
, 0x0 },
890 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2 }, /* default on */
894 static const struct hda_verb cxt5045_benq_init_verbs
[] = {
895 /* Internal Mic, Mic */
896 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
897 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
898 /* Line In,HP, Amp */
899 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
900 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
901 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
902 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
903 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
904 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
905 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
906 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
907 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
908 /* Record selector: Internal mic */
909 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x1},
910 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
911 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
912 /* SPDIF route: PCM */
913 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
914 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0},
916 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
920 static const struct hda_verb cxt5045_hp_sense_init_verbs
[] = {
921 /* pin sensing on HP jack */
922 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
926 static const struct hda_verb cxt5045_mic_sense_init_verbs
[] = {
927 /* pin sensing on HP jack */
928 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
932 #ifdef CONFIG_SND_DEBUG
933 /* Test configuration for debugging, modelled after the ALC260 test
936 static const struct hda_input_mux cxt5045_test_capture_source
= {
941 { "LINE1 pin", 0x2 },
942 { "HP-OUT pin", 0x3 },
947 static const struct snd_kcontrol_new cxt5045_test_mixer
[] = {
949 /* Output controls */
950 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
951 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
952 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
953 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
954 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
955 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
957 /* Modes for retasking pin widgets */
958 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT
),
959 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT
),
961 /* EAPD Switch Control */
962 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
964 /* Loopback mixer controls */
966 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT
),
967 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT
),
968 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT
),
969 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT
),
970 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT
),
971 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT
),
972 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT
),
973 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT
),
974 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT
),
975 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT
),
977 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
978 .name
= "Input Source",
979 .info
= conexant_mux_enum_info
,
980 .get
= conexant_mux_enum_get
,
981 .put
= conexant_mux_enum_put
,
983 /* Audio input controls */
984 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT
),
985 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT
),
986 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT
),
987 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT
),
988 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT
),
989 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT
),
990 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT
),
991 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT
),
992 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT
),
993 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT
),
997 static const struct hda_verb cxt5045_test_init_verbs
[] = {
998 /* Set connections */
999 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1000 { 0x11, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1001 { 0x12, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1002 /* Enable retasking pins as output, initially without power amp */
1003 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1004 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1006 /* Disable digital (SPDIF) pins initially, but users can enable
1007 * them via a mixer switch. In the case of SPDIF-out, this initverb
1008 * payload also sets the generation to 0, output to be in "consumer"
1009 * PCM format, copyright asserted, no pre-emphasis and no validity
1012 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1013 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1015 /* Start with output sum widgets muted and their output gains at min */
1016 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1017 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1019 /* Unmute retasking pin widget output buffers since the default
1020 * state appears to be output. As the pin mode is changed by the
1021 * user the pin mode control will take care of enabling the pin's
1022 * input/output buffers as needed.
1024 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1025 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1027 /* Mute capture amp left and right */
1028 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1030 /* Set ADC connection select to match default mixer setting (mic1
1033 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1034 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x00},
1036 /* Mute all inputs to mixer widget (even unconnected ones) */
1037 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* Mixer pin */
1038 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* Mic1 pin */
1039 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* Line pin */
1040 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* HP pin */
1041 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1048 /* initialize jack-sensing, too */
1049 static int cxt5045_init(struct hda_codec
*codec
)
1051 conexant_init(codec
);
1052 cxt5045_hp_automute(codec
);
1058 CXT5045_LAPTOP_HPSENSE
,
1059 CXT5045_LAPTOP_MICSENSE
,
1060 CXT5045_LAPTOP_HPMICSENSE
,
1062 CXT5045_LAPTOP_HP530
,
1063 #ifdef CONFIG_SND_DEBUG
1070 static const char * const cxt5045_models
[CXT5045_MODELS
] = {
1071 [CXT5045_LAPTOP_HPSENSE
] = "laptop-hpsense",
1072 [CXT5045_LAPTOP_MICSENSE
] = "laptop-micsense",
1073 [CXT5045_LAPTOP_HPMICSENSE
] = "laptop-hpmicsense",
1074 [CXT5045_BENQ
] = "benq",
1075 [CXT5045_LAPTOP_HP530
] = "laptop-hp530",
1076 #ifdef CONFIG_SND_DEBUG
1077 [CXT5045_TEST
] = "test",
1079 [CXT5045_AUTO
] = "auto",
1082 static const struct snd_pci_quirk cxt5045_cfg_tbl
[] = {
1083 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530
),
1084 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1085 CXT5045_LAPTOP_HPSENSE
),
1086 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE
),
1087 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ
),
1088 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE
),
1089 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE
),
1090 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
1091 CXT5045_LAPTOP_HPMICSENSE
),
1092 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1093 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1094 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1095 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
1096 CXT5045_LAPTOP_HPMICSENSE
),
1097 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE
),
1101 static int patch_cxt5045(struct hda_codec
*codec
)
1103 struct conexant_spec
*spec
;
1106 board_config
= snd_hda_check_board_config(codec
, CXT5045_MODELS
,
1109 #if 0 /* use the old method just for safety */
1110 if (board_config
< 0)
1111 board_config
= CXT5045_AUTO
;
1113 if (board_config
== CXT5045_AUTO
)
1114 return patch_conexant_auto(codec
);
1116 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1120 codec
->pin_amp_workaround
= 1;
1122 spec
->multiout
.max_channels
= 2;
1123 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5045_dac_nids
);
1124 spec
->multiout
.dac_nids
= cxt5045_dac_nids
;
1125 spec
->multiout
.dig_out_nid
= CXT5045_SPDIF_OUT
;
1126 spec
->num_adc_nids
= 1;
1127 spec
->adc_nids
= cxt5045_adc_nids
;
1128 spec
->capsrc_nids
= cxt5045_capsrc_nids
;
1129 spec
->input_mux
= &cxt5045_capture_source
;
1130 spec
->num_mixers
= 1;
1131 spec
->mixers
[0] = cxt5045_mixers
;
1132 spec
->num_init_verbs
= 1;
1133 spec
->init_verbs
[0] = cxt5045_init_verbs
;
1134 spec
->spdif_route
= 0;
1135 spec
->num_channel_mode
= ARRAY_SIZE(cxt5045_modes
);
1136 spec
->channel_mode
= cxt5045_modes
;
1138 set_beep_amp(spec
, 0x16, 0, 1);
1140 codec
->patch_ops
= conexant_patch_ops
;
1142 switch (board_config
) {
1143 case CXT5045_LAPTOP_HPSENSE
:
1144 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1145 spec
->input_mux
= &cxt5045_capture_source
;
1146 spec
->num_init_verbs
= 2;
1147 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1148 spec
->mixers
[0] = cxt5045_mixers
;
1149 codec
->patch_ops
.init
= cxt5045_init
;
1151 case CXT5045_LAPTOP_MICSENSE
:
1152 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1153 spec
->input_mux
= &cxt5045_capture_source
;
1154 spec
->num_init_verbs
= 2;
1155 spec
->init_verbs
[1] = cxt5045_mic_sense_init_verbs
;
1156 spec
->mixers
[0] = cxt5045_mixers
;
1157 codec
->patch_ops
.init
= cxt5045_init
;
1160 case CXT5045_LAPTOP_HPMICSENSE
:
1161 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1162 spec
->input_mux
= &cxt5045_capture_source
;
1163 spec
->num_init_verbs
= 3;
1164 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1165 spec
->init_verbs
[2] = cxt5045_mic_sense_init_verbs
;
1166 spec
->mixers
[0] = cxt5045_mixers
;
1167 codec
->patch_ops
.init
= cxt5045_init
;
1170 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1171 spec
->input_mux
= &cxt5045_capture_source_benq
;
1172 spec
->num_init_verbs
= 1;
1173 spec
->init_verbs
[0] = cxt5045_benq_init_verbs
;
1174 spec
->mixers
[0] = cxt5045_mixers
;
1175 spec
->mixers
[1] = cxt5045_benq_mixers
;
1176 spec
->num_mixers
= 2;
1177 codec
->patch_ops
.init
= cxt5045_init
;
1179 case CXT5045_LAPTOP_HP530
:
1180 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1181 spec
->input_mux
= &cxt5045_capture_source_hp530
;
1182 spec
->num_init_verbs
= 2;
1183 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1184 spec
->mixers
[0] = cxt5045_mixers_hp530
;
1185 codec
->patch_ops
.init
= cxt5045_init
;
1187 #ifdef CONFIG_SND_DEBUG
1189 spec
->input_mux
= &cxt5045_test_capture_source
;
1190 spec
->mixers
[0] = cxt5045_test_mixer
;
1191 spec
->init_verbs
[0] = cxt5045_test_init_verbs
;
1197 switch (codec
->subsystem_id
>> 16) {
1202 /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have
1203 * really bad sound over 0dB on NID 0x17. Fix max PCM level to
1204 * 0 dB (originally it has 0x2b steps with 0dB offset 0x14)
1206 snd_hda_override_amp_caps(codec
, 0x17, HDA_INPUT
,
1207 (0x14 << AC_AMPCAP_OFFSET_SHIFT
) |
1208 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1209 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1210 (1 << AC_AMPCAP_MUTE_SHIFT
));
1215 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
1221 /* Conexant 5047 specific */
1222 #define CXT5047_SPDIF_OUT 0x11
1224 static const hda_nid_t cxt5047_dac_nids
[1] = { 0x10 }; /* 0x1c */
1225 static const hda_nid_t cxt5047_adc_nids
[1] = { 0x12 };
1226 static const hda_nid_t cxt5047_capsrc_nids
[1] = { 0x1a };
1228 static const struct hda_channel_mode cxt5047_modes
[1] = {
1232 static const struct hda_input_mux cxt5047_toshiba_capture_source
= {
1240 /* turn on/off EAPD (+ mute HP) as a master switch */
1241 static int cxt5047_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1242 struct snd_ctl_elem_value
*ucontrol
)
1244 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1245 struct conexant_spec
*spec
= codec
->spec
;
1248 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1251 /* toggle internal speakers mute depending of presence of
1252 * the headphone jack
1254 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
1255 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1256 * pin widgets unlike other codecs. In this case, we need to
1257 * set index 0x01 for the volume from the mixer amp 0x19.
1259 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1260 HDA_AMP_MUTE
, bits
);
1261 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
1262 snd_hda_codec_amp_stereo(codec
, 0x13, HDA_OUTPUT
, 0,
1263 HDA_AMP_MUTE
, bits
);
1267 /* mute internal speaker if HP is plugged */
1268 static void cxt5047_hp_automute(struct hda_codec
*codec
)
1270 struct conexant_spec
*spec
= codec
->spec
;
1273 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x13);
1275 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
1276 /* See the note in cxt5047_hp_master_sw_put */
1277 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1278 HDA_AMP_MUTE
, bits
);
1281 /* toggle input of built-in and mic jack appropriately */
1282 static void cxt5047_hp_automic(struct hda_codec
*codec
)
1284 static const struct hda_verb mic_jack_on
[] = {
1285 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1286 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1289 static const struct hda_verb mic_jack_off
[] = {
1290 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1291 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1294 unsigned int present
;
1296 present
= snd_hda_jack_detect(codec
, 0x15);
1298 snd_hda_sequence_write(codec
, mic_jack_on
);
1300 snd_hda_sequence_write(codec
, mic_jack_off
);
1303 /* unsolicited event for HP jack sensing */
1304 static void cxt5047_hp_unsol_event(struct hda_codec
*codec
,
1307 switch (res
>> 26) {
1308 case CONEXANT_HP_EVENT
:
1309 cxt5047_hp_automute(codec
);
1311 case CONEXANT_MIC_EVENT
:
1312 cxt5047_hp_automic(codec
);
1317 static const struct snd_kcontrol_new cxt5047_base_mixers
[] = {
1318 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT
),
1319 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT
),
1320 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1321 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT
),
1322 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT
),
1323 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT
),
1324 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT
),
1326 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1327 .name
= "Master Playback Switch",
1328 .info
= cxt_eapd_info
,
1329 .get
= cxt_eapd_get
,
1330 .put
= cxt5047_hp_master_sw_put
,
1331 .private_value
= 0x13,
1337 static const struct snd_kcontrol_new cxt5047_hp_spk_mixers
[] = {
1338 /* See the note in cxt5047_hp_master_sw_put */
1339 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT
),
1340 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1344 static const struct snd_kcontrol_new cxt5047_hp_only_mixers
[] = {
1345 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1349 static const struct hda_verb cxt5047_init_verbs
[] = {
1350 /* Line in, Mic, Built-in Mic */
1351 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1352 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1353 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1355 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1356 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* mixer(0x19) */
1357 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mixer(0x19) */
1358 /* Record selector: Mic */
1359 {0x12, AC_VERB_SET_CONNECT_SEL
,0x03},
1360 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
,
1361 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
1362 {0x1A, AC_VERB_SET_CONNECT_SEL
,0x02},
1363 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1364 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x00},
1365 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1366 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x03},
1367 /* SPDIF route: PCM */
1368 { 0x18, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1369 /* Enable unsolicited events */
1370 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
1371 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1375 /* configuration for Toshiba Laptops */
1376 static const struct hda_verb cxt5047_toshiba_init_verbs
[] = {
1377 {0x13, AC_VERB_SET_EAPD_BTLENABLE
, 0x0}, /* default off */
1381 /* Test configuration for debugging, modelled after the ALC260 test
1384 #ifdef CONFIG_SND_DEBUG
1385 static const struct hda_input_mux cxt5047_test_capture_source
= {
1388 { "LINE1 pin", 0x0 },
1389 { "MIC1 pin", 0x1 },
1390 { "MIC2 pin", 0x2 },
1395 static const struct snd_kcontrol_new cxt5047_test_mixer
[] = {
1397 /* Output only controls */
1398 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT
),
1399 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT
),
1400 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT
),
1401 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT
),
1402 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1403 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1404 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1405 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1406 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT
),
1407 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT
),
1408 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
1409 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
1411 /* Modes for retasking pin widgets */
1412 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT
),
1413 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT
),
1415 /* EAPD Switch Control */
1416 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1418 /* Loopback mixer controls */
1419 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT
),
1420 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT
),
1421 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT
),
1422 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT
),
1423 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT
),
1424 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT
),
1425 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT
),
1426 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT
),
1428 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT
),
1429 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT
),
1430 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT
),
1431 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT
),
1432 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT
),
1433 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT
),
1434 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT
),
1435 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT
),
1437 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1438 .name
= "Input Source",
1439 .info
= conexant_mux_enum_info
,
1440 .get
= conexant_mux_enum_get
,
1441 .put
= conexant_mux_enum_put
,
1443 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1448 static const struct hda_verb cxt5047_test_init_verbs
[] = {
1449 /* Enable retasking pins as output, initially without power amp */
1450 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1451 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1452 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1454 /* Disable digital (SPDIF) pins initially, but users can enable
1455 * them via a mixer switch. In the case of SPDIF-out, this initverb
1456 * payload also sets the generation to 0, output to be in "consumer"
1457 * PCM format, copyright asserted, no pre-emphasis and no validity
1460 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1462 /* Ensure mic1, mic2, line1 pin widgets take input from the
1463 * OUT1 sum bus when acting as an output.
1465 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0},
1466 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0},
1468 /* Start with output sum widgets muted and their output gains at min */
1469 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1470 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1472 /* Unmute retasking pin widget output buffers since the default
1473 * state appears to be output. As the pin mode is changed by the
1474 * user the pin mode control will take care of enabling the pin's
1475 * input/output buffers as needed.
1477 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1478 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1479 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1481 /* Mute capture amp left and right */
1482 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1484 /* Set ADC connection select to match default mixer setting (mic1
1487 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x00},
1489 /* Mute all inputs to mixer widget (even unconnected ones) */
1490 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* mic1 pin */
1491 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* mic2 pin */
1492 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* line1 pin */
1493 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* line2 pin */
1494 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1495 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1496 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)}, /* Line-out pin */
1497 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)}, /* HP-pin pin */
1504 /* initialize jack-sensing, too */
1505 static int cxt5047_hp_init(struct hda_codec
*codec
)
1507 conexant_init(codec
);
1508 cxt5047_hp_automute(codec
);
1514 CXT5047_LAPTOP
, /* Laptops w/o EAPD support */
1515 CXT5047_LAPTOP_HP
, /* Some HP laptops */
1516 CXT5047_LAPTOP_EAPD
, /* Laptops with EAPD support */
1517 #ifdef CONFIG_SND_DEBUG
1524 static const char * const cxt5047_models
[CXT5047_MODELS
] = {
1525 [CXT5047_LAPTOP
] = "laptop",
1526 [CXT5047_LAPTOP_HP
] = "laptop-hp",
1527 [CXT5047_LAPTOP_EAPD
] = "laptop-eapd",
1528 #ifdef CONFIG_SND_DEBUG
1529 [CXT5047_TEST
] = "test",
1531 [CXT5047_AUTO
] = "auto",
1534 static const struct snd_pci_quirk cxt5047_cfg_tbl
[] = {
1535 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP
),
1536 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1538 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD
),
1542 static int patch_cxt5047(struct hda_codec
*codec
)
1544 struct conexant_spec
*spec
;
1547 board_config
= snd_hda_check_board_config(codec
, CXT5047_MODELS
,
1550 #if 0 /* not enabled as default, as BIOS often broken for this codec */
1551 if (board_config
< 0)
1552 board_config
= CXT5047_AUTO
;
1554 if (board_config
== CXT5047_AUTO
)
1555 return patch_conexant_auto(codec
);
1557 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1561 codec
->pin_amp_workaround
= 1;
1563 spec
->multiout
.max_channels
= 2;
1564 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5047_dac_nids
);
1565 spec
->multiout
.dac_nids
= cxt5047_dac_nids
;
1566 spec
->multiout
.dig_out_nid
= CXT5047_SPDIF_OUT
;
1567 spec
->num_adc_nids
= 1;
1568 spec
->adc_nids
= cxt5047_adc_nids
;
1569 spec
->capsrc_nids
= cxt5047_capsrc_nids
;
1570 spec
->num_mixers
= 1;
1571 spec
->mixers
[0] = cxt5047_base_mixers
;
1572 spec
->num_init_verbs
= 1;
1573 spec
->init_verbs
[0] = cxt5047_init_verbs
;
1574 spec
->spdif_route
= 0;
1575 spec
->num_channel_mode
= ARRAY_SIZE(cxt5047_modes
),
1576 spec
->channel_mode
= cxt5047_modes
,
1578 codec
->patch_ops
= conexant_patch_ops
;
1580 switch (board_config
) {
1581 case CXT5047_LAPTOP
:
1582 spec
->num_mixers
= 2;
1583 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1584 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1586 case CXT5047_LAPTOP_HP
:
1587 spec
->num_mixers
= 2;
1588 spec
->mixers
[1] = cxt5047_hp_only_mixers
;
1589 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1590 codec
->patch_ops
.init
= cxt5047_hp_init
;
1592 case CXT5047_LAPTOP_EAPD
:
1593 spec
->input_mux
= &cxt5047_toshiba_capture_source
;
1594 spec
->num_mixers
= 2;
1595 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1596 spec
->num_init_verbs
= 2;
1597 spec
->init_verbs
[1] = cxt5047_toshiba_init_verbs
;
1598 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1600 #ifdef CONFIG_SND_DEBUG
1602 spec
->input_mux
= &cxt5047_test_capture_source
;
1603 spec
->mixers
[0] = cxt5047_test_mixer
;
1604 spec
->init_verbs
[0] = cxt5047_test_init_verbs
;
1605 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1608 spec
->vmaster_nid
= 0x13;
1610 switch (codec
->subsystem_id
>> 16) {
1612 /* HP laptops have really bad sound over 0 dB on NID 0x10.
1613 * Fix max PCM level to 0 dB (originally it has 0x1e steps
1614 * with 0 dB offset 0x17)
1616 snd_hda_override_amp_caps(codec
, 0x10, HDA_INPUT
,
1617 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
1618 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1619 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1620 (1 << AC_AMPCAP_MUTE_SHIFT
));
1627 /* Conexant 5051 specific */
1628 static const hda_nid_t cxt5051_dac_nids
[1] = { 0x10 };
1629 static const hda_nid_t cxt5051_adc_nids
[2] = { 0x14, 0x15 };
1631 static const struct hda_channel_mode cxt5051_modes
[1] = {
1635 static void cxt5051_update_speaker(struct hda_codec
*codec
)
1637 struct conexant_spec
*spec
= codec
->spec
;
1638 unsigned int pinctl
;
1640 pinctl
= (spec
->hp_present
&& spec
->cur_eapd
) ? PIN_HP
: 0;
1641 snd_hda_codec_write(codec
, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1644 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1645 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1647 /* on ideapad there is an aditional speaker (subwoofer) to mute */
1649 snd_hda_codec_write(codec
, 0x1b, 0,
1650 AC_VERB_SET_PIN_WIDGET_CONTROL
,
1654 /* turn on/off EAPD (+ mute HP) as a master switch */
1655 static int cxt5051_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1656 struct snd_ctl_elem_value
*ucontrol
)
1658 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1660 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1662 cxt5051_update_speaker(codec
);
1666 /* toggle input of built-in and mic jack appropriately */
1667 static void cxt5051_portb_automic(struct hda_codec
*codec
)
1669 struct conexant_spec
*spec
= codec
->spec
;
1670 unsigned int present
;
1672 if (!(spec
->auto_mic
& AUTO_MIC_PORTB
))
1674 present
= snd_hda_jack_detect(codec
, 0x17);
1675 snd_hda_codec_write(codec
, 0x14, 0,
1676 AC_VERB_SET_CONNECT_SEL
,
1677 present
? 0x01 : 0x00);
1680 /* switch the current ADC according to the jack state */
1681 static void cxt5051_portc_automic(struct hda_codec
*codec
)
1683 struct conexant_spec
*spec
= codec
->spec
;
1684 unsigned int present
;
1687 if (!(spec
->auto_mic
& AUTO_MIC_PORTC
))
1689 present
= snd_hda_jack_detect(codec
, 0x18);
1691 spec
->cur_adc_idx
= 1;
1693 spec
->cur_adc_idx
= 0;
1694 new_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
1695 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
1696 /* stream is running, let's swap the current ADC */
1697 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
1698 spec
->cur_adc
= new_adc
;
1699 snd_hda_codec_setup_stream(codec
, new_adc
,
1700 spec
->cur_adc_stream_tag
, 0,
1701 spec
->cur_adc_format
);
1705 /* mute internal speaker if HP is plugged */
1706 static void cxt5051_hp_automute(struct hda_codec
*codec
)
1708 struct conexant_spec
*spec
= codec
->spec
;
1710 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x16);
1711 cxt5051_update_speaker(codec
);
1714 /* unsolicited event for HP jack sensing */
1715 static void cxt5051_hp_unsol_event(struct hda_codec
*codec
,
1718 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
1719 switch (res
>> 26) {
1720 case CONEXANT_HP_EVENT
:
1721 cxt5051_hp_automute(codec
);
1723 case CXT5051_PORTB_EVENT
:
1724 cxt5051_portb_automic(codec
);
1726 case CXT5051_PORTC_EVENT
:
1727 cxt5051_portc_automic(codec
);
1730 snd_hda_input_jack_report(codec
, nid
);
1733 static const struct snd_kcontrol_new cxt5051_playback_mixers
[] = {
1734 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1736 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1737 .name
= "Master Playback Switch",
1738 .info
= cxt_eapd_info
,
1739 .get
= cxt_eapd_get
,
1740 .put
= cxt5051_hp_master_sw_put
,
1741 .private_value
= 0x1a,
1746 static const struct snd_kcontrol_new cxt5051_capture_mixers
[] = {
1747 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1748 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1749 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT
),
1750 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT
),
1751 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT
),
1752 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT
),
1756 static const struct snd_kcontrol_new cxt5051_hp_mixers
[] = {
1757 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1758 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1759 HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT
),
1760 HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT
),
1764 static const struct snd_kcontrol_new cxt5051_hp_dv6736_mixers
[] = {
1765 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT
),
1766 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT
),
1770 static const struct snd_kcontrol_new cxt5051_f700_mixers
[] = {
1771 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT
),
1772 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT
),
1776 static const struct snd_kcontrol_new cxt5051_toshiba_mixers
[] = {
1777 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1778 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1779 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT
),
1780 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT
),
1784 static const struct hda_verb cxt5051_init_verbs
[] = {
1786 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1787 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1788 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1789 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1790 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1791 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1793 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1794 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1796 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1797 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1799 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1800 /* Record selector: Internal mic */
1801 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1802 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1803 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1804 /* SPDIF route: PCM */
1805 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1806 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1808 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1809 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1813 static const struct hda_verb cxt5051_hp_dv6736_init_verbs
[] = {
1815 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1816 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1817 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1818 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1820 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1821 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1823 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1824 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1826 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1827 /* Record selector: Internal mic */
1828 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1829 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1830 /* SPDIF route: PCM */
1831 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1833 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1834 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1838 static const struct hda_verb cxt5051_lenovo_x200_init_verbs
[] = {
1840 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1841 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1842 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1843 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1844 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1845 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1847 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1848 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1850 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1851 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1853 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1854 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00},
1856 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1857 /* Record selector: Internal mic */
1858 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1859 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1860 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1861 /* SPDIF route: PCM */
1862 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
}, /* needed for W500 Advanced Mini Dock 250410 */
1863 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1865 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1866 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1867 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1871 static const struct hda_verb cxt5051_f700_init_verbs
[] = {
1873 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1874 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1875 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1876 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1878 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1879 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1881 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1882 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1884 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1885 /* Record selector: Internal mic */
1886 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1887 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1888 /* SPDIF route: PCM */
1889 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1891 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1892 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1896 static void cxt5051_init_mic_port(struct hda_codec
*codec
, hda_nid_t nid
,
1899 snd_hda_codec_write(codec
, nid
, 0,
1900 AC_VERB_SET_UNSOLICITED_ENABLE
,
1901 AC_USRSP_EN
| event
);
1902 snd_hda_input_jack_add(codec
, nid
, SND_JACK_MICROPHONE
, NULL
);
1903 snd_hda_input_jack_report(codec
, nid
);
1906 static const struct hda_verb cxt5051_ideapad_init_verbs
[] = {
1908 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1909 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0x00},
1913 /* initialize jack-sensing, too */
1914 static int cxt5051_init(struct hda_codec
*codec
)
1916 struct conexant_spec
*spec
= codec
->spec
;
1918 conexant_init(codec
);
1919 conexant_init_jacks(codec
);
1921 if (spec
->auto_mic
& AUTO_MIC_PORTB
)
1922 cxt5051_init_mic_port(codec
, 0x17, CXT5051_PORTB_EVENT
);
1923 if (spec
->auto_mic
& AUTO_MIC_PORTC
)
1924 cxt5051_init_mic_port(codec
, 0x18, CXT5051_PORTC_EVENT
);
1926 if (codec
->patch_ops
.unsol_event
) {
1927 cxt5051_hp_automute(codec
);
1928 cxt5051_portb_automic(codec
);
1929 cxt5051_portc_automic(codec
);
1936 CXT5051_LAPTOP
, /* Laptops w/ EAPD support */
1937 CXT5051_HP
, /* no docking */
1938 CXT5051_HP_DV6736
, /* HP without mic switch */
1939 CXT5051_LENOVO_X200
, /* Lenovo X200 laptop, also used for Advanced Mini Dock 250410 */
1940 CXT5051_F700
, /* HP Compaq Presario F700 */
1941 CXT5051_TOSHIBA
, /* Toshiba M300 & co */
1942 CXT5051_IDEAPAD
, /* Lenovo IdeaPad Y430 */
1943 CXT5051_AUTO
, /* auto-parser */
1947 static const char *const cxt5051_models
[CXT5051_MODELS
] = {
1948 [CXT5051_LAPTOP
] = "laptop",
1949 [CXT5051_HP
] = "hp",
1950 [CXT5051_HP_DV6736
] = "hp-dv6736",
1951 [CXT5051_LENOVO_X200
] = "lenovo-x200",
1952 [CXT5051_F700
] = "hp-700",
1953 [CXT5051_TOSHIBA
] = "toshiba",
1954 [CXT5051_IDEAPAD
] = "ideapad",
1955 [CXT5051_AUTO
] = "auto",
1958 static const struct snd_pci_quirk cxt5051_cfg_tbl
[] = {
1959 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736
),
1960 SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP
),
1961 SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700
),
1962 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA
),
1963 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1965 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP
),
1966 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200
),
1967 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD
),
1971 static int patch_cxt5051(struct hda_codec
*codec
)
1973 struct conexant_spec
*spec
;
1976 board_config
= snd_hda_check_board_config(codec
, CXT5051_MODELS
,
1979 #if 0 /* use the old method just for safety */
1980 if (board_config
< 0)
1981 board_config
= CXT5051_AUTO
;
1983 if (board_config
== CXT5051_AUTO
)
1984 return patch_conexant_auto(codec
);
1986 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1990 codec
->pin_amp_workaround
= 1;
1992 codec
->patch_ops
= conexant_patch_ops
;
1993 codec
->patch_ops
.init
= cxt5051_init
;
1995 spec
->multiout
.max_channels
= 2;
1996 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5051_dac_nids
);
1997 spec
->multiout
.dac_nids
= cxt5051_dac_nids
;
1998 spec
->multiout
.dig_out_nid
= CXT5051_SPDIF_OUT
;
1999 spec
->num_adc_nids
= 1; /* not 2; via auto-mic switch */
2000 spec
->adc_nids
= cxt5051_adc_nids
;
2001 spec
->num_mixers
= 2;
2002 spec
->mixers
[0] = cxt5051_capture_mixers
;
2003 spec
->mixers
[1] = cxt5051_playback_mixers
;
2004 spec
->num_init_verbs
= 1;
2005 spec
->init_verbs
[0] = cxt5051_init_verbs
;
2006 spec
->spdif_route
= 0;
2007 spec
->num_channel_mode
= ARRAY_SIZE(cxt5051_modes
);
2008 spec
->channel_mode
= cxt5051_modes
;
2010 spec
->cur_adc_idx
= 0;
2012 set_beep_amp(spec
, 0x13, 0, HDA_OUTPUT
);
2014 codec
->patch_ops
.unsol_event
= cxt5051_hp_unsol_event
;
2016 spec
->auto_mic
= AUTO_MIC_PORTB
| AUTO_MIC_PORTC
;
2017 switch (board_config
) {
2019 spec
->mixers
[0] = cxt5051_hp_mixers
;
2021 case CXT5051_HP_DV6736
:
2022 spec
->init_verbs
[0] = cxt5051_hp_dv6736_init_verbs
;
2023 spec
->mixers
[0] = cxt5051_hp_dv6736_mixers
;
2026 case CXT5051_LENOVO_X200
:
2027 spec
->init_verbs
[0] = cxt5051_lenovo_x200_init_verbs
;
2028 /* Thinkpad X301 does not have S/PDIF wired and no ability
2029 to use a docking station. */
2030 if (codec
->subsystem_id
== 0x17aa211f)
2031 spec
->multiout
.dig_out_nid
= 0;
2034 spec
->init_verbs
[0] = cxt5051_f700_init_verbs
;
2035 spec
->mixers
[0] = cxt5051_f700_mixers
;
2038 case CXT5051_TOSHIBA
:
2039 spec
->mixers
[0] = cxt5051_toshiba_mixers
;
2040 spec
->auto_mic
= AUTO_MIC_PORTB
;
2042 case CXT5051_IDEAPAD
:
2043 spec
->init_verbs
[spec
->num_init_verbs
++] =
2044 cxt5051_ideapad_init_verbs
;
2050 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
2055 /* Conexant 5066 specific */
2057 static const hda_nid_t cxt5066_dac_nids
[1] = { 0x10 };
2058 static const hda_nid_t cxt5066_adc_nids
[3] = { 0x14, 0x15, 0x16 };
2059 static const hda_nid_t cxt5066_capsrc_nids
[1] = { 0x17 };
2060 static const hda_nid_t cxt5066_digout_pin_nids
[2] = { 0x20, 0x22 };
2062 /* OLPC's microphone port is DC coupled for use with external sensors,
2063 * therefore we use a 50% mic bias in order to center the input signal with
2064 * the DC input range of the codec. */
2065 #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50
2067 static const struct hda_channel_mode cxt5066_modes
[1] = {
2071 #define HP_PRESENT_PORT_A (1 << 0)
2072 #define HP_PRESENT_PORT_D (1 << 1)
2073 #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A)
2074 #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D)
2076 static void cxt5066_update_speaker(struct hda_codec
*codec
)
2078 struct conexant_spec
*spec
= codec
->spec
;
2079 unsigned int pinctl
;
2081 snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n",
2082 spec
->hp_present
, spec
->cur_eapd
);
2085 pinctl
= (hp_port_a_present(spec
) && spec
->cur_eapd
) ? PIN_HP
: 0;
2086 snd_hda_codec_write(codec
, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2089 /* Port D (HP/LO) */
2090 pinctl
= spec
->cur_eapd
? spec
->port_d_mode
: 0;
2091 if (spec
->dell_automute
|| spec
->thinkpad
) {
2092 /* Mute if Port A is connected */
2093 if (hp_port_a_present(spec
))
2096 /* Thinkpad/Dell doesn't give pin-D status */
2097 if (!hp_port_d_present(spec
))
2100 snd_hda_codec_write(codec
, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2104 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
2105 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2109 /* turn on/off EAPD (+ mute HP) as a master switch */
2110 static int cxt5066_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
2111 struct snd_ctl_elem_value
*ucontrol
)
2113 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2115 if (!cxt_eapd_put(kcontrol
, ucontrol
))
2118 cxt5066_update_speaker(codec
);
2122 static const struct hda_input_mux cxt5066_olpc_dc_bias
= {
2126 { "50%", PIN_VREF50
},
2127 { "80%", PIN_VREF80
},
2131 static int cxt5066_set_olpc_dc_bias(struct hda_codec
*codec
)
2133 struct conexant_spec
*spec
= codec
->spec
;
2134 /* Even though port F is the DC input, the bias is controlled on port B.
2135 * we also leave that port as an active input (but unselected) in DC mode
2136 * just in case that is necessary to make the bias setting take effect. */
2137 return snd_hda_codec_write_cache(codec
, 0x1a, 0,
2138 AC_VERB_SET_PIN_WIDGET_CONTROL
,
2139 cxt5066_olpc_dc_bias
.items
[spec
->dc_input_bias
].index
);
2142 /* OLPC defers mic widget control until when capture is started because the
2143 * microphone LED comes on as soon as these settings are put in place. if we
2144 * did this before recording, it would give the false indication that recording
2145 * is happening when it is not. */
2146 static void cxt5066_olpc_select_mic(struct hda_codec
*codec
)
2148 struct conexant_spec
*spec
= codec
->spec
;
2149 if (!spec
->recording
)
2152 if (spec
->dc_enable
) {
2153 /* in DC mode we ignore presence detection and just use the jack
2154 * through our special DC port */
2155 const struct hda_verb enable_dc_mode
[] = {
2156 /* disble internal mic, port C */
2157 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2159 /* enable DC capture, port F */
2160 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2164 snd_hda_sequence_write(codec
, enable_dc_mode
);
2165 /* port B input disabled (and bias set) through the following call */
2166 cxt5066_set_olpc_dc_bias(codec
);
2170 /* disable DC (port F) */
2171 snd_hda_codec_write(codec
, 0x1e, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0);
2173 /* external mic, port B */
2174 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2175 spec
->ext_mic_present
? CXT5066_OLPC_EXT_MIC_BIAS
: 0);
2177 /* internal mic, port C */
2178 snd_hda_codec_write(codec
, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2179 spec
->ext_mic_present
? 0 : PIN_VREF80
);
2182 /* toggle input of built-in and mic jack appropriately */
2183 static void cxt5066_olpc_automic(struct hda_codec
*codec
)
2185 struct conexant_spec
*spec
= codec
->spec
;
2186 unsigned int present
;
2188 if (spec
->dc_enable
) /* don't do presence detection in DC mode */
2191 present
= snd_hda_codec_read(codec
, 0x1a, 0,
2192 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
2194 snd_printdd("CXT5066: external microphone detected\n");
2196 snd_printdd("CXT5066: external microphone absent\n");
2198 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2200 spec
->ext_mic_present
= !!present
;
2202 cxt5066_olpc_select_mic(codec
);
2205 /* toggle input of built-in digital mic and mic jack appropriately */
2206 static void cxt5066_vostro_automic(struct hda_codec
*codec
)
2208 unsigned int present
;
2210 struct hda_verb ext_mic_present
[] = {
2211 /* enable external mic, port B */
2212 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2214 /* switch to external mic input */
2215 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2216 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2218 /* disable internal digital mic */
2219 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2222 static const struct hda_verb ext_mic_absent
[] = {
2223 /* enable internal mic, port C */
2224 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2226 /* switch to internal mic input */
2227 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2229 /* disable external mic, port B */
2230 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2234 present
= snd_hda_jack_detect(codec
, 0x1a);
2236 snd_printdd("CXT5066: external microphone detected\n");
2237 snd_hda_sequence_write(codec
, ext_mic_present
);
2239 snd_printdd("CXT5066: external microphone absent\n");
2240 snd_hda_sequence_write(codec
, ext_mic_absent
);
2244 /* toggle input of built-in digital mic and mic jack appropriately */
2245 static void cxt5066_ideapad_automic(struct hda_codec
*codec
)
2247 unsigned int present
;
2249 struct hda_verb ext_mic_present
[] = {
2250 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2251 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2252 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2255 static const struct hda_verb ext_mic_absent
[] = {
2256 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2257 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2258 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2262 present
= snd_hda_jack_detect(codec
, 0x1b);
2264 snd_printdd("CXT5066: external microphone detected\n");
2265 snd_hda_sequence_write(codec
, ext_mic_present
);
2267 snd_printdd("CXT5066: external microphone absent\n");
2268 snd_hda_sequence_write(codec
, ext_mic_absent
);
2273 /* toggle input of built-in digital mic and mic jack appropriately */
2274 static void cxt5066_asus_automic(struct hda_codec
*codec
)
2276 unsigned int present
;
2278 present
= snd_hda_jack_detect(codec
, 0x1b);
2279 snd_printdd("CXT5066: external microphone present=%d\n", present
);
2280 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2285 /* toggle input of built-in digital mic and mic jack appropriately */
2286 static void cxt5066_hp_laptop_automic(struct hda_codec
*codec
)
2288 unsigned int present
;
2290 present
= snd_hda_jack_detect(codec
, 0x1b);
2291 snd_printdd("CXT5066: external microphone present=%d\n", present
);
2292 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2297 /* toggle input of built-in digital mic and mic jack appropriately
2298 order is: external mic -> dock mic -> interal mic */
2299 static void cxt5066_thinkpad_automic(struct hda_codec
*codec
)
2301 unsigned int ext_present
, dock_present
;
2303 static const struct hda_verb ext_mic_present
[] = {
2304 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2305 {0x17, AC_VERB_SET_CONNECT_SEL
, 1},
2306 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2307 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2308 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2311 static const struct hda_verb dock_mic_present
[] = {
2312 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2313 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2314 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2315 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2316 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2319 static const struct hda_verb ext_mic_absent
[] = {
2320 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2321 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2322 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2323 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2327 ext_present
= snd_hda_jack_detect(codec
, 0x1b);
2328 dock_present
= snd_hda_jack_detect(codec
, 0x1a);
2330 snd_printdd("CXT5066: external microphone detected\n");
2331 snd_hda_sequence_write(codec
, ext_mic_present
);
2332 } else if (dock_present
) {
2333 snd_printdd("CXT5066: dock microphone detected\n");
2334 snd_hda_sequence_write(codec
, dock_mic_present
);
2336 snd_printdd("CXT5066: external microphone absent\n");
2337 snd_hda_sequence_write(codec
, ext_mic_absent
);
2341 /* mute internal speaker if HP is plugged */
2342 static void cxt5066_hp_automute(struct hda_codec
*codec
)
2344 struct conexant_spec
*spec
= codec
->spec
;
2345 unsigned int portA
, portD
;
2348 portA
= snd_hda_jack_detect(codec
, 0x19);
2351 portD
= snd_hda_jack_detect(codec
, 0x1c);
2353 spec
->hp_present
= portA
? HP_PRESENT_PORT_A
: 0;
2354 spec
->hp_present
|= portD
? HP_PRESENT_PORT_D
: 0;
2355 snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
2356 portA
, portD
, spec
->hp_present
);
2357 cxt5066_update_speaker(codec
);
2360 /* Dispatch the right mic autoswitch function */
2361 static void cxt5066_automic(struct hda_codec
*codec
)
2363 struct conexant_spec
*spec
= codec
->spec
;
2365 if (spec
->dell_vostro
)
2366 cxt5066_vostro_automic(codec
);
2367 else if (spec
->ideapad
)
2368 cxt5066_ideapad_automic(codec
);
2369 else if (spec
->thinkpad
)
2370 cxt5066_thinkpad_automic(codec
);
2371 else if (spec
->hp_laptop
)
2372 cxt5066_hp_laptop_automic(codec
);
2373 else if (spec
->asus
)
2374 cxt5066_asus_automic(codec
);
2377 /* unsolicited event for jack sensing */
2378 static void cxt5066_olpc_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2380 struct conexant_spec
*spec
= codec
->spec
;
2381 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2382 switch (res
>> 26) {
2383 case CONEXANT_HP_EVENT
:
2384 cxt5066_hp_automute(codec
);
2386 case CONEXANT_MIC_EVENT
:
2387 /* ignore mic events in DC mode; we're always using the jack */
2388 if (!spec
->dc_enable
)
2389 cxt5066_olpc_automic(codec
);
2394 /* unsolicited event for jack sensing */
2395 static void cxt5066_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2397 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2398 switch (res
>> 26) {
2399 case CONEXANT_HP_EVENT
:
2400 cxt5066_hp_automute(codec
);
2402 case CONEXANT_MIC_EVENT
:
2403 cxt5066_automic(codec
);
2409 static const struct hda_input_mux cxt5066_analog_mic_boost
= {
2420 static void cxt5066_set_mic_boost(struct hda_codec
*codec
)
2422 struct conexant_spec
*spec
= codec
->spec
;
2423 snd_hda_codec_write_cache(codec
, 0x17, 0,
2424 AC_VERB_SET_AMP_GAIN_MUTE
,
2425 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_OUTPUT
|
2426 cxt5066_analog_mic_boost
.items
[spec
->mic_boost
].index
);
2427 if (spec
->ideapad
|| spec
->thinkpad
) {
2428 /* adjust the internal mic as well...it is not through 0x17 */
2429 snd_hda_codec_write_cache(codec
, 0x23, 0,
2430 AC_VERB_SET_AMP_GAIN_MUTE
,
2431 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_INPUT
|
2432 cxt5066_analog_mic_boost
.
2433 items
[spec
->mic_boost
].index
);
2437 static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol
*kcontrol
,
2438 struct snd_ctl_elem_info
*uinfo
)
2440 return snd_hda_input_mux_info(&cxt5066_analog_mic_boost
, uinfo
);
2443 static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol
*kcontrol
,
2444 struct snd_ctl_elem_value
*ucontrol
)
2446 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2447 struct conexant_spec
*spec
= codec
->spec
;
2448 ucontrol
->value
.enumerated
.item
[0] = spec
->mic_boost
;
2452 static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol
*kcontrol
,
2453 struct snd_ctl_elem_value
*ucontrol
)
2455 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2456 struct conexant_spec
*spec
= codec
->spec
;
2457 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2459 idx
= ucontrol
->value
.enumerated
.item
[0];
2460 if (idx
>= imux
->num_items
)
2461 idx
= imux
->num_items
- 1;
2463 spec
->mic_boost
= idx
;
2464 if (!spec
->dc_enable
)
2465 cxt5066_set_mic_boost(codec
);
2469 static void cxt5066_enable_dc(struct hda_codec
*codec
)
2471 const struct hda_verb enable_dc_mode
[] = {
2473 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2475 /* switch to DC input */
2476 {0x17, AC_VERB_SET_CONNECT_SEL
, 3},
2480 /* configure as input source */
2481 snd_hda_sequence_write(codec
, enable_dc_mode
);
2482 cxt5066_olpc_select_mic(codec
); /* also sets configured bias */
2485 static void cxt5066_disable_dc(struct hda_codec
*codec
)
2487 /* reconfigure input source */
2488 cxt5066_set_mic_boost(codec
);
2489 /* automic also selects the right mic if we're recording */
2490 cxt5066_olpc_automic(codec
);
2493 static int cxt5066_olpc_dc_get(struct snd_kcontrol
*kcontrol
,
2494 struct snd_ctl_elem_value
*ucontrol
)
2496 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2497 struct conexant_spec
*spec
= codec
->spec
;
2498 ucontrol
->value
.integer
.value
[0] = spec
->dc_enable
;
2502 static int cxt5066_olpc_dc_put(struct snd_kcontrol
*kcontrol
,
2503 struct snd_ctl_elem_value
*ucontrol
)
2505 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2506 struct conexant_spec
*spec
= codec
->spec
;
2507 int dc_enable
= !!ucontrol
->value
.integer
.value
[0];
2509 if (dc_enable
== spec
->dc_enable
)
2512 spec
->dc_enable
= dc_enable
;
2514 cxt5066_enable_dc(codec
);
2516 cxt5066_disable_dc(codec
);
2521 static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol
*kcontrol
,
2522 struct snd_ctl_elem_info
*uinfo
)
2524 return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias
, uinfo
);
2527 static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol
*kcontrol
,
2528 struct snd_ctl_elem_value
*ucontrol
)
2530 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2531 struct conexant_spec
*spec
= codec
->spec
;
2532 ucontrol
->value
.enumerated
.item
[0] = spec
->dc_input_bias
;
2536 static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol
*kcontrol
,
2537 struct snd_ctl_elem_value
*ucontrol
)
2539 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2540 struct conexant_spec
*spec
= codec
->spec
;
2541 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2544 idx
= ucontrol
->value
.enumerated
.item
[0];
2545 if (idx
>= imux
->num_items
)
2546 idx
= imux
->num_items
- 1;
2548 spec
->dc_input_bias
= idx
;
2549 if (spec
->dc_enable
)
2550 cxt5066_set_olpc_dc_bias(codec
);
2554 static void cxt5066_olpc_capture_prepare(struct hda_codec
*codec
)
2556 struct conexant_spec
*spec
= codec
->spec
;
2557 /* mark as recording and configure the microphone widget so that the
2558 * recording LED comes on. */
2559 spec
->recording
= 1;
2560 cxt5066_olpc_select_mic(codec
);
2563 static void cxt5066_olpc_capture_cleanup(struct hda_codec
*codec
)
2565 struct conexant_spec
*spec
= codec
->spec
;
2566 const struct hda_verb disable_mics
[] = {
2567 /* disable external mic, port B */
2568 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2570 /* disble internal mic, port C */
2571 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2573 /* disable DC capture, port F */
2574 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2578 snd_hda_sequence_write(codec
, disable_mics
);
2579 spec
->recording
= 0;
2582 static void conexant_check_dig_outs(struct hda_codec
*codec
,
2583 const hda_nid_t
*dig_pins
,
2586 struct conexant_spec
*spec
= codec
->spec
;
2587 hda_nid_t
*nid_loc
= &spec
->multiout
.dig_out_nid
;
2590 for (i
= 0; i
< num_pins
; i
++, dig_pins
++) {
2591 unsigned int cfg
= snd_hda_codec_get_pincfg(codec
, *dig_pins
);
2592 if (get_defcfg_connect(cfg
) == AC_JACK_PORT_NONE
)
2594 if (snd_hda_get_connections(codec
, *dig_pins
, nid_loc
, 1) != 1)
2596 if (spec
->slave_dig_outs
[0])
2599 nid_loc
= spec
->slave_dig_outs
;
2603 static const struct hda_input_mux cxt5066_capture_source
= {
2613 static const struct hda_bind_ctls cxt5066_bind_capture_vol_others
= {
2614 .ops
= &snd_hda_bind_vol
,
2616 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2617 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2622 static const struct hda_bind_ctls cxt5066_bind_capture_sw_others
= {
2623 .ops
= &snd_hda_bind_sw
,
2625 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2626 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2631 static const struct snd_kcontrol_new cxt5066_mixer_master
[] = {
2632 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
2636 static const struct snd_kcontrol_new cxt5066_mixer_master_olpc
[] = {
2638 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2639 .name
= "Master Playback Volume",
2640 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
|
2641 SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
2642 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
,
2643 .subdevice
= HDA_SUBDEV_AMP_FLAG
,
2644 .info
= snd_hda_mixer_amp_volume_info
,
2645 .get
= snd_hda_mixer_amp_volume_get
,
2646 .put
= snd_hda_mixer_amp_volume_put
,
2647 .tlv
= { .c
= snd_hda_mixer_amp_tlv
},
2648 /* offset by 28 volume steps to limit minimum gain to -46dB */
2650 HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT
, 28),
2655 static const struct snd_kcontrol_new cxt5066_mixer_olpc_dc
[] = {
2657 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2658 .name
= "DC Mode Enable Switch",
2659 .info
= snd_ctl_boolean_mono_info
,
2660 .get
= cxt5066_olpc_dc_get
,
2661 .put
= cxt5066_olpc_dc_put
,
2664 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2665 .name
= "DC Input Bias Enum",
2666 .info
= cxt5066_olpc_dc_bias_enum_info
,
2667 .get
= cxt5066_olpc_dc_bias_enum_get
,
2668 .put
= cxt5066_olpc_dc_bias_enum_put
,
2673 static const struct snd_kcontrol_new cxt5066_mixers
[] = {
2675 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2676 .name
= "Master Playback Switch",
2677 .info
= cxt_eapd_info
,
2678 .get
= cxt_eapd_get
,
2679 .put
= cxt5066_hp_master_sw_put
,
2680 .private_value
= 0x1d,
2684 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2685 .name
= "Analog Mic Boost Capture Enum",
2686 .info
= cxt5066_mic_boost_mux_enum_info
,
2687 .get
= cxt5066_mic_boost_mux_enum_get
,
2688 .put
= cxt5066_mic_boost_mux_enum_put
,
2691 HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others
),
2692 HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others
),
2696 static const struct snd_kcontrol_new cxt5066_vostro_mixers
[] = {
2698 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2699 .name
= "Internal Mic Boost Capture Enum",
2700 .info
= cxt5066_mic_boost_mux_enum_info
,
2701 .get
= cxt5066_mic_boost_mux_enum_get
,
2702 .put
= cxt5066_mic_boost_mux_enum_put
,
2703 .private_value
= 0x23 | 0x100,
2708 static const struct hda_verb cxt5066_init_verbs
[] = {
2709 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2710 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2711 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2712 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2715 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2716 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2719 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2720 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2722 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2723 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2726 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2728 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2729 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2730 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2731 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2732 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2733 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2735 /* no digital microphone support yet */
2736 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2738 /* Audio input selector */
2739 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2741 /* SPDIF route: PCM */
2742 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2743 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2745 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2746 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2749 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2751 /* not handling these yet */
2752 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2753 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2754 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2755 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2756 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2757 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2758 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2759 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2763 static const struct hda_verb cxt5066_init_verbs_olpc
[] = {
2764 /* Port A: headphones */
2765 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2766 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2768 /* Port B: external microphone */
2769 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2771 /* Port C: internal microphone */
2772 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2774 /* Port D: unused */
2775 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2777 /* Port E: unused, but has primary EAPD */
2778 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2779 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2781 /* Port F: external DC input through microphone port */
2782 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2784 /* Port G: internal speakers */
2785 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2786 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2789 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2792 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2794 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2795 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2796 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2797 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2798 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2799 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2801 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2802 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2803 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2804 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2805 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2807 /* Disable digital microphone port */
2808 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2810 /* Audio input selectors */
2811 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2812 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2815 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2816 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2818 /* enable unsolicited events for Port A and B */
2819 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2820 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2824 static const struct hda_verb cxt5066_init_verbs_vostro
[] = {
2825 /* Port A: headphones */
2826 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2827 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2829 /* Port B: external microphone */
2830 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2832 /* Port C: unused */
2833 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2835 /* Port D: unused */
2836 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2838 /* Port E: unused, but has primary EAPD */
2839 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2840 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2842 /* Port F: unused */
2843 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2845 /* Port G: internal speakers */
2846 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2847 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2850 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2853 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2855 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2856 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2857 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2858 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2859 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2860 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2861 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2862 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2863 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2864 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2865 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2866 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2868 /* Digital microphone port */
2869 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2871 /* Audio input selectors */
2872 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2873 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2876 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2877 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2879 /* enable unsolicited events for Port A and B */
2880 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2881 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2885 static const struct hda_verb cxt5066_init_verbs_ideapad
[] = {
2886 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2887 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2888 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2889 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2892 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2893 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2896 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2897 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2899 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2900 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2903 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2905 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2906 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2907 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2908 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2909 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2911 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2913 /* Audio input selector */
2914 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2915 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2917 /* SPDIF route: PCM */
2918 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2919 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2921 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2922 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2924 /* internal microphone */
2925 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable internal mic */
2928 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2930 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2931 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2935 static const struct hda_verb cxt5066_init_verbs_thinkpad
[] = {
2936 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2937 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2939 /* Port G: internal speakers */
2940 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2941 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2943 /* Port A: HP, Amp */
2944 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2945 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2947 /* Port B: Mic Dock */
2948 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2951 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2953 /* Port D: HP Dock, Amp */
2954 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2955 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2958 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2960 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2961 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2962 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2963 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2964 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2965 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2966 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2968 /* Audio input selector */
2969 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2970 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2972 /* SPDIF route: PCM */
2973 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2974 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2976 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2977 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2979 /* internal microphone */
2980 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable internal mic */
2983 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2985 /* enable unsolicited events for Port A, B, C and D */
2986 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2987 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2988 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2989 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2993 static const struct hda_verb cxt5066_init_verbs_portd_lo
[] = {
2994 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2999 static const struct hda_verb cxt5066_init_verbs_hp_laptop
[] = {
3000 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x0},
3001 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
3002 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
3006 /* initialize jack-sensing, too */
3007 static int cxt5066_init(struct hda_codec
*codec
)
3009 snd_printdd("CXT5066: init\n");
3010 conexant_init(codec
);
3011 if (codec
->patch_ops
.unsol_event
) {
3012 cxt5066_hp_automute(codec
);
3013 cxt5066_automic(codec
);
3015 cxt5066_set_mic_boost(codec
);
3019 static int cxt5066_olpc_init(struct hda_codec
*codec
)
3021 struct conexant_spec
*spec
= codec
->spec
;
3022 snd_printdd("CXT5066: init\n");
3023 conexant_init(codec
);
3024 cxt5066_hp_automute(codec
);
3025 if (!spec
->dc_enable
) {
3026 cxt5066_set_mic_boost(codec
);
3027 cxt5066_olpc_automic(codec
);
3029 cxt5066_enable_dc(codec
);
3035 CXT5066_LAPTOP
, /* Laptops w/ EAPD support */
3036 CXT5066_DELL_LAPTOP
, /* Dell Laptop */
3037 CXT5066_OLPC_XO_1_5
, /* OLPC XO 1.5 */
3038 CXT5066_DELL_VOSTRO
, /* Dell Vostro 1015i */
3039 CXT5066_IDEAPAD
, /* Lenovo IdeaPad U150 */
3040 CXT5066_THINKPAD
, /* Lenovo ThinkPad T410s, others? */
3041 CXT5066_ASUS
, /* Asus K52JU, Lenovo G560 - Int mic at 0x1a and Ext mic at 0x1b */
3042 CXT5066_HP_LAPTOP
, /* HP Laptop */
3046 static const char * const cxt5066_models
[CXT5066_MODELS
] = {
3047 [CXT5066_LAPTOP
] = "laptop",
3048 [CXT5066_DELL_LAPTOP
] = "dell-laptop",
3049 [CXT5066_OLPC_XO_1_5
] = "olpc-xo-1_5",
3050 [CXT5066_DELL_VOSTRO
] = "dell-vostro",
3051 [CXT5066_IDEAPAD
] = "ideapad",
3052 [CXT5066_THINKPAD
] = "thinkpad",
3053 [CXT5066_ASUS
] = "asus",
3054 [CXT5066_HP_LAPTOP
] = "hp-laptop",
3057 static const struct snd_pci_quirk cxt5066_cfg_tbl
[] = {
3058 SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD
),
3059 SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO
),
3060 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD
),
3061 SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO
),
3062 SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTRO
),
3063 SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD
),
3064 SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD
),
3065 SND_PCI_QUIRK(0x1028, 0x0510, "Dell Vostro", CXT5066_IDEAPAD
),
3066 SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP
),
3067 SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS
),
3068 SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS
),
3069 SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS
),
3070 SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD
),
3071 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5
),
3072 SND_PCI_QUIRK(0x1179, 0xffe0, "Toshiba Satellite Pro T130-15F", CXT5066_OLPC_XO_1_5
),
3073 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
3075 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5
),
3076 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD
),
3077 SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD
),
3078 SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS
),
3079 SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo Thinkpad", CXT5066_THINKPAD
),
3080 SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT5066_THINKPAD
),
3081 SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT5066_THINKPAD
),
3082 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS
),
3083 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", CXT5066_IDEAPAD
), /* Fallback for Lenovos without dock mic */
3087 static int patch_cxt5066(struct hda_codec
*codec
)
3089 struct conexant_spec
*spec
;
3092 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3097 codec
->patch_ops
= conexant_patch_ops
;
3098 codec
->patch_ops
.init
= conexant_init
;
3100 spec
->dell_automute
= 0;
3101 spec
->multiout
.max_channels
= 2;
3102 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5066_dac_nids
);
3103 spec
->multiout
.dac_nids
= cxt5066_dac_nids
;
3104 conexant_check_dig_outs(codec
, cxt5066_digout_pin_nids
,
3105 ARRAY_SIZE(cxt5066_digout_pin_nids
));
3106 spec
->num_adc_nids
= 1;
3107 spec
->adc_nids
= cxt5066_adc_nids
;
3108 spec
->capsrc_nids
= cxt5066_capsrc_nids
;
3109 spec
->input_mux
= &cxt5066_capture_source
;
3111 spec
->port_d_mode
= PIN_HP
;
3113 spec
->num_init_verbs
= 1;
3114 spec
->init_verbs
[0] = cxt5066_init_verbs
;
3115 spec
->num_channel_mode
= ARRAY_SIZE(cxt5066_modes
);
3116 spec
->channel_mode
= cxt5066_modes
;
3118 spec
->cur_adc_idx
= 0;
3120 set_beep_amp(spec
, 0x13, 0, HDA_OUTPUT
);
3122 board_config
= snd_hda_check_board_config(codec
, CXT5066_MODELS
,
3123 cxt5066_models
, cxt5066_cfg_tbl
);
3124 switch (board_config
) {
3126 case CXT5066_LAPTOP
:
3127 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3128 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3130 case CXT5066_DELL_LAPTOP
:
3131 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3132 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3134 spec
->port_d_mode
= PIN_OUT
;
3135 spec
->init_verbs
[spec
->num_init_verbs
] = cxt5066_init_verbs_portd_lo
;
3136 spec
->num_init_verbs
++;
3137 spec
->dell_automute
= 1;
3140 case CXT5066_HP_LAPTOP
:
3141 codec
->patch_ops
.init
= cxt5066_init
;
3142 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3143 spec
->init_verbs
[spec
->num_init_verbs
] =
3144 cxt5066_init_verbs_hp_laptop
;
3145 spec
->num_init_verbs
++;
3146 spec
->hp_laptop
= board_config
== CXT5066_HP_LAPTOP
;
3147 spec
->asus
= board_config
== CXT5066_ASUS
;
3148 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3149 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3151 if (board_config
== CXT5066_HP_LAPTOP
)
3152 spec
->multiout
.dig_out_nid
= 0;
3153 /* input source automatically selected */
3154 spec
->input_mux
= NULL
;
3155 spec
->port_d_mode
= 0;
3156 spec
->mic_boost
= 3; /* default 30dB gain */
3159 case CXT5066_OLPC_XO_1_5
:
3160 codec
->patch_ops
.init
= cxt5066_olpc_init
;
3161 codec
->patch_ops
.unsol_event
= cxt5066_olpc_unsol_event
;
3162 spec
->init_verbs
[0] = cxt5066_init_verbs_olpc
;
3163 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
3164 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_olpc_dc
;
3165 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3166 spec
->port_d_mode
= 0;
3167 spec
->mic_boost
= 3; /* default 30dB gain */
3170 spec
->multiout
.dig_out_nid
= 0;
3172 /* input source automatically selected */
3173 spec
->input_mux
= NULL
;
3175 /* our capture hooks which allow us to turn on the microphone LED
3176 * at the right time */
3177 spec
->capture_prepare
= cxt5066_olpc_capture_prepare
;
3178 spec
->capture_cleanup
= cxt5066_olpc_capture_cleanup
;
3180 case CXT5066_DELL_VOSTRO
:
3181 codec
->patch_ops
.init
= cxt5066_init
;
3182 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3183 spec
->init_verbs
[0] = cxt5066_init_verbs_vostro
;
3184 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
3185 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3186 spec
->mixers
[spec
->num_mixers
++] = cxt5066_vostro_mixers
;
3187 spec
->port_d_mode
= 0;
3188 spec
->dell_vostro
= 1;
3189 spec
->mic_boost
= 3; /* default 30dB gain */
3192 spec
->multiout
.dig_out_nid
= 0;
3194 /* input source automatically selected */
3195 spec
->input_mux
= NULL
;
3197 case CXT5066_IDEAPAD
:
3198 codec
->patch_ops
.init
= cxt5066_init
;
3199 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3200 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3201 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3202 spec
->init_verbs
[0] = cxt5066_init_verbs_ideapad
;
3203 spec
->port_d_mode
= 0;
3205 spec
->mic_boost
= 2; /* default 20dB gain */
3208 spec
->multiout
.dig_out_nid
= 0;
3210 /* input source automatically selected */
3211 spec
->input_mux
= NULL
;
3213 case CXT5066_THINKPAD
:
3214 codec
->patch_ops
.init
= cxt5066_init
;
3215 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3216 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3217 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3218 spec
->init_verbs
[0] = cxt5066_init_verbs_thinkpad
;
3220 spec
->port_d_mode
= PIN_OUT
;
3221 spec
->mic_boost
= 2; /* default 20dB gain */
3224 spec
->multiout
.dig_out_nid
= 0;
3226 /* input source automatically selected */
3227 spec
->input_mux
= NULL
;
3232 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
3238 * Automatic parser for CX20641 & co
3241 static int cx_auto_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
3242 struct hda_codec
*codec
,
3243 unsigned int stream_tag
,
3244 unsigned int format
,
3245 struct snd_pcm_substream
*substream
)
3247 struct conexant_spec
*spec
= codec
->spec
;
3248 hda_nid_t adc
= spec
->imux_adcs
[spec
->cur_mux
[0]];
3249 if (spec
->adc_switching
) {
3250 spec
->cur_adc
= adc
;
3251 spec
->cur_adc_stream_tag
= stream_tag
;
3252 spec
->cur_adc_format
= format
;
3254 snd_hda_codec_setup_stream(codec
, adc
, stream_tag
, 0, format
);
3258 static int cx_auto_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
3259 struct hda_codec
*codec
,
3260 struct snd_pcm_substream
*substream
)
3262 struct conexant_spec
*spec
= codec
->spec
;
3263 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
3268 static const struct hda_pcm_stream cx_auto_pcm_analog_capture
= {
3272 .nid
= 0, /* fill later */
3274 .prepare
= cx_auto_capture_pcm_prepare
,
3275 .cleanup
= cx_auto_capture_pcm_cleanup
3279 static const hda_nid_t cx_auto_adc_nids
[] = { 0x14 };
3281 /* get the connection index of @nid in the widget @mux */
3282 static int get_connection_index(struct hda_codec
*codec
, hda_nid_t mux
,
3285 hda_nid_t conn
[HDA_MAX_NUM_INPUTS
];
3288 nums
= snd_hda_get_connections(codec
, mux
, conn
, ARRAY_SIZE(conn
));
3289 for (i
= 0; i
< nums
; i
++)
3295 /* get an unassigned DAC from the given list.
3296 * Return the nid if found and reduce the DAC list, or return zero if
3299 static hda_nid_t
get_unassigned_dac(struct hda_codec
*codec
, hda_nid_t pin
,
3300 hda_nid_t
*dacs
, int *num_dacs
)
3302 int i
, nums
= *num_dacs
;
3305 for (i
= 0; i
< nums
; i
++) {
3306 if (get_connection_index(codec
, pin
, dacs
[i
]) >= 0) {
3314 memmove(dacs
, dacs
+ 1, nums
* sizeof(hda_nid_t
));
3319 #define MAX_AUTO_DACS 5
3321 /* fill analog DAC list from the widget tree */
3322 static int fill_cx_auto_dacs(struct hda_codec
*codec
, hda_nid_t
*dacs
)
3324 hda_nid_t nid
, end_nid
;
3327 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3328 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
3329 unsigned int wcaps
= get_wcaps(codec
, nid
);
3330 unsigned int type
= get_wcaps_type(wcaps
);
3331 if (type
== AC_WID_AUD_OUT
&& !(wcaps
& AC_WCAP_DIGITAL
)) {
3333 if (nums
>= MAX_AUTO_DACS
)
3340 /* fill pin_dac_pair list from the pin and dac list */
3341 static int fill_dacs_for_pins(struct hda_codec
*codec
, hda_nid_t
*pins
,
3342 int num_pins
, hda_nid_t
*dacs
, int *rest
,
3343 struct pin_dac_pair
*filled
, int type
)
3348 for (i
= 0; i
< num_pins
; i
++) {
3349 filled
[nums
].pin
= pins
[i
];
3350 filled
[nums
].type
= type
;
3351 filled
[nums
].dac
= get_unassigned_dac(codec
, pins
[i
], dacs
, rest
);
3357 /* parse analog output paths */
3358 static void cx_auto_parse_output(struct hda_codec
*codec
)
3360 struct conexant_spec
*spec
= codec
->spec
;
3361 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3362 hda_nid_t dacs
[MAX_AUTO_DACS
];
3363 int i
, j
, nums
, rest
;
3365 rest
= fill_cx_auto_dacs(codec
, dacs
);
3366 /* parse all analog output pins */
3367 nums
= fill_dacs_for_pins(codec
, cfg
->line_out_pins
, cfg
->line_outs
,
3368 dacs
, &rest
, spec
->dac_info
,
3370 nums
+= fill_dacs_for_pins(codec
, cfg
->hp_pins
, cfg
->hp_outs
,
3371 dacs
, &rest
, spec
->dac_info
+ nums
,
3373 nums
+= fill_dacs_for_pins(codec
, cfg
->speaker_pins
, cfg
->speaker_outs
,
3374 dacs
, &rest
, spec
->dac_info
+ nums
,
3375 AUTO_PIN_SPEAKER_OUT
);
3376 spec
->dac_info_filled
= nums
;
3377 /* fill multiout struct */
3378 for (i
= 0; i
< nums
; i
++) {
3379 hda_nid_t dac
= spec
->dac_info
[i
].dac
;
3382 switch (spec
->dac_info
[i
].type
) {
3383 case AUTO_PIN_LINE_OUT
:
3384 spec
->private_dac_nids
[spec
->multiout
.num_dacs
] = dac
;
3385 spec
->multiout
.num_dacs
++;
3387 case AUTO_PIN_HP_OUT
:
3388 case AUTO_PIN_SPEAKER_OUT
:
3389 if (!spec
->multiout
.hp_nid
) {
3390 spec
->multiout
.hp_nid
= dac
;
3393 for (j
= 0; j
< ARRAY_SIZE(spec
->multiout
.extra_out_nid
); j
++)
3394 if (!spec
->multiout
.extra_out_nid
[j
]) {
3395 spec
->multiout
.extra_out_nid
[j
] = dac
;
3401 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3402 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
3404 if (cfg
->hp_outs
> 0)
3405 spec
->auto_mute
= 1;
3406 spec
->vmaster_nid
= spec
->private_dac_nids
[0];
3409 static void cx_auto_turn_eapd(struct hda_codec
*codec
, int num_pins
,
3410 hda_nid_t
*pins
, bool on
);
3412 /* auto-mute/unmute speaker and line outs according to headphone jack */
3413 static void cx_auto_hp_automute(struct hda_codec
*codec
)
3415 struct conexant_spec
*spec
= codec
->spec
;
3416 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3419 if (!spec
->auto_mute
)
3422 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3423 if (snd_hda_jack_detect(codec
, cfg
->hp_pins
[i
])) {
3428 cx_auto_turn_eapd(codec
, cfg
->hp_outs
, cfg
->hp_pins
, present
);
3429 for (i
= 0; i
< cfg
->line_outs
; i
++) {
3430 snd_hda_codec_write(codec
, cfg
->line_out_pins
[i
], 0,
3431 AC_VERB_SET_PIN_WIDGET_CONTROL
,
3432 present
? 0 : PIN_OUT
);
3434 cx_auto_turn_eapd(codec
, cfg
->line_outs
, cfg
->line_out_pins
, !present
);
3435 for (i
= 0; !present
&& i
< cfg
->line_outs
; i
++)
3436 if (snd_hda_jack_detect(codec
, cfg
->line_out_pins
[i
]))
3438 for (i
= 0; i
< cfg
->speaker_outs
; i
++) {
3439 snd_hda_codec_write(codec
, cfg
->speaker_pins
[i
], 0,
3440 AC_VERB_SET_PIN_WIDGET_CONTROL
,
3441 present
? 0 : PIN_OUT
);
3443 cx_auto_turn_eapd(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
, !present
);
3446 static int cx_auto_mux_enum_info(struct snd_kcontrol
*kcontrol
,
3447 struct snd_ctl_elem_info
*uinfo
)
3449 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3450 struct conexant_spec
*spec
= codec
->spec
;
3452 return snd_hda_input_mux_info(&spec
->private_imux
, uinfo
);
3455 static int cx_auto_mux_enum_get(struct snd_kcontrol
*kcontrol
,
3456 struct snd_ctl_elem_value
*ucontrol
)
3458 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3459 struct conexant_spec
*spec
= codec
->spec
;
3461 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[0];
3465 /* look for the route the given pin from mux and return the index;
3466 * if do_select is set, actually select the route.
3468 static int __select_input_connection(struct hda_codec
*codec
, hda_nid_t mux
,
3469 hda_nid_t pin
, hda_nid_t
*srcp
,
3470 bool do_select
, int depth
)
3472 hda_nid_t conn
[HDA_MAX_NUM_INPUTS
];
3475 switch (get_wcaps_type(get_wcaps(codec
, mux
))) {
3477 case AC_WID_AUD_SEL
:
3478 case AC_WID_AUD_MIX
:
3484 nums
= snd_hda_get_connections(codec
, mux
, conn
, ARRAY_SIZE(conn
));
3485 for (i
= 0; i
< nums
; i
++)
3486 if (conn
[i
] == pin
) {
3488 snd_hda_codec_write(codec
, mux
, 0,
3489 AC_VERB_SET_CONNECT_SEL
, i
);
3497 for (i
= 0; i
< nums
; i
++) {
3498 int ret
= __select_input_connection(codec
, conn
[i
], pin
, srcp
,
3502 snd_hda_codec_write(codec
, mux
, 0,
3503 AC_VERB_SET_CONNECT_SEL
, i
);
3510 static void select_input_connection(struct hda_codec
*codec
, hda_nid_t mux
,
3513 __select_input_connection(codec
, mux
, pin
, NULL
, true, 0);
3516 static int get_input_connection(struct hda_codec
*codec
, hda_nid_t mux
,
3519 return __select_input_connection(codec
, mux
, pin
, NULL
, false, 0);
3522 static int cx_auto_mux_enum_update(struct hda_codec
*codec
,
3523 const struct hda_input_mux
*imux
,
3526 struct conexant_spec
*spec
= codec
->spec
;
3529 if (!imux
->num_items
)
3531 if (idx
>= imux
->num_items
)
3532 idx
= imux
->num_items
- 1;
3533 if (spec
->cur_mux
[0] == idx
)
3535 adc
= spec
->imux_adcs
[idx
];
3536 select_input_connection(codec
, spec
->imux_adcs
[idx
],
3537 spec
->imux_pins
[idx
]);
3538 if (spec
->cur_adc
&& spec
->cur_adc
!= adc
) {
3539 /* stream is running, let's swap the current ADC */
3540 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
3541 spec
->cur_adc
= adc
;
3542 snd_hda_codec_setup_stream(codec
, adc
,
3543 spec
->cur_adc_stream_tag
, 0,
3544 spec
->cur_adc_format
);
3546 spec
->cur_mux
[0] = idx
;
3550 static int cx_auto_mux_enum_put(struct snd_kcontrol
*kcontrol
,
3551 struct snd_ctl_elem_value
*ucontrol
)
3553 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3554 struct conexant_spec
*spec
= codec
->spec
;
3556 return cx_auto_mux_enum_update(codec
, &spec
->private_imux
,
3557 ucontrol
->value
.enumerated
.item
[0]);
3560 static const struct snd_kcontrol_new cx_auto_capture_mixers
[] = {
3562 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3563 .name
= "Capture Source",
3564 .info
= cx_auto_mux_enum_info
,
3565 .get
= cx_auto_mux_enum_get
,
3566 .put
= cx_auto_mux_enum_put
3571 /* automatic switch internal and external mic */
3572 static void cx_auto_automic(struct hda_codec
*codec
)
3574 struct conexant_spec
*spec
= codec
->spec
;
3575 int ext_idx
= spec
->auto_mic_ext
;
3577 if (!spec
->auto_mic
)
3579 if (snd_hda_jack_detect(codec
, spec
->imux_pins
[ext_idx
]))
3580 cx_auto_mux_enum_update(codec
, &spec
->private_imux
, ext_idx
);
3582 cx_auto_mux_enum_update(codec
, &spec
->private_imux
, !ext_idx
);
3585 static void cx_auto_unsol_event(struct hda_codec
*codec
, unsigned int res
)
3587 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
3588 switch (res
>> 26) {
3589 case CONEXANT_HP_EVENT
:
3590 cx_auto_hp_automute(codec
);
3591 snd_hda_input_jack_report(codec
, nid
);
3593 case CONEXANT_MIC_EVENT
:
3594 cx_auto_automic(codec
);
3595 snd_hda_input_jack_report(codec
, nid
);
3600 /* return true if it's an internal-mic pin */
3601 static int is_int_mic(struct hda_codec
*codec
, hda_nid_t pin
)
3603 unsigned int def_conf
= snd_hda_codec_get_pincfg(codec
, pin
);
3604 return get_defcfg_device(def_conf
) == AC_JACK_MIC_IN
&&
3605 snd_hda_get_input_pin_attr(def_conf
) == INPUT_PIN_ATTR_INT
;
3608 /* return true if it's an external-mic pin */
3609 static int is_ext_mic(struct hda_codec
*codec
, hda_nid_t pin
)
3611 unsigned int def_conf
= snd_hda_codec_get_pincfg(codec
, pin
);
3612 return get_defcfg_device(def_conf
) == AC_JACK_MIC_IN
&&
3613 snd_hda_get_input_pin_attr(def_conf
) >= INPUT_PIN_ATTR_NORMAL
&&
3614 (snd_hda_query_pin_caps(codec
, pin
) & AC_PINCAP_PRES_DETECT
);
3617 /* check whether the pin config is suitable for auto-mic switching;
3618 * auto-mic is enabled only when one int-mic and one-ext mic exist
3620 static void cx_auto_check_auto_mic(struct hda_codec
*codec
)
3622 struct conexant_spec
*spec
= codec
->spec
;
3624 if (is_ext_mic(codec
, spec
->imux_pins
[0]) &&
3625 is_int_mic(codec
, spec
->imux_pins
[1])) {
3627 spec
->auto_mic_ext
= 0;
3630 if (is_int_mic(codec
, spec
->imux_pins
[0]) &&
3631 is_ext_mic(codec
, spec
->imux_pins
[1])) {
3633 spec
->auto_mic_ext
= 1;
3638 static void cx_auto_parse_input(struct hda_codec
*codec
)
3640 struct conexant_spec
*spec
= codec
->spec
;
3641 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3642 struct hda_input_mux
*imux
;
3645 imux
= &spec
->private_imux
;
3646 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3647 for (j
= 0; j
< spec
->num_adc_nids
; j
++) {
3648 hda_nid_t adc
= spec
->adc_nids
[j
];
3649 int idx
= get_input_connection(codec
, adc
,
3650 cfg
->inputs
[i
].pin
);
3653 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
3654 spec
->imux_cfg_idx
[imux
->num_items
] = i
;
3655 spec
->imux_boost_nid
[imux
->num_items
] = 0;
3656 spec
->imux_adcs
[imux
->num_items
] = adc
;
3657 spec
->imux_pins
[imux
->num_items
] =
3659 snd_hda_add_imux_item(imux
, label
, idx
, NULL
);
3664 if (imux
->num_items
== 2 && cfg
->num_inputs
== 2)
3665 cx_auto_check_auto_mic(codec
);
3666 if (imux
->num_items
> 1 && !spec
->auto_mic
) {
3667 for (i
= 1; i
< imux
->num_items
; i
++) {
3668 if (spec
->imux_adcs
[i
] != spec
->imux_adcs
[0]) {
3669 spec
->adc_switching
= 1;
3676 /* get digital-input audio widget corresponding to the given pin */
3677 static hda_nid_t
cx_auto_get_dig_in(struct hda_codec
*codec
, hda_nid_t pin
)
3679 hda_nid_t nid
, end_nid
;
3681 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3682 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
3683 unsigned int wcaps
= get_wcaps(codec
, nid
);
3684 unsigned int type
= get_wcaps_type(wcaps
);
3685 if (type
== AC_WID_AUD_IN
&& (wcaps
& AC_WCAP_DIGITAL
)) {
3686 if (get_connection_index(codec
, nid
, pin
) >= 0)
3693 static void cx_auto_parse_digital(struct hda_codec
*codec
)
3695 struct conexant_spec
*spec
= codec
->spec
;
3696 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3699 if (cfg
->dig_outs
&&
3700 snd_hda_get_connections(codec
, cfg
->dig_out_pins
[0], &nid
, 1) == 1)
3701 spec
->multiout
.dig_out_nid
= nid
;
3702 if (cfg
->dig_in_pin
)
3703 spec
->dig_in_nid
= cx_auto_get_dig_in(codec
, cfg
->dig_in_pin
);
3706 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3707 static void cx_auto_parse_beep(struct hda_codec
*codec
)
3709 struct conexant_spec
*spec
= codec
->spec
;
3710 hda_nid_t nid
, end_nid
;
3712 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3713 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++)
3714 if (get_wcaps_type(get_wcaps(codec
, nid
)) == AC_WID_BEEP
) {
3715 set_beep_amp(spec
, nid
, 0, HDA_OUTPUT
);
3720 #define cx_auto_parse_beep(codec)
3723 static int cx_auto_parse_auto_config(struct hda_codec
*codec
)
3725 struct conexant_spec
*spec
= codec
->spec
;
3728 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
3732 cx_auto_parse_output(codec
);
3733 cx_auto_parse_input(codec
);
3734 cx_auto_parse_digital(codec
);
3735 cx_auto_parse_beep(codec
);
3739 static void cx_auto_turn_eapd(struct hda_codec
*codec
, int num_pins
,
3740 hda_nid_t
*pins
, bool on
)
3743 for (i
= 0; i
< num_pins
; i
++) {
3744 if (snd_hda_query_pin_caps(codec
, pins
[i
]) & AC_PINCAP_EAPD
)
3745 snd_hda_codec_write(codec
, pins
[i
], 0,
3746 AC_VERB_SET_EAPD_BTLENABLE
,
3751 static void select_connection(struct hda_codec
*codec
, hda_nid_t pin
,
3754 int idx
= get_connection_index(codec
, pin
, src
);
3756 snd_hda_codec_write(codec
, pin
, 0,
3757 AC_VERB_SET_CONNECT_SEL
, idx
);
3760 static void mute_outputs(struct hda_codec
*codec
, int num_nids
,
3761 const hda_nid_t
*nids
)
3765 for (i
= 0; i
< num_nids
; i
++) {
3766 hda_nid_t nid
= nids
[i
];
3767 if (!(get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
))
3769 if (query_amp_caps(codec
, nid
, HDA_OUTPUT
) & AC_AMPCAP_MUTE
)
3773 snd_hda_codec_write(codec
, nid
, 0,
3774 AC_VERB_SET_AMP_GAIN_MUTE
, val
);
3778 static void cx_auto_init_output(struct hda_codec
*codec
)
3780 struct conexant_spec
*spec
= codec
->spec
;
3781 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3785 mute_outputs(codec
, spec
->multiout
.num_dacs
, spec
->multiout
.dac_nids
);
3786 for (i
= 0; i
< cfg
->hp_outs
; i
++)
3787 snd_hda_codec_write(codec
, cfg
->hp_pins
[i
], 0,
3788 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
);
3789 mute_outputs(codec
, cfg
->hp_outs
, cfg
->hp_pins
);
3790 mute_outputs(codec
, cfg
->line_outs
, cfg
->line_out_pins
);
3791 mute_outputs(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
);
3792 if (spec
->auto_mute
) {
3793 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3794 snd_hda_codec_write(codec
, cfg
->hp_pins
[i
], 0,
3795 AC_VERB_SET_UNSOLICITED_ENABLE
,
3796 AC_USRSP_EN
| CONEXANT_HP_EVENT
);
3798 cx_auto_hp_automute(codec
);
3800 for (i
= 0; i
< cfg
->line_outs
; i
++)
3801 snd_hda_codec_write(codec
, cfg
->line_out_pins
[i
], 0,
3802 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
3803 for (i
= 0; i
< cfg
->speaker_outs
; i
++)
3804 snd_hda_codec_write(codec
, cfg
->speaker_pins
[i
], 0,
3805 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
3807 cx_auto_turn_eapd(codec
, cfg
->line_outs
, cfg
->line_out_pins
,
3809 cx_auto_turn_eapd(codec
, cfg
->hp_outs
, cfg
->hp_pins
,
3811 cx_auto_turn_eapd(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
,
3815 for (i
= 0; i
< spec
->dac_info_filled
; i
++) {
3816 nid
= spec
->dac_info
[i
].dac
;
3818 nid
= spec
->multiout
.dac_nids
[0];
3819 select_connection(codec
, spec
->dac_info
[i
].pin
, nid
);
3823 static void cx_auto_init_input(struct hda_codec
*codec
)
3825 struct conexant_spec
*spec
= codec
->spec
;
3826 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3829 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
3830 hda_nid_t nid
= spec
->adc_nids
[i
];
3831 if (!(get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
))
3833 if (query_amp_caps(codec
, nid
, HDA_INPUT
) & AC_AMPCAP_MUTE
)
3834 val
= AMP_IN_MUTE(0);
3836 val
= AMP_IN_UNMUTE(0);
3837 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3841 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3843 if (cfg
->inputs
[i
].type
== AUTO_PIN_MIC
)
3847 snd_hda_codec_write(codec
, cfg
->inputs
[i
].pin
, 0,
3848 AC_VERB_SET_PIN_WIDGET_CONTROL
, type
);
3851 if (spec
->auto_mic
) {
3852 int ext_idx
= spec
->auto_mic_ext
;
3853 snd_hda_codec_write(codec
, cfg
->inputs
[ext_idx
].pin
, 0,
3854 AC_VERB_SET_UNSOLICITED_ENABLE
,
3855 AC_USRSP_EN
| CONEXANT_MIC_EVENT
);
3856 cx_auto_automic(codec
);
3858 select_input_connection(codec
, spec
->imux_adcs
[0],
3859 spec
->imux_pins
[0]);
3863 static void cx_auto_init_digital(struct hda_codec
*codec
)
3865 struct conexant_spec
*spec
= codec
->spec
;
3866 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3868 if (spec
->multiout
.dig_out_nid
)
3869 snd_hda_codec_write(codec
, cfg
->dig_out_pins
[0], 0,
3870 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
3871 if (spec
->dig_in_nid
)
3872 snd_hda_codec_write(codec
, cfg
->dig_in_pin
, 0,
3873 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
);
3876 static int cx_auto_init(struct hda_codec
*codec
)
3878 /*snd_hda_sequence_write(codec, cx_auto_init_verbs);*/
3879 cx_auto_init_output(codec
);
3880 cx_auto_init_input(codec
);
3881 cx_auto_init_digital(codec
);
3885 static int cx_auto_add_volume_idx(struct hda_codec
*codec
, const char *basename
,
3886 const char *dir
, int cidx
,
3887 hda_nid_t nid
, int hda_dir
, int amp_idx
)
3889 static char name
[32];
3890 static struct snd_kcontrol_new knew
[] = {
3891 HDA_CODEC_VOLUME(name
, 0, 0, 0),
3892 HDA_CODEC_MUTE(name
, 0, 0, 0),
3894 static const char * const sfx
[2] = { "Volume", "Switch" };
3897 for (i
= 0; i
< 2; i
++) {
3898 struct snd_kcontrol
*kctl
;
3899 knew
[i
].private_value
= HDA_COMPOSE_AMP_VAL(nid
, 3, amp_idx
,
3901 knew
[i
].subdevice
= HDA_SUBDEV_AMP_FLAG
;
3902 knew
[i
].index
= cidx
;
3903 snprintf(name
, sizeof(name
), "%s%s %s", basename
, dir
, sfx
[i
]);
3904 kctl
= snd_ctl_new1(&knew
[i
], codec
);
3907 err
= snd_hda_ctl_add(codec
, nid
, kctl
);
3910 if (!(query_amp_caps(codec
, nid
, hda_dir
) & AC_AMPCAP_MUTE
))
3916 #define cx_auto_add_volume(codec, str, dir, cidx, nid, hda_dir) \
3917 cx_auto_add_volume_idx(codec, str, dir, cidx, nid, hda_dir, 0)
3919 #define cx_auto_add_pb_volume(codec, nid, str, idx) \
3920 cx_auto_add_volume(codec, str, " Playback", idx, nid, HDA_OUTPUT)
3922 static int try_add_pb_volume(struct hda_codec
*codec
, hda_nid_t dac
,
3923 hda_nid_t pin
, const char *name
, int idx
)
3926 caps
= query_amp_caps(codec
, dac
, HDA_OUTPUT
);
3927 if (caps
& AC_AMPCAP_NUM_STEPS
)
3928 return cx_auto_add_pb_volume(codec
, dac
, name
, idx
);
3929 caps
= query_amp_caps(codec
, pin
, HDA_OUTPUT
);
3930 if (caps
& AC_AMPCAP_NUM_STEPS
)
3931 return cx_auto_add_pb_volume(codec
, pin
, name
, idx
);
3935 static int cx_auto_build_output_controls(struct hda_codec
*codec
)
3937 struct conexant_spec
*spec
= codec
->spec
;
3939 int num_line
= 0, num_hp
= 0, num_spk
= 0;
3940 static const char * const texts
[3] = { "Front", "Surround", "CLFE" };
3942 if (spec
->dac_info_filled
== 1)
3943 return try_add_pb_volume(codec
, spec
->dac_info
[0].dac
,
3944 spec
->dac_info
[0].pin
,
3947 for (i
= 0; i
< spec
->dac_info_filled
; i
++) {
3950 if (!spec
->dac_info
[i
].dac
)
3952 type
= spec
->dac_info
[i
].type
;
3953 if (type
== AUTO_PIN_LINE_OUT
)
3954 type
= spec
->autocfg
.line_out_type
;
3956 case AUTO_PIN_LINE_OUT
:
3958 label
= texts
[num_line
++];
3961 case AUTO_PIN_HP_OUT
:
3962 label
= "Headphone";
3965 case AUTO_PIN_SPEAKER_OUT
:
3970 err
= try_add_pb_volume(codec
, spec
->dac_info
[i
].dac
,
3971 spec
->dac_info
[i
].pin
,
3979 static int cx_auto_add_capture_volume(struct hda_codec
*codec
, hda_nid_t nid
,
3980 const char *label
, const char *pfx
,
3983 struct conexant_spec
*spec
= codec
->spec
;
3986 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
3987 hda_nid_t adc_nid
= spec
->adc_nids
[i
];
3988 int idx
= get_input_connection(codec
, adc_nid
, nid
);
3991 return cx_auto_add_volume_idx(codec
, label
, pfx
,
3992 cidx
, adc_nid
, HDA_INPUT
, idx
);
3997 static int cx_auto_add_boost_volume(struct hda_codec
*codec
, int idx
,
3998 const char *label
, int cidx
)
4000 struct conexant_spec
*spec
= codec
->spec
;
4004 nid
= spec
->imux_pins
[idx
];
4005 if (get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
)
4006 return cx_auto_add_volume(codec
, label
, " Boost", cidx
,
4008 con
= __select_input_connection(codec
, spec
->imux_adcs
[idx
], nid
, &mux
,
4012 for (i
= 0; i
< idx
; i
++) {
4013 if (spec
->imux_boost_nid
[i
] == mux
)
4014 return 0; /* already present */
4017 if (get_wcaps(codec
, mux
) & AC_WCAP_OUT_AMP
) {
4018 spec
->imux_boost_nid
[idx
] = mux
;
4019 return cx_auto_add_volume(codec
, label
, " Boost", 0,
4025 static int cx_auto_build_input_controls(struct hda_codec
*codec
)
4027 struct conexant_spec
*spec
= codec
->spec
;
4028 struct hda_input_mux
*imux
= &spec
->private_imux
;
4029 const char *prev_label
;
4030 int input_conn
[HDA_MAX_NUM_INPUTS
];
4032 int multi_connection
;
4034 multi_connection
= 0;
4035 for (i
= 0; i
< imux
->num_items
; i
++) {
4036 cidx
= get_input_connection(codec
, spec
->imux_adcs
[i
],
4037 spec
->imux_pins
[i
]);
4038 input_conn
[i
] = (spec
->imux_adcs
[i
] << 8) | cidx
;
4039 if (i
> 0 && input_conn
[i
] != input_conn
[0])
4040 multi_connection
= 1;
4045 for (i
= 0; i
< imux
->num_items
; i
++) {
4046 hda_nid_t nid
= spec
->imux_pins
[i
];
4049 label
= hda_get_autocfg_input_label(codec
, &spec
->autocfg
,
4050 spec
->imux_cfg_idx
[i
]);
4051 if (label
== prev_label
)
4057 err
= cx_auto_add_boost_volume(codec
, i
, label
, cidx
);
4061 if (!multi_connection
) {
4064 err
= cx_auto_add_capture_volume(codec
, nid
,
4065 "Capture", "", cidx
);
4067 err
= cx_auto_add_capture_volume(codec
, nid
,
4068 label
, " Capture", cidx
);
4074 if (spec
->private_imux
.num_items
> 1 && !spec
->auto_mic
) {
4075 err
= snd_hda_add_new_ctls(codec
, cx_auto_capture_mixers
);
4083 static int cx_auto_build_controls(struct hda_codec
*codec
)
4087 err
= cx_auto_build_output_controls(codec
);
4090 err
= cx_auto_build_input_controls(codec
);
4093 return conexant_build_controls(codec
);
4096 static int cx_auto_search_adcs(struct hda_codec
*codec
)
4098 struct conexant_spec
*spec
= codec
->spec
;
4099 hda_nid_t nid
, end_nid
;
4101 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
4102 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
4103 unsigned int caps
= get_wcaps(codec
, nid
);
4104 if (get_wcaps_type(caps
) != AC_WID_AUD_IN
)
4106 if (caps
& AC_WCAP_DIGITAL
)
4108 if (snd_BUG_ON(spec
->num_adc_nids
>=
4109 ARRAY_SIZE(spec
->private_adc_nids
)))
4111 spec
->private_adc_nids
[spec
->num_adc_nids
++] = nid
;
4113 spec
->adc_nids
= spec
->private_adc_nids
;
4118 static const struct hda_codec_ops cx_auto_patch_ops
= {
4119 .build_controls
= cx_auto_build_controls
,
4120 .build_pcms
= conexant_build_pcms
,
4121 .init
= cx_auto_init
,
4122 .free
= conexant_free
,
4123 .unsol_event
= cx_auto_unsol_event
,
4124 #ifdef CONFIG_SND_HDA_POWER_SAVE
4125 .suspend
= conexant_suspend
,
4127 .reboot_notify
= snd_hda_shutup_pins
,
4130 static int patch_conexant_auto(struct hda_codec
*codec
)
4132 struct conexant_spec
*spec
;
4135 printk(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
4138 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4142 codec
->pin_amp_workaround
= 1;
4143 err
= cx_auto_search_adcs(codec
);
4146 err
= cx_auto_parse_auto_config(codec
);
4152 spec
->capture_stream
= &cx_auto_pcm_analog_capture
;
4153 codec
->patch_ops
= cx_auto_patch_ops
;
4155 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
4162 static const struct hda_codec_preset snd_hda_preset_conexant
[] = {
4163 { .id
= 0x14f15045, .name
= "CX20549 (Venice)",
4164 .patch
= patch_cxt5045
},
4165 { .id
= 0x14f15047, .name
= "CX20551 (Waikiki)",
4166 .patch
= patch_cxt5047
},
4167 { .id
= 0x14f15051, .name
= "CX20561 (Hermosa)",
4168 .patch
= patch_cxt5051
},
4169 { .id
= 0x14f15066, .name
= "CX20582 (Pebble)",
4170 .patch
= patch_cxt5066
},
4171 { .id
= 0x14f15067, .name
= "CX20583 (Pebble HSF)",
4172 .patch
= patch_cxt5066
},
4173 { .id
= 0x14f15068, .name
= "CX20584",
4174 .patch
= patch_cxt5066
},
4175 { .id
= 0x14f15069, .name
= "CX20585",
4176 .patch
= patch_cxt5066
},
4177 { .id
= 0x14f1506e, .name
= "CX20590",
4178 .patch
= patch_cxt5066
},
4179 { .id
= 0x14f15097, .name
= "CX20631",
4180 .patch
= patch_conexant_auto
},
4181 { .id
= 0x14f15098, .name
= "CX20632",
4182 .patch
= patch_conexant_auto
},
4183 { .id
= 0x14f150a1, .name
= "CX20641",
4184 .patch
= patch_conexant_auto
},
4185 { .id
= 0x14f150a2, .name
= "CX20642",
4186 .patch
= patch_conexant_auto
},
4187 { .id
= 0x14f150ab, .name
= "CX20651",
4188 .patch
= patch_conexant_auto
},
4189 { .id
= 0x14f150ac, .name
= "CX20652",
4190 .patch
= patch_conexant_auto
},
4191 { .id
= 0x14f150b8, .name
= "CX20664",
4192 .patch
= patch_conexant_auto
},
4193 { .id
= 0x14f150b9, .name
= "CX20665",
4194 .patch
= patch_conexant_auto
},
4198 MODULE_ALIAS("snd-hda-codec-id:14f15045");
4199 MODULE_ALIAS("snd-hda-codec-id:14f15047");
4200 MODULE_ALIAS("snd-hda-codec-id:14f15051");
4201 MODULE_ALIAS("snd-hda-codec-id:14f15066");
4202 MODULE_ALIAS("snd-hda-codec-id:14f15067");
4203 MODULE_ALIAS("snd-hda-codec-id:14f15068");
4204 MODULE_ALIAS("snd-hda-codec-id:14f15069");
4205 MODULE_ALIAS("snd-hda-codec-id:14f1506e");
4206 MODULE_ALIAS("snd-hda-codec-id:14f15097");
4207 MODULE_ALIAS("snd-hda-codec-id:14f15098");
4208 MODULE_ALIAS("snd-hda-codec-id:14f150a1");
4209 MODULE_ALIAS("snd-hda-codec-id:14f150a2");
4210 MODULE_ALIAS("snd-hda-codec-id:14f150ab");
4211 MODULE_ALIAS("snd-hda-codec-id:14f150ac");
4212 MODULE_ALIAS("snd-hda-codec-id:14f150b8");
4213 MODULE_ALIAS("snd-hda-codec-id:14f150b9");
4215 MODULE_LICENSE("GPL");
4216 MODULE_DESCRIPTION("Conexant HD-audio codec");
4218 static struct hda_codec_preset_list conexant_list
= {
4219 .preset
= snd_hda_preset_conexant
,
4220 .owner
= THIS_MODULE
,
4223 static int __init
patch_conexant_init(void)
4225 return snd_hda_add_codec_preset(&conexant_list
);
4228 static void __exit
patch_conexant_exit(void)
4230 snd_hda_delete_codec_preset(&conexant_list
);
4233 module_init(patch_conexant_init
)
4234 module_exit(patch_conexant_exit
)