Skip to content

Commit 31c45b3

Browse files
vijendarmukundabroonie
authored andcommitted
ASoC: amd: Modified DMA transfer Mechanism for Playback
Before rendering starts, DMA driver copies full buffer valid data to ACP SRAM for the first time, after that ACP SRAM to I2S FIFO DMA will be initiated. After rendering first half of ACP SRAM, IOC will be raised then Audio data will be copied from first half of System Memory to first half of ACP SRAM. Similarly after rendering second half of ACP SRAM, IOC will be raised then Audio Data will be copied from second half of the System Memory to second half of the ACP SRAM in ping-pong way till rendering stops. Old design introducing latency issues resulting stutter sound observed during playback. Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com> Signed-off-by: Akshu Agrawal <Akshu.Agrawal@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 7db08b2 commit 31c45b3

1 file changed

Lines changed: 5 additions & 22 deletions

File tree

‎sound/soc/amd/acp-pcm-dma.c‎

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio,
193193
dmadscr[i].xfer_val = 0;
194194
if (direction == SNDRV_PCM_STREAM_PLAYBACK) {
195195
dma_dscr_idx = PLAYBACK_START_DMA_DESCR_CH12 + i;
196-
dmadscr[i].dest = ACP_SHARED_RAM_BANK_1_ADDRESS +
197-
(size / 2) - (i * (size/2));
196+
dmadscr[i].dest = ACP_SHARED_RAM_BANK_1_ADDRESS
197+
+ (i * (size/2));
198198
dmadscr[i].src = ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS
199199
+ (pte_offset * SZ_4K) + (i * (size/2));
200200
switch (asic_type) {
@@ -655,9 +655,9 @@ static irqreturn_t dma_irq_handler(int irq, void *arg)
655655
valid_irq = true;
656656
if (acp_reg_read(acp_mmio, mmACP_DMA_CUR_DSCR_13) ==
657657
PLAYBACK_START_DMA_DESCR_CH13)
658-
dscr_idx = PLAYBACK_START_DMA_DESCR_CH12;
659-
else
660658
dscr_idx = PLAYBACK_END_DMA_DESCR_CH12;
659+
else
660+
dscr_idx = PLAYBACK_START_DMA_DESCR_CH12;
661661
config_acp_dma_channel(acp_mmio, SYSRAM_TO_ACP_CH_NUM, dscr_idx,
662662
1, 0);
663663
acp_dma_start(acp_mmio, SYSRAM_TO_ACP_CH_NUM, false);
@@ -882,23 +882,6 @@ static int acp_dma_prepare(struct snd_pcm_substream *substream)
882882
config_acp_dma_channel(rtd->acp_mmio, ACP_TO_I2S_DMA_CH_NUM,
883883
PLAYBACK_START_DMA_DESCR_CH13,
884884
NUM_DSCRS_PER_CHANNEL, 0);
885-
/* Fill ACP SRAM (2 periods) with zeros from System RAM
886-
* which is zero-ed in hw_params
887-
*/
888-
acp_dma_start(rtd->acp_mmio, SYSRAM_TO_ACP_CH_NUM, false);
889-
890-
/* ACP SRAM (2 periods of buffer size) is intially filled with
891-
* zeros. Before rendering starts, 2nd half of SRAM will be
892-
* filled with valid audio data DMA'ed from first half of system
893-
* RAM and 1st half of SRAM will be filled with Zeros. This is
894-
* the initial scenario when redering starts from SRAM. Later
895-
* on, 2nd half of system memory will be DMA'ed to 1st half of
896-
* SRAM, 1st half of system memory will be DMA'ed to 2nd half of
897-
* SRAM in ping-pong way till rendering stops.
898-
*/
899-
config_acp_dma_channel(rtd->acp_mmio, SYSRAM_TO_ACP_CH_NUM,
900-
PLAYBACK_START_DMA_DESCR_CH12,
901-
1, 0);
902885
} else {
903886
config_acp_dma_channel(rtd->acp_mmio, ACP_TO_SYSRAM_CH_NUM,
904887
CAPTURE_START_DMA_DESCR_CH14,
@@ -913,7 +896,7 @@ static int acp_dma_prepare(struct snd_pcm_substream *substream)
913896
static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd)
914897
{
915898
int ret;
916-
u32 loops = 1000;
899+
u32 loops = 4000;
917900
u64 bytescount = 0;
918901

919902
struct snd_pcm_runtime *runtime = substream->runtime;

0 commit comments

Comments
 (0)