Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: rt711-sdca: add GE selected mode control

The SDCA spec defines a 'selected_mode' control which can override
the 'detected_mode' reported by hardware.
This is useful for platform integration as well as in cases
where the hardware(e.g. 3.5mm jack cable) is not able to accurately detect the jack type.

Signed-off-by: Shuming Fan <shumingf@realtek.com>
Tested-by: yung-chuan.liao@linux.intel.com
Link: https://patch.msgid.link/20240625084303.2273911-1-shumingf@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Shuming Fan and committed by
Mark Brown
50b8affb 903e8509

+73
+72
sound/soc/codecs/rt711-sdca.c
··· 81 81 RT711_HDA_LEGACY_RESET_CTL, 0x1, 0x1); 82 82 } 83 83 84 + static void rt711_sdca_ge_force_jack_type(struct rt711_sdca_priv *rt711, unsigned int det_mode) 85 + { 86 + switch (det_mode) { 87 + case 0x00: 88 + rt711_sdca_index_update_bits(rt711, RT711_VENDOR_REG, RT711_COMBO_JACK_AUTO_CTL1, 0x8400, 0x0000); 89 + rt711_sdca_index_update_bits(rt711, RT711_VENDOR_HDA_CTL, RT711_PUSH_BTN_INT_CTL0, 0x10, 0x00); 90 + break; 91 + case 0x03: 92 + rt711_sdca_index_update_bits(rt711, RT711_VENDOR_REG, RT711_COMBO_JACK_AUTO_CTL1, 0x8400, 0x8000); 93 + rt711_sdca_index_update_bits(rt711, RT711_VENDOR_HDA_CTL, RT711_PUSH_BTN_INT_CTL0, 0x17, 0x13); 94 + break; 95 + case 0x05: 96 + rt711_sdca_index_update_bits(rt711, RT711_VENDOR_REG, RT711_COMBO_JACK_AUTO_CTL1, 0x8400, 0x8400); 97 + rt711_sdca_index_update_bits(rt711, RT711_VENDOR_HDA_CTL, RT711_PUSH_BTN_INT_CTL0, 0x17, 0x15); 98 + break; 99 + } 100 + } 101 + 84 102 static int rt711_sdca_calibration(struct rt711_sdca_priv *rt711) 85 103 { 86 104 unsigned int val, loop_rc = 0, loop_dc = 0; ··· 265 247 { 266 248 unsigned int det_mode; 267 249 int ret; 250 + 251 + rt711_sdca_ge_force_jack_type(rt711, rt711->ge_mode_override); 268 252 269 253 /* get detected_mode */ 270 254 ret = regmap_read(rt711->regmap, ··· 810 790 return changed; 811 791 } 812 792 793 + static int rt711_sdca_ge_select_get(struct snd_kcontrol *kcontrol, 794 + struct snd_ctl_elem_value *ucontrol) 795 + { 796 + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 797 + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 798 + struct rt711_sdca_priv *rt711 = snd_soc_component_get_drvdata(component); 799 + unsigned int val, item; 800 + 801 + val = (rt711->ge_mode_override >> e->shift_l) & e->mask; 802 + item = snd_soc_enum_val_to_item(e, val); 803 + ucontrol->value.enumerated.item[0] = item; 804 + return 0; 805 + } 806 + 807 + static int rt711_sdca_ge_select_put(struct snd_kcontrol *kcontrol, 808 + struct snd_ctl_elem_value *ucontrol) 809 + { 810 + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 811 + unsigned int *item = ucontrol->value.enumerated.item; 812 + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 813 + struct rt711_sdca_priv *rt711 = snd_soc_component_get_drvdata(component); 814 + unsigned int val, change = 0; 815 + 816 + if (item[0] >= e->items) 817 + return -EINVAL; 818 + 819 + val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l; 820 + if (rt711->ge_mode_override != val) { 821 + rt711->ge_mode_override = val; 822 + change = 1; 823 + } 824 + 825 + return change; 826 + } 827 + 828 + static const char * const rt711_sdca_ge_select[] = { 829 + "Auto", 830 + "Headphone", 831 + "Headset", 832 + }; 833 + 834 + static int rt711_sdca_ge_select_values[] = { 835 + 0, 836 + 3, 837 + 5, 838 + }; 839 + 840 + static SOC_VALUE_ENUM_SINGLE_DECL(rt711_sdca_ge_mode_enum, SND_SOC_NOPM, 841 + 0, 0x7, rt711_sdca_ge_select, rt711_sdca_ge_select_values); 842 + 813 843 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -6525, 75, 0); 814 844 static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -1725, 75, 0); 815 845 static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, 0, 1000, 0); ··· 894 824 SDW_SDCA_CTL(FUNC_NUM_MIC_ARRAY, RT711_SDCA_ENT_PLATFORM_FU15, RT711_SDCA_CTL_FU_CH_GAIN, CH_R), 895 825 8, 3, 0, 896 826 rt711_sdca_set_gain_get, rt711_sdca_set_gain_put, mic_vol_tlv), 827 + SOC_ENUM_EXT("GE49 Selected Mode", rt711_sdca_ge_mode_enum, 828 + rt711_sdca_ge_select_get, rt711_sdca_ge_select_put), 897 829 }; 898 830 899 831 static int rt711_sdca_mux_get(struct snd_kcontrol *kcontrol,
+1
sound/soc/codecs/rt711-sdca.h
··· 33 33 int hw_ver; 34 34 bool fu0f_dapm_mute, fu0f_mixer_l_mute, fu0f_mixer_r_mute; 35 35 bool fu1e_dapm_mute, fu1e_mixer_l_mute, fu1e_mixer_r_mute; 36 + unsigned int ge_mode_override; 36 37 }; 37 38 38 39 /* NID */