From patchwork Wed Jun 19 01:14:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 11003167 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3696B6C5 for ; Wed, 19 Jun 2019 01:28:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2374828A12 for ; Wed, 19 Jun 2019 01:28:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 154F528B22; Wed, 19 Jun 2019 01:28:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 442ED28B21 for ; Wed, 19 Jun 2019 01:28:33 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A255116C1; Wed, 19 Jun 2019 03:27:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A255116C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560907711; bh=To/JRZcd0eWCmetQ/L+YRxxiQtTLW6X8MXqK5Q4UPgc=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=HH+IcQCqt/soV6xKRGqHUBQqwOuB3XJDwK7geF91Cch+AQKcDd2HNjg1rGf4ikfPz KaJHwRIkd+bQGTqyHLtl5ZtSGzCCUw51jPdQ63A8Pctcx+WUuHY5+f5MT+TxRYOLiA j/bmKxX/Yntv4BmFhSZDMP7Jlx9YnkqKzxLkm6AI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 89623F8975F; Wed, 19 Jun 2019 03:25:46 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id E2884F80C87; Wed, 19 Jun 2019 03:23:10 +0200 (CEST) Received: from relmlie6.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id CAEE2F80C87 for ; Wed, 19 Jun 2019 03:14:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CAEE2F80C87 Date: 19 Jun 2019 10:14:07 +0900 X-IronPort-AV: E=Sophos;i="5.62,391,1554735600"; d="scan'208";a="18803060" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 19 Jun 2019 10:14:07 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 809B64113AE4; Wed, 19 Jun 2019 10:14:07 +0900 (JST) Message-ID: <875zp2wf8h.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto User-Agent: Wanderlust/2.15.9 Emacs/24.5 Mule/6.0 To: Mark Brown In-Reply-To: <877e9iwf9f.wl-kuninori.morimoto.gx@renesas.com> References: <877e9iwf9f.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Linux-ALSA Subject: [alsa-devel] [PATCH resend 01/47] ASoC: soc-core: allow no Platform on dai_link X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto dai_link is used to selecting Component (= CPU/Codec/Platform) and DAI (= CPU/Codec). And selected CPU/Codec/Platform components are *listed* on Card. Many drivers don't need special Platform component, but was mandatory at legacy style ALSA SoC. Thus, there is this kind of settings on many drivers. dai_link->platform_of_node = dai_link->cpu_of_node; In this case, soc_bind_dai_link() will pick-up "CPU component" as "Platform component", and try to add it to snd_soc_pcm_runtime. But it will be ignored, because it is already added when CPU bindings. Historically, this kind of "CPU component" is used/selected as "Platform" on many ALSA SoC drivers. OTOH, Dummy Platform will be selected automatically by ALSA SoC if driver doesn't have Platform settings. These indicates that there are 2 type of Platforms exist at current ALSA SoC if driver doesn't need special Platform. 1) use Dummy Platform as Platform component 2) use CPU component as Platform component ALSA SoC will call Dummy Platform callback function if it is using Dummy Platform, but it is completely pointless. Because it is the sound card which doesn't need special Platform. Thus, the behavior we request to ALSA SoC is selecting 2) automatically instead of 1) if sound card doesn't need special Platform. And, 2) means "do nothing" as above explain. These were needed at legacy style dai_link, but is no longer needed at modern style dai_link anymore. This patch allows "no Platform" settings on dai_link, and will do nothing for it if there was no platform settings. This is same as 2). By this patch, all drivers which is selecting "CPU component" as "Platform" can remove such settings. Signed-off-by: Kuninori Morimoto --- include/sound/soc.h | 2 +- sound/soc/soc-core.c | 64 +++++++++++++++++++++++++++------------------------- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 055e6d0..2ba3099 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -926,7 +926,7 @@ struct snd_soc_dai_link { /* * You MAY specify the link's platform/PCM/DMA driver, either by * device name, or by DT/OF node, but not both. Some forms of link - * do not need a platform. + * do not need a platform. In such case, platforms are not mandatory. */ struct snd_soc_dai_link_component *platforms; unsigned int num_platforms; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 2a408cc..699f538 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -788,6 +788,9 @@ static int snd_soc_is_matching_component( { struct device_node *component_of_node; + if (!dlc) + return 0; + component_of_node = soc_component_to_node(component); if (dlc->of_node && component_of_node != dlc->of_node) @@ -1051,20 +1054,12 @@ static void soc_remove_dai_links(struct snd_soc_card *card) } } -static struct snd_soc_dai_link_component dummy_link = COMP_DUMMY(); - static int soc_init_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *link) { int i; struct snd_soc_dai_link_component *codec; - /* default Platform */ - if (!link->platforms || !link->num_platforms) { - link->platforms = &dummy_link; - link->num_platforms = 1; - } - for_each_link_codecs(link, i, codec) { /* * Codec must be specified by 1 of name or OF node, @@ -1084,32 +1079,39 @@ static int soc_init_dai_link(struct snd_soc_card *card, } } - /* FIXME */ - if (link->num_platforms > 1) { - dev_err(card->dev, - "ASoC: multi platform is not yet supported %s\n", - link->name); - return -EINVAL; - } - /* - * Platform may be specified by either name or OF node, but - * can be left unspecified, and a dummy platform will be used. + * Platform may be specified by either name or OF node, + * or no Platform. + * + * FIXME + * + * We need multi-platform support */ - if (link->platforms->name && link->platforms->of_node) { - dev_err(card->dev, - "ASoC: Both platform name/of_node are set for %s\n", - link->name); - return -EINVAL; - } + if (link->num_platforms > 0) { - /* - * Defer card registartion if platform dai component is not added to - * component list. - */ - if ((link->platforms->of_node || link->platforms->name) && - !soc_find_component(link->platforms->of_node, link->platforms->name)) - return -EPROBE_DEFER; + if (link->num_platforms > 1) { + dev_err(card->dev, + "ASoC: multi platform is not yet supported %s\n", + link->name); + return -EINVAL; + } + + if (link->platforms->name && link->platforms->of_node) { + dev_err(card->dev, + "ASoC: Both platform name/of_node are set for %s\n", + link->name); + return -EINVAL; + } + + /* + * Defer card registartion if platform dai component is not + * added to component list. + */ + if ((link->platforms->of_node || link->platforms->name) && + !soc_find_component(link->platforms->of_node, + link->platforms->name)) + return -EPROBE_DEFER; + } /* FIXME */ if (link->num_cpus > 1) {