From patchwork Mon Nov 26 04:59: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: 10697589 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 2F5C013BF for ; Mon, 26 Nov 2018 04:59:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D8B62983E for ; Mon, 26 Nov 2018 04:59:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11F0C29845; Mon, 26 Nov 2018 04:59:26 +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 0CB5F2983E for ; Mon, 26 Nov 2018 04:59:24 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id BF84E267AA1; Mon, 26 Nov 2018 05:59:23 +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 CF48C267AA3; Mon, 26 Nov 2018 05:59:21 +0100 (CET) Received: from JPN01-OS2-obe.outbound.protection.outlook.com (mail-eopbgr1410120.outbound.protection.outlook.com [40.107.141.120]) by alsa0.perex.cz (Postfix) with ESMTP id EEA3B2679A7 for ; Mon, 26 Nov 2018 05:59:18 +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=IdeMc6mvAhucZq605I8zUV5d7sF1j9nS58u2N2dSuxc=; b=Ox8nOqh5CV5ynx5NaMRHGOutdiHcXE+/2n9cOoktVST8XwGjd5TE66lCSzmtN3z2sAvnA3nVK6X7beRqvNwwQeWqSVP3seYpVpWupSLggchaURwydgNqh6JS4RVUQLIf3FqJhqvoXs2qJx0dKRXoVaKy+ZkSr7bpuvz2pBMx16U= Received: from TYAPR01MB3328.jpnprd01.prod.outlook.com (20.178.136.81) by TYAPR01MB4238.jpnprd01.prod.outlook.com (20.178.140.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.16; Mon, 26 Nov 2018 04:59: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; Mon, 26 Nov 2018 04:59:15 +0000 From: Kuninori Morimoto To: Mark Brown Thread-Topic: [PATCH 2/4] ASoC: audio-graph-scu-card: use cpu/codec pointer on graph_dai_props Thread-Index: AQHUhUTHslox9R8yP0usJNjHfDfPBA== Date: Mon, 26 Nov 2018 04:59:15 +0000 Message-ID: <878t1g30jy.wl-kuninori.morimoto.gx@renesas.com> References: <87bm6c30kz.wl-kuninori.morimoto.gx@renesas.com> In-Reply-To: <87bm6c30kz.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: TY1PR01CA0188.jpnprd01.prod.outlook.com (2603:1096:403::18) 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; TYAPR01MB4238; 20:aVdqcDlOjwYNI9XMGgSHl0w8DXoc3UXd1t5aXBpJ73qRhX56lHsPstICwO6qcnqj6gD8DDAPL2PcoiHIWFlPs+2+3notKN3bJ6XHcFQWlxezemt80q+qpOD39Y31AjBrSAPe4HgOKdDu0EfHXR7An7xgIl7OCiyLJmyvQc6aW9c= x-ms-office365-filtering-correlation-id: e0078ae8-db28-44cc-baa5-08d6535be9df 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:TYAPR01MB4238; x-ms-traffictypediagnostic: TYAPR01MB4238: 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)(3231443)(944501410)(52105112)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:TYAPR01MB4238; BCL:0; PCL:0; RULEID:; SRVR:TYAPR01MB4238; x-forefront-prvs: 086831DFB4 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(39860400002)(376002)(366004)(136003)(396003)(189003)(199004)(99286004)(68736007)(106356001)(102836004)(105586002)(386003)(6506007)(14454004)(97736004)(478600001)(52116002)(81156014)(8676002)(81166006)(8936002)(4326008)(76176011)(53936002)(446003)(256004)(2906002)(71200400001)(71190400001)(26005)(66066001)(86362001)(25786009)(305945005)(6916009)(6486002)(5660300001)(36756003)(3846002)(6116002)(316002)(11346002)(486006)(2616005)(476003)(6512007)(186003)(6436002)(7736002); DIR:OUT; SFP:1102; SCL:1; SRVR:TYAPR01MB4238; H:TYAPR01MB3328.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: JHQL9tHt/jl/vOM8yNb3xW5tDKu96KBWIWsqKW0Z7MzOvrWLoCLFVVnWVwI6++oZOr+V7xZ7dfGWYMKmpKJzp6Cwu+1aOijHnxSBlItcnQUYEF/Br4XKrvv13DYZrIeNUVqov8odzFZRiBIGov5whdNJrpNPp/5ju2Q0MEEHNF9rjawlTJ3JN6H2bGDEHxmKOjp+c8VK3uoJIh3PqKsWWgliQgxy5GHJ9CoJPuroqWhqfzO1KVOGCqw/xGjhSf+O/BP+7K/vA80kHGzHtVj2kFCwGhP4EJoWasM/NP7H9daOq2UP30UkUub4TNAXnx+HQME9sk4RxVqaBVSVsEt5FACrnIOX18CZ+ewvRUD0Wt8= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: MIME-Version: 1.0 X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0078ae8-db28-44cc-baa5-08d6535be9df X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Nov 2018 04:59:15.3199 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYAPR01MB4238 Cc: Linux-ALSA Subject: [alsa-devel] [PATCH 2/4] 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 --- 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 96ecd5a..4212b38 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; } @@ -347,6 +370,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; @@ -363,7 +387,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; /* @@ -380,6 +405,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);