From patchwork Wed Mar 26 15:04:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 3893981 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 540279F375 for ; Wed, 26 Mar 2014 15:05:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 948762021F for ; Wed, 26 Mar 2014 15:05:08 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 4CF9B20170 for ; Wed, 26 Mar 2014 15:05:07 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 30360265104; Wed, 26 Mar 2014 16:05:05 +0100 (CET) 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, NO_DNS_FOR_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 E4FC2265013; Wed, 26 Mar 2014 16:04:54 +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 80900265095; Wed, 26 Mar 2014 16:04:53 +0100 (CET) Received: from mail-bk0-f47.google.com (mail-bk0-f47.google.com [209.85.214.47]) by alsa0.perex.cz (Postfix) with ESMTP id 9A62B264FEE for ; Wed, 26 Mar 2014 16:04:46 +0100 (CET) Received: by mail-bk0-f47.google.com with SMTP id w10so575166bkz.6 for ; Wed, 26 Mar 2014 08:04:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=m43yXm3Gma71/Z+DoWPvJHg7EW3ytMk5GA4KLLbsQ5g=; b=c7SJ3Tf9rq1LicgvqFrxGz+hIcG57+yPNYaH22sVYFNDp9NgP4GjIYdafc2cI8UvPs JcbmBXliT//q7lpfYGESVb2g07LnzUG9+hqkFVVgSaGvtLk15zSsr2dIjtqMI593g6iu qZmHnGm+aVf3QgZjoGNhBThGafNC3vrwgUKCWaKhUNzFxbaQeczyMMRtbG3qwYcaWrv6 r8cTJvygaFl00dmNhQnuoEtE0RQ40JmLB1AMNplCqMXLDwdlzdyFgGuhs3lKTTqn/bng 0Zq1gYWYhpWrVeplbsrgbcqpgFMgq5L1Tmeyd6chHE3wj7StCq7aBsLULEdeypRWd2/c 7WQA== X-Received: by 10.204.101.70 with SMTP id b6mr104044bko.175.1395846286160; Wed, 26 Mar 2014 08:04:46 -0700 (PDT) Received: from tamtam.Speedport_W_723V_1_32_000 (pd907dbf4.dip0.t-ipconnect.de. [217.7.219.244]) by mx.google.com with ESMTPSA id el11sm23592227bkb.8.2014.03.26.08.04.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Mar 2014 08:04:45 -0700 (PDT) From: Daniel Mack To: broonie@kernel.org Date: Wed, 26 Mar 2014 16:04:33 +0100 Message-Id: <1395846273-26025-1-git-send-email-zonque@gmail.com> X-Mailer: git-send-email 1.8.5.3 Cc: peter.ujfalusi@ti.com, alsa-devel@alsa-project.org, Daniel Mack Subject: [alsa-devel] [PATCH] ASoC: davinci-mcasp: set up user bits for S/PDIF mode 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP In DIT (S/PDIF) mode, program the transmitted user bits to reflect the configured sample rate, along with some other details. Signed-off-by: Daniel Mack --- sound/soc/davinci/davinci-mcasp.c | 55 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 712a7cd..ec0463a 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -566,8 +567,11 @@ static int mcasp_i2s_hw_param(struct davinci_mcasp *mcasp, int stream) } /* S/PDIF */ -static int mcasp_dit_hw_param(struct davinci_mcasp *mcasp) +static int mcasp_dit_hw_param(struct davinci_mcasp *mcasp, + unsigned int rate) { + u32 val = 0; + /* Set the TX format : 24 bit right rotation, 32 bit slot, Pad 0 and LSB first */ mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, TXROT(6) | TXSSZ(15)); @@ -589,6 +593,53 @@ static int mcasp_dit_hw_param(struct davinci_mcasp *mcasp) /* Enable the DIT */ mcasp_set_bits(mcasp, DAVINCI_MCASP_TXDITCTL_REG, DITEN); + /* Set S/PDIF channel status bits */ + mcasp_set_reg(mcasp, DAVINCI_MCASP_DITCSRA_REG + 0, + IEC958_AES0_CON_NOT_COPYRIGHT); + mcasp_set_reg(mcasp, DAVINCI_MCASP_DITCSRB_REG + 0, + IEC958_AES0_CON_NOT_COPYRIGHT); + + mcasp_set_reg(mcasp, DAVINCI_MCASP_DITCSRA_REG + 1, + IEC958_AES1_CON_PCM_CODER); + mcasp_set_reg(mcasp, DAVINCI_MCASP_DITCSRB_REG + 1, + IEC958_AES1_CON_PCM_CODER); + + switch (rate) { + case 22050: + val |= IEC958_AES3_CON_FS_22050; + break; + case 24000: + val |= IEC958_AES3_CON_FS_24000; + break; + case 32000: + val |= IEC958_AES3_CON_FS_32000; + break; + case 44100: + val |= IEC958_AES3_CON_FS_44100; + break; + case 48000: + val |= IEC958_AES3_CON_FS_48000; + break; + case 88200: + val |= IEC958_AES3_CON_FS_88200; + break; + case 96000: + val |= IEC958_AES3_CON_FS_96000; + break; + case 176400: + val |= IEC958_AES3_CON_FS_176400; + break; + case 192000: + val |= IEC958_AES3_CON_FS_192000; + break; + default: + printk(KERN_WARNING "unsupported sampling rate: %d\n", rate); + return -EINVAL; + } + + mcasp_set_reg(mcasp, DAVINCI_MCASP_DITCSRA_REG + 3, val); + mcasp_set_reg(mcasp, DAVINCI_MCASP_DITCSRB_REG + 3, val); + return 0; } @@ -621,7 +672,7 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, fifo_level = mcasp->rxnumevt * active_serializers; if (mcasp->op_mode == DAVINCI_MCASP_DIT_MODE) - ret = mcasp_dit_hw_param(mcasp); + ret = mcasp_dit_hw_param(mcasp, params_rate(params)); else ret = mcasp_i2s_hw_param(mcasp, substream->stream);