All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xavier Hsu <xavier.hsu@linaro.org>
To: alsa-devel@alsa-project.org, patches@opensource.wolfsonmicro.com,
	patches@linaro.org
Cc: Xavier Hsu <xavier.hsu@linaro.org>, Andy Green <andy.green@linaro.org>
Subject: [PATCHv3 4/9] Improve wm8971_set_dai_fmt
Date: Tue,  2 Sep 2014 11:27:45 +0800	[thread overview]
Message-ID: <1409628470-13059-4-git-send-email-xavier.hsu@linaro.org> (raw)
In-Reply-To: <1409628470-13059-1-git-send-email-xavier.hsu@linaro.org>

This patch improves WM8971.
We modify the function of wm8971_set_dai_fmt().

Any comments about improving the patch are welcome.
Thanks.

Signed-off-by: Xavier Hsu <xavier.hsu@linaro.org>
Signed-off-by: Andy Green <andy.green@linaro.org>
---
 sound/soc/codecs/wm8971.c |   18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c
index 7c2b175..64ed226 100755
--- a/sound/soc/codecs/wm8971.c
+++ b/sound/soc/codecs/wm8971.c
@@ -550,12 +550,11 @@ static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai,
 			      unsigned int fmt)
 {
 	struct snd_soc_codec *codec = codec_dai->codec;
-	u16 iface = 0;
 
 	/* set master/slave audio interface */
 	switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
 	case SND_SOC_DAIFMT_CBM_CFM:
-		iface = 0x0040;
+		snd_soc_update_bits(codec, WM8971_IFACE, 0x0040, 0x0040);
 		break;
 	case SND_SOC_DAIFMT_CBS_CFS:
 		break;
@@ -566,18 +565,18 @@ static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai,
 	/* interface format */
 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
 	case SND_SOC_DAIFMT_I2S:
-		iface |= 0x0002;
+		snd_soc_update_bits(codec, WM8971_IFACE, 0x0002, 0x0002);
 		break;
 	case SND_SOC_DAIFMT_RIGHT_J:
 		break;
 	case SND_SOC_DAIFMT_LEFT_J:
-		iface |= 0x0001;
+		snd_soc_update_bits(codec, WM8971_IFACE, 0x0001, 0x0001);
 		break;
 	case SND_SOC_DAIFMT_DSP_A:
-		iface |= 0x0003;
+		snd_soc_update_bits(codec, WM8971_IFACE, 0x0003, 0x0003);
 		break;
 	case SND_SOC_DAIFMT_DSP_B:
-		iface |= 0x0013;
+		snd_soc_update_bits(codec, WM8971_IFACE, 0x0013, 0x0013);
 		break;
 	default:
 		return -EINVAL;
@@ -588,19 +587,18 @@ static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai,
 	case SND_SOC_DAIFMT_NB_NF:
 		break;
 	case SND_SOC_DAIFMT_IB_IF:
-		iface |= 0x0090;
+		snd_soc_update_bits(codec, WM8971_IFACE, 0x0090, 0x0090);
 		break;
 	case SND_SOC_DAIFMT_IB_NF:
-		iface |= 0x0080;
+		snd_soc_update_bits(codec, WM8971_IFACE, 0x0080, 0x0080);
 		break;
 	case SND_SOC_DAIFMT_NB_IF:
-		iface |= 0x0010;
+		snd_soc_update_bits(codec, WM8971_IFACE, 0x0010, 0x0010);
 		break;
 	default:
 		return -EINVAL;
 	}
 
-	snd_soc_write(codec, WM8971_IFACE, iface);
 	return 0;
 }
 
-- 
1.7.9.5

  parent reply	other threads:[~2014-09-02  3:27 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-02  3:27 [PATCHv3 1/9] Clean WM8971 through checkpatch Xavier Hsu
2014-09-02  3:27 ` [PATCHv3 2/9] WM8971 uses SOC_ENUM_SINGLE_DECL to replace SOC_ENUM_SINGLE Xavier Hsu
2014-09-02  9:33   ` Charles Keepax
2014-09-02 14:56   ` Lars-Peter Clausen
2014-09-04  3:53     ` Xavier Hsu
2014-09-02  3:27 ` [PATCHv3 3/9] WM8971 uses TLV information Xavier Hsu
2014-09-02  9:47   ` Charles Keepax
2014-09-02  3:27 ` Xavier Hsu [this message]
2014-09-02  9:48   ` [PATCHv3 4/9] Improve wm8971_set_dai_fmt Charles Keepax
2014-09-02  3:27 ` [PATCHv3 5/9] Using the constraint based on wm8971_set_dai_sysclk Xavier Hsu
2014-09-02  9:28   ` Charles Keepax
2014-09-04  9:13     ` [alsa-devel] " Xavier Hsu
2014-09-02  3:27 ` [PATCHv3 6/9] WM8971 uses msleep to replace work queue Xavier Hsu
2014-09-02 10:00   ` Charles Keepax
2014-09-05  3:09     ` Xavier Hsu
2014-09-02  3:27 ` [PATCHv3 7/9] WM8971 improves the function of regmap Xavier Hsu
2014-09-02 11:03   ` Charles Keepax
2014-09-03 19:19   ` Lars-Peter Clausen
2014-09-11  3:21     ` Xavier Hsu
2014-09-11  7:06       ` Lars-Peter Clausen
2014-09-02  3:27 ` [PATCHv3 8/9] WM8971 adds kcontrol functions Xavier Hsu
2014-09-02 12:41   ` Charles Keepax
2014-09-11  3:35     ` Xavier Hsu
2014-09-02  3:27 ` [PATCHv3 9/9] ASOC add WM8973 support to WM8971 Xavier Hsu
2014-09-02 12:38   ` Charles Keepax
2014-09-02  3:30 [PATCHv3 1/9] Clean WM8971 through checkpatch Xavier Hsu
2014-09-02  3:30 ` [PATCHv3 4/9] Improve wm8971_set_dai_fmt Xavier Hsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1409628470-13059-4-git-send-email-xavier.hsu@linaro.org \
    --to=xavier.hsu@linaro.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=andy.green@linaro.org \
    --cc=patches@linaro.org \
    --cc=patches@opensource.wolfsonmicro.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.