From patchwork Mon Jun 14 00:56:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 459944 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=-13.8 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, 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 F416EC48BDF for ; Mon, 14 Jun 2021 00:58:16 +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 BA80661059 for ; Mon, 14 Jun 2021 00:58:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BA80661059 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 3E143176D; Mon, 14 Jun 2021 02:57:24 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3E143176D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623632294; bh=+ZiF8c4zU6pS4MiA3Z/f5m2BMssRc2VF/3ZN/XanHyY=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=fvUf5iXUUF2/WlZss3swaH564dzXnt8YurXWS9G2PYAshEAbPtbo7yauIcVyIkqHv k5nIMhFGNJiuu/u6zptBnwd5+ifX6k3n59nA0d2RIjT+mznDcvItnhCABFr2nYd26U P9LsSMY0DqqCuvoMOgf2YNQG1w4k1MCrkjWHiWQA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D9912F800FB; Mon, 14 Jun 2021 02:56:56 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B2855F8016D; Mon, 14 Jun 2021 02:56:55 +0200 (CEST) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id D83A9F800FB for ; Mon, 14 Jun 2021 02:56:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D83A9F800FB Date: 14 Jun 2021 09:56:46 +0900 X-IronPort-AV: E=Sophos;i="5.83,272,1616425200"; d="scan'208";a="84248100" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 14 Jun 2021 09:56:46 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 4746B4142DF2; Mon, 14 Jun 2021 09:56:46 +0900 (JST) Message-ID: <87a6ntw9f5.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v3 1/8] ASoC: soc-core: add snd_soc_daifmt_clock_provider_from_bitmap() User-Agent: Wanderlust/2.15.9 Emacs/26.3 Mule/6.0 To: Liam Girdwood , Mark Brown In-Reply-To: <87bl89w9fw.wl-kuninori.morimoto.gx@renesas.com> References: <87bl89w9fw.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Alexandre Belloni , Timur Tabi , Xiubo Li , Martin Blumenstingl , Shengjiu Wang , Sameer Pujar , Neil Armstrong , Nicolas Ferre , Nicolin Chen , Ludovic Desroches , Kevin Hilman , Codrin Ciubotariu , alsa-devel@alsa-project.org, Fabio Estevam , Jerome Brunet 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 This patch adds snd_soc_daifmt_clock_provider_from_bitmap() function to judge clock/frame master from its bitmap. This is prepare for snd_soc_of_parse_daifmt() cleanup. Signed-off-by: Kuninori Morimoto --- include/sound/soc.h | 1 + sound/soc/soc-core.c | 33 +++++++++++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index e746da996351..ea35e431e04e 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1232,6 +1232,7 @@ void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card, int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, const char *propname); int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname); +unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame); unsigned int snd_soc_of_parse_daifmt(struct device_node *np, const char *prefix, struct device_node **bitclkmaster, diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 44e65f984a5c..f271202f4049 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3017,6 +3017,24 @@ int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname) } EXPORT_SYMBOL_GPL(snd_soc_of_parse_aux_devs); +unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame) +{ + /* Codec base */ + switch (bit_frame) { + case 0x11: + return SND_SOC_DAIFMT_CBP_CFP; + case 0x10: + return SND_SOC_DAIFMT_CBP_CFC; + case 0x01: + return SND_SOC_DAIFMT_CBC_CFP; + default: + return SND_SOC_DAIFMT_CBC_CFC; + } + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_daifmt_clock_provider_from_bitmap); + unsigned int snd_soc_of_parse_daifmt(struct device_node *np, const char *prefix, struct device_node **bitclkmaster, @@ -3115,20 +3133,7 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np, if (frame && framemaster) *framemaster = of_parse_phandle(np, prop, 0); - switch ((bit << 4) + frame) { - case 0x11: - format |= SND_SOC_DAIFMT_CBM_CFM; - break; - case 0x10: - format |= SND_SOC_DAIFMT_CBM_CFS; - break; - case 0x01: - format |= SND_SOC_DAIFMT_CBS_CFM; - break; - default: - format |= SND_SOC_DAIFMT_CBS_CFS; - break; - } + format |= snd_soc_daifmt_clock_provider_from_bitmap((bit << 4) + frame); return format; } From patchwork Mon Jun 14 00:56:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 460587 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=-13.8 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, 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 4F0A4C48BE8 for ; Mon, 14 Jun 2021 00:58: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 5C3E061374 for ; Mon, 14 Jun 2021 00:58:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C3E061374 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 C59251786; Mon, 14 Jun 2021 02:57:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C59251786 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623632309; bh=J/7aGgLansjWS+nprUPaQqsqpDAhoZ8xJCb5z64dp+c=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=U2gWMQja4EnVDGryBBh587dm/6XJi8lvSj+l1svFHVl4S5RERyuLx0mAuuS77tFLA pLJEtegksBrifKNhiWJl6hNbtshnRLJ4iqehU+JoIhdz7Q4i5/HWhyZVFPV47IGJhi MwD/57uGv8nURNywNz5ka8Fx4iQJfafFq45JxlA4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 177D3F804C2; Mon, 14 Jun 2021 02:57:06 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 625F5F804CF; Mon, 14 Jun 2021 02:57:04 +0200 (CEST) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 80917F804C2 for ; Mon, 14 Jun 2021 02:56:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 80917F804C2 Date: 14 Jun 2021 09:56:54 +0900 X-IronPort-AV: E=Sophos;i="5.83,272,1616425200"; d="scan'208";a="84107730" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 14 Jun 2021 09:56:54 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 0B4DA4007F52; Mon, 14 Jun 2021 09:56:54 +0900 (JST) Message-ID: <878s3dw9ex.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v3 2/8] ASoC: soc-core: add snd_soc_daifmt_clock_provider_fliped() User-Agent: Wanderlust/2.15.9 Emacs/26.3 Mule/6.0 To: Liam Girdwood , Mark Brown In-Reply-To: <87bl89w9fw.wl-kuninori.morimoto.gx@renesas.com> References: <87bl89w9fw.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Alexandre Belloni , Timur Tabi , Xiubo Li , Martin Blumenstingl , Shengjiu Wang , Sameer Pujar , Neil Armstrong , Nicolas Ferre , Nicolin Chen , Ludovic Desroches , Kevin Hilman , Codrin Ciubotariu , alsa-devel@alsa-project.org, Fabio Estevam , Jerome Brunet 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 Sometimes we want to get CLOCK_PROVIDER fliped dai_fmt. This patch adds new snd_soc_daifmt_clock_provider_fliped() for it. Signed-off-by: Kuninori Morimoto --- include/sound/soc.h | 2 ++ sound/soc/soc-core.c | 40 +++++++++++++++++++++++++--------------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index ea35e431e04e..45f3da277c5d 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1232,6 +1232,8 @@ void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card, int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, const char *propname); int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname); + +unsigned int snd_soc_daifmt_clock_provider_fliped(unsigned int dai_fmt); unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame); unsigned int snd_soc_of_parse_daifmt(struct device_node *np, const char *prefix, diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index f271202f4049..0a8143e3fcdb 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1249,21 +1249,8 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd, * Flip the polarity for the "CPU" end of a CODEC<->CODEC link * the component which has non_legacy_dai_naming is Codec */ - inv_dai_fmt = dai_fmt & ~SND_SOC_DAIFMT_MASTER_MASK; - switch (dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) { - case SND_SOC_DAIFMT_CBM_CFM: - inv_dai_fmt |= SND_SOC_DAIFMT_CBS_CFS; - break; - case SND_SOC_DAIFMT_CBM_CFS: - inv_dai_fmt |= SND_SOC_DAIFMT_CBS_CFM; - break; - case SND_SOC_DAIFMT_CBS_CFM: - inv_dai_fmt |= SND_SOC_DAIFMT_CBM_CFS; - break; - case SND_SOC_DAIFMT_CBS_CFS: - inv_dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; - break; - } + inv_dai_fmt = snd_soc_daifmt_clock_provider_fliped(dai_fmt); + for_each_rtd_cpu_dais(rtd, i, cpu_dai) { unsigned int fmt = dai_fmt; @@ -3017,6 +3004,29 @@ int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname) } EXPORT_SYMBOL_GPL(snd_soc_of_parse_aux_devs); +unsigned int snd_soc_daifmt_clock_provider_fliped(unsigned int dai_fmt) +{ + unsigned int inv_dai_fmt = dai_fmt & ~SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK; + + switch (dai_fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) { + case SND_SOC_DAIFMT_CBP_CFP: + inv_dai_fmt |= SND_SOC_DAIFMT_CBC_CFC; + break; + case SND_SOC_DAIFMT_CBP_CFC: + inv_dai_fmt |= SND_SOC_DAIFMT_CBC_CFP; + break; + case SND_SOC_DAIFMT_CBC_CFP: + inv_dai_fmt |= SND_SOC_DAIFMT_CBP_CFC; + break; + case SND_SOC_DAIFMT_CBC_CFC: + inv_dai_fmt |= SND_SOC_DAIFMT_CBP_CFP; + break; + } + + return inv_dai_fmt; +} +EXPORT_SYMBOL_GPL(snd_soc_daifmt_clock_provider_fliped); + unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame) { /* Codec base */ From patchwork Mon Jun 14 00:57:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 459943 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=-13.8 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, 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 07A63C48BDF for ; Mon, 14 Jun 2021 00:58:59 +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 7F6C461059 for ; Mon, 14 Jun 2021 00:58:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F6C461059 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 2423D176E; Mon, 14 Jun 2021 02:58:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2423D176E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623632337; bh=dx7fmEHVtCkRnOzybyTOc25zqkF8WYQZQJNsQDb3pH0=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=AJnkrrsDBSUGiOUOpXHTjVy+fbhQc5tvjBcoC/aD9BPJkCengOKf9d5bJQMkLffsP d/y5g81XSln4i4p/ureHsfj7pAKRzra0lSqgpKPzKYELwcPjeQrdvqHWtGJ+nmfHkK 1zQHVewxhgNn8g2H94xgdhbYeW/KvXu3bqGGX9GU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B431FF804D2; Mon, 14 Jun 2021 02:57:17 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BABD8F804D6; Mon, 14 Jun 2021 02:57:16 +0200 (CEST) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 92F03F804CC for ; Mon, 14 Jun 2021 02:57:09 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 92F03F804CC Date: 14 Jun 2021 09:57:08 +0900 X-IronPort-AV: E=Sophos;i="5.83,272,1616425200"; d="scan'208";a="84107750" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 14 Jun 2021 09:57:08 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 4476D4140BEF; Mon, 14 Jun 2021 09:57:08 +0900 (JST) Message-ID: <877dixw9ej.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v3 3/8] ASoC: soc-core: add snd_soc_daifmt_parse_format/clock_provider() User-Agent: Wanderlust/2.15.9 Emacs/26.3 Mule/6.0 To: Liam Girdwood , Mark Brown In-Reply-To: <87bl89w9fw.wl-kuninori.morimoto.gx@renesas.com> References: <87bl89w9fw.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Alexandre Belloni , Timur Tabi , Xiubo Li , Martin Blumenstingl , Shengjiu Wang , Sameer Pujar , Neil Armstrong , Nicolas Ferre , Nicolin Chen , Ludovic Desroches , Kevin Hilman , Codrin Ciubotariu , alsa-devel@alsa-project.org, Fabio Estevam , Jerome Brunet 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 snd_soc_of_parse_daifmt() parses daifmt, but bitclock/frame provider parsing part is one of headacke, because we are assuming below both cases. A) node { bitclock-master; frame-master; ... }; B) link { bitclock-master = <&xxx>; frame-master = <&xxx>; ... }; The original was style A), and style B) was added later by commit b3ca11ff59bc ("ASoC: simple-card: Move dai-link level properties away from dai subnodes"). snd_soc_of_parse_daifmt() parses it as style A), and user need to update it to style B) if needed. To handle it more flexibile, this patch adds new functions which separates snd_soc_of_parse_daifmt() helper function. snd_soc_daifmt_parse_format() :for DAI format snd_soc_daifmt_parse_clock_provider_as_flag() :for style A) snd_soc_daifmt_parse_clock_provider_as_phandl() :for style B) snd_soc_daifmt_parse_clock_provider_as_bitmap() :use with _from_bitmap This means snd_soc_of_parse_daifmt() == snd_soc_daifmt_parse_format() | snd_soc_daifmt_parse_clock_provider_as_flag() This patch also indicate relatesionship comment for snd_soc_daifmt_clock_provider_from_bitmap(). Signed-off-by: Kuninori Morimoto --- include/sound/soc.h | 14 +++++ sound/soc/soc-core.c | 124 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+) diff --git a/include/sound/soc.h b/include/sound/soc.h index 45f3da277c5d..63194a8773cd 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1235,6 +1235,20 @@ int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname); unsigned int snd_soc_daifmt_clock_provider_fliped(unsigned int dai_fmt); unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame); + +unsigned int snd_soc_daifmt_parse_format(struct device_node *np, const char *prefix); +unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np, + const char *prefix, + struct device_node **bitclkmaster, + struct device_node **framemaster); +#define snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix) \ + snd_soc_daifmt_parse_clock_provider_raw(np, prefix, NULL, NULL) +#define snd_soc_daifmt_parse_clock_provider_as_phandle \ + snd_soc_daifmt_parse_clock_provider_raw +#define snd_soc_daifmt_parse_clock_provider_as_flag(np, prefix) \ + snd_soc_daifmt_clock_provider_from_bitmap( \ + snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix)) + unsigned int snd_soc_of_parse_daifmt(struct device_node *np, const char *prefix, struct device_node **bitclkmaster, diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 0a8143e3fcdb..4cb9bb009e90 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3029,6 +3029,11 @@ EXPORT_SYMBOL_GPL(snd_soc_daifmt_clock_provider_fliped); unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame) { + /* + * bit_frame is return value from + * snd_soc_daifmt_parse_clock_provider_raw() + */ + /* Codec base */ switch (bit_frame) { case 0x11: @@ -3045,6 +3050,125 @@ unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame) } EXPORT_SYMBOL_GPL(snd_soc_daifmt_clock_provider_from_bitmap); +unsigned int snd_soc_daifmt_parse_format(struct device_node *np, + const char *prefix) +{ + int ret, i; + char prop[128]; + unsigned int format = 0; + int bit, frame; + const char *str; + struct { + char *name; + unsigned int val; + } of_fmt_table[] = { + { "i2s", SND_SOC_DAIFMT_I2S }, + { "right_j", SND_SOC_DAIFMT_RIGHT_J }, + { "left_j", SND_SOC_DAIFMT_LEFT_J }, + { "dsp_a", SND_SOC_DAIFMT_DSP_A }, + { "dsp_b", SND_SOC_DAIFMT_DSP_B }, + { "ac97", SND_SOC_DAIFMT_AC97 }, + { "pdm", SND_SOC_DAIFMT_PDM}, + { "msb", SND_SOC_DAIFMT_MSB }, + { "lsb", SND_SOC_DAIFMT_LSB }, + }; + + if (!prefix) + prefix = ""; + + /* + * check "dai-format = xxx" + * or "[prefix]format = xxx" + * SND_SOC_DAIFMT_FORMAT_MASK area + */ + ret = of_property_read_string(np, "dai-format", &str); + if (ret < 0) { + snprintf(prop, sizeof(prop), "%sformat", prefix); + ret = of_property_read_string(np, prop, &str); + } + if (ret == 0) { + for (i = 0; i < ARRAY_SIZE(of_fmt_table); i++) { + if (strcmp(str, of_fmt_table[i].name) == 0) { + format |= of_fmt_table[i].val; + break; + } + } + } + + /* + * check "[prefix]continuous-clock" + * SND_SOC_DAIFMT_CLOCK_MASK area + */ + snprintf(prop, sizeof(prop), "%scontinuous-clock", prefix); + if (of_property_read_bool(np, prop)) + format |= SND_SOC_DAIFMT_CONT; + else + format |= SND_SOC_DAIFMT_GATED; + + /* + * check "[prefix]bitclock-inversion" + * check "[prefix]frame-inversion" + * SND_SOC_DAIFMT_INV_MASK area + */ + snprintf(prop, sizeof(prop), "%sbitclock-inversion", prefix); + bit = !!of_get_property(np, prop, NULL); + + snprintf(prop, sizeof(prop), "%sframe-inversion", prefix); + frame = !!of_get_property(np, prop, NULL); + + switch ((bit << 4) + frame) { + case 0x11: + format |= SND_SOC_DAIFMT_IB_IF; + break; + case 0x10: + format |= SND_SOC_DAIFMT_IB_NF; + break; + case 0x01: + format |= SND_SOC_DAIFMT_NB_IF; + break; + default: + /* SND_SOC_DAIFMT_NB_NF is default */ + break; + } + + return format; +} +EXPORT_SYMBOL_GPL(snd_soc_daifmt_parse_format); + +unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np, + const char *prefix, + struct device_node **bitclkmaster, + struct device_node **framemaster) +{ + char prop[128]; + unsigned int bit, frame; + + if (!prefix) + prefix = ""; + + /* + * check "[prefix]bitclock-master" + * check "[prefix]frame-master" + */ + snprintf(prop, sizeof(prop), "%sbitclock-master", prefix); + bit = !!of_get_property(np, prop, NULL); + if (bit && bitclkmaster) + *bitclkmaster = of_parse_phandle(np, prop, 0); + + snprintf(prop, sizeof(prop), "%sframe-master", prefix); + frame = !!of_get_property(np, prop, NULL); + if (frame && framemaster) + *framemaster = of_parse_phandle(np, prop, 0); + + /* + * return bitmap. + * It will be parameter of + * snd_soc_daifmt_clock_provider_from_bitmap() + */ + return (bit << 4) + frame; +} +EXPORT_SYMBOL_GPL(snd_soc_daifmt_parse_clock_provider_raw); + unsigned int snd_soc_of_parse_daifmt(struct device_node *np, const char *prefix, struct device_node **bitclkmaster, From patchwork Mon Jun 14 00:57:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 460586 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=-13.8 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, 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 1FF93C48BE8 for ; Mon, 14 Jun 2021 00:59:12 +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 7A04060FE4 for ; Mon, 14 Jun 2021 00:59:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A04060FE4 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 0D329179E; Mon, 14 Jun 2021 02:58:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0D329179E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623632350; bh=/7G0mdHYoXDaFimZreriWv8f3bGncVBbArELRhd0pnI=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OnQLqqJUnXkerqf4ySRvnat7yvL/2Qbs+oE7ZMIEAqgyMzWLYqon69ZUx4C8dOvmE CG2wcE4gyu7DR9D1G+ahs/XiT59H0SBa05RKrMpb7dppj0+cwfTx1uuRFysltfSMAO KgFHXLi0wykUBmM3psgX4u8AUlf6Rq0sC9R2pMQE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 4CDE0F804D9; Mon, 14 Jun 2021 02:57:25 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 55011F804DF; Mon, 14 Jun 2021 02:57:23 +0200 (CEST) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 922CBF804D1 for ; Mon, 14 Jun 2021 02:57:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 922CBF804D1 Date: 14 Jun 2021 09:57:19 +0900 X-IronPort-AV: E=Sophos;i="5.83,272,1616425200"; d="scan'208";a="84107764" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 14 Jun 2021 09:57:19 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 46B014005E24; Mon, 14 Jun 2021 09:57:19 +0900 (JST) Message-ID: <875yyhw9e8.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v3 4/8] ASoC: atmel: switch to use snd_soc_daifmt_parse_format/clock_provider() User-Agent: Wanderlust/2.15.9 Emacs/26.3 Mule/6.0 To: Liam Girdwood , Mark Brown In-Reply-To: <87bl89w9fw.wl-kuninori.morimoto.gx@renesas.com> References: <87bl89w9fw.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Alexandre Belloni , Timur Tabi , Xiubo Li , Martin Blumenstingl , Shengjiu Wang , Sameer Pujar , Neil Armstrong , Nicolas Ferre , Nicolin Chen , Ludovic Desroches , Kevin Hilman , Codrin Ciubotariu , alsa-devel@alsa-project.org, Fabio Estevam , Jerome Brunet 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 This patch switch to use snd_soc_daifmt_parse_format/clock_provider() from snd_soc_of_parse_daifmt(). Signed-off-by: Kuninori Morimoto Reviewed-by: Codrin Ciubotariu --- sound/soc/atmel/mikroe-proto.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sound/soc/atmel/mikroe-proto.c b/sound/soc/atmel/mikroe-proto.c index f9a85fd01b79..0be7b4221c14 100644 --- a/sound/soc/atmel/mikroe-proto.c +++ b/sound/soc/atmel/mikroe-proto.c @@ -120,19 +120,22 @@ static int snd_proto_probe(struct platform_device *pdev) dai->cpus->of_node = cpu_np; dai->platforms->of_node = cpu_np; - dai_fmt = snd_soc_of_parse_daifmt(np, NULL, - &bitclkmaster, &framemaster); + dai_fmt = snd_soc_daifmt_parse_format(np, NULL); + snd_soc_daifmt_parse_clock_provider_as_phandle(np, NULL, + &bitclkmaster, &framemaster); if (bitclkmaster != framemaster) { dev_err(&pdev->dev, "Must be the same bitclock and frame master\n"); return -EINVAL; } if (bitclkmaster) { - dai_fmt &= ~SND_SOC_DAIFMT_MASTER_MASK; if (codec_np == bitclkmaster) dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; else dai_fmt |= SND_SOC_DAIFMT_CBS_CFS; + } else { + dai_fmt |= snd_soc_daifmt_parse_clock_provider_as_flag(np, NULL); } + of_node_put(bitclkmaster); of_node_put(framemaster); dai->dai_fmt = dai_fmt; From patchwork Mon Jun 14 00:57:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 459942 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=-13.8 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, 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 A11CDC48BE8 for ; Mon, 14 Jun 2021 00:59:36 +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 0DDD46134F for ; Mon, 14 Jun 2021 00:59:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0DDD46134F 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 99D3B176F; Mon, 14 Jun 2021 02:58:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 99D3B176F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623632374; bh=Bgb9LJEQvoDEFlQmLXvmCU1WWkOkyXpxWYFjLgweV8o=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=u5TAMsf8x0RJfAUjNi3zaBp5E1Ahjb3LjS43vw+sVOaBCTnm6THz6kKU+Y9g4E31e kluIfQxpFtgzWgoLTyCRIflS5xZ9OBfV2pRUrVGbCnPCCHW1DU2D7AHSkLeHv4EpCw sKz/J33fNSsgjiATCv8VILFguxgnIKyORVzuuLLc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 07363F8016C; Mon, 14 Jun 2021 02:58:07 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BE611F8016D; Mon, 14 Jun 2021 02:58:05 +0200 (CEST) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id 84281F80165 for ; Mon, 14 Jun 2021 02:57:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 84281F80165 Date: 14 Jun 2021 09:57:51 +0900 X-IronPort-AV: E=Sophos;i="5.83,272,1616425200"; d="scan'208";a="84248236" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 14 Jun 2021 09:57:51 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 78FDB4142FF2; Mon, 14 Jun 2021 09:57:51 +0900 (JST) Message-ID: <874ke1w9dc.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v3 5/8] ASoC: fsl: switch to use snd_soc_daifmt_parse_format/clock_provider() User-Agent: Wanderlust/2.15.9 Emacs/26.3 Mule/6.0 To: Liam Girdwood , Mark Brown In-Reply-To: <87bl89w9fw.wl-kuninori.morimoto.gx@renesas.com> References: <87bl89w9fw.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Alexandre Belloni , Timur Tabi , Xiubo Li , Martin Blumenstingl , Shengjiu Wang , Sameer Pujar , Neil Armstrong , Nicolas Ferre , Nicolin Chen , Ludovic Desroches , Kevin Hilman , Codrin Ciubotariu , alsa-devel@alsa-project.org, Fabio Estevam , Jerome Brunet 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 This patch switch to use snd_soc_daifmt_parse_format/clock_provider() from snd_soc_of_parse_daifmt(). Signed-off-by: Kuninori Morimoto --- sound/soc/fsl/fsl-asoc-card.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c index c62bfd1c3ac7..14d2956d0da3 100644 --- a/sound/soc/fsl/fsl-asoc-card.c +++ b/sound/soc/fsl/fsl-asoc-card.c @@ -540,7 +540,6 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) struct device *codec_dev = NULL; const char *codec_dai_name; const char *codec_dev_name; - unsigned int daifmt; u32 width; int ret; @@ -684,10 +683,10 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) } /* Format info from DT is optional. */ - daifmt = snd_soc_of_parse_daifmt(np, NULL, - &bitclkmaster, &framemaster); - daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK; + snd_soc_daifmt_parse_clock_provider_as_phandle(np, NULL, &bitclkmaster, &framemaster); if (bitclkmaster || framemaster) { + unsigned int daifmt = snd_soc_daifmt_parse_format(np, NULL); + if (codec_np == bitclkmaster) daifmt |= (codec_np == framemaster) ? SND_SOC_DAIFMT_CBM_CFM : SND_SOC_DAIFMT_CBM_CFS; From patchwork Mon Jun 14 00:58:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 460585 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=-13.8 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, 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 4C497C48BDF for ; Mon, 14 Jun 2021 00:59:57 +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 BADFA6134F for ; Mon, 14 Jun 2021 00:59:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BADFA6134F 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 5C63E1769; Mon, 14 Jun 2021 02:59:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5C63E1769 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623632395; bh=je3NGz7rnrCKhALfqcNd+jB4ExADqKO4nSfknT65kSY=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=avly9rnvKCGw78J6r2zyQj/5akqgaqbasGkZano2TxuujZnhyAH8z2WxEFrKnyNQ6 3z2pYp+9O/IsC3omQwimZjs6o4IFu61yR5QvJfbK1M1iLLRF5UJo+H48aN4PRQnCnz LR71wxcYIu+IWz0CSSvuqPLlBwTd6lxYpQjtMG90= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id AF097F80424; Mon, 14 Jun 2021 02:58:11 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 901CCF804CA; Mon, 14 Jun 2021 02:58:09 +0200 (CEST) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 8494EF802E8 for ; Mon, 14 Jun 2021 02:58:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8494EF802E8 Date: 14 Jun 2021 09:58:05 +0900 X-IronPort-AV: E=Sophos;i="5.83,272,1616425200"; d="scan'208";a="84107843" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 14 Jun 2021 09:58:05 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 22B154005E24; Mon, 14 Jun 2021 09:58:05 +0900 (JST) Message-ID: <8735tlw9cy.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v3 6/8] ASoC: meson: switch to use snd_soc_daifmt_parse_format/clock_provider() User-Agent: Wanderlust/2.15.9 Emacs/26.3 Mule/6.0 To: Liam Girdwood , Mark Brown In-Reply-To: <87bl89w9fw.wl-kuninori.morimoto.gx@renesas.com> References: <87bl89w9fw.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Alexandre Belloni , Timur Tabi , Xiubo Li , Martin Blumenstingl , Shengjiu Wang , Sameer Pujar , Neil Armstrong , Nicolas Ferre , Nicolin Chen , Ludovic Desroches , Kevin Hilman , Codrin Ciubotariu , alsa-devel@alsa-project.org, Fabio Estevam , Jerome Brunet 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 This patch switch to use snd_soc_daifmt_parse_format/clock_provider() from snd_soc_of_parse_daifmt(). Signed-off-by: Kuninori Morimoto Reviewed-by: Jerome Brunet --- sound/soc/meson/meson-card-utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/meson/meson-card-utils.c b/sound/soc/meson/meson-card-utils.c index 300ac8be46ef..415cc0046e4b 100644 --- a/sound/soc/meson/meson-card-utils.c +++ b/sound/soc/meson/meson-card-utils.c @@ -119,9 +119,9 @@ unsigned int meson_card_parse_daifmt(struct device_node *node, struct device_node *framemaster = NULL; unsigned int daifmt; - daifmt = snd_soc_of_parse_daifmt(node, "", - &bitclkmaster, &framemaster); - daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK; + daifmt = snd_soc_daifmt_parse_format(node, NULL); + + snd_soc_daifmt_parse_clock_provider_as_phandle(node, NULL, &bitclkmaster, &framemaster); /* If no master is provided, default to cpu master */ if (!bitclkmaster || bitclkmaster == cpu_node) { From patchwork Mon Jun 14 00:58:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 459941 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=-13.8 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, 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 BD20CC48BDF for ; Mon, 14 Jun 2021 01:00:19 +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 016EE61059 for ; Mon, 14 Jun 2021 01:00:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 016EE61059 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 89F52174C; Mon, 14 Jun 2021 02:59:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 89F52174C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623632417; bh=V7jTv9R46IkD5UWxSmmUup2nLdAe3xrJHfRFTP6J1ks=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=uGRPT1eIiRoChp3kPILoAH6C8B9H3JQcgTZK2k2eUcLK66QfCYs1eSExpekF4ix3I UerdNNSIT9qMr3M/YH2EOpmLlkuVkJqFMZ7f61bYqNjSj9XK5jkDEKuiz96gbFYWxV VAsHjn4qDidu+esJKedENlKW6aCBlu9Yza1a7oNI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5165EF80171; Mon, 14 Jun 2021 02:58:28 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D33F0F802A9; Mon, 14 Jun 2021 02:58:26 +0200 (CEST) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 05A7FF800FB for ; Mon, 14 Jun 2021 02:58:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 05A7FF800FB Date: 14 Jun 2021 09:58:22 +0900 X-IronPort-AV: E=Sophos;i="5.83,272,1616425200"; d="scan'208";a="84107873" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 14 Jun 2021 09:58:22 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id AB7D14142FFF; Mon, 14 Jun 2021 09:58:22 +0900 (JST) Message-ID: <871r95w9ch.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v3 7/8] ASoC: simple-card-utils: switch to use snd_soc_daifmt_parse_format/clock_provider() User-Agent: Wanderlust/2.15.9 Emacs/26.3 Mule/6.0 To: Liam Girdwood , Mark Brown In-Reply-To: <87bl89w9fw.wl-kuninori.morimoto.gx@renesas.com> References: <87bl89w9fw.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Alexandre Belloni , Timur Tabi , Xiubo Li , Martin Blumenstingl , Shengjiu Wang , Sameer Pujar , Neil Armstrong , Nicolas Ferre , Nicolin Chen , Ludovic Desroches , Kevin Hilman , Codrin Ciubotariu , alsa-devel@alsa-project.org, Fabio Estevam , Jerome Brunet 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 This patch switch to use snd_soc_daifmt_parse_format/clock_provider() from snd_soc_of_parse_daifmt(). Signed-off-by: Kuninori Morimoto --- sound/soc/generic/simple-card-utils.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index fa1247f0dda1..677f7da93b4b 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -61,10 +61,9 @@ int asoc_simple_parse_daifmt(struct device *dev, struct device_node *framemaster = NULL; unsigned int daifmt; - daifmt = snd_soc_of_parse_daifmt(node, prefix, - &bitclkmaster, &framemaster); - daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK; + daifmt = snd_soc_daifmt_parse_format(node, prefix); + snd_soc_daifmt_parse_clock_provider_as_phandle(node, prefix, &bitclkmaster, &framemaster); if (!bitclkmaster && !framemaster) { /* * No dai-link level and master setting was not found from @@ -73,15 +72,10 @@ int asoc_simple_parse_daifmt(struct device *dev, */ dev_dbg(dev, "Revert to legacy daifmt parsing\n"); - daifmt = snd_soc_of_parse_daifmt(codec, NULL, NULL, NULL) | - (daifmt & ~SND_SOC_DAIFMT_CLOCK_MASK); + daifmt |= snd_soc_daifmt_parse_clock_provider_as_flag(codec, NULL); } else { - if (codec == bitclkmaster) - daifmt |= (codec == framemaster) ? - SND_SOC_DAIFMT_CBM_CFM : SND_SOC_DAIFMT_CBM_CFS; - else - daifmt |= (codec == framemaster) ? - SND_SOC_DAIFMT_CBS_CFM : SND_SOC_DAIFMT_CBS_CFS; + daifmt |= snd_soc_daifmt_clock_provider_from_bitmap( + ((codec == bitclkmaster) << 4) | (codec == framemaster)); } of_node_put(bitclkmaster); From patchwork Mon Jun 14 00:58:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 460584 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=-13.8 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, 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 5CD66C48BDF for ; Mon, 14 Jun 2021 01:00:50 +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 C82B161059 for ; Mon, 14 Jun 2021 01:00:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C82B161059 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 662EF17A6; Mon, 14 Jun 2021 02:59:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 662EF17A6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623632448; bh=ChO3J9xbNQYCQIhfw6eGm5+MqXavHtOQuWKTPcb9oz0=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=WQwp90c/O1ulUvvaqry9SNHJuTKDIThEb00eVTiiQ6K/3MpjWDsqpOrqqGNhM7vQ6 iwH6SuEsb4bA+07SzlUu2snTmoe3SpaKQB5iYd/6K7r8+UAZdT65epT6QSYHOu5VBz jOWLLCWkZ/im7Jq1tLSFccyMzH7YLq7Hfryl7zGY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 78AD1F804CF; Mon, 14 Jun 2021 02:58:50 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8B05EF804CF; Mon, 14 Jun 2021 02:58:49 +0200 (CEST) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id 08C49F804CF for ; Mon, 14 Jun 2021 02:58:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 08C49F804CF Date: 14 Jun 2021 09:58:35 +0900 X-IronPort-AV: E=Sophos;i="5.83,272,1616425200"; d="scan'208";a="84248308" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 14 Jun 2021 09:58:35 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 9277A4143002; Mon, 14 Jun 2021 09:58:35 +0900 (JST) Message-ID: <87zgvtuuro.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v3 8/8] ASoC: soc-core: remove snd_soc_of_parse_daifmt() User-Agent: Wanderlust/2.15.9 Emacs/26.3 Mule/6.0 To: Liam Girdwood , Mark Brown In-Reply-To: <87bl89w9fw.wl-kuninori.morimoto.gx@renesas.com> References: <87bl89w9fw.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Alexandre Belloni , Timur Tabi , Xiubo Li , Martin Blumenstingl , Shengjiu Wang , Sameer Pujar , Neil Armstrong , Nicolas Ferre , Nicolin Chen , Ludovic Desroches , Kevin Hilman , Codrin Ciubotariu , alsa-devel@alsa-project.org, Fabio Estevam , Jerome Brunet 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 No driver is using snd_soc_of_parse_daifmt(). This patch removes it. Signed-off-by: Kuninori Morimoto --- include/sound/soc.h | 4 -- sound/soc/soc-core.c | 104 ------------------------------------------- 2 files changed, 108 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 63194a8773cd..675849d07284 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1249,10 +1249,6 @@ unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np, snd_soc_daifmt_clock_provider_from_bitmap( \ snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix)) -unsigned int snd_soc_of_parse_daifmt(struct device_node *np, - const char *prefix, - struct device_node **bitclkmaster, - struct device_node **framemaster); int snd_soc_get_dai_id(struct device_node *ep); int snd_soc_get_dai_name(const struct of_phandle_args *args, const char **dai_name); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 4cb9bb009e90..b9d2b8b650c4 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3169,110 +3169,6 @@ unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np, } EXPORT_SYMBOL_GPL(snd_soc_daifmt_parse_clock_provider_raw); -unsigned int snd_soc_of_parse_daifmt(struct device_node *np, - const char *prefix, - struct device_node **bitclkmaster, - struct device_node **framemaster) -{ - int ret, i; - char prop[128]; - unsigned int format = 0; - int bit, frame; - const char *str; - struct { - char *name; - unsigned int val; - } of_fmt_table[] = { - { "i2s", SND_SOC_DAIFMT_I2S }, - { "right_j", SND_SOC_DAIFMT_RIGHT_J }, - { "left_j", SND_SOC_DAIFMT_LEFT_J }, - { "dsp_a", SND_SOC_DAIFMT_DSP_A }, - { "dsp_b", SND_SOC_DAIFMT_DSP_B }, - { "ac97", SND_SOC_DAIFMT_AC97 }, - { "pdm", SND_SOC_DAIFMT_PDM}, - { "msb", SND_SOC_DAIFMT_MSB }, - { "lsb", SND_SOC_DAIFMT_LSB }, - }; - - if (!prefix) - prefix = ""; - - /* - * check "dai-format = xxx" - * or "[prefix]format = xxx" - * SND_SOC_DAIFMT_FORMAT_MASK area - */ - ret = of_property_read_string(np, "dai-format", &str); - if (ret < 0) { - snprintf(prop, sizeof(prop), "%sformat", prefix); - ret = of_property_read_string(np, prop, &str); - } - if (ret == 0) { - for (i = 0; i < ARRAY_SIZE(of_fmt_table); i++) { - if (strcmp(str, of_fmt_table[i].name) == 0) { - format |= of_fmt_table[i].val; - break; - } - } - } - - /* - * check "[prefix]continuous-clock" - * SND_SOC_DAIFMT_CLOCK_MASK area - */ - snprintf(prop, sizeof(prop), "%scontinuous-clock", prefix); - if (of_property_read_bool(np, prop)) - format |= SND_SOC_DAIFMT_CONT; - else - format |= SND_SOC_DAIFMT_GATED; - - /* - * check "[prefix]bitclock-inversion" - * check "[prefix]frame-inversion" - * SND_SOC_DAIFMT_INV_MASK area - */ - snprintf(prop, sizeof(prop), "%sbitclock-inversion", prefix); - bit = !!of_get_property(np, prop, NULL); - - snprintf(prop, sizeof(prop), "%sframe-inversion", prefix); - frame = !!of_get_property(np, prop, NULL); - - switch ((bit << 4) + frame) { - case 0x11: - format |= SND_SOC_DAIFMT_IB_IF; - break; - case 0x10: - format |= SND_SOC_DAIFMT_IB_NF; - break; - case 0x01: - format |= SND_SOC_DAIFMT_NB_IF; - break; - default: - /* SND_SOC_DAIFMT_NB_NF is default */ - break; - } - - /* - * check "[prefix]bitclock-master" - * check "[prefix]frame-master" - * SND_SOC_DAIFMT_MASTER_MASK area - */ - snprintf(prop, sizeof(prop), "%sbitclock-master", prefix); - bit = !!of_get_property(np, prop, NULL); - if (bit && bitclkmaster) - *bitclkmaster = of_parse_phandle(np, prop, 0); - - snprintf(prop, sizeof(prop), "%sframe-master", prefix); - frame = !!of_get_property(np, prop, NULL); - if (frame && framemaster) - *framemaster = of_parse_phandle(np, prop, 0); - - format |= snd_soc_daifmt_clock_provider_from_bitmap((bit << 4) + frame); - - return format; -} -EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt); - int snd_soc_get_dai_id(struct device_node *ep) { struct snd_soc_component *component;