From patchwork Wed May 22 03:38:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10954743 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 A874F13AD for ; Wed, 22 May 2019 03:40:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93C2228A81 for ; Wed, 22 May 2019 03:40:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86A6228AAC; Wed, 22 May 2019 03:40:22 +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 6718928A81 for ; Wed, 22 May 2019 03:40:21 +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 A8D631677; Wed, 22 May 2019 05:39:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A8D631677 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1558496419; bh=troFFn57MUBXOLCa7j0idl47LLSCZhyn9oK2A2z2mXU=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=fxZbtbxEp7Gtv8Of+QkI73Y7mk3lWn6wocxBhpJCjBsKy/qdSpJFZ1bSkxrzsgpQY s7Sw3kMJdGS4PNylPWQvtUT6KMRKzujcqxgz0L8orK9EChjmgTtMDH/nFsA1SUky+P w21Bjpgmd728uCw92xB6QYrMhKZ0apO+KiXulcYM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 62220F89731; Wed, 22 May 2019 05:38:30 +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 3FFC1F89730; Wed, 22 May 2019 05:38:28 +0200 (CEST) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id EF068F8972D for ; Wed, 22 May 2019 05:38:22 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz EF068F8972D Date: 22 May 2019 12:38:20 +0900 X-IronPort-AV: E=Sophos;i="5.60,497,1549897200"; d="scan'208";a="16425064" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 22 May 2019 12:38:20 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 834A04009405; Wed, 22 May 2019 12:38:20 +0900 (JST) Message-ID: <87pnobp3y9.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: <87sgt7p3zo.wl-kuninori.morimoto.gx@renesas.com> References: <87sgt7p3zo.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 002/145] ASoC: simple-card: support snd_soc_dai_link_component style for cpu 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 ASoC supports modern style dai_link (= snd_soc_dai_link_component) for CPU. legacy style dai_link (= cpu_dai_name, cpu_name, cpu_of_node) are no longer needed. This patch switches to modern style. Signed-off-by: Kuninori Morimoto --- include/sound/simple_card_utils.h | 20 ++++++------------ sound/soc/generic/audio-graph-card.c | 30 +++++++-------------------- sound/soc/generic/simple-card-utils.c | 21 ++++++------------- sound/soc/generic/simple-card.c | 39 +++++++++++++---------------------- 4 files changed, 34 insertions(+), 76 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 3429888..954563e 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -42,6 +42,7 @@ struct asoc_simple_priv { struct simple_dai_props { struct asoc_simple_dai *cpu_dai; struct asoc_simple_dai *codec_dai; + struct snd_soc_dai_link_component cpus; /* single cpu */ struct snd_soc_dai_link_component codecs; /* single codec */ struct snd_soc_dai_link_component platforms; struct asoc_simple_data adata; @@ -80,16 +81,12 @@ int asoc_simple_parse_card_name(struct snd_soc_card *card, char *prefix); #define asoc_simple_parse_clk_cpu(dev, node, dai_link, simple_dai) \ - asoc_simple_parse_clk(dev, node, dai_link->cpu_of_node, simple_dai, \ - dai_link->cpu_dai_name, NULL) + asoc_simple_parse_clk(dev, node, simple_dai, dai_link->cpus) #define asoc_simple_parse_clk_codec(dev, node, dai_link, simple_dai) \ - asoc_simple_parse_clk(dev, node, dai_link->codec_of_node, simple_dai,\ - dai_link->codec_dai_name, dai_link->codecs) + asoc_simple_parse_clk(dev, node, simple_dai, dai_link->codecs) int asoc_simple_parse_clk(struct device *dev, struct device_node *node, - struct device_node *dai_of_node, struct asoc_simple_dai *simple_dai, - const char *dai_name, struct snd_soc_dai_link_component *dlc); int asoc_simple_startup(struct snd_pcm_substream *substream); void asoc_simple_shutdown(struct snd_pcm_substream *substream); @@ -100,16 +97,11 @@ int asoc_simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params); #define asoc_simple_parse_cpu(node, dai_link, is_single_link) \ - asoc_simple_parse_dai(node, NULL, \ - &dai_link->cpu_of_node, \ - &dai_link->cpu_dai_name, is_single_link) + asoc_simple_parse_dai(node, dai_link->cpus, is_single_link) #define asoc_simple_parse_codec(node, dai_link) \ - asoc_simple_parse_dai(node, dai_link->codecs, \ - &dai_link->codec_of_node, \ - &dai_link->codec_dai_name, NULL) + asoc_simple_parse_dai(node, dai_link->codecs, NULL) #define asoc_simple_parse_platform(node, dai_link) \ - asoc_simple_parse_dai(node, dai_link->platforms, \ - &dai_link->platform_of_node, NULL, NULL) + asoc_simple_parse_dai(node, dai_link->platforms, NULL) #define asoc_simple_parse_tdm(np, dai) \ snd_soc_of_parse_tdm_slot(np, &(dai)->tx_slot_mask, \ diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index ec7e673..e438011 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -111,29 +111,14 @@ static int graph_get_dai_id(struct device_node *ep) static int asoc_simple_parse_dai(struct device_node *ep, struct snd_soc_dai_link_component *dlc, - struct device_node **dai_of_node, - const char **dai_name, int *is_single_link) { struct device_node *node; struct of_phandle_args args; int ret; - /* - * Use snd_soc_dai_link_component instead of legacy style. - * It is only for codec, but cpu will be supported in the future. - * see - * soc-core.c :: snd_soc_init_multicodec() - */ - if (dlc) { - dai_name = &dlc->dai_name; - dai_of_node = &dlc->of_node; - } - if (!ep) return 0; - if (!dai_name) - return 0; node = of_graph_get_port_parent(ep); @@ -142,11 +127,11 @@ static int asoc_simple_parse_dai(struct device_node *ep, args.args[0] = graph_get_dai_id(ep); args.args_count = (of_graph_get_endpoint_count(node) > 1); - ret = snd_soc_get_dai_name(&args, dai_name); + ret = snd_soc_get_dai_name(&args, &dlc->dai_name); if (ret < 0) return ret; - *dai_of_node = node; + dlc->of_node = node; if (is_single_link) *is_single_link = of_graph_get_endpoint_count(node) == 1; @@ -207,6 +192,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, struct device_node *ports; struct device_node *node; struct asoc_simple_dai *dai; + struct snd_soc_dai_link_component *cpus = dai_link->cpus; struct snd_soc_dai_link_component *codecs = dai_link->codecs; int ret; @@ -251,7 +237,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, ret = asoc_simple_set_dailink_name(dev, dai_link, "fe.%s", - dai_link->cpu_dai_name); + cpus->dai_name); if (ret < 0) return ret; @@ -261,9 +247,9 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, struct snd_soc_codec_conf *cconf; /* FE is dummy */ - dai_link->cpu_of_node = NULL; - dai_link->cpu_dai_name = "snd-soc-dummy-dai"; - dai_link->cpu_name = "snd-soc-dummy"; + cpus->of_node = NULL; + cpus->dai_name = "snd-soc-dummy-dai"; + cpus->name = "snd-soc-dummy"; /* BE settings */ dai_link->no_pcm = 1; @@ -383,7 +369,7 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv, ret = asoc_simple_set_dailink_name(dev, dai_link, "%s-%s", - dai_link->cpu_dai_name, + dai_link->cpus->dai_name, dai_link->codecs->dai_name); if (ret < 0) return ret; diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index f4c6375..ac8678f 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -159,24 +159,13 @@ static void asoc_simple_clk_disable(struct asoc_simple_dai *dai) int asoc_simple_parse_clk(struct device *dev, struct device_node *node, - struct device_node *dai_of_node, struct asoc_simple_dai *simple_dai, - const char *dai_name, struct snd_soc_dai_link_component *dlc) { struct clk *clk; u32 val; /* - * Use snd_soc_dai_link_component instead of legacy style. - * It is only for codec, but cpu will be supported in the future. - * see - * soc-core.c :: snd_soc_init_multicodec() - */ - if (dlc) - dai_of_node = dlc->of_node; - - /* * Parse dai->sysclk come from "clocks = <&xxx>" * (if system has common clock) * or "system-clock-frequency = " @@ -190,7 +179,7 @@ int asoc_simple_parse_clk(struct device *dev, } else if (!of_property_read_u32(node, "system-clock-frequency", &val)) { simple_dai->sysclk = val; } else { - clk = devm_get_clk_from_child(dev, dai_of_node, NULL); + clk = devm_get_clk_from_child(dev, dlc->of_node, NULL); if (!IS_ERR(clk)) simple_dai->sysclk = clk_get_rate(clk); } @@ -359,7 +348,7 @@ void asoc_simple_canonicalize_platform(struct snd_soc_dai_link *dai_link) { /* Assumes platform == cpu */ if (!dai_link->platforms->of_node) - dai_link->platforms->of_node = dai_link->cpu_of_node; + dai_link->platforms->of_node = dai_link->cpus->of_node; } EXPORT_SYMBOL_GPL(asoc_simple_canonicalize_platform); @@ -376,7 +365,7 @@ void asoc_simple_canonicalize_cpu(struct snd_soc_dai_link *dai_link, * fmt_multiple_name() */ if (is_single_links) - dai_link->cpu_dai_name = NULL; + dai_link->cpus->dai_name = NULL; } EXPORT_SYMBOL_GPL(asoc_simple_canonicalize_cpu); @@ -386,7 +375,7 @@ int asoc_simple_clean_reference(struct snd_soc_card *card) int i; for_each_card_prelinks(card, i, dai_link) { - of_node_put(dai_link->cpu_of_node); + of_node_put(dai_link->cpus->of_node); of_node_put(dai_link->codecs->of_node); } return 0; @@ -576,6 +565,8 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv, * simple-card-utils.c :: asoc_simple_canonicalize_platform() */ for (i = 0; i < li->link; i++) { + dai_link[i].cpus = &dai_props[i].cpus; + dai_link[i].num_cpus = 1; dai_link[i].codecs = &dai_props[i].codecs; dai_link[i].num_codecs = 1; dai_link[i].platforms = &dai_props[i].platforms; diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index c2a2c5f..b544eeb 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -30,8 +30,6 @@ static const struct snd_soc_ops simple_ops = { static int asoc_simple_parse_dai(struct device_node *node, struct snd_soc_dai_link_component *dlc, - struct device_node **dai_of_node, - const char **dai_name, int *is_single_link) { struct of_phandle_args args; @@ -41,17 +39,6 @@ static int asoc_simple_parse_dai(struct device_node *node, return 0; /* - * Use snd_soc_dai_link_component instead of legacy style. - * It is only for codec, but cpu will be supported in the future. - * see - * soc-core.c :: snd_soc_init_multicodec() - */ - if (dlc) { - dai_name = &dlc->dai_name; - dai_of_node = &dlc->of_node; - } - - /* * Get node via "sound-dai = <&phandle port>" * it will be used as xxx_of_node on soc_bind_dai_link() */ @@ -60,13 +47,11 @@ static int asoc_simple_parse_dai(struct device_node *node, return ret; /* Get dai->name */ - if (dai_name) { - ret = snd_soc_of_get_dai_name(node, dai_name); - if (ret < 0) - return ret; - } + ret = snd_soc_of_get_dai_name(node, &dlc->dai_name); + if (ret < 0) + return ret; - *dai_of_node = args.np; + dlc->of_node = args.np; if (is_single_link) *is_single_link = !args.args_count; @@ -119,6 +104,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); struct asoc_simple_dai *dai; + struct snd_soc_dai_link_component *cpus = dai_link->cpus; struct snd_soc_dai_link_component *codecs = dai_link->codecs; struct device_node *top = dev->of_node; struct device_node *node = of_get_parent(np); @@ -169,7 +155,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, ret = asoc_simple_set_dailink_name(dev, dai_link, "fe.%s", - dai_link->cpu_dai_name); + cpus->dai_name); if (ret < 0) return ret; @@ -178,9 +164,9 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, struct snd_soc_codec_conf *cconf; /* FE is dummy */ - dai_link->cpu_of_node = NULL; - dai_link->cpu_dai_name = "snd-soc-dummy-dai"; - dai_link->cpu_name = "snd-soc-dummy"; + cpus->of_node = NULL; + cpus->dai_name = "snd-soc-dummy-dai"; + cpus->name = "snd-soc-dummy"; /* BE settings */ dai_link->no_pcm = 1; @@ -320,7 +306,7 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv, ret = asoc_simple_set_dailink_name(dev, dai_link, "%s-%s", - dai_link->cpu_dai_name, + dai_link->cpus->dai_name, dai_link->codecs->dai_name); if (ret < 0) goto dai_link_of_err; @@ -646,6 +632,7 @@ static int asoc_simple_probe(struct platform_device *pdev) } else { struct asoc_simple_card_info *cinfo; + struct snd_soc_dai_link_component *cpus; struct snd_soc_dai_link_component *codecs; struct snd_soc_dai_link_component *platform; struct snd_soc_dai_link *dai_link = priv->dai_link; @@ -671,6 +658,9 @@ static int asoc_simple_probe(struct platform_device *pdev) dai_props->cpu_dai = &priv->dais[dai_idx++]; dai_props->codec_dai = &priv->dais[dai_idx++]; + cpus = dai_link->cpus; + cpus->dai_name = cinfo->cpu_dai.name; + codecs = dai_link->codecs; codecs->name = cinfo->codec; codecs->dai_name = cinfo->codec_dai.name; @@ -681,7 +671,6 @@ static int asoc_simple_probe(struct platform_device *pdev) card->name = (cinfo->card) ? cinfo->card : cinfo->name; dai_link->name = cinfo->name; dai_link->stream_name = cinfo->name; - dai_link->cpu_dai_name = cinfo->cpu_dai.name; dai_link->dai_fmt = cinfo->daifmt; dai_link->init = asoc_simple_dai_init; memcpy(dai_props->cpu_dai, &cinfo->cpu_dai,