2 * HD audio interface patch for Conexant HDA audio codec
4 * Copyright (c) 2006 Pototskiy Akex <alex.pototskiy@gmail.com>
5 * Takashi Iwai <tiwai@suse.de>
6 * Tobin Davis <tdavis@dsl-only.net>
8 * This driver is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This driver is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <linux/init.h>
24 #include <linux/delay.h>
25 #include <linux/slab.h>
26 #include <linux/pci.h>
27 #include <sound/core.h>
28 #include <sound/jack.h>
30 #include "hda_codec.h"
31 #include "hda_local.h"
34 #define CXT_PIN_DIR_IN 0x00
35 #define CXT_PIN_DIR_OUT 0x01
36 #define CXT_PIN_DIR_INOUT 0x02
37 #define CXT_PIN_DIR_IN_NOMICBIAS 0x03
38 #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04
40 #define CONEXANT_HP_EVENT 0x37
41 #define CONEXANT_MIC_EVENT 0x38
43 /* Conexant 5051 specific */
45 #define CXT5051_SPDIF_OUT 0x1C
46 #define CXT5051_PORTB_EVENT 0x38
47 #define CXT5051_PORTC_EVENT 0x39
49 #define AUTO_MIC_PORTB (1 << 1)
50 #define AUTO_MIC_PORTC (1 << 2)
52 struct conexant_jack
{
56 struct snd_jack
*jack
;
60 struct conexant_spec
{
62 struct snd_kcontrol_new
*mixers
[5];
64 hda_nid_t vmaster_nid
;
66 const struct hda_verb
*init_verbs
[5]; /* initialization verbs
70 unsigned int num_init_verbs
;
73 struct hda_multi_out multiout
; /* playback set-up
74 * max_channels, dacs must be set
75 * dig_out_nid and hp_nid are optional
77 unsigned int cur_eapd
;
78 unsigned int hp_present
;
79 unsigned int auto_mic
;
80 unsigned int need_dac_fix
;
83 unsigned int num_adc_nids
;
85 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
87 unsigned int cur_adc_idx
;
89 unsigned int cur_adc_stream_tag
;
90 unsigned int cur_adc_format
;
93 const struct hda_input_mux
*input_mux
;
94 hda_nid_t
*capsrc_nids
;
95 unsigned int cur_mux
[3];
98 const struct hda_channel_mode
*channel_mode
;
101 /* PCM information */
102 struct hda_pcm pcm_rec
[2]; /* used in build_pcms() */
104 unsigned int spdif_route
;
107 struct snd_array jacks
;
109 /* dynamic controls, init_verbs and input_mux */
110 struct auto_pin_cfg autocfg
;
111 struct hda_input_mux private_imux
;
112 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
114 unsigned int dell_automute
;
115 unsigned int port_d_mode
;
116 unsigned int dell_vostro
;
118 unsigned int ext_mic_present
;
119 unsigned int recording
;
120 void (*capture_prepare
)(struct hda_codec
*codec
);
121 void (*capture_cleanup
)(struct hda_codec
*codec
);
123 /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
124 * through the microphone jack.
125 * When the user enables this through a mixer switch, both internal and
126 * external microphones are disabled. Gain is fixed at 0dB. In this mode,
127 * we also allow the bias to be configured through a separate mixer
129 unsigned int dc_enable
;
130 unsigned int dc_input_bias
; /* offset into cxt5066_olpc_dc_bias */
131 unsigned int mic_boost
; /* offset into cxt5066_analog_mic_boost */
134 static int conexant_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
135 struct hda_codec
*codec
,
136 struct snd_pcm_substream
*substream
)
138 struct conexant_spec
*spec
= codec
->spec
;
139 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
143 static int conexant_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
144 struct hda_codec
*codec
,
145 unsigned int stream_tag
,
147 struct snd_pcm_substream
*substream
)
149 struct conexant_spec
*spec
= codec
->spec
;
150 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
155 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
156 struct hda_codec
*codec
,
157 struct snd_pcm_substream
*substream
)
159 struct conexant_spec
*spec
= codec
->spec
;
160 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
166 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
167 struct hda_codec
*codec
,
168 struct snd_pcm_substream
*substream
)
170 struct conexant_spec
*spec
= codec
->spec
;
171 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
174 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
175 struct hda_codec
*codec
,
176 struct snd_pcm_substream
*substream
)
178 struct conexant_spec
*spec
= codec
->spec
;
179 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
182 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
183 struct hda_codec
*codec
,
184 unsigned int stream_tag
,
186 struct snd_pcm_substream
*substream
)
188 struct conexant_spec
*spec
= codec
->spec
;
189 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
197 static int conexant_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
198 struct hda_codec
*codec
,
199 unsigned int stream_tag
,
201 struct snd_pcm_substream
*substream
)
203 struct conexant_spec
*spec
= codec
->spec
;
204 if (spec
->capture_prepare
)
205 spec
->capture_prepare(codec
);
206 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
207 stream_tag
, 0, format
);
211 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
212 struct hda_codec
*codec
,
213 struct snd_pcm_substream
*substream
)
215 struct conexant_spec
*spec
= codec
->spec
;
216 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
217 if (spec
->capture_cleanup
)
218 spec
->capture_cleanup(codec
);
224 static struct hda_pcm_stream conexant_pcm_analog_playback
= {
228 .nid
= 0, /* fill later */
230 .open
= conexant_playback_pcm_open
,
231 .prepare
= conexant_playback_pcm_prepare
,
232 .cleanup
= conexant_playback_pcm_cleanup
236 static struct hda_pcm_stream conexant_pcm_analog_capture
= {
240 .nid
= 0, /* fill later */
242 .prepare
= conexant_capture_pcm_prepare
,
243 .cleanup
= conexant_capture_pcm_cleanup
248 static struct hda_pcm_stream conexant_pcm_digital_playback
= {
252 .nid
= 0, /* fill later */
254 .open
= conexant_dig_playback_pcm_open
,
255 .close
= conexant_dig_playback_pcm_close
,
256 .prepare
= conexant_dig_playback_pcm_prepare
260 static struct hda_pcm_stream conexant_pcm_digital_capture
= {
264 /* NID is set in alc_build_pcms */
267 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
268 struct hda_codec
*codec
,
269 unsigned int stream_tag
,
271 struct snd_pcm_substream
*substream
)
273 struct conexant_spec
*spec
= codec
->spec
;
274 spec
->cur_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
275 spec
->cur_adc_stream_tag
= stream_tag
;
276 spec
->cur_adc_format
= format
;
277 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
281 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
282 struct hda_codec
*codec
,
283 struct snd_pcm_substream
*substream
)
285 struct conexant_spec
*spec
= codec
->spec
;
286 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
291 static struct hda_pcm_stream cx5051_pcm_analog_capture
= {
295 .nid
= 0, /* fill later */
297 .prepare
= cx5051_capture_pcm_prepare
,
298 .cleanup
= cx5051_capture_pcm_cleanup
302 static int conexant_build_pcms(struct hda_codec
*codec
)
304 struct conexant_spec
*spec
= codec
->spec
;
305 struct hda_pcm
*info
= spec
->pcm_rec
;
308 codec
->pcm_info
= info
;
310 info
->name
= "CONEXANT Analog";
311 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = conexant_pcm_analog_playback
;
312 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
=
313 spec
->multiout
.max_channels
;
314 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
315 spec
->multiout
.dac_nids
[0];
316 if (codec
->vendor_id
== 0x14f15051)
317 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
318 cx5051_pcm_analog_capture
;
320 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
321 conexant_pcm_analog_capture
;
322 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
= spec
->num_adc_nids
;
323 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
325 if (spec
->multiout
.dig_out_nid
) {
328 info
->name
= "Conexant Digital";
329 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
330 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
331 conexant_pcm_digital_playback
;
332 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
333 spec
->multiout
.dig_out_nid
;
334 if (spec
->dig_in_nid
) {
335 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
336 conexant_pcm_digital_capture
;
337 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
345 static int conexant_mux_enum_info(struct snd_kcontrol
*kcontrol
,
346 struct snd_ctl_elem_info
*uinfo
)
348 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
349 struct conexant_spec
*spec
= codec
->spec
;
351 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
354 static int conexant_mux_enum_get(struct snd_kcontrol
*kcontrol
,
355 struct snd_ctl_elem_value
*ucontrol
)
357 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
358 struct conexant_spec
*spec
= codec
->spec
;
359 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
361 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
365 static int conexant_mux_enum_put(struct snd_kcontrol
*kcontrol
,
366 struct snd_ctl_elem_value
*ucontrol
)
368 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
369 struct conexant_spec
*spec
= codec
->spec
;
370 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
372 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
373 spec
->capsrc_nids
[adc_idx
],
374 &spec
->cur_mux
[adc_idx
]);
377 #ifdef CONFIG_SND_HDA_INPUT_JACK
378 static void conexant_free_jack_priv(struct snd_jack
*jack
)
380 struct conexant_jack
*jacks
= jack
->private_data
;
385 static int conexant_add_jack(struct hda_codec
*codec
,
386 hda_nid_t nid
, int type
)
388 struct conexant_spec
*spec
;
389 struct conexant_jack
*jack
;
394 snd_array_init(&spec
->jacks
, sizeof(*jack
), 32);
395 jack
= snd_array_new(&spec
->jacks
);
396 name
= (type
== SND_JACK_HEADPHONE
) ? "Headphone" : "Mic" ;
404 err
= snd_jack_new(codec
->bus
->card
, name
, type
, &jack
->jack
);
407 jack
->jack
->private_data
= jack
;
408 jack
->jack
->private_free
= conexant_free_jack_priv
;
412 static void conexant_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
414 struct conexant_spec
*spec
= codec
->spec
;
415 struct conexant_jack
*jacks
= spec
->jacks
.list
;
419 for (i
= 0; i
< spec
->jacks
.used
; i
++) {
420 if (jacks
->nid
== nid
) {
421 unsigned int present
;
422 present
= snd_hda_jack_detect(codec
, nid
);
424 present
= (present
) ? jacks
->type
: 0 ;
426 snd_jack_report(jacks
->jack
,
434 static int conexant_init_jacks(struct hda_codec
*codec
)
436 struct conexant_spec
*spec
= codec
->spec
;
439 for (i
= 0; i
< spec
->num_init_verbs
; i
++) {
440 const struct hda_verb
*hv
;
442 hv
= spec
->init_verbs
[i
];
445 switch (hv
->param
^ AC_USRSP_EN
) {
446 case CONEXANT_HP_EVENT
:
447 err
= conexant_add_jack(codec
, hv
->nid
,
449 conexant_report_jack(codec
, hv
->nid
);
451 case CXT5051_PORTC_EVENT
:
452 case CONEXANT_MIC_EVENT
:
453 err
= conexant_add_jack(codec
, hv
->nid
,
454 SND_JACK_MICROPHONE
);
455 conexant_report_jack(codec
, hv
->nid
);
467 static inline void conexant_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
471 static inline int conexant_init_jacks(struct hda_codec
*codec
)
477 static int conexant_init(struct hda_codec
*codec
)
479 struct conexant_spec
*spec
= codec
->spec
;
482 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
483 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
487 static void conexant_free(struct hda_codec
*codec
)
489 #ifdef CONFIG_SND_HDA_INPUT_JACK
490 struct conexant_spec
*spec
= codec
->spec
;
491 if (spec
->jacks
.list
) {
492 struct conexant_jack
*jacks
= spec
->jacks
.list
;
494 for (i
= 0; i
< spec
->jacks
.used
; i
++, jacks
++) {
496 snd_device_free(codec
->bus
->card
, jacks
->jack
);
498 snd_array_free(&spec
->jacks
);
501 snd_hda_detach_beep_device(codec
);
505 static struct snd_kcontrol_new cxt_capture_mixers
[] = {
507 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
508 .name
= "Capture Source",
509 .info
= conexant_mux_enum_info
,
510 .get
= conexant_mux_enum_get
,
511 .put
= conexant_mux_enum_put
516 static const char *slave_vols
[] = {
517 "Headphone Playback Volume",
518 "Speaker Playback Volume",
522 static const char *slave_sws
[] = {
523 "Headphone Playback Switch",
524 "Speaker Playback Switch",
528 static int conexant_build_controls(struct hda_codec
*codec
)
530 struct conexant_spec
*spec
= codec
->spec
;
534 for (i
= 0; i
< spec
->num_mixers
; i
++) {
535 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
539 if (spec
->multiout
.dig_out_nid
) {
540 err
= snd_hda_create_spdif_out_ctls(codec
,
541 spec
->multiout
.dig_out_nid
);
544 err
= snd_hda_create_spdif_share_sw(codec
,
548 spec
->multiout
.share_spdif
= 1;
550 if (spec
->dig_in_nid
) {
551 err
= snd_hda_create_spdif_in_ctls(codec
,spec
->dig_in_nid
);
556 /* if we have no master control, let's create it */
557 if (spec
->vmaster_nid
&&
558 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
559 unsigned int vmaster_tlv
[4];
560 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
561 HDA_OUTPUT
, vmaster_tlv
);
562 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
563 vmaster_tlv
, slave_vols
);
567 if (spec
->vmaster_nid
&&
568 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
569 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
575 if (spec
->input_mux
) {
576 err
= snd_hda_add_new_ctls(codec
, cxt_capture_mixers
);
584 static struct hda_codec_ops conexant_patch_ops
= {
585 .build_controls
= conexant_build_controls
,
586 .build_pcms
= conexant_build_pcms
,
587 .init
= conexant_init
,
588 .free
= conexant_free
,
593 * the private value = nid | (invert << 8)
596 #define cxt_eapd_info snd_ctl_boolean_mono_info
598 static int cxt_eapd_get(struct snd_kcontrol
*kcontrol
,
599 struct snd_ctl_elem_value
*ucontrol
)
601 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
602 struct conexant_spec
*spec
= codec
->spec
;
603 int invert
= (kcontrol
->private_value
>> 8) & 1;
605 ucontrol
->value
.integer
.value
[0] = !spec
->cur_eapd
;
607 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
612 static int cxt_eapd_put(struct snd_kcontrol
*kcontrol
,
613 struct snd_ctl_elem_value
*ucontrol
)
615 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
616 struct conexant_spec
*spec
= codec
->spec
;
617 int invert
= (kcontrol
->private_value
>> 8) & 1;
618 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
621 eapd
= !!ucontrol
->value
.integer
.value
[0];
624 if (eapd
== spec
->cur_eapd
)
627 spec
->cur_eapd
= eapd
;
628 snd_hda_codec_write_cache(codec
, nid
,
629 0, AC_VERB_SET_EAPD_BTLENABLE
,
634 /* controls for test mode */
635 #ifdef CONFIG_SND_DEBUG
637 #define CXT_EAPD_SWITCH(xname, nid, mask) \
638 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
639 .info = cxt_eapd_info, \
640 .get = cxt_eapd_get, \
641 .put = cxt_eapd_put, \
642 .private_value = nid | (mask<<16) }
646 static int conexant_ch_mode_info(struct snd_kcontrol
*kcontrol
,
647 struct snd_ctl_elem_info
*uinfo
)
649 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
650 struct conexant_spec
*spec
= codec
->spec
;
651 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
652 spec
->num_channel_mode
);
655 static int conexant_ch_mode_get(struct snd_kcontrol
*kcontrol
,
656 struct snd_ctl_elem_value
*ucontrol
)
658 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
659 struct conexant_spec
*spec
= codec
->spec
;
660 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
661 spec
->num_channel_mode
,
662 spec
->multiout
.max_channels
);
665 static int conexant_ch_mode_put(struct snd_kcontrol
*kcontrol
,
666 struct snd_ctl_elem_value
*ucontrol
)
668 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
669 struct conexant_spec
*spec
= codec
->spec
;
670 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
671 spec
->num_channel_mode
,
672 &spec
->multiout
.max_channels
);
673 if (err
>= 0 && spec
->need_dac_fix
)
674 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
678 #define CXT_PIN_MODE(xname, nid, dir) \
679 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
680 .info = conexant_ch_mode_info, \
681 .get = conexant_ch_mode_get, \
682 .put = conexant_ch_mode_put, \
683 .private_value = nid | (dir<<16) }
685 #endif /* CONFIG_SND_DEBUG */
687 /* Conexant 5045 specific */
689 static hda_nid_t cxt5045_dac_nids
[1] = { 0x19 };
690 static hda_nid_t cxt5045_adc_nids
[1] = { 0x1a };
691 static hda_nid_t cxt5045_capsrc_nids
[1] = { 0x1a };
692 #define CXT5045_SPDIF_OUT 0x18
694 static struct hda_channel_mode cxt5045_modes
[1] = {
698 static struct hda_input_mux cxt5045_capture_source
= {
706 static struct hda_input_mux cxt5045_capture_source_benq
= {
717 static struct hda_input_mux cxt5045_capture_source_hp530
= {
725 /* turn on/off EAPD (+ mute HP) as a master switch */
726 static int cxt5045_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
727 struct snd_ctl_elem_value
*ucontrol
)
729 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
730 struct conexant_spec
*spec
= codec
->spec
;
733 if (!cxt_eapd_put(kcontrol
, ucontrol
))
736 /* toggle internal speakers mute depending of presence of
739 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
740 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
743 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
744 snd_hda_codec_amp_stereo(codec
, 0x11, HDA_OUTPUT
, 0,
749 /* bind volumes of both NID 0x10 and 0x11 */
750 static struct hda_bind_ctls cxt5045_hp_bind_master_vol
= {
751 .ops
= &snd_hda_bind_vol
,
753 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT
),
754 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT
),
759 /* toggle input of built-in and mic jack appropriately */
760 static void cxt5045_hp_automic(struct hda_codec
*codec
)
762 static struct hda_verb mic_jack_on
[] = {
763 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
764 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
767 static struct hda_verb mic_jack_off
[] = {
768 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
769 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
772 unsigned int present
;
774 present
= snd_hda_jack_detect(codec
, 0x12);
776 snd_hda_sequence_write(codec
, mic_jack_on
);
778 snd_hda_sequence_write(codec
, mic_jack_off
);
782 /* mute internal speaker if HP is plugged */
783 static void cxt5045_hp_automute(struct hda_codec
*codec
)
785 struct conexant_spec
*spec
= codec
->spec
;
788 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x11);
790 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
791 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
795 /* unsolicited event for HP jack sensing */
796 static void cxt5045_hp_unsol_event(struct hda_codec
*codec
,
801 case CONEXANT_HP_EVENT
:
802 cxt5045_hp_automute(codec
);
804 case CONEXANT_MIC_EVENT
:
805 cxt5045_hp_automic(codec
);
811 static struct snd_kcontrol_new cxt5045_mixers
[] = {
812 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
813 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
814 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
815 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
816 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
817 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
818 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
819 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
820 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
821 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
822 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
824 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
825 .name
= "Master Playback Switch",
826 .info
= cxt_eapd_info
,
828 .put
= cxt5045_hp_master_sw_put
,
829 .private_value
= 0x10,
835 static struct snd_kcontrol_new cxt5045_benq_mixers
[] = {
836 HDA_CODEC_VOLUME("CD Capture Volume", 0x1a, 0x04, HDA_INPUT
),
837 HDA_CODEC_MUTE("CD Capture Switch", 0x1a, 0x04, HDA_INPUT
),
838 HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x4, HDA_INPUT
),
839 HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x4, HDA_INPUT
),
841 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT
),
842 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT
),
843 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT
),
844 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT
),
846 HDA_CODEC_VOLUME("Mixer Capture Volume", 0x1a, 0x0, HDA_INPUT
),
847 HDA_CODEC_MUTE("Mixer Capture Switch", 0x1a, 0x0, HDA_INPUT
),
852 static struct snd_kcontrol_new cxt5045_mixers_hp530
[] = {
853 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
854 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
855 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
856 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
857 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
858 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
859 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
860 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
861 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
862 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
863 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
865 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
866 .name
= "Master Playback Switch",
867 .info
= cxt_eapd_info
,
869 .put
= cxt5045_hp_master_sw_put
,
870 .private_value
= 0x10,
876 static struct hda_verb cxt5045_init_verbs
[] = {
878 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
879 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
881 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
882 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
883 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
884 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
885 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
886 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
887 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
888 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
889 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
890 /* Record selector: Int mic */
891 {0x1a, AC_VERB_SET_CONNECT_SEL
,0x1},
892 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
893 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
894 /* SPDIF route: PCM */
895 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
896 { 0x13, AC_VERB_SET_CONNECT_SEL
, 0x0 },
898 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2 }, /* default on */
902 static struct hda_verb cxt5045_benq_init_verbs
[] = {
904 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
905 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
906 /* Line In,HP, Amp */
907 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
908 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
909 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
910 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
911 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
912 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
913 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
914 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
915 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
916 /* Record selector: Int mic */
917 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x1},
918 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
919 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
920 /* SPDIF route: PCM */
921 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
922 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0},
924 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
928 static struct hda_verb cxt5045_hp_sense_init_verbs
[] = {
929 /* pin sensing on HP jack */
930 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
934 static struct hda_verb cxt5045_mic_sense_init_verbs
[] = {
935 /* pin sensing on HP jack */
936 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
940 #ifdef CONFIG_SND_DEBUG
941 /* Test configuration for debugging, modelled after the ALC260 test
944 static struct hda_input_mux cxt5045_test_capture_source
= {
949 { "LINE1 pin", 0x2 },
950 { "HP-OUT pin", 0x3 },
955 static struct snd_kcontrol_new cxt5045_test_mixer
[] = {
957 /* Output controls */
958 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
959 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
960 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
961 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
962 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
963 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
965 /* Modes for retasking pin widgets */
966 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT
),
967 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT
),
969 /* EAPD Switch Control */
970 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
972 /* Loopback mixer controls */
974 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT
),
975 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT
),
976 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT
),
977 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT
),
978 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT
),
979 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT
),
980 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT
),
981 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT
),
982 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT
),
983 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT
),
985 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
986 .name
= "Input Source",
987 .info
= conexant_mux_enum_info
,
988 .get
= conexant_mux_enum_get
,
989 .put
= conexant_mux_enum_put
,
991 /* Audio input controls */
992 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT
),
993 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT
),
994 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT
),
995 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT
),
996 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT
),
997 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT
),
998 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT
),
999 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT
),
1000 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT
),
1001 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT
),
1005 static struct hda_verb cxt5045_test_init_verbs
[] = {
1006 /* Set connections */
1007 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1008 { 0x11, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1009 { 0x12, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1010 /* Enable retasking pins as output, initially without power amp */
1011 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1012 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1014 /* Disable digital (SPDIF) pins initially, but users can enable
1015 * them via a mixer switch. In the case of SPDIF-out, this initverb
1016 * payload also sets the generation to 0, output to be in "consumer"
1017 * PCM format, copyright asserted, no pre-emphasis and no validity
1020 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1021 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1023 /* Start with output sum widgets muted and their output gains at min */
1024 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1025 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1027 /* Unmute retasking pin widget output buffers since the default
1028 * state appears to be output. As the pin mode is changed by the
1029 * user the pin mode control will take care of enabling the pin's
1030 * input/output buffers as needed.
1032 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1033 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1035 /* Mute capture amp left and right */
1036 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1038 /* Set ADC connection select to match default mixer setting (mic1
1041 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1042 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x00},
1044 /* Mute all inputs to mixer widget (even unconnected ones) */
1045 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* Mixer pin */
1046 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* Mic1 pin */
1047 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* Line pin */
1048 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* HP pin */
1049 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1056 /* initialize jack-sensing, too */
1057 static int cxt5045_init(struct hda_codec
*codec
)
1059 conexant_init(codec
);
1060 cxt5045_hp_automute(codec
);
1066 CXT5045_LAPTOP_HPSENSE
,
1067 CXT5045_LAPTOP_MICSENSE
,
1068 CXT5045_LAPTOP_HPMICSENSE
,
1070 CXT5045_LAPTOP_HP530
,
1071 #ifdef CONFIG_SND_DEBUG
1077 static const char *cxt5045_models
[CXT5045_MODELS
] = {
1078 [CXT5045_LAPTOP_HPSENSE
] = "laptop-hpsense",
1079 [CXT5045_LAPTOP_MICSENSE
] = "laptop-micsense",
1080 [CXT5045_LAPTOP_HPMICSENSE
] = "laptop-hpmicsense",
1081 [CXT5045_BENQ
] = "benq",
1082 [CXT5045_LAPTOP_HP530
] = "laptop-hp530",
1083 #ifdef CONFIG_SND_DEBUG
1084 [CXT5045_TEST
] = "test",
1088 static struct snd_pci_quirk cxt5045_cfg_tbl
[] = {
1089 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530
),
1090 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1091 CXT5045_LAPTOP_HPSENSE
),
1092 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE
),
1093 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ
),
1094 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE
),
1095 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE
),
1096 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
1097 CXT5045_LAPTOP_HPMICSENSE
),
1098 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1099 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1100 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1101 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
1102 CXT5045_LAPTOP_HPMICSENSE
),
1103 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE
),
1107 static int patch_cxt5045(struct hda_codec
*codec
)
1109 struct conexant_spec
*spec
;
1112 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1116 codec
->pin_amp_workaround
= 1;
1118 spec
->multiout
.max_channels
= 2;
1119 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5045_dac_nids
);
1120 spec
->multiout
.dac_nids
= cxt5045_dac_nids
;
1121 spec
->multiout
.dig_out_nid
= CXT5045_SPDIF_OUT
;
1122 spec
->num_adc_nids
= 1;
1123 spec
->adc_nids
= cxt5045_adc_nids
;
1124 spec
->capsrc_nids
= cxt5045_capsrc_nids
;
1125 spec
->input_mux
= &cxt5045_capture_source
;
1126 spec
->num_mixers
= 1;
1127 spec
->mixers
[0] = cxt5045_mixers
;
1128 spec
->num_init_verbs
= 1;
1129 spec
->init_verbs
[0] = cxt5045_init_verbs
;
1130 spec
->spdif_route
= 0;
1131 spec
->num_channel_mode
= ARRAY_SIZE(cxt5045_modes
),
1132 spec
->channel_mode
= cxt5045_modes
,
1135 codec
->patch_ops
= conexant_patch_ops
;
1137 board_config
= snd_hda_check_board_config(codec
, CXT5045_MODELS
,
1140 switch (board_config
) {
1141 case CXT5045_LAPTOP_HPSENSE
:
1142 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1143 spec
->input_mux
= &cxt5045_capture_source
;
1144 spec
->num_init_verbs
= 2;
1145 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1146 spec
->mixers
[0] = cxt5045_mixers
;
1147 codec
->patch_ops
.init
= cxt5045_init
;
1149 case CXT5045_LAPTOP_MICSENSE
:
1150 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1151 spec
->input_mux
= &cxt5045_capture_source
;
1152 spec
->num_init_verbs
= 2;
1153 spec
->init_verbs
[1] = cxt5045_mic_sense_init_verbs
;
1154 spec
->mixers
[0] = cxt5045_mixers
;
1155 codec
->patch_ops
.init
= cxt5045_init
;
1158 case CXT5045_LAPTOP_HPMICSENSE
:
1159 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1160 spec
->input_mux
= &cxt5045_capture_source
;
1161 spec
->num_init_verbs
= 3;
1162 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1163 spec
->init_verbs
[2] = cxt5045_mic_sense_init_verbs
;
1164 spec
->mixers
[0] = cxt5045_mixers
;
1165 codec
->patch_ops
.init
= cxt5045_init
;
1168 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1169 spec
->input_mux
= &cxt5045_capture_source_benq
;
1170 spec
->num_init_verbs
= 1;
1171 spec
->init_verbs
[0] = cxt5045_benq_init_verbs
;
1172 spec
->mixers
[0] = cxt5045_mixers
;
1173 spec
->mixers
[1] = cxt5045_benq_mixers
;
1174 spec
->num_mixers
= 2;
1175 codec
->patch_ops
.init
= cxt5045_init
;
1177 case CXT5045_LAPTOP_HP530
:
1178 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1179 spec
->input_mux
= &cxt5045_capture_source_hp530
;
1180 spec
->num_init_verbs
= 2;
1181 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1182 spec
->mixers
[0] = cxt5045_mixers_hp530
;
1183 codec
->patch_ops
.init
= cxt5045_init
;
1185 #ifdef CONFIG_SND_DEBUG
1187 spec
->input_mux
= &cxt5045_test_capture_source
;
1188 spec
->mixers
[0] = cxt5045_test_mixer
;
1189 spec
->init_verbs
[0] = cxt5045_test_init_verbs
;
1195 switch (codec
->subsystem_id
>> 16) {
1198 /* HP & Fujitsu-Siemens laptops have really bad sound over 0dB
1199 * on NID 0x17. Fix max PCM level to 0 dB
1200 * (originally it has 0x2b steps with 0dB offset 0x14)
1202 snd_hda_override_amp_caps(codec
, 0x17, HDA_INPUT
,
1203 (0x14 << AC_AMPCAP_OFFSET_SHIFT
) |
1204 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1205 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1206 (1 << AC_AMPCAP_MUTE_SHIFT
));
1214 /* Conexant 5047 specific */
1215 #define CXT5047_SPDIF_OUT 0x11
1217 static hda_nid_t cxt5047_dac_nids
[1] = { 0x10 }; /* 0x1c */
1218 static hda_nid_t cxt5047_adc_nids
[1] = { 0x12 };
1219 static hda_nid_t cxt5047_capsrc_nids
[1] = { 0x1a };
1221 static struct hda_channel_mode cxt5047_modes
[1] = {
1225 static struct hda_input_mux cxt5047_toshiba_capture_source
= {
1233 /* turn on/off EAPD (+ mute HP) as a master switch */
1234 static int cxt5047_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1235 struct snd_ctl_elem_value
*ucontrol
)
1237 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1238 struct conexant_spec
*spec
= codec
->spec
;
1241 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1244 /* toggle internal speakers mute depending of presence of
1245 * the headphone jack
1247 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
1248 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1249 * pin widgets unlike other codecs. In this case, we need to
1250 * set index 0x01 for the volume from the mixer amp 0x19.
1252 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1253 HDA_AMP_MUTE
, bits
);
1254 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
1255 snd_hda_codec_amp_stereo(codec
, 0x13, HDA_OUTPUT
, 0,
1256 HDA_AMP_MUTE
, bits
);
1260 /* mute internal speaker if HP is plugged */
1261 static void cxt5047_hp_automute(struct hda_codec
*codec
)
1263 struct conexant_spec
*spec
= codec
->spec
;
1266 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x13);
1268 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
1269 /* See the note in cxt5047_hp_master_sw_put */
1270 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1271 HDA_AMP_MUTE
, bits
);
1274 /* toggle input of built-in and mic jack appropriately */
1275 static void cxt5047_hp_automic(struct hda_codec
*codec
)
1277 static struct hda_verb mic_jack_on
[] = {
1278 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1279 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1282 static struct hda_verb mic_jack_off
[] = {
1283 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1284 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1287 unsigned int present
;
1289 present
= snd_hda_jack_detect(codec
, 0x15);
1291 snd_hda_sequence_write(codec
, mic_jack_on
);
1293 snd_hda_sequence_write(codec
, mic_jack_off
);
1296 /* unsolicited event for HP jack sensing */
1297 static void cxt5047_hp_unsol_event(struct hda_codec
*codec
,
1300 switch (res
>> 26) {
1301 case CONEXANT_HP_EVENT
:
1302 cxt5047_hp_automute(codec
);
1304 case CONEXANT_MIC_EVENT
:
1305 cxt5047_hp_automic(codec
);
1310 static struct snd_kcontrol_new cxt5047_base_mixers
[] = {
1311 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT
),
1312 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT
),
1313 HDA_CODEC_VOLUME("Mic Boost", 0x1a, 0x0, HDA_OUTPUT
),
1314 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT
),
1315 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT
),
1316 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT
),
1317 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT
),
1319 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1320 .name
= "Master Playback Switch",
1321 .info
= cxt_eapd_info
,
1322 .get
= cxt_eapd_get
,
1323 .put
= cxt5047_hp_master_sw_put
,
1324 .private_value
= 0x13,
1330 static struct snd_kcontrol_new cxt5047_hp_spk_mixers
[] = {
1331 /* See the note in cxt5047_hp_master_sw_put */
1332 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT
),
1333 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1337 static struct snd_kcontrol_new cxt5047_hp_only_mixers
[] = {
1338 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1342 static struct hda_verb cxt5047_init_verbs
[] = {
1343 /* Line in, Mic, Built-in Mic */
1344 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1345 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1346 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1348 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1349 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* mixer(0x19) */
1350 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mixer(0x19) */
1351 /* Record selector: Mic */
1352 {0x12, AC_VERB_SET_CONNECT_SEL
,0x03},
1353 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
,
1354 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
1355 {0x1A, AC_VERB_SET_CONNECT_SEL
,0x02},
1356 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1357 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x00},
1358 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1359 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x03},
1360 /* SPDIF route: PCM */
1361 { 0x18, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1362 /* Enable unsolicited events */
1363 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
1364 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1368 /* configuration for Toshiba Laptops */
1369 static struct hda_verb cxt5047_toshiba_init_verbs
[] = {
1370 {0x13, AC_VERB_SET_EAPD_BTLENABLE
, 0x0}, /* default off */
1374 /* Test configuration for debugging, modelled after the ALC260 test
1377 #ifdef CONFIG_SND_DEBUG
1378 static struct hda_input_mux cxt5047_test_capture_source
= {
1381 { "LINE1 pin", 0x0 },
1382 { "MIC1 pin", 0x1 },
1383 { "MIC2 pin", 0x2 },
1388 static struct snd_kcontrol_new cxt5047_test_mixer
[] = {
1390 /* Output only controls */
1391 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT
),
1392 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT
),
1393 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT
),
1394 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT
),
1395 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1396 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1397 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1398 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1399 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT
),
1400 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT
),
1401 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
1402 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
1404 /* Modes for retasking pin widgets */
1405 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT
),
1406 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT
),
1408 /* EAPD Switch Control */
1409 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1411 /* Loopback mixer controls */
1412 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT
),
1413 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT
),
1414 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT
),
1415 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT
),
1416 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT
),
1417 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT
),
1418 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT
),
1419 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT
),
1421 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT
),
1422 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT
),
1423 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT
),
1424 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT
),
1425 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT
),
1426 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT
),
1427 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT
),
1428 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT
),
1430 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1431 .name
= "Input Source",
1432 .info
= conexant_mux_enum_info
,
1433 .get
= conexant_mux_enum_get
,
1434 .put
= conexant_mux_enum_put
,
1436 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1441 static struct hda_verb cxt5047_test_init_verbs
[] = {
1442 /* Enable retasking pins as output, initially without power amp */
1443 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1444 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1445 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1447 /* Disable digital (SPDIF) pins initially, but users can enable
1448 * them via a mixer switch. In the case of SPDIF-out, this initverb
1449 * payload also sets the generation to 0, output to be in "consumer"
1450 * PCM format, copyright asserted, no pre-emphasis and no validity
1453 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1455 /* Ensure mic1, mic2, line1 pin widgets take input from the
1456 * OUT1 sum bus when acting as an output.
1458 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0},
1459 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0},
1461 /* Start with output sum widgets muted and their output gains at min */
1462 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1463 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1465 /* Unmute retasking pin widget output buffers since the default
1466 * state appears to be output. As the pin mode is changed by the
1467 * user the pin mode control will take care of enabling the pin's
1468 * input/output buffers as needed.
1470 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1471 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1472 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1474 /* Mute capture amp left and right */
1475 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1477 /* Set ADC connection select to match default mixer setting (mic1
1480 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x00},
1482 /* Mute all inputs to mixer widget (even unconnected ones) */
1483 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* mic1 pin */
1484 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* mic2 pin */
1485 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* line1 pin */
1486 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* line2 pin */
1487 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1488 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1489 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)}, /* Line-out pin */
1490 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)}, /* HP-pin pin */
1497 /* initialize jack-sensing, too */
1498 static int cxt5047_hp_init(struct hda_codec
*codec
)
1500 conexant_init(codec
);
1501 cxt5047_hp_automute(codec
);
1507 CXT5047_LAPTOP
, /* Laptops w/o EAPD support */
1508 CXT5047_LAPTOP_HP
, /* Some HP laptops */
1509 CXT5047_LAPTOP_EAPD
, /* Laptops with EAPD support */
1510 #ifdef CONFIG_SND_DEBUG
1516 static const char *cxt5047_models
[CXT5047_MODELS
] = {
1517 [CXT5047_LAPTOP
] = "laptop",
1518 [CXT5047_LAPTOP_HP
] = "laptop-hp",
1519 [CXT5047_LAPTOP_EAPD
] = "laptop-eapd",
1520 #ifdef CONFIG_SND_DEBUG
1521 [CXT5047_TEST
] = "test",
1525 static struct snd_pci_quirk cxt5047_cfg_tbl
[] = {
1526 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP
),
1527 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1529 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD
),
1533 static int patch_cxt5047(struct hda_codec
*codec
)
1535 struct conexant_spec
*spec
;
1538 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1542 codec
->pin_amp_workaround
= 1;
1544 spec
->multiout
.max_channels
= 2;
1545 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5047_dac_nids
);
1546 spec
->multiout
.dac_nids
= cxt5047_dac_nids
;
1547 spec
->multiout
.dig_out_nid
= CXT5047_SPDIF_OUT
;
1548 spec
->num_adc_nids
= 1;
1549 spec
->adc_nids
= cxt5047_adc_nids
;
1550 spec
->capsrc_nids
= cxt5047_capsrc_nids
;
1551 spec
->num_mixers
= 1;
1552 spec
->mixers
[0] = cxt5047_base_mixers
;
1553 spec
->num_init_verbs
= 1;
1554 spec
->init_verbs
[0] = cxt5047_init_verbs
;
1555 spec
->spdif_route
= 0;
1556 spec
->num_channel_mode
= ARRAY_SIZE(cxt5047_modes
),
1557 spec
->channel_mode
= cxt5047_modes
,
1559 codec
->patch_ops
= conexant_patch_ops
;
1561 board_config
= snd_hda_check_board_config(codec
, CXT5047_MODELS
,
1564 switch (board_config
) {
1565 case CXT5047_LAPTOP
:
1566 spec
->num_mixers
= 2;
1567 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1568 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1570 case CXT5047_LAPTOP_HP
:
1571 spec
->num_mixers
= 2;
1572 spec
->mixers
[1] = cxt5047_hp_only_mixers
;
1573 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1574 codec
->patch_ops
.init
= cxt5047_hp_init
;
1576 case CXT5047_LAPTOP_EAPD
:
1577 spec
->input_mux
= &cxt5047_toshiba_capture_source
;
1578 spec
->num_mixers
= 2;
1579 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1580 spec
->num_init_verbs
= 2;
1581 spec
->init_verbs
[1] = cxt5047_toshiba_init_verbs
;
1582 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1584 #ifdef CONFIG_SND_DEBUG
1586 spec
->input_mux
= &cxt5047_test_capture_source
;
1587 spec
->mixers
[0] = cxt5047_test_mixer
;
1588 spec
->init_verbs
[0] = cxt5047_test_init_verbs
;
1589 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1592 spec
->vmaster_nid
= 0x13;
1596 /* Conexant 5051 specific */
1597 static hda_nid_t cxt5051_dac_nids
[1] = { 0x10 };
1598 static hda_nid_t cxt5051_adc_nids
[2] = { 0x14, 0x15 };
1600 static struct hda_channel_mode cxt5051_modes
[1] = {
1604 static void cxt5051_update_speaker(struct hda_codec
*codec
)
1606 struct conexant_spec
*spec
= codec
->spec
;
1607 unsigned int pinctl
;
1608 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1609 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1613 /* turn on/off EAPD (+ mute HP) as a master switch */
1614 static int cxt5051_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1615 struct snd_ctl_elem_value
*ucontrol
)
1617 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1619 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1621 cxt5051_update_speaker(codec
);
1625 /* toggle input of built-in and mic jack appropriately */
1626 static void cxt5051_portb_automic(struct hda_codec
*codec
)
1628 struct conexant_spec
*spec
= codec
->spec
;
1629 unsigned int present
;
1631 if (!(spec
->auto_mic
& AUTO_MIC_PORTB
))
1633 present
= snd_hda_jack_detect(codec
, 0x17);
1634 snd_hda_codec_write(codec
, 0x14, 0,
1635 AC_VERB_SET_CONNECT_SEL
,
1636 present
? 0x01 : 0x00);
1639 /* switch the current ADC according to the jack state */
1640 static void cxt5051_portc_automic(struct hda_codec
*codec
)
1642 struct conexant_spec
*spec
= codec
->spec
;
1643 unsigned int present
;
1646 if (!(spec
->auto_mic
& AUTO_MIC_PORTC
))
1648 present
= snd_hda_jack_detect(codec
, 0x18);
1650 spec
->cur_adc_idx
= 1;
1652 spec
->cur_adc_idx
= 0;
1653 new_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
1654 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
1655 /* stream is running, let's swap the current ADC */
1656 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
1657 spec
->cur_adc
= new_adc
;
1658 snd_hda_codec_setup_stream(codec
, new_adc
,
1659 spec
->cur_adc_stream_tag
, 0,
1660 spec
->cur_adc_format
);
1664 /* mute internal speaker if HP is plugged */
1665 static void cxt5051_hp_automute(struct hda_codec
*codec
)
1667 struct conexant_spec
*spec
= codec
->spec
;
1669 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x16);
1670 cxt5051_update_speaker(codec
);
1673 /* unsolicited event for HP jack sensing */
1674 static void cxt5051_hp_unsol_event(struct hda_codec
*codec
,
1677 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
1678 switch (res
>> 26) {
1679 case CONEXANT_HP_EVENT
:
1680 cxt5051_hp_automute(codec
);
1682 case CXT5051_PORTB_EVENT
:
1683 cxt5051_portb_automic(codec
);
1685 case CXT5051_PORTC_EVENT
:
1686 cxt5051_portc_automic(codec
);
1689 conexant_report_jack(codec
, nid
);
1692 static struct snd_kcontrol_new cxt5051_playback_mixers
[] = {
1693 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1695 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1696 .name
= "Master Playback Switch",
1697 .info
= cxt_eapd_info
,
1698 .get
= cxt_eapd_get
,
1699 .put
= cxt5051_hp_master_sw_put
,
1700 .private_value
= 0x1a,
1705 static struct snd_kcontrol_new cxt5051_capture_mixers
[] = {
1706 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1707 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1708 HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT
),
1709 HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT
),
1710 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT
),
1711 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT
),
1715 static struct snd_kcontrol_new cxt5051_hp_mixers
[] = {
1716 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1717 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1718 HDA_CODEC_VOLUME("External Mic Volume", 0x15, 0x00, HDA_INPUT
),
1719 HDA_CODEC_MUTE("External Mic Switch", 0x15, 0x00, HDA_INPUT
),
1723 static struct snd_kcontrol_new cxt5051_hp_dv6736_mixers
[] = {
1724 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT
),
1725 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT
),
1729 static struct snd_kcontrol_new cxt5051_f700_mixers
[] = {
1730 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT
),
1731 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT
),
1735 static struct snd_kcontrol_new cxt5051_toshiba_mixers
[] = {
1736 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1737 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1738 HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT
),
1739 HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT
),
1743 static struct hda_verb cxt5051_init_verbs
[] = {
1745 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1746 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1747 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1748 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1749 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1750 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1752 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1753 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1755 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1756 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1758 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1759 /* Record selector: Int mic */
1760 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1761 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1762 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1763 /* SPDIF route: PCM */
1764 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1766 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1767 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1768 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTB_EVENT
},
1769 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTC_EVENT
},
1773 static struct hda_verb cxt5051_hp_dv6736_init_verbs
[] = {
1775 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1776 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1777 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1778 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1780 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1781 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1783 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1784 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1786 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1787 /* Record selector: Int mic */
1788 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1789 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1790 /* SPDIF route: PCM */
1791 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1793 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1794 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1795 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTB_EVENT
},
1799 static struct hda_verb cxt5051_lenovo_x200_init_verbs
[] = {
1801 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1802 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1803 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1804 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1805 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1806 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1808 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1809 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1811 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1812 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1814 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1815 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00},
1817 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1818 /* Record selector: Int mic */
1819 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1820 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1821 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1822 /* SPDIF route: PCM */
1823 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1825 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1826 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1827 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTB_EVENT
},
1828 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTC_EVENT
},
1829 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1833 static struct hda_verb cxt5051_f700_init_verbs
[] = {
1835 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x03},
1836 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1837 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1838 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1840 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1841 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1843 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1844 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1846 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1847 /* Record selector: Int mic */
1848 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1849 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1850 /* SPDIF route: PCM */
1851 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1853 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1854 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1855 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTB_EVENT
},
1859 /* initialize jack-sensing, too */
1860 static int cxt5051_init(struct hda_codec
*codec
)
1862 conexant_init(codec
);
1863 conexant_init_jacks(codec
);
1864 if (codec
->patch_ops
.unsol_event
) {
1865 cxt5051_hp_automute(codec
);
1866 cxt5051_portb_automic(codec
);
1867 cxt5051_portc_automic(codec
);
1874 CXT5051_LAPTOP
, /* Laptops w/ EAPD support */
1875 CXT5051_HP
, /* no docking */
1876 CXT5051_HP_DV6736
, /* HP without mic switch */
1877 CXT5051_LENOVO_X200
, /* Lenovo X200 laptop */
1878 CXT5051_F700
, /* HP Compaq Presario F700 */
1879 CXT5051_TOSHIBA
, /* Toshiba M300 & co */
1883 static const char *cxt5051_models
[CXT5051_MODELS
] = {
1884 [CXT5051_LAPTOP
] = "laptop",
1885 [CXT5051_HP
] = "hp",
1886 [CXT5051_HP_DV6736
] = "hp-dv6736",
1887 [CXT5051_LENOVO_X200
] = "lenovo-x200",
1888 [CXT5051_F700
] = "hp-700",
1889 [CXT5051_TOSHIBA
] = "toshiba",
1892 static struct snd_pci_quirk cxt5051_cfg_tbl
[] = {
1893 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736
),
1894 SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP
),
1895 SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700
),
1896 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA
),
1897 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1899 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP
),
1900 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200
),
1904 static int patch_cxt5051(struct hda_codec
*codec
)
1906 struct conexant_spec
*spec
;
1909 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1913 codec
->pin_amp_workaround
= 1;
1915 codec
->patch_ops
= conexant_patch_ops
;
1916 codec
->patch_ops
.init
= cxt5051_init
;
1918 spec
->multiout
.max_channels
= 2;
1919 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5051_dac_nids
);
1920 spec
->multiout
.dac_nids
= cxt5051_dac_nids
;
1921 spec
->multiout
.dig_out_nid
= CXT5051_SPDIF_OUT
;
1922 spec
->num_adc_nids
= 1; /* not 2; via auto-mic switch */
1923 spec
->adc_nids
= cxt5051_adc_nids
;
1924 spec
->num_mixers
= 2;
1925 spec
->mixers
[0] = cxt5051_capture_mixers
;
1926 spec
->mixers
[1] = cxt5051_playback_mixers
;
1927 spec
->num_init_verbs
= 1;
1928 spec
->init_verbs
[0] = cxt5051_init_verbs
;
1929 spec
->spdif_route
= 0;
1930 spec
->num_channel_mode
= ARRAY_SIZE(cxt5051_modes
);
1931 spec
->channel_mode
= cxt5051_modes
;
1933 spec
->cur_adc_idx
= 0;
1935 codec
->patch_ops
.unsol_event
= cxt5051_hp_unsol_event
;
1937 board_config
= snd_hda_check_board_config(codec
, CXT5051_MODELS
,
1940 spec
->auto_mic
= AUTO_MIC_PORTB
| AUTO_MIC_PORTC
;
1941 switch (board_config
) {
1943 spec
->mixers
[0] = cxt5051_hp_mixers
;
1945 case CXT5051_HP_DV6736
:
1946 spec
->init_verbs
[0] = cxt5051_hp_dv6736_init_verbs
;
1947 spec
->mixers
[0] = cxt5051_hp_dv6736_mixers
;
1950 case CXT5051_LENOVO_X200
:
1951 spec
->init_verbs
[0] = cxt5051_lenovo_x200_init_verbs
;
1954 spec
->init_verbs
[0] = cxt5051_f700_init_verbs
;
1955 spec
->mixers
[0] = cxt5051_f700_mixers
;
1958 case CXT5051_TOSHIBA
:
1959 spec
->mixers
[0] = cxt5051_toshiba_mixers
;
1960 spec
->auto_mic
= AUTO_MIC_PORTB
;
1967 /* Conexant 5066 specific */
1969 static hda_nid_t cxt5066_dac_nids
[1] = { 0x10 };
1970 static hda_nid_t cxt5066_adc_nids
[3] = { 0x14, 0x15, 0x16 };
1971 static hda_nid_t cxt5066_capsrc_nids
[1] = { 0x17 };
1972 #define CXT5066_SPDIF_OUT 0x21
1974 /* OLPC's microphone port is DC coupled for use with external sensors,
1975 * therefore we use a 50% mic bias in order to center the input signal with
1976 * the DC input range of the codec. */
1977 #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50
1979 static struct hda_channel_mode cxt5066_modes
[1] = {
1983 static void cxt5066_update_speaker(struct hda_codec
*codec
)
1985 struct conexant_spec
*spec
= codec
->spec
;
1986 unsigned int pinctl
;
1988 snd_printdd("CXT5066: update speaker, hp_present=%d\n",
1992 pinctl
= ((spec
->hp_present
& 1) && spec
->cur_eapd
) ? PIN_HP
: 0;
1993 snd_hda_codec_write(codec
, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1996 /* Port D (HP/LO) */
1997 pinctl
= ((spec
->hp_present
& 2) && spec
->cur_eapd
)
1998 ? spec
->port_d_mode
: 0;
1999 snd_hda_codec_write(codec
, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2003 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
2004 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2007 if (spec
->dell_automute
) {
2008 /* DELL AIO Port Rule: PortA > PortD > IntSpk */
2009 pinctl
= (!(spec
->hp_present
& 1) && spec
->cur_eapd
)
2011 snd_hda_codec_write(codec
, 0x1c, 0,
2012 AC_VERB_SET_PIN_WIDGET_CONTROL
, pinctl
);
2016 /* turn on/off EAPD (+ mute HP) as a master switch */
2017 static int cxt5066_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
2018 struct snd_ctl_elem_value
*ucontrol
)
2020 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2022 if (!cxt_eapd_put(kcontrol
, ucontrol
))
2025 cxt5066_update_speaker(codec
);
2029 static const struct hda_input_mux cxt5066_olpc_dc_bias
= {
2033 { "50%", PIN_VREF50
},
2034 { "80%", PIN_VREF80
},
2038 static int cxt5066_set_olpc_dc_bias(struct hda_codec
*codec
)
2040 struct conexant_spec
*spec
= codec
->spec
;
2041 /* Even though port F is the DC input, the bias is controlled on port B.
2042 * we also leave that port as an active input (but unselected) in DC mode
2043 * just in case that is necessary to make the bias setting take effect. */
2044 return snd_hda_codec_write_cache(codec
, 0x1a, 0,
2045 AC_VERB_SET_PIN_WIDGET_CONTROL
,
2046 cxt5066_olpc_dc_bias
.items
[spec
->dc_input_bias
].index
);
2049 /* OLPC defers mic widget control until when capture is started because the
2050 * microphone LED comes on as soon as these settings are put in place. if we
2051 * did this before recording, it would give the false indication that recording
2052 * is happening when it is not. */
2053 static void cxt5066_olpc_select_mic(struct hda_codec
*codec
)
2055 struct conexant_spec
*spec
= codec
->spec
;
2056 if (!spec
->recording
)
2059 if (spec
->dc_enable
) {
2060 /* in DC mode we ignore presence detection and just use the jack
2061 * through our special DC port */
2062 const struct hda_verb enable_dc_mode
[] = {
2063 /* disble internal mic, port C */
2064 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2066 /* enable DC capture, port F */
2067 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2071 snd_hda_sequence_write(codec
, enable_dc_mode
);
2072 /* port B input disabled (and bias set) through the following call */
2073 cxt5066_set_olpc_dc_bias(codec
);
2077 /* disable DC (port F) */
2078 snd_hda_codec_write(codec
, 0x1e, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0);
2080 /* external mic, port B */
2081 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2082 spec
->ext_mic_present
? CXT5066_OLPC_EXT_MIC_BIAS
: 0);
2084 /* internal mic, port C */
2085 snd_hda_codec_write(codec
, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2086 spec
->ext_mic_present
? 0 : PIN_VREF80
);
2089 /* toggle input of built-in and mic jack appropriately */
2090 static void cxt5066_olpc_automic(struct hda_codec
*codec
)
2092 struct conexant_spec
*spec
= codec
->spec
;
2093 unsigned int present
;
2095 if (spec
->dc_enable
) /* don't do presence detection in DC mode */
2098 present
= snd_hda_codec_read(codec
, 0x1a, 0,
2099 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
2101 snd_printdd("CXT5066: external microphone detected\n");
2103 snd_printdd("CXT5066: external microphone absent\n");
2105 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2107 spec
->ext_mic_present
= !!present
;
2109 cxt5066_olpc_select_mic(codec
);
2112 /* toggle input of built-in digital mic and mic jack appropriately */
2113 static void cxt5066_vostro_automic(struct hda_codec
*codec
)
2115 unsigned int present
;
2117 struct hda_verb ext_mic_present
[] = {
2118 /* enable external mic, port B */
2119 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2121 /* switch to external mic input */
2122 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2123 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2125 /* disable internal digital mic */
2126 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2129 static struct hda_verb ext_mic_absent
[] = {
2130 /* enable internal mic, port C */
2131 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2133 /* switch to internal mic input */
2134 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2136 /* disable external mic, port B */
2137 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2141 present
= snd_hda_jack_detect(codec
, 0x1a);
2143 snd_printdd("CXT5066: external microphone detected\n");
2144 snd_hda_sequence_write(codec
, ext_mic_present
);
2146 snd_printdd("CXT5066: external microphone absent\n");
2147 snd_hda_sequence_write(codec
, ext_mic_absent
);
2151 /* mute internal speaker if HP is plugged */
2152 static void cxt5066_hp_automute(struct hda_codec
*codec
)
2154 struct conexant_spec
*spec
= codec
->spec
;
2155 unsigned int portA
, portD
;
2158 portA
= snd_hda_jack_detect(codec
, 0x19);
2161 portD
= snd_hda_jack_detect(codec
, 0x1c);
2163 spec
->hp_present
= !!(portA
| portD
);
2164 snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
2165 portA
, portD
, spec
->hp_present
);
2166 cxt5066_update_speaker(codec
);
2169 /* unsolicited event for jack sensing */
2170 static void cxt5066_olpc_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2172 struct conexant_spec
*spec
= codec
->spec
;
2173 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2174 switch (res
>> 26) {
2175 case CONEXANT_HP_EVENT
:
2176 cxt5066_hp_automute(codec
);
2178 case CONEXANT_MIC_EVENT
:
2179 /* ignore mic events in DC mode; we're always using the jack */
2180 if (!spec
->dc_enable
)
2181 cxt5066_olpc_automic(codec
);
2186 /* unsolicited event for jack sensing */
2187 static void cxt5066_vostro_event(struct hda_codec
*codec
, unsigned int res
)
2189 snd_printdd("CXT5066_vostro: unsol event %x (%x)\n", res
, res
>> 26);
2190 switch (res
>> 26) {
2191 case CONEXANT_HP_EVENT
:
2192 cxt5066_hp_automute(codec
);
2194 case CONEXANT_MIC_EVENT
:
2195 cxt5066_vostro_automic(codec
);
2200 static const struct hda_input_mux cxt5066_analog_mic_boost
= {
2211 static int cxt5066_set_mic_boost(struct hda_codec
*codec
)
2213 struct conexant_spec
*spec
= codec
->spec
;
2214 return snd_hda_codec_write_cache(codec
, 0x17, 0,
2215 AC_VERB_SET_AMP_GAIN_MUTE
,
2216 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_OUTPUT
|
2217 cxt5066_analog_mic_boost
.items
[spec
->mic_boost
].index
);
2220 static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol
*kcontrol
,
2221 struct snd_ctl_elem_info
*uinfo
)
2223 return snd_hda_input_mux_info(&cxt5066_analog_mic_boost
, uinfo
);
2226 static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol
*kcontrol
,
2227 struct snd_ctl_elem_value
*ucontrol
)
2229 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2230 struct conexant_spec
*spec
= codec
->spec
;
2231 ucontrol
->value
.enumerated
.item
[0] = spec
->mic_boost
;
2235 static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol
*kcontrol
,
2236 struct snd_ctl_elem_value
*ucontrol
)
2238 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2239 struct conexant_spec
*spec
= codec
->spec
;
2240 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2242 idx
= ucontrol
->value
.enumerated
.item
[0];
2243 if (idx
>= imux
->num_items
)
2244 idx
= imux
->num_items
- 1;
2246 spec
->mic_boost
= idx
;
2247 if (!spec
->dc_enable
)
2248 cxt5066_set_mic_boost(codec
);
2252 static void cxt5066_enable_dc(struct hda_codec
*codec
)
2254 const struct hda_verb enable_dc_mode
[] = {
2256 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2258 /* switch to DC input */
2259 {0x17, AC_VERB_SET_CONNECT_SEL
, 3},
2263 /* configure as input source */
2264 snd_hda_sequence_write(codec
, enable_dc_mode
);
2265 cxt5066_olpc_select_mic(codec
); /* also sets configured bias */
2268 static void cxt5066_disable_dc(struct hda_codec
*codec
)
2270 /* reconfigure input source */
2271 cxt5066_set_mic_boost(codec
);
2272 /* automic also selects the right mic if we're recording */
2273 cxt5066_olpc_automic(codec
);
2276 static int cxt5066_olpc_dc_get(struct snd_kcontrol
*kcontrol
,
2277 struct snd_ctl_elem_value
*ucontrol
)
2279 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2280 struct conexant_spec
*spec
= codec
->spec
;
2281 ucontrol
->value
.integer
.value
[0] = spec
->dc_enable
;
2285 static int cxt5066_olpc_dc_put(struct snd_kcontrol
*kcontrol
,
2286 struct snd_ctl_elem_value
*ucontrol
)
2288 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2289 struct conexant_spec
*spec
= codec
->spec
;
2290 int dc_enable
= !!ucontrol
->value
.integer
.value
[0];
2292 if (dc_enable
== spec
->dc_enable
)
2295 spec
->dc_enable
= dc_enable
;
2297 cxt5066_enable_dc(codec
);
2299 cxt5066_disable_dc(codec
);
2304 static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol
*kcontrol
,
2305 struct snd_ctl_elem_info
*uinfo
)
2307 return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias
, uinfo
);
2310 static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol
*kcontrol
,
2311 struct snd_ctl_elem_value
*ucontrol
)
2313 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2314 struct conexant_spec
*spec
= codec
->spec
;
2315 ucontrol
->value
.enumerated
.item
[0] = spec
->dc_input_bias
;
2319 static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol
*kcontrol
,
2320 struct snd_ctl_elem_value
*ucontrol
)
2322 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2323 struct conexant_spec
*spec
= codec
->spec
;
2324 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2327 idx
= ucontrol
->value
.enumerated
.item
[0];
2328 if (idx
>= imux
->num_items
)
2329 idx
= imux
->num_items
- 1;
2331 spec
->dc_input_bias
= idx
;
2332 if (spec
->dc_enable
)
2333 cxt5066_set_olpc_dc_bias(codec
);
2337 static void cxt5066_olpc_capture_prepare(struct hda_codec
*codec
)
2339 struct conexant_spec
*spec
= codec
->spec
;
2340 /* mark as recording and configure the microphone widget so that the
2341 * recording LED comes on. */
2342 spec
->recording
= 1;
2343 cxt5066_olpc_select_mic(codec
);
2346 static void cxt5066_olpc_capture_cleanup(struct hda_codec
*codec
)
2348 struct conexant_spec
*spec
= codec
->spec
;
2349 const struct hda_verb disable_mics
[] = {
2350 /* disable external mic, port B */
2351 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2353 /* disble internal mic, port C */
2354 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2356 /* disable DC capture, port F */
2357 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2361 snd_hda_sequence_write(codec
, disable_mics
);
2362 spec
->recording
= 0;
2365 static struct hda_input_mux cxt5066_capture_source
= {
2375 static struct hda_bind_ctls cxt5066_bind_capture_vol_others
= {
2376 .ops
= &snd_hda_bind_vol
,
2378 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2379 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2384 static struct hda_bind_ctls cxt5066_bind_capture_sw_others
= {
2385 .ops
= &snd_hda_bind_sw
,
2387 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2388 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2393 static struct snd_kcontrol_new cxt5066_mixer_master
[] = {
2394 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
2398 static struct snd_kcontrol_new cxt5066_mixer_master_olpc
[] = {
2400 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2401 .name
= "Master Playback Volume",
2402 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
|
2403 SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
2404 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
,
2405 .subdevice
= HDA_SUBDEV_AMP_FLAG
,
2406 .info
= snd_hda_mixer_amp_volume_info
,
2407 .get
= snd_hda_mixer_amp_volume_get
,
2408 .put
= snd_hda_mixer_amp_volume_put
,
2409 .tlv
= { .c
= snd_hda_mixer_amp_tlv
},
2410 /* offset by 28 volume steps to limit minimum gain to -46dB */
2412 HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT
, 28),
2417 static struct snd_kcontrol_new cxt5066_mixer_olpc_dc
[] = {
2419 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2420 .name
= "DC Mode Enable Switch",
2421 .info
= snd_ctl_boolean_mono_info
,
2422 .get
= cxt5066_olpc_dc_get
,
2423 .put
= cxt5066_olpc_dc_put
,
2426 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2427 .name
= "DC Input Bias Enum",
2428 .info
= cxt5066_olpc_dc_bias_enum_info
,
2429 .get
= cxt5066_olpc_dc_bias_enum_get
,
2430 .put
= cxt5066_olpc_dc_bias_enum_put
,
2435 static struct snd_kcontrol_new cxt5066_mixers
[] = {
2437 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2438 .name
= "Master Playback Switch",
2439 .info
= cxt_eapd_info
,
2440 .get
= cxt_eapd_get
,
2441 .put
= cxt5066_hp_master_sw_put
,
2442 .private_value
= 0x1d,
2446 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2447 .name
= "Analog Mic Boost Capture Enum",
2448 .info
= cxt5066_mic_boost_mux_enum_info
,
2449 .get
= cxt5066_mic_boost_mux_enum_get
,
2450 .put
= cxt5066_mic_boost_mux_enum_put
,
2453 HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others
),
2454 HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others
),
2458 static struct snd_kcontrol_new cxt5066_vostro_mixers
[] = {
2460 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2461 .name
= "Int Mic Boost Capture Enum",
2462 .info
= cxt5066_mic_boost_mux_enum_info
,
2463 .get
= cxt5066_mic_boost_mux_enum_get
,
2464 .put
= cxt5066_mic_boost_mux_enum_put
,
2465 .private_value
= 0x23 | 0x100,
2467 HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT
),
2471 static struct hda_verb cxt5066_init_verbs
[] = {
2472 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2473 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2474 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2475 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2478 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2479 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2482 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2483 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2485 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2486 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2489 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2491 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2492 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2493 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2494 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2495 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2498 /* no digital microphone support yet */
2499 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2501 /* Audio input selector */
2502 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2504 /* SPDIF route: PCM */
2505 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2506 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2508 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2509 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2512 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2514 /* not handling these yet */
2515 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2516 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2517 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2518 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2519 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2520 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2521 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2522 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2526 static struct hda_verb cxt5066_init_verbs_olpc
[] = {
2527 /* Port A: headphones */
2528 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2529 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2531 /* Port B: external microphone */
2532 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2534 /* Port C: internal microphone */
2535 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2537 /* Port D: unused */
2538 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2540 /* Port E: unused, but has primary EAPD */
2541 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2542 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2544 /* Port F: external DC input through microphone port */
2545 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2547 /* Port G: internal speakers */
2548 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2549 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2552 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2555 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2557 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2558 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2559 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2560 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2561 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2562 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2563 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2564 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2565 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2566 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2567 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2568 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2570 /* Disable digital microphone port */
2571 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2573 /* Audio input selectors */
2574 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2575 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2578 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2579 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2581 /* enable unsolicited events for Port A and B */
2582 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2583 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2587 static struct hda_verb cxt5066_init_verbs_vostro
[] = {
2588 /* Port A: headphones */
2589 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2590 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2592 /* Port B: external microphone */
2593 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2595 /* Port C: unused */
2596 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2598 /* Port D: unused */
2599 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2601 /* Port E: unused, but has primary EAPD */
2602 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2603 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2605 /* Port F: unused */
2606 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2608 /* Port G: internal speakers */
2609 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2610 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2613 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2616 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2618 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2619 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2620 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2621 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2622 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2623 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2624 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2625 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2626 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2627 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2628 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2629 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2631 /* Digital microphone port */
2632 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2634 /* Audio input selectors */
2635 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2636 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2639 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2640 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2642 /* enable unsolicited events for Port A and B */
2643 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2644 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2648 static struct hda_verb cxt5066_init_verbs_portd_lo
[] = {
2649 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2653 /* initialize jack-sensing, too */
2654 static int cxt5066_init(struct hda_codec
*codec
)
2656 struct conexant_spec
*spec
= codec
->spec
;
2658 snd_printdd("CXT5066: init\n");
2659 conexant_init(codec
);
2660 if (codec
->patch_ops
.unsol_event
) {
2661 cxt5066_hp_automute(codec
);
2662 if (spec
->dell_vostro
)
2663 cxt5066_vostro_automic(codec
);
2665 cxt5066_set_mic_boost(codec
);
2669 static int cxt5066_olpc_init(struct hda_codec
*codec
)
2671 struct conexant_spec
*spec
= codec
->spec
;
2672 snd_printdd("CXT5066: init\n");
2673 conexant_init(codec
);
2674 cxt5066_hp_automute(codec
);
2675 if (!spec
->dc_enable
) {
2676 cxt5066_set_mic_boost(codec
);
2677 cxt5066_olpc_automic(codec
);
2679 cxt5066_enable_dc(codec
);
2685 CXT5066_LAPTOP
, /* Laptops w/ EAPD support */
2686 CXT5066_DELL_LAPTOP
, /* Dell Laptop */
2687 CXT5066_OLPC_XO_1_5
, /* OLPC XO 1.5 */
2688 CXT5066_DELL_VOSTO
, /* Dell Vostro 1015i */
2692 static const char *cxt5066_models
[CXT5066_MODELS
] = {
2693 [CXT5066_LAPTOP
] = "laptop",
2694 [CXT5066_DELL_LAPTOP
] = "dell-laptop",
2695 [CXT5066_OLPC_XO_1_5
] = "olpc-xo-1_5",
2696 [CXT5066_DELL_VOSTO
] = "dell-vostro"
2699 static struct snd_pci_quirk cxt5066_cfg_tbl
[] = {
2700 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
2702 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell",
2703 CXT5066_DELL_LAPTOP
),
2704 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5
),
2705 SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTO
),
2709 static int patch_cxt5066(struct hda_codec
*codec
)
2711 struct conexant_spec
*spec
;
2714 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2719 codec
->patch_ops
= conexant_patch_ops
;
2720 codec
->patch_ops
.init
= conexant_init
;
2722 spec
->dell_automute
= 0;
2723 spec
->multiout
.max_channels
= 2;
2724 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5066_dac_nids
);
2725 spec
->multiout
.dac_nids
= cxt5066_dac_nids
;
2726 spec
->multiout
.dig_out_nid
= CXT5066_SPDIF_OUT
;
2727 spec
->num_adc_nids
= 1;
2728 spec
->adc_nids
= cxt5066_adc_nids
;
2729 spec
->capsrc_nids
= cxt5066_capsrc_nids
;
2730 spec
->input_mux
= &cxt5066_capture_source
;
2732 spec
->port_d_mode
= PIN_HP
;
2734 spec
->num_init_verbs
= 1;
2735 spec
->init_verbs
[0] = cxt5066_init_verbs
;
2736 spec
->num_channel_mode
= ARRAY_SIZE(cxt5066_modes
);
2737 spec
->channel_mode
= cxt5066_modes
;
2739 spec
->cur_adc_idx
= 0;
2741 board_config
= snd_hda_check_board_config(codec
, CXT5066_MODELS
,
2742 cxt5066_models
, cxt5066_cfg_tbl
);
2743 switch (board_config
) {
2745 case CXT5066_LAPTOP
:
2746 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
2747 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2749 case CXT5066_DELL_LAPTOP
:
2750 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
2751 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2753 spec
->port_d_mode
= PIN_OUT
;
2754 spec
->init_verbs
[spec
->num_init_verbs
] = cxt5066_init_verbs_portd_lo
;
2755 spec
->num_init_verbs
++;
2756 spec
->dell_automute
= 1;
2758 case CXT5066_OLPC_XO_1_5
:
2759 codec
->patch_ops
.init
= cxt5066_olpc_init
;
2760 codec
->patch_ops
.unsol_event
= cxt5066_olpc_unsol_event
;
2761 spec
->init_verbs
[0] = cxt5066_init_verbs_olpc
;
2762 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
2763 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_olpc_dc
;
2764 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2765 spec
->port_d_mode
= 0;
2766 spec
->mic_boost
= 3; /* default 30dB gain */
2769 spec
->multiout
.dig_out_nid
= 0;
2771 /* input source automatically selected */
2772 spec
->input_mux
= NULL
;
2774 /* our capture hooks which allow us to turn on the microphone LED
2775 * at the right time */
2776 spec
->capture_prepare
= cxt5066_olpc_capture_prepare
;
2777 spec
->capture_cleanup
= cxt5066_olpc_capture_cleanup
;
2779 case CXT5066_DELL_VOSTO
:
2780 codec
->patch_ops
.init
= cxt5066_init
;
2781 codec
->patch_ops
.unsol_event
= cxt5066_vostro_event
;
2782 spec
->init_verbs
[0] = cxt5066_init_verbs_vostro
;
2783 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
2784 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2785 spec
->mixers
[spec
->num_mixers
++] = cxt5066_vostro_mixers
;
2786 spec
->port_d_mode
= 0;
2787 spec
->dell_vostro
= 1;
2788 spec
->mic_boost
= 3; /* default 30dB gain */
2789 snd_hda_attach_beep_device(codec
, 0x13);
2792 spec
->multiout
.dig_out_nid
= 0;
2794 /* input source automatically selected */
2795 spec
->input_mux
= NULL
;
2805 static struct hda_codec_preset snd_hda_preset_conexant
[] = {
2806 { .id
= 0x14f15045, .name
= "CX20549 (Venice)",
2807 .patch
= patch_cxt5045
},
2808 { .id
= 0x14f15047, .name
= "CX20551 (Waikiki)",
2809 .patch
= patch_cxt5047
},
2810 { .id
= 0x14f15051, .name
= "CX20561 (Hermosa)",
2811 .patch
= patch_cxt5051
},
2812 { .id
= 0x14f15066, .name
= "CX20582 (Pebble)",
2813 .patch
= patch_cxt5066
},
2814 { .id
= 0x14f15067, .name
= "CX20583 (Pebble HSF)",
2815 .patch
= patch_cxt5066
},
2819 MODULE_ALIAS("snd-hda-codec-id:14f15045");
2820 MODULE_ALIAS("snd-hda-codec-id:14f15047");
2821 MODULE_ALIAS("snd-hda-codec-id:14f15051");
2822 MODULE_ALIAS("snd-hda-codec-id:14f15066");
2823 MODULE_ALIAS("snd-hda-codec-id:14f15067");
2825 MODULE_LICENSE("GPL");
2826 MODULE_DESCRIPTION("Conexant HD-audio codec");
2828 static struct hda_codec_preset_list conexant_list
= {
2829 .preset
= snd_hda_preset_conexant
,
2830 .owner
= THIS_MODULE
,
2833 static int __init
patch_conexant_init(void)
2835 return snd_hda_add_codec_preset(&conexant_list
);
2838 static void __exit
patch_conexant_exit(void)
2840 snd_hda_delete_codec_preset(&conexant_list
);
2843 module_init(patch_conexant_init
)
2844 module_exit(patch_conexant_exit
)