From patchwork Mon May 27 12:56:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sameer Pujar X-Patchwork-Id: 799898 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 08119C25B74 for ; Mon, 27 May 2024 13:00:20 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 79317950; Mon, 27 May 2024 15:00:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 79317950 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1716814818; bh=a0REPNbuIHSoWHoQfsgWgJbtychCnXXW6GLy4PNwQok=; h=From:To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=KGjxu4eJZLFbQRS6yGkt6pNEl0m6IAMk/vMaNROlmWroDLdhZ+5fFdrqjdZbtxhV9 4dyuuax5q4lK7viti9N4m3cAvw1kQ/QEfzyiuwF4u+Xh5s/J/d1ozWQha8mLVStGyP jFikOQLILuY1Hqb4raEo1GyjHZmjEgjxsDMqTD6o= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7332FF805F3; Mon, 27 May 2024 14:59:15 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 9873DF805F1; Mon, 27 May 2024 14:59:15 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 627DEF8026D; Mon, 27 May 2024 14:58:12 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on20601.outbound.protection.outlook.com [IPv6:2a01:111:f403:2009::601]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id EEF12F800BA for ; Mon, 27 May 2024 14:56:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz EEF12F800BA Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=ZZoINmhH ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aVTCoY/eYPgjdomx6QqwL1H60wVhHvjmJtFh+9vqw46+gYT72YOmeDCsX+Hy9yu6eVGV0rg03gUeLQF8adic4mQhRm4D3ieZjfnszyN3i4yRUspIKsGRwol8DPvEWusyE4vVdbR6BjLrg8mQfoEl7w/5hZHGliTF783UJrotZbV1/76SmU5ctHGQ8/DXZFerbvs3jpCQVIvWYpldUZun+CB4XQjLQh4XNqkAzUjO0WI7Re4AyILmFp/f1S+82jxM6iyPL9VNwwA3+aH+w6/sIo1C2X3kWlMWOzsiy+8Lo0llOLqTEYj/uYSlnIEk9Tl0b1s/ZYJEni2ZRtBtohFHVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Bl/ZA2+WnCpyMbxp7vZHNbPEAEvoiRjkFL+KokRs0Oo=; b=hH2r/qRcJT/cKcolSepG9Bja3SlTr3VcXU7pLyiHmjiR5fkPqN/Idk7k2d+Vf9kNFInTSPAHDQWlvyYmHy5aCRW8QL1JyqbhccRfExyAld5g8PsW7oznS8maPQgBlt+rcJQK6bTclFYzQLY7H53AdqqAmuMLVyx3HEN3V1Os2JF9i/l82R4aPEFSfbMXLE5tm1XtSUD/DAGpptEhQgqgvAxkzhAWVCLNG92j8FNXvibrDfz3wPMizqRfeqNHkt0jwMh6t+K5TY86DuYewcR3XepzOkETBjI+yeoK6RXjwYDAJLUVuqazShp774CMkn0oDsHRn9tRU81CMeNiUj96FQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Bl/ZA2+WnCpyMbxp7vZHNbPEAEvoiRjkFL+KokRs0Oo=; b=ZZoINmhHfiQLED99u6UKdNDJSuzsqK4RRJmg9xFlmwcYzptHSGNK48M7dtxGE4Gtuet1+h0fQGy1YUEheZrHfiAgIgl+CclrqSogW2QI1O0F3KlgVus7ckPg/XzqpcJ/uDbRFmCDH2MEK15Le9P0kv9QXdCgFBozbO4aWGGHHNoHBW/Q9Q4bPdmAtI1pWb8cH9piiA7oRXF+QiopTHSZEeHE9+ivLDqW8EobGMmD/ldzW5KN13X9tQwcCyhXKCs1Ab7/+ZdyAae95+XdmxWi2sqgr/KXeL1fCs7CnH4tb7wQodzVsiR1noxERgbU54/Nm8oX543lmrhUHGX4QG+V1Q== Received: from CH3P220CA0008.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:1e8::19) by DS0PR12MB7680.namprd12.prod.outlook.com (2603:10b6:8:11c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.29; Mon, 27 May 2024 12:56:34 +0000 Received: from DS2PEPF00003446.namprd04.prod.outlook.com (2603:10b6:610:1e8:cafe::d7) by CH3P220CA0008.outlook.office365.com (2603:10b6:610:1e8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.36 via Frontend Transport; Mon, 27 May 2024 12:56:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DS2PEPF00003446.mail.protection.outlook.com (10.167.17.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Mon, 27 May 2024 12:56:33 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 27 May 2024 05:56:20 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 27 May 2024 05:56:19 -0700 Received: from build-spujar-20240506T080629452.internal (10.127.8.9) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 27 May 2024 05:56:19 -0700 From: Sameer Pujar To: , , CC: , , , , , , Subject: [PATCH v2 1/2] ASoC: simple-card-utils: Split simple_fixup_sample_fmt func Date: Mon, 27 May 2024 12:56:06 +0000 Message-ID: <20240527125608.2461300-2-spujar@nvidia.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240527125608.2461300-1-spujar@nvidia.com> References: <20240527125608.2461300-1-spujar@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003446:EE_|DS0PR12MB7680:EE_ X-MS-Office365-Filtering-Correlation-Id: 54d92d2b-7d32-404c-9dd2-08dc7e4c6ff3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|1800799015|82310400017|376005|36860700004; X-Microsoft-Antispam-Message-Info: /Nqkcfo3QWXpSu4i9FJ6Ckbh6uxzPt6LzpI6YzZQiuHs92MWWBK0rbdDIUmfWEVk8X/fqNPh+eBFvd7eRl80clkN8TqWmjg9nwEsMh0EU7p9Br75Uht8/E0FKTUoEh4wZpxX4J6ukyH12hwizf1oEBWSRLpkxSBVjNEsgmSEXCgZtz0Q2Li7b7WmuT71ey5hSnsDBtlSyO1U926cA+N7KdG7byp9F65BCu/X7JrqxQvVcfaN60orFiRVdXa2RcHH/bGgYfUL5aXae++pPvZQ96d35z853i7q5quu3ZqaRaV58i8undD/Mm2xGy7bL+fi4pulvfo+Q3VhgQgAOrG6eSXMU+Z4DY1kt0WRq5oMaW2OEe+Ql3lGTOuoZvWwTeB0ONKSefdxGDp8buQHPk/luMgKEQen4sbitlz7zEWTrX9hRjkZEAm53pQuYkdWLizOfCCPS6/ATiMm5PzPS8Fcjsd9kdJlIMHcFHfEpF+3S+T7U9CkjvZ4ndWiZZYu8nmOzHyrZPi+y+kTnR2YHNiU9C49t38+965AAiIwb5BI5wiH+a2TiZIgLXP3NXuFlgSzlglh8j/pV410VGsd8hvkdsHwcHFtOK9h632n7PhcjU6A4ZQpnjujTgm/Zkl+MZ01EnWrQ79JUB5lplrfQjZApsDxz4/5uySVcInQ7vnbNxWxsIORYRDmq6Z245i2thw0qjwSvxtL8QTFhKT9v4xjyHGIqr2GKiN5KfYHPppo6D5BFDtzukjirYPtDUyoP4ttIDwOcLx37BN+e4geFNd495Y9++fbwSTRXoTa5icMPsKuxCjV7hoz0A4DC8Efplyu3McMnGN8Q68PExbuYzhamylIEEJW+LuAa25bbx6u7Foz3XPVTM1gnEWJ/wci6aAjjSsT8S5T8vaPzhFB6nLUUlmut2Q2NHqtvmXfAIm/s8qsuhpmC/zTk5AL1zfX3DM46f2Jqsoi0R5O1cd/EPM70TMXkiT4UqdJfVjLV3cHpJqqa5lsuqaty3m50372Y+O7pE/8pzZb54lyvUSzGDi7apfqYWfBdMMt/atT5hcj2IOVfILWI6C8C8u/MOwtZLcHNm51T2xY1M32Ec6NwAGedfv/4jMXUcmEdBiUK3FCOtL5sKWCVxasymMuNHRxVL3fQU5VvTnw70562A7EsYwO8968VbQK9Gc+9GumLkCrPdNIzeV795dFHWBADiSwoCGqnQKxUZ/Dc3cMg4mfJ3/YdoFpfMlAQeNXNO09O3DvrtHyHDqI6dBlMx8Ufx0BUBTQo9Q2BqHaEflSc2IeUKNoNOqFZhHlXwGEO6gS0eTXdTeM5QKldhn343wAR5zwGr2l9jl2EqCsuo/kkgQVevJWG3Mv8yK5daLu3OUrduEA0fgms9zC87UYZVi0BxgyGtNc X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230031)(1800799015)(82310400017)(376005)(36860700004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 May 2024 12:56:33.9056 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 54d92d2b-7d32-404c-9dd2-08dc7e4c6ff3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003446.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7680 Message-ID-Hash: XHH6EQPLZ3WLO6WRICIZU3I5YESITMXW X-Message-ID-Hash: XHH6EQPLZ3WLO6WRICIZU3I5YESITMXW X-MailFrom: spujar@nvidia.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Mohan Kumar Split the simple_fixup_sample_fmt() into two functions by adding one more function named simple_util_get_sample_fmt() to return the sample format value. This is useful for drivers that wish to simply get the sample format without setting the mask. Signed-off-by: Mohan Kumar Signed-off-by: Sameer Pujar Reviewed-by: Thierry Reding --- include/sound/simple_card_utils.h | 2 ++ sound/soc/generic/simple-card-utils.c | 26 ++++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index ad67957b7b48..2c2279d082ec 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -174,6 +174,8 @@ void simple_util_parse_convert(struct device_node *np, char *prefix, struct simple_util_data *data); bool simple_util_is_convert_required(const struct simple_util_data *data); +int simple_util_get_sample_fmt(struct simple_util_data *data); + int simple_util_parse_routing(struct snd_soc_card *card, char *prefix); int simple_util_parse_widgets(struct snd_soc_card *card, diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 81077d16d22f..f1f5a1c025fc 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -13,12 +13,11 @@ #include #include -static void simple_fixup_sample_fmt(struct simple_util_data *data, - struct snd_pcm_hw_params *params) +int simple_util_get_sample_fmt(struct simple_util_data *data) { int i; - struct snd_mask *mask = hw_param_mask(params, - SNDRV_PCM_HW_PARAM_FORMAT); + int val = -EINVAL; + struct { char *fmt; u32 val; @@ -33,11 +32,26 @@ static void simple_fixup_sample_fmt(struct simple_util_data *data, for (i = 0; i < ARRAY_SIZE(of_sample_fmt_table); i++) { if (!strcmp(data->convert_sample_format, of_sample_fmt_table[i].fmt)) { - snd_mask_none(mask); - snd_mask_set(mask, of_sample_fmt_table[i].val); + val = of_sample_fmt_table[i].val; break; } } + return val; +} +EXPORT_SYMBOL_GPL(simple_util_get_sample_fmt); + +static void simple_fixup_sample_fmt(struct simple_util_data *data, + struct snd_pcm_hw_params *params) +{ + int val; + struct snd_mask *mask = hw_param_mask(params, + SNDRV_PCM_HW_PARAM_FORMAT); + + val = simple_util_get_sample_fmt(data); + if (val >= 0) { + snd_mask_none(mask); + snd_mask_set(mask, val); + } } void simple_util_parse_convert(struct device_node *np, From patchwork Mon May 27 12:56:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sameer Pujar X-Patchwork-Id: 799275 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D2533C25B74 for ; Mon, 27 May 2024 13:00:09 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 19AD8846; Mon, 27 May 2024 14:59:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 19AD8846 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1716814807; bh=RAkzFFqQu34Q3YXgcLIlTC9WfEiCFD7e+tKEsOSe6Ao=; h=From:To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=FrFpmDmHKxsMr7mgy1Ecpn8j2DR0FPrIIXACyP/NR04vul9k3pZPEkY1pVxIHhRqd Afo5UeZCQFpzgQ+5TN6VphnpR0lrxle2iBMucpeILYUkK+ijLlbPlY5PTiHEAc1S2E MQ5o76UGDK6Z/A5aquzJw1F9xQhPrHcNBjRvglbM= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3FAD8F805CB; Mon, 27 May 2024 14:59:14 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 77C76F8055C; Mon, 27 May 2024 14:59:14 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 98184F8047C; Mon, 27 May 2024 14:57:03 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20625.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::625]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 15C22F80149 for ; Mon, 27 May 2024 14:56:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 15C22F80149 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=f6+a9bvx ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gdiAznLc+tXYdXeUaNv+aOFDVuaU+HUxfEoVRDfkrJVOHCFhIvP1+b/0bS31KelfVTU8dlQ8haJNGEV2SU9+SqgNrt5dTm5X4QbFKHPzt+2P5IXNZau24Haf37K+bAPthI5AZBoitF7NFV+fkp4C0xnfotUhMX2N2GYxsyxRu21+N/3h6WhCwOyQdgYLMJzCFaj5fP7Wq4r+yf8UgRY8xLiEAgNAqnJWSJ8KuDWrTLV1TOHDrttjedbA+bnV4d2VnZc+P8sjVEG1SxM9YSkudLy5+aO0AzShEgah29dC5TcwsKJqhsouSJeN104VBEv04+GCh9ARiE9qICEvGPWAxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Wnkj4wBXchlVFTLDqqNEicEPhlk1BjsiuyZF+MT6G1M=; b=GCrR1nR3uHGO+h4fovFUPsx8Edg7klALNStqKgFFebzsEOCM6cdvnw1tObvrw0JrG8dbK2N0jm+W6d2kQlsXIoz752fz6PkIX4Q3xyLLVlDtY4KRV3mF8AUsan5geJVdYcbVETnBUVThCriqiTRBLuQ8wasS+B8rXZ17zDouDIJ42Tg8XnJiSQngInAP/8Oqw0H/5rJwZq7Nic4b1PgXzsD8vrTWG3gNmOsOEM6+b5oQ8sWDz64giTaTrQXslTAxto+vSU8Qdpf2GAdYU3lUHf+0D6Xe5X8bb8Gifr0OEgY8FRWrhIHQfCVxcY2dMls5EeqUwsEzCyRMmSzNTGEyGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Wnkj4wBXchlVFTLDqqNEicEPhlk1BjsiuyZF+MT6G1M=; b=f6+a9bvxym/4CFTbQ5LxYo2T/X7X6mjPJ7Swf4t1iZSQbld4KlgRfhq3mHt8xOSOR6lkqt1HXnTBJRMKShFQfMb75taRfN/WeKNLAnCodmfGNN2zJxBrMTdueNP5npN1YRvSZXM9YLjDD1dkddposnA0if0mpQJ/BApw3S0HdEbixTGH7zT1YdF/lDDJdS8AXmJmyVjRVtZQG/xCPuiyNDNpGs5Z+YQh6uxnTRQBUat3h/IqPCsdcDdcRZN2gYqD9qtSrzHpy65ZS/4HN7kGAYOZLjUcx2ZtayvMnR/oNsZFUfpQ2kXVOb1CJ7iBqqHXwAt6FhSl1E5LkhbmVcAtkg== Received: from BN0PR02CA0014.namprd02.prod.outlook.com (2603:10b6:408:e4::19) by DM6PR12MB4434.namprd12.prod.outlook.com (2603:10b6:5:2ad::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.29; Mon, 27 May 2024 12:56:37 +0000 Received: from BL6PEPF0002256E.namprd02.prod.outlook.com (2603:10b6:408:e4:cafe::7e) by BN0PR02CA0014.outlook.office365.com (2603:10b6:408:e4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30 via Frontend Transport; Mon, 27 May 2024 12:56:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BL6PEPF0002256E.mail.protection.outlook.com (10.167.249.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Mon, 27 May 2024 12:56:37 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 27 May 2024 05:56:20 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 27 May 2024 05:56:20 -0700 Received: from build-spujar-20240506T080629452.internal (10.127.8.9) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 27 May 2024 05:56:20 -0700 From: Sameer Pujar To: , , CC: , , , , , , Subject: [PATCH v2 2/2] ASoC: tegra: I2S client convert formats handling Date: Mon, 27 May 2024 12:56:07 +0000 Message-ID: <20240527125608.2461300-3-spujar@nvidia.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240527125608.2461300-1-spujar@nvidia.com> References: <20240527125608.2461300-1-spujar@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0002256E:EE_|DM6PR12MB4434:EE_ X-MS-Office365-Filtering-Correlation-Id: 62a4e48c-34ad-44e0-9dfc-08dc7e4c71e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|36860700004|82310400017|1800799015|376005; X-Microsoft-Antispam-Message-Info: myW5sSYvg1PfbI3ZUSWI8TkZs25ApcXgZxwypHeMa3qxuXPm1Pwh5oIC6fzYz47p/CWg+iSYMqp9V5v3U4JBY03vc7YzakgLpSIUKAHF+6u8CkLwcr8ONK5LW4OPdEMd+l1jDdJBRfssJ/5DEOuZuHoDqVaFko0Yo94rRM+Z6Az38HMyJHbhZ0MP4bbADbZ/WpAEkuMsWw/kyEHqLdebQlYnlYn3VD2oYMTmva1Db8oA+NTLaNvwv4pndtBGBleTpqReMEaBx6c/jcqyPzWwtK4ir8izLnVwKhfsGjYdfTFYuSLPP+cPdRlOtM5srqh236w28lrX72RyJNMYNtHh3b5PFyChxjfq87/l4GAdMrG5Cv7bczGH/U+//lqCBdpZqLoJrS+DCAMCmpqANqVwmXWiRpe1lsaB6yacdOx7tWqvyF9g7qhZRgRo+QFkTbr4b1+Ubqvs9EG4ODR6s22RGcZ9illq1iMizoY/gMxNcEMWOmbQ3vv8OqoMkOcQNQjmlD1F38f0AGlxAPIhUs0mQ/7vZn+yWq598nyG4Cl5CWjD+TMlua2IRjNUVZ2KWmBGf+IN2lHeM1uy5mahMNQ/le9SmsZDzNEnQ8hc1Exuo773DL6p+JuyfWLOq8/JIwGcNEr85CSts9+gwNqoQlJrJP9hEX5QXlrXbPgFdQhaOy/lWKO+lFmtQf3w8r7qGso4BBis9qQJeDtTRYOscmUY+mTQhzbGbcdstKdLLxsFmU/0WstRDTWlT8QqCIP6fdwPfDOvoGoiOBv7C395ehb076VVY0juoYqYEtF9hcVND5ACmoagQowRFnCuqtKuNBsf5c9eRn3Bt9VqGZAkmwBkhOgOp4CjKbjNSiWOLouT78Aro5LZfEtheKrTTSuc+IDZNtJWG4vetUViYni/xQZLQ3XxbzXq25qkkBwoEmo3StoIB/Lq/rGIdkDB9Lau2MxXm4lKKVpWPkbHi+b9QQ/p0Dgkaft+2gnBtCdzRf9pRuW/7FbYtCmZ1mwE13ccI9fyv/l0y/8qUxCjlFqsCrGHwbbPCzn9EqzamKnOPuo8p9vWZjqaWHqtnE4M2LxPjfZ4e+PwzQMXHYtoO3osBxj2Yr73wHm03nFk6gk59Bmn3LNRipdpx1zMhpiyRBipEleOPUL7661MdYqt8w5L5mg+8Pkw0l6Y2Vc3QAKtNsBPochlldH/gnOrQsv3PbcHTiW7AjXUzHt0w/ZlXOsAjZpeNbVm5I4KTZpXtx/nGmENYve1bdXsLWe272FgmgsV1kRVliJ5q+eUarFy0yojwwMtD5re85nszO8adm6LlPak+G+22Tg+mrJN438blxVABPOKWngAtgPFFCijO+WyqBnPxotjSgZ+w/EQG5VpKqzJLXQKBGBXvr5BTGko0d6qq1FK X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(36860700004)(82310400017)(1800799015)(376005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 May 2024 12:56:37.1002 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 62a4e48c-34ad-44e0-9dfc-08dc7e4c71e4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0002256E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4434 Message-ID-Hash: 67IYE3MDF6UUVXF47A2PWDDWNLBZ5QHI X-Message-ID-Hash: 67IYE3MDF6UUVXF47A2PWDDWNLBZ5QHI X-MailFrom: spujar@nvidia.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Mohan Kumar The AHUB HW modules are interconnected with CIF which are capable of supporting Channel and Sample bit format conversion. Due to this, the I2S Client can have different Channel and Sample bit from the hw_params() and this config is passed from CIF port of I2S DT node which can help to perform this conversion. For e.g. HFP usecase consists of BT SCO with 1ch and 8k audio data which needs to be converted and mixed with external codec playback and capture path which is of 2ch and 48k format. For HFP Playback: The path includes mono to stereo and 8k to 48k conversion _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |1ch | | 1ch | |2ch | SFC | 2ch | | |BT SCO |---->| I2Sx |------>| CIF |----->| 8k->48k |---->| Codec I2Sy| |_ _ _ _| |_ _ __|client |_ _ _|audio |_ _ _ _ _| |_ _ _ _ _ _| For HFP Capture: The path includes stereo to mono and 48k to 8k conversion _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | | 2ch | SFC | 2ch | | 1ch | | 1ch | | | codec I2Sy|---->| 48k->8k |----->| CIF |------>| I2Sx |---->| BT SCO| |_ _ _ _ _ _| |_ _ _ _ _| audio|_ _ _|client |_ _ _ _| |_ _ _ _| For above two path, I2S client channel uses existing DT binding to pass channels and format conversion in I2Sx CIF Port. Signed-off-by: Mohan Kumar Signed-off-by: Sameer Pujar Reviewed-by: Thierry Reding --- sound/soc/tegra/tegra210_i2s.c | 71 ++++++++++++++++++++++++++++++++-- sound/soc/tegra/tegra210_i2s.h | 2 + 2 files changed, 69 insertions(+), 4 deletions(-) diff --git a/sound/soc/tegra/tegra210_i2s.c b/sound/soc/tegra/tegra210_i2s.c index ba7fdd7405ac..fe4fde844d86 100644 --- a/sound/soc/tegra/tegra210_i2s.c +++ b/sound/soc/tegra/tegra210_i2s.c @@ -8,11 +8,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include "tegra210_i2s.h" #include "tegra_cif.h" @@ -603,6 +605,7 @@ static int tegra210_i2s_hw_params(struct snd_pcm_substream *substream, struct tegra210_i2s *i2s = snd_soc_dai_get_drvdata(dai); unsigned int sample_size, channels, srate, val, reg, path; struct tegra_cif_conf cif_conf; + snd_pcm_format_t sample_format; memset(&cif_conf, 0, sizeof(struct tegra_cif_conf)); @@ -615,28 +618,51 @@ static int tegra210_i2s_hw_params(struct snd_pcm_substream *substream, cif_conf.audio_ch = channels; cif_conf.client_ch = channels; + if (i2s->client_channels) + cif_conf.client_ch = i2s->client_channels; + /* AHUB CIF Audio bits configs */ switch (params_format(params)) { + case SNDRV_PCM_FORMAT_S8: + cif_conf.audio_bits = TEGRA_ACIF_BITS_8; + break; + case SNDRV_PCM_FORMAT_S16_LE: + cif_conf.audio_bits = TEGRA_ACIF_BITS_16; + break; + case SNDRV_PCM_FORMAT_S32_LE: + cif_conf.audio_bits = TEGRA_ACIF_BITS_32; + break; + default: + dev_err(dev, "unsupported params audio bit format!\n"); + return -EOPNOTSUPP; + } + + sample_format = params_format(params); + if (i2s->client_sample_format >= 0) + sample_format = (snd_pcm_format_t)i2s->client_sample_format; + + /* + * Format of the I2S for sending/receiving the audio + * to/from external device. + */ + switch (sample_format) { case SNDRV_PCM_FORMAT_S8: val = I2S_BITS_8; sample_size = 8; - cif_conf.audio_bits = TEGRA_ACIF_BITS_8; cif_conf.client_bits = TEGRA_ACIF_BITS_8; break; case SNDRV_PCM_FORMAT_S16_LE: val = I2S_BITS_16; sample_size = 16; - cif_conf.audio_bits = TEGRA_ACIF_BITS_16; cif_conf.client_bits = TEGRA_ACIF_BITS_16; break; case SNDRV_PCM_FORMAT_S32_LE: val = I2S_BITS_32; sample_size = 32; - cif_conf.audio_bits = TEGRA_ACIF_BITS_32; cif_conf.client_bits = TEGRA_ACIF_BITS_32; break; default: - dev_err(dev, "unsupported format!\n"); + dev_err(dev, "unsupported client bit format!\n"); return -EOPNOTSUPP; } @@ -872,6 +898,40 @@ static const struct regmap_config tegra210_i2s_regmap_config = { .cache_type = REGCACHE_FLAT, }; +/* + * The AHUB HW modules are interconnected with CIF which are capable of + * supporting Channel and Sample bit format conversion. This needs different + * CIF Audio and client configuration. As one of the config comes from + * params_channels() or params_format(), the extra configuration is passed from + * CIF Port of DT I2S node which can help to perform this conversion. + * + * 4ch audio = 4ch client = 2ch 2ch + * -----> ADMAIF -----------> CIF -------------> I2S ----> + */ +static void tegra210_parse_client_convert(struct device *dev) +{ + struct tegra210_i2s *i2s = dev_get_drvdata(dev); + struct device_node *ports, *ep; + struct simple_util_data data = {}; + int cif_port = 0; + + ports = of_get_child_by_name(dev->of_node, "ports"); + if (ports) { + ep = of_graph_get_endpoint_by_regs(ports, cif_port, -1); + if (ep) { + simple_util_parse_convert(ep, NULL, &data); + of_node_put(ep); + } + of_node_put(ports); + } + + if (data.convert_channels) + i2s->client_channels = data.convert_channels; + + if (data.convert_sample_format) + i2s->client_sample_format = simple_util_get_sample_fmt(&data); +} + static int tegra210_i2s_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -887,6 +947,7 @@ static int tegra210_i2s_probe(struct platform_device *pdev) i2s->tx_mask = DEFAULT_I2S_SLOT_MASK; i2s->rx_mask = DEFAULT_I2S_SLOT_MASK; i2s->loopback = false; + i2s->client_sample_format = -EINVAL; dev_set_drvdata(dev, i2s); @@ -916,6 +977,8 @@ static int tegra210_i2s_probe(struct platform_device *pdev) return PTR_ERR(i2s->regmap); } + tegra210_parse_client_convert(dev); + regcache_cache_only(i2s->regmap, true); err = devm_snd_soc_register_component(dev, &tegra210_i2s_cmpnt, diff --git a/sound/soc/tegra/tegra210_i2s.h b/sound/soc/tegra/tegra210_i2s.h index 030d70c45e18..fe478f3d8435 100644 --- a/sound/soc/tegra/tegra210_i2s.h +++ b/sound/soc/tegra/tegra210_i2s.h @@ -112,6 +112,8 @@ struct tegra210_i2s { struct clk *clk_i2s; struct clk *clk_sync_input; struct regmap *regmap; + int client_sample_format; + unsigned int client_channels; unsigned int stereo_to_mono[I2S_PATHS]; unsigned int mono_to_stereo[I2S_PATHS]; unsigned int dai_fmt;