From patchwork Tue May 8 04:47:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Mukunda,Vijendar" X-Patchwork-Id: 10385345 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 983EC6053E for ; Tue, 8 May 2018 04:44:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 880E028CBF for ; Tue, 8 May 2018 04:44:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B9DD28CC2; Tue, 8 May 2018 04:44:58 +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 2263528CBF for ; Tue, 8 May 2018 04:44:56 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id B5BEA267663; Tue, 8 May 2018 06:44:54 +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 C76F8267672; Tue, 8 May 2018 06:44:51 +0200 (CEST) Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0041.outbound.protection.outlook.com [104.47.41.41]) by alsa0.perex.cz (Postfix) with ESMTP id 6EED9267646 for ; Tue, 8 May 2018 06:44:46 +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=keT/9DcIaRDIRVnHO/3x9ViqX2U/wsMse1daMxOlyH0=; b=x7eI8JA7yOdVHpyD8d83az8gV/N5SE4p+V8Eqc8Rz1OS6ipzrnQOt4lNEYk/F/fahY3hBVlHqlndAEDp39defBMfKwfMDOkgZl7WKRcHP7M4LTZ163DDACNrnUO7jGzgdWq5/TmEQ13iwB/ZUIoFySRWuILpbIC2WWHgCDlRKlg= Received: from BN6PR1201CA0020.namprd12.prod.outlook.com (2603:10b6:405:4c::30) by BY2PR12MB0322.namprd12.prod.outlook.com (2a01:111:e400:585c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.735.16; Tue, 8 May 2018 04:44:43 +0000 Received: from DM3NAM03FT038.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::207) by BN6PR1201CA0020.outlook.office365.com (2603:10b6:405:4c::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.735.17 via Frontend Transport; Tue, 8 May 2018 04:44:42 +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 DM3NAM03FT038.mail.protection.outlook.com (10.152.83.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.735.16 via Frontend Transport; Tue, 8 May 2018 04:44:41 +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, 7 May 2018 23:44:40 -0500 From: Vijendar Mukunda To: Date: Tue, 8 May 2018 10:17:44 +0530 Message-ID: <1525754888-14124-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)(39860400002)(396003)(39380400002)(376002)(346002)(2980300002)(428003)(199004)(189003)(50226002)(305945005)(72206003)(478600001)(47776003)(68736007)(2906002)(186003)(104016004)(5660300001)(8936002)(97736004)(1671002)(2616005)(109986005)(77096007)(316002)(356003)(26005)(53416004)(16586007)(476003)(336012)(105586002)(39060400002)(36756003)(59450400001)(81156014)(126002)(81166006)(106466001)(51416003)(48376002)(426003)(4326008)(486006)(50466002)(54906003)(7696005)(53936002)(86362001)(8676002)(266003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0322; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT038; 1:c3nsSVyT6IsS/2N56KDVStSUrutgq7qXzzHdWSO3NIxX78Tm4hfx0dbVDrg5zb2DGxHx+jEOasti14kfJcH7OnxYw9ZpyKRcNWBYuvxIyEXm0wy16dQPS7DmWXK/gapC X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060); SRVR:BY2PR12MB0322; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0322; 3:J7fkSygbbqM+k4HtCH5lMwh9FPCbutNJAQajCAdJKOqXt7nCzNMWfaXWdbqGm+oFMI2dBe0VRZnpQj18z8J0CuhCUi8W15cmpGmKp0t0CNUz2hHpithJkhkbTxM0xxzCI5hNtOdPE6Z1vT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4mOnLKjTgWwyDfXt4jySg39tUoDsNkyA2w0rcuETDBNhhOJSq1MlvJY5opcT51ltNer3Nyi50u+ORE5BADHUJHXs11nll1Gy8alGBmYqhZRixo93irCok5UHqvjgOvw+TdJjTvC1k65fdgEZsKdimzJu/LTEuFpt11+hn95Cb/zQBVsiQGC84TOfCIqW48qOZqeOthmgII1ZmW1iR7ZGV0iR18W0Xy2C9RhSCT2B2672DvAtns6h3fwHbt98V6DM7qpLBv/qLcK6UppyNP3NsjXCOmnRu5CBDZwxKVsRrEXHOOLdeG3oB 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)(3002001)(93006095)(93003095)(3231254)(944501410)(52105095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(6072148)(201708071742011); SRVR:BY2PR12MB0322; BCL:0; PCL:0; RULEID:; SRVR:BY2PR12MB0322; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0322; 4:6hySKW+XZTz43s9HBql94XEeE7gJODu+1yDtjkpA/v0h9H1jbgqXenH7adGa64kGBfHkuxB57dWyZRoih6/Zqc0iJkbWvFKVFu+f+jO4ezWP/i+JUSs3yQl9F3ygts6nflUv8iFaEhwPzwRouVDazNae01IA4xh3fFftluHZmjp23aaOf6LFhZhkpEgYAHu6+Sm73GbHCXLJOuewWksnBKrDN+Jk3ImMBK0uZGQCPVKL1h82Cit9w5PPzqWf+d8vOJGt+DZjly6kSEXAlsUYzrEYnQ9Hg6La4mtYu1EaAltzePKLb7hcDFYVppVAhNhz X-Forefront-PRVS: 0666E15D35 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR12MB0322; 23:TYnIn69ZVaip6UFSpd/M7B0l6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akSCMr4ZDBF/AUIw==; 5:Xkv9Cg9IGT6QqVEMtdSaUMRHkftz5nbC1XiAaNHLNPkB0kHmckrmBGjZmpknPrRxx6g969XIWxk+pvVxQssDqYX76LIoWPXJbJB1xqAcNxoNj6IPVUFuUksT084W7OH1Jsh09YoyillOHhE+18CeQvqDGZZtQjybrfSmB47SEHs=; 24:fzIOidmsDPpMIfjAu2aarC+L/AQ0Bua16D4gThq0oas0DiXbEv2Ni0Du7XemF5V1yvGjsr5Cemdp6JQwr/2ZslMbejFzyedjnQly9Q1zBRk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0322; 7:kcSH3o9YkloEV12fCob0DCfXYK7lbP+NISSgBJ3mFgE5+L+1xNK1GkofWp1JsN6LOWh344/umvFf9Wq8y0jVNj4wYdSHyUhJ19urPhFxx/Cqe0g+EQkcLNjpFboMFcqOPZDpO94M0R3JjFg4odvh+pa/KqmMMX6D+tUJGMUdASkG5YKPH81lFHz8+fF6dATDtH/cZpoK2iQgxEKCsw/8Fshby1WVIRjfAXz2vVg3OvBc96pUmmIrpdKarKiD4R6S; 20:gOO7htMH4yYT49m8M0bKhnBPYsDiIyYZAERW6ZAYACLBSKnLcvxH/Mcbpbk6dpgiEO6FwNGm/L14SQNXuoebImvOZCyJe3CvFM2+XgcolGtgHqKKDTWrEFdxS5TeYb26zyTrZk44UY9VNA7C/ZMmO5gEBqxa9M+trg6CowKA6gAajBJGVfosG6Ix1eEbV1O7ZKK0GAr/RSvN/OQIZASnrzyQnU+T2akrCEgnhbn4WoFnieUzfh6jiTch6z2TemHy X-MS-Office365-Filtering-Correlation-Id: e974bcc7-8603-4622-5b8d-08d5b49e6a4d X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2018 04:44:41.9392 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e974bcc7-8603-4622-5b8d-08d5b49e6a4d 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: BY2PR12MB0322 Cc: "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list , Liam Girdwood , Greg Kroah-Hartman , Takashi Iwai , Daniel Kurtz , 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 Reviewed-by: Daniel Kurtz --- 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;