From patchwork Fri Feb 16 07:33:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Mukunda,Vijendar" X-Patchwork-Id: 10224125 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 CB73A603EE for ; Fri, 16 Feb 2018 07:33:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC19629095 for ; Fri, 16 Feb 2018 07:33:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0719290B3; Fri, 16 Feb 2018 07:33:29 +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 7EFA029095 for ; Fri, 16 Feb 2018 07:33:28 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id EC7E4267DA2; Fri, 16 Feb 2018 08:32:32 +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 CFCFB267DA2; Fri, 16 Feb 2018 08:32:31 +0100 (CET) Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0074.outbound.protection.outlook.com [104.47.42.74]) by alsa0.perex.cz (Postfix) with ESMTP id 97208267D81 for ; Fri, 16 Feb 2018 08:32:28 +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=wuj+sWReHmJWOhtOHBigBMKz53zOhAB4gEO1LqLGDvw=; b=IrlMTJYkS/6TEMXlL4JMFAVlue1voRnUuE/PMxkXOxvZhS6m3wywf0yiaxBVz8mc7VUGjg7BiyOnQW0ylImhKrEImZDrm/MMBabDicZvOaUMXdav1DP1LxWeRKAv08OzjdTV69yair1hek02w6/PLHTSCwzffkORo9ECj/iBWc0= Received: from CY1PR1201CA0023.namprd12.prod.outlook.com (2a01:111:e400:5b9a::33) by DM2PR12MB0267.namprd12.prod.outlook.com (2a01:111:e400:50d1::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.485.10; Fri, 16 Feb 2018 07:32:23 +0000 Received: from BY2NAM03FT040.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::208) by CY1PR1201CA0023.outlook.office365.com (2a01:111:e400:5b9a::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.506.18 via Frontend Transport; Fri, 16 Feb 2018 07:32:23 +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 BY2NAM03FT040.mail.protection.outlook.com (10.152.85.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.506.19 via Frontend Transport; Fri, 16 Feb 2018 07:32:22 +0000 Received: from SATLEXDAG04.amd.com (10.181.40.9) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server (TLS) id 14.3.382.0; Fri, 16 Feb 2018 01:32:22 -0600 Received: from SCYBEXDAG03.amd.com (10.34.11.13) by satlexdag04.amd.com (10.181.40.9) with Microsoft SMTP Server (TLS) id 14.3.382.0; Fri, 16 Feb 2018 02:32:21 -0500 Received: from LinuxHost.amd.com (10.129.12.246) by SCYBEXDAG03.amd.com (10.34.11.13) with Microsoft SMTP Server id 14.3.382.0; Fri, 16 Feb 2018 15:32:17 +0800 From: Vijendar Mukunda To: , , Date: Fri, 16 Feb 2018 13:03:51 +0530 Message-ID: <1518766434-7911-7-git-send-email-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518766434-7911-1-git-send-email-Vijendar.Mukunda@amd.com> References: <1518766434-7911-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)(376002)(39380400002)(346002)(396003)(39860400002)(2980300002)(428003)(199004)(189003)(316002)(16586007)(8936002)(8676002)(81156014)(50226002)(106466001)(81166006)(53416004)(4326008)(39060400002)(54906003)(86362001)(2201001)(110136005)(48376002)(2906002)(305945005)(72206003)(36756003)(356003)(97736004)(50466002)(5660300001)(53936002)(76176011)(478600001)(26005)(186003)(77096007)(336011)(51416003)(105586002)(59450400001)(7696005)(68736007)(6666003)(47776003)(2950100002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0267; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2NAM03FT040; 1:OHqdqtZM9p5qo2AWEl1r5BzGukDkJ3yui/wRf2LzzYIyrhGU+SSebUcDpyhAjI4awXqAFzt42zI4W67x6Uz0tK5zguyXo9ri9agaLr3tvI/ZZcY45HmJxEoe2OSF2rOr X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ccc67ab8-8892-4172-f1b9-08d5750f6b60 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:DM2PR12MB0267; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0267; 3:OdpdfZ0rYxd3hZ/KeRBIHcge372ozkYEvoU3bI3tmbm4/VvHEQjLMCcASZ6d5OWmkw/r1EpZi+b3gHF2sL7ksKUJIue2ML7YXshQTq/QUkk7Vs3ccWOcNpfBukxkmJL7vcyAUS5sAeaLLpAyN/fAgP9pAMI40u6WIdW8bCW/+i9op3bDgVERgpAbuGjHTxzPqWz8mB7x/Fb1SIOFMu2bRoG13wG7dqxmEHaYNG5UovuwCYFaklPVIdiqvGQrOkIkc+Czknkq94UT8a1bXJrIDRyIhFsB/yhjRvZrfbhcv/EE8oBvuOtgo0RK+MnYDysktb4qtNQGEnA0qS4rn8DJDAYPI0LoMBNUH0pj/OYzhGg=; 25:NfC4OQ5x0vFqv8sUuu+v4fx6zy6pv4xihIyutsKG44gtH3gdG50xCIo3bjMDdQ4zbmHNyZ1J3awMX4VuP53Skp+D8hE87LZMnlK+57Y9qqpU3NZdj5rat2AaepLPACZynH1P15HCzkZsHcZMOhMxbYUeVMpq+tNfe8ztX/d2gyCjts83e0ZERO2CwJlDYuJ71r4IiH5pKAlczbl5lYvUjaOLqpRbn2wpDlpsQ6zvGaWVbtCVdvDEVIjqxp6Pm0CYQYyuo37/o/JkTxMAi5jrd5/0RhEtAWW4JP4RQNz0jJG/KjyrmYbNM7QIzuLhJLUVi/aniNcaEsafNt4JnxIbsA== X-MS-TrafficTypeDiagnostic: DM2PR12MB0267: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0267; 31:QKbdbJx4pgkJZQ1dQ0Hev1ST/Mmfj9gir9nB6E8P2SSpFYzHY9VLNGu08uESmbfp48s9FfPENPIvUlAmtzOagkhZ9xtS4YUEhwHCq7Np9ZU1rcAUPQOALvPa4/IiPs4x2HbIZ3YKZelej6QuHP3Cx0hm18e70auEItMEaLlfQZtmhJLbaMLZqhb7ko3xMU/1HYsR3HyYjoqlvQIjHnWqki/K5oUrKqjHp3b5ZdsWDEw=; 20:wOKYnsiI8Wv5QQ6Mgxb5NweYLFgGm/Iu/sp+d2jJMb3AkHUKsUqQn0qEzsoLigM4UCfkLkvxV12gblU/LB4hnYue0Y21mgqDcM4cnqhncubTiJBN7viMzusJCXX/SHspiSPcHUihZ1t1hcsk9HHzLdTSv2ffPdiG8C87Zhs5OX1IwnS0Ia4D4YlyroC0rbBsF+2P3Hed/bNBQ5sk4Wau8P0RuRDj6UbjpckOs4uL0rTIKtlymJSmMCM65iuvsNEpdIlN9zuAyupcznK8aPEjh1O+/vq6qHEojxyl08nPmdxJ7YNS9NAjKUOLUOwTgmL0HTtRpwoWjRDR5ImLQX0sgBBO6OoUv5GYVAAdNI6cvlMougXLRYSJUMusUKcxwbZkA2bcloKHi8suoEpvg1JsxpAvsiNunklhN1D5vZYCsXWq+ZdNiNM5F4vU3MFEw45sMESJy+1qd7lDhUMsk5Z7wjQImS4TPxLUzvfmAJPxlUHsQdZSCZNcY7tjfjmjEdGJ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93003095)(3002001)(3231101)(944501161)(6055026)(6041288)(20161123564045)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:DM2PR12MB0267; BCL:0; PCL:0; RULEID:; SRVR:DM2PR12MB0267; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0267; 4:EcCQrXnqJGoGUo2dEyh+QZrEjBhrfJ2WUh3TXdybT4qSluQC0SDTdkLtcRjKTmodDkZLj8qOGAO3QKLmv0VpBNC4dXtBZSaVLeATLtVSdOpmfJsMXR+N2vLySGYVV170DpqUQugxveqZF8zWO7kLsIJ2uXlnf8OYvuC+3Y/PfUa+yxdH4WTxKxRawT37IGmPibajpxMUWgeZ81dSRuOKemjpxWI9UWKFwXaqdekpC31DT1YMW/B9Mz6F93+zHU4cvZzIDNrQblVoRT4L1W3FqiFCkzu4rUd+D4Pageo0PwRZB4BIOcsO3FgijKQITg3N X-Forefront-PRVS: 0585417D7B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0267; 23:DNXojEl5p4uYZGLfKlUi9V3iYU4ZvdVSIzy3+wMtF?= =?us-ascii?Q?A0J+U9EY+zdMopcaJpJQOOlf/onq0YOiaNSoURTL/t0CW8V3md29A2BIjhzW?= =?us-ascii?Q?QVlkLE0F5alcCmGjr4bp5SbXQzhRvr0mdsCL8/oFlvu4f7VCudXq9f0CyFvh?= =?us-ascii?Q?vuC12S4HIjCds4A2BiFKSeNPgRQFg+sW/ituk4aT64wABta/H8eg/WyZL3Uv?= =?us-ascii?Q?uY+wwwKD79OMXEERcKAWopxxLPIn6G7Ktavu1eUns8djd1rfEuYfYzD9j5sP?= =?us-ascii?Q?Ou4EPzeDV771qznLk+0bhEhIz9HTtPh42J5W1gcgkLF2eG6LowJmX68Fqf1F?= =?us-ascii?Q?G/3KcaxXfWpOHXOVcSxz3hfWVQ/OAMtmNV9cXuLIDQ+yAS8FqhOYacA9brmu?= =?us-ascii?Q?KIVb0yQFKZlVr3mucZDcRsILFD0urJIn8c6XsmUPrafOS/dRpYwbeIDQk5IR?= =?us-ascii?Q?yjF0mRd6PQ4CABn2ybRypkEK+TNKt22mK6W/2/71J2doaygYaYoVde0q52d0?= =?us-ascii?Q?S2rdt9V1OoemnBRZ/8rybAIcIc+SSZj5qqNM4F5xZzn2L/UebytSDguIo/hR?= =?us-ascii?Q?s9sFx+fNGbIIBbwlV2HldTDugzhb13xIIKW2aHvQ1Fcg1IMuej3OIb7/HgnP?= =?us-ascii?Q?8PTBmJNAja1pAaAslquIkjAKC7kL26T+LSAmHUkctGm36rXkHUUtlr730jx6?= =?us-ascii?Q?siHxZybt7E28yyl14Lcj5K9yT4hwSAZXkyMMinLZmrhv+Ec+2ksLuW8/G6sz?= =?us-ascii?Q?RWXWnJeJpmLWKe2nk1fYH/ws5lAuGvPwkZV3u3N4/HnQ4vko2cKBwbASl+q3?= =?us-ascii?Q?KZ5rAzs6l1V7YM/x5HR17ySO9L8VicuaVgsTU315cUGQ5O16/UvB8jXd6B04?= =?us-ascii?Q?WObmq06RsMhKh7hFObXlq+tZltxD/tz6z8WKMUr9NqzsuaKyV6iahxIRoFtE?= =?us-ascii?Q?snowOpJp35LA4Xt1+WiVKcnwm3sRJdUW+zg2fpZEZHC7zxQ20nE4+5bPy6ta?= =?us-ascii?Q?/2t1NmzXkMZURlQk+x/lUdcHYlUjLn/V8zXEyQf8WE89b2vkJe0iSbVKUz2A?= =?us-ascii?Q?tAiOJRyAwcVVex7xeEfo0COnXinEbgiRUtWjqxxQxOaBh+c4i/SYLdksKXW2?= =?us-ascii?Q?qdVnA+jG60=3D?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0267; 6:vJFuVT/9pqW8VPgTscluZI0UiOvGomkdK5n/EnpAUh9R5omjopPukb3B74qHsKQycBWWs4ofqzn91tXe7RzKi8mZE/LM2Zf4tqLKspJ6kX+tLXFpduDdmzmB2nGsuxw+Ik0loDExb3iC7CRodJDqVkdFmfcLhoPcgYYolgNp16cf4RZ4ZWZRRq2okbIq7XB3sH9aPX43KIHh+a1VEUHfbmiobzRKyYIolzGREycmKX4Voi15DeHALBeCtG0CiaXAW87yqlhbW2qIW80FOZc2dfp6UNtoUYowu5D2ep954XLSRBxvhV2IQoeA0pfgQviK6E6WZoIXPY+WNjSjYqnBDQEwvrEC10yr+YNpl9SuKQY=; 5:c+dvMzn0kLv2WDTCfQDpxSZhBETOWkxh88pjSf7AYnQ9DAf5lJIuETRreEEN3gw9NB+y9Oo3WiJUiIcVKxTlvGovrmlpooYHg9abmK7Tu3FodFjrw4s6FwI1SRYaumrR3AuVczVU3TtNLuOEtaoAPXmI6KQgmxLkDeruXdDy3zc=; 24:xeMcvXoo1ftqaVd6eQ7lMMWlxBZqO6wyuajtdpUnCuDy9GwEyHmxpOiimThxnLJ4cpSus7XxXtwDKE7imKGT6caJiyiN6KpDdjHrgzRb7Mg=; 7:zYSNLa1AREz4JbE1/eKtexaOK+pnaE5M0nRFlHoJgesEtPyInVE+cjWNBjTo9Sdsha/C1TlNhOS3Y8Xn62GzToVxg4orCcnTICA27XuEHD4eYhnR/sjlXwGG1+B3G141tqbhPdzDGunww4AP7NZqlc1KvkUfTS6ZxkTPQJPYDG6T9yzTCHVtqZMSXbVyeS5E4RV1NA+AKBYy9YAhmTvEqzY+gnAjAX00p+qwKw3a94wDcJwJgMLicikYSYNSJveQ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0267; 20:/09R+GBs3sFYfM7bukajbdJzMXlHg59D9BerKGRLHoqexcnVbNZEEOB4mQQ2Iods+pYlLu0ryumk+TiG4pXDZSxwHenDWHfTEPHswVP93PWE6zd2+dVuymx2Agx7IP93oBOTu01sInqivMSFdYoS6RuoHrR/zDtHHAGGlAW+HzenzrIJWVIsJzDvcjKiCJyx+WyRwHqy3d7uZW4avf4Gkmw5m5aolGIQV+Yvi26urnfy2iN5MrJnCgVMM0TDEpEm X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2018 07:32:22.7080 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ccc67ab8-8892-4172-f1b9-08d5750f6b60 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: DM2PR12MB0267 Cc: tiwai@suse.de, Alexander.Deucher@amd.com, lgirdwood@gmail.com, Vijendar Mukunda Subject: [alsa-devel] [PATCH 6/9] ASoC: amd: pcm callbacks modifications for bt i2s instance 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 prepare,trigger and pointer callbacks for bt i2s instance. Signed-off-by: Vijendar Mukunda Reviewed-by: Alex Deucher --- sound/soc/amd/acp-pcm-dma.c | 231 +++++++++++++++++++++++++++++++++----------- 1 file changed, 172 insertions(+), 59 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index b1c1ff2..0e2dc05 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -947,23 +947,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; @@ -982,14 +1002,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); @@ -1003,25 +1041,54 @@ static int acp_dma_mmap(struct snd_pcm_substream *substream, static int acp_dma_prepare(struct snd_pcm_substream *substream) { + u16 start_dscr_idx; struct snd_pcm_runtime *runtime = substream->runtime; struct audio_substream_data *rtd = runtime->private_data; 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); + switch (rtd->i2s_play_instance) { + case I2S_BT_INSTANCE: + start_dscr_idx = PLAYBACK_START_DMA_DESCR_CH8; + config_acp_dma_channel(rtd->acp_mmio, SYSRAM_TO_ACP_BT_INSTANCE_CH_NUM, + start_dscr_idx, + NUM_DSCRS_PER_CHANNEL, 0); + config_acp_dma_channel(rtd->acp_mmio, ACP_TO_I2S_DMA_BT_INSTANCE_CH_NUM, + start_dscr_idx + 2, + NUM_DSCRS_PER_CHANNEL, 0); + break; + case I2S_SP_INSTANCE: + default: + start_dscr_idx = PLAYBACK_START_DMA_DESCR_CH12; + config_acp_dma_channel(rtd->acp_mmio, SYSRAM_TO_ACP_CH_NUM, + start_dscr_idx, + NUM_DSCRS_PER_CHANNEL, 0); + config_acp_dma_channel(rtd->acp_mmio, ACP_TO_I2S_DMA_CH_NUM, + start_dscr_idx + 2, + 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); + switch (rtd->i2s_capture_instance) { + case I2S_BT_INSTANCE: + start_dscr_idx = CAPTURE_START_DMA_DESCR_CH10; + config_acp_dma_channel(rtd->acp_mmio, ACP_TO_SYSRAM_BT_INSTANCE_CH_NUM, + start_dscr_idx, + NUM_DSCRS_PER_CHANNEL, 0); + config_acp_dma_channel(rtd->acp_mmio, I2S_TO_ACP_DMA_BT_INSTANCE_CH_NUM, + start_dscr_idx + 2, + NUM_DSCRS_PER_CHANNEL, 0); + break; + case I2S_SP_INSTANCE: + default: + start_dscr_idx = CAPTURE_START_DMA_DESCR_CH14; + config_acp_dma_channel(rtd->acp_mmio, ACP_TO_SYSRAM_CH_NUM, + start_dscr_idx, + NUM_DSCRS_PER_CHANNEL, 0); + config_acp_dma_channel(rtd->acp_mmio, I2S_TO_ACP_DMA_CH_NUM, + start_dscr_idx + 2, + NUM_DSCRS_PER_CHANNEL, 0); + } } return 0; } @@ -1043,50 +1110,96 @@ 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, - ACP_TO_I2S_DMA_CH_NUM); - rtd->i2ssp_renderbytescount = 0; + switch (rtd->i2s_play_instance) { + case I2S_BT_INSTANCE: + 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, + ACP_TO_I2S_DMA_CH_NUM); + rtd->i2ssp_renderbytescount = 0; + } } else { - ret = acp_dma_stop(rtd->acp_mmio, - I2S_TO_ACP_DMA_CH_NUM); - rtd->i2ssp_capturebytescount = 0; + switch (rtd->i2s_capture_instance) { + case I2S_BT_INSTANCE: + ret = acp_dma_stop(rtd->acp_mmio, + I2S_TO_ACP_DMA_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); + rtd->i2ssp_capturebytescount = 0; + } } break; default: