Skip to content

Commit 5bfd7f4

Browse files
author
Codrin Ciubotariu
committed
ASoC: atmel: mchp-i2s-mcc: 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: 2c1ab8c ("ASoC: atmel: mchp-i2s-mcc: calculate maxburst based on period size") Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
1 parent 2e00b0a commit 5bfd7f4

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -504,13 +504,13 @@ static int mchp_i2s_mcc_is_running(struct mchp_i2s_mcc_dev *dev)
504504
return !!(sr & (MCHP_I2SMCC_SR_TXEN | MCHP_I2SMCC_SR_RXEN));
505505
}
506506

507-
static inline int mchp_i2s_mcc_period_to_maxburst(int period_size)
507+
static inline int mchp_i2s_mcc_period_to_maxburst(int period_size, int sample_size)
508508
{
509-
if (!(period_size % 8))
509+
if (!(period_size % (sample_size * 8)))
510510
return 8;
511-
if (!(period_size % 4))
511+
if (!(period_size % (sample_size * 4)))
512512
return 4;
513-
if (!(period_size % 2))
513+
if (!(period_size % (sample_size * 2)))
514514
return 2;
515515
return 1;
516516
}
@@ -521,7 +521,9 @@ static int mchp_i2s_mcc_hw_params(struct snd_pcm_substream *substream,
521521
{
522522
unsigned long rate = 0;
523523
struct mchp_i2s_mcc_dev *dev = snd_soc_dai_get_drvdata(dai);
524+
int sample_bytes = params_physical_width(params) / 8;
524525
int period_size = snd_pcm_lib_period_bytes(substream);
526+
int maxburst;
525527
u32 mra = 0;
526528
u32 mrb = 0;
527529
unsigned int channels = params_channels(params);
@@ -642,11 +644,12 @@ static int mchp_i2s_mcc_hw_params(struct snd_pcm_substream *substream,
642644
* We must have the same burst size configured
643645
* in the DMA transfer and in out IP
644646
*/
645-
mrb |= MCHP_I2SMCC_MRB_DMACHUNK(mchp_i2s_mcc_period_to_maxburst(period_size));
647+
maxburst = mchp_i2s_mcc_period_to_maxburst(period_size, sample_bytes);
648+
mrb |= MCHP_I2SMCC_MRB_DMACHUNK(maxburst);
646649
if (is_playback)
647-
dev->playback.maxburst = mchp_i2s_mcc_period_to_maxburst(period_size);
650+
dev->playback.maxburst = maxburst;
648651
else
649-
dev->capture.maxburst = mchp_i2s_mcc_period_to_maxburst(period_size);
652+
dev->capture.maxburst = maxburst;
650653

651654
switch (params_format(params)) {
652655
case SNDRV_PCM_FORMAT_S8:

0 commit comments

Comments
 (0)