Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1093349iog; Mon, 13 Jun 2022 21:37:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDO50YiyBBc0yDS7wAGdXJTJUNz5jaupfbzbtMAFfj0xgBPW0V6E1/M3wNoVtAqNi+Cext X-Received: by 2002:a05:6402:160b:b0:431:35df:63c0 with SMTP id f11-20020a056402160b00b0043135df63c0mr3665190edv.124.1655181441959; Mon, 13 Jun 2022 21:37:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655181441; cv=none; d=google.com; s=arc-20160816; b=ezNiVSI8lfNAmzOBNH5ZA7thB4NnkE1WkK/NpMHOLfW+RvKBZpdMdHcQD8GrzC/5KK g6SmOFlasW4fNUt5Q45006NANotaqrjysLFsrdwIhwFMmUWmBygtP6esD5BA+A7w0rF4 7UV8S1keQzJQqpT78QtL3NYfZ38q/DI6FssmHWBa80P0QFUJ5fSrL3GciVahsygeYuvl Kp+3vjpMJ0qDHu6rR39dQHulo17L8rqW6nsTHxwfyKcMHXit4wZZbkX3NjWVBYIB/is1 fCPoHP9/PeLRBMOYNiLJtzUcjf4szNG/4F3SubIKUBDGgLvj1BEnPNEymlhReAQwhtvj TjIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=LeNxTtrdVwNUTEvnKmbjLyQTXL4XVN0aEtA5Gatu/JU=; b=sYPWFJIce86ewBkgNMTol9KwWD4U6LXA+4fPLr96RkFCNBauZP7Bhw+4N8oAu6klks 8UjOV3YV+3f4m+44Dk4EbJC04lHsXeS6CCkq4Id8YO4aqaZRt0qsrOomCws5pVzaGq7p ULJV9aJZm2YmRjAH45Sf7sYWZvWAzENiePyDHyAFKiwSbg85fNjemPuGV9Q61IRL997o LpKpGMhrfE5xNolxSz3+9WwSaduJbBXcu1gTAl1u5+xqCYOH6h2aHcB5/EFVNJcQHiPz 1D/kAxK9rhYvsEMoCqzOHCAIS42vZUnk03tATyni8+rxkJAbjmJEb+vuLcrQ2fzSYbsx mYVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn1-20020a17090794c100b007122a9d20bdsi11028993ejc.237.2022.06.13.21.36.53; Mon, 13 Jun 2022 21:37:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351229AbiFNEZu (ORCPT + 99 others); Tue, 14 Jun 2022 00:25:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349068AbiFNEZf (ORCPT ); Tue, 14 Jun 2022 00:25:35 -0400 Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D48CF2AC76; Mon, 13 Jun 2022 21:25:31 -0700 (PDT) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 3DB13202719; Tue, 14 Jun 2022 06:25:30 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id E85B8202718; Tue, 14 Jun 2022 06:25:29 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 0E88B180219B; Tue, 14 Jun 2022 12:25:27 +0800 (+08) From: Shengjiu Wang To: nicoleotsuka@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, shengjiu.wang@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, robh+dt@kernel.org, krzk+dt@kernel.org, devicetree@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/7] ASoC: fsl_sai: Add PDM daifmt support Date: Tue, 14 Jun 2022 12:11:18 +0800 Message-Id: <1655179884-12278-2-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1655179884-12278-1-git-send-email-shengjiu.wang@nxp.com> References: <1655179884-12278-1-git-send-email-shengjiu.wang@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org PDM format is used for 1-bit stream, so clear the FBT and SYWD, and the each dataline only has one channel data. Signed-off-by: Shengjiu Wang --- sound/soc/fsl/fsl_sai.c | 17 +++++++++++++++-- sound/soc/fsl/fsl_sai.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 4f5bd9597c74..d11ee3b6f163 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -224,6 +224,7 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai, if (!sai->is_lsb_first) val_cr4 |= FSL_SAI_CR4_MF; + sai->is_pdm_mode = false; /* DAI mode */ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: @@ -262,6 +263,11 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai, val_cr2 |= FSL_SAI_CR2_BCP; sai->is_dsp_mode = true; break; + case SND_SOC_DAIFMT_PDM: + val_cr2 |= FSL_SAI_CR2_BCP; + val_cr4 &= ~FSL_SAI_CR4_MF; + sai->is_pdm_mode = true; + break; case SND_SOC_DAIFMT_RIGHT_J: /* To be done */ default: @@ -470,6 +476,13 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream, pins = DIV_ROUND_UP(channels, slots); + /* + * PDM mode, channels are independent + * each channels are on one dataline/FIFO. + */ + if (sai->is_pdm_mode) + pins = channels; + if (!sai->is_consumer_mode) { if (sai->bclk_ratio) ret = fsl_sai_set_bclk(cpu_dai, tx, @@ -492,13 +505,13 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream, } } - if (!sai->is_dsp_mode) + if (!sai->is_dsp_mode && !sai->is_pdm_mode) val_cr4 |= FSL_SAI_CR4_SYWD(slot_width); val_cr5 |= FSL_SAI_CR5_WNW(slot_width); val_cr5 |= FSL_SAI_CR5_W0W(slot_width); - if (sai->is_lsb_first) + if (sai->is_lsb_first || sai->is_pdm_mode) val_cr5 |= FSL_SAI_CR5_FBT(0); else val_cr5 |= FSL_SAI_CR5_FBT(word_width - 1); diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index 1c8f5ca07f9d..bc2a86a413e1 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -259,6 +259,7 @@ struct fsl_sai { bool is_consumer_mode; bool is_lsb_first; bool is_dsp_mode; + bool is_pdm_mode; bool synchronous[2]; unsigned int mclk_id[2]; -- 2.17.1