From patchwork Tue Sep 2 03:30:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xavier Hsu X-Patchwork-Id: 36443 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 032CF2032B for ; Tue, 2 Sep 2014 03:30:58 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id eu11sf67250930pac.3 for ; Mon, 01 Sep 2014 20:30:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=Bqm9reCIjiyn1My5r+a49EoDfqQunesS4JD6V4fjX0U=; b=YG9PfQeki2os/jNsg8wZ55zjtA/FeZOz5uZTsKHNpil5veDoxWgmq2pS8ROvdHDLWM AptL7KPezA7QdSc5xRyTvB89KqiUwRnC+KEOcL3ZFYCp2yupcgvH3REhCr045xnMzHW4 3DCe+s3wPEsd/IKz3jKCgH8vjeONvSPEzAoG0F5djUotubutkq5bhvyPSr3gmNvr/vvN UsSYFYZKD7GyAW3o3CHE3S8ujEhdgoGL01FsfpqwtAr+9OJ27AqmlMMRHC4V3nEHgsCg vHOdCTnSfSQiL6mvx8deaqa6TmuofnWP5uOarOnDRRL0vFpAPj1lLQHm0F23gBsXsVtp EhDw== X-Gm-Message-State: ALoCoQkboL59xkC5Jn2r7lWhHoa9Ek2yoM3TxR8o3WpAi4Q2nW9j/6lDnxa7LhKAfkhq+6qD6Ibd X-Received: by 10.69.29.234 with SMTP id jz10mr17819895pbd.1.1409628658359; Mon, 01 Sep 2014 20:30:58 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.103.74 with SMTP id x68ls2215340qge.28.gmail; Mon, 01 Sep 2014 20:30:58 -0700 (PDT) X-Received: by 10.220.97.5 with SMTP id j5mr28417045vcn.16.1409628658272; Mon, 01 Sep 2014 20:30:58 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id w7si1764222vcs.17.2014.09.01.20.30.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Sep 2014 20:30:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id lf12so6268591vcb.20 for ; Mon, 01 Sep 2014 20:30:58 -0700 (PDT) X-Received: by 10.52.138.210 with SMTP id qs18mr3795476vdb.18.1409628658190; Mon, 01 Sep 2014 20:30:58 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp465342vcb; Mon, 1 Sep 2014 20:30:57 -0700 (PDT) X-Received: by 10.70.87.225 with SMTP id bb1mr44025392pdb.67.1409628657224; Mon, 01 Sep 2014 20:30:57 -0700 (PDT) Received: from Kraken ([124.219.7.128]) by mx.google.com with ESMTP id yn9si3726015pac.118.2014.09.01.20.30.55 for ; Mon, 01 Sep 2014 20:30:57 -0700 (PDT) Received-SPF: none (google.com: xavier@kraken does not designate permitted sender hosts) client-ip=124.219.7.128; Received: by Kraken (Postfix, from userid 1011) id 31B0F6A27A7; Tue, 2 Sep 2014 11:30:54 +0800 (CST) From: Xavier Hsu To: alsa-devel@alsa-project.org, patches@opensource.wolfsonmicro.com, patches@linaro.org Cc: lars@metafoo.de, ckeepax@opensource.wolfsonmicro.com, Xavier Hsu , Andy Green Subject: [PATCHv3 7/9] WM8971 improves the function of regmap Date: Tue, 2 Sep 2014 11:30:46 +0800 Message-Id: <1409628648-13732-7-git-send-email-xavier.hsu@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1409628648-13732-1-git-send-email-xavier.hsu@linaro.org> References: <1409628648-13732-1-git-send-email-xavier.hsu@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: xavier.hsu@linaro.org 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.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch improves WM8971. We modify the function of regmap. Any comments about improving the patch are welcome. Thanks. Signed-off-by: Xavier Hsu Signed-off-by: Andy Green --- sound/soc/codecs/wm8971.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c index 68b4f52..95e7c39 100755 --- a/sound/soc/codecs/wm8971.c +++ b/sound/soc/codecs/wm8971.c @@ -38,6 +38,7 @@ /* codec private data */ struct wm8971_priv { + struct regmap *regmap; unsigned int sysclk; struct snd_pcm_hw_constraint_list *sysclk_constraints; int playback_fs; @@ -716,6 +717,7 @@ static int wm8971_mute(struct snd_soc_dai *dai, int mute) static int wm8971_set_bias_level(struct snd_soc_codec *codec, enum snd_soc_bias_level level) { + struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); u16 pwr_reg = snd_soc_read(codec, WM8971_PWR1) & 0xfe3e; switch (level) { @@ -727,7 +729,7 @@ static int wm8971_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) - snd_soc_cache_sync(codec); + regcache_sync(wm8971->regmap); /* mute dac and set vmid to 500k, enable VREF */ snd_soc_write(codec, WM8971_PWR1, pwr_reg | 0x0140); @@ -774,7 +776,11 @@ static struct snd_soc_dai_driver wm8971_dai = { static int wm8971_suspend(struct snd_soc_codec *codec) { + struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); + wm8971_set_bias_level(codec, SND_SOC_BIAS_OFF); + regcache_mark_dirty(wm8971->regmap); + return 0; } @@ -797,9 +803,12 @@ static int wm8971_resume(struct snd_soc_codec *codec) static int wm8971_probe(struct snd_soc_codec *codec) { + struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); int ret = 0; u16 reg; + codec->control_data = wm8971->regmap; + wm8971_reset(codec); /* charge output caps - set vmid to 5k for quick power up */ @@ -830,12 +839,20 @@ static int wm8971_remove(struct snd_soc_codec *codec) return 0; } +struct regmap *wm8971_get_regmap(struct device *dev) +{ + struct wm8971_priv *priv = dev_get_drvdata(dev); + + return priv->regmap; +} + static struct snd_soc_codec_driver soc_codec_dev_wm8971 = { .probe = wm8971_probe, .remove = wm8971_remove, .suspend = wm8971_suspend, .resume = wm8971_resume, .set_bias_level = wm8971_set_bias_level, + .get_regmap = wm8971_get_regmap, .controls = wm8971_snd_controls, .num_controls = ARRAY_SIZE(wm8971_snd_controls), @@ -859,7 +876,6 @@ static int wm8971_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct wm8971_priv *wm8971; - struct regmap *regmap; int ret; wm8971 = devm_kzalloc(&i2c->dev, sizeof(struct wm8971_priv), @@ -867,9 +883,9 @@ static int wm8971_i2c_probe(struct i2c_client *i2c, if (wm8971 == NULL) return -ENOMEM; - regmap = devm_regmap_init_i2c(i2c, &wm8971_regmap); - if (IS_ERR(regmap)) - return PTR_ERR(regmap); + wm8971->regmap = devm_regmap_init_i2c(i2c, &wm8971_regmap); + if (IS_ERR(wm8971->regmap)) + return PTR_ERR(wm8971->regmap); i2c_set_clientdata(i2c, wm8971);