From patchwork Mon Aug 6 07:27:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akshu Agrawal X-Patchwork-Id: 10556581 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 84B7C13BB for ; Mon, 6 Aug 2018 07:29:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66D6329210 for ; Mon, 6 Aug 2018 07:29:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B24029217; Mon, 6 Aug 2018 07:29:04 +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 9CEBD29210 for ; Mon, 6 Aug 2018 07:29:03 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 844F7267814; Mon, 6 Aug 2018 09:29:02 +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 65EF126781F; Mon, 6 Aug 2018 09:29:00 +0200 (CEST) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0076.outbound.protection.outlook.com [104.47.33.76]) by alsa0.perex.cz (Postfix) with ESMTP id 437242677BC for ; Mon, 6 Aug 2018 09:28:58 +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=1sCxUg9BZWW+eCb2cPtyo4pLsw8oYbrfQiJ07wzKkQE=; b=irl+KeGYQhJDI7mtw7Uue9K4G7v8xWacHS4tUqXwDlZeQYrQqbfpMmPiZK81HTbF0XNoczy7vJem4iivhUTQxPkHg3UaeLVpNtIxz0geDGfBb+MeJPUI0OdYUcvmJ3JwFasANhrFU9Zwv09V7u6HVKQynrdzk25nQrFpuoZAvOo= 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:28:48 +0000 From: Akshu Agrawal To: Date: Mon, 6 Aug 2018 12:57:15 +0530 Message-Id: <1533540439-18735-2-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: e5245cf7-9396-4fcf-ee66-08d5fb6e44d7 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:QsvszDWVowSjDtK4ZIK2LKkjDKlT1FZBCGx0/hMdhhNv3C4nCnFbMeGMSDsMcG/WnqtM0/jM1K3fVBphAQhS7fMaonn2vReW+UpIMyY/pjWaN/vIPYqTI0hogjzynX0svHixW0fJ8D2dd0A6BPZzT9sO7rEsUx5lF5sOiCeFvwyhJqINCfW1NCwhBKUXr1MainIzMkni3u3h/P5Hqkk6cCcG6xFNmjTpWI+1RygmyBsX69r58RnpcJy8dfUIMtRZ; 25:BLdQKFr5rlKEWBbQPaLA3zdXR37QyNP7B9Cd7MGQSvwYaWeXD19C6QCfOHekrVbRSz8JA/RukzmhH7FP7iJz2XCwkOZ3Pj5kXXZaZjkxCadEdW/aKVEGij5w7ZxKSQplhSOC+swt3B5sIABM+HCKlJXR69WpwW9xbO9TfFyy6Xgnqjh9/KYzja30wYEw+g6Ycw6COhV3NsnNytcTfagyde13EGJ4EG876a43E+obMncI2CkTau7ZcJm8wIhzZiLLxJWd/39bCyA/t3rfScu9QDCKK/YKchYhNXvKT7iVuShd/5F3e6gB2ERECBA/FBhLXHI7M6SezWiSm4BzsGZF4w==; 31:sycoyCQOI/RXOlRIX3h7LBsOV3bT7EL5wrHbyPl182GZRPId9v3H9PTASf5UXNGDzH7urx6ncvW+O4Zutqz1dy2QsTgLDABHPOkxbnch36kJVlFpCirPilL87AhYaM2+HgWWJwaaLvK08picejJegRpP3aLn9Um9v0lxtUYwtzy52DhJzi6/Rlr6FmiD9zOGtOW/dobzmmgrctnTMY1vN/NJOgAv1l9/HM7mywlKJK0= X-MS-TrafficTypeDiagnostic: MW2PR12MB2364: X-Microsoft-Exchange-Diagnostics: 1; MW2PR12MB2364; 20:0fueSvTfe+cfVNmJRNaE6AtMYNfuerR66Xne4/ihzpx2kGELNqEnmKOvY/x7V2R3EglKvl2txRC5mYMRi0ml6BjwJZyhcPR0ARJawL9x9hS/mxJ49BzNlXCGDHbSQ9oRQ+8iHqRg612PaP0ILAvyUV9D3hp5FDXkT5urHI6YSYXDgiW4FdvHBuW5Ri1T1Qx7C5OhGIG25PTi6sFax6oisnZJTx0HlHZQOTZTPl7yB8Zt7Ok8LZyhheUO78E2r3pmCvRWozGc3QTnvzU0Enl/3gor3d9LLnM5NdXMQj6BRxLr8iUCyQuI9cUVSax76w5Ant3cqaL2Sc9TJ5e/cvnr33M+B6CD8dVD1/EDnT93EEgwK02EWFNsYk1NugZyFIXHjNTrVeDwMN1d7EuJkM6TwdD5m3Qa5CSXXJL4b0wOW4pmYJ4LY4Yd1CQsaMSizuKeMuOyfuhCA+aSVXhmVRGxCTkCAUiDxGXFRkP+7dZC8VnmsVsS6PAvkZwrxVf51MdE; 4:1qznqv0xE3vM5s9S4D3k5aEaK6gsCU+jHTAnfXqEp8kvjVj0OEq3r7+9SNItYHJh6GXmbLgxISx7vzI809N7sDqTOSepktveQwDg2gVNNsHHLU+jB2+1ubd0INVRTrZumDokgwE5ytxym//jw59LjK6JMe6iexb2ckO+xo6SW7sajmGHQGA2aoji4i1ul5ElJWd5zbTQ8+iOQre5Mso8dhuzBtEzXc0SpxOJ2IBKYGzHUpWzIJaeAnp2J/GySnXXDgslsGps/Zcro1MSuKkMIk64WVBPgi3Tyi/5uydYUYTIylF0dOwcmSz+xC81Wrx/ 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)(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:XR1W7oye+dbklkFsGiUqaK6vDcEAIOo1Jyf09TeCm?= WamYjTWNrNTG3Vs6fUmIf+MUTuADSckcl67Y9fygEU3zqFmly3cKcJTx1xGBUrt0tqxIYTlSHQcwZLol31a9D7KtV4cKCj7uiZZF288qJzS1IDMs9D1JopqkkWynlFiq8Io7jO1dAuTNYwHLsSp35PWQrAKh3BUn16Ai6B6CJY6YGMHXzjlfHTVttKw/P8VUZQrtp9V4KgL87pMEBRSY1iVVeos8RYcCTGNixp9Y2KMg7eNrg8rpRzZdar9D1FtTZUXRPVenwEw4Wk5tTR67IDfhtBEEsd7WMB4Mi/h6rJpJuzdhfF8uIAj/wp/J7X+m+48l0BPcylRPfAX65D0g7pNXV+w2s2Os/dzy/3lzAw92Se6d+Y9fyRCxHhq/CL7i7cq4A8M3P0MsjVvfwbZQtGDhIo71ijosM8vKgKtHt4LUxFoiNSDMDALlHLRx3j71JaFcKcEsdFFUbSmA6FH3MlBRJ4QqH871rjy4Xzkc0sgjPdKMlIL8+XexXEE4dI3h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12MB2364; 20:f37Y4pnGiUL6ziCglBIESxNe83hQTuRvIUTj4U96wF2KjKWGShQFjapo2U6BBqpeKneo+yu1CX+QataNkSDw20XKmESv011jduD5bUA8rq8RpjPq14IELO9t9ISNFlHth/m8ME/LKTduVSnI/RIoiErIlJmx6aIZOGYf8XEfHplqYbvwIt1JFvjbYXDo8+VUcxefk9oYsERbwMjzHQeiLV2JFsqGyzhesH4T3XzNpRQmbMshakEw1uwaXc3kqn/B X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2018 07:28:48.1144 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e5245cf7-9396-4fcf-ee66-08d5fb6e44d7 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 , 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 v2 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 basis of current descriptor under service. Signed-off-by: Vijendar Mukunda Signed-off-by: Akshu Agrawal --- v2: Fixed position, now position = 0 if on 1st descriptor and pos = period_bytes if on second descriptor. sound/soc/amd/acp-pcm-dma.c | 31 ++++++++++++++++++------------- sound/soc/amd/acp.h | 1 + 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index 816abd6..32f27c5 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -922,10 +922,7 @@ 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; case I2S_SP_INSTANCE: @@ -945,10 +942,7 @@ 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; } } @@ -1002,6 +996,8 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_pcm_substream *substream) u32 buffersize; u32 pos = 0; u64 bytescount = 0; + u16 dscr; + u32 period_bytes; struct snd_pcm_runtime *runtime = substream->runtime; struct audio_substream_data *rtd = runtime->private_data; @@ -1009,11 +1005,20 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_pcm_substream *substream) if (!rtd) 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); + if (dscr == rtd->dma_dscr_idx_1) + pos = period_bytes; + else + pos = 0; + } else { + 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); + } return bytes_to_frames(runtime, pos); } diff --git a/sound/soc/amd/acp.h b/sound/soc/amd/acp.h index 0a2240b..be3963e 100644 --- a/sound/soc/amd/acp.h +++ b/sound/soc/amd/acp.h @@ -138,6 +138,7 @@ struct audio_substream_data { u32 sram_bank; u32 byte_cnt_high_reg_offset; u32 byte_cnt_low_reg_offset; + u32 dma_curr_dscr; uint64_t size; u64 bytescount; void __iomem *acp_mmio;