Merge remote-tracking branches 'asoc/topic/samsung', 'asoc/topic/sgtl5000', 'asoc...
[sfrench/cifs-2.6.git] / sound / soc / sunxi / sun8i-codec.c
index 50a9e077f01b2372f1fe20d4ebd1179e208fa69d..3dd183be08a40f8dc271f16eebab7f8d71ef0e1e 100644 (file)
@@ -198,9 +198,20 @@ static int sun8i_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
        regmap_update_bits(scodec->regmap, SUN8I_AIF1CLK_CTRL,
                           BIT(SUN8I_AIF1CLK_CTRL_AIF1_BCLK_INV),
                           value << SUN8I_AIF1CLK_CTRL_AIF1_BCLK_INV);
+
+       /*
+        * It appears that the DAI and the codec don't share the same
+        * polarity for the LRCK signal when they mean 'normal' and
+        * 'inverted' in the datasheet.
+        *
+        * Since the DAI here is our regular i2s driver that have been
+        * tested with way more codecs than just this one, it means
+        * that the codec probably gets it backward, and we have to
+        * invert the value here.
+        */
        regmap_update_bits(scodec->regmap, SUN8I_AIF1CLK_CTRL,
                           BIT(SUN8I_AIF1CLK_CTRL_AIF1_LRCK_INV),
-                          value << SUN8I_AIF1CLK_CTRL_AIF1_LRCK_INV);
+                          !value << SUN8I_AIF1CLK_CTRL_AIF1_LRCK_INV);
 
        /* DAI format */
        switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {