[PATCH 06/10] Added mask variable to apply it in one round after the switch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Ryan Lee <ryans.lee@xxxxxxxxxxxxxxxxxxx>
---
Added the mask variable to apply in one round after the switch.

 sound/soc/codecs/max98927.c | 64 ++++++++++++++++++++++-----------------------
 1 file changed, 31 insertions(+), 33 deletions(-)

diff --git a/sound/soc/codecs/max98927.c b/sound/soc/codecs/max98927.c
index 0abf6d3..9e70883 100755
--- a/sound/soc/codecs/max98927.c
+++ b/sound/soc/codecs/max98927.c
@@ -171,34 +171,31 @@ static int max98927_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 {
 	struct snd_soc_codec *codec = codec_dai->codec;
 	struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec);
+	unsigned int mode = 0;
 	unsigned int invert = 0;
 
 	dev_dbg(codec->dev, "%s: fmt 0x%08X\n", __func__, fmt);
 
 	switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
 	case SND_SOC_DAIFMT_CBS_CFS:
-		regmap_update_bits(max98927->regmap,
-			MAX98927_R0021_PCM_MASTER_MODE,
-			MAX98927_PCM_MASTER_MODE_MASK,
-			MAX98927_PCM_MASTER_MODE_SLAVE);
+		mode = MAX98927_PCM_MASTER_MODE_SLAVE;
 		break;
 	case SND_SOC_DAIFMT_CBM_CFM:
 		max98927->master = true;
-		regmap_update_bits(max98927->regmap,
-			MAX98927_R0021_PCM_MASTER_MODE,
-			MAX98927_PCM_MASTER_MODE_MASK,
-			MAX98927_PCM_MASTER_MODE_MASTER);
+		mode = MAX98927_PCM_MASTER_MODE_MASTER;
 		break;
 	case SND_SOC_DAIFMT_CBS_CFM:
-		regmap_update_bits(max98927->regmap,
-			MAX98927_R0021_PCM_MASTER_MODE,
-			MAX98927_PCM_MASTER_MODE_MASK,
-			MAX98927_PCM_MASTER_MODE_HYBRID);
+		mode = MAX98927_PCM_MASTER_MODE_HYBRID;
 	default:
 		dev_err(codec->dev, "DAI clock mode unsupported");
 		return -EINVAL;
 	}
 
+	regmap_update_bits(max98927->regmap,
+		MAX98927_R0021_PCM_MASTER_MODE,
+		MAX98927_PCM_MASTER_MODE_MASK,
+		mode);
+
 	switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
 	case SND_SOC_DAIFMT_NB_NF:
 		break;
@@ -210,24 +207,28 @@ static int max98927_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 		return -EINVAL;
 	}
 
+	regmap_update_bits(max98927->regmap,
+		MAX98927_R0020_PCM_MODE_CFG,
+		MAX98927_PCM_MODE_CFG_PCM_BCLKEDGE,
+		invert);
+
 	/* interface format */
 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
 	case SND_SOC_DAIFMT_I2S:
 		max98927->iface |= SND_SOC_DAIFMT_I2S;
-		regmap_update_bits(max98927->regmap,
-			MAX98927_R0020_PCM_MODE_CFG,
-			max98927->iface, max98927->iface);
-		break;
+
+	break;
 	case SND_SOC_DAIFMT_LEFT_J:
 		max98927->iface |= SND_SOC_DAIFMT_LEFT_J;
-		regmap_update_bits(max98927->regmap,
-			MAX98927_R0020_PCM_MODE_CFG,
-			max98927->iface, max98927->iface);
-		break;
+	break;
 	default:
 		return -EINVAL;
 	}
 
+	regmap_update_bits(max98927->regmap,
+		MAX98927_R0020_PCM_MODE_CFG,
+		max98927->iface, max98927->iface);
+
 	/* pcm channel configuration */
 	if (max98927->iface & (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_LEFT_J)) {
 		regmap_write(max98927->regmap,
@@ -301,29 +302,21 @@ static int max98927_dai_hw_params(struct snd_pcm_substream *substream,
 {
 	struct snd_soc_codec *codec = dai->codec;
 	struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec);
-	int sampling_rate = 0;
+	unsigned int sampling_rate = 0;
+	unsigned int chan_sz = 0;
 
 	/* pcm mode configuration */
 	switch (snd_pcm_format_width(params_format(params))) {
 	case 16:
-		regmap_update_bits(max98927->regmap,
-			MAX98927_R0020_PCM_MODE_CFG,
-			MAX98927_PCM_MODE_CFG_CHANSZ_16,
-			MAX98927_PCM_MODE_CFG_CHANSZ_16);
+		chan_sz = MAX98927_PCM_MODE_CFG_CHANSZ_16;
 		max98927->ch_size = 16;
 		break;
 	case 24:
-		regmap_update_bits(max98927->regmap,
-			MAX98927_R0020_PCM_MODE_CFG,
-			MAX98927_PCM_MODE_CFG_CHANSZ_24,
-			MAX98927_PCM_MODE_CFG_CHANSZ_24);
+		chan_sz = MAX98927_PCM_MODE_CFG_CHANSZ_24;
 		max98927->ch_size = 24;
 		break;
 	case 32:
-		regmap_update_bits(max98927->regmap,
-			MAX98927_R0020_PCM_MODE_CFG,
-			MAX98927_PCM_MODE_CFG_CHANSZ_32,
-			MAX98927_PCM_MODE_CFG_CHANSZ_32);
+		chan_sz = MAX98927_PCM_MODE_CFG_CHANSZ_32;
 		max98927->ch_size = 32;
 		break;
 	default:
@@ -331,6 +324,11 @@ static int max98927_dai_hw_params(struct snd_pcm_substream *substream,
 			params_format(params));
 		goto err;
 	}
+
+	regmap_update_bits(max98927->regmap,
+		MAX98927_R0020_PCM_MODE_CFG,
+		MAX98927_PCM_MODE_CFG_CHANSZ_MASK, chan_sz);
+
 	dev_dbg(codec->dev, "format supported %d",
 		params_format(params));
 
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux