From patchwork Mon Mar 16 06:36:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 11439787 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B31761668 for ; Mon, 16 Mar 2020 06:38:22 +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 4A63E2071C for ; Mon, 16 Mar 2020 06:38:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="vB2mvpeG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A63E2071C 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 81C4C1897; Mon, 16 Mar 2020 07:37:36 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 81C4C1897 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1584340700; bh=JEv922kqkT0sU32VjvSU2fvQHC3EmLdBkNZgxrVrXWY=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=vB2mvpeGw5wuudCWnTMvhutU7kIrtfBt0MQF/MxWjE0HCn/77UTe/tTJIINAKMuJS ExMKF53TKjZ1/6yxbmcCbxLIE9BSsvn3xR2JfbE6xZfWhSOXLWq7UWFr2L3HQesQXB yB46/BYEQ0di4tmJznLaCYeWG/zeOjRO2M3ejk9k= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DA8CDF801DB; Mon, 16 Mar 2020 07:37:08 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id BA93DF800CD; Mon, 16 Mar 2020 07:37:05 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 0162BF800CD for ; Mon, 16 Mar 2020 07:37:00 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0162BF800CD Date: 16 Mar 2020 15:36:58 +0900 X-IronPort-AV: E=Sophos;i="5.70,559,1574089200"; d="scan'208";a="41771232" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 16 Mar 2020 15:36:58 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id EE95B4005E27; Mon, 16 Mar 2020 15:36:57 +0900 (JST) Message-ID: <87wo7kolfa.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 1/6] ASoC: soc-core: Merge CPU/Codec DAIs User-Agent: Wanderlust/2.15.9 Emacs/25.2 Mule/6.0 To: Mark Brown In-Reply-To: <87y2s0olg6.wl-kuninori.morimoto.gx@renesas.com> References: <87y2s0olg6.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 ALSA SoC is currently categorizing CPU/Codec DAIs, and it works well. But modern devices require more complex connections, for example Codec to Codec, etc, and future devices will enable to more complex connections. Because of these background, CPU/Codec DAIs categorizing is no longer good much to modern device. Currently, rtd has both CPU/Codec DAIs pointer. rtd->cpu_dais = [][][][][][][][][] rtd->codec_dais = [][][][][][][][][] This patch merges these into DAIs pointer. rtd->dais = [][][][][][][][][][][][][][][][][][] ^cpu_dais ^codec_dais |--- num_cpus ---|--- num_codecs --| Then, we can merge for_each_rtd_cpu/codec_dais() from this patch. - for_each_rtd_cpu_dais() { - ... - } - for_each_rtd_codec_dais() { - ... - } + for_each_rtd_dais() { + ... + } Signed-off-by: Kuninori Morimoto --- include/sound/soc.h | 7 ++++++- sound/soc/soc-core.c | 18 +++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 03054bf9cd37..efa12256bb33 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1144,6 +1144,7 @@ struct snd_soc_pcm_runtime { struct snd_compr *compr; struct snd_soc_dai *codec_dai; struct snd_soc_dai *cpu_dai; + struct snd_soc_dai **dais; struct snd_soc_dai **codec_dais; unsigned int num_codecs; @@ -1183,7 +1184,11 @@ struct snd_soc_pcm_runtime { (i)++) #define for_each_rtd_codec_dais_rollback(rtd, i, dai) \ for (; (--(i) >= 0) && ((dai) = rtd->codec_dais[i]);) - +#define for_each_rtd_dais(rtd, i, dai) \ + for ((i) = 0; \ + ((i) < (rtd)->num_cpus + (rtd)->num_codecs) && \ + ((dai) = (rtd)->dais[i]); \ + (i)++) void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 4e0f55555e37..511f6b0cb2e0 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -475,22 +475,22 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work); /* - * for rtd->codec_dais + * for rtd->dais */ - rtd->codec_dais = devm_kcalloc(dev, dai_link->num_codecs, + rtd->dais = devm_kcalloc(dev, dai_link->num_cpus + dai_link->num_codecs, sizeof(struct snd_soc_dai *), GFP_KERNEL); - if (!rtd->codec_dais) + if (!rtd->dais) goto free_rtd; /* - * for rtd->cpu_dais + * dais = [][][][][][][][][][][][][][][][][][] + * ^cpu_dais ^codec_dais + * |--- num_cpus ---|--- num_codecs --| */ - rtd->cpu_dais = devm_kcalloc(dev, dai_link->num_cpus, - sizeof(struct snd_soc_dai *), - GFP_KERNEL); - if (!rtd->cpu_dais) - goto free_rtd; + rtd->cpu_dais = &rtd->dais[0]; + rtd->codec_dais = &rtd->dais[dai_link->num_cpus]; + /* * rtd remaining settings */ From patchwork Mon Mar 16 06:37:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 11439791 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 73D7B14B4 for ; Mon, 16 Mar 2020 06:39:44 +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 096802071C for ; Mon, 16 Mar 2020 06:39:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="mZBeHMg6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 096802071C 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 41A73188E; Mon, 16 Mar 2020 07:38:58 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 41A73188E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1584340782; bh=ghQ+2aheD8tn/1hhbY08ZXow7bcPJze035S+RX62kgc=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=mZBeHMg6fADGxRC5RbfzC7Hkqm/M9LjBNGLSkPYv0xnu3XcMDu2Om9PSmmLOcnmKf x6x7owbo6D3RVsxVZeO+zTuHqr8dIeegzlQJ51TkRm0oFWtQLwlHi7NV+Bn3v+r5IE uWGivwcDihCmVSABw1KDGOG3rcjwWwIhks6COD6I= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0B2C1F8028C; Mon, 16 Mar 2020 07:37:27 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4AC98F8028C; Mon, 16 Mar 2020 07:37:16 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS, SURBL_BLOCKED,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id 8E661F80212 for ; Mon, 16 Mar 2020 07:37:04 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8E661F80212 Date: 16 Mar 2020 15:37:03 +0900 X-IronPort-AV: E=Sophos;i="5.70,559,1574089200"; d="scan'208";a="41985593" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 16 Mar 2020 15:37:03 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id BD6EB4005E27; Mon, 16 Mar 2020 15:37:03 +0900 (JST) Message-ID: <87v9n4olf4.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 2/6] ASoC: soc-core: Merge for_each_rtd_cpu/codec_dais() User-Agent: Wanderlust/2.15.9 Emacs/25.2 Mule/6.0 To: Mark Brown In-Reply-To: <87y2s0olg6.wl-kuninori.morimoto.gx@renesas.com> References: <87y2s0olg6.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 Now we can use for_each_rtd_dais(). Let's use it instead of for_each_rtd_cpu/codec_dais(). Signed-off-by: Kuninori Morimoto --- sound/soc/soc-core.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 511f6b0cb2e0..333cbbd268b4 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1313,26 +1313,22 @@ static int soc_probe_dai(struct snd_soc_dai *dai, int order) static void soc_remove_link_dais(struct snd_soc_card *card) { int i; - struct snd_soc_dai *codec_dai; - struct snd_soc_dai *cpu_dai; + struct snd_soc_dai *dai; struct snd_soc_pcm_runtime *rtd; int order; for_each_comp_order(order) { for_each_card_rtds(card, rtd) { - /* remove the CODEC DAI */ - for_each_rtd_codec_dais(rtd, i, codec_dai) - soc_remove_dai(codec_dai, order); - - for_each_rtd_cpu_dais(rtd, i, cpu_dai) - soc_remove_dai(cpu_dai, order); + /* remove DAIs */ + for_each_rtd_dais(rtd, i, dai) + soc_remove_dai(dai, order); } } } static int soc_probe_link_dais(struct snd_soc_card *card) { - struct snd_soc_dai *codec_dai, *cpu_dai; + struct snd_soc_dai *dai; struct snd_soc_pcm_runtime *rtd; int i, order, ret; @@ -1344,15 +1340,8 @@ static int soc_probe_link_dais(struct snd_soc_card *card) card->name, rtd->num, order); /* probe the CPU DAI */ - for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - ret = soc_probe_dai(cpu_dai, order); - if (ret) - return ret; - } - - /* probe the CODEC DAI */ - for_each_rtd_codec_dais(rtd, i, codec_dai) { - ret = soc_probe_dai(codec_dai, order); + for_each_rtd_dais(rtd, i, dai) { + ret = soc_probe_dai(dai, order); if (ret) return ret; } From patchwork Mon Mar 16 06:37:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 11439789 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D253E90 for ; Mon, 16 Mar 2020 06:39:09 +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 69AD92071C for ; Mon, 16 Mar 2020 06:39:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="ute2z0Yh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 69AD92071C 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 A6F7F18A8; Mon, 16 Mar 2020 07:38:23 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A6F7F18A8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1584340747; bh=ejdv2deeGP+a2OMxwhE0Be+/OhI4PHTshx+gBWSybTQ=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ute2z0Yhd7HxZAB+gGdfxRGV01qlOniIs2M41hY0QWyAINMpDk9KLte3FmnsvOEVY 3+ccPC1BPalJGCoYaHiaE8prbnqu+yCscBW1gvHP5dKeUzS6ZfTJp/mdHfeTh2c7ts dxqvezP/fNwp45vW6WY3EunajcMzHI8bU98Q1l+M= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 00594F8028B; Mon, 16 Mar 2020 07:37:18 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id BE002F8028C; Mon, 16 Mar 2020 07:37:15 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS, SURBL_BLOCKED,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 9A382F80248 for ; Mon, 16 Mar 2020 07:37:10 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9A382F80248 Date: 16 Mar 2020 15:37:09 +0900 X-IronPort-AV: E=Sophos;i="5.70,559,1574089200"; d="scan'208";a="41771254" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 16 Mar 2020 15:37:09 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 4B1094005E27; Mon, 16 Mar 2020 15:37:09 +0900 (JST) Message-ID: <87tv2ooley.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 3/6] ASoC: soc-dapm: Merge for_each_rtd_cpu/codec_dais() User-Agent: Wanderlust/2.15.9 Emacs/25.2 Mule/6.0 To: Mark Brown In-Reply-To: <87y2s0olg6.wl-kuninori.morimoto.gx@renesas.com> References: <87y2s0olg6.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 Now we can use for_each_rtd_dais(). Let's use it instead of for_each_rtd_cpu/codec_dais(). Signed-off-by: Kuninori Morimoto --- sound/soc/soc-dapm.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index d5eb52fe115b..04da7928c873 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -4433,14 +4433,11 @@ void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card) static void soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, int event) { - struct snd_soc_dai *codec_dai; - struct snd_soc_dai *cpu_dai; + struct snd_soc_dai *dai; int i; - for_each_rtd_cpu_dais(rtd, i, cpu_dai) - soc_dapm_dai_stream_event(cpu_dai, stream, event); - for_each_rtd_codec_dais(rtd, i, codec_dai) - soc_dapm_dai_stream_event(codec_dai, stream, event); + for_each_rtd_dais(rtd, i, dai) + soc_dapm_dai_stream_event(dai, stream, event); dapm_power_widgets(rtd->card, event); } From patchwork Mon Mar 16 06:37:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 11439793 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7CB4390 for ; Mon, 16 Mar 2020 06:40:11 +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 12B9120722 for ; Mon, 16 Mar 2020 06:40:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="r2xuUDbd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 12B9120722 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 5F3FD18BC; Mon, 16 Mar 2020 07:39:25 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5F3FD18BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1584340809; bh=LA5889CS1Ix3B1uOAKVG3kyZRww3XCYckeEATQQiCvU=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=r2xuUDbda6HGdib7E1upOL6fLQgpQt2VW2lqV+n0PyICbYam55vS8999mMF/PtzmJ r9blMZa4TZmHbJtYrYezn2/4rA1E5OQyNBKYR9ousX/eurtLCEKXplTBu/RULPYwaW EtkCZ/osMzafiqN9uXVpL8g9XQs1QnZDIvoqIunY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 21A4EF802A7; Mon, 16 Mar 2020 07:37:32 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 78221F80290; Mon, 16 Mar 2020 07:37:23 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 0E96AF8022D for ; Mon, 16 Mar 2020 07:37:14 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0E96AF8022D Date: 16 Mar 2020 15:37:14 +0900 X-IronPort-AV: E=Sophos;i="5.70,559,1574089200"; d="scan'208";a="41771263" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 16 Mar 2020 15:37:14 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 87E1441AD593; Mon, 16 Mar 2020 15:37:14 +0900 (JST) Message-ID: <87sgi8olet.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 4/6] ASoC: soc-pcm: Merge for_each_rtd_cpu/codec_dais() User-Agent: Wanderlust/2.15.9 Emacs/25.2 Mule/6.0 To: Mark Brown In-Reply-To: <87y2s0olg6.wl-kuninori.morimoto.gx@renesas.com> References: <87y2s0olg6.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 Now we can use for_each_rtd_dais(). Let's use it instead of for_each_rtd_cpu/codec_dais(). Signed-off-by: Kuninori Morimoto --- sound/soc/soc-pcm.c | 311 +++++++++++--------------------------------- 1 file changed, 75 insertions(+), 236 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 2b915f41e955..e256d438ee68 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -259,25 +259,15 @@ static int soc_rtd_trigger(struct snd_soc_pcm_runtime *rtd, static void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd, int stream, int action) { - struct snd_soc_dai *cpu_dai; - struct snd_soc_dai *codec_dai; + struct snd_soc_dai *dai; int i; lockdep_assert_held(&rtd->card->pcm_mutex); - for_each_rtd_cpu_dais(rtd, i, cpu_dai) - cpu_dai->stream_active[stream] += action; - - for_each_rtd_codec_dais(rtd, i, codec_dai) - codec_dai->stream_active[stream] += action; - - for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - cpu_dai->active += action; - cpu_dai->component->active += action; - } - for_each_rtd_codec_dais(rtd, i, codec_dai) { - codec_dai->active += action; - codec_dai->component->active += action; + for_each_rtd_dais(rtd, i, dai) { + dai->stream_active[stream] += action; + dai->active += action; + dai->component->active += action; } } @@ -446,8 +436,8 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *dai; struct snd_soc_dai *cpu_dai; - struct snd_soc_dai *codec_dai; unsigned int rate, channels, sample_bits, symmetry, i; rate = params_rate(params); @@ -457,11 +447,8 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream, /* reject unmatched parameters when applying symmetry */ symmetry = rtd->dai_link->symmetric_rates; - for_each_rtd_cpu_dais(rtd, i, cpu_dai) - symmetry |= cpu_dai->driver->symmetric_rates; - - for_each_rtd_codec_dais(rtd, i, codec_dai) - symmetry |= codec_dai->driver->symmetric_rates; + for_each_rtd_cpu_dais(rtd, i, dai) + symmetry |= dai->driver->symmetric_rates; if (symmetry) { for_each_rtd_cpu_dais(rtd, i, cpu_dai) { @@ -475,11 +462,8 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream, symmetry = rtd->dai_link->symmetric_channels; - for_each_rtd_cpu_dais(rtd, i, cpu_dai) - symmetry |= cpu_dai->driver->symmetric_channels; - - for_each_rtd_codec_dais(rtd, i, codec_dai) - symmetry |= codec_dai->driver->symmetric_channels; + for_each_rtd_dais(rtd, i, dai) + symmetry |= dai->driver->symmetric_channels; if (symmetry) { for_each_rtd_cpu_dais(rtd, i, cpu_dai) { @@ -494,11 +478,8 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream, symmetry = rtd->dai_link->symmetric_samplebits; - for_each_rtd_cpu_dais(rtd, i, cpu_dai) - symmetry |= cpu_dai->driver->symmetric_samplebits; - - for_each_rtd_codec_dais(rtd, i, codec_dai) - symmetry |= codec_dai->driver->symmetric_samplebits; + for_each_rtd_dais(rtd, i, dai) + symmetry |= dai->driver->symmetric_samplebits; if (symmetry) { for_each_rtd_cpu_dais(rtd, i, cpu_dai) { @@ -518,25 +499,18 @@ static bool soc_pcm_has_symmetry(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai_link *link = rtd->dai_link; - struct snd_soc_dai *codec_dai; - struct snd_soc_dai *cpu_dai; + struct snd_soc_dai *dai; unsigned int symmetry, i; symmetry = link->symmetric_rates || link->symmetric_channels || link->symmetric_samplebits; - for_each_rtd_cpu_dais(rtd, i, cpu_dai) - symmetry = symmetry || - cpu_dai->driver->symmetric_rates || - cpu_dai->driver->symmetric_channels || - cpu_dai->driver->symmetric_samplebits; - - for_each_rtd_codec_dais(rtd, i, codec_dai) + for_each_rtd_dais(rtd, i, dai) symmetry = symmetry || - codec_dai->driver->symmetric_rates || - codec_dai->driver->symmetric_channels || - codec_dai->driver->symmetric_samplebits; + dai->driver->symmetric_rates || + dai->driver->symmetric_channels || + dai->driver->symmetric_samplebits; return symmetry; } @@ -774,19 +748,15 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_component *component; - struct snd_soc_dai *cpu_dai; - struct snd_soc_dai *codec_dai; + struct snd_soc_dai *dai; int i; mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); snd_soc_runtime_deactivate(rtd, substream->stream); - for_each_rtd_cpu_dais(rtd, i, cpu_dai) - snd_soc_dai_shutdown(cpu_dai, substream); - - for_each_rtd_codec_dais(rtd, i, codec_dai) - snd_soc_dai_shutdown(codec_dai, substream); + for_each_rtd_dais(rtd, i, dai) + snd_soc_dai_shutdown(dai, substream); soc_rtd_shutdown(rtd, substream); @@ -818,8 +788,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_component *component; - struct snd_soc_dai *cpu_dai; - struct snd_soc_dai *codec_dai; + struct snd_soc_dai *dai; const char *codec_dai_name = "multicodec"; const char *cpu_dai_name = "multicpu"; int i, ret = 0; @@ -844,28 +813,19 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) } /* startup the audio subsystem */ - for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - ret = snd_soc_dai_startup(cpu_dai, substream); + for_each_rtd_dais(rtd, i, dai) { + ret = snd_soc_dai_startup(dai, substream); if (ret < 0) { - dev_err(cpu_dai->dev, "ASoC: can't open interface %s: %d\n", - cpu_dai->name, ret); - goto cpu_dai_err; - } - } - - for_each_rtd_codec_dais(rtd, i, codec_dai) { - ret = snd_soc_dai_startup(codec_dai, substream); - if (ret < 0) { - dev_err(codec_dai->dev, - "ASoC: can't open codec %s: %d\n", - codec_dai->name, ret); + dev_err(dai->dev, + "ASoC: can't open DAI %s: %d\n", + dai->name, ret); goto config_err; } if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - codec_dai->tx_mask = 0; + dai->tx_mask = 0; else - codec_dai->rx_mask = 0; + dai->rx_mask = 0; } /* Dynamic PCM DAI links compat checks use dynamic capabilities */ @@ -905,17 +865,9 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) soc_pcm_apply_msb(substream); /* Symmetry only applies if we've already got an active stream. */ - for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - if (cpu_dai->active) { - ret = soc_pcm_apply_symmetry(substream, cpu_dai); - if (ret != 0) - goto config_err; - } - } - - for_each_rtd_codec_dais(rtd, i, codec_dai) { - if (codec_dai->active) { - ret = soc_pcm_apply_symmetry(substream, codec_dai); + for_each_rtd_dais(rtd, i, dai) { + if (dai->active) { + ret = soc_pcm_apply_symmetry(substream, dai); if (ret != 0) goto config_err; } @@ -937,11 +889,8 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) return 0; config_err: - for_each_rtd_codec_dais(rtd, i, codec_dai) - snd_soc_dai_shutdown(codec_dai, substream); -cpu_dai_err: - for_each_rtd_cpu_dais(rtd, i, cpu_dai) - snd_soc_dai_shutdown(cpu_dai, substream); + for_each_rtd_dais(rtd, i, dai) + snd_soc_dai_shutdown(dai, substream); soc_rtd_shutdown(rtd, substream); rtd_startup_err: @@ -980,8 +929,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_component *component; - struct snd_soc_dai *cpu_dai; - struct snd_soc_dai *codec_dai; + struct snd_soc_dai *dai; int i, ret = 0; mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); @@ -1002,21 +950,11 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) } } - for_each_rtd_codec_dais(rtd, i, codec_dai) { - ret = snd_soc_dai_prepare(codec_dai, substream); - if (ret < 0) { - dev_err(codec_dai->dev, - "ASoC: codec DAI prepare error: %d\n", - ret); - goto out; - } - } - - for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - ret = snd_soc_dai_prepare(cpu_dai, substream); + for_each_rtd_dais(rtd, i, dai) { + ret = snd_soc_dai_prepare(dai, substream); if (ret < 0) { - dev_err(cpu_dai->dev, - "ASoC: cpu DAI prepare error: %d\n", ret); + dev_err(dai->dev, + "ASoC: DAI prepare error: %d\n", ret); goto out; } } @@ -1031,11 +969,8 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) snd_soc_dapm_stream_event(rtd, substream->stream, SND_SOC_DAPM_STREAM_START); - for_each_rtd_codec_dais(rtd, i, codec_dai) - snd_soc_dai_digital_mute(codec_dai, 0, - substream->stream); - for_each_rtd_cpu_dais(rtd, i, cpu_dai) - snd_soc_dai_digital_mute(cpu_dai, 0, substream->stream); + for_each_rtd_dais(rtd, i, dai) + snd_soc_dai_digital_mute(dai, 0, substream->stream); out: mutex_unlock(&rtd->card->pcm_mutex); @@ -1219,44 +1154,23 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, static int soc_pcm_hw_free(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai; - struct snd_soc_dai *codec_dai; + struct snd_soc_dai *dai; int i; mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); /* clear the corresponding DAIs parameters when going to be inactive */ - for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - if (cpu_dai->active == 1) { - cpu_dai->rate = 0; - cpu_dai->channels = 0; - cpu_dai->sample_bits = 0; - } - } + for_each_rtd_dais(rtd, i, dai) { + int active = dai->stream_active[substream->stream]; - for_each_rtd_codec_dais(rtd, i, codec_dai) { - if (codec_dai->active == 1) { - codec_dai->rate = 0; - codec_dai->channels = 0; - codec_dai->sample_bits = 0; + if (dai->active == 1) { + dai->rate = 0; + dai->channels = 0; + dai->sample_bits = 0; } - } - - /* apply codec digital mute */ - for_each_rtd_codec_dais(rtd, i, codec_dai) { - int active = codec_dai->stream_active[substream->stream]; if (active == 1) - snd_soc_dai_digital_mute(codec_dai, 1, - substream->stream); - } - - for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - int active = cpu_dai->stream_active[substream->stream]; - - if (active == 1) - snd_soc_dai_digital_mute(cpu_dai, 1, - substream->stream); + snd_soc_dai_digital_mute(dai, 1, substream->stream); } /* free any machine hw params */ @@ -1266,18 +1180,11 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) soc_pcm_components_hw_free(substream, NULL); /* now free hw params for the DAIs */ - for_each_rtd_codec_dais(rtd, i, codec_dai) { - if (!snd_soc_dai_stream_valid(codec_dai, substream->stream)) - continue; - - snd_soc_dai_hw_free(codec_dai, substream); - } - - for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - if (!snd_soc_dai_stream_valid(cpu_dai, substream->stream)) + for_each_rtd_dais(rtd, i, dai) { + if (!snd_soc_dai_stream_valid(dai, substream->stream)) continue; - snd_soc_dai_hw_free(cpu_dai, substream); + snd_soc_dai_hw_free(dai, substream); } mutex_unlock(&rtd->card->pcm_mutex); @@ -1288,8 +1195,7 @@ static int soc_pcm_trigger_start(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_component *component; - struct snd_soc_dai *cpu_dai; - struct snd_soc_dai *codec_dai; + struct snd_soc_dai *dai; int i, ret; ret = soc_rtd_trigger(rtd, substream, cmd); @@ -1302,14 +1208,8 @@ static int soc_pcm_trigger_start(struct snd_pcm_substream *substream, int cmd) return ret; } - for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - ret = snd_soc_dai_trigger(cpu_dai, substream, cmd); - if (ret < 0) - return ret; - } - - for_each_rtd_codec_dais(rtd, i, codec_dai) { - ret = snd_soc_dai_trigger(codec_dai, substream, cmd); + for_each_rtd_dais(rtd, i, dai) { + ret = snd_soc_dai_trigger(dai, substream, cmd); if (ret < 0) return ret; } @@ -1321,18 +1221,11 @@ static int soc_pcm_trigger_stop(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_component *component; - struct snd_soc_dai *cpu_dai; - struct snd_soc_dai *codec_dai; + struct snd_soc_dai *dai; int i, ret; - for_each_rtd_codec_dais(rtd, i, codec_dai) { - ret = snd_soc_dai_trigger(codec_dai, substream, cmd); - if (ret < 0) - return ret; - } - - for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - ret = snd_soc_dai_trigger(cpu_dai, substream, cmd); + for_each_rtd_dais(rtd, i, dai) { + ret = snd_soc_dai_trigger(dai, substream, cmd); if (ret < 0) return ret; } @@ -1376,18 +1269,11 @@ static int soc_pcm_bespoke_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai; - struct snd_soc_dai *codec_dai; + struct snd_soc_dai *dai; int i, ret; - for_each_rtd_codec_dais(rtd, i, codec_dai) { - ret = snd_soc_dai_bespoke_trigger(codec_dai, substream, cmd); - if (ret < 0) - return ret; - } - - for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - ret = snd_soc_dai_bespoke_trigger(cpu_dai, substream, cmd); + for_each_rtd_dais(rtd, i, dai) { + ret = snd_soc_dai_bespoke_trigger(dai, substream, cmd); if (ret < 0) return ret; } @@ -1546,7 +1432,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card, if (!be->dai_link->no_pcm) continue; - for_each_rtd_cpu_dais(be, i, dai) { + for_each_rtd_dais(be, i, dai) { w = snd_soc_dai_get_widget(dai, stream); dev_dbg(card->dev, "ASoC: try BE : %s\n", @@ -1555,13 +1441,6 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card, if (w == widget) return be; } - - for_each_rtd_codec_dais(be, i, dai) { - w = snd_soc_dai_get_widget(dai, stream); - - if (w == widget) - return be; - } } /* Widget provided is not a BE */ @@ -1635,27 +1514,18 @@ static bool dpcm_be_is_active(struct snd_soc_dpcm *dpcm, int stream, struct snd_soc_dai *dai; unsigned int i; - /* is there a valid CPU DAI widget for this BE */ - for_each_rtd_cpu_dais(dpcm->be, i, dai) { + /* is there a valid DAI widget for this BE */ + for_each_rtd_dais(dpcm->be, i, dai) { widget = snd_soc_dai_get_widget(dai, stream); /* - * The BE is pruned only if none of the cpu_dai + * The BE is pruned only if none of the dai * widgets are in the active list. */ if (widget && widget_in_list(list, widget)) return true; } - /* is there a valid CODEC DAI widget for this BE */ - for_each_rtd_codec_dais(dpcm->be, i, dai) { - widget = snd_soc_dai_get_widget(dai, stream); - - /* prune the BE if it's no longer in our active list */ - if (widget && widget_in_list(list, widget)) - return true; - } - return false; } @@ -2001,43 +1871,23 @@ static void dpcm_runtime_merge_rate(struct snd_pcm_substream *substream, for_each_dpcm_be(fe, stream, dpcm) { struct snd_soc_pcm_runtime *be = dpcm->be; - struct snd_soc_pcm_stream *codec_stream; - struct snd_soc_pcm_stream *cpu_stream; + struct snd_soc_pcm_stream *pcm; struct snd_soc_dai *dai; int i; - for_each_rtd_cpu_dais(be, i, dai) { + for_each_rtd_dais(be, i, dai) { /* - * Skip CPUs which don't support the current stream + * Skip DAIs which don't support the current stream * type. See soc_pcm_init_runtime_hw() for more details */ if (!snd_soc_dai_stream_valid(dai, stream)) continue; - cpu_stream = snd_soc_dai_get_pcm_stream(dai, stream); + pcm = snd_soc_dai_get_pcm_stream(dai, stream); - *rate_min = max(*rate_min, cpu_stream->rate_min); - *rate_max = min_not_zero(*rate_max, - cpu_stream->rate_max); - *rates = snd_pcm_rate_mask_intersect(*rates, - cpu_stream->rates); - } - - for_each_rtd_codec_dais(be, i, dai) { - /* - * Skip CODECs which don't support the current stream - * type. See soc_pcm_init_runtime_hw() for more details - */ - if (!snd_soc_dai_stream_valid(dai, stream)) - continue; - - codec_stream = snd_soc_dai_get_pcm_stream(dai, stream); - - *rate_min = max(*rate_min, codec_stream->rate_min); - *rate_max = min_not_zero(*rate_max, - codec_stream->rate_max); - *rates = snd_pcm_rate_mask_intersect(*rates, - codec_stream->rates); + *rate_min = max(*rate_min, pcm->rate_min); + *rate_max = min_not_zero(*rate_max, pcm->rate_max); + *rates = snd_pcm_rate_mask_intersect(*rates, pcm->rates); } } } @@ -2120,8 +1970,7 @@ static int dpcm_apply_symmetry(struct snd_pcm_substream *fe_substream, struct snd_pcm_substream *be_substream = snd_soc_dpcm_get_substream(be, stream); struct snd_soc_pcm_runtime *rtd; - struct snd_soc_dai *codec_dai; - struct snd_soc_dai *cpu_dai; + struct snd_soc_dai *dai; int i; /* A backend may not have the requested substream */ @@ -2136,19 +1985,9 @@ static int dpcm_apply_symmetry(struct snd_pcm_substream *fe_substream, be_substream->runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX; /* Symmetry only applies if we've got an active stream. */ - for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - if (cpu_dai->active) { - err = soc_pcm_apply_symmetry(fe_substream, - cpu_dai); - if (err < 0) - return err; - } - } - - for_each_rtd_codec_dais(rtd, i, codec_dai) { - if (codec_dai->active) { - err = soc_pcm_apply_symmetry(fe_substream, - codec_dai); + for_each_rtd_dais(rtd, i, dai) { + if (dai->active) { + err = soc_pcm_apply_symmetry(fe_substream, dai); if (err < 0) return err; } From patchwork Mon Mar 16 06:37:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 11439795 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E8A8F90 for ; Mon, 16 Mar 2020 06:40:51 +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 7EF262071C for ; Mon, 16 Mar 2020 06:40:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="EX6VJFVE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7EF262071C 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 1FB2E18A9; Mon, 16 Mar 2020 07:40:05 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1FB2E18A9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1584340849; bh=HkHFy9aSE/wwB8Z3vzP6n8YzI+kS+bo/m9DDVI3sKjE=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=EX6VJFVELZ05vh0l915XO35OpMrd/eIGm1V8WzOvpcyNYUzEoMCpN4WVpBAjAJdrn xSsgVr496j7KHId0+TO2KKFTExy0bKM0iru1vQ8bxmBVG8ycg6ylKHPjZ8ijb4Qy7P uAa0A/kYkTjTJywXKLr1G72q6I42XGhJ2uF6mhMM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8F1DEF80058; Mon, 16 Mar 2020 07:37:40 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4EDADF8028F; Mon, 16 Mar 2020 07:37:26 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS, SURBL_BLOCKED,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 92625F8028C for ; Mon, 16 Mar 2020 07:37:20 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 92625F8028C Date: 16 Mar 2020 15:37:20 +0900 X-IronPort-AV: E=Sophos;i="5.70,559,1574089200"; d="scan'208";a="41771277" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 16 Mar 2020 15:37:20 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 1EE8341AD594; Mon, 16 Mar 2020 15:37:20 +0900 (JST) Message-ID: <87r1xsolen.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 5/6] ASoC: soc-core: Merge CPU/Codec for soc_dai_pcm_new() User-Agent: Wanderlust/2.15.9 Emacs/25.2 Mule/6.0 To: Mark Brown In-Reply-To: <87y2s0olg6.wl-kuninori.morimoto.gx@renesas.com> References: <87y2s0olg6.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 Now CPU/Codec DAIs are alias for dais. Thus, we can directly use for_each_rtd_dais() macro for soc_dai_pcm_new(). This patch merge CPU/Codec for it. Signed-off-by: Kuninori Morimoto --- sound/soc/soc-core.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 333cbbd268b4..38c2b0434f8f 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1037,20 +1037,20 @@ int snd_soc_add_pcm_runtime(struct snd_soc_card *card, } EXPORT_SYMBOL_GPL(snd_soc_add_pcm_runtime); -static int soc_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, - struct snd_soc_pcm_runtime *rtd) +static int soc_dai_pcm_new(struct snd_soc_pcm_runtime *rtd) { + struct snd_soc_dai *dai; int i, ret = 0; - for (i = 0; i < num_dais; ++i) { - struct snd_soc_dai_driver *drv = dais[i]->driver; + for_each_rtd_dais(rtd, i, dai) { + struct snd_soc_dai_driver *drv = dai->driver; if (drv->pcm_new) - ret = drv->pcm_new(rtd, dais[i]); + ret = drv->pcm_new(rtd, dai); if (ret < 0) { - dev_err(dais[i]->dev, + dev_err(dai->dev, "ASoC: Failed to bind %s with pcm device\n", - dais[i]->name); + dai->name); return ret; } } @@ -1121,13 +1121,8 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card, dai_link->stream_name, ret); return ret; } - ret = soc_dai_pcm_new(rtd->cpu_dais, - rtd->num_cpus, rtd); - if (ret < 0) - return ret; - ret = soc_dai_pcm_new(rtd->codec_dais, - rtd->num_codecs, rtd); - return ret; + + return soc_dai_pcm_new(rtd); } static void soc_set_name_prefix(struct snd_soc_card *card, From patchwork Mon Mar 16 06:37:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 11439797 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA14614B4 for ; Mon, 16 Mar 2020 06:41:32 +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 4629E2071C for ; Mon, 16 Mar 2020 06:41:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="MgAFxrf+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4629E2071C 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 7FB7318B0; Mon, 16 Mar 2020 07:40:46 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7FB7318B0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1584340890; bh=aLf/Y9gjZ5JZ5iQng8xi8Vtp+J1ri5pmVSbLNIBj7B4=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=MgAFxrf+2Yhfn78EhpvfEgK43OXU356HIVJAa+xgq/6UOHEK0T/3rLC81/qBOCdSX B5zW1KJyvFEkr9dSkLR5yLraoBvidX0HHJWWRCqwv+iPh+xkHvA5V1PAc9udtgs7pE F1RVfuO7iaMwm/bA3j48Mdx3Bz8n/18/XS5BWJP8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9C51AF802BE; Mon, 16 Mar 2020 07:37:41 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5E890F802A9; Mon, 16 Mar 2020 07:37:32 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS, SURBL_BLOCKED,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id 9F352F8029A for ; Mon, 16 Mar 2020 07:37:27 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9F352F8029A Date: 16 Mar 2020 15:37:26 +0900 X-IronPort-AV: E=Sophos;i="5.70,559,1574089200"; d="scan'208";a="41985626" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 16 Mar 2020 15:37:26 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 145404005E25; Mon, 16 Mar 2020 15:37:26 +0900 (JST) Message-ID: <87pndcoleh.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 6/6] ASoC: soc-pcm: Merge CPU/Codec MSB at soc_pcm_apply_msb() User-Agent: Wanderlust/2.15.9 Emacs/25.2 Mule/6.0 To: Mark Brown In-Reply-To: <87y2s0olg6.wl-kuninori.morimoto.gx@renesas.com> References: <87y2s0olg6.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 soc_pcm_apply_msb() is setting msb for both CPU/Codec, but we can merge these into one. This patch do it. Signed-off-by: Kuninori Morimoto --- sound/soc/soc-pcm.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index e256d438ee68..aadf3349fb07 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -532,35 +532,23 @@ static void soc_pcm_set_msb(struct snd_pcm_substream *substream, int bits) static void soc_pcm_apply_msb(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai; - struct snd_soc_dai *codec_dai; - struct snd_soc_pcm_stream *pcm_codec, *pcm_cpu; + struct snd_soc_dai *dai; + struct snd_soc_pcm_stream *pcm; int stream = substream->stream; int i; - unsigned int bits = 0, cpu_bits = 0; + unsigned int bits = 0; - for_each_rtd_codec_dais(rtd, i, codec_dai) { - pcm_codec = snd_soc_dai_get_pcm_stream(codec_dai, stream); + for_each_rtd_dais(rtd, i, dai) { + pcm = snd_soc_dai_get_pcm_stream(dai, stream); - if (pcm_codec->sig_bits == 0) { + if (pcm->sig_bits == 0) { bits = 0; break; } - bits = max(pcm_codec->sig_bits, bits); - } - - for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - pcm_cpu = snd_soc_dai_get_pcm_stream(cpu_dai, stream); - - if (pcm_cpu->sig_bits == 0) { - cpu_bits = 0; - break; - } - cpu_bits = max(pcm_cpu->sig_bits, cpu_bits); + bits = max(pcm->sig_bits, bits); } soc_pcm_set_msb(substream, bits); - soc_pcm_set_msb(substream, cpu_bits); } /**