ASoC: cs4349: Fix setting digital interface format
authorAxel Lin <axel.lin@ingics.com>
Sun, 19 Jul 2015 14:42:49 +0000 (22:42 +0800)
committerMark Brown <broonie@kernel.org>
Mon, 20 Jul 2015 17:16:16 +0000 (18:16 +0100)
Mode Control - Register 02h

Digital Interface Format (DIF[2:0]) Bits 6-4

DIF2    DIF1    DIF0    Description
0       0       0       Left-Justified, up to 24-bit data
0       0       1       I²S, up to 24-bit data
0       1       0       Right-Justified, 16-bit data
0       1       1       Right-Justified, 24-bit data
1       0       0       TDM slot 0
1       0       1       TDM slot 1
1       1       0       TDM slot 2
1       1       1       TDM slot 3

The DIF_MASK is 0x70, so current code does not correctly set the DIFx
setting. Fix it.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/cs4349.c

index ab071675357ee6fcb5de750f23ff568eca25693e..4885695e35a73f2b040d60dc42940f406e69a924 100644 (file)
@@ -96,17 +96,16 @@ static int cs4349_pcm_hw_params(struct snd_pcm_substream *substream,
 {
        struct snd_soc_codec *codec = dai->codec;
        struct cs4349_private *cs4349 = snd_soc_codec_get_drvdata(codec);
-       int mode, fmt, ret;
+       int fmt, ret;
 
-       mode = snd_soc_read(codec, CS4349_MODE);
        cs4349->rate = params_rate(params);
 
        switch (cs4349->mode) {
        case SND_SOC_DAIFMT_I2S:
-               mode |= MODE_FORMAT(DIF_I2S);
+               fmt = DIF_I2S;
                break;
        case SND_SOC_DAIFMT_LEFT_J:
-               mode |= MODE_FORMAT(DIF_LEFT_JST);
+               fmt = DIF_LEFT_JST;
                break;
        case SND_SOC_DAIFMT_RIGHT_J:
                switch (params_width(params)) {
@@ -119,13 +118,13 @@ static int cs4349_pcm_hw_params(struct snd_pcm_substream *substream,
                default:
                        return -EINVAL;
                }
-               mode |= MODE_FORMAT(fmt);
                break;
        default:
                return -EINVAL;
        }
 
-       ret = snd_soc_write(codec, CS4349_MODE, mode);
+       ret = snd_soc_update_bits(codec, CS4349_MODE, DIF_MASK,
+                                 MODE_FORMAT(fmt));
        if (ret < 0)
                return ret;