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
42 #define CONEXANT_LINE_EVENT 0x39
44 /* Conexant 5051 specific */
46 #define CXT5051_SPDIF_OUT 0x12
47 #define CXT5051_PORTB_EVENT 0x38
48 #define CXT5051_PORTC_EVENT 0x39
50 #define AUTO_MIC_PORTB (1 << 1)
51 #define AUTO_MIC_PORTC (1 << 2)
60 hda_nid_t pin
; /* input pin NID */
61 hda_nid_t adc
; /* connected ADC NID */
62 hda_nid_t boost
; /* optional boost volume NID */
63 int index
; /* corresponding to autocfg.input */
66 struct conexant_spec
{
68 const struct snd_kcontrol_new
*mixers
[5];
70 hda_nid_t vmaster_nid
;
72 const struct hda_verb
*init_verbs
[5]; /* initialization verbs
76 unsigned int num_init_verbs
;
79 struct hda_multi_out multiout
; /* playback set-up
80 * max_channels, dacs must be set
81 * dig_out_nid and hp_nid are optional
83 unsigned int cur_eapd
;
84 unsigned int hp_present
;
85 unsigned int line_present
;
86 unsigned int auto_mic
;
87 int auto_mic_ext
; /* imux_pins[] index for ext mic */
88 int auto_mic_dock
; /* imux_pins[] index for dock mic */
89 int auto_mic_int
; /* imux_pins[] index for int mic */
90 unsigned int need_dac_fix
;
91 hda_nid_t slave_dig_outs
[2];
94 unsigned int num_adc_nids
;
95 const hda_nid_t
*adc_nids
;
96 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
98 unsigned int cur_adc_idx
;
100 unsigned int cur_adc_stream_tag
;
101 unsigned int cur_adc_format
;
103 const struct hda_pcm_stream
*capture_stream
;
106 const struct hda_input_mux
*input_mux
;
107 const hda_nid_t
*capsrc_nids
;
108 unsigned int cur_mux
[3];
111 const struct hda_channel_mode
*channel_mode
;
112 int num_channel_mode
;
114 /* PCM information */
115 struct hda_pcm pcm_rec
[2]; /* used in build_pcms() */
117 unsigned int spdif_route
;
119 /* dynamic controls, init_verbs and input_mux */
120 struct auto_pin_cfg autocfg
;
121 struct hda_input_mux private_imux
;
122 struct imux_info imux_info
[HDA_MAX_NUM_INPUTS
];
123 hda_nid_t private_adc_nids
[HDA_MAX_NUM_INPUTS
];
124 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
125 struct pin_dac_pair dac_info
[8];
128 unsigned int port_d_mode
;
129 unsigned int auto_mute
:1; /* used in auto-parser */
130 unsigned int detect_line
:1; /* Line-out detection enabled */
131 unsigned int automute_lines
:1; /* automute line-out as well */
132 unsigned int automute_hp_lo
:1; /* both HP and LO available */
133 unsigned int dell_automute
:1;
134 unsigned int dell_vostro
:1;
135 unsigned int ideapad
:1;
136 unsigned int thinkpad
:1;
137 unsigned int hp_laptop
:1;
140 unsigned int adc_switching
:1;
142 unsigned int ext_mic_present
;
143 unsigned int recording
;
144 void (*capture_prepare
)(struct hda_codec
*codec
);
145 void (*capture_cleanup
)(struct hda_codec
*codec
);
147 /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
148 * through the microphone jack.
149 * When the user enables this through a mixer switch, both internal and
150 * external microphones are disabled. Gain is fixed at 0dB. In this mode,
151 * we also allow the bias to be configured through a separate mixer
153 unsigned int dc_enable
;
154 unsigned int dc_input_bias
; /* offset into cxt5066_olpc_dc_bias */
155 unsigned int mic_boost
; /* offset into cxt5066_analog_mic_boost */
157 unsigned int beep_amp
;
159 /* extra EAPD pins */
160 unsigned int num_eapds
;
164 static int conexant_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
165 struct hda_codec
*codec
,
166 struct snd_pcm_substream
*substream
)
168 struct conexant_spec
*spec
= codec
->spec
;
169 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
173 static int conexant_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
174 struct hda_codec
*codec
,
175 unsigned int stream_tag
,
177 struct snd_pcm_substream
*substream
)
179 struct conexant_spec
*spec
= codec
->spec
;
180 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
185 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
186 struct hda_codec
*codec
,
187 struct snd_pcm_substream
*substream
)
189 struct conexant_spec
*spec
= codec
->spec
;
190 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
196 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
197 struct hda_codec
*codec
,
198 struct snd_pcm_substream
*substream
)
200 struct conexant_spec
*spec
= codec
->spec
;
201 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
204 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
205 struct hda_codec
*codec
,
206 struct snd_pcm_substream
*substream
)
208 struct conexant_spec
*spec
= codec
->spec
;
209 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
212 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
213 struct hda_codec
*codec
,
214 unsigned int stream_tag
,
216 struct snd_pcm_substream
*substream
)
218 struct conexant_spec
*spec
= codec
->spec
;
219 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
227 static int conexant_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
228 struct hda_codec
*codec
,
229 unsigned int stream_tag
,
231 struct snd_pcm_substream
*substream
)
233 struct conexant_spec
*spec
= codec
->spec
;
234 if (spec
->capture_prepare
)
235 spec
->capture_prepare(codec
);
236 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
237 stream_tag
, 0, format
);
241 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
242 struct hda_codec
*codec
,
243 struct snd_pcm_substream
*substream
)
245 struct conexant_spec
*spec
= codec
->spec
;
246 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
247 if (spec
->capture_cleanup
)
248 spec
->capture_cleanup(codec
);
254 static const struct hda_pcm_stream conexant_pcm_analog_playback
= {
258 .nid
= 0, /* fill later */
260 .open
= conexant_playback_pcm_open
,
261 .prepare
= conexant_playback_pcm_prepare
,
262 .cleanup
= conexant_playback_pcm_cleanup
266 static const struct hda_pcm_stream conexant_pcm_analog_capture
= {
270 .nid
= 0, /* fill later */
272 .prepare
= conexant_capture_pcm_prepare
,
273 .cleanup
= conexant_capture_pcm_cleanup
278 static const struct hda_pcm_stream conexant_pcm_digital_playback
= {
282 .nid
= 0, /* fill later */
284 .open
= conexant_dig_playback_pcm_open
,
285 .close
= conexant_dig_playback_pcm_close
,
286 .prepare
= conexant_dig_playback_pcm_prepare
290 static const struct hda_pcm_stream conexant_pcm_digital_capture
= {
294 /* NID is set in alc_build_pcms */
297 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
298 struct hda_codec
*codec
,
299 unsigned int stream_tag
,
301 struct snd_pcm_substream
*substream
)
303 struct conexant_spec
*spec
= codec
->spec
;
304 spec
->cur_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
305 spec
->cur_adc_stream_tag
= stream_tag
;
306 spec
->cur_adc_format
= format
;
307 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
311 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
312 struct hda_codec
*codec
,
313 struct snd_pcm_substream
*substream
)
315 struct conexant_spec
*spec
= codec
->spec
;
316 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
321 static const struct hda_pcm_stream cx5051_pcm_analog_capture
= {
325 .nid
= 0, /* fill later */
327 .prepare
= cx5051_capture_pcm_prepare
,
328 .cleanup
= cx5051_capture_pcm_cleanup
332 static int conexant_build_pcms(struct hda_codec
*codec
)
334 struct conexant_spec
*spec
= codec
->spec
;
335 struct hda_pcm
*info
= spec
->pcm_rec
;
338 codec
->pcm_info
= info
;
340 info
->name
= "CONEXANT Analog";
341 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = conexant_pcm_analog_playback
;
342 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
=
343 spec
->multiout
.max_channels
;
344 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
345 spec
->multiout
.dac_nids
[0];
346 if (spec
->capture_stream
)
347 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *spec
->capture_stream
;
349 if (codec
->vendor_id
== 0x14f15051)
350 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
351 cx5051_pcm_analog_capture
;
353 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
354 conexant_pcm_analog_capture
;
355 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
=
359 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
361 if (spec
->multiout
.dig_out_nid
) {
364 info
->name
= "Conexant Digital";
365 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
366 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
367 conexant_pcm_digital_playback
;
368 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
369 spec
->multiout
.dig_out_nid
;
370 if (spec
->dig_in_nid
) {
371 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
372 conexant_pcm_digital_capture
;
373 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
376 if (spec
->slave_dig_outs
[0])
377 codec
->slave_dig_outs
= spec
->slave_dig_outs
;
383 static int conexant_mux_enum_info(struct snd_kcontrol
*kcontrol
,
384 struct snd_ctl_elem_info
*uinfo
)
386 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
387 struct conexant_spec
*spec
= codec
->spec
;
389 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
392 static int conexant_mux_enum_get(struct snd_kcontrol
*kcontrol
,
393 struct snd_ctl_elem_value
*ucontrol
)
395 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
396 struct conexant_spec
*spec
= codec
->spec
;
397 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
399 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
403 static int conexant_mux_enum_put(struct snd_kcontrol
*kcontrol
,
404 struct snd_ctl_elem_value
*ucontrol
)
406 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
407 struct conexant_spec
*spec
= codec
->spec
;
408 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
410 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
411 spec
->capsrc_nids
[adc_idx
],
412 &spec
->cur_mux
[adc_idx
]);
415 static int conexant_init_jacks(struct hda_codec
*codec
)
417 #ifdef CONFIG_SND_HDA_INPUT_JACK
418 struct conexant_spec
*spec
= codec
->spec
;
421 for (i
= 0; i
< spec
->num_init_verbs
; i
++) {
422 const struct hda_verb
*hv
;
424 hv
= spec
->init_verbs
[i
];
427 switch (hv
->param
^ AC_USRSP_EN
) {
428 case CONEXANT_HP_EVENT
:
429 err
= snd_hda_input_jack_add(codec
, hv
->nid
,
430 SND_JACK_HEADPHONE
, NULL
);
431 snd_hda_input_jack_report(codec
, hv
->nid
);
433 case CXT5051_PORTC_EVENT
:
434 case CONEXANT_MIC_EVENT
:
435 err
= snd_hda_input_jack_add(codec
, hv
->nid
,
436 SND_JACK_MICROPHONE
, NULL
);
437 snd_hda_input_jack_report(codec
, hv
->nid
);
445 #endif /* CONFIG_SND_HDA_INPUT_JACK */
449 static void conexant_set_power(struct hda_codec
*codec
, hda_nid_t fg
,
450 unsigned int power_state
)
452 if (power_state
== AC_PWRST_D3
)
454 snd_hda_codec_read(codec
, fg
, 0, AC_VERB_SET_POWER_STATE
,
456 /* partial workaround for "azx_get_response timeout" */
457 if (power_state
== AC_PWRST_D0
)
459 snd_hda_codec_set_power_to_all(codec
, fg
, power_state
, true);
462 static int conexant_init(struct hda_codec
*codec
)
464 struct conexant_spec
*spec
= codec
->spec
;
467 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
468 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
472 static void conexant_free(struct hda_codec
*codec
)
474 snd_hda_input_jack_free(codec
);
475 snd_hda_detach_beep_device(codec
);
479 static const struct snd_kcontrol_new cxt_capture_mixers
[] = {
481 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
482 .name
= "Capture Source",
483 .info
= conexant_mux_enum_info
,
484 .get
= conexant_mux_enum_get
,
485 .put
= conexant_mux_enum_put
490 #ifdef CONFIG_SND_HDA_INPUT_BEEP
491 /* additional beep mixers; the actual parameters are overwritten at build */
492 static const struct snd_kcontrol_new cxt_beep_mixer
[] = {
493 HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT
),
494 HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT
),
499 static const char * const slave_vols
[] = {
500 "Headphone Playback Volume",
501 "Speaker Playback Volume",
502 "Front Playback Volume",
503 "Surround Playback Volume",
504 "CLFE Playback Volume",
508 static const char * const slave_sws
[] = {
509 "Headphone Playback Switch",
510 "Speaker Playback Switch",
511 "Front Playback Switch",
512 "Surround Playback Switch",
513 "CLFE Playback Switch",
517 static int conexant_build_controls(struct hda_codec
*codec
)
519 struct conexant_spec
*spec
= codec
->spec
;
523 for (i
= 0; i
< spec
->num_mixers
; i
++) {
524 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
528 if (spec
->multiout
.dig_out_nid
) {
529 err
= snd_hda_create_spdif_out_ctls(codec
,
530 spec
->multiout
.dig_out_nid
,
531 spec
->multiout
.dig_out_nid
);
534 err
= snd_hda_create_spdif_share_sw(codec
,
538 spec
->multiout
.share_spdif
= 1;
540 if (spec
->dig_in_nid
) {
541 err
= snd_hda_create_spdif_in_ctls(codec
,spec
->dig_in_nid
);
546 /* if we have no master control, let's create it */
547 if (spec
->vmaster_nid
&&
548 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
549 unsigned int vmaster_tlv
[4];
550 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
551 HDA_OUTPUT
, vmaster_tlv
);
552 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
553 vmaster_tlv
, slave_vols
);
557 if (spec
->vmaster_nid
&&
558 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
559 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
565 if (spec
->input_mux
) {
566 err
= snd_hda_add_new_ctls(codec
, cxt_capture_mixers
);
571 #ifdef CONFIG_SND_HDA_INPUT_BEEP
572 /* create beep controls if needed */
573 if (spec
->beep_amp
) {
574 const struct snd_kcontrol_new
*knew
;
575 for (knew
= cxt_beep_mixer
; knew
->name
; knew
++) {
576 struct snd_kcontrol
*kctl
;
577 kctl
= snd_ctl_new1(knew
, codec
);
580 kctl
->private_value
= spec
->beep_amp
;
581 err
= snd_hda_ctl_add(codec
, 0, kctl
);
591 #ifdef CONFIG_SND_HDA_POWER_SAVE
592 static int conexant_suspend(struct hda_codec
*codec
, pm_message_t state
)
594 snd_hda_shutup_pins(codec
);
599 static const struct hda_codec_ops conexant_patch_ops
= {
600 .build_controls
= conexant_build_controls
,
601 .build_pcms
= conexant_build_pcms
,
602 .init
= conexant_init
,
603 .free
= conexant_free
,
604 .set_power_state
= conexant_set_power
,
605 #ifdef CONFIG_SND_HDA_POWER_SAVE
606 .suspend
= conexant_suspend
,
608 .reboot_notify
= snd_hda_shutup_pins
,
611 #ifdef CONFIG_SND_HDA_INPUT_BEEP
612 #define set_beep_amp(spec, nid, idx, dir) \
613 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir))
615 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
618 static int patch_conexant_auto(struct hda_codec
*codec
);
621 * the private value = nid | (invert << 8)
624 #define cxt_eapd_info snd_ctl_boolean_mono_info
626 static int cxt_eapd_get(struct snd_kcontrol
*kcontrol
,
627 struct snd_ctl_elem_value
*ucontrol
)
629 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
630 struct conexant_spec
*spec
= codec
->spec
;
631 int invert
= (kcontrol
->private_value
>> 8) & 1;
633 ucontrol
->value
.integer
.value
[0] = !spec
->cur_eapd
;
635 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
640 static int cxt_eapd_put(struct snd_kcontrol
*kcontrol
,
641 struct snd_ctl_elem_value
*ucontrol
)
643 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
644 struct conexant_spec
*spec
= codec
->spec
;
645 int invert
= (kcontrol
->private_value
>> 8) & 1;
646 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
649 eapd
= !!ucontrol
->value
.integer
.value
[0];
652 if (eapd
== spec
->cur_eapd
)
655 spec
->cur_eapd
= eapd
;
656 snd_hda_codec_write_cache(codec
, nid
,
657 0, AC_VERB_SET_EAPD_BTLENABLE
,
662 /* controls for test mode */
663 #ifdef CONFIG_SND_DEBUG
665 #define CXT_EAPD_SWITCH(xname, nid, mask) \
666 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
667 .info = cxt_eapd_info, \
668 .get = cxt_eapd_get, \
669 .put = cxt_eapd_put, \
670 .private_value = nid | (mask<<16) }
674 static int conexant_ch_mode_info(struct snd_kcontrol
*kcontrol
,
675 struct snd_ctl_elem_info
*uinfo
)
677 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
678 struct conexant_spec
*spec
= codec
->spec
;
679 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
680 spec
->num_channel_mode
);
683 static int conexant_ch_mode_get(struct snd_kcontrol
*kcontrol
,
684 struct snd_ctl_elem_value
*ucontrol
)
686 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
687 struct conexant_spec
*spec
= codec
->spec
;
688 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
689 spec
->num_channel_mode
,
690 spec
->multiout
.max_channels
);
693 static int conexant_ch_mode_put(struct snd_kcontrol
*kcontrol
,
694 struct snd_ctl_elem_value
*ucontrol
)
696 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
697 struct conexant_spec
*spec
= codec
->spec
;
698 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
699 spec
->num_channel_mode
,
700 &spec
->multiout
.max_channels
);
701 if (err
>= 0 && spec
->need_dac_fix
)
702 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
706 #define CXT_PIN_MODE(xname, nid, dir) \
707 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
708 .info = conexant_ch_mode_info, \
709 .get = conexant_ch_mode_get, \
710 .put = conexant_ch_mode_put, \
711 .private_value = nid | (dir<<16) }
713 #endif /* CONFIG_SND_DEBUG */
715 /* Conexant 5045 specific */
717 static const hda_nid_t cxt5045_dac_nids
[1] = { 0x19 };
718 static const hda_nid_t cxt5045_adc_nids
[1] = { 0x1a };
719 static const hda_nid_t cxt5045_capsrc_nids
[1] = { 0x1a };
720 #define CXT5045_SPDIF_OUT 0x18
722 static const struct hda_channel_mode cxt5045_modes
[1] = {
726 static const struct hda_input_mux cxt5045_capture_source
= {
734 static const struct hda_input_mux cxt5045_capture_source_benq
= {
745 static const struct hda_input_mux cxt5045_capture_source_hp530
= {
753 /* turn on/off EAPD (+ mute HP) as a master switch */
754 static int cxt5045_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
755 struct snd_ctl_elem_value
*ucontrol
)
757 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
758 struct conexant_spec
*spec
= codec
->spec
;
761 if (!cxt_eapd_put(kcontrol
, ucontrol
))
764 /* toggle internal speakers mute depending of presence of
767 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
768 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
771 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
772 snd_hda_codec_amp_stereo(codec
, 0x11, HDA_OUTPUT
, 0,
777 /* bind volumes of both NID 0x10 and 0x11 */
778 static const struct hda_bind_ctls cxt5045_hp_bind_master_vol
= {
779 .ops
= &snd_hda_bind_vol
,
781 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT
),
782 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT
),
787 /* toggle input of built-in and mic jack appropriately */
788 static void cxt5045_hp_automic(struct hda_codec
*codec
)
790 static const struct hda_verb mic_jack_on
[] = {
791 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
792 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
795 static const struct hda_verb mic_jack_off
[] = {
796 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
797 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
800 unsigned int present
;
802 present
= snd_hda_jack_detect(codec
, 0x12);
804 snd_hda_sequence_write(codec
, mic_jack_on
);
806 snd_hda_sequence_write(codec
, mic_jack_off
);
810 /* mute internal speaker if HP is plugged */
811 static void cxt5045_hp_automute(struct hda_codec
*codec
)
813 struct conexant_spec
*spec
= codec
->spec
;
816 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x11);
818 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
819 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
823 /* unsolicited event for HP jack sensing */
824 static void cxt5045_hp_unsol_event(struct hda_codec
*codec
,
829 case CONEXANT_HP_EVENT
:
830 cxt5045_hp_automute(codec
);
832 case CONEXANT_MIC_EVENT
:
833 cxt5045_hp_automic(codec
);
839 static const struct snd_kcontrol_new cxt5045_mixers
[] = {
840 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
841 HDA_CODEC_MUTE("Internal Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
842 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
843 HDA_CODEC_MUTE("Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
844 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
845 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
846 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
847 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
848 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
849 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
850 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
852 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
853 .name
= "Master Playback Switch",
854 .info
= cxt_eapd_info
,
856 .put
= cxt5045_hp_master_sw_put
,
857 .private_value
= 0x10,
863 static const struct snd_kcontrol_new cxt5045_benq_mixers
[] = {
864 HDA_CODEC_VOLUME("CD Capture Volume", 0x1a, 0x04, HDA_INPUT
),
865 HDA_CODEC_MUTE("CD Capture Switch", 0x1a, 0x04, HDA_INPUT
),
866 HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x4, HDA_INPUT
),
867 HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x4, HDA_INPUT
),
869 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT
),
870 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT
),
871 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT
),
872 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT
),
874 HDA_CODEC_VOLUME("Mixer Capture Volume", 0x1a, 0x0, HDA_INPUT
),
875 HDA_CODEC_MUTE("Mixer Capture Switch", 0x1a, 0x0, HDA_INPUT
),
880 static const struct snd_kcontrol_new cxt5045_mixers_hp530
[] = {
881 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
882 HDA_CODEC_MUTE("Internal Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
883 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
884 HDA_CODEC_MUTE("Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
885 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
886 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
887 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
888 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
889 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
890 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
891 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
893 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
894 .name
= "Master Playback Switch",
895 .info
= cxt_eapd_info
,
897 .put
= cxt5045_hp_master_sw_put
,
898 .private_value
= 0x10,
904 static const struct hda_verb cxt5045_init_verbs
[] = {
906 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
907 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
909 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
910 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
911 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
912 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
913 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
914 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
915 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
916 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
917 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
918 /* Record selector: Internal mic */
919 {0x1a, AC_VERB_SET_CONNECT_SEL
,0x1},
920 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
921 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
922 /* SPDIF route: PCM */
923 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
924 { 0x13, AC_VERB_SET_CONNECT_SEL
, 0x0 },
926 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2 }, /* default on */
930 static const struct hda_verb cxt5045_benq_init_verbs
[] = {
931 /* Internal Mic, Mic */
932 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
933 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
934 /* Line In,HP, Amp */
935 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
936 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
937 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
938 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
939 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
940 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
941 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
942 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
943 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
944 /* Record selector: Internal mic */
945 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x1},
946 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
947 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
948 /* SPDIF route: PCM */
949 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
950 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0},
952 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
956 static const struct hda_verb cxt5045_hp_sense_init_verbs
[] = {
957 /* pin sensing on HP jack */
958 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
962 static const struct hda_verb cxt5045_mic_sense_init_verbs
[] = {
963 /* pin sensing on HP jack */
964 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
968 #ifdef CONFIG_SND_DEBUG
969 /* Test configuration for debugging, modelled after the ALC260 test
972 static const struct hda_input_mux cxt5045_test_capture_source
= {
977 { "LINE1 pin", 0x2 },
978 { "HP-OUT pin", 0x3 },
983 static const struct snd_kcontrol_new cxt5045_test_mixer
[] = {
985 /* Output controls */
986 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
987 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
988 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
989 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
990 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
991 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
993 /* Modes for retasking pin widgets */
994 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT
),
995 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT
),
997 /* EAPD Switch Control */
998 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
1000 /* Loopback mixer controls */
1002 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT
),
1003 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT
),
1004 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT
),
1005 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT
),
1006 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT
),
1007 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT
),
1008 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT
),
1009 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT
),
1010 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT
),
1011 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT
),
1013 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1014 .name
= "Input Source",
1015 .info
= conexant_mux_enum_info
,
1016 .get
= conexant_mux_enum_get
,
1017 .put
= conexant_mux_enum_put
,
1019 /* Audio input controls */
1020 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT
),
1021 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT
),
1022 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT
),
1023 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT
),
1024 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT
),
1025 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT
),
1026 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT
),
1027 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT
),
1028 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT
),
1029 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT
),
1033 static const struct hda_verb cxt5045_test_init_verbs
[] = {
1034 /* Set connections */
1035 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1036 { 0x11, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1037 { 0x12, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1038 /* Enable retasking pins as output, initially without power amp */
1039 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1040 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1042 /* Disable digital (SPDIF) pins initially, but users can enable
1043 * them via a mixer switch. In the case of SPDIF-out, this initverb
1044 * payload also sets the generation to 0, output to be in "consumer"
1045 * PCM format, copyright asserted, no pre-emphasis and no validity
1048 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1049 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1051 /* Start with output sum widgets muted and their output gains at min */
1052 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1053 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1055 /* Unmute retasking pin widget output buffers since the default
1056 * state appears to be output. As the pin mode is changed by the
1057 * user the pin mode control will take care of enabling the pin's
1058 * input/output buffers as needed.
1060 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1061 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1063 /* Mute capture amp left and right */
1064 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1066 /* Set ADC connection select to match default mixer setting (mic1
1069 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1070 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x00},
1072 /* Mute all inputs to mixer widget (even unconnected ones) */
1073 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* Mixer pin */
1074 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* Mic1 pin */
1075 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* Line pin */
1076 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* HP pin */
1077 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1084 /* initialize jack-sensing, too */
1085 static int cxt5045_init(struct hda_codec
*codec
)
1087 conexant_init(codec
);
1088 cxt5045_hp_automute(codec
);
1094 CXT5045_LAPTOP_HPSENSE
,
1095 CXT5045_LAPTOP_MICSENSE
,
1096 CXT5045_LAPTOP_HPMICSENSE
,
1098 CXT5045_LAPTOP_HP530
,
1099 #ifdef CONFIG_SND_DEBUG
1106 static const char * const cxt5045_models
[CXT5045_MODELS
] = {
1107 [CXT5045_LAPTOP_HPSENSE
] = "laptop-hpsense",
1108 [CXT5045_LAPTOP_MICSENSE
] = "laptop-micsense",
1109 [CXT5045_LAPTOP_HPMICSENSE
] = "laptop-hpmicsense",
1110 [CXT5045_BENQ
] = "benq",
1111 [CXT5045_LAPTOP_HP530
] = "laptop-hp530",
1112 #ifdef CONFIG_SND_DEBUG
1113 [CXT5045_TEST
] = "test",
1115 [CXT5045_AUTO
] = "auto",
1118 static const struct snd_pci_quirk cxt5045_cfg_tbl
[] = {
1119 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530
),
1120 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1121 CXT5045_LAPTOP_HPSENSE
),
1122 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE
),
1123 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ
),
1124 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE
),
1125 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE
),
1126 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
1127 CXT5045_LAPTOP_HPMICSENSE
),
1128 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1129 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1130 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1131 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
1132 CXT5045_LAPTOP_HPMICSENSE
),
1133 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE
),
1137 static int patch_cxt5045(struct hda_codec
*codec
)
1139 struct conexant_spec
*spec
;
1142 board_config
= snd_hda_check_board_config(codec
, CXT5045_MODELS
,
1145 if (board_config
< 0)
1146 board_config
= CXT5045_AUTO
; /* model=auto as default */
1147 if (board_config
== CXT5045_AUTO
)
1148 return patch_conexant_auto(codec
);
1150 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1154 codec
->pin_amp_workaround
= 1;
1156 spec
->multiout
.max_channels
= 2;
1157 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5045_dac_nids
);
1158 spec
->multiout
.dac_nids
= cxt5045_dac_nids
;
1159 spec
->multiout
.dig_out_nid
= CXT5045_SPDIF_OUT
;
1160 spec
->num_adc_nids
= 1;
1161 spec
->adc_nids
= cxt5045_adc_nids
;
1162 spec
->capsrc_nids
= cxt5045_capsrc_nids
;
1163 spec
->input_mux
= &cxt5045_capture_source
;
1164 spec
->num_mixers
= 1;
1165 spec
->mixers
[0] = cxt5045_mixers
;
1166 spec
->num_init_verbs
= 1;
1167 spec
->init_verbs
[0] = cxt5045_init_verbs
;
1168 spec
->spdif_route
= 0;
1169 spec
->num_channel_mode
= ARRAY_SIZE(cxt5045_modes
);
1170 spec
->channel_mode
= cxt5045_modes
;
1172 set_beep_amp(spec
, 0x16, 0, 1);
1174 codec
->patch_ops
= conexant_patch_ops
;
1176 switch (board_config
) {
1177 case CXT5045_LAPTOP_HPSENSE
:
1178 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1179 spec
->input_mux
= &cxt5045_capture_source
;
1180 spec
->num_init_verbs
= 2;
1181 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1182 spec
->mixers
[0] = cxt5045_mixers
;
1183 codec
->patch_ops
.init
= cxt5045_init
;
1185 case CXT5045_LAPTOP_MICSENSE
:
1186 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1187 spec
->input_mux
= &cxt5045_capture_source
;
1188 spec
->num_init_verbs
= 2;
1189 spec
->init_verbs
[1] = cxt5045_mic_sense_init_verbs
;
1190 spec
->mixers
[0] = cxt5045_mixers
;
1191 codec
->patch_ops
.init
= cxt5045_init
;
1194 case CXT5045_LAPTOP_HPMICSENSE
:
1195 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1196 spec
->input_mux
= &cxt5045_capture_source
;
1197 spec
->num_init_verbs
= 3;
1198 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1199 spec
->init_verbs
[2] = cxt5045_mic_sense_init_verbs
;
1200 spec
->mixers
[0] = cxt5045_mixers
;
1201 codec
->patch_ops
.init
= cxt5045_init
;
1204 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1205 spec
->input_mux
= &cxt5045_capture_source_benq
;
1206 spec
->num_init_verbs
= 1;
1207 spec
->init_verbs
[0] = cxt5045_benq_init_verbs
;
1208 spec
->mixers
[0] = cxt5045_mixers
;
1209 spec
->mixers
[1] = cxt5045_benq_mixers
;
1210 spec
->num_mixers
= 2;
1211 codec
->patch_ops
.init
= cxt5045_init
;
1213 case CXT5045_LAPTOP_HP530
:
1214 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1215 spec
->input_mux
= &cxt5045_capture_source_hp530
;
1216 spec
->num_init_verbs
= 2;
1217 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1218 spec
->mixers
[0] = cxt5045_mixers_hp530
;
1219 codec
->patch_ops
.init
= cxt5045_init
;
1221 #ifdef CONFIG_SND_DEBUG
1223 spec
->input_mux
= &cxt5045_test_capture_source
;
1224 spec
->mixers
[0] = cxt5045_test_mixer
;
1225 spec
->init_verbs
[0] = cxt5045_test_init_verbs
;
1231 switch (codec
->subsystem_id
>> 16) {
1236 /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have
1237 * really bad sound over 0dB on NID 0x17. Fix max PCM level to
1238 * 0 dB (originally it has 0x2b steps with 0dB offset 0x14)
1240 snd_hda_override_amp_caps(codec
, 0x17, HDA_INPUT
,
1241 (0x14 << AC_AMPCAP_OFFSET_SHIFT
) |
1242 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1243 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1244 (1 << AC_AMPCAP_MUTE_SHIFT
));
1249 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
1255 /* Conexant 5047 specific */
1256 #define CXT5047_SPDIF_OUT 0x11
1258 static const hda_nid_t cxt5047_dac_nids
[1] = { 0x10 }; /* 0x1c */
1259 static const hda_nid_t cxt5047_adc_nids
[1] = { 0x12 };
1260 static const hda_nid_t cxt5047_capsrc_nids
[1] = { 0x1a };
1262 static const struct hda_channel_mode cxt5047_modes
[1] = {
1266 static const struct hda_input_mux cxt5047_toshiba_capture_source
= {
1274 /* turn on/off EAPD (+ mute HP) as a master switch */
1275 static int cxt5047_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1276 struct snd_ctl_elem_value
*ucontrol
)
1278 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1279 struct conexant_spec
*spec
= codec
->spec
;
1282 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1285 /* toggle internal speakers mute depending of presence of
1286 * the headphone jack
1288 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
1289 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1290 * pin widgets unlike other codecs. In this case, we need to
1291 * set index 0x01 for the volume from the mixer amp 0x19.
1293 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1294 HDA_AMP_MUTE
, bits
);
1295 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
1296 snd_hda_codec_amp_stereo(codec
, 0x13, HDA_OUTPUT
, 0,
1297 HDA_AMP_MUTE
, bits
);
1301 /* mute internal speaker if HP is plugged */
1302 static void cxt5047_hp_automute(struct hda_codec
*codec
)
1304 struct conexant_spec
*spec
= codec
->spec
;
1307 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x13);
1309 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
1310 /* See the note in cxt5047_hp_master_sw_put */
1311 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1312 HDA_AMP_MUTE
, bits
);
1315 /* toggle input of built-in and mic jack appropriately */
1316 static void cxt5047_hp_automic(struct hda_codec
*codec
)
1318 static const struct hda_verb mic_jack_on
[] = {
1319 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1320 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1323 static const struct hda_verb mic_jack_off
[] = {
1324 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1325 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1328 unsigned int present
;
1330 present
= snd_hda_jack_detect(codec
, 0x15);
1332 snd_hda_sequence_write(codec
, mic_jack_on
);
1334 snd_hda_sequence_write(codec
, mic_jack_off
);
1337 /* unsolicited event for HP jack sensing */
1338 static void cxt5047_hp_unsol_event(struct hda_codec
*codec
,
1341 switch (res
>> 26) {
1342 case CONEXANT_HP_EVENT
:
1343 cxt5047_hp_automute(codec
);
1345 case CONEXANT_MIC_EVENT
:
1346 cxt5047_hp_automic(codec
);
1351 static const struct snd_kcontrol_new cxt5047_base_mixers
[] = {
1352 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT
),
1353 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT
),
1354 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1355 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT
),
1356 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT
),
1357 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT
),
1358 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT
),
1360 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1361 .name
= "Master Playback Switch",
1362 .info
= cxt_eapd_info
,
1363 .get
= cxt_eapd_get
,
1364 .put
= cxt5047_hp_master_sw_put
,
1365 .private_value
= 0x13,
1371 static const struct snd_kcontrol_new cxt5047_hp_spk_mixers
[] = {
1372 /* See the note in cxt5047_hp_master_sw_put */
1373 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT
),
1374 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1378 static const struct snd_kcontrol_new cxt5047_hp_only_mixers
[] = {
1379 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1383 static const struct hda_verb cxt5047_init_verbs
[] = {
1384 /* Line in, Mic, Built-in Mic */
1385 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1386 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1387 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1389 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1390 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* mixer(0x19) */
1391 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mixer(0x19) */
1392 /* Record selector: Mic */
1393 {0x12, AC_VERB_SET_CONNECT_SEL
,0x03},
1394 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
,
1395 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
1396 {0x1A, AC_VERB_SET_CONNECT_SEL
,0x02},
1397 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1398 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x00},
1399 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1400 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x03},
1401 /* SPDIF route: PCM */
1402 { 0x18, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1403 /* Enable unsolicited events */
1404 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
1405 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1409 /* configuration for Toshiba Laptops */
1410 static const struct hda_verb cxt5047_toshiba_init_verbs
[] = {
1411 {0x13, AC_VERB_SET_EAPD_BTLENABLE
, 0x0}, /* default off */
1415 /* Test configuration for debugging, modelled after the ALC260 test
1418 #ifdef CONFIG_SND_DEBUG
1419 static const struct hda_input_mux cxt5047_test_capture_source
= {
1422 { "LINE1 pin", 0x0 },
1423 { "MIC1 pin", 0x1 },
1424 { "MIC2 pin", 0x2 },
1429 static const struct snd_kcontrol_new cxt5047_test_mixer
[] = {
1431 /* Output only controls */
1432 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT
),
1433 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT
),
1434 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT
),
1435 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT
),
1436 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1437 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1438 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1439 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1440 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT
),
1441 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT
),
1442 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
1443 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
1445 /* Modes for retasking pin widgets */
1446 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT
),
1447 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT
),
1449 /* EAPD Switch Control */
1450 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1452 /* Loopback mixer controls */
1453 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT
),
1454 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT
),
1455 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT
),
1456 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT
),
1457 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT
),
1458 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT
),
1459 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT
),
1460 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT
),
1462 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT
),
1463 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT
),
1464 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT
),
1465 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT
),
1466 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT
),
1467 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT
),
1468 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT
),
1469 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT
),
1471 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1472 .name
= "Input Source",
1473 .info
= conexant_mux_enum_info
,
1474 .get
= conexant_mux_enum_get
,
1475 .put
= conexant_mux_enum_put
,
1477 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1482 static const struct hda_verb cxt5047_test_init_verbs
[] = {
1483 /* Enable retasking pins as output, initially without power amp */
1484 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1485 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1486 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1488 /* Disable digital (SPDIF) pins initially, but users can enable
1489 * them via a mixer switch. In the case of SPDIF-out, this initverb
1490 * payload also sets the generation to 0, output to be in "consumer"
1491 * PCM format, copyright asserted, no pre-emphasis and no validity
1494 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1496 /* Ensure mic1, mic2, line1 pin widgets take input from the
1497 * OUT1 sum bus when acting as an output.
1499 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0},
1500 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0},
1502 /* Start with output sum widgets muted and their output gains at min */
1503 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1504 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1506 /* Unmute retasking pin widget output buffers since the default
1507 * state appears to be output. As the pin mode is changed by the
1508 * user the pin mode control will take care of enabling the pin's
1509 * input/output buffers as needed.
1511 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1512 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1513 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1515 /* Mute capture amp left and right */
1516 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1518 /* Set ADC connection select to match default mixer setting (mic1
1521 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x00},
1523 /* Mute all inputs to mixer widget (even unconnected ones) */
1524 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* mic1 pin */
1525 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* mic2 pin */
1526 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* line1 pin */
1527 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* line2 pin */
1528 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1529 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1530 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)}, /* Line-out pin */
1531 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)}, /* HP-pin pin */
1538 /* initialize jack-sensing, too */
1539 static int cxt5047_hp_init(struct hda_codec
*codec
)
1541 conexant_init(codec
);
1542 cxt5047_hp_automute(codec
);
1548 CXT5047_LAPTOP
, /* Laptops w/o EAPD support */
1549 CXT5047_LAPTOP_HP
, /* Some HP laptops */
1550 CXT5047_LAPTOP_EAPD
, /* Laptops with EAPD support */
1551 #ifdef CONFIG_SND_DEBUG
1558 static const char * const cxt5047_models
[CXT5047_MODELS
] = {
1559 [CXT5047_LAPTOP
] = "laptop",
1560 [CXT5047_LAPTOP_HP
] = "laptop-hp",
1561 [CXT5047_LAPTOP_EAPD
] = "laptop-eapd",
1562 #ifdef CONFIG_SND_DEBUG
1563 [CXT5047_TEST
] = "test",
1565 [CXT5047_AUTO
] = "auto",
1568 static const struct snd_pci_quirk cxt5047_cfg_tbl
[] = {
1569 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP
),
1570 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1572 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD
),
1576 static int patch_cxt5047(struct hda_codec
*codec
)
1578 struct conexant_spec
*spec
;
1581 board_config
= snd_hda_check_board_config(codec
, CXT5047_MODELS
,
1584 if (board_config
< 0)
1585 board_config
= CXT5047_AUTO
; /* model=auto as default */
1586 if (board_config
== CXT5047_AUTO
)
1587 return patch_conexant_auto(codec
);
1589 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1593 codec
->pin_amp_workaround
= 1;
1595 spec
->multiout
.max_channels
= 2;
1596 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5047_dac_nids
);
1597 spec
->multiout
.dac_nids
= cxt5047_dac_nids
;
1598 spec
->multiout
.dig_out_nid
= CXT5047_SPDIF_OUT
;
1599 spec
->num_adc_nids
= 1;
1600 spec
->adc_nids
= cxt5047_adc_nids
;
1601 spec
->capsrc_nids
= cxt5047_capsrc_nids
;
1602 spec
->num_mixers
= 1;
1603 spec
->mixers
[0] = cxt5047_base_mixers
;
1604 spec
->num_init_verbs
= 1;
1605 spec
->init_verbs
[0] = cxt5047_init_verbs
;
1606 spec
->spdif_route
= 0;
1607 spec
->num_channel_mode
= ARRAY_SIZE(cxt5047_modes
),
1608 spec
->channel_mode
= cxt5047_modes
,
1610 codec
->patch_ops
= conexant_patch_ops
;
1612 switch (board_config
) {
1613 case CXT5047_LAPTOP
:
1614 spec
->num_mixers
= 2;
1615 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1616 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1618 case CXT5047_LAPTOP_HP
:
1619 spec
->num_mixers
= 2;
1620 spec
->mixers
[1] = cxt5047_hp_only_mixers
;
1621 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1622 codec
->patch_ops
.init
= cxt5047_hp_init
;
1624 case CXT5047_LAPTOP_EAPD
:
1625 spec
->input_mux
= &cxt5047_toshiba_capture_source
;
1626 spec
->num_mixers
= 2;
1627 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1628 spec
->num_init_verbs
= 2;
1629 spec
->init_verbs
[1] = cxt5047_toshiba_init_verbs
;
1630 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1632 #ifdef CONFIG_SND_DEBUG
1634 spec
->input_mux
= &cxt5047_test_capture_source
;
1635 spec
->mixers
[0] = cxt5047_test_mixer
;
1636 spec
->init_verbs
[0] = cxt5047_test_init_verbs
;
1637 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1640 spec
->vmaster_nid
= 0x13;
1642 switch (codec
->subsystem_id
>> 16) {
1644 /* HP laptops have really bad sound over 0 dB on NID 0x10.
1645 * Fix max PCM level to 0 dB (originally it has 0x1e steps
1646 * with 0 dB offset 0x17)
1648 snd_hda_override_amp_caps(codec
, 0x10, HDA_INPUT
,
1649 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
1650 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1651 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1652 (1 << AC_AMPCAP_MUTE_SHIFT
));
1659 /* Conexant 5051 specific */
1660 static const hda_nid_t cxt5051_dac_nids
[1] = { 0x10 };
1661 static const hda_nid_t cxt5051_adc_nids
[2] = { 0x14, 0x15 };
1663 static const struct hda_channel_mode cxt5051_modes
[1] = {
1667 static void cxt5051_update_speaker(struct hda_codec
*codec
)
1669 struct conexant_spec
*spec
= codec
->spec
;
1670 unsigned int pinctl
;
1672 pinctl
= (spec
->hp_present
&& spec
->cur_eapd
) ? PIN_HP
: 0;
1673 snd_hda_codec_write(codec
, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1676 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1677 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1679 /* on ideapad there is an aditional speaker (subwoofer) to mute */
1681 snd_hda_codec_write(codec
, 0x1b, 0,
1682 AC_VERB_SET_PIN_WIDGET_CONTROL
,
1686 /* turn on/off EAPD (+ mute HP) as a master switch */
1687 static int cxt5051_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1688 struct snd_ctl_elem_value
*ucontrol
)
1690 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1692 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1694 cxt5051_update_speaker(codec
);
1698 /* toggle input of built-in and mic jack appropriately */
1699 static void cxt5051_portb_automic(struct hda_codec
*codec
)
1701 struct conexant_spec
*spec
= codec
->spec
;
1702 unsigned int present
;
1704 if (!(spec
->auto_mic
& AUTO_MIC_PORTB
))
1706 present
= snd_hda_jack_detect(codec
, 0x17);
1707 snd_hda_codec_write(codec
, 0x14, 0,
1708 AC_VERB_SET_CONNECT_SEL
,
1709 present
? 0x01 : 0x00);
1712 /* switch the current ADC according to the jack state */
1713 static void cxt5051_portc_automic(struct hda_codec
*codec
)
1715 struct conexant_spec
*spec
= codec
->spec
;
1716 unsigned int present
;
1719 if (!(spec
->auto_mic
& AUTO_MIC_PORTC
))
1721 present
= snd_hda_jack_detect(codec
, 0x18);
1723 spec
->cur_adc_idx
= 1;
1725 spec
->cur_adc_idx
= 0;
1726 new_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
1727 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
1728 /* stream is running, let's swap the current ADC */
1729 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
1730 spec
->cur_adc
= new_adc
;
1731 snd_hda_codec_setup_stream(codec
, new_adc
,
1732 spec
->cur_adc_stream_tag
, 0,
1733 spec
->cur_adc_format
);
1737 /* mute internal speaker if HP is plugged */
1738 static void cxt5051_hp_automute(struct hda_codec
*codec
)
1740 struct conexant_spec
*spec
= codec
->spec
;
1742 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x16);
1743 cxt5051_update_speaker(codec
);
1746 /* unsolicited event for HP jack sensing */
1747 static void cxt5051_hp_unsol_event(struct hda_codec
*codec
,
1750 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
1751 switch (res
>> 26) {
1752 case CONEXANT_HP_EVENT
:
1753 cxt5051_hp_automute(codec
);
1755 case CXT5051_PORTB_EVENT
:
1756 cxt5051_portb_automic(codec
);
1758 case CXT5051_PORTC_EVENT
:
1759 cxt5051_portc_automic(codec
);
1762 snd_hda_input_jack_report(codec
, nid
);
1765 static const struct snd_kcontrol_new cxt5051_playback_mixers
[] = {
1766 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1768 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1769 .name
= "Master Playback Switch",
1770 .info
= cxt_eapd_info
,
1771 .get
= cxt_eapd_get
,
1772 .put
= cxt5051_hp_master_sw_put
,
1773 .private_value
= 0x1a,
1778 static const struct snd_kcontrol_new cxt5051_capture_mixers
[] = {
1779 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1780 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1781 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT
),
1782 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT
),
1783 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT
),
1784 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT
),
1788 static const struct snd_kcontrol_new cxt5051_hp_mixers
[] = {
1789 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1790 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1791 HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT
),
1792 HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT
),
1796 static const struct snd_kcontrol_new cxt5051_hp_dv6736_mixers
[] = {
1797 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT
),
1798 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT
),
1802 static const struct snd_kcontrol_new cxt5051_f700_mixers
[] = {
1803 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT
),
1804 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT
),
1808 static const struct snd_kcontrol_new cxt5051_toshiba_mixers
[] = {
1809 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1810 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1811 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT
),
1812 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT
),
1816 static const struct hda_verb cxt5051_init_verbs
[] = {
1818 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1819 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1820 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1821 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1822 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1823 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1825 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1826 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1828 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1829 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1831 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1832 /* Record selector: Internal mic */
1833 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1834 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1835 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1836 /* SPDIF route: PCM */
1837 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1838 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1840 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1841 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1845 static const struct hda_verb cxt5051_hp_dv6736_init_verbs
[] = {
1847 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1848 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1849 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1850 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1852 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1853 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1855 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1856 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1858 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1859 /* Record selector: Internal mic */
1860 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1861 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1862 /* SPDIF route: PCM */
1863 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1865 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1866 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1870 static const struct hda_verb cxt5051_f700_init_verbs
[] = {
1872 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1873 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1874 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1875 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1877 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1878 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1880 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1881 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1883 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1884 /* Record selector: Internal mic */
1885 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1886 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1887 /* SPDIF route: PCM */
1888 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1890 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1891 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1895 static void cxt5051_init_mic_port(struct hda_codec
*codec
, hda_nid_t nid
,
1898 snd_hda_codec_write(codec
, nid
, 0,
1899 AC_VERB_SET_UNSOLICITED_ENABLE
,
1900 AC_USRSP_EN
| event
);
1901 snd_hda_input_jack_add(codec
, nid
, SND_JACK_MICROPHONE
, NULL
);
1902 snd_hda_input_jack_report(codec
, nid
);
1905 static const struct hda_verb cxt5051_ideapad_init_verbs
[] = {
1907 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1908 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0x00},
1912 /* initialize jack-sensing, too */
1913 static int cxt5051_init(struct hda_codec
*codec
)
1915 struct conexant_spec
*spec
= codec
->spec
;
1917 conexant_init(codec
);
1918 conexant_init_jacks(codec
);
1920 if (spec
->auto_mic
& AUTO_MIC_PORTB
)
1921 cxt5051_init_mic_port(codec
, 0x17, CXT5051_PORTB_EVENT
);
1922 if (spec
->auto_mic
& AUTO_MIC_PORTC
)
1923 cxt5051_init_mic_port(codec
, 0x18, CXT5051_PORTC_EVENT
);
1925 if (codec
->patch_ops
.unsol_event
) {
1926 cxt5051_hp_automute(codec
);
1927 cxt5051_portb_automic(codec
);
1928 cxt5051_portc_automic(codec
);
1935 CXT5051_LAPTOP
, /* Laptops w/ EAPD support */
1936 CXT5051_HP
, /* no docking */
1937 CXT5051_HP_DV6736
, /* HP without mic switch */
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_F700
] = "hp-700",
1950 [CXT5051_TOSHIBA
] = "toshiba",
1951 [CXT5051_IDEAPAD
] = "ideapad",
1952 [CXT5051_AUTO
] = "auto",
1955 static const struct snd_pci_quirk cxt5051_cfg_tbl
[] = {
1956 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736
),
1957 SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP
),
1958 SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700
),
1959 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA
),
1960 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1962 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP
),
1963 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD
),
1967 static int patch_cxt5051(struct hda_codec
*codec
)
1969 struct conexant_spec
*spec
;
1972 board_config
= snd_hda_check_board_config(codec
, CXT5051_MODELS
,
1975 if (board_config
< 0)
1976 board_config
= CXT5051_AUTO
; /* model=auto as default */
1977 if (board_config
== CXT5051_AUTO
)
1978 return patch_conexant_auto(codec
);
1980 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1984 codec
->pin_amp_workaround
= 1;
1986 codec
->patch_ops
= conexant_patch_ops
;
1987 codec
->patch_ops
.init
= cxt5051_init
;
1989 spec
->multiout
.max_channels
= 2;
1990 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5051_dac_nids
);
1991 spec
->multiout
.dac_nids
= cxt5051_dac_nids
;
1992 spec
->multiout
.dig_out_nid
= CXT5051_SPDIF_OUT
;
1993 spec
->num_adc_nids
= 1; /* not 2; via auto-mic switch */
1994 spec
->adc_nids
= cxt5051_adc_nids
;
1995 spec
->num_mixers
= 2;
1996 spec
->mixers
[0] = cxt5051_capture_mixers
;
1997 spec
->mixers
[1] = cxt5051_playback_mixers
;
1998 spec
->num_init_verbs
= 1;
1999 spec
->init_verbs
[0] = cxt5051_init_verbs
;
2000 spec
->spdif_route
= 0;
2001 spec
->num_channel_mode
= ARRAY_SIZE(cxt5051_modes
);
2002 spec
->channel_mode
= cxt5051_modes
;
2004 spec
->cur_adc_idx
= 0;
2006 set_beep_amp(spec
, 0x13, 0, HDA_OUTPUT
);
2008 codec
->patch_ops
.unsol_event
= cxt5051_hp_unsol_event
;
2010 spec
->auto_mic
= AUTO_MIC_PORTB
| AUTO_MIC_PORTC
;
2011 switch (board_config
) {
2013 spec
->mixers
[0] = cxt5051_hp_mixers
;
2015 case CXT5051_HP_DV6736
:
2016 spec
->init_verbs
[0] = cxt5051_hp_dv6736_init_verbs
;
2017 spec
->mixers
[0] = cxt5051_hp_dv6736_mixers
;
2021 spec
->init_verbs
[0] = cxt5051_f700_init_verbs
;
2022 spec
->mixers
[0] = cxt5051_f700_mixers
;
2025 case CXT5051_TOSHIBA
:
2026 spec
->mixers
[0] = cxt5051_toshiba_mixers
;
2027 spec
->auto_mic
= AUTO_MIC_PORTB
;
2029 case CXT5051_IDEAPAD
:
2030 spec
->init_verbs
[spec
->num_init_verbs
++] =
2031 cxt5051_ideapad_init_verbs
;
2037 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
2042 /* Conexant 5066 specific */
2044 static const hda_nid_t cxt5066_dac_nids
[1] = { 0x10 };
2045 static const hda_nid_t cxt5066_adc_nids
[3] = { 0x14, 0x15, 0x16 };
2046 static const hda_nid_t cxt5066_capsrc_nids
[1] = { 0x17 };
2047 static const hda_nid_t cxt5066_digout_pin_nids
[2] = { 0x20, 0x22 };
2049 /* OLPC's microphone port is DC coupled for use with external sensors,
2050 * therefore we use a 50% mic bias in order to center the input signal with
2051 * the DC input range of the codec. */
2052 #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50
2054 static const struct hda_channel_mode cxt5066_modes
[1] = {
2058 #define HP_PRESENT_PORT_A (1 << 0)
2059 #define HP_PRESENT_PORT_D (1 << 1)
2060 #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A)
2061 #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D)
2063 static void cxt5066_update_speaker(struct hda_codec
*codec
)
2065 struct conexant_spec
*spec
= codec
->spec
;
2066 unsigned int pinctl
;
2068 snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n",
2069 spec
->hp_present
, spec
->cur_eapd
);
2072 pinctl
= (hp_port_a_present(spec
) && spec
->cur_eapd
) ? PIN_HP
: 0;
2073 snd_hda_codec_write(codec
, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2076 /* Port D (HP/LO) */
2077 pinctl
= spec
->cur_eapd
? spec
->port_d_mode
: 0;
2078 if (spec
->dell_automute
|| spec
->thinkpad
) {
2079 /* Mute if Port A is connected */
2080 if (hp_port_a_present(spec
))
2083 /* Thinkpad/Dell doesn't give pin-D status */
2084 if (!hp_port_d_present(spec
))
2087 snd_hda_codec_write(codec
, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2091 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
2092 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2096 /* turn on/off EAPD (+ mute HP) as a master switch */
2097 static int cxt5066_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
2098 struct snd_ctl_elem_value
*ucontrol
)
2100 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2102 if (!cxt_eapd_put(kcontrol
, ucontrol
))
2105 cxt5066_update_speaker(codec
);
2109 static const struct hda_input_mux cxt5066_olpc_dc_bias
= {
2113 { "50%", PIN_VREF50
},
2114 { "80%", PIN_VREF80
},
2118 static int cxt5066_set_olpc_dc_bias(struct hda_codec
*codec
)
2120 struct conexant_spec
*spec
= codec
->spec
;
2121 /* Even though port F is the DC input, the bias is controlled on port B.
2122 * we also leave that port as an active input (but unselected) in DC mode
2123 * just in case that is necessary to make the bias setting take effect. */
2124 return snd_hda_codec_write_cache(codec
, 0x1a, 0,
2125 AC_VERB_SET_PIN_WIDGET_CONTROL
,
2126 cxt5066_olpc_dc_bias
.items
[spec
->dc_input_bias
].index
);
2129 /* OLPC defers mic widget control until when capture is started because the
2130 * microphone LED comes on as soon as these settings are put in place. if we
2131 * did this before recording, it would give the false indication that recording
2132 * is happening when it is not. */
2133 static void cxt5066_olpc_select_mic(struct hda_codec
*codec
)
2135 struct conexant_spec
*spec
= codec
->spec
;
2136 if (!spec
->recording
)
2139 if (spec
->dc_enable
) {
2140 /* in DC mode we ignore presence detection and just use the jack
2141 * through our special DC port */
2142 const struct hda_verb enable_dc_mode
[] = {
2143 /* disble internal mic, port C */
2144 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2146 /* enable DC capture, port F */
2147 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2151 snd_hda_sequence_write(codec
, enable_dc_mode
);
2152 /* port B input disabled (and bias set) through the following call */
2153 cxt5066_set_olpc_dc_bias(codec
);
2157 /* disable DC (port F) */
2158 snd_hda_codec_write(codec
, 0x1e, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0);
2160 /* external mic, port B */
2161 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2162 spec
->ext_mic_present
? CXT5066_OLPC_EXT_MIC_BIAS
: 0);
2164 /* internal mic, port C */
2165 snd_hda_codec_write(codec
, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2166 spec
->ext_mic_present
? 0 : PIN_VREF80
);
2169 /* toggle input of built-in and mic jack appropriately */
2170 static void cxt5066_olpc_automic(struct hda_codec
*codec
)
2172 struct conexant_spec
*spec
= codec
->spec
;
2173 unsigned int present
;
2175 if (spec
->dc_enable
) /* don't do presence detection in DC mode */
2178 present
= snd_hda_codec_read(codec
, 0x1a, 0,
2179 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
2181 snd_printdd("CXT5066: external microphone detected\n");
2183 snd_printdd("CXT5066: external microphone absent\n");
2185 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2187 spec
->ext_mic_present
= !!present
;
2189 cxt5066_olpc_select_mic(codec
);
2192 /* toggle input of built-in digital mic and mic jack appropriately */
2193 static void cxt5066_vostro_automic(struct hda_codec
*codec
)
2195 unsigned int present
;
2197 struct hda_verb ext_mic_present
[] = {
2198 /* enable external mic, port B */
2199 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2201 /* switch to external mic input */
2202 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2203 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2205 /* disable internal digital mic */
2206 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2209 static const struct hda_verb ext_mic_absent
[] = {
2210 /* enable internal mic, port C */
2211 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2213 /* switch to internal mic input */
2214 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2216 /* disable external mic, port B */
2217 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2221 present
= snd_hda_jack_detect(codec
, 0x1a);
2223 snd_printdd("CXT5066: external microphone detected\n");
2224 snd_hda_sequence_write(codec
, ext_mic_present
);
2226 snd_printdd("CXT5066: external microphone absent\n");
2227 snd_hda_sequence_write(codec
, ext_mic_absent
);
2231 /* toggle input of built-in digital mic and mic jack appropriately */
2232 static void cxt5066_ideapad_automic(struct hda_codec
*codec
)
2234 unsigned int present
;
2236 struct hda_verb ext_mic_present
[] = {
2237 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2238 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2239 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2242 static const struct hda_verb ext_mic_absent
[] = {
2243 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2244 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2245 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2249 present
= snd_hda_jack_detect(codec
, 0x1b);
2251 snd_printdd("CXT5066: external microphone detected\n");
2252 snd_hda_sequence_write(codec
, ext_mic_present
);
2254 snd_printdd("CXT5066: external microphone absent\n");
2255 snd_hda_sequence_write(codec
, ext_mic_absent
);
2260 /* toggle input of built-in digital mic and mic jack appropriately */
2261 static void cxt5066_asus_automic(struct hda_codec
*codec
)
2263 unsigned int present
;
2265 present
= snd_hda_jack_detect(codec
, 0x1b);
2266 snd_printdd("CXT5066: external microphone present=%d\n", present
);
2267 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2272 /* toggle input of built-in digital mic and mic jack appropriately */
2273 static void cxt5066_hp_laptop_automic(struct hda_codec
*codec
)
2275 unsigned int present
;
2277 present
= snd_hda_jack_detect(codec
, 0x1b);
2278 snd_printdd("CXT5066: external microphone present=%d\n", present
);
2279 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2284 /* toggle input of built-in digital mic and mic jack appropriately
2285 order is: external mic -> dock mic -> interal mic */
2286 static void cxt5066_thinkpad_automic(struct hda_codec
*codec
)
2288 unsigned int ext_present
, dock_present
;
2290 static const struct hda_verb ext_mic_present
[] = {
2291 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2292 {0x17, AC_VERB_SET_CONNECT_SEL
, 1},
2293 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2294 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2295 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2298 static const struct hda_verb dock_mic_present
[] = {
2299 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2300 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2301 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2302 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2303 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2306 static const struct hda_verb ext_mic_absent
[] = {
2307 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2308 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2309 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2310 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2314 ext_present
= snd_hda_jack_detect(codec
, 0x1b);
2315 dock_present
= snd_hda_jack_detect(codec
, 0x1a);
2317 snd_printdd("CXT5066: external microphone detected\n");
2318 snd_hda_sequence_write(codec
, ext_mic_present
);
2319 } else if (dock_present
) {
2320 snd_printdd("CXT5066: dock microphone detected\n");
2321 snd_hda_sequence_write(codec
, dock_mic_present
);
2323 snd_printdd("CXT5066: external microphone absent\n");
2324 snd_hda_sequence_write(codec
, ext_mic_absent
);
2328 /* mute internal speaker if HP is plugged */
2329 static void cxt5066_hp_automute(struct hda_codec
*codec
)
2331 struct conexant_spec
*spec
= codec
->spec
;
2332 unsigned int portA
, portD
;
2335 portA
= snd_hda_jack_detect(codec
, 0x19);
2338 portD
= snd_hda_jack_detect(codec
, 0x1c);
2340 spec
->hp_present
= portA
? HP_PRESENT_PORT_A
: 0;
2341 spec
->hp_present
|= portD
? HP_PRESENT_PORT_D
: 0;
2342 snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
2343 portA
, portD
, spec
->hp_present
);
2344 cxt5066_update_speaker(codec
);
2347 /* Dispatch the right mic autoswitch function */
2348 static void cxt5066_automic(struct hda_codec
*codec
)
2350 struct conexant_spec
*spec
= codec
->spec
;
2352 if (spec
->dell_vostro
)
2353 cxt5066_vostro_automic(codec
);
2354 else if (spec
->ideapad
)
2355 cxt5066_ideapad_automic(codec
);
2356 else if (spec
->thinkpad
)
2357 cxt5066_thinkpad_automic(codec
);
2358 else if (spec
->hp_laptop
)
2359 cxt5066_hp_laptop_automic(codec
);
2360 else if (spec
->asus
)
2361 cxt5066_asus_automic(codec
);
2364 /* unsolicited event for jack sensing */
2365 static void cxt5066_olpc_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2367 struct conexant_spec
*spec
= codec
->spec
;
2368 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2369 switch (res
>> 26) {
2370 case CONEXANT_HP_EVENT
:
2371 cxt5066_hp_automute(codec
);
2373 case CONEXANT_MIC_EVENT
:
2374 /* ignore mic events in DC mode; we're always using the jack */
2375 if (!spec
->dc_enable
)
2376 cxt5066_olpc_automic(codec
);
2381 /* unsolicited event for jack sensing */
2382 static void cxt5066_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2384 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2385 switch (res
>> 26) {
2386 case CONEXANT_HP_EVENT
:
2387 cxt5066_hp_automute(codec
);
2389 case CONEXANT_MIC_EVENT
:
2390 cxt5066_automic(codec
);
2396 static const struct hda_input_mux cxt5066_analog_mic_boost
= {
2407 static void cxt5066_set_mic_boost(struct hda_codec
*codec
)
2409 struct conexant_spec
*spec
= codec
->spec
;
2410 snd_hda_codec_write_cache(codec
, 0x17, 0,
2411 AC_VERB_SET_AMP_GAIN_MUTE
,
2412 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_OUTPUT
|
2413 cxt5066_analog_mic_boost
.items
[spec
->mic_boost
].index
);
2414 if (spec
->ideapad
|| spec
->thinkpad
) {
2415 /* adjust the internal mic as well...it is not through 0x17 */
2416 snd_hda_codec_write_cache(codec
, 0x23, 0,
2417 AC_VERB_SET_AMP_GAIN_MUTE
,
2418 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_INPUT
|
2419 cxt5066_analog_mic_boost
.
2420 items
[spec
->mic_boost
].index
);
2424 static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol
*kcontrol
,
2425 struct snd_ctl_elem_info
*uinfo
)
2427 return snd_hda_input_mux_info(&cxt5066_analog_mic_boost
, uinfo
);
2430 static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol
*kcontrol
,
2431 struct snd_ctl_elem_value
*ucontrol
)
2433 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2434 struct conexant_spec
*spec
= codec
->spec
;
2435 ucontrol
->value
.enumerated
.item
[0] = spec
->mic_boost
;
2439 static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol
*kcontrol
,
2440 struct snd_ctl_elem_value
*ucontrol
)
2442 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2443 struct conexant_spec
*spec
= codec
->spec
;
2444 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2446 idx
= ucontrol
->value
.enumerated
.item
[0];
2447 if (idx
>= imux
->num_items
)
2448 idx
= imux
->num_items
- 1;
2450 spec
->mic_boost
= idx
;
2451 if (!spec
->dc_enable
)
2452 cxt5066_set_mic_boost(codec
);
2456 static void cxt5066_enable_dc(struct hda_codec
*codec
)
2458 const struct hda_verb enable_dc_mode
[] = {
2460 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2462 /* switch to DC input */
2463 {0x17, AC_VERB_SET_CONNECT_SEL
, 3},
2467 /* configure as input source */
2468 snd_hda_sequence_write(codec
, enable_dc_mode
);
2469 cxt5066_olpc_select_mic(codec
); /* also sets configured bias */
2472 static void cxt5066_disable_dc(struct hda_codec
*codec
)
2474 /* reconfigure input source */
2475 cxt5066_set_mic_boost(codec
);
2476 /* automic also selects the right mic if we're recording */
2477 cxt5066_olpc_automic(codec
);
2480 static int cxt5066_olpc_dc_get(struct snd_kcontrol
*kcontrol
,
2481 struct snd_ctl_elem_value
*ucontrol
)
2483 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2484 struct conexant_spec
*spec
= codec
->spec
;
2485 ucontrol
->value
.integer
.value
[0] = spec
->dc_enable
;
2489 static int cxt5066_olpc_dc_put(struct snd_kcontrol
*kcontrol
,
2490 struct snd_ctl_elem_value
*ucontrol
)
2492 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2493 struct conexant_spec
*spec
= codec
->spec
;
2494 int dc_enable
= !!ucontrol
->value
.integer
.value
[0];
2496 if (dc_enable
== spec
->dc_enable
)
2499 spec
->dc_enable
= dc_enable
;
2501 cxt5066_enable_dc(codec
);
2503 cxt5066_disable_dc(codec
);
2508 static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol
*kcontrol
,
2509 struct snd_ctl_elem_info
*uinfo
)
2511 return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias
, uinfo
);
2514 static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol
*kcontrol
,
2515 struct snd_ctl_elem_value
*ucontrol
)
2517 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2518 struct conexant_spec
*spec
= codec
->spec
;
2519 ucontrol
->value
.enumerated
.item
[0] = spec
->dc_input_bias
;
2523 static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol
*kcontrol
,
2524 struct snd_ctl_elem_value
*ucontrol
)
2526 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2527 struct conexant_spec
*spec
= codec
->spec
;
2528 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2531 idx
= ucontrol
->value
.enumerated
.item
[0];
2532 if (idx
>= imux
->num_items
)
2533 idx
= imux
->num_items
- 1;
2535 spec
->dc_input_bias
= idx
;
2536 if (spec
->dc_enable
)
2537 cxt5066_set_olpc_dc_bias(codec
);
2541 static void cxt5066_olpc_capture_prepare(struct hda_codec
*codec
)
2543 struct conexant_spec
*spec
= codec
->spec
;
2544 /* mark as recording and configure the microphone widget so that the
2545 * recording LED comes on. */
2546 spec
->recording
= 1;
2547 cxt5066_olpc_select_mic(codec
);
2550 static void cxt5066_olpc_capture_cleanup(struct hda_codec
*codec
)
2552 struct conexant_spec
*spec
= codec
->spec
;
2553 const struct hda_verb disable_mics
[] = {
2554 /* disable external mic, port B */
2555 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2557 /* disble internal mic, port C */
2558 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2560 /* disable DC capture, port F */
2561 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2565 snd_hda_sequence_write(codec
, disable_mics
);
2566 spec
->recording
= 0;
2569 static void conexant_check_dig_outs(struct hda_codec
*codec
,
2570 const hda_nid_t
*dig_pins
,
2573 struct conexant_spec
*spec
= codec
->spec
;
2574 hda_nid_t
*nid_loc
= &spec
->multiout
.dig_out_nid
;
2577 for (i
= 0; i
< num_pins
; i
++, dig_pins
++) {
2578 unsigned int cfg
= snd_hda_codec_get_pincfg(codec
, *dig_pins
);
2579 if (get_defcfg_connect(cfg
) == AC_JACK_PORT_NONE
)
2581 if (snd_hda_get_connections(codec
, *dig_pins
, nid_loc
, 1) != 1)
2583 if (spec
->slave_dig_outs
[0])
2586 nid_loc
= spec
->slave_dig_outs
;
2590 static const struct hda_input_mux cxt5066_capture_source
= {
2600 static const struct hda_bind_ctls cxt5066_bind_capture_vol_others
= {
2601 .ops
= &snd_hda_bind_vol
,
2603 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2604 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2609 static const struct hda_bind_ctls cxt5066_bind_capture_sw_others
= {
2610 .ops
= &snd_hda_bind_sw
,
2612 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2613 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2618 static const struct snd_kcontrol_new cxt5066_mixer_master
[] = {
2619 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
2623 static const struct snd_kcontrol_new cxt5066_mixer_master_olpc
[] = {
2625 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2626 .name
= "Master Playback Volume",
2627 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
|
2628 SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
2629 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
,
2630 .subdevice
= HDA_SUBDEV_AMP_FLAG
,
2631 .info
= snd_hda_mixer_amp_volume_info
,
2632 .get
= snd_hda_mixer_amp_volume_get
,
2633 .put
= snd_hda_mixer_amp_volume_put
,
2634 .tlv
= { .c
= snd_hda_mixer_amp_tlv
},
2635 /* offset by 28 volume steps to limit minimum gain to -46dB */
2637 HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT
, 28),
2642 static const struct snd_kcontrol_new cxt5066_mixer_olpc_dc
[] = {
2644 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2645 .name
= "DC Mode Enable Switch",
2646 .info
= snd_ctl_boolean_mono_info
,
2647 .get
= cxt5066_olpc_dc_get
,
2648 .put
= cxt5066_olpc_dc_put
,
2651 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2652 .name
= "DC Input Bias Enum",
2653 .info
= cxt5066_olpc_dc_bias_enum_info
,
2654 .get
= cxt5066_olpc_dc_bias_enum_get
,
2655 .put
= cxt5066_olpc_dc_bias_enum_put
,
2660 static const struct snd_kcontrol_new cxt5066_mixers
[] = {
2662 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2663 .name
= "Master Playback Switch",
2664 .info
= cxt_eapd_info
,
2665 .get
= cxt_eapd_get
,
2666 .put
= cxt5066_hp_master_sw_put
,
2667 .private_value
= 0x1d,
2671 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2672 .name
= "Analog Mic Boost Capture Enum",
2673 .info
= cxt5066_mic_boost_mux_enum_info
,
2674 .get
= cxt5066_mic_boost_mux_enum_get
,
2675 .put
= cxt5066_mic_boost_mux_enum_put
,
2678 HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others
),
2679 HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others
),
2683 static const struct snd_kcontrol_new cxt5066_vostro_mixers
[] = {
2685 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2686 .name
= "Internal Mic Boost Capture Enum",
2687 .info
= cxt5066_mic_boost_mux_enum_info
,
2688 .get
= cxt5066_mic_boost_mux_enum_get
,
2689 .put
= cxt5066_mic_boost_mux_enum_put
,
2690 .private_value
= 0x23 | 0x100,
2695 static const struct hda_verb cxt5066_init_verbs
[] = {
2696 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2697 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2698 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2699 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2702 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2703 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2706 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2707 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2709 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2710 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2713 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2715 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2716 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2717 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2718 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2719 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2720 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2722 /* no digital microphone support yet */
2723 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2725 /* Audio input selector */
2726 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2728 /* SPDIF route: PCM */
2729 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2730 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2732 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2733 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2736 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2738 /* not handling these yet */
2739 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2740 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2741 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2742 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2743 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2744 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2745 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2746 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2750 static const struct hda_verb cxt5066_init_verbs_olpc
[] = {
2751 /* Port A: headphones */
2752 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2753 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2755 /* Port B: external microphone */
2756 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2758 /* Port C: internal microphone */
2759 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2761 /* Port D: unused */
2762 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2764 /* Port E: unused, but has primary EAPD */
2765 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2766 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2768 /* Port F: external DC input through microphone port */
2769 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2771 /* Port G: internal speakers */
2772 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2773 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2776 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2779 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2781 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2782 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2783 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2784 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2785 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2786 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2787 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2788 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2789 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2790 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2791 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2792 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2794 /* Disable digital microphone port */
2795 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2797 /* Audio input selectors */
2798 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2799 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2802 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2803 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2805 /* enable unsolicited events for Port A and B */
2806 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2807 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2811 static const struct hda_verb cxt5066_init_verbs_vostro
[] = {
2812 /* Port A: headphones */
2813 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2814 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2816 /* Port B: external microphone */
2817 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2819 /* Port C: unused */
2820 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2822 /* Port D: unused */
2823 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2825 /* Port E: unused, but has primary EAPD */
2826 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2827 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2829 /* Port F: unused */
2830 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2832 /* Port G: internal speakers */
2833 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2834 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2837 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2840 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2842 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2843 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2844 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2845 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2846 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2847 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2848 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2849 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2850 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2851 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2852 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2853 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2855 /* Digital microphone port */
2856 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2858 /* Audio input selectors */
2859 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2860 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2863 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2864 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2866 /* enable unsolicited events for Port A and B */
2867 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2868 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2872 static const struct hda_verb cxt5066_init_verbs_ideapad
[] = {
2873 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2874 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2875 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2876 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2879 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2880 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2883 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2884 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2886 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2887 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2890 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2892 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2893 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2894 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2895 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2896 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2897 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2898 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2900 /* Audio input selector */
2901 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2902 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2904 /* SPDIF route: PCM */
2905 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2906 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2908 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2909 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2911 /* internal microphone */
2912 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable internal mic */
2915 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2917 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2918 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2922 static const struct hda_verb cxt5066_init_verbs_thinkpad
[] = {
2923 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2924 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2926 /* Port G: internal speakers */
2927 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2928 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2930 /* Port A: HP, Amp */
2931 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2932 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2934 /* Port B: Mic Dock */
2935 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2938 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2940 /* Port D: HP Dock, Amp */
2941 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2942 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2945 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2947 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2948 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2949 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2950 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2951 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2952 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2953 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2955 /* Audio input selector */
2956 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2957 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2959 /* SPDIF route: PCM */
2960 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2961 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2963 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2964 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2966 /* internal microphone */
2967 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable internal mic */
2970 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2972 /* enable unsolicited events for Port A, B, C and D */
2973 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2974 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2975 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2976 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2980 static const struct hda_verb cxt5066_init_verbs_portd_lo
[] = {
2981 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2986 static const struct hda_verb cxt5066_init_verbs_hp_laptop
[] = {
2987 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x0},
2988 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2989 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2993 /* initialize jack-sensing, too */
2994 static int cxt5066_init(struct hda_codec
*codec
)
2996 snd_printdd("CXT5066: init\n");
2997 conexant_init(codec
);
2998 if (codec
->patch_ops
.unsol_event
) {
2999 cxt5066_hp_automute(codec
);
3000 cxt5066_automic(codec
);
3002 cxt5066_set_mic_boost(codec
);
3006 static int cxt5066_olpc_init(struct hda_codec
*codec
)
3008 struct conexant_spec
*spec
= codec
->spec
;
3009 snd_printdd("CXT5066: init\n");
3010 conexant_init(codec
);
3011 cxt5066_hp_automute(codec
);
3012 if (!spec
->dc_enable
) {
3013 cxt5066_set_mic_boost(codec
);
3014 cxt5066_olpc_automic(codec
);
3016 cxt5066_enable_dc(codec
);
3022 CXT5066_LAPTOP
, /* Laptops w/ EAPD support */
3023 CXT5066_DELL_LAPTOP
, /* Dell Laptop */
3024 CXT5066_OLPC_XO_1_5
, /* OLPC XO 1.5 */
3025 CXT5066_DELL_VOSTRO
, /* Dell Vostro 1015i */
3026 CXT5066_IDEAPAD
, /* Lenovo IdeaPad U150 */
3027 CXT5066_THINKPAD
, /* Lenovo ThinkPad T410s, others? */
3028 CXT5066_ASUS
, /* Asus K52JU, Lenovo G560 - Int mic at 0x1a and Ext mic at 0x1b */
3029 CXT5066_HP_LAPTOP
, /* HP Laptop */
3030 CXT5066_AUTO
, /* BIOS auto-parser */
3034 static const char * const cxt5066_models
[CXT5066_MODELS
] = {
3035 [CXT5066_LAPTOP
] = "laptop",
3036 [CXT5066_DELL_LAPTOP
] = "dell-laptop",
3037 [CXT5066_OLPC_XO_1_5
] = "olpc-xo-1_5",
3038 [CXT5066_DELL_VOSTRO
] = "dell-vostro",
3039 [CXT5066_IDEAPAD
] = "ideapad",
3040 [CXT5066_THINKPAD
] = "thinkpad",
3041 [CXT5066_ASUS
] = "asus",
3042 [CXT5066_HP_LAPTOP
] = "hp-laptop",
3043 [CXT5066_AUTO
] = "auto",
3046 static const struct snd_pci_quirk cxt5066_cfg_tbl
[] = {
3047 SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT5066_AUTO
),
3048 SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD
),
3049 SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO
),
3050 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD
),
3051 SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO
),
3052 SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTRO
),
3053 SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD
),
3054 SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD
),
3055 SND_PCI_QUIRK(0x1028, 0x0510, "Dell Vostro", CXT5066_IDEAPAD
),
3056 SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP
),
3057 SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS
),
3058 SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS
),
3059 SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS
),
3060 SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD
),
3061 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5
),
3062 SND_PCI_QUIRK(0x1179, 0xffe0, "Toshiba Satellite Pro T130-15F", CXT5066_OLPC_XO_1_5
),
3063 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
3065 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5
),
3066 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD
),
3067 SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD
),
3068 SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS
),
3069 SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo Thinkpad", CXT5066_THINKPAD
),
3070 SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT5066_THINKPAD
),
3071 SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT5066_THINKPAD
),
3072 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo U350", CXT5066_ASUS
),
3073 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS
),
3074 SND_PCI_QUIRK(0x17aa, 0x3938, "Lenovo G565", CXT5066_AUTO
),
3075 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", CXT5066_IDEAPAD
), /* Fallback for Lenovos without dock mic */
3076 SND_PCI_QUIRK(0x1b0a, 0x2092, "CyberpowerPC Gamer Xplorer N57001", CXT5066_AUTO
),
3080 static int patch_cxt5066(struct hda_codec
*codec
)
3082 struct conexant_spec
*spec
;
3085 board_config
= snd_hda_check_board_config(codec
, CXT5066_MODELS
,
3086 cxt5066_models
, cxt5066_cfg_tbl
);
3087 if (board_config
< 0)
3088 board_config
= CXT5066_AUTO
; /* model=auto as default */
3089 if (board_config
== CXT5066_AUTO
)
3090 return patch_conexant_auto(codec
);
3092 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3097 codec
->patch_ops
= conexant_patch_ops
;
3098 codec
->patch_ops
.init
= conexant_init
;
3100 spec
->dell_automute
= 0;
3101 spec
->multiout
.max_channels
= 2;
3102 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5066_dac_nids
);
3103 spec
->multiout
.dac_nids
= cxt5066_dac_nids
;
3104 conexant_check_dig_outs(codec
, cxt5066_digout_pin_nids
,
3105 ARRAY_SIZE(cxt5066_digout_pin_nids
));
3106 spec
->num_adc_nids
= 1;
3107 spec
->adc_nids
= cxt5066_adc_nids
;
3108 spec
->capsrc_nids
= cxt5066_capsrc_nids
;
3109 spec
->input_mux
= &cxt5066_capture_source
;
3111 spec
->port_d_mode
= PIN_HP
;
3113 spec
->num_init_verbs
= 1;
3114 spec
->init_verbs
[0] = cxt5066_init_verbs
;
3115 spec
->num_channel_mode
= ARRAY_SIZE(cxt5066_modes
);
3116 spec
->channel_mode
= cxt5066_modes
;
3118 spec
->cur_adc_idx
= 0;
3120 set_beep_amp(spec
, 0x13, 0, HDA_OUTPUT
);
3122 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_info
[spec
->cur_mux
[0]].adc
;
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 #define get_connection_index(codec, mux, nid)\
3280 snd_hda_get_conn_index(codec, mux, nid, 0)
3282 /* get an unassigned DAC from the given list.
3283 * Return the nid if found and reduce the DAC list, or return zero if
3286 static hda_nid_t
get_unassigned_dac(struct hda_codec
*codec
, hda_nid_t pin
,
3287 hda_nid_t
*dacs
, int *num_dacs
)
3289 int i
, nums
= *num_dacs
;
3292 for (i
= 0; i
< nums
; i
++) {
3293 if (get_connection_index(codec
, pin
, dacs
[i
]) >= 0) {
3301 memmove(dacs
, dacs
+ 1, nums
* sizeof(hda_nid_t
));
3306 #define MAX_AUTO_DACS 5
3308 #define DAC_SLAVE_FLAG 0x8000 /* filled dac is a slave */
3310 /* fill analog DAC list from the widget tree */
3311 static int fill_cx_auto_dacs(struct hda_codec
*codec
, hda_nid_t
*dacs
)
3313 hda_nid_t nid
, end_nid
;
3316 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3317 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
3318 unsigned int wcaps
= get_wcaps(codec
, nid
);
3319 unsigned int type
= get_wcaps_type(wcaps
);
3320 if (type
== AC_WID_AUD_OUT
&& !(wcaps
& AC_WCAP_DIGITAL
)) {
3322 if (nums
>= MAX_AUTO_DACS
)
3329 /* fill pin_dac_pair list from the pin and dac list */
3330 static int fill_dacs_for_pins(struct hda_codec
*codec
, hda_nid_t
*pins
,
3331 int num_pins
, hda_nid_t
*dacs
, int *rest
,
3332 struct pin_dac_pair
*filled
, int nums
,
3335 int i
, start
= nums
;
3337 for (i
= 0; i
< num_pins
; i
++, nums
++) {
3338 filled
[nums
].pin
= pins
[i
];
3339 filled
[nums
].type
= type
;
3340 filled
[nums
].dac
= get_unassigned_dac(codec
, pins
[i
], dacs
, rest
);
3341 if (filled
[nums
].dac
)
3343 if (filled
[start
].dac
&& get_connection_index(codec
, pins
[i
], filled
[start
].dac
) >= 0) {
3344 filled
[nums
].dac
= filled
[start
].dac
| DAC_SLAVE_FLAG
;
3347 if (filled
[0].dac
&& get_connection_index(codec
, pins
[i
], filled
[0].dac
) >= 0) {
3348 filled
[nums
].dac
= filled
[0].dac
| DAC_SLAVE_FLAG
;
3351 snd_printdd("Failed to find a DAC for pin 0x%x", pins
[i
]);
3356 /* parse analog output paths */
3357 static void cx_auto_parse_output(struct hda_codec
*codec
)
3359 struct conexant_spec
*spec
= codec
->spec
;
3360 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3361 hda_nid_t dacs
[MAX_AUTO_DACS
];
3362 int i
, j
, nums
, rest
;
3364 rest
= fill_cx_auto_dacs(codec
, dacs
);
3365 /* parse all analog output pins */
3366 nums
= fill_dacs_for_pins(codec
, cfg
->line_out_pins
, cfg
->line_outs
,
3367 dacs
, &rest
, spec
->dac_info
, 0,
3369 nums
= fill_dacs_for_pins(codec
, cfg
->hp_pins
, cfg
->hp_outs
,
3370 dacs
, &rest
, spec
->dac_info
, nums
,
3372 nums
= fill_dacs_for_pins(codec
, cfg
->speaker_pins
, cfg
->speaker_outs
,
3373 dacs
, &rest
, spec
->dac_info
, nums
,
3374 AUTO_PIN_SPEAKER_OUT
);
3375 spec
->dac_info_filled
= nums
;
3376 /* fill multiout struct */
3377 for (i
= 0; i
< nums
; i
++) {
3378 hda_nid_t dac
= spec
->dac_info
[i
].dac
;
3379 if (!dac
|| (dac
& DAC_SLAVE_FLAG
))
3381 switch (spec
->dac_info
[i
].type
) {
3382 case AUTO_PIN_LINE_OUT
:
3383 spec
->private_dac_nids
[spec
->multiout
.num_dacs
] = dac
;
3384 spec
->multiout
.num_dacs
++;
3386 case AUTO_PIN_HP_OUT
:
3387 case AUTO_PIN_SPEAKER_OUT
:
3388 if (!spec
->multiout
.hp_nid
) {
3389 spec
->multiout
.hp_nid
= dac
;
3392 for (j
= 0; j
< ARRAY_SIZE(spec
->multiout
.extra_out_nid
); j
++)
3393 if (!spec
->multiout
.extra_out_nid
[j
]) {
3394 spec
->multiout
.extra_out_nid
[j
] = dac
;
3400 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3401 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
3403 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3404 if (is_jack_detectable(codec
, cfg
->hp_pins
[i
])) {
3405 spec
->auto_mute
= 1;
3409 if (spec
->auto_mute
&&
3410 cfg
->line_out_pins
[0] &&
3411 cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
&&
3412 cfg
->line_out_pins
[0] != cfg
->hp_pins
[0] &&
3413 cfg
->line_out_pins
[0] != cfg
->speaker_pins
[0]) {
3414 for (i
= 0; i
< cfg
->line_outs
; i
++) {
3415 if (is_jack_detectable(codec
, cfg
->line_out_pins
[i
])) {
3416 spec
->detect_line
= 1;
3420 spec
->automute_lines
= spec
->detect_line
;
3423 spec
->vmaster_nid
= spec
->private_dac_nids
[0];
3426 static void cx_auto_turn_eapd(struct hda_codec
*codec
, int num_pins
,
3427 hda_nid_t
*pins
, bool on
);
3429 static void do_automute(struct hda_codec
*codec
, int num_pins
,
3430 hda_nid_t
*pins
, bool on
)
3433 for (i
= 0; i
< num_pins
; i
++)
3434 snd_hda_codec_write(codec
, pins
[i
], 0,
3435 AC_VERB_SET_PIN_WIDGET_CONTROL
,
3437 cx_auto_turn_eapd(codec
, num_pins
, pins
, on
);
3440 static int detect_jacks(struct hda_codec
*codec
, int num_pins
, hda_nid_t
*pins
)
3444 for (i
= 0; i
< num_pins
; i
++) {
3445 hda_nid_t nid
= pins
[i
];
3446 if (!nid
|| !is_jack_detectable(codec
, nid
))
3448 snd_hda_input_jack_report(codec
, nid
);
3449 present
|= snd_hda_jack_detect(codec
, nid
);
3454 /* auto-mute/unmute speaker and line outs according to headphone jack */
3455 static void cx_auto_update_speakers(struct hda_codec
*codec
)
3457 struct conexant_spec
*spec
= codec
->spec
;
3458 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3461 /* turn on HP EAPD when HP jacks are present */
3462 if (spec
->auto_mute
)
3463 on
= spec
->hp_present
;
3464 cx_auto_turn_eapd(codec
, cfg
->hp_outs
, cfg
->hp_pins
, on
);
3465 /* mute speakers in auto-mode if HP or LO jacks are plugged */
3466 if (spec
->auto_mute
)
3467 on
= !(spec
->hp_present
||
3468 (spec
->detect_line
&& spec
->line_present
));
3469 do_automute(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
, on
);
3471 /* toggle line-out mutes if needed, too */
3472 /* if LO is a copy of either HP or Speaker, don't need to handle it */
3473 if (cfg
->line_out_pins
[0] == cfg
->hp_pins
[0] ||
3474 cfg
->line_out_pins
[0] == cfg
->speaker_pins
[0])
3476 if (spec
->auto_mute
) {
3477 /* mute LO in auto-mode when HP jack is present */
3478 if (cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
||
3479 spec
->automute_lines
)
3480 on
= !spec
->hp_present
;
3484 do_automute(codec
, cfg
->line_outs
, cfg
->line_out_pins
, on
);
3487 static void cx_auto_hp_automute(struct hda_codec
*codec
)
3489 struct conexant_spec
*spec
= codec
->spec
;
3490 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3492 if (!spec
->auto_mute
)
3494 spec
->hp_present
= detect_jacks(codec
, cfg
->hp_outs
, cfg
->hp_pins
);
3495 cx_auto_update_speakers(codec
);
3498 static void cx_auto_line_automute(struct hda_codec
*codec
)
3500 struct conexant_spec
*spec
= codec
->spec
;
3501 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3503 if (!spec
->auto_mute
|| !spec
->detect_line
)
3505 spec
->line_present
= detect_jacks(codec
, cfg
->line_outs
,
3506 cfg
->line_out_pins
);
3507 cx_auto_update_speakers(codec
);
3510 static int cx_automute_mode_info(struct snd_kcontrol
*kcontrol
,
3511 struct snd_ctl_elem_info
*uinfo
)
3513 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3514 struct conexant_spec
*spec
= codec
->spec
;
3515 static const char * const texts2
[] = {
3516 "Disabled", "Enabled"
3518 static const char * const texts3
[] = {
3519 "Disabled", "Speaker Only", "Line-Out+Speaker"
3521 const char * const *texts
;
3523 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
3525 if (spec
->automute_hp_lo
) {
3526 uinfo
->value
.enumerated
.items
= 3;
3529 uinfo
->value
.enumerated
.items
= 2;
3532 if (uinfo
->value
.enumerated
.item
>= uinfo
->value
.enumerated
.items
)
3533 uinfo
->value
.enumerated
.item
= uinfo
->value
.enumerated
.items
- 1;
3534 strcpy(uinfo
->value
.enumerated
.name
,
3535 texts
[uinfo
->value
.enumerated
.item
]);
3539 static int cx_automute_mode_get(struct snd_kcontrol
*kcontrol
,
3540 struct snd_ctl_elem_value
*ucontrol
)
3542 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3543 struct conexant_spec
*spec
= codec
->spec
;
3545 if (!spec
->auto_mute
)
3547 else if (!spec
->automute_lines
)
3551 ucontrol
->value
.enumerated
.item
[0] = val
;
3555 static int cx_automute_mode_put(struct snd_kcontrol
*kcontrol
,
3556 struct snd_ctl_elem_value
*ucontrol
)
3558 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3559 struct conexant_spec
*spec
= codec
->spec
;
3561 switch (ucontrol
->value
.enumerated
.item
[0]) {
3563 if (!spec
->auto_mute
)
3565 spec
->auto_mute
= 0;
3568 if (spec
->auto_mute
&& !spec
->automute_lines
)
3570 spec
->auto_mute
= 1;
3571 spec
->automute_lines
= 0;
3574 if (!spec
->automute_hp_lo
)
3576 if (spec
->auto_mute
&& spec
->automute_lines
)
3578 spec
->auto_mute
= 1;
3579 spec
->automute_lines
= 1;
3584 cx_auto_update_speakers(codec
);
3588 static const struct snd_kcontrol_new cx_automute_mode_enum
[] = {
3590 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3591 .name
= "Auto-Mute Mode",
3592 .info
= cx_automute_mode_info
,
3593 .get
= cx_automute_mode_get
,
3594 .put
= cx_automute_mode_put
,
3599 static int cx_auto_mux_enum_info(struct snd_kcontrol
*kcontrol
,
3600 struct snd_ctl_elem_info
*uinfo
)
3602 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3603 struct conexant_spec
*spec
= codec
->spec
;
3605 return snd_hda_input_mux_info(&spec
->private_imux
, uinfo
);
3608 static int cx_auto_mux_enum_get(struct snd_kcontrol
*kcontrol
,
3609 struct snd_ctl_elem_value
*ucontrol
)
3611 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3612 struct conexant_spec
*spec
= codec
->spec
;
3614 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[0];
3618 /* look for the route the given pin from mux and return the index;
3619 * if do_select is set, actually select the route.
3621 static int __select_input_connection(struct hda_codec
*codec
, hda_nid_t mux
,
3622 hda_nid_t pin
, hda_nid_t
*srcp
,
3623 bool do_select
, int depth
)
3625 hda_nid_t conn
[HDA_MAX_NUM_INPUTS
];
3628 switch (get_wcaps_type(get_wcaps(codec
, mux
))) {
3630 case AC_WID_AUD_SEL
:
3631 case AC_WID_AUD_MIX
:
3637 nums
= snd_hda_get_connections(codec
, mux
, conn
, ARRAY_SIZE(conn
));
3638 for (i
= 0; i
< nums
; i
++)
3639 if (conn
[i
] == pin
) {
3641 snd_hda_codec_write(codec
, mux
, 0,
3642 AC_VERB_SET_CONNECT_SEL
, i
);
3650 for (i
= 0; i
< nums
; i
++) {
3651 int ret
= __select_input_connection(codec
, conn
[i
], pin
, srcp
,
3655 snd_hda_codec_write(codec
, mux
, 0,
3656 AC_VERB_SET_CONNECT_SEL
, i
);
3663 static void select_input_connection(struct hda_codec
*codec
, hda_nid_t mux
,
3666 __select_input_connection(codec
, mux
, pin
, NULL
, true, 0);
3669 static int get_input_connection(struct hda_codec
*codec
, hda_nid_t mux
,
3672 return __select_input_connection(codec
, mux
, pin
, NULL
, false, 0);
3675 static int cx_auto_mux_enum_update(struct hda_codec
*codec
,
3676 const struct hda_input_mux
*imux
,
3679 struct conexant_spec
*spec
= codec
->spec
;
3683 if (!imux
->num_items
)
3685 if (idx
>= imux
->num_items
)
3686 idx
= imux
->num_items
- 1;
3687 if (spec
->cur_mux
[0] == idx
)
3689 adc
= spec
->imux_info
[idx
].adc
;
3690 select_input_connection(codec
, spec
->imux_info
[idx
].adc
,
3691 spec
->imux_info
[idx
].pin
);
3692 if (spec
->cur_adc
&& spec
->cur_adc
!= adc
) {
3693 /* stream is running, let's swap the current ADC */
3694 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
3695 spec
->cur_adc
= adc
;
3696 snd_hda_codec_setup_stream(codec
, adc
,
3697 spec
->cur_adc_stream_tag
, 0,
3698 spec
->cur_adc_format
);
3700 spec
->cur_mux
[0] = idx
;
3704 static int cx_auto_mux_enum_put(struct snd_kcontrol
*kcontrol
,
3705 struct snd_ctl_elem_value
*ucontrol
)
3707 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3708 struct conexant_spec
*spec
= codec
->spec
;
3710 return cx_auto_mux_enum_update(codec
, &spec
->private_imux
,
3711 ucontrol
->value
.enumerated
.item
[0]);
3714 static const struct snd_kcontrol_new cx_auto_capture_mixers
[] = {
3716 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3717 .name
= "Capture Source",
3718 .info
= cx_auto_mux_enum_info
,
3719 .get
= cx_auto_mux_enum_get
,
3720 .put
= cx_auto_mux_enum_put
3725 static bool select_automic(struct hda_codec
*codec
, int idx
, bool detect
)
3727 struct conexant_spec
*spec
= codec
->spec
;
3730 if (detect
&& !snd_hda_jack_detect(codec
, spec
->imux_info
[idx
].pin
))
3732 cx_auto_mux_enum_update(codec
, &spec
->private_imux
, idx
);
3736 /* automatic switch internal and external mic */
3737 static void cx_auto_automic(struct hda_codec
*codec
)
3739 struct conexant_spec
*spec
= codec
->spec
;
3741 if (!spec
->auto_mic
)
3743 if (!select_automic(codec
, spec
->auto_mic_ext
, true))
3744 if (!select_automic(codec
, spec
->auto_mic_dock
, true))
3745 select_automic(codec
, spec
->auto_mic_int
, false);
3748 static void cx_auto_unsol_event(struct hda_codec
*codec
, unsigned int res
)
3750 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
3751 switch (res
>> 26) {
3752 case CONEXANT_HP_EVENT
:
3753 cx_auto_hp_automute(codec
);
3755 case CONEXANT_LINE_EVENT
:
3756 cx_auto_line_automute(codec
);
3758 case CONEXANT_MIC_EVENT
:
3759 cx_auto_automic(codec
);
3760 snd_hda_input_jack_report(codec
, nid
);
3765 /* check whether the pin config is suitable for auto-mic switching;
3766 * auto-mic is enabled only when one int-mic and one ext- and/or
3767 * one dock-mic exist
3769 static void cx_auto_check_auto_mic(struct hda_codec
*codec
)
3771 struct conexant_spec
*spec
= codec
->spec
;
3772 int pset
[INPUT_PIN_ATTR_NORMAL
+ 1];
3775 for (i
= 0; i
< ARRAY_SIZE(pset
); i
++)
3777 for (i
= 0; i
< spec
->private_imux
.num_items
; i
++) {
3778 hda_nid_t pin
= spec
->imux_info
[i
].pin
;
3779 unsigned int def_conf
= snd_hda_codec_get_pincfg(codec
, pin
);
3781 attr
= snd_hda_get_input_pin_attr(def_conf
);
3782 if (attr
== INPUT_PIN_ATTR_UNUSED
)
3783 return; /* invalid entry */
3784 if (attr
> INPUT_PIN_ATTR_NORMAL
)
3785 attr
= INPUT_PIN_ATTR_NORMAL
;
3786 if (attr
!= INPUT_PIN_ATTR_INT
&&
3787 !is_jack_detectable(codec
, pin
))
3788 return; /* non-detectable pin */
3789 type
= get_defcfg_device(def_conf
);
3790 if (type
!= AC_JACK_MIC_IN
&&
3791 (attr
!= INPUT_PIN_ATTR_DOCK
|| type
!= AC_JACK_LINE_IN
))
3792 return; /* no valid input type */
3793 if (pset
[attr
] >= 0)
3794 return; /* already occupied */
3797 if (pset
[INPUT_PIN_ATTR_INT
] < 0 ||
3798 (pset
[INPUT_PIN_ATTR_NORMAL
] < 0 && pset
[INPUT_PIN_ATTR_DOCK
]))
3799 return; /* no input to switch*/
3801 spec
->auto_mic_ext
= pset
[INPUT_PIN_ATTR_NORMAL
];
3802 spec
->auto_mic_dock
= pset
[INPUT_PIN_ATTR_DOCK
];
3803 spec
->auto_mic_int
= pset
[INPUT_PIN_ATTR_INT
];
3806 static void cx_auto_parse_input(struct hda_codec
*codec
)
3808 struct conexant_spec
*spec
= codec
->spec
;
3809 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3810 struct hda_input_mux
*imux
;
3813 imux
= &spec
->private_imux
;
3814 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3815 for (j
= 0; j
< spec
->num_adc_nids
; j
++) {
3816 hda_nid_t adc
= spec
->adc_nids
[j
];
3817 int idx
= get_input_connection(codec
, adc
,
3818 cfg
->inputs
[i
].pin
);
3821 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
3822 spec
->imux_info
[imux
->num_items
].index
= i
;
3823 spec
->imux_info
[imux
->num_items
].boost
= 0;
3824 spec
->imux_info
[imux
->num_items
].adc
= adc
;
3825 spec
->imux_info
[imux
->num_items
].pin
=
3827 snd_hda_add_imux_item(imux
, label
, idx
, NULL
);
3832 if (imux
->num_items
>= 2 && cfg
->num_inputs
== imux
->num_items
)
3833 cx_auto_check_auto_mic(codec
);
3834 if (imux
->num_items
> 1) {
3835 for (i
= 1; i
< imux
->num_items
; i
++) {
3836 if (spec
->imux_info
[i
].adc
!= spec
->imux_info
[0].adc
) {
3837 spec
->adc_switching
= 1;
3844 /* get digital-input audio widget corresponding to the given pin */
3845 static hda_nid_t
cx_auto_get_dig_in(struct hda_codec
*codec
, hda_nid_t pin
)
3847 hda_nid_t nid
, end_nid
;
3849 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3850 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
3851 unsigned int wcaps
= get_wcaps(codec
, nid
);
3852 unsigned int type
= get_wcaps_type(wcaps
);
3853 if (type
== AC_WID_AUD_IN
&& (wcaps
& AC_WCAP_DIGITAL
)) {
3854 if (get_connection_index(codec
, nid
, pin
) >= 0)
3861 static void cx_auto_parse_digital(struct hda_codec
*codec
)
3863 struct conexant_spec
*spec
= codec
->spec
;
3864 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3867 if (cfg
->dig_outs
&&
3868 snd_hda_get_connections(codec
, cfg
->dig_out_pins
[0], &nid
, 1) == 1)
3869 spec
->multiout
.dig_out_nid
= nid
;
3870 if (cfg
->dig_in_pin
)
3871 spec
->dig_in_nid
= cx_auto_get_dig_in(codec
, cfg
->dig_in_pin
);
3874 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3875 static void cx_auto_parse_beep(struct hda_codec
*codec
)
3877 struct conexant_spec
*spec
= codec
->spec
;
3878 hda_nid_t nid
, end_nid
;
3880 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3881 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++)
3882 if (get_wcaps_type(get_wcaps(codec
, nid
)) == AC_WID_BEEP
) {
3883 set_beep_amp(spec
, nid
, 0, HDA_OUTPUT
);
3888 #define cx_auto_parse_beep(codec)
3891 static bool found_in_nid_list(hda_nid_t nid
, const hda_nid_t
*list
, int nums
)
3894 for (i
= 0; i
< nums
; i
++)
3900 /* parse extra-EAPD that aren't assigned to any pins */
3901 static void cx_auto_parse_eapd(struct hda_codec
*codec
)
3903 struct conexant_spec
*spec
= codec
->spec
;
3904 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3905 hda_nid_t nid
, end_nid
;
3907 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3908 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
3909 if (get_wcaps_type(get_wcaps(codec
, nid
)) != AC_WID_PIN
)
3911 if (!(snd_hda_query_pin_caps(codec
, nid
) & AC_PINCAP_EAPD
))
3913 if (found_in_nid_list(nid
, cfg
->line_out_pins
, cfg
->line_outs
) ||
3914 found_in_nid_list(nid
, cfg
->hp_pins
, cfg
->hp_outs
) ||
3915 found_in_nid_list(nid
, cfg
->speaker_pins
, cfg
->speaker_outs
))
3917 spec
->eapds
[spec
->num_eapds
++] = nid
;
3918 if (spec
->num_eapds
>= ARRAY_SIZE(spec
->eapds
))
3923 static int cx_auto_parse_auto_config(struct hda_codec
*codec
)
3925 struct conexant_spec
*spec
= codec
->spec
;
3928 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
3932 cx_auto_parse_output(codec
);
3933 cx_auto_parse_input(codec
);
3934 cx_auto_parse_digital(codec
);
3935 cx_auto_parse_beep(codec
);
3936 cx_auto_parse_eapd(codec
);
3940 static void cx_auto_turn_eapd(struct hda_codec
*codec
, int num_pins
,
3941 hda_nid_t
*pins
, bool on
)
3944 for (i
= 0; i
< num_pins
; i
++) {
3945 if (snd_hda_query_pin_caps(codec
, pins
[i
]) & AC_PINCAP_EAPD
)
3946 snd_hda_codec_write(codec
, pins
[i
], 0,
3947 AC_VERB_SET_EAPD_BTLENABLE
,
3952 static void select_connection(struct hda_codec
*codec
, hda_nid_t pin
,
3955 int idx
= get_connection_index(codec
, pin
, src
);
3957 snd_hda_codec_write(codec
, pin
, 0,
3958 AC_VERB_SET_CONNECT_SEL
, idx
);
3961 static void mute_outputs(struct hda_codec
*codec
, int num_nids
,
3962 const hda_nid_t
*nids
)
3966 for (i
= 0; i
< num_nids
; i
++) {
3967 hda_nid_t nid
= nids
[i
];
3968 if (!(get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
))
3970 if (query_amp_caps(codec
, nid
, HDA_OUTPUT
) & AC_AMPCAP_MUTE
)
3974 snd_hda_codec_write(codec
, nid
, 0,
3975 AC_VERB_SET_AMP_GAIN_MUTE
, val
);
3979 static void enable_unsol_pins(struct hda_codec
*codec
, int num_pins
,
3980 hda_nid_t
*pins
, unsigned int tag
)
3983 for (i
= 0; i
< num_pins
; i
++)
3984 snd_hda_codec_write(codec
, pins
[i
], 0,
3985 AC_VERB_SET_UNSOLICITED_ENABLE
,
3989 static void cx_auto_init_output(struct hda_codec
*codec
)
3991 struct conexant_spec
*spec
= codec
->spec
;
3992 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3996 mute_outputs(codec
, spec
->multiout
.num_dacs
, spec
->multiout
.dac_nids
);
3997 for (i
= 0; i
< cfg
->hp_outs
; i
++)
3998 snd_hda_codec_write(codec
, cfg
->hp_pins
[i
], 0,
3999 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
);
4000 mute_outputs(codec
, cfg
->hp_outs
, cfg
->hp_pins
);
4001 mute_outputs(codec
, cfg
->line_outs
, cfg
->line_out_pins
);
4002 mute_outputs(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
);
4003 for (i
= 0; i
< spec
->dac_info_filled
; i
++) {
4004 nid
= spec
->dac_info
[i
].dac
;
4006 nid
= spec
->multiout
.dac_nids
[0];
4007 else if (nid
& DAC_SLAVE_FLAG
)
4008 nid
&= ~DAC_SLAVE_FLAG
;
4009 select_connection(codec
, spec
->dac_info
[i
].pin
, nid
);
4011 if (spec
->auto_mute
) {
4012 enable_unsol_pins(codec
, cfg
->hp_outs
, cfg
->hp_pins
,
4014 spec
->hp_present
= detect_jacks(codec
, cfg
->hp_outs
,
4016 if (spec
->detect_line
) {
4017 enable_unsol_pins(codec
, cfg
->line_outs
,
4019 CONEXANT_LINE_EVENT
);
4020 spec
->line_present
=
4021 detect_jacks(codec
, cfg
->line_outs
,
4022 cfg
->line_out_pins
);
4025 cx_auto_update_speakers(codec
);
4026 /* turn on/off extra EAPDs, too */
4027 cx_auto_turn_eapd(codec
, spec
->num_eapds
, spec
->eapds
, true);
4030 static void cx_auto_init_input(struct hda_codec
*codec
)
4032 struct conexant_spec
*spec
= codec
->spec
;
4033 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4036 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
4037 hda_nid_t nid
= spec
->adc_nids
[i
];
4038 if (!(get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
))
4040 if (query_amp_caps(codec
, nid
, HDA_INPUT
) & AC_AMPCAP_MUTE
)
4041 val
= AMP_IN_MUTE(0);
4043 val
= AMP_IN_UNMUTE(0);
4044 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
4048 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
4050 if (cfg
->inputs
[i
].type
== AUTO_PIN_MIC
)
4054 snd_hda_codec_write(codec
, cfg
->inputs
[i
].pin
, 0,
4055 AC_VERB_SET_PIN_WIDGET_CONTROL
, type
);
4058 if (spec
->auto_mic
) {
4059 if (spec
->auto_mic_ext
>= 0) {
4060 snd_hda_codec_write(codec
,
4061 cfg
->inputs
[spec
->auto_mic_ext
].pin
, 0,
4062 AC_VERB_SET_UNSOLICITED_ENABLE
,
4063 AC_USRSP_EN
| CONEXANT_MIC_EVENT
);
4065 if (spec
->auto_mic_dock
>= 0) {
4066 snd_hda_codec_write(codec
,
4067 cfg
->inputs
[spec
->auto_mic_dock
].pin
, 0,
4068 AC_VERB_SET_UNSOLICITED_ENABLE
,
4069 AC_USRSP_EN
| CONEXANT_MIC_EVENT
);
4071 cx_auto_automic(codec
);
4073 select_input_connection(codec
, spec
->imux_info
[0].adc
,
4074 spec
->imux_info
[0].pin
);
4078 static void cx_auto_init_digital(struct hda_codec
*codec
)
4080 struct conexant_spec
*spec
= codec
->spec
;
4081 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4083 if (spec
->multiout
.dig_out_nid
)
4084 snd_hda_codec_write(codec
, cfg
->dig_out_pins
[0], 0,
4085 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
4086 if (spec
->dig_in_nid
)
4087 snd_hda_codec_write(codec
, cfg
->dig_in_pin
, 0,
4088 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
);
4091 static int cx_auto_init(struct hda_codec
*codec
)
4093 /*snd_hda_sequence_write(codec, cx_auto_init_verbs);*/
4094 cx_auto_init_output(codec
);
4095 cx_auto_init_input(codec
);
4096 cx_auto_init_digital(codec
);
4100 static int cx_auto_add_volume_idx(struct hda_codec
*codec
, const char *basename
,
4101 const char *dir
, int cidx
,
4102 hda_nid_t nid
, int hda_dir
, int amp_idx
)
4104 static char name
[32];
4105 static struct snd_kcontrol_new knew
[] = {
4106 HDA_CODEC_VOLUME(name
, 0, 0, 0),
4107 HDA_CODEC_MUTE(name
, 0, 0, 0),
4109 static const char * const sfx
[2] = { "Volume", "Switch" };
4112 for (i
= 0; i
< 2; i
++) {
4113 struct snd_kcontrol
*kctl
;
4114 knew
[i
].private_value
= HDA_COMPOSE_AMP_VAL(nid
, 3, amp_idx
,
4116 knew
[i
].subdevice
= HDA_SUBDEV_AMP_FLAG
;
4117 knew
[i
].index
= cidx
;
4118 snprintf(name
, sizeof(name
), "%s%s %s", basename
, dir
, sfx
[i
]);
4119 kctl
= snd_ctl_new1(&knew
[i
], codec
);
4122 err
= snd_hda_ctl_add(codec
, nid
, kctl
);
4125 if (!(query_amp_caps(codec
, nid
, hda_dir
) & AC_AMPCAP_MUTE
))
4131 #define cx_auto_add_volume(codec, str, dir, cidx, nid, hda_dir) \
4132 cx_auto_add_volume_idx(codec, str, dir, cidx, nid, hda_dir, 0)
4134 #define cx_auto_add_pb_volume(codec, nid, str, idx) \
4135 cx_auto_add_volume(codec, str, " Playback", idx, nid, HDA_OUTPUT)
4137 static int try_add_pb_volume(struct hda_codec
*codec
, hda_nid_t dac
,
4138 hda_nid_t pin
, const char *name
, int idx
)
4141 if (dac
&& !(dac
& DAC_SLAVE_FLAG
)) {
4142 caps
= query_amp_caps(codec
, dac
, HDA_OUTPUT
);
4143 if (caps
& AC_AMPCAP_NUM_STEPS
)
4144 return cx_auto_add_pb_volume(codec
, dac
, name
, idx
);
4146 caps
= query_amp_caps(codec
, pin
, HDA_OUTPUT
);
4147 if (caps
& AC_AMPCAP_NUM_STEPS
)
4148 return cx_auto_add_pb_volume(codec
, pin
, name
, idx
);
4152 static int cx_auto_build_output_controls(struct hda_codec
*codec
)
4154 struct conexant_spec
*spec
= codec
->spec
;
4156 int num_line
= 0, num_hp
= 0, num_spk
= 0;
4157 static const char * const texts
[3] = { "Front", "Surround", "CLFE" };
4159 if (spec
->dac_info_filled
== 1)
4160 return try_add_pb_volume(codec
, spec
->dac_info
[0].dac
,
4161 spec
->dac_info
[0].pin
,
4164 for (i
= 0; i
< spec
->dac_info_filled
; i
++) {
4167 hda_nid_t dac
= spec
->dac_info
[i
].dac
;
4168 type
= spec
->dac_info
[i
].type
;
4169 if (type
== AUTO_PIN_LINE_OUT
)
4170 type
= spec
->autocfg
.line_out_type
;
4172 case AUTO_PIN_LINE_OUT
:
4174 label
= texts
[num_line
++];
4177 case AUTO_PIN_HP_OUT
:
4178 label
= "Headphone";
4181 case AUTO_PIN_SPEAKER_OUT
:
4186 err
= try_add_pb_volume(codec
, dac
,
4187 spec
->dac_info
[i
].pin
,
4193 if (spec
->auto_mute
) {
4194 err
= snd_hda_add_new_ctls(codec
, cx_automute_mode_enum
);
4202 static int cx_auto_add_capture_volume(struct hda_codec
*codec
, hda_nid_t nid
,
4203 const char *label
, const char *pfx
,
4206 struct conexant_spec
*spec
= codec
->spec
;
4209 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
4210 hda_nid_t adc_nid
= spec
->adc_nids
[i
];
4211 int idx
= get_input_connection(codec
, adc_nid
, nid
);
4214 return cx_auto_add_volume_idx(codec
, label
, pfx
,
4215 cidx
, adc_nid
, HDA_INPUT
, idx
);
4220 static int cx_auto_add_boost_volume(struct hda_codec
*codec
, int idx
,
4221 const char *label
, int cidx
)
4223 struct conexant_spec
*spec
= codec
->spec
;
4227 nid
= spec
->imux_info
[idx
].pin
;
4228 if (get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
)
4229 return cx_auto_add_volume(codec
, label
, " Boost", cidx
,
4231 con
= __select_input_connection(codec
, spec
->imux_info
[idx
].adc
, nid
,
4235 for (i
= 0; i
< idx
; i
++) {
4236 if (spec
->imux_info
[i
].boost
== mux
)
4237 return 0; /* already present */
4240 if (get_wcaps(codec
, mux
) & AC_WCAP_OUT_AMP
) {
4241 spec
->imux_info
[idx
].boost
= mux
;
4242 return cx_auto_add_volume(codec
, label
, " Boost", 0,
4248 static int cx_auto_build_input_controls(struct hda_codec
*codec
)
4250 struct conexant_spec
*spec
= codec
->spec
;
4251 struct hda_input_mux
*imux
= &spec
->private_imux
;
4252 const char *prev_label
;
4253 int input_conn
[HDA_MAX_NUM_INPUTS
];
4255 int multi_connection
;
4257 multi_connection
= 0;
4258 for (i
= 0; i
< imux
->num_items
; i
++) {
4259 cidx
= get_input_connection(codec
, spec
->imux_info
[i
].adc
,
4260 spec
->imux_info
[i
].pin
);
4261 input_conn
[i
] = (spec
->imux_info
[i
].adc
<< 8) | cidx
;
4262 if (i
> 0 && input_conn
[i
] != input_conn
[0])
4263 multi_connection
= 1;
4268 for (i
= 0; i
< imux
->num_items
; i
++) {
4269 hda_nid_t nid
= spec
->imux_info
[i
].pin
;
4272 label
= hda_get_autocfg_input_label(codec
, &spec
->autocfg
,
4273 spec
->imux_info
[i
].index
);
4274 if (label
== prev_label
)
4280 err
= cx_auto_add_boost_volume(codec
, i
, label
, cidx
);
4284 if (!multi_connection
) {
4287 err
= cx_auto_add_capture_volume(codec
, nid
,
4288 "Capture", "", cidx
);
4290 err
= cx_auto_add_capture_volume(codec
, nid
,
4291 label
, " Capture", cidx
);
4297 if (spec
->private_imux
.num_items
> 1 && !spec
->auto_mic
) {
4298 err
= snd_hda_add_new_ctls(codec
, cx_auto_capture_mixers
);
4306 static int cx_auto_build_controls(struct hda_codec
*codec
)
4310 err
= cx_auto_build_output_controls(codec
);
4313 err
= cx_auto_build_input_controls(codec
);
4316 return conexant_build_controls(codec
);
4319 static int cx_auto_search_adcs(struct hda_codec
*codec
)
4321 struct conexant_spec
*spec
= codec
->spec
;
4322 hda_nid_t nid
, end_nid
;
4324 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
4325 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
4326 unsigned int caps
= get_wcaps(codec
, nid
);
4327 if (get_wcaps_type(caps
) != AC_WID_AUD_IN
)
4329 if (caps
& AC_WCAP_DIGITAL
)
4331 if (snd_BUG_ON(spec
->num_adc_nids
>=
4332 ARRAY_SIZE(spec
->private_adc_nids
)))
4334 spec
->private_adc_nids
[spec
->num_adc_nids
++] = nid
;
4336 spec
->adc_nids
= spec
->private_adc_nids
;
4341 static const struct hda_codec_ops cx_auto_patch_ops
= {
4342 .build_controls
= cx_auto_build_controls
,
4343 .build_pcms
= conexant_build_pcms
,
4344 .init
= cx_auto_init
,
4345 .free
= conexant_free
,
4346 .unsol_event
= cx_auto_unsol_event
,
4347 #ifdef CONFIG_SND_HDA_POWER_SAVE
4348 .suspend
= conexant_suspend
,
4350 .reboot_notify
= snd_hda_shutup_pins
,
4361 static void apply_pincfg(struct hda_codec
*codec
, const struct cxt_pincfg
*cfg
)
4363 for (; cfg
->nid
; cfg
++)
4364 snd_hda_codec_set_pincfg(codec
, cfg
->nid
, cfg
->val
);
4368 static void apply_pin_fixup(struct hda_codec
*codec
,
4369 const struct snd_pci_quirk
*quirk
,
4370 const struct cxt_pincfg
**table
)
4372 quirk
= snd_pci_quirk_lookup(codec
->bus
->pci
, quirk
);
4374 snd_printdd(KERN_INFO
"hda_codec: applying pincfg for %s\n",
4376 apply_pincfg(codec
, table
[quirk
->value
]);
4381 CXT_PINCFG_LENOVO_X200
,
4384 static const struct cxt_pincfg cxt_pincfg_lenovo_x200
[] = {
4385 { 0x16, 0x042140ff }, /* HP (seq# overridden) */
4386 { 0x17, 0x21a11000 }, /* dock-mic */
4387 { 0x19, 0x2121103f }, /* dock-HP */
4391 static const struct cxt_pincfg
*cxt_pincfg_tbl
[] = {
4392 [CXT_PINCFG_LENOVO_X200
] = cxt_pincfg_lenovo_x200
,
4395 static const struct snd_pci_quirk cxt_fixups
[] = {
4396 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200
),
4400 static int patch_conexant_auto(struct hda_codec
*codec
)
4402 struct conexant_spec
*spec
;
4405 printk(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
4408 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4412 codec
->pin_amp_workaround
= 1;
4414 apply_pin_fixup(codec
, cxt_fixups
, cxt_pincfg_tbl
);
4416 err
= cx_auto_search_adcs(codec
);
4419 err
= cx_auto_parse_auto_config(codec
);
4425 spec
->capture_stream
= &cx_auto_pcm_analog_capture
;
4426 codec
->patch_ops
= cx_auto_patch_ops
;
4428 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
4435 static const struct hda_codec_preset snd_hda_preset_conexant
[] = {
4436 { .id
= 0x14f15045, .name
= "CX20549 (Venice)",
4437 .patch
= patch_cxt5045
},
4438 { .id
= 0x14f15047, .name
= "CX20551 (Waikiki)",
4439 .patch
= patch_cxt5047
},
4440 { .id
= 0x14f15051, .name
= "CX20561 (Hermosa)",
4441 .patch
= patch_cxt5051
},
4442 { .id
= 0x14f15066, .name
= "CX20582 (Pebble)",
4443 .patch
= patch_cxt5066
},
4444 { .id
= 0x14f15067, .name
= "CX20583 (Pebble HSF)",
4445 .patch
= patch_cxt5066
},
4446 { .id
= 0x14f15068, .name
= "CX20584",
4447 .patch
= patch_cxt5066
},
4448 { .id
= 0x14f15069, .name
= "CX20585",
4449 .patch
= patch_cxt5066
},
4450 { .id
= 0x14f1506c, .name
= "CX20588",
4451 .patch
= patch_cxt5066
},
4452 { .id
= 0x14f1506e, .name
= "CX20590",
4453 .patch
= patch_cxt5066
},
4454 { .id
= 0x14f15097, .name
= "CX20631",
4455 .patch
= patch_conexant_auto
},
4456 { .id
= 0x14f15098, .name
= "CX20632",
4457 .patch
= patch_conexant_auto
},
4458 { .id
= 0x14f150a1, .name
= "CX20641",
4459 .patch
= patch_conexant_auto
},
4460 { .id
= 0x14f150a2, .name
= "CX20642",
4461 .patch
= patch_conexant_auto
},
4462 { .id
= 0x14f150ab, .name
= "CX20651",
4463 .patch
= patch_conexant_auto
},
4464 { .id
= 0x14f150ac, .name
= "CX20652",
4465 .patch
= patch_conexant_auto
},
4466 { .id
= 0x14f150b8, .name
= "CX20664",
4467 .patch
= patch_conexant_auto
},
4468 { .id
= 0x14f150b9, .name
= "CX20665",
4469 .patch
= patch_conexant_auto
},
4473 MODULE_ALIAS("snd-hda-codec-id:14f15045");
4474 MODULE_ALIAS("snd-hda-codec-id:14f15047");
4475 MODULE_ALIAS("snd-hda-codec-id:14f15051");
4476 MODULE_ALIAS("snd-hda-codec-id:14f15066");
4477 MODULE_ALIAS("snd-hda-codec-id:14f15067");
4478 MODULE_ALIAS("snd-hda-codec-id:14f15068");
4479 MODULE_ALIAS("snd-hda-codec-id:14f15069");
4480 MODULE_ALIAS("snd-hda-codec-id:14f1506c");
4481 MODULE_ALIAS("snd-hda-codec-id:14f1506e");
4482 MODULE_ALIAS("snd-hda-codec-id:14f15097");
4483 MODULE_ALIAS("snd-hda-codec-id:14f15098");
4484 MODULE_ALIAS("snd-hda-codec-id:14f150a1");
4485 MODULE_ALIAS("snd-hda-codec-id:14f150a2");
4486 MODULE_ALIAS("snd-hda-codec-id:14f150ab");
4487 MODULE_ALIAS("snd-hda-codec-id:14f150ac");
4488 MODULE_ALIAS("snd-hda-codec-id:14f150b8");
4489 MODULE_ALIAS("snd-hda-codec-id:14f150b9");
4491 MODULE_LICENSE("GPL");
4492 MODULE_DESCRIPTION("Conexant HD-audio codec");
4494 static struct hda_codec_preset_list conexant_list
= {
4495 .preset
= snd_hda_preset_conexant
,
4496 .owner
= THIS_MODULE
,
4499 static int __init
patch_conexant_init(void)
4501 return snd_hda_add_codec_preset(&conexant_list
);
4504 static void __exit
patch_conexant_exit(void)
4506 snd_hda_delete_codec_preset(&conexant_list
);
4509 module_init(patch_conexant_init
)
4510 module_exit(patch_conexant_exit
)