From patchwork Thu Nov 27 15:02:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 5396761 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 B353CC11AC for ; Thu, 27 Nov 2014 15:03:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DBD4E201EC for ; Thu, 27 Nov 2014 15:03:40 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id BA338201EF for ; Thu, 27 Nov 2014 15:03:39 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id DB40626658C; Thu, 27 Nov 2014 16:03:38 +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, 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 9E9CC266406; Thu, 27 Nov 2014 16:02:40 +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 5EA85266192; Thu, 27 Nov 2014 16:02:37 +0100 (CET) Received: from mail-qg0-f54.google.com (mail-qg0-f54.google.com [209.85.192.54]) by alsa0.perex.cz (Postfix) with ESMTP id C15AA266192 for ; Thu, 27 Nov 2014 16:02:29 +0100 (CET) Received: by mail-qg0-f54.google.com with SMTP id q107so3616563qgd.13 for ; Thu, 27 Nov 2014 07:02:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9Xo5Mp7kJVMLXLgw2S2SKqjuvESRYphAlwd1PRxRj80=; b=mPIIDzHNrs9XNLDXk0RcbMDKtSy7TFYfVyuxik9jvBcc6YEnfyrOCanjfnUTtH2tIj i5pkpzfl+Vd2CfVGETVuaC0eu+/G7NoHG08yOzFjKThFrr17/Npwep9vYvVmXoOuUlN0 UYVjKOuq/4gak+8fE5qfpy4mzCGcg8E2qS45mYfFxH1fmCr76vr52gTqbxBq7dtPDUVh VI1c6kLVUN9xkd/9NyUuTti+gw7e0TY2ISXdlv0GzdNYBf/gxXALBLKXom+mcYZY7j71 s+gwgOKkbTx5APunEDUbJUy9WYcnJM2xh72xgpLFOXqA3Idwgb0o3Dw/3gL75ZG26vYW Nhvg== X-Received: by 10.140.101.68 with SMTP id t62mr53779550qge.92.1417100549310; Thu, 27 Nov 2014 07:02:29 -0800 (PST) Received: from localhost.localdomain ([201.82.52.106]) by mx.google.com with ESMTPSA id b17sm6728466qah.35.2014.11.27.07.02.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Nov 2014 07:02:28 -0800 (PST) From: Fabio Estevam To: broonie@kernel.org Date: Thu, 27 Nov 2014 13:02:01 -0200 Message-Id: <1417100521-8483-3-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1417100521-8483-1-git-send-email-festevam@gmail.com> References: <1417100521-8483-1-git-send-email-festevam@gmail.com> Cc: Fabio Estevam , alsa-devel@alsa-project.org, shawn.guo@linaro.org, craig.mcqueen@beamcommunications.com Subject: [alsa-devel] [PATCH 3/3] ASoC: sgtl5000: Allow 8kHz playback in codec slave 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 From: Fabio Estevam When trying to play a 8kHz file with codec in slave mode we get the following error on a mx28evk: $ aplay -Dhw:0,0 stereo_8k.wav Playing WAVE 'stereo_8k.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Stereo [ 21.218647] sgtl5000 0-000a: PLL not supported in slave mode [ 21.224559] sgtl5000 0-000a: 128 ratio is not supported. SYS_MCLK needs to be 256, 384 or 512 * fs [ 21.233687] sgtl5000 0-000a: ASoC: can't set sgtl5000 hw params: -22 aplay: set_params:1123: Unable to install hw params: This error happens because we are using 'sys_fs' instead of 'frame_rate' in the valid ratio check. Use the real'frame_rate' so that the ratio is correctly calculated and the playback can run. sgtl5000 codec manual states that in 'Synchronous SYS_MCLK input' mode that the following SYS_CLK frequencies are allowed: 256*fs, 384*fs, 512*fs. , where fs is the sampling frequency, which can be in the range of: 8, 11.025, 16, 22.5, 32, 44.1, 48, 96 kHz. Signed-off-by: Fabio Estevam --- sound/soc/codecs/sgtl5000.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 8dea6b3..29cf7ce 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -618,7 +618,7 @@ static int sgtl5000_set_clock(struct snd_soc_codec *codec, int frame_rate) * factor of freq = 96 kHz can only be 256, since mclk is in the range * of 8 MHz - 27 MHz */ - switch (sgtl5000->sysclk / sys_fs) { + switch (sgtl5000->sysclk / frame_rate) { case 256: clk_ctl |= SGTL5000_MCLK_FREQ_256FS << SGTL5000_MCLK_FREQ_SHIFT; @@ -641,7 +641,7 @@ static int sgtl5000_set_clock(struct snd_soc_codec *codec, int frame_rate) "PLL not supported in slave mode\n"); dev_err(codec->dev, "%d ratio is not supported. " "SYS_MCLK needs to be 256, 384 or 512 * fs\n", - sgtl5000->sysclk / sys_fs); + sgtl5000->sysclk / frame_rate); return -EINVAL; } }