@@ -448,6 +448,7 @@ struct rt5645_priv {
448
448
struct regulator_bulk_data supplies [ARRAY_SIZE (rt5645_supply_names )];
449
449
struct rt5645_eq_param_s * eq_param ;
450
450
struct timer_list btn_check_timer ;
451
+ struct mutex jd_mutex ;
451
452
452
453
int codec_type ;
453
454
int sysclk ;
@@ -3193,6 +3194,8 @@ static int rt5645_jack_detect(struct snd_soc_component *component, int jack_inse
3193
3194
rt5645_enable_push_button_irq (component , true);
3194
3195
}
3195
3196
} else {
3197
+ if (rt5645 -> en_button_func )
3198
+ rt5645_enable_push_button_irq (component , false);
3196
3199
snd_soc_dapm_disable_pin (dapm , "Mic Det Power" );
3197
3200
snd_soc_dapm_sync (dapm );
3198
3201
rt5645 -> jack_type = SND_JACK_HEADPHONE ;
@@ -3295,6 +3298,8 @@ static void rt5645_jack_detect_work(struct work_struct *work)
3295
3298
if (!rt5645 -> component )
3296
3299
return ;
3297
3300
3301
+ mutex_lock (& rt5645 -> jd_mutex );
3302
+
3298
3303
switch (rt5645 -> pdata .jd_mode ) {
3299
3304
case 0 : /* Not using rt5645 JD */
3300
3305
if (rt5645 -> gpiod_hp_det ) {
@@ -3321,7 +3326,7 @@ static void rt5645_jack_detect_work(struct work_struct *work)
3321
3326
3322
3327
if (!val && (rt5645 -> jack_type == 0 )) { /* jack in */
3323
3328
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 ) {
3325
3330
/* for push button and jack out */
3326
3331
btn_type = 0 ;
3327
3332
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)
3377
3382
rt5645_jack_detect (rt5645 -> component , 0 );
3378
3383
}
3379
3384
3385
+ mutex_unlock (& rt5645 -> jd_mutex );
3386
+
3380
3387
snd_soc_jack_report (rt5645 -> hp_jack , report , SND_JACK_HEADPHONE );
3381
3388
snd_soc_jack_report (rt5645 -> mic_jack , report , SND_JACK_MICROPHONE );
3382
3389
if (rt5645 -> en_button_func )
@@ -4150,6 +4157,7 @@ static int rt5645_i2c_probe(struct i2c_client *i2c)
4150
4157
}
4151
4158
timer_setup (& rt5645 -> btn_check_timer , rt5645_btn_check_callback , 0 );
4152
4159
4160
+ mutex_init (& rt5645 -> jd_mutex );
4153
4161
INIT_DELAYED_WORK (& rt5645 -> jack_detect_work , rt5645_jack_detect_work );
4154
4162
INIT_DELAYED_WORK (& rt5645 -> rcclock_work , rt5645_rcclock_work );
4155
4163
0 commit comments