From patchwork Thu Apr 1 04:15:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 414433 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C970C433B4 for ; Thu, 1 Apr 2021 04:17:39 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 809336101A for ; Thu, 1 Apr 2021 04:17:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 809336101A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 DAC4816BB; Thu, 1 Apr 2021 06:16:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DAC4816BB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1617250656; bh=g2t+Cpx6BGgCw5lf4em2PcSai8rIZyHPVCx1SRHIGWI=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=oYhQDnOCsxbH9UaY9bni7fxmx16lFqIDX2Urgx8zTXPSXLB5ryrNZqIjEHzJivfPA U+XsjG9yHGZ0n4qkAgmhshGQsaj8lyR+TZnZhEsH3mHz+k6sdNNQz2L3l2B9dgCjEX IKd40wZ2K4hzT0TTRGbRFNHqpOFsmCSQGynWjXnI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 62472F80431; Thu, 1 Apr 2021 06:15:48 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D24E5F80482; Thu, 1 Apr 2021 06:15:47 +0200 (CEST) Received: from relmlie6.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id CFD08F80431 for ; Thu, 1 Apr 2021 06:15:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CFD08F80431 Date: 01 Apr 2021 13:15:43 +0900 X-IronPort-AV: E=Sophos;i="5.81,295,1610377200"; d="scan'208";a="76723848" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 01 Apr 2021 13:15:43 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 9DAF84185A3B; Thu, 1 Apr 2021 13:15:43 +0900 (JST) Message-ID: <87sg4aod1s.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 03/14] ASoC: simple-card-utils: setup dai_props cpu_dai/codec_dai at initial timing User-Agent: Wanderlust/2.15.9 Emacs/26.3 Mule/6.0 To: Mark Brown In-Reply-To: <87wntmod33.wl-kuninori.morimoto.gx@renesas.com> References: <87wntmod33.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Linux-ALSA 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" From: Kuninori Morimoto We couldn't setup dai_props cpu_dai/codec_dai at the initial timing, because "counting DAIs loop" and "detecting DAIs loop" were different. But we can do it now, because these are using same loops. This patch setups dai_props cpu_dai/codec_dai at the initial timing. It can removes triky code from simple-card / audio-graph. Signed-off-by: Kuninori Morimoto --- sound/soc/generic/audio-graph-card.c | 19 +++++-------------- sound/soc/generic/simple-card-utils.c | 10 ++++++++++ sound/soc/generic/simple-card.c | 24 +++++------------------- 3 files changed, 20 insertions(+), 33 deletions(-) diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 49d37964e40a..75f18929f0e9 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -245,8 +245,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai_link->dynamic = 1; dai_link->dpcm_merged_format = 1; - dai = - dai_props->cpu_dai = &priv->dais[li->dais++]; + dai = dai_props->cpu_dai; ret = asoc_simple_parse_cpu(ep, dai_link, &is_single_links); if (ret) @@ -288,11 +287,8 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai_link->no_pcm = 1; dai_link->be_hw_params_fixup = asoc_simple_be_hw_params_fixup; - dai = - dai_props->codec_dai = &priv->dais[li->dais++]; - - cconf = - dai_props->codec_conf = &priv->codec_conf[li->conf++]; + dai = dai_props->codec_dai; + cconf = dai_props->codec_conf; ret = asoc_simple_parse_codec(ep, dai_link); if (ret < 0) @@ -358,19 +354,14 @@ static int graph_dai_link_of(struct asoc_simple_priv *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; + struct asoc_simple_dai *cpu_dai = dai_props->cpu_dai; + struct asoc_simple_dai *codec_dai = dai_props->codec_dai; int ret, single_cpu; dev_dbg(dev, "link_of (%pOF)\n", cpu_ep); li->link++; - cpu_dai = - dai_props->cpu_dai = &priv->dais[li->dais++]; - codec_dai = - dai_props->codec_dai = &priv->dais[li->dais++]; - /* Factor to mclk, used in hw_params() */ graph_parse_mclk_fs(top, cpu_ep, dai_props); graph_parse_mclk_fs(top, codec_ep, dai_props); diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 64b1ff5bafda..ca74dfa58458 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -649,8 +649,10 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv, dai_link[i].cpus = dlcs; dai_props[i].num.cpus = dai_link[i].num_cpus = li->num[i].cpus; + dai_props[i].cpu_dai = dais; dlcs += li->num[i].cpus; + dais += li->num[i].cpus; } else { /* DPCM Be's CPU = dummy */ dai_props[i].cpus = @@ -665,8 +667,16 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv, dai_link[i].codecs = dlcs; dai_props[i].num.codecs = dai_link[i].num_codecs = li->num[i].codecs; + dai_props[i].codec_dai = dais; dlcs += li->num[i].codecs; + dais += li->num[i].codecs; + + if (!li->num[i].cpus) { + /* DPCM Be's Codec */ + dai_props[i].codec_conf = cconf; + cconf += li->num[i].codecs; + } } else { /* DPCM Fe's Codec = dummy */ dai_props[i].codecs = diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 542180a19a06..fc8b6facd473 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -146,8 +146,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai_link->dynamic = 1; dai_link->dpcm_merged_format = 1; - dai = - dai_props->cpu_dai = &priv->dais[li->dais++]; + dai = dai_props->cpu_dai; ret = asoc_simple_parse_cpu(np, dai_link, &is_single_links); if (ret) @@ -174,11 +173,8 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai_link->no_pcm = 1; dai_link->be_hw_params_fixup = asoc_simple_be_hw_params_fixup; - dai = - dai_props->codec_dai = &priv->dais[li->dais++]; - - cconf = - dai_props->codec_conf = &priv->codec_conf[li->conf++]; + dai = dai_props->codec_dai; + cconf = dai_props->codec_conf; ret = asoc_simple_parse_codec(np, dai_link); if (ret < 0) @@ -234,8 +230,8 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv, 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 asoc_simple_dai *cpu_dai; - struct asoc_simple_dai *codec_dai; + struct asoc_simple_dai *cpu_dai = dai_props->cpu_dai; + struct asoc_simple_dai *codec_dai = dai_props->codec_dai; struct device_node *top = dev->of_node; struct device_node *cpu = NULL; struct device_node *node = NULL; @@ -257,11 +253,6 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv, snprintf(prop, sizeof(prop), "%splat", prefix); plat = of_get_child_by_name(node, prop); - cpu_dai = - dai_props->cpu_dai = &priv->dais[li->dais++]; - codec_dai = - dai_props->codec_dai = &priv->dais[li->dais++]; - ret = asoc_simple_parse_daifmt(dev, node, codec, prefix, &dai_link->dai_fmt); if (ret < 0) @@ -670,8 +661,6 @@ static int asoc_simple_probe(struct platform_device *pdev) 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; if (!cinfo) { dev_err(dev, "no info for asoc-simple-card\n"); @@ -687,9 +676,6 @@ static int asoc_simple_probe(struct platform_device *pdev) return -EINVAL; } - dai_props->cpu_dai = &priv->dais[dai_idx++]; - dai_props->codec_dai = &priv->dais[dai_idx++]; - cpus = dai_link->cpus; cpus->dai_name = cinfo->cpu_dai.name;