@@ -45,6 +45,82 @@ struct es8326_priv {
45
45
int jack_remove_retry ;
46
46
};
47
47
48
+ static int es8326_crosstalk1_get (struct snd_kcontrol * kcontrol ,
49
+ struct snd_ctl_elem_value * ucontrol )
50
+ {
51
+ struct snd_soc_component * component = snd_kcontrol_chip (kcontrol );
52
+ struct es8326_priv * es8326 = snd_soc_component_get_drvdata (component );
53
+ unsigned int crosstalk_h , crosstalk_l ;
54
+ unsigned int crosstalk ;
55
+
56
+ regmap_read (es8326 -> regmap , ES8326_DAC_RAMPRATE , & crosstalk_h );
57
+ regmap_read (es8326 -> regmap , ES8326_DAC_CROSSTALK , & crosstalk_l );
58
+ crosstalk_h &= 0x20 ;
59
+ crosstalk_l &= 0xf0 ;
60
+ crosstalk = crosstalk_h >> 1 | crosstalk_l >> 4 ;
61
+ ucontrol -> value .integer .value [0 ] = crosstalk ;
62
+
63
+ return 0 ;
64
+ }
65
+
66
+ static int es8326_crosstalk1_set (struct snd_kcontrol * kcontrol ,
67
+ struct snd_ctl_elem_value * ucontrol )
68
+ {
69
+ struct snd_soc_component * component = snd_kcontrol_chip (kcontrol );
70
+ struct es8326_priv * es8326 = snd_soc_component_get_drvdata (component );
71
+ unsigned int crosstalk_h , crosstalk_l ;
72
+ unsigned int crosstalk ;
73
+
74
+ crosstalk = ucontrol -> value .integer .value [0 ];
75
+ regmap_read (es8326 -> regmap , ES8326_DAC_CROSSTALK , & crosstalk_l );
76
+ crosstalk_h = (crosstalk & 0x10 ) << 1 ;
77
+ crosstalk_l &= 0x0f ;
78
+ crosstalk_l |= (crosstalk & 0x0f ) << 4 ;
79
+ regmap_update_bits (es8326 -> regmap , ES8326_DAC_RAMPRATE ,
80
+ 0x20 , crosstalk_h );
81
+ regmap_write (es8326 -> regmap , ES8326_DAC_CROSSTALK , crosstalk_l );
82
+
83
+ return 0 ;
84
+ }
85
+
86
+ static int es8326_crosstalk2_get (struct snd_kcontrol * kcontrol ,
87
+ struct snd_ctl_elem_value * ucontrol )
88
+ {
89
+ struct snd_soc_component * component = snd_kcontrol_chip (kcontrol );
90
+ struct es8326_priv * es8326 = snd_soc_component_get_drvdata (component );
91
+ unsigned int crosstalk_h , crosstalk_l ;
92
+ unsigned int crosstalk ;
93
+
94
+ regmap_read (es8326 -> regmap , ES8326_DAC_RAMPRATE , & crosstalk_h );
95
+ regmap_read (es8326 -> regmap , ES8326_DAC_CROSSTALK , & crosstalk_l );
96
+ crosstalk_h &= 0x10 ;
97
+ crosstalk_l &= 0x0f ;
98
+ crosstalk = crosstalk_h | crosstalk_l ;
99
+ ucontrol -> value .integer .value [0 ] = crosstalk ;
100
+
101
+ return 0 ;
102
+ }
103
+
104
+ static int es8326_crosstalk2_set (struct snd_kcontrol * kcontrol ,
105
+ struct snd_ctl_elem_value * ucontrol )
106
+ {
107
+ struct snd_soc_component * component = snd_kcontrol_chip (kcontrol );
108
+ struct es8326_priv * es8326 = snd_soc_component_get_drvdata (component );
109
+ unsigned int crosstalk_h , crosstalk_l ;
110
+ unsigned int crosstalk ;
111
+
112
+ crosstalk = ucontrol -> value .integer .value [0 ];
113
+ regmap_read (es8326 -> regmap , ES8326_DAC_CROSSTALK , & crosstalk_l );
114
+ crosstalk_h = crosstalk & 0x10 ;
115
+ crosstalk_l &= 0xf0 ;
116
+ crosstalk_l |= crosstalk & 0x0f ;
117
+ regmap_update_bits (es8326 -> regmap , ES8326_DAC_RAMPRATE ,
118
+ 0x10 , crosstalk_h );
119
+ regmap_write (es8326 -> regmap , ES8326_DAC_CROSSTALK , crosstalk_l );
120
+
121
+ return 0 ;
122
+ }
123
+
48
124
static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE (dac_vol_tlv , -9550 , 50 , 0 ) ;
49
125
static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE (adc_vol_tlv , -9550 , 50 , 0 ) ;
50
126
static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE (adc_analog_pga_tlv , 0 , 300 , 0 ) ;
@@ -102,6 +178,10 @@ static const struct snd_kcontrol_new es8326_snd_controls[] = {
102
178
SOC_SINGLE_TLV ("ALC Capture Target Level" , ES8326_ALC_LEVEL ,
103
179
0 , 0x0f , 0 , drc_target_tlv ),
104
180
181
+ SOC_SINGLE_EXT ("CROSSTALK1" , SND_SOC_NOPM , 0 , 31 , 0 ,
182
+ es8326_crosstalk1_get , es8326_crosstalk1_set ),
183
+ SOC_SINGLE_EXT ("CROSSTALK2" , SND_SOC_NOPM , 0 , 31 , 0 ,
184
+ es8326_crosstalk2_get , es8326_crosstalk2_set ),
105
185
};
106
186
107
187
static const struct snd_soc_dapm_widget es8326_dapm_widgets [] = {
@@ -117,12 +197,6 @@ static const struct snd_soc_dapm_widget es8326_dapm_widgets[] = {
117
197
SND_SOC_DAPM_AIF_OUT ("I2S OUT" , "I2S1 Capture" , 0 , SND_SOC_NOPM , 0 , 0 ),
118
198
SND_SOC_DAPM_AIF_IN ("I2S IN" , "I2S1 Playback" , 0 , SND_SOC_NOPM , 0 , 0 ),
119
199
120
- /* ADC Digital Mute */
121
- SND_SOC_DAPM_PGA ("ADC L1" , ES8326_ADC_MUTE , 0 , 1 , NULL , 0 ),
122
- SND_SOC_DAPM_PGA ("ADC R1" , ES8326_ADC_MUTE , 1 , 1 , NULL , 0 ),
123
- SND_SOC_DAPM_PGA ("ADC L2" , ES8326_ADC_MUTE , 2 , 1 , NULL , 0 ),
124
- SND_SOC_DAPM_PGA ("ADC R2" , ES8326_ADC_MUTE , 3 , 1 , NULL , 0 ),
125
-
126
200
/* Analog Power Supply*/
127
201
SND_SOC_DAPM_DAC ("Right DAC" , NULL , ES8326_ANA_PDN , 0 , 1 ),
128
202
SND_SOC_DAPM_DAC ("Left DAC" , NULL , ES8326_ANA_PDN , 1 , 1 ),
@@ -142,15 +216,10 @@ static const struct snd_soc_dapm_widget es8326_dapm_widgets[] = {
142
216
};
143
217
144
218
static const struct snd_soc_dapm_route es8326_dapm_routes [] = {
145
- {"ADC L1" , NULL , "MIC1" },
146
- {"ADC R1" , NULL , "MIC2" },
147
- {"ADC L2" , NULL , "MIC3" },
148
- {"ADC R2" , NULL , "MIC4" },
149
-
150
- {"ADC L" , NULL , "ADC L1" },
151
- {"ADC R" , NULL , "ADC R1" },
152
- {"ADC L" , NULL , "ADC L2" },
153
- {"ADC R" , NULL , "ADC R2" },
219
+ {"ADC L" , NULL , "MIC1" },
220
+ {"ADC R" , NULL , "MIC2" },
221
+ {"ADC L" , NULL , "MIC3" },
222
+ {"ADC R" , NULL , "MIC4" },
154
223
155
224
{"I2S OUT" , NULL , "ADC L" },
156
225
{"I2S OUT" , NULL , "ADC R" },
@@ -440,10 +509,16 @@ static int es8326_mute(struct snd_soc_dai *dai, int mute, int direction)
440
509
unsigned int offset_l , offset_r ;
441
510
442
511
if (mute ) {
443
- regmap_write (es8326 -> regmap , ES8326_HP_CAL , ES8326_HP_OFF );
444
- regmap_update_bits (es8326 -> regmap , ES8326_DAC_MUTE ,
445
- ES8326_MUTE_MASK , ES8326_MUTE );
446
- regmap_write (es8326 -> regmap , ES8326_HP_DRIVER , 0xf0 );
512
+ if (direction == SNDRV_PCM_STREAM_PLAYBACK ) {
513
+ regmap_write (es8326 -> regmap , ES8326_HP_CAL , ES8326_HP_OFF );
514
+ regmap_update_bits (es8326 -> regmap , ES8326_DAC_MUTE ,
515
+ ES8326_MUTE_MASK , ES8326_MUTE );
516
+ regmap_update_bits (es8326 -> regmap , ES8326_HP_DRIVER_REF ,
517
+ 0x30 , 0x00 );
518
+ } else {
519
+ regmap_update_bits (es8326 -> regmap , ES8326_ADC_MUTE ,
520
+ 0x0F , 0x0F );
521
+ }
447
522
} else {
448
523
if (!es8326 -> calibrated ) {
449
524
regmap_write (es8326 -> regmap , ES8326_HP_CAL , ES8326_HP_FORCE_CAL );
@@ -456,11 +531,22 @@ static int es8326_mute(struct snd_soc_dai *dai, int mute, int direction)
456
531
regmap_write (es8326 -> regmap , ES8326_HPR_OFFSET_INI , offset_r );
457
532
es8326 -> calibrated = true;
458
533
}
459
- regmap_write (es8326 -> regmap , ES8326_HP_DRIVER , 0xa1 );
460
- regmap_write (es8326 -> regmap , ES8326_HP_VOL , 0x91 );
461
- regmap_write (es8326 -> regmap , ES8326_HP_CAL , ES8326_HP_ON );
462
- regmap_update_bits (es8326 -> regmap , ES8326_DAC_MUTE ,
463
- ES8326_MUTE_MASK , ~(ES8326_MUTE ));
534
+ if (direction == SNDRV_PCM_STREAM_PLAYBACK ) {
535
+ regmap_update_bits (es8326 -> regmap , ES8326_DAC_DSM , 0x01 , 0x01 );
536
+ usleep_range (1000 , 5000 );
537
+ regmap_update_bits (es8326 -> regmap , ES8326_DAC_DSM , 0x01 , 0x00 );
538
+ usleep_range (1000 , 5000 );
539
+ regmap_update_bits (es8326 -> regmap , ES8326_HP_DRIVER_REF , 0x30 , 0x20 );
540
+ regmap_update_bits (es8326 -> regmap , ES8326_HP_DRIVER_REF , 0x30 , 0x30 );
541
+ regmap_write (es8326 -> regmap , ES8326_HP_DRIVER , 0xa1 );
542
+ regmap_write (es8326 -> regmap , ES8326_HP_CAL , ES8326_HP_ON );
543
+ regmap_update_bits (es8326 -> regmap , ES8326_DAC_MUTE ,
544
+ ES8326_MUTE_MASK , ~(ES8326_MUTE ));
545
+ } else {
546
+ msleep (300 );
547
+ regmap_update_bits (es8326 -> regmap , ES8326_ADC_MUTE ,
548
+ 0x0F , 0x00 );
549
+ }
464
550
}
465
551
return 0 ;
466
552
}
@@ -477,23 +563,20 @@ static int es8326_set_bias_level(struct snd_soc_component *codec,
477
563
if (ret )
478
564
return ret ;
479
565
480
- regmap_update_bits (es8326 -> regmap , ES8326_DAC_DSM , 0x01 , 0x00 );
566
+ regmap_update_bits (es8326 -> regmap , ES8326_RESET , 0x02 , 0x02 );
567
+ usleep_range (5000 , 10000 );
481
568
regmap_write (es8326 -> regmap , ES8326_INTOUT_IO , es8326 -> interrupt_clk );
482
569
regmap_write (es8326 -> regmap , ES8326_SDINOUT1_IO ,
483
570
(ES8326_IO_DMIC_CLK << ES8326_SDINOUT1_SHIFT ));
484
- regmap_write (es8326 -> regmap , ES8326_VMIDSEL , 0x0E );
485
571
regmap_write (es8326 -> regmap , ES8326_PGA_PDN , 0x40 );
486
572
regmap_write (es8326 -> regmap , ES8326_ANA_PDN , 0x00 );
487
573
regmap_update_bits (es8326 -> regmap , ES8326_CLK_CTL , 0x20 , 0x20 );
488
-
489
- regmap_update_bits (es8326 -> regmap , ES8326_RESET ,
490
- ES8326_CSM_ON , ES8326_CSM_ON );
574
+ regmap_update_bits (es8326 -> regmap , ES8326_RESET , 0x02 , 0x00 );
491
575
break ;
492
576
case SND_SOC_BIAS_PREPARE :
493
577
break ;
494
578
case SND_SOC_BIAS_STANDBY :
495
579
regmap_write (es8326 -> regmap , ES8326_ANA_PDN , 0x3b );
496
- regmap_write (es8326 -> regmap , ES8326_VMIDSEL , 0x00 );
497
580
regmap_update_bits (es8326 -> regmap , ES8326_CLK_CTL , 0x20 , 0x00 );
498
581
regmap_write (es8326 -> regmap , ES8326_SDINOUT1_IO , ES8326_IO_INPUT );
499
582
break ;
@@ -513,7 +596,7 @@ static const struct snd_soc_dai_ops es8326_ops = {
513
596
.set_fmt = es8326_set_dai_fmt ,
514
597
.set_sysclk = es8326_set_dai_sysclk ,
515
598
.mute_stream = es8326_mute ,
516
- .no_capture_mute = 1 ,
599
+ .no_capture_mute = 0 ,
517
600
};
518
601
519
602
static struct snd_soc_dai_driver es8326_dai = {
@@ -672,6 +755,8 @@ static void es8326_jack_detect_handler(struct work_struct *work)
672
755
es8326 -> hp = 0 ;
673
756
}
674
757
regmap_update_bits (es8326 -> regmap , ES8326_HPDET_TYPE , 0x03 , 0x01 );
758
+ regmap_write (es8326 -> regmap , ES8326_SYS_BIAS , 0x0a );
759
+ regmap_update_bits (es8326 -> regmap , ES8326_HP_DRIVER_REF , 0x0f , 0x03 );
675
760
/*
676
761
* Inverted HPJACK_POL bit to trigger one IRQ to double check HP Removal event
677
762
*/
@@ -695,8 +780,11 @@ static void es8326_jack_detect_handler(struct work_struct *work)
695
780
* Don't report jack status.
696
781
*/
697
782
regmap_update_bits (es8326 -> regmap , ES8326_HPDET_TYPE , 0x03 , 0x01 );
783
+ es8326_enable_micbias (es8326 -> component );
698
784
usleep_range (50000 , 70000 );
699
785
regmap_update_bits (es8326 -> regmap , ES8326_HPDET_TYPE , 0x03 , 0x00 );
786
+ regmap_write (es8326 -> regmap , ES8326_SYS_BIAS , 0x1f );
787
+ regmap_update_bits (es8326 -> regmap , ES8326_HP_DRIVER_REF , 0x0f , 0x08 );
700
788
queue_delayed_work (system_wq , & es8326 -> jack_detect_work ,
701
789
msecs_to_jiffies (400 ));
702
790
es8326 -> hp = 1 ;
@@ -736,13 +824,10 @@ static void es8326_jack_detect_handler(struct work_struct *work)
736
824
static irqreturn_t es8326_irq (int irq , void * dev_id )
737
825
{
738
826
struct es8326_priv * es8326 = dev_id ;
739
- struct snd_soc_component * comp = es8326 -> component ;
740
827
741
828
if (!es8326 -> jack )
742
829
goto out ;
743
830
744
- es8326_enable_micbias (comp );
745
-
746
831
if (es8326 -> jack -> status & SND_JACK_HEADSET )
747
832
queue_delayed_work (system_wq , & es8326 -> jack_detect_work ,
748
833
msecs_to_jiffies (10 ));
@@ -766,14 +851,14 @@ static int es8326_calibrate(struct snd_soc_component *component)
766
851
if ((es8326 -> version == ES8326_VERSION_B ) && (es8326 -> calibrated == false)) {
767
852
dev_dbg (component -> dev , "ES8326_VERSION_B, calibrating\n" );
768
853
regmap_write (es8326 -> regmap , ES8326_CLK_INV , 0xc0 );
769
- regmap_write (es8326 -> regmap , ES8326_CLK_DIV1 , 0x01 );
854
+ regmap_write (es8326 -> regmap , ES8326_CLK_DIV1 , 0x03 );
770
855
regmap_write (es8326 -> regmap , ES8326_CLK_DLL , 0x30 );
771
856
regmap_write (es8326 -> regmap , ES8326_CLK_MUX , 0xed );
772
857
regmap_write (es8326 -> regmap , ES8326_CLK_DAC_SEL , 0x08 );
773
858
regmap_write (es8326 -> regmap , ES8326_CLK_TRI , 0xc1 );
774
859
regmap_write (es8326 -> regmap , ES8326_DAC_MUTE , 0x03 );
775
860
regmap_write (es8326 -> regmap , ES8326_ANA_VSEL , 0x7f );
776
- regmap_write (es8326 -> regmap , ES8326_VMIDLOW , 0x03 );
861
+ regmap_write (es8326 -> regmap , ES8326_VMIDLOW , 0x23 );
777
862
regmap_write (es8326 -> regmap , ES8326_DAC2HPMIX , 0x88 );
778
863
usleep_range (15000 , 20000 );
779
864
regmap_write (es8326 -> regmap , ES8326_HP_OFFSET_CAL , 0x8c );
@@ -814,28 +899,29 @@ static int es8326_resume(struct snd_soc_component *component)
814
899
/* reset internal clock state */
815
900
regmap_write (es8326 -> regmap , ES8326_RESET , 0x1f );
816
901
regmap_write (es8326 -> regmap , ES8326_VMIDSEL , 0x0E );
902
+ regmap_write (es8326 -> regmap , ES8326_ANA_LP , 0xf0 );
817
903
usleep_range (10000 , 15000 );
818
904
regmap_write (es8326 -> regmap , ES8326_HPJACK_TIMER , 0xe9 );
819
- regmap_write (es8326 -> regmap , ES8326_ANA_MICBIAS , 0x4b );
905
+ regmap_write (es8326 -> regmap , ES8326_ANA_MICBIAS , 0xcb );
820
906
/* set headphone default type and detect pin */
821
907
regmap_write (es8326 -> regmap , ES8326_HPDET_TYPE , 0x83 );
822
908
regmap_write (es8326 -> regmap , ES8326_CLK_RESAMPLE , 0x05 );
823
- regmap_write (es8326 -> regmap , ES8326_HP_MISC , 0x30 );
824
909
825
910
/* set internal oscillator as clock source of headpone cp */
826
911
regmap_write (es8326 -> regmap , ES8326_CLK_DIV_CPC , 0x89 );
827
912
regmap_write (es8326 -> regmap , ES8326_CLK_CTL , ES8326_CLK_ON );
828
913
/* clock manager reset release */
829
914
regmap_write (es8326 -> regmap , ES8326_RESET , 0x17 );
830
915
/* set headphone detection as half scan mode */
831
- regmap_write (es8326 -> regmap , ES8326_HP_MISC , 0x30 );
916
+ regmap_write (es8326 -> regmap , ES8326_HP_MISC , 0x3d );
832
917
regmap_write (es8326 -> regmap , ES8326_PULLUP_CTL , 0x00 );
833
918
834
919
/* enable headphone driver */
920
+ regmap_write (es8326 -> regmap , ES8326_HP_VOL , 0xc4 );
835
921
regmap_write (es8326 -> regmap , ES8326_HP_DRIVER , 0xa7 );
836
922
usleep_range (2000 , 5000 );
837
- regmap_write (es8326 -> regmap , ES8326_HP_DRIVER_REF , 0xa3 );
838
- regmap_write (es8326 -> regmap , ES8326_HP_DRIVER_REF , 0xb3 );
923
+ regmap_write (es8326 -> regmap , ES8326_HP_DRIVER_REF , 0x23 );
924
+ regmap_write (es8326 -> regmap , ES8326_HP_DRIVER_REF , 0x33 );
839
925
regmap_write (es8326 -> regmap , ES8326_HP_DRIVER , 0xa1 );
840
926
841
927
regmap_write (es8326 -> regmap , ES8326_CLK_INV , 0x00 );
@@ -844,6 +930,8 @@ static int es8326_resume(struct snd_soc_component *component)
844
930
regmap_write (es8326 -> regmap , ES8326_CLK_CAL_TIME , 0x00 );
845
931
/* calibrate for B version */
846
932
es8326_calibrate (component );
933
+ regmap_write (es8326 -> regmap , ES8326_DAC_CROSSTALK , 0xaa );
934
+ regmap_write (es8326 -> regmap , ES8326_DAC_RAMPRATE , 0x00 );
847
935
/* turn off headphone out */
848
936
regmap_write (es8326 -> regmap , ES8326_HP_CAL , 0x00 );
849
937
/* set ADC and DAC in low power mode */
@@ -856,6 +944,14 @@ static int es8326_resume(struct snd_soc_component *component)
856
944
regmap_write (es8326 -> regmap , ES8326_DAC_DSM , 0x08 );
857
945
regmap_write (es8326 -> regmap , ES8326_DAC_VPPSCALE , 0x15 );
858
946
947
+ regmap_write (es8326 -> regmap , ES8326_HPDET_TYPE , 0x80 |
948
+ ((es8326 -> version == ES8326_VERSION_B ) ?
949
+ (ES8326_HP_DET_SRC_PIN9 | es8326 -> jack_pol ) :
950
+ (ES8326_HP_DET_SRC_PIN9 | es8326 -> jack_pol | 0x04 )));
951
+ usleep_range (5000 , 10000 );
952
+ es8326_enable_micbias (es8326 -> component );
953
+ usleep_range (50000 , 70000 );
954
+ regmap_update_bits (es8326 -> regmap , ES8326_HPDET_TYPE , 0x03 , 0x00 );
859
955
regmap_write (es8326 -> regmap , ES8326_INT_SOURCE ,
860
956
(ES8326_INT_SRC_PIN9 | ES8326_INT_SRC_BUTTON ));
861
957
regmap_write (es8326 -> regmap , ES8326_INTOUT_IO ,
@@ -864,19 +960,15 @@ static int es8326_resume(struct snd_soc_component *component)
864
960
(ES8326_IO_DMIC_CLK << ES8326_SDINOUT1_SHIFT ));
865
961
regmap_write (es8326 -> regmap , ES8326_SDINOUT23_IO , ES8326_IO_INPUT );
866
962
867
- regmap_write (es8326 -> regmap , ES8326_ANA_PDN , 0x3b );
963
+ regmap_write (es8326 -> regmap , ES8326_ANA_PDN , 0x00 );
868
964
regmap_write (es8326 -> regmap , ES8326_RESET , ES8326_CSM_ON );
869
965
regmap_update_bits (es8326 -> regmap , ES8326_PGAGAIN , ES8326_MIC_SEL_MASK ,
870
966
ES8326_MIC1_SEL );
871
967
872
968
regmap_update_bits (es8326 -> regmap , ES8326_DAC_MUTE , ES8326_MUTE_MASK ,
873
969
ES8326_MUTE );
874
970
875
- regmap_write (es8326 -> regmap , ES8326_HPDET_TYPE , 0x80 |
876
- ((es8326 -> version == ES8326_VERSION_B ) ?
877
- (ES8326_HP_DET_SRC_PIN9 | es8326 -> jack_pol ) :
878
- (ES8326_HP_DET_SRC_PIN9 | es8326 -> jack_pol | 0x04 )));
879
- regmap_write (es8326 -> regmap , ES8326_HP_VOL , 0x11 );
971
+ regmap_write (es8326 -> regmap , ES8326_ADC_MUTE , 0x0f );
880
972
881
973
es8326 -> jack_remove_retry = 0 ;
882
974
es8326 -> hp = 0 ;
0 commit comments