From patchwork Sat Jan 26 13:23:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitris Papavasiliou X-Patchwork-Id: 10782459 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 82D0291E for ; Sat, 26 Jan 2019 13:23:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F58728795 for ; Sat, 26 Jan 2019 13:23:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63763287D2; Sat, 26 Jan 2019 13:23:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD6DD28795 for ; Sat, 26 Jan 2019 13:23:53 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 1FA6A26744B; Sat, 26 Jan 2019 14:23:52 +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 D4195267975; Sat, 26 Jan 2019 14:23:49 +0100 (CET) Received: from mail-ed1-f67.google.com (mail-ed1-f67.google.com [209.85.208.67]) by alsa0.perex.cz (Postfix) with ESMTP id 7F955267420 for ; Sat, 26 Jan 2019 14:23:47 +0100 (CET) Received: by mail-ed1-f67.google.com with SMTP id y20so9477592edw.9 for ; Sat, 26 Jan 2019 05:23:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=vORlJDJQWEgppUUWZDr06HtOvunrHGA42Wj0+i9CYD0=; b=VK3iTaxtk4Iu0+9EK1+wtg2mqK4Xc+ii7nRYI5eOaNXnk2OBFp8GzbQVqLoZgaFgGK hifvWRwMev8/w4gDzQTJzZMV+GYktd/1EigbAmQV1G4fUzYPafZvMUqn6n1nMhsQrBtG yDMl97JnQY8OH2/8ufhYnwRPoWKTsTSg8qoomCi73GeIToBhxbeg49PFQWAD/hv7fkSO XhfF4GRcAzKcJm+nsEKlUQxvqQAIlyLl0UnaCeIHHTxZxKusHQSmBmqEni7LBe51TV23 m9g3WaoStBWfyhSH+0HIAeEhob3r737+XOE8gYF/KBxnW9sg67MeCcxq/zkeqYOHy3pc +O/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=vORlJDJQWEgppUUWZDr06HtOvunrHGA42Wj0+i9CYD0=; b=s0FY9ORaCDt1G8pqYp4jAqopQssiI6tqOQkVphhnXbYHYiGWrGzjXv5vdmFN/G9dt+ onVkzwnkzZdidsFpj1gGRYtNEt0Ureqf1CvH35ZaeWkI5zBFtSbFizOF80dCqTl9mJHg 7gjiZmIfjvLyaAZ0blXR2ox948XOAPzDjF1qRKhJ7LiUoXWAw3ZymproAVyEGgCTtA+8 tpklHJqVaq0kyy8KLJ4CC3NZiSyIN/HyoPzGhfcDmBpodM46KNaTFCOMyKzm6s181n+U 5T4pPbT/IS0jJow5RGmrri2kljI7fps2ZFPW5smtfJRjoanqsXx8ggltZOigayJlRWtR v93g== X-Gm-Message-State: AJcUukcO3iiTVT1etDZItnug4sOrfIql2+5LXFOhQBrMW7Q8gB8QITfL awqT3ZjATiKX8AFUwpsaDRM= X-Google-Smtp-Source: ALg8bN6+tnh2NDk6snrWjLnQf6SmZcPIugMyylqJHz1mf+h9yI9qNtUJCwDSt5nhLZjUYhn4pRPHJQ== X-Received: by 2002:a50:ba3d:: with SMTP id g58mr14402494edc.35.1548509026898; Sat, 26 Jan 2019 05:23:46 -0800 (PST) Received: from [192.168.1.2] (ppp141237191004.access.hol.gr. [141.237.191.4]) by smtp.googlemail.com with ESMTPSA id b11-v6sm6878918ejd.16.2019.01.26.05.23.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 26 Jan 2019 05:23:46 -0800 (PST) From: Dimitris Papavasiliou To: alsa-devel@alsa-project.org Message-ID: Date: Sat, 26 Jan 2019 15:23:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Content-Language: en-US Cc: Kuninori Morimoto , Takashi Iwai , Liam Girdwood , Matthias Reichl , Mark Brown , Peter Rosin Subject: [alsa-devel] [PATCH 2/2] ASoC: pcm512x: Fix clocking calculations when not using the PLL 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 The rationale behind the current calculation is somewhat obscure [1] and can yield slightly wrong dividers in certain cases, which the machine drivers for some boards (like the HiFiBerry DAC+ Pro) seemingly try to circumvent, by updating the rate fraction so as to suit this calculation. The updated calculation should correctly yield the smallest bit clock rate that would fit the frame. [1] http://mailman.alsa-project.org/pipermail/alsa-devel/2019-January/144219.html Signed-off-by: Dimitris Papavasiliou --- sound/soc/codecs/pcm512x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c index b63d9392bae3..87a2bff366f3 100644 --- a/sound/soc/codecs/pcm512x.c +++ b/sound/soc/codecs/pcm512x.c @@ -929,8 +929,8 @@ static int pcm512x_set_dividers(struct snd_soc_dai *dai, if (!pcm512x->pll_out) { sck_rate = clk_get_rate(pcm512x->sclk); - bclk_div = params->rate_den * 64 / lrclk_div; - bclk_rate = DIV_ROUND_CLOSEST(sck_rate, bclk_div); + bclk_rate = params_rate(params) * lrclk_div; + bclk_div = DIV_ROUND_CLOSEST(sck_rate, bclk_rate); mck_rate = sck_rate; } else {