]> Git Repo - linux.git/commitdiff
ASoC: rt5682s: Fix the TDM Tx settings
authorDerek Fang <[email protected]>
Wed, 12 Oct 2022 03:13:20 +0000 (11:13 +0800)
committerMark Brown <[email protected]>
Thu, 13 Oct 2022 12:01:31 +0000 (13:01 +0100)
Complete the missing and correct the TDM Tx settings.

Signed-off-by: Derek Fang <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
sound/soc/codecs/rt5682s.c
sound/soc/codecs/rt5682s.h

index 3b91a3442c6829d466efb69ec4988c5b9b830659..5199d3bbaf0b996f3b1f4e7f069f97c500ca8131 100644 (file)
@@ -1981,7 +1981,7 @@ static int rt5682s_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
                unsigned int rx_mask, int slots, int slot_width)
 {
        struct snd_soc_component *component = dai->component;
-       unsigned int cl, val = 0;
+       unsigned int cl, val = 0, tx_slotnum;
 
        if (tx_mask || rx_mask)
                snd_soc_component_update_bits(component,
@@ -1990,6 +1990,16 @@ static int rt5682s_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
                snd_soc_component_update_bits(component,
                        RT5682S_TDM_ADDA_CTRL_2, RT5682S_TDM_EN, 0);
 
+       /* Tx slot configuration */
+       tx_slotnum = hweight_long(tx_mask);
+       if (tx_slotnum) {
+               if (tx_slotnum > slots) {
+                       dev_err(component->dev, "Invalid or oversized Tx slots.\n");
+                       return -EINVAL;
+               }
+               val |= (tx_slotnum - 1) << RT5682S_TDM_ADC_DL_SFT;
+       }
+
        switch (slots) {
        case 4:
                val |= RT5682S_TDM_TX_CH_4;
@@ -2010,7 +2020,8 @@ static int rt5682s_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
        }
 
        snd_soc_component_update_bits(component, RT5682S_TDM_CTRL,
-               RT5682S_TDM_TX_CH_MASK | RT5682S_TDM_RX_CH_MASK, val);
+               RT5682S_TDM_TX_CH_MASK | RT5682S_TDM_RX_CH_MASK |
+               RT5682S_TDM_ADC_DL_MASK, val);
 
        switch (slot_width) {
        case 8:
index 824dc6543c182429ac21ca3aee5ecfd65558c747..45464a0417654c187102954f98057a3d5d006e1e 100644 (file)
 #define RT5682S_TDM_RX_CH_8                    (0x3 << 8)
 #define RT5682S_TDM_ADC_LCA_MASK               (0x7 << 4)
 #define RT5682S_TDM_ADC_LCA_SFT                        4
+#define RT5682S_TDM_ADC_DL_MASK                        (0x3 << 0)
 #define RT5682S_TDM_ADC_DL_SFT                 0
 
 /* TDM control 2 (0x007a) */
This page took 0.052083 seconds and 4 git commands to generate.