From patchwork Mon Mar 18 04:50:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10856869 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 1E2A26C2 for ; Mon, 18 Mar 2019 04:51:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E93E52924C for ; Mon, 18 Mar 2019 04:51:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8DF02924E; Mon, 18 Mar 2019 04:51:45 +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 2B3B62924C for ; Mon, 18 Mar 2019 04:51:45 +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 508DB86E; Mon, 18 Mar 2019 05:50:53 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 508DB86E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1552884703; bh=3a+1veP/Cu8fAOj9Tbc0rUnY/xlK7sacufpSfrxAr9g=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Ntlhg7jDcn8tvFZQnMTxzCeBzrno5XrFAiSrxU+vXGPR27MUh3PxGMPHEWD+41AX1 d9UrtH3rrljbXn3his+rWRxxF7DL1x89aNwDq95kWctFBQs3Rj9V3ryInchfiePjrG tVAy5cgxgXuWcTgOFy+vXetth8jQ2Tu6RH94FEL8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3589BF80059; Mon, 18 Mar 2019 05:50:17 +0100 (CET) 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 88094F89678; Mon, 18 Mar 2019 05:50:15 +0100 (CET) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id C8A33F80059 for ; Mon, 18 Mar 2019 05:50:09 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C8A33F80059 Date: 18 Mar 2019 13:50:08 +0900 X-IronPort-AV: E=Sophos;i="5.58,492,1544454000"; d="scan'208";a="10425114" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 18 Mar 2019 13:50:08 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 20415401BA23; Mon, 18 Mar 2019 13:50:08 +0900 (JST) Message-ID: <874l80ztkm.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: <875zsgztld.wl-kuninori.morimoto.gx@renesas.com> References: <875zsgztld.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 01/15] ASoC: simple-card: rename simple_get_conversion() to simple_parse_convert() 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 use same naming rule Signed-off-by: Kuninori Morimoto --- sound/soc/generic/simple-card.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 7147bba..5238c91 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -172,9 +172,9 @@ static int simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, return 0; } -static void simple_get_conversion(struct device *dev, - struct device_node *np, - struct asoc_simple_card_data *adata) +static void simple_parse_convert(struct device *dev, + struct device_node *np, + struct asoc_simple_card_data *adata) { struct device_node *top = dev->of_node; struct device_node *node = of_get_parent(np); @@ -295,7 +295,7 @@ static int simple_dai_link_of_dpcm(struct simple_priv *priv, "prefix"); } - simple_get_conversion(dev, np, &dai_props->adata); + simple_parse_convert(dev, np, &dai_props->adata); asoc_simple_card_canonicalize_platform(dai_link); @@ -471,7 +471,7 @@ static int simple_for_each_link(struct simple_priv *priv, /* get convert-xxx property */ memset(&adata, 0, sizeof(adata)); for_each_child_of_node(node, np) - simple_get_conversion(dev, np, &adata); + simple_parse_convert(dev, np, &adata); /* loop for all CPU/Codec node */ for_each_child_of_node(node, np) { From patchwork Mon Mar 18 04:50:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10856871 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 1E8256C2 for ; Mon, 18 Mar 2019 04:52:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF8772924C for ; Mon, 18 Mar 2019 04:52:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E12612924E; Mon, 18 Mar 2019 04:52:28 +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 3096F2924C for ; Mon, 18 Mar 2019 04:52:28 +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 D9B1487E; Mon, 18 Mar 2019 05:51:35 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D9B1487E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1552884745; bh=OsCaupg3HAF9WKR3oFRv5J9k34UBz2nOtC0IMWUmVJ0=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=sfTgnQdFeZmp5dgPyG5iKVCdoqyhmv3yMrWBiKinin5dyqqsFdC8W8QAL9H8Z0tVu Sopu2LY+G0mVbtQv85Uz0AiqYx6kOywVeDBzxroOltn4O69jnBm32r4R1+Z7pJRwNa KR3YKokfJdoE/ps2Hq4/rgYp43ieRl7OlBKSN4SY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 43014F8961C; Mon, 18 Mar 2019 05:50:23 +0100 (CET) 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 56C40F89713; Mon, 18 Mar 2019 05:50:22 +0100 (CET) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id E10C0F8961C for ; Mon, 18 Mar 2019 05:50:17 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E10C0F8961C Date: 18 Mar 2019 13:50:17 +0900 X-IronPort-AV: E=Sophos;i="5.58,492,1544454000"; d="scan'208";a="10425136" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 18 Mar 2019 13:50:17 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 65C6B401BA28; Mon, 18 Mar 2019 13:50:17 +0900 (JST) Message-ID: <8736nkztkd.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: <875zsgztld.wl-kuninori.morimoto.gx@renesas.com> References: <875zsgztld.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 02/15] ASoC: simple-card: add simple_parse_mclk_fs() 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 It is parsing mclk_fs at many places, but it should be same operation. This patch adds simple_parse_mclk_fs() and parse it. Signed-off-by: Kuninori Morimoto --- sound/soc/generic/simple-card.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 5238c91..b792638 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -187,6 +187,26 @@ static void simple_parse_convert(struct device *dev, of_node_put(node); } +static void simple_parse_mclk_fs(struct device_node *top, + struct device_node *cpu, + struct device_node *codec, + struct simple_dai_props *props, + char *prefix) +{ + struct device_node *node = of_get_parent(cpu); + char prop[128]; + + snprintf(prop, sizeof(prop), "%smclk-fs", PREFIX); + of_property_read_u32(top, prop, &props->mclk_fs); + + snprintf(prop, sizeof(prop), "%smclk-fs", prefix); + of_property_read_u32(node, prop, &props->mclk_fs); + of_property_read_u32(cpu, prop, &props->mclk_fs); + of_property_read_u32(codec, prop, &props->mclk_fs); + + of_node_put(node); +} + static int simple_dai_link_of_dpcm(struct simple_priv *priv, struct device_node *np, struct device_node *codec, @@ -200,7 +220,6 @@ static int simple_dai_link_of_dpcm(struct simple_priv *priv, 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); - char prop[128]; char *prefix = ""; int ret; @@ -296,6 +315,7 @@ static int simple_dai_link_of_dpcm(struct simple_priv *priv, } simple_parse_convert(dev, np, &dai_props->adata); + simple_parse_mclk_fs(top, np, codec, dai_props, prefix); asoc_simple_card_canonicalize_platform(dai_link); @@ -303,11 +323,6 @@ static int simple_dai_link_of_dpcm(struct simple_priv *priv, if (ret) return ret; - snprintf(prop, sizeof(prop), "%smclk-fs", prefix); - of_property_read_u32(top, PREFIX "mclk-fs", &dai_props->mclk_fs); - of_property_read_u32(node, prop, &dai_props->mclk_fs); - of_property_read_u32(np, prop, &dai_props->mclk_fs); - ret = asoc_simple_card_parse_daifmt(dev, node, codec, prefix, &dai_link->dai_fmt); if (ret < 0) @@ -372,11 +387,7 @@ static int simple_dai_link_of(struct simple_priv *priv, if (ret < 0) goto dai_link_of_err; - snprintf(prop, sizeof(prop), "%smclk-fs", prefix); - of_property_read_u32(top, PREFIX "mclk-fs", &dai_props->mclk_fs); - of_property_read_u32(node, prop, &dai_props->mclk_fs); - of_property_read_u32(cpu, prop, &dai_props->mclk_fs); - of_property_read_u32(codec, prop, &dai_props->mclk_fs); + simple_parse_mclk_fs(top, cpu, codec, dai_props, prefix); ret = asoc_simple_card_parse_cpu(cpu, dai_link, DAI, CELL, &single_cpu); From patchwork Mon Mar 18 04:50:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10856873 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 090956C2 for ; Mon, 18 Mar 2019 04:53:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D985E2924D for ; Mon, 18 Mar 2019 04:53:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDB252924C; Mon, 18 Mar 2019 04:53:14 +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 224672924C for ; Mon, 18 Mar 2019 04:53:14 +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 56E0486F; Mon, 18 Mar 2019 05:52:22 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 56E0486F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1552884792; bh=SBzG6qkiFYwlbqKrZyLi3UbjRwdWqtUoAnPzZK1KI/M=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=D5JvyQkf9T4jytlmubqjEk2C00v9LEWA44q00MfcHhRCBFre0ziy7ltDpGfqVU5ku pchLIj30QKTyuDjyiJV48/k9GRzBmsi8BFfW/QVJywtNlQuLka3EdfNRj/1u0GkFym vbB55nkZUdjOZ5W6p8XSK2Tx+W8IUubXaQUCrwgs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 80DD1F89718; Mon, 18 Mar 2019 05:50:34 +0100 (CET) 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 E04A2F89718; Mon, 18 Mar 2019 05:50:32 +0100 (CET) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 67EEEF89715 for ; Mon, 18 Mar 2019 05:50:27 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 67EEEF89715 Date: 18 Mar 2019 13:50:25 +0900 X-IronPort-AV: E=Sophos;i="5.58,492,1544454000"; d="scan'208";a="10425151" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 18 Mar 2019 13:50:25 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 041CF401BA25; Mon, 18 Mar 2019 13:50:25 +0900 (JST) Message-ID: <871s34ztk5.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: <875zsgztld.wl-kuninori.morimoto.gx@renesas.com> References: <875zsgztld.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 03/15] ASoC: audio-graph: rename graph_get_conversion() to graph_parse_convert() 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 use same naming rule, and this patch add missing of_node_put() on it Signed-off-by: Kuninori Morimoto --- sound/soc/generic/audio-graph-card.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index bb12351..733ba1e 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -176,9 +176,9 @@ static int graph_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, return 0; } -static void graph_get_conversion(struct device *dev, - struct device_node *ep, - struct asoc_simple_card_data *adata) +static void graph_parse_convert(struct device *dev, + struct device_node *ep, + struct asoc_simple_card_data *adata) { struct device_node *top = dev->of_node; struct device_node *port = of_get_parent(ep); @@ -190,6 +190,10 @@ static void graph_get_conversion(struct device *dev, asoc_simple_card_parse_convert(dev, ports, NULL, adata); asoc_simple_card_parse_convert(dev, port, NULL, adata); asoc_simple_card_parse_convert(dev, ep, NULL, adata); + + of_node_put(port); + of_node_put(ports); + of_node_put(node); } static int graph_dai_link_of_dpcm(struct graph_priv *priv, @@ -227,7 +231,7 @@ static int graph_dai_link_of_dpcm(struct graph_priv *priv, of_property_read_u32(port, "mclk-fs", &dai_props->mclk_fs); of_property_read_u32(ep, "mclk-fs", &dai_props->mclk_fs); - graph_get_conversion(dev, ep, &dai_props->adata); + graph_parse_convert(dev, ep, &dai_props->adata); of_node_put(ports); of_node_put(port); @@ -462,8 +466,8 @@ static int graph_for_each_link(struct graph_priv *priv, /* get convert-xxx property */ memset(&adata, 0, sizeof(adata)); - graph_get_conversion(dev, codec_ep, &adata); - graph_get_conversion(dev, cpu_ep, &adata); + graph_parse_convert(dev, codec_ep, &adata); + graph_parse_convert(dev, cpu_ep, &adata); /* * It is DPCM From patchwork Mon Mar 18 04:50:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10856875 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 9F4236C2 for ; Mon, 18 Mar 2019 04:54:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E00D2924C for ; Mon, 18 Mar 2019 04:54:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7288E2924D; Mon, 18 Mar 2019 04:54:05 +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 9BE4C2924F for ; Mon, 18 Mar 2019 04:54:04 +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 DC536854; Mon, 18 Mar 2019 05:53:12 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DC536854 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1552884842; bh=/5k0pHaIQt9Uaxx9kZ35qJk8EoZ4bEzavg9UMSfYf1Y=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=kOpRkg23uHoX2GX5EN5PDFc4CDI+elvU6rgRVUS35VgW2mjTbTTB6iySufIWV0Wc8 sq9nlJtt8qrRSIC6r96yReeb+4JNBs/3XUUZv42Pq2U0BM54fonZXjHr7WAdbtLTT6 7W3gOap7fbXWtScqjOEPTrb4vElza0Ck3vDbVzmE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 66468F8971F; Mon, 18 Mar 2019 05:50:38 +0100 (CET) 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 E741CF89722; Mon, 18 Mar 2019 05:50:37 +0100 (CET) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id BD834F89716 for ; Mon, 18 Mar 2019 05:50:32 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BD834F89716 Date: 18 Mar 2019 13:50:31 +0900 X-IronPort-AV: E=Sophos;i="5.58,492,1544454000"; d="scan'208";a="10633628" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 18 Mar 2019 13:50:31 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 6729D41DCD13; Mon, 18 Mar 2019 13:50:31 +0900 (JST) Message-ID: <87zhpsyezj.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: <875zsgztld.wl-kuninori.morimoto.gx@renesas.com> References: <875zsgztld.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 04/15] ASoC: audio-graph: add graph_parse_mclk_fs() 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 It is parsing mclk_fs at many places, but it should be same operation. This patch adds graph_parse_mclk_fs() and parse it. This patch also renames similar function graph_get_conversion() to graph_parse_convert(). Signed-off-by: Kuninori Morimoto --- sound/soc/generic/audio-graph-card.c | 50 +++++++++++++++++------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 733ba1e..7dd772a 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -196,6 +196,24 @@ static void graph_parse_convert(struct device *dev, of_node_put(node); } +static void graph_parse_mclk_fs(struct device_node *top, + struct device_node *ep, + struct graph_dai_props *props) +{ + struct device_node *port = of_get_parent(ep); + struct device_node *ports = of_get_parent(port); + struct device_node *node = of_graph_get_port_parent(ep); + + of_property_read_u32(top, "mclk-fs", &props->mclk_fs); + of_property_read_u32(ports, "mclk-fs", &props->mclk_fs); + of_property_read_u32(port, "mclk-fs", &props->mclk_fs); + of_property_read_u32(ep, "mclk-fs", &props->mclk_fs); + + of_node_put(port); + of_node_put(ports); + of_node_put(node); +} + static int graph_dai_link_of_dpcm(struct graph_priv *priv, struct device_node *cpu_ep, struct device_node *codec_ep, @@ -226,13 +244,6 @@ static int graph_dai_link_of_dpcm(struct graph_priv *priv, dev_dbg(dev, "link_of DPCM (%pOF)\n", ep); - of_property_read_u32(top, "mclk-fs", &dai_props->mclk_fs); - of_property_read_u32(ports, "mclk-fs", &dai_props->mclk_fs); - of_property_read_u32(port, "mclk-fs", &dai_props->mclk_fs); - of_property_read_u32(ep, "mclk-fs", &dai_props->mclk_fs); - - graph_parse_convert(dev, ep, &dai_props->adata); - of_node_put(ports); of_node_put(port); of_node_put(node); @@ -311,6 +322,9 @@ static int graph_dai_link_of_dpcm(struct graph_priv *priv, "prefix"); } + graph_parse_convert(dev, ep, &dai_props->adata); + graph_parse_mclk_fs(top, ep, dai_props); + asoc_simple_card_canonicalize_platform(dai_link); ret = asoc_simple_card_of_parse_tdm(ep, dai); @@ -339,10 +353,6 @@ static int graph_dai_link_of(struct graph_priv *priv, struct snd_soc_dai_link *dai_link = graph_priv_to_link(priv, li->link); struct graph_dai_props *dai_props = graph_priv_to_props(priv, li->link); struct device_node *top = dev->of_node; - struct device_node *cpu_port; - struct device_node *cpu_ports; - struct device_node *codec_port; - struct device_node *codec_ports; struct asoc_simple_dai *cpu_dai; struct asoc_simple_dai *codec_dai; int ret; @@ -351,11 +361,6 @@ static int graph_dai_link_of(struct graph_priv *priv, if (!li->cpu) return 0; - cpu_port = of_get_parent(cpu_ep); - cpu_ports = of_get_parent(cpu_port); - codec_port = of_get_parent(codec_ep); - codec_ports = of_get_parent(codec_port); - dev_dbg(dev, "link_of (%pOF)\n", cpu_ep); li->link++; @@ -366,17 +371,8 @@ static int graph_dai_link_of(struct graph_priv *priv, dai_props->codec_dai = &priv->dais[li->dais++]; /* Factor to mclk, used in hw_params() */ - of_property_read_u32(top, "mclk-fs", &dai_props->mclk_fs); - of_property_read_u32(cpu_ports, "mclk-fs", &dai_props->mclk_fs); - of_property_read_u32(codec_ports, "mclk-fs", &dai_props->mclk_fs); - of_property_read_u32(cpu_port, "mclk-fs", &dai_props->mclk_fs); - of_property_read_u32(codec_port, "mclk-fs", &dai_props->mclk_fs); - of_property_read_u32(cpu_ep, "mclk-fs", &dai_props->mclk_fs); - of_property_read_u32(codec_ep, "mclk-fs", &dai_props->mclk_fs); - of_node_put(cpu_port); - of_node_put(cpu_ports); - of_node_put(codec_port); - of_node_put(codec_ports); + graph_parse_mclk_fs(top, cpu_ep, dai_props); + graph_parse_mclk_fs(top, codec_ep, dai_props); ret = asoc_simple_card_parse_daifmt(dev, cpu_ep, codec_ep, NULL, &dai_link->dai_fmt); From patchwork Mon Mar 18 04:53:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10856877 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 D79B66C2 for ; Mon, 18 Mar 2019 04:54:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B367C290DA for ; Mon, 18 Mar 2019 04:54:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A36DF2924D; Mon, 18 Mar 2019 04:54:44 +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 A595D290DA for ; Mon, 18 Mar 2019 04:54:43 +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 DDF4F867; Mon, 18 Mar 2019 05:53:51 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DDF4F867 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1552884882; bh=OhUuvgmpU1aV2XNvOYJETn69Bygzef1Mq6+kbBx1cKQ=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=jpREEtP4jGjZNZvjPcfTLvQZIY8ioWiyY/ljn+nnPY89bmJk/2Mu3cJDfCVyr2odk 0BbhJzQ6APItjOViIA3feQiQSl6Dq2zzhOqMVWMH4L4mAV6IhodnGBoC/C4XF/1y3v 4Yj6E0PZ3TQov9znBKYNmf8OKaN/vAhUrDmoUwCg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DE5F3F80792; Mon, 18 Mar 2019 05:53:12 +0100 (CET) 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 B4DA8F80C0F; Mon, 18 Mar 2019 05:53:10 +0100 (CET) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id 17E70F80059 for ; Mon, 18 Mar 2019 05:53:03 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 17E70F80059 Date: 18 Mar 2019 13:53:01 +0900 X-IronPort-AV: E=Sophos;i="5.58,492,1544454000"; d="scan'208";a="10633983" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 18 Mar 2019 13:53:01 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id A71A4401BA2C; Mon, 18 Mar 2019 13:53:01 +0900 (JST) Message-ID: <87y35cyevd.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: <875zsgztld.wl-kuninori.morimoto.gx@renesas.com> References: <875zsgztld.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 05/15] ASoC: simple-card-utils: add asoc_simple_debug_info() 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 Current simple-card-utils has dev_dbg(), but people want to add #define DEBUG at simple-card/audio-graph, not simple-card-utils. And, people want to get all information. This patch adds new asoc_simple_debug_info() to indicates information. Signed-off-by: Kuninori Morimoto --- include/sound/simple_card_utils.h | 72 +++++++++++++++++++++++++++++++++++ sound/soc/generic/audio-graph-card.c | 2 + sound/soc/generic/simple-card-utils.c | 12 ------ sound/soc/generic/simple-card.c | 2 + 4 files changed, 76 insertions(+), 12 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 7afe453..0199ad0 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -129,4 +129,76 @@ int asoc_simple_card_init_jack(struct snd_soc_card *card, struct asoc_simple_jack *sjack, int is_hp, char *prefix); + +#ifdef DEBUG +inline void asoc_simple_debug_dai(struct asoc_simple_priv *priv, + char *name, + struct asoc_simple_dai *dai) +{ + struct device *dev = simple_priv_to_dev(priv); + + if (dai->name) + dev_dbg(dev, "%s dai name = %s\n", + name, dai->name); + if (dai->sysclk) + dev_dbg(dev, "%s sysclk = %d\n", + name, dai->sysclk); + + dev_dbg(dev, "%s direction = %s\n", + name, dai->clk_direction ? "OUT" : "IN"); + + if (dai->slots) + dev_dbg(dev, "%s slots = %d\n", name, dai->slots); + if (dai->slot_width) + dev_dbg(dev, "%s slot width = %d\n", name, dai->slot_width); + if (dai->tx_slot_mask) + dev_dbg(dev, "%s tx slot mask = %d\n", name, dai->tx_slot_mask); + if (dai->rx_slot_mask) + dev_dbg(dev, "%s rx slot mask = %d\n", name, dai->rx_slot_mask); + if (dai->clk) + dev_dbg(dev, "%s clk %luHz\n", name, clk_get_rate(dai->clk)); +} + +inline void asoc_simple_debug_info(struct asoc_simple_priv *priv) +{ + struct snd_soc_card *card = simple_priv_to_card(priv); + struct device *dev = simple_priv_to_dev(priv); + + int i; + + if (card->name) + dev_dbg(dev, "Card Name: %s\n", card->name); + + for (i = 0; i < card->num_links; i++) { + struct simple_dai_props *props = simple_priv_to_props(priv, i); + struct snd_soc_dai_link *link = simple_priv_to_link(priv, i); + + dev_dbg(dev, "DAI%d\n", i); + + asoc_simple_debug_dai(priv, "cpu", props->cpu_dai); + asoc_simple_debug_dai(priv, "codec", props->codec_dai); + + if (link->name) + dev_dbg(dev, "dai name = %s\n", link->name); + + dev_dbg(dev, "dai format = %04x\n", link->dai_fmt); + + if (props->adata.convert_rate) + dev_dbg(dev, "convert_rate = %d\n", + props->adata.convert_rate); + if (props->adata.convert_channels) + dev_dbg(dev, "convert_channels = %d\n", + props->adata.convert_channels); + if (props->codec_conf && props->codec_conf->name_prefix) + dev_dbg(dev, "name prefix = %s\n", + props->codec_conf->name_prefix); + if (props->mclk_fs) + dev_dbg(dev, "mclk-fs = %d\n", + props->mclk_fs); + } +} +#else +#define asoc_simple_debug_info(priv) +#endif /* DEBUG */ + #endif /* __SIMPLE_CARD_UTILS_H */ diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 7dd772a..2a95355 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -712,6 +712,8 @@ static int graph_probe(struct platform_device *pdev) snd_soc_card_set_drvdata(card, priv); + asoc_simple_debug_info(priv); + ret = devm_snd_soc_register_card(dev, card); if (ret < 0) goto err; diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 5c1424f..f5ba5ad 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -49,9 +49,6 @@ void asoc_simple_card_parse_convert(struct device *dev, /* channels transfer */ snprintf(prop, sizeof(prop), "%s%s", prefix, "convert-channels"); of_property_read_u32(np, prop, &data->convert_channels); - - dev_dbg(dev, "convert_rate %d\n", data->convert_rate); - dev_dbg(dev, "convert_channels %d\n", data->convert_channels); } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_convert); @@ -93,8 +90,6 @@ int asoc_simple_card_parse_daifmt(struct device *dev, *retfmt = daifmt; - dev_dbg(dev, "format : %04x\n", daifmt); - return 0; } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_daifmt); @@ -116,8 +111,6 @@ int asoc_simple_card_set_dailink_name(struct device *dev, dai_link->name = name; dai_link->stream_name = name; - - dev_dbg(dev, "name : %s\n", name); } return ret; @@ -146,8 +139,6 @@ int asoc_simple_card_parse_card_name(struct snd_soc_card *card, if (!card->name && card->dai_link) card->name = card->dai_link->name; - dev_dbg(card->dev, "Card Name: %s\n", card->name ? card->name : ""); - return 0; } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_name); @@ -211,9 +202,6 @@ 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, - simple_dai->sysclk, simple_dai->clk_direction); - return 0; } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_clk); diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index b792638..7789962 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -813,6 +813,8 @@ static int simple_probe(struct platform_device *pdev) snd_soc_card_set_drvdata(card, priv); + asoc_simple_debug_info(priv); + ret = devm_snd_soc_register_card(dev, card); if (ret < 0) goto err; From patchwork Mon Mar 18 04:53:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10856879 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 D0DCD1390 for ; Mon, 18 Mar 2019 04:55:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A368A290DA for ; Mon, 18 Mar 2019 04:55:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9251B2924D; Mon, 18 Mar 2019 04:55:09 +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 22C5C290DA for ; Mon, 18 Mar 2019 04:55:08 +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 E80CA88B; Mon, 18 Mar 2019 05:54:15 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E80CA88B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1552884906; bh=GeOttJGS0IdpG7aCUi42hc83W5foHLqf3hJirBKh+VI=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=qHM6jqccxVydWvS53aPkhssTPXXulfq/LcNSGrg5AH0b9IGFj4plpDZNsAFbDi8xa 3w31m9KfcgD7XRMsWgh1bOHVBgqqO2JWCusn7Xfqvr+phR4QtG4DNP5SBUH/K6yBeP iPwRsJl4N5LhFSaBq8wAZ6w01aeZfvbYGfQHEdb0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 279D2F89713; Mon, 18 Mar 2019 05:53:23 +0100 (CET) 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 B23F9F896FF; Mon, 18 Mar 2019 05:53:20 +0100 (CET) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id 351DDF8961C for ; Mon, 18 Mar 2019 05:53:13 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 351DDF8961C Date: 18 Mar 2019 13:53:12 +0900 X-IronPort-AV: E=Sophos;i="5.58,492,1544454000"; d="scan'208";a="10634002" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 18 Mar 2019 13:53:12 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 4DE6741E7C36; Mon, 18 Mar 2019 13:53:12 +0900 (JST) Message-ID: <87wokwyev2.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: <875zsgztld.wl-kuninori.morimoto.gx@renesas.com> References: <875zsgztld.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 06/15] ASoC: simple_card_utils: share common priv for simple-card/audio-graph 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 Historically, simple-card/simple-scu-card/audio-graph/audio-graph-scu are similar but different generic sound card. simple-scu-card which was for DPCM was merged into simple-card, and audio-graph-scu which was for DPCM was merged into audio-graph. simple-card is for non OF graph sound card, and audio-graph is for OF graph sound card. And, small detail difference (= function parameter, naming, etc) between simple-card/audio-graph has been unified. So today, the difference between simple-card/audio-graph are just using OF graph style, or not. In other words, there should no difference other than OF graph sytle. simple-card/audio-graph are using own priv today , but we can merge it. This patch merge it at simple_card_utils. Signed-off-by: Kuninori Morimoto --- include/sound/simple_card_utils.h | 23 +++++++++ sound/soc/generic/audio-graph-card.c | 96 ++++++++++++++---------------------- sound/soc/generic/simple-card.c | 57 +++++++-------------- 3 files changed, 76 insertions(+), 100 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 0199ad0..c0161ec 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -37,6 +37,29 @@ struct asoc_simple_jack { struct snd_soc_jack_gpio gpio; }; +struct asoc_simple_priv { + struct snd_soc_card snd_card; + struct simple_dai_props { + struct asoc_simple_dai *cpu_dai; + struct asoc_simple_dai *codec_dai; + struct snd_soc_dai_link_component codecs; /* single codec */ + struct snd_soc_dai_link_component platforms; + struct asoc_simple_card_data adata; + struct snd_soc_codec_conf *codec_conf; + unsigned int mclk_fs; + } *dai_props; + struct asoc_simple_jack hp_jack; + struct asoc_simple_jack mic_jack; + struct snd_soc_dai_link *dai_link; + struct asoc_simple_dai *dais; + struct snd_soc_codec_conf *codec_conf; + struct gpio_desc *pa_gpio; +}; +#define simple_priv_to_card(priv) (&(priv)->snd_card) +#define simple_priv_to_props(priv, i) ((priv)->dai_props + (i)) +#define simple_priv_to_dev(priv) (simple_priv_to_card(priv)->dev) +#define simple_priv_to_link(priv, i) (simple_priv_to_card(priv)->dai_link + (i)) + int asoc_simple_card_parse_daifmt(struct device *dev, struct device_node *node, struct device_node *codec, diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 2a95355..656ca49 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -20,25 +20,6 @@ #include #include -struct graph_priv { - struct snd_soc_card snd_card; - struct graph_dai_props { - struct asoc_simple_dai *cpu_dai; - struct asoc_simple_dai *codec_dai; - struct snd_soc_dai_link_component codecs; /* single codec */ - struct snd_soc_dai_link_component platforms; - struct asoc_simple_card_data adata; - struct snd_soc_codec_conf *codec_conf; - unsigned int mclk_fs; - } *dai_props; - struct asoc_simple_jack hp_jack; - struct asoc_simple_jack mic_jack; - struct snd_soc_dai_link *dai_link; - struct asoc_simple_dai *dais; - struct snd_soc_codec_conf *codec_conf; - struct gpio_desc *pa_gpio; -}; - struct link_info { int dais; /* number of dai */ int link; /* number of link */ @@ -46,11 +27,6 @@ struct link_info { int cpu; /* turn for CPU / Codec */ }; -#define graph_priv_to_card(priv) (&(priv)->snd_card) -#define graph_priv_to_props(priv, i) ((priv)->dai_props + (i)) -#define graph_priv_to_dev(priv) (graph_priv_to_card(priv)->dev) -#define graph_priv_to_link(priv, i) (graph_priv_to_card(priv)->dai_link + (i)) - #define PREFIX "audio-graph-card," static int graph_outdrv_event(struct snd_soc_dapm_widget *w, @@ -58,7 +34,7 @@ static int graph_outdrv_event(struct snd_soc_dapm_widget *w, int event) { struct snd_soc_dapm_context *dapm = w->dapm; - struct graph_priv *priv = snd_soc_card_get_drvdata(dapm->card); + struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(dapm->card); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -83,8 +59,8 @@ static const struct snd_soc_dapm_widget graph_dapm_widgets[] = { static int graph_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct graph_priv *priv = snd_soc_card_get_drvdata(rtd->card); - struct graph_dai_props *dai_props = graph_priv_to_props(priv, rtd->num); + struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); int ret; ret = asoc_simple_card_clk_enable(dai_props->cpu_dai); @@ -101,8 +77,8 @@ static int graph_startup(struct snd_pcm_substream *substream) static void graph_shutdown(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct graph_priv *priv = snd_soc_card_get_drvdata(rtd->card); - struct graph_dai_props *dai_props = graph_priv_to_props(priv, rtd->num); + struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); asoc_simple_card_clk_disable(dai_props->cpu_dai); @@ -115,8 +91,8 @@ static int graph_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct graph_priv *priv = snd_soc_card_get_drvdata(rtd->card); - struct graph_dai_props *dai_props = graph_priv_to_props(priv, rtd->num); + struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); unsigned int mclk, mclk_fs = 0; int ret = 0; @@ -148,8 +124,8 @@ static const struct snd_soc_ops graph_ops = { static int graph_dai_init(struct snd_soc_pcm_runtime *rtd) { - struct graph_priv *priv = snd_soc_card_get_drvdata(rtd->card); - struct graph_dai_props *dai_props = graph_priv_to_props(priv, rtd->num); + struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); int ret = 0; ret = asoc_simple_card_init_dai(rtd->codec_dai, @@ -168,8 +144,8 @@ static int graph_dai_init(struct snd_soc_pcm_runtime *rtd) static int graph_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { - struct graph_priv *priv = snd_soc_card_get_drvdata(rtd->card); - struct graph_dai_props *dai_props = graph_priv_to_props(priv, rtd->num); + struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); asoc_simple_card_convert_fixup(&dai_props->adata, params); @@ -198,7 +174,7 @@ static void graph_parse_convert(struct device *dev, static void graph_parse_mclk_fs(struct device_node *top, struct device_node *ep, - struct graph_dai_props *props) + struct simple_dai_props *props) { struct device_node *port = of_get_parent(ep); struct device_node *ports = of_get_parent(port); @@ -214,15 +190,15 @@ static void graph_parse_mclk_fs(struct device_node *top, of_node_put(node); } -static int graph_dai_link_of_dpcm(struct graph_priv *priv, +static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, struct device_node *cpu_ep, struct device_node *codec_ep, struct link_info *li, int dup_codec) { - struct device *dev = graph_priv_to_dev(priv); - struct snd_soc_dai_link *dai_link = graph_priv_to_link(priv, li->link); - struct graph_dai_props *dai_props = graph_priv_to_props(priv, li->link); + struct device *dev = simple_priv_to_dev(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 device_node *top = dev->of_node; struct device_node *ep = li->cpu ? cpu_ep : codec_ep; struct device_node *port; @@ -344,14 +320,14 @@ static int graph_dai_link_of_dpcm(struct graph_priv *priv, return 0; } -static int graph_dai_link_of(struct graph_priv *priv, +static int graph_dai_link_of(struct asoc_simple_priv *priv, struct device_node *cpu_ep, struct device_node *codec_ep, struct link_info *li) { - struct device *dev = graph_priv_to_dev(priv); - struct snd_soc_dai_link *dai_link = graph_priv_to_link(priv, li->link); - struct graph_dai_props *dai_props = graph_priv_to_props(priv, li->link); + struct device *dev = simple_priv_to_dev(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 device_node *top = dev->of_node; struct asoc_simple_dai *cpu_dai; struct asoc_simple_dai *codec_dai; @@ -420,19 +396,19 @@ static int graph_dai_link_of(struct graph_priv *priv, return 0; } -static int graph_for_each_link(struct graph_priv *priv, +static int graph_for_each_link(struct asoc_simple_priv *priv, struct link_info *li, - int (*func_noml)(struct graph_priv *priv, + int (*func_noml)(struct asoc_simple_priv *priv, struct device_node *cpu_ep, struct device_node *codec_ep, struct link_info *li), - int (*func_dpcm)(struct graph_priv *priv, + int (*func_dpcm)(struct asoc_simple_priv *priv, struct device_node *cpu_ep, struct device_node *codec_ep, struct link_info *li, int dup_codec)) { struct of_phandle_iterator it; - struct device *dev = graph_priv_to_dev(priv); + struct device *dev = simple_priv_to_dev(priv); struct device_node *node = dev->of_node; struct device_node *cpu_port; struct device_node *cpu_ep; @@ -488,9 +464,9 @@ static int graph_for_each_link(struct graph_priv *priv, return 0; } -static int graph_parse_of(struct graph_priv *priv) +static int graph_parse_of(struct asoc_simple_priv *priv) { - struct snd_soc_card *card = graph_priv_to_card(priv); + struct snd_soc_card *card = simple_priv_to_card(priv); struct link_info li; int ret; @@ -526,12 +502,12 @@ static int graph_parse_of(struct graph_priv *priv) return asoc_simple_card_parse_card_name(card, NULL); } -static int graph_count_noml(struct graph_priv *priv, +static int graph_count_noml(struct asoc_simple_priv *priv, struct device_node *cpu_ep, struct device_node *codec_ep, struct link_info *li) { - struct device *dev = graph_priv_to_dev(priv); + struct device *dev = simple_priv_to_dev(priv); li->link += 1; /* 1xCPU-Codec */ li->dais += 2; /* 1xCPU + 1xCodec */ @@ -541,13 +517,13 @@ static int graph_count_noml(struct graph_priv *priv, return 0; } -static int graph_count_dpcm(struct graph_priv *priv, +static int graph_count_dpcm(struct asoc_simple_priv *priv, struct device_node *cpu_ep, struct device_node *codec_ep, struct link_info *li, int dup_codec) { - struct device *dev = graph_priv_to_dev(priv); + struct device *dev = simple_priv_to_dev(priv); li->link++; /* 1xCPU-dummy */ li->dais++; /* 1xCPU */ @@ -563,10 +539,10 @@ static int graph_count_dpcm(struct graph_priv *priv, return 0; } -static void graph_get_dais_count(struct graph_priv *priv, +static void graph_get_dais_count(struct asoc_simple_priv *priv, struct link_info *li) { - struct device *dev = graph_priv_to_dev(priv); + struct device *dev = simple_priv_to_dev(priv); /* * link_num : number of links. @@ -623,7 +599,7 @@ static void graph_get_dais_count(struct graph_priv *priv, static int graph_card_probe(struct snd_soc_card *card) { - struct graph_priv *priv = snd_soc_card_get_drvdata(card); + struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(card); int ret; ret = asoc_simple_card_init_hp(card, &priv->hp_jack, NULL); @@ -639,9 +615,9 @@ static int graph_card_probe(struct snd_soc_card *card) static int graph_probe(struct platform_device *pdev) { - struct graph_priv *priv; + struct asoc_simple_priv *priv; struct snd_soc_dai_link *dai_link; - struct graph_dai_props *dai_props; + struct simple_dai_props *dai_props; struct asoc_simple_dai *dais; struct device *dev = &pdev->dev; struct snd_soc_card *card; @@ -654,7 +630,7 @@ static int graph_probe(struct platform_device *pdev) if (!priv) return -ENOMEM; - card = graph_priv_to_card(priv); + card = simple_priv_to_card(priv); card->owner = THIS_MODULE; card->dev = dev; card->dapm_widgets = graph_dapm_widgets; diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 7789962..628c19a 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -15,24 +15,6 @@ #include #include -struct simple_priv { - struct snd_soc_card snd_card; - struct simple_dai_props { - struct asoc_simple_dai *cpu_dai; - struct asoc_simple_dai *codec_dai; - struct snd_soc_dai_link_component codecs; /* single codec */ - struct snd_soc_dai_link_component platforms; - struct asoc_simple_card_data adata; - struct snd_soc_codec_conf *codec_conf; - unsigned int mclk_fs; - } *dai_props; - struct asoc_simple_jack hp_jack; - struct asoc_simple_jack mic_jack; - struct snd_soc_dai_link *dai_link; - struct asoc_simple_dai *dais; - struct snd_soc_codec_conf *codec_conf; -}; - struct link_info { int dais; /* number of dai */ int link; /* number of link */ @@ -40,11 +22,6 @@ struct link_info { int cpu; /* turn for CPU / Codec */ }; -#define simple_priv_to_card(priv) (&(priv)->snd_card) -#define simple_priv_to_props(priv, i) ((priv)->dai_props + (i)) -#define simple_priv_to_dev(priv) (simple_priv_to_card(priv)->dev) -#define simple_priv_to_link(priv, i) (simple_priv_to_card(priv)->dai_link + (i)) - #define DAI "sound-dai" #define CELL "#sound-dai-cells" #define PREFIX "simple-audio-card," @@ -52,7 +29,7 @@ struct link_info { static int simple_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); int ret; @@ -71,7 +48,7 @@ static int simple_startup(struct snd_pcm_substream *substream) static void simple_shutdown(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); @@ -101,7 +78,7 @@ static int simple_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); unsigned int mclk, mclk_fs = 0; @@ -144,7 +121,7 @@ static const struct snd_soc_ops simple_ops = { static int simple_dai_init(struct snd_soc_pcm_runtime *rtd) { - struct simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); int ret; @@ -164,7 +141,7 @@ static int simple_dai_init(struct snd_soc_pcm_runtime *rtd) static int simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { - struct simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); asoc_simple_card_convert_fixup(&dai_props->adata, params); @@ -207,7 +184,7 @@ static void simple_parse_mclk_fs(struct device_node *top, of_node_put(node); } -static int simple_dai_link_of_dpcm(struct simple_priv *priv, +static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, struct device_node *np, struct device_node *codec, struct link_info *li, @@ -336,7 +313,7 @@ static int simple_dai_link_of_dpcm(struct simple_priv *priv, return 0; } -static int simple_dai_link_of(struct simple_priv *priv, +static int simple_dai_link_of(struct asoc_simple_priv *priv, struct device_node *np, struct device_node *codec, struct link_info *li, @@ -438,13 +415,13 @@ static int simple_dai_link_of(struct simple_priv *priv, return ret; } -static int simple_for_each_link(struct simple_priv *priv, +static int simple_for_each_link(struct asoc_simple_priv *priv, struct link_info *li, - int (*func_noml)(struct simple_priv *priv, + int (*func_noml)(struct asoc_simple_priv *priv, struct device_node *np, struct device_node *codec, struct link_info *li, bool is_top), - int (*func_dpcm)(struct simple_priv *priv, + int (*func_dpcm)(struct asoc_simple_priv *priv, struct device_node *np, struct device_node *codec, struct link_info *li, bool is_top)) @@ -513,7 +490,7 @@ static int simple_for_each_link(struct simple_priv *priv, } static int simple_parse_aux_devs(struct device_node *node, - struct simple_priv *priv) + struct asoc_simple_priv *priv) { struct device *dev = simple_priv_to_dev(priv); struct device_node *aux_node; @@ -543,7 +520,7 @@ static int simple_parse_aux_devs(struct device_node *node, return 0; } -static int simple_parse_of(struct simple_priv *priv) +static int simple_parse_of(struct asoc_simple_priv *priv) { struct device *dev = simple_priv_to_dev(priv); struct device_node *top = dev->of_node; @@ -593,7 +570,7 @@ static int simple_parse_of(struct simple_priv *priv) return ret; } -static int simple_count_noml(struct simple_priv *priv, +static int simple_count_noml(struct asoc_simple_priv *priv, struct device_node *np, struct device_node *codec, struct link_info *li, bool is_top) @@ -605,7 +582,7 @@ static int simple_count_noml(struct simple_priv *priv, return 0; } -static int simple_count_dpcm(struct simple_priv *priv, +static int simple_count_dpcm(struct asoc_simple_priv *priv, struct device_node *np, struct device_node *codec, struct link_info *li, bool is_top) @@ -618,7 +595,7 @@ static int simple_count_dpcm(struct simple_priv *priv, return 0; } -static void simple_get_dais_count(struct simple_priv *priv, +static void simple_get_dais_count(struct asoc_simple_priv *priv, struct link_info *li) { struct device *dev = simple_priv_to_dev(priv); @@ -687,7 +664,7 @@ static void simple_get_dais_count(struct simple_priv *priv, static int simple_soc_probe(struct snd_soc_card *card) { - struct simple_priv *priv = snd_soc_card_get_drvdata(card); + struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(card); int ret; ret = asoc_simple_card_init_hp(card, &priv->hp_jack, PREFIX); @@ -703,7 +680,7 @@ static int simple_soc_probe(struct snd_soc_card *card) static int simple_probe(struct platform_device *pdev) { - struct simple_priv *priv; + struct asoc_simple_priv *priv; struct snd_soc_dai_link *dai_link; struct simple_dai_props *dai_props; struct asoc_simple_dai *dais; From patchwork Mon Mar 18 04:53:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10856881 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 B95346C2 for ; Mon, 18 Mar 2019 04:56:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 956B32924E for ; Mon, 18 Mar 2019 04:56:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89CC629250; Mon, 18 Mar 2019 04:56:03 +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 9AAFC2924E for ; Mon, 18 Mar 2019 04:56:02 +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 D603A872; Mon, 18 Mar 2019 05:55:10 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D603A872 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1552884960; bh=9OEEl4iEsbwZR50eJhLBcOYo9P6p2OXgTmpr+ZFMlxo=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=lULjsOcmwYBHPlYerBJSPjqonfxfjNeTvNt2PWZ6eTWtrrus/mmxCgq7kjciW5VHG 0+5f6FFFYvViAqzLFbJM7ZI3Ivm7Vgx41tMR+roHDvQ5JHt0xgvTs/LhMxoo7p5Tap EV4Lbc7/2AtHiPtv8PtzW2VsvoMVcwTsAZ6Z67n0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 86343F896FF; Mon, 18 Mar 2019 05:53:38 +0100 (CET) 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 A28D4F89719; Mon, 18 Mar 2019 05:53:36 +0100 (CET) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id 9C214F89706 for ; Mon, 18 Mar 2019 05:53:29 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9C214F89706 Date: 18 Mar 2019 13:53:28 +0900 X-IronPort-AV: E=Sophos;i="5.58,492,1544454000"; d="scan'208";a="10634034" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 18 Mar 2019 13:53:28 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 52FED41E841F; Mon, 18 Mar 2019 13:53:28 +0900 (JST) Message-ID: <87va0gyeum.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: <875zsgztld.wl-kuninori.morimoto.gx@renesas.com> References: <875zsgztld.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 07/15] ASoC: simple-card-utils: share asoc_simple_startup() 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 The difference between simple-card / audio-graph are just using OF graph style, or not. In other words, other things should be same. This means, simple-card/audio-graph common functions should be implemented at simple-card-utils, and its own functions should be implemented at each files. Current simple-card / audio-graph have almost same functions. This patch shares asoc_simple_startup() between in these 2 drivers. Signed-off-by: Kuninori Morimoto --- include/sound/simple_card_utils.h | 2 +- sound/soc/generic/audio-graph-card.c | 20 +------------------- sound/soc/generic/simple-card-utils.c | 22 ++++++++++++++++++++-- sound/soc/generic/simple-card.c | 21 +-------------------- 4 files changed, 23 insertions(+), 42 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index c0161ec..0653fb9 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -84,8 +84,8 @@ int asoc_simple_card_parse_clk(struct device *dev, 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); +int asoc_simple_startup(struct snd_pcm_substream *substream); #define asoc_simple_card_parse_cpu(node, dai_link, \ list_name, cells_name, is_single_link) \ diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 656ca49..29ae71b 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -56,24 +56,6 @@ static const struct snd_soc_dapm_widget graph_dapm_widgets[] = { SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), }; -static int graph_startup(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); - struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); - int ret; - - ret = asoc_simple_card_clk_enable(dai_props->cpu_dai); - if (ret) - return ret; - - ret = asoc_simple_card_clk_enable(dai_props->codec_dai); - if (ret) - asoc_simple_card_clk_disable(dai_props->cpu_dai); - - return ret; -} - static void graph_shutdown(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -117,7 +99,7 @@ static int graph_hw_params(struct snd_pcm_substream *substream, } static const struct snd_soc_ops graph_ops = { - .startup = graph_startup, + .startup = asoc_simple_startup, .shutdown = graph_shutdown, .hw_params = graph_hw_params, }; diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index f5ba5ad..83ea1af 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -143,14 +143,13 @@ int asoc_simple_card_parse_card_name(struct snd_soc_card *card, } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_name); -int asoc_simple_card_clk_enable(struct asoc_simple_dai *dai) +static int asoc_simple_card_clk_enable(struct asoc_simple_dai *dai) { if (dai) return clk_prepare_enable(dai->clk); return 0; } -EXPORT_SYMBOL_GPL(asoc_simple_card_clk_enable); void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai) { @@ -206,6 +205,25 @@ int asoc_simple_card_parse_clk(struct device *dev, } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_clk); +int asoc_simple_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); + int ret; + + ret = asoc_simple_card_clk_enable(dai_props->cpu_dai); + if (ret) + return ret; + + ret = asoc_simple_card_clk_enable(dai_props->codec_dai); + if (ret) + asoc_simple_card_clk_disable(dai_props->cpu_dai); + + return ret; +} +EXPORT_SYMBOL_GPL(asoc_simple_startup); + int asoc_simple_card_parse_dai(struct device_node *node, struct snd_soc_dai_link_component *dlc, struct device_node **dai_of_node, diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 628c19a..d0ea573 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -26,25 +26,6 @@ struct link_info { #define CELL "#sound-dai-cells" #define PREFIX "simple-audio-card," -static int simple_startup(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); - struct simple_dai_props *dai_props = - simple_priv_to_props(priv, rtd->num); - int ret; - - ret = asoc_simple_card_clk_enable(dai_props->cpu_dai); - if (ret) - return ret; - - ret = asoc_simple_card_clk_enable(dai_props->codec_dai); - if (ret) - asoc_simple_card_clk_disable(dai_props->cpu_dai); - - return ret; -} - static void simple_shutdown(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -114,7 +95,7 @@ static int simple_hw_params(struct snd_pcm_substream *substream, } static const struct snd_soc_ops simple_ops = { - .startup = simple_startup, + .startup = asoc_simple_startup, .shutdown = simple_shutdown, .hw_params = simple_hw_params, }; From patchwork Mon Mar 18 04:53:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10856883 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 A5E6D1390 for ; Mon, 18 Mar 2019 04:56:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 830702924E for ; Mon, 18 Mar 2019 04:56:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7510F29250; Mon, 18 Mar 2019 04:56:45 +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 9FA0E2924E for ; Mon, 18 Mar 2019 04:56:44 +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 C1F62884; Mon, 18 Mar 2019 05:55:52 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C1F62884 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1552885002; bh=Hhfu/JT+GvKLLQMRDbb3hAMb0/isYjin8IBgPoy6AVM=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=bpCZYTu1TRCy/j3+hQPwp46GRuOXekua9UPL2hs0kPNeYOHiESwvr0PTRp9n8i2/W r/YKOYRa11RNv5r9YUuhrQDfNDA0nBZIiP9YRgUJSVk62etygynMhiAC7PtHABKOQO sBYooMVSx6TY9AzxDg9nUirMvmwzoIc6e7VBng+c= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DDF5CF8971E; Mon, 18 Mar 2019 05:53:50 +0100 (CET) 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 2844AF89721; Mon, 18 Mar 2019 05:53:48 +0100 (CET) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 227E1F8971D for ; Mon, 18 Mar 2019 05:53:43 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 227E1F8971D Date: 18 Mar 2019 13:53:42 +0900 X-IronPort-AV: E=Sophos;i="5.58,492,1544454000"; d="scan'208";a="10425595" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 18 Mar 2019 13:53:42 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 3D2F441E841A; Mon, 18 Mar 2019 13:53:42 +0900 (JST) Message-ID: <87tvg0yeu8.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: <875zsgztld.wl-kuninori.morimoto.gx@renesas.com> References: <875zsgztld.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 08/15] ASoC: simple-card-utils: share asoc_simple_shutdown() 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 The difference between simple-card / audio-graph are just using OF graph style, or not. In other words, other things should be same. This means, simple-card/audio-graph common functions should be implemented at simple-card-utils, and its own functions should be implemented at each files. Current simple-card / audio-graph have almost same functions. This patch shares asoc_simple_shutdown() between in these 2 drivers. Signed-off-by: Kuninori Morimoto --- include/sound/simple_card_utils.h | 2 +- sound/soc/generic/audio-graph-card.c | 13 +------------ sound/soc/generic/simple-card-utils.c | 16 ++++++++++++++-- sound/soc/generic/simple-card.c | 14 +------------- 4 files changed, 17 insertions(+), 28 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 0653fb9..edda646 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -84,8 +84,8 @@ int asoc_simple_card_parse_clk(struct device *dev, struct asoc_simple_dai *simple_dai, const char *dai_name, struct snd_soc_dai_link_component *dlc); -void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai); int asoc_simple_startup(struct snd_pcm_substream *substream); +void asoc_simple_shutdown(struct snd_pcm_substream *substream); #define asoc_simple_card_parse_cpu(node, dai_link, \ list_name, cells_name, is_single_link) \ diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 29ae71b..f3577b5 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -56,17 +56,6 @@ static const struct snd_soc_dapm_widget graph_dapm_widgets[] = { SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), }; -static void graph_shutdown(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); - struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); - - asoc_simple_card_clk_disable(dai_props->cpu_dai); - - asoc_simple_card_clk_disable(dai_props->codec_dai); -} - static int graph_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { @@ -100,7 +89,7 @@ static int graph_hw_params(struct snd_pcm_substream *substream, static const struct snd_soc_ops graph_ops = { .startup = asoc_simple_startup, - .shutdown = graph_shutdown, + .shutdown = asoc_simple_shutdown, .hw_params = graph_hw_params, }; diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 83ea1af..7ede163 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -151,12 +151,11 @@ static int asoc_simple_card_clk_enable(struct asoc_simple_dai *dai) return 0; } -void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai) +static void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai) { if (dai) clk_disable_unprepare(dai->clk); } -EXPORT_SYMBOL_GPL(asoc_simple_card_clk_disable); int asoc_simple_card_parse_clk(struct device *dev, struct device_node *node, @@ -224,6 +223,19 @@ int asoc_simple_startup(struct snd_pcm_substream *substream) } EXPORT_SYMBOL_GPL(asoc_simple_startup); +void asoc_simple_shutdown(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct simple_dai_props *dai_props = + simple_priv_to_props(priv, rtd->num); + + asoc_simple_card_clk_disable(dai_props->cpu_dai); + + asoc_simple_card_clk_disable(dai_props->codec_dai); +} +EXPORT_SYMBOL_GPL(asoc_simple_shutdown); + int asoc_simple_card_parse_dai(struct device_node *node, struct snd_soc_dai_link_component *dlc, struct device_node **dai_of_node, diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index d0ea573..bb57c48 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -26,18 +26,6 @@ struct link_info { #define CELL "#sound-dai-cells" #define PREFIX "simple-audio-card," -static void simple_shutdown(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); - struct simple_dai_props *dai_props = - simple_priv_to_props(priv, rtd->num); - - asoc_simple_card_clk_disable(dai_props->cpu_dai); - - asoc_simple_card_clk_disable(dai_props->codec_dai); -} - static int simple_set_clk_rate(struct asoc_simple_dai *simple_dai, unsigned long rate) { @@ -96,7 +84,7 @@ static int simple_hw_params(struct snd_pcm_substream *substream, static const struct snd_soc_ops simple_ops = { .startup = asoc_simple_startup, - .shutdown = simple_shutdown, + .shutdown = asoc_simple_shutdown, .hw_params = simple_hw_params, }; From patchwork Mon Mar 18 04:53:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10856885 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 7604B1669 for ; Mon, 18 Mar 2019 04:57:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5209329250 for ; Mon, 18 Mar 2019 04:57:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43E7229253; Mon, 18 Mar 2019 04:57:25 +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 41C2129250 for ; Mon, 18 Mar 2019 04:57:24 +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 7BFD788A; Mon, 18 Mar 2019 05:56:32 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7BFD788A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1552885042; bh=o69IJrICtTwjbLF4oh+DTaELcuoDznC/F/HBgaJO76A=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=s01wFvuP9vvPK0e9wmpvvdst+MiHH/SvH71apWSgL9FtyMuDdQRJPUi6tYV4uRVi7 DALhn+aFCiW9mkNWc4aX23+kxFv7+mIIdoM43ZAVScwnOBbS2yP49+yP3eVxTCi0cy kYtPPau3gW9gVWAjLvcLtcTR9oT6mLwhfb08CSSE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 78D59F8971F; Mon, 18 Mar 2019 05:54:04 +0100 (CET) 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 19757F89729; Mon, 18 Mar 2019 05:54:01 +0100 (CET) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 52D3DF89725 for ; Mon, 18 Mar 2019 05:53:56 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 52D3DF89725 Date: 18 Mar 2019 13:53:55 +0900 X-IronPort-AV: E=Sophos;i="5.58,492,1544454000"; d="scan'208";a="10425606" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 18 Mar 2019 13:53:55 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 0915E401BA29; Mon, 18 Mar 2019 13:53:55 +0900 (JST) Message-ID: <87sgvkyetv.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: <875zsgztld.wl-kuninori.morimoto.gx@renesas.com> References: <875zsgztld.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 09/15] ASoC: simple-card-utils: share asoc_simple_hw_param() 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 The difference between simple-card / audio-graph are just using OF graph style, or not. In other words, other things should be same. This means, simple-card/audio-graph common functions should be implemented at simple-card-utils, and its own functions should be implemented at each files. Current simple-card / audio-graph have almost same functions. This patch shares asoc_simple_hw_param() between in these 2 drivers. One note is that only simple-card supports simple_set_clk_rate() at hw_param from commit e9be4ffd4f40fcb ("ASoC: simple-card: set cpu dai clk in hw_params"). By this patch, audio-graph has same feature. Signed-off-by: Kuninori Morimoto --- include/sound/simple_card_utils.h | 2 ++ sound/soc/generic/audio-graph-card.c | 33 +------------------- sound/soc/generic/simple-card-utils.c | 57 ++++++++++++++++++++++++++++++++++ sound/soc/generic/simple-card.c | 58 +---------------------------------- 4 files changed, 61 insertions(+), 89 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index edda646..89ae084 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -86,6 +86,8 @@ int asoc_simple_card_parse_clk(struct device *dev, 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); +int asoc_simple_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params); #define asoc_simple_card_parse_cpu(node, dai_link, \ list_name, cells_name, is_single_link) \ diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index f3577b5..51160ad 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -56,41 +56,10 @@ static const struct snd_soc_dapm_widget graph_dapm_widgets[] = { SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), }; -static int graph_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); - struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); - unsigned int mclk, mclk_fs = 0; - int ret = 0; - - if (dai_props->mclk_fs) - mclk_fs = dai_props->mclk_fs; - - if (mclk_fs) { - mclk = params_rate(params) * mclk_fs; - ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, - SND_SOC_CLOCK_IN); - if (ret && ret != -ENOTSUPP) - goto err; - - ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk, - SND_SOC_CLOCK_OUT); - if (ret && ret != -ENOTSUPP) - goto err; - } - return 0; -err: - return ret; -} - static const struct snd_soc_ops graph_ops = { .startup = asoc_simple_startup, .shutdown = asoc_simple_shutdown, - .hw_params = graph_hw_params, + .hw_params = asoc_simple_hw_params, }; static int graph_dai_init(struct snd_soc_pcm_runtime *rtd) diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 7ede163..de23cf8 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -236,6 +236,63 @@ void asoc_simple_shutdown(struct snd_pcm_substream *substream) } EXPORT_SYMBOL_GPL(asoc_simple_shutdown); +static int asoc_simple_set_clk_rate(struct asoc_simple_dai *simple_dai, + unsigned long rate) +{ + if (!simple_dai) + return 0; + + if (!simple_dai->clk) + return 0; + + if (clk_get_rate(simple_dai->clk) == rate) + return 0; + + return clk_set_rate(simple_dai->clk, rate); +} + +int asoc_simple_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct simple_dai_props *dai_props = + simple_priv_to_props(priv, rtd->num); + unsigned int mclk, mclk_fs = 0; + int ret = 0; + + if (dai_props->mclk_fs) + mclk_fs = dai_props->mclk_fs; + + if (mclk_fs) { + mclk = params_rate(params) * mclk_fs; + + ret = asoc_simple_set_clk_rate(dai_props->codec_dai, mclk); + if (ret < 0) + return ret; + + ret = asoc_simple_set_clk_rate(dai_props->cpu_dai, mclk); + if (ret < 0) + return ret; + + ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, + SND_SOC_CLOCK_IN); + if (ret && ret != -ENOTSUPP) + goto err; + + ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk, + SND_SOC_CLOCK_OUT); + if (ret && ret != -ENOTSUPP) + goto err; + } + return 0; +err: + return ret; +} +EXPORT_SYMBOL_GPL(asoc_simple_hw_params); + int asoc_simple_card_parse_dai(struct device_node *node, struct snd_soc_dai_link_component *dlc, struct device_node **dai_of_node, diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index bb57c48..7e83647 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -26,66 +26,10 @@ struct link_info { #define CELL "#sound-dai-cells" #define PREFIX "simple-audio-card," -static int simple_set_clk_rate(struct asoc_simple_dai *simple_dai, - unsigned long rate) -{ - if (!simple_dai) - return 0; - - if (!simple_dai->clk) - return 0; - - if (clk_get_rate(simple_dai->clk) == rate) - return 0; - - return clk_set_rate(simple_dai->clk, rate); -} - -static int simple_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); - struct simple_dai_props *dai_props = - simple_priv_to_props(priv, rtd->num); - unsigned int mclk, mclk_fs = 0; - int ret = 0; - - if (dai_props->mclk_fs) - mclk_fs = dai_props->mclk_fs; - - if (mclk_fs) { - mclk = params_rate(params) * mclk_fs; - - ret = simple_set_clk_rate(dai_props->codec_dai, mclk); - if (ret < 0) - return ret; - - ret = simple_set_clk_rate(dai_props->cpu_dai, mclk); - if (ret < 0) - return ret; - - ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, - SND_SOC_CLOCK_IN); - if (ret && ret != -ENOTSUPP) - goto err; - - ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk, - SND_SOC_CLOCK_OUT); - if (ret && ret != -ENOTSUPP) - goto err; - } - return 0; -err: - return ret; -} - static const struct snd_soc_ops simple_ops = { .startup = asoc_simple_startup, .shutdown = asoc_simple_shutdown, - .hw_params = simple_hw_params, + .hw_params = asoc_simple_hw_params, }; static int simple_dai_init(struct snd_soc_pcm_runtime *rtd) From patchwork Mon Mar 18 04:54:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10856887 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 EBAA36C2 for ; Mon, 18 Mar 2019 04:58:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA02329250 for ; Mon, 18 Mar 2019 04:58:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBD1929253; Mon, 18 Mar 2019 04:58:04 +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 57EEA29250 for ; Mon, 18 Mar 2019 04:58:03 +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 970CD847; Mon, 18 Mar 2019 05:57:11 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 970CD847 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1552885081; bh=rl10VJum2ZqL6/ISLJJV6oyE6OUhHBFjNlc7q9oqHkc=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=La4xLOFRPQCjjCFnfK2Q74DyG8RUoyfIElnKBq58QhuNfqajqWrG+YKOIW3fcBAsh vxrAZ0yZ4ulUWfXGLCK4gWbu9SxG1M44oIXBGnvoNniiNNGxtwhpeksIVvYoycsw86 iUmKCHSw2cNRjA1U17WekoyA9CzWizKUXqI+tUuY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3BC5FF89716; Mon, 18 Mar 2019 05:54:21 +0100 (CET) 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 3F8EEF89728; Mon, 18 Mar 2019 05:54:19 +0100 (CET) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id EF239F89720 for ; Mon, 18 Mar 2019 05:54:10 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz EF239F89720 Date: 18 Mar 2019 13:54:09 +0900 X-IronPort-AV: E=Sophos;i="5.58,492,1544454000"; d="scan'208";a="10425629" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 18 Mar 2019 13:54:09 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 047C141E8425; Mon, 18 Mar 2019 13:54:09 +0900 (JST) Message-ID: <87r2b4yeth.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: <875zsgztld.wl-kuninori.morimoto.gx@renesas.com> References: <875zsgztld.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 10/15] ASoC: simple-card-utils: share asoc_simple_dai_init() 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 The difference between simple-card / audio-graph are just using OF graph style, or not. In other words, other things should be same. This means, simple-card/audio-graph common functions should be implemented at simple-card-utils, and its own functions should be implemented at each files. Current simple-card / audio-graph have almost same functions. This patch shares asoc_simple_dai_init() between in these 2 drivers. Signed-off-by: Kuninori Morimoto --- include/sound/simple_card_utils.h | 4 +--- sound/soc/generic/audio-graph-card.c | 23 ++--------------------- sound/soc/generic/simple-card-utils.c | 25 ++++++++++++++++++++++--- sound/soc/generic/simple-card.c | 25 +++---------------------- 4 files changed, 28 insertions(+), 49 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 89ae084..2043437 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -88,6 +88,7 @@ int asoc_simple_startup(struct snd_pcm_substream *substream); void asoc_simple_shutdown(struct snd_pcm_substream *substream); int asoc_simple_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params); +int asoc_simple_dai_init(struct snd_soc_pcm_runtime *rtd); #define asoc_simple_card_parse_cpu(node, dai_link, \ list_name, cells_name, is_single_link) \ @@ -130,9 +131,6 @@ int asoc_simple_card_parse_graph_dai(struct device_node *ep, &(dai)->slots, \ &(dai)->slot_width); -int asoc_simple_card_init_dai(struct snd_soc_dai *dai, - struct asoc_simple_dai *simple_dai); - void asoc_simple_card_canonicalize_platform(struct snd_soc_dai_link *dai_link); void asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link *dai_link, int is_single_links); diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 51160ad..b1ceefc 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -62,25 +62,6 @@ static const struct snd_soc_ops graph_ops = { .hw_params = asoc_simple_hw_params, }; -static int graph_dai_init(struct snd_soc_pcm_runtime *rtd) -{ - struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); - struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); - int ret = 0; - - ret = asoc_simple_card_init_dai(rtd->codec_dai, - dai_props->codec_dai); - if (ret < 0) - return ret; - - ret = asoc_simple_card_init_dai(rtd->cpu_dai, - dai_props->cpu_dai); - if (ret < 0) - return ret; - - return 0; -} - static int graph_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { @@ -255,7 +236,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai_link->dpcm_playback = 1; dai_link->dpcm_capture = 1; dai_link->ops = &graph_ops; - dai_link->init = graph_dai_init; + dai_link->init = asoc_simple_dai_init; return 0; } @@ -327,7 +308,7 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv, return ret; dai_link->ops = &graph_ops; - dai_link->init = graph_dai_init; + dai_link->init = asoc_simple_dai_init; asoc_simple_card_canonicalize_platform(dai_link); asoc_simple_card_canonicalize_cpu(dai_link, diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index de23cf8..c9b53b3 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -436,8 +436,8 @@ int asoc_simple_card_parse_graph_dai(struct device_node *ep, } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_graph_dai); -int asoc_simple_card_init_dai(struct snd_soc_dai *dai, - struct asoc_simple_dai *simple_dai) +static int asoc_simple_card_init_dai(struct snd_soc_dai *dai, + struct asoc_simple_dai *simple_dai) { int ret; @@ -467,7 +467,26 @@ int asoc_simple_card_init_dai(struct snd_soc_dai *dai, return 0; } -EXPORT_SYMBOL_GPL(asoc_simple_card_init_dai); + +int asoc_simple_dai_init(struct snd_soc_pcm_runtime *rtd) +{ + struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); + int ret; + + ret = asoc_simple_card_init_dai(rtd->codec_dai, + dai_props->codec_dai); + if (ret < 0) + return ret; + + ret = asoc_simple_card_init_dai(rtd->cpu_dai, + dai_props->cpu_dai); + if (ret < 0) + return ret; + + return 0; +} +EXPORT_SYMBOL_GPL(asoc_simple_dai_init); void asoc_simple_card_canonicalize_platform(struct snd_soc_dai_link *dai_link) { diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 7e83647..bf4482e 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -32,25 +32,6 @@ static const struct snd_soc_ops simple_ops = { .hw_params = asoc_simple_hw_params, }; -static int simple_dai_init(struct snd_soc_pcm_runtime *rtd) -{ - struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); - struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); - int ret; - - ret = asoc_simple_card_init_dai(rtd->codec_dai, - dai_props->codec_dai); - if (ret < 0) - return ret; - - ret = asoc_simple_card_init_dai(rtd->cpu_dai, - dai_props->cpu_dai); - if (ret < 0) - return ret; - - return 0; -} - static int simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { @@ -221,7 +202,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai_link->dpcm_playback = 1; dai_link->dpcm_capture = 1; dai_link->ops = &simple_ops; - dai_link->init = simple_dai_init; + dai_link->init = asoc_simple_dai_init; return 0; } @@ -316,7 +297,7 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv, goto dai_link_of_err; dai_link->ops = &simple_ops; - dai_link->init = simple_dai_init; + dai_link->init = asoc_simple_dai_init; asoc_simple_card_canonicalize_cpu(dai_link, single_cpu); asoc_simple_card_canonicalize_platform(dai_link); @@ -694,7 +675,7 @@ static int simple_probe(struct platform_device *pdev) 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; + dai_link->init = asoc_simple_dai_init; memcpy(priv->dai_props->cpu_dai, &cinfo->cpu_dai, sizeof(*priv->dai_props->cpu_dai)); memcpy(priv->dai_props->codec_dai, &cinfo->codec_dai, From patchwork Mon Mar 18 04:54:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10856889 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 03DBA1669 for ; Mon, 18 Mar 2019 04:58:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2E3C29250 for ; Mon, 18 Mar 2019 04:58:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C700729253; Mon, 18 Mar 2019 04:58:54 +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 0707429250 for ; Mon, 18 Mar 2019 04:58:53 +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 1FEAE88D; Mon, 18 Mar 2019 05:58:02 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1FEAE88D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1552885132; bh=fjSY3le4xEZGMJN3F8D+uNV/lrtMDEy8grEtqgRp84o=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=qt8ZHhk3Juy3VD6Fnooyr0MAo0ZjHb0usMc+OGwYE2faWDyiP4/JKrC+HB976xn4t 2GmBli67LH4mpuEDJiApPplsAVJXugM7933ktCGQQzgvthCMlexByg99sSXeuJSbsE PE6cG7zgeZa+S2ovgS9eYjw+f0l2GJc3PzIbeXqM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 49BEFF89730; Mon, 18 Mar 2019 05:54:37 +0100 (CET) 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 B0743F89731; Mon, 18 Mar 2019 05:54:35 +0100 (CET) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 0821FF89722 for ; Mon, 18 Mar 2019 05:54:31 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0821FF89722 Date: 18 Mar 2019 13:54:30 +0900 X-IronPort-AV: E=Sophos;i="5.58,492,1544454000"; d="scan'208";a="10425660" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 18 Mar 2019 13:54:30 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id AE12741E8428; Mon, 18 Mar 2019 13:54:30 +0900 (JST) Message-ID: <87pnqoyesw.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: <875zsgztld.wl-kuninori.morimoto.gx@renesas.com> References: <875zsgztld.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 11/15] ASoC: simple-card-utils: share asoc_simple_be_hw_params_fixup() 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 The difference between simple-card / audio-graph are just using OF graph style, or not. In other words, other things should be same. This means, simple-card/audio-graph common functions should be implemented at simple-card-utils, and its own functions should be implemented at each files. Current simple-card / audio-graph have almost same functions. This patch shares asoc_simple_be_hw_params_fixup() between in these 2 drivers. Signed-off-by: Kuninori Morimoto --- include/sound/simple_card_utils.h | 2 ++ sound/soc/generic/audio-graph-card.c | 13 +------------ sound/soc/generic/simple-card-utils.c | 12 ++++++++++++ sound/soc/generic/simple-card.c | 13 +------------ 4 files changed, 16 insertions(+), 24 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 2043437..20d41bb 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -89,6 +89,8 @@ void asoc_simple_shutdown(struct snd_pcm_substream *substream); int asoc_simple_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params); int asoc_simple_dai_init(struct snd_soc_pcm_runtime *rtd); +int asoc_simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params); #define asoc_simple_card_parse_cpu(node, dai_link, \ list_name, cells_name, is_single_link) \ diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index b1ceefc..605126f 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -62,17 +62,6 @@ static const struct snd_soc_ops graph_ops = { .hw_params = asoc_simple_hw_params, }; -static int graph_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); - struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); - - asoc_simple_card_convert_fixup(&dai_props->adata, params); - - return 0; -} - static void graph_parse_convert(struct device *dev, struct device_node *ep, struct asoc_simple_card_data *adata) @@ -186,7 +175,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, /* BE settings */ dai_link->no_pcm = 1; - dai_link->be_hw_params_fixup = graph_be_hw_params_fixup; + dai_link->be_hw_params_fixup = asoc_simple_be_hw_params_fixup; dai = dai_props->codec_dai = &priv->dais[li->dais++]; diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index c9b53b3..ec4a010 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -293,6 +293,18 @@ int asoc_simple_hw_params(struct snd_pcm_substream *substream, } EXPORT_SYMBOL_GPL(asoc_simple_hw_params); +int asoc_simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); + + asoc_simple_card_convert_fixup(&dai_props->adata, params); + + return 0; +} +EXPORT_SYMBOL_GPL(asoc_simple_be_hw_params_fixup); + int asoc_simple_card_parse_dai(struct device_node *node, struct snd_soc_dai_link_component *dlc, struct device_node **dai_of_node, diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index bf4482e..60a88a5 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -32,17 +32,6 @@ static const struct snd_soc_ops simple_ops = { .hw_params = asoc_simple_hw_params, }; -static int simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); - struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); - - asoc_simple_card_convert_fixup(&dai_props->adata, params); - - return 0; -} - static void simple_parse_convert(struct device *dev, struct device_node *np, struct asoc_simple_card_data *adata) @@ -154,7 +143,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, /* BE settings */ dai_link->no_pcm = 1; - dai_link->be_hw_params_fixup = simple_be_hw_params_fixup; + dai_link->be_hw_params_fixup = asoc_simple_be_hw_params_fixup; dai = dai_props->codec_dai = &priv->dais[li->dais++]; From patchwork Mon Mar 18 04:54:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10856891 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 8C3AB6C2 for ; Mon, 18 Mar 2019 04:59:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 649C020748 for ; Mon, 18 Mar 2019 04:59:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55623287E8; Mon, 18 Mar 2019 04:59:35 +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 4BA6820748 for ; Mon, 18 Mar 2019 04:59:34 +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 5FCA9882; Mon, 18 Mar 2019 05:58:42 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5FCA9882 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1552885172; bh=JNqc1dKdrDM9d6tgG9BP0xlEg9xARsra81YgDN9Yo+Y=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=eI+Hfr+X1KWZb8+j6yNcx8BQkOhQllsfKAMmFCx1RNOW+GNqTkG5lOG/aY0PsBetB tYht/1nf/iwv9XVlkjPtc23xDD5S8FAhlaba2MBv1r57dU3uOohCsmDEbh3CQPyey2 qwYpl0PHkcffVN5VnMtijoBWYgXzyKPMFtyDoxSY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 38FE5F89734; Mon, 18 Mar 2019 05:55:00 +0100 (CET) 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 F11B3F89734; Mon, 18 Mar 2019 05:54:58 +0100 (CET) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id C471AF80792 for ; Mon, 18 Mar 2019 05:54:52 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C471AF80792 Date: 18 Mar 2019 13:54:49 +0900 X-IronPort-AV: E=Sophos;i="5.58,492,1544454000"; d="scan'208";a="10634179" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 18 Mar 2019 13:54:49 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id E3EB0401BA25; Mon, 18 Mar 2019 13:54:49 +0900 (JST) Message-ID: <87o968yesc.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: <875zsgztld.wl-kuninori.morimoto.gx@renesas.com> References: <875zsgztld.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 12/15] ASoC: simple-card-utils: share asoc_simple_card_init_priv() 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 The difference between simple-card / audio-graph are just using OF graph style, or not. In other words, other things should be same. This means, simple-card/audio-graph common functions should be implemented at simple-card-utils, and its own functions should be implemented at each files. Current simple-card / audio-graph are initializing each priv, but it is same operation. This patch adds new asoc_simple_card_init_priv() and initialize priv by same operation. Signed-off-by: Kuninori Morimoto --- include/sound/simple_card_utils.h | 10 ++++++- sound/soc/generic/audio-graph-card.c | 45 +++------------------------- sound/soc/generic/simple-card-utils.c | 48 ++++++++++++++++++++++++++++++ sound/soc/generic/simple-card.c | 56 +++++++---------------------------- 4 files changed, 72 insertions(+), 87 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 20d41bb..c0be02d 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -60,6 +60,13 @@ struct asoc_simple_priv { #define simple_priv_to_dev(priv) (simple_priv_to_card(priv)->dev) #define simple_priv_to_link(priv, i) (simple_priv_to_card(priv)->dai_link + (i)) +struct link_info { + int dais; /* number of dai */ + int link; /* number of link */ + int conf; /* number of codec_conf */ + int cpu; /* turn for CPU / Codec */ +}; + int asoc_simple_card_parse_daifmt(struct device *dev, struct device_node *node, struct device_node *codec, @@ -153,7 +160,8 @@ int asoc_simple_card_of_parse_widgets(struct snd_soc_card *card, int asoc_simple_card_init_jack(struct snd_soc_card *card, struct asoc_simple_jack *sjack, int is_hp, char *prefix); - +int asoc_simple_card_init_priv(struct asoc_simple_priv *priv, + struct link_info *li); #ifdef DEBUG inline void asoc_simple_debug_dai(struct asoc_simple_priv *priv, diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 605126f..b9a9337 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -20,13 +20,6 @@ #include #include -struct link_info { - int dais; /* number of dai */ - int link; /* number of link */ - int conf; /* number of codec_conf */ - int cpu; /* turn for CPU / Codec */ -}; - #define PREFIX "audio-graph-card," static int graph_outdrv_event(struct snd_soc_dapm_widget *w, @@ -526,14 +519,10 @@ static int graph_card_probe(struct snd_soc_card *card) static int graph_probe(struct platform_device *pdev) { struct asoc_simple_priv *priv; - struct snd_soc_dai_link *dai_link; - struct simple_dai_props *dai_props; - struct asoc_simple_dai *dais; struct device *dev = &pdev->dev; struct snd_soc_card *card; - struct snd_soc_codec_conf *cconf; struct link_info li; - int ret, i; + int ret; /* Allocate the private data and the DAI link array */ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); @@ -552,25 +541,9 @@ static int graph_probe(struct platform_device *pdev) if (!li.link || !li.dais) return -EINVAL; - dai_props = devm_kcalloc(dev, li.link, sizeof(*dai_props), GFP_KERNEL); - dai_link = devm_kcalloc(dev, li.link, sizeof(*dai_link), GFP_KERNEL); - dais = devm_kcalloc(dev, li.dais, sizeof(*dais), GFP_KERNEL); - cconf = devm_kcalloc(dev, li.conf, sizeof(*cconf), GFP_KERNEL); - if (!dai_props || !dai_link || !dais) - return -ENOMEM; - - /* - * Use snd_soc_dai_link_component instead of legacy style - * It is codec only. but cpu/platform will be supported in the future. - * see - * soc-core.c :: snd_soc_init_multicodec() - */ - for (i = 0; i < li.link; i++) { - dai_link[i].codecs = &dai_props[i].codecs; - dai_link[i].num_codecs = 1; - dai_link[i].platforms = &dai_props[i].platforms; - dai_link[i].num_platforms = 1; - } + ret = asoc_simple_card_init_priv(priv, &li); + if (ret < 0) + return ret; priv->pa_gpio = devm_gpiod_get_optional(dev, "pa", GPIOD_OUT_LOW); if (IS_ERR(priv->pa_gpio)) { @@ -579,16 +552,6 @@ static int graph_probe(struct platform_device *pdev) return ret; } - priv->dai_props = dai_props; - priv->dai_link = dai_link; - priv->dais = dais; - priv->codec_conf = cconf; - - card->dai_link = dai_link; - card->num_links = li.link; - card->codec_conf = cconf; - card->num_configs = li.conf; - ret = graph_parse_of(priv); if (ret < 0) { if (ret != -EPROBE_DEFER) diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index ec4a010..69d0b4c 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -630,6 +630,54 @@ int asoc_simple_card_init_jack(struct snd_soc_card *card, } EXPORT_SYMBOL_GPL(asoc_simple_card_init_jack); +int asoc_simple_card_init_priv(struct asoc_simple_priv *priv, + struct link_info *li) +{ + struct snd_soc_card *card = simple_priv_to_card(priv); + struct device *dev = simple_priv_to_dev(priv); + struct snd_soc_dai_link *dai_link; + struct simple_dai_props *dai_props; + struct asoc_simple_dai *dais; + struct snd_soc_codec_conf *cconf; + int i; + + dai_props = devm_kcalloc(dev, li->link, sizeof(*dai_props), GFP_KERNEL); + dai_link = devm_kcalloc(dev, li->link, sizeof(*dai_link), GFP_KERNEL); + dais = devm_kcalloc(dev, li->dais, sizeof(*dais), GFP_KERNEL); + cconf = devm_kcalloc(dev, li->conf, sizeof(*cconf), GFP_KERNEL); + if (!dai_props || !dai_link || !dais) + return -ENOMEM; + + /* + * Use snd_soc_dai_link_component instead of legacy style + * It is codec only. but cpu/platform will be supported in the future. + * see + * soc-core.c :: snd_soc_init_multicodec() + * + * "platform" might be removed + * see + * simple-card-utils.c :: asoc_simple_card_canonicalize_platform() + */ + for (i = 0; i < li->link; i++) { + dai_link[i].codecs = &dai_props[i].codecs; + dai_link[i].num_codecs = 1; + dai_link[i].platforms = &dai_props[i].platforms; + dai_link[i].num_platforms = 1; + } + + priv->dai_props = dai_props; + priv->dai_link = dai_link; + priv->dais = dais; + priv->codec_conf = cconf; + + card->dai_link = priv->dai_link; + card->num_links = li->link; + card->codec_conf = cconf; + card->num_configs = li->conf; + + return 0; +} + /* Module information */ MODULE_AUTHOR("Kuninori Morimoto "); MODULE_DESCRIPTION("ALSA SoC Simple Card Utils"); diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 60a88a5..4e3e6b3 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -15,13 +15,6 @@ #include #include -struct link_info { - int dais; /* number of dai */ - int link; /* number of link */ - int conf; /* number of codec_conf */ - int cpu; /* turn for CPU / Codec */ -}; - #define DAI "sound-dai" #define CELL "#sound-dai-cells" #define PREFIX "simple-audio-card," @@ -564,15 +557,11 @@ static int simple_soc_probe(struct snd_soc_card *card) static int simple_probe(struct platform_device *pdev) { struct asoc_simple_priv *priv; - struct snd_soc_dai_link *dai_link; - struct simple_dai_props *dai_props; - struct asoc_simple_dai *dais; struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; struct snd_soc_card *card; - struct snd_soc_codec_conf *cconf; struct link_info li; - int ret, i; + int ret; /* Allocate the private data and the DAI link array */ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); @@ -589,35 +578,9 @@ static int simple_probe(struct platform_device *pdev) if (!li.link || !li.dais) return -EINVAL; - dai_props = devm_kcalloc(dev, li.link, sizeof(*dai_props), GFP_KERNEL); - dai_link = devm_kcalloc(dev, li.link, sizeof(*dai_link), GFP_KERNEL); - dais = devm_kcalloc(dev, li.dais, sizeof(*dais), GFP_KERNEL); - cconf = devm_kcalloc(dev, li.conf, sizeof(*cconf), GFP_KERNEL); - if (!dai_props || !dai_link || !dais) - return -ENOMEM; - - /* - * Use snd_soc_dai_link_component instead of legacy style - * It is codec only. but cpu/platform will be supported in the future. - * see - * soc-core.c :: snd_soc_init_multicodec() - */ - for (i = 0; i < li.link; i++) { - dai_link[i].codecs = &dai_props[i].codecs; - dai_link[i].num_codecs = 1; - dai_link[i].platforms = &dai_props[i].platforms; - dai_link[i].num_platforms = 1; - } - - priv->dai_props = dai_props; - priv->dai_link = dai_link; - priv->dais = dais; - priv->codec_conf = cconf; - - card->dai_link = priv->dai_link; - card->num_links = li.link; - card->codec_conf = cconf; - card->num_configs = li.conf; + ret = asoc_simple_card_init_priv(priv, &li); + if (ret < 0) + return ret; if (np && of_device_is_available(np)) { @@ -632,6 +595,9 @@ static int simple_probe(struct platform_device *pdev) struct asoc_simple_card_info *cinfo; struct snd_soc_dai_link_component *codecs; struct snd_soc_dai_link_component *platform; + struct snd_soc_dai_link *dai_link = priv->dai_link; + struct simple_dai_props *dai_props = priv->dai_props; + int dai_idx = 0; cinfo = dev->platform_data; @@ -665,10 +631,10 @@ static int simple_probe(struct platform_device *pdev) dai_link->cpu_dai_name = cinfo->cpu_dai.name; dai_link->dai_fmt = cinfo->daifmt; dai_link->init = asoc_simple_dai_init; - memcpy(priv->dai_props->cpu_dai, &cinfo->cpu_dai, - sizeof(*priv->dai_props->cpu_dai)); - memcpy(priv->dai_props->codec_dai, &cinfo->codec_dai, - sizeof(*priv->dai_props->codec_dai)); + memcpy(dai_props->cpu_dai, &cinfo->cpu_dai, + sizeof(*dai_props->cpu_dai)); + memcpy(dai_props->codec_dai, &cinfo->codec_dai, + sizeof(*dai_props->codec_dai)); } snd_soc_card_set_drvdata(card, priv); From patchwork Mon Mar 18 04:55:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10856893 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 6091A6C2 for ; Mon, 18 Mar 2019 05:00:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35FDA29250 for ; Mon, 18 Mar 2019 05:00:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 29D1A29258; Mon, 18 Mar 2019 05:00:09 +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 E12C029250 for ; Mon, 18 Mar 2019 05:00:06 +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 1CDDB920; Mon, 18 Mar 2019 05:59:15 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1CDDB920 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1552885205; bh=MVSu5fTd2cwCs1VxSRZbGUscstLM6q5QDjIoEpWYYJk=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=WFrRTmdaHvUJQJ81oM/6w9Iw3jD+r1w81giNBeW+Lw7tFF+LXJvlWNHHtoiKaxDnp SJuIW2ZYD84AGeI/DVwtgxDz0jizn+FPTZtwsxUl8t4q8O27EZU1yphI++URoGTCtf P3TgwwRGsrPPpDcgjd6kbio9QRbzEQ30B/2rqr10= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6B106F80C0B; Mon, 18 Mar 2019 05:55:35 +0100 (CET) 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 5DF9CF80C0F; Mon, 18 Mar 2019 05:55:34 +0100 (CET) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id 88F3CF80792 for ; Mon, 18 Mar 2019 05:55:27 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 88F3CF80792 Date: 18 Mar 2019 13:55:26 +0900 X-IronPort-AV: E=Sophos;i="5.58,492,1544454000"; d="scan'208";a="10634232" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 18 Mar 2019 13:55:26 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 41C6F41E843F; Mon, 18 Mar 2019 13:55:26 +0900 (JST) Message-ID: <87mulsyerc.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: <875zsgztld.wl-kuninori.morimoto.gx@renesas.com> References: <875zsgztld.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 13/15] ASoC: simple-card-utils: separate asoc_simple_card_parse_dai() 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 The difference between simple-card / audio-graph are just using OF graph style, or not. In other words, other things should be same. This means, simple-card/audio-graph common functions should be implemented at simple-card-utils, and its own functions should be implemented at each files. Current simple-card / audio-graph are using asoc_simple_card_parse_dai() which is different implementation. But, these are implemanted at simple-card-utils. It should be implemanted at each files. This patch separate these into each files. Signed-off-by: Kuninori Morimoto --- include/sound/simple_card_utils.h | 39 ++-------- sound/soc/generic/audio-graph-card.c | 114 ++++++++++++++++++++++++--- sound/soc/generic/simple-card-utils.c | 143 ---------------------------------- sound/soc/generic/simple-card.c | 58 ++++++++++++-- 4 files changed, 164 insertions(+), 190 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index c0be02d..0c070c2 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -99,40 +99,17 @@ int asoc_simple_dai_init(struct snd_soc_pcm_runtime *rtd); int asoc_simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params); -#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) -#define asoc_simple_card_parse_codec(node, dai_link, list_name, cells_name) \ +#define asoc_simple_card_parse_cpu(node, dai_link, is_single_link) \ + asoc_simple_card_parse_dai(node, NULL, \ + &dai_link->cpu_of_node, \ + &dai_link->cpu_dai_name, is_single_link) +#define asoc_simple_card_parse_codec(node, dai_link) \ asoc_simple_card_parse_dai(node, dai_link->codecs, \ &dai_link->codec_of_node, \ - &dai_link->codec_dai_name, \ - list_name, cells_name, NULL) -#define asoc_simple_card_parse_platform(node, dai_link, list_name, cells_name) \ + &dai_link->codec_dai_name, NULL) +#define asoc_simple_card_parse_platform(node, dai_link) \ asoc_simple_card_parse_dai(node, dai_link->platforms, \ - &dai_link->platform_of_node, \ - NULL, list_name, cells_name, 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); - -#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) -#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) -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); + &dai_link->platform_of_node, NULL, NULL) #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 b9a9337..3370b6f 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -55,6 +55,103 @@ static const struct snd_soc_ops graph_ops = { .hw_params = asoc_simple_hw_params, }; +static int graph_get_dai_id(struct device_node *ep) +{ + struct device_node *node; + struct device_node *endpoint; + struct of_endpoint info; + int i, id; + int ret; + + /* use driver specified DAI ID if exist */ + ret = snd_soc_get_dai_id(ep); + if (ret != -ENOTSUPP) + return ret; + + /* use endpoint/port reg if exist */ + ret = of_graph_parse_endpoint(ep, &info); + if (ret == 0) { + /* + * Because it will count port/endpoint if it doesn't have "reg". + * But, we can't judge whether it has "no reg", or "reg = <0>" + * only of_graph_parse_endpoint(). + * We need to check "reg" property + */ + if (of_get_property(ep, "reg", NULL)) + return info.id; + + node = of_get_parent(ep); + of_node_put(node); + if (of_get_property(node, "reg", NULL)) + return info.port; + } + node = of_graph_get_port_parent(ep); + + /* + * Non HDMI sound case, counting port/endpoint on its DT + * is enough. Let's count it. + */ + i = 0; + id = -1; + for_each_endpoint_of_node(node, endpoint) { + if (endpoint == ep) + id = i; + i++; + } + + of_node_put(node); + + if (id < 0) + return -ENODEV; + + return id; +} + +static int asoc_simple_card_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); + + /* Get dai->name */ + args.np = node; + 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); + if (ret < 0) + return ret; + + *dai_of_node = node; + + if (is_single_link) + *is_single_link = of_graph_get_endpoint_count(node) == 1; + + return 0; +} + static void graph_parse_convert(struct device *dev, struct device_node *ep, struct asoc_simple_card_data *adata) @@ -128,6 +225,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, of_node_put(node); if (li->cpu) { + int is_single_links = 0; /* BE is dummy */ codecs->of_node = NULL; @@ -141,7 +239,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai = dai_props->cpu_dai = &priv->dais[li->dais++]; - ret = asoc_simple_card_parse_graph_cpu(ep, dai_link); + ret = asoc_simple_card_parse_cpu(ep, dai_link, &is_single_links); if (ret) return ret; @@ -156,8 +254,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, 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); + asoc_simple_card_canonicalize_cpu(dai_link, is_single_links); } else { struct snd_soc_codec_conf *cconf; @@ -176,7 +273,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, cconf = dai_props->codec_conf = &priv->codec_conf[li->conf++]; - ret = asoc_simple_card_parse_graph_codec(ep, dai_link); + ret = asoc_simple_card_parse_codec(ep, dai_link); if (ret < 0) return ret; @@ -234,7 +331,7 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv, struct device_node *top = dev->of_node; struct asoc_simple_dai *cpu_dai; struct asoc_simple_dai *codec_dai; - int ret; + int ret, single_cpu; /* Do it only CPU turn */ if (!li->cpu) @@ -258,11 +355,11 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv, if (ret < 0) return ret; - ret = asoc_simple_card_parse_graph_cpu(cpu_ep, dai_link); + ret = asoc_simple_card_parse_cpu(cpu_ep, dai_link, &single_cpu); if (ret < 0) return ret; - ret = asoc_simple_card_parse_graph_codec(codec_ep, dai_link); + ret = asoc_simple_card_parse_codec(codec_ep, dai_link); if (ret < 0) return ret; @@ -293,8 +390,7 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv, dai_link->init = asoc_simple_dai_init; asoc_simple_card_canonicalize_platform(dai_link); - asoc_simple_card_canonicalize_cpu(dai_link, - of_graph_get_endpoint_count(dai_link->cpu_of_node) == 1); + asoc_simple_card_canonicalize_cpu(dai_link, single_cpu); return 0; } diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 69d0b4c..b87fc48 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -305,149 +305,6 @@ int asoc_simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, } EXPORT_SYMBOL_GPL(asoc_simple_be_hw_params_fixup); -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 of_phandle_args args; - int ret; - - if (!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() - */ - ret = of_parse_phandle_with_args(node, list_name, cells_name, 0, &args); - if (ret) - return ret; - - /* Get dai->name */ - if (dai_name) { - ret = snd_soc_of_get_dai_name(node, dai_name); - if (ret < 0) - return ret; - } - - *dai_of_node = args.np; - - if (is_single_link) - *is_single_link = !args.args_count; - - return 0; -} -EXPORT_SYMBOL_GPL(asoc_simple_card_parse_dai); - -static int asoc_simple_card_get_dai_id(struct device_node *ep) -{ - struct device_node *node; - struct device_node *endpoint; - struct of_endpoint info; - int i, id; - int ret; - - /* use driver specified DAI ID if exist */ - ret = snd_soc_get_dai_id(ep); - if (ret != -ENOTSUPP) - return ret; - - /* use endpoint/port reg if exist */ - ret = of_graph_parse_endpoint(ep, &info); - if (ret == 0) { - /* - * Because it will count port/endpoint if it doesn't have "reg". - * But, we can't judge whether it has "no reg", or "reg = <0>" - * only of_graph_parse_endpoint(). - * We need to check "reg" property - */ - if (of_get_property(ep, "reg", NULL)) - return info.id; - - node = of_get_parent(ep); - of_node_put(node); - if (of_get_property(node, "reg", NULL)) - return info.port; - } - node = of_graph_get_port_parent(ep); - - /* - * Non HDMI sound case, counting port/endpoint on its DT - * is enough. Let's count it. - */ - i = 0; - id = -1; - for_each_endpoint_of_node(node, endpoint) { - if (endpoint == ep) - id = i; - i++; - } - - of_node_put(node); - - if (id < 0) - return -ENODEV; - - return id; -} - -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 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); - - /* Get dai->name */ - args.np = node; - 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); - if (ret < 0) - return ret; - - *dai_of_node = node; - - return 0; -} -EXPORT_SYMBOL_GPL(asoc_simple_card_parse_graph_dai); - static int asoc_simple_card_init_dai(struct snd_soc_dai *dai, struct asoc_simple_dai *simple_dai) { diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 4e3e6b3..d8560fb 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -25,6 +25,52 @@ static const struct snd_soc_ops simple_ops = { .hw_params = asoc_simple_hw_params, }; +static 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, + int *is_single_link) +{ + struct of_phandle_args args; + int ret; + + if (!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() + */ + ret = of_parse_phandle_with_args(node, DAI, CELL, 0, &args); + if (ret) + return ret; + + /* Get dai->name */ + if (dai_name) { + ret = snd_soc_of_get_dai_name(node, dai_name); + if (ret < 0) + return ret; + } + + *dai_of_node = args.np; + + if (is_single_link) + *is_single_link = !args.args_count; + + return 0; +} + static void simple_parse_convert(struct device *dev, struct device_node *np, struct asoc_simple_card_data *adata) @@ -110,8 +156,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai = dai_props->cpu_dai = &priv->dais[li->dais++]; - ret = asoc_simple_card_parse_cpu(np, dai_link, DAI, CELL, - &is_single_links); + ret = asoc_simple_card_parse_cpu(np, dai_link, &is_single_links); if (ret) return ret; @@ -144,7 +189,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, cconf = dai_props->codec_conf = &priv->codec_conf[li->conf++]; - ret = asoc_simple_card_parse_codec(np, dai_link, DAI, CELL); + ret = asoc_simple_card_parse_codec(np, dai_link); if (ret < 0) return ret; @@ -242,16 +287,15 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv, simple_parse_mclk_fs(top, cpu, codec, dai_props, prefix); - ret = asoc_simple_card_parse_cpu(cpu, dai_link, - DAI, CELL, &single_cpu); + ret = asoc_simple_card_parse_cpu(cpu, dai_link, &single_cpu); if (ret < 0) goto dai_link_of_err; - ret = asoc_simple_card_parse_codec(codec, dai_link, DAI, CELL); + ret = asoc_simple_card_parse_codec(codec, dai_link); if (ret < 0) goto dai_link_of_err; - ret = asoc_simple_card_parse_platform(plat, dai_link, DAI, CELL); + ret = asoc_simple_card_parse_platform(plat, dai_link); if (ret < 0) goto dai_link_of_err; From patchwork Mon Mar 18 04:55:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10856897 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 F24A96C2 for ; Mon, 18 Mar 2019 05:00:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7E0029250 for ; Mon, 18 Mar 2019 05:00:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6E6129253; Mon, 18 Mar 2019 05:00:59 +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 C5CA729250 for ; Mon, 18 Mar 2019 05:00:57 +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 065BB921; Mon, 18 Mar 2019 06:00:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 065BB921 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1552885256; bh=DKfg0qyrUgC9TArmx/ST9ZhkeFZUSe1yvv4ifMbOXU0=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=GiPJQkn+rQNvmZnk+SvKUZ5Y8aCkIBuCGRdv/2jQqx7JAjkiHPKoVxmRdWfYb/9Qh vazWrfO2++XNgQTVmCFiqS3AbDAVj/3MqQ1cVXD73Xm4V0TqZaRKmXV0kfmRRwJyl2 AYHIN2C/sDPHTETjoeGKDwhQM4+DWXxfBnBgp3rs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 260DAF8961C; Mon, 18 Mar 2019 05:55:50 +0100 (CET) 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 87403F89739; Mon, 18 Mar 2019 05:55:48 +0100 (CET) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id 99137F8971A for ; Mon, 18 Mar 2019 05:55:40 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 99137F8971A Date: 18 Mar 2019 13:55:39 +0900 X-IronPort-AV: E=Sophos;i="5.58,492,1544454000"; d="scan'208";a="10634252" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 18 Mar 2019 13:55:39 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id AD7A141E8700; Mon, 18 Mar 2019 13:55:39 +0900 (JST) Message-ID: <87lg1cyeqz.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: <875zsgztld.wl-kuninori.morimoto.gx@renesas.com> References: <875zsgztld.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 14/15] ASoC: simple-card-utils: rename asoc_simple_card_xxx() to asoc_simple_() 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 Current simple-card-utils is using asoc_simple_card_xxx() for each function naming, but it is very verbose. Thus it is easy to be over 80 char. This patch renames it to asoc_simple_xxx(). Signed-off-by: Kuninori Morimoto --- include/sound/simple_card_utils.h | 90 ++++++++++++------------- sound/soc/generic/audio-graph-card.c | 98 +++++++++++++-------------- sound/soc/generic/simple-card-utils.c | 122 +++++++++++++++++----------------- sound/soc/generic/simple-card.c | 98 +++++++++++++-------------- 4 files changed, 204 insertions(+), 204 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 0c070c2..67dc3ee 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -10,10 +10,10 @@ #include -#define asoc_simple_card_init_hp(card, sjack, prefix) \ - asoc_simple_card_init_jack(card, sjack, 1, prefix) -#define asoc_simple_card_init_mic(card, sjack, prefix) \ - asoc_simple_card_init_jack(card, sjack, 0, prefix) +#define asoc_simple_init_hp(card, sjack, prefix) \ + asoc_simple_init_jack(card, sjack, 1, prefix) +#define asoc_simple_init_mic(card, sjack, prefix) \ + asoc_simple_init_jack(card, sjack, 0, prefix) struct asoc_simple_dai { const char *name; @@ -26,7 +26,7 @@ struct asoc_simple_dai { struct clk *clk; }; -struct asoc_simple_card_data { +struct asoc_simple_data { u32 convert_rate; u32 convert_channels; }; @@ -44,7 +44,7 @@ struct asoc_simple_priv { struct asoc_simple_dai *codec_dai; struct snd_soc_dai_link_component codecs; /* single codec */ struct snd_soc_dai_link_component platforms; - struct asoc_simple_card_data adata; + struct asoc_simple_data adata; struct snd_soc_codec_conf *codec_conf; unsigned int mclk_fs; } *dai_props; @@ -67,30 +67,30 @@ struct link_info { int cpu; /* turn for CPU / Codec */ }; -int asoc_simple_card_parse_daifmt(struct device *dev, - struct device_node *node, - struct device_node *codec, - char *prefix, - unsigned int *retfmt); +int asoc_simple_parse_daifmt(struct device *dev, + struct device_node *node, + struct device_node *codec, + char *prefix, + unsigned int *retfmt); __printf(3, 4) -int asoc_simple_card_set_dailink_name(struct device *dev, - struct snd_soc_dai_link *dai_link, - const char *fmt, ...); -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, \ +int asoc_simple_set_dailink_name(struct device *dev, + struct snd_soc_dai_link *dai_link, + const char *fmt, ...); +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) -#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,\ +#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) -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_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); int asoc_simple_hw_params(struct snd_pcm_substream *substream, @@ -99,45 +99,45 @@ int asoc_simple_dai_init(struct snd_soc_pcm_runtime *rtd); int asoc_simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params); -#define asoc_simple_card_parse_cpu(node, dai_link, is_single_link) \ - asoc_simple_card_parse_dai(node, NULL, \ +#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) -#define asoc_simple_card_parse_codec(node, dai_link) \ - asoc_simple_card_parse_dai(node, dai_link->codecs, \ +#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) -#define asoc_simple_card_parse_platform(node, dai_link) \ - asoc_simple_card_parse_dai(node, dai_link->platforms, \ +#define asoc_simple_parse_platform(node, dai_link) \ + asoc_simple_parse_dai(node, dai_link->platforms, \ &dai_link->platform_of_node, NULL, NULL) -#define asoc_simple_card_of_parse_tdm(np, dai) \ +#define asoc_simple_parse_tdm(np, dai) \ snd_soc_of_parse_tdm_slot(np, &(dai)->tx_slot_mask, \ &(dai)->rx_slot_mask, \ &(dai)->slots, \ &(dai)->slot_width); -void asoc_simple_card_canonicalize_platform(struct snd_soc_dai_link *dai_link); -void asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link *dai_link, +void asoc_simple_canonicalize_platform(struct snd_soc_dai_link *dai_link); +void asoc_simple_canonicalize_cpu(struct snd_soc_dai_link *dai_link, int is_single_links); -int asoc_simple_card_clean_reference(struct snd_soc_card *card); +int asoc_simple_clean_reference(struct snd_soc_card *card); -void asoc_simple_card_convert_fixup(struct asoc_simple_card_data *data, +void asoc_simple_convert_fixup(struct asoc_simple_data *data, struct snd_pcm_hw_params *params); -void asoc_simple_card_parse_convert(struct device *dev, - struct device_node *np, char *prefix, - struct asoc_simple_card_data *data); +void asoc_simple_parse_convert(struct device *dev, + struct device_node *np, char *prefix, + struct asoc_simple_data *data); -int asoc_simple_card_of_parse_routing(struct snd_soc_card *card, +int asoc_simple_parse_routing(struct snd_soc_card *card, char *prefix); -int asoc_simple_card_of_parse_widgets(struct snd_soc_card *card, +int asoc_simple_parse_widgets(struct snd_soc_card *card, char *prefix); -int asoc_simple_card_init_jack(struct snd_soc_card *card, +int asoc_simple_init_jack(struct snd_soc_card *card, struct asoc_simple_jack *sjack, int is_hp, char *prefix); -int asoc_simple_card_init_priv(struct asoc_simple_priv *priv, +int asoc_simple_init_priv(struct asoc_simple_priv *priv, struct link_info *li); #ifdef DEBUG diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 3370b6f..8114b5ea 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -107,11 +107,11 @@ static int graph_get_dai_id(struct device_node *ep) return id; } -static int asoc_simple_card_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) +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; @@ -154,18 +154,18 @@ static int asoc_simple_card_parse_dai(struct device_node *ep, static void graph_parse_convert(struct device *dev, struct device_node *ep, - struct asoc_simple_card_data *adata) + struct asoc_simple_data *adata) { struct device_node *top = dev->of_node; struct device_node *port = of_get_parent(ep); struct device_node *ports = of_get_parent(port); struct device_node *node = of_graph_get_port_parent(ep); - asoc_simple_card_parse_convert(dev, top, NULL, adata); - asoc_simple_card_parse_convert(dev, node, PREFIX, adata); - asoc_simple_card_parse_convert(dev, ports, NULL, adata); - asoc_simple_card_parse_convert(dev, port, NULL, adata); - asoc_simple_card_parse_convert(dev, ep, NULL, adata); + asoc_simple_parse_convert(dev, top, NULL, adata); + asoc_simple_parse_convert(dev, node, PREFIX, adata); + asoc_simple_parse_convert(dev, ports, NULL, adata); + asoc_simple_parse_convert(dev, port, NULL, adata); + asoc_simple_parse_convert(dev, ep, NULL, adata); of_node_put(port); of_node_put(ports); @@ -239,22 +239,22 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai = dai_props->cpu_dai = &priv->dais[li->dais++]; - ret = asoc_simple_card_parse_cpu(ep, dai_link, &is_single_links); + ret = asoc_simple_parse_cpu(ep, dai_link, &is_single_links); if (ret) return ret; - ret = asoc_simple_card_parse_clk_cpu(dev, ep, dai_link, dai); + ret = asoc_simple_parse_clk_cpu(dev, ep, dai_link, dai); if (ret < 0) return ret; - ret = asoc_simple_card_set_dailink_name(dev, dai_link, - "fe.%s", - dai_link->cpu_dai_name); + ret = asoc_simple_set_dailink_name(dev, dai_link, + "fe.%s", + dai_link->cpu_dai_name); if (ret < 0) return ret; /* card->num_links includes Codec */ - asoc_simple_card_canonicalize_cpu(dai_link, is_single_links); + asoc_simple_canonicalize_cpu(dai_link, is_single_links); } else { struct snd_soc_codec_conf *cconf; @@ -273,17 +273,17 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, cconf = dai_props->codec_conf = &priv->codec_conf[li->conf++]; - ret = asoc_simple_card_parse_codec(ep, dai_link); + ret = asoc_simple_parse_codec(ep, dai_link); if (ret < 0) return ret; - ret = asoc_simple_card_parse_clk_codec(dev, ep, dai_link, dai); + ret = asoc_simple_parse_clk_codec(dev, ep, dai_link, dai); if (ret < 0) return ret; - ret = asoc_simple_card_set_dailink_name(dev, dai_link, - "be.%s", - codecs->dai_name); + ret = asoc_simple_set_dailink_name(dev, dai_link, + "be.%s", + codecs->dai_name); if (ret < 0) return ret; @@ -301,14 +301,14 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, graph_parse_convert(dev, ep, &dai_props->adata); graph_parse_mclk_fs(top, ep, dai_props); - asoc_simple_card_canonicalize_platform(dai_link); + asoc_simple_canonicalize_platform(dai_link); - ret = asoc_simple_card_of_parse_tdm(ep, dai); + ret = asoc_simple_parse_tdm(ep, dai); if (ret) return ret; - ret = asoc_simple_card_parse_daifmt(dev, cpu_ep, codec_ep, - NULL, &dai_link->dai_fmt); + ret = asoc_simple_parse_daifmt(dev, cpu_ep, codec_ep, + NULL, &dai_link->dai_fmt); if (ret < 0) return ret; @@ -350,47 +350,47 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv, graph_parse_mclk_fs(top, cpu_ep, dai_props); graph_parse_mclk_fs(top, codec_ep, dai_props); - ret = asoc_simple_card_parse_daifmt(dev, cpu_ep, codec_ep, - NULL, &dai_link->dai_fmt); + ret = asoc_simple_parse_daifmt(dev, cpu_ep, codec_ep, + NULL, &dai_link->dai_fmt); if (ret < 0) return ret; - ret = asoc_simple_card_parse_cpu(cpu_ep, dai_link, &single_cpu); + ret = asoc_simple_parse_cpu(cpu_ep, dai_link, &single_cpu); if (ret < 0) return ret; - ret = asoc_simple_card_parse_codec(codec_ep, dai_link); + ret = asoc_simple_parse_codec(codec_ep, dai_link); if (ret < 0) return ret; - ret = asoc_simple_card_of_parse_tdm(cpu_ep, cpu_dai); + ret = asoc_simple_parse_tdm(cpu_ep, cpu_dai); if (ret < 0) return ret; - ret = asoc_simple_card_of_parse_tdm(codec_ep, codec_dai); + ret = asoc_simple_parse_tdm(codec_ep, codec_dai); if (ret < 0) return ret; - ret = asoc_simple_card_parse_clk_cpu(dev, cpu_ep, dai_link, cpu_dai); + ret = asoc_simple_parse_clk_cpu(dev, cpu_ep, dai_link, cpu_dai); if (ret < 0) return ret; - ret = asoc_simple_card_parse_clk_codec(dev, codec_ep, dai_link, codec_dai); + ret = asoc_simple_parse_clk_codec(dev, codec_ep, dai_link, codec_dai); if (ret < 0) return ret; - ret = asoc_simple_card_set_dailink_name(dev, dai_link, - "%s-%s", - dai_link->cpu_dai_name, - dai_link->codecs->dai_name); + ret = asoc_simple_set_dailink_name(dev, dai_link, + "%s-%s", + dai_link->cpu_dai_name, + dai_link->codecs->dai_name); if (ret < 0) return ret; dai_link->ops = &graph_ops; dai_link->init = asoc_simple_dai_init; - asoc_simple_card_canonicalize_platform(dai_link); - asoc_simple_card_canonicalize_cpu(dai_link, single_cpu); + asoc_simple_canonicalize_cpu(dai_link, single_cpu); + asoc_simple_canonicalize_platform(dai_link); return 0; } @@ -414,7 +414,7 @@ static int graph_for_each_link(struct asoc_simple_priv *priv, struct device_node *codec_ep; struct device_node *codec_port; struct device_node *codec_port_old = NULL; - struct asoc_simple_card_data adata; + struct asoc_simple_data adata; int rc, ret; /* loop for all listed CPU port */ @@ -469,11 +469,11 @@ static int graph_parse_of(struct asoc_simple_priv *priv) struct link_info li; int ret; - ret = asoc_simple_card_of_parse_widgets(card, NULL); + ret = asoc_simple_parse_widgets(card, NULL); if (ret < 0) return ret; - ret = asoc_simple_card_of_parse_routing(card, NULL); + ret = asoc_simple_parse_routing(card, NULL); if (ret < 0) return ret; @@ -498,7 +498,7 @@ static int graph_parse_of(struct asoc_simple_priv *priv) return ret; } - return asoc_simple_card_parse_card_name(card, NULL); + return asoc_simple_parse_card_name(card, NULL); } static int graph_count_noml(struct asoc_simple_priv *priv, @@ -601,11 +601,11 @@ static int graph_card_probe(struct snd_soc_card *card) struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(card); int ret; - ret = asoc_simple_card_init_hp(card, &priv->hp_jack, NULL); + ret = asoc_simple_init_hp(card, &priv->hp_jack, NULL); if (ret < 0) return ret; - ret = asoc_simple_card_init_mic(card, &priv->mic_jack, NULL); + ret = asoc_simple_init_mic(card, &priv->mic_jack, NULL); if (ret < 0) return ret; @@ -637,7 +637,7 @@ static int graph_probe(struct platform_device *pdev) if (!li.link || !li.dais) return -EINVAL; - ret = asoc_simple_card_init_priv(priv, &li); + ret = asoc_simple_init_priv(priv, &li); if (ret < 0) return ret; @@ -665,7 +665,7 @@ static int graph_probe(struct platform_device *pdev) return 0; err: - asoc_simple_card_clean_reference(card); + asoc_simple_clean_reference(card); return ret; } @@ -674,7 +674,7 @@ static int graph_remove(struct platform_device *pdev) { struct snd_soc_card *card = platform_get_drvdata(pdev); - return asoc_simple_card_clean_reference(card); + return asoc_simple_clean_reference(card); } static const struct of_device_id graph_of_match[] = { diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index b87fc48..b2b09c8 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -14,8 +14,8 @@ #include #include -void asoc_simple_card_convert_fixup(struct asoc_simple_card_data *data, - struct snd_pcm_hw_params *params) +void asoc_simple_convert_fixup(struct asoc_simple_data *data, + struct snd_pcm_hw_params *params) { struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); @@ -30,12 +30,12 @@ void asoc_simple_card_convert_fixup(struct asoc_simple_card_data *data, channels->min = channels->max = data->convert_channels; } -EXPORT_SYMBOL_GPL(asoc_simple_card_convert_fixup); +EXPORT_SYMBOL_GPL(asoc_simple_convert_fixup); -void asoc_simple_card_parse_convert(struct device *dev, - struct device_node *np, - char *prefix, - struct asoc_simple_card_data *data) +void asoc_simple_parse_convert(struct device *dev, + struct device_node *np, + char *prefix, + struct asoc_simple_data *data) { char prop[128]; @@ -50,13 +50,13 @@ void asoc_simple_card_parse_convert(struct device *dev, snprintf(prop, sizeof(prop), "%s%s", prefix, "convert-channels"); of_property_read_u32(np, prop, &data->convert_channels); } -EXPORT_SYMBOL_GPL(asoc_simple_card_parse_convert); +EXPORT_SYMBOL_GPL(asoc_simple_parse_convert); -int asoc_simple_card_parse_daifmt(struct device *dev, - struct device_node *node, - struct device_node *codec, - char *prefix, - unsigned int *retfmt) +int asoc_simple_parse_daifmt(struct device *dev, + struct device_node *node, + struct device_node *codec, + char *prefix, + unsigned int *retfmt) { struct device_node *bitclkmaster = NULL; struct device_node *framemaster = NULL; @@ -92,11 +92,11 @@ int asoc_simple_card_parse_daifmt(struct device *dev, return 0; } -EXPORT_SYMBOL_GPL(asoc_simple_card_parse_daifmt); +EXPORT_SYMBOL_GPL(asoc_simple_parse_daifmt); -int asoc_simple_card_set_dailink_name(struct device *dev, - struct snd_soc_dai_link *dai_link, - const char *fmt, ...) +int asoc_simple_set_dailink_name(struct device *dev, + struct snd_soc_dai_link *dai_link, + const char *fmt, ...) { va_list ap; char *name = NULL; @@ -115,10 +115,10 @@ int asoc_simple_card_set_dailink_name(struct device *dev, return ret; } -EXPORT_SYMBOL_GPL(asoc_simple_card_set_dailink_name); +EXPORT_SYMBOL_GPL(asoc_simple_set_dailink_name); -int asoc_simple_card_parse_card_name(struct snd_soc_card *card, - char *prefix) +int asoc_simple_parse_card_name(struct snd_soc_card *card, + char *prefix) { int ret; @@ -141,9 +141,9 @@ int asoc_simple_card_parse_card_name(struct snd_soc_card *card, return 0; } -EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_name); +EXPORT_SYMBOL_GPL(asoc_simple_parse_card_name); -static int asoc_simple_card_clk_enable(struct asoc_simple_dai *dai) +static int asoc_simple_clk_enable(struct asoc_simple_dai *dai) { if (dai) return clk_prepare_enable(dai->clk); @@ -151,18 +151,18 @@ static int asoc_simple_card_clk_enable(struct asoc_simple_dai *dai) return 0; } -static void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai) +static void asoc_simple_clk_disable(struct asoc_simple_dai *dai) { if (dai) clk_disable_unprepare(dai->clk); } -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_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; @@ -202,7 +202,7 @@ int asoc_simple_card_parse_clk(struct device *dev, return 0; } -EXPORT_SYMBOL_GPL(asoc_simple_card_parse_clk); +EXPORT_SYMBOL_GPL(asoc_simple_parse_clk); int asoc_simple_startup(struct snd_pcm_substream *substream) { @@ -211,13 +211,13 @@ int asoc_simple_startup(struct snd_pcm_substream *substream) struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); int ret; - ret = asoc_simple_card_clk_enable(dai_props->cpu_dai); + ret = asoc_simple_clk_enable(dai_props->cpu_dai); if (ret) return ret; - ret = asoc_simple_card_clk_enable(dai_props->codec_dai); + ret = asoc_simple_clk_enable(dai_props->codec_dai); if (ret) - asoc_simple_card_clk_disable(dai_props->cpu_dai); + asoc_simple_clk_disable(dai_props->cpu_dai); return ret; } @@ -230,9 +230,9 @@ void asoc_simple_shutdown(struct snd_pcm_substream *substream) struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); - asoc_simple_card_clk_disable(dai_props->cpu_dai); + asoc_simple_clk_disable(dai_props->cpu_dai); - asoc_simple_card_clk_disable(dai_props->codec_dai); + asoc_simple_clk_disable(dai_props->codec_dai); } EXPORT_SYMBOL_GPL(asoc_simple_shutdown); @@ -299,13 +299,13 @@ int asoc_simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); - asoc_simple_card_convert_fixup(&dai_props->adata, params); + asoc_simple_convert_fixup(&dai_props->adata, params); return 0; } EXPORT_SYMBOL_GPL(asoc_simple_be_hw_params_fixup); -static int asoc_simple_card_init_dai(struct snd_soc_dai *dai, +static int asoc_simple_init_dai(struct snd_soc_dai *dai, struct asoc_simple_dai *simple_dai) { int ret; @@ -343,13 +343,13 @@ int asoc_simple_dai_init(struct snd_soc_pcm_runtime *rtd) struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); int ret; - ret = asoc_simple_card_init_dai(rtd->codec_dai, - dai_props->codec_dai); + ret = asoc_simple_init_dai(rtd->codec_dai, + dai_props->codec_dai); if (ret < 0) return ret; - ret = asoc_simple_card_init_dai(rtd->cpu_dai, - dai_props->cpu_dai); + ret = asoc_simple_init_dai(rtd->cpu_dai, + dai_props->cpu_dai); if (ret < 0) return ret; @@ -357,16 +357,16 @@ int asoc_simple_dai_init(struct snd_soc_pcm_runtime *rtd) } EXPORT_SYMBOL_GPL(asoc_simple_dai_init); -void asoc_simple_card_canonicalize_platform(struct snd_soc_dai_link *dai_link) +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; } -EXPORT_SYMBOL_GPL(asoc_simple_card_canonicalize_platform); +EXPORT_SYMBOL_GPL(asoc_simple_canonicalize_platform); -void asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link *dai_link, - int is_single_links) +void asoc_simple_canonicalize_cpu(struct snd_soc_dai_link *dai_link, + int is_single_links) { /* * In soc_bind_dai_link() will check cpu name after @@ -380,9 +380,9 @@ void asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link *dai_link, if (is_single_links) dai_link->cpu_dai_name = NULL; } -EXPORT_SYMBOL_GPL(asoc_simple_card_canonicalize_cpu); +EXPORT_SYMBOL_GPL(asoc_simple_canonicalize_cpu); -int asoc_simple_card_clean_reference(struct snd_soc_card *card) +int asoc_simple_clean_reference(struct snd_soc_card *card) { struct snd_soc_dai_link *dai_link; int i; @@ -393,10 +393,10 @@ int asoc_simple_card_clean_reference(struct snd_soc_card *card) } return 0; } -EXPORT_SYMBOL_GPL(asoc_simple_card_clean_reference); +EXPORT_SYMBOL_GPL(asoc_simple_clean_reference); -int asoc_simple_card_of_parse_routing(struct snd_soc_card *card, - char *prefix) +int asoc_simple_parse_routing(struct snd_soc_card *card, + char *prefix) { struct device_node *node = card->dev->of_node; char prop[128]; @@ -411,10 +411,10 @@ int asoc_simple_card_of_parse_routing(struct snd_soc_card *card, return snd_soc_of_parse_audio_routing(card, prop); } -EXPORT_SYMBOL_GPL(asoc_simple_card_of_parse_routing); +EXPORT_SYMBOL_GPL(asoc_simple_parse_routing); -int asoc_simple_card_of_parse_widgets(struct snd_soc_card *card, - char *prefix) +int asoc_simple_parse_widgets(struct snd_soc_card *card, + char *prefix) { struct device_node *node = card->dev->of_node; char prop[128]; @@ -430,11 +430,11 @@ int asoc_simple_card_of_parse_widgets(struct snd_soc_card *card, /* no widgets is not error */ return 0; } -EXPORT_SYMBOL_GPL(asoc_simple_card_of_parse_widgets); +EXPORT_SYMBOL_GPL(asoc_simple_parse_widgets); -int asoc_simple_card_init_jack(struct snd_soc_card *card, - struct asoc_simple_jack *sjack, - int is_hp, char *prefix) +int asoc_simple_init_jack(struct snd_soc_card *card, + struct asoc_simple_jack *sjack, + int is_hp, char *prefix) { struct device *dev = card->dev; enum of_gpio_flags flags; @@ -485,10 +485,10 @@ int asoc_simple_card_init_jack(struct snd_soc_card *card, return 0; } -EXPORT_SYMBOL_GPL(asoc_simple_card_init_jack); +EXPORT_SYMBOL_GPL(asoc_simple_init_jack); -int asoc_simple_card_init_priv(struct asoc_simple_priv *priv, - struct link_info *li) +int asoc_simple_init_priv(struct asoc_simple_priv *priv, + struct link_info *li) { struct snd_soc_card *card = simple_priv_to_card(priv); struct device *dev = simple_priv_to_dev(priv); @@ -513,7 +513,7 @@ int asoc_simple_card_init_priv(struct asoc_simple_priv *priv, * * "platform" might be removed * see - * simple-card-utils.c :: asoc_simple_card_canonicalize_platform() + * simple-card-utils.c :: asoc_simple_canonicalize_platform() */ for (i = 0; i < li->link; i++) { dai_link[i].codecs = &dai_props[i].codecs; diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index d8560fb..dd9ac60 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -25,11 +25,11 @@ static const struct snd_soc_ops simple_ops = { .hw_params = asoc_simple_hw_params, }; -static 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, - int *is_single_link) +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; int ret; @@ -73,15 +73,15 @@ static int asoc_simple_card_parse_dai(struct device_node *node, static void simple_parse_convert(struct device *dev, struct device_node *np, - struct asoc_simple_card_data *adata) + struct asoc_simple_data *adata) { struct device_node *top = dev->of_node; struct device_node *node = of_get_parent(np); - asoc_simple_card_parse_convert(dev, top, PREFIX, adata); - asoc_simple_card_parse_convert(dev, node, PREFIX, adata); - asoc_simple_card_parse_convert(dev, node, NULL, adata); - asoc_simple_card_parse_convert(dev, np, NULL, adata); + asoc_simple_parse_convert(dev, top, PREFIX, adata); + asoc_simple_parse_convert(dev, node, PREFIX, adata); + asoc_simple_parse_convert(dev, node, NULL, adata); + asoc_simple_parse_convert(dev, np, NULL, adata); of_node_put(node); } @@ -156,21 +156,21 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai = dai_props->cpu_dai = &priv->dais[li->dais++]; - ret = asoc_simple_card_parse_cpu(np, dai_link, &is_single_links); + ret = asoc_simple_parse_cpu(np, dai_link, &is_single_links); if (ret) return ret; - ret = asoc_simple_card_parse_clk_cpu(dev, np, dai_link, dai); + ret = asoc_simple_parse_clk_cpu(dev, np, dai_link, dai); if (ret < 0) return ret; - ret = asoc_simple_card_set_dailink_name(dev, dai_link, - "fe.%s", - dai_link->cpu_dai_name); + ret = asoc_simple_set_dailink_name(dev, dai_link, + "fe.%s", + dai_link->cpu_dai_name); if (ret < 0) return ret; - asoc_simple_card_canonicalize_cpu(dai_link, is_single_links); + asoc_simple_canonicalize_cpu(dai_link, is_single_links); } else { struct snd_soc_codec_conf *cconf; @@ -189,17 +189,17 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, cconf = dai_props->codec_conf = &priv->codec_conf[li->conf++]; - ret = asoc_simple_card_parse_codec(np, dai_link); + ret = asoc_simple_parse_codec(np, dai_link); if (ret < 0) return ret; - ret = asoc_simple_card_parse_clk_codec(dev, np, dai_link, dai); + ret = asoc_simple_parse_clk_codec(dev, np, dai_link, dai); if (ret < 0) return ret; - ret = asoc_simple_card_set_dailink_name(dev, dai_link, - "be.%s", - codecs->dai_name); + ret = asoc_simple_set_dailink_name(dev, dai_link, + "be.%s", + codecs->dai_name); if (ret < 0) return ret; @@ -215,14 +215,14 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, simple_parse_convert(dev, np, &dai_props->adata); simple_parse_mclk_fs(top, np, codec, dai_props, prefix); - asoc_simple_card_canonicalize_platform(dai_link); + asoc_simple_canonicalize_platform(dai_link); - ret = asoc_simple_card_of_parse_tdm(np, dai); + ret = asoc_simple_parse_tdm(np, dai); if (ret) return ret; - ret = asoc_simple_card_parse_daifmt(dev, node, codec, - prefix, &dai_link->dai_fmt); + ret = asoc_simple_parse_daifmt(dev, node, codec, + prefix, &dai_link->dai_fmt); if (ret < 0) return ret; @@ -280,53 +280,53 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv, codec_dai = dai_props->codec_dai = &priv->dais[li->dais++]; - ret = asoc_simple_card_parse_daifmt(dev, node, codec, - prefix, &dai_link->dai_fmt); + ret = asoc_simple_parse_daifmt(dev, node, codec, + prefix, &dai_link->dai_fmt); if (ret < 0) goto dai_link_of_err; simple_parse_mclk_fs(top, cpu, codec, dai_props, prefix); - ret = asoc_simple_card_parse_cpu(cpu, dai_link, &single_cpu); + ret = asoc_simple_parse_cpu(cpu, dai_link, &single_cpu); if (ret < 0) goto dai_link_of_err; - ret = asoc_simple_card_parse_codec(codec, dai_link); + ret = asoc_simple_parse_codec(codec, dai_link); if (ret < 0) goto dai_link_of_err; - ret = asoc_simple_card_parse_platform(plat, dai_link); + ret = asoc_simple_parse_platform(plat, dai_link); if (ret < 0) goto dai_link_of_err; - ret = asoc_simple_card_of_parse_tdm(cpu, cpu_dai); + ret = asoc_simple_parse_tdm(cpu, cpu_dai); if (ret < 0) goto dai_link_of_err; - ret = asoc_simple_card_of_parse_tdm(codec, codec_dai); + ret = asoc_simple_parse_tdm(codec, codec_dai); if (ret < 0) goto dai_link_of_err; - ret = asoc_simple_card_parse_clk_cpu(dev, cpu, dai_link, cpu_dai); + ret = asoc_simple_parse_clk_cpu(dev, cpu, dai_link, cpu_dai); if (ret < 0) goto dai_link_of_err; - ret = asoc_simple_card_parse_clk_codec(dev, codec, dai_link, codec_dai); + ret = asoc_simple_parse_clk_codec(dev, codec, dai_link, codec_dai); if (ret < 0) goto dai_link_of_err; - ret = asoc_simple_card_set_dailink_name(dev, dai_link, - "%s-%s", - dai_link->cpu_dai_name, - dai_link->codecs->dai_name); + ret = asoc_simple_set_dailink_name(dev, dai_link, + "%s-%s", + dai_link->cpu_dai_name, + dai_link->codecs->dai_name); if (ret < 0) goto dai_link_of_err; dai_link->ops = &simple_ops; dai_link->init = asoc_simple_dai_init; - asoc_simple_card_canonicalize_cpu(dai_link, single_cpu); - asoc_simple_card_canonicalize_platform(dai_link); + asoc_simple_canonicalize_cpu(dai_link, single_cpu); + asoc_simple_canonicalize_platform(dai_link); dai_link_of_err: of_node_put(plat); @@ -361,7 +361,7 @@ static int simple_for_each_link(struct asoc_simple_priv *priv, /* loop for all dai-link */ do { - struct asoc_simple_card_data adata; + struct asoc_simple_data adata; struct device_node *codec; struct device_node *np; int num = of_get_child_count(node); @@ -451,11 +451,11 @@ static int simple_parse_of(struct asoc_simple_priv *priv) if (!top) return -EINVAL; - ret = asoc_simple_card_of_parse_widgets(card, PREFIX); + ret = asoc_simple_parse_widgets(card, PREFIX); if (ret < 0) return ret; - ret = asoc_simple_card_of_parse_routing(card, PREFIX); + ret = asoc_simple_parse_routing(card, PREFIX); if (ret < 0) return ret; @@ -481,7 +481,7 @@ static int simple_parse_of(struct asoc_simple_priv *priv) return ret; } - ret = asoc_simple_card_parse_card_name(card, PREFIX); + ret = asoc_simple_parse_card_name(card, PREFIX); if (ret < 0) return ret; @@ -587,11 +587,11 @@ static int simple_soc_probe(struct snd_soc_card *card) struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(card); int ret; - ret = asoc_simple_card_init_hp(card, &priv->hp_jack, PREFIX); + ret = asoc_simple_init_hp(card, &priv->hp_jack, PREFIX); if (ret < 0) return ret; - ret = asoc_simple_card_init_mic(card, &priv->mic_jack, PREFIX); + ret = asoc_simple_init_mic(card, &priv->mic_jack, PREFIX); if (ret < 0) return ret; @@ -622,7 +622,7 @@ static int simple_probe(struct platform_device *pdev) if (!li.link || !li.dais) return -EINVAL; - ret = asoc_simple_card_init_priv(priv, &li); + ret = asoc_simple_init_priv(priv, &li); if (ret < 0) return ret; @@ -691,7 +691,7 @@ static int simple_probe(struct platform_device *pdev) return 0; err: - asoc_simple_card_clean_reference(card); + asoc_simple_clean_reference(card); return ret; } @@ -700,7 +700,7 @@ static int simple_remove(struct platform_device *pdev) { struct snd_soc_card *card = platform_get_drvdata(pdev); - return asoc_simple_card_clean_reference(card); + return asoc_simple_clean_reference(card); } static const struct of_device_id simple_of_match[] = { From patchwork Mon Mar 18 04:55:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10856899 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 E2C366C2 for ; Mon, 18 Mar 2019 05:01:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C196129250 for ; Mon, 18 Mar 2019 05:01:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4C4029253; Mon, 18 Mar 2019 05:01:53 +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 5A70029250 for ; Mon, 18 Mar 2019 05:01:52 +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 8803786E; Mon, 18 Mar 2019 06:01:00 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8803786E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1552885310; bh=aLf/K1utGi2dsQKhC2SIBiW4nF3vFy9jAh4b4fHaxpw=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=iw+V686R5u2t2Sb7XmZ8UEqUlwYVn9FP69ACfzMcEVKqdf8eoSBkg/SpwNCwOLj4c KeQEi92ZqZngn0E0BS4oq+Fi0zWtXD9Wf4cekxWIBamhxBHAJuoWSz6QFZHd6ckDHO eV2QqxuqNLY2NC92WX5f/uqtSUrHRLcygFyoLqj0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 03DD8F89744; Mon, 18 Mar 2019 05:55:56 +0100 (CET) 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 C5558F89744; Mon, 18 Mar 2019 05:55:54 +0100 (CET) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id 9AFC6F8973A for ; Mon, 18 Mar 2019 05:55:49 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9AFC6F8973A Date: 18 Mar 2019 13:55:49 +0900 X-IronPort-AV: E=Sophos;i="5.58,492,1544454000"; d="scan'208";a="10634282" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 18 Mar 2019 13:55:49 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 1FA3C41E8700; Mon, 18 Mar 2019 13:55:49 +0900 (JST) Message-ID: <87k1gwyeqp.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: <875zsgztld.wl-kuninori.morimoto.gx@renesas.com> References: <875zsgztld.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 15/15] ASoC: simple-card-utils: test memory allocation 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 li->conf will be 0 if it was not DPCM case. Then, 1) we shouldn't call devm_kcalloc() with size 0, 2) we need NULL pointer check if li->conf was not 0. This patch fixed above issues. Special thanks to Pierre-Louis Bossart Reported-by: Pierre-Louis Bossart Signed-off-by: Kuninori Morimoto --- sound/soc/generic/simple-card-utils.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index b2b09c8..a26a4b7 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -495,16 +495,21 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv, struct snd_soc_dai_link *dai_link; struct simple_dai_props *dai_props; struct asoc_simple_dai *dais; - struct snd_soc_codec_conf *cconf; + struct snd_soc_codec_conf *cconf = NULL; int i; dai_props = devm_kcalloc(dev, li->link, sizeof(*dai_props), GFP_KERNEL); dai_link = devm_kcalloc(dev, li->link, sizeof(*dai_link), GFP_KERNEL); dais = devm_kcalloc(dev, li->dais, sizeof(*dais), GFP_KERNEL); - cconf = devm_kcalloc(dev, li->conf, sizeof(*cconf), GFP_KERNEL); if (!dai_props || !dai_link || !dais) return -ENOMEM; + if (li->conf) { + cconf = devm_kcalloc(dev, li->conf, sizeof(*cconf), GFP_KERNEL); + if (!cconf) + return -ENOMEM; + } + /* * Use snd_soc_dai_link_component instead of legacy style * It is codec only. but cpu/platform will be supported in the future.