From patchwork Mon Jan 19 09:54:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 5656501 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 348389F2ED for ; Mon, 19 Jan 2015 09:55:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 665CD2037D for ; Mon, 19 Jan 2015 09:55:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 81D3D20381 for ; Mon, 19 Jan 2015 09:55:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751928AbbASJzJ (ORCPT ); Mon, 19 Jan 2015 04:55:09 -0500 Received: from smtp-out-152.synserver.de ([212.40.185.152]:1046 "EHLO smtp-out-152.synserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751841AbbASJzI (ORCPT ); Mon, 19 Jan 2015 04:55:08 -0500 Received: (qmail 30086 invoked by uid 0); 19 Jan 2015 09:55:07 -0000 X-SynServer-TrustedSrc: 1 X-SynServer-AuthUser: lars@metafoo.de X-SynServer-PPID: 29681 Received: from pd9e2fc65.dip0.t-ipconnect.de (HELO lars-adi-laptop.analog.com) [217.226.252.101] by 217.119.54.87 with SMTP; 19 Jan 2015 09:55:06 -0000 From: Lars-Peter Clausen To: Mark Brown , Liam Girdwood Cc: Kuninori Morimoto , Simon Horman , Magnus Damm , linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org, alsa-devel@alsa-project.org, Lars-Peter Clausen Subject: [PATCH 2/3] ASoC: sh: fsi: Fix clock inversion Date: Mon, 19 Jan 2015 10:54:56 +0100 Message-Id: <1421661297-19654-2-git-send-email-lars@metafoo.de> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1421661297-19654-1-git-send-email-lars@metafoo.de> References: <1421661297-19654-1-git-send-email-lars@metafoo.de> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP According to the sh7724 hardware user manual (Rev.2.00 Jan 2013) page 1851 to 1856 the FSI bit-clock is inverted to the bit-clock as specified by the I2S standard. This means the bit clock inversion bit should be set for a normal I2S clock and should not be set for an inverted I2S clock. Similarly when operating in left-justified mode both the frame-clock and the bit-clock need to be inverted to be standards compliant. This means also that the extra clock inversion setting in the armadillo800eva machine driver for CPU component should now be removed. Signed-off-by: Lars-Peter Clausen --- I don't have the hardware but I'd like to get rid of the extra SND_SOC_DAIFMT_IB_NF in simple-card platform data, so we can remove the fmt field. Kuninori can you check if this works? --- arch/arm/mach-shmobile/board-armadillo800eva.c | 1 - sound/soc/sh/fsi.c | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c b/arch/arm/mach-shmobile/board-armadillo800eva.c index 75de26c..36aaeb1 100644 --- a/arch/arm/mach-shmobile/board-armadillo800eva.c +++ b/arch/arm/mach-shmobile/board-armadillo800eva.c @@ -1015,7 +1015,6 @@ static struct asoc_simple_card_info fsi_wm8978_info = { .platform = "sh_fsi2", .daifmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, .cpu_dai = { - .fmt = SND_SOC_DAIFMT_IB_NF, .name = "fsia-dai", }, .codec_dai = { diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index b87b22e..dfb17f6 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c @@ -1594,6 +1594,12 @@ static int fsi_dai_trigger(struct snd_pcm_substream *substream, int cmd, static int fsi_set_fmt_dai(struct fsi_priv *fsi, unsigned int fmt) { + /* + * FSI bit clock is inverted to the I2S specification, so we invert it + * when a non-inverted I2S clock was requested and vice versa. + */ + fsi->bit_clk_inv = !fsi->bit_clk_inv; + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: fsi->fmt = CR_I2S; @@ -1602,6 +1608,7 @@ static int fsi_set_fmt_dai(struct fsi_priv *fsi, unsigned int fmt) case SND_SOC_DAIFMT_LEFT_J: fsi->fmt = CR_PCM; fsi->chan_num = 2; + fsi->lr_clk_inv = !fsi->lr_clk_inv; break; default: return -EINVAL;