From patchwork Fri Jul 14 06:36:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 9839951 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 A09D7602D8 for ; Fri, 14 Jul 2017 06:36:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D07228770 for ; Fri, 14 Jul 2017 06:36:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7EBD528779; Fri, 14 Jul 2017 06:36:59 +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=-1.9 required=2.0 tests=BAYES_00, 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 A4AED28770 for ; Fri, 14 Jul 2017 06:36:58 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id AA254266B23; Fri, 14 Jul 2017 08:36:56 +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 4FAB92672A8; Fri, 14 Jul 2017 08:36:55 +0200 (CEST) Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) by alsa0.perex.cz (Postfix) with ESMTP id C026126648D for ; Fri, 14 Jul 2017 08:36:49 +0200 (CEST) Authenticated-By: X-SpamFilter-By: BOX Solutions SpamTrap 5.59 with qID v6E6akab005694, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtitcas12.realtek.com.tw [172.21.6.16]) by rtits2.realtek.com.tw (8.15.2/2.55/5.73) with ESMTP id v6E6akab005694; Fri, 14 Jul 2017 14:36:46 +0800 Received: from RTITCASV01.realtek.com.tw (172.21.6.18) by RTITCAS12.realtek.com.tw (172.21.6.16) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 14 Jul 2017 14:36:46 +0800 Received: from localhost.localdomain (172.21.85.85) by RTITCASV01.realtek.com.tw (172.21.6.18) with Microsoft SMTP Server id 14.3.294.0; Fri, 14 Jul 2017 14:36:45 +0800 From: Bard Liao To: , Date: Fri, 14 Jul 2017 14:36:32 +0800 Message-ID: <1500014192-1411-1-git-send-email-bardliao@realtek.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [172.21.85.85] Cc: oder_chiou@realtek.com, jack.yu@realtek.com, alsa-devel@alsa-project.org, lars@metafoo.de, shumingf@realtek.com, Bard Liao , xiaoxiang@pinecone.net, zhongan@pinecone.net, flove@realtek.com Subject: [alsa-devel] [PATCH] ASoC: rt5665: force using PLL if MCLK is not suitable 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 Idealy PLL will be set in machine driver if MCLK doesn't meet the requirement of codec. To let the codec driver be more general, we can use a common PLL setting once sysclk/pll doesn't set properly in machine driver. Signed-off-by: Bard Liao --- sound/soc/codecs/rt5665.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/rt5665.c b/sound/soc/codecs/rt5665.c index 370ed54d..d3103ef 100644 --- a/sound/soc/codecs/rt5665.c +++ b/sound/soc/codecs/rt5665.c @@ -4098,9 +4098,12 @@ static int rt5665_hw_params(struct snd_pcm_substream *substream, rt5665->lrck[dai->id] = params_rate(params); pre_div = rl6231_get_clk_info(rt5665->sysclk, rt5665->lrck[dai->id]); if (pre_div < 0) { - dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n", - rt5665->lrck[dai->id], dai->id); - return -EINVAL; + dev_warn(codec->dev, "Force using PLL"); + snd_soc_codec_set_pll(codec, 0, RT5665_PLL1_S_MCLK, + rt5665->sysclk, rt5665->lrck[dai->id] * 512); + snd_soc_codec_set_sysclk(codec, RT5665_SCLK_S_PLL1, 0, + rt5665->lrck[dai->id] * 512, 0); + pre_div = 1; } frame_size = snd_soc_params_to_frame_size(params); if (frame_size < 0) {