From patchwork Thu Oct 24 01:29:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 838125 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 BEDDED0BB4C for ; Thu, 24 Oct 2024 01:31:51 +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 27D57209; Thu, 24 Oct 2024 03:31:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 27D57209 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1729733510; bh=hWZDDc+K/kdwffOnLdmbNgnm+RizNKlSGc3PBMvyg/g=; h=From:To:In-Reply-To:References:Subject:Date:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From; b=OkiLvnVNrsGRHJ6cfMsKTdkhmISURLzQBGH22TdBuWqR5E6YCkqR8WRHK0m6/KVIA 2tM+bKO7WxlQA3U/7xs6ayf8enQI1FKigRG6dssaQzP58/T1eTX/htjFkrcOeuO6JB ukJLFmV04hm1bd1ChLg5ISIOOcqieUthaOa24rLw= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 63025F8065B; Thu, 24 Oct 2024 03:30:23 +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 734F7F8067C; Thu, 24 Oct 2024 03:30:23 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 633A5F805FB; Thu, 24 Oct 2024 03:30:03 +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 19EE1F805FB for ; Thu, 24 Oct 2024 03:29:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 19EE1F805FB 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=EIuhz51Y ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iERxb42PB0Fuq/g3UsO33Rw5fUrCdLKZ7WQXR2wmeWytsEg04XJQSnIYwB1DE0FA5M/Zpg/AbAqKEqUBfvQcrTg2VALfkQVTX/0SMNkPa+tPsj7QqEofk5mSDUKSvGUQdx3fbqksyp+sjh5NWiycl9m5pUDuSq0cJqCejoiQB1sbn9is+JvQ5fGp3nXiq5EMS76zK5Cm4wKwpWP8YxoFr5v0i6XAyrGl/RHOebLfUHmPQw1iHfkDFAEaqzZUCTZyP2l6tAhImmeDIMYbIx6p/pKKDGLmBmOTCrh+a/3t53uctZDNuScseWVchCz/5efui75jeOjUPOugPZ0ksDsTgw== 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=VmZkwuleJoNuag2OU5otDRqER2R1E3uHWvzEwJOZBq0=; b=aXftLuteqB9NYpsuUoRhohshrnYPXgLTZrHvp+zqQA6SP3DVJdfr47/1SCFOEgb/p2I9qT0l73iM9t0BntD6gUueXGT1XROYzJaiY5jqy07/8gvoTE8WGAqPgwm8r1V+qXkX/FVVuRd6sOFKCwBKFa3ZJ7bxXnGo6/NHcceXuiXsz/SsI2spdO77GEOR+qPlAPDQXV6rIGJIVZT8DK85OH7QhUvnjYkMLJuIrgJg1WvMz0qQ6vXy/yzpFQN/xwwXeRc7xnWe/ySdNMihyFmj14lI7W3Uy7UKJF/A/MfJ5i6vrmR3yWimkcn6wyxy883Cz1HVR6Mw1GlxzY+2uXoBkQ== 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=VmZkwuleJoNuag2OU5otDRqER2R1E3uHWvzEwJOZBq0=; b=EIuhz51YBQTrg3QhRh8HgUFU3ABWQVZ5IrXEZLJ9i/KvzOoQ3YIHrbIMcu8efYUOYOAt4qBDrZHYImxMtKu0RC4c0zKfrcWQICuqKdglbD4mWWH4Jbnto7obi+mnr1TBATjrJc1WkyQ08m8JFkt94VNex53f3zxJLw+80SS+kSg= 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 TYCPR01MB12111.jpnprd01.prod.outlook.com (2603:1096:400:43d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16; Thu, 24 Oct 2024 01:29:52 +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.8093.014; Thu, 24 Oct 2024 01:29:52 +0000 Message-ID: <87r086b84w.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto To: Jaroslav Kysela , Jerome Brunet , Kevin Hilman , Lad Prabhakar , Liam Girdwood , Mark Brown , Neil Armstrong , Sascha Hauer , Shawn Guo , Shengjiu Wang , Takashi Iwai , Vinod Koul , Xiubo Li , alsa-devel@alsa-project.org, imx@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-sound@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, patches@opensource.cirrus.com In-Reply-To: <871q06cmsl.wl-kuninori.morimoto.gx@renesas.com> References: <871q06cmsl.wl-kuninori.morimoto.gx@renesas.com> Subject: [PATCH 7/8] ASoC: soc-core: do rtd->id trick at snd_soc_add_pcm_runtime() User-Agent: Wanderlust/2.15.9 Emacs/29.3 Mule/6.0 Date: Thu, 24 Oct 2024 01:29:52 +0000 X-ClientProxiedBy: TYXPR01CA0052.jpnprd01.prod.outlook.com (2603:1096:403:a::22) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|TYCPR01MB12111:EE_ X-MS-Office365-Filtering-Correlation-Id: 56c07a78-fed2-4c21-772b-08dcf3cb5bd7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|52116014|376014|366016|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: sWMo1pOc7Uy+Oig1HHplNBTrQ+tqf5H2nyozbM+M/XU9vaEfw2o0ri9tvH29E18hgM5gwMGUbGKfp5Jh0hQbDlgf49Z1ZXFPOzogD9ThTxuCy66Wt4EehdRRcRKQnCSCH0iYefIsLqBqxzDB9iGh+xNn8Qxb4CQMIZ23+QVkcjVx6VxTbMUOc1nA7rVoaIbOBFS8Zb8BxH+bx+trvKoVbB0Bo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lBlG2wl+gKyz2I++RabTnagIm+x+Vb5gAmYnFkQabnv1PmDx6yoU42f7k7NwTQ5/PlC4x56usrZWudOvsmqGKuqJ2dyt1uaRTrs 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)(7416014)(52116014)(376014)(366016)(1800799024)(38350700014)(921020); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rK41qo+/5J6faqirKyTcAsXSOWpajz62zM2yWdzYhN+m76L6wxGscuhomoqgaEtalpIr2SrYUDmCpWOFmOOucpQRe0uOibmq+G8NYrPxOKu6ySun1FdpgpKdd6Oi0zrmmMoQFq2HStlU13/Q5/atV3soDjDvcTU9/hs8mbX12waf5EbOOHjnPEOHAew7yP/5YiNpQX7Cn/saOal81FGTH0bo2oLSatt+2CXFv8vdT28Z6Nv9yLx1/MyD9JREjguLYCI0vg0H6iG12Zn0Cb8yNGftTY8A5G5X+XAPpx6FckHzq+GGwnUhfn2QcVoPQheybqImrSRgtB0kknAk4nrLLA4l8zBnWxebSgUEjkkzO2YjBKWKA+5u7wXoNAArn3AXwLRg7gVF37koGVrZqjf5qBzTVGx0lCKEuAz0w2gdavdX8rL1ojpAcNorzuZby4OtINoJ9VNu4/B3mAVa9QUoiLeqSyYtbf3m8pOh2ZX7ukGYkkujTaPmPGErx9c0UBb7vMAHhrKyrxy9LiYDwEsE8cQHqWv4xNsqTlyLFsKcTn9qXjY47MhfFHLoHTAcYdyTcXoYuegG6u4x0CTwG9/OnRiFIMkWCYgKl7godgxuUoh1qgfNZzsf1Nk24m2vCSQup80jZQSeXR7YXFUlJ3J8A+eMcemSd1xzOq5GvDqHKGQNy9cAd/2PbvXlQMVt2rSgbdv6+GoZeb/fSSLHh1Qjex8uDR4ZuQCf796I3BaaVnsgoAXDZw49P9oR1A6JuWxthWTa74VLmw8nKpBUKzEf7X/4xYLOa/pzIEYPHG+dggwWT0DiqP8UBLwxVu1M8A9SrcsV6DexuomFlPHIdbmMw1M0w+hEEJXzc6PGnLV8KnGfxMwxfU+qnHz4Wb16pRNyAGsdl0BlmIWT4IO0Ndj2/WaKDCs+Ny0RsEVHSm24JBgCc9UjcYB1HK5JTsBXvwABbGO6aP5DnVt0cwvF3JLnmvI0VjoGBeDsOjK9dCC3quJcsl1YfSCdgPx2ShANztuJwRRXLLGVKHtGQWCm2rYtyj2icrn516qUXidbt0S5cmwnRxO50WiIlOLslsXIzrPhIvyU5YhhX/zk4Ojj/JDAXeahWXth/svJZShHX4O+oUyWt7or2S8KxfOH77j9C98hVIL/hUThqKuiZLYuJRty6+n7s+m4c2ypkTsUttn7wLG3DYOLXdjI9mO/oMzWhzr0A2UZmnL4AaVfoVouT3Q3Pd7xA0xFAaaUylN3Jud7oYSoHHQDr/AQW74jAqG9WlYqa2giNycdiZxX83m+ks31SMfk2SmZRKZka01iBOAk5twgJncyogO9sKR0RI2CIDgXwgeXopUO7FxhAsvmPeJ0SAfkBSOdj/jaaa5+WCLZ0qK0nXCEoAPTA6cq2xkw+XDrjR1b4UkITmcmq7plDzt+MwxvFyC19r5eXWki070PLUvOjMREVFkopfSgmtuZLD8l/OxCZNa07j1Y3zVdGe5U+YNsz9AqWrTyfHH0fNzdF42vU0eOTpS7wyslwaXlsL9a3NAbi4WZVlHXoTqUH+DV66nlFynztfyxwaB+Mn/yHsGI0TI5CLxvgOlPbj/mt+eJq98cBZQTidA+eIm4nlg5yw78MXgdvT8k0ESpTj4WsMI= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 56c07a78-fed2-4c21-772b-08dcf3cb5bd7 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2024 01:29:52.5344 (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: +VZttcix0XA87LAGsDaf5Z8WXZUNuGK0OoIhdIVqbbJs/fPTXV2d4vtuE/RePVyc9IWQOVk9HI1yW2w8loRkfSiI2Yzc3Yk5DEsFCj2LIV+RN6k+bUnBF5iIoV83ZSjh X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYCPR01MB12111 Message-ID-Hash: M4T5FZCF7GNLMKJVVN6ZQ4FWWMQ2XAGD X-Message-ID-Hash: M4T5FZCF7GNLMKJVVN6ZQ4FWWMQ2XAGD 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: qcom/qdsp6 want to use irregular rtd->id because of its topology. Current code is calculating it at soc_init_pcm_runtime() which calls soc_new_pcm(), and it doesn't save it to rtd->id. Let's calculate and save it to rtd at snd_soc_add_pcm_runtime() which create rtd and connect related components. But, this feature should be implemented by using "dai_link" instead of "component". Add FIXME as comment. Signed-off-by: Kuninori Morimoto --- sound/soc/soc-core.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 233c91e60f0cb..4f0bfe73fe15e 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1166,7 +1166,7 @@ static int snd_soc_add_pcm_runtime(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai_link_component *codec, *platform, *cpu; struct snd_soc_component *component; - int i, ret; + int i, id, ret; lockdep_assert_held(&client_mutex); @@ -1225,6 +1225,28 @@ static int snd_soc_add_pcm_runtime(struct snd_soc_card *card, } } + /* + * Most drivers will register their PCMs using DAI link ordering but + * topology based drivers can use the DAI link id field to set PCM + * device number and then use rtd + a base offset of the BEs. + * + * FIXME + * + * This should be implemented by using "dai_link" feature instead of + * "component" feature. + */ + id = rtd->id; + for_each_rtd_components(rtd, i, component) { + if (!component->driver->use_dai_pcm_id) + continue; + + if (rtd->dai_link->no_pcm) + id += component->driver->be_pcm_base; + else + id = rtd->dai_link->id; + } + rtd->id = id; + return 0; _err_defer: @@ -1457,8 +1479,7 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card, { struct snd_soc_dai_link *dai_link = rtd->dai_link; struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); - struct snd_soc_component *component; - int ret, id, i; + int ret, id; /* do machine specific initialization */ ret = snd_soc_link_init(rtd); @@ -1475,21 +1496,6 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card, id = rtd->id; - /* - * most drivers will register their PCMs using DAI link ordering but - * topology based drivers can use the DAI link id field to set PCM - * device number and then use rtd + a base offset of the BEs. - */ - for_each_rtd_components(rtd, i, component) { - if (!component->driver->use_dai_pcm_id) - continue; - - if (rtd->dai_link->no_pcm) - id += component->driver->be_pcm_base; - else - id = rtd->dai_link->id; - } - /* create compress_device if possible */ ret = snd_soc_dai_compress_new(cpu_dai, rtd, id); if (ret != -ENOTSUPP)