@@ -1984,7 +1984,12 @@ static int rt5640_set_bias_level(struct snd_soc_component *component,
19841984 snd_soc_component_write (component , RT5640_PWR_DIG2 , 0x0000 );
19851985 snd_soc_component_write (component , RT5640_PWR_VOL , 0x0000 );
19861986 snd_soc_component_write (component , RT5640_PWR_MIXER , 0x0000 );
1987- snd_soc_component_write (component , RT5640_PWR_ANLG1 , 0x0000 );
1987+ if (rt5640 -> jd_src == RT5640_JD_SRC_HDA_HEADER )
1988+ snd_soc_component_write (component , RT5640_PWR_ANLG1 ,
1989+ 0x0018 );
1990+ else
1991+ snd_soc_component_write (component , RT5640_PWR_ANLG1 ,
1992+ 0x0000 );
19881993 snd_soc_component_write (component , RT5640_PWR_ANLG2 , 0x0000 );
19891994 break ;
19901995
@@ -2393,9 +2398,15 @@ static void rt5640_jack_work(struct work_struct *work)
23932398static irqreturn_t rt5640_irq (int irq , void * data )
23942399{
23952400 struct rt5640_priv * rt5640 = data ;
2401+ int delay = 0 ;
2402+
2403+ if (rt5640 -> jd_src == RT5640_JD_SRC_HDA_HEADER ) {
2404+ cancel_delayed_work_sync (& rt5640 -> jack_work );
2405+ delay = 100 ;
2406+ }
23962407
23972408 if (rt5640 -> jack )
2398- queue_delayed_work (system_long_wq , & rt5640 -> jack_work , 0 );
2409+ queue_delayed_work (system_long_wq , & rt5640 -> jack_work , delay );
23992410
24002411 return IRQ_HANDLED ;
24012412}
@@ -2580,6 +2591,12 @@ static void rt5640_enable_hda_jack_detect(
25802591
25812592 snd_soc_component_update_bits (component , RT5640_DUMMY1 , 0x400 , 0x0 );
25822593
2594+ snd_soc_component_update_bits (component , RT5640_PWR_ANLG1 ,
2595+ RT5640_PWR_VREF2 , RT5640_PWR_VREF2 );
2596+ usleep_range (10000 , 15000 );
2597+ snd_soc_component_update_bits (component , RT5640_PWR_ANLG1 ,
2598+ RT5640_PWR_FV2 , RT5640_PWR_FV2 );
2599+
25832600 rt5640 -> jack = jack ;
25842601
25852602 ret = request_irq (rt5640 -> irq , rt5640_irq ,
@@ -2696,16 +2713,13 @@ static int rt5640_probe(struct snd_soc_component *component)
26962713
26972714 if (device_property_read_u32 (component -> dev ,
26982715 "realtek,jack-detect-source" , & val ) == 0 ) {
2699- if (val <= RT5640_JD_SRC_GPIO4 ) {
2716+ if (val <= RT5640_JD_SRC_GPIO4 )
27002717 rt5640 -> jd_src = val << RT5640_JD_SFT ;
2701- } else if (val == RT5640_JD_SRC_HDA_HEADER ) {
2718+ else if (val == RT5640_JD_SRC_HDA_HEADER )
27022719 rt5640 -> jd_src = RT5640_JD_SRC_HDA_HEADER ;
2703- snd_soc_component_update_bits (component , RT5640_DUMMY1 ,
2704- 0x0300 , 0x0 );
2705- } else {
2720+ else
27062721 dev_warn (component -> dev , "Warning: Invalid jack-detect-source value: %d, leaving jack-detect disabled\n" ,
27072722 val );
2708- }
27092723 }
27102724
27112725 if (!device_property_read_bool (component -> dev , "realtek,jack-detect-not-inverted" ))
0 commit comments