Skip to content

Commit 2c1ab8c

Browse files
author
Codrin Ciubotariu
committed
ASoC: atmel: mchp-i2s-mcc: calculate maxburst based on period size
The period size represents the size of the DMA descriptor. This means that the period size can be used to compute a higher maxburst value, to increase the performance of the DMA transfer. Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
1 parent 4807d29 commit 2c1ab8c

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,12 +504,24 @@ 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)
508+
{
509+
if (!(period_size % 8))
510+
return 8;
511+
if (!(period_size % 4))
512+
return 4;
513+
if (!(period_size % 2))
514+
return 2;
515+
return 1;
516+
}
517+
507518
static int mchp_i2s_mcc_hw_params(struct snd_pcm_substream *substream,
508519
struct snd_pcm_hw_params *params,
509520
struct snd_soc_dai *dai)
510521
{
511522
unsigned long rate = 0;
512523
struct mchp_i2s_mcc_dev *dev = snd_soc_dai_get_drvdata(dai);
524+
int period_size = snd_pcm_lib_period_bytes(substream);
513525
u32 mra = 0;
514526
u32 mrb = 0;
515527
unsigned int channels = params_channels(params);
@@ -630,11 +642,11 @@ static int mchp_i2s_mcc_hw_params(struct snd_pcm_substream *substream,
630642
* We must have the same burst size configured
631643
* in the DMA transfer and in out IP
632644
*/
633-
mrb |= MCHP_I2SMCC_MRB_DMACHUNK(channels);
645+
mrb |= MCHP_I2SMCC_MRB_DMACHUNK(mchp_i2s_mcc_period_to_maxburst(period_size));
634646
if (is_playback)
635-
dev->playback.maxburst = 1 << (fls(channels) - 1);
647+
dev->playback.maxburst = mchp_i2s_mcc_period_to_maxburst(period_size);
636648
else
637-
dev->capture.maxburst = 1 << (fls(channels) - 1);
649+
dev->capture.maxburst = mchp_i2s_mcc_period_to_maxburst(period_size);
638650

639651
switch (params_format(params)) {
640652
case SNDRV_PCM_FORMAT_S8:

0 commit comments

Comments
 (0)