input: touchscreen: goodix_berlin_driver: Introduce a power workqueue for suspend/resume

To avoid blocking the system wide resume for too long while sending
commands and waiting for the touchscreen.

Change-Id: I8ac0ca80c359cc65613245abe2c32de81b459ae0
This commit is contained in:
Arian 2024-10-13 23:16:54 +02:00 committed by Jens Reidel
parent 31c2ee898d
commit 8b03e5f498
No known key found for this signature in database
GPG Key ID: 23C1E5F512C12303
2 changed files with 37 additions and 4 deletions

View File

@ -1871,6 +1871,13 @@ static int goodix_ts_suspend(struct goodix_ts_core *core_data)
return 0;
}
static void goodix_suspend_work(struct work_struct *work)
{
struct goodix_ts_core *core_data = container_of(work, struct goodix_ts_core, suspend_work);
goodix_ts_suspend(core_data);
}
/**
* goodix_ts_resume - Touchscreen resume function
* Called by PM/FB/EARLYSUSPEN module to wakeup device
@ -1937,6 +1944,13 @@ static int goodix_ts_resume(struct goodix_ts_core *core_data)
return 0;
}
static void goodix_resume_work(struct work_struct *work)
{
struct goodix_ts_core *core_data = container_of(work, struct goodix_ts_core, resume_work);
goodix_ts_resume(core_data);
}
#if defined(CONFIG_DRM)
static void goodix_panel_notifier_callback(enum panel_event_notifier_tag tag,
@ -1954,14 +1968,18 @@ static void goodix_panel_notifier_callback(enum panel_event_notifier_tag tag,
notification->notif_data.early_trigger);
switch (notification->notif_type) {
case DRM_PANEL_EVENT_UNBLANK:
if (notification->notif_data.early_trigger)
goodix_ts_resume(core_data);
if (notification->notif_data.early_trigger) {
flush_workqueue(core_data->power_wq);
queue_work(core_data->power_wq, &core_data->resume_work);
}
break;
case DRM_PANEL_EVENT_BLANK:
case DRM_PANEL_EVENT_BLANK_LP:
if (notification->notif_data.early_trigger)
goodix_ts_suspend(core_data);
if (notification->notif_data.early_trigger) {
flush_workqueue(core_data->power_wq);
queue_work(core_data->power_wq, &core_data->suspend_work);
}
break;
case DRM_PANEL_EVENT_FPS_CHANGE:
ts_debug("Received fps change old fps:%d new fps:%d\n",
@ -2091,6 +2109,17 @@ int goodix_ts_stage2_init(struct goodix_ts_core *cd)
}
ts_info("success register irq");
cd->power_wq =
alloc_workqueue("gtp-power-queue",
WQ_UNBOUND | WQ_HIGHPRI | WQ_CPU_INTENSIVE, 1);
if (!cd->power_wq) {
ts_err("cannot create power work thread");
ret = -ENOMEM;
goto exit;
}
INIT_WORK(&cd->resume_work, goodix_resume_work);
INIT_WORK(&cd->suspend_work, goodix_suspend_work);
#if defined(CONFIG_DRM)
if (active_panel)
goodix_register_for_panel_events(cd->bus->dev->of_node, cd);

View File

@ -542,6 +542,10 @@ struct goodix_ts_core {
atomic_t delayed_vm_probe_pending;
atomic_t trusted_touch_mode;
#endif
struct workqueue_struct *power_wq;
struct work_struct resume_work;
struct work_struct suspend_work;
};
/* external module structures */