codec: fixed audio codec tlv320adc3101 input mode error
authorPeipeng Zhao <peipeng.zhao@amlogic.com>
Mon, 11 Sep 2017 02:10:42 +0000 (10:10 +0800)
committerPeipeng Zhao <peipeng.zhao@amlogic.com>
Mon, 11 Sep 2017 02:45:38 +0000 (10:45 +0800)
PD#150798: codec: fixed audio codec tlv320adc3101 input mode
add single end and differential input for S400&S420

Change-Id: I83086663b38e322425f6719247c89877504f22f5
Signed-off-by: Peipeng Zhao <peipeng.zhao@amlogic.com>
arch/arm64/boot/dts/amlogic/axg_s400.dts
arch/arm64/boot/dts/amlogic/axg_s400_v03.dts
arch/arm64/boot/dts/amlogic/axg_s420.dts
arch/arm64/boot/dts/amlogic/axg_s420_128m.dts
arch/arm64/boot/dts/amlogic/axg_s420_v03.dts
sound/soc/codecs/amlogic/tlv320adc3101.c

index af4ccef..d5ee330 100644 (file)
                compatible = "ti,tlv320adc3101";
                #sound-dai-cells = <0>;
                reg = <0x19>;
+               differential_pair = <1>;
                status = "okay";
        };
 
index 803894e..933950d 100644 (file)
                compatible = "ti,tlv320adc3101";
                #sound-dai-cells = <0>;
                reg = <0x19>;
+               differential_pair = <1>;
                status = "okay";
        };
 
index 8a29880..63bac6a 100644 (file)
                compatible = "ti,tlv320adc3101";
                #sound-dai-cells = <0>;
                reg = <0x19>;
+               differential_pair = <1>;
                status = "okay";
        };
 
index d4c497f..38806bf 100644 (file)
                compatible = "ti,tlv320adc3101";
                #sound-dai-cells = <0>;
                reg = <0x19>;
+               differential_pair = <1>;
                status = "okay";
        };
 
index a702bc0..435b88f 100644 (file)
                compatible = "ti,tlv320adc3101";
                #sound-dai-cells = <0>;
                reg = <0x19>;
+               differential_pair = <1>;
                status = "okay";
        };
 
index dbb6131..acb1cc9 100644 (file)
@@ -67,6 +67,11 @@ struct adc3101_priv {
        int codec_mask;
        struct i2c_client *client[4];
        u8 page_no;
+       /* differential_pair
+        * 0: Single-ended;
+        * 1: Differential Pair;
+        */
+       unsigned int differential_pair;
 };
 
 enum{
@@ -523,14 +528,20 @@ static int adc3101_hw_params(struct snd_pcm_substream *substream,
        pr_info("%s iface1 = %02x\n", __func__, data);
 
        snd_soc_write(codec, ADC3101_MICBIAS, 0x50);
-       /* 0x3f: differential, 0xFC:single input */
-       snd_soc_write(codec, ADC3101_LMICPGANIN, 0x3F);
-       /* 0x3f: differential input */
-       snd_soc_write(codec, ADC3101_RMICPGANIN, 0x3F);
-       /* 0x3f: differential, 0xFC:single input */
-       snd_soc_write(codec, ADC3101_LMICPGAPIN, 0x3F);
-       /* 0x3f: differential input */
-       snd_soc_write(codec, ADC3101_RMICPGAPIN, 0x3F);
+
+       if (adc3101->differential_pair == 1) {
+               pr_info("%s differential pair\n", __func__);
+               snd_soc_write(codec, ADC3101_LMICPGANIN, 0x33); //54
+               snd_soc_write(codec, ADC3101_RMICPGANIN, 0x33); //57
+               snd_soc_write(codec, ADC3101_LMICPGAPIN, 0x3F); //52
+               snd_soc_write(codec, ADC3101_RMICPGAPIN, 0x3F); //55
+       } else {
+               pr_info("%s single end\n", __func__);
+               snd_soc_write(codec, ADC3101_LMICPGANIN, 0x3F); //54
+               snd_soc_write(codec, ADC3101_RMICPGANIN, 0x3F); //57
+               snd_soc_write(codec, ADC3101_LMICPGAPIN, 0xCF); //52
+               snd_soc_write(codec, ADC3101_RMICPGAPIN, 0xCF); //55
+       }
        snd_soc_write(codec, ADC3101_LMICPGAVOL, lr_gain);
        snd_soc_write(codec, ADC3101_RMICPGAVOL, lr_gain);
        snd_soc_write(codec, ADC3101_ADCSETUP, 0xc2);
@@ -822,6 +833,13 @@ static int adc3101_i2c_probe(struct i2c_client *i2c,
                        return ret;
                }
        }
+       ret = of_property_read_u32(i2c->dev.of_node, "differential_pair",
+               &adc3101->differential_pair);
+       if (ret) {
+               pr_err("failed to get differential_pair, set it default\n");
+               adc3101->differential_pair = 0;
+               ret = 0;
+       }
        pr_info("%s i2c:%p\n", __func__, i2c);
        ret = snd_soc_register_codec(&i2c->dev,
                                &soc_codec_dev_adc3101, adc3101_dai, 1);