From patchwork Fri Feb 16 07:33:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 10224117 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 3A359603EE for ; Fri, 16 Feb 2018 07:32:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25AF4283E7 for ; Fri, 16 Feb 2018 07:32:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 161A228844; Fri, 16 Feb 2018 07:32:34 +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 25A60283E7 for ; Fri, 16 Feb 2018 07:32:33 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 217E6267D70; Fri, 16 Feb 2018 08:32:11 +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 668DB267D77; Fri, 16 Feb 2018 08:32:10 +0100 (CET) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0089.outbound.protection.outlook.com [104.47.33.89]) by alsa0.perex.cz (Postfix) with ESMTP id CB27D267D6E for ; Fri, 16 Feb 2018 08:32:06 +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=O0k66T55BRg0fMdl1Wsj6iCfgAi1gqdBRisInmCz9LY=; b=ACPQrSVkqTpvxhThnMnn1X6TGSAcTeMj5F06sFW85CGASiK669Ojv86qvwWAipFQl+1xoRZY7Bghb7HL5v5K/4IJOyIwM1zA3UMKwWmRqqipq8QtXTmIRIaWrj3sj2V2muaHKaY58eXdnz1UgM5z/DN4Nej7jotCREjtk+Hn3OU= Received: from DM3PR12CA0091.namprd12.prod.outlook.com (2603:10b6:0:55::11) by MWHPR12MB1248.namprd12.prod.outlook.com (2603:10b6:300:10::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.485.12; Fri, 16 Feb 2018 07:32:03 +0000 Received: from BY2NAM03FT064.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::205) by DM3PR12CA0091.outlook.office365.com (2603:10b6:0:55::11) 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:02 +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 SATLEXCHOV01.amd.com (165.204.84.17) by BY2NAM03FT064.mail.protection.outlook.com (10.152.85.143) 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:01 +0000 Received: from SATLEXDAG04.amd.com (10.181.40.9) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server (TLS) id 14.3.382.0; Fri, 16 Feb 2018 01:32:01 -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:00 -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:31:56 +0800 From: Vijendar Mukunda To: , , Date: Fri, 16 Feb 2018 13:03:47 +0530 Message-ID: <1518766434-7911-3-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)(39380400002)(376002)(396003)(346002)(39860400002)(2980300002)(428003)(189003)(199004)(68736007)(53936002)(8936002)(50466002)(186003)(4326008)(81166006)(81156014)(106466001)(8676002)(5660300001)(336011)(76176011)(39060400002)(97736004)(105586002)(54906003)(16586007)(77096007)(2201001)(110136005)(26005)(50226002)(86362001)(48376002)(478600001)(51416003)(7696005)(2950100002)(305945005)(356003)(316002)(2906002)(6666003)(36756003)(53416004)(72206003)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1248; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2NAM03FT064; 1:1BcdfA+ObM1vA80+3Znx7aPvQbV+zJrafALMyZ62C5yhJgIKurjM8Z5ZtwL5nvmfWMQ0+fNbdG6BwnSrGT36qw8Df8j7FgIDYKjGYsIuK8i35Qo0PNqgH+EvttKshb21 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4e720391-d352-4a52-1036-08d5750f5eec X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060); SRVR:MWHPR12MB1248; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1248; 3:BGJZlqZvL54jIlp7Kf1/kRV5etUL1pWPMvFr9TbcpY0ERbtHGwBIJJdgJk0RRrfiVhwGs3B9EMGYXbjrCUZwu2lgfQAMAV04GHjyXfPRDhhy7bY1UQUiLVZyYrfEYLCiBUeeh/3Z8m4DtpnKXf9s+aYBR6M6VW9mzLn4AsUD9e/ySgLpxc5jKc9lej7tvXAvTEWitOBOFFG/Zh8Uwjb3AAju/4r2ZgcmKlHsEC6tLEVfyuGDVZmm5BCyV13TgNhkWqAVOULy+ldJzPdLeIhBAqkgt+jUveoKXNirKxjk6h9BF4n1BPIMQCJ9pfE7i924SOR+8tmDtI1Wrnm9Q6v6C1EKExCsGTp6Uc4z3eOXpkE=; 25:ryI1c5wF2W3MXO9HNGRu1+I6RzEIULAOjsc2kGv69Ee8B6wdkix4iPOgOoKNUxvbwVRnxzy292LoYW6lMbVDcRdmWy4KkH8pqWqEXiRd+2Dlr55Lzzh9d4coJyHwDCILYB+WGkn3RovhXkWboAMuabzyJdg4QTx1xXQl5IzZOeby5w4h/e26+2uYW+qVjzneODx6xNowCC7kk473x/8+EnyGcX+xuU8vNgB0moTCKhkGGtpkcYMqJsJ59EkBvhka0UbJ3OIcqPD5kzi5oR1LogWDHe42b82A18IPXSG+n/YNs5JYDc3MWZ3AbXsM1iLbRikGXPLgh9a6+D48ksv1mw== X-MS-TrafficTypeDiagnostic: MWHPR12MB1248: X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1248; 31:Eqa3JhvoR2VW2TW0KU/qWkTT9x9ZVr5JLeUL6OOT0WSjKbBWKiXLctpg+46voI6vdljhFzkMHGNz7KHwCe3hLzgZH8joEpjpHuG7zAEeZq6yJxMeGSgcbNXDtxJw2PU7rqjob8YDL67z6+F/zwGh22sR45vona/skklyA29lT2XtgSIadOIsv3/wVD8Bh1yZiUWgHFaeXuL+OfKJ/z3zpIIhCaaQKsa7sORyGrVhpKw=; 20:2AJr1f1RvfBtR3O7aKHpSBcKvY+Qog3fO+HRFeFveNtw7i/7QDINHJTmcTh9vn+zIOAXNRR07SqowYy9mfwh1E31RztUofPkMwL5uNWTI6HD+QUJp1nQBbAigzRsO0fStgVKT5WvKhhr/7Ln1a2+CDnF5yzFuA8tYeuLKt4NYZFoj7F0BQ3RMkEEnAqJWLgYa17fWls/qYXXBliYK76a4joHINx1SuicvqAlxIlYCEwkepExappguNBS8zo5/5OaBQxim7kk62Ybx+0IUA1EEeGMfKliysn+jor/olf3856DqONlg83WpLj6JDX6frbXJj64zK9dDlCElkQw76myWQo479/ozUQu/tDzFiwKuKABDztyQ0ARb4V6ViqEl6ZPOmM+T2K2MeW0TCjgRkL6ayC7ByNIU8F033ctx6XECSNWdYUxgoHZ1flzeEaep+by9cOIRcxHtENzeYR9uxiAG9OAXLMfKO8T1Vs/m3zD6+f1VrLT0uFjCYxtVPc0j4Lb X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3231101)(2400082)(944501161)(3002001)(10201501046)(93006095)(93003095)(6055026)(6041288)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:MWHPR12MB1248; BCL:0; PCL:0; RULEID:; SRVR:MWHPR12MB1248; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1248; 4:LyoK5uw0GC96bfIHwVYpdAL5SoVAymjhPklfkfNcEVOd/a53IqG5XHqxjwQioNcdcXRFOACjUh1UB/ZU5ErbWEK5XI9f8ZGu0pH1L+tBj6yftRYkKjKMkwA8s2mtFmmMNQ7vAtn22SbT22PyIRacB46G3hF+8dybsaIICWNApwC15yeiyh23q+/gpVTlu7TjcxZdsbn1Bhkhbmxmk9au1Ht2dGyknahhvMitV9NIk5k0tacpnGDzIg90emODKBVDW2h7ld0NEsQNvM53r5g6uFoEOjoY0kCBxXgXPqVGix6J7BwzzicjamPDluk/V+09 X-Forefront-PRVS: 0585417D7B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR12MB1248; 23:hjo6TS5OWLkaHqgb6xO96Vur1Ni93VWiEAcjB1KhJ?= =?us-ascii?Q?h9x/x/DTFYoj1dt/s49+Irf0OjQS9MbBoXJ1VRX6SRmTbwyc88Zhb8JETksK?= =?us-ascii?Q?WTG2qPFY2ka8qqwznt0cAk6WGQHKJ7PMUWhVzmsviNEX+9WG5l2pAN2xvBBM?= =?us-ascii?Q?24Sw4b+KfYx9DCudvWVPLQkOn8b6HFRh1A0UddBWvC8NNSRGv3Y+sfbXaSj8?= =?us-ascii?Q?TLfCUwPIP4wiiq6PNVeVJJV18ZnpbFCQeqrOduBF+4/GtecTl2gUMwWfYtcd?= =?us-ascii?Q?7SapaDGd4QcByp+bAaUjT6S0icmD7Rggkl3xJBJJUw9HAr7nFnvUjh7qH0Ls?= =?us-ascii?Q?07DQJ5/U8u3wMsIMGvyqyO2bU1f2WYyVVlBTEz2xcQUMWyUX5sRfJjop8y6I?= =?us-ascii?Q?3D29qSXtJO5/BTarmPOVEe/Y0odwWP05CQbSmxDB3dKTCqJOMTWKxlACETWs?= =?us-ascii?Q?cxap/2hK5r1tvrKUM+4Kx1uzedCK5gXV2ebnmQ8IfXX2oBWLp3MmGUWwVh8N?= =?us-ascii?Q?MtO/940YFrWJOkzN2VMbWjB0oGOOPnToTJPVZBiZFk5Ai5Zkhe/RXiHm3GJ7?= =?us-ascii?Q?2eNA5zysfMzggvOpL3GgkBzGtA1mmOEK77IxxasbCkegC8dFHGBkpqZDYZA4?= =?us-ascii?Q?4REs1RryOnbjfhSqjqIiTqoDw21VM7cBpZc+4/0+NTXP4wlxpH2z2aSm8rMb?= =?us-ascii?Q?6U7YthqaKP3gT02qLWmSx6IAdHaSklYmVTdlFakZRFw+FfAOg9a9VsFqYUXZ?= =?us-ascii?Q?v/GLIMB7j660YXo7FjDlRcVNHLzj2eWMiG9BMBTQys4K38MVdUasL12KSqfY?= =?us-ascii?Q?iEnEZQnop+IjFqGLJmUTobjBOXiqlyrszXdLd8Os453Ygc94PbB2uYVNzw/K?= =?us-ascii?Q?JXdhgjR+4s3fCPbTh/cJGYaCvVkuajUDQBDSVb/P8FnQ9teJ0YxoAcZUBdUs?= =?us-ascii?Q?6iEwRmsjTabgHXcYS6fzv1fsFcEIgJSb1Lp2HZjM2YtAguSLG1t4CFT1Nc9w?= =?us-ascii?Q?52AbzRAPx4kobIR/bOQYp8mMqboklW5kUFTXWqyda5uHzDWNx2gExgAfbl+Z?= =?us-ascii?Q?OCZdthmyCB3rh0nb8SumNJSNCr7FURKhemIbfj3jkwd9WQfHw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1248; 6:Mhp/Ed+YRldvp2vVm8PveyVyeoynCkohi0ySmGwxxvc7uMDXF51hpOQqzVpYYoQmggZhZ2kIX3A+kZtwKAImoZdsw09oZfsVrDhyZ0Nvexw5/9e6pNxJ5Ud04OY1dLsGz9eHFlpKmkKCZY/Fxpi1bDov9HfYh5RE3KIdIKj3yEUBwxfH5QF8MrIMuVCx4HH/r4bkRqWjHQOMc9ZtSG7hQxy/muudtKAl1Be8G2NLX/4E+wGTjQkN3pTDUfwzwlUWJ2oEvc+qcs0ucrm3iSPcqS8wqkU6ZQCa4b/4Ot8SnO1MrhpGL3Fqj4CHSV9La0+AICX2QG8mVZrg01Yi7mGAeCJmZrpThPEQZxUm5py9+o4=; 5:D62qMxm3+fIGXRi+itPttuS8/RkQmLDbY6YO58+8ZNV+ctcVnpOvquxmXY7P40Nm/C4dE4+gd3CSfNi42Vv1pL8xgCLZ2ZZClWaTPagF/PU3lbv/ijG/RPwmhHaqCnhrt1n/GtZbbbknOl0x+wSMQXyasGglbpbrHAcSyQcYjEE=; 24:UqVIpWfXVZWVg+verKLtUHUfzxtN/AVlQf7If5LQAlmI6LzDCb3KAUUwp5kBrJfnaol4M525wqL312KiGto5w9Xm+Ju77CXhn/Gulyhbe6k=; 7:o9WdhXBNJmPQ2CZWIMsBHSH6AKK6sNvdsn0oZQFNj4CxuyWF5oKES8D7IAvYWjGhvmrkEuWZ5QBqfEC63huV9aBYzWbQGWhFBuugPXX0s9UBGbgu4wqccKQavsAq6IK+x4xrfHEPkkcwPkrJ1NnTktQyP9FhTfqPd12GIteZJz3hQSi5JKPSzTQqWIrN1MiROsVdoG4OX256tsoejHoRkjyC7+3p+MfOiF7s0BXgZ2d/5sM/huMuVwHJ6oeyXgo6 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1248; 20:e05UW5e34c0I51kEhyAq7nu2Bxt76hKOltChpGPpKlOFnASNp5JI3M/rif4TAkMbEOgMo82qFg9wyatl6oF4ZSvKHlB460DVeuwxNHZVNeSPL0uQ5Fz8wKF232SgJp129NTHf0XK1AwVay9/BPBt03IogpUK6fMpBHQ7tKPo8BoGTtqH2Uw+V4JihbhbM92fitV5IW3Gww3XAjzE//Pe6XVtezluKae7j5C9QTE295/Lgaf9YC8GTl0rq5rSW4D6 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2018 07:32:01.8718 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4e720391-d352-4a52-1036-08d5750f5eec 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=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1248 Cc: tiwai@suse.de, Alexander.Deucher@amd.com, lgirdwood@gmail.com, Vijendar Mukunda Subject: [alsa-devel] [PATCH 2/9] ASoC: amd: Coding style changes for acp dma driver 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 Removed hardcoding in dma descriptor programming api's. These changes are required to extend the logic to support dma descriptor programming for multiple i2s controller instances. Signed-off-by: Vijendar Mukunda Reviewed-by: Alex Deucher --- sound/soc/amd/acp-pcm-dma.c | 124 ++++++++++++++++++++++---------------------- 1 file changed, 61 insertions(+), 63 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index fcc5b4f..91c4775 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -184,19 +184,18 @@ static void config_dma_descriptor_in_sram(void __iomem *acp_mmio, * system memory <-> ACP SRAM */ static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio, - u32 size, int direction, - u32 pte_offset, u32 asic_type) + u32 size, int direction, u32 pte_offset, + u16 ch, u32 sram_bank, + u16 dma_dscr_idx, u32 asic_type) { u16 i; - u16 dma_dscr_idx = PLAYBACK_START_DMA_DESCR_CH12; acp_dma_dscr_transfer_t dmadscr[NUM_DSCRS_PER_CHANNEL]; for (i = 0; i < NUM_DSCRS_PER_CHANNEL; i++) { dmadscr[i].xfer_val = 0; if (direction == SNDRV_PCM_STREAM_PLAYBACK) { - dma_dscr_idx = PLAYBACK_START_DMA_DESCR_CH12 + i; - dmadscr[i].dest = ACP_SHARED_RAM_BANK_1_ADDRESS - + (i * (size/2)); + dma_dscr_idx = dma_dscr_idx + i; + dmadscr[i].dest = sram_bank + (i * (size/2)); dmadscr[i].src = ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS + (pte_offset * SZ_4K) + (i * (size/2)); switch (asic_type) { @@ -211,25 +210,19 @@ static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio, (size / 2); } } else { - dma_dscr_idx = CAPTURE_START_DMA_DESCR_CH14 + i; + dma_dscr_idx = dma_dscr_idx + i; + dmadscr[i].src = sram_bank + (i * (size/2)); + dmadscr[i].dest = + ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS + + (pte_offset * SZ_4K) + (i * (size/2)); switch (asic_type) { case CHIP_STONEY: - dmadscr[i].src = ACP_SHARED_RAM_BANK_3_ADDRESS + - (i * (size/2)); - dmadscr[i].dest = - ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS + - (pte_offset * SZ_4K) + (i * (size/2)); dmadscr[i].xfer_val |= BIT(22) | (ACP_DMA_ATTRIBUTES_SHARED_MEM_TO_DAGB_GARLIC << 16) | (size / 2); break; default: - dmadscr[i].src = ACP_SHARED_RAM_BANK_5_ADDRESS + - (i * (size/2)); - dmadscr[i].dest = - ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS + - (pte_offset * SZ_4K) + (i * (size/2)); dmadscr[i].xfer_val |= BIT(22) | (ACP_DMA_ATTRIBUTES_SHAREDMEM_TO_DAGB_ONION << 16) | @@ -239,72 +232,49 @@ static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio, config_dma_descriptor_in_sram(acp_mmio, dma_dscr_idx, &dmadscr[i]); } - if (direction == SNDRV_PCM_STREAM_PLAYBACK) - config_acp_dma_channel(acp_mmio, SYSRAM_TO_ACP_CH_NUM, - PLAYBACK_START_DMA_DESCR_CH12, - NUM_DSCRS_PER_CHANNEL, - ACP_DMA_PRIORITY_LEVEL_NORMAL); - else - config_acp_dma_channel(acp_mmio, ACP_TO_SYSRAM_CH_NUM, - CAPTURE_START_DMA_DESCR_CH14, - NUM_DSCRS_PER_CHANNEL, - ACP_DMA_PRIORITY_LEVEL_NORMAL); + config_acp_dma_channel(acp_mmio, ch, + dma_dscr_idx - 1, + NUM_DSCRS_PER_CHANNEL, + ACP_DMA_PRIORITY_LEVEL_NORMAL); } /* Initialize the DMA descriptor information for transfer between * ACP SRAM <-> I2S */ -static void set_acp_to_i2s_dma_descriptors(void __iomem *acp_mmio, - u32 size, int direction, - u32 asic_type) +static void set_acp_to_i2s_dma_descriptors(void __iomem *acp_mmio, u32 size, + int direction, u32 sram_bank, + u16 destination, u16 ch, + u16 dma_dscr_idx, u32 asic_type) { u16 i; - u16 dma_dscr_idx = PLAYBACK_START_DMA_DESCR_CH13; acp_dma_dscr_transfer_t dmadscr[NUM_DSCRS_PER_CHANNEL]; for (i = 0; i < NUM_DSCRS_PER_CHANNEL; i++) { dmadscr[i].xfer_val = 0; if (direction == SNDRV_PCM_STREAM_PLAYBACK) { - dma_dscr_idx = PLAYBACK_START_DMA_DESCR_CH13 + i; - dmadscr[i].src = ACP_SHARED_RAM_BANK_1_ADDRESS + - (i * (size/2)); + dma_dscr_idx = dma_dscr_idx + i; + dmadscr[i].src = sram_bank + (i * (size/2)); /* dmadscr[i].dest is unused by hardware. */ dmadscr[i].dest = 0; - dmadscr[i].xfer_val |= BIT(22) | (TO_ACP_I2S_1 << 16) | + dmadscr[i].xfer_val |= BIT(22) | (destination << 16) | (size / 2); } else { - dma_dscr_idx = CAPTURE_START_DMA_DESCR_CH15 + i; + dma_dscr_idx = dma_dscr_idx + i; /* dmadscr[i].src is unused by hardware. */ dmadscr[i].src = 0; - switch (asic_type) { - case CHIP_STONEY: - dmadscr[i].dest = - ACP_SHARED_RAM_BANK_3_ADDRESS + - (i * (size / 2)); - break; - default: - dmadscr[i].dest = - ACP_SHARED_RAM_BANK_5_ADDRESS + - (i * (size / 2)); - } + dmadscr[i].dest = + sram_bank + (i * (size / 2)); dmadscr[i].xfer_val |= BIT(22) | - (FROM_ACP_I2S_1 << 16) | (size / 2); + (destination << 16) | (size / 2); } config_dma_descriptor_in_sram(acp_mmio, dma_dscr_idx, &dmadscr[i]); } /* Configure the DMA channel with the above descriptore */ - if (direction == SNDRV_PCM_STREAM_PLAYBACK) - config_acp_dma_channel(acp_mmio, ACP_TO_I2S_DMA_CH_NUM, - PLAYBACK_START_DMA_DESCR_CH13, - NUM_DSCRS_PER_CHANNEL, - ACP_DMA_PRIORITY_LEVEL_NORMAL); - else - config_acp_dma_channel(acp_mmio, I2S_TO_ACP_DMA_CH_NUM, - CAPTURE_START_DMA_DESCR_CH15, - NUM_DSCRS_PER_CHANNEL, - ACP_DMA_PRIORITY_LEVEL_NORMAL); + config_acp_dma_channel(acp_mmio, ch, dma_dscr_idx - 1, + NUM_DSCRS_PER_CHANNEL, + ACP_DMA_PRIORITY_LEVEL_NORMAL); } /* Create page table entries in ACP SRAM for the allocated memory */ @@ -346,23 +316,51 @@ static void config_acp_dma(void __iomem *acp_mmio, struct audio_substream_data *audio_config, u32 asic_type) { - u32 pte_offset; + u32 pte_offset, sram_bank; + u16 ch1, ch2, destination, dma_dscr_idx; - if (audio_config->direction == SNDRV_PCM_STREAM_PLAYBACK) + if (audio_config->direction == SNDRV_PCM_STREAM_PLAYBACK) { pte_offset = ACP_PLAYBACK_PTE_OFFSET; - else + 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; + break; + default: + sram_bank = ACP_SHARED_RAM_BANK_5_ADDRESS; + } + destination = FROM_ACP_I2S_1; + } acp_pte_config(acp_mmio, audio_config->pg, audio_config->num_of_pages, pte_offset); + if (audio_config->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, audio_config->size, - audio_config->direction, pte_offset, asic_type); + audio_config->direction, pte_offset, + ch1, sram_bank, dma_dscr_idx, asic_type); + if (audio_config->direction == SNDRV_PCM_STREAM_PLAYBACK) + dma_dscr_idx = PLAYBACK_START_DMA_DESCR_CH13; + else + dma_dscr_idx = CAPTURE_START_DMA_DESCR_CH15; /* Configure ACP SRAM <-> I2S DMA descriptors */ set_acp_to_i2s_dma_descriptors(acp_mmio, audio_config->size, - audio_config->direction, asic_type); + audio_config->direction, sram_bank, + destination, ch2, dma_dscr_idx, + asic_type); } /* Start a given DMA channel transfer */