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

ASoC: rt712-sdca: Add FU05 playback switch control

Because there is no playback switch control for rt712-sdw headphone endpoint,
it causes there is no way to control HP on and off in ALSA UCM config.

Signed-off-by: derek.fang <derek.fang@realtek.com>
Signed-off-by: Shuming Fan <shumingf@realtek.com>
Link: https://patch.msgid.link/20250226084728.1889082-1-shumingf@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Shuming Fan and committed by
Mark Brown
62142da2 dc64e1b9

+66 -17
+63 -17
sound/soc/codecs/rt712-sdca.c
··· 652 652 return 1; 653 653 } 654 654 655 + static int rt712_sdca_set_fu05_playback_ctl(struct rt712_sdca_priv *rt712) 656 + { 657 + int err; 658 + unsigned int ch_01, ch_02; 659 + 660 + ch_01 = (rt712->fu05_dapm_mute || rt712->fu05_mixer_l_mute) ? 0x01 : 0x00; 661 + ch_02 = (rt712->fu05_dapm_mute || rt712->fu05_mixer_r_mute) ? 0x01 : 0x00; 662 + 663 + err = regmap_write(rt712->regmap, 664 + SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT712_SDCA_ENT_USER_FU05, 665 + RT712_SDCA_CTL_FU_MUTE, CH_01), ch_01); 666 + if (err < 0) 667 + return err; 668 + 669 + err = regmap_write(rt712->regmap, 670 + SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT712_SDCA_ENT_USER_FU05, 671 + RT712_SDCA_CTL_FU_MUTE, CH_02), ch_02); 672 + if (err < 0) 673 + return err; 674 + 675 + return 0; 676 + } 677 + 678 + static int rt712_sdca_fu05_playback_get(struct snd_kcontrol *kcontrol, 679 + struct snd_ctl_elem_value *ucontrol) 680 + { 681 + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); 682 + struct rt712_sdca_priv *rt712 = snd_soc_component_get_drvdata(component); 683 + 684 + ucontrol->value.integer.value[0] = !rt712->fu05_mixer_l_mute; 685 + ucontrol->value.integer.value[1] = !rt712->fu05_mixer_r_mute; 686 + return 0; 687 + } 688 + 689 + static int rt712_sdca_fu05_playback_put(struct snd_kcontrol *kcontrol, 690 + struct snd_ctl_elem_value *ucontrol) 691 + { 692 + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); 693 + struct rt712_sdca_priv *rt712 = snd_soc_component_get_drvdata(component); 694 + int err; 695 + 696 + if (rt712->fu05_mixer_l_mute == !ucontrol->value.integer.value[0] && 697 + rt712->fu05_mixer_r_mute == !ucontrol->value.integer.value[1]) 698 + return 0; 699 + 700 + rt712->fu05_mixer_l_mute = !ucontrol->value.integer.value[0]; 701 + rt712->fu05_mixer_r_mute = !ucontrol->value.integer.value[1]; 702 + 703 + err = rt712_sdca_set_fu05_playback_ctl(rt712); 704 + if (err < 0) 705 + return err; 706 + 707 + return 1; 708 + } 709 + 655 710 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -6525, 75, 0); 656 711 static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, -1725, 75, 0); 657 712 static const DECLARE_TLV_DB_SCALE(boost_vol_tlv, 0, 1000, 0); ··· 729 674 SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT712_SDCA_ENT_PLATFORM_FU44, RT712_SDCA_CTL_FU_CH_GAIN, CH_02), 730 675 8, 3, 0, 731 676 rt712_sdca_set_gain_get, rt712_sdca_set_gain_put, boost_vol_tlv), 677 + SOC_DOUBLE_EXT("FU05 Playback Switch", SND_SOC_NOPM, 0, 1, 1, 0, 678 + rt712_sdca_fu05_playback_get, rt712_sdca_fu05_playback_put), 732 679 }; 733 680 734 681 static const struct snd_kcontrol_new rt712_sdca_spk_controls[] = { ··· 823 766 struct snd_soc_component *component = 824 767 snd_soc_dapm_to_component(w->dapm); 825 768 struct rt712_sdca_priv *rt712 = snd_soc_component_get_drvdata(component); 826 - unsigned char unmute = 0x0, mute = 0x1; 827 769 828 770 switch (event) { 829 771 case SND_SOC_DAPM_POST_PMU: 830 - regmap_write(rt712->regmap, 831 - SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT712_SDCA_ENT_USER_FU05, 832 - RT712_SDCA_CTL_FU_MUTE, CH_01), 833 - unmute); 834 - regmap_write(rt712->regmap, 835 - SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT712_SDCA_ENT_USER_FU05, 836 - RT712_SDCA_CTL_FU_MUTE, CH_02), 837 - unmute); 772 + rt712->fu05_dapm_mute = false; 773 + rt712_sdca_set_fu05_playback_ctl(rt712); 838 774 break; 839 775 case SND_SOC_DAPM_PRE_PMD: 840 - regmap_write(rt712->regmap, 841 - SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT712_SDCA_ENT_USER_FU05, 842 - RT712_SDCA_CTL_FU_MUTE, CH_01), 843 - mute); 844 - regmap_write(rt712->regmap, 845 - SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT712_SDCA_ENT_USER_FU05, 846 - RT712_SDCA_CTL_FU_MUTE, CH_02), 847 - mute); 776 + rt712->fu05_dapm_mute = true; 777 + rt712_sdca_set_fu05_playback_ctl(rt712); 848 778 break; 849 779 } 850 780 return 0; ··· 1684 1640 rt712->fu1e_dapm_mute = true; 1685 1641 rt712->fu1e_mixer_mute[0] = rt712->fu1e_mixer_mute[1] = 1686 1642 rt712->fu1e_mixer_mute[2] = rt712->fu1e_mixer_mute[3] = true; 1643 + rt712->fu05_dapm_mute = true; 1644 + rt712->fu05_mixer_l_mute = rt712->fu05_mixer_r_mute = false; 1687 1645 1688 1646 /* JD source uses JD1 in default */ 1689 1647 rt712->jd_src = RT712_JD1;
+3
sound/soc/codecs/rt712-sdca.h
··· 42 42 bool fu0f_mixer_r_mute; 43 43 bool fu1e_dapm_mute; 44 44 bool fu1e_mixer_mute[4]; 45 + bool fu05_dapm_mute; 46 + bool fu05_mixer_l_mute; 47 + bool fu05_mixer_r_mute; 45 48 }; 46 49 47 50 struct rt712_dmic_kctrl_priv {