From patchwork Mon Jul 10 01:20:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13306148 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 91518EB64DC for ; Mon, 10 Jul 2023 01:22:14 +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 CCC96852; Mon, 10 Jul 2023 03:21:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CCC96852 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1688952131; bh=nCO2o29qqE/0eJl1+nTWL3SUNqwGghk3/QCngiCSbUg=; h=Date:From:Subject:To:Cc:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=fMDMe/JUasrnC6bf1KEcrr0kC4FOL/kyrMcQksdoFbg35B37YDV2yNLMQw0VHCebZ 65qkF3niFDibndMGxBkYHQJQJAownPMTal/FfTqwzmUIDLtwecA25YmyQKc4KGDnrN xN+EkI3CHlWTPIsbMjPQx6GsepstVBt4pkJ5VB0g= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 23952F80548; Mon, 10 Jul 2023 03:20:18 +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 BAE05F800E4; Mon, 10 Jul 2023 03:20:17 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 87671F805A8; Mon, 10 Jul 2023 03:20:13 +0200 (CEST) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id 9AC79F8057E for ; Mon, 10 Jul 2023 03:20:09 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9AC79F8057E Date: 10 Jul 2023 10:20:06 +0900 X-IronPort-AV: E=Sophos;i="6.01,193,1684767600"; d="scan'208";a="167840668" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 10 Jul 2023 10:20:06 +0900 Received: from venus.renesas.com (unknown [10.166.252.89]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 91A7740EF4B9; Mon, 10 Jul 2023 10:20:06 +0900 (JST) Message-ID: <87edlgo94p.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v2 06/15] ASoC: soc-core.c: add snd_soc_get_dai_via_args() User-Agent: Wanderlust/2.15.9 Emacs/27.1 Mule/6.0 To: Mark Brown , Cezary Rojewski , "Pierre-Louis Bossart" , =?iso-8859-2?q?=22Amadeusz_S=B3awi=F1ski=22?= Cc: Linux-ALSA In-Reply-To: <87mt04o96f.wl-kuninori.morimoto.gx@renesas.com> References: <87mt04o96f.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Message-ID-Hash: NPGIRYXNKYDDIQ72SAB6GPVQ65HAN7UI X-Message-ID-Hash: NPGIRYXNKYDDIQ72SAB6GPVQ65HAN7UI 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: To enable multi Component, Card driver need to get DAI via dai_args to identify it. This patch adds snd_soc_get_dai_via_args() for it. This is helper function for multi Component support. Signed-off-by: Kuninori Morimoto --- include/sound/soc.h | 1 + sound/soc/soc-core.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/sound/soc.h b/include/sound/soc.h index dda731795bd4..1b3c58fe14c4 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1336,6 +1336,7 @@ int snd_soc_add_pcm_runtimes(struct snd_soc_card *card, void snd_soc_remove_pcm_runtime(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd); +struct snd_soc_dai *snd_soc_get_dai_via_args(struct of_phandle_args *dai_args); struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component, struct snd_soc_dai_driver *dai_drv, bool legacy_dai_naming); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 8487a4c12753..22a065f4c908 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3446,6 +3446,24 @@ int snd_soc_of_get_dai_name(struct device_node *of_node, } EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_name); +struct snd_soc_dai *snd_soc_get_dai_via_args(struct of_phandle_args *dai_args) +{ + struct snd_soc_dai *dai; + struct snd_soc_component *component; + + mutex_lock(&client_mutex); + for_each_component(component) { + for_each_component_dais(component, dai) + if (snd_soc_is_match_dai_args(dai->driver->dai_args, dai_args)) + goto found; + } + dai = NULL; +found: + mutex_unlock(&client_mutex); + return dai; +} +EXPORT_SYMBOL_GPL(snd_soc_get_dai_via_args); + static void __snd_soc_of_put_component(struct snd_soc_dai_link_component *component) { if (component->of_node) {