@@ -67,6 +67,11 @@ struct adc3101_priv {
6767 int codec_mask ;
6868 struct i2c_client * client [4 ];
6969 u8 page_no ;
70+ /* differential_pair
71+ * 0: Single-ended;
72+ * 1: Differential Pair;
73+ */
74+ unsigned int differential_pair ;
7075};
7176
7277enum {
@@ -523,14 +528,20 @@ static int adc3101_hw_params(struct snd_pcm_substream *substream,
523528 pr_info ("%s iface1 = %02x\n" , __func__ , data );
524529
525530 snd_soc_write (codec , ADC3101_MICBIAS , 0x50 );
526- /* 0x3f: differential, 0xFC:single input */
527- snd_soc_write (codec , ADC3101_LMICPGANIN , 0x3F );
528- /* 0x3f: differential input */
529- snd_soc_write (codec , ADC3101_RMICPGANIN , 0x3F );
530- /* 0x3f: differential, 0xFC:single input */
531- snd_soc_write (codec , ADC3101_LMICPGAPIN , 0x3F );
532- /* 0x3f: differential input */
533- snd_soc_write (codec , ADC3101_RMICPGAPIN , 0x3F );
531+
532+ if (adc3101 -> differential_pair == 1 ) {
533+ pr_info ("%s differential pair\n" , __func__ );
534+ snd_soc_write (codec , ADC3101_LMICPGANIN , 0x33 ); //54
535+ snd_soc_write (codec , ADC3101_RMICPGANIN , 0x33 ); //57
536+ snd_soc_write (codec , ADC3101_LMICPGAPIN , 0x3F ); //52
537+ snd_soc_write (codec , ADC3101_RMICPGAPIN , 0x3F ); //55
538+ } else {
539+ pr_info ("%s single end\n" , __func__ );
540+ snd_soc_write (codec , ADC3101_LMICPGANIN , 0x3F ); //54
541+ snd_soc_write (codec , ADC3101_RMICPGANIN , 0x3F ); //57
542+ snd_soc_write (codec , ADC3101_LMICPGAPIN , 0xCF ); //52
543+ snd_soc_write (codec , ADC3101_RMICPGAPIN , 0xCF ); //55
544+ }
534545 snd_soc_write (codec , ADC3101_LMICPGAVOL , lr_gain );
535546 snd_soc_write (codec , ADC3101_RMICPGAVOL , lr_gain );
536547 snd_soc_write (codec , ADC3101_ADCSETUP , 0xc2 );
@@ -822,6 +833,13 @@ static int adc3101_i2c_probe(struct i2c_client *i2c,
822833 return ret ;
823834 }
824835 }
836+ ret = of_property_read_u32 (i2c -> dev .of_node , "differential_pair" ,
837+ & adc3101 -> differential_pair );
838+ if (ret ) {
839+ pr_err ("failed to get differential_pair, set it default\n" );
840+ adc3101 -> differential_pair = 0 ;
841+ ret = 0 ;
842+ }
825843 pr_info ("%s i2c:%p\n" , __func__ , i2c );
826844 ret = snd_soc_register_codec (& i2c -> dev ,
827845 & soc_codec_dev_adc3101 , adc3101_dai , 1 );
0 commit comments