Skip to content

Commit af241e3

Browse files
TE-N-ShengjiuWangbroonie
authored andcommitted
ASoC: fsl-asoc-card: add sysclk_ratio for calculate sysclk frequency
The sysclk frequency can be calculated from sample rate multiply ratio. When sysclk_freq is not configured, but sysclk_ratio is configured, then calculate sysclk frequency according to sysclk_ratio. Apply this change for wm8524 codec. Signed-off-by: Shengjiu Wang <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent ad46556 commit af241e3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

sound/soc/fsl/fsl-asoc-card.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ struct codec_priv {
6363
* @sysclk_freq: SYSCLK rates for set_sysclk()
6464
* @sysclk_dir: SYSCLK directions for set_sysclk()
6565
* @sysclk_id: SYSCLK ids for set_sysclk()
66+
* @sysclk_ratio: SYSCLK ratio on sample rate
6667
* @slot_width: Slot width of each frame
6768
* @slot_num: Number of slots of each frame
6869
*
@@ -72,6 +73,7 @@ struct cpu_priv {
7273
unsigned long sysclk_freq[2];
7374
u32 sysclk_dir[2];
7475
u32 sysclk_id[2];
76+
u32 sysclk_ratio[2];
7577
u32 slot_width;
7678
u32 slot_num;
7779
};
@@ -176,7 +178,7 @@ static int fsl_asoc_card_hw_params(struct snd_pcm_substream *substream,
176178
struct snd_soc_dai *codec_dai;
177179
struct cpu_priv *cpu_priv = &priv->cpu_priv;
178180
struct device *dev = rtd->card->dev;
179-
unsigned int pll_out;
181+
unsigned int pll_out, sysclk_freq;
180182
int codec_idx;
181183
int ret;
182184

@@ -187,9 +189,14 @@ static int fsl_asoc_card_hw_params(struct snd_pcm_substream *substream,
187189
if (fsl_asoc_card_is_ac97(priv))
188190
return 0;
189191

192+
if (!cpu_priv->sysclk_freq[tx] && cpu_priv->sysclk_ratio[tx])
193+
sysclk_freq = priv->sample_rate * cpu_priv->sysclk_ratio[tx];
194+
else
195+
sysclk_freq = cpu_priv->sysclk_freq[tx];
196+
190197
/* Specific configurations of DAIs starts from here */
191198
ret = snd_soc_dai_set_sysclk(snd_soc_rtd_to_cpu(rtd, 0), cpu_priv->sysclk_id[tx],
192-
cpu_priv->sysclk_freq[tx],
199+
sysclk_freq,
193200
cpu_priv->sysclk_dir[tx]);
194201
if (ret && ret != -ENOTSUPP) {
195202
dev_err(dev, "failed to set sysclk for cpu dai\n");
@@ -799,6 +806,8 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
799806
priv->cpu_priv.slot_width = 32;
800807
priv->card.dapm_routes = audio_map_tx;
801808
priv->card.num_dapm_routes = ARRAY_SIZE(audio_map_tx);
809+
priv->cpu_priv.sysclk_dir[TX] = SND_SOC_CLOCK_OUT;
810+
priv->cpu_priv.sysclk_ratio[TX] = 256;
802811
} else if (of_device_is_compatible(np, "fsl,imx-audio-si476x")) {
803812
codec_dai_name[0] = "si476x-codec";
804813
priv->dai_fmt |= SND_SOC_DAIFMT_CBC_CFC;

0 commit comments

Comments
 (0)