@@ -822,6 +822,7 @@ static void rt5682s_jack_detect_handler(struct work_struct *work)
822822{
823823 struct rt5682s_priv * rt5682s =
824824 container_of (work , struct rt5682s_priv , jack_detect_work .work );
825+ struct snd_soc_dapm_context * dapm ;
825826 int val , btn_type ;
826827
827828 if (!rt5682s -> component || !rt5682s -> component -> card ||
@@ -832,7 +833,9 @@ static void rt5682s_jack_detect_handler(struct work_struct *work)
832833 return ;
833834 }
834835
835- mutex_lock (& rt5682s -> jdet_mutex );
836+ dapm = snd_soc_component_get_dapm (rt5682s -> component );
837+
838+ snd_soc_dapm_mutex_lock (dapm );
836839 mutex_lock (& rt5682s -> calibrate_mutex );
837840
838841 val = snd_soc_component_read (rt5682s -> component , RT5682S_AJD1_CTRL )
@@ -889,6 +892,9 @@ static void rt5682s_jack_detect_handler(struct work_struct *work)
889892 rt5682s -> irq_work_delay_time = 50 ;
890893 }
891894
895+ mutex_unlock (& rt5682s -> calibrate_mutex );
896+ snd_soc_dapm_mutex_unlock (dapm );
897+
892898 snd_soc_jack_report (rt5682s -> hs_jack , rt5682s -> jack_type ,
893899 SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
894900 SND_JACK_BTN_2 | SND_JACK_BTN_3 );
@@ -898,24 +904,16 @@ static void rt5682s_jack_detect_handler(struct work_struct *work)
898904 schedule_delayed_work (& rt5682s -> jd_check_work , 0 );
899905 else
900906 cancel_delayed_work_sync (& rt5682s -> jd_check_work );
901-
902- mutex_unlock (& rt5682s -> calibrate_mutex );
903- mutex_unlock (& rt5682s -> jdet_mutex );
904907}
905908
906909static void rt5682s_jd_check_handler (struct work_struct * work )
907910{
908911 struct rt5682s_priv * rt5682s =
909912 container_of (work , struct rt5682s_priv , jd_check_work .work );
910913
911- if (snd_soc_component_read (rt5682s -> component , RT5682S_AJD1_CTRL )
912- & RT5682S_JDH_RS_MASK ) {
914+ if (snd_soc_component_read (rt5682s -> component , RT5682S_AJD1_CTRL ) & RT5682S_JDH_RS_MASK ) {
913915 /* jack out */
914- rt5682s -> jack_type = rt5682s_headset_detect (rt5682s -> component , 0 );
915-
916- snd_soc_jack_report (rt5682s -> hs_jack , rt5682s -> jack_type ,
917- SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
918- SND_JACK_BTN_2 | SND_JACK_BTN_3 );
916+ schedule_delayed_work (& rt5682s -> jack_detect_work , 0 );
919917 } else {
920918 schedule_delayed_work (& rt5682s -> jd_check_work , 500 );
921919 }
@@ -1323,7 +1321,6 @@ static int rt5682s_hp_amp_event(struct snd_soc_dapm_widget *w,
13231321 struct snd_kcontrol * kcontrol , int event )
13241322{
13251323 struct snd_soc_component * component = snd_soc_dapm_to_component (w -> dapm );
1326- struct rt5682s_priv * rt5682s = snd_soc_component_get_drvdata (component );
13271324
13281325 switch (event ) {
13291326 case SND_SOC_DAPM_POST_PMU :
@@ -1339,17 +1336,13 @@ static int rt5682s_hp_amp_event(struct snd_soc_dapm_widget *w,
13391336 snd_soc_component_write (component , RT5682S_BIAS_CUR_CTRL_11 , 0x6666 );
13401337 snd_soc_component_write (component , RT5682S_BIAS_CUR_CTRL_12 , 0xa82a );
13411338
1342- mutex_lock (& rt5682s -> jdet_mutex );
1343-
13441339 snd_soc_component_update_bits (component , RT5682S_HP_CTRL_2 ,
13451340 RT5682S_HPO_L_PATH_MASK | RT5682S_HPO_R_PATH_MASK |
13461341 RT5682S_HPO_SEL_IP_EN_SW , RT5682S_HPO_L_PATH_EN |
13471342 RT5682S_HPO_R_PATH_EN | RT5682S_HPO_IP_EN_GATING );
13481343 usleep_range (5000 , 10000 );
13491344 snd_soc_component_update_bits (component , RT5682S_HP_AMP_DET_CTL_1 ,
13501345 RT5682S_CP_SW_SIZE_MASK , RT5682S_CP_SW_SIZE_L | RT5682S_CP_SW_SIZE_S );
1351-
1352- mutex_unlock (& rt5682s -> jdet_mutex );
13531346 break ;
13541347
13551348 case SND_SOC_DAPM_POST_PMD :
@@ -3103,7 +3096,6 @@ static int rt5682s_i2c_probe(struct i2c_client *i2c,
31033096
31043097 mutex_init (& rt5682s -> calibrate_mutex );
31053098 mutex_init (& rt5682s -> sar_mutex );
3106- mutex_init (& rt5682s -> jdet_mutex );
31073099 rt5682s_calibrate (rt5682s );
31083100
31093101 regmap_update_bits (rt5682s -> regmap , RT5682S_MICBIAS_2 ,
0 commit comments