xref: /openbmc/linux/sound/pci/hda/patch_conexant.c (revision f6b28e4ded45bb91bc4cd115d55e35badedfce5f)
1c9b443d4STobin Davis /*
2c9b443d4STobin Davis  * HD audio interface patch for Conexant HDA audio codec
3c9b443d4STobin Davis  *
4c9b443d4STobin Davis  * Copyright (c) 2006 Pototskiy Akex <alex.pototskiy@gmail.com>
5c9b443d4STobin Davis  * 		      Takashi Iwai <tiwai@suse.de>
6c9b443d4STobin Davis  * 		      Tobin Davis  <tdavis@dsl-only.net>
7c9b443d4STobin Davis  *
8c9b443d4STobin Davis  *  This driver is free software; you can redistribute it and/or modify
9c9b443d4STobin Davis  *  it under the terms of the GNU General Public License as published by
10c9b443d4STobin Davis  *  the Free Software Foundation; either version 2 of the License, or
11c9b443d4STobin Davis  *  (at your option) any later version.
12c9b443d4STobin Davis  *
13c9b443d4STobin Davis  *  This driver is distributed in the hope that it will be useful,
14c9b443d4STobin Davis  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15c9b443d4STobin Davis  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16c9b443d4STobin Davis  *  GNU General Public License for more details.
17c9b443d4STobin Davis  *
18c9b443d4STobin Davis  *  You should have received a copy of the GNU General Public License
19c9b443d4STobin Davis  *  along with this program; if not, write to the Free Software
20c9b443d4STobin Davis  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21c9b443d4STobin Davis  */
22c9b443d4STobin Davis 
23c9b443d4STobin Davis #include <linux/init.h>
24c9b443d4STobin Davis #include <linux/delay.h>
25c9b443d4STobin Davis #include <linux/slab.h>
26da155d5bSPaul Gortmaker #include <linux/module.h>
27c9b443d4STobin Davis #include <sound/core.h>
28bc7a166dSUlrich Dangel #include <sound/jack.h>
29bc7a166dSUlrich Dangel 
30c9b443d4STobin Davis #include "hda_codec.h"
31c9b443d4STobin Davis #include "hda_local.h"
3223d30f28STakashi Iwai #include "hda_auto_parser.h"
33c0f8faf0SEinar Rünkaru #include "hda_beep.h"
341835a0f9STakashi Iwai #include "hda_jack.h"
35aed523f1STakashi Iwai #include "hda_generic.h"
36c9b443d4STobin Davis 
37c9b443d4STobin Davis struct conexant_spec {
3823d30f28STakashi Iwai 	struct hda_gen_spec gen;
39c9b443d4STobin Davis 
40bf92d1d5STakashi Iwai 	unsigned int beep_amp;
41bf92d1d5STakashi Iwai 
42bf92d1d5STakashi Iwai 	/* extra EAPD pins */
43bf92d1d5STakashi Iwai 	unsigned int num_eapds;
44bf92d1d5STakashi Iwai 	hda_nid_t eapds[4];
45ff359b14STakashi Iwai 	bool dynamic_eapd;
463542aed7STakashi Iwai 	hda_nid_t mute_led_eapd;
47bf92d1d5STakashi Iwai 
48e4c3bce2SDavid Henningsson 	unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
49e4c3bce2SDavid Henningsson 
503a00c660STakashi Iwai 	/* OPLC XO specific */
513a00c660STakashi Iwai 	bool recording;
523a00c660STakashi Iwai 	bool dc_enable;
533a00c660STakashi Iwai 	unsigned int dc_input_bias; /* offset into olpc_xo_dc_bias */
543a00c660STakashi Iwai 	struct nid_path *dc_mode_path;
55c9b443d4STobin Davis };
56c9b443d4STobin Davis 
57bf92d1d5STakashi Iwai 
58bf92d1d5STakashi Iwai #ifdef CONFIG_SND_HDA_INPUT_BEEP
597504b6cdSTakashi Iwai static inline void set_beep_amp(struct conexant_spec *spec, hda_nid_t nid,
607504b6cdSTakashi Iwai 				int idx, int dir)
617504b6cdSTakashi Iwai {
627504b6cdSTakashi Iwai 	spec->gen.beep_nid = nid;
637504b6cdSTakashi Iwai 	spec->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir);
647504b6cdSTakashi Iwai }
65bf92d1d5STakashi Iwai /* additional beep mixers; the actual parameters are overwritten at build */
66bf92d1d5STakashi Iwai static const struct snd_kcontrol_new cxt_beep_mixer[] = {
67bf92d1d5STakashi Iwai 	HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT),
68bf92d1d5STakashi Iwai 	HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT),
69bf92d1d5STakashi Iwai 	{ } /* end */
70bf92d1d5STakashi Iwai };
71bf92d1d5STakashi Iwai 
72bf92d1d5STakashi Iwai /* create beep controls if needed */
73bf92d1d5STakashi Iwai static int add_beep_ctls(struct hda_codec *codec)
74bf92d1d5STakashi Iwai {
75bf92d1d5STakashi Iwai 	struct conexant_spec *spec = codec->spec;
76bf92d1d5STakashi Iwai 	int err;
77bf92d1d5STakashi Iwai 
78bf92d1d5STakashi Iwai 	if (spec->beep_amp) {
79bf92d1d5STakashi Iwai 		const struct snd_kcontrol_new *knew;
80bf92d1d5STakashi Iwai 		for (knew = cxt_beep_mixer; knew->name; knew++) {
81bf92d1d5STakashi Iwai 			struct snd_kcontrol *kctl;
82bf92d1d5STakashi Iwai 			kctl = snd_ctl_new1(knew, codec);
83bf92d1d5STakashi Iwai 			if (!kctl)
84bf92d1d5STakashi Iwai 				return -ENOMEM;
85bf92d1d5STakashi Iwai 			kctl->private_value = spec->beep_amp;
86bf92d1d5STakashi Iwai 			err = snd_hda_ctl_add(codec, 0, kctl);
87bf92d1d5STakashi Iwai 			if (err < 0)
88bf92d1d5STakashi Iwai 				return err;
89bf92d1d5STakashi Iwai 		}
90bf92d1d5STakashi Iwai 	}
91bf92d1d5STakashi Iwai 	return 0;
92bf92d1d5STakashi Iwai }
93bf92d1d5STakashi Iwai #else
94bf92d1d5STakashi Iwai #define set_beep_amp(spec, nid, idx, dir) /* NOP */
95bf92d1d5STakashi Iwai #define add_beep_ctls(codec)	0
96bf92d1d5STakashi Iwai #endif
97bf92d1d5STakashi Iwai 
98461e2c78STakashi Iwai /*
99f2e5731dSTakashi Iwai  * Automatic parser for CX20641 & co
100f2e5731dSTakashi Iwai  */
101f2e5731dSTakashi Iwai 
102f2e5731dSTakashi Iwai #ifdef CONFIG_SND_HDA_INPUT_BEEP
103f2e5731dSTakashi Iwai static void cx_auto_parse_beep(struct hda_codec *codec)
104f2e5731dSTakashi Iwai {
105f2e5731dSTakashi Iwai 	struct conexant_spec *spec = codec->spec;
1067639a06cSTakashi Iwai 	hda_nid_t nid;
107f2e5731dSTakashi Iwai 
1087639a06cSTakashi Iwai 	for_each_hda_codec_node(nid, codec)
109f2e5731dSTakashi Iwai 		if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) {
110f2e5731dSTakashi Iwai 			set_beep_amp(spec, nid, 0, HDA_OUTPUT);
111f2e5731dSTakashi Iwai 			break;
112f2e5731dSTakashi Iwai 		}
113f2e5731dSTakashi Iwai }
114f2e5731dSTakashi Iwai #else
115f2e5731dSTakashi Iwai #define cx_auto_parse_beep(codec)
116f2e5731dSTakashi Iwai #endif
117f2e5731dSTakashi Iwai 
118254f2968STakashi Iwai /* parse EAPDs */
11919110595STakashi Iwai static void cx_auto_parse_eapd(struct hda_codec *codec)
12019110595STakashi Iwai {
12119110595STakashi Iwai 	struct conexant_spec *spec = codec->spec;
1227639a06cSTakashi Iwai 	hda_nid_t nid;
12319110595STakashi Iwai 
1247639a06cSTakashi Iwai 	for_each_hda_codec_node(nid, codec) {
12519110595STakashi Iwai 		if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
12619110595STakashi Iwai 			continue;
12719110595STakashi Iwai 		if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD))
12819110595STakashi Iwai 			continue;
12919110595STakashi Iwai 		spec->eapds[spec->num_eapds++] = nid;
13019110595STakashi Iwai 		if (spec->num_eapds >= ARRAY_SIZE(spec->eapds))
13119110595STakashi Iwai 			break;
13219110595STakashi Iwai 	}
133254f2968STakashi Iwai 
134254f2968STakashi Iwai 	/* NOTE: below is a wild guess; if we have more than two EAPDs,
135254f2968STakashi Iwai 	 * it's a new chip, where EAPDs are supposed to be associated to
136254f2968STakashi Iwai 	 * pins, and we can control EAPD per pin.
137254f2968STakashi Iwai 	 * OTOH, if only one or two EAPDs are found, it's an old chip,
138254f2968STakashi Iwai 	 * thus it might control over all pins.
139254f2968STakashi Iwai 	 */
140aed523f1STakashi Iwai 	if (spec->num_eapds > 2)
141ff359b14STakashi Iwai 		spec->dynamic_eapd = 1;
142f2e5731dSTakashi Iwai }
143f2e5731dSTakashi Iwai 
144da339866STakashi Iwai static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins,
145da339866STakashi Iwai 			      hda_nid_t *pins, bool on)
146f2e5731dSTakashi Iwai {
147f2e5731dSTakashi Iwai 	int i;
148f2e5731dSTakashi Iwai 	for (i = 0; i < num_pins; i++) {
149f2e5731dSTakashi Iwai 		if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD)
150f2e5731dSTakashi Iwai 			snd_hda_codec_write(codec, pins[i], 0,
151da339866STakashi Iwai 					    AC_VERB_SET_EAPD_BTLENABLE,
152da339866STakashi Iwai 					    on ? 0x02 : 0);
153f2e5731dSTakashi Iwai 	}
154f2e5731dSTakashi Iwai }
155f2e5731dSTakashi Iwai 
156527c73baSTakashi Iwai /* turn on/off EAPD according to Master switch */
157527c73baSTakashi Iwai static void cx_auto_vmaster_hook(void *private_data, int enabled)
158527c73baSTakashi Iwai {
159527c73baSTakashi Iwai 	struct hda_codec *codec = private_data;
160527c73baSTakashi Iwai 	struct conexant_spec *spec = codec->spec;
161527c73baSTakashi Iwai 
162527c73baSTakashi Iwai 	cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, enabled);
163527c73baSTakashi Iwai }
164527c73baSTakashi Iwai 
1653542aed7STakashi Iwai /* turn on/off EAPD according to Master switch (inversely!) for mute LED */
1663542aed7STakashi Iwai static void cx_auto_vmaster_hook_mute_led(void *private_data, int enabled)
1673542aed7STakashi Iwai {
1683542aed7STakashi Iwai 	struct hda_codec *codec = private_data;
1693542aed7STakashi Iwai 	struct conexant_spec *spec = codec->spec;
1703542aed7STakashi Iwai 
1713542aed7STakashi Iwai 	snd_hda_codec_write(codec, spec->mute_led_eapd, 0,
1723542aed7STakashi Iwai 			    AC_VERB_SET_EAPD_BTLENABLE,
1733542aed7STakashi Iwai 			    enabled ? 0x00 : 0x02);
1743542aed7STakashi Iwai }
1753542aed7STakashi Iwai 
176f2e5731dSTakashi Iwai static int cx_auto_build_controls(struct hda_codec *codec)
177f2e5731dSTakashi Iwai {
178f2e5731dSTakashi Iwai 	int err;
179f2e5731dSTakashi Iwai 
180aed523f1STakashi Iwai 	err = snd_hda_gen_build_controls(codec);
181f2e5731dSTakashi Iwai 	if (err < 0)
182f2e5731dSTakashi Iwai 		return err;
183f2e5731dSTakashi Iwai 
184aed523f1STakashi Iwai 	err = add_beep_ctls(codec);
185aed523f1STakashi Iwai 	if (err < 0)
186aed523f1STakashi Iwai 		return err;
18722ce5f74STakashi Iwai 
18822ce5f74STakashi Iwai 	return 0;
18922ce5f74STakashi Iwai }
19022ce5f74STakashi Iwai 
191ff359b14STakashi Iwai static int cx_auto_init(struct hda_codec *codec)
192ff359b14STakashi Iwai {
193ff359b14STakashi Iwai 	struct conexant_spec *spec = codec->spec;
194ff359b14STakashi Iwai 	snd_hda_gen_init(codec);
195ff359b14STakashi Iwai 	if (!spec->dynamic_eapd)
196ff359b14STakashi Iwai 		cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, true);
197e4c3bce2SDavid Henningsson 
198e4c3bce2SDavid Henningsson 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
199e4c3bce2SDavid Henningsson 
200ff359b14STakashi Iwai 	return 0;
201ff359b14STakashi Iwai }
202ff359b14STakashi Iwai 
203*f6b28e4dSDavid Henningsson static void cx_auto_reboot_notify(struct hda_codec *codec)
204*f6b28e4dSDavid Henningsson {
205*f6b28e4dSDavid Henningsson 	struct conexant_spec *spec = codec->spec;
206*f6b28e4dSDavid Henningsson 
207*f6b28e4dSDavid Henningsson 	if (codec->core.vendor_id != 0x14f150f2)
208*f6b28e4dSDavid Henningsson 		return;
209*f6b28e4dSDavid Henningsson 
210*f6b28e4dSDavid Henningsson 	/* Turn the CX20722 codec into D3 to avoid spurious noises
211*f6b28e4dSDavid Henningsson 	   from the internal speaker during (and after) reboot */
212*f6b28e4dSDavid Henningsson 	cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, false);
213*f6b28e4dSDavid Henningsson 
214*f6b28e4dSDavid Henningsson 	snd_hda_codec_set_power_to_all(codec, codec->core.afg, AC_PWRST_D3);
215*f6b28e4dSDavid Henningsson 	snd_hda_codec_write(codec, codec->core.afg, 0,
216*f6b28e4dSDavid Henningsson 			    AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
217*f6b28e4dSDavid Henningsson }
218*f6b28e4dSDavid Henningsson 
219*f6b28e4dSDavid Henningsson static void cx_auto_free(struct hda_codec *codec)
220*f6b28e4dSDavid Henningsson {
221*f6b28e4dSDavid Henningsson 	cx_auto_reboot_notify(codec);
222*f6b28e4dSDavid Henningsson 	snd_hda_gen_free(codec);
223*f6b28e4dSDavid Henningsson }
22408cf680cSDavid Henningsson 
22534cbe3a6STakashi Iwai static const struct hda_codec_ops cx_auto_patch_ops = {
226f2e5731dSTakashi Iwai 	.build_controls = cx_auto_build_controls,
227aed523f1STakashi Iwai 	.build_pcms = snd_hda_gen_build_pcms,
228ff359b14STakashi Iwai 	.init = cx_auto_init,
229*f6b28e4dSDavid Henningsson 	.reboot_notify = cx_auto_reboot_notify,
23008cf680cSDavid Henningsson 	.free = cx_auto_free,
23129adc4b9SDavid Henningsson 	.unsol_event = snd_hda_jack_unsol_event,
232164a7adaSTakashi Iwai #ifdef CONFIG_PM
233164a7adaSTakashi Iwai 	.check_power_status = snd_hda_gen_check_power_status,
234164a7adaSTakashi Iwai #endif
235f2e5731dSTakashi Iwai };
236f2e5731dSTakashi Iwai 
237e92d4b08STakashi Iwai /*
238e92d4b08STakashi Iwai  * pin fix-up
239e92d4b08STakashi Iwai  */
24018dcd304SDavid Henningsson enum {
24118dcd304SDavid Henningsson 	CXT_PINCFG_LENOVO_X200,
242d3980110STakashi Iwai 	CXT_PINCFG_LENOVO_TP410,
243239fb862SHuacai Chen 	CXT_PINCFG_LEMOTE_A1004,
244239fb862SHuacai Chen 	CXT_PINCFG_LEMOTE_A1205,
245ddb6ca75STakashi Iwai 	CXT_PINCFG_COMPAQ_CQ60,
24618dcd304SDavid Henningsson 	CXT_FIXUP_STEREO_DMIC,
247239fb862SHuacai Chen 	CXT_FIXUP_INC_MIC_BOOST,
248e4c3bce2SDavid Henningsson 	CXT_FIXUP_HEADPHONE_MIC_PIN,
249e4c3bce2SDavid Henningsson 	CXT_FIXUP_HEADPHONE_MIC,
2504a437044STakashi Iwai 	CXT_FIXUP_GPIO1,
251ff50479aSTakashi Iwai 	CXT_FIXUP_ASPIRE_DMIC,
25208cf680cSDavid Henningsson 	CXT_FIXUP_THINKPAD_ACPI,
2533a00c660STakashi Iwai 	CXT_FIXUP_OLPC_XO,
254ad7725d3STakashi Iwai 	CXT_FIXUP_CAP_MIX_AMP,
2556dcbadefSTakashi Iwai 	CXT_FIXUP_TOSHIBA_P105,
256e5eac90dSTakashi Iwai 	CXT_FIXUP_HP_530,
257ea30e7dfSTakashi Iwai 	CXT_FIXUP_CAP_MIX_AMP_5047,
2583542aed7STakashi Iwai 	CXT_FIXUP_MUTE_LED_EAPD,
25918dcd304SDavid Henningsson };
26018dcd304SDavid Henningsson 
261b317b032STakashi Iwai /* for hda_fixup_thinkpad_acpi() */
262b317b032STakashi Iwai #include "thinkpad_helper.c"
26308cf680cSDavid Henningsson 
26423d30f28STakashi Iwai static void cxt_fixup_stereo_dmic(struct hda_codec *codec,
26523d30f28STakashi Iwai 				  const struct hda_fixup *fix, int action)
266e92d4b08STakashi Iwai {
26718dcd304SDavid Henningsson 	struct conexant_spec *spec = codec->spec;
268aed523f1STakashi Iwai 	spec->gen.inv_dmic_split = 1;
269e92d4b08STakashi Iwai }
270e92d4b08STakashi Iwai 
271239fb862SHuacai Chen static void cxt5066_increase_mic_boost(struct hda_codec *codec,
272239fb862SHuacai Chen 				   const struct hda_fixup *fix, int action)
273239fb862SHuacai Chen {
274239fb862SHuacai Chen 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
275239fb862SHuacai Chen 		return;
276239fb862SHuacai Chen 
277239fb862SHuacai Chen 	snd_hda_override_amp_caps(codec, 0x17, HDA_OUTPUT,
278239fb862SHuacai Chen 				  (0x3 << AC_AMPCAP_OFFSET_SHIFT) |
279239fb862SHuacai Chen 				  (0x4 << AC_AMPCAP_NUM_STEPS_SHIFT) |
280239fb862SHuacai Chen 				  (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
281239fb862SHuacai Chen 				  (0 << AC_AMPCAP_MUTE_SHIFT));
282239fb862SHuacai Chen }
283239fb862SHuacai Chen 
284e4c3bce2SDavid Henningsson static void cxt_update_headset_mode(struct hda_codec *codec)
285e4c3bce2SDavid Henningsson {
286e4c3bce2SDavid Henningsson 	/* The verbs used in this function were tested on a Conexant CX20751/2 codec. */
287e4c3bce2SDavid Henningsson 	int i;
288e4c3bce2SDavid Henningsson 	bool mic_mode = false;
289e4c3bce2SDavid Henningsson 	struct conexant_spec *spec = codec->spec;
290e4c3bce2SDavid Henningsson 	struct auto_pin_cfg *cfg = &spec->gen.autocfg;
291e4c3bce2SDavid Henningsson 
292e4c3bce2SDavid Henningsson 	hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
293e4c3bce2SDavid Henningsson 
294e4c3bce2SDavid Henningsson 	for (i = 0; i < cfg->num_inputs; i++)
295e4c3bce2SDavid Henningsson 		if (cfg->inputs[i].pin == mux_pin) {
296e4c3bce2SDavid Henningsson 			mic_mode = !!cfg->inputs[i].is_headphone_mic;
297e4c3bce2SDavid Henningsson 			break;
298e4c3bce2SDavid Henningsson 		}
299e4c3bce2SDavid Henningsson 
300e4c3bce2SDavid Henningsson 	if (mic_mode) {
301e4c3bce2SDavid Henningsson 		snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x7c); /* enable merged mode for analog int-mic */
302e4c3bce2SDavid Henningsson 		spec->gen.hp_jack_present = false;
303e4c3bce2SDavid Henningsson 	} else {
304e4c3bce2SDavid Henningsson 		snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x54); /* disable merged mode for analog int-mic */
305e4c3bce2SDavid Henningsson 		spec->gen.hp_jack_present = snd_hda_jack_detect(codec, spec->gen.autocfg.hp_pins[0]);
306e4c3bce2SDavid Henningsson 	}
307e4c3bce2SDavid Henningsson 
308e4c3bce2SDavid Henningsson 	snd_hda_gen_update_outputs(codec);
309e4c3bce2SDavid Henningsson }
310e4c3bce2SDavid Henningsson 
311e4c3bce2SDavid Henningsson static void cxt_update_headset_mode_hook(struct hda_codec *codec,
3127fe30711STakashi Iwai 					 struct snd_kcontrol *kcontrol,
313e4c3bce2SDavid Henningsson 					 struct snd_ctl_elem_value *ucontrol)
314e4c3bce2SDavid Henningsson {
315e4c3bce2SDavid Henningsson 	cxt_update_headset_mode(codec);
316e4c3bce2SDavid Henningsson }
317e4c3bce2SDavid Henningsson 
318e4c3bce2SDavid Henningsson static void cxt_fixup_headphone_mic(struct hda_codec *codec,
319e4c3bce2SDavid Henningsson 				    const struct hda_fixup *fix, int action)
320e4c3bce2SDavid Henningsson {
321e4c3bce2SDavid Henningsson 	struct conexant_spec *spec = codec->spec;
322e4c3bce2SDavid Henningsson 
323e4c3bce2SDavid Henningsson 	switch (action) {
324e4c3bce2SDavid Henningsson 	case HDA_FIXUP_ACT_PRE_PROBE:
325e4c3bce2SDavid Henningsson 		spec->parse_flags |= HDA_PINCFG_HEADPHONE_MIC;
326a551d914STakashi Iwai 		snd_hdac_regmap_add_vendor_verb(&codec->core, 0x410);
327e4c3bce2SDavid Henningsson 		break;
328e4c3bce2SDavid Henningsson 	case HDA_FIXUP_ACT_PROBE:
329e4c3bce2SDavid Henningsson 		spec->gen.cap_sync_hook = cxt_update_headset_mode_hook;
330e4c3bce2SDavid Henningsson 		spec->gen.automute_hook = cxt_update_headset_mode;
331e4c3bce2SDavid Henningsson 		break;
332e4c3bce2SDavid Henningsson 	case HDA_FIXUP_ACT_INIT:
333e4c3bce2SDavid Henningsson 		cxt_update_headset_mode(codec);
334e4c3bce2SDavid Henningsson 		break;
335e4c3bce2SDavid Henningsson 	}
336e4c3bce2SDavid Henningsson }
337e4c3bce2SDavid Henningsson 
3383a00c660STakashi Iwai /* OPLC XO 1.5 fixup */
3393a00c660STakashi Iwai 
3403a00c660STakashi Iwai /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
3413a00c660STakashi Iwai  * through the microphone jack.
3423a00c660STakashi Iwai  * When the user enables this through a mixer switch, both internal and
3433a00c660STakashi Iwai  * external microphones are disabled. Gain is fixed at 0dB. In this mode,
3443a00c660STakashi Iwai  * we also allow the bias to be configured through a separate mixer
3453a00c660STakashi Iwai  * control. */
3463a00c660STakashi Iwai 
3473a00c660STakashi Iwai #define update_mic_pin(codec, nid, val)					\
3483a00c660STakashi Iwai 	snd_hda_codec_update_cache(codec, nid, 0,			\
3493a00c660STakashi Iwai 				   AC_VERB_SET_PIN_WIDGET_CONTROL, val)
3503a00c660STakashi Iwai 
3513a00c660STakashi Iwai static const struct hda_input_mux olpc_xo_dc_bias = {
3523a00c660STakashi Iwai 	.num_items = 3,
3533a00c660STakashi Iwai 	.items = {
3543a00c660STakashi Iwai 		{ "Off", PIN_IN },
3553a00c660STakashi Iwai 		{ "50%", PIN_VREF50 },
3563a00c660STakashi Iwai 		{ "80%", PIN_VREF80 },
3573a00c660STakashi Iwai 	},
3583a00c660STakashi Iwai };
3593a00c660STakashi Iwai 
3603a00c660STakashi Iwai static void olpc_xo_update_mic_boost(struct hda_codec *codec)
3613a00c660STakashi Iwai {
3623a00c660STakashi Iwai 	struct conexant_spec *spec = codec->spec;
3633a00c660STakashi Iwai 	int ch, val;
3643a00c660STakashi Iwai 
3653a00c660STakashi Iwai 	for (ch = 0; ch < 2; ch++) {
3663a00c660STakashi Iwai 		val = AC_AMP_SET_OUTPUT |
3673a00c660STakashi Iwai 			(ch ? AC_AMP_SET_RIGHT : AC_AMP_SET_LEFT);
3683a00c660STakashi Iwai 		if (!spec->dc_enable)
3693a00c660STakashi Iwai 			val |= snd_hda_codec_amp_read(codec, 0x17, ch, HDA_OUTPUT, 0);
3703a00c660STakashi Iwai 		snd_hda_codec_write(codec, 0x17, 0,
3713a00c660STakashi Iwai 				    AC_VERB_SET_AMP_GAIN_MUTE, val);
3723a00c660STakashi Iwai 	}
3733a00c660STakashi Iwai }
3743a00c660STakashi Iwai 
3753a00c660STakashi Iwai static void olpc_xo_update_mic_pins(struct hda_codec *codec)
3763a00c660STakashi Iwai {
3773a00c660STakashi Iwai 	struct conexant_spec *spec = codec->spec;
3783a00c660STakashi Iwai 	int cur_input, val;
3793a00c660STakashi Iwai 	struct nid_path *path;
3803a00c660STakashi Iwai 
3813a00c660STakashi Iwai 	cur_input = spec->gen.input_paths[0][spec->gen.cur_mux[0]];
3823a00c660STakashi Iwai 
3833a00c660STakashi Iwai 	/* Set up mic pins for port-B, C and F dynamically as the recording
3843a00c660STakashi Iwai 	 * LED is turned on/off by these pin controls
3853a00c660STakashi Iwai 	 */
3863a00c660STakashi Iwai 	if (!spec->dc_enable) {
3873a00c660STakashi Iwai 		/* disable DC bias path and pin for port F */
3883a00c660STakashi Iwai 		update_mic_pin(codec, 0x1e, 0);
3893a00c660STakashi Iwai 		snd_hda_activate_path(codec, spec->dc_mode_path, false, false);
3903a00c660STakashi Iwai 
3913a00c660STakashi Iwai 		/* update port B (ext mic) and C (int mic) */
3923a00c660STakashi Iwai 		/* OLPC defers mic widget control until when capture is
3933a00c660STakashi Iwai 		 * started because the microphone LED comes on as soon as
3943a00c660STakashi Iwai 		 * these settings are put in place. if we did this before
3953a00c660STakashi Iwai 		 * recording, it would give the false indication that
3963a00c660STakashi Iwai 		 * recording is happening when it is not.
3973a00c660STakashi Iwai 		 */
3983a00c660STakashi Iwai 		update_mic_pin(codec, 0x1a, spec->recording ?
3993a00c660STakashi Iwai 			       snd_hda_codec_get_pin_target(codec, 0x1a) : 0);
4003a00c660STakashi Iwai 		update_mic_pin(codec, 0x1b, spec->recording ?
4013a00c660STakashi Iwai 			       snd_hda_codec_get_pin_target(codec, 0x1b) : 0);
4023a00c660STakashi Iwai 		/* enable normal mic path */
4033a00c660STakashi Iwai 		path = snd_hda_get_path_from_idx(codec, cur_input);
4043a00c660STakashi Iwai 		if (path)
4053a00c660STakashi Iwai 			snd_hda_activate_path(codec, path, true, false);
4063a00c660STakashi Iwai 	} else {
4073a00c660STakashi Iwai 		/* disable normal mic path */
4083a00c660STakashi Iwai 		path = snd_hda_get_path_from_idx(codec, cur_input);
4093a00c660STakashi Iwai 		if (path)
4103a00c660STakashi Iwai 			snd_hda_activate_path(codec, path, false, false);
4113a00c660STakashi Iwai 
4123a00c660STakashi Iwai 		/* Even though port F is the DC input, the bias is controlled
4133a00c660STakashi Iwai 		 * on port B.  We also leave that port as an active input (but
4143a00c660STakashi Iwai 		 * unselected) in DC mode just in case that is necessary to
4153a00c660STakashi Iwai 		 * make the bias setting take effect.
4163a00c660STakashi Iwai 		 */
4173a00c660STakashi Iwai 		if (spec->recording)
4183a00c660STakashi Iwai 			val = olpc_xo_dc_bias.items[spec->dc_input_bias].index;
4193a00c660STakashi Iwai 		else
4203a00c660STakashi Iwai 			val = 0;
4213a00c660STakashi Iwai 		update_mic_pin(codec, 0x1a, val);
4223a00c660STakashi Iwai 		update_mic_pin(codec, 0x1b, 0);
4233a00c660STakashi Iwai 		/* enable DC bias path and pin */
4243a00c660STakashi Iwai 		update_mic_pin(codec, 0x1e, spec->recording ? PIN_IN : 0);
4253a00c660STakashi Iwai 		snd_hda_activate_path(codec, spec->dc_mode_path, true, false);
4263a00c660STakashi Iwai 	}
4273a00c660STakashi Iwai }
4283a00c660STakashi Iwai 
4293a00c660STakashi Iwai /* mic_autoswitch hook */
4301a4f69d5STakashi Iwai static void olpc_xo_automic(struct hda_codec *codec,
4311a4f69d5STakashi Iwai 			    struct hda_jack_callback *jack)
4323a00c660STakashi Iwai {
4333a00c660STakashi Iwai 	struct conexant_spec *spec = codec->spec;
4343a00c660STakashi Iwai 
4353a00c660STakashi Iwai 	/* in DC mode, we don't handle automic */
4363a00c660STakashi Iwai 	if (!spec->dc_enable)
4373a00c660STakashi Iwai 		snd_hda_gen_mic_autoswitch(codec, jack);
4383a00c660STakashi Iwai 	olpc_xo_update_mic_pins(codec);
4393a00c660STakashi Iwai 	if (spec->dc_enable)
4403a00c660STakashi Iwai 		olpc_xo_update_mic_boost(codec);
4413a00c660STakashi Iwai }
4423a00c660STakashi Iwai 
4433a00c660STakashi Iwai /* pcm_capture hook */
4443a00c660STakashi Iwai static void olpc_xo_capture_hook(struct hda_pcm_stream *hinfo,
4453a00c660STakashi Iwai 				 struct hda_codec *codec,
4463a00c660STakashi Iwai 				 struct snd_pcm_substream *substream,
4473a00c660STakashi Iwai 				 int action)
4483a00c660STakashi Iwai {
4493a00c660STakashi Iwai 	struct conexant_spec *spec = codec->spec;
4503a00c660STakashi Iwai 
4513a00c660STakashi Iwai 	/* toggle spec->recording flag and update mic pins accordingly
4523a00c660STakashi Iwai 	 * for turning on/off LED
4533a00c660STakashi Iwai 	 */
4543a00c660STakashi Iwai 	switch (action) {
4553a00c660STakashi Iwai 	case HDA_GEN_PCM_ACT_PREPARE:
4563a00c660STakashi Iwai 		spec->recording = 1;
4573a00c660STakashi Iwai 		olpc_xo_update_mic_pins(codec);
4583a00c660STakashi Iwai 		break;
4593a00c660STakashi Iwai 	case HDA_GEN_PCM_ACT_CLEANUP:
4603a00c660STakashi Iwai 		spec->recording = 0;
4613a00c660STakashi Iwai 		olpc_xo_update_mic_pins(codec);
4623a00c660STakashi Iwai 		break;
4633a00c660STakashi Iwai 	}
4643a00c660STakashi Iwai }
4653a00c660STakashi Iwai 
4663a00c660STakashi Iwai static int olpc_xo_dc_mode_get(struct snd_kcontrol *kcontrol,
4673a00c660STakashi Iwai 			       struct snd_ctl_elem_value *ucontrol)
4683a00c660STakashi Iwai {
4693a00c660STakashi Iwai 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4703a00c660STakashi Iwai 	struct conexant_spec *spec = codec->spec;
4713a00c660STakashi Iwai 	ucontrol->value.integer.value[0] = spec->dc_enable;
4723a00c660STakashi Iwai 	return 0;
4733a00c660STakashi Iwai }
4743a00c660STakashi Iwai 
4753a00c660STakashi Iwai static int olpc_xo_dc_mode_put(struct snd_kcontrol *kcontrol,
4763a00c660STakashi Iwai 			       struct snd_ctl_elem_value *ucontrol)
4773a00c660STakashi Iwai {
4783a00c660STakashi Iwai 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4793a00c660STakashi Iwai 	struct conexant_spec *spec = codec->spec;
4803a00c660STakashi Iwai 	int dc_enable = !!ucontrol->value.integer.value[0];
4813a00c660STakashi Iwai 
4823a00c660STakashi Iwai 	if (dc_enable == spec->dc_enable)
4833a00c660STakashi Iwai 		return 0;
4843a00c660STakashi Iwai 
4853a00c660STakashi Iwai 	spec->dc_enable = dc_enable;
4863a00c660STakashi Iwai 	olpc_xo_update_mic_pins(codec);
4873a00c660STakashi Iwai 	olpc_xo_update_mic_boost(codec);
4883a00c660STakashi Iwai 	return 1;
4893a00c660STakashi Iwai }
4903a00c660STakashi Iwai 
4913a00c660STakashi Iwai static int olpc_xo_dc_bias_enum_get(struct snd_kcontrol *kcontrol,
4923a00c660STakashi Iwai 				    struct snd_ctl_elem_value *ucontrol)
4933a00c660STakashi Iwai {
4943a00c660STakashi Iwai 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4953a00c660STakashi Iwai 	struct conexant_spec *spec = codec->spec;
4963a00c660STakashi Iwai 	ucontrol->value.enumerated.item[0] = spec->dc_input_bias;
4973a00c660STakashi Iwai 	return 0;
4983a00c660STakashi Iwai }
4993a00c660STakashi Iwai 
5003a00c660STakashi Iwai static int olpc_xo_dc_bias_enum_info(struct snd_kcontrol *kcontrol,
5013a00c660STakashi Iwai 				     struct snd_ctl_elem_info *uinfo)
5023a00c660STakashi Iwai {
5033a00c660STakashi Iwai 	return snd_hda_input_mux_info(&olpc_xo_dc_bias, uinfo);
5043a00c660STakashi Iwai }
5053a00c660STakashi Iwai 
5063a00c660STakashi Iwai static int olpc_xo_dc_bias_enum_put(struct snd_kcontrol *kcontrol,
5073a00c660STakashi Iwai 				    struct snd_ctl_elem_value *ucontrol)
5083a00c660STakashi Iwai {
5093a00c660STakashi Iwai 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5103a00c660STakashi Iwai 	struct conexant_spec *spec = codec->spec;
5113a00c660STakashi Iwai 	const struct hda_input_mux *imux = &olpc_xo_dc_bias;
5123a00c660STakashi Iwai 	unsigned int idx;
5133a00c660STakashi Iwai 
5143a00c660STakashi Iwai 	idx = ucontrol->value.enumerated.item[0];
5153a00c660STakashi Iwai 	if (idx >= imux->num_items)
5163a00c660STakashi Iwai 		idx = imux->num_items - 1;
5173a00c660STakashi Iwai 	if (spec->dc_input_bias == idx)
5183a00c660STakashi Iwai 		return 0;
5193a00c660STakashi Iwai 
5203a00c660STakashi Iwai 	spec->dc_input_bias = idx;
5213a00c660STakashi Iwai 	if (spec->dc_enable)
5223a00c660STakashi Iwai 		olpc_xo_update_mic_pins(codec);
5233a00c660STakashi Iwai 	return 1;
5243a00c660STakashi Iwai }
5253a00c660STakashi Iwai 
5263a00c660STakashi Iwai static const struct snd_kcontrol_new olpc_xo_mixers[] = {
5273a00c660STakashi Iwai 	{
5283a00c660STakashi Iwai 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5293a00c660STakashi Iwai 		.name = "DC Mode Enable Switch",
5303a00c660STakashi Iwai 		.info = snd_ctl_boolean_mono_info,
5313a00c660STakashi Iwai 		.get = olpc_xo_dc_mode_get,
5323a00c660STakashi Iwai 		.put = olpc_xo_dc_mode_put,
5333a00c660STakashi Iwai 	},
5343a00c660STakashi Iwai 	{
5353a00c660STakashi Iwai 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5363a00c660STakashi Iwai 		.name = "DC Input Bias Enum",
5373a00c660STakashi Iwai 		.info = olpc_xo_dc_bias_enum_info,
5383a00c660STakashi Iwai 		.get = olpc_xo_dc_bias_enum_get,
5393a00c660STakashi Iwai 		.put = olpc_xo_dc_bias_enum_put,
5403a00c660STakashi Iwai 	},
5413a00c660STakashi Iwai 	{}
5423a00c660STakashi Iwai };
5433a00c660STakashi Iwai 
5443a00c660STakashi Iwai /* overriding mic boost put callback; update mic boost volume only when
5453a00c660STakashi Iwai  * DC mode is disabled
5463a00c660STakashi Iwai  */
5473a00c660STakashi Iwai static int olpc_xo_mic_boost_put(struct snd_kcontrol *kcontrol,
5483a00c660STakashi Iwai 				 struct snd_ctl_elem_value *ucontrol)
5493a00c660STakashi Iwai {
5503a00c660STakashi Iwai 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5513a00c660STakashi Iwai 	struct conexant_spec *spec = codec->spec;
5523a00c660STakashi Iwai 	int ret = snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
5533a00c660STakashi Iwai 	if (ret > 0 && spec->dc_enable)
5543a00c660STakashi Iwai 		olpc_xo_update_mic_boost(codec);
5553a00c660STakashi Iwai 	return ret;
5563a00c660STakashi Iwai }
5573a00c660STakashi Iwai 
5583a00c660STakashi Iwai static void cxt_fixup_olpc_xo(struct hda_codec *codec,
5593a00c660STakashi Iwai 				    const struct hda_fixup *fix, int action)
5603a00c660STakashi Iwai {
5613a00c660STakashi Iwai 	struct conexant_spec *spec = codec->spec;
5623a00c660STakashi Iwai 	int i;
5633a00c660STakashi Iwai 
5643a00c660STakashi Iwai 	if (action != HDA_FIXUP_ACT_PROBE)
5653a00c660STakashi Iwai 		return;
5663a00c660STakashi Iwai 
5673a00c660STakashi Iwai 	spec->gen.mic_autoswitch_hook = olpc_xo_automic;
5683a00c660STakashi Iwai 	spec->gen.pcm_capture_hook = olpc_xo_capture_hook;
5693a00c660STakashi Iwai 	spec->dc_mode_path = snd_hda_add_new_path(codec, 0x1e, 0x14, 0);
5703a00c660STakashi Iwai 
5713a00c660STakashi Iwai 	snd_hda_add_new_ctls(codec, olpc_xo_mixers);
5723a00c660STakashi Iwai 
5733a00c660STakashi Iwai 	/* OLPC's microphone port is DC coupled for use with external sensors,
5743a00c660STakashi Iwai 	 * therefore we use a 50% mic bias in order to center the input signal
5753a00c660STakashi Iwai 	 * with the DC input range of the codec.
5763a00c660STakashi Iwai 	 */
5773a00c660STakashi Iwai 	snd_hda_codec_set_pin_target(codec, 0x1a, PIN_VREF50);
5783a00c660STakashi Iwai 
5793a00c660STakashi Iwai 	/* override mic boost control */
5803a00c660STakashi Iwai 	for (i = 0; i < spec->gen.kctls.used; i++) {
5813a00c660STakashi Iwai 		struct snd_kcontrol_new *kctl =
5823a00c660STakashi Iwai 			snd_array_elem(&spec->gen.kctls, i);
5833a00c660STakashi Iwai 		if (!strcmp(kctl->name, "Mic Boost Volume")) {
5843a00c660STakashi Iwai 			kctl->put = olpc_xo_mic_boost_put;
5853a00c660STakashi Iwai 			break;
5863a00c660STakashi Iwai 		}
5873a00c660STakashi Iwai 	}
5883a00c660STakashi Iwai }
5893a00c660STakashi Iwai 
5903542aed7STakashi Iwai static void cxt_fixup_mute_led_eapd(struct hda_codec *codec,
5913542aed7STakashi Iwai 				    const struct hda_fixup *fix, int action)
5923542aed7STakashi Iwai {
5933542aed7STakashi Iwai 	struct conexant_spec *spec = codec->spec;
5943542aed7STakashi Iwai 
5953542aed7STakashi Iwai 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5963542aed7STakashi Iwai 		spec->mute_led_eapd = 0x1b;
5973542aed7STakashi Iwai 		spec->dynamic_eapd = 1;
5983542aed7STakashi Iwai 		spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook_mute_led;
5993542aed7STakashi Iwai 	}
6003542aed7STakashi Iwai }
6013542aed7STakashi Iwai 
602ad7725d3STakashi Iwai /*
603ad7725d3STakashi Iwai  * Fix max input level on mixer widget to 0dB
604ad7725d3STakashi Iwai  * (originally it has 0x2b steps with 0dB offset 0x14)
605ad7725d3STakashi Iwai  */
606ad7725d3STakashi Iwai static void cxt_fixup_cap_mix_amp(struct hda_codec *codec,
607ad7725d3STakashi Iwai 				  const struct hda_fixup *fix, int action)
608ad7725d3STakashi Iwai {
609ad7725d3STakashi Iwai 	snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT,
610ad7725d3STakashi Iwai 				  (0x14 << AC_AMPCAP_OFFSET_SHIFT) |
611ad7725d3STakashi Iwai 				  (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) |
612ad7725d3STakashi Iwai 				  (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
613ad7725d3STakashi Iwai 				  (1 << AC_AMPCAP_MUTE_SHIFT));
614ad7725d3STakashi Iwai }
615e4c3bce2SDavid Henningsson 
616ea30e7dfSTakashi Iwai /*
617ea30e7dfSTakashi Iwai  * Fix max input level on mixer widget to 0dB
618ea30e7dfSTakashi Iwai  * (originally it has 0x1e steps with 0 dB offset 0x17)
619ea30e7dfSTakashi Iwai  */
620ea30e7dfSTakashi Iwai static void cxt_fixup_cap_mix_amp_5047(struct hda_codec *codec,
621ea30e7dfSTakashi Iwai 				  const struct hda_fixup *fix, int action)
622ea30e7dfSTakashi Iwai {
623ea30e7dfSTakashi Iwai 	snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT,
624ea30e7dfSTakashi Iwai 				  (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
625ea30e7dfSTakashi Iwai 				  (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
626ea30e7dfSTakashi Iwai 				  (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
627ea30e7dfSTakashi Iwai 				  (1 << AC_AMPCAP_MUTE_SHIFT));
628ea30e7dfSTakashi Iwai }
629ea30e7dfSTakashi Iwai 
630d70f3632STakashi Iwai /* ThinkPad X200 & co with cxt5051 */
63123d30f28STakashi Iwai static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = {
632e92d4b08STakashi Iwai 	{ 0x16, 0x042140ff }, /* HP (seq# overridden) */
633e92d4b08STakashi Iwai 	{ 0x17, 0x21a11000 }, /* dock-mic */
634e92d4b08STakashi Iwai 	{ 0x19, 0x2121103f }, /* dock-HP */
6353e93f5efSTakashi Iwai 	{ 0x1c, 0x21440100 }, /* dock SPDIF out */
636e92d4b08STakashi Iwai 	{}
637e92d4b08STakashi Iwai };
638e92d4b08STakashi Iwai 
639d70f3632STakashi Iwai /* ThinkPad 410/420/510/520, X201 & co with cxt5066 */
64023d30f28STakashi Iwai static const struct hda_pintbl cxt_pincfg_lenovo_tp410[] = {
641d70f3632STakashi Iwai 	{ 0x19, 0x042110ff }, /* HP (seq# overridden) */
642d70f3632STakashi Iwai 	{ 0x1a, 0x21a190f0 }, /* dock-mic */
643d70f3632STakashi Iwai 	{ 0x1c, 0x212140ff }, /* dock-HP */
644d70f3632STakashi Iwai 	{}
645e92d4b08STakashi Iwai };
646e92d4b08STakashi Iwai 
647239fb862SHuacai Chen /* Lemote A1004/A1205 with cxt5066 */
648239fb862SHuacai Chen static const struct hda_pintbl cxt_pincfg_lemote[] = {
649239fb862SHuacai Chen 	{ 0x1a, 0x90a10020 }, /* Internal mic */
650239fb862SHuacai Chen 	{ 0x1b, 0x03a11020 }, /* External mic */
651239fb862SHuacai Chen 	{ 0x1d, 0x400101f0 }, /* Not used */
652239fb862SHuacai Chen 	{ 0x1e, 0x40a701f0 }, /* Not used */
653239fb862SHuacai Chen 	{ 0x20, 0x404501f0 }, /* Not used */
654239fb862SHuacai Chen 	{ 0x22, 0x404401f0 }, /* Not used */
655239fb862SHuacai Chen 	{ 0x23, 0x40a701f0 }, /* Not used */
656239fb862SHuacai Chen 	{}
657239fb862SHuacai Chen };
658239fb862SHuacai Chen 
65923d30f28STakashi Iwai static const struct hda_fixup cxt_fixups[] = {
66023d30f28STakashi Iwai 	[CXT_PINCFG_LENOVO_X200] = {
66123d30f28STakashi Iwai 		.type = HDA_FIXUP_PINS,
66223d30f28STakashi Iwai 		.v.pins = cxt_pincfg_lenovo_x200,
66323d30f28STakashi Iwai 	},
66423d30f28STakashi Iwai 	[CXT_PINCFG_LENOVO_TP410] = {
66523d30f28STakashi Iwai 		.type = HDA_FIXUP_PINS,
66623d30f28STakashi Iwai 		.v.pins = cxt_pincfg_lenovo_tp410,
66708cf680cSDavid Henningsson 		.chained = true,
66808cf680cSDavid Henningsson 		.chain_id = CXT_FIXUP_THINKPAD_ACPI,
66923d30f28STakashi Iwai 	},
670239fb862SHuacai Chen 	[CXT_PINCFG_LEMOTE_A1004] = {
671239fb862SHuacai Chen 		.type = HDA_FIXUP_PINS,
672239fb862SHuacai Chen 		.chained = true,
673239fb862SHuacai Chen 		.chain_id = CXT_FIXUP_INC_MIC_BOOST,
674239fb862SHuacai Chen 		.v.pins = cxt_pincfg_lemote,
675239fb862SHuacai Chen 	},
676239fb862SHuacai Chen 	[CXT_PINCFG_LEMOTE_A1205] = {
677239fb862SHuacai Chen 		.type = HDA_FIXUP_PINS,
678239fb862SHuacai Chen 		.v.pins = cxt_pincfg_lemote,
679239fb862SHuacai Chen 	},
680ddb6ca75STakashi Iwai 	[CXT_PINCFG_COMPAQ_CQ60] = {
681ddb6ca75STakashi Iwai 		.type = HDA_FIXUP_PINS,
682ddb6ca75STakashi Iwai 		.v.pins = (const struct hda_pintbl[]) {
683ddb6ca75STakashi Iwai 			/* 0x17 was falsely set up as a mic, it should 0x1d */
684ddb6ca75STakashi Iwai 			{ 0x17, 0x400001f0 },
685ddb6ca75STakashi Iwai 			{ 0x1d, 0x97a70120 },
686ddb6ca75STakashi Iwai 			{ }
687ddb6ca75STakashi Iwai 		}
688ddb6ca75STakashi Iwai 	},
68923d30f28STakashi Iwai 	[CXT_FIXUP_STEREO_DMIC] = {
69023d30f28STakashi Iwai 		.type = HDA_FIXUP_FUNC,
69123d30f28STakashi Iwai 		.v.func = cxt_fixup_stereo_dmic,
69223d30f28STakashi Iwai 	},
693239fb862SHuacai Chen 	[CXT_FIXUP_INC_MIC_BOOST] = {
694239fb862SHuacai Chen 		.type = HDA_FIXUP_FUNC,
695239fb862SHuacai Chen 		.v.func = cxt5066_increase_mic_boost,
696239fb862SHuacai Chen 	},
697e4c3bce2SDavid Henningsson 	[CXT_FIXUP_HEADPHONE_MIC_PIN] = {
698e4c3bce2SDavid Henningsson 		.type = HDA_FIXUP_PINS,
699e4c3bce2SDavid Henningsson 		.chained = true,
700e4c3bce2SDavid Henningsson 		.chain_id = CXT_FIXUP_HEADPHONE_MIC,
701e4c3bce2SDavid Henningsson 		.v.pins = (const struct hda_pintbl[]) {
702e4c3bce2SDavid Henningsson 			{ 0x18, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
703e4c3bce2SDavid Henningsson 			{ }
704e4c3bce2SDavid Henningsson 		}
705e4c3bce2SDavid Henningsson 	},
706e4c3bce2SDavid Henningsson 	[CXT_FIXUP_HEADPHONE_MIC] = {
707e4c3bce2SDavid Henningsson 		.type = HDA_FIXUP_FUNC,
708e4c3bce2SDavid Henningsson 		.v.func = cxt_fixup_headphone_mic,
709e4c3bce2SDavid Henningsson 	},
7104a437044STakashi Iwai 	[CXT_FIXUP_GPIO1] = {
7114a437044STakashi Iwai 		.type = HDA_FIXUP_VERBS,
7124a437044STakashi Iwai 		.v.verbs = (const struct hda_verb[]) {
7134a437044STakashi Iwai 			{ 0x01, AC_VERB_SET_GPIO_MASK, 0x01 },
7144a437044STakashi Iwai 			{ 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 },
7154a437044STakashi Iwai 			{ 0x01, AC_VERB_SET_GPIO_DATA, 0x01 },
7164a437044STakashi Iwai 			{ }
7174a437044STakashi Iwai 		},
7184a437044STakashi Iwai 	},
719ff50479aSTakashi Iwai 	[CXT_FIXUP_ASPIRE_DMIC] = {
720ff50479aSTakashi Iwai 		.type = HDA_FIXUP_FUNC,
721ff50479aSTakashi Iwai 		.v.func = cxt_fixup_stereo_dmic,
722ff50479aSTakashi Iwai 		.chained = true,
723ff50479aSTakashi Iwai 		.chain_id = CXT_FIXUP_GPIO1,
724ff50479aSTakashi Iwai 	},
72508cf680cSDavid Henningsson 	[CXT_FIXUP_THINKPAD_ACPI] = {
72608cf680cSDavid Henningsson 		.type = HDA_FIXUP_FUNC,
727b317b032STakashi Iwai 		.v.func = hda_fixup_thinkpad_acpi,
72808cf680cSDavid Henningsson 	},
7293a00c660STakashi Iwai 	[CXT_FIXUP_OLPC_XO] = {
7303a00c660STakashi Iwai 		.type = HDA_FIXUP_FUNC,
7313a00c660STakashi Iwai 		.v.func = cxt_fixup_olpc_xo,
7323a00c660STakashi Iwai 	},
733ad7725d3STakashi Iwai 	[CXT_FIXUP_CAP_MIX_AMP] = {
734ad7725d3STakashi Iwai 		.type = HDA_FIXUP_FUNC,
735ad7725d3STakashi Iwai 		.v.func = cxt_fixup_cap_mix_amp,
736ad7725d3STakashi Iwai 	},
7376dcbadefSTakashi Iwai 	[CXT_FIXUP_TOSHIBA_P105] = {
7386dcbadefSTakashi Iwai 		.type = HDA_FIXUP_PINS,
7396dcbadefSTakashi Iwai 		.v.pins = (const struct hda_pintbl[]) {
7406dcbadefSTakashi Iwai 			{ 0x10, 0x961701f0 }, /* speaker/hp */
7416dcbadefSTakashi Iwai 			{ 0x12, 0x02a1901e }, /* ext mic */
7426dcbadefSTakashi Iwai 			{ 0x14, 0x95a70110 }, /* int mic */
7436dcbadefSTakashi Iwai 			{}
7446dcbadefSTakashi Iwai 		},
7456dcbadefSTakashi Iwai 	},
746e5eac90dSTakashi Iwai 	[CXT_FIXUP_HP_530] = {
747e5eac90dSTakashi Iwai 		.type = HDA_FIXUP_PINS,
748e5eac90dSTakashi Iwai 		.v.pins = (const struct hda_pintbl[]) {
749e5eac90dSTakashi Iwai 			{ 0x12, 0x90a60160 }, /* int mic */
750e5eac90dSTakashi Iwai 			{}
751e5eac90dSTakashi Iwai 		},
752e5eac90dSTakashi Iwai 		.chained = true,
753e5eac90dSTakashi Iwai 		.chain_id = CXT_FIXUP_CAP_MIX_AMP,
754e5eac90dSTakashi Iwai 	},
755ea30e7dfSTakashi Iwai 	[CXT_FIXUP_CAP_MIX_AMP_5047] = {
756ea30e7dfSTakashi Iwai 		.type = HDA_FIXUP_FUNC,
757ea30e7dfSTakashi Iwai 		.v.func = cxt_fixup_cap_mix_amp_5047,
758ea30e7dfSTakashi Iwai 	},
7593542aed7STakashi Iwai 	[CXT_FIXUP_MUTE_LED_EAPD] = {
7603542aed7STakashi Iwai 		.type = HDA_FIXUP_FUNC,
7613542aed7STakashi Iwai 		.v.func = cxt_fixup_mute_led_eapd,
7623542aed7STakashi Iwai 	},
763ad7725d3STakashi Iwai };
764ad7725d3STakashi Iwai 
765ad7725d3STakashi Iwai static const struct snd_pci_quirk cxt5045_fixups[] = {
766e5eac90dSTakashi Iwai 	SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT_FIXUP_HP_530),
7676dcbadefSTakashi Iwai 	SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT_FIXUP_TOSHIBA_P105),
768ad7725d3STakashi Iwai 	/* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have
769ad7725d3STakashi Iwai 	 * really bad sound over 0dB on NID 0x17.
770ad7725d3STakashi Iwai 	 */
771ad7725d3STakashi Iwai 	SND_PCI_QUIRK_VENDOR(0x103c, "HP", CXT_FIXUP_CAP_MIX_AMP),
772ad7725d3STakashi Iwai 	SND_PCI_QUIRK_VENDOR(0x1631, "Packard Bell", CXT_FIXUP_CAP_MIX_AMP),
773ad7725d3STakashi Iwai 	SND_PCI_QUIRK_VENDOR(0x1734, "Fujitsu", CXT_FIXUP_CAP_MIX_AMP),
774ad7725d3STakashi Iwai 	SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", CXT_FIXUP_CAP_MIX_AMP),
775ad7725d3STakashi Iwai 	{}
776ad7725d3STakashi Iwai };
777ad7725d3STakashi Iwai 
778ad7725d3STakashi Iwai static const struct hda_model_fixup cxt5045_fixup_models[] = {
779ad7725d3STakashi Iwai 	{ .id = CXT_FIXUP_CAP_MIX_AMP, .name = "cap-mix-amp" },
7806dcbadefSTakashi Iwai 	{ .id = CXT_FIXUP_TOSHIBA_P105, .name = "toshiba-p105" },
781e5eac90dSTakashi Iwai 	{ .id = CXT_FIXUP_HP_530, .name = "hp-530" },
782ad7725d3STakashi Iwai 	{}
783e92d4b08STakashi Iwai };
784e92d4b08STakashi Iwai 
785ea30e7dfSTakashi Iwai static const struct snd_pci_quirk cxt5047_fixups[] = {
786ea30e7dfSTakashi Iwai 	/* HP laptops have really bad sound over 0 dB on NID 0x10.
787ea30e7dfSTakashi Iwai 	 */
788ea30e7dfSTakashi Iwai 	SND_PCI_QUIRK_VENDOR(0x103c, "HP", CXT_FIXUP_CAP_MIX_AMP_5047),
789ea30e7dfSTakashi Iwai 	{}
790ea30e7dfSTakashi Iwai };
791ea30e7dfSTakashi Iwai 
792ea30e7dfSTakashi Iwai static const struct hda_model_fixup cxt5047_fixup_models[] = {
793ea30e7dfSTakashi Iwai 	{ .id = CXT_FIXUP_CAP_MIX_AMP_5047, .name = "cap-mix-amp" },
794ea30e7dfSTakashi Iwai 	{}
795ea30e7dfSTakashi Iwai };
796ea30e7dfSTakashi Iwai 
797d70f3632STakashi Iwai static const struct snd_pci_quirk cxt5051_fixups[] = {
798ddb6ca75STakashi Iwai 	SND_PCI_QUIRK(0x103c, 0x360b, "Compaq CQ60", CXT_PINCFG_COMPAQ_CQ60),
799e92d4b08STakashi Iwai 	SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200),
800e92d4b08STakashi Iwai 	{}
801e92d4b08STakashi Iwai };
802e92d4b08STakashi Iwai 
803a2dd933dSTakashi Iwai static const struct hda_model_fixup cxt5051_fixup_models[] = {
804a2dd933dSTakashi Iwai 	{ .id = CXT_PINCFG_LENOVO_X200, .name = "lenovo-x200" },
805a2dd933dSTakashi Iwai 	{}
806a2dd933dSTakashi Iwai };
807a2dd933dSTakashi Iwai 
808d70f3632STakashi Iwai static const struct snd_pci_quirk cxt5066_fixups[] = {
80963a077e2STakashi Iwai 	SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC),
810ff50479aSTakashi Iwai 	SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT_FIXUP_ASPIRE_DMIC),
811522a7fa8SDavid Henningsson 	SND_PCI_QUIRK(0x1025, 0x054f, "Acer Aspire 4830T", CXT_FIXUP_ASPIRE_DMIC),
812e4c3bce2SDavid Henningsson 	SND_PCI_QUIRK(0x1043, 0x138d, "Asus", CXT_FIXUP_HEADPHONE_MIC_PIN),
8133a00c660STakashi Iwai 	SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT_FIXUP_OLPC_XO),
814d70f3632STakashi Iwai 	SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410),
815d70f3632STakashi Iwai 	SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410),
816d70f3632STakashi Iwai 	SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410),
817d70f3632STakashi Iwai 	SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410),
818d70f3632STakashi Iwai 	SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410),
819a555bb8cSDavid Henningsson 	SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT_PINCFG_LENOVO_TP410),
82088d57606SDavid Henningsson 	SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT_PINCFG_LENOVO_TP410),
8213542aed7STakashi Iwai 	SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo IdeaPad Z560", CXT_FIXUP_MUTE_LED_EAPD),
82218dcd304SDavid Henningsson 	SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC),
823e4db0952SFelix Kaechele 	SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC),
824b3c5dce8SDavid Henningsson 	SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC),
8252fd3f170SHui Wang 	SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI),
826239fb862SHuacai Chen 	SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004),
827239fb862SHuacai Chen 	SND_PCI_QUIRK(0x1c06, 0x2012, "Lemote A1205", CXT_PINCFG_LEMOTE_A1205),
828f2e5731dSTakashi Iwai 	{}
829f2e5731dSTakashi Iwai };
830f2e5731dSTakashi Iwai 
831a2dd933dSTakashi Iwai static const struct hda_model_fixup cxt5066_fixup_models[] = {
832a2dd933dSTakashi Iwai 	{ .id = CXT_FIXUP_STEREO_DMIC, .name = "stereo-dmic" },
833a2dd933dSTakashi Iwai 	{ .id = CXT_FIXUP_GPIO1, .name = "gpio1" },
834a2dd933dSTakashi Iwai 	{ .id = CXT_FIXUP_HEADPHONE_MIC_PIN, .name = "headphone-mic-pin" },
835a2dd933dSTakashi Iwai 	{ .id = CXT_PINCFG_LENOVO_TP410, .name = "tp410" },
836a2dd933dSTakashi Iwai 	{ .id = CXT_FIXUP_THINKPAD_ACPI, .name = "thinkpad" },
837a2dd933dSTakashi Iwai 	{ .id = CXT_PINCFG_LEMOTE_A1004, .name = "lemote-a1004" },
8388245b363SHuacai Chen 	{ .id = CXT_PINCFG_LEMOTE_A1205, .name = "lemote-a1205" },
8393a00c660STakashi Iwai 	{ .id = CXT_FIXUP_OLPC_XO, .name = "olpc-xo" },
8403542aed7STakashi Iwai 	{ .id = CXT_FIXUP_MUTE_LED_EAPD, .name = "mute-led-eapd" },
841a2dd933dSTakashi Iwai 	{}
842a2dd933dSTakashi Iwai };
843a2dd933dSTakashi Iwai 
8443868137eSTakashi Iwai /* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches
8453868137eSTakashi Iwai  * can be created (bko#42825)
8463868137eSTakashi Iwai  */
8473868137eSTakashi Iwai static void add_cx5051_fake_mutes(struct hda_codec *codec)
8483868137eSTakashi Iwai {
849d89c6c0cSTakashi Iwai 	struct conexant_spec *spec = codec->spec;
8503868137eSTakashi Iwai 	static hda_nid_t out_nids[] = {
8513868137eSTakashi Iwai 		0x10, 0x11, 0
8523868137eSTakashi Iwai 	};
8533868137eSTakashi Iwai 	hda_nid_t *p;
8543868137eSTakashi Iwai 
8553868137eSTakashi Iwai 	for (p = out_nids; *p; p++)
8563868137eSTakashi Iwai 		snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT,
8573868137eSTakashi Iwai 					  AC_AMPCAP_MIN_MUTE |
8583868137eSTakashi Iwai 					  query_amp_caps(codec, *p, HDA_OUTPUT));
859d89c6c0cSTakashi Iwai 	spec->gen.dac_min_mute = true;
8603868137eSTakashi Iwai }
8613868137eSTakashi Iwai 
862f2e5731dSTakashi Iwai static int patch_conexant_auto(struct hda_codec *codec)
863f2e5731dSTakashi Iwai {
864f2e5731dSTakashi Iwai 	struct conexant_spec *spec;
865f2e5731dSTakashi Iwai 	int err;
866f2e5731dSTakashi Iwai 
8677639a06cSTakashi Iwai 	codec_info(codec, "%s: BIOS auto-probing.\n", codec->core.chip_name);
8681f8458a2STakashi Iwai 
869f2e5731dSTakashi Iwai 	spec = kzalloc(sizeof(*spec), GFP_KERNEL);
870f2e5731dSTakashi Iwai 	if (!spec)
871f2e5731dSTakashi Iwai 		return -ENOMEM;
872aed523f1STakashi Iwai 	snd_hda_gen_spec_init(&spec->gen);
873f2e5731dSTakashi Iwai 	codec->spec = spec;
874225068abSTakashi Iwai 	codec->patch_ops = cx_auto_patch_ops;
875e92d4b08STakashi Iwai 
876aed523f1STakashi Iwai 	cx_auto_parse_beep(codec);
877aed523f1STakashi Iwai 	cx_auto_parse_eapd(codec);
878ff359b14STakashi Iwai 	spec->gen.own_eapd_ctl = 1;
879ff359b14STakashi Iwai 	if (spec->dynamic_eapd)
880aed523f1STakashi Iwai 		spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook;
881e92d4b08STakashi Iwai 
8827639a06cSTakashi Iwai 	switch (codec->core.vendor_id) {
8836b452142STakashi Iwai 	case 0x14f15045:
8844f32456eSMichael Karcher 		codec->single_adc_amp = 1;
88570540e24STakashi Iwai 		spec->gen.mixer_nid = 0x17;
88674f14b36STakashi Iwai 		spec->gen.add_stereo_mix_input = HDA_HINT_STEREO_MIX_AUTO;
887ad7725d3STakashi Iwai 		snd_hda_pick_fixup(codec, cxt5045_fixup_models,
888ad7725d3STakashi Iwai 				   cxt5045_fixups, cxt_fixups);
8896b452142STakashi Iwai 		break;
890164a7adaSTakashi Iwai 	case 0x14f15047:
891164a7adaSTakashi Iwai 		codec->pin_amp_workaround = 1;
892164a7adaSTakashi Iwai 		spec->gen.mixer_nid = 0x19;
89374f14b36STakashi Iwai 		spec->gen.add_stereo_mix_input = HDA_HINT_STEREO_MIX_AUTO;
894ea30e7dfSTakashi Iwai 		snd_hda_pick_fixup(codec, cxt5047_fixup_models,
895ea30e7dfSTakashi Iwai 				   cxt5047_fixups, cxt_fixups);
896164a7adaSTakashi Iwai 		break;
8973868137eSTakashi Iwai 	case 0x14f15051:
8983868137eSTakashi Iwai 		add_cx5051_fake_mutes(codec);
89951969d62SMichael Karcher 		codec->pin_amp_workaround = 1;
900a2dd933dSTakashi Iwai 		snd_hda_pick_fixup(codec, cxt5051_fixup_models,
901a2dd933dSTakashi Iwai 				   cxt5051_fixups, cxt_fixups);
9023868137eSTakashi Iwai 		break;
90351969d62SMichael Karcher 	default:
90451969d62SMichael Karcher 		codec->pin_amp_workaround = 1;
905a2dd933dSTakashi Iwai 		snd_hda_pick_fixup(codec, cxt5066_fixup_models,
906a2dd933dSTakashi Iwai 				   cxt5066_fixups, cxt_fixups);
90723d30f28STakashi Iwai 		break;
9086b452142STakashi Iwai 	}
9096b452142STakashi Iwai 
910f29735cbSTakashi Iwai 	/* Show mute-led control only on HP laptops
911f29735cbSTakashi Iwai 	 * This is a sort of white-list: on HP laptops, EAPD corresponds
912f29735cbSTakashi Iwai 	 * only to the mute-LED without actualy amp function.  Meanwhile,
913f29735cbSTakashi Iwai 	 * others may use EAPD really as an amp switch, so it might be
914f29735cbSTakashi Iwai 	 * not good to expose it blindly.
915527c73baSTakashi Iwai 	 */
9167639a06cSTakashi Iwai 	switch (codec->core.subsystem_id >> 16) {
917f29735cbSTakashi Iwai 	case 0x103c:
918aed523f1STakashi Iwai 		spec->gen.vmaster_mute_enum = 1;
919f29735cbSTakashi Iwai 		break;
920f29735cbSTakashi Iwai 	}
921527c73baSTakashi Iwai 
922aed523f1STakashi Iwai 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
923aed523f1STakashi Iwai 
924e4c3bce2SDavid Henningsson 	err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL,
925e4c3bce2SDavid Henningsson 				       spec->parse_flags);
92622ce5f74STakashi Iwai 	if (err < 0)
927aed523f1STakashi Iwai 		goto error;
928aed523f1STakashi Iwai 
929aed523f1STakashi Iwai 	err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
930aed523f1STakashi Iwai 	if (err < 0)
931aed523f1STakashi Iwai 		goto error;
932aed523f1STakashi Iwai 
9334f2864a4STakashi Iwai 	/* Some laptops with Conexant chips show stalls in S3 resume,
9344f2864a4STakashi Iwai 	 * which falls into the single-cmd mode.
9354f2864a4STakashi Iwai 	 * Better to make reset, then.
9364f2864a4STakashi Iwai 	 */
937d068ebc2STakashi Iwai 	if (!codec->bus->core.sync_write) {
9384e76a883STakashi Iwai 		codec_info(codec,
9394f2864a4STakashi Iwai 			   "Enable sync_write for stable communication\n");
940d068ebc2STakashi Iwai 		codec->bus->core.sync_write = 1;
9414f2864a4STakashi Iwai 		codec->bus->allow_bus_reset = 1;
9424f2864a4STakashi Iwai 	}
9434f2864a4STakashi Iwai 
944e4c3bce2SDavid Henningsson 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
945e4c3bce2SDavid Henningsson 
946f2e5731dSTakashi Iwai 	return 0;
947aed523f1STakashi Iwai 
948aed523f1STakashi Iwai  error:
94908cf680cSDavid Henningsson 	cx_auto_free(codec);
950aed523f1STakashi Iwai 	return err;
951f2e5731dSTakashi Iwai }
952f2e5731dSTakashi Iwai 
953f2e5731dSTakashi Iwai /*
954461e2c78STakashi Iwai  */
955461e2c78STakashi Iwai 
95634cbe3a6STakashi Iwai static const struct hda_codec_preset snd_hda_preset_conexant[] = {
95782f30040STobin Davis 	{ .id = 0x14f15045, .name = "CX20549 (Venice)",
958d0ea6d27STakashi Iwai 	  .patch = patch_conexant_auto },
95982f30040STobin Davis 	{ .id = 0x14f15047, .name = "CX20551 (Waikiki)",
960d0ea6d27STakashi Iwai 	  .patch = patch_conexant_auto },
961461e2c78STakashi Iwai 	{ .id = 0x14f15051, .name = "CX20561 (Hermosa)",
962d0ea6d27STakashi Iwai 	  .patch = patch_conexant_auto },
9630fb67e98SDaniel Drake 	{ .id = 0x14f15066, .name = "CX20582 (Pebble)",
964d0ea6d27STakashi Iwai 	  .patch = patch_conexant_auto },
96595a618bdSEinar Rünkaru 	{ .id = 0x14f15067, .name = "CX20583 (Pebble HSF)",
966d0ea6d27STakashi Iwai 	  .patch = patch_conexant_auto },
967850eab9dSTakashi Iwai 	{ .id = 0x14f15068, .name = "CX20584",
968d0ea6d27STakashi Iwai 	  .patch = patch_conexant_auto },
9697b2bfdbcSJens Taprogge 	{ .id = 0x14f15069, .name = "CX20585",
970d0ea6d27STakashi Iwai 	  .patch = patch_conexant_auto },
971f0ca89b0SDavid Henningsson 	{ .id = 0x14f1506c, .name = "CX20588",
972d0ea6d27STakashi Iwai 	  .patch = patch_conexant_auto },
9736da8b516SDavid Henningsson 	{ .id = 0x14f1506e, .name = "CX20590",
974d0ea6d27STakashi Iwai 	  .patch = patch_conexant_auto },
975f2e5731dSTakashi Iwai 	{ .id = 0x14f15097, .name = "CX20631",
976f2e5731dSTakashi Iwai 	  .patch = patch_conexant_auto },
977f2e5731dSTakashi Iwai 	{ .id = 0x14f15098, .name = "CX20632",
978f2e5731dSTakashi Iwai 	  .patch = patch_conexant_auto },
979f2e5731dSTakashi Iwai 	{ .id = 0x14f150a1, .name = "CX20641",
980f2e5731dSTakashi Iwai 	  .patch = patch_conexant_auto },
981f2e5731dSTakashi Iwai 	{ .id = 0x14f150a2, .name = "CX20642",
982f2e5731dSTakashi Iwai 	  .patch = patch_conexant_auto },
983f2e5731dSTakashi Iwai 	{ .id = 0x14f150ab, .name = "CX20651",
984f2e5731dSTakashi Iwai 	  .patch = patch_conexant_auto },
985f2e5731dSTakashi Iwai 	{ .id = 0x14f150ac, .name = "CX20652",
986f2e5731dSTakashi Iwai 	  .patch = patch_conexant_auto },
987f2e5731dSTakashi Iwai 	{ .id = 0x14f150b8, .name = "CX20664",
988f2e5731dSTakashi Iwai 	  .patch = patch_conexant_auto },
989f2e5731dSTakashi Iwai 	{ .id = 0x14f150b9, .name = "CX20665",
990f2e5731dSTakashi Iwai 	  .patch = patch_conexant_auto },
9916ffc0898SDavid Henningsson 	{ .id = 0x14f150f1, .name = "CX20721",
9926ffc0898SDavid Henningsson 	  .patch = patch_conexant_auto },
9936ffc0898SDavid Henningsson 	{ .id = 0x14f150f2, .name = "CX20722",
9946ffc0898SDavid Henningsson 	  .patch = patch_conexant_auto },
9956ffc0898SDavid Henningsson 	{ .id = 0x14f150f3, .name = "CX20723",
9966ffc0898SDavid Henningsson 	  .patch = patch_conexant_auto },
9976ffc0898SDavid Henningsson 	{ .id = 0x14f150f4, .name = "CX20724",
9986ffc0898SDavid Henningsson 	  .patch = patch_conexant_auto },
9992d825fd8STakashi Iwai 	{ .id = 0x14f1510f, .name = "CX20751/2",
10002d825fd8STakashi Iwai 	  .patch = patch_conexant_auto },
10012d825fd8STakashi Iwai 	{ .id = 0x14f15110, .name = "CX20751/2",
10022d825fd8STakashi Iwai 	  .patch = patch_conexant_auto },
10032d825fd8STakashi Iwai 	{ .id = 0x14f15111, .name = "CX20753/4",
10042d825fd8STakashi Iwai 	  .patch = patch_conexant_auto },
100542c364acSTakashi Iwai 	{ .id = 0x14f15113, .name = "CX20755",
100642c364acSTakashi Iwai 	  .patch = patch_conexant_auto },
100742c364acSTakashi Iwai 	{ .id = 0x14f15114, .name = "CX20756",
100842c364acSTakashi Iwai 	  .patch = patch_conexant_auto },
100942c364acSTakashi Iwai 	{ .id = 0x14f15115, .name = "CX20757",
101042c364acSTakashi Iwai 	  .patch = patch_conexant_auto },
10118f42d769STakashi Iwai 	{ .id = 0x14f151d7, .name = "CX20952",
10128f42d769STakashi Iwai 	  .patch = patch_conexant_auto },
1013c9b443d4STobin Davis 	{} /* terminator */
1014c9b443d4STobin Davis };
10151289e9e8STakashi Iwai 
10161289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15045");
10171289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15047");
10181289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15051");
10190fb67e98SDaniel Drake MODULE_ALIAS("snd-hda-codec-id:14f15066");
102095a618bdSEinar Rünkaru MODULE_ALIAS("snd-hda-codec-id:14f15067");
1021850eab9dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15068");
10227b2bfdbcSJens Taprogge MODULE_ALIAS("snd-hda-codec-id:14f15069");
1023f0ca89b0SDavid Henningsson MODULE_ALIAS("snd-hda-codec-id:14f1506c");
10246da8b516SDavid Henningsson MODULE_ALIAS("snd-hda-codec-id:14f1506e");
1025f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15097");
1026f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15098");
1027f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150a1");
1028f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150a2");
1029f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150ab");
1030f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150ac");
1031f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150b8");
1032f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150b9");
10336ffc0898SDavid Henningsson MODULE_ALIAS("snd-hda-codec-id:14f150f1");
10346ffc0898SDavid Henningsson MODULE_ALIAS("snd-hda-codec-id:14f150f2");
10356ffc0898SDavid Henningsson MODULE_ALIAS("snd-hda-codec-id:14f150f3");
10366ffc0898SDavid Henningsson MODULE_ALIAS("snd-hda-codec-id:14f150f4");
10372d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f1510f");
10382d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15110");
10392d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15111");
104042c364acSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15113");
104142c364acSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15114");
104242c364acSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15115");
10438f42d769STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f151d7");
10441289e9e8STakashi Iwai 
10451289e9e8STakashi Iwai MODULE_LICENSE("GPL");
10461289e9e8STakashi Iwai MODULE_DESCRIPTION("Conexant HD-audio codec");
10471289e9e8STakashi Iwai 
1048d8a766a1STakashi Iwai static struct hda_codec_driver conexant_driver = {
10491289e9e8STakashi Iwai 	.preset = snd_hda_preset_conexant,
10501289e9e8STakashi Iwai };
10511289e9e8STakashi Iwai 
1052d8a766a1STakashi Iwai module_hda_codec_driver(conexant_driver);
1053