From patchwork Fri Jul 2 17:12:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raffaele Recalcati X-Patchwork-Id: 109922 Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o62HFQnN025228 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 2 Jul 2010 17:16:03 GMT Received: from dlep34.itg.ti.com ([157.170.170.115]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id o62HDfkb003501 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 2 Jul 2010 12:13:41 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep34.itg.ti.com (8.13.7/8.13.7) with ESMTP id o62HDeq0029601; Fri, 2 Jul 2010 12:13:40 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 5D90880813; Fri, 2 Jul 2010 12:13:10 -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 A86668062C for ; Fri, 2 Jul 2010 12:12:28 -0500 (CDT) Received: from red.ext.ti.com (localhost [127.0.0.1]) by dflp51.itg.ti.com (8.13.7/8.13.7) with ESMTP id o62HCSfZ027995 for ; Fri, 2 Jul 2010 12:12:28 -0500 (CDT) Received: from psmtp.com (na3sys009amx183.postini.com [74.125.149.164]) by red.ext.ti.com (8.13.7/8.13.7) with SMTP id o62HCRxH019444 for ; Fri, 2 Jul 2010 12:12:27 -0500 Received: from source ([74.125.82.47]) by na3sys009amx183.postini.com ([74.125.148.10]) with SMTP; Fri, 02 Jul 2010 12:12:27 CDT Received: by mail-ww0-f47.google.com with SMTP id 18so1460808wwi.4 for ; Fri, 02 Jul 2010 10:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=R0Hy5uvOJfVaQm6GgH/nRbiMcLrd2W4jBwY6hWVHFZY=; b=o0nmLXy1T5Al5NrW0SDPV4jg+4R6Q9VHMygQrgVuOQxHvDA0MIrXnywSwROSYkpcj/ Eolpv/VGg8+uCed9A/vaN9Fce2Z9/ZXGGo2nAQSUeTFuZyyx0+2FAtC+g+HARBFgFoCg D9/OQWknloD9xjYzX0FN5/1lkHlbH9/W4fVW8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=iTnCP2uFjIW9Fe2u5sck2MC1S7n2LWjruVWnR0o89ve2JzAChRIZCWkvuX3lExgqQV al3VlQUdBNJftwLKOYHmNNwsKZcNGVFdH5bVIu+FIls7NK3asaB9x98SPybxJq4i91aI 0XLWf1r1uBI5XWkKqOnYfeRV2u26doUAUzIFE= Received: by 10.227.137.137 with SMTP id w9mr591033wbt.154.1278090746917; Fri, 02 Jul 2010 10:12:26 -0700 (PDT) Received: from localhost.localdomain (host81-90-static.72-81-b.business.telecomitalia.it [81.72.90.81]) by mx.google.com with ESMTPS id g37sm6098553wbg.3.2010.07.02.10.12.24 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 02 Jul 2010 10:12:26 -0700 (PDT) From: Raffaele Recalcati To: davinci-linux-open-source@linux.davincidsp.com Subject: [PATCH 3/3] ASoC: DaVinci: More accurate calculation for clock divider for McBSP (I2S) Date: Fri, 2 Jul 2010 19:12:27 +0200 Message-Id: <1278090747-5124-4-git-send-email-lamiaposta71@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1278090747-5124-1-git-send-email-lamiaposta71@gmail.com> References: <1278090747-5124-1-git-send-email-lamiaposta71@gmail.com> X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:31.49744/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.5000) s cv gt3 gt2 gt1 r p m c X-pstn-addresses: from [db-null] Cc: Mark Brown , Raffaele Recalcati 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.3 (demeter.kernel.org [140.211.167.41]); Fri, 02 Jul 2010 17:16:03 +0000 (UTC) diff --git a/arch/arm/mach-davinci/include/mach/asp.h b/arch/arm/mach-davinci/include/mach/asp.h index 0847d21..21c886e 100644 --- a/arch/arm/mach-davinci/include/mach/asp.h +++ b/arch/arm/mach-davinci/include/mach/asp.h @@ -73,6 +73,13 @@ struct snd_platform_data { */ int clk_input_pin; + /* + * This define works when both clock and FS are output for the cpu + * and makes clock more accurate (FS is not symmetrical and the + * clock is very fast. + */ + bool i2s_accurate_clock; + /* McASP specific fields */ int tdm_slots; u8 op_mode; diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c index 17f594f..2fb1209 100644 --- a/sound/soc/davinci/davinci-i2s.c +++ b/sound/soc/davinci/davinci-i2s.c @@ -154,6 +154,7 @@ struct davinci_mcbsp_dev { unsigned int fmt; int clk_div; int clk_input_pin; + bool i2s_accurate_clock; }; static inline void davinci_mcbsp_write_reg(struct davinci_mcbsp_dev *dev, @@ -447,6 +448,24 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream, DAVINCI_MCBSP_SRGR_CLKSM; srgr |= DAVINCI_MCBSP_SRGR_FWID(mcbsp_word_length * 8 - 1); + if (dev->i2s_accurate_clock) { + clk_div = 256; + do { + framesize = (freq / (--clk_div)) / + params->rate_num * + params->rate_den; + } while (((framesize < 33) || (framesize > 4095)) && + (clk_div)); + clk_div--; + srgr |= DAVINCI_MCBSP_SRGR_FPER(framesize - 1); + } else { + /* symmetric waveforms */ + clk_div = freq / (mcbsp_word_length * 16) / + params->rate_num * params->rate_den; + srgr |= DAVINCI_MCBSP_SRGR_FPER(mcbsp_word_length * + 16 - 1); + } + /* symmetric waveforms */ clk_div = freq / (mcbsp_word_length * 16) / params->rate_num * params->rate_den; @@ -662,6 +681,7 @@ static int davinci_i2s_probe(struct platform_device *pdev) dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].sram_size = pdata->sram_size_capture; dev->clk_input_pin = pdata->clk_input_pin; + dev->i2s_accurate_clock = pdata->i2s_accurate_clock; } dev->clk = clk_get(&pdev->dev, NULL); if (IS_ERR(dev->clk)) {