summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolin Chen <nicoleotsuka@gmail.com>2018-04-08 00:40:21 -0400
committerMark Brown <broonie@kernel.org>2018-04-12 10:30:23 -0400
commitfac8a5a5ea40b03dcbb0f46977094099ba2220b8 (patch)
treef202c6fc9989a3aa5b431a77f57a99d3302705f7
parentc656941df9bc80f7ec65b92ca73c42f8b0b62628 (diff)
ASoC: fsl_ssi: Fix mode setting when changing channel number
This is a partial revert (in a cleaner way) of commit ebf08ae3bc90 ("ASoC: fsl_ssi: Keep ssi->i2s_net updated") to fix a regression at test cases when switching between mono and stereo audio. The problem is that ssi->i2s_net is initialized in set_dai_fmt() only, while this set_dai_fmt() is only called during the dai-link probe(). The original patch assumed set_dai_fmt() would be called during every playback instance, so it failed at the overriding use cases. This patch adds the local variable i2s_net back to let regular use cases still follow the mode settings from the set_dai_fmt(). Meanwhile, the original commit of keeping ssi->i2s_net updated was to make set_tdm_slot() clean by checking the ssi->i2s_net directly instead of reading SCR register. However, the change itself is not necessary (or even harmful) because the set_tdm_slot() might fail to check the slot number for Normal-Mode-None-Net settings while mono audio cases still need 2 slots. So this patch can also fix it. And it adds an extra line of comments to declare ssi->i2s_net does not reflect the register value but merely the initial setting from the set_dai_fmt(). Reported-by: Mika Penttilä <mika.penttila@nextfour.com> Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com> Tested-by: Mika Penttilä <mika.penttila@nextfour.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/fsl/fsl_ssi.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 0823b08923b5..89df2d9f63d7 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -217,6 +217,7 @@ struct fsl_ssi_soc_data {
217 * @dai_fmt: DAI configuration this device is currently used with 217 * @dai_fmt: DAI configuration this device is currently used with
218 * @streams: Mask of current active streams: BIT(TX) and BIT(RX) 218 * @streams: Mask of current active streams: BIT(TX) and BIT(RX)
219 * @i2s_net: I2S and Network mode configurations of SCR register 219 * @i2s_net: I2S and Network mode configurations of SCR register
220 * (this is the initial settings based on the DAI format)
220 * @synchronous: Use synchronous mode - both of TX and RX use STCK and SFCK 221 * @synchronous: Use synchronous mode - both of TX and RX use STCK and SFCK
221 * @use_dma: DMA is used or FIQ with stream filter 222 * @use_dma: DMA is used or FIQ with stream filter
222 * @use_dual_fifo: DMA with support for dual FIFO mode 223 * @use_dual_fifo: DMA with support for dual FIFO mode
@@ -829,16 +830,23 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
829 } 830 }
830 831
831 if (!fsl_ssi_is_ac97(ssi)) { 832 if (!fsl_ssi_is_ac97(ssi)) {
833 /*
834 * Keep the ssi->i2s_net intact while having a local variable
835 * to override settings for special use cases. Otherwise, the
836 * ssi->i2s_net will lose the settings for regular use cases.
837 */
838 u8 i2s_net = ssi->i2s_net;
839
832 /* Normal + Network mode to send 16-bit data in 32-bit frames */ 840 /* Normal + Network mode to send 16-bit data in 32-bit frames */
833 if (fsl_ssi_is_i2s_cbm_cfs(ssi) && sample_size == 16) 841 if (fsl_ssi_is_i2s_cbm_cfs(ssi) && sample_size == 16)
834 ssi->i2s_net = SSI_SCR_I2S_MODE_NORMAL | SSI_SCR_NET; 842 i2s_net = SSI_SCR_I2S_MODE_NORMAL | SSI_SCR_NET;
835 843
836 /* Use Normal mode to send mono data at 1st slot of 2 slots */ 844 /* Use Normal mode to send mono data at 1st slot of 2 slots */
837 if (channels == 1) 845 if (channels == 1)
838 ssi->i2s_net = SSI_SCR_I2S_MODE_NORMAL; 846 i2s_net = SSI_SCR_I2S_MODE_NORMAL;
839 847
840 regmap_update_bits(regs, REG_SSI_SCR, 848 regmap_update_bits(regs, REG_SSI_SCR,
841 SSI_SCR_I2S_NET_MASK, ssi->i2s_net); 849 SSI_SCR_I2S_NET_MASK, i2s_net);
842 } 850 }
843 851
844 /* In synchronous mode, the SSI uses STCCR for capture */ 852 /* In synchronous mode, the SSI uses STCCR for capture */