Skip to content

Commit b238e5a

Browse files
author
Codrin Ciubotariu
committed
ASoC: atmel: mchp-pdmc: use sample size when calculating maxburst
The period size must be divided by sample size * maxburst, not just by maxburst. This assures that all the DMA descriptors start from a well aligned address. Fixes: 62ba700 ("ASoC: atmel: mchp-pdmc: add PDMC driver") Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
1 parent 4b34308 commit b238e5a

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

sound/soc/atmel/mchp-pdmc.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -506,13 +506,13 @@ static u32 mchp_pdmc_mr_set_osr(int audio_filter_en, unsigned int osr)
506506
return 0;
507507
}
508508

509-
static inline int mchp_pdmc_period_to_maxburst(int period_size)
509+
static inline int mchp_pdmc_period_to_maxburst(int period_size, int sample_size)
510510
{
511-
if (!(period_size % 8))
511+
if (!(period_size % (sample_size * 8)))
512512
return 8;
513-
if (!(period_size % 4))
513+
if (!(period_size % (sample_size * 4)))
514514
return 4;
515-
if (!(period_size % 2))
515+
if (!(period_size % (sample_size * 2)))
516516
return 2;
517517
return 1;
518518
}
@@ -542,6 +542,8 @@ static int mchp_pdmc_hw_params(struct snd_pcm_substream *substream,
542542
unsigned int channels = params_channels(params);
543543
unsigned int osr = 0, osr_start;
544544
unsigned int fs = params_rate(params);
545+
int sample_bytes = params_physical_width(params) / 8;
546+
int maxburst;
545547
u32 mr_val = 0;
546548
u32 cfgr_val = 0;
547549
int i;
@@ -611,7 +613,9 @@ static int mchp_pdmc_hw_params(struct snd_pcm_substream *substream,
611613

612614
mr_val |= MCHP_PDMC_MR_SINCORDER(dd->sinc_order);
613615

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

0 commit comments

Comments
 (0)