Skip to content

Commit e678a68

Browse files
author
Codrin Ciubotariu
committed
ASoC: atmel: mchp-pdmc: 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: 62ba700 ("ASoC: atmel: mchp-pdmc: add PDMC driver") Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
1 parent b238e5a commit e678a68

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

sound/soc/atmel/mchp-pdmc.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,15 +543,17 @@ static int mchp_pdmc_hw_params(struct snd_pcm_substream *substream,
543543
unsigned int osr = 0, osr_start;
544544
unsigned int fs = params_rate(params);
545545
int sample_bytes = params_physical_width(params) / 8;
546+
int period_bytes = params_period_size(params) *
547+
params_channels(params) * sample_bytes;
546548
int maxburst;
547549
u32 mr_val = 0;
548550
u32 cfgr_val = 0;
549551
int i;
550552
int ret;
551553

552-
dev_dbg(comp->dev, "%s() rate=%u format=%#x width=%u channels=%u\n",
554+
dev_dbg(comp->dev, "%s() rate=%u format=%#x width=%u channels=%u period_bytes=%d\n",
553555
__func__, params_rate(params), params_format(params),
554-
params_width(params), params_channels(params));
556+
params_width(params), params_channels(params), period_bytes);
555557

556558
if (channels > dd->mic_no) {
557559
dev_err(comp->dev, "more channels %u than microphones %d\n",
@@ -613,8 +615,7 @@ static int mchp_pdmc_hw_params(struct snd_pcm_substream *substream,
613615

614616
mr_val |= MCHP_PDMC_MR_SINCORDER(dd->sinc_order);
615617

616-
maxburst = mchp_pdmc_period_to_maxburst(snd_pcm_lib_period_bytes(substream),
617-
sample_bytes);
618+
maxburst = mchp_pdmc_period_to_maxburst(period_bytes, sample_bytes);
618619
dd->addr.maxburst = maxburst;
619620
mr_val |= MCHP_PDMC_MR_CHUNK(dd->addr.maxburst);
620621
dev_dbg(comp->dev, "maxburst set to %d\n", dd->addr.maxburst);

0 commit comments

Comments
 (0)