From patchwork Thu Aug 2 06:41:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akshu Agrawal X-Patchwork-Id: 10553273 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 318D513BF for ; Thu, 2 Aug 2018 06:43:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2172C2A19B for ; Thu, 2 Aug 2018 06:43:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 132BF2A2EB; Thu, 2 Aug 2018 06:43:50 +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=ham 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 4B2742A19B for ; Thu, 2 Aug 2018 06:43:49 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id DC5452677DD; Thu, 2 Aug 2018 08:43:47 +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 D336A2677E2; Thu, 2 Aug 2018 08:43:45 +0200 (CEST) Received: from NAM04-BN3-obe.outbound.protection.outlook.com (mail-eopbgr680073.outbound.protection.outlook.com [40.107.68.73]) by alsa0.perex.cz (Postfix) with ESMTP id A690A2677E2 for ; Thu, 2 Aug 2018 08:43:43 +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:X-MS-Exchange-SenderADCheck; bh=PEYwv5MisgYqj/po7Du2okKIvCQFnsKAvdHI5z46hxA=; b=vdvEjB7mk8CQxtA8jrDqOmuWqI3mxKpQRLjiTZOZAAGEJ+S4MXiBjDwGf0bmIPTjkOxw55LBv0wiN/oMhLFVfsiw8IUEWSb5yH9JExzA1YyOmMGkUKd2PGtRSQU6mZC276uJ9iiTOINuIpB4Sc4+ZD2nh+Epr3wNzF7kXMN5C8Y= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Akshu.Agrawal@amd.com; Received: from akshu-HP-EliteBook-745-G2.amd.com (125.21.194.1) by DM5PR12MB2359.namprd12.prod.outlook.com (2603:10b6:4:b4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.15; Thu, 2 Aug 2018 06:43:32 +0000 From: Akshu Agrawal To: Date: Thu, 2 Aug 2018 12:11:55 +0530 Message-Id: <1533192134-11626-2-git-send-email-akshu.agrawal@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1533192134-11626-1-git-send-email-akshu.agrawal@amd.com> References: <1533192134-11626-1-git-send-email-akshu.agrawal@amd.com> MIME-Version: 1.0 X-Originating-IP: [125.21.194.1] X-ClientProxiedBy: MA1PR01CA0086.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00::26) To DM5PR12MB2359.namprd12.prod.outlook.com (2603:10b6:4:b4::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bdb49dae-18cd-4666-b5ea-08d5f8434903 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); S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Je3whQRZsEXmk6V2m3fU0zOqt81WdAdZHliu6SQnFlCo/ye2jesF+WhwyCTp31kHXC6Pg4s/tvWARZylaV0TxqiffQYGINtI8YV+yoALns8V6q9Ugq+yseF0+qlprbWrj4djCNHxhGtobk1W/wy9C8zPmcRQcHmnpS4MjKPPnaTRtYCRT6wSFRCxL7OL0M7gkA8znnDV/BMJHFEHpPK0cnMAdDsjb+hPdYQhmXiRRNA8IZsu2IeA2BLO4qaCmNPiF7gAUZreUU1Xi0h/WG19ns4jTJQv9GG2+L8DsYBKDjp9wHjUkiEt7o06AD25cysH92IQzzgLEDSCU8DEpKpEpPW34BxndcoqA0WUgoHKBxAR21vngZCJGHlcptSCOD/mo0sNuAB3tG559aQ+TULV0Cl9o0m1GZ5LuBQOmvO; 4:50TaUZhQBn1892RpWLkHZwR3p/A8LJep6vqbo4rPT/13EN1ZSzGf4Pqrt1pdf4lNh8uT4fNFCHhyEL9YsYfFbgdLaX54Xpw2e3qLm9SZ0ueKBa0S1fDL3wIMSLXtKTLw9GHTWCUmllL58ZfjgzJp0MZ2kHcbxbRYhfwYPqa/ViepcQKM7uW8xYu+Rv9fitzYldD8nxHQVBxpvVY6dbXdDEdCt9wFKWYM0mRGcPKRb1Bw6F64fK/kpkshGjZIVinbfaTwBIE8QA0MH0zDlVLGtlObyVZyDRL8DXPgmEX2UmIWWShn1FIW2LvYFdBnQ8UX 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)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3231311)(944501410)(52105095)(3002001)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:DM5PR12MB2359; BCL:0; PCL:0; RULEID:; SRVR:DM5PR12MB2359; X-Forefront-PRVS: 07521929C1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(136003)(376002)(396003)(39860400002)(366004)(199004)(189003)(51416003)(50466002)(2906002)(6486002)(8936002)(8676002)(39060400002)(3846002)(81156014)(81166006)(109986005)(4326008)(36756003)(48376002)(44832011)(486006)(575784001)(1671002)(25786009)(86362001)(476003)(50226002)(6116002)(68736007)(66066001)(6666003)(446003)(7696005)(26005)(105586002)(106356001)(16526019)(53936002)(47776003)(54906003)(16586007)(2616005)(5660300001)(956004)(53416004)(7736002)(11346002)(478600001)(72206003)(76176011)(305945005)(52116002)(97736004)(186003)(316002)(386003)(266003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB2359; H:akshu-HP-EliteBook-745-G2.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR12MB2359; 23:8b3KtB1FfT52a3zpb8whgkZvEC76tlFF49vOaRljU?= t5HPxZfDASckp5HLkLfHfXllDiSAMWC6BvtmANXoy2/Rbj6zptmssSsydOXd7YYLiJ3f/IcUFiIVNoysfoG1riYPZTGPTbyT4nNQa54FtjC9H+QUq/zmvRp9IF1gixJLREYVDpXgHSL6kWiA9e0G9mYRaezEKDubRAmvm5eqISa+E5mlsQJsoavU/yqKiEcIpYPvcu06F8qJBCAdguvXbb2jnZtvUVnEXUId5mrD2qI7a6REkRW4SSlBgFzvEavNCZlVvIyuC2dpc1u12sYNg2yubrvXHVdp5zxai8+VkwEBJAQn0OBe0MPv3ZgeC1pi1bDDgKwUX6KyoGWJfuWnYSxp76h6HKmAisAJVRLva4f/VDXlyhJSeIvaAXFK7BhQKl2bT79dxNObc/BEsgf7vidGT0VzH8t8n/03U5PblwL0QRpasaeehEbhQAsUZPtdiGr7uNwjQre2rA9yJQhZDZiX3jd6XQl8oDVDII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agnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB2359; 20:z/evvwropjGtQFtKw+JCAC1uev76tK3HDIcawUTeL5zEyudA4Hy96hQHNmGoumxnraH/EZBSl3EixIFLOKqu+48g9lidCnP/e1iVDlBH/p/h8CAoldrKtpCBdUz7ullShykioGXh1Ofqcpuxrixz861FFBEBLXIt8g/+xaLijjZVLJIFg+d8+P460ZUE0UPGZwQTuwJZgD5r4R0hZOIr1T/4tvMe3ti3pAowcCBl/Id1RWmN+NGZUPoNmGwP1OrV X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2018 06:43:32.2164 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bdb49dae-18cd-4666-b5ea-08d5f8434903 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB2359 Cc: "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list , Greg Kroah-Hartman , Takashi Iwai , Liam Girdwood , djkurtz@chromium.org, akshu.agrawal@amd.com, Mark Brown , "Mukunda, Vijendar" , Alex Deucher , Guenter Roeck Subject: [alsa-devel] [PATCH 2/3] ASoC: AMD: Modified DMA pointer for capture 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 From: "Mukunda, Vijendar" Give position on ACP->SYSMEM DMA channel for the number of bytes that have been transferred on the current descriptor under service. Signed-off-by: Vijendar Mukunda Signed-off-by: Akshu Agrawal --- sound/soc/amd/acp-pcm-dma.c | 34 ++++++++++++++++++++++------------ sound/soc/amd/acp.h | 3 +++ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index 816abd6..6240a77 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -922,10 +922,9 @@ 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_curr_dscr = mmACP_DMA_CUR_DSCR_11; + rtd->cur_trans_cnt = mmACP_DMA_CUR_TRANS_CNT_11; + rtd->end_dma_dscr = CAPTURE_END_DMA_DESCR_CH10; adata->capture_i2sbt_stream = substream; break; case I2S_SP_INSTANCE: @@ -945,10 +944,9 @@ 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_curr_dscr = mmACP_DMA_CUR_DSCR_15; + rtd->cur_trans_cnt = mmACP_DMA_CUR_TRANS_CNT_15; + rtd->end_dma_dscr = CAPTURE_END_DMA_DESCR_CH14; adata->capture_i2ssp_stream = substream; } } @@ -1002,6 +1000,9 @@ 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; @@ -1010,10 +1011,19 @@ 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); - - bytescount -= rtd->bytescount; - pos = do_div(bytescount, buffersize); + if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { + period_bytes = frames_to_bytes(runtime, runtime->period_size); + 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; + } else { + bytescount = acp_get_byte_count(rtd); + if (bytescount > rtd->bytescount) + bytescount -= rtd->bytescount; + pos = do_div(bytescount, buffersize); + } return bytes_to_frames(runtime, pos); } diff --git a/sound/soc/amd/acp.h b/sound/soc/amd/acp.h index 0a2240b..cf7c0b9 100644 --- a/sound/soc/amd/acp.h +++ b/sound/soc/amd/acp.h @@ -134,10 +134,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_curr_dscr; + u32 cur_trans_cnt; uint64_t size; u64 bytescount; void __iomem *acp_mmio;