From patchwork Thu Mar 27 10:27:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 3897251 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 69A3BBF540 for ; Thu, 27 Mar 2014 10:29:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B3C082010E for ; Thu, 27 Mar 2014 10:29:27 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 64794200F3 for ; Thu, 27 Mar 2014 10:29:26 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4F66526535B; Thu, 27 Mar 2014 11:29:25 +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 568C32652AE; Thu, 27 Mar 2014 11:28:43 +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 CCFC22652AE; Thu, 27 Mar 2014 11:28:41 +0100 (CET) Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com [209.85.214.53]) by alsa0.perex.cz (Postfix) with ESMTP id 472A42652CD for ; Thu, 27 Mar 2014 11:27:46 +0100 (CET) Received: by mail-bk0-f53.google.com with SMTP id r7so748396bkg.12 for ; Thu, 27 Mar 2014 03:27:45 -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=QSkt8zhKDb37Amp4BTIZ/zvvQaPMtRewmzv/RQ8Mmik=; b=Ih+XAminRvnZKUbkz9bKoDHWq/+44ZktT3fb+N8Okp6svDvU/wwYg0YpUA99uhgv5B mdnIRNz7Fcd2deQf3LAYrZMglvJotyEW3MxEqRIZzf0LFl7yscYFxeZf00Cf9/0oQOe8 WuAl2L6uBz+Ybs+sEpXV9eNjCDdDv3iEzkO8FrY3bt2eGYMFAhFaJMC5S4lwbNItHFBF RxBu/zEFr0WCHll7rgTcUaNPSZ6ifggyWAGYNGyKGjzfq+ugvfhnv1VfaMbuwaytFRKS e/gdE4N4Hkk25QX27VJGEgtwHRJfFkrNXD6+7UE3DlbJKijqRfijT5tkyN3u/oceCmo9 2uXQ== X-Received: by 10.205.74.196 with SMTP id yx4mr89557bkb.109.1395916065897; Thu, 27 Mar 2014 03:27:45 -0700 (PDT) Received: from tamtam.fritz.box (p5099deeb.dip0.t-ipconnect.de. [80.153.222.235]) by mx.google.com with ESMTPSA id m4sm1703236bkj.4.2014.03.27.03.27.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Mar 2014 03:27:45 -0700 (PDT) From: Daniel Mack To: broonie@kernel.org Date: Thu, 27 Mar 2014 11:27:40 +0100 Message-Id: <1395916060-16234-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 v3] ASoC: davinci-mcasp: set up channel status 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 Acked-by: Peter Ujfalusi --- v3 just changes variable names. sound/soc/davinci/davinci-mcasp.c | 49 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 4500cf0..a21a7d4 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 @@ -576,8 +577,12 @@ 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 cs_value = 0; + u8 *cs_bytes = (u8*) &cs_value; + /* 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)); @@ -599,6 +604,46 @@ 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 */ + cs_bytes[0] = IEC958_AES0_CON_NOT_COPYRIGHT; + cs_bytes[1] = IEC958_AES1_CON_PCM_CODER; + + switch (rate) { + case 22050: + cs_bytes[3] |= IEC958_AES3_CON_FS_22050; + break; + case 24000: + cs_bytes[3] |= IEC958_AES3_CON_FS_24000; + break; + case 32000: + cs_bytes[3] |= IEC958_AES3_CON_FS_32000; + break; + case 44100: + cs_bytes[3] |= IEC958_AES3_CON_FS_44100; + break; + case 48000: + cs_bytes[3] |= IEC958_AES3_CON_FS_48000; + break; + case 88200: + cs_bytes[3] |= IEC958_AES3_CON_FS_88200; + break; + case 96000: + cs_bytes[3] |= IEC958_AES3_CON_FS_96000; + break; + case 176400: + cs_bytes[3] |= IEC958_AES3_CON_FS_176400; + break; + case 192000: + cs_bytes[3] |= 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, cs_value); + mcasp_set_reg(mcasp, DAVINCI_MCASP_DITCSRB_REG, cs_value); + return 0; } @@ -634,7 +679,7 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, return ret; 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);