From patchwork Wed Jan 16 08:27:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10765501 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 5121213B5 for ; Wed, 16 Jan 2019 08:27:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E8182CC2E for ; Wed, 16 Jan 2019 08:27:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31E182CC4D; Wed, 16 Jan 2019 08:27:31 +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,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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 030732CC2E for ; Wed, 16 Jan 2019 08:27:30 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id B9FCA266A7C; Wed, 16 Jan 2019 09:27:28 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 544B9266B98; Wed, 16 Jan 2019 09:27:27 +0100 (CET) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa0.perex.cz (Postfix) with ESMTP id 0D569266AA9 for ; Wed, 16 Jan 2019 09:27:23 +0100 (CET) Date: 16 Jan 2019 17:27:22 +0900 X-IronPort-AV: E=Sophos;i="5.56,485,1539615600"; d="scan'208";a="5116827" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 16 Jan 2019 17:27:22 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 771F8435A7F4; Wed, 16 Jan 2019 17:27:22 +0900 (JST) Message-ID: <877ef5m2zi.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: <87bm4hm30t.wl-kuninori.morimoto.gx@renesas.com> References: <87bm4hm30t.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][RFC] ASoC: audio-graph/simple-card: use modern style dai_link for CPU X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Now ALSA SoC is supporting modern style (= snd_soc_dai_link_component) dai_link for CPU, let's switch to it. Because audio-graph/simple-card are sharing simple-card-utils, we need to update both in the same time. Signed-off-by: Kuninori Morimoto --- include/sound/simple_card_utils.h | 42 +++++++------------- sound/soc/generic/audio-graph-card.c | 18 +++++---- sound/soc/generic/simple-card-utils.c | 72 ++++++++--------------------------- sound/soc/generic/simple-card.c | 19 ++++++--- 4 files changed, 53 insertions(+), 98 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index ab5a2ba..d02de45 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -50,54 +50,38 @@ int asoc_simple_card_parse_card_name(struct snd_soc_card *card, char *prefix); #define asoc_simple_card_parse_clk_cpu(dev, node, dai_link, simple_dai) \ - asoc_simple_card_parse_clk(dev, node, dai_link->cpu_of_node, simple_dai, \ - dai_link->cpu_dai_name, NULL) + asoc_simple_card_parse_clk(dev, node, simple_dai, dai_link->cpus) #define asoc_simple_card_parse_clk_codec(dev, node, dai_link, simple_dai) \ - asoc_simple_card_parse_clk(dev, node, dai_link->codec_of_node, simple_dai,\ - dai_link->codec_dai_name, dai_link->codecs) + asoc_simple_card_parse_clk(dev, node, simple_dai, dai_link->codecs) int asoc_simple_card_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_card_clk_enable(struct asoc_simple_dai *dai); void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai); #define asoc_simple_card_parse_cpu(node, dai_link, \ list_name, cells_name, is_single_link) \ - asoc_simple_card_parse_dai(node, NULL, \ - &dai_link->cpu_of_node, \ - &dai_link->cpu_dai_name, list_name, cells_name, is_single_link) + asoc_simple_card_parse_dai(node, dai_link->cpus, \ + list_name, cells_name, 1, is_single_link) #define asoc_simple_card_parse_codec(node, dai_link, list_name, cells_name) \ asoc_simple_card_parse_dai(node, dai_link->codecs, \ - &dai_link->codec_of_node, \ - &dai_link->codec_dai_name, \ - list_name, cells_name, NULL) + list_name, cells_name, 1, NULL) #define asoc_simple_card_parse_platform(node, dai_link, list_name, cells_name) \ asoc_simple_card_parse_dai(node, dai_link->platforms, \ - &dai_link->platform_of_node, \ - NULL, list_name, cells_name, NULL) + list_name, cells_name, 0, NULL) int asoc_simple_card_parse_dai(struct device_node *node, - struct snd_soc_dai_link_component *dlc, - struct device_node **endpoint_np, - const char **dai_name, - const char *list_name, - const char *cells_name, - int *is_single_links); + struct snd_soc_dai_link_component *dlc, + const char *list_name, + const char *cells_name, + int with_dai, int *is_single_links); #define asoc_simple_card_parse_graph_cpu(ep, dai_link) \ - asoc_simple_card_parse_graph_dai(ep, NULL, \ - &dai_link->cpu_of_node, \ - &dai_link->cpu_dai_name) + asoc_simple_card_parse_graph_dai(ep, dai_link->cpus) #define asoc_simple_card_parse_graph_codec(ep, dai_link) \ - asoc_simple_card_parse_graph_dai(ep, dai_link->codecs, \ - &dai_link->codec_of_node, \ - &dai_link->codec_dai_name) + asoc_simple_card_parse_graph_dai(ep, dai_link->codecs) int asoc_simple_card_parse_graph_dai(struct device_node *ep, - struct snd_soc_dai_link_component *dlc, - struct device_node **endpoint_np, - const char **dai_name); + struct snd_soc_dai_link_component *dlc); #define asoc_simple_card_of_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 42b077c..374f041 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -25,6 +25,7 @@ struct graph_priv { struct graph_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_card_data adata; @@ -208,6 +209,7 @@ static int graph_dai_link_of_dpcm(struct graph_priv *priv, struct device_node *node; struct asoc_simple_dai *dai; struct snd_soc_dai_link_component *codecs = dai_link->codecs; + struct snd_soc_dai_link_component *cpus = dai_link->cpus; int ret; /* Do it all CPU endpoint, and 1st Codec endpoint */ @@ -257,20 +259,20 @@ static int graph_dai_link_of_dpcm(struct graph_priv *priv, ret = asoc_simple_card_set_dailink_name(dev, dai_link, "fe.%s", - dai_link->cpu_dai_name); + cpus->dai_name); if (ret < 0) return ret; /* card->num_links includes Codec */ asoc_simple_card_canonicalize_cpu(dai_link, - of_graph_get_endpoint_count(dai_link->cpu_of_node) == 1); + of_graph_get_endpoint_count(cpus->of_node) == 1); } else { 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; @@ -411,7 +413,7 @@ static int graph_dai_link_of(struct graph_priv *priv, ret = asoc_simple_card_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; @@ -420,7 +422,7 @@ static int graph_dai_link_of(struct graph_priv *priv, dai_link->init = graph_dai_init; asoc_simple_card_canonicalize_cpu(dai_link, - of_graph_get_endpoint_count(dai_link->cpu_of_node) == 1); + of_graph_get_endpoint_count(dai_link->cpus->of_node) == 1); return 0; } @@ -685,6 +687,8 @@ static int graph_probe(struct platform_device *pdev) * soc-core.c :: snd_soc_init_multicodec() */ 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-utils.c b/sound/soc/generic/simple-card-utils.c index 3c0901d..c98a074 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -170,26 +170,13 @@ EXPORT_SYMBOL_GPL(asoc_simple_card_clk_disable); int asoc_simple_card_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; - dai_name = dlc->dai_name; - } - - /* * Parse dai->sysclk come from "clocks = <&xxx>" * (if system has common clock) * or "system-clock-frequency = " @@ -203,7 +190,7 @@ int asoc_simple_card_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); } @@ -211,7 +198,7 @@ int asoc_simple_card_parse_clk(struct device *dev, if (of_property_read_bool(node, "system-clock-direction-out")) simple_dai->clk_direction = SND_SOC_CLOCK_OUT; - dev_dbg(dev, "%s : sysclk = %d, direction %d\n", dai_name, + dev_dbg(dev, "%s : sysclk = %d, direction %d\n", dlc->dai_name, simple_dai->sysclk, simple_dai->clk_direction); return 0; @@ -219,12 +206,11 @@ int asoc_simple_card_parse_clk(struct device *dev, EXPORT_SYMBOL_GPL(asoc_simple_card_parse_clk); int asoc_simple_card_parse_dai(struct device_node *node, - struct snd_soc_dai_link_component *dlc, - struct device_node **dai_of_node, - const char **dai_name, - const char *list_name, - const char *cells_name, - int *is_single_link) + struct snd_soc_dai_link_component *dlc, + const char *list_name, + const char *cells_name, + int with_dai, + int *is_single_link) { struct of_phandle_args args; int ret; @@ -233,17 +219,6 @@ int asoc_simple_card_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() */ @@ -252,13 +227,13 @@ int asoc_simple_card_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 (with_dai) { + 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; @@ -320,29 +295,14 @@ static int asoc_simple_card_get_dai_id(struct device_node *ep) } int asoc_simple_card_parse_graph_dai(struct device_node *ep, - struct snd_soc_dai_link_component *dlc, - struct device_node **dai_of_node, - const char **dai_name) + struct snd_soc_dai_link_component *dlc) { 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); @@ -351,11 +311,11 @@ int asoc_simple_card_parse_graph_dai(struct device_node *ep, args.args[0] = asoc_simple_card_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; return 0; } @@ -398,7 +358,7 @@ int asoc_simple_card_canonicalize_dailink(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; return 0; @@ -418,7 +378,7 @@ void asoc_simple_card_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_card_canonicalize_cpu); @@ -428,7 +388,7 @@ int asoc_simple_card_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; diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index d8a0d1e..1869f1f 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -20,6 +20,7 @@ struct 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_card_data adata; @@ -198,6 +199,7 @@ static int simple_dai_link_of_dpcm(struct simple_priv *priv, struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); struct asoc_simple_dai *dai; struct snd_soc_dai_link_component *codecs = dai_link->codecs; + struct snd_soc_dai_link_component *cpus = dai_link->cpus; struct device_node *top = dev->of_node; struct device_node *node = of_get_parent(np); char prop[128]; @@ -249,7 +251,7 @@ static int simple_dai_link_of_dpcm(struct simple_priv *priv, ret = asoc_simple_card_set_dailink_name(dev, dai_link, "fe.%s", - dai_link->cpu_dai_name); + dai_link->cpus->dai_name); if (ret < 0) return ret; @@ -258,9 +260,9 @@ static int simple_dai_link_of_dpcm(struct 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; @@ -415,7 +417,7 @@ static int simple_dai_link_of(struct simple_priv *priv, ret = asoc_simple_card_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; @@ -730,6 +732,8 @@ static int simple_probe(struct platform_device *pdev) * soc-core.c :: snd_soc_init_multicodec() */ 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; @@ -757,6 +761,7 @@ static int 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; int dai_idx = 0; @@ -779,6 +784,9 @@ static int 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; @@ -789,7 +797,6 @@ static int 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 = simple_dai_init; memcpy(priv->dai_props->cpu_dai, &cinfo->cpu_dai,