From patchwork Mon Mar 12 06:34:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Mukunda,Vijendar" X-Patchwork-Id: 10275503 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 3142B6038F for ; Mon, 12 Mar 2018 06:33:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F19A28AC1 for ; Mon, 12 Mar 2018 06:33:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 141F728AC7; Mon, 12 Mar 2018 06:33:47 +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=-1.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no 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 9205A28AC1 for ; Mon, 12 Mar 2018 06:33:45 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id C61072676A2; Mon, 12 Mar 2018 07:33:42 +0100 (CET) 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 5A97A267684; Mon, 12 Mar 2018 07:33:40 +0100 (CET) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0061.outbound.protection.outlook.com [104.47.33.61]) by alsa0.perex.cz (Postfix) with ESMTP id C82872673CE for ; Mon, 12 Mar 2018 07:33:37 +0100 (CET) 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=y/uxfXIdvsbgQJf6Fkl8HDux7JGtcNQJmdjZNdTPlzY=; b=teipU0R26ZosDVzahh5seK5hZspoBR6trEXueO4q6BHTRWucO7qfPO0vG+AufOcfPknP3APycaZ6vKIgr0Ah65LWnx9o6Nr4GZfpxpn4vcB9h/l2b5DZfMMU25uXc/ZWDsDgrLBaktIX7jHbaxeYnlq5JkAvfegMlgDBIf2OpNE= Received: from DM5PR12CA0016.namprd12.prod.outlook.com (10.172.32.154) by BY2PR12MB0021.namprd12.prod.outlook.com (10.160.66.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.567.14; Mon, 12 Mar 2018 06:33:33 +0000 Received: from CO1NAM03FT037.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::208) by DM5PR12CA0016.outlook.office365.com (2603:10b6:4:1::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.567.14 via Frontend Transport; Mon, 12 Mar 2018 06:33:33 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; gmail.com; dkim=none (message not signed) header.d=none; gmail.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 CO1NAM03FT037.mail.protection.outlook.com (10.152.80.241) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.527.18 via Frontend Transport; Mon, 12 Mar 2018 06:33:32 +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, 12 Mar 2018 01:33:31 -0500 From: Vijendar Mukunda To: , , Date: Mon, 12 Mar 2018 12:04:18 +0530 Message-ID: <1520836460-21809-6-git-send-email-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520836460-21809-1-git-send-email-Vijendar.Mukunda@amd.com> References: <1520836460-21809-1-git-send-email-Vijendar.Mukunda@amd.com> 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)(346002)(39380400002)(39860400002)(376002)(396003)(2980300002)(428003)(199004)(189003)(54906003)(2201001)(2906002)(53416004)(2950100002)(110136005)(50226002)(6666003)(72206003)(478600001)(5660300001)(316002)(81156014)(8936002)(81166006)(305945005)(106466001)(8676002)(105586002)(86362001)(59450400001)(50466002)(48376002)(36756003)(68736007)(76176011)(53936002)(26005)(39060400002)(77096007)(356003)(97736004)(186003)(4326008)(336012)(104016004)(7696005)(16586007)(47776003)(51416003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0021; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT037; 1:DhyeS7BaYbumKTdbhAN97zohXWJ9+kj8UctCcRS141SsotgtazzMuJ6GT7jFfdydFDiqzz+2wYvHSp5EJwFo8Ac2lF7TWz1eCHShmAxVvsdhv8eygvlVW9Qp48WSt0kM X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8bd9bec2-2c76-48c1-5d9f-08d587e32d3d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060); SRVR:BY2PR12MB0021; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0021; 3:cV6SpgEevHMg7Q3nsqKFRaRag0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KUK33uFnuSREPdAqm2CSkTJHqmL5/1/+0Za/OwcRK+6+1MJB4uGuCSDT4fV0cOcnp85PEdDijQnx9gthF3g81kXXRVrRVfDNVJuH3HJddC92TEk1rzVIirf2+WPU2y3LJ/WWg1w9sv6ybBVEQK6NNiKehIHxEf8b0nGVVzU8ffgHqJwb0h7plvHpQZpT0qmn5Mt1dRS9jq3ADX/lMET2K82Y+b15Bhj4KwODnAgf8hOMxiWVKi4VWT1PWLwxGQgPIek+TTe/WsSQePCiuRyBmQfojT9v2/9BBCvpL7igPRFZMq2DLMv40GkQk+UoU/IgLM0wRE/Z9vT79aw+NbhWYY9z14mCUH06azCdsw3ODlPaWy70rkY6vKqtgTM3jvs8BIXOxrtI6C1UOdX163N2s/e92uegH58g5qXtlZOfl5Nmw0VNOxEOUsNAvMRw X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(93006095)(93003095)(10201501046)(3231220)(944501244)(52105095)(6055026)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(6072148)(201708071742011); SRVR:BY2PR12MB0021; BCL:0; PCL:0; RULEID:; SRVR:BY2PR12MB0021; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0021; 4:b1Ad8hsTv6swoNfoJUbdAyDl0BQk5ckYSg9FNpgW1guYx7oaBVZR/VRtBGPpOMzf+3r9ypb1gLj9H3DJLkVy6oN+EYgoJ2dm+gNu9WGRtAxuknFs/q/VQV36N9WhCZdmD9oSjNufLCcwGS1aFs+TVbT6DeFC9oa+Vbj70atxLmtkSIKtBU7IKHlJ3TIgvA74badi1VGuhviA1GWQL33WMb4px3HVcch6G10Cvaxdv9GL1maB1im4hDtfRHD/Zd7BpZ/aBj3AfPtaY0fXXpotDkwldwjRpoPQrtK5D9qRcsMLIpRSZlPUsiAj/U//LJ65 X-Forefront-PRVS: 06098A2863 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR12MB0021; 23:Rx2nU2LRWuH3Y3gOhBmJYkZSDufGbxd+8IeUb+PZs?= =?us-ascii?Q?igbtaa0gYOBvIHV61oF64vYbLKK8D/HIZldSUi2xpDU42gHsIhC5xMuRF8/o?= =?us-ascii?Q?SHoUzWfrlgIRhHSqlUCwRzCuXLVW+m6Nw7mw+yKM0g7Mcvv381ru/YbY7ZjL?= =?us-ascii?Q?zbiyZdG69F9VIPWDDGcphlm122udNjkgufmgaKWP9yCFbKKUeqYc12heN9AW?= =?us-ascii?Q?OPO9gOIFwb1MOGYU7NGOXIopuqk5F13775Aq7Q1nSQ3Ge58BuG6ZCo4bHAPC?= =?us-ascii?Q?Fg+xCQpphiy5kODa7y9txTFovdosYUMPgOBuDaAxhLAXRhe83Qa0nISKEkdG?= =?us-ascii?Q?lb+154zRPAAZLixLA/ND6Za4r0x7hEzThMXxiMyoGFydf0PTQazoRC5+GZUY?= =?us-ascii?Q?EZuRpkBqdYfrChO6RvFCtX56snrfjs1UvJLNatV6RZaK8fSJJgNoPdNN8KuB?= =?us-ascii?Q?GH2A9VvvWyWVht0HySo8S7CPh0btei1geElt6sa/JI30WtcFB9L6PGLEKFL+?= =?us-ascii?Q?h/MAiJd0YgWhCyB5BsgJIshR212dZNMFZHz4ps5UeS2B6CpDMx1ZjUUF4Vza?= =?us-ascii?Q?5t8a0a7LUaLrUM46xG+cA70ZSqju3gcy5OvPRLF6IT2hwk9cKuTcCXVojxEC?= =?us-ascii?Q?v2k46piATauJ3uC70lZ4EbegD5onHitl1Iz2EoJZk2+lgIZTaneu2pE6BbvZ?= =?us-ascii?Q?Z84DI/8TO8tA6cn4npN2m2JElhWtRO2zInbsPmrHM7sX043Va7IOYC6i+86Q?= =?us-ascii?Q?1YTbkuGFGB/EVPIhkjcydUCo0tuG+Aa4NIp1yNFtWNFWQ4gDh2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2X4mKV8EBKzHZgtNHoBIRZqx9QkNz8AczCdu+VNu9tVGpDA2sEoSo0uK/vuLLS5oarZNrTeI511UmzfaHIOUQP9zZBL+7VjSWWsvUFTVMYPiJY4DMFXyFZ+np2/QJ7PFeMPX2g1EE6cJ9UZwonZDnWNRPR4g=; 24:CbpV+0nwQsACp1gzydZexLluKEJyg7vAbGnHKauNJ5GgnQ8h1w3tcHsO7mORxJZPXAVZg2G1stDXPHlE8sFdebQ8KQ/POSuA+wP4/hvdrWo=; 7:dPW/Yax9EUZLKZb69sZgQ2n9E4pT+2hEAHpNvE7/VJi9ZKkLtv5XYhZAH2ZJTUf6WZRrQyI7WmFzKA8tSMEu3f54pKjx7XhSjktJx9etYJSNkOQs4+cJwUHGN200zR9RVpFB4Dq/jzuozCmCoTvzZECbYYOy4PnH0N2SUdQYkgYqYb4qaBlCaoUcWdIWPGArboDEoWmGV03B7l1GZfRc3p81bFUGac4EY5N3x83l8ZQS4OkkghM9X+AOxy7/s/mr SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0021; 20:U82gkFLFk+uOmYUt64tGIF0bGRackt1L19Qi8WDlqsfVdETJYB0b/6R8sTS9sW7pdIsUrngxeLlV3wZiKRG7HXAscPwr1PaqKXUpnjuglCuSAUY2pHg5NTKlFPE/yGgxIHKDt/ImisShdMotQDERynQPx35qhud7LozcE2R9hLdu3bp9YRCp8Q1SVWZNtxcRmPIzZyqQ9x0Sd1xXxgqMQmtZHOUyUwBLq6CiSe9jF+bK1XDt3F4vfKtLgY0mIL9J X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2018 06:33:32.5209 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8bd9bec2-2c76-48c1-5d9f-08d587e32d3d 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: BY2PR12MB0021 Cc: tiwai@suse.de, Alexander.Deucher@amd.com, lgirdwood@gmail.com, Vijendar Mukunda Subject: [alsa-devel] [PATCH 5/7] ASoC: amd: pointer and trigger callback modifications for bt i2s 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 trigger and pointer callbacks for bt i2s instance. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/acp-pcm-dma.c | 186 ++++++++++++++++++++++++++++++++------------ 1 file changed, 137 insertions(+), 49 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index 2b6c9ad..ad46719 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -958,23 +958,43 @@ static int acp_dma_hw_free(struct snd_pcm_substream *substream) return snd_pcm_lib_free_pages(substream); } -static u64 acp_get_byte_count(void __iomem *acp_mmio, int stream) +static u64 acp_get_byte_count(void __iomem *acp_mmio, u16 instance, int stream) { union acp_dma_count playback_dma_count; union acp_dma_count capture_dma_count; u64 bytescount = 0; if (stream == SNDRV_PCM_STREAM_PLAYBACK) { - playback_dma_count.bcount.high = acp_reg_read(acp_mmio, - mmACP_I2S_TRANSMIT_BYTE_CNT_HIGH); - playback_dma_count.bcount.low = acp_reg_read(acp_mmio, - mmACP_I2S_TRANSMIT_BYTE_CNT_LOW); + switch (instance) { + case I2S_BT_INSTANCE: + playback_dma_count.bcount.high = acp_reg_read(acp_mmio, + mmACP_I2S_BT_TRANSMIT_BYTE_CNT_HIGH); + playback_dma_count.bcount.low = acp_reg_read(acp_mmio, + mmACP_I2S_BT_TRANSMIT_BYTE_CNT_LOW); + break; + case I2S_SP_INSTANCE: + default: + playback_dma_count.bcount.high = acp_reg_read(acp_mmio, + mmACP_I2S_TRANSMIT_BYTE_CNT_HIGH); + playback_dma_count.bcount.low = acp_reg_read(acp_mmio, + mmACP_I2S_TRANSMIT_BYTE_CNT_LOW); + } bytescount = playback_dma_count.bytescount; } else { - capture_dma_count.bcount.high = acp_reg_read(acp_mmio, - mmACP_I2S_RECEIVED_BYTE_CNT_HIGH); - capture_dma_count.bcount.low = acp_reg_read(acp_mmio, - mmACP_I2S_RECEIVED_BYTE_CNT_LOW); + switch (instance) { + case I2S_BT_INSTANCE: + capture_dma_count.bcount.high = acp_reg_read(acp_mmio, + mmACP_I2S_BT_RECEIVE_BYTE_CNT_HIGH); + capture_dma_count.bcount.low = acp_reg_read(acp_mmio, + mmACP_I2S_BT_RECEIVE_BYTE_CNT_LOW); + break; + case I2S_SP_INSTANCE: + default: + capture_dma_count.bcount.high = acp_reg_read(acp_mmio, + mmACP_I2S_RECEIVED_BYTE_CNT_HIGH); + capture_dma_count.bcount.low = acp_reg_read(acp_mmio, + mmACP_I2S_RECEIVED_BYTE_CNT_LOW); + } bytescount = capture_dma_count.bytescount; } return bytescount; @@ -993,14 +1013,32 @@ 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->acp_mmio, substream->stream); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - if (bytescount > rtd->i2ssp_renderbytescount) - bytescount = bytescount - rtd->i2ssp_renderbytescount; + bytescount = acp_get_byte_count(rtd->acp_mmio, + rtd->i2s_play_instance, substream->stream); + switch (rtd->i2s_play_instance) { + case I2S_BT_INSTANCE: + if (bytescount > rtd->i2sbt_renderbytescount) + bytescount = bytescount - rtd->i2sbt_renderbytescount; + break; + case I2S_SP_INSTANCE: + default: + if (bytescount > rtd->i2ssp_renderbytescount) + bytescount = bytescount - rtd->i2ssp_renderbytescount; + } } else { - if (bytescount > rtd->i2ssp_capturebytescount) - bytescount = bytescount - rtd->i2ssp_capturebytescount; + bytescount = acp_get_byte_count(rtd->acp_mmio, + rtd->i2s_capture_instance, substream->stream); + switch (rtd->i2s_capture_instance) { + case I2S_BT_INSTANCE: + if (bytescount > rtd->i2sbt_capturebytescount) + bytescount = bytescount - rtd->i2sbt_capturebytescount; + break; + case I2S_SP_INSTANCE: + default: + if (bytescount > rtd->i2ssp_capturebytescount) + bytescount = bytescount - rtd->i2ssp_capturebytescount; + } } pos = do_div(bytescount, buffersize); return bytes_to_frames(runtime, pos); @@ -1083,54 +1121,104 @@ 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->acp_mmio, - substream->stream); 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); - while (acp_reg_read(rtd->acp_mmio, mmACP_DMA_CH_STS) & - BIT(SYSRAM_TO_ACP_CH_NUM)) { - if (!loops--) { - dev_err(component->dev, - "acp dma start timeout\n"); - return -ETIMEDOUT; + bytescount = acp_get_byte_count(rtd->acp_mmio, + rtd->i2s_play_instance, + substream->stream); + switch (rtd->i2s_play_instance) { + case I2S_BT_INSTANCE: + if (rtd->i2sbt_renderbytescount == 0) + rtd->i2sbt_renderbytescount = bytescount; + acp_dma_start(rtd->acp_mmio, + SYSRAM_TO_ACP_BT_INSTANCE_CH_NUM, false); + while (acp_reg_read(rtd->acp_mmio, mmACP_DMA_CH_STS) & + BIT(SYSRAM_TO_ACP_BT_INSTANCE_CH_NUM)) { + if (!loops--) { + dev_err(component->dev, + "acp dma start timeout\n"); + return -ETIMEDOUT; + } + cpu_relax(); } - cpu_relax(); - } - - acp_dma_start(rtd->acp_mmio, + acp_dma_start(rtd->acp_mmio, + ACP_TO_I2S_DMA_BT_INSTANCE_CH_NUM, true); + break; + case I2S_SP_INSTANCE: + default: + if (rtd->i2ssp_renderbytescount == 0) + rtd->i2ssp_renderbytescount = bytescount; + acp_dma_start(rtd->acp_mmio, + SYSRAM_TO_ACP_CH_NUM, false); + while (acp_reg_read(rtd->acp_mmio, mmACP_DMA_CH_STS) & + BIT(SYSRAM_TO_ACP_CH_NUM)) { + if (!loops--) { + dev_err(component->dev, + "acp dma start timeout\n"); + return -ETIMEDOUT; + } + 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); + bytescount = acp_get_byte_count(rtd->acp_mmio, + rtd->i2s_capture_instance, + substream->stream); + switch (rtd->i2s_capture_instance) { + case I2S_BT_INSTANCE: + if (rtd->i2sbt_capturebytescount == 0) + rtd->i2sbt_capturebytescount = 0; + acp_dma_start(rtd->acp_mmio, + I2S_TO_ACP_DMA_BT_INSTANCE_CH_NUM, true); + break; + case I2S_SP_INSTANCE: + default: + if (rtd->i2ssp_capturebytescount == 0) + rtd->i2ssp_capturebytescount = bytescount; + acp_dma_start(rtd->acp_mmio, + I2S_TO_ACP_DMA_CH_NUM, 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 - */ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - ret = acp_dma_stop(rtd->acp_mmio, + switch (rtd->i2s_play_instance) { + case I2S_BT_INSTANCE: + ret = acp_dma_stop(rtd->acp_mmio, + SYSRAM_TO_ACP_BT_INSTANCE_CH_NUM); + ret = acp_dma_stop(rtd->acp_mmio, + ACP_TO_I2S_DMA_BT_INSTANCE_CH_NUM); + rtd->i2sbt_renderbytescount = 0; + break; + case I2S_SP_INSTANCE: + default: + 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); - rtd->i2ssp_renderbytescount = 0; + ret = acp_dma_stop(rtd->acp_mmio, + ACP_TO_I2S_DMA_CH_NUM); + 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, + switch (rtd->i2s_capture_instance) { + case I2S_BT_INSTANCE: + ret = acp_dma_stop(rtd->acp_mmio, + I2S_TO_ACP_DMA_BT_INSTANCE_CH_NUM); + ret = acp_dma_stop(rtd->acp_mmio, + ACP_TO_SYSRAM_BT_INSTANCE_CH_NUM); + rtd->i2sbt_capturebytescount = 0; + break; + case I2S_SP_INSTANCE: + default: + 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); - rtd->i2ssp_capturebytescount = 0; + rtd->i2ssp_capturebytescount = 0; + } } break; default: