From patchwork Tue Dec 11 03:25:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10723027 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 57A3C1751 for ; Tue, 11 Dec 2018 04:42:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4465B2A81E for ; Tue, 11 Dec 2018 04:42:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38F5E2A835; Tue, 11 Dec 2018 04:42: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.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 2418F2A852 for ; Tue, 11 Dec 2018 04:42:52 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 0B3AC267B6D; Tue, 11 Dec 2018 04:25:36 +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 8E7D8267B6F; Tue, 11 Dec 2018 04:25:33 +0100 (CET) Received: from JPN01-OS2-obe.outbound.protection.outlook.com (mail-eopbgr1410092.outbound.protection.outlook.com [40.107.141.92]) by alsa0.perex.cz (Postfix) with ESMTP id 2452526770D for ; Tue, 11 Dec 2018 04:25:30 +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=DBXhGX1bEvkYNwnMHN3eTeneziVT0cGStE6lesXbOY0=; b=fWQiz2nWH4jYIV9Al+CSN2xmgU+Yyv23HRTLBs0ij0iRQslMNqTZyjFTX/NoptJrWI+F0/4F2gnsoRwKFERSCU/TTFjv2il1hAwtYbihJPr9x6CM76ooOWcpUTZ3ZHsNimcDg6xhQoAwwlF1NJs65y7QxCpFfJ6eJVkwDVcroGM= Received: from TYAPR01MB3661.jpnprd01.prod.outlook.com (20.178.137.210) by TYAPR01MB4047.jpnprd01.prod.outlook.com (20.178.139.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.20; Tue, 11 Dec 2018 03:25:28 +0000 Received: from TYAPR01MB3661.jpnprd01.prod.outlook.com ([fe80::939:87f0:3329:af2f]) by TYAPR01MB3661.jpnprd01.prod.outlook.com ([fe80::939:87f0:3329:af2f%4]) with mapi id 15.20.1404.026; Tue, 11 Dec 2018 03:25:28 +0000 From: Kuninori Morimoto To: Mark Brown Thread-Topic: [PATCH 4/5] ASoC: simple-scu-card: use cpu/codec pointer on graph_dai_props Thread-Index: AQHUkQEp8UibqkZ/PU6N9sXdyPG7UQ== Date: Tue, 11 Dec 2018 03:25:27 +0000 Message-ID: <875zw0bvol.wl-kuninori.morimoto.gx@renesas.com> References: <87bm5sbvq6.wl-kuninori.morimoto.gx@renesas.com> In-Reply-To: <87bm5sbvq6.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: TY2PR06CA0012.apcprd06.prod.outlook.com (2603:1096:404:42::24) 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; TYAPR01MB4047; 20:UM8DwdWHGTVv1Scol83YKZjTV+t4i6stDqPz0M0cnXT22YSFuH/z4cce4wqN+QbNH09KhDYhZ9XfpmZ25JPWOlSy79w260VtMtgOPAYLSHkBpH4LWOOYsIUeXHbOEnccsex1oTB1zVRzHXplSESXSWxuWGmErXJgRG5TnMa8WNg= x-ms-office365-filtering-correlation-id: ba883f47-67fd-48ae-b24f-08d65f184bff 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:TYAPR01MB4047; x-ms-traffictypediagnostic: TYAPR01MB4047: 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)(93006095)(93001095)(3231455)(999002)(944501520)(52105112)(3002001)(6055026)(148016)(149066)(150057)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:TYAPR01MB4047; BCL:0; PCL:0; RULEID:; SRVR:TYAPR01MB4047; x-forefront-prvs: 08831F51DC x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(39860400002)(346002)(136003)(376002)(366004)(189003)(199004)(478600001)(76176011)(99286004)(2906002)(66066001)(14454004)(5660300001)(7736002)(446003)(316002)(305945005)(186003)(6436002)(11346002)(97736004)(6486002)(486006)(2616005)(4326008)(8936002)(476003)(256004)(3846002)(25786009)(68736007)(6116002)(81166006)(106356001)(81156014)(105586002)(8676002)(386003)(26005)(6506007)(52116002)(71200400001)(6512007)(36756003)(6916009)(71190400001)(102836004)(86362001)(53936002); DIR:OUT; SFP:1102; SCL:1; SRVR:TYAPR01MB4047; H:TYAPR01MB3661.jpnprd01.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: renesas.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: XoH59LWeQ7VTPwVlmIN7ofAMwxfCnf7w1E06Br3Bcj1iSn/eBvuOpTnTeUfhSJUlqkAhumK8JMkgVJt2hzzmIzXB3n7PbmfevJ/hwFJwYdv+AsyOBmHqfSQIXZxa4wz/d4RpZsPdWiOgc6Jz+kpn0+xYEV10Ro5opuyz6Mv+RJdkDAgkZ8kOMnkR2iEy4c/fXGatQi8qM9WXMtL/6V2aqN0zAtteAbkXM4XVI9P9/jHLR4Cmn2okWJN4dU7R34cqITP9Ncv5++aacJBLZFr2k3oMCeTyb4+bLpwmaUatD2lJI420GaOegRm6siPFLa1A spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: <80362DCC054A6F40A242BCC8398577F4@jpnprd01.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba883f47-67fd-48ae-b24f-08d65f184bff X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Dec 2018 03:25:27.9656 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYAPR01MB4047 Cc: Linux-ALSA Subject: [alsa-devel] [PATCH 4/5] ASoC: simple-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 simple-card and simple-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 simple-scu-card. It is same logic with simple-card, thus easy merging. This is prepare for merging simple card Signed-off-by: Kuninori Morimoto --- sound/soc/generic/simple-scu-card.c | 77 +++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 25 deletions(-) diff --git a/sound/soc/generic/simple-scu-card.c b/sound/soc/generic/simple-scu-card.c index 3c4e289..944a6f4 100644 --- a/sound/soc/generic/simple-scu-card.c +++ b/sound/soc/generic/simple-scu-card.c @@ -23,12 +23,14 @@ struct simple_card_data { struct snd_soc_card snd_card; struct snd_soc_codec_conf codec_conf; struct simple_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_simple_card_startup(struct snd_pcm_substream *substream) struct simple_card_data *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 asoc_simple_card_clk_enable(&dai_props->dai); + return ret; } static void asoc_simple_card_shutdown(struct snd_pcm_substream *substream) @@ -58,7 +69,9 @@ static void asoc_simple_card_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->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_simple_card_ops = { @@ -68,19 +81,21 @@ static const struct snd_soc_ops asoc_simple_card_ops = { static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) { - struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card); - struct snd_soc_dai *dai; - struct snd_soc_dai_link *dai_link; - struct simple_dai_props *dai_props; - int num = rtd->num; + struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card); + struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); + int ret; - dai_link = simple_priv_to_link(priv, num); - dai_props = simple_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_simple_card_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, @@ -101,13 +116,14 @@ static int asoc_simple_card_dai_link_of(struct device_node *link, struct device_node *np, struct device_node *codec, struct simple_card_data *priv, - int idx, bool is_fe, + int *dai_idx, int link_idx, int is_fe, bool is_top_level_node) { struct device *dev = simple_priv_to_dev(priv); - struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, idx); - struct simple_dai_props *dai_props = simple_priv_to_props(priv, idx); + struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, link_idx); + struct simple_dai_props *dai_props = simple_priv_to_props(priv, link_idx); struct snd_soc_card *card = simple_priv_to_card(priv); + struct asoc_simple_dai *dai; char *prefix = ""; int ret; @@ -129,12 +145,15 @@ static int asoc_simple_card_dai_link_of(struct device_node *link, dai_link->dynamic = 1; dai_link->dpcm_merged_format = 1; + dai = + dai_props->cpu_dai = &priv->dais[(*dai_idx)++]; + ret = asoc_simple_card_parse_cpu(np, dai_link, DAI, CELL, &is_single_links); if (ret) return ret; - ret = asoc_simple_card_parse_clk_cpu(dev, np, dai_link, &dai_props->dai); + ret = asoc_simple_card_parse_clk_cpu(dev, np, dai_link, dai); if (ret < 0) return ret; @@ -155,11 +174,14 @@ static int asoc_simple_card_dai_link_of(struct device_node *link, dai_link->no_pcm = 1; dai_link->be_hw_params_fixup = asoc_simple_card_be_hw_params_fixup; + dai = + dai_props->codec_dai = &priv->dais[(*dai_idx)++]; + ret = asoc_simple_card_parse_codec(np, dai_link, DAI, CELL); if (ret < 0) return ret; - ret = asoc_simple_card_parse_clk_codec(dev, np, dai_link, &dai_props->dai); + ret = asoc_simple_card_parse_clk_codec(dev, np, dai_link, dai); if (ret < 0) return ret; @@ -184,7 +206,7 @@ static int asoc_simple_card_dai_link_of(struct device_node *link, asoc_simple_card_parse_convert(dev, link, prefix, &dai_props->adata); - ret = asoc_simple_card_of_parse_tdm(np, &dai_props->dai); + ret = asoc_simple_card_of_parse_tdm(np, dai); if (ret) return ret; @@ -215,7 +237,8 @@ static int asoc_simple_card_parse_of(struct simple_card_data *priv) struct device_node *codec; struct snd_soc_card *card = simple_priv_to_card(priv); bool is_fe; - int ret, i, loop; + int ret, loop; + int dai_idx, link_idx; if (!top) return -EINVAL; @@ -231,7 +254,8 @@ static int asoc_simple_card_parse_of(struct simple_card_data *priv) asoc_simple_card_parse_convert(dev, top, PREFIX, &priv->adata); loop = 1; - i = 0; + link_idx = 0; + dai_idx = 0; node = of_get_child_by_name(top, PREFIX "dai-link"); if (!node) { node = dev->of_node; @@ -248,10 +272,10 @@ static int asoc_simple_card_parse_of(struct simple_card_data *priv) is_fe = (np != codec); ret = asoc_simple_card_dai_link_of(node, np, codec, priv, - i, is_fe, !loop); + &dai_idx, link_idx++, + is_fe, !loop); if (ret < 0) return ret; - i++; } node = of_get_next_child(top, node); } while (loop && node); @@ -342,6 +366,7 @@ static int asoc_simple_card_probe(struct platform_device *pdev) struct simple_card_data *priv; struct snd_soc_dai_link *dai_link; struct simple_dai_props *dai_props; + struct asoc_simple_dai *dais; struct snd_soc_card *card; struct device *dev = &pdev->dev; int ret, i; @@ -358,7 +383,8 @@ static int asoc_simple_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; /* @@ -375,6 +401,7 @@ static int asoc_simple_card_probe(struct platform_device *pdev) priv->dai_props = dai_props; priv->dai_link = dai_link; + priv->dais = dais; /* Init snd_soc_card */ card = simple_priv_to_card(priv);