From patchwork Thu Feb 27 00:45:01 2014
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Xiubo Li
X-Patchwork-Id: 3729831
Return-Path:
X-Original-To: patchwork-alsa-devel@patchwork.kernel.org
Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org
Received: from mail.kernel.org (mail.kernel.org [198.145.19.201])
by patchwork2.web.kernel.org (Postfix) with ESMTP id 7186CBF13A
for ;
Thu, 27 Feb 2014 01:52:02 +0000 (UTC)
Received: from mail.kernel.org (localhost [127.0.0.1])
by mail.kernel.org (Postfix) with ESMTP id 64EEB20219
for ;
Thu, 27 Feb 2014 01:52:01 +0000 (UTC)
Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243])
by mail.kernel.org (Postfix) with ESMTP id 030732020E
for ;
Thu, 27 Feb 2014 01:52:00 +0000 (UTC)
Received: by alsa0.perex.cz (Postfix, from userid 1000)
id 390AC2657DB; Thu, 27 Feb 2014 02:51:57 +0100 (CET)
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org
X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY,
UNRESOLVED_TEMPLATE autolearn=no version=3.3.1
Received: from alsa0.perex.cz (localhost [IPv6:::1])
by alsa0.perex.cz (Postfix) with ESMTP id C75AE2657B4;
Thu, 27 Feb 2014 02:51:46 +0100 (CET)
X-Original-To: alsa-devel@alsa-project.org
Delivered-To: alsa-devel@alsa-project.org
Received: by alsa0.perex.cz (Postfix, from userid 1000)
id E02742657B5; Thu, 27 Feb 2014 02:51:44 +0100 (CET)
Received: from tx2outboundpool.messaging.microsoft.com
(tx2ehsobe003.messaging.microsoft.com [65.55.88.13])
by alsa0.perex.cz (Postfix) with ESMTP id 8AD7F2657AD
for ;
Thu, 27 Feb 2014 02:51:37 +0100 (CET)
Received: from mail11-tx2-R.bigfish.com (10.9.14.236) by
TX2EHSOBE003.bigfish.com (10.9.40.23) with Microsoft SMTP Server id
14.1.225.22; Thu, 27 Feb 2014 01:51:34 +0000
Received: from mail11-tx2 (localhost [127.0.0.1]) by mail11-tx2-R.bigfish.com
(Postfix) with ESMTP id 1CC861A0500;
Thu, 27 Feb 2014 01:51:34 +0000 (UTC)
X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null);
IPV:NLI;
H:mail.freescale.net; RD:none; EFVD:NLI
X-SpamScore: 0
X-BigFish:
VS0(zze0eahzz1f42h2148h208ch1ee6h1de0h1fdah2073h2146h1202h1e76h2189h1d1ah1d2ah21bch1fc6hzz1de098h8275bh1de097hz2dh2a8h839he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh2222h224fh1fb3h1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e23h1fe8h1ff5h2218h2216h226dh22d0h24afh2327h2336h2438h2461h2487h24d7h2516h2545h255eh25cch1155h)
Received: from mail11-tx2 (localhost.localdomain [127.0.0.1]) by mail11-tx2
(MessageSwitch) id 1393465892411307_22584;
Thu, 27 Feb 2014 01:51:32 +0000 (UTC)
Received: from TX2EHSMHS032.bigfish.com (unknown [10.9.14.228]) by
mail11-tx2.bigfish.com (Postfix) with ESMTP id 56FEA3000B6;
Thu, 27 Feb 2014 01:51:32 +0000 (UTC)
Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS032.bigfish.com
(10.9.99.132) with Microsoft SMTP Server (TLS) id 14.16.227.3;
Thu, 27 Feb 2014 01:51:32 +0000
Received: from az84smr01.freescale.net (10.64.34.197) by
039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP
Server (TLS) id 14.3.158.2; Thu, 27 Feb 2014 01:51:32 +0000
Received: from rock.am.freescale.net (rock.ap.freescale.net [10.193.20.106])
by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id
s1R1pPVU009072; Wed, 26 Feb 2014 18:51:26 -0700
From: Xiubo Li
To:
Date: Thu, 27 Feb 2014 08:45:01 +0800
Message-ID: <1393461901-23844-1-git-send-email-Li.Xiubo@freescale.com>
X-Mailer: git-send-email 1.8.0
MIME-Version: 1.0
X-OriginatorOrg: freescale.com
X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn%
X-FOPE-CONNECTOR:
Id%0$Dn%FREESCALE.MAIL.ONMICROSOFT.COM$RO%1$TLS%0$FQDN%$TlsDn%
Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org,
Xiubo Li , lgirdwood@gmail.com, timur@tabi.org
Subject: [alsa-devel] [PATCH] ASoC: fsl-sai: Add SND_SOC_DAIFMT_DSP_A/B
support.
X-BeenThere: alsa-devel@alsa-project.org
X-Mailman-Version: 2.1.14
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-bounces@alsa-project.org
X-Virus-Scanned: ClamAV using ClamSMTP
o Add SND_SOC_DAIFMT_DSP_A support.
o Add SND_SOC_DAIFMT_DSP_B support.
Signed-off-by: Xiubo Li
---
sound/soc/fsl/fsl_sai.c | 45 ++++++++++++++++++++++++++++++++++++++++++---
sound/soc/fsl/fsl_sai.h | 1 +
2 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index 26d9f5e..c4a4231 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -108,15 +108,44 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai,
/* DAI mode */
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S:
- /* Data on rising edge of bclk, frame low, 1clk before data */
+ /*
+ * Frame low, 1clk before data, one word length for frame sync,
+ * frame sync starts one serial clock cycle earlier,
+ * that is, together with the last bit of the previous
+ * data word.
+ */
val_cr2 &= ~FSL_SAI_CR2_BCP;
val_cr4 |= FSL_SAI_CR4_FSE | FSL_SAI_CR4_FSP;
break;
case SND_SOC_DAIFMT_LEFT_J:
- /* Data on rising edge of bclk, frame high, 0clk before data */
+ /*
+ * Frame high, one word length for frame sync,
+ * frame sync asserts with the first bit of the frame.
+ */
val_cr2 &= ~FSL_SAI_CR2_BCP;
val_cr4 &= ~(FSL_SAI_CR4_FSE | FSL_SAI_CR4_FSP);
break;
+ case SND_SOC_DAIFMT_DSP_A:
+ /*
+ * Frame high, 1clk before data, one bit for frame sync,
+ * frame sync starts one serial clock cycle earlier,
+ * that is, together with the last bit of the previous
+ * data word.
+ */
+ val_cr2 &= ~FSL_SAI_CR2_BCP;
+ val_cr4 &= ~FSL_SAI_CR4_FSP;
+ val_cr4 |= FSL_SAI_CR4_FSE;
+ sai->is_dsp_mode = true;
+ break;
+ case SND_SOC_DAIFMT_DSP_B:
+ /*
+ * Frame high, one bit for frame sync,
+ * frame sync asserts with the first bit of the frame.
+ */
+ val_cr2 &= ~FSL_SAI_CR2_BCP;
+ val_cr4 &= ~(FSL_SAI_CR4_FSE | FSL_SAI_CR4_FSP);
+ sai->is_dsp_mode = true;
+ break;
case SND_SOC_DAIFMT_RIGHT_J:
/* To be done */
default:
@@ -219,7 +248,9 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream,
val_cr5 &= ~FSL_SAI_CR5_W0W_MASK;
val_cr5 &= ~FSL_SAI_CR5_FBT_MASK;
- val_cr4 |= FSL_SAI_CR4_SYWD(word_width);
+ if (!sai->is_dsp_mode)
+ val_cr4 |= FSL_SAI_CR4_SYWD(word_width);
+
val_cr5 |= FSL_SAI_CR5_WNW(word_width);
val_cr5 |= FSL_SAI_CR5_W0W(word_width);
@@ -245,6 +276,10 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd,
struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai);
u32 tcsr, rcsr;
+ /*
+ * The transmitter bit clock and frame sync are to be
+ * used by both the transmitter and receiver.
+ */
regmap_update_bits(sai->regmap, FSL_SAI_TCR2, FSL_SAI_CR2_SYNC,
~FSL_SAI_CR2_SYNC);
regmap_update_bits(sai->regmap, FSL_SAI_RCR2, FSL_SAI_CR2_SYNC,
@@ -261,6 +296,10 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd,
tcsr &= ~FSL_SAI_CSR_FRDE;
}
+ /*
+ * It is recommended that the transmitter is the last enabled
+ * and the first disabled.
+ */
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h
index 1571459..e432260 100644
--- a/sound/soc/fsl/fsl_sai.h
+++ b/sound/soc/fsl/fsl_sai.h
@@ -103,6 +103,7 @@ struct fsl_sai {
bool big_endian_regs;
bool big_endian_data;
+ bool is_dsp_mode;
struct snd_dmaengine_dai_dma_data dma_params_rx;
struct snd_dmaengine_dai_dma_data dma_params_tx;