From patchwork Tue Oct 15 00:56:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 835857 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 C854BD1815E for ; Tue, 15 Oct 2024 01:01:30 +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 02D2C741; Tue, 15 Oct 2024 03:01:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 02D2C741 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1728954089; 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=aDiaTyAtpcvVEGAbmmCY6BOQMpYK4Rt7gWOIod01bgfqM5a3cwJtufuNYU5f9jt0X h+XDIjPEIIWlNkE7z3SEK5m+Szez1St3QpT55SpdGt7gUaS8gzP+M+M3BvKlmjVrff +imUVO5+xdtqvW1mZQjQbZnkpUMEcJbDJO05xBZc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 18EA8F80C81; Tue, 15 Oct 2024 02:57:05 +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 AA88AF80C71; Tue, 15 Oct 2024 02:57:04 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 51414F80879; Tue, 15 Oct 2024 02:56:59 +0200 (CEST) Received: from TY3P286CU002.outbound.protection.outlook.com (mail-japaneastazlp170100001.outbound.protection.outlook.com [IPv6:2a01:111:f403:c405::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 C6414F80803 for ; Tue, 15 Oct 2024 02:56:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C6414F80803 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=pazxBHKu ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=t4WPk0fSUcWAgmpNC+BF27iMAs7TjITolSdi/ZztqXx+0uve94JXTP3hWufjOBQAvWJqmXrDn4Z/3ZveBBFMJpcvF5eaPhf9aunFSkU7676LLuIqO1YQqBUqk1gwGgN/ilQ3Gt2oTV+8Emo+a5EhDn/lb5oRxhARY2RH7fb6GHph1qserJaXxL1pvizY5hIyNrQuF6Gpv/HrzEvajaDNKpVHewjQWcw0YTDpVZpIElK13YO37MwLa1MHTnIvMZfLf8xVIi9Sp+MXu7ZcDXrM3IGY6LFusR7KqRE5fiUN7PmdVGD+cEZ6AhvypI6FMq0KVQ3Nqx4ckLRMPJ3t5mmySg== 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=Qy6/HSskDlSBJXUD+kr0xsSCjqz4Oz7Yfo1zER4UmjPdySd4NneRLmx3uvpqUTA+r8lN1S1+cfi72ZZWgkH+Rx9X0+giEGHu2mnpGG6wLV4IyOp9d2CzQFcm7dfAlsWtHaqe4mKfShM/kYJ/t791snvcDuCXb3roBerJfcDr8igWk28CgpYlV4zUY9U7vHtPXyWP022mWq6MuaGuAR1S2m+wm3M/ujBqUe/lWFrrP/t6k4Ecxx9NvSJyci8yr8e7ZbW9HaMhQK4MBmkr0+0hV9tPOHJUfQbyBM018Rt67asEtvgujZBYo8oSXVicr9itq0EGTuxky8V0aMsP5S3FIQ== 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=pazxBHKu9BxPhEZLdxQUqFt3fYsF5LNHmKA1inYIR7cozSTKiIwZIBBUTBsurdVEyvmC8nyy0PWNBPBmJs+qZN2v/sIlL/VXU7CfuS6OR/lHw57uVcZA97t1tVuRFMVWzvu486sQWik93Fcmm7RqcMNpJlnjHIdEfnEfZhzOy8o= 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 TYCPR01MB7121.jpnprd01.prod.outlook.com (2603:1096:400:c0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 00:56:51 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11%4]) with mapi id 15.20.8048.020; Tue, 15 Oct 2024 00:56:51 +0000 Message-ID: <875xpuqj3g.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v4 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: <87o73mqj5b.wl-kuninori.morimoto.gx@renesas.com> References: <87o73mqj5b.wl-kuninori.morimoto.gx@renesas.com> Date: Tue, 15 Oct 2024 00:56:51 +0000 X-ClientProxiedBy: TYWP286CA0033.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:262::18) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|TYCPR01MB7121:EE_ X-MS-Office365-Filtering-Correlation-Id: 544521f2-5acd-4290-6c69-08dcecb4417b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: P1xsf/y4Da5ijaCauR7uwNb31YCADiUPv0tjUr/9dBho4CiO2Vj5id9H0ve+v9RI1JjbXIUj/o5kL3EsgWOv3sAq9vEHopfW8buqeD4L7K9regz6eLRlWJlLF+MQy8xTGCmlSpR5wlFnGzaVq1V8hkRqoSVVvDgyY81u3rR72jbDRKlLXSvbm/N8iTfeIOY1LnCitoaYjEa76yRZmk1AfzopAiOHLLaMI1JS7DWX4LOQ+6Bu7bgIa3YkFFHZosorsYg7MLmvxaLis3/OTz9PX41CaOlDVAFhcZvF9VlA260iJX83kSwtpDpUg7fVtiNivI8Kh+EvDSF6zyrDT7E1Ruw86xDXXyn5pmRZegZ4ytEFnWFk4L10/VRhxYtdK/2wmXoJxEEuJS0Z9mmDdZoxnFjaYpXqG9ZorPDEX3dote57m2StYD0x7RYAKX7W/yy9yhuMYicUh3iJPrWWmQGYIkGFoUmSm5rfgGQOAgTHGsZgjhK411wM8hAYUkuYxtULKOJ1XafkG1RwU958w4ogjlHfSR9ZwogWYXACeW6BmOvmlLs1o5RTlKYJQLUiXZEcS+UkPVlvG/BxH69jcNqoaCsO7dItCAL+nO9Qc2rgCwhkyFjlx87/P7WMuWS+A2bQ5+XSnLSl9A5qtnLe7QuvA2cjBzloGDtekErs5e4cEI4pkn5OfmROf7k817u2V47/mRYRGPVKFlDiIo2VM0rVGDP0a3kVVFiSXXt2RD5Lgg6Ew//I8N9K8ITUgzkzaLupZUDT8YAYlXeO7buDcIRrrW62cLtFp0pwVthunfs1SzuTkzpNe9N/tWJmbqEWrKtNVbnIRHqHomLkb1NVVSa9ROZkrJEHDtmKEGFx9wbWS7GELM0LejcH7i2kW4LX5IvIeT3c1DUeGWvnkl79HeI0RAZBChwnhdGyXb9ki98wMRuP7YYAk3OfgWDsoU56x0ZAFCYyQh72Mbd7mpvmwnvtNnu89EZVuOEpePidBC1swOkYX/Gn2zGswwrLHeMvNcWCDyiDQnV9ttpOm9QgDotcoG25f0PvahlsHQ0oNYsdvzmgsNU1uRFUiAIQkfAboYzif0gA6/yXooi4fYq8yT/4pZVpcYZv/2ZsOSBojlbtxzqO4H9WLGJFnfHVIrJV2mctp1T8tv9etA/GuwFTwABbL+dRG/AW0vZyN3oWdwfkJ5ZOPEgb6VL0Fnq+Oz6Fa7ofpKkOv8N21lwCfY9Aj4IQzqiRZ8QLWTXbqxmUYSXR+R3HUqGALqQYdww0j6puSjKi8fSy43QPzcYRQNQZIos+J/csHGqaKGkS6glOF9tbvlKrOmgN006zJdrZ/ADesDR6j8YL7ObRiArO7D8tkD3yTw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TYCPR01MB10914.jpnprd01.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376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vwEX4LvDCkM/eq5SQ+hW58OskXh9dRyOGi8V5F0mBhgKSXKMTHL/LslK8wqzevwE2fLXsxtuhdATXTOBIn5vfbqPHt9FLXJ0rx+bheF4vlIwvhK+vRj7rouRqHZtparWx+lfHsaqN7sIDP3rGP1Q1ivLHZjph8gVaWM8JZcHJ5uoBbZQmNg4BHziEUyju5kyQvPg1CZGDQNXiFhfnSV9lRheEr8KKXPTrGyKqgRrfEv9dARx9N58quZwxMIxRci2C1uEG1YhWcZLAP75KZ6SA7xgmeH1Ka7ZhnvT9ZyWYguIXZAkndQHljzDMyHP90juB00OB6B1D3lIWaGRzJYGWEb1miptz0yzezWv7u+0azvv4lApO8ec/30v83w/owHR5kZVkYM1phZbMpqL+amPQ0uSErEKbO5ibyZ0+vi/K/y35Ou0M2V/juIzszhBgGUXFDEIwt7YUANKNlH8fUgsK1ZjP+aeQtoapcA2qhhbFSH5nRUqAxCflknjbFXi0DRfg/pA3GUBz6hUa+m2zcx2vdFZ5HM7Q3H9jy6r4YuTQVPSmc4M+GrJtp5RPfKTQXLgCBP/wrT351IAMOX4/gk4GpQ+54vL84cKV3BYNjQwC4iI49K58tGjn5nwr7TnyCYG5Y4IepRIJ4t8rA3nmOl/goPXmCZIhgq48= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 544521f2-5acd-4290-6c69-08dcecb4417b X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 00:56:51.7618 (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: eLTLtQhnFozZwuPOpkg0nMTTpZ9Lc9xXMdtV+qp/UFdiOBHF6hqW4dFZlCcyP/OpiqVOFeh17z7cYAS2+JTiFjy93l2HD385tmpzqPLE0d71WGTsee5OtwjOvZvmYjz+ X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYCPR01MB7121 Message-ID-Hash: XMRV527VEDUVLZRM3OCDBLA4Q3PMKFZY X-Message-ID-Hash: XMRV527VEDUVLZRM3OCDBLA4Q3PMKFZY 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)