From patchwork Thu Jul 31 06:52:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 4654111 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2417D9F2B8 for ; Thu, 31 Jul 2014 06:53:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2C0EF201B4 for ; Thu, 31 Jul 2014 06:53:13 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id E56632011E for ; Thu, 31 Jul 2014 06:53:11 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 01048264EF3; Thu, 31 Jul 2014 08:53:11 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 66E14265006; Thu, 31 Jul 2014 08:52:53 +0200 (CEST) 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 A3492264FFF; Thu, 31 Jul 2014 08:52:51 +0200 (CEST) Received: from mail-pd0-f182.google.com (mail-pd0-f182.google.com [209.85.192.182]) by alsa0.perex.cz (Postfix) with ESMTP id 6F2EB261AAF for ; Thu, 31 Jul 2014 08:52:28 +0200 (CEST) Received: by mail-pd0-f182.google.com with SMTP id fp1so2920661pdb.27 for ; Wed, 30 Jul 2014 23:52:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:message-id:from:subject:user-agent:to:cc:mime-version :content-type; bh=EqW+TK/qHlI08ZjBCuXTTGfsBG3ff7FK1lnuRkXh7Sc=; b=e+WxxmxgJRaYgMxlaRR4JXwiNd3FQUnIa73TjIHy8bfdofEwpDbi/4l9acRXPVGbQT /3cu4w+BSpEDvffkzFAq/iIqBJJaKq6CSgkI9e/CT4L/jMDuUndAaNy5yhJoFcMvvlnJ Q9gDwKN0j6czKYLkR7x80dRKv58vNLH5vCS4pFsf0na5vcykt+IXAiwPo/wC0d3wAiva XlkakBuzINH1JkJei7C98FJoHGlvAsuLqZHCNkOUXy67fx2DSHZWRf6THbOA3b+ktuw7 oFEcjEj7f9JFAz7oE5f78dmiw76hlgG0CCLjHJtm9zwDqJ55y1ROie2GlBvP4baZCZ9y /1XQ== X-Received: by 10.66.100.200 with SMTP id fa8mr2078145pab.23.1406789546765; Wed, 30 Jul 2014 23:52:26 -0700 (PDT) Received: from remon.gmail.com (49.14.32.202.bf.2iij.net. [202.32.14.49]) by mx.google.com with ESMTPSA id iq10sm4412484pbc.14.2014.07.30.23.52.25 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 30 Jul 2014 23:52:26 -0700 (PDT) Date: Wed, 30 Jul 2014 23:52:26 -0700 (PDT) Message-ID: <87egx2uijb.wl%kuninori.morimoto.gx@gmail.com> From: Kuninori Morimoto User-Agent: Wanderlust/2.14.0 Emacs/23.3 Mule/6.0 To: Mark Brown MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Cc: Jun Watanabe , Linux-ALSA , Simon , Liam Girdwood , Kuninori Morimoto Subject: [alsa-devel] [PATCH] ASoC: rsnd: care audio local bus data format consistency 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 From: Kuninori Morimoto R-Car sound uses Audio Local Bus which uses Lch/Rch format. This bus is used if driver uses BUSIF. But sound data is written as Rch/Lch format in register. This means Rch <-> Lch will be inverted. SSIU :: BUSIF_DALIGN is used to controlling data format. Reported-by: Jun Watanabe Signed-off-by: Kuninori Morimoto --- sound/soc/sh/rcar/gen.c | 1 + sound/soc/sh/rcar/rsnd.h | 2 ++ sound/soc/sh/rcar/src.c | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c index 5f9e0722..5db0557 100644 --- a/sound/soc/sh/rcar/gen.c +++ b/sound/soc/sh/rcar/gen.c @@ -284,6 +284,7 @@ static int rsnd_gen2_probe(struct platform_device *pdev, /* FIXME: it needs SSI_MODE2/3 in the future */ RSND_GEN_M_REG(SSI_BUSIF_MODE, 0x0, 0x80), RSND_GEN_M_REG(SSI_BUSIF_ADINR, 0x4, 0x80), + RSND_GEN_M_REG(BUSIF_DALIGN, 0x8, 0x80), RSND_GEN_M_REG(SSI_CTRL, 0x10, 0x80), RSND_GEN_M_REG(INT_ENABLE, 0x18, 0x80), }; diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 631b149..d119adf 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -90,6 +90,7 @@ enum rsnd_reg { RSND_REG_SHARE19, RSND_REG_SHARE20, RSND_REG_SHARE21, + RSND_REG_SHARE22, RSND_REG_MAX, }; @@ -127,6 +128,7 @@ enum rsnd_reg { #define RSND_REG_AUDIO_CLK_SEL2 RSND_REG_SHARE19 #define RSND_REG_CMD_CTRL RSND_REG_SHARE20 #define RSND_REG_CMDOUT_TIMSEL RSND_REG_SHARE21 +#define RSND_REG_BUSIF_DALIGN RSND_REG_SHARE22 struct rsnd_of_data; struct rsnd_priv; diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index 1ef811a..9183e01 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c @@ -110,6 +110,8 @@ int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod, struct rsnd_dai *rdai, int use_busif) { + struct rsnd_dai_stream *io = rsnd_mod_to_io(ssi_mod); + struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); int ssi_id = rsnd_mod_id(ssi_mod); /* @@ -146,10 +148,27 @@ int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod, * DMA settings for SSIU */ if (use_busif) { + u32 val = 0x76543210; + u32 mask = ~0; + rsnd_mod_write(ssi_mod, SSI_BUSIF_ADINR, rsnd_get_adinr(ssi_mod)); rsnd_mod_write(ssi_mod, SSI_BUSIF_MODE, 1); rsnd_mod_write(ssi_mod, SSI_CTRL, 0x1); + + mask <<= runtime->channels * 4; + val = val & mask; + + switch (runtime->sample_bits) { + case 16: + val |= 0x67452301 & ~mask; + break; + case 32: + val |= 0x76543210 & ~mask; + break; + } + rsnd_mod_write(ssi_mod, BUSIF_DALIGN, val); + } return 0;