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+jh8kOy4ZXgBNyT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h4EqgaEWkOrrLTgQZciwY7S8BulDopxKdjILzZgaBmAzQDDI= 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; } }