@@ -104,7 +104,7 @@ static const struct pll_div ac108_pll_div_list[] = {
104
104
{ 16000000 , 24576000 , 12 , 0 , 400 , 9 , 1 },
105
105
{ 19200000 , 24576000 , 15 , 0 , 410 , 9 , 1 },
106
106
{ 19680000 , 24576000 , 15 , 0 , 400 , 9 , 1 },
107
- { 24000000 , 24576000 , 9 , 0 , 205 , 9 , 1 },
107
+ { 24000000 , 24576000 , 4 , 0 , 128 , 24 , 0 }, //accurate
108
108
109
109
{ 400000 , 22579200 , 0 , 0 , 566 , 4 , 1 },
110
110
{ 512000 , 22579200 , 0 , 0 , 880 , 9 , 1 },
@@ -122,7 +122,7 @@ static const struct pll_div ac108_pll_div_list[] = {
122
122
{ 16000000 , 22579200 , 11 , 0 , 340 , 9 , 1 },
123
123
{ 19200000 , 22579200 , 13 , 0 , 330 , 9 , 1 },
124
124
{ 19680000 , 22579200 , 14 , 0 , 345 , 9 , 1 },
125
- { 24000000 , 22579200 , 16 , 0 , 320 , 9 , 1 },
125
+ { 24000000 , 22579200 , 24 , 0 , 588 , 24 , 0 }, // accurate
126
126
127
127
{ 12288000 , 24576000 , 9 , 0 , 400 , 9 , 1 }, //24576000/2
128
128
{ 11289600 , 22579200 , 9 , 0 , 400 , 9 , 1 }, //22579200/2
@@ -216,12 +216,11 @@ static int snd_ac108_get_volsw(struct snd_kcontrol *kcontrol,
216
216
if ((ret = ac10x_read (mc -> reg , & val , ac10x -> i2cmap [chip ])) < 0 )
217
217
return ret ;
218
218
219
- val = (val >> mc -> shift ) & mask ;
220
- ucontrol -> value .integer .value [0 ] = val - mc -> min ;
219
+ val = ((val >> mc -> shift ) & mask ) - mc -> min ;
221
220
if (invert ) {
222
- ucontrol -> value .integer .value [0 ] =
223
- mc -> max - ucontrol -> value .integer .value [0 ];
221
+ val = mc -> max - val ;
224
222
}
223
+ ucontrol -> value .integer .value [0 ] = val ;
225
224
return 0 ;
226
225
}
227
226
@@ -532,7 +531,7 @@ static int ac108_configure_clocking(struct ac10x_priv *ac10x, unsigned int rate)
532
531
ac108_multi_chips_update_bits (PLL_CTRL4 , 0xff << PLL_LOOPDIV_LSB , (unsigned char )ac108_pll_div .n << PLL_LOOPDIV_LSB , ac10x );
533
532
ac108_multi_chips_update_bits (PLL_CTRL3 , 0x03 << PLL_LOOPDIV_MSB , (ac108_pll_div .n >> 8 ) << PLL_LOOPDIV_MSB , ac10x );
534
533
ac108_multi_chips_update_bits (PLL_CTRL2 , 0x1f << PLL_PREDIV1 | 0x01 << PLL_PREDIV2 ,
535
- ac108_pll_div .m1 << PLL_PREDIV1 | ac108_pll_div .m2 << PLL_PREDIV2 , ac10x );
534
+ ac108_pll_div .m1 << PLL_PREDIV1 | ac108_pll_div .m2 << PLL_PREDIV2 , ac10x );
536
535
537
536
/*0x18: PLL clk lock enable*/
538
537
ac108_multi_chips_update_bits (PLL_LOCK_CTRL , 0x1 << PLL_LOCK_EN , 0x1 << PLL_LOCK_EN , ac10x );
@@ -545,7 +544,7 @@ static int ac108_configure_clocking(struct ac10x_priv *ac10x, unsigned int rate)
545
544
* pll,enable sysclk
546
545
*/
547
546
ac108_multi_chips_update_bits (SYSCLK_CTRL , 0x01 << PLLCLK_EN | 0x03 << PLLCLK_SRC | 0x01 << SYSCLK_SRC | 0x01 << SYSCLK_EN ,
548
- 0x01 << PLLCLK_EN | 0x00 << PLLCLK_SRC | 0x01 << SYSCLK_SRC | 0x01 << SYSCLK_EN , ac10x );
547
+ 0x01 << PLLCLK_EN | 0x00 << PLLCLK_SRC | 0x01 << SYSCLK_SRC | 0x01 << SYSCLK_EN , ac10x );
549
548
ac10x -> mclk = ac108_pll_div .freq_out ;
550
549
}
551
550
if (ac10x -> clk_id == SYSCLK_SRC_MCLK ) {
@@ -725,9 +724,12 @@ static int ac108_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_h
725
724
}
726
725
727
726
} else {
727
+ unsigned div ;
728
+
728
729
/*TDM mode or normal mode*/
729
- ac108_multi_chips_write (I2S_LRCK_CTRL2 , ac108_samp_res [samp_res ].real_val * channels - 1 , ac10x );
730
- ac108_multi_chips_update_bits (I2S_LRCK_CTRL1 , 0x03 << 0 , 0x00 , ac10x );
730
+ div = ac108_samp_res [samp_res ].real_val * channels - 1 ;
731
+ ac108_multi_chips_write (I2S_LRCK_CTRL2 , (div & 0xFF ), ac10x );
732
+ ac108_multi_chips_update_bits (I2S_LRCK_CTRL1 , 0x03 << 0 , (div >> 8 ) << 0 , ac10x );
731
733
}
732
734
733
735
/**
@@ -819,7 +821,7 @@ static int ac108_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) {
819
821
* 0x30:chip is master mode ,BCLK & LRCK output
820
822
*/
821
823
ac108_multi_chips_update_bits (I2S_CTRL , 0x03 << LRCK_IOEN | 0x03 << SDO1_EN | 0x1 << TXEN | 0x1 << GEN ,
822
- 0x00 << LRCK_IOEN | 0x03 << SDO1_EN | 0x1 << TXEN | 0x1 << GEN , ac10x );
824
+ 0x00 << LRCK_IOEN | 0x03 << SDO1_EN | 0x1 << TXEN | 0x1 << GEN , ac10x );
823
825
/* multi_chips: only one chip set as Master, and the others also need to set as Slave */
824
826
ac10x_update_bits (I2S_CTRL , 0x3 << LRCK_IOEN , 0x2 << LRCK_IOEN , ac10x -> i2cmap [_MASTER_INDEX ]);
825
827
break ;
@@ -869,11 +871,10 @@ static int ac108_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) {
869
871
tx_offset = 0 ;
870
872
break ;
871
873
default :
872
- ac10x -> i2s_mode = LEFT_JUSTIFIED_FORMAT ;
873
- tx_offset = 1 ;
874
- return - EINVAL ;
875
874
pr_err ("AC108 I2S format config error:%u\n\n" , fmt & SND_SOC_DAIFMT_FORMAT_MASK );
875
+ return - EINVAL ;
876
876
}
877
+
877
878
/*AC108 config BCLK&LRCK polarity*/
878
879
switch (fmt & SND_SOC_DAIFMT_INV_MASK ) {
879
880
case SND_SOC_DAIFMT_NB_NF :
@@ -912,7 +913,7 @@ static int ac108_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) {
912
913
913
914
/**
914
915
*0x31: 0: normal mode, negative edge drive and positive edge sample
915
- 1: invert mode, positive edge drive and negative edge sample
916
+ 1: invert mode, positive edge drive and negative edge sample
916
917
*/
917
918
ac108_multi_chips_update_bits (I2S_BCLK_CTRL , 0x01 << BCLK_POLARITY , brck_polarity << BCLK_POLARITY , ac10x );
918
919
/**
@@ -957,6 +958,7 @@ static int ac108_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) {
957
958
/*
958
959
* due to miss channels order in cpu_dai, we meed defer the clock starting.
959
960
*/
961
+ #if _MASTER_MULTI_CODEC == _MASTER_AC108
960
962
static int ac108_set_clock (int y_start_n_stop ) {
961
963
u8 r ;
962
964
@@ -983,6 +985,7 @@ static int ac108_set_clock(int y_start_n_stop) {
983
985
984
986
return 0 ;
985
987
}
988
+ #endif
986
989
987
990
static int ac108_trigger (struct snd_pcm_substream * substream , int cmd ,
988
991
struct snd_soc_dai * dai )
@@ -1001,18 +1004,18 @@ static int ac108_trigger(struct snd_pcm_substream *substream, int cmd,
1001
1004
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE :
1002
1005
/* disable global clock if lrck disabled */
1003
1006
ac10x_read (I2S_CTRL , & r , ac10x -> i2cmap [_MASTER_INDEX ]);
1004
- if ((r & (0x01 << LRCK_IOEN )) == 0 ) {
1007
+ if ((r & (0x02 << LRCK_IOEN )) && ( r & ( 0x01 << LRCK_IOEN )) == 0 ) {
1005
1008
/* disable global clock */
1006
1009
ac108_multi_chips_update_bits (I2S_CTRL , 0x1 << TXEN | 0x1 << GEN , 0x1 << TXEN | 0x0 << GEN , ac10x );
1010
+ }
1007
1011
1008
- /*0x21: Module clock enable<I2S, ADC digital, MIC offset Calibration, ADC analog>*/
1009
- ac108_multi_chips_write (MOD_CLK_EN , 1 << I2S | 1 << ADC_DIGITAL | 1 << MIC_OFFSET_CALIBRATION | 1 << ADC_ANALOG , ac10x );
1012
+ /*0x21: Module clock enable<I2S, ADC digital, MIC offset Calibration, ADC analog>*/
1013
+ ac108_multi_chips_write (MOD_CLK_EN , 1 << I2S | 1 << ADC_DIGITAL | 1 << MIC_OFFSET_CALIBRATION | 1 << ADC_ANALOG , ac10x );
1010
1014
1011
- /*0x22: Module reset de-asserted<I2S, ADC digital, MIC offset Calibration, ADC analog>*/
1012
- ac108_multi_chips_write (MOD_RST_CTRL , 1 << I2S | 1 << ADC_DIGITAL | 1 << MIC_OFFSET_CALIBRATION | 1 << ADC_ANALOG , ac10x );
1015
+ /*0x22: Module reset de-asserted<I2S, ADC digital, MIC offset Calibration, ADC analog>*/
1016
+ ac108_multi_chips_write (MOD_RST_CTRL , 1 << I2S | 1 << ADC_DIGITAL | 1 << MIC_OFFSET_CALIBRATION | 1 << ADC_ANALOG , ac10x );
1013
1017
1014
- /* delayed clock starting, move to simple_card_trigger() */
1015
- }
1018
+ /* delayed clock starting, move to simple_card_trigger() */
1016
1019
break ;
1017
1020
case SNDRV_PCM_TRIGGER_STOP :
1018
1021
case SNDRV_PCM_TRIGGER_SUSPEND :
@@ -1342,7 +1345,7 @@ static int ac108_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *i
1342
1345
if (of_property_read_u32 (np , "tdm-chips-count" , & val )) val = 1 ;
1343
1346
ac10x -> tdm_chips_cnt = val ;
1344
1347
1345
- pr_err (" i2c_id number : %d\n" , index );
1348
+ pr_err (" ac10x i2c_id number: %d\n" , index );
1346
1349
pr_err (" ac10x data protocol: %d\n" , ac10x -> data_protocol );
1347
1350
1348
1351
ac10x -> i2c [index ] = i2c ;
0 commit comments