From patchwork Thu Aug 4 14:35:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Thomson X-Patchwork-Id: 9264643 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 0DEF760754 for ; Fri, 5 Aug 2016 00:28:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2D4D27FAC for ; Fri, 5 Aug 2016 00:28:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E76BC283E4; Fri, 5 Aug 2016 00:28:28 +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 F111228138 for ; Fri, 5 Aug 2016 00:28:27 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id E1E4E266F9D; Fri, 5 Aug 2016 02:28:24 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 915F42659FB; Fri, 5 Aug 2016 01:21:01 +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 9F3A42659FB; Fri, 5 Aug 2016 01:20:58 +0200 (CEST) Received: from mail1.bemta5.messagelabs.com (mail1.bemta5.messagelabs.com [195.245.231.146]) by alsa0.perex.cz (Postfix) with ESMTP id 6093E2665AA for ; Thu, 4 Aug 2016 16:35:40 +0200 (CEST) Received: from [85.158.139.51] by server-10.bemta-5.messagelabs.com id AB/62-19922-CB253A75; Thu, 04 Aug 2016 14:35:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGIsWRWlGSWpSXmKPExsUSt3Opse6eoMX hBn8+c1tcuXiIyWLqwydsFt+udDBZXN41h82ic1c/q8WG72sZHdg8NnxuYvPYOesuu8emVZ1s HvveLmPzWL/lKovH501yAWxRrJl5SfkVCawZrzu/sRe08lfsm3qVsYFxA08XIxeHkMA6Rol1U 5YzdTFyAjkVEh1fdzOC2LwCmRLz180Ei3MKuEu8O7GNEaLGTWLG3D0sIDabgIXE5BMP2EBsFg EViT1bmthBbGGBCIknu+6xgCwQEehilFj96jFYglmgXGLLp4nMEAsEJU7OfMICEZeQOPjiBTP EAgOJ0wsaweISAvYS099fBYpzANn6Eo3HYiHChhLfZ31jgQibS7yYZjyBUXAWkqGzkAxdwMi0 ilGjOLWoLLVI18hcL6koMz2jJDcxM0fX0MBULze1uDgxPTUnMalYLzk/dxMjMPzrGRgYdzBe3 eJ3iFGSg0lJlHdGwOJwIb6k/JTKjMTijPii0pzU4kOMMhwcShK85oFAOcGi1PTUirTMHGAkwq QlOHiURHgDQdK8xQWJucWZ6RCpU4yKUuK8miAJAZBERmkeXBss+i8xykoJ8zIyMDAI8RSkFuV mlqDKv2IU52BUEuZNAZnCk5lXAjf9FdBiJqDFJwwWgCwuSURISTUwmlyZ4L1J8PIbxbhM1rjH G5dtCJ9x/z33lkSzFfcEgxz1fkhb7D8vwO9oeO9Uvs/DD9w2UXyPru86nv9vndKjhwsvZAmXG Dm1thc5WJvoFKz/eoK5KOntvO9mvFLnDEvYUxOLuPtMta0uvb07NcTB3na7tuwl7xMZv1W+/5 P1Wz4jaYee4U5GJZbijERDLeai4kQAuK/62vkCAAA= X-Env-Sender: Adam.Thomson.Opensource@diasemi.com X-Msg-Ref: server-11.tower-180.messagelabs.com!1470321339!48386626!1 X-Originating-IP: [94.185.165.51] X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27628 invoked from network); 4 Aug 2016 14:35:40 -0000 Received: from mailrelay2.diasemi.com (HELO sw-ex-cashub01.diasemi.com) (94.185.165.51) by server-11.tower-180.messagelabs.com with AES128-SHA encrypted SMTP; 4 Aug 2016 14:35:40 -0000 Received: from swsrvapps-01.diasemi.com (10.20.28.141) by SW-EX-CASHUB01.diasemi.com (10.20.16.140) with Microsoft SMTP Server id 14.3.248.2; Thu, 4 Aug 2016 15:35:39 +0100 Received: by swsrvapps-01.diasemi.com (Postfix, from userid 22379) id 6037F3FB84; Thu, 4 Aug 2016 15:35:39 +0100 (BST) Message-ID: <0a4cee872d31223fa076c58e4328aad3a11104a8.1470318378.git.Adam.Thomson.Opensource@diasemi.com> In-Reply-To: References: From: Adam Thomson Date: Thu, 4 Aug 2016 15:35:39 +0100 To: Mark Brown , Liam Girdwood , Jaroslav Kysela , Takashi Iwai MIME-Version: 1.0 X-KSE-AttachmentFiltering-Interceptor-Info: protection disabled X-KSE-ServerInfo: sw-ex-cashub01.diasemi.com, 9 X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean, bases: 04/08/2016 12:49:00 Cc: alsa-devel@alsa-project.org, Support Opensource , linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH 2/4] ASoC: da7213: Improve driver efficiency with regards to MCLK usage 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 Currently MCLK remains enabled during bias STANDBY state, and this is not necessary. This patch updates the code to handle enabling and disabling of MCLK, if provided, when moving between STANDBY and PREPARE states, therefore saving power when no active streams present. Signed-off-by: Adam Thomson Tested-by: Peter Meerwald-Stadler --- sound/soc/codecs/da7213.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c index bcf1834..7701f4e 100644 --- a/sound/soc/codecs/da7213.c +++ b/sound/soc/codecs/da7213.c @@ -1454,11 +1454,10 @@ static int da7213_set_bias_level(struct snd_soc_codec *codec, switch (level) { case SND_SOC_BIAS_ON: - case SND_SOC_BIAS_PREPARE: break; - case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { - /* MCLK */ + case SND_SOC_BIAS_PREPARE: + /* Enable MCLK for transition to ON state */ + if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) { if (da7213->mclk) { ret = clk_prepare_enable(da7213->mclk); if (ret) { @@ -1467,21 +1466,24 @@ static int da7213_set_bias_level(struct snd_soc_codec *codec, return ret; } } - + } + break; + case SND_SOC_BIAS_STANDBY: + if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { /* Enable VMID reference & master bias */ snd_soc_update_bits(codec, DA7213_REFERENCES, DA7213_VMID_EN | DA7213_BIAS_EN, DA7213_VMID_EN | DA7213_BIAS_EN); + } else { + /* Remove MCLK */ + if (da7213->mclk) + clk_disable_unprepare(da7213->mclk); } break; case SND_SOC_BIAS_OFF: /* Disable VMID reference & master bias */ snd_soc_update_bits(codec, DA7213_REFERENCES, DA7213_VMID_EN | DA7213_BIAS_EN, 0); - - /* MCLK */ - if (da7213->mclk) - clk_disable_unprepare(da7213->mclk); break; } return 0;