From patchwork Fri Nov 14 02:53:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 5302751 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 2C51DC11AC for ; Fri, 14 Nov 2014 02:53:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 55B99201BB for ; Fri, 14 Nov 2014 02:53:47 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 2F3B9200E6 for ; Fri, 14 Nov 2014 02:53:46 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 7F8692664F7; Fri, 14 Nov 2014 03:53:44 +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, RCVD_IN_DNSWL_NONE, 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 3CE69260503; Fri, 14 Nov 2014 03:53:34 +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 72C2C26050C; Fri, 14 Nov 2014 03:53:33 +0100 (CET) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com [209.85.215.51]) by alsa0.perex.cz (Postfix) with ESMTP id 4137C260503 for ; Fri, 14 Nov 2014 03:53:25 +0100 (CET) Received: by mail-la0-f51.google.com with SMTP id q1so14443960lam.10 for ; Thu, 13 Nov 2014 18:53:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=vHqhAJiunxFJ9EQkQXqkpspfdbWcjs7+Kj8fBRjZfoU=; b=F55zyCNqm56za8DWUe6LCW33zl6z8XJOhfl+Xx6sYnz4aIt5L4TqWzs0TArHDekTtt i8z1WInjqhz52tIj2GePGzdhaPAmX6Toqj+3Rb37HQXzF82LsVdGm2ki3gu+6vgxvbuU 2vCQi6LylAuY3B637NDuBSrSfylQbfs3twsHLlHTpwzzaNmQl4Km11GeWg3jlkwZ2tVe /QZglFZedP4wWQYZqFHhgLFG14cQ/jjqBbIJxlNFN/yD8b6hPMQ/n3eNkbxFsC8RhgZA ySPV16ETYBPtQSW17Ts9ZyuuxR4/KzUHbDJTcIrYgzL9Bn3OJG2SR5ODWkjQeho0pNv9 JcdA== MIME-Version: 1.0 X-Received: by 10.152.43.80 with SMTP id u16mr5749261lal.53.1415933604430; Thu, 13 Nov 2014 18:53:24 -0800 (PST) Received: by 10.152.7.39 with HTTP; Thu, 13 Nov 2014 18:53:24 -0800 (PST) In-Reply-To: References: <546450E5.9090203@beamcommunications.com> <54653283.5070404@beamcommunications.com> Date: Fri, 14 Nov 2014 00:53:24 -0200 Message-ID: From: Fabio Estevam To: Craig McQueen Cc: Nicolin Chen , "alsa-devel@alsa-project.org" , Mark Brown Subject: Re: [alsa-devel] Low sample rates for SGTL5000 on i.MX28 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Nov 13, 2014 at 10:59 PM, Fabio Estevam wrote: > On Thu, Nov 13, 2014 at 10:29 PM, Fabio Estevam wrote: > >> Ok, so the 'aplay stereo_8k.wav' is converting the rate to 44.1kHz, so >> that's why it does not fail. > > From the sgtl5000 datasheet, it looks like the MCLK range of 8 to > 27MHz limitation does not apply when sgtl5000 runs in slave mode. > > A quick hack that allows 'aplay -D hw:0,0 stereo_8k.wav' to play: I don't have a scope handy to measure the MCLK, LRCLK, but I found a bug below where we use sys_fs instead of frame_rate: if (ret) { aplay -D hw:0,0 /home/stereo_8k.wav plays in a incorrect pitch, so we still need to adjust the clocking. diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 6bb77d7..a46ec7e 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -605,7 +605,7 @@ static int sgtl5000_set_clock(struct snd_soc_codec *codec, int frame_rate) * calculate the divider of mclk/sample_freq, * factor of freq =96k can only be 256, since mclk in range (12m,27m) */ - switch (sgtl5000->sysclk / sys_fs) { + switch (sgtl5000->sysclk / frame_rate) { case 256: clk_ctl |= SGTL5000_MCLK_FREQ_256FS << SGTL5000_MCLK_FREQ_SHIFT; @@ -1441,14 +1441,6 @@ static int sgtl5000_i2c_probe(struct i2c_client *client, return ret; } - /* SGTL5000 SYS_MCLK should be between 8 and 27 MHz */ - mclk = clk_get_rate(sgtl5000->mclk); - if (mclk < 8000000 || mclk > 27000000) { - dev_err(&client->dev, "Invalid SYS_CLK frequency: %u.%03uMHz\n", - mclk / 1000000, mclk / 1000 % 1000); - return -EINVAL; - } - ret = clk_prepare_enable(sgtl5000->mclk); if (ret) return ret; diff --git a/sound/soc/mxs/mxs-sgtl5000.c b/sound/soc/mxs/mxs-sgtl5000.c index 61822cc..3bba6cf 100644 --- a/sound/soc/mxs/mxs-sgtl5000.c +++ b/sound/soc/mxs/mxs-sgtl5000.c @@ -49,13 +49,6 @@ static int mxs_sgtl5000_hw_params(struct snd_pcm_substream *substream, break; } - /* Sgtl5000 sysclk should be >= 8MHz and <= 27M */ - if (mclk < 8000000 || mclk > 27000000) { - dev_err(codec_dai->dev, "Invalid mclk frequency: %u.%03uMHz\n", - mclk / 1000000, mclk / 1000 % 1000); - return -EINVAL; - } - /* Set SGTL5000's SYSCLK (provided by SAIF MCLK) */ ret = snd_soc_dai_set_sysclk(codec_dai, SGTL5000_SYSCLK, mclk, 0);