Skip to content

Commit 4b34308

Browse files
author
Codrin Ciubotariu
committed
ASoC: atmel: mchp-i2s-mcc: fix period size calculation
The size of the period is used to compute the maxburst. However, snd_pcm_lib_period_bytes() is 0 because the runtime HW parameters are computed after the hw_params() callbacks are used. Because of this, to compute the period size we use params_*() functions. Fixes: 2c1ab8c ("ASoC: atmel: mchp-i2s-mcc: calculate maxburst based on period size") Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
1 parent 5bfd7f4 commit 4b34308

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

sound/soc/atmel/mchp-i2s-mcc.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,8 @@ static int mchp_i2s_mcc_hw_params(struct snd_pcm_substream *substream,
522522
unsigned long rate = 0;
523523
struct mchp_i2s_mcc_dev *dev = snd_soc_dai_get_drvdata(dai);
524524
int sample_bytes = params_physical_width(params) / 8;
525-
int period_size = snd_pcm_lib_period_bytes(substream);
525+
int period_bytes = params_period_size(params) *
526+
params_channels(params) * sample_bytes;
526527
int maxburst;
527528
u32 mra = 0;
528529
u32 mrb = 0;
@@ -533,9 +534,9 @@ static int mchp_i2s_mcc_hw_params(struct snd_pcm_substream *substream,
533534
int ret;
534535
bool is_playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
535536

536-
dev_dbg(dev->dev, "%s() rate=%u format=%#x width=%u channels=%u\n",
537+
dev_dbg(dev->dev, "%s() rate=%u format=%#x width=%u channels=%u period_bytes=%d\n",
537538
__func__, params_rate(params), params_format(params),
538-
params_width(params), params_channels(params));
539+
params_width(params), params_channels(params), period_bytes);
539540

540541
switch (dev->fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
541542
case SND_SOC_DAIFMT_I2S:
@@ -644,7 +645,7 @@ static int mchp_i2s_mcc_hw_params(struct snd_pcm_substream *substream,
644645
* We must have the same burst size configured
645646
* in the DMA transfer and in out IP
646647
*/
647-
maxburst = mchp_i2s_mcc_period_to_maxburst(period_size, sample_bytes);
648+
maxburst = mchp_i2s_mcc_period_to_maxburst(period_bytes, sample_bytes);
648649
mrb |= MCHP_I2SMCC_MRB_DMACHUNK(maxburst);
649650
if (is_playback)
650651
dev->playback.maxburst = maxburst;

0 commit comments

Comments
 (0)