@@ -243,21 +243,14 @@ static int late_enable_dac(struct snd_soc_codec* codec, int event) {
243
243
ac10x -> dac_enable ++ ;
244
244
break ;
245
245
case SND_SOC_DAPM_POST_PMD :
246
- #if 0
247
- if (ac10x -> dac_enable > 0 ){
248
- ac10x -> dac_enable -- ;
249
- #else
250
- {
251
- #endif
252
- if (ac10x -> dac_enable != 0 ){
253
- ac10x -> dac_enable = 0 ;
254
-
255
- ac101_update_bits (codec , DAC_DIG_CTRL , (0x1 <<ENHPF ),(0x0 <<ENHPF ));
256
- ac101_update_bits (codec , DAC_DIG_CTRL , (0x1 <<ENDA ), (0x0 <<ENDA ));
257
- /*disable dac module clk*/
258
- ac101_update_bits (codec , MOD_CLK_ENA , (0x1 <<MOD_CLK_DAC_DIG ), (0x0 <<MOD_CLK_DAC_DIG ));
259
- ac101_update_bits (codec , MOD_RST_CTRL , (0x1 <<MOD_RESET_DAC_DIG ), (0x0 <<MOD_RESET_DAC_DIG ));
260
- }
246
+ if (ac10x -> dac_enable != 0 ){
247
+ ac10x -> dac_enable = 0 ;
248
+
249
+ ac101_update_bits (codec , DAC_DIG_CTRL , (0x1 <<ENHPF ),(0x0 <<ENHPF ));
250
+ ac101_update_bits (codec , DAC_DIG_CTRL , (0x1 <<ENDA ), (0x0 <<ENDA ));
251
+ /*disable dac module clk*/
252
+ ac101_update_bits (codec , MOD_CLK_ENA , (0x1 <<MOD_CLK_DAC_DIG ), (0x0 <<MOD_CLK_DAC_DIG ));
253
+ ac101_update_bits (codec , MOD_RST_CTRL , (0x1 <<MOD_RESET_DAC_DIG ), (0x0 <<MOD_RESET_DAC_DIG ));
261
254
}
262
255
break ;
263
256
}
@@ -543,6 +536,30 @@ static const unsigned ac101_bclkdivs[] = {
543
536
128 , 192 , 0 , 0 ,
544
537
};
545
538
539
+ static int ac101_aif_play (struct ac10x_priv * ac10x ) {
540
+ struct snd_soc_codec * codec = ac10x -> codec ;
541
+
542
+ late_enable_dac (codec , SND_SOC_DAPM_PRE_PMU );
543
+ ac101_headphone_event (codec , SND_SOC_DAPM_POST_PMU );
544
+ if (drc_used ) {
545
+ drc_enable (codec , 1 );
546
+ }
547
+
548
+ /* Enable Left & Right Speaker */
549
+ ac101_update_bits (codec , SPKOUT_CTRL , (0x1 << LSPK_EN ) | (0x1 << RSPK_EN ), (0x1 << LSPK_EN ) | (0x1 << RSPK_EN ));
550
+ if (ac10x -> gpiod_spk_amp_gate ) {
551
+ gpiod_set_value (ac10x -> gpiod_spk_amp_gate , 1 );
552
+ }
553
+ return 0 ;
554
+ }
555
+
556
+ static void ac10x_work_aif_play (struct work_struct * work ) {
557
+ struct ac10x_priv * ac10x = container_of (work , struct ac10x_priv , dlywork .work );
558
+
559
+ ac101_aif_play (ac10x );
560
+ return ;
561
+ }
562
+
546
563
int ac101_aif_mute (struct snd_soc_dai * codec_dai , int mute )
547
564
{
548
565
struct snd_soc_codec * codec = codec_dai -> codec ;
@@ -555,22 +572,17 @@ int ac101_aif_mute(struct snd_soc_dai *codec_dai, int mute)
555
572
if (!mute ) {
556
573
#if _MASTER_MULTI_CODEC != _MASTER_AC101
557
574
/* enable global clock */
558
- ac101_aif1clk (static_ac10x -> codec , SND_SOC_DAPM_PRE_PMU );
575
+ ac10x -> aif1_clken = 0 ;
576
+ ac101_aif1clk (codec , SND_SOC_DAPM_PRE_PMU );
577
+ ac101_aif_play (ac10x );
578
+ #else
579
+ schedule_delayed_work (& ac10x -> dlywork , msecs_to_jiffies (50 ));
559
580
#endif
560
-
561
- late_enable_dac (codec , SND_SOC_DAPM_PRE_PMU );
562
- ac101_headphone_event (codec , SND_SOC_DAPM_POST_PMU );
563
- if (drc_used ) {
564
- drc_enable (codec , 1 );
565
- }
566
-
567
- /* Enable Left & Right Speaker */
568
- ac101_update_bits (codec , SPKOUT_CTRL , (0x1 << LSPK_EN ) | (0x1 << RSPK_EN ), (0x1 << LSPK_EN ) | (0x1 << RSPK_EN ));
569
- if (ac10x -> gpiod_spk_amp_gate ) {
570
- gpiod_set_value (ac10x -> gpiod_spk_amp_gate , 1 );
571
- }
572
-
573
581
} else {
582
+ #if _MASTER_MULTI_CODEC == _MASTER_AC101
583
+ cancel_delayed_work_sync (& ac10x -> dlywork );
584
+ #endif
585
+
574
586
if (ac10x -> gpiod_spk_amp_gate ) {
575
587
gpiod_set_value (ac10x -> gpiod_spk_amp_gate , 1 );
576
588
}
@@ -603,6 +615,8 @@ void ac101_aif_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai
603
615
if (!codec_dai -> active ) {
604
616
ac10x -> aif1_clken = 1 ;
605
617
ac101_aif1clk (codec , SND_SOC_DAPM_POST_PMD );
618
+ } else {
619
+ ac101_aif1clk (codec , SND_SOC_DAPM_PRE_PMU );
606
620
}
607
621
}
608
622
@@ -1013,6 +1027,7 @@ int ac101_codec_probe(struct snd_soc_codec *codec)
1013
1027
}
1014
1028
ac10x -> codec = codec ;
1015
1029
1030
+ INIT_DELAYED_WORK (& ac10x -> dlywork , ac10x_work_aif_play );
1016
1031
INIT_WORK (& ac10x -> codec_resume , codec_resume_work );
1017
1032
ac10x -> dac_enable = 0 ;
1018
1033
ac10x -> aif1_clken = 0 ;
0 commit comments