From patchwork Mon Sep 30 02:14:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 831597 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 9B83CCF6498 for ; Mon, 30 Sep 2024 02:18:15 +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 D8552162B; Mon, 30 Sep 2024 04:18:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D8552162B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1727662693; bh=Vw2xYdXdckIo0v/pRr6zwYaapVl4vL3esBItTt93teM=; 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=RNYi39MDIxc6vxQ1Qb0zGq/j3lTCztNa8DHFqTqUrE0c5TUpKWoXnO7yO8HScAsOL adWq1uKUlCTpPjpG4Grknr45+oBmE8a8UWqUi1+nzQ3UzvE7+e/AX7JJ/ENByAJYNx d4J6uHltICRESHLP7jJBXpP10BQOExqg+764Iq7o= Received: by alsa1.perex.cz (Postfix, from userid 50401) id D9799F8080B; Mon, 30 Sep 2024 04:15:00 +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 DFB37F80854; Mon, 30 Sep 2024 04:14:59 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5B3A2F80806; Mon, 30 Sep 2024 04:14:54 +0200 (CEST) Received: from OS0P286CU010.outbound.protection.outlook.com (mail-japanwestazlp170110001.outbound.protection.outlook.com [IPv6:2a01:111:f403:c407::1]) (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 3B76BF805EE for ; Mon, 30 Sep 2024 04:14:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3B76BF805EE 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=XBxDYyHK ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fcq0C6M8a/SRGmgPavsxHJ/fWDhYN6mCe2ODm8hYN49m8yFIkHK6Bzwd3Bm/0tvHbH1cVz2iUBUMXC92mtQmKNTbhaG36qkllXUHf84o6pVstN4/nct9Tcn1I2J3DUvOZhhfoWUHJQ41FBnLXrP1urgLCHnWZM1uxCTyB7bZOAlXnWGDzlhnqm0cK9/+0E7Rc3bWsS/8+Jjz5j1JalSDo5cSQceFky/nyvSoE8RYq81Reb8XJ5zM2v/eKpzzkLGFkvzIW1sqbpLFYhknw4c6K92F5R/uG3jzM0ImmxRyzghq7wJSBIjwPc7Jatn7lmbzuVMo/7KMBoufnFiXQKjV8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=bOovbfK6vR/xOXcpsAN/tbbxAML/E0D1rQC/dk4nId0=; b=fAb9BoGwHiyfyfeae44Hm1tKGPTTr4dNdIX2T/1D9/kzhptkp4NEhxh241mRDejzkx9GwPrmjxNkHf8dS4izJOZR4X81SixCy0WWiqNERclpRNxLce9Sqh1/dyIaifYK+8IYI+oxt1wc/s2XY6PBhbr6yXKRZv8AQrUTzJVgrsieu3iZvv/ctSAKkKJoaPABAI6NIVe0WJEQWDbhcjU90Ru3yz5NbUioZ6ftujQc/Ok9lCzVjjYf7TTOq1wjT30U4Icz8kRMPqYrXeh+k3stoxYqmhJcTkgF6yKA0CaiCYTgaOw+0HncbrGzpmXd0Bs0nSXzuA7BqmCk+BFyHC7c7w== 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=bOovbfK6vR/xOXcpsAN/tbbxAML/E0D1rQC/dk4nId0=; b=XBxDYyHKbyqbY9psHRa06WSj8kGBDBdWqaRMDwWspHSbVnzmc+4hf2SfMr8bLs0AlKx7xQPGZOBVV/3UEYbdTocffHA7BOg5OY0G2YJdZOdgyk0ar8jyoALT13uVQRYR7hmwKqTpzC3WSNfKNCKbeiqvGD/U5sm4LBNs9z2wY9I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=renesas.com; Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) by OS3PR01MB5798.jpnprd01.prod.outlook.com (2603:1096:604:c3::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.26; Mon, 30 Sep 2024 02:14:47 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11%5]) with mapi id 15.20.8005.024; Mon, 30 Sep 2024 02:14:47 +0000 Message-ID: <878qv9lwfc.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v2 13/13] ASoC: soc-pcm: merge DPCM and non-DPCM validation check User-Agent: Wanderlust/2.15.9 Emacs/29.3 Mule/6.0 To: Mark Brown Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org In-Reply-To: <87r091lwhg.wl-kuninori.morimoto.gx@renesas.com> References: <87r091lwhg.wl-kuninori.morimoto.gx@renesas.com> Date: Mon, 30 Sep 2024 02:14:47 +0000 X-ClientProxiedBy: TYCP286CA0009.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:26c::11) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|OS3PR01MB5798:EE_ X-MS-Office365-Filtering-Correlation-Id: b9f06f06-7932-43f3-0091-08dce0f5a83e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|366016|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: vKAH6fG46PoMI/qQQqXIw6KLXSXp0PuQwSqRuaSw2qbpta/QohTxqedgHssDuqUVGdMoiDX9reNFBN+Y0I31gPAg6EoMVHxPkVkRMS0dDf/LgukE8Z0joE0Kic4VlkQ+9oX2BwU8jHwMtsK+yFdYpGkaM0Xcv7JxWna/2ko35FtG8mRe2vPmpkBdlUn5H2QOQD2dJF4D80JQ03LtvDs7he0LrTbDRpKLQtqdoxs6ERo76A1wFNwr1kqBj4k3nmidEOb747A58JfYuHp06e6HVheVieeK80bHwRIB3FhnIKQomECnRZumQ1XdLl0D/XSxYSZYm0BfEcGHUQe0PazSZqX9wUoCuCIqtAd1UHv1uqioqr1MrADDwHimCz8P03UBgulB5bSa/h7qUxzvGPLJ0lx94j0QyJ1vC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SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TYCPR01MB10914.jpnprd01.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014)(52116014)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gx2TcEaFQZNjoB4TfKEovps01+sKO4qYFmi7At3z4rdZg5HG6S0DDjX5iS6ZI+1qSgLmwpNrjx8LfYnhGQQ0YQfiLqVSb9+LBTtgUVgWrUjperiW/GfPvlOb5bOteKvC1Qyyv5JHs6u9YiSDT7TWfArr/8BGsw3RF2t3M+EfXIV9iKm5CMoIQQZP5xa1AiFJmkLo9WIH1IImogCx4k67cZlatS+CjiDdHcQKs7vzQT/w7KIdg83SlEQmX8YKrqvG81gkecG8UNT8Ppo0jCQpxrdMt8vKvRyJja9Ev8u8kt+TWRTTu4j5uEb1wUWcmLwei3wrgJX8UAbTpxK+uriHx+WYnJunWlelS/Ib9thbiRI12QaxJMUdu5Qkz+0qE+Ikb5i+aQw20CA1tKg45RinBNnY5E19YjAuTqHzTSUy9+bxTg2Hu4+YvngicbcfzmDgvgIApOxQJNAAXk0CxkswGL6ClJMTOAJbd95jDKdtJuDMhwI7nuGgvmX6oXd/kk868Y1euO2wWNCU3ZOKvDTkl0TWdDe1G0ZOZVhX4cWt/7zoenPWSKjr0D/1fvTYpC80nx0C81d6PjKaYpx2/vOW+jMOwhqeuXuImJBNsuTrUZEXxB3mg3XfcSqWH+EaI4y8bpY11vJLhQal55/rDLF/2EPhP4eqCkO4C7AUHVXnJQzPfj2IklZ4VW/iqfEGcre5b6rZ8LaC/Q9NgpP3QwLTKCVTj9hye2Xs0DWE4LmE/hM3EvxD1z+94XGgkPOMGcx2lwYfKgqSwxPrXaAmjhL+NNDJfPFVd6dTOvuTZ7pM8kfwep++nGdf/E45N0GghcyPyh+cOR4H2S1Xl+klg+LSRfhhoWjY3VtfCRfL1XQq0xh0r6yULhV35X9frCOU1YUNKnXh9KNFboEtE87sMsQmrcsAFx3MhAcU55nfERhl/+NZNnL6BV9hgy2xVqhn0BT+Xr7KciizqlfGdnOdJglDfrU0hX7YgI59OzhBFSNwIWyF8texXLiglIYZ9TRpaOpEDPkou0whWuPHTYfzaV6+57WNiQRDLBni+Pjl8Tb17VizLjpaao1tz4vIGuIN/ysTMvYykVqb5bnbeTJqwSlNTeJnf887MxpbxnBcWdRbWRzuW0As1Qm2/OMbhBwB51lVWQ5oGB+NbFp2v1mJG9S54o3jjnhoWEH5YLVAcvQXSb1Rvw7mWIxfGSwgpD57Zh4f2QGXM6CrtB9ktmVR2SMtck+NAAlvw/PeGAlxw8hKr3tlM0M+cDs/5ZAVqItICFAm+5hdbptUgCjvqtjJve7/FjKb1g/SzsUnp8JRjD89wgfWKpB/q8CmtfxECLi++6ycDUTI7C4MtfxwaBa1kYgqjhzhZ2d3L0VVM9VApSaNpy5j3M8LDBdHUzjgWyTmApg1Qm/MuBhm7grdvBMfI6EGTjW4hg+ruOrhHgtXpuHOPRJHGlBEadIQC4BZ3qLiaXTlSVmj1bg6Q3JWiHIkUFhMaddfsQ7ii7jLIDRyFCcrIl4hqLHGZL8Avhou9ZWiBe1bcKUrZrAW6teqLymyKMx80dVShqr9k7onEARi7hmdQqgyL25ANcfwv4ZVdnswB6xtVmtNbSQhp1RO/QdkyUPESqHLHNokDl1nCwjsktqcYpo= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: b9f06f06-7932-43f3-0091-08dce0f5a83e X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2024 02:14:47.4861 (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: 3sggcjDT8NhjYuauZ4GKDmslE5ZbgWdrt42dVjXx8uPrWVNmFm/N1C93cht8lY2Jgr2NGILnbtGuz7DUP0ckIXVLqamHceYI3Yoc0/IscqtzUPlY+/z/qsF2wfk4QLEk X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3PR01MB5798 Message-ID-Hash: 3JIINAIPK3H5G5ODA6QPLQEDKA7HACHM X-Message-ID-Hash: 3JIINAIPK3H5G5ODA6QPLQEDKA7HACHM 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.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: DPCM and non-DPCM validation check are very similar. The big difference is that DPCM doesn't check Codec validation. This is historical reason. It should be checked, but it breaks existing driver/behavior. Anyway, if we uses dummy DAI as Codec when DPCM case, there is no difference between DPCM and non-DPCM. Let's merge these. Signed-off-by: Kuninori Morimoto --- sound/soc/soc-pcm.c | 62 +++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 27810f6f86302..76cfb6b115445 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -2838,7 +2838,11 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, { struct snd_soc_dai_link *dai_link = rtd->dai_link; struct snd_soc_dai *cpu_dai; + struct snd_soc_dai *codec_dai; struct snd_soc_dai_link_ch_map *ch_maps; + struct snd_soc_dai *dummy_dai = snd_soc_find_dai(&snd_soc_dummy_dlc); + int cpu_capture; + int cpu_playback; int has_playback = 0; int has_capture = 0; int i; @@ -2848,40 +2852,38 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, return -EINVAL; } - if (dai_link->dynamic || dai_link->no_pcm) { - - for_each_rtd_ch_maps(rtd, i, ch_maps) { - cpu_dai = snd_soc_rtd_to_cpu(rtd, ch_maps->cpu); - - if (snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_PLAYBACK)) - has_playback = 1; - - if (snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_CAPTURE)) - has_capture = 1; - } - - } else { - struct snd_soc_dai *codec_dai; + /* Adapt stream for codec2codec links */ + cpu_capture = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_CAPTURE); + cpu_playback = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_PLAYBACK); - /* 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); + /* + * see + * soc.h :: [dai_link->ch_maps Image sample] + */ + for_each_rtd_ch_maps(rtd, i, ch_maps) { + cpu_dai = snd_soc_rtd_to_cpu(rtd, ch_maps->cpu); + codec_dai = snd_soc_rtd_to_codec(rtd, ch_maps->codec); /* - * see - * soc.h :: [dai_link->ch_maps Image sample] + * FIXME + * + * DPCM Codec has been no checked before. + * It should be checked, but it breaks compatibility. + * + * For example there is a case that CPU have loopback capabilities which is used + * for tests on boards where the Codec has no capture capabilities. In this case, + * Codec capture validation check will be fail, but system should allow capture + * capabilities. We have no solution for it today. */ - for_each_rtd_ch_maps(rtd, i, ch_maps) { - cpu_dai = snd_soc_rtd_to_cpu(rtd, ch_maps->cpu); - codec_dai = snd_soc_rtd_to_codec(rtd, ch_maps->codec); - - 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 (dai_link->dynamic || dai_link->no_pcm) + codec_dai = dummy_dai; + + 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 (dai_link->playback_only)