MLK-13224: ASoC: imx-hdmi-dma: fix glitch noise issue in long time playback
authorShengjiu Wang <shengjiu.wang@freescale.com>
Fri, 14 Oct 2016 03:44:34 +0000 (11:44 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:52:25 +0000 (14:52 -0500)
The calculation "runtime->status->hw_ptr * (runtime->frame_bits / 8)" may
exceed the integer scope, then appl_bytes is no correct.
This patch is to fix this issue.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
sound/soc/fsl/imx-hdmi-dma.c

index 0df6851..411906f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * imx-hdmi-dma.c  --  HDMI DMA driver for ALSA Soc Audio Layer
  *
- * Copyright (C) 2011-2014 Freescale Semiconductor, Inc.
+ * Copyright (C) 2011-2016 Freescale Semiconductor, Inc.
  *
  * based on imx-pcm-dma-mx2.c
  * Copyright 2009 Sascha Hauer <s.hauer@pengutronix.de>
@@ -455,7 +455,7 @@ static void hdmi_dma_data_copy(struct snd_pcm_substream *substream,
        if (runtime->access != SNDRV_PCM_ACCESS_MMAP_INTERLEAVED)
                return;
 
-       appl_bytes =  runtime->status->hw_ptr * (runtime->frame_bits / 8);
+       appl_bytes =  (runtime->status->hw_ptr % (priv->buffer_bytes/(runtime->frame_bits/8))) * (runtime->frame_bits/8);
        if (type == 'p')
                appl_bytes += 2 * priv->period_bytes;
        offset = appl_bytes % priv->buffer_bytes;