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"
33 #define CXT_PIN_DIR_IN 0x00
34 #define CXT_PIN_DIR_OUT 0x01
35 #define CXT_PIN_DIR_INOUT 0x02
36 #define CXT_PIN_DIR_IN_NOMICBIAS 0x03
37 #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04
39 #define CONEXANT_HP_EVENT 0x37
40 #define CONEXANT_MIC_EVENT 0x38
42 /* Conexant 5051 specific */
44 #define CXT5051_SPDIF_OUT 0x1C
45 #define CXT5051_PORTB_EVENT 0x38
46 #define CXT5051_PORTC_EVENT 0x39
49 struct conexant_jack
{
53 struct snd_jack
*jack
;
57 struct conexant_spec
{
59 struct snd_kcontrol_new
*mixers
[5];
61 hda_nid_t vmaster_nid
;
63 const struct hda_verb
*init_verbs
[5]; /* initialization verbs
67 unsigned int num_init_verbs
;
70 struct hda_multi_out multiout
; /* playback set-up
71 * max_channels, dacs must be set
72 * dig_out_nid and hp_nid are optional
74 unsigned int cur_eapd
;
75 unsigned int hp_present
;
76 unsigned int no_auto_mic
;
77 unsigned int need_dac_fix
;
80 unsigned int num_adc_nids
;
82 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
84 unsigned int cur_adc_idx
;
86 unsigned int cur_adc_stream_tag
;
87 unsigned int cur_adc_format
;
90 const struct hda_input_mux
*input_mux
;
91 hda_nid_t
*capsrc_nids
;
92 unsigned int cur_mux
[3];
95 const struct hda_channel_mode
*channel_mode
;
99 struct hda_pcm pcm_rec
[2]; /* used in build_pcms() */
101 unsigned int spdif_route
;
104 struct snd_array jacks
;
106 /* dynamic controls, init_verbs and input_mux */
107 struct auto_pin_cfg autocfg
;
108 struct hda_input_mux private_imux
;
109 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
111 unsigned int dell_automute
;
112 unsigned int port_d_mode
;
113 unsigned char ext_mic_bias
;
116 static int conexant_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
117 struct hda_codec
*codec
,
118 struct snd_pcm_substream
*substream
)
120 struct conexant_spec
*spec
= codec
->spec
;
121 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
125 static int conexant_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
126 struct hda_codec
*codec
,
127 unsigned int stream_tag
,
129 struct snd_pcm_substream
*substream
)
131 struct conexant_spec
*spec
= codec
->spec
;
132 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
137 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
138 struct hda_codec
*codec
,
139 struct snd_pcm_substream
*substream
)
141 struct conexant_spec
*spec
= codec
->spec
;
142 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
148 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
149 struct hda_codec
*codec
,
150 struct snd_pcm_substream
*substream
)
152 struct conexant_spec
*spec
= codec
->spec
;
153 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
156 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
157 struct hda_codec
*codec
,
158 struct snd_pcm_substream
*substream
)
160 struct conexant_spec
*spec
= codec
->spec
;
161 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
164 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
165 struct hda_codec
*codec
,
166 unsigned int stream_tag
,
168 struct snd_pcm_substream
*substream
)
170 struct conexant_spec
*spec
= codec
->spec
;
171 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
179 static int conexant_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
180 struct hda_codec
*codec
,
181 unsigned int stream_tag
,
183 struct snd_pcm_substream
*substream
)
185 struct conexant_spec
*spec
= codec
->spec
;
186 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
187 stream_tag
, 0, format
);
191 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
192 struct hda_codec
*codec
,
193 struct snd_pcm_substream
*substream
)
195 struct conexant_spec
*spec
= codec
->spec
;
196 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
202 static struct hda_pcm_stream conexant_pcm_analog_playback
= {
206 .nid
= 0, /* fill later */
208 .open
= conexant_playback_pcm_open
,
209 .prepare
= conexant_playback_pcm_prepare
,
210 .cleanup
= conexant_playback_pcm_cleanup
214 static struct hda_pcm_stream conexant_pcm_analog_capture
= {
218 .nid
= 0, /* fill later */
220 .prepare
= conexant_capture_pcm_prepare
,
221 .cleanup
= conexant_capture_pcm_cleanup
226 static struct hda_pcm_stream conexant_pcm_digital_playback
= {
230 .nid
= 0, /* fill later */
232 .open
= conexant_dig_playback_pcm_open
,
233 .close
= conexant_dig_playback_pcm_close
,
234 .prepare
= conexant_dig_playback_pcm_prepare
238 static struct hda_pcm_stream conexant_pcm_digital_capture
= {
242 /* NID is set in alc_build_pcms */
245 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
246 struct hda_codec
*codec
,
247 unsigned int stream_tag
,
249 struct snd_pcm_substream
*substream
)
251 struct conexant_spec
*spec
= codec
->spec
;
252 spec
->cur_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
253 spec
->cur_adc_stream_tag
= stream_tag
;
254 spec
->cur_adc_format
= format
;
255 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
259 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
260 struct hda_codec
*codec
,
261 struct snd_pcm_substream
*substream
)
263 struct conexant_spec
*spec
= codec
->spec
;
264 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
269 static struct hda_pcm_stream cx5051_pcm_analog_capture
= {
273 .nid
= 0, /* fill later */
275 .prepare
= cx5051_capture_pcm_prepare
,
276 .cleanup
= cx5051_capture_pcm_cleanup
280 static int conexant_build_pcms(struct hda_codec
*codec
)
282 struct conexant_spec
*spec
= codec
->spec
;
283 struct hda_pcm
*info
= spec
->pcm_rec
;
286 codec
->pcm_info
= info
;
288 info
->name
= "CONEXANT Analog";
289 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = conexant_pcm_analog_playback
;
290 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
=
291 spec
->multiout
.max_channels
;
292 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
293 spec
->multiout
.dac_nids
[0];
294 if (codec
->vendor_id
== 0x14f15051)
295 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
296 cx5051_pcm_analog_capture
;
298 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
299 conexant_pcm_analog_capture
;
300 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
= spec
->num_adc_nids
;
301 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
303 if (spec
->multiout
.dig_out_nid
) {
306 info
->name
= "Conexant Digital";
307 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
308 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
309 conexant_pcm_digital_playback
;
310 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
311 spec
->multiout
.dig_out_nid
;
312 if (spec
->dig_in_nid
) {
313 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
314 conexant_pcm_digital_capture
;
315 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
323 static int conexant_mux_enum_info(struct snd_kcontrol
*kcontrol
,
324 struct snd_ctl_elem_info
*uinfo
)
326 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
327 struct conexant_spec
*spec
= codec
->spec
;
329 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
332 static int conexant_mux_enum_get(struct snd_kcontrol
*kcontrol
,
333 struct snd_ctl_elem_value
*ucontrol
)
335 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
336 struct conexant_spec
*spec
= codec
->spec
;
337 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
339 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
343 static int conexant_mux_enum_put(struct snd_kcontrol
*kcontrol
,
344 struct snd_ctl_elem_value
*ucontrol
)
346 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
347 struct conexant_spec
*spec
= codec
->spec
;
348 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
350 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
351 spec
->capsrc_nids
[adc_idx
],
352 &spec
->cur_mux
[adc_idx
]);
355 #ifdef CONFIG_SND_HDA_INPUT_JACK
356 static void conexant_free_jack_priv(struct snd_jack
*jack
)
358 struct conexant_jack
*jacks
= jack
->private_data
;
363 static int conexant_add_jack(struct hda_codec
*codec
,
364 hda_nid_t nid
, int type
)
366 struct conexant_spec
*spec
;
367 struct conexant_jack
*jack
;
372 snd_array_init(&spec
->jacks
, sizeof(*jack
), 32);
374 jack
= spec
->jacks
.list
;
375 for (i
= 0; i
< spec
->jacks
.used
; i
++, jack
++)
376 if (jack
->nid
== nid
)
377 return 0 ; /* already present */
379 jack
= snd_array_new(&spec
->jacks
);
380 name
= (type
== SND_JACK_HEADPHONE
) ? "Headphone" : "Mic" ;
388 err
= snd_jack_new(codec
->bus
->card
, name
, type
, &jack
->jack
);
391 jack
->jack
->private_data
= jack
;
392 jack
->jack
->private_free
= conexant_free_jack_priv
;
396 static void conexant_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
398 struct conexant_spec
*spec
= codec
->spec
;
399 struct conexant_jack
*jacks
= spec
->jacks
.list
;
403 for (i
= 0; i
< spec
->jacks
.used
; i
++) {
404 if (jacks
->nid
== nid
) {
405 unsigned int present
;
406 present
= snd_hda_codec_read(codec
, nid
, 0,
407 AC_VERB_GET_PIN_SENSE
, 0) &
408 AC_PINSENSE_PRESENCE
;
410 present
= (present
) ? jacks
->type
: 0 ;
412 snd_jack_report(jacks
->jack
,
420 static int conexant_init_jacks(struct hda_codec
*codec
)
422 struct conexant_spec
*spec
= codec
->spec
;
425 for (i
= 0; i
< spec
->num_init_verbs
; i
++) {
426 const struct hda_verb
*hv
;
428 hv
= spec
->init_verbs
[i
];
431 switch (hv
->param
^ AC_USRSP_EN
) {
432 case CONEXANT_HP_EVENT
:
433 err
= conexant_add_jack(codec
, hv
->nid
,
435 conexant_report_jack(codec
, hv
->nid
);
437 case CXT5051_PORTC_EVENT
:
438 case CONEXANT_MIC_EVENT
:
439 err
= conexant_add_jack(codec
, hv
->nid
,
440 SND_JACK_MICROPHONE
);
441 conexant_report_jack(codec
, hv
->nid
);
453 static inline void conexant_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
457 static inline int conexant_init_jacks(struct hda_codec
*codec
)
463 static int conexant_init(struct hda_codec
*codec
)
465 struct conexant_spec
*spec
= codec
->spec
;
468 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
469 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
473 static void conexant_free(struct hda_codec
*codec
)
475 #ifdef CONFIG_SND_HDA_INPUT_JACK
476 struct conexant_spec
*spec
= codec
->spec
;
477 if (spec
->jacks
.list
) {
478 struct conexant_jack
*jacks
= spec
->jacks
.list
;
480 for (i
= 0; i
< spec
->jacks
.used
; i
++, jacks
++) {
482 snd_device_free(codec
->bus
->card
, jacks
->jack
);
484 snd_array_free(&spec
->jacks
);
490 static struct snd_kcontrol_new cxt_capture_mixers
[] = {
492 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
493 .name
= "Capture Source",
494 .info
= conexant_mux_enum_info
,
495 .get
= conexant_mux_enum_get
,
496 .put
= conexant_mux_enum_put
501 static const char *slave_vols
[] = {
502 "Headphone Playback Volume",
503 "Speaker Playback Volume",
507 static const char *slave_sws
[] = {
508 "Headphone Playback Switch",
509 "Speaker Playback Switch",
513 static int conexant_build_controls(struct hda_codec
*codec
)
515 struct conexant_spec
*spec
= codec
->spec
;
519 for (i
= 0; i
< spec
->num_mixers
; i
++) {
520 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
524 if (spec
->multiout
.dig_out_nid
) {
525 err
= snd_hda_create_spdif_out_ctls(codec
,
526 spec
->multiout
.dig_out_nid
);
529 err
= snd_hda_create_spdif_share_sw(codec
,
533 spec
->multiout
.share_spdif
= 1;
535 if (spec
->dig_in_nid
) {
536 err
= snd_hda_create_spdif_in_ctls(codec
,spec
->dig_in_nid
);
541 /* if we have no master control, let's create it */
542 if (spec
->vmaster_nid
&&
543 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
544 unsigned int vmaster_tlv
[4];
545 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
546 HDA_OUTPUT
, vmaster_tlv
);
547 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
548 vmaster_tlv
, slave_vols
);
552 if (spec
->vmaster_nid
&&
553 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
554 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
560 if (spec
->input_mux
) {
561 err
= snd_hda_add_new_ctls(codec
, cxt_capture_mixers
);
569 static struct hda_codec_ops conexant_patch_ops
= {
570 .build_controls
= conexant_build_controls
,
571 .build_pcms
= conexant_build_pcms
,
572 .init
= conexant_init
,
573 .free
= conexant_free
,
578 * the private value = nid | (invert << 8)
581 #define cxt_eapd_info snd_ctl_boolean_mono_info
583 static int cxt_eapd_get(struct snd_kcontrol
*kcontrol
,
584 struct snd_ctl_elem_value
*ucontrol
)
586 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
587 struct conexant_spec
*spec
= codec
->spec
;
588 int invert
= (kcontrol
->private_value
>> 8) & 1;
590 ucontrol
->value
.integer
.value
[0] = !spec
->cur_eapd
;
592 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
597 static int cxt_eapd_put(struct snd_kcontrol
*kcontrol
,
598 struct snd_ctl_elem_value
*ucontrol
)
600 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
601 struct conexant_spec
*spec
= codec
->spec
;
602 int invert
= (kcontrol
->private_value
>> 8) & 1;
603 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
606 eapd
= !!ucontrol
->value
.integer
.value
[0];
609 if (eapd
== spec
->cur_eapd
)
612 spec
->cur_eapd
= eapd
;
613 snd_hda_codec_write_cache(codec
, nid
,
614 0, AC_VERB_SET_EAPD_BTLENABLE
,
619 /* controls for test mode */
620 #ifdef CONFIG_SND_DEBUG
622 #define CXT_EAPD_SWITCH(xname, nid, mask) \
623 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
624 .info = cxt_eapd_info, \
625 .get = cxt_eapd_get, \
626 .put = cxt_eapd_put, \
627 .private_value = nid | (mask<<16) }
631 static int conexant_ch_mode_info(struct snd_kcontrol
*kcontrol
,
632 struct snd_ctl_elem_info
*uinfo
)
634 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
635 struct conexant_spec
*spec
= codec
->spec
;
636 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
637 spec
->num_channel_mode
);
640 static int conexant_ch_mode_get(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 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
646 spec
->num_channel_mode
,
647 spec
->multiout
.max_channels
);
650 static int conexant_ch_mode_put(struct snd_kcontrol
*kcontrol
,
651 struct snd_ctl_elem_value
*ucontrol
)
653 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
654 struct conexant_spec
*spec
= codec
->spec
;
655 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
656 spec
->num_channel_mode
,
657 &spec
->multiout
.max_channels
);
658 if (err
>= 0 && spec
->need_dac_fix
)
659 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
663 #define CXT_PIN_MODE(xname, nid, dir) \
664 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
665 .info = conexant_ch_mode_info, \
666 .get = conexant_ch_mode_get, \
667 .put = conexant_ch_mode_put, \
668 .private_value = nid | (dir<<16) }
670 #endif /* CONFIG_SND_DEBUG */
672 /* Conexant 5045 specific */
674 static hda_nid_t cxt5045_dac_nids
[1] = { 0x19 };
675 static hda_nid_t cxt5045_adc_nids
[1] = { 0x1a };
676 static hda_nid_t cxt5045_capsrc_nids
[1] = { 0x1a };
677 #define CXT5045_SPDIF_OUT 0x18
679 static struct hda_channel_mode cxt5045_modes
[1] = {
683 static struct hda_input_mux cxt5045_capture_source
= {
691 static struct hda_input_mux cxt5045_capture_source_benq
= {
702 static struct hda_input_mux cxt5045_capture_source_hp530
= {
710 /* turn on/off EAPD (+ mute HP) as a master switch */
711 static int cxt5045_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
712 struct snd_ctl_elem_value
*ucontrol
)
714 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
715 struct conexant_spec
*spec
= codec
->spec
;
718 if (!cxt_eapd_put(kcontrol
, ucontrol
))
721 /* toggle internal speakers mute depending of presence of
724 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
725 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
728 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
729 snd_hda_codec_amp_stereo(codec
, 0x11, HDA_OUTPUT
, 0,
734 /* bind volumes of both NID 0x10 and 0x11 */
735 static struct hda_bind_ctls cxt5045_hp_bind_master_vol
= {
736 .ops
= &snd_hda_bind_vol
,
738 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT
),
739 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT
),
744 /* toggle input of built-in and mic jack appropriately */
745 static void cxt5045_hp_automic(struct hda_codec
*codec
)
747 static struct hda_verb mic_jack_on
[] = {
748 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
749 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
752 static struct hda_verb mic_jack_off
[] = {
753 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
754 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
757 unsigned int present
;
759 present
= snd_hda_codec_read(codec
, 0x12, 0,
760 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
762 snd_hda_sequence_write(codec
, mic_jack_on
);
764 snd_hda_sequence_write(codec
, mic_jack_off
);
768 /* mute internal speaker if HP is plugged */
769 static void cxt5045_hp_automute(struct hda_codec
*codec
)
771 struct conexant_spec
*spec
= codec
->spec
;
774 spec
->hp_present
= snd_hda_codec_read(codec
, 0x11, 0,
775 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
777 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
778 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
782 /* unsolicited event for HP jack sensing */
783 static void cxt5045_hp_unsol_event(struct hda_codec
*codec
,
788 case CONEXANT_HP_EVENT
:
789 cxt5045_hp_automute(codec
);
791 case CONEXANT_MIC_EVENT
:
792 cxt5045_hp_automic(codec
);
798 static struct snd_kcontrol_new cxt5045_mixers
[] = {
799 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
800 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
801 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
802 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
803 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
804 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
805 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
806 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
807 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
808 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
809 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
811 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
812 .name
= "Master Playback Switch",
813 .info
= cxt_eapd_info
,
815 .put
= cxt5045_hp_master_sw_put
,
816 .private_value
= 0x10,
822 static struct snd_kcontrol_new cxt5045_benq_mixers
[] = {
823 HDA_CODEC_VOLUME("CD Capture Volume", 0x1a, 0x04, HDA_INPUT
),
824 HDA_CODEC_MUTE("CD Capture Switch", 0x1a, 0x04, HDA_INPUT
),
825 HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x4, HDA_INPUT
),
826 HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x4, HDA_INPUT
),
828 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT
),
829 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT
),
830 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT
),
831 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT
),
833 HDA_CODEC_VOLUME("Mixer Capture Volume", 0x1a, 0x0, HDA_INPUT
),
834 HDA_CODEC_MUTE("Mixer Capture Switch", 0x1a, 0x0, HDA_INPUT
),
839 static struct snd_kcontrol_new cxt5045_mixers_hp530
[] = {
840 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
841 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
842 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
843 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x01, 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("Int Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
847 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
848 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
849 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x1, 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 struct hda_verb cxt5045_init_verbs
[] = {
865 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
866 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
868 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
869 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
870 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
871 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
872 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
873 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
874 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
875 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
876 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
877 /* Record selector: Int mic */
878 {0x1a, AC_VERB_SET_CONNECT_SEL
,0x1},
879 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
880 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
881 /* SPDIF route: PCM */
882 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
883 { 0x13, AC_VERB_SET_CONNECT_SEL
, 0x0 },
885 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2 }, /* default on */
889 static struct hda_verb cxt5045_benq_init_verbs
[] = {
891 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
892 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
893 /* Line In,HP, Amp */
894 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
895 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
896 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
897 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
898 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
899 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
900 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
901 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
902 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
903 /* Record selector: Int mic */
904 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x1},
905 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
906 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
907 /* SPDIF route: PCM */
908 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
909 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0},
911 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
915 static struct hda_verb cxt5045_hp_sense_init_verbs
[] = {
916 /* pin sensing on HP jack */
917 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
921 static struct hda_verb cxt5045_mic_sense_init_verbs
[] = {
922 /* pin sensing on HP jack */
923 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
927 #ifdef CONFIG_SND_DEBUG
928 /* Test configuration for debugging, modelled after the ALC260 test
931 static struct hda_input_mux cxt5045_test_capture_source
= {
936 { "LINE1 pin", 0x2 },
937 { "HP-OUT pin", 0x3 },
942 static struct snd_kcontrol_new cxt5045_test_mixer
[] = {
944 /* Output controls */
945 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
946 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
947 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
948 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
949 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
950 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
952 /* Modes for retasking pin widgets */
953 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT
),
954 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT
),
956 /* EAPD Switch Control */
957 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
959 /* Loopback mixer controls */
961 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT
),
962 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT
),
963 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT
),
964 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT
),
965 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT
),
966 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT
),
967 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT
),
968 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT
),
969 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT
),
970 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT
),
972 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
973 .name
= "Input Source",
974 .info
= conexant_mux_enum_info
,
975 .get
= conexant_mux_enum_get
,
976 .put
= conexant_mux_enum_put
,
978 /* Audio input controls */
979 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT
),
980 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT
),
981 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT
),
982 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT
),
983 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT
),
984 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT
),
985 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT
),
986 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT
),
987 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT
),
988 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT
),
992 static struct hda_verb cxt5045_test_init_verbs
[] = {
993 /* Set connections */
994 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
995 { 0x11, AC_VERB_SET_CONNECT_SEL
, 0x0 },
996 { 0x12, AC_VERB_SET_CONNECT_SEL
, 0x0 },
997 /* Enable retasking pins as output, initially without power amp */
998 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
999 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1001 /* Disable digital (SPDIF) pins initially, but users can enable
1002 * them via a mixer switch. In the case of SPDIF-out, this initverb
1003 * payload also sets the generation to 0, output to be in "consumer"
1004 * PCM format, copyright asserted, no pre-emphasis and no validity
1007 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1008 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1010 /* Start with output sum widgets muted and their output gains at min */
1011 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1012 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1014 /* Unmute retasking pin widget output buffers since the default
1015 * state appears to be output. As the pin mode is changed by the
1016 * user the pin mode control will take care of enabling the pin's
1017 * input/output buffers as needed.
1019 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1020 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1022 /* Mute capture amp left and right */
1023 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1025 /* Set ADC connection select to match default mixer setting (mic1
1028 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1029 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x00},
1031 /* Mute all inputs to mixer widget (even unconnected ones) */
1032 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* Mixer pin */
1033 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* Mic1 pin */
1034 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* Line pin */
1035 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* HP pin */
1036 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1043 /* initialize jack-sensing, too */
1044 static int cxt5045_init(struct hda_codec
*codec
)
1046 conexant_init(codec
);
1047 cxt5045_hp_automute(codec
);
1053 CXT5045_LAPTOP_HPSENSE
,
1054 CXT5045_LAPTOP_MICSENSE
,
1055 CXT5045_LAPTOP_HPMICSENSE
,
1057 CXT5045_LAPTOP_HP530
,
1058 #ifdef CONFIG_SND_DEBUG
1064 static const char *cxt5045_models
[CXT5045_MODELS
] = {
1065 [CXT5045_LAPTOP_HPSENSE
] = "laptop-hpsense",
1066 [CXT5045_LAPTOP_MICSENSE
] = "laptop-micsense",
1067 [CXT5045_LAPTOP_HPMICSENSE
] = "laptop-hpmicsense",
1068 [CXT5045_BENQ
] = "benq",
1069 [CXT5045_LAPTOP_HP530
] = "laptop-hp530",
1070 #ifdef CONFIG_SND_DEBUG
1071 [CXT5045_TEST
] = "test",
1075 static struct snd_pci_quirk cxt5045_cfg_tbl
[] = {
1076 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530
),
1077 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1078 CXT5045_LAPTOP_HPSENSE
),
1079 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE
),
1080 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ
),
1081 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE
),
1082 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE
),
1083 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
1084 CXT5045_LAPTOP_HPMICSENSE
),
1085 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1086 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1087 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1088 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
1089 CXT5045_LAPTOP_HPMICSENSE
),
1090 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE
),
1094 static int patch_cxt5045(struct hda_codec
*codec
)
1096 struct conexant_spec
*spec
;
1099 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1103 codec
->pin_amp_workaround
= 1;
1105 spec
->multiout
.max_channels
= 2;
1106 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5045_dac_nids
);
1107 spec
->multiout
.dac_nids
= cxt5045_dac_nids
;
1108 spec
->multiout
.dig_out_nid
= CXT5045_SPDIF_OUT
;
1109 spec
->num_adc_nids
= 1;
1110 spec
->adc_nids
= cxt5045_adc_nids
;
1111 spec
->capsrc_nids
= cxt5045_capsrc_nids
;
1112 spec
->input_mux
= &cxt5045_capture_source
;
1113 spec
->num_mixers
= 1;
1114 spec
->mixers
[0] = cxt5045_mixers
;
1115 spec
->num_init_verbs
= 1;
1116 spec
->init_verbs
[0] = cxt5045_init_verbs
;
1117 spec
->spdif_route
= 0;
1118 spec
->num_channel_mode
= ARRAY_SIZE(cxt5045_modes
),
1119 spec
->channel_mode
= cxt5045_modes
,
1122 codec
->patch_ops
= conexant_patch_ops
;
1124 board_config
= snd_hda_check_board_config(codec
, CXT5045_MODELS
,
1127 switch (board_config
) {
1128 case CXT5045_LAPTOP_HPSENSE
:
1129 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1130 spec
->input_mux
= &cxt5045_capture_source
;
1131 spec
->num_init_verbs
= 2;
1132 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1133 spec
->mixers
[0] = cxt5045_mixers
;
1134 codec
->patch_ops
.init
= cxt5045_init
;
1136 case CXT5045_LAPTOP_MICSENSE
:
1137 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1138 spec
->input_mux
= &cxt5045_capture_source
;
1139 spec
->num_init_verbs
= 2;
1140 spec
->init_verbs
[1] = cxt5045_mic_sense_init_verbs
;
1141 spec
->mixers
[0] = cxt5045_mixers
;
1142 codec
->patch_ops
.init
= cxt5045_init
;
1145 case CXT5045_LAPTOP_HPMICSENSE
:
1146 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1147 spec
->input_mux
= &cxt5045_capture_source
;
1148 spec
->num_init_verbs
= 3;
1149 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1150 spec
->init_verbs
[2] = cxt5045_mic_sense_init_verbs
;
1151 spec
->mixers
[0] = cxt5045_mixers
;
1152 codec
->patch_ops
.init
= cxt5045_init
;
1155 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1156 spec
->input_mux
= &cxt5045_capture_source_benq
;
1157 spec
->num_init_verbs
= 1;
1158 spec
->init_verbs
[0] = cxt5045_benq_init_verbs
;
1159 spec
->mixers
[0] = cxt5045_mixers
;
1160 spec
->mixers
[1] = cxt5045_benq_mixers
;
1161 spec
->num_mixers
= 2;
1162 codec
->patch_ops
.init
= cxt5045_init
;
1164 case CXT5045_LAPTOP_HP530
:
1165 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1166 spec
->input_mux
= &cxt5045_capture_source_hp530
;
1167 spec
->num_init_verbs
= 2;
1168 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1169 spec
->mixers
[0] = cxt5045_mixers_hp530
;
1170 codec
->patch_ops
.init
= cxt5045_init
;
1172 #ifdef CONFIG_SND_DEBUG
1174 spec
->input_mux
= &cxt5045_test_capture_source
;
1175 spec
->mixers
[0] = cxt5045_test_mixer
;
1176 spec
->init_verbs
[0] = cxt5045_test_init_verbs
;
1182 switch (codec
->subsystem_id
>> 16) {
1187 /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have
1188 * really bad sound over 0dB on NID 0x17. Fix max PCM level to
1189 * 0 dB (originally it has 0x2b steps with 0dB offset 0x14)
1191 snd_hda_override_amp_caps(codec
, 0x17, HDA_INPUT
,
1192 (0x14 << AC_AMPCAP_OFFSET_SHIFT
) |
1193 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1194 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1195 (1 << AC_AMPCAP_MUTE_SHIFT
));
1203 /* Conexant 5047 specific */
1204 #define CXT5047_SPDIF_OUT 0x11
1206 static hda_nid_t cxt5047_dac_nids
[1] = { 0x10 }; /* 0x1c */
1207 static hda_nid_t cxt5047_adc_nids
[1] = { 0x12 };
1208 static hda_nid_t cxt5047_capsrc_nids
[1] = { 0x1a };
1210 static struct hda_channel_mode cxt5047_modes
[1] = {
1214 static struct hda_input_mux cxt5047_toshiba_capture_source
= {
1222 /* turn on/off EAPD (+ mute HP) as a master switch */
1223 static int cxt5047_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1224 struct snd_ctl_elem_value
*ucontrol
)
1226 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1227 struct conexant_spec
*spec
= codec
->spec
;
1230 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1233 /* toggle internal speakers mute depending of presence of
1234 * the headphone jack
1236 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
1237 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1238 * pin widgets unlike other codecs. In this case, we need to
1239 * set index 0x01 for the volume from the mixer amp 0x19.
1241 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1242 HDA_AMP_MUTE
, bits
);
1243 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
1244 snd_hda_codec_amp_stereo(codec
, 0x13, HDA_OUTPUT
, 0,
1245 HDA_AMP_MUTE
, bits
);
1249 /* mute internal speaker if HP is plugged */
1250 static void cxt5047_hp_automute(struct hda_codec
*codec
)
1252 struct conexant_spec
*spec
= codec
->spec
;
1255 spec
->hp_present
= snd_hda_codec_read(codec
, 0x13, 0,
1256 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
1258 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
1259 /* See the note in cxt5047_hp_master_sw_put */
1260 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1261 HDA_AMP_MUTE
, bits
);
1264 /* toggle input of built-in and mic jack appropriately */
1265 static void cxt5047_hp_automic(struct hda_codec
*codec
)
1267 static struct hda_verb mic_jack_on
[] = {
1268 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1269 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1272 static struct hda_verb mic_jack_off
[] = {
1273 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1274 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1277 unsigned int present
;
1279 present
= snd_hda_codec_read(codec
, 0x15, 0,
1280 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
1282 snd_hda_sequence_write(codec
, mic_jack_on
);
1284 snd_hda_sequence_write(codec
, mic_jack_off
);
1287 /* unsolicited event for HP jack sensing */
1288 static void cxt5047_hp_unsol_event(struct hda_codec
*codec
,
1291 switch (res
>> 26) {
1292 case CONEXANT_HP_EVENT
:
1293 cxt5047_hp_automute(codec
);
1295 case CONEXANT_MIC_EVENT
:
1296 cxt5047_hp_automic(codec
);
1301 static struct snd_kcontrol_new cxt5047_base_mixers
[] = {
1302 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT
),
1303 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT
),
1304 HDA_CODEC_VOLUME("Mic Boost", 0x1a, 0x0, HDA_OUTPUT
),
1305 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT
),
1306 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT
),
1307 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT
),
1308 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT
),
1310 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1311 .name
= "Master Playback Switch",
1312 .info
= cxt_eapd_info
,
1313 .get
= cxt_eapd_get
,
1314 .put
= cxt5047_hp_master_sw_put
,
1315 .private_value
= 0x13,
1321 static struct snd_kcontrol_new cxt5047_hp_spk_mixers
[] = {
1322 /* See the note in cxt5047_hp_master_sw_put */
1323 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT
),
1324 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1328 static struct snd_kcontrol_new cxt5047_hp_only_mixers
[] = {
1329 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1333 static struct hda_verb cxt5047_init_verbs
[] = {
1334 /* Line in, Mic, Built-in Mic */
1335 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1336 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1337 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1339 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1340 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* mixer(0x19) */
1341 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mixer(0x19) */
1342 /* Record selector: Mic */
1343 {0x12, AC_VERB_SET_CONNECT_SEL
,0x03},
1344 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
,
1345 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
1346 {0x1A, AC_VERB_SET_CONNECT_SEL
,0x02},
1347 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1348 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x00},
1349 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1350 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x03},
1351 /* SPDIF route: PCM */
1352 { 0x18, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1353 /* Enable unsolicited events */
1354 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
1355 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1359 /* configuration for Toshiba Laptops */
1360 static struct hda_verb cxt5047_toshiba_init_verbs
[] = {
1361 {0x13, AC_VERB_SET_EAPD_BTLENABLE
, 0x0}, /* default off */
1365 /* Test configuration for debugging, modelled after the ALC260 test
1368 #ifdef CONFIG_SND_DEBUG
1369 static struct hda_input_mux cxt5047_test_capture_source
= {
1372 { "LINE1 pin", 0x0 },
1373 { "MIC1 pin", 0x1 },
1374 { "MIC2 pin", 0x2 },
1379 static struct snd_kcontrol_new cxt5047_test_mixer
[] = {
1381 /* Output only controls */
1382 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT
),
1383 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT
),
1384 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT
),
1385 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT
),
1386 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1387 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1388 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1389 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1390 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT
),
1391 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT
),
1392 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
1393 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
1395 /* Modes for retasking pin widgets */
1396 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT
),
1397 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT
),
1399 /* EAPD Switch Control */
1400 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1402 /* Loopback mixer controls */
1403 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT
),
1404 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT
),
1405 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT
),
1406 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT
),
1407 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT
),
1408 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT
),
1409 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT
),
1410 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT
),
1412 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT
),
1413 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT
),
1414 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT
),
1415 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT
),
1416 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT
),
1417 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT
),
1418 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT
),
1419 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT
),
1421 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1422 .name
= "Input Source",
1423 .info
= conexant_mux_enum_info
,
1424 .get
= conexant_mux_enum_get
,
1425 .put
= conexant_mux_enum_put
,
1427 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT
),
1428 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT
),
1429 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT
),
1430 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT
),
1431 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT
),
1432 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT
),
1433 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT
),
1434 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT
),
1435 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT
),
1436 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT
),
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;
1594 switch (codec
->subsystem_id
>> 16) {
1596 /* HP laptops have really bad sound over 0 dB on NID 0x10.
1597 * Fix max PCM level to 0 dB (originally it has 0x1e steps
1598 * with 0 dB offset 0x17)
1600 snd_hda_override_amp_caps(codec
, 0x10, HDA_INPUT
,
1601 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
1602 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1603 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1604 (1 << AC_AMPCAP_MUTE_SHIFT
));
1611 /* Conexant 5051 specific */
1612 static hda_nid_t cxt5051_dac_nids
[1] = { 0x10 };
1613 static hda_nid_t cxt5051_adc_nids
[2] = { 0x14, 0x15 };
1615 static struct hda_channel_mode cxt5051_modes
[1] = {
1619 static void cxt5051_update_speaker(struct hda_codec
*codec
)
1621 struct conexant_spec
*spec
= codec
->spec
;
1622 unsigned int pinctl
;
1623 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1624 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1628 /* turn on/off EAPD (+ mute HP) as a master switch */
1629 static int cxt5051_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1630 struct snd_ctl_elem_value
*ucontrol
)
1632 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1634 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1636 cxt5051_update_speaker(codec
);
1640 /* toggle input of built-in and mic jack appropriately */
1641 static void cxt5051_portb_automic(struct hda_codec
*codec
)
1643 struct conexant_spec
*spec
= codec
->spec
;
1644 unsigned int present
;
1646 if (spec
->no_auto_mic
)
1648 present
= snd_hda_codec_read(codec
, 0x17, 0,
1649 AC_VERB_GET_PIN_SENSE
, 0) &
1650 AC_PINSENSE_PRESENCE
;
1651 snd_hda_codec_write(codec
, 0x14, 0,
1652 AC_VERB_SET_CONNECT_SEL
,
1653 present
? 0x01 : 0x00);
1656 /* switch the current ADC according to the jack state */
1657 static void cxt5051_portc_automic(struct hda_codec
*codec
)
1659 struct conexant_spec
*spec
= codec
->spec
;
1660 unsigned int present
;
1663 if (spec
->no_auto_mic
)
1665 present
= snd_hda_codec_read(codec
, 0x18, 0,
1666 AC_VERB_GET_PIN_SENSE
, 0) &
1667 AC_PINSENSE_PRESENCE
;
1669 spec
->cur_adc_idx
= 1;
1671 spec
->cur_adc_idx
= 0;
1672 new_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
1673 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
1674 /* stream is running, let's swap the current ADC */
1675 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
1676 spec
->cur_adc
= new_adc
;
1677 snd_hda_codec_setup_stream(codec
, new_adc
,
1678 spec
->cur_adc_stream_tag
, 0,
1679 spec
->cur_adc_format
);
1683 /* mute internal speaker if HP is plugged */
1684 static void cxt5051_hp_automute(struct hda_codec
*codec
)
1686 struct conexant_spec
*spec
= codec
->spec
;
1688 spec
->hp_present
= snd_hda_codec_read(codec
, 0x16, 0,
1689 AC_VERB_GET_PIN_SENSE
, 0) &
1690 AC_PINSENSE_PRESENCE
;
1691 cxt5051_update_speaker(codec
);
1694 /* unsolicited event for HP jack sensing */
1695 static void cxt5051_hp_unsol_event(struct hda_codec
*codec
,
1698 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
1699 switch (res
>> 26) {
1700 case CONEXANT_HP_EVENT
:
1701 cxt5051_hp_automute(codec
);
1703 case CXT5051_PORTB_EVENT
:
1704 cxt5051_portb_automic(codec
);
1706 case CXT5051_PORTC_EVENT
:
1707 cxt5051_portc_automic(codec
);
1710 conexant_report_jack(codec
, nid
);
1713 static struct snd_kcontrol_new cxt5051_mixers
[] = {
1714 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1715 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1716 HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT
),
1717 HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT
),
1718 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT
),
1719 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT
),
1720 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1722 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1723 .name
= "Master Playback Switch",
1724 .info
= cxt_eapd_info
,
1725 .get
= cxt_eapd_get
,
1726 .put
= cxt5051_hp_master_sw_put
,
1727 .private_value
= 0x1a,
1733 static struct snd_kcontrol_new cxt5051_hp_mixers
[] = {
1734 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1735 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1736 HDA_CODEC_VOLUME("External Mic Volume", 0x15, 0x00, HDA_INPUT
),
1737 HDA_CODEC_MUTE("External Mic Switch", 0x15, 0x00, HDA_INPUT
),
1738 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1740 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1741 .name
= "Master Playback Switch",
1742 .info
= cxt_eapd_info
,
1743 .get
= cxt_eapd_get
,
1744 .put
= cxt5051_hp_master_sw_put
,
1745 .private_value
= 0x1a,
1751 static struct snd_kcontrol_new cxt5051_hp_dv6736_mixers
[] = {
1752 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x00, HDA_INPUT
),
1753 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x00, HDA_INPUT
),
1754 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1756 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1757 .name
= "Master Playback Switch",
1758 .info
= cxt_eapd_info
,
1759 .get
= cxt_eapd_get
,
1760 .put
= cxt5051_hp_master_sw_put
,
1761 .private_value
= 0x1a,
1767 static struct hda_verb cxt5051_init_verbs
[] = {
1769 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1770 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1771 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1772 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1773 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1774 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1776 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1777 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1779 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1780 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1782 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1783 /* Record selector: Int mic */
1784 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1785 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1786 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1787 /* SPDIF route: PCM */
1788 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1790 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1791 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1792 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTB_EVENT
},
1793 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTC_EVENT
},
1797 static struct hda_verb cxt5051_hp_dv6736_init_verbs
[] = {
1799 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1800 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1801 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1802 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1804 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1805 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1807 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1808 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1810 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1811 /* Record selector: Int mic */
1812 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1813 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1814 /* SPDIF route: PCM */
1815 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1817 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1818 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1819 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTB_EVENT
},
1823 static struct hda_verb cxt5051_lenovo_x200_init_verbs
[] = {
1825 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1826 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1827 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1828 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1829 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1830 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1832 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1833 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1835 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1836 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1838 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1839 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00},
1841 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1842 /* Record selector: Int mic */
1843 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1844 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1845 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1846 /* SPDIF route: PCM */
1847 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1849 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1850 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1851 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTB_EVENT
},
1852 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTC_EVENT
},
1853 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1857 /* initialize jack-sensing, too */
1858 static int cxt5051_init(struct hda_codec
*codec
)
1860 conexant_init(codec
);
1861 conexant_init_jacks(codec
);
1862 if (codec
->patch_ops
.unsol_event
) {
1863 cxt5051_hp_automute(codec
);
1864 cxt5051_portb_automic(codec
);
1865 cxt5051_portc_automic(codec
);
1872 CXT5051_LAPTOP
, /* Laptops w/ EAPD support */
1873 CXT5051_HP
, /* no docking */
1874 CXT5051_HP_DV6736
, /* HP without mic switch */
1875 CXT5051_LENOVO_X200
, /* Lenovo X200 laptop */
1879 static const char *cxt5051_models
[CXT5051_MODELS
] = {
1880 [CXT5051_LAPTOP
] = "laptop",
1881 [CXT5051_HP
] = "hp",
1882 [CXT5051_HP_DV6736
] = "hp-dv6736",
1883 [CXT5051_LENOVO_X200
] = "lenovo-x200",
1886 static struct snd_pci_quirk cxt5051_cfg_tbl
[] = {
1887 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736
),
1888 SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP
),
1889 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1891 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP
),
1892 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200
),
1896 static int patch_cxt5051(struct hda_codec
*codec
)
1898 struct conexant_spec
*spec
;
1901 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1905 codec
->pin_amp_workaround
= 1;
1907 codec
->patch_ops
= conexant_patch_ops
;
1908 codec
->patch_ops
.init
= cxt5051_init
;
1910 spec
->multiout
.max_channels
= 2;
1911 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5051_dac_nids
);
1912 spec
->multiout
.dac_nids
= cxt5051_dac_nids
;
1913 spec
->multiout
.dig_out_nid
= CXT5051_SPDIF_OUT
;
1914 spec
->num_adc_nids
= 1; /* not 2; via auto-mic switch */
1915 spec
->adc_nids
= cxt5051_adc_nids
;
1916 spec
->num_mixers
= 1;
1917 spec
->mixers
[0] = cxt5051_mixers
;
1918 spec
->num_init_verbs
= 1;
1919 spec
->init_verbs
[0] = cxt5051_init_verbs
;
1920 spec
->spdif_route
= 0;
1921 spec
->num_channel_mode
= ARRAY_SIZE(cxt5051_modes
);
1922 spec
->channel_mode
= cxt5051_modes
;
1924 spec
->cur_adc_idx
= 0;
1926 codec
->patch_ops
.unsol_event
= cxt5051_hp_unsol_event
;
1928 board_config
= snd_hda_check_board_config(codec
, CXT5051_MODELS
,
1931 switch (board_config
) {
1933 spec
->mixers
[0] = cxt5051_hp_mixers
;
1935 case CXT5051_HP_DV6736
:
1936 spec
->init_verbs
[0] = cxt5051_hp_dv6736_init_verbs
;
1937 spec
->mixers
[0] = cxt5051_hp_dv6736_mixers
;
1938 spec
->no_auto_mic
= 1;
1940 case CXT5051_LENOVO_X200
:
1941 spec
->init_verbs
[0] = cxt5051_lenovo_x200_init_verbs
;
1948 /* Conexant 5066 specific */
1950 static hda_nid_t cxt5066_dac_nids
[1] = { 0x10 };
1951 static hda_nid_t cxt5066_adc_nids
[3] = { 0x14, 0x15, 0x16 };
1952 static hda_nid_t cxt5066_capsrc_nids
[1] = { 0x17 };
1953 #define CXT5066_SPDIF_OUT 0x21
1955 /* OLPC's microphone port is DC coupled for use with external sensors,
1956 * therefore we use a 50% mic bias in order to center the input signal with
1957 * the DC input range of the codec. */
1958 #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50
1960 static struct hda_channel_mode cxt5066_modes
[1] = {
1964 static void cxt5066_update_speaker(struct hda_codec
*codec
)
1966 struct conexant_spec
*spec
= codec
->spec
;
1967 unsigned int pinctl
;
1969 snd_printdd("CXT5066: update speaker, hp_present=%d\n",
1973 pinctl
= ((spec
->hp_present
& 1) && spec
->cur_eapd
) ? PIN_HP
: 0;
1974 snd_hda_codec_write(codec
, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1977 /* Port D (HP/LO) */
1978 pinctl
= ((spec
->hp_present
& 2) && spec
->cur_eapd
)
1979 ? spec
->port_d_mode
: 0;
1980 snd_hda_codec_write(codec
, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1984 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1985 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1988 if (spec
->dell_automute
) {
1989 /* DELL AIO Port Rule: PortA > PortD > IntSpk */
1990 pinctl
= (!(spec
->hp_present
& 1) && spec
->cur_eapd
)
1992 snd_hda_codec_write(codec
, 0x1c, 0,
1993 AC_VERB_SET_PIN_WIDGET_CONTROL
, pinctl
);
1997 /* turn on/off EAPD (+ mute HP) as a master switch */
1998 static int cxt5066_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1999 struct snd_ctl_elem_value
*ucontrol
)
2001 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2003 if (!cxt_eapd_put(kcontrol
, ucontrol
))
2006 cxt5066_update_speaker(codec
);
2010 /* toggle input of built-in and mic jack appropriately */
2011 static void cxt5066_automic(struct hda_codec
*codec
)
2013 struct conexant_spec
*spec
= codec
->spec
;
2014 struct hda_verb ext_mic_present
[] = {
2015 /* enable external mic, port B */
2016 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, spec
->ext_mic_bias
},
2018 /* switch to external mic input */
2019 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2021 /* disable internal mic, port C */
2022 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2025 static struct hda_verb ext_mic_absent
[] = {
2026 /* enable internal mic, port C */
2027 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2029 /* switch to internal mic input */
2030 {0x17, AC_VERB_SET_CONNECT_SEL
, 1},
2032 /* disable external mic, port B */
2033 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2036 unsigned int present
;
2038 present
= snd_hda_codec_read(codec
, 0x1a, 0,
2039 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
2041 snd_printdd("CXT5066: external microphone detected\n");
2042 snd_hda_sequence_write(codec
, ext_mic_present
);
2044 snd_printdd("CXT5066: external microphone absent\n");
2045 snd_hda_sequence_write(codec
, ext_mic_absent
);
2049 /* mute internal speaker if HP is plugged */
2050 static void cxt5066_hp_automute(struct hda_codec
*codec
)
2052 struct conexant_spec
*spec
= codec
->spec
;
2053 unsigned int portA
, portD
;
2056 portA
= snd_hda_codec_read(codec
, 0x19, 0, AC_VERB_GET_PIN_SENSE
, 0)
2057 & AC_PINSENSE_PRESENCE
;
2060 portD
= (snd_hda_codec_read(codec
, 0x1c, 0, AC_VERB_GET_PIN_SENSE
, 0)
2061 & AC_PINSENSE_PRESENCE
) << 1;
2063 spec
->hp_present
= !!(portA
| portD
);
2064 snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
2065 portA
, portD
, spec
->hp_present
);
2066 cxt5066_update_speaker(codec
);
2069 /* unsolicited event for jack sensing */
2070 static void cxt5066_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2072 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2073 switch (res
>> 26) {
2074 case CONEXANT_HP_EVENT
:
2075 cxt5066_hp_automute(codec
);
2077 case CONEXANT_MIC_EVENT
:
2078 cxt5066_automic(codec
);
2083 static const struct hda_input_mux cxt5066_analog_mic_boost
= {
2094 static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol
*kcontrol
,
2095 struct snd_ctl_elem_info
*uinfo
)
2097 return snd_hda_input_mux_info(&cxt5066_analog_mic_boost
, uinfo
);
2100 static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol
*kcontrol
,
2101 struct snd_ctl_elem_value
*ucontrol
)
2103 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2106 val
= snd_hda_codec_read(codec
, 0x17, 0,
2107 AC_VERB_GET_AMP_GAIN_MUTE
, AC_AMP_GET_OUTPUT
);
2109 ucontrol
->value
.enumerated
.item
[0] = val
& AC_AMP_GAIN
;
2113 static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol
*kcontrol
,
2114 struct snd_ctl_elem_value
*ucontrol
)
2116 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2117 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2120 if (!imux
->num_items
)
2122 idx
= ucontrol
->value
.enumerated
.item
[0];
2123 if (idx
>= imux
->num_items
)
2124 idx
= imux
->num_items
- 1;
2126 snd_hda_codec_write_cache(codec
, 0x17, 0,
2127 AC_VERB_SET_AMP_GAIN_MUTE
,
2128 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_OUTPUT
|
2129 imux
->items
[idx
].index
);
2134 static struct hda_input_mux cxt5066_capture_source
= {
2144 static struct hda_bind_ctls cxt5066_bind_capture_vol_others
= {
2145 .ops
= &snd_hda_bind_vol
,
2147 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2148 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2153 static struct hda_bind_ctls cxt5066_bind_capture_sw_others
= {
2154 .ops
= &snd_hda_bind_sw
,
2156 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2157 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2162 static struct snd_kcontrol_new cxt5066_mixer_master
[] = {
2163 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
2167 static struct snd_kcontrol_new cxt5066_mixer_master_olpc
[] = {
2169 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2170 .name
= "Master Playback Volume",
2171 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
|
2172 SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
2173 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
,
2174 .info
= snd_hda_mixer_amp_volume_info
,
2175 .get
= snd_hda_mixer_amp_volume_get
,
2176 .put
= snd_hda_mixer_amp_volume_put
,
2177 .tlv
= { .c
= snd_hda_mixer_amp_tlv
},
2178 /* offset by 28 volume steps to limit minimum gain to -46dB */
2180 HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT
, 28),
2185 static struct snd_kcontrol_new cxt5066_mixers
[] = {
2187 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2188 .name
= "Master Playback Switch",
2189 .info
= cxt_eapd_info
,
2190 .get
= cxt_eapd_get
,
2191 .put
= cxt5066_hp_master_sw_put
,
2192 .private_value
= 0x1d,
2196 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2197 .name
= "Analog Mic Boost Capture Enum",
2198 .info
= cxt5066_mic_boost_mux_enum_info
,
2199 .get
= cxt5066_mic_boost_mux_enum_get
,
2200 .put
= cxt5066_mic_boost_mux_enum_put
,
2203 HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others
),
2204 HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others
),
2208 static struct hda_verb cxt5066_init_verbs
[] = {
2209 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2210 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2211 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2212 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2215 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2216 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2219 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2220 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2222 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2223 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2226 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2228 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2229 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2230 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2231 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2232 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2233 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2235 /* no digital microphone support yet */
2236 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2238 /* Audio input selector */
2239 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2241 /* SPDIF route: PCM */
2242 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2243 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2245 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2246 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2249 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2251 /* not handling these yet */
2252 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2253 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2254 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2255 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2256 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2257 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2258 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2259 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2263 static struct hda_verb cxt5066_init_verbs_olpc
[] = {
2264 /* Port A: headphones */
2265 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2266 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2268 /* Port B: external microphone */
2269 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, CXT5066_OLPC_EXT_MIC_BIAS
},
2271 /* Port C: internal microphone */
2272 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2274 /* Port D: unused */
2275 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2277 /* Port E: unused, but has primary EAPD */
2278 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2279 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2281 /* Port F: unused */
2282 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2284 /* Port G: internal speakers */
2285 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2286 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2289 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2292 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2294 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2295 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2296 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2297 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2298 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2299 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2300 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2301 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2302 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2303 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2304 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2305 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2307 /* Disable digital microphone port */
2308 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2310 /* Audio input selectors */
2311 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2312 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2315 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2316 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2318 /* enable unsolicited events for Port A and B */
2319 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2320 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2324 static struct hda_verb cxt5066_init_verbs_portd_lo
[] = {
2325 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2329 /* initialize jack-sensing, too */
2330 static int cxt5066_init(struct hda_codec
*codec
)
2332 snd_printdd("CXT5066: init\n");
2333 conexant_init(codec
);
2334 if (codec
->patch_ops
.unsol_event
) {
2335 cxt5066_hp_automute(codec
);
2336 cxt5066_automic(codec
);
2342 CXT5066_LAPTOP
, /* Laptops w/ EAPD support */
2343 CXT5066_DELL_LAPTOP
, /* Dell Laptop */
2344 CXT5066_OLPC_XO_1_5
, /* OLPC XO 1.5 */
2348 static const char *cxt5066_models
[CXT5066_MODELS
] = {
2349 [CXT5066_LAPTOP
] = "laptop",
2350 [CXT5066_DELL_LAPTOP
] = "dell-laptop",
2351 [CXT5066_OLPC_XO_1_5
] = "olpc-xo-1_5",
2354 static struct snd_pci_quirk cxt5066_cfg_tbl
[] = {
2355 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
2357 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell",
2358 CXT5066_DELL_LAPTOP
),
2359 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5
),
2360 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5
),
2361 SND_PCI_QUIRK(0x1179, 0xffe0, "Toshiba Satellite Pro T130-15F", CXT5066_OLPC_XO_1_5
),
2365 static int patch_cxt5066(struct hda_codec
*codec
)
2367 struct conexant_spec
*spec
;
2370 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2375 codec
->patch_ops
= conexant_patch_ops
;
2376 codec
->patch_ops
.init
= cxt5066_init
;
2378 spec
->dell_automute
= 0;
2379 spec
->multiout
.max_channels
= 2;
2380 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5066_dac_nids
);
2381 spec
->multiout
.dac_nids
= cxt5066_dac_nids
;
2382 spec
->multiout
.dig_out_nid
= CXT5066_SPDIF_OUT
;
2383 spec
->num_adc_nids
= 1;
2384 spec
->adc_nids
= cxt5066_adc_nids
;
2385 spec
->capsrc_nids
= cxt5066_capsrc_nids
;
2386 spec
->input_mux
= &cxt5066_capture_source
;
2388 spec
->port_d_mode
= PIN_HP
;
2389 spec
->ext_mic_bias
= PIN_VREF80
;
2391 spec
->num_init_verbs
= 1;
2392 spec
->init_verbs
[0] = cxt5066_init_verbs
;
2393 spec
->num_channel_mode
= ARRAY_SIZE(cxt5066_modes
);
2394 spec
->channel_mode
= cxt5066_modes
;
2396 spec
->cur_adc_idx
= 0;
2398 board_config
= snd_hda_check_board_config(codec
, CXT5066_MODELS
,
2399 cxt5066_models
, cxt5066_cfg_tbl
);
2400 switch (board_config
) {
2402 case CXT5066_LAPTOP
:
2403 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
2404 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2406 case CXT5066_DELL_LAPTOP
:
2407 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
2408 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2410 spec
->port_d_mode
= PIN_OUT
;
2411 spec
->init_verbs
[spec
->num_init_verbs
] = cxt5066_init_verbs_portd_lo
;
2412 spec
->num_init_verbs
++;
2413 spec
->dell_automute
= 1;
2415 case CXT5066_OLPC_XO_1_5
:
2416 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
2417 spec
->init_verbs
[0] = cxt5066_init_verbs_olpc
;
2418 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
2419 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2420 spec
->port_d_mode
= 0;
2421 spec
->ext_mic_bias
= CXT5066_OLPC_EXT_MIC_BIAS
;
2424 spec
->multiout
.dig_out_nid
= 0;
2426 /* input source automatically selected */
2427 spec
->input_mux
= NULL
;
2437 static struct hda_codec_preset snd_hda_preset_conexant
[] = {
2438 { .id
= 0x14f15045, .name
= "CX20549 (Venice)",
2439 .patch
= patch_cxt5045
},
2440 { .id
= 0x14f15047, .name
= "CX20551 (Waikiki)",
2441 .patch
= patch_cxt5047
},
2442 { .id
= 0x14f15051, .name
= "CX20561 (Hermosa)",
2443 .patch
= patch_cxt5051
},
2444 { .id
= 0x14f15066, .name
= "CX20582 (Pebble)",
2445 .patch
= patch_cxt5066
},
2449 MODULE_ALIAS("snd-hda-codec-id:14f15045");
2450 MODULE_ALIAS("snd-hda-codec-id:14f15047");
2451 MODULE_ALIAS("snd-hda-codec-id:14f15051");
2452 MODULE_ALIAS("snd-hda-codec-id:14f15066");
2454 MODULE_LICENSE("GPL");
2455 MODULE_DESCRIPTION("Conexant HD-audio codec");
2457 static struct hda_codec_preset_list conexant_list
= {
2458 .preset
= snd_hda_preset_conexant
,
2459 .owner
= THIS_MODULE
,
2462 static int __init
patch_conexant_init(void)
2464 return snd_hda_add_codec_preset(&conexant_list
);
2467 static void __exit
patch_conexant_exit(void)
2469 snd_hda_delete_codec_preset(&conexant_list
);
2472 module_init(patch_conexant_init
)
2473 module_exit(patch_conexant_exit
)