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 hda_nid_t imux_adcs
[HDA_MAX_NUM_INPUTS
];
112 hda_nid_t imux_pins
[HDA_MAX_NUM_INPUTS
];
113 hda_nid_t private_adc_nids
[HDA_MAX_NUM_INPUTS
];
114 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
115 struct pin_dac_pair dac_info
[8];
118 unsigned int port_d_mode
;
119 unsigned int auto_mute
:1; /* used in auto-parser */
120 unsigned int dell_automute
:1;
121 unsigned int dell_vostro
:1;
122 unsigned int ideapad
:1;
123 unsigned int thinkpad
:1;
124 unsigned int hp_laptop
:1;
127 unsigned int adc_switching
:1;
129 unsigned int ext_mic_present
;
130 unsigned int recording
;
131 void (*capture_prepare
)(struct hda_codec
*codec
);
132 void (*capture_cleanup
)(struct hda_codec
*codec
);
134 /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
135 * through the microphone jack.
136 * When the user enables this through a mixer switch, both internal and
137 * external microphones are disabled. Gain is fixed at 0dB. In this mode,
138 * we also allow the bias to be configured through a separate mixer
140 unsigned int dc_enable
;
141 unsigned int dc_input_bias
; /* offset into cxt5066_olpc_dc_bias */
142 unsigned int mic_boost
; /* offset into cxt5066_analog_mic_boost */
144 unsigned int beep_amp
;
147 static int conexant_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
148 struct hda_codec
*codec
,
149 struct snd_pcm_substream
*substream
)
151 struct conexant_spec
*spec
= codec
->spec
;
152 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
156 static int conexant_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
157 struct hda_codec
*codec
,
158 unsigned int stream_tag
,
160 struct snd_pcm_substream
*substream
)
162 struct conexant_spec
*spec
= codec
->spec
;
163 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
168 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
169 struct hda_codec
*codec
,
170 struct snd_pcm_substream
*substream
)
172 struct conexant_spec
*spec
= codec
->spec
;
173 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
179 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
180 struct hda_codec
*codec
,
181 struct snd_pcm_substream
*substream
)
183 struct conexant_spec
*spec
= codec
->spec
;
184 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
187 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
188 struct hda_codec
*codec
,
189 struct snd_pcm_substream
*substream
)
191 struct conexant_spec
*spec
= codec
->spec
;
192 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
195 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
196 struct hda_codec
*codec
,
197 unsigned int stream_tag
,
199 struct snd_pcm_substream
*substream
)
201 struct conexant_spec
*spec
= codec
->spec
;
202 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
210 static int conexant_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
211 struct hda_codec
*codec
,
212 unsigned int stream_tag
,
214 struct snd_pcm_substream
*substream
)
216 struct conexant_spec
*spec
= codec
->spec
;
217 if (spec
->capture_prepare
)
218 spec
->capture_prepare(codec
);
219 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
220 stream_tag
, 0, format
);
224 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
225 struct hda_codec
*codec
,
226 struct snd_pcm_substream
*substream
)
228 struct conexant_spec
*spec
= codec
->spec
;
229 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
230 if (spec
->capture_cleanup
)
231 spec
->capture_cleanup(codec
);
237 static const struct hda_pcm_stream conexant_pcm_analog_playback
= {
241 .nid
= 0, /* fill later */
243 .open
= conexant_playback_pcm_open
,
244 .prepare
= conexant_playback_pcm_prepare
,
245 .cleanup
= conexant_playback_pcm_cleanup
249 static const struct hda_pcm_stream conexant_pcm_analog_capture
= {
253 .nid
= 0, /* fill later */
255 .prepare
= conexant_capture_pcm_prepare
,
256 .cleanup
= conexant_capture_pcm_cleanup
261 static const struct hda_pcm_stream conexant_pcm_digital_playback
= {
265 .nid
= 0, /* fill later */
267 .open
= conexant_dig_playback_pcm_open
,
268 .close
= conexant_dig_playback_pcm_close
,
269 .prepare
= conexant_dig_playback_pcm_prepare
273 static const struct hda_pcm_stream conexant_pcm_digital_capture
= {
277 /* NID is set in alc_build_pcms */
280 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
281 struct hda_codec
*codec
,
282 unsigned int stream_tag
,
284 struct snd_pcm_substream
*substream
)
286 struct conexant_spec
*spec
= codec
->spec
;
287 spec
->cur_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
288 spec
->cur_adc_stream_tag
= stream_tag
;
289 spec
->cur_adc_format
= format
;
290 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
294 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
295 struct hda_codec
*codec
,
296 struct snd_pcm_substream
*substream
)
298 struct conexant_spec
*spec
= codec
->spec
;
299 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
304 static const struct hda_pcm_stream cx5051_pcm_analog_capture
= {
308 .nid
= 0, /* fill later */
310 .prepare
= cx5051_capture_pcm_prepare
,
311 .cleanup
= cx5051_capture_pcm_cleanup
315 static int conexant_build_pcms(struct hda_codec
*codec
)
317 struct conexant_spec
*spec
= codec
->spec
;
318 struct hda_pcm
*info
= spec
->pcm_rec
;
321 codec
->pcm_info
= info
;
323 info
->name
= "CONEXANT Analog";
324 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = conexant_pcm_analog_playback
;
325 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
=
326 spec
->multiout
.max_channels
;
327 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
328 spec
->multiout
.dac_nids
[0];
329 if (spec
->capture_stream
)
330 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *spec
->capture_stream
;
332 if (codec
->vendor_id
== 0x14f15051)
333 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
334 cx5051_pcm_analog_capture
;
336 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
337 conexant_pcm_analog_capture
;
338 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
=
342 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
344 if (spec
->multiout
.dig_out_nid
) {
347 info
->name
= "Conexant Digital";
348 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
349 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
350 conexant_pcm_digital_playback
;
351 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
352 spec
->multiout
.dig_out_nid
;
353 if (spec
->dig_in_nid
) {
354 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
355 conexant_pcm_digital_capture
;
356 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
359 if (spec
->slave_dig_outs
[0])
360 codec
->slave_dig_outs
= spec
->slave_dig_outs
;
366 static int conexant_mux_enum_info(struct snd_kcontrol
*kcontrol
,
367 struct snd_ctl_elem_info
*uinfo
)
369 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
370 struct conexant_spec
*spec
= codec
->spec
;
372 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
375 static int conexant_mux_enum_get(struct snd_kcontrol
*kcontrol
,
376 struct snd_ctl_elem_value
*ucontrol
)
378 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
379 struct conexant_spec
*spec
= codec
->spec
;
380 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
382 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
386 static int conexant_mux_enum_put(struct snd_kcontrol
*kcontrol
,
387 struct snd_ctl_elem_value
*ucontrol
)
389 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
390 struct conexant_spec
*spec
= codec
->spec
;
391 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
393 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
394 spec
->capsrc_nids
[adc_idx
],
395 &spec
->cur_mux
[adc_idx
]);
398 static int conexant_init_jacks(struct hda_codec
*codec
)
400 #ifdef CONFIG_SND_HDA_INPUT_JACK
401 struct conexant_spec
*spec
= codec
->spec
;
404 for (i
= 0; i
< spec
->num_init_verbs
; i
++) {
405 const struct hda_verb
*hv
;
407 hv
= spec
->init_verbs
[i
];
410 switch (hv
->param
^ AC_USRSP_EN
) {
411 case CONEXANT_HP_EVENT
:
412 err
= snd_hda_input_jack_add(codec
, hv
->nid
,
413 SND_JACK_HEADPHONE
, NULL
);
414 snd_hda_input_jack_report(codec
, hv
->nid
);
416 case CXT5051_PORTC_EVENT
:
417 case CONEXANT_MIC_EVENT
:
418 err
= snd_hda_input_jack_add(codec
, hv
->nid
,
419 SND_JACK_MICROPHONE
, NULL
);
420 snd_hda_input_jack_report(codec
, hv
->nid
);
428 #endif /* CONFIG_SND_HDA_INPUT_JACK */
432 static int conexant_init(struct hda_codec
*codec
)
434 struct conexant_spec
*spec
= codec
->spec
;
437 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
438 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
442 static void conexant_free(struct hda_codec
*codec
)
444 snd_hda_input_jack_free(codec
);
445 snd_hda_detach_beep_device(codec
);
449 static const struct snd_kcontrol_new cxt_capture_mixers
[] = {
451 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
452 .name
= "Capture Source",
453 .info
= conexant_mux_enum_info
,
454 .get
= conexant_mux_enum_get
,
455 .put
= conexant_mux_enum_put
460 #ifdef CONFIG_SND_HDA_INPUT_BEEP
461 /* additional beep mixers; the actual parameters are overwritten at build */
462 static const struct snd_kcontrol_new cxt_beep_mixer
[] = {
463 HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT
),
464 HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT
),
469 static const char * const slave_vols
[] = {
470 "Headphone Playback Volume",
471 "Speaker Playback Volume",
475 static const char * const slave_sws
[] = {
476 "Headphone Playback Switch",
477 "Speaker Playback Switch",
481 static int conexant_build_controls(struct hda_codec
*codec
)
483 struct conexant_spec
*spec
= codec
->spec
;
487 for (i
= 0; i
< spec
->num_mixers
; i
++) {
488 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
492 if (spec
->multiout
.dig_out_nid
) {
493 err
= snd_hda_create_spdif_out_ctls(codec
,
494 spec
->multiout
.dig_out_nid
);
497 err
= snd_hda_create_spdif_share_sw(codec
,
501 spec
->multiout
.share_spdif
= 1;
503 if (spec
->dig_in_nid
) {
504 err
= snd_hda_create_spdif_in_ctls(codec
,spec
->dig_in_nid
);
509 /* if we have no master control, let's create it */
510 if (spec
->vmaster_nid
&&
511 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
512 unsigned int vmaster_tlv
[4];
513 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
514 HDA_OUTPUT
, vmaster_tlv
);
515 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
516 vmaster_tlv
, slave_vols
);
520 if (spec
->vmaster_nid
&&
521 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
522 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
528 if (spec
->input_mux
) {
529 err
= snd_hda_add_new_ctls(codec
, cxt_capture_mixers
);
534 #ifdef CONFIG_SND_HDA_INPUT_BEEP
535 /* create beep controls if needed */
536 if (spec
->beep_amp
) {
537 const struct snd_kcontrol_new
*knew
;
538 for (knew
= cxt_beep_mixer
; knew
->name
; knew
++) {
539 struct snd_kcontrol
*kctl
;
540 kctl
= snd_ctl_new1(knew
, codec
);
543 kctl
->private_value
= spec
->beep_amp
;
544 err
= snd_hda_ctl_add(codec
, 0, kctl
);
554 #ifdef CONFIG_SND_HDA_POWER_SAVE
555 static int conexant_suspend(struct hda_codec
*codec
, pm_message_t state
)
557 snd_hda_shutup_pins(codec
);
562 static const struct hda_codec_ops conexant_patch_ops
= {
563 .build_controls
= conexant_build_controls
,
564 .build_pcms
= conexant_build_pcms
,
565 .init
= conexant_init
,
566 .free
= conexant_free
,
567 #ifdef CONFIG_SND_HDA_POWER_SAVE
568 .suspend
= conexant_suspend
,
570 .reboot_notify
= snd_hda_shutup_pins
,
573 #ifdef CONFIG_SND_HDA_INPUT_BEEP
574 #define set_beep_amp(spec, nid, idx, dir) \
575 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir))
577 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
580 static int patch_conexant_auto(struct hda_codec
*codec
);
583 * the private value = nid | (invert << 8)
586 #define cxt_eapd_info snd_ctl_boolean_mono_info
588 static int cxt_eapd_get(struct snd_kcontrol
*kcontrol
,
589 struct snd_ctl_elem_value
*ucontrol
)
591 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
592 struct conexant_spec
*spec
= codec
->spec
;
593 int invert
= (kcontrol
->private_value
>> 8) & 1;
595 ucontrol
->value
.integer
.value
[0] = !spec
->cur_eapd
;
597 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
602 static int cxt_eapd_put(struct snd_kcontrol
*kcontrol
,
603 struct snd_ctl_elem_value
*ucontrol
)
605 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
606 struct conexant_spec
*spec
= codec
->spec
;
607 int invert
= (kcontrol
->private_value
>> 8) & 1;
608 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
611 eapd
= !!ucontrol
->value
.integer
.value
[0];
614 if (eapd
== spec
->cur_eapd
)
617 spec
->cur_eapd
= eapd
;
618 snd_hda_codec_write_cache(codec
, nid
,
619 0, AC_VERB_SET_EAPD_BTLENABLE
,
624 /* controls for test mode */
625 #ifdef CONFIG_SND_DEBUG
627 #define CXT_EAPD_SWITCH(xname, nid, mask) \
628 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
629 .info = cxt_eapd_info, \
630 .get = cxt_eapd_get, \
631 .put = cxt_eapd_put, \
632 .private_value = nid | (mask<<16) }
636 static int conexant_ch_mode_info(struct snd_kcontrol
*kcontrol
,
637 struct snd_ctl_elem_info
*uinfo
)
639 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
640 struct conexant_spec
*spec
= codec
->spec
;
641 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
642 spec
->num_channel_mode
);
645 static int conexant_ch_mode_get(struct snd_kcontrol
*kcontrol
,
646 struct snd_ctl_elem_value
*ucontrol
)
648 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
649 struct conexant_spec
*spec
= codec
->spec
;
650 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
651 spec
->num_channel_mode
,
652 spec
->multiout
.max_channels
);
655 static int conexant_ch_mode_put(struct snd_kcontrol
*kcontrol
,
656 struct snd_ctl_elem_value
*ucontrol
)
658 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
659 struct conexant_spec
*spec
= codec
->spec
;
660 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
661 spec
->num_channel_mode
,
662 &spec
->multiout
.max_channels
);
663 if (err
>= 0 && spec
->need_dac_fix
)
664 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
668 #define CXT_PIN_MODE(xname, nid, dir) \
669 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
670 .info = conexant_ch_mode_info, \
671 .get = conexant_ch_mode_get, \
672 .put = conexant_ch_mode_put, \
673 .private_value = nid | (dir<<16) }
675 #endif /* CONFIG_SND_DEBUG */
677 /* Conexant 5045 specific */
679 static const hda_nid_t cxt5045_dac_nids
[1] = { 0x19 };
680 static const hda_nid_t cxt5045_adc_nids
[1] = { 0x1a };
681 static const hda_nid_t cxt5045_capsrc_nids
[1] = { 0x1a };
682 #define CXT5045_SPDIF_OUT 0x18
684 static const struct hda_channel_mode cxt5045_modes
[1] = {
688 static const struct hda_input_mux cxt5045_capture_source
= {
696 static const struct hda_input_mux cxt5045_capture_source_benq
= {
707 static const struct hda_input_mux cxt5045_capture_source_hp530
= {
715 /* turn on/off EAPD (+ mute HP) as a master switch */
716 static int cxt5045_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
717 struct snd_ctl_elem_value
*ucontrol
)
719 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
720 struct conexant_spec
*spec
= codec
->spec
;
723 if (!cxt_eapd_put(kcontrol
, ucontrol
))
726 /* toggle internal speakers mute depending of presence of
729 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
730 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
733 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
734 snd_hda_codec_amp_stereo(codec
, 0x11, HDA_OUTPUT
, 0,
739 /* bind volumes of both NID 0x10 and 0x11 */
740 static const struct hda_bind_ctls cxt5045_hp_bind_master_vol
= {
741 .ops
= &snd_hda_bind_vol
,
743 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT
),
744 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT
),
749 /* toggle input of built-in and mic jack appropriately */
750 static void cxt5045_hp_automic(struct hda_codec
*codec
)
752 static const struct hda_verb mic_jack_on
[] = {
753 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
754 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
757 static const struct hda_verb mic_jack_off
[] = {
758 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
759 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
762 unsigned int present
;
764 present
= snd_hda_jack_detect(codec
, 0x12);
766 snd_hda_sequence_write(codec
, mic_jack_on
);
768 snd_hda_sequence_write(codec
, mic_jack_off
);
772 /* mute internal speaker if HP is plugged */
773 static void cxt5045_hp_automute(struct hda_codec
*codec
)
775 struct conexant_spec
*spec
= codec
->spec
;
778 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x11);
780 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
781 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
785 /* unsolicited event for HP jack sensing */
786 static void cxt5045_hp_unsol_event(struct hda_codec
*codec
,
791 case CONEXANT_HP_EVENT
:
792 cxt5045_hp_automute(codec
);
794 case CONEXANT_MIC_EVENT
:
795 cxt5045_hp_automic(codec
);
801 static const struct snd_kcontrol_new cxt5045_mixers
[] = {
802 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
803 HDA_CODEC_MUTE("Internal Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
804 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
805 HDA_CODEC_MUTE("Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
806 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
807 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
808 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
809 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
811 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
812 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
814 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
815 .name
= "Master Playback Switch",
816 .info
= cxt_eapd_info
,
818 .put
= cxt5045_hp_master_sw_put
,
819 .private_value
= 0x10,
825 static const struct snd_kcontrol_new cxt5045_benq_mixers
[] = {
826 HDA_CODEC_VOLUME("CD Capture Volume", 0x1a, 0x04, HDA_INPUT
),
827 HDA_CODEC_MUTE("CD Capture Switch", 0x1a, 0x04, HDA_INPUT
),
828 HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x4, HDA_INPUT
),
829 HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x4, HDA_INPUT
),
831 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT
),
832 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT
),
833 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT
),
834 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT
),
836 HDA_CODEC_VOLUME("Mixer Capture Volume", 0x1a, 0x0, HDA_INPUT
),
837 HDA_CODEC_MUTE("Mixer Capture Switch", 0x1a, 0x0, HDA_INPUT
),
842 static const struct snd_kcontrol_new cxt5045_mixers_hp530
[] = {
843 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
844 HDA_CODEC_MUTE("Internal Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
845 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
846 HDA_CODEC_MUTE("Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
847 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
848 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
849 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
850 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
851 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
852 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
853 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
855 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
856 .name
= "Master Playback Switch",
857 .info
= cxt_eapd_info
,
859 .put
= cxt5045_hp_master_sw_put
,
860 .private_value
= 0x10,
866 static const struct hda_verb cxt5045_init_verbs
[] = {
868 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
869 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
871 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
872 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
873 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
874 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
875 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
876 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
877 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
878 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
879 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
880 /* Record selector: Internal mic */
881 {0x1a, AC_VERB_SET_CONNECT_SEL
,0x1},
882 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
883 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
884 /* SPDIF route: PCM */
885 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
886 { 0x13, AC_VERB_SET_CONNECT_SEL
, 0x0 },
888 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2 }, /* default on */
892 static const struct hda_verb cxt5045_benq_init_verbs
[] = {
893 /* Internal Mic, Mic */
894 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
895 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
896 /* Line In,HP, Amp */
897 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
898 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
899 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
900 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
901 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
902 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
903 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
904 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
905 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
906 /* Record selector: Internal mic */
907 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x1},
908 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
909 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
910 /* SPDIF route: PCM */
911 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
912 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0},
914 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
918 static const struct hda_verb cxt5045_hp_sense_init_verbs
[] = {
919 /* pin sensing on HP jack */
920 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
924 static const struct hda_verb cxt5045_mic_sense_init_verbs
[] = {
925 /* pin sensing on HP jack */
926 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
930 #ifdef CONFIG_SND_DEBUG
931 /* Test configuration for debugging, modelled after the ALC260 test
934 static const struct hda_input_mux cxt5045_test_capture_source
= {
939 { "LINE1 pin", 0x2 },
940 { "HP-OUT pin", 0x3 },
945 static const struct snd_kcontrol_new cxt5045_test_mixer
[] = {
947 /* Output controls */
948 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
949 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
950 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
951 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
952 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
953 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
955 /* Modes for retasking pin widgets */
956 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT
),
957 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT
),
959 /* EAPD Switch Control */
960 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
962 /* Loopback mixer controls */
964 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT
),
965 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT
),
966 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT
),
967 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT
),
968 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT
),
969 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT
),
970 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT
),
971 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT
),
972 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT
),
973 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT
),
975 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
976 .name
= "Input Source",
977 .info
= conexant_mux_enum_info
,
978 .get
= conexant_mux_enum_get
,
979 .put
= conexant_mux_enum_put
,
981 /* Audio input controls */
982 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT
),
983 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT
),
984 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT
),
985 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT
),
986 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT
),
987 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT
),
988 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT
),
989 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT
),
990 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT
),
991 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT
),
995 static const struct hda_verb cxt5045_test_init_verbs
[] = {
996 /* Set connections */
997 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
998 { 0x11, AC_VERB_SET_CONNECT_SEL
, 0x0 },
999 { 0x12, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1000 /* Enable retasking pins as output, initially without power amp */
1001 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1002 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1004 /* Disable digital (SPDIF) pins initially, but users can enable
1005 * them via a mixer switch. In the case of SPDIF-out, this initverb
1006 * payload also sets the generation to 0, output to be in "consumer"
1007 * PCM format, copyright asserted, no pre-emphasis and no validity
1010 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1011 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1013 /* Start with output sum widgets muted and their output gains at min */
1014 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1015 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1017 /* Unmute retasking pin widget output buffers since the default
1018 * state appears to be output. As the pin mode is changed by the
1019 * user the pin mode control will take care of enabling the pin's
1020 * input/output buffers as needed.
1022 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1023 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1025 /* Mute capture amp left and right */
1026 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1028 /* Set ADC connection select to match default mixer setting (mic1
1031 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1032 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x00},
1034 /* Mute all inputs to mixer widget (even unconnected ones) */
1035 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* Mixer pin */
1036 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* Mic1 pin */
1037 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* Line pin */
1038 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* HP pin */
1039 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1046 /* initialize jack-sensing, too */
1047 static int cxt5045_init(struct hda_codec
*codec
)
1049 conexant_init(codec
);
1050 cxt5045_hp_automute(codec
);
1056 CXT5045_LAPTOP_HPSENSE
,
1057 CXT5045_LAPTOP_MICSENSE
,
1058 CXT5045_LAPTOP_HPMICSENSE
,
1060 CXT5045_LAPTOP_HP530
,
1061 #ifdef CONFIG_SND_DEBUG
1068 static const char * const cxt5045_models
[CXT5045_MODELS
] = {
1069 [CXT5045_LAPTOP_HPSENSE
] = "laptop-hpsense",
1070 [CXT5045_LAPTOP_MICSENSE
] = "laptop-micsense",
1071 [CXT5045_LAPTOP_HPMICSENSE
] = "laptop-hpmicsense",
1072 [CXT5045_BENQ
] = "benq",
1073 [CXT5045_LAPTOP_HP530
] = "laptop-hp530",
1074 #ifdef CONFIG_SND_DEBUG
1075 [CXT5045_TEST
] = "test",
1077 [CXT5045_AUTO
] = "auto",
1080 static const struct snd_pci_quirk cxt5045_cfg_tbl
[] = {
1081 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530
),
1082 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1083 CXT5045_LAPTOP_HPSENSE
),
1084 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE
),
1085 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ
),
1086 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE
),
1087 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE
),
1088 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
1089 CXT5045_LAPTOP_HPMICSENSE
),
1090 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1091 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1092 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1093 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
1094 CXT5045_LAPTOP_HPMICSENSE
),
1095 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE
),
1099 static int patch_cxt5045(struct hda_codec
*codec
)
1101 struct conexant_spec
*spec
;
1104 board_config
= snd_hda_check_board_config(codec
, CXT5045_MODELS
,
1107 #if 0 /* use the old method just for safety */
1108 if (board_config
< 0)
1109 board_config
= CXT5045_AUTO
;
1111 if (board_config
== CXT5045_AUTO
)
1112 return patch_conexant_auto(codec
);
1114 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1118 codec
->pin_amp_workaround
= 1;
1120 spec
->multiout
.max_channels
= 2;
1121 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5045_dac_nids
);
1122 spec
->multiout
.dac_nids
= cxt5045_dac_nids
;
1123 spec
->multiout
.dig_out_nid
= CXT5045_SPDIF_OUT
;
1124 spec
->num_adc_nids
= 1;
1125 spec
->adc_nids
= cxt5045_adc_nids
;
1126 spec
->capsrc_nids
= cxt5045_capsrc_nids
;
1127 spec
->input_mux
= &cxt5045_capture_source
;
1128 spec
->num_mixers
= 1;
1129 spec
->mixers
[0] = cxt5045_mixers
;
1130 spec
->num_init_verbs
= 1;
1131 spec
->init_verbs
[0] = cxt5045_init_verbs
;
1132 spec
->spdif_route
= 0;
1133 spec
->num_channel_mode
= ARRAY_SIZE(cxt5045_modes
);
1134 spec
->channel_mode
= cxt5045_modes
;
1136 set_beep_amp(spec
, 0x16, 0, 1);
1138 codec
->patch_ops
= conexant_patch_ops
;
1140 switch (board_config
) {
1141 case CXT5045_LAPTOP_HPSENSE
:
1142 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1143 spec
->input_mux
= &cxt5045_capture_source
;
1144 spec
->num_init_verbs
= 2;
1145 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1146 spec
->mixers
[0] = cxt5045_mixers
;
1147 codec
->patch_ops
.init
= cxt5045_init
;
1149 case CXT5045_LAPTOP_MICSENSE
:
1150 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1151 spec
->input_mux
= &cxt5045_capture_source
;
1152 spec
->num_init_verbs
= 2;
1153 spec
->init_verbs
[1] = cxt5045_mic_sense_init_verbs
;
1154 spec
->mixers
[0] = cxt5045_mixers
;
1155 codec
->patch_ops
.init
= cxt5045_init
;
1158 case CXT5045_LAPTOP_HPMICSENSE
:
1159 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1160 spec
->input_mux
= &cxt5045_capture_source
;
1161 spec
->num_init_verbs
= 3;
1162 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1163 spec
->init_verbs
[2] = cxt5045_mic_sense_init_verbs
;
1164 spec
->mixers
[0] = cxt5045_mixers
;
1165 codec
->patch_ops
.init
= cxt5045_init
;
1168 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1169 spec
->input_mux
= &cxt5045_capture_source_benq
;
1170 spec
->num_init_verbs
= 1;
1171 spec
->init_verbs
[0] = cxt5045_benq_init_verbs
;
1172 spec
->mixers
[0] = cxt5045_mixers
;
1173 spec
->mixers
[1] = cxt5045_benq_mixers
;
1174 spec
->num_mixers
= 2;
1175 codec
->patch_ops
.init
= cxt5045_init
;
1177 case CXT5045_LAPTOP_HP530
:
1178 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1179 spec
->input_mux
= &cxt5045_capture_source_hp530
;
1180 spec
->num_init_verbs
= 2;
1181 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1182 spec
->mixers
[0] = cxt5045_mixers_hp530
;
1183 codec
->patch_ops
.init
= cxt5045_init
;
1185 #ifdef CONFIG_SND_DEBUG
1187 spec
->input_mux
= &cxt5045_test_capture_source
;
1188 spec
->mixers
[0] = cxt5045_test_mixer
;
1189 spec
->init_verbs
[0] = cxt5045_test_init_verbs
;
1195 switch (codec
->subsystem_id
>> 16) {
1200 /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have
1201 * really bad sound over 0dB on NID 0x17. Fix max PCM level to
1202 * 0 dB (originally it has 0x2b steps with 0dB offset 0x14)
1204 snd_hda_override_amp_caps(codec
, 0x17, HDA_INPUT
,
1205 (0x14 << AC_AMPCAP_OFFSET_SHIFT
) |
1206 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1207 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1208 (1 << AC_AMPCAP_MUTE_SHIFT
));
1213 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
1219 /* Conexant 5047 specific */
1220 #define CXT5047_SPDIF_OUT 0x11
1222 static const hda_nid_t cxt5047_dac_nids
[1] = { 0x10 }; /* 0x1c */
1223 static const hda_nid_t cxt5047_adc_nids
[1] = { 0x12 };
1224 static const hda_nid_t cxt5047_capsrc_nids
[1] = { 0x1a };
1226 static const struct hda_channel_mode cxt5047_modes
[1] = {
1230 static const struct hda_input_mux cxt5047_toshiba_capture_source
= {
1238 /* turn on/off EAPD (+ mute HP) as a master switch */
1239 static int cxt5047_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1240 struct snd_ctl_elem_value
*ucontrol
)
1242 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1243 struct conexant_spec
*spec
= codec
->spec
;
1246 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1249 /* toggle internal speakers mute depending of presence of
1250 * the headphone jack
1252 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
1253 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1254 * pin widgets unlike other codecs. In this case, we need to
1255 * set index 0x01 for the volume from the mixer amp 0x19.
1257 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1258 HDA_AMP_MUTE
, bits
);
1259 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
1260 snd_hda_codec_amp_stereo(codec
, 0x13, HDA_OUTPUT
, 0,
1261 HDA_AMP_MUTE
, bits
);
1265 /* mute internal speaker if HP is plugged */
1266 static void cxt5047_hp_automute(struct hda_codec
*codec
)
1268 struct conexant_spec
*spec
= codec
->spec
;
1271 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x13);
1273 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
1274 /* See the note in cxt5047_hp_master_sw_put */
1275 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1276 HDA_AMP_MUTE
, bits
);
1279 /* toggle input of built-in and mic jack appropriately */
1280 static void cxt5047_hp_automic(struct hda_codec
*codec
)
1282 static const struct hda_verb mic_jack_on
[] = {
1283 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1284 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1287 static const struct hda_verb mic_jack_off
[] = {
1288 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1289 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1292 unsigned int present
;
1294 present
= snd_hda_jack_detect(codec
, 0x15);
1296 snd_hda_sequence_write(codec
, mic_jack_on
);
1298 snd_hda_sequence_write(codec
, mic_jack_off
);
1301 /* unsolicited event for HP jack sensing */
1302 static void cxt5047_hp_unsol_event(struct hda_codec
*codec
,
1305 switch (res
>> 26) {
1306 case CONEXANT_HP_EVENT
:
1307 cxt5047_hp_automute(codec
);
1309 case CONEXANT_MIC_EVENT
:
1310 cxt5047_hp_automic(codec
);
1315 static const struct snd_kcontrol_new cxt5047_base_mixers
[] = {
1316 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT
),
1317 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT
),
1318 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1319 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT
),
1320 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT
),
1321 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT
),
1322 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT
),
1324 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1325 .name
= "Master Playback Switch",
1326 .info
= cxt_eapd_info
,
1327 .get
= cxt_eapd_get
,
1328 .put
= cxt5047_hp_master_sw_put
,
1329 .private_value
= 0x13,
1335 static const struct snd_kcontrol_new cxt5047_hp_spk_mixers
[] = {
1336 /* See the note in cxt5047_hp_master_sw_put */
1337 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT
),
1338 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1342 static const struct snd_kcontrol_new cxt5047_hp_only_mixers
[] = {
1343 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1347 static const struct hda_verb cxt5047_init_verbs
[] = {
1348 /* Line in, Mic, Built-in Mic */
1349 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1350 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1351 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1353 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1354 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* mixer(0x19) */
1355 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mixer(0x19) */
1356 /* Record selector: Mic */
1357 {0x12, AC_VERB_SET_CONNECT_SEL
,0x03},
1358 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
,
1359 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
1360 {0x1A, AC_VERB_SET_CONNECT_SEL
,0x02},
1361 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1362 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x00},
1363 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1364 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x03},
1365 /* SPDIF route: PCM */
1366 { 0x18, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1367 /* Enable unsolicited events */
1368 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
1369 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1373 /* configuration for Toshiba Laptops */
1374 static const struct hda_verb cxt5047_toshiba_init_verbs
[] = {
1375 {0x13, AC_VERB_SET_EAPD_BTLENABLE
, 0x0}, /* default off */
1379 /* Test configuration for debugging, modelled after the ALC260 test
1382 #ifdef CONFIG_SND_DEBUG
1383 static const struct hda_input_mux cxt5047_test_capture_source
= {
1386 { "LINE1 pin", 0x0 },
1387 { "MIC1 pin", 0x1 },
1388 { "MIC2 pin", 0x2 },
1393 static const struct snd_kcontrol_new cxt5047_test_mixer
[] = {
1395 /* Output only controls */
1396 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT
),
1397 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT
),
1398 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT
),
1399 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT
),
1400 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1401 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1402 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1403 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1404 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT
),
1405 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT
),
1406 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
1407 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
1409 /* Modes for retasking pin widgets */
1410 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT
),
1411 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT
),
1413 /* EAPD Switch Control */
1414 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1416 /* Loopback mixer controls */
1417 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT
),
1418 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT
),
1419 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT
),
1420 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT
),
1421 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT
),
1422 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT
),
1423 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT
),
1424 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT
),
1426 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT
),
1427 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT
),
1428 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT
),
1429 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT
),
1430 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT
),
1431 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT
),
1432 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT
),
1433 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT
),
1435 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1436 .name
= "Input Source",
1437 .info
= conexant_mux_enum_info
,
1438 .get
= conexant_mux_enum_get
,
1439 .put
= conexant_mux_enum_put
,
1441 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1446 static const struct hda_verb cxt5047_test_init_verbs
[] = {
1447 /* Enable retasking pins as output, initially without power amp */
1448 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1449 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1450 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1452 /* Disable digital (SPDIF) pins initially, but users can enable
1453 * them via a mixer switch. In the case of SPDIF-out, this initverb
1454 * payload also sets the generation to 0, output to be in "consumer"
1455 * PCM format, copyright asserted, no pre-emphasis and no validity
1458 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1460 /* Ensure mic1, mic2, line1 pin widgets take input from the
1461 * OUT1 sum bus when acting as an output.
1463 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0},
1464 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0},
1466 /* Start with output sum widgets muted and their output gains at min */
1467 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1468 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1470 /* Unmute retasking pin widget output buffers since the default
1471 * state appears to be output. As the pin mode is changed by the
1472 * user the pin mode control will take care of enabling the pin's
1473 * input/output buffers as needed.
1475 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1476 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1477 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1479 /* Mute capture amp left and right */
1480 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1482 /* Set ADC connection select to match default mixer setting (mic1
1485 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x00},
1487 /* Mute all inputs to mixer widget (even unconnected ones) */
1488 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* mic1 pin */
1489 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* mic2 pin */
1490 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* line1 pin */
1491 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* line2 pin */
1492 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1493 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1494 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)}, /* Line-out pin */
1495 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)}, /* HP-pin pin */
1502 /* initialize jack-sensing, too */
1503 static int cxt5047_hp_init(struct hda_codec
*codec
)
1505 conexant_init(codec
);
1506 cxt5047_hp_automute(codec
);
1512 CXT5047_LAPTOP
, /* Laptops w/o EAPD support */
1513 CXT5047_LAPTOP_HP
, /* Some HP laptops */
1514 CXT5047_LAPTOP_EAPD
, /* Laptops with EAPD support */
1515 #ifdef CONFIG_SND_DEBUG
1522 static const char * const cxt5047_models
[CXT5047_MODELS
] = {
1523 [CXT5047_LAPTOP
] = "laptop",
1524 [CXT5047_LAPTOP_HP
] = "laptop-hp",
1525 [CXT5047_LAPTOP_EAPD
] = "laptop-eapd",
1526 #ifdef CONFIG_SND_DEBUG
1527 [CXT5047_TEST
] = "test",
1529 [CXT5047_AUTO
] = "auto",
1532 static const struct snd_pci_quirk cxt5047_cfg_tbl
[] = {
1533 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP
),
1534 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1536 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD
),
1540 static int patch_cxt5047(struct hda_codec
*codec
)
1542 struct conexant_spec
*spec
;
1545 board_config
= snd_hda_check_board_config(codec
, CXT5047_MODELS
,
1548 #if 0 /* not enabled as default, as BIOS often broken for this codec */
1549 if (board_config
< 0)
1550 board_config
= CXT5047_AUTO
;
1552 if (board_config
== CXT5047_AUTO
)
1553 return patch_conexant_auto(codec
);
1555 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1559 codec
->pin_amp_workaround
= 1;
1561 spec
->multiout
.max_channels
= 2;
1562 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5047_dac_nids
);
1563 spec
->multiout
.dac_nids
= cxt5047_dac_nids
;
1564 spec
->multiout
.dig_out_nid
= CXT5047_SPDIF_OUT
;
1565 spec
->num_adc_nids
= 1;
1566 spec
->adc_nids
= cxt5047_adc_nids
;
1567 spec
->capsrc_nids
= cxt5047_capsrc_nids
;
1568 spec
->num_mixers
= 1;
1569 spec
->mixers
[0] = cxt5047_base_mixers
;
1570 spec
->num_init_verbs
= 1;
1571 spec
->init_verbs
[0] = cxt5047_init_verbs
;
1572 spec
->spdif_route
= 0;
1573 spec
->num_channel_mode
= ARRAY_SIZE(cxt5047_modes
),
1574 spec
->channel_mode
= cxt5047_modes
,
1576 codec
->patch_ops
= conexant_patch_ops
;
1578 switch (board_config
) {
1579 case CXT5047_LAPTOP
:
1580 spec
->num_mixers
= 2;
1581 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1582 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1584 case CXT5047_LAPTOP_HP
:
1585 spec
->num_mixers
= 2;
1586 spec
->mixers
[1] = cxt5047_hp_only_mixers
;
1587 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1588 codec
->patch_ops
.init
= cxt5047_hp_init
;
1590 case CXT5047_LAPTOP_EAPD
:
1591 spec
->input_mux
= &cxt5047_toshiba_capture_source
;
1592 spec
->num_mixers
= 2;
1593 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1594 spec
->num_init_verbs
= 2;
1595 spec
->init_verbs
[1] = cxt5047_toshiba_init_verbs
;
1596 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1598 #ifdef CONFIG_SND_DEBUG
1600 spec
->input_mux
= &cxt5047_test_capture_source
;
1601 spec
->mixers
[0] = cxt5047_test_mixer
;
1602 spec
->init_verbs
[0] = cxt5047_test_init_verbs
;
1603 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1606 spec
->vmaster_nid
= 0x13;
1608 switch (codec
->subsystem_id
>> 16) {
1610 /* HP laptops have really bad sound over 0 dB on NID 0x10.
1611 * Fix max PCM level to 0 dB (originally it has 0x1e steps
1612 * with 0 dB offset 0x17)
1614 snd_hda_override_amp_caps(codec
, 0x10, HDA_INPUT
,
1615 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
1616 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1617 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1618 (1 << AC_AMPCAP_MUTE_SHIFT
));
1625 /* Conexant 5051 specific */
1626 static const hda_nid_t cxt5051_dac_nids
[1] = { 0x10 };
1627 static const hda_nid_t cxt5051_adc_nids
[2] = { 0x14, 0x15 };
1629 static const struct hda_channel_mode cxt5051_modes
[1] = {
1633 static void cxt5051_update_speaker(struct hda_codec
*codec
)
1635 struct conexant_spec
*spec
= codec
->spec
;
1636 unsigned int pinctl
;
1638 pinctl
= (spec
->hp_present
&& spec
->cur_eapd
) ? PIN_HP
: 0;
1639 snd_hda_codec_write(codec
, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1642 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1643 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1645 /* on ideapad there is an aditional speaker (subwoofer) to mute */
1647 snd_hda_codec_write(codec
, 0x1b, 0,
1648 AC_VERB_SET_PIN_WIDGET_CONTROL
,
1652 /* turn on/off EAPD (+ mute HP) as a master switch */
1653 static int cxt5051_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1654 struct snd_ctl_elem_value
*ucontrol
)
1656 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1658 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1660 cxt5051_update_speaker(codec
);
1664 /* toggle input of built-in and mic jack appropriately */
1665 static void cxt5051_portb_automic(struct hda_codec
*codec
)
1667 struct conexant_spec
*spec
= codec
->spec
;
1668 unsigned int present
;
1670 if (!(spec
->auto_mic
& AUTO_MIC_PORTB
))
1672 present
= snd_hda_jack_detect(codec
, 0x17);
1673 snd_hda_codec_write(codec
, 0x14, 0,
1674 AC_VERB_SET_CONNECT_SEL
,
1675 present
? 0x01 : 0x00);
1678 /* switch the current ADC according to the jack state */
1679 static void cxt5051_portc_automic(struct hda_codec
*codec
)
1681 struct conexant_spec
*spec
= codec
->spec
;
1682 unsigned int present
;
1685 if (!(spec
->auto_mic
& AUTO_MIC_PORTC
))
1687 present
= snd_hda_jack_detect(codec
, 0x18);
1689 spec
->cur_adc_idx
= 1;
1691 spec
->cur_adc_idx
= 0;
1692 new_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
1693 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
1694 /* stream is running, let's swap the current ADC */
1695 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
1696 spec
->cur_adc
= new_adc
;
1697 snd_hda_codec_setup_stream(codec
, new_adc
,
1698 spec
->cur_adc_stream_tag
, 0,
1699 spec
->cur_adc_format
);
1703 /* mute internal speaker if HP is plugged */
1704 static void cxt5051_hp_automute(struct hda_codec
*codec
)
1706 struct conexant_spec
*spec
= codec
->spec
;
1708 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x16);
1709 cxt5051_update_speaker(codec
);
1712 /* unsolicited event for HP jack sensing */
1713 static void cxt5051_hp_unsol_event(struct hda_codec
*codec
,
1716 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
1717 switch (res
>> 26) {
1718 case CONEXANT_HP_EVENT
:
1719 cxt5051_hp_automute(codec
);
1721 case CXT5051_PORTB_EVENT
:
1722 cxt5051_portb_automic(codec
);
1724 case CXT5051_PORTC_EVENT
:
1725 cxt5051_portc_automic(codec
);
1728 snd_hda_input_jack_report(codec
, nid
);
1731 static const struct snd_kcontrol_new cxt5051_playback_mixers
[] = {
1732 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1734 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1735 .name
= "Master Playback Switch",
1736 .info
= cxt_eapd_info
,
1737 .get
= cxt_eapd_get
,
1738 .put
= cxt5051_hp_master_sw_put
,
1739 .private_value
= 0x1a,
1744 static const struct snd_kcontrol_new cxt5051_capture_mixers
[] = {
1745 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1746 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1747 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT
),
1748 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT
),
1749 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT
),
1750 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT
),
1754 static const struct snd_kcontrol_new cxt5051_hp_mixers
[] = {
1755 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1756 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1757 HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT
),
1758 HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT
),
1762 static const struct snd_kcontrol_new cxt5051_hp_dv6736_mixers
[] = {
1763 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT
),
1764 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT
),
1768 static const struct snd_kcontrol_new cxt5051_f700_mixers
[] = {
1769 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT
),
1770 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT
),
1774 static const struct snd_kcontrol_new cxt5051_toshiba_mixers
[] = {
1775 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1776 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1777 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT
),
1778 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT
),
1782 static const struct hda_verb cxt5051_init_verbs
[] = {
1784 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1785 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1786 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1787 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1788 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1789 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1791 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1792 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1794 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1795 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1797 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1798 /* Record selector: Internal mic */
1799 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1800 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1801 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1802 /* SPDIF route: PCM */
1803 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1804 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1806 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1807 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1811 static const struct hda_verb cxt5051_hp_dv6736_init_verbs
[] = {
1813 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1814 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1815 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1816 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1818 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1819 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1821 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1822 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1824 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1825 /* Record selector: Internal mic */
1826 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1827 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1828 /* SPDIF route: PCM */
1829 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1831 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1832 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1836 static const struct hda_verb cxt5051_lenovo_x200_init_verbs
[] = {
1838 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1839 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1840 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1841 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1842 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1843 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1845 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1846 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1848 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1849 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1851 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1852 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00},
1854 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1855 /* Record selector: Internal mic */
1856 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1857 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1858 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1859 /* SPDIF route: PCM */
1860 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
}, /* needed for W500 Advanced Mini Dock 250410 */
1861 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1863 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1864 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1865 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1869 static const struct hda_verb cxt5051_f700_init_verbs
[] = {
1871 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1872 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1873 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1874 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1876 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1877 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1879 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1880 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1882 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1883 /* Record selector: Internal mic */
1884 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1885 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1886 /* SPDIF route: PCM */
1887 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1889 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1890 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1894 static void cxt5051_init_mic_port(struct hda_codec
*codec
, hda_nid_t nid
,
1897 snd_hda_codec_write(codec
, nid
, 0,
1898 AC_VERB_SET_UNSOLICITED_ENABLE
,
1899 AC_USRSP_EN
| event
);
1900 snd_hda_input_jack_add(codec
, nid
, SND_JACK_MICROPHONE
, NULL
);
1901 snd_hda_input_jack_report(codec
, nid
);
1904 static const struct hda_verb cxt5051_ideapad_init_verbs
[] = {
1906 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1907 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0x00},
1911 /* initialize jack-sensing, too */
1912 static int cxt5051_init(struct hda_codec
*codec
)
1914 struct conexant_spec
*spec
= codec
->spec
;
1916 conexant_init(codec
);
1917 conexant_init_jacks(codec
);
1919 if (spec
->auto_mic
& AUTO_MIC_PORTB
)
1920 cxt5051_init_mic_port(codec
, 0x17, CXT5051_PORTB_EVENT
);
1921 if (spec
->auto_mic
& AUTO_MIC_PORTC
)
1922 cxt5051_init_mic_port(codec
, 0x18, CXT5051_PORTC_EVENT
);
1924 if (codec
->patch_ops
.unsol_event
) {
1925 cxt5051_hp_automute(codec
);
1926 cxt5051_portb_automic(codec
);
1927 cxt5051_portc_automic(codec
);
1934 CXT5051_LAPTOP
, /* Laptops w/ EAPD support */
1935 CXT5051_HP
, /* no docking */
1936 CXT5051_HP_DV6736
, /* HP without mic switch */
1937 CXT5051_LENOVO_X200
, /* Lenovo X200 laptop, also used for Advanced Mini Dock 250410 */
1938 CXT5051_F700
, /* HP Compaq Presario F700 */
1939 CXT5051_TOSHIBA
, /* Toshiba M300 & co */
1940 CXT5051_IDEAPAD
, /* Lenovo IdeaPad Y430 */
1941 CXT5051_AUTO
, /* auto-parser */
1945 static const char *const cxt5051_models
[CXT5051_MODELS
] = {
1946 [CXT5051_LAPTOP
] = "laptop",
1947 [CXT5051_HP
] = "hp",
1948 [CXT5051_HP_DV6736
] = "hp-dv6736",
1949 [CXT5051_LENOVO_X200
] = "lenovo-x200",
1950 [CXT5051_F700
] = "hp-700",
1951 [CXT5051_TOSHIBA
] = "toshiba",
1952 [CXT5051_IDEAPAD
] = "ideapad",
1953 [CXT5051_AUTO
] = "auto",
1956 static const struct snd_pci_quirk cxt5051_cfg_tbl
[] = {
1957 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736
),
1958 SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP
),
1959 SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700
),
1960 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA
),
1961 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1963 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP
),
1964 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200
),
1965 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD
),
1969 static int patch_cxt5051(struct hda_codec
*codec
)
1971 struct conexant_spec
*spec
;
1974 board_config
= snd_hda_check_board_config(codec
, CXT5051_MODELS
,
1977 #if 0 /* use the old method just for safety */
1978 if (board_config
< 0)
1979 board_config
= CXT5051_AUTO
;
1981 if (board_config
== CXT5051_AUTO
)
1982 return patch_conexant_auto(codec
);
1984 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1988 codec
->pin_amp_workaround
= 1;
1990 codec
->patch_ops
= conexant_patch_ops
;
1991 codec
->patch_ops
.init
= cxt5051_init
;
1993 spec
->multiout
.max_channels
= 2;
1994 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5051_dac_nids
);
1995 spec
->multiout
.dac_nids
= cxt5051_dac_nids
;
1996 spec
->multiout
.dig_out_nid
= CXT5051_SPDIF_OUT
;
1997 spec
->num_adc_nids
= 1; /* not 2; via auto-mic switch */
1998 spec
->adc_nids
= cxt5051_adc_nids
;
1999 spec
->num_mixers
= 2;
2000 spec
->mixers
[0] = cxt5051_capture_mixers
;
2001 spec
->mixers
[1] = cxt5051_playback_mixers
;
2002 spec
->num_init_verbs
= 1;
2003 spec
->init_verbs
[0] = cxt5051_init_verbs
;
2004 spec
->spdif_route
= 0;
2005 spec
->num_channel_mode
= ARRAY_SIZE(cxt5051_modes
);
2006 spec
->channel_mode
= cxt5051_modes
;
2008 spec
->cur_adc_idx
= 0;
2010 set_beep_amp(spec
, 0x13, 0, HDA_OUTPUT
);
2012 codec
->patch_ops
.unsol_event
= cxt5051_hp_unsol_event
;
2014 spec
->auto_mic
= AUTO_MIC_PORTB
| AUTO_MIC_PORTC
;
2015 switch (board_config
) {
2017 spec
->mixers
[0] = cxt5051_hp_mixers
;
2019 case CXT5051_HP_DV6736
:
2020 spec
->init_verbs
[0] = cxt5051_hp_dv6736_init_verbs
;
2021 spec
->mixers
[0] = cxt5051_hp_dv6736_mixers
;
2024 case CXT5051_LENOVO_X200
:
2025 spec
->init_verbs
[0] = cxt5051_lenovo_x200_init_verbs
;
2026 /* Thinkpad X301 does not have S/PDIF wired and no ability
2027 to use a docking station. */
2028 if (codec
->subsystem_id
== 0x17aa211f)
2029 spec
->multiout
.dig_out_nid
= 0;
2032 spec
->init_verbs
[0] = cxt5051_f700_init_verbs
;
2033 spec
->mixers
[0] = cxt5051_f700_mixers
;
2036 case CXT5051_TOSHIBA
:
2037 spec
->mixers
[0] = cxt5051_toshiba_mixers
;
2038 spec
->auto_mic
= AUTO_MIC_PORTB
;
2040 case CXT5051_IDEAPAD
:
2041 spec
->init_verbs
[spec
->num_init_verbs
++] =
2042 cxt5051_ideapad_init_verbs
;
2048 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
2053 /* Conexant 5066 specific */
2055 static const hda_nid_t cxt5066_dac_nids
[1] = { 0x10 };
2056 static const hda_nid_t cxt5066_adc_nids
[3] = { 0x14, 0x15, 0x16 };
2057 static const hda_nid_t cxt5066_capsrc_nids
[1] = { 0x17 };
2058 static const hda_nid_t cxt5066_digout_pin_nids
[2] = { 0x20, 0x22 };
2060 /* OLPC's microphone port is DC coupled for use with external sensors,
2061 * therefore we use a 50% mic bias in order to center the input signal with
2062 * the DC input range of the codec. */
2063 #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50
2065 static const struct hda_channel_mode cxt5066_modes
[1] = {
2069 #define HP_PRESENT_PORT_A (1 << 0)
2070 #define HP_PRESENT_PORT_D (1 << 1)
2071 #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A)
2072 #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D)
2074 static void cxt5066_update_speaker(struct hda_codec
*codec
)
2076 struct conexant_spec
*spec
= codec
->spec
;
2077 unsigned int pinctl
;
2079 snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n",
2080 spec
->hp_present
, spec
->cur_eapd
);
2083 pinctl
= (hp_port_a_present(spec
) && spec
->cur_eapd
) ? PIN_HP
: 0;
2084 snd_hda_codec_write(codec
, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2087 /* Port D (HP/LO) */
2088 pinctl
= spec
->cur_eapd
? spec
->port_d_mode
: 0;
2089 if (spec
->dell_automute
|| spec
->thinkpad
) {
2090 /* Mute if Port A is connected */
2091 if (hp_port_a_present(spec
))
2094 /* Thinkpad/Dell doesn't give pin-D status */
2095 if (!hp_port_d_present(spec
))
2098 snd_hda_codec_write(codec
, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2102 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
2103 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2107 /* turn on/off EAPD (+ mute HP) as a master switch */
2108 static int cxt5066_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
2109 struct snd_ctl_elem_value
*ucontrol
)
2111 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2113 if (!cxt_eapd_put(kcontrol
, ucontrol
))
2116 cxt5066_update_speaker(codec
);
2120 static const struct hda_input_mux cxt5066_olpc_dc_bias
= {
2124 { "50%", PIN_VREF50
},
2125 { "80%", PIN_VREF80
},
2129 static int cxt5066_set_olpc_dc_bias(struct hda_codec
*codec
)
2131 struct conexant_spec
*spec
= codec
->spec
;
2132 /* Even though port F is the DC input, the bias is controlled on port B.
2133 * we also leave that port as an active input (but unselected) in DC mode
2134 * just in case that is necessary to make the bias setting take effect. */
2135 return snd_hda_codec_write_cache(codec
, 0x1a, 0,
2136 AC_VERB_SET_PIN_WIDGET_CONTROL
,
2137 cxt5066_olpc_dc_bias
.items
[spec
->dc_input_bias
].index
);
2140 /* OLPC defers mic widget control until when capture is started because the
2141 * microphone LED comes on as soon as these settings are put in place. if we
2142 * did this before recording, it would give the false indication that recording
2143 * is happening when it is not. */
2144 static void cxt5066_olpc_select_mic(struct hda_codec
*codec
)
2146 struct conexant_spec
*spec
= codec
->spec
;
2147 if (!spec
->recording
)
2150 if (spec
->dc_enable
) {
2151 /* in DC mode we ignore presence detection and just use the jack
2152 * through our special DC port */
2153 const struct hda_verb enable_dc_mode
[] = {
2154 /* disble internal mic, port C */
2155 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2157 /* enable DC capture, port F */
2158 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2162 snd_hda_sequence_write(codec
, enable_dc_mode
);
2163 /* port B input disabled (and bias set) through the following call */
2164 cxt5066_set_olpc_dc_bias(codec
);
2168 /* disable DC (port F) */
2169 snd_hda_codec_write(codec
, 0x1e, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0);
2171 /* external mic, port B */
2172 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2173 spec
->ext_mic_present
? CXT5066_OLPC_EXT_MIC_BIAS
: 0);
2175 /* internal mic, port C */
2176 snd_hda_codec_write(codec
, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2177 spec
->ext_mic_present
? 0 : PIN_VREF80
);
2180 /* toggle input of built-in and mic jack appropriately */
2181 static void cxt5066_olpc_automic(struct hda_codec
*codec
)
2183 struct conexant_spec
*spec
= codec
->spec
;
2184 unsigned int present
;
2186 if (spec
->dc_enable
) /* don't do presence detection in DC mode */
2189 present
= snd_hda_codec_read(codec
, 0x1a, 0,
2190 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
2192 snd_printdd("CXT5066: external microphone detected\n");
2194 snd_printdd("CXT5066: external microphone absent\n");
2196 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2198 spec
->ext_mic_present
= !!present
;
2200 cxt5066_olpc_select_mic(codec
);
2203 /* toggle input of built-in digital mic and mic jack appropriately */
2204 static void cxt5066_vostro_automic(struct hda_codec
*codec
)
2206 unsigned int present
;
2208 struct hda_verb ext_mic_present
[] = {
2209 /* enable external mic, port B */
2210 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2212 /* switch to external mic input */
2213 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2214 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2216 /* disable internal digital mic */
2217 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2220 static const struct hda_verb ext_mic_absent
[] = {
2221 /* enable internal mic, port C */
2222 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2224 /* switch to internal mic input */
2225 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2227 /* disable external mic, port B */
2228 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2232 present
= snd_hda_jack_detect(codec
, 0x1a);
2234 snd_printdd("CXT5066: external microphone detected\n");
2235 snd_hda_sequence_write(codec
, ext_mic_present
);
2237 snd_printdd("CXT5066: external microphone absent\n");
2238 snd_hda_sequence_write(codec
, ext_mic_absent
);
2242 /* toggle input of built-in digital mic and mic jack appropriately */
2243 static void cxt5066_ideapad_automic(struct hda_codec
*codec
)
2245 unsigned int present
;
2247 struct hda_verb ext_mic_present
[] = {
2248 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2249 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2250 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2253 static const struct hda_verb ext_mic_absent
[] = {
2254 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2255 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2256 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2260 present
= snd_hda_jack_detect(codec
, 0x1b);
2262 snd_printdd("CXT5066: external microphone detected\n");
2263 snd_hda_sequence_write(codec
, ext_mic_present
);
2265 snd_printdd("CXT5066: external microphone absent\n");
2266 snd_hda_sequence_write(codec
, ext_mic_absent
);
2271 /* toggle input of built-in digital mic and mic jack appropriately */
2272 static void cxt5066_asus_automic(struct hda_codec
*codec
)
2274 unsigned int present
;
2276 present
= snd_hda_jack_detect(codec
, 0x1b);
2277 snd_printdd("CXT5066: external microphone present=%d\n", present
);
2278 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2283 /* toggle input of built-in digital mic and mic jack appropriately */
2284 static void cxt5066_hp_laptop_automic(struct hda_codec
*codec
)
2286 unsigned int present
;
2288 present
= snd_hda_jack_detect(codec
, 0x1b);
2289 snd_printdd("CXT5066: external microphone present=%d\n", present
);
2290 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2295 /* toggle input of built-in digital mic and mic jack appropriately
2296 order is: external mic -> dock mic -> interal mic */
2297 static void cxt5066_thinkpad_automic(struct hda_codec
*codec
)
2299 unsigned int ext_present
, dock_present
;
2301 static const struct hda_verb ext_mic_present
[] = {
2302 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2303 {0x17, AC_VERB_SET_CONNECT_SEL
, 1},
2304 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2305 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2306 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2309 static const struct hda_verb dock_mic_present
[] = {
2310 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2311 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2312 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2313 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2314 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2317 static const struct hda_verb ext_mic_absent
[] = {
2318 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2319 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2320 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2321 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2325 ext_present
= snd_hda_jack_detect(codec
, 0x1b);
2326 dock_present
= snd_hda_jack_detect(codec
, 0x1a);
2328 snd_printdd("CXT5066: external microphone detected\n");
2329 snd_hda_sequence_write(codec
, ext_mic_present
);
2330 } else if (dock_present
) {
2331 snd_printdd("CXT5066: dock microphone detected\n");
2332 snd_hda_sequence_write(codec
, dock_mic_present
);
2334 snd_printdd("CXT5066: external microphone absent\n");
2335 snd_hda_sequence_write(codec
, ext_mic_absent
);
2339 /* mute internal speaker if HP is plugged */
2340 static void cxt5066_hp_automute(struct hda_codec
*codec
)
2342 struct conexant_spec
*spec
= codec
->spec
;
2343 unsigned int portA
, portD
;
2346 portA
= snd_hda_jack_detect(codec
, 0x19);
2349 portD
= snd_hda_jack_detect(codec
, 0x1c);
2351 spec
->hp_present
= portA
? HP_PRESENT_PORT_A
: 0;
2352 spec
->hp_present
|= portD
? HP_PRESENT_PORT_D
: 0;
2353 snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
2354 portA
, portD
, spec
->hp_present
);
2355 cxt5066_update_speaker(codec
);
2358 /* Dispatch the right mic autoswitch function */
2359 static void cxt5066_automic(struct hda_codec
*codec
)
2361 struct conexant_spec
*spec
= codec
->spec
;
2363 if (spec
->dell_vostro
)
2364 cxt5066_vostro_automic(codec
);
2365 else if (spec
->ideapad
)
2366 cxt5066_ideapad_automic(codec
);
2367 else if (spec
->thinkpad
)
2368 cxt5066_thinkpad_automic(codec
);
2369 else if (spec
->hp_laptop
)
2370 cxt5066_hp_laptop_automic(codec
);
2371 else if (spec
->asus
)
2372 cxt5066_asus_automic(codec
);
2375 /* unsolicited event for jack sensing */
2376 static void cxt5066_olpc_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2378 struct conexant_spec
*spec
= codec
->spec
;
2379 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2380 switch (res
>> 26) {
2381 case CONEXANT_HP_EVENT
:
2382 cxt5066_hp_automute(codec
);
2384 case CONEXANT_MIC_EVENT
:
2385 /* ignore mic events in DC mode; we're always using the jack */
2386 if (!spec
->dc_enable
)
2387 cxt5066_olpc_automic(codec
);
2392 /* unsolicited event for jack sensing */
2393 static void cxt5066_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2395 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2396 switch (res
>> 26) {
2397 case CONEXANT_HP_EVENT
:
2398 cxt5066_hp_automute(codec
);
2400 case CONEXANT_MIC_EVENT
:
2401 cxt5066_automic(codec
);
2407 static const struct hda_input_mux cxt5066_analog_mic_boost
= {
2418 static void cxt5066_set_mic_boost(struct hda_codec
*codec
)
2420 struct conexant_spec
*spec
= codec
->spec
;
2421 snd_hda_codec_write_cache(codec
, 0x17, 0,
2422 AC_VERB_SET_AMP_GAIN_MUTE
,
2423 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_OUTPUT
|
2424 cxt5066_analog_mic_boost
.items
[spec
->mic_boost
].index
);
2425 if (spec
->ideapad
|| spec
->thinkpad
) {
2426 /* adjust the internal mic as well...it is not through 0x17 */
2427 snd_hda_codec_write_cache(codec
, 0x23, 0,
2428 AC_VERB_SET_AMP_GAIN_MUTE
,
2429 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_INPUT
|
2430 cxt5066_analog_mic_boost
.
2431 items
[spec
->mic_boost
].index
);
2435 static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol
*kcontrol
,
2436 struct snd_ctl_elem_info
*uinfo
)
2438 return snd_hda_input_mux_info(&cxt5066_analog_mic_boost
, uinfo
);
2441 static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol
*kcontrol
,
2442 struct snd_ctl_elem_value
*ucontrol
)
2444 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2445 struct conexant_spec
*spec
= codec
->spec
;
2446 ucontrol
->value
.enumerated
.item
[0] = spec
->mic_boost
;
2450 static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol
*kcontrol
,
2451 struct snd_ctl_elem_value
*ucontrol
)
2453 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2454 struct conexant_spec
*spec
= codec
->spec
;
2455 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2457 idx
= ucontrol
->value
.enumerated
.item
[0];
2458 if (idx
>= imux
->num_items
)
2459 idx
= imux
->num_items
- 1;
2461 spec
->mic_boost
= idx
;
2462 if (!spec
->dc_enable
)
2463 cxt5066_set_mic_boost(codec
);
2467 static void cxt5066_enable_dc(struct hda_codec
*codec
)
2469 const struct hda_verb enable_dc_mode
[] = {
2471 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2473 /* switch to DC input */
2474 {0x17, AC_VERB_SET_CONNECT_SEL
, 3},
2478 /* configure as input source */
2479 snd_hda_sequence_write(codec
, enable_dc_mode
);
2480 cxt5066_olpc_select_mic(codec
); /* also sets configured bias */
2483 static void cxt5066_disable_dc(struct hda_codec
*codec
)
2485 /* reconfigure input source */
2486 cxt5066_set_mic_boost(codec
);
2487 /* automic also selects the right mic if we're recording */
2488 cxt5066_olpc_automic(codec
);
2491 static int cxt5066_olpc_dc_get(struct snd_kcontrol
*kcontrol
,
2492 struct snd_ctl_elem_value
*ucontrol
)
2494 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2495 struct conexant_spec
*spec
= codec
->spec
;
2496 ucontrol
->value
.integer
.value
[0] = spec
->dc_enable
;
2500 static int cxt5066_olpc_dc_put(struct snd_kcontrol
*kcontrol
,
2501 struct snd_ctl_elem_value
*ucontrol
)
2503 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2504 struct conexant_spec
*spec
= codec
->spec
;
2505 int dc_enable
= !!ucontrol
->value
.integer
.value
[0];
2507 if (dc_enable
== spec
->dc_enable
)
2510 spec
->dc_enable
= dc_enable
;
2512 cxt5066_enable_dc(codec
);
2514 cxt5066_disable_dc(codec
);
2519 static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol
*kcontrol
,
2520 struct snd_ctl_elem_info
*uinfo
)
2522 return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias
, uinfo
);
2525 static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol
*kcontrol
,
2526 struct snd_ctl_elem_value
*ucontrol
)
2528 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2529 struct conexant_spec
*spec
= codec
->spec
;
2530 ucontrol
->value
.enumerated
.item
[0] = spec
->dc_input_bias
;
2534 static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol
*kcontrol
,
2535 struct snd_ctl_elem_value
*ucontrol
)
2537 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2538 struct conexant_spec
*spec
= codec
->spec
;
2539 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2542 idx
= ucontrol
->value
.enumerated
.item
[0];
2543 if (idx
>= imux
->num_items
)
2544 idx
= imux
->num_items
- 1;
2546 spec
->dc_input_bias
= idx
;
2547 if (spec
->dc_enable
)
2548 cxt5066_set_olpc_dc_bias(codec
);
2552 static void cxt5066_olpc_capture_prepare(struct hda_codec
*codec
)
2554 struct conexant_spec
*spec
= codec
->spec
;
2555 /* mark as recording and configure the microphone widget so that the
2556 * recording LED comes on. */
2557 spec
->recording
= 1;
2558 cxt5066_olpc_select_mic(codec
);
2561 static void cxt5066_olpc_capture_cleanup(struct hda_codec
*codec
)
2563 struct conexant_spec
*spec
= codec
->spec
;
2564 const struct hda_verb disable_mics
[] = {
2565 /* disable external mic, port B */
2566 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2568 /* disble internal mic, port C */
2569 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2571 /* disable DC capture, port F */
2572 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2576 snd_hda_sequence_write(codec
, disable_mics
);
2577 spec
->recording
= 0;
2580 static void conexant_check_dig_outs(struct hda_codec
*codec
,
2581 const hda_nid_t
*dig_pins
,
2584 struct conexant_spec
*spec
= codec
->spec
;
2585 hda_nid_t
*nid_loc
= &spec
->multiout
.dig_out_nid
;
2588 for (i
= 0; i
< num_pins
; i
++, dig_pins
++) {
2589 unsigned int cfg
= snd_hda_codec_get_pincfg(codec
, *dig_pins
);
2590 if (get_defcfg_connect(cfg
) == AC_JACK_PORT_NONE
)
2592 if (snd_hda_get_connections(codec
, *dig_pins
, nid_loc
, 1) != 1)
2594 if (spec
->slave_dig_outs
[0])
2597 nid_loc
= spec
->slave_dig_outs
;
2601 static const struct hda_input_mux cxt5066_capture_source
= {
2611 static const struct hda_bind_ctls cxt5066_bind_capture_vol_others
= {
2612 .ops
= &snd_hda_bind_vol
,
2614 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2615 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2620 static const struct hda_bind_ctls cxt5066_bind_capture_sw_others
= {
2621 .ops
= &snd_hda_bind_sw
,
2623 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2624 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2629 static const struct snd_kcontrol_new cxt5066_mixer_master
[] = {
2630 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
2634 static const struct snd_kcontrol_new cxt5066_mixer_master_olpc
[] = {
2636 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2637 .name
= "Master Playback Volume",
2638 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
|
2639 SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
2640 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
,
2641 .subdevice
= HDA_SUBDEV_AMP_FLAG
,
2642 .info
= snd_hda_mixer_amp_volume_info
,
2643 .get
= snd_hda_mixer_amp_volume_get
,
2644 .put
= snd_hda_mixer_amp_volume_put
,
2645 .tlv
= { .c
= snd_hda_mixer_amp_tlv
},
2646 /* offset by 28 volume steps to limit minimum gain to -46dB */
2648 HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT
, 28),
2653 static const struct snd_kcontrol_new cxt5066_mixer_olpc_dc
[] = {
2655 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2656 .name
= "DC Mode Enable Switch",
2657 .info
= snd_ctl_boolean_mono_info
,
2658 .get
= cxt5066_olpc_dc_get
,
2659 .put
= cxt5066_olpc_dc_put
,
2662 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2663 .name
= "DC Input Bias Enum",
2664 .info
= cxt5066_olpc_dc_bias_enum_info
,
2665 .get
= cxt5066_olpc_dc_bias_enum_get
,
2666 .put
= cxt5066_olpc_dc_bias_enum_put
,
2671 static const struct snd_kcontrol_new cxt5066_mixers
[] = {
2673 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2674 .name
= "Master Playback Switch",
2675 .info
= cxt_eapd_info
,
2676 .get
= cxt_eapd_get
,
2677 .put
= cxt5066_hp_master_sw_put
,
2678 .private_value
= 0x1d,
2682 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2683 .name
= "Analog Mic Boost Capture Enum",
2684 .info
= cxt5066_mic_boost_mux_enum_info
,
2685 .get
= cxt5066_mic_boost_mux_enum_get
,
2686 .put
= cxt5066_mic_boost_mux_enum_put
,
2689 HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others
),
2690 HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others
),
2694 static const struct snd_kcontrol_new cxt5066_vostro_mixers
[] = {
2696 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2697 .name
= "Internal Mic Boost Capture Enum",
2698 .info
= cxt5066_mic_boost_mux_enum_info
,
2699 .get
= cxt5066_mic_boost_mux_enum_get
,
2700 .put
= cxt5066_mic_boost_mux_enum_put
,
2701 .private_value
= 0x23 | 0x100,
2706 static const struct hda_verb cxt5066_init_verbs
[] = {
2707 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2708 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2709 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2710 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2713 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2714 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2717 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2718 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2720 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2721 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2724 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2726 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2727 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2728 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2729 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2730 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2731 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2733 /* no digital microphone support yet */
2734 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2736 /* Audio input selector */
2737 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2739 /* SPDIF route: PCM */
2740 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2741 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2743 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2744 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2747 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2749 /* not handling these yet */
2750 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2751 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2752 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2753 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2754 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2755 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2756 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2757 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2761 static const struct hda_verb cxt5066_init_verbs_olpc
[] = {
2762 /* Port A: headphones */
2763 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2764 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2766 /* Port B: external microphone */
2767 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2769 /* Port C: internal microphone */
2770 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2772 /* Port D: unused */
2773 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2775 /* Port E: unused, but has primary EAPD */
2776 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2777 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2779 /* Port F: external DC input through microphone port */
2780 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2782 /* Port G: internal speakers */
2783 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2784 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2787 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2790 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2792 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2793 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2794 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2795 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2796 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2797 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2798 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2799 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2800 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2801 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2802 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2803 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2805 /* Disable digital microphone port */
2806 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2808 /* Audio input selectors */
2809 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2810 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2813 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2814 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2816 /* enable unsolicited events for Port A and B */
2817 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2818 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2822 static const struct hda_verb cxt5066_init_verbs_vostro
[] = {
2823 /* Port A: headphones */
2824 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2825 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2827 /* Port B: external microphone */
2828 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2830 /* Port C: unused */
2831 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2833 /* Port D: unused */
2834 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2836 /* Port E: unused, but has primary EAPD */
2837 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2838 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2840 /* Port F: unused */
2841 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2843 /* Port G: internal speakers */
2844 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2845 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2848 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2851 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2853 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2854 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2855 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2856 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2857 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2858 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2859 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2860 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2861 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2862 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2863 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2864 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2866 /* Digital microphone port */
2867 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2869 /* Audio input selectors */
2870 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2871 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2874 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2875 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2877 /* enable unsolicited events for Port A and B */
2878 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2879 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2883 static const struct hda_verb cxt5066_init_verbs_ideapad
[] = {
2884 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2885 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2886 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2887 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2890 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2891 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2894 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2895 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2897 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2898 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2901 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2903 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2904 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2905 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2906 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2907 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2908 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2909 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2911 /* Audio input selector */
2912 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2913 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2915 /* SPDIF route: PCM */
2916 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2917 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2919 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2920 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2922 /* internal microphone */
2923 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable internal mic */
2926 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2928 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2929 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2933 static const struct hda_verb cxt5066_init_verbs_thinkpad
[] = {
2934 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2935 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2937 /* Port G: internal speakers */
2938 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2939 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2941 /* Port A: HP, Amp */
2942 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2943 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2945 /* Port B: Mic Dock */
2946 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2949 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2951 /* Port D: HP Dock, Amp */
2952 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2953 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2956 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2958 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2959 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2960 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2961 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2962 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2963 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2964 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2966 /* Audio input selector */
2967 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2968 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2970 /* SPDIF route: PCM */
2971 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2972 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2974 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2975 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2977 /* internal microphone */
2978 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable internal mic */
2981 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2983 /* enable unsolicited events for Port A, B, C and D */
2984 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2985 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2986 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2987 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2991 static const struct hda_verb cxt5066_init_verbs_portd_lo
[] = {
2992 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2997 static const struct hda_verb cxt5066_init_verbs_hp_laptop
[] = {
2998 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x0},
2999 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
3000 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
3004 /* initialize jack-sensing, too */
3005 static int cxt5066_init(struct hda_codec
*codec
)
3007 snd_printdd("CXT5066: init\n");
3008 conexant_init(codec
);
3009 if (codec
->patch_ops
.unsol_event
) {
3010 cxt5066_hp_automute(codec
);
3011 cxt5066_automic(codec
);
3013 cxt5066_set_mic_boost(codec
);
3017 static int cxt5066_olpc_init(struct hda_codec
*codec
)
3019 struct conexant_spec
*spec
= codec
->spec
;
3020 snd_printdd("CXT5066: init\n");
3021 conexant_init(codec
);
3022 cxt5066_hp_automute(codec
);
3023 if (!spec
->dc_enable
) {
3024 cxt5066_set_mic_boost(codec
);
3025 cxt5066_olpc_automic(codec
);
3027 cxt5066_enable_dc(codec
);
3033 CXT5066_LAPTOP
, /* Laptops w/ EAPD support */
3034 CXT5066_DELL_LAPTOP
, /* Dell Laptop */
3035 CXT5066_OLPC_XO_1_5
, /* OLPC XO 1.5 */
3036 CXT5066_DELL_VOSTRO
, /* Dell Vostro 1015i */
3037 CXT5066_IDEAPAD
, /* Lenovo IdeaPad U150 */
3038 CXT5066_THINKPAD
, /* Lenovo ThinkPad T410s, others? */
3039 CXT5066_ASUS
, /* Asus K52JU, Lenovo G560 - Int mic at 0x1a and Ext mic at 0x1b */
3040 CXT5066_HP_LAPTOP
, /* HP Laptop */
3044 static const char * const cxt5066_models
[CXT5066_MODELS
] = {
3045 [CXT5066_LAPTOP
] = "laptop",
3046 [CXT5066_DELL_LAPTOP
] = "dell-laptop",
3047 [CXT5066_OLPC_XO_1_5
] = "olpc-xo-1_5",
3048 [CXT5066_DELL_VOSTRO
] = "dell-vostro",
3049 [CXT5066_IDEAPAD
] = "ideapad",
3050 [CXT5066_THINKPAD
] = "thinkpad",
3051 [CXT5066_ASUS
] = "asus",
3052 [CXT5066_HP_LAPTOP
] = "hp-laptop",
3055 static const struct snd_pci_quirk cxt5066_cfg_tbl
[] = {
3056 SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD
),
3057 SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO
),
3058 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD
),
3059 SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO
),
3060 SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTRO
),
3061 SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD
),
3062 SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD
),
3063 SND_PCI_QUIRK(0x1028, 0x0510, "Dell Vostro", CXT5066_IDEAPAD
),
3064 SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP
),
3065 SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS
),
3066 SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS
),
3067 SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS
),
3068 SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD
),
3069 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5
),
3070 SND_PCI_QUIRK(0x1179, 0xffe0, "Toshiba Satellite Pro T130-15F", CXT5066_OLPC_XO_1_5
),
3071 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
3073 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5
),
3074 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD
),
3075 SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD
),
3076 SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS
),
3077 SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo Thinkpad", CXT5066_THINKPAD
),
3078 SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT5066_THINKPAD
),
3079 SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT5066_THINKPAD
),
3080 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS
),
3081 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", CXT5066_IDEAPAD
), /* Fallback for Lenovos without dock mic */
3085 static int patch_cxt5066(struct hda_codec
*codec
)
3087 struct conexant_spec
*spec
;
3090 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3095 codec
->patch_ops
= conexant_patch_ops
;
3096 codec
->patch_ops
.init
= conexant_init
;
3098 spec
->dell_automute
= 0;
3099 spec
->multiout
.max_channels
= 2;
3100 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5066_dac_nids
);
3101 spec
->multiout
.dac_nids
= cxt5066_dac_nids
;
3102 conexant_check_dig_outs(codec
, cxt5066_digout_pin_nids
,
3103 ARRAY_SIZE(cxt5066_digout_pin_nids
));
3104 spec
->num_adc_nids
= 1;
3105 spec
->adc_nids
= cxt5066_adc_nids
;
3106 spec
->capsrc_nids
= cxt5066_capsrc_nids
;
3107 spec
->input_mux
= &cxt5066_capture_source
;
3109 spec
->port_d_mode
= PIN_HP
;
3111 spec
->num_init_verbs
= 1;
3112 spec
->init_verbs
[0] = cxt5066_init_verbs
;
3113 spec
->num_channel_mode
= ARRAY_SIZE(cxt5066_modes
);
3114 spec
->channel_mode
= cxt5066_modes
;
3116 spec
->cur_adc_idx
= 0;
3118 set_beep_amp(spec
, 0x13, 0, HDA_OUTPUT
);
3120 board_config
= snd_hda_check_board_config(codec
, CXT5066_MODELS
,
3121 cxt5066_models
, cxt5066_cfg_tbl
);
3122 switch (board_config
) {
3124 case CXT5066_LAPTOP
:
3125 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3126 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3128 case CXT5066_DELL_LAPTOP
:
3129 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3130 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3132 spec
->port_d_mode
= PIN_OUT
;
3133 spec
->init_verbs
[spec
->num_init_verbs
] = cxt5066_init_verbs_portd_lo
;
3134 spec
->num_init_verbs
++;
3135 spec
->dell_automute
= 1;
3138 case CXT5066_HP_LAPTOP
:
3139 codec
->patch_ops
.init
= cxt5066_init
;
3140 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3141 spec
->init_verbs
[spec
->num_init_verbs
] =
3142 cxt5066_init_verbs_hp_laptop
;
3143 spec
->num_init_verbs
++;
3144 spec
->hp_laptop
= board_config
== CXT5066_HP_LAPTOP
;
3145 spec
->asus
= board_config
== CXT5066_ASUS
;
3146 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3147 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3149 if (board_config
== CXT5066_HP_LAPTOP
)
3150 spec
->multiout
.dig_out_nid
= 0;
3151 /* input source automatically selected */
3152 spec
->input_mux
= NULL
;
3153 spec
->port_d_mode
= 0;
3154 spec
->mic_boost
= 3; /* default 30dB gain */
3157 case CXT5066_OLPC_XO_1_5
:
3158 codec
->patch_ops
.init
= cxt5066_olpc_init
;
3159 codec
->patch_ops
.unsol_event
= cxt5066_olpc_unsol_event
;
3160 spec
->init_verbs
[0] = cxt5066_init_verbs_olpc
;
3161 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
3162 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_olpc_dc
;
3163 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3164 spec
->port_d_mode
= 0;
3165 spec
->mic_boost
= 3; /* default 30dB gain */
3168 spec
->multiout
.dig_out_nid
= 0;
3170 /* input source automatically selected */
3171 spec
->input_mux
= NULL
;
3173 /* our capture hooks which allow us to turn on the microphone LED
3174 * at the right time */
3175 spec
->capture_prepare
= cxt5066_olpc_capture_prepare
;
3176 spec
->capture_cleanup
= cxt5066_olpc_capture_cleanup
;
3178 case CXT5066_DELL_VOSTRO
:
3179 codec
->patch_ops
.init
= cxt5066_init
;
3180 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3181 spec
->init_verbs
[0] = cxt5066_init_verbs_vostro
;
3182 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
3183 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3184 spec
->mixers
[spec
->num_mixers
++] = cxt5066_vostro_mixers
;
3185 spec
->port_d_mode
= 0;
3186 spec
->dell_vostro
= 1;
3187 spec
->mic_boost
= 3; /* default 30dB gain */
3190 spec
->multiout
.dig_out_nid
= 0;
3192 /* input source automatically selected */
3193 spec
->input_mux
= NULL
;
3195 case CXT5066_IDEAPAD
:
3196 codec
->patch_ops
.init
= cxt5066_init
;
3197 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3198 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3199 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3200 spec
->init_verbs
[0] = cxt5066_init_verbs_ideapad
;
3201 spec
->port_d_mode
= 0;
3203 spec
->mic_boost
= 2; /* default 20dB gain */
3206 spec
->multiout
.dig_out_nid
= 0;
3208 /* input source automatically selected */
3209 spec
->input_mux
= NULL
;
3211 case CXT5066_THINKPAD
:
3212 codec
->patch_ops
.init
= cxt5066_init
;
3213 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3214 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3215 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3216 spec
->init_verbs
[0] = cxt5066_init_verbs_thinkpad
;
3218 spec
->port_d_mode
= PIN_OUT
;
3219 spec
->mic_boost
= 2; /* default 20dB gain */
3222 spec
->multiout
.dig_out_nid
= 0;
3224 /* input source automatically selected */
3225 spec
->input_mux
= NULL
;
3230 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
3236 * Automatic parser for CX20641 & co
3239 static int cx_auto_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
3240 struct hda_codec
*codec
,
3241 unsigned int stream_tag
,
3242 unsigned int format
,
3243 struct snd_pcm_substream
*substream
)
3245 struct conexant_spec
*spec
= codec
->spec
;
3246 hda_nid_t adc
= spec
->imux_adcs
[spec
->cur_mux
[0]];
3247 if (spec
->adc_switching
) {
3248 spec
->cur_adc
= adc
;
3249 spec
->cur_adc_stream_tag
= stream_tag
;
3250 spec
->cur_adc_format
= format
;
3252 snd_hda_codec_setup_stream(codec
, adc
, stream_tag
, 0, format
);
3256 static int cx_auto_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
3257 struct hda_codec
*codec
,
3258 struct snd_pcm_substream
*substream
)
3260 struct conexant_spec
*spec
= codec
->spec
;
3261 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
3266 static const struct hda_pcm_stream cx_auto_pcm_analog_capture
= {
3270 .nid
= 0, /* fill later */
3272 .prepare
= cx_auto_capture_pcm_prepare
,
3273 .cleanup
= cx_auto_capture_pcm_cleanup
3277 static const hda_nid_t cx_auto_adc_nids
[] = { 0x14 };
3279 /* get the connection index of @nid in the widget @mux */
3280 static int get_connection_index(struct hda_codec
*codec
, hda_nid_t mux
,
3283 hda_nid_t conn
[HDA_MAX_NUM_INPUTS
];
3286 nums
= snd_hda_get_connections(codec
, mux
, conn
, ARRAY_SIZE(conn
));
3287 for (i
= 0; i
< nums
; i
++)
3293 /* get an unassigned DAC from the given list.
3294 * Return the nid if found and reduce the DAC list, or return zero if
3297 static hda_nid_t
get_unassigned_dac(struct hda_codec
*codec
, hda_nid_t pin
,
3298 hda_nid_t
*dacs
, int *num_dacs
)
3300 int i
, nums
= *num_dacs
;
3303 for (i
= 0; i
< nums
; i
++) {
3304 if (get_connection_index(codec
, pin
, dacs
[i
]) >= 0) {
3312 memmove(dacs
, dacs
+ 1, nums
* sizeof(hda_nid_t
));
3317 #define MAX_AUTO_DACS 5
3319 /* fill analog DAC list from the widget tree */
3320 static int fill_cx_auto_dacs(struct hda_codec
*codec
, hda_nid_t
*dacs
)
3322 hda_nid_t nid
, end_nid
;
3325 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3326 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
3327 unsigned int wcaps
= get_wcaps(codec
, nid
);
3328 unsigned int type
= get_wcaps_type(wcaps
);
3329 if (type
== AC_WID_AUD_OUT
&& !(wcaps
& AC_WCAP_DIGITAL
)) {
3331 if (nums
>= MAX_AUTO_DACS
)
3338 /* fill pin_dac_pair list from the pin and dac list */
3339 static int fill_dacs_for_pins(struct hda_codec
*codec
, hda_nid_t
*pins
,
3340 int num_pins
, hda_nid_t
*dacs
, int *rest
,
3341 struct pin_dac_pair
*filled
, int type
)
3346 for (i
= 0; i
< num_pins
; i
++) {
3347 filled
[nums
].pin
= pins
[i
];
3348 filled
[nums
].type
= type
;
3349 filled
[nums
].dac
= get_unassigned_dac(codec
, pins
[i
], dacs
, rest
);
3355 /* parse analog output paths */
3356 static void cx_auto_parse_output(struct hda_codec
*codec
)
3358 struct conexant_spec
*spec
= codec
->spec
;
3359 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3360 hda_nid_t dacs
[MAX_AUTO_DACS
];
3361 int i
, j
, nums
, rest
;
3363 rest
= fill_cx_auto_dacs(codec
, dacs
);
3364 /* parse all analog output pins */
3365 nums
= fill_dacs_for_pins(codec
, cfg
->line_out_pins
, cfg
->line_outs
,
3366 dacs
, &rest
, spec
->dac_info
,
3368 nums
+= fill_dacs_for_pins(codec
, cfg
->hp_pins
, cfg
->hp_outs
,
3369 dacs
, &rest
, spec
->dac_info
+ nums
,
3371 nums
+= fill_dacs_for_pins(codec
, cfg
->speaker_pins
, cfg
->speaker_outs
,
3372 dacs
, &rest
, spec
->dac_info
+ nums
,
3373 AUTO_PIN_SPEAKER_OUT
);
3374 spec
->dac_info_filled
= nums
;
3375 /* fill multiout struct */
3376 for (i
= 0; i
< nums
; i
++) {
3377 hda_nid_t dac
= spec
->dac_info
[i
].dac
;
3380 switch (spec
->dac_info
[i
].type
) {
3381 case AUTO_PIN_LINE_OUT
:
3382 spec
->private_dac_nids
[spec
->multiout
.num_dacs
] = dac
;
3383 spec
->multiout
.num_dacs
++;
3385 case AUTO_PIN_HP_OUT
:
3386 case AUTO_PIN_SPEAKER_OUT
:
3387 if (!spec
->multiout
.hp_nid
) {
3388 spec
->multiout
.hp_nid
= dac
;
3391 for (j
= 0; j
< ARRAY_SIZE(spec
->multiout
.extra_out_nid
); j
++)
3392 if (!spec
->multiout
.extra_out_nid
[j
]) {
3393 spec
->multiout
.extra_out_nid
[j
] = dac
;
3399 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3400 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
3402 if (cfg
->hp_outs
> 0)
3403 spec
->auto_mute
= 1;
3404 spec
->vmaster_nid
= spec
->private_dac_nids
[0];
3407 static void cx_auto_turn_eapd(struct hda_codec
*codec
, int num_pins
,
3408 hda_nid_t
*pins
, bool on
);
3410 /* auto-mute/unmute speaker and line outs according to headphone jack */
3411 static void cx_auto_hp_automute(struct hda_codec
*codec
)
3413 struct conexant_spec
*spec
= codec
->spec
;
3414 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3417 if (!spec
->auto_mute
)
3420 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3421 if (snd_hda_jack_detect(codec
, cfg
->hp_pins
[i
])) {
3426 cx_auto_turn_eapd(codec
, cfg
->hp_outs
, cfg
->hp_pins
, present
);
3427 for (i
= 0; i
< cfg
->line_outs
; i
++) {
3428 snd_hda_codec_write(codec
, cfg
->line_out_pins
[i
], 0,
3429 AC_VERB_SET_PIN_WIDGET_CONTROL
,
3430 present
? 0 : PIN_OUT
);
3432 cx_auto_turn_eapd(codec
, cfg
->line_outs
, cfg
->line_out_pins
, !present
);
3433 for (i
= 0; !present
&& i
< cfg
->line_outs
; i
++)
3434 if (snd_hda_jack_detect(codec
, cfg
->line_out_pins
[i
]))
3436 for (i
= 0; i
< cfg
->speaker_outs
; i
++) {
3437 snd_hda_codec_write(codec
, cfg
->speaker_pins
[i
], 0,
3438 AC_VERB_SET_PIN_WIDGET_CONTROL
,
3439 present
? 0 : PIN_OUT
);
3441 cx_auto_turn_eapd(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
, !present
);
3444 static int cx_auto_mux_enum_info(struct snd_kcontrol
*kcontrol
,
3445 struct snd_ctl_elem_info
*uinfo
)
3447 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3448 struct conexant_spec
*spec
= codec
->spec
;
3450 return snd_hda_input_mux_info(&spec
->private_imux
, uinfo
);
3453 static int cx_auto_mux_enum_get(struct snd_kcontrol
*kcontrol
,
3454 struct snd_ctl_elem_value
*ucontrol
)
3456 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3457 struct conexant_spec
*spec
= codec
->spec
;
3459 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[0];
3463 /* look for the route the given pin from mux and return the index;
3464 * if do_select is set, actually select the route.
3466 static int __select_input_connection(struct hda_codec
*codec
, hda_nid_t mux
,
3467 hda_nid_t pin
, bool do_select
, int depth
)
3469 hda_nid_t conn
[HDA_MAX_NUM_INPUTS
];
3472 nums
= snd_hda_get_connections(codec
, mux
, conn
, ARRAY_SIZE(conn
));
3473 for (i
= 0; i
< nums
; i
++)
3474 if (conn
[i
] == pin
) {
3476 snd_hda_codec_write(codec
, mux
, 0,
3477 AC_VERB_SET_CONNECT_SEL
, i
);
3483 for (i
= 0; i
< nums
; i
++) {
3484 int ret
= __select_input_connection(codec
, conn
[i
], pin
,
3488 snd_hda_codec_write(codec
, mux
, 0,
3489 AC_VERB_SET_CONNECT_SEL
, i
);
3496 static void select_input_connection(struct hda_codec
*codec
, hda_nid_t mux
,
3499 __select_input_connection(codec
, mux
, pin
, true, 0);
3502 static int get_input_connection(struct hda_codec
*codec
, hda_nid_t mux
,
3505 return __select_input_connection(codec
, mux
, pin
, false, 0);
3508 static int cx_auto_mux_enum_update(struct hda_codec
*codec
,
3509 const struct hda_input_mux
*imux
,
3512 struct conexant_spec
*spec
= codec
->spec
;
3515 if (!imux
->num_items
)
3517 if (idx
>= imux
->num_items
)
3518 idx
= imux
->num_items
- 1;
3519 if (spec
->cur_mux
[0] == idx
)
3521 adc
= spec
->imux_adcs
[idx
];
3522 select_input_connection(codec
, spec
->imux_adcs
[idx
],
3523 spec
->imux_pins
[idx
]);
3524 if (spec
->cur_adc
&& spec
->cur_adc
!= adc
) {
3525 /* stream is running, let's swap the current ADC */
3526 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
3527 spec
->cur_adc
= adc
;
3528 snd_hda_codec_setup_stream(codec
, adc
,
3529 spec
->cur_adc_stream_tag
, 0,
3530 spec
->cur_adc_format
);
3532 spec
->cur_mux
[0] = idx
;
3536 static int cx_auto_mux_enum_put(struct snd_kcontrol
*kcontrol
,
3537 struct snd_ctl_elem_value
*ucontrol
)
3539 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3540 struct conexant_spec
*spec
= codec
->spec
;
3542 return cx_auto_mux_enum_update(codec
, &spec
->private_imux
,
3543 ucontrol
->value
.enumerated
.item
[0]);
3546 static const struct snd_kcontrol_new cx_auto_capture_mixers
[] = {
3548 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3549 .name
= "Capture Source",
3550 .info
= cx_auto_mux_enum_info
,
3551 .get
= cx_auto_mux_enum_get
,
3552 .put
= cx_auto_mux_enum_put
3557 /* automatic switch internal and external mic */
3558 static void cx_auto_automic(struct hda_codec
*codec
)
3560 struct conexant_spec
*spec
= codec
->spec
;
3561 int ext_idx
= spec
->auto_mic_ext
;
3563 if (!spec
->auto_mic
)
3565 if (snd_hda_jack_detect(codec
, spec
->imux_pins
[ext_idx
]))
3566 cx_auto_mux_enum_update(codec
, &spec
->private_imux
, ext_idx
);
3568 cx_auto_mux_enum_update(codec
, &spec
->private_imux
, !ext_idx
);
3571 static void cx_auto_unsol_event(struct hda_codec
*codec
, unsigned int res
)
3573 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
3574 switch (res
>> 26) {
3575 case CONEXANT_HP_EVENT
:
3576 cx_auto_hp_automute(codec
);
3577 snd_hda_input_jack_report(codec
, nid
);
3579 case CONEXANT_MIC_EVENT
:
3580 cx_auto_automic(codec
);
3581 snd_hda_input_jack_report(codec
, nid
);
3586 /* return true if it's an internal-mic pin */
3587 static int is_int_mic(struct hda_codec
*codec
, hda_nid_t pin
)
3589 unsigned int def_conf
= snd_hda_codec_get_pincfg(codec
, pin
);
3590 return get_defcfg_device(def_conf
) == AC_JACK_MIC_IN
&&
3591 snd_hda_get_input_pin_attr(def_conf
) == INPUT_PIN_ATTR_INT
;
3594 /* return true if it's an external-mic pin */
3595 static int is_ext_mic(struct hda_codec
*codec
, hda_nid_t pin
)
3597 unsigned int def_conf
= snd_hda_codec_get_pincfg(codec
, pin
);
3598 return get_defcfg_device(def_conf
) == AC_JACK_MIC_IN
&&
3599 snd_hda_get_input_pin_attr(def_conf
) >= INPUT_PIN_ATTR_NORMAL
&&
3600 (snd_hda_query_pin_caps(codec
, pin
) & AC_PINCAP_PRES_DETECT
);
3603 /* check whether the pin config is suitable for auto-mic switching;
3604 * auto-mic is enabled only when one int-mic and one-ext mic exist
3606 static void cx_auto_check_auto_mic(struct hda_codec
*codec
)
3608 struct conexant_spec
*spec
= codec
->spec
;
3610 if (is_ext_mic(codec
, spec
->imux_pins
[0]) &&
3611 is_int_mic(codec
, spec
->imux_pins
[1])) {
3613 spec
->auto_mic_ext
= 0;
3616 if (is_int_mic(codec
, spec
->imux_pins
[0]) &&
3617 is_ext_mic(codec
, spec
->imux_pins
[1])) {
3619 spec
->auto_mic_ext
= 1;
3624 static void cx_auto_parse_input(struct hda_codec
*codec
)
3626 struct conexant_spec
*spec
= codec
->spec
;
3627 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3628 struct hda_input_mux
*imux
;
3631 imux
= &spec
->private_imux
;
3632 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3633 for (j
= 0; j
< spec
->num_adc_nids
; j
++) {
3634 hda_nid_t adc
= spec
->adc_nids
[j
];
3635 int idx
= get_input_connection(codec
, adc
,
3636 cfg
->inputs
[i
].pin
);
3639 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
3640 spec
->imux_adcs
[imux
->num_items
] = adc
;
3641 spec
->imux_pins
[imux
->num_items
] =
3643 snd_hda_add_imux_item(imux
, label
, idx
, NULL
);
3648 if (imux
->num_items
== 2 && cfg
->num_inputs
== 2)
3649 cx_auto_check_auto_mic(codec
);
3650 if (imux
->num_items
> 1 && !spec
->auto_mic
) {
3651 for (i
= 1; i
< imux
->num_items
; i
++) {
3652 if (spec
->imux_adcs
[i
] != spec
->imux_adcs
[0]) {
3653 spec
->adc_switching
= 1;
3660 /* get digital-input audio widget corresponding to the given pin */
3661 static hda_nid_t
cx_auto_get_dig_in(struct hda_codec
*codec
, hda_nid_t pin
)
3663 hda_nid_t nid
, end_nid
;
3665 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3666 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
3667 unsigned int wcaps
= get_wcaps(codec
, nid
);
3668 unsigned int type
= get_wcaps_type(wcaps
);
3669 if (type
== AC_WID_AUD_IN
&& (wcaps
& AC_WCAP_DIGITAL
)) {
3670 if (get_connection_index(codec
, nid
, pin
) >= 0)
3677 static void cx_auto_parse_digital(struct hda_codec
*codec
)
3679 struct conexant_spec
*spec
= codec
->spec
;
3680 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3683 if (cfg
->dig_outs
&&
3684 snd_hda_get_connections(codec
, cfg
->dig_out_pins
[0], &nid
, 1) == 1)
3685 spec
->multiout
.dig_out_nid
= nid
;
3686 if (cfg
->dig_in_pin
)
3687 spec
->dig_in_nid
= cx_auto_get_dig_in(codec
, cfg
->dig_in_pin
);
3690 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3691 static void cx_auto_parse_beep(struct hda_codec
*codec
)
3693 struct conexant_spec
*spec
= codec
->spec
;
3694 hda_nid_t nid
, end_nid
;
3696 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3697 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++)
3698 if (get_wcaps_type(get_wcaps(codec
, nid
)) == AC_WID_BEEP
) {
3699 set_beep_amp(spec
, nid
, 0, HDA_OUTPUT
);
3704 #define cx_auto_parse_beep(codec)
3707 static int cx_auto_parse_auto_config(struct hda_codec
*codec
)
3709 struct conexant_spec
*spec
= codec
->spec
;
3712 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
3716 cx_auto_parse_output(codec
);
3717 cx_auto_parse_input(codec
);
3718 cx_auto_parse_digital(codec
);
3719 cx_auto_parse_beep(codec
);
3723 static void cx_auto_turn_eapd(struct hda_codec
*codec
, int num_pins
,
3724 hda_nid_t
*pins
, bool on
)
3727 for (i
= 0; i
< num_pins
; i
++) {
3728 if (snd_hda_query_pin_caps(codec
, pins
[i
]) & AC_PINCAP_EAPD
)
3729 snd_hda_codec_write(codec
, pins
[i
], 0,
3730 AC_VERB_SET_EAPD_BTLENABLE
,
3735 static void select_connection(struct hda_codec
*codec
, hda_nid_t pin
,
3738 int idx
= get_connection_index(codec
, pin
, src
);
3740 snd_hda_codec_write(codec
, pin
, 0,
3741 AC_VERB_SET_CONNECT_SEL
, idx
);
3744 static void mute_outputs(struct hda_codec
*codec
, int num_nids
,
3745 const hda_nid_t
*nids
)
3749 for (i
= 0; i
< num_nids
; i
++) {
3750 hda_nid_t nid
= nids
[i
];
3751 if (!(get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
))
3753 if (query_amp_caps(codec
, nid
, HDA_OUTPUT
) & AC_AMPCAP_MUTE
)
3757 snd_hda_codec_write(codec
, nid
, 0,
3758 AC_VERB_SET_AMP_GAIN_MUTE
, val
);
3762 static void cx_auto_init_output(struct hda_codec
*codec
)
3764 struct conexant_spec
*spec
= codec
->spec
;
3765 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3769 mute_outputs(codec
, spec
->multiout
.num_dacs
, spec
->multiout
.dac_nids
);
3770 for (i
= 0; i
< cfg
->hp_outs
; i
++)
3771 snd_hda_codec_write(codec
, cfg
->hp_pins
[i
], 0,
3772 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
);
3773 mute_outputs(codec
, cfg
->hp_outs
, cfg
->hp_pins
);
3774 mute_outputs(codec
, cfg
->line_outs
, cfg
->line_out_pins
);
3775 mute_outputs(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
);
3776 if (spec
->auto_mute
) {
3777 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3778 snd_hda_codec_write(codec
, cfg
->hp_pins
[i
], 0,
3779 AC_VERB_SET_UNSOLICITED_ENABLE
,
3780 AC_USRSP_EN
| CONEXANT_HP_EVENT
);
3782 cx_auto_hp_automute(codec
);
3784 for (i
= 0; i
< cfg
->line_outs
; i
++)
3785 snd_hda_codec_write(codec
, cfg
->line_out_pins
[i
], 0,
3786 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
3787 for (i
= 0; i
< cfg
->speaker_outs
; i
++)
3788 snd_hda_codec_write(codec
, cfg
->speaker_pins
[i
], 0,
3789 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
3791 cx_auto_turn_eapd(codec
, cfg
->line_outs
, cfg
->line_out_pins
,
3793 cx_auto_turn_eapd(codec
, cfg
->hp_outs
, cfg
->hp_pins
,
3795 cx_auto_turn_eapd(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
,
3799 for (i
= 0; i
< spec
->dac_info_filled
; i
++) {
3800 nid
= spec
->dac_info
[i
].dac
;
3802 nid
= spec
->multiout
.dac_nids
[0];
3803 select_connection(codec
, spec
->dac_info
[i
].pin
, nid
);
3807 static void cx_auto_init_input(struct hda_codec
*codec
)
3809 struct conexant_spec
*spec
= codec
->spec
;
3810 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3813 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
3814 hda_nid_t nid
= spec
->adc_nids
[i
];
3815 if (!(get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
))
3817 if (query_amp_caps(codec
, nid
, HDA_INPUT
) & AC_AMPCAP_MUTE
)
3818 val
= AMP_IN_MUTE(0);
3820 val
= AMP_IN_UNMUTE(0);
3821 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3825 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3827 if (cfg
->inputs
[i
].type
== AUTO_PIN_MIC
)
3831 snd_hda_codec_write(codec
, cfg
->inputs
[i
].pin
, 0,
3832 AC_VERB_SET_PIN_WIDGET_CONTROL
, type
);
3835 if (spec
->auto_mic
) {
3836 int ext_idx
= spec
->auto_mic_ext
;
3837 snd_hda_codec_write(codec
, cfg
->inputs
[ext_idx
].pin
, 0,
3838 AC_VERB_SET_UNSOLICITED_ENABLE
,
3839 AC_USRSP_EN
| CONEXANT_MIC_EVENT
);
3840 cx_auto_automic(codec
);
3842 select_input_connection(codec
, spec
->imux_adcs
[0],
3843 spec
->imux_pins
[0]);
3847 static void cx_auto_init_digital(struct hda_codec
*codec
)
3849 struct conexant_spec
*spec
= codec
->spec
;
3850 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3852 if (spec
->multiout
.dig_out_nid
)
3853 snd_hda_codec_write(codec
, cfg
->dig_out_pins
[0], 0,
3854 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
3855 if (spec
->dig_in_nid
)
3856 snd_hda_codec_write(codec
, cfg
->dig_in_pin
, 0,
3857 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
);
3860 static int cx_auto_init(struct hda_codec
*codec
)
3862 /*snd_hda_sequence_write(codec, cx_auto_init_verbs);*/
3863 cx_auto_init_output(codec
);
3864 cx_auto_init_input(codec
);
3865 cx_auto_init_digital(codec
);
3869 static int cx_auto_add_volume_idx(struct hda_codec
*codec
, const char *basename
,
3870 const char *dir
, int cidx
,
3871 hda_nid_t nid
, int hda_dir
, int amp_idx
)
3873 static char name
[32];
3874 static struct snd_kcontrol_new knew
[] = {
3875 HDA_CODEC_VOLUME(name
, 0, 0, 0),
3876 HDA_CODEC_MUTE(name
, 0, 0, 0),
3878 static const char * const sfx
[2] = { "Volume", "Switch" };
3881 for (i
= 0; i
< 2; i
++) {
3882 struct snd_kcontrol
*kctl
;
3883 knew
[i
].private_value
= HDA_COMPOSE_AMP_VAL(nid
, 3, amp_idx
,
3885 knew
[i
].subdevice
= HDA_SUBDEV_AMP_FLAG
;
3886 knew
[i
].index
= cidx
;
3887 snprintf(name
, sizeof(name
), "%s%s %s", basename
, dir
, sfx
[i
]);
3888 kctl
= snd_ctl_new1(&knew
[i
], codec
);
3891 err
= snd_hda_ctl_add(codec
, nid
, kctl
);
3894 if (!(query_amp_caps(codec
, nid
, hda_dir
) & AC_AMPCAP_MUTE
))
3900 #define cx_auto_add_volume(codec, str, dir, cidx, nid, hda_dir) \
3901 cx_auto_add_volume_idx(codec, str, dir, cidx, nid, hda_dir, 0)
3903 #define cx_auto_add_pb_volume(codec, nid, str, idx) \
3904 cx_auto_add_volume(codec, str, " Playback", idx, nid, HDA_OUTPUT)
3906 static int try_add_pb_volume(struct hda_codec
*codec
, hda_nid_t dac
,
3907 hda_nid_t pin
, const char *name
, int idx
)
3910 caps
= query_amp_caps(codec
, dac
, HDA_OUTPUT
);
3911 if (caps
& AC_AMPCAP_NUM_STEPS
)
3912 return cx_auto_add_pb_volume(codec
, dac
, name
, idx
);
3913 caps
= query_amp_caps(codec
, pin
, HDA_OUTPUT
);
3914 if (caps
& AC_AMPCAP_NUM_STEPS
)
3915 return cx_auto_add_pb_volume(codec
, pin
, name
, idx
);
3919 static int cx_auto_build_output_controls(struct hda_codec
*codec
)
3921 struct conexant_spec
*spec
= codec
->spec
;
3923 int num_line
= 0, num_hp
= 0, num_spk
= 0;
3924 static const char * const texts
[3] = { "Front", "Surround", "CLFE" };
3926 if (spec
->dac_info_filled
== 1)
3927 return try_add_pb_volume(codec
, spec
->dac_info
[0].dac
,
3928 spec
->dac_info
[0].pin
,
3931 for (i
= 0; i
< spec
->dac_info_filled
; i
++) {
3934 if (!spec
->dac_info
[i
].dac
)
3936 type
= spec
->dac_info
[i
].type
;
3937 if (type
== AUTO_PIN_LINE_OUT
)
3938 type
= spec
->autocfg
.line_out_type
;
3940 case AUTO_PIN_LINE_OUT
:
3942 label
= texts
[num_line
++];
3945 case AUTO_PIN_HP_OUT
:
3946 label
= "Headphone";
3949 case AUTO_PIN_SPEAKER_OUT
:
3954 err
= try_add_pb_volume(codec
, spec
->dac_info
[i
].dac
,
3955 spec
->dac_info
[i
].pin
,
3963 static int cx_auto_add_capture_volume(struct hda_codec
*codec
, hda_nid_t nid
,
3964 const char *label
, const char *pfx
,
3967 struct conexant_spec
*spec
= codec
->spec
;
3970 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
3971 hda_nid_t adc_nid
= spec
->adc_nids
[i
];
3972 int idx
= get_input_connection(codec
, adc_nid
, nid
);
3975 return cx_auto_add_volume_idx(codec
, label
, pfx
,
3976 cidx
, adc_nid
, HDA_INPUT
, idx
);
3981 static int cx_auto_build_input_controls(struct hda_codec
*codec
)
3983 struct conexant_spec
*spec
= codec
->spec
;
3984 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3985 static const char *prev_label
;
3990 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3991 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
3993 int pin_amp
= get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
;
3995 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
3996 if (label
== prev_label
)
4003 err
= cx_auto_add_volume(codec
, label
, " Boost", cidx
,
4009 if (cfg
->num_inputs
== 1) {
4010 err
= cx_auto_add_capture_volume(codec
, nid
,
4011 "Capture", "", cidx
);
4013 err
= cx_auto_add_capture_volume(codec
, nid
,
4014 label
, " Capture", cidx
);
4020 if (spec
->private_imux
.num_items
> 1 && !spec
->auto_mic
) {
4021 err
= snd_hda_add_new_ctls(codec
, cx_auto_capture_mixers
);
4029 static int cx_auto_build_controls(struct hda_codec
*codec
)
4033 err
= cx_auto_build_output_controls(codec
);
4036 err
= cx_auto_build_input_controls(codec
);
4039 return conexant_build_controls(codec
);
4042 static int cx_auto_search_adcs(struct hda_codec
*codec
)
4044 struct conexant_spec
*spec
= codec
->spec
;
4045 hda_nid_t nid
, end_nid
;
4047 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
4048 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
4049 unsigned int caps
= get_wcaps(codec
, nid
);
4050 if (get_wcaps_type(caps
) != AC_WID_AUD_IN
)
4052 if (caps
& AC_WCAP_DIGITAL
)
4054 if (snd_BUG_ON(spec
->num_adc_nids
>=
4055 ARRAY_SIZE(spec
->private_adc_nids
)))
4057 spec
->private_adc_nids
[spec
->num_adc_nids
++] = nid
;
4059 spec
->adc_nids
= spec
->private_adc_nids
;
4064 static const struct hda_codec_ops cx_auto_patch_ops
= {
4065 .build_controls
= cx_auto_build_controls
,
4066 .build_pcms
= conexant_build_pcms
,
4067 .init
= cx_auto_init
,
4068 .free
= conexant_free
,
4069 .unsol_event
= cx_auto_unsol_event
,
4070 #ifdef CONFIG_SND_HDA_POWER_SAVE
4071 .suspend
= conexant_suspend
,
4073 .reboot_notify
= snd_hda_shutup_pins
,
4076 static int patch_conexant_auto(struct hda_codec
*codec
)
4078 struct conexant_spec
*spec
;
4081 printk(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
4084 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4088 codec
->pin_amp_workaround
= 1;
4089 err
= cx_auto_search_adcs(codec
);
4092 err
= cx_auto_parse_auto_config(codec
);
4098 spec
->capture_stream
= &cx_auto_pcm_analog_capture
;
4099 codec
->patch_ops
= cx_auto_patch_ops
;
4101 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
4108 static const struct hda_codec_preset snd_hda_preset_conexant
[] = {
4109 { .id
= 0x14f15045, .name
= "CX20549 (Venice)",
4110 .patch
= patch_cxt5045
},
4111 { .id
= 0x14f15047, .name
= "CX20551 (Waikiki)",
4112 .patch
= patch_cxt5047
},
4113 { .id
= 0x14f15051, .name
= "CX20561 (Hermosa)",
4114 .patch
= patch_cxt5051
},
4115 { .id
= 0x14f15066, .name
= "CX20582 (Pebble)",
4116 .patch
= patch_cxt5066
},
4117 { .id
= 0x14f15067, .name
= "CX20583 (Pebble HSF)",
4118 .patch
= patch_cxt5066
},
4119 { .id
= 0x14f15068, .name
= "CX20584",
4120 .patch
= patch_cxt5066
},
4121 { .id
= 0x14f15069, .name
= "CX20585",
4122 .patch
= patch_cxt5066
},
4123 { .id
= 0x14f1506e, .name
= "CX20590",
4124 .patch
= patch_cxt5066
},
4125 { .id
= 0x14f15097, .name
= "CX20631",
4126 .patch
= patch_conexant_auto
},
4127 { .id
= 0x14f15098, .name
= "CX20632",
4128 .patch
= patch_conexant_auto
},
4129 { .id
= 0x14f150a1, .name
= "CX20641",
4130 .patch
= patch_conexant_auto
},
4131 { .id
= 0x14f150a2, .name
= "CX20642",
4132 .patch
= patch_conexant_auto
},
4133 { .id
= 0x14f150ab, .name
= "CX20651",
4134 .patch
= patch_conexant_auto
},
4135 { .id
= 0x14f150ac, .name
= "CX20652",
4136 .patch
= patch_conexant_auto
},
4137 { .id
= 0x14f150b8, .name
= "CX20664",
4138 .patch
= patch_conexant_auto
},
4139 { .id
= 0x14f150b9, .name
= "CX20665",
4140 .patch
= patch_conexant_auto
},
4144 MODULE_ALIAS("snd-hda-codec-id:14f15045");
4145 MODULE_ALIAS("snd-hda-codec-id:14f15047");
4146 MODULE_ALIAS("snd-hda-codec-id:14f15051");
4147 MODULE_ALIAS("snd-hda-codec-id:14f15066");
4148 MODULE_ALIAS("snd-hda-codec-id:14f15067");
4149 MODULE_ALIAS("snd-hda-codec-id:14f15068");
4150 MODULE_ALIAS("snd-hda-codec-id:14f15069");
4151 MODULE_ALIAS("snd-hda-codec-id:14f1506e");
4152 MODULE_ALIAS("snd-hda-codec-id:14f15097");
4153 MODULE_ALIAS("snd-hda-codec-id:14f15098");
4154 MODULE_ALIAS("snd-hda-codec-id:14f150a1");
4155 MODULE_ALIAS("snd-hda-codec-id:14f150a2");
4156 MODULE_ALIAS("snd-hda-codec-id:14f150ab");
4157 MODULE_ALIAS("snd-hda-codec-id:14f150ac");
4158 MODULE_ALIAS("snd-hda-codec-id:14f150b8");
4159 MODULE_ALIAS("snd-hda-codec-id:14f150b9");
4161 MODULE_LICENSE("GPL");
4162 MODULE_DESCRIPTION("Conexant HD-audio codec");
4164 static struct hda_codec_preset_list conexant_list
= {
4165 .preset
= snd_hda_preset_conexant
,
4166 .owner
= THIS_MODULE
,
4169 static int __init
patch_conexant_init(void)
4171 return snd_hda_add_codec_preset(&conexant_list
);
4174 static void __exit
patch_conexant_exit(void)
4176 snd_hda_delete_codec_preset(&conexant_list
);
4179 module_init(patch_conexant_init
)
4180 module_exit(patch_conexant_exit
)