From patchwork Fri Aug 26 16:02:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Gardiner X-Patchwork-Id: 1102572 Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7QG6a5F027079 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 26 Aug 2011 16:06:57 GMT Received: from dlep34.itg.ti.com ([157.170.170.115]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id p7QG2vT6000890 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 26 Aug 2011 11:02:59 -0500 Received: from linux.omap.com (smtp-le.itg.ti.com [157.170.170.27]) by dlep34.itg.ti.com (8.13.7/8.13.8) with ESMTP id p7QG2uVR012065; Fri, 26 Aug 2011 11:02:56 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 885CD80627; Fri, 26 Aug 2011 11:02:56 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp51.itg.ti.com (dflp51.itg.ti.com [128.247.22.94]) by linux.omap.com (Postfix) with ESMTP id 3297180626 for ; Fri, 26 Aug 2011 11:02:55 -0500 (CDT) Received: from white.ext.ti.com (white.ext.ti.com [192.94.93.38]) by dflp51.itg.ti.com (8.13.7/8.13.8) with ESMTP id p7QG2rDi024074 for ; Fri, 26 Aug 2011 11:02:53 -0500 (CDT) Received: from psmtp.com (na3sys009amx255.postini.com [74.125.149.139]) by white.ext.ti.com (8.13.7/8.13.7) with SMTP id p7QG2pnM026735 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 26 Aug 2011 11:02:52 -0500 Received: from na3sys009aog124.obsmtp.com ([74.125.149.151]) (using TLSv1) by na3sys009amx255.postini.com ([74.125.148.10]) with SMTP; Fri, 26 Aug 2011 16:02:52 GMT Received: from mail-ey0-f169.google.com ([209.85.215.169]) (using TLSv1) by na3sys009aob124.postini.com ([74.125.148.12]) with SMTP ID DSNKTlfDqhMyYRMKwsACGXcAeL1FbkbU4KXW@postini.com; Fri, 26 Aug 2011 09:02:52 PDT Received: by mail-ey0-f169.google.com with SMTP id 22so2492877eye.28 for ; Fri, 26 Aug 2011 09:02:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nanometrics.ca; s=google; h=from:to:subject:date:message-id:x-mailer; bh=HL1Eq5F+xYAvkjqpKxxpgnxw9LhRYi4VAeXUcFj3Aio=; b=GMViRQsVKjAtqtPZ7k8xCwE3wCsRKT99RWnVQv4Rx8ri195MKqMSqB9XPhmo/3/kHv nWvke90txUurEC4UlRvAcy+vc5VlkJP26Vm3xQpnjrQVzAsFzPxaKeI5rjpcZI7n0daQ gNks++ZUaPm7YSZOS7Clu7hTVs/z3HlsTc/9s= Received: by 10.14.16.35 with SMTP id g35mr521359eeg.126.1314374570012; Fri, 26 Aug 2011 09:02:50 -0700 (PDT) Received: from localhost.localdomain ([206.191.47.130]) by mx.google.com with ESMTPS id w9sm1157094eej.19.2011.08.26.09.02.46 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 26 Aug 2011 09:02:48 -0700 (PDT) From: Ben Gardiner To: Liam Girdwood , Mark Brown , Sekhar Nori , alsa-devel@alsa-project.org, davinci-linux-open-source@linux.davincidsp.com Subject: [PATCH] ASoC: davinci-mcasp: add support for unsigned PCM formats Date: Fri, 26 Aug 2011 12:02:44 -0400 Message-Id: <1314374564-10291-1-git-send-email-bengardiner@nanometrics.ca> X-Mailer: git-send-email 1.7.4.1 X-pstn-levels: (S:45.79098/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-settings: 2 (0.5000:0.0750) s cv GT3 gt2 gt1 r p m c X-pstn-addresses: from [35/1] X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 26 Aug 2011 16:06:58 +0000 (UTC) Although the McASP supports sign-extending samples in RX or TX [1]; the davinci-mcasp driver does not touch the {R,X}PBIT or {R,X}PAD field of the {R,X}FMT registers meaning that the McASP will serialize the bytes it is given regardless of their signedness. So supporting unsigned formats is as simple as adding them to the metadata of the davinci-mcasp driver. Update the FMTBITs reported in the snd_soc_dai_driver and also update the case statements in davinci-mcasp's hw_params() function so that the McASP can be connected to CODECs that use unsigned values. [1] http://www.ti.com/lit/ug/sprufm1/sprufm1.pdf Signed-off-by: Ben Gardiner Acked-by: Liam Girdwood --- Tested with a logic analyzer on da850evm where an unsigned 16bit codec was registered with the mcasp and a 16bit signed file was played to it. ALSA's plug pcm mapped to unsigned and the samples serialized as unsigned 16bit -- as expected. --- sound/soc/davinci/davinci-mcasp.c | 20 +++++++++++++------- 1 files changed, 13 insertions(+), 7 deletions(-) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 8566238..7173df2 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -732,16 +732,19 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, davinci_hw_param(dev, substream->stream); switch (params_format(params)) { + case SNDRV_PCM_FORMAT_U8: case SNDRV_PCM_FORMAT_S8: dma_params->data_type = 1; word_length = DAVINCI_AUDIO_WORD_8; break; + case SNDRV_PCM_FORMAT_U16_LE: case SNDRV_PCM_FORMAT_S16_LE: dma_params->data_type = 2; word_length = DAVINCI_AUDIO_WORD_16; break; + case SNDRV_PCM_FORMAT_U32_LE: case SNDRV_PCM_FORMAT_S32_LE: dma_params->data_type = 4; word_length = DAVINCI_AUDIO_WORD_32; @@ -818,6 +821,13 @@ static struct snd_soc_dai_ops davinci_mcasp_dai_ops = { }; +#define DAVINCI_MCASP_PCM_FMTS (SNDRV_PCM_FMTBIT_S8 | \ + SNDRV_PCM_FMTBIT_U8 | \ + SNDRV_PCM_FMTBIT_S16_LE | \ + SNDRV_PCM_FMTBIT_U16_LE | \ + SNDRV_PCM_FMTBIT_S32_LE | \ + SNDRV_PCM_FMTBIT_U32_LE) + static struct snd_soc_dai_driver davinci_mcasp_dai[] = { { .name = "davinci-mcasp.0", @@ -825,17 +835,13 @@ static struct snd_soc_dai_driver davinci_mcasp_dai[] = { .channels_min = 2, .channels_max = 2, .rates = DAVINCI_MCASP_RATES, - .formats = SNDRV_PCM_FMTBIT_S8 | - SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S32_LE, + .formats = DAVINCI_MCASP_PCM_FMTS, }, .capture = { .channels_min = 2, .channels_max = 2, .rates = DAVINCI_MCASP_RATES, - .formats = SNDRV_PCM_FMTBIT_S8 | - SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S32_LE, + .formats = DAVINCI_MCASP_PCM_FMTS, }, .ops = &davinci_mcasp_dai_ops, @@ -846,7 +852,7 @@ static struct snd_soc_dai_driver davinci_mcasp_dai[] = { .channels_min = 1, .channels_max = 384, .rates = DAVINCI_MCASP_RATES, - .formats = SNDRV_PCM_FMTBIT_S16_LE, + .formats = DAVINCI_MCASP_PCM_FMTS, }, .ops = &davinci_mcasp_dai_ops, },