From patchwork Fri Jun 13 09:50:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jyri Sarha X-Patchwork-Id: 4348011 Return-Path: X-Original-To: patchwork-linux-omap@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 CB27ABEEAA for ; Fri, 13 Jun 2014 09:50:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E2C402018A for ; Fri, 13 Jun 2014 09:50:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E9B1E2028D for ; Fri, 13 Jun 2014 09:50:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751784AbaFMJuQ (ORCPT ); Fri, 13 Jun 2014 05:50:16 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:37575 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751300AbaFMJuN (ORCPT ); Fri, 13 Jun 2014 05:50:13 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s5D9o84V011913; Fri, 13 Jun 2014 04:50:08 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5D9o8BV007600; Fri, 13 Jun 2014 04:50:08 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Fri, 13 Jun 2014 04:50:08 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5D9o7WI001440; Fri, 13 Jun 2014 04:50:08 -0500 From: Jyri Sarha To: , CC: , , , , Jyri Sarha Subject: [PATCH 2/2] ASoC: davinci-mcasp: Allow best effort in selecting BCLK divider Date: Fri, 13 Jun 2014 12:50:00 +0300 Message-ID: <6f645a7d31219c4410db31030a3ab07a4af6ae0e.1402652359.git.jsarha@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Do not fail if the exact BLCK rate can not be produced, just print a warning. Check that sysclk frequency is set before implicitly setting the BCLK divider. Signed-off-by: Jyri Sarha --- sound/soc/davinci/davinci-mcasp.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 0ee4986..e26a89d 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -676,14 +676,18 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, int ret; /* If mcasp is BCLK master we need to set BCLK divider */ - if (mcasp->bclk_master) { + if (mcasp->bclk_master && mcasp->sysclk_freq) { unsigned int bclk_freq = snd_soc_params_to_bclk(params); + unsigned int div = mcasp->sysclk_freq / bclk_freq; if (mcasp->sysclk_freq % bclk_freq != 0) { - dev_err(mcasp->dev, "Can't produce required BCLK\n"); - return -EINVAL; + if (((mcasp->sysclk_freq / div) - bclk_freq) > + (bclk_freq - (mcasp->sysclk_freq / (div+1)))) + div++; + dev_warn(mcasp->dev, + "Inaccurate BCLK: %u Hz / %u != %u Hz\n", + mcasp->sysclk_freq, div, bclk_freq); } - davinci_mcasp_set_clkdiv( - cpu_dai, 1, mcasp->sysclk_freq / bclk_freq); + davinci_mcasp_set_clkdiv(cpu_dai, 1, div); } ret = mcasp_common_hw_param(mcasp, substream->stream,