@@ -42,10 +42,12 @@ static void tas2764_reset(struct tas2764_priv *tas2764)
4242 gpiod_set_value_cansleep (tas2764 -> reset_gpio , 0 );
4343 msleep (20 );
4444 gpiod_set_value_cansleep (tas2764 -> reset_gpio , 1 );
45+ usleep_range (1000 , 2000 );
4546 }
4647
4748 snd_soc_component_write (tas2764 -> component , TAS2764_SW_RST ,
4849 TAS2764_RST );
50+ usleep_range (1000 , 2000 );
4951}
5052
5153static int tas2764_set_bias_level (struct snd_soc_component * component ,
@@ -107,8 +109,10 @@ static int tas2764_codec_resume(struct snd_soc_component *component)
107109 struct tas2764_priv * tas2764 = snd_soc_component_get_drvdata (component );
108110 int ret ;
109111
110- if (tas2764 -> sdz_gpio )
112+ if (tas2764 -> sdz_gpio ) {
111113 gpiod_set_value_cansleep (tas2764 -> sdz_gpio , 1 );
114+ usleep_range (1000 , 2000 );
115+ }
112116
113117 ret = snd_soc_component_update_bits (component , TAS2764_PWR_CTRL ,
114118 TAS2764_PWR_CTRL_MASK ,
@@ -131,7 +135,8 @@ static const char * const tas2764_ASI1_src[] = {
131135};
132136
133137static SOC_ENUM_SINGLE_DECL (
134- tas2764_ASI1_src_enum , TAS2764_TDM_CFG2 , 4 , tas2764_ASI1_src ) ;
138+ tas2764_ASI1_src_enum , TAS2764_TDM_CFG2 , TAS2764_TDM_CFG2_SCFG_SHIFT ,
139+ tas2764_ASI1_src ) ;
135140
136141static const struct snd_kcontrol_new tas2764_asi1_mux =
137142 SOC_DAPM_ENUM ("ASI1 Source" , tas2764_ASI1_src_enum );
@@ -329,20 +334,22 @@ static int tas2764_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
329334{
330335 struct snd_soc_component * component = dai -> component ;
331336 struct tas2764_priv * tas2764 = snd_soc_component_get_drvdata (component );
332- u8 tdm_rx_start_slot = 0 , asi_cfg_1 = 0 ;
333- int iface ;
337+ u8 tdm_rx_start_slot = 0 , asi_cfg_0 = 0 , asi_cfg_1 = 0 ;
334338 int ret ;
335339
336340 switch (fmt & SND_SOC_DAIFMT_INV_MASK ) {
341+ case SND_SOC_DAIFMT_NB_IF :
342+ asi_cfg_0 ^= TAS2764_TDM_CFG0_FRAME_START ;
343+ fallthrough ;
337344 case SND_SOC_DAIFMT_NB_NF :
338345 asi_cfg_1 = TAS2764_TDM_CFG1_RX_RISING ;
339346 break ;
347+ case SND_SOC_DAIFMT_IB_IF :
348+ asi_cfg_0 ^= TAS2764_TDM_CFG0_FRAME_START ;
349+ fallthrough ;
340350 case SND_SOC_DAIFMT_IB_NF :
341351 asi_cfg_1 = TAS2764_TDM_CFG1_RX_FALLING ;
342352 break ;
343- default :
344- dev_err (tas2764 -> dev , "ASI format Inverse is not found\n" );
345- return - EINVAL ;
346353 }
347354
348355 ret = snd_soc_component_update_bits (component , TAS2764_TDM_CFG1 ,
@@ -353,13 +360,13 @@ static int tas2764_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
353360
354361 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK ) {
355362 case SND_SOC_DAIFMT_I2S :
363+ asi_cfg_0 ^= TAS2764_TDM_CFG0_FRAME_START ;
364+ fallthrough ;
356365 case SND_SOC_DAIFMT_DSP_A :
357- iface = TAS2764_TDM_CFG2_SCFG_I2S ;
358366 tdm_rx_start_slot = 1 ;
359367 break ;
360368 case SND_SOC_DAIFMT_DSP_B :
361369 case SND_SOC_DAIFMT_LEFT_J :
362- iface = TAS2764_TDM_CFG2_SCFG_LEFT_J ;
363370 tdm_rx_start_slot = 0 ;
364371 break ;
365372 default :
@@ -368,14 +375,15 @@ static int tas2764_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
368375 return - EINVAL ;
369376 }
370377
371- ret = snd_soc_component_update_bits (component , TAS2764_TDM_CFG1 ,
372- TAS2764_TDM_CFG1_MASK ,
373- ( tdm_rx_start_slot << TAS2764_TDM_CFG1_51_SHIFT ) );
378+ ret = snd_soc_component_update_bits (component , TAS2764_TDM_CFG0 ,
379+ TAS2764_TDM_CFG0_FRAME_START ,
380+ asi_cfg_0 );
374381 if (ret < 0 )
375382 return ret ;
376383
377- ret = snd_soc_component_update_bits (component , TAS2764_TDM_CFG2 ,
378- TAS2764_TDM_CFG2_SCFG_MASK , iface );
384+ ret = snd_soc_component_update_bits (component , TAS2764_TDM_CFG1 ,
385+ TAS2764_TDM_CFG1_MASK ,
386+ (tdm_rx_start_slot << TAS2764_TDM_CFG1_51_SHIFT ));
379387 if (ret < 0 )
380388 return ret ;
381389
@@ -501,8 +509,10 @@ static int tas2764_codec_probe(struct snd_soc_component *component)
501509
502510 tas2764 -> component = component ;
503511
504- if (tas2764 -> sdz_gpio )
512+ if (tas2764 -> sdz_gpio ) {
505513 gpiod_set_value_cansleep (tas2764 -> sdz_gpio , 1 );
514+ usleep_range (1000 , 2000 );
515+ }
506516
507517 tas2764_reset (tas2764 );
508518
@@ -526,12 +536,12 @@ static int tas2764_codec_probe(struct snd_soc_component *component)
526536}
527537
528538static DECLARE_TLV_DB_SCALE (tas2764_digital_tlv , 1100 , 50 , 0 ) ;
529- static DECLARE_TLV_DB_SCALE (tas2764_playback_volume , -10000 , 50 , 0 ) ;
539+ static DECLARE_TLV_DB_SCALE (tas2764_playback_volume , -10050 , 50 , 1 ) ;
530540
531541static const struct snd_kcontrol_new tas2764_snd_controls [] = {
532542 SOC_SINGLE_TLV ("Speaker Volume" , TAS2764_DVC , 0 ,
533543 TAS2764_DVC_MAX , 1 , tas2764_playback_volume ),
534- SOC_SINGLE_TLV ("Amp Gain Volume" , TAS2764_CHNL_0 , 0 , 0x14 , 0 ,
544+ SOC_SINGLE_TLV ("Amp Gain Volume" , TAS2764_CHNL_0 , 1 , 0x14 , 0 ,
535545 tas2764_digital_tlv ),
536546};
537547
@@ -556,7 +566,7 @@ static const struct reg_default tas2764_reg_defaults[] = {
556566 { TAS2764_SW_RST , 0x00 },
557567 { TAS2764_PWR_CTRL , 0x1a },
558568 { TAS2764_DVC , 0x00 },
559- { TAS2764_CHNL_0 , 0x00 },
569+ { TAS2764_CHNL_0 , 0x28 },
560570 { TAS2764_TDM_CFG0 , 0x09 },
561571 { TAS2764_TDM_CFG1 , 0x02 },
562572 { TAS2764_TDM_CFG2 , 0x0a },
0 commit comments