From patchwork Wed Jul 16 12:10:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 4566711 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 84A379F37C for ; Wed, 16 Jul 2014 12:11:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B541C2018E for ; Wed, 16 Jul 2014 12:11:22 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id A639620120 for ; Wed, 16 Jul 2014 12:11:17 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 676D726537B; Wed, 16 Jul 2014 14:11:16 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 1A30926513F; Wed, 16 Jul 2014 14:11:05 +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 ADF40265197; Wed, 16 Jul 2014 14:11:03 +0200 (CEST) Received: from opensource.wolfsonmicro.com (opensource.wolfsonmicro.com [80.75.67.52]) by alsa0.perex.cz (Postfix) with ESMTP id 7B5FA2619E9 for ; Wed, 16 Jul 2014 14:10:55 +0200 (CEST) Received: from opensource.wolfsonmicro.com (opensource [80.75.67.52]) by opensource.wolfsonmicro.com (Postfix) with ESMTPSA id EB9B8111065; Wed, 16 Jul 2014 13:10:54 +0100 (BST) Date: Wed, 16 Jul 2014 13:10:39 +0100 From: Richard Fitzgerald To: perex@perex.cz, tiwai@suse.de, lgirdwood@gmail.com, broonie@kernel.org Message-ID: <20140716121029.GA22222@opensource.wolfsonmicro.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.17+20080114 (2008-01-14) Cc: alsa-devel@alsa-project.org, patches@opensource.wolfsonmicro.com, linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH] ASoC: arizona: Disable AIF TX/RX before configuring it 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 If we don't disable the AIF TX/RX then we may fall into a situation where the new AIF settings are ignored by the device. For example, this problem manifests when switching between different sample rates. Signed-off-by: Dimitris Papastamos Signed-off-by: Richard Fitzgerald --- sound/soc/codecs/arizona.c | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c index fb30c82..270e7ad 100644 --- a/sound/soc/codecs/arizona.c +++ b/sound/soc/codecs/arizona.c @@ -1249,6 +1249,7 @@ static int arizona_hw_params(struct snd_pcm_substream *substream, int tdm_width = arizona->tdm_width[dai->id - 1]; int tdm_slots = arizona->tdm_slots[dai->id - 1]; int bclk, lrclk, wl, frame, bclk_target; + unsigned int aif_tx_state, aif_rx_state; if (params_rate(params) % 8000) rates = &arizona_44k1_bclk_rates[0]; @@ -1299,9 +1300,18 @@ static int arizona_hw_params(struct snd_pcm_substream *substream, wl = snd_pcm_format_width(params_format(params)); frame = wl << ARIZONA_AIF1TX_WL_SHIFT | wl; + /* Save AIF TX/RX state */ + aif_tx_state = snd_soc_read(codec, base + ARIZONA_AIF_TX_ENABLES); + aif_rx_state = snd_soc_read(codec, base + ARIZONA_AIF_RX_ENABLES); + /* Disable AIF TX/RX before configuring it */ + snd_soc_update_bits(codec, base + ARIZONA_AIF_TX_ENABLES, + 0xff, 0x0); + snd_soc_update_bits(codec, base + ARIZONA_AIF_RX_ENABLES, + 0xff, 0x0); + ret = arizona_hw_params_rate(substream, params, dai); if (ret != 0) - return ret; + goto restore_aif; regmap_update_bits_async(arizona->regmap, base + ARIZONA_AIF_BCLK_CTRL, @@ -1320,7 +1330,13 @@ static int arizona_hw_params(struct snd_pcm_substream *substream, ARIZONA_AIF1RX_WL_MASK | ARIZONA_AIF1RX_SLOT_LEN_MASK, frame); - return 0; +restore_aif: + /* Restore AIF TX/RX state */ + snd_soc_update_bits(codec, base + ARIZONA_AIF_TX_ENABLES, + 0xff, aif_tx_state); + snd_soc_update_bits(codec, base + ARIZONA_AIF_RX_ENABLES, + 0xff, aif_rx_state); + return ret; } static const char *arizona_dai_clk_str(int clk_id)