ASoC: fsl_sai: Handle slave mode per TX/RX direction
Subsystems (3)
PATCH 1/1 ASoC: fsl_sai: Handle slave mode per TX/RX direction
From: Viorel Suman <[email protected]>
The SAI interface can be a clock supplier or consumer as a function of stream direction. e.g SAI can be master for Tx and slave for Rx.
--- sound/soc/fsl/fsl_sai.c | 18 +++++++++--------- sound/soc/fsl/fsl_sai.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-)
sound/soc/fsl/fsl_sai.c +9 -9
@@ -273,18 +273,18 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai,case SND_SOC_DAIFMT_CBS_CFS : val_cr2 |=FSL_SAI_CR2_BCD_MSTR ; val_cr4 |=FSL_SAI_CR4_FSD_MSTR ; - sai->is_slave_mode = false; + sai->is_slave_mode[tx] = false;break ;case SND_SOC_DAIFMT_CBM_CFM : - sai->is_slave_mode = true; + sai->is_slave_mode[tx] = true;break ;case SND_SOC_DAIFMT_CBS_CFM : val_cr2 |=FSL_SAI_CR2_BCD_MSTR ; - sai->is_slave_mode = false; + sai->is_slave_mode[tx] = false;break ;case SND_SOC_DAIFMT_CBM_CFS : val_cr4 |=FSL_SAI_CR4_FSD_MSTR ; - sai->is_slave_mode = true; + sai->is_slave_mode[tx] = true;break ;default :return -EINVAL ;
@@ -326,7 +326,7 @@ static int fsl_sai_set_bclk(struct snd_soc_dai *dai, bool tx, u32 freq)int ret =0 ;/* Don't apply to slave mode */ -if (sai->is_slave_mode) +if (sai->is_slave_mode[tx])return 0 ;for (id =0 ; id <FSL_SAI_MCLK_MAX ; id++) {
@@ -422,7 +422,7 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream,if (sai->slot_width) slot_width = sai->slot_width; -if (!sai->is_slave_mode) { +if (!sai->is_slave_mode[tx]) { ret =fsl_sai_set_bclk (cpu_dai, tx, slots * slot_width *params_rate (params));if (ret)
@@ -458,7 +458,7 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream,* error. */ -if (!sai->is_slave_mode) { +if (!sai->is_slave_mode[tx]) {if (!sai->synchronous[TX ] && sai->synchronous[RX ] && !tx) { regmap_update_bits(sai->regmap, FSL_SAI_TCR4(ofs), FSL_SAI_CR4_SYWD_MASK | FSL_SAI_CR4_FRSZ_MASK,
@@ -497,7 +497,7 @@ static int fsl_sai_hw_free(struct snd_pcm_substream *substream,struct fsl_sai *sai =snd_soc_dai_get_drvdata (cpu_dai);bool tx = substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ; -if (!sai->is_slave_mode && +if (!sai->is_slave_mode[tx] && sai->mclk_streams &BIT (substream->stream)) {clk_disable_unprepare (sai->mclk_clk[sai->mclk_id[tx]]); sai->mclk_streams &= ~BIT (substream->stream);
@@ -581,7 +581,7 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd,* This is a hardware bug, and will be fix in the * next sai version. */ -if (!sai->is_slave_mode) { +if (!sai->is_slave_mode[tx]) {/* Software Reset for both Tx and Rx */ regmap_write (sai->regmap,FSL_SAI_TCSR (ofs),FSL_SAI_CSR_SR );
sound/soc/fsl/fsl_sai.h +1 -1
@@ -167,7 +167,7 @@ struct fsl_sai {struct clk *bus_clk;struct clk *mclk_clk[FSL_SAI_MCLK_MAX ]; -bool is_slave_mode; +bool is_slave_mode[2 ];bool is_lsb_first;bool is_dsp_mode;bool synchronous[2 ];
Signature · 1 line
2.17.1
Nicolin Chen
reviewersound/soc/fsl/fsl_sai.c static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai,
Quoted 18 lines · Daniel Baluta
From: Viorel Suman <[email protected]>
The SAI interface can be a clock supplier or consumer as a function of stream direction. e.g SAI can be master for Tx and slave for Rx.
Signed-off-by Viorel Suman <[email protected]>Signed-off-by Daniel Baluta <[email protected]>--- sound/soc/fsl/fsl_sai.c | 18 +++++++++--------- sound/soc/fsl/fsl_sai.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-)sound/soc/fsl/fsl_sai.c +0
-0@@ -273,18 +273,18 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai,
This function is called for both TX and RX at the same time from fsl_sai_set_dai_fmt() so I don't actually see how it can operate in two opposite directions from this change alone. Anything that I have missed?
Thanks
Nicolin
Quoted 83 lines
sound/soc/fsl/fsl_sai.c +9
-9case SND_SOC_DAIFMT_CBS_CFS : val_cr2 |=FSL_SAI_CR2_BCD_MSTR ; val_cr4 |=FSL_SAI_CR4_FSD_MSTR ; - sai->is_slave_mode = false; + sai->is_slave_mode[tx] = false;break ;case SND_SOC_DAIFMT_CBM_CFM : - sai->is_slave_mode = true; + sai->is_slave_mode[tx] = true;break ;case SND_SOC_DAIFMT_CBS_CFM : val_cr2 |=FSL_SAI_CR2_BCD_MSTR ; - sai->is_slave_mode = false; + sai->is_slave_mode[tx] = false;break ;case SND_SOC_DAIFMT_CBM_CFS : val_cr4 |=FSL_SAI_CR4_FSD_MSTR ; - sai->is_slave_mode = true; + sai->is_slave_mode[tx] = true;break ;default :return -EINVAL ;@@ -326,7 +326,7 @@ static int fsl_sai_set_bclk(struct snd_soc_dai *dai, bool tx, u32 freq)int ret =0 ;/* Don't apply to slave mode */ -if (sai->is_slave_mode) +if (sai->is_slave_mode[tx])return 0 ;for (id =0 ; id <FSL_SAI_MCLK_MAX ; id++) {@@ -422,7 +422,7 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream,if (sai->slot_width) slot_width = sai->slot_width; -if (!sai->is_slave_mode) { +if (!sai->is_slave_mode[tx]) { ret =fsl_sai_set_bclk (cpu_dai, tx, slots * slot_width *params_rate (params));if (ret)@@ -458,7 +458,7 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream,* error. */ -if (!sai->is_slave_mode) { +if (!sai->is_slave_mode[tx]) {if (!sai->synchronous[TX ] && sai->synchronous[RX ] && !tx) { regmap_update_bits(sai->regmap, FSL_SAI_TCR4(ofs), FSL_SAI_CR4_SYWD_MASK | FSL_SAI_CR4_FRSZ_MASK,@@ -497,7 +497,7 @@ static int fsl_sai_hw_free(struct snd_pcm_substream *substream,struct fsl_sai *sai =snd_soc_dai_get_drvdata (cpu_dai);bool tx = substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ; -if (!sai->is_slave_mode && +if (!sai->is_slave_mode[tx] && sai->mclk_streams &BIT (substream->stream)) {clk_disable_unprepare (sai->mclk_clk[sai->mclk_id[tx]]); sai->mclk_streams &= ~BIT (substream->stream);@@ -581,7 +581,7 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd,* This is a hardware bug, and will be fix in the * next sai version. */ -if (!sai->is_slave_mode) { +if (!sai->is_slave_mode[tx]) {/* Software Reset for both Tx and Rx */ regmap_write (sai->regmap,FSL_SAI_TCSR (ofs),FSL_SAI_CSR_SR );sound/soc/fsl/fsl_sai.h +1
-1@@ -167,7 +167,7 @@ struct fsl_sai {struct clk *bus_clk;struct clk *mclk_clk[FSL_SAI_MCLK_MAX ]; -bool is_slave_mode; +bool is_slave_mode[2 ];bool is_lsb_first;bool is_dsp_mode;bool synchronous[2 ];Signature · 1 line
2.17.1
Quoted 15 lines · Nicolin Chen
Quoted 13 lines · Daniel Baluta
From: Viorel Suman <[email protected]>
The SAI interface can be a clock supplier or consumer as a function of stream direction. e.g SAI can be master for Tx and slave for Rx.
Signed-off-by Viorel Suman <[email protected]>Signed-off-by Daniel Baluta <[email protected]>--- sound/soc/fsl/fsl_sai.c | 18 +++++++++--------- sound/soc/fsl/fsl_sai.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-)
Quoted 10 lines
sound/soc/fsl/fsl_sai.c static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai,
Quoted 5 lines
sound/soc/fsl/fsl_sai.c +0
-0@@ -273,18 +273,18 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai,This function is called for both TX and RX at the same time from
fsl_sai_set_dai_fmt()so I don't actually see how it can operate in two opposite directions from this change alone. Anything that I have missed?
Good catch. I'm missing a patch that updates fmt after the first call of fsl_sai_set_dai_fmt_tr.
Let me update the patch and resend.