From patchwork Fri Jul 18 17:31:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 33884 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f72.google.com (mail-qa0-f72.google.com [209.85.216.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6BADA208CF for ; Fri, 18 Jul 2014 17:31:33 +0000 (UTC) Received: by mail-qa0-f72.google.com with SMTP id cm18sf10436563qab.3 for ; Fri, 18 Jul 2014 10:31:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:mime-version:cc:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=d96Ab7NO88CoVW+j60YZpYTYYYhirDFRv8aDFIiUKmM=; b=O61xEYUxWazqZkPX4SXel+fXNQur2YNR+T0lJUPvhQGrWcON/wTV9wJyqBKLnfJSO8 O2L4ma/r7SByEF8WwBqTsOnKpw2Utl41IT0lsddqdGBPYIJRA/tTnwmnI1oCgeclaeo9 TEGMGiHnL+SAmnDZzALEXQAyNVtBA4e4vyn97Zz++0WKF4WTlxnxV0bHNRc5niOoaiuM S8UDtpLgjM2BKqadQnVCgvr6RDAGmeemgp5PFGA3TZdJLK4OqRKOPmp4UTf3UqY/gR5n p6axC1WyrwtoGAggsS2rzjfNZgy6DPEDfH4oy2Mqt7x6N1wJ/9SVMc61pxLh7L4Ai5kH voZg== X-Gm-Message-State: ALoCoQl1bjE8veSe8sqQ2wVEwMEbiccq7Kf7JAykFwXYGVPBGLFPtmj2+qubB2m1vJOzH3mEcIGJ X-Received: by 10.224.2.193 with SMTP id 1mr2967462qak.9.1405704691699; Fri, 18 Jul 2014 10:31:31 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.92.120 with SMTP id a111ls1106066qge.15.gmail; Fri, 18 Jul 2014 10:31:31 -0700 (PDT) X-Received: by 10.220.161.8 with SMTP id p8mr8234708vcx.4.1405704691466; Fri, 18 Jul 2014 10:31:31 -0700 (PDT) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id vb10si5200172vec.20.2014.07.18.10.31.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Jul 2014 10:31:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.176 as permitted sender) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id id10so3293170vcb.21 for ; Fri, 18 Jul 2014 10:31:31 -0700 (PDT) X-Received: by 10.52.244.81 with SMTP id xe17mr6889812vdc.24.1405704691253; Fri, 18 Jul 2014 10:31:31 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp29113vcb; Fri, 18 Jul 2014 10:31:30 -0700 (PDT) X-Received: by 10.180.106.66 with SMTP id gs2mr10060385wib.5.1405704690016; Fri, 18 Jul 2014 10:31:30 -0700 (PDT) Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id j14si2312443wiw.14.2014.07.18.10.31.29 for ; Fri, 18 Jul 2014 10:31:30 -0700 (PDT) Received-SPF: none (google.com: alsa-devel-bounces@alsa-project.org does not designate permitted sender hosts) client-ip=77.48.224.243; Received: by alsa0.perex.cz (Postfix, from userid 1000) id 41E0926564A; Fri, 18 Jul 2014 19:31:28 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-8.0 required=5.0 tests=RCVD_IN_DNSWL_HI autolearn=disabled version=3.2.4 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 9DD6F26562D; Fri, 18 Jul 2014 19:31:22 +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 0D5B7265631; Fri, 18 Jul 2014 19:31:21 +0200 (CEST) Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by alsa0.perex.cz (Postfix) with ESMTP id 97A092608D3 for ; Fri, 18 Jul 2014 19:31:13 +0200 (CEST) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s6IHVAMI031435; Fri, 18 Jul 2014 12:31:11 -0500 Received: from DLEE70.ent.ti.com (dlemailx.itg.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s6IHVAgL016274; Fri, 18 Jul 2014 12:31:10 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.174.1; Fri, 18 Jul 2014 12:31:10 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s6IHVAsg002743; Fri, 18 Jul 2014 12:31:10 -0500 Received: from localhost (j-172-22-79-180.vpn.ti.com [172.22.79.180]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id s6IHVAt12595; Fri, 18 Jul 2014 12:31:10 -0500 (CDT) From: Dan Murphy To: Date: Fri, 18 Jul 2014 12:31:08 -0500 Message-ID: <1405704668-8038-2-git-send-email-dmurphy@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1405704668-8038-1-git-send-email-dmurphy@ti.com> References: <1405704668-8038-1-git-send-email-dmurphy@ti.com> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, broonie@kernel.org, linux-kernel@vger.kernel.org, Dan Murphy Subject: [alsa-devel] [PATCH 2/2] ASoC: tas2552: Add DAPM calls for amp and PLL X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: 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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: dmurphy@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.176 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Add DAPM calls to enable/disable the Class D amp. Also add a DAPM call to turn off the PLL upon the stream completing. Signed-off-by: Dan Murphy --- sound/soc/codecs/tas2552.c | 58 +++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/sound/soc/codecs/tas2552.c b/sound/soc/codecs/tas2552.c index a3ae394..3fdb173 100644 --- a/sound/soc/codecs/tas2552.c +++ b/sound/soc/codecs/tas2552.c @@ -78,6 +78,40 @@ struct tas2552_data { unsigned int mclk; }; + +static int tas2552_pll_disable(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + if (event == SND_SOC_DAPM_POST_PMD) + snd_soc_update_bits(w->codec, TAS2552_CFG_2, TAS2552_PLL_ENABLE, 0); + + return 0; +} + +static int tas2552_class_d_en(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + snd_soc_update_bits(w->codec, TAS2552_CFG_2, + TAS2552_CLASSD_EN_MASK, TAS2552_CLASSD_EN_MASK); + break; + case SND_SOC_DAPM_POST_PMD: + snd_soc_update_bits(w->codec, TAS2552_CFG_2, + TAS2552_CLASSD_EN_MASK, 0); + break; + } + + return 0; +} + +static const struct snd_soc_dapm_widget tas2552_dapm_widgets[] = +{ +SND_SOC_DAPM_PRE("Class D Enable", tas2552_class_d_en), +SND_SOC_DAPM_POST("Class D Disable", tas2552_class_d_en), +SND_SOC_DAPM_POST("PLL Disable", tas2552_pll_disable), +}; + static void tas2552_sw_shutdown(struct tas2552_data *tas_data, int sw_shutdown) { u8 cfg1_reg; @@ -101,10 +135,6 @@ static int tas2552_hw_params(struct snd_pcm_substream *substream, int d; u8 p, j; - /* Turn on Class D amplifier */ - snd_soc_update_bits(codec, TAS2552_CFG_2, TAS2552_CLASSD_EN_MASK, - TAS2552_CLASSD_EN); - if (!tas2552->mclk) return -EINVAL; @@ -149,7 +179,6 @@ static int tas2552_hw_params(struct snd_pcm_substream *substream, snd_soc_update_bits(codec, TAS2552_CFG_2, TAS2552_PLL_ENABLE, TAS2552_PLL_ENABLE); - return 0; } @@ -269,19 +298,10 @@ static const struct dev_pm_ops tas2552_pm = { NULL) }; -static void tas2552_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct snd_soc_codec *codec = dai->codec; - - snd_soc_update_bits(codec, TAS2552_CFG_2, TAS2552_PLL_ENABLE, 0); -} - static struct snd_soc_dai_ops tas2552_speaker_dai_ops = { .hw_params = tas2552_hw_params, .set_sysclk = tas2552_set_dai_sysclk, .set_fmt = tas2552_set_dai_fmt, - .shutdown = tas2552_shutdown, .digital_mute = tas2552_mute, }; @@ -321,6 +341,7 @@ static const struct reg_default tas2552_init_regs[] = { static int tas2552_codec_probe(struct snd_soc_codec *codec) { struct tas2552_data *tas2552 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = &codec->dapm; int ret; tas2552->codec = codec; @@ -362,9 +383,12 @@ static int tas2552_codec_probe(struct snd_soc_codec *codec) goto patch_fail; } - snd_soc_write(codec, TAS2552_CFG_2, TAS2552_CLASSD_EN | - TAS2552_BOOST_EN | TAS2552_APT_EN | - TAS2552_LIM_EN); + snd_soc_write(codec, TAS2552_CFG_2, TAS2552_BOOST_EN | + TAS2552_APT_EN | TAS2552_LIM_EN); + + snd_soc_dapm_new_controls(dapm, tas2552_dapm_widgets, + ARRAY_SIZE(tas2552_dapm_widgets)); + return 0; patch_fail: