From patchwork Wed Oct 17 11:53:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 149059 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp551970lji; Wed, 17 Oct 2018 04:53:07 -0700 (PDT) X-Google-Smtp-Source: ACcGV633JJFEg0gtAUKGFv85QgOkfaXR0xiTE3+M/kpzoqetKNFd3NP5KjaLgfodvaXHl9huiRvo X-Received: by 2002:a1c:e583:: with SMTP id c125-v6mr2625790wmh.134.1539777187816; Wed, 17 Oct 2018 04:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539777187; cv=none; d=google.com; s=arc-20160816; b=dxwFoLzXyJYya4qn4otbwQZnJNCtGwD5zMvY1lrWt22uHGr5oNs435CYGZ3vcPK6U3 gLGWGn1S9FzBYGfKG7cS5bdsr2P/O6I9xD/yv9JecdEU9+6GpYdIcdcO1gkpdYqLt32u 72lBrD0aq4tUP7QmxBnEX2HcIAXZ0zQVbwECGfvn9iAU9heTIi7XmfXUQqYx7b1dZYum Ae4odFwQ/gu8eSJ91p7lSgdgPvaNBCGBMe+QzL/SdSl1MWv+3fPKf+KNFjkD4R0l6xzS ZHyjqnK7uOfHbkCr+w13ndcbdhrmD7uqIcOcN49nj2ziD9UIlXVkHdA2XdvXeJqNW7vW rrgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:date:message-id:in-reply-to:to:from :dkim-signature:delivered-to; bh=Sbsbw6g++bjIh6gWIBOTJS+wChCr0HW0PkTMuko0yzo=; b=VTOGkLpmp1HZXytVRpToI8KWOJOdM2j99xBYlQTcKv6KLbWJH1jZU0+YQj6BJPfWDP x2FhVzsv/GZKCrmsiTPFofSyuWYW356l+6PZGAqLv19Qml+3GzOviCyyn2E2vjDdkfB3 9LxCtxrsKdFeB/Ilu3V4igJRsQrj4AI08UfuJh4K4EsaFwLxlhefOasTASELltagzAxy 88tj388/OHIW7KZte7BCHTINeOlcWMoB6V7MAKW4qoYdhEZ2xll/lp1a4br1Bs6RoPYe FnH9/ynoS7Vtz1uEWT8MRKA10TMRHfH6E0T48lfi7O1FgZDMl5kPVou7Srw0CTDe5Txg hWzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=TgTjRvuN; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id r17-v6si13391141wrn.227.2018.10.17.04.53.07; Wed, 17 Oct 2018 04:53:07 -0700 (PDT) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=TgTjRvuN; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 852B32675BF; Wed, 17 Oct 2018 13:53:05 +0200 (CEST) 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 E207D2675BF; Wed, 17 Oct 2018 13:53:03 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE autolearn=disabled version=3.4.0 Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk [172.104.155.198]) by alsa0.perex.cz (Postfix) with ESMTP id 0F54C2675BB for ; Wed, 17 Oct 2018 13:53:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=8Yx8C5azjRO10+MIbF0COQuTnQxUrgXnrQPq+a0HYxE=; b=TgTjRvuNM0n+ EcwfbQfaP4nSkbYy8kmV7/jFHNz6bi0ifs1ZGg+3VCmEbef7qA4wZ8r3AoQDWpiNEIdCTUby35Vvz PwRCqiR+ecNcmaGOnL656MWLndQ1Gu4fhBnHU0TiG03CIycJ4qLwqXv4qNbJz9ZJ5wlE9xXWKs2xW Zuakk=; Received: from cpc102320-sgyl38-2-0-cust46.18-2.cable.virginm.net ([82.37.168.47] helo=debutante.sirena.org.uk) by heliosphere.sirena.org.uk with esmtpa (Exim 4.89) (envelope-from ) id 1gCkNo-0000zn-Do; Wed, 17 Oct 2018 11:53:00 +0000 Received: by debutante.sirena.org.uk (Postfix, from userid 1000) id 2BFDB11224C4; Wed, 17 Oct 2018 12:53:00 +0100 (BST) From: Mark Brown To: Vasily Khoruzhick In-Reply-To: <20181017073813.14127-3-anarsoul@gmail.com> Message-Id: <20181017115300.2BFDB11224C4@debutante.sirena.org.uk> Date: Wed, 17 Oct 2018 12:53:00 +0100 (BST) Cc: Mark Rutland , devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Maxime Ripard , Takashi Iwai , Liam Girdwood , Rob Herring , Marcus Cooper , Mark Brown , Mylene JOSSERAND , linux-arm-kernel@lists.infradead.org, Jerome Brunet Subject: [alsa-devel] Applied "ASoC: sun8i-codec: Don't hardcode BCLK / LRCK ratio" to the asoc tree 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 The patch ASoC: sun8i-codec: Don't hardcode BCLK / LRCK ratio has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From 13c3bf174becfb8b55adcfeb6f01724dc99347f0 Mon Sep 17 00:00:00 2001 From: Vasily Khoruzhick Date: Wed, 17 Oct 2018 00:38:06 -0700 Subject: [PATCH] ASoC: sun8i-codec: Don't hardcode BCLK / LRCK ratio BCLK / LRCK ratio should be sample size * channels, but it was hardcoded to 32 (0x1 is 32 as per A33 and A64 datasheets). Calculate it basing on sample size and number of channels. Signed-off-by: Vasily Khoruzhick Acked-by: Maxime Ripard Signed-off-by: Mark Brown --- sound/soc/sunxi/sun8i-codec.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) -- 2.19.0.rc2 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/sunxi/sun8i-codec.c b/sound/soc/sunxi/sun8i-codec.c index fb37dd927e33..522a72fde78d 100644 --- a/sound/soc/sunxi/sun8i-codec.c +++ b/sound/soc/sunxi/sun8i-codec.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -52,7 +53,6 @@ #define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_INV 13 #define SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV 9 #define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV 6 -#define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_16 (1 << 6) #define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ 4 #define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ_16 (1 << 4) #define SUN8I_AIF1CLK_CTRL_AIF1_DATA_FMT 2 @@ -300,12 +300,23 @@ static u8 sun8i_codec_get_bclk_div(struct sun8i_codec *scodec, return best_val; } +static int sun8i_codec_get_lrck_div(unsigned int channels, + unsigned int word_size) +{ + unsigned int div = word_size * channels; + + if (div < 16 || div > 256) + return -EINVAL; + + return ilog2(div) - 4; +} + static int sun8i_codec_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct sun8i_codec *scodec = snd_soc_component_get_drvdata(dai->component); - int sample_rate; + int sample_rate, lrck_div; u8 bclk_div; /* @@ -321,9 +332,14 @@ static int sun8i_codec_hw_params(struct snd_pcm_substream *substream, SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV_MASK, bclk_div << SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV); + lrck_div = sun8i_codec_get_lrck_div(params_channels(params), + params_physical_width(params)); + if (lrck_div < 0) + return lrck_div; + regmap_update_bits(scodec->regmap, SUN8I_AIF1CLK_CTRL, SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_MASK, - SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_16); + lrck_div << SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV); sample_rate = sun8i_codec_get_hw_rate(params); if (sample_rate < 0)