From patchwork Wed Jun 30 13:47:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raffaele Recalcati X-Patchwork-Id: 110552 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 o66N7nYc022744 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 6 Jul 2010 23:08:25 GMT Received: from dlep36.itg.ti.com ([157.170.170.91]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id o66N7nGF002035 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 6 Jul 2010 18:07:49 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep36.itg.ti.com (8.13.8/8.13.8) with ESMTP id o66N7mxH027330 for ; Tue, 6 Jul 2010 18:07:48 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id D906F8062C for ; Tue, 6 Jul 2010 18:07:47 -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 947E480627 for ; Wed, 30 Jun 2010 08:48:16 -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 o5UDmGBa020460 for ; Wed, 30 Jun 2010 08:48:16 -0500 (CDT) Received: from psmtp.com (na3sys009amx242.postini.com [74.125.149.126]) by red.ext.ti.com (8.13.7/8.13.7) with SMTP id o5UDmFMo018720 for ; Wed, 30 Jun 2010 08:48:15 -0500 Received: from source ([209.85.161.45]) by na3sys009amx242.postini.com ([74.125.148.10]) with SMTP; Wed, 30 Jun 2010 13:48:15 GMT Received: by mail-fx0-f45.google.com with SMTP id 10so520249fxm.4 for ; Wed, 30 Jun 2010 06:48:15 -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=7xZ83X/Jm8HXp5S2WkAXbdila5UCiOwrBwLKdcAAgI0=; b=Q1wFEoumy7fJ9i3xKhmpZf90nIL+FCNx3KP6Wmh0NMV22ItO0xErfJTCbiBgbVW/SU /RPBfNWGDR/NoASg7Nl+9oAQI+Rq6IxA3xEdYApZr6Vr7hf33IJuyu+UI25/IoBoa+f5 xcsQPrd1AnUEoptLMv3UHUsqn5RcGMEqtk9RE= 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=qfSOEuZzo9staszsZzg+cG/6hjY6lTpYrJZD1Kbgk5Sc2nyPrvLo86uNHpuym9yL0l dYLQKOkSoqxertmW/NLGPGVLcUhSgkm38l7zsNEAtheAzXBx8w/MMjTM4SDmRQQd4M24 arWLHcaBqJbHowPKh8s3Yv9I22c+JDQuuYVsw= Received: by 10.216.172.134 with SMTP id t6mr7193641wel.23.1277905694132; Wed, 30 Jun 2010 06:48:14 -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 w19sm10373721weq.20.2010.06.30.06.48.11 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 30 Jun 2010 06:48:13 -0700 (PDT) From: Raffaele Recalcati To: davinci-linux-open-source@linux.davincidsp.com Subject: [PATCH 3/3] ASoC: DaVinci: Added fast clock timing for McBSP (I2S) Date: Wed, 30 Jun 2010 15:47:58 +0200 Message-Id: <1277905678-4695-4-git-send-email-lamiaposta71@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1277905678-4695-1-git-send-email-lamiaposta71@gmail.com> References: <1277905678-4695-1-git-send-email-lamiaposta71@gmail.com> X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:19.71259/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] X-Mailman-Approved-At: Tue, 06 Jul 2010 18:07:30 -0500 Cc: alsa-devel@alsa-project.org, Russell King , Takashi Iwai , Mark Brown , linux-kernel@vger.kernel.org, Raffaele Recalcati , Jaroslav Kysela , linux-arm-kernel@lists.infradead.org, Liam Girdwood 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+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 06 Jul 2010 23:08:25 +0000 (UTC) diff --git a/arch/arm/mach-davinci/include/mach/asp.h b/arch/arm/mach-davinci/include/mach/asp.h index 314570d..2d8f8af 100644 --- a/arch/arm/mach-davinci/include/mach/asp.h +++ b/arch/arm/mach-davinci/include/mach/asp.h @@ -63,6 +63,13 @@ struct snd_platform_data { unsigned sram_size_playback; unsigned sram_size_capture; + /* + * This define works when both clock and FS are output for the cpu + * and makes clock very fast (FS is not symmetrical, but sampling + * frequency is better approximated + */ + bool i2s_fast_clock; + /* To be used when cpu gets clock from external pin */ int clk_input_pin; diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c index e478be9..0af5bae 100644 --- a/sound/soc/davinci/davinci-i2s.c +++ b/sound/soc/davinci/davinci-i2s.c @@ -150,6 +150,7 @@ struct davinci_mcbsp_dev { */ unsigned enable_channel_combine:1; + bool i2s_fast_clock; unsigned int fmt; int clk_div; int clk_input_pin; @@ -443,11 +444,23 @@ 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); - /* 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); + if (dev->i2s_fast_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); + } clk_div &= 0xFF; srgr |= clk_div; break; @@ -643,6 +656,7 @@ static int davinci_i2s_probe(struct platform_device *pdev) pdata->sram_size_playback; dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].sram_size = pdata->sram_size_capture; + dev->i2s_fast_clock = pdata->i2s_fast_clock; dev->clk_input_pin = pdata->clk_input_pin; } dev->clk = clk_get(&pdev->dev, NULL);