ASoC: nau8822: Don't reconfigure PLL to the same values
authorMark Brown <broonie@kernel.org>
Fri, 3 Jun 2022 10:35:30 +0000 (12:35 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 6 Jun 2022 11:38:41 +0000 (12:38 +0100)
When we configure the PLL record the input and output frequency, then if we
get asked to configure the same values again just skip reprogramming the
hardware. This makes things a bit easier to use for machine drivers since
it means they don't need to keep track of if they've programmed the PLL
so much.

Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20220603103530.3844527-1-broonie@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/nau8822.c
sound/soc/codecs/nau8822.h

index 08f6c56..f4f68b5 100644 (file)
@@ -726,6 +726,10 @@ static int nau8822_set_pll(struct snd_soc_dai *dai, int pll_id, int source,
        struct nau8822_pll *pll_param = &nau8822->pll;
        int ret, fs;
 
+       if (freq_in == pll_param->freq_in &&
+           freq_out == pll_param->freq_out)
+               return 0;
+
        fs = freq_out / 256;
 
        ret = nau8822_calc_pll(freq_in, fs, pll_param);
@@ -762,6 +766,9 @@ static int nau8822_set_pll(struct snd_soc_dai *dai, int pll_id, int source,
        snd_soc_component_update_bits(component,
                NAU8822_REG_POWER_MANAGEMENT_1, NAU8822_PLL_EN_MASK, NAU8822_PLL_ON);
 
+       pll_param->freq_in = freq_in;
+       pll_param->freq_out = freq_out;
+
        return 0;
 }
 
index b45d42c..547ec05 100644 (file)
@@ -198,6 +198,8 @@ struct nau8822_pll {
        int mclk_scaler;
        int pll_frac;
        int pll_int;
+       int freq_in;
+       int freq_out;
 };
 
 /* Codec Private Data */