From patchwork Mon May 14 11:57:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 10398137 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 9574F60216 for ; Mon, 14 May 2018 12:02:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84ACD2911D for ; Mon, 14 May 2018 12:02:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7778429120; Mon, 14 May 2018 12:02:14 +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 5ADAD2911F for ; Mon, 14 May 2018 12:02:11 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E2A25266EDF; Mon, 14 May 2018 13:54:59 +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 A61C9266F0F; Mon, 14 May 2018 13:54:57 +0200 (CEST) Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0070.outbound.protection.outlook.com [104.47.42.70]) by alsa0.perex.cz (Postfix) with ESMTP id 281F8266C1C for ; Mon, 14 May 2018 13:54:52 +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=BUz82NxT8aD2q6/2u6uaAM5iTP5YL9X8p9yfg5JmYtY=; b=FXsAAcXRBVSe7nUxzpV6WKHTO87swPL0LFCsp0EQg2WEatXkHIH+jfBEftOGG3Iv1mxCaFLM0hEE3Egug0543q0DjBnElthkDhzBwFFPTa+zwiZ5TxVL5yjAbl+Vjc3TGlj3fqmSI61DAqxGcTxCIW+5fc8LGwrnIhDYtWPkkpE= Received: from SN1PR12CA0039.namprd12.prod.outlook.com (2a01:111:e400:5174::49) by DM3PR12MB0764.namprd12.prod.outlook.com (2a01:111:e400:5984::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.755.16; Mon, 14 May 2018 11:54:48 +0000 Received: from CO1NAM03FT032.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::201) by SN1PR12CA0039.outlook.office365.com (2a01:111:e400:5174::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.755.16 via Frontend Transport; Mon, 14 May 2018 11:54:48 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; nexb.com; dkim=none (message not signed) header.d=none; nexb.com; 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 CO1NAM03FT032.mail.protection.outlook.com (10.152.80.173) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.755.15 via Frontend Transport; Mon, 14 May 2018 11:54:47 +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; Mon, 14 May 2018 06:54:46 -0500 From: Vijendar Mukunda To: Date: Mon, 14 May 2018 17:27:36 +0530 Message-ID: <1526299075-31475-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)(39380400002)(346002)(396003)(39860400002)(376002)(2980300002)(428003)(189003)(199004)(478600001)(186003)(8676002)(81156014)(47776003)(97736004)(8936002)(104016004)(356003)(72206003)(86362001)(7696005)(51416003)(77096007)(36756003)(16586007)(126002)(476003)(6666003)(81166006)(54906003)(305945005)(486006)(2616005)(105586002)(39060400002)(4326008)(50226002)(106466001)(53416004)(26005)(2906002)(426003)(5660300001)(68736007)(1671002)(316002)(109986005)(48376002)(7416002)(336012)(53936002)(50466002)(266003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM3PR12MB0764; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT032; 1:0zPtF/cWZVhdGd5u9Brt7S1nJWiXjGMxhtg17ZiP5fOF97ZYQ1+fNTu3Hgj/P0uaxqsYXW8hXMpR0hR+FOu1MKYZpZGWaYiOo1l24tjbo86IExiFDltkYAoaf8TFX8SS X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060); SRVR:DM3PR12MB0764; X-Microsoft-Exchange-Diagnostics: 1; DM3PR12MB0764; 3:xLeLwqglfD65jc4GiBpaYqOSzHdentkT/xEB5r0ZZ8NQJMDVpYNyV2EudpO71grcSPS1XRB2umxsEXTxKeYbZ19jsi3iT77otEh8iOtWMuT5eMQbaowkOp3g9o+fCOH2cmiT7Lh+YAUY+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DGvuoVRTH4I8QUb1PWuoSt0BxlHbaqx2yfn9elByfJtUreISX0/J/4WeSMDk17sCCObXp8kz+5t9d0fhPU877+314mlgE3RA43wQWEBqaGp+0jCoDKxOshjDeePy1IbFXBa1nZ+kNdXZeHVauTGFiXzYCTOEE9JhAJ3yFyaHdbzManittzFZtnt4a6QWE/4Qm3dsFPT8IqfJj5rrxloECw9yLcJSREfrBNn4tKzFaDT3s6OEgLFHyd+enu5dYV/JFySSF78FDXMGnVxpst60gpHeYgFtkyeHgzTggV18sYJjhWpmazvjA+YhUYnvS1l9hxJDECyKHoj0RVVbfyGfCl X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93003095)(3002001)(10201501046)(3231254)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:DM3PR12MB0764; BCL:0; PCL:0; RULEID:; SRVR:DM3PR12MB0764; X-Microsoft-Exchange-Diagnostics: 1; DM3PR12MB0764; 4:9pObodnN/DvrJ20uDZ8FqQzAmwoRen/5Vx8XtJ7pShtcpGLriUmR7/Occ/WtPe4Lycz7Uiq2howqcoGYmvHm3NNiwPAyhBQCNh7KVzu08b8ABTBJTbc1mjH6zI7GGIfsFcFsxkVzEuwdTsWmOEVSkMkgehQuOQdTLBKLhpeQiWhc4W5ky7U7K57t8l5ZzvQgINYtd28C/xaXUzWn3cR6RH7kPpUTXL6+mgR5J6Sl3BLx7Um3qlvEfSqI2fY1ClxBGiLrSyEGHb86IOF9ezxjYpZL/yEWvulCElRtGEoI1IJ1mp28Tss4W1iM+Ridpbjz X-Forefront-PRVS: 067270ECAF X-Microsoft-Exchange-Diagnostics: =?us-ascii?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8kSIHX?= =?us-ascii?Q?l88atPq1aefImOZpaREH1omrJazW7STNZZuxoBp1NGRqJEm1ghzBAs7K7aqA?= =?us-ascii?Q?g5zHuCtRaCrtmiW9I9EVskqeNw37jNqniVDbKiBrprPVweJxLO6KeZX46d5Q?= =?us-ascii?Q?dWHlK2vctNdW01kGguSg5MV44kPYx1yZe4DJmqPblwL4HKSgS8hcGmZHaIrw?= =?us-ascii?Q?27Kw8rfvoNH3NyzO6R5XjDMqP3KDALgBFjSb5ULVd3sGCj7NHOAw+rAQJRH9?= =?us-ascii?Q?iin2Lu4hwYettO9V9Q/FZcrBe/75c4n4Fba/gvguYzbODU5JF6np5/ltvZPf?= =?us-ascii?Q?Y5pY3C0RQs4AVI=3D?= X-Microsoft-Antispam-Message-Info: pYx+/aZHSZnZ9o6uScktaBVsSO1vbHedPkCPZlv90ZXwEoKAipncAEEAAf8st3K82Xm/ouc1xpQKPzWHn6H5fe40IN4CP41FEL51OxmFhYptEN3aQ3TY5n63qq3lT9KKspIR0Grt76kWq17Y2kcvJdzCAl+kwxp7cyJzKTillnvldPQcU9sDbXwhBA7ZsW0R X-Microsoft-Exchange-Diagnostics: 1; DM3PR12MB0764; 6:jiJcdCRlsiBMWYs69wee8B5cs5gGe+FEokzdhFALEK7lMnDgNOAdCmZZb+wKKBGsLgGBCpAW4rMTxpInq63Z1DHGdpeEM2YvoGIkCViHQbiDSr4d6M9quoe6YS45TwM/LFAtRQb4YRS2w4BQa5I38kKeoq/eJqVHnc4IWHq4YI9Kn73xMzeyodsC48xRIYp4v2QqLx3lJPrxYrhbMGCeklftujuz5TbjCILUet7Wj9GVRsmsG+3hLVMdlNHJy7XOENiNDYmfChTYA5O6tg4XPGmrNTEVY9UlBKBf+5m0i2ZL4U1hWzVZmONK0hkobmSYcho8m2hk3B3GjHbcEFDNFdzK+kkHZgFUBLc8DioxJNMUfYrIVsWI7xVvLeLSM+xbXu/9VqZaY+HMLEGMktLn/iD1DZOJQnIXsXyW0UCZYbztQGeOeHSv9/OAoJOCLT9rjfBG2rHcBdTkGHKFD7Nulw==; 5:KIZtBMZ/vhRruWaA844fqOTOrrJ+iKTairyvFdEP1hpr9VmvgPj9kuvVk7ihdYNv+vJ35E2hE/TqcjekPk8cj0MMiTEh9LnLef2EkihLp4lpExsxhGyoa3RpRMmfWN9VeGzxDMxJDH0ZrxJmg3hnjh0lys+ygHrx6hPbbUmuqWA=; 24:5vKa6IQ3ZvPNj3cidjg61r1adDp8OK+f7kwms0h7EDTSI+7xg3KarNL3vICsT5UvXMKvz3j6M0CSHCWwjWOVchDPkYcfcjb8HgvRw6fxlzg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM3PR12MB0764; 7:cD18/lxip0n+BbAbFaS3fXzixRoercDyRAzDQr7lgrASPIOiuLlAjqZjKQlNbu94Binhs2HjKmMynPVLmL7GMOmYALyWwm9MwmpDi90bodkdw4Arrk+TdcC/GDEHY9da88uZi4QSQyyTl/nGqXWHCpzLm35BF8ruNEz344SF+WJfIkuzCDJcwbQDfc/fHSaNTjSbtFVVRVTkdSJvdaU+34peLtd4IV/kb0M90r+4YVTf+nV0PfPuLQCf2j6Z0EsX; 20:/skdwvAtf19Rdl4VLA1WDb4ByiMU64++5naqGiJubV0v0pi6eIYiR1DhMzpXRfRtFahk1sSAGPkO8aP068qT2mlYaW0rEQI6q23aUiMQs+nDAfVLa9COaRr/Qn8OAl+J6byY02OdEhscvjK9XsLihogsGjRsQgtYwkvE4cFUvBWB2BFT7gXcWFHhgpwhzO8QtzhCkGAnjWIHwDL3mNpnUZEVyr5yDpbOhzfLjsqvZ9w1d2lBQWpEZYvhd7kYgvr9 X-MS-Office365-Filtering-Correlation-Id: 26d9b453-c634-4469-d5d8-08d5b9917e49 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2018 11:54:47.9207 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 26d9b453-c634-4469-d5d8-08d5b9917e49 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: DM3PR12MB0764 Cc: "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list , Liam Girdwood , Greg Kroah-Hartman , Philippe Ombredanne , Takashi Iwai , Daniel Kurtz , Mark Brown , Vijendar Mukunda , Alex Deucher , Akshu Agrawal , Guenter Roeck Subject: [alsa-devel] [PATCH V2] ASoC: amd: modified dma pointer callback implementation 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 Modified dma pointer callback implementation. hw ptr calculated based on System Memory to ACP SRAM dma channel transfer count in case of playback. Increased min period size for playback to 4096 to avoid underruns. In case of capture, hw ptr calculated based on dma transfer count for ACP SRAM to System Memory Dma channel. Signed-off-by: Vijendar Mukunda --- v1->v2: removed hard coded values in acp dma pointer callback declared dma varaibles in rtd structure sound/soc/amd/acp-pcm-dma.c | 66 +++++++++++++++++++-------------------------- sound/soc/amd/acp.h | 15 +++-------- 2 files changed, 31 insertions(+), 50 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index 906eb77..34a88ab 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -28,7 +28,7 @@ #define PLAYBACK_MIN_NUM_PERIODS 2 #define PLAYBACK_MAX_NUM_PERIODS 2 #define PLAYBACK_MAX_PERIOD_SIZE 16384 -#define PLAYBACK_MIN_PERIOD_SIZE 1024 +#define PLAYBACK_MIN_PERIOD_SIZE 4096 #define CAPTURE_MIN_NUM_PERIODS 2 #define CAPTURE_MAX_NUM_PERIODS 2 #define CAPTURE_MAX_PERIOD_SIZE 16384 @@ -854,10 +854,9 @@ static int acp_dma_hw_params(struct snd_pcm_substream *substream, rtd->destination = TO_BLUETOOTH; rtd->dma_dscr_idx_1 = PLAYBACK_START_DMA_DESCR_CH8; rtd->dma_dscr_idx_2 = PLAYBACK_START_DMA_DESCR_CH9; - rtd->byte_cnt_high_reg_offset = - mmACP_I2S_BT_TRANSMIT_BYTE_CNT_HIGH; - rtd->byte_cnt_low_reg_offset = - mmACP_I2S_BT_TRANSMIT_BYTE_CNT_LOW; + rtd->dma_curr_dscr = mmACP_DMA_CUR_DSCR_8; + rtd->cur_trans_cnt = mmACP_DMA_CUR_TRANS_CNT_8; + rtd->end_dma_dscr = PLAYBACK_END_DMA_DESCR_CH8; adata->play_i2sbt_stream = substream; break; case I2S_SP_INSTANCE: @@ -875,10 +874,9 @@ static int acp_dma_hw_params(struct snd_pcm_substream *substream, 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; - rtd->byte_cnt_high_reg_offset = - mmACP_I2S_TRANSMIT_BYTE_CNT_HIGH; - rtd->byte_cnt_low_reg_offset = - mmACP_I2S_TRANSMIT_BYTE_CNT_LOW; + rtd->dma_curr_dscr = mmACP_DMA_CUR_DSCR_12; + rtd->cur_trans_cnt = mmACP_DMA_CUR_TRANS_CNT_12; + rtd->end_dma_dscr = PLAYBACK_END_DMA_DESCR_CH12; adata->play_i2ssp_stream = substream; } } else { @@ -891,10 +889,10 @@ static int acp_dma_hw_params(struct snd_pcm_substream *substream, rtd->destination = FROM_BLUETOOTH; rtd->dma_dscr_idx_1 = CAPTURE_START_DMA_DESCR_CH10; rtd->dma_dscr_idx_2 = CAPTURE_START_DMA_DESCR_CH11; - rtd->byte_cnt_high_reg_offset = - mmACP_I2S_BT_RECEIVE_BYTE_CNT_HIGH; - rtd->byte_cnt_low_reg_offset = - mmACP_I2S_BT_RECEIVE_BYTE_CNT_LOW; + rtd->dma_cntl = mmACP_DMA_CNTL_10; + rtd->dma_curr_dscr = mmACP_DMA_CUR_DSCR_10; + rtd->cur_trans_cnt = mmACP_DMA_CUR_TRANS_CNT_10; + rtd->end_dma_dscr = CAPTURE_END_DMA_DESCR_CH10; adata->capture_i2sbt_stream = substream; break; case I2S_SP_INSTANCE: @@ -914,10 +912,10 @@ static int acp_dma_hw_params(struct snd_pcm_substream *substream, 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; - rtd->byte_cnt_high_reg_offset = - mmACP_I2S_RECEIVED_BYTE_CNT_HIGH; - rtd->byte_cnt_low_reg_offset = - mmACP_I2S_RECEIVED_BYTE_CNT_LOW; + rtd->dma_cntl = mmACP_DMA_CNTL_14; + rtd->dma_curr_dscr = mmACP_DMA_CUR_DSCR_14; + rtd->cur_trans_cnt = mmACP_DMA_CUR_TRANS_CNT_14; + rtd->end_dma_dscr = CAPTURE_END_DMA_DESCR_CH14; adata->capture_i2ssp_stream = substream; } } @@ -955,22 +953,13 @@ static int acp_dma_hw_free(struct snd_pcm_substream *substream) return snd_pcm_lib_free_pages(substream); } -static u64 acp_get_byte_count(struct audio_substream_data *rtd) -{ - union acp_dma_count byte_count; - - byte_count.bcount.high = acp_reg_read(rtd->acp_mmio, - rtd->byte_cnt_high_reg_offset); - byte_count.bcount.low = acp_reg_read(rtd->acp_mmio, - rtd->byte_cnt_low_reg_offset); - return byte_count.bytescount; -} - static snd_pcm_uframes_t acp_dma_pointer(struct snd_pcm_substream *substream) { u32 buffersize; u32 pos = 0; - u64 bytescount = 0; + u32 dma_count = 0; + u16 dscr; + u32 period_bytes; struct snd_pcm_runtime *runtime = substream->runtime; struct audio_substream_data *rtd = runtime->private_data; @@ -979,11 +968,15 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_pcm_substream *substream) return -EINVAL; buffersize = frames_to_bytes(runtime, runtime->buffer_size); - bytescount = acp_get_byte_count(rtd); - - if (bytescount > rtd->bytescount) - bytescount -= rtd->bytescount; - pos = do_div(bytescount, buffersize); + period_bytes = frames_to_bytes(runtime, runtime->period_size); + if ((substream->stream == SNDRV_PCM_STREAM_CAPTURE) && + acp_reg_read(rtd->acp_mmio, rtd->dma_cntl) == 0) + return 0; + dscr = acp_reg_read(rtd->acp_mmio, rtd->dma_curr_dscr); + dma_count = acp_reg_read(rtd->acp_mmio, rtd->cur_trans_cnt); + if (dscr == rtd->end_dma_dscr) + dma_count += period_bytes; + pos = dma_count % buffersize; return bytes_to_frames(runtime, pos); } @@ -1016,7 +1009,6 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) { int ret; u32 loops = 4000; - u64 bytescount = 0; struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *prtd = substream->private_data; @@ -1030,9 +1022,6 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_RESUME: - bytescount = acp_get_byte_count(rtd); - if (rtd->bytescount == 0) - rtd->bytescount = bytescount; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { acp_dma_start(rtd->acp_mmio, rtd->ch1, false); while (acp_reg_read(rtd->acp_mmio, mmACP_DMA_CH_STS) & @@ -1066,7 +1055,6 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) acp_dma_stop(rtd->acp_mmio, rtd->ch2); ret = acp_dma_stop(rtd->acp_mmio, rtd->ch1); } - rtd->bytescount = 0; break; default: ret = -EINVAL; diff --git a/sound/soc/amd/acp.h b/sound/soc/amd/acp.h index 9cd3e96..4740804 100644 --- a/sound/soc/amd/acp.h +++ b/sound/soc/amd/acp.h @@ -131,12 +131,13 @@ struct audio_substream_data { u16 destination; u16 dma_dscr_idx_1; u16 dma_dscr_idx_2; + u16 end_dma_dscr; u32 pte_offset; u32 sram_bank; - u32 byte_cnt_high_reg_offset; - u32 byte_cnt_low_reg_offset; + u32 dma_cntl; + u32 dma_curr_dscr; + u32 cur_trans_cnt; uint64_t size; - u64 bytescount; void __iomem *acp_mmio; }; @@ -157,14 +158,6 @@ struct acp_platform_info { u16 i2s_instance; }; -union acp_dma_count { - struct { - u32 low; - u32 high; - } bcount; - u64 bytescount; -}; - enum { ACP_TILE_P1 = 0, ACP_TILE_P2,