From patchwork Thu Nov 9 17:35:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 10051523 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4F351603FA for ; Thu, 9 Nov 2017 17:36:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 377972B00E for ; Thu, 9 Nov 2017 17:36:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C0342B047; Thu, 9 Nov 2017 17:36:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A5D02B00E for ; Thu, 9 Nov 2017 17:36:26 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 0390C267846; Thu, 9 Nov 2017 18:36:11 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id CA718267843; Thu, 9 Nov 2017 18:36:06 +0100 (CET) Received: from mail-qt0-f193.google.com (mail-qt0-f193.google.com [209.85.216.193]) by alsa0.perex.cz (Postfix) with ESMTP id 0294A26783F for ; Thu, 9 Nov 2017 18:36:02 +0100 (CET) Received: by mail-qt0-f193.google.com with SMTP id y45so2492737qty.6 for ; Thu, 09 Nov 2017 09:36:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SUT1SqA02wmIONHitlxe0lvxbaREdNOPngqa5BSJwJo=; b=JhMVSHFTmF9kHCwvq95DOi6ZQL9iYb3I/0JTPxrHP5fUi3EGEqTVGKbtJWvZwKcHli TGO3KVU6ScCuDV0hTEtLvR/Zo+iU56s0WDPibedd0u+VApRRbhrLYgpu2iqB85eOaym2 3grbp8DtTAgeIW4AvwgfuM3shHoeMAz+QifnYYciazaV0LMw8xFKC733uz55h1CRx2tV TVA+v1fDVeO9/TdV1jrluNNH6ZcsHvGbl3JPzEl4MZMOYkR20YqBPuaMewsPYX9UKg8s fkG2/ey2CDkXPUQmL3ngP3uMl9zExYz2/8UegLJmgXurXZiHofXIDy4+DW1obIVp/f3x 88/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SUT1SqA02wmIONHitlxe0lvxbaREdNOPngqa5BSJwJo=; b=tbVqienltopyddPUT0iLlVmHBHrYvM/B+aUyEMAGrcs4AxqP4sDscLNeZrvc3kr9+a KubY432+jdK+RbuC0wOSVRQTO3tlwq6p6aX3wpDxx3NSylvtXvoIwrmwVz4cWXDnS/Q/ P5rsJz7NHq/eYW/q2kIE1w7C718WQV78bqBzyOLmD87iMs7KCQ08fskHfR2JpEpCAh9Z zs00l0FbLus+4klcarrnkuU7lTTffT9DkRaLXODqf0hQSc/0TIg79QHTrS3rUrhxjQSE a0jiNAEbSlwi7LREWdpd+ITI9TTXO8FXrrY4VRZAeMchMF1I9PnbpQFjvp4kVK02UQPJ BeFQ== X-Gm-Message-State: AJaThX7o8ANU98wXAVyC/0yKqjmFLD8NHQzTCvSZe8AWHEQG7N7CZRmb S2hbgrG0cykPrF0u6me7lxPF7g== X-Google-Smtp-Source: AGs4zMbmeeqPCOhor+4oe4+LLx1RE3mLz+AWV9ej5+/utqOx62kHf93xf4yI6MrChucyR7AR9hpJ6g== X-Received: by 10.200.20.13 with SMTP id k13mr2013931qtj.261.1510248962036; Thu, 09 Nov 2017 09:36:02 -0800 (PST) Received: from localhost.localdomain (va-67-233-122-109.dhcp.embarqhsd.net. [67.233.122.109]) by smtp.gmail.com with ESMTPSA id t49sm5017532qta.54.2017.11.09.09.36.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Nov 2017 09:36:01 -0800 (PST) From: Alex Deucher X-Google-Original-From: Alex Deucher To: alsa-devel@alsa-project.org, broonie@kernel.org, Vijendar.Mukunda@amd.com Date: Thu, 9 Nov 2017 12:35:52 -0500 Message-Id: <20171109173552.21438-2-alexander.deucher@amd.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171109173552.21438-1-alexander.deucher@amd.com> References: <20171109173552.21438-1-alexander.deucher@amd.com> Cc: tiwai@suse.de, Alex Deucher , lgirdwood@gmail.com, Akshu Agrawal Subject: [alsa-devel] [PATCH] ASoC: amd: Modified DMA transfer Mechanism for Playback X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Vijendar Mukunda 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 Signed-off-by: Akshu Agrawal Signed-off-by: Alex Deucher --- sound/soc/amd/acp-pcm-dma.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index ef7e98ad960c..9f521a55d610 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -193,8 +193,8 @@ static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio, dmadscr[i].xfer_val = 0; if (direction == SNDRV_PCM_STREAM_PLAYBACK) { dma_dscr_idx = PLAYBACK_START_DMA_DESCR_CH12 + i; - dmadscr[i].dest = ACP_SHARED_RAM_BANK_1_ADDRESS + - (size / 2) - (i * (size/2)); + dmadscr[i].dest = ACP_SHARED_RAM_BANK_1_ADDRESS + + (i * (size/2)); dmadscr[i].src = ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS + (pte_offset * SZ_4K) + (i * (size/2)); switch (asic_type) { @@ -655,9 +655,9 @@ static irqreturn_t dma_irq_handler(int irq, void *arg) valid_irq = true; if (acp_reg_read(acp_mmio, mmACP_DMA_CUR_DSCR_13) == PLAYBACK_START_DMA_DESCR_CH13) - dscr_idx = PLAYBACK_START_DMA_DESCR_CH12; - else dscr_idx = PLAYBACK_END_DMA_DESCR_CH12; + else + dscr_idx = PLAYBACK_START_DMA_DESCR_CH12; config_acp_dma_channel(acp_mmio, SYSRAM_TO_ACP_CH_NUM, dscr_idx, 1, 0); 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) config_acp_dma_channel(rtd->acp_mmio, ACP_TO_I2S_DMA_CH_NUM, PLAYBACK_START_DMA_DESCR_CH13, NUM_DSCRS_PER_CHANNEL, 0); - /* Fill ACP SRAM (2 periods) with zeros from System RAM - * which is zero-ed in hw_params - */ - acp_dma_start(rtd->acp_mmio, SYSRAM_TO_ACP_CH_NUM, false); - - /* ACP SRAM (2 periods of buffer size) is intially filled with - * zeros. Before rendering starts, 2nd half of SRAM will be - * filled with valid audio data DMA'ed from first half of system - * RAM and 1st half of SRAM will be filled with Zeros. This is - * the initial scenario when redering starts from SRAM. Later - * on, 2nd half of system memory will be DMA'ed to 1st half of - * SRAM, 1st half of system memory will be DMA'ed to 2nd half of - * SRAM in ping-pong way till rendering stops. - */ - config_acp_dma_channel(rtd->acp_mmio, SYSRAM_TO_ACP_CH_NUM, - PLAYBACK_START_DMA_DESCR_CH12, - 1, 0); } else { config_acp_dma_channel(rtd->acp_mmio, ACP_TO_SYSRAM_CH_NUM, CAPTURE_START_DMA_DESCR_CH14, @@ -913,7 +896,7 @@ static int acp_dma_prepare(struct snd_pcm_substream *substream) static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) { int ret; - u32 loops = 1000; + u32 loops = 4000; u64 bytescount = 0; struct snd_pcm_runtime *runtime = substream->runtime;