From patchwork Sun Oct 20 23:59:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13843349 Received: from OS0P286CU011.outbound.protection.outlook.com (mail-japanwestazon11010003.outbound.protection.outlook.com [52.101.228.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9E5E198E63 for ; Sun, 20 Oct 2024 23:59:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.228.3 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729468794; cv=fail; b=NJruUduMruA6S9rqS2ELyRbn/azOYzS3tFxW8cqDElAcCHUvbP7hSihRSW2UzIqoMwUrWz9g7CP8VnKpU2nVOkx8ayizZiuL4IEGOSY3YrVod3ahleA4RbBJMmPlMpMbvD+62o7yBQISFMAgsWt7oeXWgAEkNVVVyEX43Td/Moc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729468794; c=relaxed/simple; bh=q3K47Ix06ztqHR2fT471Jy6zPSf5frK7N4iHFcqYa9I=; h=Message-ID:From:Subject:To:Cc:In-Reply-To:References:Content-Type: Date:MIME-Version; b=GZ3hKY3LCfVXBBdrDJ0eV0wB/SaN7JMsC2ewjfP8IJc9zSbP6yNOG1gO8u5vvp1nw++wKl6IQxQN1JHBlxIcyyL7BC4GCYwOwET4q8jwTUFgX6Q++7iTbKcXdM/DiXhc0arqOfGdb2/VSOBrxtrn/pO1bqyQAn8Jl61q+kfcqu4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; dkim=pass (1024-bit key) header.d=renesas.com header.i=@renesas.com header.b=e2uCXgPv; arc=fail smtp.client-ip=52.101.228.3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=renesas.com header.i=@renesas.com header.b="e2uCXgPv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QYE16JRcdnq2YJPJEWFQkjov/zUH2HwsgmTgEkUaPmr5n7E1T6Oi/XrpEFfsMFetcGRmZCL2mV+qneUETFhn4pRKBGiT3HnOYf2EL9f/P12xAz6GSvN1a+plL38C4KU5Sk/0UvdtxRmbY/lwAqHDR/GND53JtIZcoY6ek8riff4GgJkgeiRcaRGJJoUqHRLVX+zhn48xMKaikMwY8feJZGmL0s2sBozEB+DpXhuvRLEkfQXd8mGIlQ7QMbeHBDzOvx0gzI8J6iIaqpzR4vz4KENh5rTOahcJfAYu8ZLyu/J6o9N4uEPlcMk40yP4EHklJwiKKDpzzVzF97i5YC4tDQ== 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=OPcoVuxjb4OlUhRC7ptTQhVcWoYjTj1nqw2QrQKd1QU=; b=kqlDh7gm5L3IzQvLpc/gnByTDGv/PaGMLVw+YbElnDpiy8Q+B14Ih2lEb+kdMULsOip5T6kubhDo+N6ZPAyFLSxYQrPUjcNz6uyhJsYOq2MaBrrkxw5mc2twWlHIZ/Ie1pt+1u/xjA/QgE1jWZ5Ajcxy9PdTwB1bGFb+cRrewXBMPcqS9o0YYDZ25dLc1Mm3u0AqWdYo+b7mEHTGydCKFK7CAu3IaweZBHSltJBaAoEbdJR2LBTCtIhKeJtsy48LxP6jU+rjee+6dzPXMgsf6qnyXWB1o9Av8a49l32+qZ1jDN5secvuSEBL12GtR7ElhJ/Nwc1eAZd/UD/2vnwO4Q== 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=OPcoVuxjb4OlUhRC7ptTQhVcWoYjTj1nqw2QrQKd1QU=; b=e2uCXgPvKnCc5YkzzJ7bHFkXjxguHKBXGb2PbFCqXrHcsl8qfV1u915MwzKgX4Hgj02tKkO/8qffX4vn9WJ9Vl7Zz23Kd2r2YpocvYqf/JSvHbHVr0ZvPFRJoxK8jpXOje9Bqjo08MhKITXL2OCaLeuCgPpZ7Tb06pRSEJ3VJI4= 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 TYRPR01MB12916.jpnprd01.prod.outlook.com (2603:1096:405:1b4::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Sun, 20 Oct 2024 23:59:50 +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.8069.027; Sun, 20 Oct 2024 23:59:50 +0000 Message-ID: <8734kq9vgq.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v5 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: <87ldyi9vje.wl-kuninori.morimoto.gx@renesas.com> References: <87ldyi9vje.wl-kuninori.morimoto.gx@renesas.com> Date: Sun, 20 Oct 2024 23:59:49 +0000 X-ClientProxiedBy: TYCP286CA0098.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:2b4::19) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|TYRPR01MB12916:EE_ X-MS-Office365-Filtering-Correlation-Id: 917bd1ed-fb31-4ea5-359c-08dcf163486c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: 0Yh66Y0ji2GhU/gAIJOJ1YmMZZG2YsOTg1q9BbhcfaZGz7ZTbQLIUjyOnzbB4ylcPayqtB/0DbVPj4HYdkiE/2jreKceL8zYCuePaHPNOZK7LPToirAMz16qKOqXIPzdWhmnFcRSTRxDQgrTFip/byfj4iKfrMusEc0kJMJ5JEcwiUmob2VaBtpLcnn4xFbNGKa828acKSWYqpxE9G2iytBU7dm6iFJUkh06LsfLc+zArzUsfeh7sTWI/iI1IuG7RcYfWpIO9kF+y6t6L7fy6dkthGijDhPmttohRVRhYw/8BwtfVDH/qwHtue2FlfQWZPRplBJQBCEd1ZGX0/TtccYJXn0kTcXZKIpGjMZS/pCElGjKziJ3nO3FF/j3hB3leeq91vywxZmxc3B4vZhxE5EzHbjz8Fd3RkT/gnvBNcijmzEVi6uReLzMMQ02PeAwjoig1qHKMG3N5vxNlL7UaX/UeX50vCkwESQCfEiBdJpdZSsZ9kyk73y0xZz8DRbWi7NUtdqwcAjV4250IVsIjZjrn11SGOBfA9+pQTggpWPUzpJcStrH25KkP7b6d33qEBoJ5QmV6xu6Th11jUeAAgGP47JuBXt22c3kSuew8buRcFt08JgV9bKiLpZex4zxeDIK8kjTPVELVgCiE5wWd/SjA9Pz4onkcsR1eB+aLFlcClwS3a6QHMdxISKc/DTGkQxrwpL8SVNvMPJ3ix6RJmdCUyRYwOW6y6P34C/bwuTv/BSM0Lw41v4bd/LflOSITdsVn4Ut/2jKlNFSRS79hTMAWDJac7Ius9LL5FKEWgcdQjwa+hS4Jpspdj65GoukQETSRQ+FIUBfrGATVvkGWqSOGCXcN6khq5SRCMqaXQBigHJecdYj7fa5W4uMpyQhhB7jhxRKrRHZ0nIVRyogIr+3XENrUh9qYRRXB2yrqonyITJtkmjeLqlF7nbvWLIejvBK937lkZIcZLfFXJEGniAlk4SUfFSPrweV9gvZkXvwl8FgP0E7kOgNJ5MSmo76WLzRm0K8RkDlSq1LryBoQ5OUY2Qvg9Whdu3C3xcQ8IN7qUTKESd8xnR1B13RtkdUvPGgjEeHhEdy096TFBq/7I/C7K1XwcGkeKvATCvIUh9pv3S9AR4xofYvhyIUo4t3++LoXibVCmP7qOrl7ry2G+CJJ48blQie7U6fzlMroeimeQTfx99i06Z6uKpUqDU/HQGF134i5xC+GVfeiIiIdc/z814q9W0zkVM8XPymALeaCnsrRCcuseoKd/TJTQKy7ul5anRnkPczOoGf8yv0q5xtbAi6h9l8CQJoXW6A7mkMZJ/1H2oeQ5i13xO+b9O3vxHMm2WrF8SE4OL39hsZtZqUji+cfQ5DcCm5u3LqT3Y= 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)(1800799024)(52116014)(376014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WD4J+Rj8olK+b2rgzYPPZSwYZlRvHM3rMhxymNgCBXScgnbYVpKkV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O+1Mo54wL56VBPFqs7eIjFOhRK3bOC8RIdv0E7/pRl3pC2GNU43ubgSfYoF6c/Nrg41S+jbgyfpMWFamoiUG7ID1uTcUzkR+DYBpeiPWh4+/Zq0j0mxh+ZiqnOPaV46cIIxV35vt31+I9kK5tiXvCWILHFe9QGCy8dPCCojPSrD8O9ygLrgtHtkm5xKjzbTB52RREXQt9OOwdCSFIXPZody+uyvi3JR9uCFEmmrYII9GYqKYyVhoYqqSHiamJZLBeWpvcQvt2+5PdhA+TAfwzddjbr2IE8hoZmTMOvNXM5+HZBtJkNjfsX8VFl5FQcxYO13l4dU4xEV3CFENKme3dR2JNMTnEq29nV3H/YLw9iGQ/nmaE1UB91QOvNS6UlR2rELaTBWIThohQG5dQ3YSYC7B23clMl6cfgCfX3zLpdKEhHnauB/cTPofnRg/YlkOCZgADe1T+7kKpqx3hKu1KsjEvCQN8QidD0VyqvGtB9zVd9HK0Wtu4zqF8AkajovfCA= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 917bd1ed-fb31-4ea5-359c-08dcf163486c X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2024 23:59:49.9992 (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: 9V00BquKKYxVxX9mbVDc/7wy0+Yrm1R/9x5Xv27NKxwdQTIXW2DURQHYplmh+47xbCsJfWNbmNON4S7Yo2iXyEuvgJJrv5oinKyUvQlp7AkaZvxdlk67Q2YXXG5zViR7 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYRPR01MB12916 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 5142d1abbc7b0..678400e76e53b 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -2822,7 +2822,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; @@ -2832,40 +2836,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)