From patchwork Tue Oct 16 03:11:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Khoruzhick X-Patchwork-Id: 10642867 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF63014E2 for ; Tue, 16 Oct 2018 03:11:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB6AB212DB for ; Tue, 16 Oct 2018 03:11:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E50C2988C; Tue, 16 Oct 2018 03:11:57 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,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 47303212DB for ; Tue, 16 Oct 2018 03:11:56 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id A61EC2677F5; Tue, 16 Oct 2018 05:11:54 +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 5788E267845; Tue, 16 Oct 2018 05:11:52 +0200 (CEST) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by alsa0.perex.cz (Postfix) with ESMTP id 5E77B2677F0 for ; Tue, 16 Oct 2018 05:11:49 +0200 (CEST) Received: by mail-pf1-f196.google.com with SMTP id c25-v6so10691354pfe.6 for ; Mon, 15 Oct 2018 20:11:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rAfgjoeXGtR6r3nDwvuQAB/E9x/hZxQ3I9y5hIuiEVA=; b=bOJ7fJA3J/kq3vduXD2OG/mdEl6NlGz5+q2Q0MLTEmqvwJlnB/a27FEFATCh8S1BXZ +i5epAPKRcBesQRu9WO7LlfCtP4gHyoKaPXRiI9FCdyOo/e/5H6iYjvaB6MlXNPTIff2 7af5NpoJOCUpbcyIGrzbC6dwIF0c43kFosqnmkjiA3BAaxsiOvJe3c25pFv1HMmVle7l RMWI5Ksl8uXQkpqXGZf7IeBOsSzKYW9eKMexeG9IMvUBx6sJVT2NWe+JEwPYd33AJMF0 7f4RN9+VGVS/YN57jGQS2nxFb2pqWvg8jkLmVuaqH9xgtlROk29sv6T43JURQLThBTMe thzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rAfgjoeXGtR6r3nDwvuQAB/E9x/hZxQ3I9y5hIuiEVA=; b=tlyMzrvBqdJ5q9FTyeRhIBy9JEVQgBfQe0MpVHRKDtdeWuu4MtZZ2HVAwXxaMA0oOx RVL4Hn51XdVumPFVmNJIZ4jbhkgwEJCBkBs5xpnEGApE3y/KE20LMxO/2mblSSzIudqj 3ebFoH/bMlYNjZuAJRXFxMzpcIoB9SdsViFEnp1o0JcNoRF1Qvcd4raCZ18CrRQIPDqB SSszrTYSdF2M/d9vDUvq06VkvT4+xdW0mEMVYLVIZFS1wgGbFEX7ApiHmZq7aUBAy3vK P+dBpxh7XlQticdxurh/C19WfioXxpSu758OU4XsxHF8jxaBLMj2FhShO7tdLP2eM5Tz qqdw== X-Gm-Message-State: ABuFfoj5LE0H1ONGTEQ4XDLWE3slE8RKysG36y8Y92fA743H1VfNOEJp 47Eng8K1jWmP2B5BsFgKwWc= X-Google-Smtp-Source: ACcGV60I40yj+sQX0D2fwRPKlop5ZUE7NotG3Jji/qeX46xVM/SxTqc4ZGPJruG7/cMTkvvoacQKgg== X-Received: by 2002:a63:84c1:: with SMTP id k184-v6mr18702852pgd.196.1539659508893; Mon, 15 Oct 2018 20:11:48 -0700 (PDT) Received: from anarsoul-thinkpad.lan (216-71-193-140.dyn.novuscom.net. [216.71.193.140]) by smtp.gmail.com with ESMTPSA id o62-v6sm15364459pfb.0.2018.10.15.20.11.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 20:11:48 -0700 (PDT) From: Vasily Khoruzhick To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Maxime Ripard , Chen-Yu Tsai , Marcus Cooper , Yong Deng , alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org Date: Mon, 15 Oct 2018 20:11:41 -0700 Message-Id: <20181016031141.16259-1-anarsoul@gmail.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Cc: Vasily Khoruzhick Subject: [alsa-devel] [PATCH v2] ASoC: sun4i-i2s: move code from startup/shutdown hooks into pm_runtime hooks 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 startup() and shutdown() hooks are called for both substreams, so stopping either substream when another is running breaks the latter. E.g. playback breaks if capture is stopped when playback is running. Move code from startup() and shutdown() to resume() and suspend() hooks respectively to fix this issue Signed-off-by: Vasily Khoruzhick Acked-by: Maxime Ripard --- v2: - rename from "ASoC: sun4i-i2s: don't try to start up or shut down DAI if it's active" - move code from startup/shutdown hooks into pm_runtime sound/soc/sunxi/sun4i-i2s.c | 61 +++++++++++++++---------------------- 1 file changed, 25 insertions(+), 36 deletions(-) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index a4aa931ebfae..daa6c08cffbc 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -644,40 +644,6 @@ static int sun4i_i2s_trigger(struct snd_pcm_substream *substream, int cmd, return 0; } -static int sun4i_i2s_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai); - - /* Enable the whole hardware block */ - regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, - SUN4I_I2S_CTRL_GL_EN, SUN4I_I2S_CTRL_GL_EN); - - /* Enable the first output line */ - regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, - SUN4I_I2S_CTRL_SDO_EN_MASK, - SUN4I_I2S_CTRL_SDO_EN(0)); - - - return clk_prepare_enable(i2s->mod_clk); -} - -static void sun4i_i2s_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai); - - clk_disable_unprepare(i2s->mod_clk); - - /* Disable our output lines */ - regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, - SUN4I_I2S_CTRL_SDO_EN_MASK, 0); - - /* Disable the whole hardware block */ - regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, - SUN4I_I2S_CTRL_GL_EN, 0); -} - static int sun4i_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { @@ -695,8 +661,6 @@ static const struct snd_soc_dai_ops sun4i_i2s_dai_ops = { .hw_params = sun4i_i2s_hw_params, .set_fmt = sun4i_i2s_set_fmt, .set_sysclk = sun4i_i2s_set_sysclk, - .shutdown = sun4i_i2s_shutdown, - .startup = sun4i_i2s_startup, .trigger = sun4i_i2s_trigger, }; @@ -869,6 +833,21 @@ static int sun4i_i2s_runtime_resume(struct device *dev) goto err_disable_clk; } + /* Enable the whole hardware block */ + regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, + SUN4I_I2S_CTRL_GL_EN, SUN4I_I2S_CTRL_GL_EN); + + /* Enable the first output line */ + regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, + SUN4I_I2S_CTRL_SDO_EN_MASK, + SUN4I_I2S_CTRL_SDO_EN(0)); + + ret = clk_prepare_enable(i2s->mod_clk); + if (ret) { + dev_err(dev, "Failed to enable module clock\n"); + goto err_disable_clk; + } + return 0; err_disable_clk: @@ -880,6 +859,16 @@ static int sun4i_i2s_runtime_suspend(struct device *dev) { struct sun4i_i2s *i2s = dev_get_drvdata(dev); + clk_disable_unprepare(i2s->mod_clk); + + /* Disable our output lines */ + regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, + SUN4I_I2S_CTRL_SDO_EN_MASK, 0); + + /* Disable the whole hardware block */ + regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, + SUN4I_I2S_CTRL_GL_EN, 0); + regcache_cache_only(i2s->regmap, true); clk_disable_unprepare(i2s->bus_clk);