Skip to content

Commit d0f5f0e

Browse files
pujarsroxanan1996
authored andcommitted
ASoC: tegra: Fix redundant PLLA and PLLA_OUT0 updates
BugLink: https://bugs.launchpad.net/bugs/2045809 [ Upstream commit e765886 ] Tegra audio graph card has many DAI links which connects internal AHUB modules and external audio codecs. Since these are DPCM links, hw_params() call in the machine driver happens for each connected BE link and PLLA is updated every time. This is not really needed for all links as only I/O link DAIs derive respective clocks from PLLA_OUT0 and thus from PLLA. Hence add checks to limit the clock updates to DAIs over I/O links. This found to be fixing a DMIC clock discrepancy which is suspected to happen because of back to back quick PLLA and PLLA_OUT0 rate updates. This was observed on Jetson TX2 platform where DMIC clock ended up with unexpected value. Fixes: 202e2f7 ("ASoC: tegra: Add audio graph based card driver") Cc: stable@vger.kernel.org Signed-off-by: Sameer Pujar <spujar@nvidia.com> Link: https://lore.kernel.org/r/1694098945-32760-3-git-send-email-spujar@nvidia.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 8e3abcf commit d0f5f0e

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

sound/soc/tegra/tegra_audio_graph_card.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/platform_device.h>
1111
#include <sound/graph_card.h>
1212
#include <sound/pcm_params.h>
13+
#include <sound/soc-dai.h>
1314

1415
#define MAX_PLLA_OUT0_DIV 128
1516

@@ -44,6 +45,21 @@ struct tegra_audio_cdata {
4445
unsigned int plla_out0_rates[NUM_RATE_TYPE];
4546
};
4647

48+
static bool need_clk_update(struct snd_soc_dai *dai)
49+
{
50+
if (snd_soc_dai_is_dummy(dai) ||
51+
!dai->driver->ops ||
52+
!dai->driver->name)
53+
return false;
54+
55+
if (strstr(dai->driver->name, "I2S") ||
56+
strstr(dai->driver->name, "DMIC") ||
57+
strstr(dai->driver->name, "DSPK"))
58+
return true;
59+
60+
return false;
61+
}
62+
4763
/* Setup PLL clock as per the given sample rate */
4864
static int tegra_audio_graph_update_pll(struct snd_pcm_substream *substream,
4965
struct snd_pcm_hw_params *params)
@@ -140,19 +156,7 @@ static int tegra_audio_graph_hw_params(struct snd_pcm_substream *substream,
140156
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
141157
int err;
142158

143-
/*
144-
* This gets called for each DAI link (FE or BE) when DPCM is used.
145-
* We may not want to update PLLA rate for each call. So PLLA update
146-
* must be restricted to external I/O links (I2S, DMIC or DSPK) since
147-
* they actually depend on it. I/O modules update their clocks in
148-
* hw_param() of their respective component driver and PLLA rate
149-
* update here helps them to derive appropriate rates.
150-
*
151-
* TODO: When more HW accelerators get added (like sample rate
152-
* converter, volume gain controller etc., which don't really
153-
* depend on PLLA) we need a better way to filter here.
154-
*/
155-
if (cpu_dai->driver->ops && rtd->dai_link->no_pcm) {
159+
if (need_clk_update(cpu_dai)) {
156160
err = tegra_audio_graph_update_pll(substream, params);
157161
if (err)
158162
return err;

0 commit comments

Comments
 (0)