Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  * HD audio interface patch for Conexant HDA audio codec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  * Copyright (c) 2006 Pototskiy Akex <alex.pototskiy@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  * 		      Takashi Iwai <tiwai@suse.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  * 		      Tobin Davis  <tdavis@dsl-only.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14) #include <sound/core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) #include <sound/jack.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17) #include <sound/hda_codec.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18) #include "hda_local.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) #include "hda_auto_parser.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) #include "hda_beep.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) #include "hda_jack.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) #include "hda_generic.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) struct conexant_spec {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) 	struct hda_gen_spec gen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) 	/* extra EAPD pins */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) 	unsigned int num_eapds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) 	hda_nid_t eapds[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) 	bool dynamic_eapd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) 	hda_nid_t mute_led_eapd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) 	unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) 	/* OPLC XO specific */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) 	bool recording;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) 	bool dc_enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) 	unsigned int dc_input_bias; /* offset into olpc_xo_dc_bias */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) 	struct nid_path *dc_mode_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) 	int mute_led_polarity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) 	unsigned int gpio_led;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) 	unsigned int gpio_mute_led_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) 	unsigned int gpio_mic_led_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) #ifdef CONFIG_SND_HDA_INPUT_BEEP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) /* additional beep mixers; private_value will be overwritten */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) static const struct snd_kcontrol_new cxt_beep_mixer[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) 	HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) 	HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) static int set_beep_amp(struct conexant_spec *spec, hda_nid_t nid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) 			int idx, int dir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) 	struct snd_kcontrol_new *knew;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) 	unsigned int beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) 	spec->gen.beep_nid = nid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) 	for (i = 0; i < ARRAY_SIZE(cxt_beep_mixer); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) 		knew = snd_hda_gen_add_kctl(&spec->gen, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) 					    &cxt_beep_mixer[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) 		if (!knew)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) 			return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) 		knew->private_value = beep_amp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) static int cx_auto_parse_beep(struct hda_codec *codec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) 	hda_nid_t nid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) 	for_each_hda_codec_node(nid, codec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) 		if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) 			return set_beep_amp(spec, nid, 0, HDA_OUTPUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) #define cx_auto_parse_beep(codec)	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89)  * Automatic parser for CX20641 & co
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) /* parse EAPDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) static void cx_auto_parse_eapd(struct hda_codec *codec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 	hda_nid_t nid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 	for_each_hda_codec_node(nid, codec) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 		if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) 		if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) 		spec->eapds[spec->num_eapds++] = nid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) 		if (spec->num_eapds >= ARRAY_SIZE(spec->eapds))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) 	/* NOTE: below is a wild guess; if we have more than two EAPDs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) 	 * it's a new chip, where EAPDs are supposed to be associated to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 	 * pins, and we can control EAPD per pin.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 	 * OTOH, if only one or two EAPDs are found, it's an old chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) 	 * thus it might control over all pins.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 	if (spec->num_eapds > 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 		spec->dynamic_eapd = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 			      const hda_nid_t *pins, bool on)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 	for (i = 0; i < num_pins; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 		if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) 			snd_hda_codec_write(codec, pins[i], 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 					    AC_VERB_SET_EAPD_BTLENABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) 					    on ? 0x02 : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) /* turn on/off EAPD according to Master switch */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) static void cx_auto_vmaster_hook(void *private_data, int enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 	struct hda_codec *codec = private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 	cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, enabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) /* turn on/off EAPD according to Master switch (inversely!) for mute LED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) static int cx_auto_vmaster_mute_led(struct led_classdev *led_cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) 				    enum led_brightness brightness)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 	struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) 	snd_hda_codec_write(codec, spec->mute_led_eapd, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) 			    AC_VERB_SET_EAPD_BTLENABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) 			    brightness ? 0x02 : 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) static void cxt_init_gpio_led(struct hda_codec *codec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 	unsigned int mask = spec->gpio_mute_led_mask | spec->gpio_mic_led_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 	if (mask) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 		snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 				    mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 		snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 				    mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 		snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 				    spec->gpio_led);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) static int cx_auto_init(struct hda_codec *codec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) 	snd_hda_gen_init(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 	if (!spec->dynamic_eapd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 		cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) 	cxt_init_gpio_led(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) static void cx_auto_reboot_notify(struct hda_codec *codec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 	/* Turn the problematic codec into D3 to avoid spurious noises
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 	   from the internal speaker during (and after) reboot */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 	cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 	snd_hda_gen_reboot_notify(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) static void cx_auto_free(struct hda_codec *codec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 	cx_auto_reboot_notify(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 	snd_hda_gen_free(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) static const struct hda_codec_ops cx_auto_patch_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 	.build_controls = snd_hda_gen_build_controls,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 	.build_pcms = snd_hda_gen_build_pcms,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) 	.init = cx_auto_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) 	.reboot_notify = cx_auto_reboot_notify,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) 	.free = cx_auto_free,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 	.unsol_event = snd_hda_jack_unsol_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 	.check_power_status = snd_hda_gen_check_power_status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209)  * pin fix-up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 	CXT_PINCFG_LENOVO_X200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 	CXT_PINCFG_LENOVO_TP410,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 	CXT_PINCFG_LEMOTE_A1004,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 	CXT_PINCFG_LEMOTE_A1205,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 	CXT_PINCFG_COMPAQ_CQ60,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 	CXT_FIXUP_STEREO_DMIC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 	CXT_FIXUP_INC_MIC_BOOST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 	CXT_FIXUP_HEADPHONE_MIC_PIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 	CXT_FIXUP_HEADPHONE_MIC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 	CXT_FIXUP_GPIO1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 	CXT_FIXUP_ASPIRE_DMIC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 	CXT_FIXUP_THINKPAD_ACPI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 	CXT_FIXUP_OLPC_XO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 	CXT_FIXUP_CAP_MIX_AMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 	CXT_FIXUP_TOSHIBA_P105,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 	CXT_FIXUP_HP_530,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 	CXT_FIXUP_CAP_MIX_AMP_5047,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 	CXT_FIXUP_MUTE_LED_EAPD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 	CXT_FIXUP_HP_DOCK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 	CXT_FIXUP_HP_SPECTRE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 	CXT_FIXUP_HP_GATE_MIC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 	CXT_FIXUP_MUTE_LED_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 	CXT_FIXUP_HP_ZBOOK_MUTE_LED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 	CXT_FIXUP_HEADSET_MIC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 	CXT_FIXUP_HP_MIC_NO_PRESENCE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) /* for hda_fixup_thinkpad_acpi() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) #include "thinkpad_helper.c"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) static void cxt_fixup_stereo_dmic(struct hda_codec *codec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 				  const struct hda_fixup *fix, int action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 	spec->gen.inv_dmic_split = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) static void cxt5066_increase_mic_boost(struct hda_codec *codec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 				   const struct hda_fixup *fix, int action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 	if (action != HDA_FIXUP_ACT_PRE_PROBE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 	snd_hda_override_amp_caps(codec, 0x17, HDA_OUTPUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 				  (0x3 << AC_AMPCAP_OFFSET_SHIFT) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 				  (0x4 << AC_AMPCAP_NUM_STEPS_SHIFT) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 				  (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 				  (0 << AC_AMPCAP_MUTE_SHIFT));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) static void cxt_update_headset_mode(struct hda_codec *codec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 	/* The verbs used in this function were tested on a Conexant CX20751/2 codec. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 	bool mic_mode = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) 	struct auto_pin_cfg *cfg = &spec->gen.autocfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 	hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 	for (i = 0; i < cfg->num_inputs; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 		if (cfg->inputs[i].pin == mux_pin) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) 			mic_mode = !!cfg->inputs[i].is_headphone_mic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 	if (mic_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 		snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x7c); /* enable merged mode for analog int-mic */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 		spec->gen.hp_jack_present = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 		snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x54); /* disable merged mode for analog int-mic */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 		spec->gen.hp_jack_present = snd_hda_jack_detect(codec, spec->gen.autocfg.hp_pins[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 	snd_hda_gen_update_outputs(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) static void cxt_update_headset_mode_hook(struct hda_codec *codec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 					 struct snd_kcontrol *kcontrol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 					 struct snd_ctl_elem_value *ucontrol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 	cxt_update_headset_mode(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) static void cxt_fixup_headphone_mic(struct hda_codec *codec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 				    const struct hda_fixup *fix, int action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 	switch (action) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 	case HDA_FIXUP_ACT_PRE_PROBE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 		spec->parse_flags |= HDA_PINCFG_HEADPHONE_MIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 		snd_hdac_regmap_add_vendor_verb(&codec->core, 0x410);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 	case HDA_FIXUP_ACT_PROBE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 		WARN_ON(spec->gen.cap_sync_hook);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 		spec->gen.cap_sync_hook = cxt_update_headset_mode_hook;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 		spec->gen.automute_hook = cxt_update_headset_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 	case HDA_FIXUP_ACT_INIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 		cxt_update_headset_mode(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) static void cxt_fixup_headset_mic(struct hda_codec *codec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 				    const struct hda_fixup *fix, int action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 	switch (action) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 	case HDA_FIXUP_ACT_PRE_PROBE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) /* OPLC XO 1.5 fixup */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332)  * through the microphone jack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333)  * When the user enables this through a mixer switch, both internal and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334)  * external microphones are disabled. Gain is fixed at 0dB. In this mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335)  * we also allow the bias to be configured through a separate mixer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336)  * control. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) #define update_mic_pin(codec, nid, val)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 	snd_hda_codec_write_cache(codec, nid, 0,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 				   AC_VERB_SET_PIN_WIDGET_CONTROL, val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) static const struct hda_input_mux olpc_xo_dc_bias = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 	.num_items = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 	.items = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 		{ "Off", PIN_IN },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 		{ "50%", PIN_VREF50 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 		{ "80%", PIN_VREF80 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) static void olpc_xo_update_mic_boost(struct hda_codec *codec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 	int ch, val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 	for (ch = 0; ch < 2; ch++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) 		val = AC_AMP_SET_OUTPUT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 			(ch ? AC_AMP_SET_RIGHT : AC_AMP_SET_LEFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 		if (!spec->dc_enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 			val |= snd_hda_codec_amp_read(codec, 0x17, ch, HDA_OUTPUT, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 		snd_hda_codec_write(codec, 0x17, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 				    AC_VERB_SET_AMP_GAIN_MUTE, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) static void olpc_xo_update_mic_pins(struct hda_codec *codec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 	int cur_input, val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 	struct nid_path *path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 	cur_input = spec->gen.input_paths[0][spec->gen.cur_mux[0]];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 	/* Set up mic pins for port-B, C and F dynamically as the recording
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 	 * LED is turned on/off by these pin controls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 	if (!spec->dc_enable) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 		/* disable DC bias path and pin for port F */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 		update_mic_pin(codec, 0x1e, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 		snd_hda_activate_path(codec, spec->dc_mode_path, false, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 		/* update port B (ext mic) and C (int mic) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 		/* OLPC defers mic widget control until when capture is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 		 * started because the microphone LED comes on as soon as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 		 * these settings are put in place. if we did this before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 		 * recording, it would give the false indication that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 		 * recording is happening when it is not.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 		update_mic_pin(codec, 0x1a, spec->recording ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 			       snd_hda_codec_get_pin_target(codec, 0x1a) : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 		update_mic_pin(codec, 0x1b, spec->recording ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 			       snd_hda_codec_get_pin_target(codec, 0x1b) : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 		/* enable normal mic path */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 		path = snd_hda_get_path_from_idx(codec, cur_input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 		if (path)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 			snd_hda_activate_path(codec, path, true, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 		/* disable normal mic path */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 		path = snd_hda_get_path_from_idx(codec, cur_input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 		if (path)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 			snd_hda_activate_path(codec, path, false, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 		/* Even though port F is the DC input, the bias is controlled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 		 * on port B.  We also leave that port as an active input (but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 		 * unselected) in DC mode just in case that is necessary to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 		 * make the bias setting take effect.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 		if (spec->recording)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 			val = olpc_xo_dc_bias.items[spec->dc_input_bias].index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 			val = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 		update_mic_pin(codec, 0x1a, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 		update_mic_pin(codec, 0x1b, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 		/* enable DC bias path and pin */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 		update_mic_pin(codec, 0x1e, spec->recording ? PIN_IN : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 		snd_hda_activate_path(codec, spec->dc_mode_path, true, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) /* mic_autoswitch hook */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) static void olpc_xo_automic(struct hda_codec *codec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 			    struct hda_jack_callback *jack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 	/* in DC mode, we don't handle automic */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 	if (!spec->dc_enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 		snd_hda_gen_mic_autoswitch(codec, jack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 	olpc_xo_update_mic_pins(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 	if (spec->dc_enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 		olpc_xo_update_mic_boost(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) /* pcm_capture hook */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) static void olpc_xo_capture_hook(struct hda_pcm_stream *hinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 				 struct hda_codec *codec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 				 struct snd_pcm_substream *substream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 				 int action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 	/* toggle spec->recording flag and update mic pins accordingly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 	 * for turning on/off LED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 	switch (action) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 	case HDA_GEN_PCM_ACT_PREPARE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 		spec->recording = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 		olpc_xo_update_mic_pins(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 	case HDA_GEN_PCM_ACT_CLEANUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 		spec->recording = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 		olpc_xo_update_mic_pins(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) static int olpc_xo_dc_mode_get(struct snd_kcontrol *kcontrol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 			       struct snd_ctl_elem_value *ucontrol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 	ucontrol->value.integer.value[0] = spec->dc_enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) static int olpc_xo_dc_mode_put(struct snd_kcontrol *kcontrol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 			       struct snd_ctl_elem_value *ucontrol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 	int dc_enable = !!ucontrol->value.integer.value[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 	if (dc_enable == spec->dc_enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 	spec->dc_enable = dc_enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 	olpc_xo_update_mic_pins(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 	olpc_xo_update_mic_boost(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) static int olpc_xo_dc_bias_enum_get(struct snd_kcontrol *kcontrol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 				    struct snd_ctl_elem_value *ucontrol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 	ucontrol->value.enumerated.item[0] = spec->dc_input_bias;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) static int olpc_xo_dc_bias_enum_info(struct snd_kcontrol *kcontrol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 				     struct snd_ctl_elem_info *uinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 	return snd_hda_input_mux_info(&olpc_xo_dc_bias, uinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) static int olpc_xo_dc_bias_enum_put(struct snd_kcontrol *kcontrol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 				    struct snd_ctl_elem_value *ucontrol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 	const struct hda_input_mux *imux = &olpc_xo_dc_bias;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 	unsigned int idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 	idx = ucontrol->value.enumerated.item[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 	if (idx >= imux->num_items)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 		idx = imux->num_items - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 	if (spec->dc_input_bias == idx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 	spec->dc_input_bias = idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 	if (spec->dc_enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 		olpc_xo_update_mic_pins(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) static const struct snd_kcontrol_new olpc_xo_mixers[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 		.name = "DC Mode Enable Switch",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 		.info = snd_ctl_boolean_mono_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 		.get = olpc_xo_dc_mode_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 		.put = olpc_xo_dc_mode_put,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 		.name = "DC Input Bias Enum",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 		.info = olpc_xo_dc_bias_enum_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 		.get = olpc_xo_dc_bias_enum_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 		.put = olpc_xo_dc_bias_enum_put,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) /* overriding mic boost put callback; update mic boost volume only when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536)  * DC mode is disabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) static int olpc_xo_mic_boost_put(struct snd_kcontrol *kcontrol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 				 struct snd_ctl_elem_value *ucontrol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 	int ret = snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 	if (ret > 0 && spec->dc_enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 		olpc_xo_update_mic_boost(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) static void cxt_fixup_olpc_xo(struct hda_codec *codec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 				    const struct hda_fixup *fix, int action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 	struct snd_kcontrol_new *kctl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 	if (action != HDA_FIXUP_ACT_PROBE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) 	spec->gen.mic_autoswitch_hook = olpc_xo_automic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 	spec->gen.pcm_capture_hook = olpc_xo_capture_hook;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 	spec->dc_mode_path = snd_hda_add_new_path(codec, 0x1e, 0x14, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 	snd_hda_add_new_ctls(codec, olpc_xo_mixers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 	/* OLPC's microphone port is DC coupled for use with external sensors,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 	 * therefore we use a 50% mic bias in order to center the input signal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 	 * with the DC input range of the codec.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 	snd_hda_codec_set_pin_target(codec, 0x1a, PIN_VREF50);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 	/* override mic boost control */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 	snd_array_for_each(&spec->gen.kctls, i, kctl) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 		if (!strcmp(kctl->name, "Mic Boost Volume")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 			kctl->put = olpc_xo_mic_boost_put;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) static void cxt_fixup_mute_led_eapd(struct hda_codec *codec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 				    const struct hda_fixup *fix, int action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 		spec->mute_led_eapd = 0x1b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 		spec->dynamic_eapd = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 		snd_hda_gen_add_mute_led_cdev(codec, cx_auto_vmaster_mute_led);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593)  * Fix max input level on mixer widget to 0dB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594)  * (originally it has 0x2b steps with 0dB offset 0x14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) static void cxt_fixup_cap_mix_amp(struct hda_codec *codec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 				  const struct hda_fixup *fix, int action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 	snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 				  (0x14 << AC_AMPCAP_OFFSET_SHIFT) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 				  (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 				  (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 				  (1 << AC_AMPCAP_MUTE_SHIFT));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607)  * Fix max input level on mixer widget to 0dB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608)  * (originally it has 0x1e steps with 0 dB offset 0x17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) static void cxt_fixup_cap_mix_amp_5047(struct hda_codec *codec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 				  const struct hda_fixup *fix, int action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 	snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 				  (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 				  (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 				  (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 				  (1 << AC_AMPCAP_MUTE_SHIFT));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) static void cxt_fixup_hp_gate_mic_jack(struct hda_codec *codec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 				       const struct hda_fixup *fix,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 				       int action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 	/* the mic pin (0x19) doesn't give an unsolicited event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 	 * probe the mic pin together with the headphone pin (0x16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 	if (action == HDA_FIXUP_ACT_PROBE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 		snd_hda_jack_set_gating_jack(codec, 0x19, 0x16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) /* update LED status via GPIO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) static void cxt_update_gpio_led(struct hda_codec *codec, unsigned int mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 				bool led_on)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 	unsigned int oldval = spec->gpio_led;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 	if (spec->mute_led_polarity)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) 		led_on = !led_on;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 	if (led_on)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 		spec->gpio_led |= mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 		spec->gpio_led &= ~mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) 	codec_dbg(codec, "mask:%d enabled:%d gpio_led:%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 			mask, led_on, spec->gpio_led);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 	if (spec->gpio_led != oldval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 		snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 				    spec->gpio_led);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) /* turn on/off mute LED via GPIO per vmaster hook */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) static int cxt_gpio_mute_update(struct led_classdev *led_cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 				enum led_brightness brightness)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) 	struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 	cxt_update_gpio_led(codec, spec->gpio_mute_led_mask, brightness);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) /* turn on/off mic-mute LED via GPIO per capture hook */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) static int cxt_gpio_micmute_update(struct led_classdev *led_cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 				   enum led_brightness brightness)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 	struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 	cxt_update_gpio_led(codec, spec->gpio_mic_led_mask, brightness);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) static void cxt_setup_mute_led(struct hda_codec *codec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 			       unsigned int mute, unsigned int mic_mute)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 	spec->gpio_led = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 	spec->mute_led_polarity = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 	if (mute) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 		snd_hda_gen_add_mute_led_cdev(codec, cxt_gpio_mute_update);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 		spec->gpio_mute_led_mask = mute;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 	if (mic_mute) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 		snd_hda_gen_add_micmute_led_cdev(codec, cxt_gpio_micmute_update);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 		spec->gpio_mic_led_mask = mic_mute;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) static void cxt_fixup_mute_led_gpio(struct hda_codec *codec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 				const struct hda_fixup *fix, int action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 		cxt_setup_mute_led(codec, 0x01, 0x02);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) static void cxt_fixup_hp_zbook_mute_led(struct hda_codec *codec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 					const struct hda_fixup *fix, int action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 	if (action == HDA_FIXUP_ACT_PRE_PROBE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 		cxt_setup_mute_led(codec, 0x10, 0x20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) /* ThinkPad X200 & co with cxt5051 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 	{ 0x16, 0x042140ff }, /* HP (seq# overridden) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 	{ 0x17, 0x21a11000 }, /* dock-mic */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 	{ 0x19, 0x2121103f }, /* dock-HP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 	{ 0x1c, 0x21440100 }, /* dock SPDIF out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) /* ThinkPad 410/420/510/520, X201 & co with cxt5066 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) static const struct hda_pintbl cxt_pincfg_lenovo_tp410[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 	{ 0x19, 0x042110ff }, /* HP (seq# overridden) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 	{ 0x1a, 0x21a190f0 }, /* dock-mic */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 	{ 0x1c, 0x212140ff }, /* dock-HP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) /* Lemote A1004/A1205 with cxt5066 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) static const struct hda_pintbl cxt_pincfg_lemote[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 	{ 0x1a, 0x90a10020 }, /* Internal mic */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 	{ 0x1b, 0x03a11020 }, /* External mic */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 	{ 0x1d, 0x400101f0 }, /* Not used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 	{ 0x1e, 0x40a701f0 }, /* Not used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 	{ 0x20, 0x404501f0 }, /* Not used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 	{ 0x22, 0x404401f0 }, /* Not used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 	{ 0x23, 0x40a701f0 }, /* Not used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) static const struct hda_fixup cxt_fixups[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 	[CXT_PINCFG_LENOVO_X200] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 		.type = HDA_FIXUP_PINS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 		.v.pins = cxt_pincfg_lenovo_x200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 	[CXT_PINCFG_LENOVO_TP410] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 		.type = HDA_FIXUP_PINS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 		.v.pins = cxt_pincfg_lenovo_tp410,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 		.chained = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 		.chain_id = CXT_FIXUP_THINKPAD_ACPI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 	[CXT_PINCFG_LEMOTE_A1004] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 		.type = HDA_FIXUP_PINS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 		.chained = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 		.chain_id = CXT_FIXUP_INC_MIC_BOOST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 		.v.pins = cxt_pincfg_lemote,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 	[CXT_PINCFG_LEMOTE_A1205] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 		.type = HDA_FIXUP_PINS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 		.v.pins = cxt_pincfg_lemote,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 	[CXT_PINCFG_COMPAQ_CQ60] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 		.type = HDA_FIXUP_PINS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 		.v.pins = (const struct hda_pintbl[]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 			/* 0x17 was falsely set up as a mic, it should 0x1d */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 			{ 0x17, 0x400001f0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 			{ 0x1d, 0x97a70120 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 			{ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 	[CXT_FIXUP_STEREO_DMIC] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 		.type = HDA_FIXUP_FUNC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 		.v.func = cxt_fixup_stereo_dmic,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 	[CXT_FIXUP_INC_MIC_BOOST] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 		.type = HDA_FIXUP_FUNC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 		.v.func = cxt5066_increase_mic_boost,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 	[CXT_FIXUP_HEADPHONE_MIC_PIN] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 		.type = HDA_FIXUP_PINS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 		.chained = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 		.chain_id = CXT_FIXUP_HEADPHONE_MIC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 		.v.pins = (const struct hda_pintbl[]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 			{ 0x18, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 			{ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 	[CXT_FIXUP_HEADPHONE_MIC] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 		.type = HDA_FIXUP_FUNC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 		.v.func = cxt_fixup_headphone_mic,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 	[CXT_FIXUP_GPIO1] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 		.type = HDA_FIXUP_VERBS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 		.v.verbs = (const struct hda_verb[]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 			{ 0x01, AC_VERB_SET_GPIO_MASK, 0x01 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 			{ 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 			{ 0x01, AC_VERB_SET_GPIO_DATA, 0x01 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) 			{ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 	[CXT_FIXUP_ASPIRE_DMIC] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 		.type = HDA_FIXUP_FUNC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) 		.v.func = cxt_fixup_stereo_dmic,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 		.chained = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 		.chain_id = CXT_FIXUP_GPIO1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 	[CXT_FIXUP_THINKPAD_ACPI] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 		.type = HDA_FIXUP_FUNC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 		.v.func = hda_fixup_thinkpad_acpi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 	[CXT_FIXUP_OLPC_XO] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 		.type = HDA_FIXUP_FUNC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 		.v.func = cxt_fixup_olpc_xo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 	[CXT_FIXUP_CAP_MIX_AMP] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 		.type = HDA_FIXUP_FUNC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 		.v.func = cxt_fixup_cap_mix_amp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 	[CXT_FIXUP_TOSHIBA_P105] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 		.type = HDA_FIXUP_PINS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 		.v.pins = (const struct hda_pintbl[]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 			{ 0x10, 0x961701f0 }, /* speaker/hp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 			{ 0x12, 0x02a1901e }, /* ext mic */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 			{ 0x14, 0x95a70110 }, /* int mic */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 			{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 	[CXT_FIXUP_HP_530] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 		.type = HDA_FIXUP_PINS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 		.v.pins = (const struct hda_pintbl[]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 			{ 0x12, 0x90a60160 }, /* int mic */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 			{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 		.chained = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 		.chain_id = CXT_FIXUP_CAP_MIX_AMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 	[CXT_FIXUP_CAP_MIX_AMP_5047] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 		.type = HDA_FIXUP_FUNC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 		.v.func = cxt_fixup_cap_mix_amp_5047,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 	[CXT_FIXUP_MUTE_LED_EAPD] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 		.type = HDA_FIXUP_FUNC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 		.v.func = cxt_fixup_mute_led_eapd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 	[CXT_FIXUP_HP_DOCK] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 		.type = HDA_FIXUP_PINS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 		.v.pins = (const struct hda_pintbl[]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 			{ 0x16, 0x21011020 }, /* line-out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 			{ 0x18, 0x2181103f }, /* line-in */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 			{ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 		.chained = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 		.chain_id = CXT_FIXUP_MUTE_LED_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 	[CXT_FIXUP_HP_SPECTRE] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 		.type = HDA_FIXUP_PINS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 		.v.pins = (const struct hda_pintbl[]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 			/* enable NID 0x1d for the speaker on top */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 			{ 0x1d, 0x91170111 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 			{ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 	[CXT_FIXUP_HP_GATE_MIC] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) 		.type = HDA_FIXUP_FUNC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 		.v.func = cxt_fixup_hp_gate_mic_jack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 	[CXT_FIXUP_MUTE_LED_GPIO] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 		.type = HDA_FIXUP_FUNC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 		.v.func = cxt_fixup_mute_led_gpio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 	[CXT_FIXUP_HP_ZBOOK_MUTE_LED] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 		.type = HDA_FIXUP_FUNC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 		.v.func = cxt_fixup_hp_zbook_mute_led,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 	[CXT_FIXUP_HEADSET_MIC] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 		.type = HDA_FIXUP_FUNC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 		.v.func = cxt_fixup_headset_mic,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 	[CXT_FIXUP_HP_MIC_NO_PRESENCE] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 		.type = HDA_FIXUP_PINS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 		.v.pins = (const struct hda_pintbl[]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 			{ 0x1a, 0x02a1113c },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 			{ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 		.chained = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 		.chain_id = CXT_FIXUP_HEADSET_MIC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) static const struct snd_pci_quirk cxt5045_fixups[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) 	SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT_FIXUP_HP_530),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 	SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT_FIXUP_TOSHIBA_P105),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 	/* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 	 * really bad sound over 0dB on NID 0x17.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 	SND_PCI_QUIRK_VENDOR(0x103c, "HP", CXT_FIXUP_CAP_MIX_AMP),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 	SND_PCI_QUIRK_VENDOR(0x1631, "Packard Bell", CXT_FIXUP_CAP_MIX_AMP),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 	SND_PCI_QUIRK_VENDOR(0x1734, "Fujitsu", CXT_FIXUP_CAP_MIX_AMP),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 	SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", CXT_FIXUP_CAP_MIX_AMP),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) static const struct hda_model_fixup cxt5045_fixup_models[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 	{ .id = CXT_FIXUP_CAP_MIX_AMP, .name = "cap-mix-amp" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 	{ .id = CXT_FIXUP_TOSHIBA_P105, .name = "toshiba-p105" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 	{ .id = CXT_FIXUP_HP_530, .name = "hp-530" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) static const struct snd_pci_quirk cxt5047_fixups[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 	/* HP laptops have really bad sound over 0 dB on NID 0x10.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 	SND_PCI_QUIRK_VENDOR(0x103c, "HP", CXT_FIXUP_CAP_MIX_AMP_5047),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) static const struct hda_model_fixup cxt5047_fixup_models[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 	{ .id = CXT_FIXUP_CAP_MIX_AMP_5047, .name = "cap-mix-amp" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) static const struct snd_pci_quirk cxt5051_fixups[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) 	SND_PCI_QUIRK(0x103c, 0x360b, "Compaq CQ60", CXT_PINCFG_COMPAQ_CQ60),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 	SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) static const struct hda_model_fixup cxt5051_fixup_models[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 	{ .id = CXT_PINCFG_LENOVO_X200, .name = "lenovo-x200" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) static const struct snd_pci_quirk cxt5066_fixups[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 	SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 	SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT_FIXUP_ASPIRE_DMIC),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 	SND_PCI_QUIRK(0x1025, 0x054f, "Acer Aspire 4830T", CXT_FIXUP_ASPIRE_DMIC),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 	SND_PCI_QUIRK(0x103c, 0x8079, "HP EliteBook 840 G3", CXT_FIXUP_HP_DOCK),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 	SND_PCI_QUIRK(0x103c, 0x807C, "HP EliteBook 820 G3", CXT_FIXUP_HP_DOCK),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 	SND_PCI_QUIRK(0x103c, 0x80FD, "HP ProBook 640 G2", CXT_FIXUP_HP_DOCK),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 	SND_PCI_QUIRK(0x103c, 0x8115, "HP Z1 Gen3", CXT_FIXUP_HP_GATE_MIC),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 	SND_PCI_QUIRK(0x103c, 0x814f, "HP ZBook 15u G3", CXT_FIXUP_MUTE_LED_GPIO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 	SND_PCI_QUIRK(0x103c, 0x8174, "HP Spectre x360", CXT_FIXUP_HP_SPECTRE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 	SND_PCI_QUIRK(0x103c, 0x822e, "HP ProBook 440 G4", CXT_FIXUP_MUTE_LED_GPIO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 	SND_PCI_QUIRK(0x103c, 0x828c, "HP EliteBook 840 G4", CXT_FIXUP_HP_DOCK),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 	SND_PCI_QUIRK(0x103c, 0x8299, "HP 800 G3 SFF", CXT_FIXUP_HP_MIC_NO_PRESENCE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 	SND_PCI_QUIRK(0x103c, 0x829a, "HP 800 G3 DM", CXT_FIXUP_HP_MIC_NO_PRESENCE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 	SND_PCI_QUIRK(0x103c, 0x836e, "HP ProBook 455 G5", CXT_FIXUP_MUTE_LED_GPIO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 	SND_PCI_QUIRK(0x103c, 0x837f, "HP ProBook 470 G5", CXT_FIXUP_MUTE_LED_GPIO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 	SND_PCI_QUIRK(0x103c, 0x83b2, "HP EliteBook 840 G5", CXT_FIXUP_HP_DOCK),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 	SND_PCI_QUIRK(0x103c, 0x83b3, "HP EliteBook 830 G5", CXT_FIXUP_HP_DOCK),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 	SND_PCI_QUIRK(0x103c, 0x83d3, "HP ProBook 640 G4", CXT_FIXUP_HP_DOCK),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 	SND_PCI_QUIRK(0x103c, 0x8402, "HP ProBook 645 G4", CXT_FIXUP_MUTE_LED_GPIO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 	SND_PCI_QUIRK(0x103c, 0x8427, "HP ZBook Studio G5", CXT_FIXUP_HP_ZBOOK_MUTE_LED),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 	SND_PCI_QUIRK(0x103c, 0x844f, "HP ZBook Studio G5", CXT_FIXUP_HP_ZBOOK_MUTE_LED),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 	SND_PCI_QUIRK(0x103c, 0x8455, "HP Z2 G4", CXT_FIXUP_HP_MIC_NO_PRESENCE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 	SND_PCI_QUIRK(0x103c, 0x8456, "HP Z2 G4 SFF", CXT_FIXUP_HP_MIC_NO_PRESENCE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 	SND_PCI_QUIRK(0x103c, 0x8457, "HP Z2 G4 mini", CXT_FIXUP_HP_MIC_NO_PRESENCE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 	SND_PCI_QUIRK(0x103c, 0x8458, "HP Z2 G4 mini premium", CXT_FIXUP_HP_MIC_NO_PRESENCE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 	SND_PCI_QUIRK(0x1043, 0x138d, "Asus", CXT_FIXUP_HEADPHONE_MIC_PIN),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 	SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT_FIXUP_OLPC_XO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 	SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 	SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 	SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 	SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 	SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 	SND_PCI_QUIRK(0x17aa, 0x21d2, "Lenovo T420s", CXT_PINCFG_LENOVO_TP410),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 	SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT_PINCFG_LENOVO_TP410),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 	SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT_PINCFG_LENOVO_TP410),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 	SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo IdeaPad Z560", CXT_FIXUP_MUTE_LED_EAPD),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) 	SND_PCI_QUIRK(0x17aa, 0x3905, "Lenovo G50-30", CXT_FIXUP_STEREO_DMIC),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 	SND_PCI_QUIRK(0x17aa, 0x390b, "Lenovo G50-80", CXT_FIXUP_STEREO_DMIC),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 	SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 	SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 	SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo G50-70", CXT_FIXUP_STEREO_DMIC),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 	SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 	SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 	SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 	SND_PCI_QUIRK(0x1c06, 0x2012, "Lemote A1205", CXT_PINCFG_LEMOTE_A1205),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) static const struct hda_model_fixup cxt5066_fixup_models[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 	{ .id = CXT_FIXUP_STEREO_DMIC, .name = "stereo-dmic" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 	{ .id = CXT_FIXUP_GPIO1, .name = "gpio1" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 	{ .id = CXT_FIXUP_HEADPHONE_MIC_PIN, .name = "headphone-mic-pin" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 	{ .id = CXT_PINCFG_LENOVO_TP410, .name = "tp410" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 	{ .id = CXT_FIXUP_THINKPAD_ACPI, .name = "thinkpad" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 	{ .id = CXT_PINCFG_LEMOTE_A1004, .name = "lemote-a1004" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 	{ .id = CXT_PINCFG_LEMOTE_A1205, .name = "lemote-a1205" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 	{ .id = CXT_FIXUP_OLPC_XO, .name = "olpc-xo" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 	{ .id = CXT_FIXUP_MUTE_LED_EAPD, .name = "mute-led-eapd" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 	{ .id = CXT_FIXUP_HP_DOCK, .name = "hp-dock" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 	{ .id = CXT_FIXUP_MUTE_LED_GPIO, .name = "mute-led-gpio" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 	{ .id = CXT_FIXUP_HP_ZBOOK_MUTE_LED, .name = "hp-zbook-mute-led" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 	{ .id = CXT_FIXUP_HP_MIC_NO_PRESENCE, .name = "hp-mic-fix" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) /* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993)  * can be created (bko#42825)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) static void add_cx5051_fake_mutes(struct hda_codec *codec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) 	struct conexant_spec *spec = codec->spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 	static const hda_nid_t out_nids[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) 		0x10, 0x11, 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 	const hda_nid_t *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 	for (p = out_nids; *p; p++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 		snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) 					  AC_AMPCAP_MIN_MUTE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 					  query_amp_caps(codec, *p, HDA_OUTPUT));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 	spec->gen.dac_min_mute = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) static int patch_conexant_auto(struct hda_codec *codec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 	struct conexant_spec *spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 	codec_info(codec, "%s: BIOS auto-probing.\n", codec->core.chip_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 	spec = kzalloc(sizeof(*spec), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 	if (!spec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) 	snd_hda_gen_spec_init(&spec->gen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 	codec->spec = spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 	codec->patch_ops = cx_auto_patch_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 	cx_auto_parse_eapd(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 	spec->gen.own_eapd_ctl = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 	switch (codec->core.vendor_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 	case 0x14f15045:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 		codec->single_adc_amp = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 		spec->gen.mixer_nid = 0x17;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 		spec->gen.add_stereo_mix_input = HDA_HINT_STEREO_MIX_AUTO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 		snd_hda_pick_fixup(codec, cxt5045_fixup_models,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 				   cxt5045_fixups, cxt_fixups);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 	case 0x14f15047:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 		codec->pin_amp_workaround = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 		spec->gen.mixer_nid = 0x19;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 		spec->gen.add_stereo_mix_input = HDA_HINT_STEREO_MIX_AUTO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 		snd_hda_pick_fixup(codec, cxt5047_fixup_models,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 				   cxt5047_fixups, cxt_fixups);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 	case 0x14f15051:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) 		add_cx5051_fake_mutes(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) 		codec->pin_amp_workaround = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) 		snd_hda_pick_fixup(codec, cxt5051_fixup_models,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) 				   cxt5051_fixups, cxt_fixups);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) 	case 0x14f150f2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) 		codec->power_save_node = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) 		codec->pin_amp_workaround = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) 		snd_hda_pick_fixup(codec, cxt5066_fixup_models,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) 				   cxt5066_fixups, cxt_fixups);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) 	if (!spec->gen.vmaster_mute.hook && spec->dynamic_eapd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 		spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) 	err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) 				       spec->parse_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) 	if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) 		goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) 	err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) 	if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) 		goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 	err = cx_auto_parse_beep(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) 	if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) 		goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 	/* Some laptops with Conexant chips show stalls in S3 resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) 	 * which falls into the single-cmd mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) 	 * Better to make reset, then.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) 	if (!codec->bus->core.sync_write) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) 		codec_info(codec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) 			   "Enable sync_write for stable communication\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) 		codec->bus->core.sync_write = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) 		codec->bus->allow_bus_reset = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) 	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091)  error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) 	cx_auto_free(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) static const struct hda_device_id snd_hda_id_conexant[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 	HDA_CODEC_ENTRY(0x14f11f86, "CX8070", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) 	HDA_CODEC_ENTRY(0x14f12008, "CX8200", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) 	HDA_CODEC_ENTRY(0x14f120d0, "CX11970", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 	HDA_CODEC_ENTRY(0x14f15045, "CX20549 (Venice)", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) 	HDA_CODEC_ENTRY(0x14f15047, "CX20551 (Waikiki)", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) 	HDA_CODEC_ENTRY(0x14f15051, "CX20561 (Hermosa)", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) 	HDA_CODEC_ENTRY(0x14f15066, "CX20582 (Pebble)", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 	HDA_CODEC_ENTRY(0x14f15067, "CX20583 (Pebble HSF)", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) 	HDA_CODEC_ENTRY(0x14f15068, "CX20584", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) 	HDA_CODEC_ENTRY(0x14f15069, "CX20585", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 	HDA_CODEC_ENTRY(0x14f1506c, "CX20588", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) 	HDA_CODEC_ENTRY(0x14f1506e, "CX20590", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 	HDA_CODEC_ENTRY(0x14f15097, "CX20631", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 	HDA_CODEC_ENTRY(0x14f15098, "CX20632", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 	HDA_CODEC_ENTRY(0x14f150a1, "CX20641", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 	HDA_CODEC_ENTRY(0x14f150a2, "CX20642", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 	HDA_CODEC_ENTRY(0x14f150ab, "CX20651", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 	HDA_CODEC_ENTRY(0x14f150ac, "CX20652", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 	HDA_CODEC_ENTRY(0x14f150b8, "CX20664", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) 	HDA_CODEC_ENTRY(0x14f150b9, "CX20665", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) 	HDA_CODEC_ENTRY(0x14f150f1, "CX21722", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 	HDA_CODEC_ENTRY(0x14f150f2, "CX20722", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) 	HDA_CODEC_ENTRY(0x14f150f3, "CX21724", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) 	HDA_CODEC_ENTRY(0x14f150f4, "CX20724", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) 	HDA_CODEC_ENTRY(0x14f1510f, "CX20751/2", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 	HDA_CODEC_ENTRY(0x14f15110, "CX20751/2", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 	HDA_CODEC_ENTRY(0x14f15111, "CX20753/4", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) 	HDA_CODEC_ENTRY(0x14f15113, "CX20755", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) 	HDA_CODEC_ENTRY(0x14f15114, "CX20756", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) 	HDA_CODEC_ENTRY(0x14f15115, "CX20757", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) 	HDA_CODEC_ENTRY(0x14f151d7, "CX20952", patch_conexant_auto),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) 	{} /* terminator */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_conexant);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) MODULE_DESCRIPTION("Conexant HD-audio codec");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) static struct hda_codec_driver conexant_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) 	.id = snd_hda_id_conexant,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) module_hda_codec_driver(conexant_driver);