From patchwork Thu Jan 18 11:22:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 124934 Delivered-To: patch@linaro.org Received: by 10.46.64.27 with SMTP id n27csp84026lja; Thu, 18 Jan 2018 03:23:09 -0800 (PST) X-Google-Smtp-Source: ACJfBovzhvk0BOciMTlfhvQ6XtrJ6a9yj0wvxwwK0YRI5Tax9YgrRQ9CZ4BXVW4CUgUbODCR7TsX X-Received: by 10.223.190.4 with SMTP id n4mr6344214wrh.28.1516274588938; Thu, 18 Jan 2018 03:23:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516274588; cv=none; d=google.com; s=arc-20160816; b=xLcvO/gQXYMzne+Uw7zgk5y2QMuZ89ZoKObmOY5zFHsUP05JjucvUu/qK9NhvBAXRP K8lE1X7xlp9Jzg9f2x4bJtkeyi85f53n/XNYYM6L8Ty5ZW3Qu9ykEmt98EsYb3fsBolO 1DHaarp8DV/ncRrJv7L4uTAPYyuP9YOLyoKqSuTa7g6+pqW41c0Us6+qtyiIsAfT1/QT cw/m5yhVK0naQ6vFsg2LCyxdfSw9UuoExeqEigtqt38+bHqqoWQOeIde8vSepAxddaXh HcqJdyOJ5dwoMlvBpZGdv9hOfU9iz70U7i1uuc8x6NDgzhRoGlz6nB21emRV81mvOH5V Ptjw== 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:arc-authentication-results; bh=G1LDMAG8V6kA/soj34avXNe5q1rPF74KNdHNYUGdB9s=; b=vVrA4+tgDjOelQD+dWlJ8M0ZvIJSKQwRm6XvFKC1Ltwgm+QTS+fA/WGOG5hbRH/9yV pBRqdKm0Qy4dxJAe46O1Q/8BFrLFddT/OKcHmz6QzNWodXJ9Zh+HuSNIxXAc6+nGwv5K /v8eszreYfPQl3FmLEkiQQYBYE1TLAsHbNUTf6WIyMkaOt+QnW5D+c7ilHH1DBupQecP KyPIGMXEuH+tXFDQZqOew8MjqTWMjEj2KzOSgAdqh2FMumXPIUgYn4o0o/GiH99+X7GM LZ1MWYBuBGEfsOMnBRVj/bGkWtkU+35tOsyNPCSmEaGfuEuSEVTT4bR9y+BgQHXRjvEb ss4g== 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=gduJb79K; 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 Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id r10si6971763wrg.466.2018.01.18.03.23.08; Thu, 18 Jan 2018 03:23:08 -0800 (PST) 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=gduJb79K; 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 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 49F292671A9; Thu, 18 Jan 2018 12:22:57 +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 CF7922671AE; Thu, 18 Jan 2018 12:22:55 +0100 (CET) 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, SPF_PASS, T_RP_MATCHES_RCVD 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 CF9542671A8 for ; Thu, 18 Jan 2018 12:22:52 +0100 (CET) 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=v4S0pLHT2ihcJ0aLjOa4cVJUTPzFWFlq1gXeg3HrC7Y=; b=gduJb79KSsPq YHvtH6dDjPA039aL8afpTbiIfJOSsKwV8Q/WPjyGHBSS4Ev+tYpWihmfzdc119WMFxhBVSl/RUFyd HwKUQtYiyoEc3W/oPfyWvbXw5Ml31WRQVnOE0iFWzK73Zl3VBuixD9n1n0Kn2yGvYQc4Q+Nt3l9Lr 1jvuI=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ec8HP-0007Jl-Vs; Thu, 18 Jan 2018 11:22:48 +0000 Received: from broonie by debutante with local (Exim 4.90) (envelope-from ) id 1ec8HP-0003k8-GV; Thu, 18 Jan 2018 11:22:47 +0000 From: Mark Brown To: Matthias Reichl In-Reply-To: <20180117125050.2948-1-hias@horus.com> Message-Id: Date: Thu, 18 Jan 2018 11:22:47 +0000 Cc: Stefan Wahren , alsa-devel@alsa-project.org, Phil Elwell , Eric Anholt , Mark Brown , linux-rpi-kernel@lists.infradead.org Subject: [alsa-devel] Applied "ASoC: bcm2835: fix hw_params error when device is in prepared state" 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: bcm2835: fix hw_params error when device is in prepared state 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 8d5737a5f53902a916ee1e1cb248c9b8b883b2ea Mon Sep 17 00:00:00 2001 From: Matthias Reichl Date: Wed, 17 Jan 2018 13:50:50 +0100 Subject: [PATCH] ASoC: bcm2835: fix hw_params error when device is in prepared state If bcm2835 is configured as bitclock master calling hw_params() after prepare() fails with EBUSY. This also makes it impossible to use bcm2835 in full duplex mode. The error is caused by the split clock setup: clk_set_rate is called in hw_params, clk_prepare_enable in prepare. As hw_params doesn't check if the clock was already enabled clk_set_rate fails with EBUSY. Fix this by moving clock startup from prepare to hw_params and let hw_params properly deal with an already set up or enabled clock. Signed-off-by: Matthias Reichl Signed-off-by: Mark Brown --- sound/soc/bcm/bcm2835-i2s.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) -- 2.15.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/bcm/bcm2835-i2s.c b/sound/soc/bcm/bcm2835-i2s.c index 2e449d7173fc..d5f73a8ab893 100644 --- a/sound/soc/bcm/bcm2835-i2s.c +++ b/sound/soc/bcm/bcm2835-i2s.c @@ -130,6 +130,7 @@ struct bcm2835_i2s_dev { struct regmap *i2s_regmap; struct clk *clk; bool clk_prepared; + int clk_rate; }; static void bcm2835_i2s_start_clock(struct bcm2835_i2s_dev *dev) @@ -419,10 +420,19 @@ static int bcm2835_i2s_hw_params(struct snd_pcm_substream *substream, } /* Clock should only be set up here if CPU is clock master */ - if (bit_clock_master) { - ret = clk_set_rate(dev->clk, bclk_rate); - if (ret) - return ret; + if (bit_clock_master && + (!dev->clk_prepared || dev->clk_rate != bclk_rate)) { + if (dev->clk_prepared) + bcm2835_i2s_stop_clock(dev); + + if (dev->clk_rate != bclk_rate) { + ret = clk_set_rate(dev->clk, bclk_rate); + if (ret) + return ret; + dev->clk_rate = bclk_rate; + } + + bcm2835_i2s_start_clock(dev); } /* Setup the frame format */ @@ -618,8 +628,6 @@ static int bcm2835_i2s_prepare(struct snd_pcm_substream *substream, struct bcm2835_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); uint32_t cs_reg; - bcm2835_i2s_start_clock(dev); - /* * Clear both FIFOs if the one that should be started * is not empty at the moment. This should only happen