openwrt/target/linux/layerscape/patches-5.4/801-audio-0052-MLK-18682-1-ASoC-fsl-sai-use-set_bclk_ratio-to-calcu.patch
Yangbo Lu cddd459140 layerscape: add patches-5.4
Add patches for linux-5.4. The patches are from NXP LSDK-20.04 release
which was tagged LSDK-20.04-V5.4.
https://source.codeaurora.org/external/qoriq/qoriq-components/linux/

For boards LS1021A-IOT, and Traverse-LS1043 which are not involved in
LSDK, port the dts patches from 4.14.

The patches are sorted into the following categories:
  301-arch-xxxx
  302-dts-xxxx
  303-core-xxxx
  701-net-xxxx
  801-audio-xxxx
  802-can-xxxx
  803-clock-xxxx
  804-crypto-xxxx
  805-display-xxxx
  806-dma-xxxx
  807-gpio-xxxx
  808-i2c-xxxx
  809-jailhouse-xxxx
  810-keys-xxxx
  811-kvm-xxxx
  812-pcie-xxxx
  813-pm-xxxx
  814-qe-xxxx
  815-sata-xxxx
  816-sdhc-xxxx
  817-spi-xxxx
  818-thermal-xxxx
  819-uart-xxxx
  820-usb-xxxx
  821-vfio-xxxx

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2020-05-07 12:53:06 +02:00

99 lines
3.0 KiB
Diff

From fc4146698489c4725c9ac86ea3e0484914d5285b Mon Sep 17 00:00:00 2001
From: Viorel Suman <viorel.suman@nxp.com>
Date: Wed, 27 Jun 2018 10:31:02 +0300
Subject: [PATCH] MLK-18682-1: ASoC: fsl: sai: use set_bclk_ratio to calculate
BCLK freq (part 1)
ALSA API has a standard way to configure DAI BCLK by calling
"snd_soc_dai_set_bclk_ratio" function. So use it to set BCLK ratio
and calculate SAI BCLK frequency.
Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
[ Aisheng: split machine imx-pdm changes ]
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
sound/soc/fsl/fsl_sai.c | 21 +++++++++++++--------
sound/soc/fsl/fsl_sai.h | 3 +--
2 files changed, 14 insertions(+), 10 deletions(-)
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -234,6 +234,14 @@ static int fsl_sai_set_dai_sysclk_tr(str
return 0;
}
+static int fsl_sai_set_dai_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
+{
+ struct fsl_sai *sai = snd_soc_dai_get_drvdata(dai);
+
+ sai->bitclk_ratio = ratio;
+ return 0;
+}
+
static int fsl_sai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
int clk_id, unsigned int freq, int dir)
{
@@ -243,11 +251,6 @@ static int fsl_sai_set_dai_sysclk(struct
if (dir == SND_SOC_CLOCK_IN)
return 0;
- if (clk_id == FSL_SAI_CLK_BIT) {
- sai->bitclk_freq = freq;
- return 0;
- }
-
if (freq > 0) {
if (clk_id < 0 || clk_id >= FSL_SAI_MCLK_MAX) {
dev_err(cpu_dai->dev, "Unknown clock id: %d\n", clk_id);
@@ -571,6 +574,7 @@ static int fsl_sai_hw_params(struct snd_
bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
unsigned int channels = params_channels(params);
u32 word_width = params_width(params);
+ u32 rate = params_rate(params);
u32 val_cr4 = 0, val_cr5 = 0;
u32 slots = (channels == 1) ? 2 : channels;
u32 slot_width = word_width;
@@ -605,12 +609,12 @@ static int fsl_sai_hw_params(struct snd_
slot_width = sai->slot_width;
if (!sai->slave_mode[tx]) {
- if (sai->bitclk_freq)
+ if (sai->bitclk_ratio)
ret = fsl_sai_set_bclk(cpu_dai, tx,
- sai->bitclk_freq);
+ rate * sai->bitclk_ratio);
else
ret = fsl_sai_set_bclk(cpu_dai, tx,
- slots * slot_width * params_rate(params));
+ rate * slots * slot_width);
if (ret)
return ret;
@@ -935,6 +939,7 @@ static void fsl_sai_shutdown(struct snd_
}
static const struct snd_soc_dai_ops fsl_sai_pcm_dai_ops = {
+ .set_bclk_ratio = fsl_sai_set_dai_bclk_ratio,
.set_sysclk = fsl_sai_set_dai_sysclk,
.set_fmt = fsl_sai_set_dai_fmt,
.set_tdm_slot = fsl_sai_set_dai_tdm_slot,
--- a/sound/soc/fsl/fsl_sai.h
+++ b/sound/soc/fsl/fsl_sai.h
@@ -203,7 +203,6 @@
#define FSL_SAI_CLK_MAST3 3
#define FSL_SAI_MCLK_MAX 4
-#define FSL_SAI_CLK_BIT 5
/* SAI data transfer numbers per DMA request */
#define FSL_SAI_MAXBURST_TX 6
@@ -258,7 +257,7 @@ struct fsl_sai {
unsigned int mclk_streams;
unsigned int slots;
unsigned int slot_width;
- unsigned int bitclk_freq;
+ unsigned int bitclk_ratio;
struct snd_dmaengine_dai_dma_data dma_params_rx;
struct snd_dmaengine_dai_dma_data dma_params_tx;