From patchwork Wed Oct 4 08:07:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13408367 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 5A159E8FDD9 for ; Wed, 4 Oct 2023 08:10:26 +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 C2987A4B; Wed, 4 Oct 2023 10:09:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C2987A4B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1696407023; bh=xYoLB+YutO9Vxcob6nrPi8LlIX11Rx9HHXQ5g9dSyQA=; h=From:Subject:To:Cc:In-Reply-To:References:Date:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=d+JVhuM3ZQdQwe9vWXtATsbZ5iPnvq+zG0wy1195jiEHtjx4TL8d/LWKVHMOXlEHH jDaLs7lxd1MRy6i3j06Zi3+RIh84gtWPZGQXS8TLAkTw2EQ9wKxGKyuYWW0Al2SOly gIbpgOtGuvVjVJKvrAntaDrBy0C2iFQ7MNtIHOuo= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4FD7FF8056F; Wed, 4 Oct 2023 10:08:44 +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 6D856F800C1; Wed, 4 Oct 2023 10:08:44 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D79C9F8047D; Wed, 4 Oct 2023 10:07:56 +0200 (CEST) Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01on2072d.outbound.protection.outlook.com [IPv6:2a01:111:f403:7010::72d]) (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 CCE26F800C1 for ; Wed, 4 Oct 2023 10:07:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CCE26F800C1 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=renesas.com header.i=@renesas.com header.a=rsa-sha256 header.s=selector1 header.b=KEGwcuYY ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VoObnVSP6KvqqyRUzk3UGx05dkdefe+jQJpzV8pyN8Js/GzkX9vSEevDqlfPWtYN5HL5yCttYp2Ln9edCECLemxHbjJ06rEszoKuNfQAF5lDu+RZ7a/5XLuUiWLInr+0qaL/wSOm2rEjJbhFNgdppzw+O0nd29XS18SOxbFXupASrxaAy91H61Na6UeuO5uVrJWRhrGl9D4og2vn5nazEPnpZ45jOihUoTHJs2j243JOtMh8wpi8bUlNWxVhwgDXe8TLqSkBDEPpHhF6g17/Uig5zNpDuhW76RMK6mTjcBbJYCZ1/JFeQ175wdjhgEWD9h4oUMdRRMd8UQ8RxyWo/A== 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=V67v6A0PVUZdKmk3jdF02XhzE70u4q7SzVSEnuhVTYs=; b=lv6IFqozjkSwICl8j+8rEK8wRDDCXGmNLhwD+yZ7WQFVSa4tZOnX0mKhqR5Wm971QMP/SkTm2petDAl++T74ykh8Y2/F0STWoAvxKR35wCfND9jZmvN7B0+4dCJfNbS0ov3UxFpbzSOYzbnxyBmcI/kgxSuy6UWdMfA8BYLXq5ICsYkj/mO9xzBcRU33pqHFYfifUmy3Pfic+0G5S1e5pyIVj1itVTA0A4Pl1Wk0RiKzBiAjnyU0Z5fwA5Qz1GM4CqMyagGwJtAv857FyAbxb/6JXuZSBCvtsm42PzL+YxY8YKWcRPD66denb2qQ/EGhSiMa3fQ5Eokep3NuszIMjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=renesas.com; dmarc=pass action=none header.from=renesas.com; dkim=pass header.d=renesas.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesas.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V67v6A0PVUZdKmk3jdF02XhzE70u4q7SzVSEnuhVTYs=; b=KEGwcuYYjpNE+pSQBckzgwnREe5HwGgCN+Pzm9sVyZbIfMQBYEzSx2jH1SsGDGiTQs/oT+v36MCh94hfZJ1BZeYlZ4IekopSVKnHP0qLhdopSqOnQnOmqIpQwKP5pHFrP1tgg+yfI0/awpuFvHF4Cg3QI8Pwgx22XvKKAZWJJHA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=renesas.com; Received: from OS3PR01MB8426.jpnprd01.prod.outlook.com (2603:1096:604:194::10) by TY3PR01MB11572.jpnprd01.prod.outlook.com (2603:1096:400:371::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.35; Wed, 4 Oct 2023 08:07:42 +0000 Received: from OS3PR01MB8426.jpnprd01.prod.outlook.com ([fe80::d2a3:45df:a180:595c]) by OS3PR01MB8426.jpnprd01.prod.outlook.com ([fe80::d2a3:45df:a180:595c%6]) with mapi id 15.20.6838.033; Wed, 4 Oct 2023 08:07:42 +0000 Message-ID: <87h6n6g69d.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 1/2] ASoC: soc-pcm.c: fixup validation check of multi CPU/Codec on soc_get_playback_capture() User-Agent: Wanderlust/2.15.9 Emacs/27.1 Mule/6.0 To: Mark Brown Cc: Linux-ALSA , Pierre-Louis Bossart In-Reply-To: <87il7mg69z.wl-kuninori.morimoto.gx@renesas.com> References: <87il7mg69z.wl-kuninori.morimoto.gx@renesas.com> Date: Wed, 4 Oct 2023 08:07:42 +0000 X-ClientProxiedBy: TYCPR01CA0090.jpnprd01.prod.outlook.com (2603:1096:405:3::30) To OS3PR01MB8426.jpnprd01.prod.outlook.com (2603:1096:604:194::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS3PR01MB8426:EE_|TY3PR01MB11572:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f310842-34fe-4ff1-4833-08dbc4b0fc03 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yVMnadMUMOwaJHb4xPWcVOR5jx8+z7rFdhPgigcIKPFnsNKPGWvnM/BXhekEyOcu+rQl7DHC0pG49Ks7mCjXuSQa08YWv6bAXSVrFv977m/dYWeBa7lK1b/Q/TBfGdqUwzIV44+TrmVRRv/o2O9nyyROckmsDcNkU5KLPGQrCBSPtGNMbSdGwAZufpkGmRnm3uWG7e4hBY0DuO4rQYJqau8gzD0hQrJv79p3wrZHS3mCt4JQE1Q3XHuB+JthU3eGZq3cD3QgEqnS5yTBUNScIX8TCkZaDNgpiLhnGb2MQq+TYMGEgOtgFbbY/90GAhu9M+iz4er0XDDOq+WC/VtkEBLkdN+LUbiKqNo6a/3LDMTemKUZ0D4a60goPZLCaI4NPPh0kil76wHXsPoEZlcshAWNDRVXSwArZDXEj3YMwVYZdSmwatErutnv/9xpAjPoDoQmxDoof7OhQRI4fe7riMcVZ8zuhWZnkavvb1aNm4e7PRy2oV+5Px9vYlw1SqAQrgB6sWhlRtj9sEhhIijC2Rrot3rTuxn7YArODYCEQsid07nlzt124K7YdshqCSUH9CU2eJ/Urk9KX8kNEIUfDvTGvMM52LP0dKNLpYsn+AM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS3PR01MB8426.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(136003)(376002)(366004)(396003)(346002)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(26005)(83380400001)(8936002)(8676002)(4326008)(966005)(52116002)(66946007)(66476007)(54906003)(6916009)(41300700001)(316002)(478600001)(6486002)(2616005)(6512007)(2906002)(66556008)(5660300002)(6506007)(36756003)(86362001)(38350700002)(38100700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XojZILLRoQ6XejF7BL3uDloan3aU4XlD/wAgmTRVv5WsWL7Ikd8wzmFIqkIpyQeipl92+za77IEwcqcaEZaXnKzzix4UsaBCy27Tt3ZRO2khvF4WgYaIyISUpo91ueMDpRii//O1y7nfqYoCp9l3UhLlxnu0Lyc+LN8tEg/dUWjopEkxFyx7tXgMSPoSv+vCiBifIME3nNzi2f/WK6Ivk5WM1urXkN/RIFsFOMPWl+P1ycWuJCSX+kIRbnFx39Fe6Kwwv94KxEy7LIC9uZCMG2KF81ACfcqVN8oU9po2yQJecuY42LZy2pNrRqrfnBfOVpiWPEVaX42MdiMYFMB4GGpEc5ikifbQCnUfDoaK5CPjwoaBlM2i00uvHoObqELB2aXGp8pyVfnbnquXczwLvbRYfJsiIwDFaT48ItJRNUm9gvu44mAuKWXmlqN3atR4gaiw/XojEUZtENRRzCQlEhCc0ft4EORli4Ntb4JKG0dobS3WksA8wxqaacIr6OHLzdmbVpdT59B9SR029U9KjBt0oBp+E4oPrs+VoQ9yYiNSJ1ANTPdoNlWA8CTs2XvnEOOUyAa1WCyylFkIvl2yGVAheGC9GA7X+QOwKwO2xmXwDIGD2IV2E4u32pBKdtDvXhNHHYH2IzxxzZVbvT9rgR6+X5PylG2WqO+hw+9YyqfXSergMNPnq0l0h+d5PV8XiLbUdDo0QuSGdTj2rDWZVZsLY/fLQo7u241McwJXZ/sWdoDcCpyfBU27In2W7c/nNOIHehsyGdxvC5ucCSmbYcQURgiSs9h1MvFcxuTC7l9z23d8tvFwcT/6E12JO44KpbbDwx9eGguNAf+OdT7GKvFWbK16aUsxfrnsjAq8DagfbysvJrN9YG+0Z2nrsLVlcggbyt66pv02DISuMDRGpQswWSOntP84LrBV3MkaBrybjjSRGVYmJtkgIB9+3vyEO4GxRXSDzrr8FRgqbkuhHeSUDsHSlMS+nV9iituyJQzAatR0tHkXCV7X696Nk+mi2gMTEuAZVQE0fuZtZR4UQUo0TG3Wdz0QHC2pGU61TkTq+7CJxT63KTKXnY2JbCyY4TixfJk7EYHWrazl7REHfIohmdbeTIKCM7atCV0zIRKre5hUbUXSCLDIxuTISmHTnPCvIPCD6XS7smWpI+Ioc1dRHee8Z70tPSnTFq+p6itwUrg6Q/65i0B+zCt44ped4TC399fCjL+9+6OMRG+1fdw7R6f9KH6mAQRwej5OIcGzhG5t/HvmX3T8UszVxZ08SP+QsTyWN9YbHUomPk2+BuPGcIwqcxBnjGMWBYu3dXVQ0hdLJTBO/AC5bhR+D1Fex57TX4UnymJsjTEVMMnuxrWFLjU3l5T8mlD4SQU900BcQZT36aju55rgUWaInluUVGt4nmdLV8fen/dBRCBtOEON+Sb66M9bgwhCeVJ9TwYEefJm6Zny/kRYYHPg1jmW3AhJSILQ67lEhdbAXYNbmsPStum7kQ6faIdgSeg9xrWUI/BdVcOyV+5mzlV7GElVBkCFbMzobOkC86lH1p5pN5AJDozeixTkvAAq55BAuOm5tnzIj0/xYR15U8ABQVc3WOY7Adm+NO+juD8Q0btNAUe59UScAC9m9neXcNyQrrM= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9f310842-34fe-4ff1-4833-08dbc4b0fc03 X-MS-Exchange-CrossTenant-AuthSource: OS3PR01MB8426.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2023 08:07:42.5953 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sQnukYMGTh104Y9WcMToljzJqqu5aqf6eeJ3Fmc0Rhcx+RDUbpL7T2AVI+mz6p05In63hR/B0Mm/4Qd14zIIezhaiZe5dp4gg/4/VucOq+0L5MVlPjshJ3gfc/Mx6NHd X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY3PR01MB11572 Message-ID-Hash: XJRYPV7LOFNI5JZQAK56AQ5GYKEN6JK6 X-Message-ID-Hash: XJRYPV7LOFNI5JZQAK56AQ5GYKEN6JK6 X-MailFrom: kuninori.morimoto.gx@renesas.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.8 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: Current soc_get_playback_capture() are checking validation of CPU/Codec like below static int soc_get_playback_capture(...) { ... ^ if (dai_link->dynamic || dai_link->no_pcm) { (X) ... v } else { ^ ... | for_each_rtd_codec_dais(rtd, i, codec_dai) { | ... | if (snd_soc_dai_stream_valid(codec_dai, ...) && | snd_soc_dai_stream_valid(cpu_dai, ...)) (Y)(a) has_playback = 1; | if (snd_soc_dai_stream_valid(codec_dai, ...) && | snd_soc_dai_stream_valid(cpu_dai, ..)) | (b) has_capture = 1; | } v } ... } (X) is for DPCM connection, (Y) is for Normal connection. In Normal connection (Y), it is handling CPU/Codec, and it will set has_playback/capture = 1 at (a)(b), but it means today is "at least one of CPU/Codec pair was valid" in multi CPU/Codec case. This is wrong, it should be handled when "all CPU/Codec are valid". This patch fixup it. Link: https://lore.kernel.org/r/87mt1ihhm3.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Kuninori Morimoto --- sound/soc/soc-pcm.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 8c168dc553f6..a45c0cf0fa14 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -2787,9 +2787,10 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, if (dai_link->dpcm_playback) { stream = SNDRV_PCM_STREAM_PLAYBACK; + has_playback = (dai_link->num_cpus > 0); for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - if (snd_soc_dai_stream_valid(cpu_dai, stream)) { - has_playback = 1; + if (!snd_soc_dai_stream_valid(cpu_dai, stream)) { + has_playback = 0; break; } } @@ -2803,9 +2804,10 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, if (dai_link->dpcm_capture) { stream = SNDRV_PCM_STREAM_CAPTURE; + has_capture = (dai_link->num_cpus > 0); for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - if (snd_soc_dai_stream_valid(cpu_dai, stream)) { - has_capture = 1; + if (!snd_soc_dai_stream_valid(cpu_dai, stream)) { + has_capture = 0; break; } } @@ -2824,6 +2826,8 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, int cpu_capture = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_CAPTURE); int cpu_playback = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_PLAYBACK); + has_playback = (dai_link->num_codecs > 0); + has_capture = (dai_link->num_codecs > 0); for_each_rtd_codec_dais(rtd, i, codec_dai) { if (dai_link->num_cpus == 1) { cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); @@ -2848,12 +2852,12 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, return -EINVAL; } - if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) && - snd_soc_dai_stream_valid(cpu_dai, cpu_playback)) - has_playback = 1; - if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) && - snd_soc_dai_stream_valid(cpu_dai, cpu_capture)) - has_capture = 1; + if (!(snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) && + snd_soc_dai_stream_valid(cpu_dai, cpu_playback))) + has_playback = 0; + if (!(snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) && + snd_soc_dai_stream_valid(cpu_dai, cpu_capture))) + has_capture = 0; } } From patchwork Wed Oct 4 08:07:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13408368 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 93002E8FDD9 for ; Wed, 4 Oct 2023 08:11:56 +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 774E8868; Wed, 4 Oct 2023 10:11:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 774E8868 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1696407114; bh=Zf2+cFkFXOgbFZUU7AwBoT4wHfy0KT1p6gfOvGSwnoY=; h=From:Subject:To:Cc:In-Reply-To:References:Date:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=XgSAqEOTB1P3rIKpXR1zDb7jEUMXafxD2ztEx6LEYyRXEYIsDhx/pgcpHqoznOOK7 FjUGNFzXNCMyMTR3Jx9u9DrJvC+lQhpWQdB0lgLTx6HyJOnZIripgMZWVn1+ku+9TL eqDiAVTHlqnqVqYS4o7N0Dl8amRnxAev8KVlQthU= Received: by alsa1.perex.cz (Postfix, from userid 50401) id CD020F80553; Wed, 4 Oct 2023 10:11:02 +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 8B9F8F80553; Wed, 4 Oct 2023 10:11:02 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B6316F8047D; Wed, 4 Oct 2023 10:08:00 +0200 (CEST) Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01on20706.outbound.protection.outlook.com [IPv6:2a01:111:f403:7010::706]) (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 1291CF80166 for ; Wed, 4 Oct 2023 10:07:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1291CF80166 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=renesas.com header.i=@renesas.com header.a=rsa-sha256 header.s=selector1 header.b=b0VtfihV ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mth0ytlGMoK4sI4NBeKM36KVgO94cce0Dx7VGNbq1B91CQA8dlxgavsRQFZOAxuzBp0BKzqkKy3ZE6D76ih4DgXWzkSIyMTxROh/GWrNZf7Bz5jQlS5XfKg+/uvbC3D2+iRmDOwCUgmz7oINOXnJxJYeQA/xCMHySf4lEYgMhzrvOQCspT2jVm+KjZ+nila4AuEf8cVI29fRzJti2FBcococoK1mRDXlaiHDxm4f0teJ9cvPzLlQpACNrc0wFyfI+zROdGOeXWrwt87XuiGJVCBNZoqz4bv8EbUCkeRRk2/D5GRXn4095NB0T4PhaUV+syLZNJurKfUo/BjBovdGfQ== 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=2qQj+kLX/PTfQn/+FswTVapAvIm1/Ezze7b79gKjnp4=; b=nkcdBpAqhqEO24ZEEQouWu/z9yFQP90fJQf3aDeqHr9z38+T6atyFibKWpL4ju7/+fQUgbsILYRxNje6xnnLP6ykF6JEAjom2ExCYip8y/CHCu69TPTqOHp4LdYdVXCvb+dKc81JVxrSiDKqCngZxXC/g28dmIsfWwMKAGpRrPj3W2k/rlsdEawgSmfJqahvUpMAP3V7qhl7JdkE1AKwvvqZeIZAWNRIHHZ66vHZj4zMg3yAOsml1AhjKIONQc0TJMKh9Zzw/+ttxlearVwnZD9gFae+oWOA0qHyJGEbTXbUt563B6M07gtiJQ59RSL1wYfqBd/YhNR5ETG/+DcGew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=renesas.com; dmarc=pass action=none header.from=renesas.com; dkim=pass header.d=renesas.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesas.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2qQj+kLX/PTfQn/+FswTVapAvIm1/Ezze7b79gKjnp4=; b=b0VtfihVsm6WJKkQr+JaEJhRB3TWMvWX65hM+PMm7O+j/c2Om/YjTF/GlJdBuW13inR7xGZ4yhn+29n37u6vQeOEDs1AMuC6ro6KNeZ6Qui95EmlKbI4gW2nLDoo2c8qCmDkQtf5YrNi+gUgOhceO2QlmxefTE8nxGN4dPluwso= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=renesas.com; Received: from OS3PR01MB8426.jpnprd01.prod.outlook.com (2603:1096:604:194::10) by TY3PR01MB11572.jpnprd01.prod.outlook.com (2603:1096:400:371::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.35; Wed, 4 Oct 2023 08:07:48 +0000 Received: from OS3PR01MB8426.jpnprd01.prod.outlook.com ([fe80::d2a3:45df:a180:595c]) by OS3PR01MB8426.jpnprd01.prod.outlook.com ([fe80::d2a3:45df:a180:595c%6]) with mapi id 15.20.6838.033; Wed, 4 Oct 2023 08:07:48 +0000 Message-ID: <87fs2qg698.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 2/2] ASoC: soc-pcm.c: factorize CPU/Codec validation check on soc_get_playback_capture() User-Agent: Wanderlust/2.15.9 Emacs/27.1 Mule/6.0 To: Mark Brown Cc: Linux-ALSA , Pierre-Louis Bossart In-Reply-To: <87il7mg69z.wl-kuninori.morimoto.gx@renesas.com> References: <87il7mg69z.wl-kuninori.morimoto.gx@renesas.com> Date: Wed, 4 Oct 2023 08:07:48 +0000 X-ClientProxiedBy: TYCPR01CA0096.jpnprd01.prod.outlook.com (2603:1096:405:3::36) To OS3PR01MB8426.jpnprd01.prod.outlook.com (2603:1096:604:194::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS3PR01MB8426:EE_|TY3PR01MB11572:EE_ X-MS-Office365-Filtering-Correlation-Id: 410bb1c7-1677-4c68-30f2-08dbc4b0ff81 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XcK4DFVvTi6WpmChKe0mxurJIrBLqiU4k55Y0TmbxxmtkyYDUAiLn4D3Sb8MvTw8HUrBEURVxUKZ3yVXTJD41yAbYYhDFsV/4KHhtB0cfa6C8+ibFykMFI2bcpPRh75Ph3F4Oa2wvO7lVpZqTAhLeKHdjmhCYuU30ngT8usyjQFghlTbEO4eeZesgZKiFLPhD3o7Ua/L0wX14z8T6oVDqhtO+WkYXmrycZCKhpi0ixNGL5OREK/eWWYmBbb0+niV5kANo/MvLsjrF9YiDt2fV/PCzZ6IN5SRsDwFP8elSqD7XRs4wvCzXnaT10wEstm4t/yo5q1MVnQkd1MN6V2gByeqg33C8MGESqJ125cFBV5Ickf8iL7RKJYUWPLVBxzN5ip3DmIYR1vxfWJzojC00ZoJQ6HS8faHnM1bAxX7wdXqZF4UIyFhzJgWD0YehmiUejgu1vddGZRy8FuObrPoByKIH/j0oVohKrkMj0lrEzy9vUkYJl37dXcIT04mmxjM4P/nYyT6dqlcg8CNNCLkASoHEbC2sy7oEIXG7O7XHHoSFf4k5xfMFkf+QXbnVO1OX62apdGW87kx4mP55fCWtNa35AKt7ohMunBZBO2lEkKl+f0p97K3+W4BhTbpV+u2 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS3PR01MB8426.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(136003)(376002)(366004)(396003)(346002)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(26005)(83380400001)(8936002)(8676002)(4326008)(52116002)(66946007)(66476007)(54906003)(6916009)(41300700001)(316002)(478600001)(6486002)(2616005)(6512007)(2906002)(66556008)(5660300002)(6506007)(36756003)(86362001)(38350700002)(38100700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: i8OV5QV7IeVhzuqDyAYVoaEL6mcVXuB4GQrqvE5fGCuTUjw9BvCaIctek0D4RV5d2iRXFuJxYSGRXwHlvIXd4vOjCADVwRNCzDUdyn8yqPpYXKZn+cgP1wRyD+K/r3tvyfwhiVxHUu/Yok8i11PS22Kzbodpy+4n7/yEyoABt8HD0vldqULqbTz4gdLBa21/+OF3l7anNQBQoPJLkGnQ7agqNkWF4e4yFqMWEsE59unUyDPwmMTng4OJRqmy7Rx13EbV/96Rfo5bFCr4uRbJFqOH+5EhdQPG3V5nF7M7Tio+7CByEfke4sMyyRXJAS/mLtzK5NJsWQpDmIcQKjM/NC/71a/uGone7to3NmuLMw2lBdL0ygFZlx6sC6R6PyaReoSxMhm2FHgYmiTZT3AaQ6Aaq/7Em553m7XMCG4td2JC9/ALZd76vMlTEllpTiw8tcQKw3O0grSBDwSc6PVo1DTkCuiW1uVz6PUM4prkITooXU/0/pw+jh8kOy4ZXgBNyT1d5VJCfTjsVkEV82QrsftFE+VUf8yQP8n/HY+k2Iu8ws2cJhn3VQfucX/NR8EZ+P2cJ2invgMcOQ9bRDTErkRIRWbf00uuHXlHcp9ZuwbKMSVMXxU/bmadwW553uUGVxLi2cz41VVqpSjhP+VldSBzyzoyZ5yMbvUR5yFFEEYeGLZrwJhKwKkEiuoWJ4pIvdBeNtgjj+nvsITFuFIakI6maxpZbd9vxubcNw87cst9jiXevVp9QXuVarrJKFW/JazX2wbl+HB75ihDZInlRYvSb23Yg9wINmkHBUhL0V4ZYL5aFx2ek4I4YoR09ksmWVM6/OjTicf5SI6IK43v69QNQOqJU9neY0LbmROF6JEGdiUbIzJa2ajwqlbVSOVh2JIwVB9vhB5nUKwQEaAxazNXJUO7ylYAlGssMM2t/yTg7CinYW1s5IREm7NDHRmBcYDs40bydfdxAl5szjE3DSZifNPeWeBzwxRZJLa6wYsFHTaxf3ec87PpGHx+/buX0AZ7NNw2VUjHPtAK4iQTHYASmyKZGZaI/Mz0O9aW6c/qH26aU7Yu8KrKc2hPVPUdHmjFfK7oOmac7NfvNc/MY1/KhN0WV9KodXZKdx8MMBspUdhAjgMMIBkkCbaxz74S2XGPXCqZal9AnOkB8QMFbRFkp3mxBlPENVuKYBPJYbTeoRX3ymE3iSVpw13yecvZTirfs/+Xf2QVYws5HZcZH4BkzjWTXTCYbBX8w03JqVHPjC6TeyrcU7vKT86G8oerDv7V0iQCyoepab6nk8ECF/VzSwltnz66Ead+d84x+hDHjK2DE85pYQeoMDi5Q+FSbI5NwtaDZ89CUvpKCtT+XQRKLanrsRA9geNFfcrkPnYY1HcMvSoo0fnEM5/oTXPMk3hR6qyU0Hz0vyKmeDjWhny6+2KEyvUrCgm+b9dsJPFLWMesNfYtR6zUSKrda3MuDMevQUy8K2/KbBQlBMelrpGh2BPH8RGGLDG4u0d4p+l2zgvfwz2RmfLmlUj5o+1hmS1KWEqbDlX7obSgwxSVQ9K8aZOlIFgg6J77YAtnFcTbBB83TM3PvSo33S5h4EqgaEWkOrrLTgQZciwY7S8BulDopxKdjILzZgaBmAzQDDI= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 410bb1c7-1677-4c68-30f2-08dbc4b0ff81 X-MS-Exchange-CrossTenant-AuthSource: OS3PR01MB8426.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2023 08:07:48.4006 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lVmrsv78iA67hEUYXDjiGmeAOFA6AHnoaYvvt+SUMW99qTvb8VHMSh2o2KFYAUldLZzI377G19O7ronEDWMIb2ZSNY1QLI6nXZ+PnCFDRvf1IwyuqYYoXEw+65aTdxHT X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY3PR01MB11572 Message-ID-Hash: MSHPAW7S4CJSVQCX4GUHRZ3YY5RXMCMZ X-Message-ID-Hash: MSHPAW7S4CJSVQCX4GUHRZ3YY5RXMCMZ X-MailFrom: kuninori.morimoto.gx@renesas.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.8 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: Current soc_get_playback_capture() is checking CPU/Codec validation. But it is using different operation for each 1:N, N:N, N:M connections, thus it is very complex. Therefore, there was omission of check at 1:N, N:N, N:M connections. It was handles as "valid" eventhough it was just "at least one of CPU/Codec pair was valid", and off course it was wrong. It is fixed and handled as "valid" when "all CPUs and Codecs were valid" today. Because it checks all CPUs/Codecs today, we no longer need to think about CPU/Codec connection pair style. This patch cleanup CPU/Codec validation check. Signed-off-by: Kuninori Morimoto --- sound/soc/soc-pcm.c | 43 ++++++++++++++----------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index a45c0cf0fa14..1e7925b93689 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -2820,43 +2820,28 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, } } } else { - struct snd_soc_dai *codec_dai; + struct snd_soc_dai *dai; /* Adapt stream for codec2codec links */ int cpu_capture = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_CAPTURE); int cpu_playback = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_PLAYBACK); - has_playback = (dai_link->num_codecs > 0); - has_capture = (dai_link->num_codecs > 0); - for_each_rtd_codec_dais(rtd, i, codec_dai) { - if (dai_link->num_cpus == 1) { - cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); - } else if (dai_link->num_cpus == dai_link->num_codecs) { - cpu_dai = snd_soc_rtd_to_cpu(rtd, i); - } else if (rtd->dai_link->num_codecs > rtd->dai_link->num_cpus) { - int cpu_id; - - if (!rtd->dai_link->codec_ch_maps) { - dev_err(rtd->card->dev, "%s: no codec channel mapping table provided\n", - __func__); - return -EINVAL; - } + has_playback = + has_capture = (dai_link->num_cpus > 0 && dai_link->num_codecs > 0); - cpu_id = rtd->dai_link->codec_ch_maps[i].connected_cpu_id; - cpu_dai = snd_soc_rtd_to_cpu(rtd, cpu_id); - } else { - dev_err(rtd->card->dev, - "%s codec number %d < cpu number %d is not supported\n", - __func__, rtd->dai_link->num_codecs, - rtd->dai_link->num_cpus); - return -EINVAL; - } + /* CPU validation check */ + for_each_rtd_cpu_dais(rtd, i, dai) { + if (!snd_soc_dai_stream_valid(dai, cpu_playback)) + has_playback = 0; + if (!snd_soc_dai_stream_valid(dai, cpu_capture)) + has_capture = 0; + } - if (!(snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) && - snd_soc_dai_stream_valid(cpu_dai, cpu_playback))) + /* Codec validation check */ + for_each_rtd_codec_dais(rtd, i, dai) { + if (!snd_soc_dai_stream_valid(dai, SNDRV_PCM_STREAM_PLAYBACK)) has_playback = 0; - if (!(snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) && - snd_soc_dai_stream_valid(cpu_dai, cpu_capture))) + if (!snd_soc_dai_stream_valid(dai, SNDRV_PCM_STREAM_CAPTURE)) has_capture = 0; } }