From patchwork Fri Mar 26 03:26:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 409565 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 D5921C433C1 for ; Fri, 26 Mar 2021 03:28:48 +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 C7F9260201 for ; Fri, 26 Mar 2021 03:28:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C7F9260201 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 2FA661660; Fri, 26 Mar 2021 04:27:56 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2FA661660 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1616729326; bh=h3vS7OSgf2thte2+K98th30/zFy+1JIAIlrRvPoTJGw=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=o/VGCfHrEbntOXgtO7jVzvVbi/GGrtLGYVfvxQMYczBQ+Nc5t0n0St9ic6Q/nZKAs ST9lbKsQ8liwQYwzyKQ4tnI4jysaTb9vpPDvHucPJxFzIv7Tk5C1JVbolDOtj8QjDm YOloXo69/wSa0wFUD95hHRQ+N1RO2irRhoIkGnJc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9451EF802E3; Fri, 26 Mar 2021 04:26:46 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 93D5EF804A9; Fri, 26 Mar 2021 04:26:41 +0100 (CET) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 237E1F8049C for ; Fri, 26 Mar 2021 04:26:33 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 237E1F8049C Date: 26 Mar 2021 12:26:33 +0900 X-IronPort-AV: E=Sophos;i="5.81,279,1610377200"; d="scan'208";a="76117727" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 26 Mar 2021 12:26:33 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id B100B40104F3; Fri, 26 Mar 2021 12:26:33 +0900 (JST) Message-ID: <877dlu1tp2.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 5/6] ASoC: simple-card: count DAI / link numbers as in order User-Agent: Wanderlust/2.15.9 Emacs/26.3 Mule/6.0 To: Mark Brown In-Reply-To: <87eeg21tqz.wl-kuninori.morimoto.gx@renesas.com> References: <87eeg21tqz.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 simple-card checks DT links 2 times. 1st is for counting DAIs / links to allocating memory, 2nd is for detecting DAIs. To detecting DAIs as CPU-dummy -> dummy-Codec order when DPCM case, it uses loops 2 times at 2nd DT link check. But it doesn't do it at 1st DT link check. for (li.cpu = 1; li.cpu >= 0; li.cpu--) { /* * Detect all CPU first, and Detect all Codec 2n * * In Normal sound case, all DAIs are detected * as "CPU-Codec". * * In DPCM sound case, * all CPUs are detected as "CPU-dummy", and * all Codecs are detected as "dummy-Codec". * To avoid random sub-device numbering, * detect "dummy-Codec" in last; */ ret = simple_for_each_link(...); ... } To prepare supporting multi-CPU/Codec, and code cleanup, this patch use same loop for 1st DT link check, too. Signed-off-by: Kuninori Morimoto --- sound/soc/generic/simple-card.c | 40 +++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 75365c7bb393..f53f76ee0a8b 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -483,9 +483,17 @@ static int simple_count_noml(struct asoc_simple_priv *priv, struct device_node *codec, struct link_info *li, bool is_top) { - li->dais++; /* CPU or Codec */ - if (np != codec) - li->link++; /* CPU-Codec */ + /* + * |CPU |Codec : turn + * CPU |Pass |return + * Codec |return|return + * np + */ + if (!li->cpu || np == codec) + return 0; + + li->link += 1; + li->dais += 2; return 0; } @@ -495,10 +503,23 @@ static int simple_count_dpcm(struct asoc_simple_priv *priv, struct device_node *codec, struct link_info *li, bool is_top) { - li->dais++; /* CPU or Codec */ - li->link++; /* CPU-dummy or dummy-Codec */ - if (np == codec) + /* + * |CPU |Codec : turn + * CPU |Pass |return + * Codec |return|Pass + * np + */ + if (li->cpu == (np == codec)) + return 0; + + if (li->cpu) { + li->link++; /* CPU-dummy */ + li->dais++; + } else { + li->link++; /* dummy-Codec */ + li->dais++; li->conf++; + } return 0; } @@ -562,9 +583,10 @@ static void simple_get_dais_count(struct asoc_simple_priv *priv, return; } - simple_for_each_link(priv, li, - simple_count_noml, - simple_count_dpcm); + for (li->cpu = 1; li->cpu >= 0; li->cpu--) + simple_for_each_link(priv, li, + simple_count_noml, + simple_count_dpcm); dev_dbg(dev, "link %d, dais %d, ccnf %d\n", li->link, li->dais, li->conf);