From patchwork Wed Dec 5 01:31:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10712881 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 3FD241057 for ; Wed, 5 Dec 2018 01:32:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 276E02C497 for ; Wed, 5 Dec 2018 01:32:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 161E22C4CC; Wed, 5 Dec 2018 01:32:12 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36C172C497 for ; Wed, 5 Dec 2018 01:32:11 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 1AB7D267BD1; Wed, 5 Dec 2018 02:32:10 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id C2E35267BD9; Wed, 5 Dec 2018 02:32:01 +0100 (CET) Received: from JPN01-TY1-obe.outbound.protection.outlook.com (mail-eopbgr1400097.outbound.protection.outlook.com [40.107.140.97]) by alsa0.perex.cz (Postfix) with ESMTP id 5366B267BD4 for ; Wed, 5 Dec 2018 02:31:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/9Fa8QqJUa9ztu/si1xjidO/kUmFyfxZqEfgXarX5wk=; b=N8CBPMFznU/7LhcOHTCcKAKTdwzpv2jl5/zxJzdor1FirtwzDKyY4AAv2+i/MJ6/Y2Xp+5oCnlDAZ0y2U33zXX5bHzw85ZKg5o2qi8/vl+/Wb+urzYnMzejCuF+4yDNmX7ZBr4LGEUJhBR8GzjpDSX53Z2V3t/FlEMBXvvykai4= Received: from TYAPR01MB3661.jpnprd01.prod.outlook.com (20.178.137.210) by TYAPR01MB1918.jpnprd01.prod.outlook.com (52.133.176.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1382.22; Wed, 5 Dec 2018 01:31:54 +0000 Received: from TYAPR01MB3661.jpnprd01.prod.outlook.com ([fe80::70b6:5ef2:3f71:77c7]) by TYAPR01MB3661.jpnprd01.prod.outlook.com ([fe80::70b6:5ef2:3f71:77c7%4]) with mapi id 15.20.1382.023; Wed, 5 Dec 2018 01:31:54 +0000 From: Kuninori Morimoto To: Mark Brown Thread-Topic: [PATCH 3/6] ASoC: audio-graph-card: tidyup mclk-fs method Thread-Index: AQHUjDpNzXCKdagYbka61QOxSiox/Q== Date: Wed, 5 Dec 2018 01:31:54 +0000 Message-ID: <87wooodayg.wl-kuninori.morimoto.gx@renesas.com> References: <871s6wepmp.wl-kuninori.morimoto.gx@renesas.com> In-Reply-To: <871s6wepmp.wl-kuninori.morimoto.gx@renesas.com> Accept-Language: ja-JP, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: TY2PR01CA0021.jpnprd01.prod.outlook.com (2603:1096:404:a::33) To TYAPR01MB3661.jpnprd01.prod.outlook.com (2603:1096:404:c1::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [211.11.155.130] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; TYAPR01MB1918; 20:MxlErknMgoJDmUVSyVnhhscezwmc7FcdOTOR6A8kg+FdmcStdR8gD2QDvur48oMY+s9wljzDQmixEnAi5E/4EJCwRXLtfFqnyJTw+cf4n10mFeTUpmFEIzguLdfBXItgfChUHDXpnnzwYRaFWGoKrshZRGUKni5etWfk5MMy0zI= x-ms-office365-filtering-correlation-id: 322afac1-95aa-4c04-54c7-08d65a51700e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:TYAPR01MB1918; x-ms-traffictypediagnostic: TYAPR01MB1918: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(3231455)(999002)(944501520)(52105112)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(201708071742011)(7699051)(76991095); SRVR:TYAPR01MB1918; BCL:0; PCL:0; RULEID:; SRVR:TYAPR01MB1918; x-forefront-prvs: 08770259B4 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(346002)(136003)(376002)(366004)(396003)(199004)(189003)(97736004)(305945005)(6916009)(7736002)(53936002)(6116002)(3846002)(6436002)(26005)(8936002)(6486002)(316002)(76176011)(6512007)(71190400001)(71200400001)(476003)(68736007)(14454004)(446003)(2616005)(2906002)(25786009)(81166006)(5660300001)(105586002)(11346002)(478600001)(81156014)(66066001)(99286004)(8676002)(186003)(256004)(386003)(52116002)(86362001)(6506007)(106356001)(486006)(4326008)(36756003)(102836004); DIR:OUT; SFP:1102; SCL:1; SRVR:TYAPR01MB1918; H:TYAPR01MB3661.jpnprd01.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: renesas.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 5Pc3N39DdECo5ktPAIuj8QVYfpz4Vl+cBPnKZLK2nB7Ti7ahJN5wixEOV8KHWx3QRT8kH3izxRfDSOifoy7WAOOehANaXgxqAeYhHKY4HNloJVq+l3d1mKe21Wfp93/OsfwNSdxW7qXr7ak5F/lj1tX7/hJFsy0Td1Qrt/oRDPHrYTG2ztCz+lw45HkNHWxrl/cU0K+lJzc1hC7DD+xMnFIXijfRTA9tWwn7TEtbNCZDwmPxYOsQu4xOHOqX48s5TSd5oRzdJCAC7nVNAeRDzymwGA1BZrqnRJWkh/mw+T3opQZyiiam+PijeZJgSRFJgwm/d3rRFrrLEOG7rxXyj4Qrrkz1h9WDXawvLgMXAvs= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: <8E1F378C28376C429605EE503ED5AFDA@jpnprd01.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 322afac1-95aa-4c04-54c7-08d65a51700e X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Dec 2018 01:31:54.1304 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYAPR01MB1918 Cc: Linux-ALSA Subject: [alsa-devel] [PATCH 3/6] ASoC: audio-graph-card: tidyup mclk-fs method X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto Current audio-graph-card is handling "mclk-fs" by many way. But, it is not useful and readable. We want to do is that allow having mclk-fs everywere. This patch support it. It will be overwrote if lower node has it. sound { mclk-fs = ; // initial }; codec { ports { mclk-fs = ; // overwrite port { mclk-fs = ; // overwrite endpoint { mclk-fs = ; // overwrite }; }; }; }; Signed-off-by: Kuninori Morimoto --- sound/soc/generic/audio-graph-card.c | 52 ++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 5b8e7a1..efa6be6 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -31,7 +31,6 @@ struct graph_card_data { struct snd_soc_codec_conf *codec_conf; unsigned int mclk_fs; } *dai_props; - unsigned int mclk_fs; struct asoc_simple_jack hp_jack; struct asoc_simple_jack mic_jack; struct snd_soc_dai_link *dai_link; @@ -115,9 +114,7 @@ static int asoc_graph_card_hw_params(struct snd_pcm_substream *substream, unsigned int mclk, mclk_fs = 0; int ret = 0; - if (priv->mclk_fs) - mclk_fs = priv->mclk_fs; - else if (dai_props->mclk_fs) + if (dai_props->mclk_fs) mclk_fs = dai_props->mclk_fs; if (mclk_fs) { @@ -176,7 +173,8 @@ static int asoc_graph_card_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, return 0; } -static int asoc_graph_card_dai_link_of_dpcm(struct device_node *cpu_ep, +static int asoc_graph_card_dai_link_of_dpcm(struct device_node *top, + struct device_node *cpu_ep, struct device_node *codec_ep, struct graph_card_data *priv, int *dai_idx, int link_idx, @@ -187,12 +185,21 @@ static int asoc_graph_card_dai_link_of_dpcm(struct device_node *cpu_ep, struct graph_dai_props *dai_props = graph_priv_to_props(priv, link_idx); struct snd_soc_card *card = graph_priv_to_card(priv); struct device_node *ep = is_cpu ? cpu_ep : codec_ep; + 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); struct asoc_simple_dai *dai; int ret; dev_dbg(dev, "link_of DPCM (for %s)\n", is_cpu ? "CPU" : "Codec"); + 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); + of_node_put(ports); + of_node_put(port); + if (is_cpu) { struct snd_soc_dai_link_component *codecs; @@ -279,8 +286,6 @@ static int asoc_graph_card_dai_link_of_dpcm(struct device_node *cpu_ep, if (ret < 0) return ret; - of_property_read_u32(ep, "mclk-fs", &dai_props->mclk_fs); - ret = asoc_simple_card_parse_daifmt(dev, cpu_ep, codec_ep, NULL, &dai_link->dai_fmt); if (ret < 0) @@ -294,7 +299,8 @@ static int asoc_graph_card_dai_link_of_dpcm(struct device_node *cpu_ep, return 0; } -static int asoc_graph_card_dai_link_of(struct device_node *cpu_ep, +static int asoc_graph_card_dai_link_of(struct device_node *top, + struct device_node *cpu_ep, struct device_node *codec_ep, struct graph_card_data *priv, int *dai_idx, int link_idx) @@ -302,6 +308,10 @@ static int asoc_graph_card_dai_link_of(struct device_node *cpu_ep, struct device *dev = graph_priv_to_dev(priv); struct snd_soc_dai_link *dai_link = graph_priv_to_link(priv, link_idx); struct graph_dai_props *dai_props = graph_priv_to_props(priv, link_idx); + struct device_node *cpu_port = of_get_parent(cpu_ep); + struct device_node *codec_port = of_get_parent(codec_ep); + struct device_node *cpu_ports = of_get_parent(cpu_port); + struct device_node *codec_ports = of_get_parent(codec_port); struct asoc_simple_dai *cpu_dai; struct asoc_simple_dai *codec_dai; int ret; @@ -313,14 +323,24 @@ static int asoc_graph_card_dai_link_of(struct device_node *cpu_ep, codec_dai = dai_props->codec_dai = &priv->dais[(*dai_idx)++]; + /* 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); + ret = asoc_simple_card_parse_daifmt(dev, cpu_ep, codec_ep, NULL, &dai_link->dai_fmt); if (ret < 0) return ret; - of_property_read_u32(cpu_ep, "mclk-fs", &dai_props->mclk_fs); - of_property_read_u32(codec_ep, "mclk-fs", &dai_props->mclk_fs); - ret = asoc_simple_card_parse_graph_cpu(cpu_ep, dai_link); if (ret < 0) return ret; @@ -370,7 +390,8 @@ static int asoc_graph_card_parse_of(struct graph_card_data *priv) struct of_phandle_iterator it; struct device *dev = graph_priv_to_dev(priv); struct snd_soc_card *card = graph_priv_to_card(priv); - struct device_node *node = dev->of_node; + struct device_node *top = dev->of_node; + struct device_node *node = top; struct device_node *cpu_port; struct device_node *cpu_ep = NULL; struct device_node *codec_ep = NULL; @@ -390,9 +411,6 @@ static int asoc_graph_card_parse_of(struct graph_card_data *priv) asoc_simple_card_parse_convert(dev, node, NULL, &priv->adata); - /* Factor to mclk, used in hw_params() */ - of_property_read_u32(node, "mclk-fs", &priv->mclk_fs); - link_idx = 0; dai_idx = 0; conf_idx = 0; @@ -434,7 +452,7 @@ static int asoc_graph_card_parse_of(struct graph_card_data *priv) codec_port_old = codec_port; } ret = asoc_graph_card_dai_link_of_dpcm( - cpu_ep, codec_ep, priv, + top, cpu_ep, codec_ep, priv, &dai_idx, link_idx++, &conf_idx, cpu); } else if (cpu) { @@ -442,7 +460,7 @@ static int asoc_graph_card_parse_of(struct graph_card_data *priv) * for Normal sound */ ret = asoc_graph_card_dai_link_of( - cpu_ep, codec_ep, priv, + top, cpu_ep, codec_ep, priv, &dai_idx, link_idx++); } if (ret < 0)