From patchwork Wed Mar 14 16:41:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 10282715 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3AF21602C2 for ; Wed, 14 Mar 2018 16:41:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B45820881 for ; Wed, 14 Mar 2018 16:41:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F2932847A; Wed, 14 Mar 2018 16:41:38 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DA7720881 for ; Wed, 14 Mar 2018 16:41:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751420AbeCNQlg (ORCPT ); Wed, 14 Mar 2018 12:41:36 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:28095 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751289AbeCNQlf (ORCPT ); Wed, 14 Mar 2018 12:41:35 -0400 Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20180314164133epoutp01b4c40bb4225abeece74c8276cc5b8e9c~b1v-BnFiW1158011580epoutp01j; Wed, 14 Mar 2018 16:41:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20180314164133epoutp01b4c40bb4225abeece74c8276cc5b8e9c~b1v-BnFiW1158011580epoutp01j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1521045693; bh=izRo+P3hSsEplJ4w3IYPKJuYOjMjAG4pFaXLbG6uKoI=; h=From:To:Cc:Subject:Date:References:From; b=MPXfDLBNBE/zQZGnrl75sVq//IIc+03VSGDHNRcnG+ACB/+7mO4Y+H5dMIraqa/fp xI7e/007Dg4ckxaoYK3pN3XOO8QVA8NR6axtTDrMt0ZaoV9MoPwKU0xP0dSWux8X7t Cc/zDqTMYLbRhud36UkOsdCr+G59wGHI4+905faI= Received: from epsmges2p2.samsung.com (unknown [182.195.42.70]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20180314164132epcas2p234c06d3e81790ae3186c11697b74aaf4~b1v_y7B9e3120331203epcas2p2d; Wed, 14 Mar 2018 16:41:32 +0000 (GMT) Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p2.samsung.com (Symantec Messaging Gateway) with SMTP id F6.81.04137.CB059AA5; Thu, 15 Mar 2018 01:41:32 +0900 (KST) Received: from epsmgms2p2new.samsung.com (unknown [182.195.42.143]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20180314164131epcas2p426aa34f4503ff12fa041a817cdd3eed9~b1v9okIcC1353113531epcas2p42; Wed, 14 Mar 2018 16:41:31 +0000 (GMT) X-AuditID: b6c32a46-3c1ff70000001029-ac-5aa950bcc519 Received: from epmmp1.local.host ( [203.254.227.16]) by epsmgms2p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 7D.00.03890.BB059AA5; Thu, 15 Mar 2018 01:41:31 +0900 (KST) Received: from AMDC3061.digital.local ([106.116.147.40]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P5L00M6VACUIH60@mmp1.samsung.com>; Thu, 15 Mar 2018 01:41:31 +0900 (KST) From: Sylwester Nawrocki To: broonie@kernel.org Cc: lgirdwood@gmail.com, krzk@kernel.org, sbkim73@samsung.com, alsa-devel@alsa-project.org, robh+dt@kernel.org, devicetree@vger.kernel.org, linux-samsung-soc@vger.kernel.org, b.zolnierkie@samsung.com, m.szyprowski@samsung.com, Sylwester Nawrocki Subject: [PATCH 1/5] ASoC: samsung: odroid: Fix 32000 sample rate handling Date: Wed, 14 Mar 2018 17:41:13 +0100 Message-id: <20180314164115.22736-1-s.nawrocki@samsung.com> X-Mailer: git-send-email 2.14.2 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJIsWRmVeSWpSXmKPExsWy7bCmhe6egJVRBk/m61tcuXiIyWLjjPWs FlMfPmGzmH/kHKvF+fMb2C2+Xelgsphxfh+Txdojd9ktWvceYbc4/Kad1eLiii9MDtweGz43 sXnsnHWX3WPTqk42j74tqxg9Pm+SC2CN4rJJSc3JLEst0rdL4MpomP6OrWChQMWE35vYGhh/ 83QxcnJICJhIHLhym62LkYtDSGAHo8TGrR3sIAkhge+MEmvvVMAUzfn6mxmiaDejxPtNLVAd vxgl2r/cYAapYhMwlOg92scIYosIiEncntMJFmcWmMIk8eBxKogtLOAlcfPkTaYuRg4OFgFV iYZVuSBhXgFribPTbrFBLJOXeL/gPiPIfAmBCWwSS3atY4FIuEgcv7gWqkhY4tXxLewQtrTE s1UbGSHsaonOti52iOYWRok/0y5BNVhLHD5+kRXiID6JjsN/2UGOkBDglehoE4IwPSR6p5tD VDtKXFs0mw0SELESe5qaGScwSi5gZFjFKJZaUJybnlpsVGCkV5yYW1yal66XnJ+7iREcoVpu OxiXnPM5xCjAwajEw2ugtjJKiDWxrLgy9xCjBAezkgjvHmugEG9KYmVValF+fFFpTmrxIUZp DhYlcd7WAJcoIYH0xJLU7NTUgtQimCwTB6dUA6NU/4nbX+x/Z8xkbfvu+C5NXt3duCfy5L2q +UG3cp4qzHgh9sQ5OiPBy5p5r6JAaldw9HX5P7MatqWfMFNfuytu2Y1aW8YPeXa2ej6bpv6b k7ys69Rsl3+hW8r7Wvvmf70xUSfM9pv4ElbhyxzmLYW7V0w14f3NrP2jXEdg4ibvbTVPDJ8L WCuxFGckGmoxFxUnAgCDQCZlzAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupgluLIzCtJLcpLzFFi42I5/e+xgO7ugJVRBjeOyVtcuXiIyWLjjPWs FlMfPmGzmH/kHKvF+fMb2C2+Xelgsphxfh+Txdojd9ktWvceYbc4/Kad1eLiii9MDtweGz43 sXnsnHWX3WPTqk42j74tqxg9Pm+SC2CN4rJJSc3JLEst0rdL4MpomP6OrWChQMWE35vYGhh/ 83QxcnJICJhIzPn6m7mLkYtDSGAno0TjmW+sEM4vRomWDadZQKrYBAwleo/2MYLYIgJiErfn dIJ1MAtMYZL4PecxWEJYwEvi5smbTF2MHBwsAqoSDatyQcK8AtYSZ6fdYoPYJi/xfsF9xgmM XAsYGVYxSqYWFOem5xYbFRjlpZbrFSfmFpfmpesl5+duYgSGz7bDWv07GB8viT/EKMDBqMTD a6C2MkqINbGsuDL3EKMEB7OSCO8ea6AQb0piZVVqUX58UWlOavEhRmkOFiVxXv78Y5FCAumJ JanZqakFqUUwWSYOTqkGxvKJ1m7SO+LDGb5tzpdiOWN3rP7i6eslWRMdn+WeqH/Qc2RRQV3S g4gqrjgRQZ3n8pca+X+6MJRtcWRVqYx8fTjk+wuTKdonXRWa1HYsVnFOkubLfmJW2snc/uh0 Q2TDy0+nFQI+3jRZtvqF+H32tGzfvVFT1tzg/n3vYWbbZjGLhdcDfqnPV2Ipzkg01GIuKk4E AGW1zpsbAgAA X-CMS-MailID: 20180314164131epcas2p426aa34f4503ff12fa041a817cdd3eed9 X-Msg-Generator: CA CMS-TYPE: 102P X-CMS-RootMailID: 20180314164131epcas2p426aa34f4503ff12fa041a817cdd3eed9 X-RootMTR: 20180314164131epcas2p426aa34f4503ff12fa041a817cdd3eed9 References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In case of sample rates lower than 44100 currently there is too low MCLK frequency set for the CODEC. Playback fails with following errors: $ speaker-test -c2 -t sine -f 1500 -l2 -r 32000 Sine wave rate is 1500.0000Hz Rate set to 32000Hz (requested 32000Hz) Buffer size range from 128 to 131072 Period size range from 64 to 65536 Using max buffer size 131072 Periods = 4 Unable to set hw params for playback: Invalid argument Setting of hwparams failed: Invalid argument [ 497.883700] max98090 1-0010: Invalid master clock frequency To fix this the I2S root clock's frequency is increased, depending on sampling rate. Signed-off-by: Sylwester Nawrocki Acked-by: Krzysztof Kozlowski --- sound/soc/samsung/odroid.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c index 92d750806d1d..e698e67f5f84 100644 --- a/sound/soc/samsung/odroid.c +++ b/sound/soc/samsung/odroid.c @@ -36,23 +36,26 @@ static int odroid_card_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct odroid_priv *priv = snd_soc_card_get_drvdata(rtd->card); - unsigned int pll_freq, rclk_freq; + unsigned int pll_freq, rclk_freq, rfs; int ret; switch (params_rate(params)) { - case 32000: case 64000: - pll_freq = 131072006U; + pll_freq = 196608001U; + rfs = 384; break; case 44100: case 88200: case 176400: pll_freq = 180633609U; + rfs = 512; break; + case 32000: case 48000: case 96000: case 192000: pll_freq = 196608001U; + rfs = 512; break; default: return -EINVAL; @@ -67,7 +70,7 @@ static int odroid_card_hw_params(struct snd_pcm_substream *substream, * frequency values due to the EPLL output frequency not being exact * multiple of the audio sampling rate. */ - rclk_freq = params_rate(params) * 256 + 1; + rclk_freq = params_rate(params) * rfs + 1; ret = clk_set_rate(priv->sclk_i2s, rclk_freq); if (ret < 0)