From patchwork Tue May 1 20:49:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 10374413 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 088BB601C7 for ; Tue, 1 May 2018 20:47:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED7E628D35 for ; Tue, 1 May 2018 20:47:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E20E028CD6; Tue, 1 May 2018 20:47:43 +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=-2.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=unavailable 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 ADC3928CD6 for ; Tue, 1 May 2018 20:47:42 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 89D2E266F0F; Tue, 1 May 2018 22:47:40 +0200 (CEST) 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 A804E266F44; Tue, 1 May 2018 22:47:38 +0200 (CEST) Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0074.outbound.protection.outlook.com [104.47.37.74]) by alsa0.perex.cz (Postfix) with ESMTP id ABAA4266C1C for ; Tue, 1 May 2018 22:47:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=/7uh4tTZ+Ka2KK7+s1G4NYMedSbCtWcaEAIF1omMNPk=; b=N5CPMfl9kQFZc4ZLuYEZVCkxLkpOY1mXbHn9YkLHhmY3qZy1VSKpLBD8h1lK4JSaQTJs+N+WhSP91V8vx5hUwWiGEgK/jUDgZE3xrfUtI9iuBBsu/5yFbdgaUoGvnqvCfzttIj5t0VSfbb7/hey9MIBtdmhtOxNgYDUB1Y15CB0= Received: from DM3PR12CA0081.namprd12.prod.outlook.com (2603:10b6:0:57::25) by DM5PR12MB2422.namprd12.prod.outlook.com (2603:10b6:4:b4::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.715.18; Tue, 1 May 2018 20:47:32 +0000 Received: from DM3NAM03FT039.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::208) by DM3PR12CA0081.outlook.office365.com (2603:10b6:0:57::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.715.20 via Frontend Transport; Tue, 1 May 2018 20:47:31 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; linuxfoundation.org; dkim=none (message not signed) header.d=none;linuxfoundation.org; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV02.amd.com (165.204.84.17) by DM3NAM03FT039.mail.protection.outlook.com (10.152.83.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.715.13 via Frontend Transport; Tue, 1 May 2018 20:47:31 +0000 Received: from LinuxHost.amd.com (10.34.1.3) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server id 14.3.382.0; Tue, 1 May 2018 15:47:28 -0500 From: Vijendar Mukunda To: Date: Wed, 2 May 2018 02:19:55 +0530 Message-ID: <1525207810-1305-1-git-send-email-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(346002)(39380400002)(396003)(376002)(39860400002)(2980300002)(428003)(189003)(199004)(72206003)(7696005)(86362001)(356003)(53936002)(2906002)(126002)(8936002)(2616005)(476003)(478600001)(68736007)(97736004)(109986005)(6666003)(59450400001)(426003)(486006)(51416003)(47776003)(336012)(8676002)(186003)(39060400002)(26005)(48376002)(7416002)(1671002)(316002)(50466002)(54906003)(305945005)(5660300001)(81166006)(81156014)(36756003)(105586002)(16586007)(106466001)(77096007)(104016004)(53416004)(50226002)(4326008)(266003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB2422; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT039; 1:YRvPZS4rkqJsNDbi626NWUiXZxOZdt+Y537SKuAWjPf0HsP/x478h0yYT3fBk/cHtWA4mtsJ9epmfN11Aarmb2UrMqLDGqx3p2OFYFEpwe13r8aATHUbOExqjRqu9ZZj X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060); SRVR:DM5PR12MB2422; X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB2422; 3:jtLl0mnJn8xv+H4JsywzK6g0Dgv6gwdBy6EiAIEzVwu59q/cC0g9nSEUTo1iWFplkJtZaYLMz93H2CR1Wy+JHXou4k5DGzLXWSwBmeXhfi1ElYULqd5Jo0xeu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FOAOlMKZ+nz+oXdaP80+U6Ct9rQlOCpZtNA70mcLtP00Aqn86KX4foioRFJoEh26MloZ3ethK0MILgPHtgnQkO9kEU2FJ4n/NVLtb/LpFIj03UVic/eyI2luejiAvEZZmWIChBKWj43VY36vHOo6YTxMo7VV477IDqAFrkCq1oBSh1c+Kn0Ht6/Cq10m4Z6p0gLW7A14Bxq6b84ZRSmQfJipcCIJpye1J/Y/QDdKUVJoI+YaC/bfPG6/xQ1b2VSCUUNmikLuRGtMKWfOcSEafIYu+mfOHWiWphsP6uvd8dHj5AOAb43+TYirHhjEp0ilTVSeq8ZxXt7LyEAjB+pK4mu X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93003095)(10201501046)(3002001)(3231254)(944501410)(52105095)(6055026)(6041310)(20161123560045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011); SRVR:DM5PR12MB2422; BCL:0; PCL:0; RULEID:; SRVR:DM5PR12MB2422; X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB2422; 4:H3cme1/+tycco79myvgsDt+AVfLIFERl7qOceHpwMBaRcWIJrntzlFxq4YSYv45rhqloSnb9Qjce3NinWtzH/xrgzHC4AxD2CzQqz5Sm3t6fhaa2bHQz/5hErZT5URqiWhncjEE7GjDkZbTLCrUOgQJYAybM7lpG+7HfjEtAyf68alv55PJ2J3WGkIZ+PU5JLLpJPUgYVD7UOmY/qYyWAC2g9kVe0/KQrr59xD5FHQ5pgiYQRUhsaUq1smQWTuu/0rLRTBuHwY/6DqmzsMNjZwy/8oVUWojS8KqdNVYE+S0Rxb5CK03TkHGFwcnBaD+l X-Forefront-PRVS: 06592CCE58 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR12MB2422; 23:38aqHO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?= =?us-ascii?Q?iiPGMAwTzcNQC7xYado6AbXyFQgsoMfMLTxiVyW94NRG7vujP66L29JA4TST?= =?us-ascii?Q?Db3wa+CGc8SwvgJhXIGvR3XD7NRZlaBOg2XeAlItW1apMa6tOh/zzUuMZwGp?= =?us-ascii?Q?5PI4m0C4JqoHWo5h4hApM4CQo5IvZLlDw1lkSzhbrq2qWKxN6BP/Mw0+GLWX?= =?us-ascii?Q?TdQmUBm+pwvxiQZsuzTRXsYucah8vLAUH6iSXbOxd0DgieL3qYaU1C2el6MH?= =?us-ascii?Q?4fZIdPrwNck2hFocTPqXthU6TbvRlcY3a0w3Lo4EQdNItaj0iKZg4K0775cn?= =?us-ascii?Q?c92v/eicZoWRS7fdfy40l0S34Nk5s3qBKKQKWofFfMZAhairmkZ58H6Hw=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Antispam-Message-Info: KvxqwN1uhgprjOhl3RlHQrPV8JxwjwRrMl4gFfYxmuG2wjUlPZyzWFiYyhcnp8+Av3cfiWtYIdbMB5DkhQypzR3WqoEcRyJY09stRZSLYuvBrQXotKnIyp78VXE1JDewj0osSyij6qfnjB/JY43zrbexXj16op+CsSPY4GwdM0Sy8U2ZMRBdJdYxJkeX4XWe X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB2422; 6:uCi4p3ENEtj86zIoei9W7COpnn4hfFtHpy4KsN+vl4USQ22TZemn6IehuOpU/vHR9K5hnydJa0hUfMwxOAibYUGudoxelIYgl7vF15lp1cLrmQpSJvhk4kjM/kuMpnBio6nV9jIfcy1O9fpaBPvg26+IkGEB+uv+1TrISADx7KuY8FCHbjnw+VeYMRpgngb+vWVcBLkSO1nYJFc1jKrOnG6X6FPfylsCKzzqPJz0jvio8zt9BCtcZFgK0HDSCjOihB5mpPdYaFpWFQ0tXGLGw2gtxPnAQcDW8zEZ69XvvPtLsx/H8vF0xBepFp1Pq4uzyNN5bKkKYGzik1u6jACiM+ZyLHhTKxdn+rTs2zPPSo7moE4zUZTAIMoNav9Yv4/csODbsQZboPtM64I/vMcerDcUWY9Jp65/COvdQCgnC3ihrrffLwhvxZ0G+MZbSCWQdAHUg1ZLB94FIZyq+WcnrA==; 5:oJWpk8PjVJim0oXBZrpjJ8LAlXe22NpQ4L8orVJkFHDV5t0v2xABSOyFwbHpSwHNCOvzCd0idVjX+P7VFFJwQBs8O29UabvjAH5ozqNpzxrDAiVtQh8ZrnEIgouMBQCiSXAzRkeq4mPvfV7DOOysvvLZt0AIAKacpibRsgbMqQ4=; 24:JL29NOSgGd6jM7zTWCY4mZL5+UG80vDjULS6amvowI5rS5Bwe02wZIk56KH2iw/2luVtp7OcR+t6dyFQJM3WBTE4GpS+CEOap5chqQG5Nt4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB2422; 7:BHp06lxadW2Gp7qBAGOyuxM23At+iLKb7giHqsx03cnxVJN2m7cMwdO1ciRNNrFP5XsqzOzBLQvJT5ejuvK9xTjDn3eXqkgqPIpwRM/TFDaAHULGfAhSHzHTehHAzdHj58Y7HnNOSAM/O20HYCHuRVUXsGk+PuTwDCjmOxUm8tfQKlx295qfI51g6oNLp7v1XAVICklsuWm4aa7nE2xESHKu75gQhNU2wE428pHPVd0tWUTcRsFhQQ/V0pgjKV6M; 20:+pdMmsCpgssU51Rhm+uBO7nufA983ZsEO7AscFtv03L0OvS3WWVgMhhLYrp2a2fJ/utnzKsCVmk8uJvNNJNu2/EW+UjxF4H0BoXZFnefdoHsLvg4uHI64bTgkMc9fgJNo2mZZD1QOgBrZq7rW3/U7qhEkx8H3F9wySsctcTzkDHicB6G2yogyK9itNH7WlslVmvTdpg/V+WzYsU1fy21+qvhjaqqzWm7mtA4N/cycAd+Tr1cbO8b6GRDpvPRp0nV X-MS-Office365-Filtering-Correlation-Id: 96d60d24-285a-48c3-2f4c-08d5afa4c295 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2018 20:47:31.1066 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 96d60d24-285a-48c3-2f4c-08d5afa4c295 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB2422 Cc: Kate Stewart , "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list , Kuninori Morimoto , Liam Girdwood , Greg Kroah-Hartman , Philippe Ombredanne , Takashi Iwai , Jason Clinton , Mark Brown , Vijendar Mukunda , Alex Deucher , Akshu Agrawal , Guenter Roeck Subject: [alsa-devel] [PATCH V2 01/10] ASoC: amd: dma config parameters changes 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Added dma configuration parameters to rtd structure. Moved dma configuration parameters initialization to hw_params callback. Removed hard coding in prepare and trigger callbacks. Signed-off-by: Vijendar Mukunda --- v1->v2 : Fixed capture stream wrong channel assignment added comments in dma trigger api sound/soc/amd/acp-pcm-dma.c | 103 ++++++++++++++++++-------------------------- sound/soc/amd/acp.h | 5 +++ 2 files changed, 48 insertions(+), 60 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index 9c026c4..e9736fe 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -321,19 +321,12 @@ static void config_acp_dma(void __iomem *acp_mmio, u32 asic_type) { u32 pte_offset, sram_bank; - u16 ch1, ch2, destination, dma_dscr_idx; if (rtd->direction == SNDRV_PCM_STREAM_PLAYBACK) { pte_offset = ACP_PLAYBACK_PTE_OFFSET; - ch1 = SYSRAM_TO_ACP_CH_NUM; - ch2 = ACP_TO_I2S_DMA_CH_NUM; sram_bank = ACP_SHARED_RAM_BANK_1_ADDRESS; - destination = TO_ACP_I2S_1; - } else { pte_offset = ACP_CAPTURE_PTE_OFFSET; - ch1 = SYSRAM_TO_ACP_CH_NUM; - ch2 = ACP_TO_I2S_DMA_CH_NUM; switch (asic_type) { case CHIP_STONEY: sram_bank = ACP_SHARED_RAM_BANK_3_ADDRESS; @@ -341,30 +334,19 @@ static void config_acp_dma(void __iomem *acp_mmio, default: sram_bank = ACP_SHARED_RAM_BANK_5_ADDRESS; } - destination = FROM_ACP_I2S_1; } - acp_pte_config(acp_mmio, rtd->pg, rtd->num_of_pages, pte_offset); - if (rtd->direction == SNDRV_PCM_STREAM_PLAYBACK) - dma_dscr_idx = PLAYBACK_START_DMA_DESCR_CH12; - else - dma_dscr_idx = CAPTURE_START_DMA_DESCR_CH14; - /* Configure System memory <-> ACP SRAM DMA descriptors */ set_acp_sysmem_dma_descriptors(acp_mmio, rtd->size, - rtd->direction, pte_offset, ch1, - sram_bank, dma_dscr_idx, asic_type); - - if (rtd->direction == SNDRV_PCM_STREAM_PLAYBACK) - dma_dscr_idx = PLAYBACK_START_DMA_DESCR_CH13; - else - dma_dscr_idx = CAPTURE_START_DMA_DESCR_CH15; + rtd->direction, pte_offset, + rtd->ch1, sram_bank, + rtd->dma_dscr_idx_1, asic_type); /* Configure ACP SRAM <-> I2S DMA descriptors */ set_acp_to_i2s_dma_descriptors(acp_mmio, rtd->size, rtd->direction, sram_bank, - destination, ch2, dma_dscr_idx, - asic_type); + rtd->destination, rtd->ch2, + rtd->dma_dscr_idx_2, asic_type); } /* Start a given DMA channel transfer */ @@ -804,6 +786,21 @@ static int acp_dma_hw_params(struct snd_pcm_substream *substream, acp_reg_write(val, adata->acp_mmio, mmACP_I2S_16BIT_RESOLUTION_EN); } + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + rtd->ch1 = SYSRAM_TO_ACP_CH_NUM; + rtd->ch2 = ACP_TO_I2S_DMA_CH_NUM; + rtd->destination = TO_ACP_I2S_1; + rtd->dma_dscr_idx_1 = PLAYBACK_START_DMA_DESCR_CH12; + rtd->dma_dscr_idx_2 = PLAYBACK_START_DMA_DESCR_CH13; + } else { + rtd->ch1 = ACP_TO_SYSRAM_CH_NUM; + rtd->ch2 = I2S_TO_ACP_DMA_CH_NUM; + rtd->destination = FROM_ACP_I2S_1; + rtd->dma_dscr_idx_1 = CAPTURE_START_DMA_DESCR_CH14; + rtd->dma_dscr_idx_2 = CAPTURE_START_DMA_DESCR_CH15; + } + size = params_buffer_bytes(params); status = snd_pcm_lib_malloc_pages(substream, size); if (status < 0) @@ -898,21 +895,15 @@ static int acp_dma_prepare(struct snd_pcm_substream *substream) if (!rtd) return -EINVAL; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - config_acp_dma_channel(rtd->acp_mmio, SYSRAM_TO_ACP_CH_NUM, - PLAYBACK_START_DMA_DESCR_CH12, - NUM_DSCRS_PER_CHANNEL, 0); - config_acp_dma_channel(rtd->acp_mmio, ACP_TO_I2S_DMA_CH_NUM, - PLAYBACK_START_DMA_DESCR_CH13, - NUM_DSCRS_PER_CHANNEL, 0); - } else { - config_acp_dma_channel(rtd->acp_mmio, ACP_TO_SYSRAM_CH_NUM, - CAPTURE_START_DMA_DESCR_CH14, - NUM_DSCRS_PER_CHANNEL, 0); - config_acp_dma_channel(rtd->acp_mmio, I2S_TO_ACP_DMA_CH_NUM, - CAPTURE_START_DMA_DESCR_CH15, - NUM_DSCRS_PER_CHANNEL, 0); - } + + config_acp_dma_channel(rtd->acp_mmio, + rtd->ch1, + rtd->dma_dscr_idx_1, + NUM_DSCRS_PER_CHANNEL, 0); + config_acp_dma_channel(rtd->acp_mmio, + rtd->ch2, + rtd->dma_dscr_idx_2, + NUM_DSCRS_PER_CHANNEL, 0); return 0; } @@ -939,10 +930,9 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { if (rtd->i2ssp_renderbytescount == 0) rtd->i2ssp_renderbytescount = bytescount; - acp_dma_start(rtd->acp_mmio, - SYSRAM_TO_ACP_CH_NUM, false); + acp_dma_start(rtd->acp_mmio, rtd->ch1, false); while (acp_reg_read(rtd->acp_mmio, mmACP_DMA_CH_STS) & - BIT(SYSRAM_TO_ACP_CH_NUM)) { + BIT(rtd->ch1)) { if (!loops--) { dev_err(component->dev, "acp dma start timeout\n"); @@ -950,38 +940,31 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) } cpu_relax(); } - - acp_dma_start(rtd->acp_mmio, - ACP_TO_I2S_DMA_CH_NUM, true); - } else { if (rtd->i2ssp_capturebytescount == 0) rtd->i2ssp_capturebytescount = bytescount; - acp_dma_start(rtd->acp_mmio, - I2S_TO_ACP_DMA_CH_NUM, true); } + acp_dma_start(rtd->acp_mmio, rtd->ch2, true); ret = 0; break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: case SNDRV_PCM_TRIGGER_SUSPEND: - /* - * Need to stop only circular DMA channels : - * ACP_TO_I2S_DMA_CH_NUM / I2S_TO_ACP_DMA_CH_NUM. Non-circular - * channels will stopped automatically after its transfer - * completes : SYSRAM_TO_ACP_CH_NUM / ACP_TO_SYSRAM_CH_NUM + /* For playback, non circular dma should be stopped first + * i.e Sysram to acp dma transfer channel(rtd->ch1) should be + * stopped before stopping cirular dma which is acp sram to i2s + * fifo dma transfer channel(rtd->ch2). Where as in Capture + * scenario, i2s fifo to acp sram dma channel(rtd->ch2) stopped + * first before stopping acp sram to sysram which is circular + * dma(rtd->ch1). */ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - ret = acp_dma_stop(rtd->acp_mmio, - SYSRAM_TO_ACP_CH_NUM); - ret = acp_dma_stop(rtd->acp_mmio, - ACP_TO_I2S_DMA_CH_NUM); + acp_dma_stop(rtd->acp_mmio, rtd->ch1); + ret = acp_dma_stop(rtd->acp_mmio, rtd->ch2); rtd->i2ssp_renderbytescount = 0; } else { - ret = acp_dma_stop(rtd->acp_mmio, - I2S_TO_ACP_DMA_CH_NUM); - ret = acp_dma_stop(rtd->acp_mmio, - ACP_TO_SYSRAM_CH_NUM); + acp_dma_stop(rtd->acp_mmio, rtd->ch2); + ret = acp_dma_stop(rtd->acp_mmio, rtd->ch1); rtd->i2ssp_capturebytescount = 0; } break; diff --git a/sound/soc/amd/acp.h b/sound/soc/amd/acp.h index 0e6089b..5e25428 100644 --- a/sound/soc/amd/acp.h +++ b/sound/soc/amd/acp.h @@ -85,6 +85,11 @@ struct audio_substream_data { unsigned int order; u16 num_of_pages; u16 direction; + u16 ch1; + u16 ch2; + u16 destination; + u16 dma_dscr_idx_1; + u16 dma_dscr_idx_2; uint64_t size; u64 i2ssp_renderbytescount; u64 i2ssp_capturebytescount;