ASoC: madera: Update calculation of I2S slot width
authorjbodzay <james.bodzay@cirrus.com>
Tue, 3 Apr 2018 15:21:58 +0000 (16:21 +0100)
committer강신형 <s47.kang@samsung.com>
Tue, 19 Jun 2018 07:59:27 +0000 (16:59 +0900)
Allow for different slot and data widths by determining slot width
separately from data width.

Change-Id: I3a143d671a47f584c206b4a174ee433663e424af
Signed-off-by: James Bodzay <james.bodzay@cirrus.com>
sound/soc/codecs/madera.c

index aaf22748a437afa1ee78c7ade21787a6328fdd02..5d13a60f8b21f4c0fbb7f4a45e2cc059741c4858 100644 (file)
@@ -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);