From 8272b732e2ab3ae92d54626a02df232d3cc82583 Mon Sep 17 00:00:00 2001 From: jbodzay Date: Tue, 3 Apr 2018 16:21:58 +0100 Subject: [PATCH] ASoC: madera: Update calculation of I2S slot width Allow for different slot and data widths by determining slot width separately from data width. Change-Id: I3a143d671a47f584c206b4a174ee433663e424af Signed-off-by: James Bodzay --- sound/soc/codecs/madera.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sound/soc/codecs/madera.c b/sound/soc/codecs/madera.c index aaf22748a437..5d13a60f8b21 100644 --- a/sound/soc/codecs/madera.c +++ b/sound/soc/codecs/madera.c @@ -3432,7 +3432,7 @@ static int madera_hw_params(struct snd_pcm_substream *substream, madera->pdata.codec.max_channels_clocked[dai->id - 1]; int tdm_width = priv->tdm_width[dai->id - 1]; int tdm_slots = priv->tdm_slots[dai->id - 1]; - int bclk, lrclk, wl, frame, bclk_target, num_rates; + int bclk, lrclk, dataw, slotw, frame, bclk_target, num_rates; bool reconfig; unsigned int aif_tx_state = 0, aif_rx_state = 0; @@ -3444,18 +3444,18 @@ static int madera_hw_params(struct snd_pcm_substream *substream, num_rates = ARRAY_SIZE(madera_48k_bclk_rates); } - wl = snd_pcm_format_width(params_format(params)); + dataw = snd_pcm_format_width(params_format(params)); + slotw = snd_pcm_format_physical_width(params_format(params)); if (tdm_slots) { madera_aif_dbg(dai, "Configuring for %d %d bit TDM slots\n", tdm_slots, tdm_width); - bclk_target = tdm_slots * tdm_width * params_rate(params); + slotw = tdm_width; channels = tdm_slots; - } else { - bclk_target = snd_soc_params_to_bclk(params); - tdm_width = wl; } + bclk_target = slotw * channels * params_rate(params); + if (chan_limit && chan_limit < channels) { madera_aif_dbg(dai, "Limiting to %d channels\n", chan_limit); bclk_target /= channels; @@ -3490,7 +3490,7 @@ static int madera_hw_params(struct snd_pcm_substream *substream, madera_aif_dbg(dai, "BCLK %dHz LRCLK %dHz\n", rates[bclk], rates[bclk] / lrclk); - frame = wl << MADERA_AIF1TX_WL_SHIFT | tdm_width; + frame = dataw << MADERA_AIF1TX_WL_SHIFT | slotw; reconfig = madera_aif_cfg_changed(codec, base, bclk, lrclk, frame); -- 2.20.1