From patchwork Fri Nov 30 02:07:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10705639 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 5491C13BB for ; Fri, 30 Nov 2018 02:07:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42A162FC5D for ; Fri, 30 Nov 2018 02:07:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36F012FC68; Fri, 30 Nov 2018 02:07:27 +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 587082FC5D for ; Fri, 30 Nov 2018 02:07:26 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 320C9267B8E; Fri, 30 Nov 2018 03:07:25 +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 E3871267B93; Fri, 30 Nov 2018 03:07:22 +0100 (CET) Received: from JPN01-OS2-obe.outbound.protection.outlook.com (mail-eopbgr1410102.outbound.protection.outlook.com [40.107.141.102]) by alsa0.perex.cz (Postfix) with ESMTP id 479DF267B8E for ; Fri, 30 Nov 2018 03:07:19 +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=WGYD2Fb1UCkBzfZEk3KLGh0q9uEF/slLiWmrGwmXp6M=; b=Ba7wMWswjUmiaOxIfdgR5O1012ThcAaAXonsQgID3FZuCwUFWBQcKh9/EY/NhDszLCwmjpWrXZMluV17BHFckaxEe9rzc0RajFUgsabkJWwasLB9/AUSfGzncGLjyI5XQEfKLl/32c9o13fEbxxafDljLHjliRvjpqaENvEMXQc= Received: from TYAPR01MB3328.jpnprd01.prod.outlook.com (20.178.136.81) by TYAPR01MB4655.jpnprd01.prod.outlook.com (20.179.174.213) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1382.19; Fri, 30 Nov 2018 02:07:15 +0000 Received: from TYAPR01MB3328.jpnprd01.prod.outlook.com ([fe80::8903:38b9:bfa8:89b7]) by TYAPR01MB3328.jpnprd01.prod.outlook.com ([fe80::8903:38b9:bfa8:89b7%2]) with mapi id 15.20.1361.019; Fri, 30 Nov 2018 02:07:15 +0000 From: Kuninori Morimoto To: Mark Brown Thread-Topic: [PATCH v2 3/5] ASoC: audio-graph-scu-card: use cpu/codec pointer on graph_dai_props Thread-Index: AQHUiFFpAwxaA1S+GUmE7O4pzFHWhA== Date: Fri, 30 Nov 2018 02:07:15 +0000 Message-ID: <87va4fz5ra.wl-kuninori.morimoto.gx@renesas.com> References: <87zhtrz5yt.wl-kuninori.morimoto.gx@renesas.com> In-Reply-To: <87zhtrz5yt.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: TYAPR01CA0044.jpnprd01.prod.outlook.com (2603:1096:404:28::32) To TYAPR01MB3328.jpnprd01.prod.outlook.com (2603:1096:404:bb::17) 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; TYAPR01MB4655; 20:Zk6YzsXc4zFGVCUdEOzEXyga9FB71r0vwubU7aqocZKnLq+dZAUFGZhl1ccbQrZLxucyyMea5v9bYtxozbl8KaH4xOVXiIEGqVUFIGLdIZR+NJXB6ie8oLeMMt5OuvxNz9mgTcHbAFNk7zvGyUCm7J7cZZ04W8btLakkRFn2maY= x-ms-office365-filtering-correlation-id: d3d7ce37-1e36-4549-8bae-08d656688c30 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:TYAPR01MB4655; x-ms-traffictypediagnostic: TYAPR01MB4655: 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)(3002001)(10201501046)(3231453)(999002)(944501457)(52105112)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123560045)(20161123562045)(201708071742011)(7699051)(76991095); SRVR:TYAPR01MB4655; BCL:0; PCL:0; RULEID:; SRVR:TYAPR01MB4655; x-forefront-prvs: 087223B4DA x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(346002)(39860400002)(376002)(136003)(366004)(199004)(189003)(68736007)(52116002)(256004)(76176011)(6916009)(6512007)(99286004)(478600001)(106356001)(105586002)(36756003)(476003)(2616005)(446003)(11346002)(71190400001)(5660300001)(71200400001)(8936002)(25786009)(186003)(102836004)(26005)(8676002)(386003)(486006)(86362001)(81166006)(81156014)(575784001)(6506007)(316002)(53936002)(305945005)(6436002)(66066001)(7736002)(6486002)(2906002)(3846002)(6116002)(14454004)(4326008)(97736004); DIR:OUT; SFP:1102; SCL:1; SRVR:TYAPR01MB4655; H:TYAPR01MB3328.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: 7ox/uurtvEAj7dT75YRIaK42FH0CD6G0iK5Riz++BHe7Ml7R9qP4iKI0uU1Ebv19GrsBpTM7myZhrk+c0Bcj8HNDw1hl1177M1Np8F+WZxl8yWQZM734kZYTKl64kMukAD/Enx8ekjML73h/SMrpiL2RqKJXGaOqfGvOb+Ur3L0G9PCJ541hvlaRP8ETIcg7N3+qA6tFBl/2bYyyZJjc4PqJSN9I/zziLvsrg3tun+ZZIU1BQpmGvNa2kHQt0zDyYFjhRo7IyALqD+wCbCkFaHG6OeQOEG/c09yOHT3oG8hObCZpsz2+cywA9kQiFiesZG12e7r3VHDEnTxVvzzy3R6/a8B9z7rroEItYMWPWfA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: MIME-Version: 1.0 X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: d3d7ce37-1e36-4549-8bae-08d656688c30 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Nov 2018 02:07:15.1208 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYAPR01MB4655 Cc: Linux-ALSA Subject: [alsa-devel] [PATCH v2 3/5] ASoC: audio-graph-scu-card: use cpu/codec pointer on graph_dai_props 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 In DPCM case, it uses CPU-dummy / dummy-Codec dai links, and non DPCM case, it uses CPU-Codec dai links. Now, we want to merge audio-graph-card and audio-graph-scu-card. These sound cards are using silimar but not same logic on each functions. Then, of course we want to share same logic. To compromise, this patch uses cpu/codec pointer on audio-graph-scu-card. It is same logic with audio-graph-card, thus easy merging. This is prepare for merging audio card Signed-off-by: Kuninori Morimoto --- v1 -> v2 - no change sound/soc/generic/audio-graph-scu-card.c | 72 ++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 23 deletions(-) diff --git a/sound/soc/generic/audio-graph-scu-card.c b/sound/soc/generic/audio-graph-scu-card.c index a0a2867..ed128d4 100644 --- a/sound/soc/generic/audio-graph-scu-card.c +++ b/sound/soc/generic/audio-graph-scu-card.c @@ -26,12 +26,14 @@ struct graph_card_data { struct snd_soc_card snd_card; struct snd_soc_codec_conf codec_conf; struct graph_dai_props { - struct asoc_simple_dai dai; + struct asoc_simple_dai *cpu_dai; + struct asoc_simple_dai *codec_dai; struct snd_soc_dai_link_component codecs; struct snd_soc_dai_link_component platform; struct asoc_simple_card_data adata; } *dai_props; struct snd_soc_dai_link *dai_link; + struct asoc_simple_dai *dais; struct asoc_simple_card_data adata; }; @@ -47,8 +49,17 @@ static int asoc_graph_card_startup(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct graph_card_data *priv = snd_soc_card_get_drvdata(rtd->card); struct graph_dai_props *dai_props = graph_priv_to_props(priv, rtd->num); + int ret = 0; - return asoc_simple_card_clk_enable(&dai_props->dai); + 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 asoc_graph_card_shutdown(struct snd_pcm_substream *substream) @@ -57,7 +68,9 @@ static void asoc_graph_card_shutdown(struct snd_pcm_substream *substream) struct graph_card_data *priv = snd_soc_card_get_drvdata(rtd->card); struct graph_dai_props *dai_props = graph_priv_to_props(priv, rtd->num); - asoc_simple_card_clk_disable(&dai_props->dai); + asoc_simple_card_clk_disable(dai_props->cpu_dai); + + asoc_simple_card_clk_disable(dai_props->codec_dai); } static const struct snd_soc_ops asoc_graph_card_ops = { @@ -68,18 +81,20 @@ static const struct snd_soc_ops asoc_graph_card_ops = { static int asoc_graph_card_dai_init(struct snd_soc_pcm_runtime *rtd) { struct graph_card_data *priv = snd_soc_card_get_drvdata(rtd->card); - struct snd_soc_dai *dai; - struct snd_soc_dai_link *dai_link; - struct graph_dai_props *dai_props; - int num = rtd->num; + struct graph_dai_props *dai_props = graph_priv_to_props(priv, rtd->num); + int ret = 0; - dai_link = graph_priv_to_link(priv, num); - dai_props = graph_priv_to_props(priv, num); - dai = dai_link->dynamic ? - rtd->cpu_dai : - rtd->codec_dai; + ret = asoc_simple_card_init_dai(rtd->codec_dai, + dai_props->codec_dai); + if (ret < 0) + return ret; - return asoc_simple_card_init_dai(dai, &dai_props->dai); + ret = asoc_simple_card_init_dai(rtd->cpu_dai, + dai_props->cpu_dai); + if (ret < 0) + return ret; + + return 0; } static int asoc_graph_card_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, @@ -99,14 +114,15 @@ static int asoc_graph_card_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, static int asoc_graph_card_dai_link_of(struct device_node *cpu_ep, struct device_node *codec_ep, struct graph_card_data *priv, - int idx, int is_fe) + int *dai_idx, int link_idx, int is_fe) { struct device *dev = graph_priv_to_dev(priv); - struct snd_soc_dai_link *dai_link = graph_priv_to_link(priv, idx); - struct graph_dai_props *dai_props = graph_priv_to_props(priv, idx); + 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 snd_soc_card *card = graph_priv_to_card(priv); struct device_node *ep = is_fe ? cpu_ep : codec_ep; struct device_node *node = of_graph_get_port_parent(ep); + struct asoc_simple_dai *dai; int ret; if (is_fe) { @@ -122,11 +138,14 @@ static int asoc_graph_card_dai_link_of(struct device_node *cpu_ep, dai_link->dynamic = 1; dai_link->dpcm_merged_format = 1; + dai = + dai_props->cpu_dai = &priv->dais[(*dai_idx)++]; + ret = asoc_simple_card_parse_graph_cpu(ep, dai_link); if (ret) return ret; - ret = asoc_simple_card_parse_clk_cpu(dev, ep, dai_link, &dai_props->dai); + ret = asoc_simple_card_parse_clk_cpu(dev, ep, dai_link, dai); if (ret < 0) return ret; @@ -149,11 +168,14 @@ static int asoc_graph_card_dai_link_of(struct device_node *cpu_ep, dai_link->no_pcm = 1; dai_link->be_hw_params_fixup = asoc_graph_card_be_hw_params_fixup; + dai = + dai_props->codec_dai = &priv->dais[(*dai_idx)++]; + ret = asoc_simple_card_parse_graph_codec(ep, dai_link); if (ret < 0) return ret; - ret = asoc_simple_card_parse_clk_codec(dev, ep, dai_link, &dai_props->dai); + ret = asoc_simple_card_parse_clk_codec(dev, ep, dai_link, dai); if (ret < 0) return ret; @@ -178,7 +200,7 @@ static int asoc_graph_card_dai_link_of(struct device_node *cpu_ep, asoc_simple_card_parse_convert(dev, node, PREFIX, &dai_props->adata); - ret = asoc_simple_card_of_parse_tdm(ep, &dai_props->dai); + ret = asoc_simple_card_of_parse_tdm(ep, dai); if (ret) return ret; @@ -210,7 +232,7 @@ static int asoc_graph_card_parse_of(struct graph_card_data *priv) struct device_node *codec_ep; struct device_node *codec_port; struct device_node *codec_port_old; - int dai_idx, ret; + int dai_idx, link_idx, ret; int rc, codec; if (!node) @@ -232,6 +254,7 @@ static int asoc_graph_card_parse_of(struct graph_card_data *priv) * see asoc_graph_get_dais_count */ + link_idx = 0; dai_idx = 0; codec_port_old = NULL; for (codec = 0; codec < 2; codec++) { @@ -260,8 +283,8 @@ static int asoc_graph_card_parse_of(struct graph_card_data *priv) } ret = asoc_graph_card_dai_link_of(cpu_ep, codec_ep, - priv, dai_idx++, - !codec); + priv, &dai_idx, + link_idx++, !codec); if (ret < 0) goto parse_of_err; } @@ -364,6 +387,7 @@ static int asoc_graph_card_probe(struct platform_device *pdev) struct graph_card_data *priv; struct snd_soc_dai_link *dai_link; struct graph_dai_props *dai_props; + struct asoc_simple_dai *dais; struct device *dev = &pdev->dev; struct snd_soc_card *card; int lnum = 0, dnum = 0, cnum = 0; @@ -380,7 +404,8 @@ static int asoc_graph_card_probe(struct platform_device *pdev) dai_props = devm_kcalloc(dev, lnum, sizeof(*dai_props), GFP_KERNEL); dai_link = devm_kcalloc(dev, lnum, sizeof(*dai_link), GFP_KERNEL); - if (!dai_props || !dai_link) + dais = devm_kcalloc(dev, dnum, sizeof(*dais), GFP_KERNEL); + if (!dai_props || !dai_link || !dais) return -ENOMEM; /* @@ -397,6 +422,7 @@ static int asoc_graph_card_probe(struct platform_device *pdev) priv->dai_props = dai_props; priv->dai_link = dai_link; + priv->dais = dais; /* Init snd_soc_card */ card = graph_priv_to_card(priv);