From patchwork Mon Aug 6 07:27:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akshu Agrawal X-Patchwork-Id: 10556583 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 F09A413AC for ; Mon, 6 Aug 2018 07:29:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3C0E29210 for ; Mon, 6 Aug 2018 07:29:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4D8229217; Mon, 6 Aug 2018 07:29:16 +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 E39BE29210 for ; Mon, 6 Aug 2018 07:29:15 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id D8A172677BC; Mon, 6 Aug 2018 09:29:14 +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 B91F7267812; Mon, 6 Aug 2018 09:29:12 +0200 (CEST) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0075.outbound.protection.outlook.com [104.47.33.75]) by alsa0.perex.cz (Postfix) with ESMTP id 59114267818 for ; Mon, 6 Aug 2018 09:29:10 +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=3ZRrrNLvOJvb0lhoN4eU2afev8R1r2Tp80pl4kbkhJY=; b=svnaNHzbmbbdAF7xDn36Ewfb99nr87AKWE3TpQaIGls/VN47mwLBB1NUQEM8cK1F363QiPGkE563472w/wQf3Ft2fKUYcdvmPUIKuB9Cja0L5Umvy0ZGgKWyQX/HA8/o8udWCk9/n/3RRGRFJHdeAq+kJC454OBytRw+Ct7a9T4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Akshu.Agrawal@amd.com; Received: from akshu-HP-EliteBook-745-G2.amd.com (202.56.249.162) by MW2PR12MB2364.namprd12.prod.outlook.com (2603:10b6:907:8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.15; Mon, 6 Aug 2018 07:29:00 +0000 From: Akshu Agrawal To: Date: Mon, 6 Aug 2018 12:57:16 +0530 Message-Id: <1533540439-18735-3-git-send-email-akshu.agrawal@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1533540439-18735-1-git-send-email-akshu.agrawal@amd.com> References: <1533540439-18735-1-git-send-email-akshu.agrawal@amd.com> MIME-Version: 1.0 X-Originating-IP: [202.56.249.162] X-ClientProxiedBy: MAXPR0101CA0041.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:d::27) To MW2PR12MB2364.namprd12.prod.outlook.com (2603:10b6:907:8::11) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ba44b046-3dd4-456c-bd52-08d5fb6e4bf8 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); SRVR:MW2PR12MB2364; X-Microsoft-Exchange-Diagnostics: 1; MW2PR12MB2364; 3:eYKi5lBPnkWqaMts8GkIukV5RSWCXAA5O07L5nin7JRCYlaugAi7i0Ynuo3V7b1tcvr89WRMtYTq34RnB9eVFh//XI5vZ/gww2+rePf3TPSCVXN3yKFGGLz8wFXiotQmmWvhXE3+PIq6dBj5vmdrMpGvM8yKUmZ6lDQcTfSjIHJ9V/Knj6hk+AnO8MYNaOwIPMIXegWG9HsRE/m8SRAN4SK48Ll5NPZdByFmX1s5sMMHnj2bz1LcPgLFyYoBq818; 25:9aihwuaTGfcC3/a6DIhwn3f7Lqql7AiEaxUfsLJ9oKl+ZxXdIGgQrdqqtMUM2IS/OWQjIaF2V5K5c3s3gsfPb1lyx8lUuVlr1qeId2rW4mbeZIPcIT0KauW6FctBs134JliYKTbI6uQresRXB7zjAUzJy+IeMhmUEt46H+VGJiDYG0KSS9Idk7fkl7eBhc+FeXqJNY80OOgdPjDXyPhoEMzXEZlU+ut8p/VyI05LcNaYARm0MbabNDkNC3Bg8SnTbyMuSK3+q+Boq73KjcEoGzeVvmJlaY/csSReNLIppxkYTcLZcs+nVBtoy7uODpjIfTwisUQwX+nLRhyoRt3fPA==; 31:CLsheNo2TEgLMPateUN8cvlJwRV/LkR1x1xZOOfqODMcTGFH8yZRrvd9bfO0N31j7dEu0ND1kFw82OE2BBmhQmbZNQlo0UUolx3o231QkOpuV35fiG4NFWGxGKGNaNjQ1SCNmchKa9vGDyvz5VfDYeroQYXbsawgRevA69wcP+SI0A5g2ckXQyFlNk7pRITqBOWanScd5ser2lkGoMFaJpLcHVeEDsE2xD5j3TfJGqs= X-MS-TrafficTypeDiagnostic: MW2PR12MB2364: X-Microsoft-Exchange-Diagnostics: 1; MW2PR12MB2364; 20:ZANdEFkc0oM117I1NoyzvyPRDT8KiVoiClS4Jar6n1rrBE9Racd0Fiu5pk2cgVIQol3Q5hU02aqtscX9ZRXR9rjAhtZ3Mlm4GKu8xAEOClkm+fcgWCAZO7nRjpPJEYxxhPtI4hb2I4IDvYMJ12f/LMNtswUmGvXU647yfqjuruBSQLuqjgc5I2rnPt/2krBeYdAcKXoHzbr10LsDt5pw7Q7RH+HXrfC5C0nLLYYk/1Mn2q5zTB/FOLSTn4eDYLF6sZogW8p/JSxRiYGo4/0D53pXIY0ac3DpdktSppo9qtSxUYqjzeTtjt3KO4msxrlLBc8zrdB7jsXLOKcCpSyt9eAxWwjxIVd1lH2ZPJxdTvlwlUNzlBTwDuFQK9ECMLIoPW1LvZoR/iQtbsNLgsy32PiW2RzJZM3Qktf6C7tjwj+QDNvKNQmxcFDrPiEKqi+hnn5ukOmgZmt5u7unzZdjh3IORIS12E1+0+jSNuBSfhaJrE6HWlZr4L7LmCEF2+te; 4:NepBpGiU2BhBaT/b9eSZmKgFnWk8tUoS9T5OfuDKH3zzkCCcS4SuhwDp5AWof+RiNpAT744GyO+wa2hFDDggdgAOiSeftNAtZWh0jEsLdCz+1NQzSJ6z85i+0upVoMIN7+eQfb3T1C5SczT8FSaLKGLsFw9elLpQe2ZkkOkQh95Srx4M/19qQ3ZASCWoMOdoa2w2dXzoW52xVH7S1j1W3NkEZ56eAu/clmi9OHsHzyQ58JkGjq1HyVKn8ny6i0Jcn1SEBhbCdp/MWLj1khgov27rOacWIW2sN08cjB+lmIbhHe7UbMYv3nHDfuTDOY+s 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)(3002001)(3231311)(944501410)(52105095)(93006095)(93001095)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:MW2PR12MB2364; BCL:0; PCL:0; RULEID:; SRVR:MW2PR12MB2364; X-Forefront-PRVS: 07562C22DA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(136003)(396003)(376002)(39860400002)(346002)(366004)(189003)(199004)(6486002)(386003)(86362001)(2906002)(486006)(476003)(186003)(16526019)(105586002)(48376002)(54906003)(1671002)(36756003)(52116002)(51416003)(305945005)(7736002)(7696005)(76176011)(47776003)(26005)(2616005)(956004)(44832011)(66066001)(478600001)(8676002)(316002)(25786009)(11346002)(4326008)(53416004)(72206003)(97736004)(16586007)(3846002)(6116002)(109986005)(8936002)(53936002)(50466002)(39060400002)(68736007)(446003)(5660300001)(14444005)(50226002)(106356001)(81166006)(6666003)(81156014)(266003); DIR:OUT; SFP:1101; SCL:1; SRVR:MW2PR12MB2364; H:akshu-HP-EliteBook-745-G2.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MW2PR12MB2364; 23:TFdfZ0woEffU8w7Goq+Nkf+pRo/LIfoY2yisVD9sN?= tiiZCMGjyUVyvvlSAM6IZVpdRwUr6qSwqesvG396h36NAcqVtkc4fcj2tlpaGKf2Hj0XzqpS8KEIBCLUQ/UutwvddSbsX6I/886m1bigyHQBVvdRoFePpMKUXmmby2gXWat3XH7x1urEbbscAkGj6Izv3I+ouNZ+dZW7CHe++4iIttI53q9gJXXqwD+fCPlSs0Uo/Yh0py4mVxq+m/xUd6oQ6cDgT0aLQJc7HQVfl6g8mruHSIO6ZyeDjsCzMF+IF/e7DyNjaa/kF+FtgQHo/VvVHt1M4iebvRSoiLYla8jtyGlsGSWuXyAKN/K1l7ur4qjzOOIwAte7cvZVjm1FM1q2I1MeaxuBkLe+dssx8J+qLJo6hwWQ+Bx2rPtw07t1ijIoDehhP+9dJIzZKmPMvJ/ip5s8Nb4lp+C83759ww3BrtdTpeeJh1y/93G58kMdCO3Ox0JgVVTaPubldiWryN5Y7tK6d3KS+NBnHnXhSJfKYESVZM7T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osticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MW2PR12MB2364; 20:wM1zjHRZqVMevbb2qdh+0tQvkKmn9B435uEgzG5EzuAg7R5xkA9rpKML0nhIgdSciaxpuFzB43H5NsjXpDJVHXl+KfVPm2Bz2pHALOKLK2kOBu983OaeWEdjWvduWgSBzMoWujsvs5kQJ/jwxkK5D4cAm+UELEZijM5UzJmBi8atJTnXKAZo8c47jKYdmD/pd8X33+i0esX8np+KqvHXbP5NMU9jG0UfUrvrgQUT1pfM4mMBxHWSndVGz9i4ETTa X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2018 07:29:00.2306 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ba44b046-3dd4-456c-bd52-08d5fb6e4bf8 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR12MB2364 Cc: "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list , Takashi Iwai , Liam Girdwood , djkurtz@chromium.org, Mark Brown , "Mukunda, Vijendar" , Alex Deucher , akshu.agrawal@amd.com, Guenter Roeck Subject: [alsa-devel] [PATCH v2 3/3] ASoC: AMD: Set delay value for the capture case 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 ACP->SYSMEM DMA happens at every I2S->SYSMEM period completion. Thus, there is delay of x frames till I2S->SYSMEM reaches a period length. This delay is communicated to user space. Signed-off-by: Akshu Agrawal --- v2: moved reading of bytes transfered from I2S->ACP to get more accurate delay information. sound/soc/amd/acp-pcm-dma.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index 32f27c5..e359938 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -922,6 +922,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_curr_dscr = mmACP_DMA_CUR_DSCR_11; adata->capture_i2sbt_stream = substream; break; @@ -942,6 +946,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_curr_dscr = mmACP_DMA_CUR_DSCR_15; adata->capture_i2ssp_stream = substream; } @@ -997,7 +1005,7 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_pcm_substream *substream) u32 pos = 0; u64 bytescount = 0; u16 dscr; - u32 period_bytes; + u32 period_bytes, delay; struct snd_pcm_runtime *runtime = substream->runtime; struct audio_substream_data *rtd = runtime->private_data; @@ -1012,6 +1020,11 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_pcm_substream *substream) pos = period_bytes; else pos = 0; + bytescount = acp_get_byte_count(rtd); + if (bytescount > rtd->bytescount) + bytescount -= rtd->bytescount; + delay = do_div(bytescount, period_bytes); + runtime->delay = bytes_to_frames(runtime, delay); } else { buffersize = frames_to_bytes(runtime, runtime->buffer_size); bytescount = acp_get_byte_count(rtd);