@@ -448,6 +448,7 @@ struct rt5645_priv {
448448 struct regulator_bulk_data supplies [ARRAY_SIZE (rt5645_supply_names )];
449449 struct rt5645_eq_param_s * eq_param ;
450450 struct timer_list btn_check_timer ;
451+ struct mutex jd_mutex ;
451452
452453 int codec_type ;
453454 int sysclk ;
@@ -3193,6 +3194,8 @@ static int rt5645_jack_detect(struct snd_soc_component *component, int jack_inse
31933194 rt5645_enable_push_button_irq (component , true);
31943195 }
31953196 } else {
3197+ if (rt5645 -> en_button_func )
3198+ rt5645_enable_push_button_irq (component , false);
31963199 snd_soc_dapm_disable_pin (dapm , "Mic Det Power" );
31973200 snd_soc_dapm_sync (dapm );
31983201 rt5645 -> jack_type = SND_JACK_HEADPHONE ;
@@ -3295,6 +3298,8 @@ static void rt5645_jack_detect_work(struct work_struct *work)
32953298 if (!rt5645 -> component )
32963299 return ;
32973300
3301+ mutex_lock (& rt5645 -> jd_mutex );
3302+
32983303 switch (rt5645 -> pdata .jd_mode ) {
32993304 case 0 : /* Not using rt5645 JD */
33003305 if (rt5645 -> gpiod_hp_det ) {
@@ -3321,7 +3326,7 @@ static void rt5645_jack_detect_work(struct work_struct *work)
33213326
33223327 if (!val && (rt5645 -> jack_type == 0 )) { /* jack in */
33233328 report = rt5645_jack_detect (rt5645 -> component , 1 );
3324- } else if (!val && rt5645 -> jack_type != 0 ) {
3329+ } else if (!val && rt5645 -> jack_type == SND_JACK_HEADSET ) {
33253330 /* for push button and jack out */
33263331 btn_type = 0 ;
33273332 if (snd_soc_component_read (rt5645 -> component , RT5645_INT_IRQ_ST ) & 0x4 ) {
@@ -3377,6 +3382,8 @@ static void rt5645_jack_detect_work(struct work_struct *work)
33773382 rt5645_jack_detect (rt5645 -> component , 0 );
33783383 }
33793384
3385+ mutex_unlock (& rt5645 -> jd_mutex );
3386+
33803387 snd_soc_jack_report (rt5645 -> hp_jack , report , SND_JACK_HEADPHONE );
33813388 snd_soc_jack_report (rt5645 -> mic_jack , report , SND_JACK_MICROPHONE );
33823389 if (rt5645 -> en_button_func )
@@ -4150,6 +4157,7 @@ static int rt5645_i2c_probe(struct i2c_client *i2c)
41504157 }
41514158 timer_setup (& rt5645 -> btn_check_timer , rt5645_btn_check_callback , 0 );
41524159
4160+ mutex_init (& rt5645 -> jd_mutex );
41534161 INIT_DELAYED_WORK (& rt5645 -> jack_detect_work , rt5645_jack_detect_work );
41544162 INIT_DELAYED_WORK (& rt5645 -> rcclock_work , rt5645_rcclock_work );
41554163
0 commit comments