From baa8973d8f018e98f860d329ed0bbb15ea386292 Mon Sep 17 00:00:00 2001 From: lingwenk Date: Tue, 12 Mar 2024 19:12:14 +0800 Subject: [PATCH] touch: st: update driver version update driver code version for kernel-5.15 Change-Id:Ia9aa2bdc4fd13832171d19d04db7e913d991508f Signed-off-by: lingwenk --- st/fts.c | 150 +++++++++++++++++++++++-------------------- st/fts.h | 2 + st/fts_lib/ftsTime.c | 4 +- st/fts_lib/ftsTime.h | 2 +- st/fts_lib/ftsTool.c | 4 -- 5 files changed, 86 insertions(+), 76 deletions(-) diff --git a/st/fts.c b/st/fts.c index f5dc14c681..f6d8323345 100644 --- a/st/fts.c +++ b/st/fts.c @@ -38,6 +38,7 @@ #include #else #include +#include #endif #ifdef KERNEL_ABOVE_2_6_38 @@ -1035,6 +1036,76 @@ static int fts_chip_initialization(struct fts_ts_info *info); static int fts_enable_reg(struct fts_ts_info *info, bool enable); static struct drm_panel *active_panel; +#if defined(CONFIG_DRM) +static void st_ts_panel_notifier_callback(enum panel_event_notifier_tag tag, + struct panel_event_notification *notification, void *client_data) +{ + struct fts_ts_info *info = client_data; + + if (!notification) { + pr_err("Invalid notification\n"); + return; + } + + logError(0, "%s %s Notification type:%d, early_trigger:%d, sensor_sleep:%d", tag, __func__, + notification->notif_type, + notification->notif_data.early_trigger, + info->sensor_sleep); + + switch (notification->notif_type) { + case DRM_PANEL_EVENT_UNBLANK: + if (!notification->notif_data.early_trigger) { + logError(0, "%s %s: DRM_PANEL_EVENT_UNBLANK\n", tag, __func__); + queue_work(info->event_wq, &info->resume_work); + } + break; + + case DRM_PANEL_EVENT_BLANK: + if (!notification->notif_data.early_trigger) { + logError(0, "%s %s: DRM_PANEL_EVENT_BLANK\n", tag, __func__); + queue_work(info->event_wq, &info->suspend_work); + } + break; + + case DRM_PANEL_EVENT_BLANK_LP: + logError(0, "%s %s:received lp event\n", tag, __func__); + break; + + case DRM_PANEL_EVENT_FPS_CHANGE: + logError(0, "%s %s: Received fps change old fps:%d new fps:%d\n", + tag, __func__, + notification->notif_data.old_fps, + notification->notif_data.new_fps); + break; + + default: + logError(0, "%s %s:notification serviced :%d\n", + tag, __func__, notification->notif_type); + break; + } +} + +static int st_register_for_panel_events(struct device_node *dp, + struct fts_ts_info *info) +{ + void *cookie; + + cookie = panel_event_notifier_register(PANEL_EVENT_NOTIFICATION_PRIMARY, + PANEL_EVENT_NOTIFIER_CLIENT_PRIMARY_TOUCH, active_panel, + &st_ts_panel_notifier_callback, info); + if (!cookie) { + pr_err("Failed to register for panel events\n"); + return -1; + } + + logError(0, "%s %s registered for panel notifications panel: 0x%x\n", + tag, __func__, active_panel); + + info->notifier_cookie = cookie; + + return 0; +} +#endif void touch_callback(unsigned int status) { @@ -3141,9 +3212,8 @@ static ssize_t fts_stm_cmd_show(struct device *dev, #if defined(CONFIG_FB_MSM) res = fb_unregister_client(&info->notifier); #else - if (active_panel) - res = drm_panel_notifier_unregister(active_panel, - &info->notifier); + if (active_panel && info->notifier_cookie) + panel_event_notifier_unregister(info->notifier_cookie); #endif if (res < 0) { logError(1, "%s ERROR: unregister notifier failed!\n", @@ -3346,9 +3416,8 @@ static ssize_t fts_stm_cmd_show(struct device *dev, if (fb_register_client(&info->notifier) < 0) logError(1, "%s ERROR: register notifier failed!\n", tag); #else - if (active_panel && - drm_panel_notifier_register(active_panel, &info->notifier) < 0) - logError(1, "%s ERROR: register notifier failed!\n", tag); + if (active_panel) + st_register_for_panel_events(info->dev->of_node, info); #endif END: @@ -4617,8 +4686,7 @@ static int fts_init_afterProbe(struct fts_ts_info *info) error |= fb_register_client(&info->notifier); #else if (active_panel) - error |= drm_panel_notifier_register(active_panel, - &info->notifier); + st_register_for_panel_events(info->dev->of_node, info); #endif if (error < OK) @@ -5091,68 +5159,10 @@ static int fts_fb_state_chg_callback(struct notifier_block *nb, return NOTIFY_OK; } -#else -static int fts_fb_state_chg_callback(struct notifier_block *nb, - unsigned long val, void *data) -{ - struct fts_ts_info *info = container_of(nb, struct fts_ts_info, - notifier); - struct drm_panel_notifier *evdata = data; - unsigned int blank; - - if (!evdata) - return 0; - - if (val != DRM_PANEL_EVENT_BLANK) - return 0; - - logError(0, "%s %s: fts notifier begin!\n", tag, __func__); - if (evdata->data && val == DRM_PANEL_EVENT_BLANK && info) { - blank = *(int *) (evdata->data); - - switch (blank) { - case DRM_PANEL_BLANK_POWERDOWN: - if (info->sensor_sleep && info->aoi_notify_enabled) - break; - - if (info->aoi_notify_enabled) - info->aoi_wake_on_suspend = true; - else - info->aoi_wake_on_suspend = false; - - if (info->aoi_wake_on_suspend) { - info->sensor_sleep = true; - __pm_stay_awake(info->wakeup_source); - } else { - queue_work(info->event_wq, &info->suspend_work); - } - break; - - case DRM_PANEL_BLANK_UNBLANK: - if (info->aoi_wake_on_suspend) - __pm_relax(info->wakeup_source); - - if (!info->sensor_sleep) - break; - - if (!info->resume_bit) - queue_work(info->event_wq, &info->resume_work); - - if (info->aoi_wake_on_suspend) - info->sensor_sleep = false; - - break; - default: - break; - } - } - return NOTIFY_OK; -} -#endif - static struct notifier_block fts_noti_block = { .notifier_call = fts_fb_state_chg_callback, }; +#endif static int fts_pinctrl_init(struct fts_ts_info *info) { @@ -5777,7 +5787,9 @@ static int fts_probe_internal(struct i2c_client *client, info->edge_palm_rej_enabled = 0; info->resume_bit = 1; +#if defined(CONFIG_FB_MSM) info->notifier = fts_noti_block; +#endif #ifdef CONFIG_ST_TRUSTED_TOUCH fts_trusted_touch_init(info); @@ -5986,8 +5998,8 @@ static int fts_remove(struct i2c_client *client) #if defined(CONFIG_FB_MSM) fb_unregister_client(&info->notifier); #else - if (active_panel) - drm_panel_notifier_register(active_panel, &info->notifier); + if (active_panel && info->notifier_cookie) + panel_event_notifier_unregister(info->notifier_cookie); #endif /* unregister the device */ diff --git a/st/fts.h b/st/fts.h index 817096209a..ca1888ac3b 100644 --- a/st/fts.h +++ b/st/fts.h @@ -260,6 +260,7 @@ struct trusted_touch_vm_info { * @resume_bit Indicate if screen off/on * @fwupdate_stat Store the result of a fw update triggered by the host * @notifier Used for be notified from a suspend/resume event + * @notifier_cookie saved cookie during panel event notification * @sensor_sleep true susped was called, false resume was called * @wakelock Wake Lock struct * @input_report_mutex mutex for handling the pressure of keys @@ -322,6 +323,7 @@ struct fts_ts_info { int fwupdate_stat; struct notifier_block notifier; + void *notifier_cookie; bool sensor_sleep; struct wakeup_source *wakeup_source; diff --git a/st/fts_lib/ftsTime.c b/st/fts_lib/ftsTime.c index 07d1bf5dba..88d03dc27a 100644 --- a/st/fts_lib/ftsTime.c +++ b/st/fts_lib/ftsTime.c @@ -66,12 +66,12 @@ void startStopWatch(struct StopWatch *w) { - ktime_get_ts(&w->start); + w->start = ktime_to_timespec64(ktime_get()); } void stopStopWatch(struct StopWatch *w) { - ktime_get_ts(&w->end); + w->end = ktime_to_timespec64(ktime_get()); } int elapsedMillisecond(struct StopWatch *w) diff --git a/st/fts_lib/ftsTime.h b/st/fts_lib/ftsTime.h index d98dd2a9fc..64968e77af 100644 --- a/st/fts_lib/ftsTime.h +++ b/st/fts_lib/ftsTime.h @@ -42,7 +42,7 @@ #include "ftsCrossCompile.h" struct StopWatch { - struct timespec start, end; + struct timespec64 start, end; }; void startStopWatch(struct StopWatch *w); diff --git a/st/fts_lib/ftsTool.c b/st/fts_lib/ftsTool.c index 543682d1e3..6dac5b1ddf 100644 --- a/st/fts_lib/ftsTool.c +++ b/st/fts_lib/ftsTool.c @@ -84,10 +84,6 @@ int readB2(u16 address, u8 *outBuf, int len) u8 readEvent[FIFO_EVENT_SIZE] = {0}; u8 cmd[4] = { FTS_CMD_REQU_FW_CONF, 0x00, 0x00, (u8)len }; - if (readEvent == NULL) { - logError(1, "%s %s:ERROR %02X\n", tag, __func__, ERROR_ALLOC); - return ERROR_ALLOC; - } u16ToU8_be(address, &cmd[1]); temp = printHex("Command B2 = ", cmd, 4); if (temp != NULL)