diff options
author | Surya Teja Kudiri <quic_skudiri@quicinc.com> | 2023-01-03 11:00:56 +0530 |
---|---|---|
committer | Surya Teja Kudiri <quic_skudiri@quicinc.com> | 2023-01-03 11:02:02 +0530 |
commit | 3574f26e7eee52e9861ec90d1d3b20b5e74e5543 (patch) | |
tree | 43e22c90c269b2c9d3f8d7d9c711f4ace8491396 | |
parent | 302815ce7eb95bc66aae216e8ee04da09ccbe504 (diff) | |
download | touch-3574f26e7eee52e9861ec90d1d3b20b5e74e5543.tar.gz |
touch: Add panel event notifier support
Add panel event notifier support for raydium driver.
Change-Id: I4ebe4ebf8522bb0ecc637aefec69f35a0d426c9e
Signed-off-by: Surya Teja Kudiri <quic_skudiri@quicinc.com>
-rw-r--r-- | raydium/raydium_driver.c | 201 | ||||
-rw-r--r-- | raydium/raydium_driver.h | 8 |
2 files changed, 171 insertions, 38 deletions
diff --git a/raydium/raydium_driver.c b/raydium/raydium_driver.c index c85e746..c40489b 100644 --- a/raydium/raydium_driver.c +++ b/raydium/raydium_driver.c @@ -38,16 +38,16 @@ #include <linux/of_gpio.h> #include <linux/err.h> #include <linux/of_device.h> -#include <linux/soc/qcom/panel_event_notifier.h> - +#include "raydium_driver.h" #if defined(CONFIG_FB) #include <linux/notifier.h> #include <linux/fb.h> #elif defined(CONFIG_HAS_EARLYSUSPEND) #include <linux/earlysuspend.h> #endif /*end of CONFIG_FB*/ - -#include "raydium_driver.h" +#if defined(CONFIG_PANEL_NOTIFIER) +#include <linux/soc/qcom/panel_event_notifier.h> +#endif struct raydium_slot_status { unsigned char pt_id; /*Occupied point ID*/ @@ -65,7 +65,7 @@ static int raydium_enable_regulator(struct raydium_ts_data *cd, bool en); const struct attribute_group raydium_attr_group; #endif /*end of CONFIG_RM_SYSFS_DEBUG*/ -#if defined(CONFIG_DRM) +#if defined(CONFIG_DRM) || defined(CONFIG_PANEL_NOTIFIER) static struct drm_panel *active_panel; #endif @@ -696,7 +696,11 @@ void raydium_irq_control(bool enable) } /* Clear interrupts first */ - if (g_raydium_ts->blank != DRM_PANEL_EVENT_BLANK_LP) { +#if defined(CONFIG_PANEL_NOTIFIER) + if (g_raydium_ts->blank != DRM_PANEL_EVENT_BLANK) { +#else + if (g_raydium_ts->blank != DRM_PANEL_BLANK_POWERDOWN) { +#endif if (g_u8_i2c_mode == PDA2_MODE) { mutex_lock(&g_raydium_ts->lock); if (raydium_i2c_pda2_set_page(g_raydium_ts->client, @@ -1202,9 +1206,13 @@ static void raydium_work_handler(struct work_struct *work) return; } } - - if (g_raydium_ts->blank == DRM_PANEL_EVENT_BLANK_LP|| - g_raydium_ts->blank == DRM_PANEL_EVENT_BLANK_LP || g_raydium_ts->fb_state == FB_OFF) { +#if defined(CONFIG_PANEL_NOTIFIER) + if (g_raydium_ts->blank == DRM_PANEL_EVENT_BLANK_LP || + g_raydium_ts->blank == DRM_PANEL_EVENT_BLANK || g_raydium_ts->fb_state == FB_OFF) { +#else + if (g_raydium_ts->blank == DRM_PANEL_BLANK_LP || + g_raydium_ts->blank == DRM_PANEL_BLANK_POWERDOWN || g_raydium_ts->fb_state == FB_OFF) { +#endif LOGD(LOG_DEBUG, "[touch] elseif u8_tp_status:%x\n", u8_tp_status[POS_GES_STATUS]); /*need check small area*/ /*if (u8_tp_status[POS_GES_STATUS] == RAD_WAKE_UP */ @@ -1221,7 +1229,11 @@ static void raydium_work_handler(struct work_struct *work) } } /*when display on can use palm to suspend*/ +#if defined(CONFIG_PANEL_NOTIFIER) else if (g_raydium_ts->blank == DRM_PANEL_EVENT_UNBLANK) { +#else + else if (g_raydium_ts->blank == DRM_PANEL_BLANK_UNBLANK) { +#endif if (u8_tp_status[POS_GES_STATUS] == RAD_PALM_ENABLE) { if (g_raydium_ts->is_palm == 0) { /* release all touches*/ @@ -1570,9 +1582,8 @@ static int raydium_ts_resume(struct device *dev) } #endif /*end of CONFIG_FB*/ - -#if defined(CONFIG_DRM) -static void drm_notifier_callback(enum panel_event_notifier_tag tag, +#if defined(CONFIG_PANEL_NOTIFIER) +static void panel_event_notifier_callback(enum panel_event_notifier_tag tag, struct panel_event_notification *notification, void *client_data) { @@ -1584,11 +1595,6 @@ static void drm_notifier_callback(enum panel_event_notifier_tag tag, } LOGD(LOG_INFO, "%s: DRM notifier called!\n", __func__); - if (!(notification->notif_type == DRM_PANEL_EVENT_BLANK)){ - LOGD(LOG_INFO, "%s: Event(%d do not need process\n", - __func__, notification->notif_type); - goto exit; - } LOGD(LOG_INFO, "%s: DRM event:%d fb_state %d ", __func__, notification->notif_type, g_raydium_ts->fb_state); @@ -1598,11 +1604,10 @@ static void drm_notifier_callback(enum panel_event_notifier_tag tag, if (notification->notif_type == DRM_PANEL_EVENT_UNBLANK) { LOGD(LOG_INFO, "%s: UNBLANK!\n", __func__); - if (notification->notif_type == DRM_PANEL_EVENT_BLANK) { + if (notification->notif_data.early_trigger) { LOGD(LOG_INFO, "%s: resume: event = %d not care\n", __func__, notification->notif_type); - } else if (notification->notif_type == DRM_PANEL_EVENT_BLANK) { - if (g_raydium_ts->fb_state != FB_ON) { + } else { LOGD(LOG_INFO, "%s: Resume notifier called!\n", __func__); #ifdef GESTURE_EN @@ -1615,13 +1620,15 @@ static void drm_notifier_callback(enum panel_event_notifier_tag tag, #endif g_raydium_ts->fb_state = FB_ON; LOGD(LOG_INFO, "%s: Resume notified!\n", __func__); - } } } else if (notification->notif_type == DRM_PANEL_EVENT_BLANK_LP || - notification->notif_type == DRM_PANEL_EVENT_FPS_CHANGE) { - LOGD(LOG_INFO, "%s: LOWPOWER!\n", __func__); - if (notification->notif_type == DRM_PANEL_EVENT_BLANK) { - if (g_raydium_ts->fb_state != FB_OFF) { + notification->notif_type == DRM_PANEL_EVENT_BLANK) { + if (notification->notif_type == DRM_PANEL_EVENT_BLANK_LP) { + LOGD(LOG_INFO, "%s: LOWPOWER!\n", __func__); + } else { + LOGD(LOG_INFO, "%s: BLANK!\n", __func__); + } + if (notification->notif_data.early_trigger) { LOGD(LOG_INFO, "%s: Suspend notifier called!\n", __func__); #ifdef GESTURE_EN @@ -1634,16 +1641,14 @@ static void drm_notifier_callback(enum panel_event_notifier_tag tag, #endif g_raydium_ts->fb_state = FB_OFF; LOGD(LOG_INFO, "%s: Suspend notified!\n", __func__); - } - } else if (notification->notif_type == DRM_PANEL_EVENT_BLANK) { + } else { LOGD(LOG_INFO, "%s: suspend: event = %d not care\n", __func__, notification->notif_type); } } else { - LOGD(LOG_INFO, "%s: DRM BLANK(%d) do not need process\n", + LOGD(LOG_INFO, "%s: Undefined notif type (%d) do not need process\n", __func__, notification->notif_type); } -exit: return ; } @@ -1655,7 +1660,7 @@ exit: * PARAMETERS: * g_raydium_ts - pointer to core data *******************************************************************************/ -static void raydium_setup_drm_notifier(struct raydium_ts_data *g_raydium_ts) +static void raydium_setup_panel_notifier(struct raydium_ts_data *g_raydium_ts) { void *cookie = NULL; if (!active_panel) @@ -1663,7 +1668,123 @@ static void raydium_setup_drm_notifier(struct raydium_ts_data *g_raydium_ts) cookie = panel_event_notifier_register(PANEL_EVENT_NOTIFICATION_PRIMARY, PANEL_EVENT_NOTIFIER_CLIENT_PRIMARY_TOUCH, - active_panel,&drm_notifier_callback, g_raydium_ts); + active_panel,&panel_event_notifier_callback, g_raydium_ts); +} + +#elif defined(CONFIG_DRM) +/******************************************************************************* + * FUNCTION: drm_notifier_callback + * + * SUMMARY: Call back function for DRM notifier to allow to call + * resume/suspend attention list. + * + * RETURN: + * 0 = success + * + * PARAMETERS: + * self - pointer to notifier_block structure + * event - event type of fb notifier + * data - pointer to fb_event structure + ******************************************************************************/ +static int drm_notifier_callback(struct notifier_block *self, + unsigned long event, void *data) +{ + struct raydium_ts_data *g_raydium_ts = + container_of(self, struct raydium_ts_data, fb_notif); + struct drm_panel_notifier *evdata = data; + int *blank; + + LOGD(LOG_INFO, "%s: DRM notifier called!\n", __func__); + + if (!evdata) + goto exit; + + if (!(event == DRM_PANEL_EARLY_EVENT_BLANK || + event == DRM_PANEL_EVENT_BLANK)) { + LOGD(LOG_INFO, "%s: Event(%lu) do not need process\n", + __func__, event); + goto exit; + } + + blank = evdata->data; + g_raydium_ts->blank = (*blank); + LOGD(LOG_INFO, "%s: DRM event:%lu,blank:%d fb_state %d ", + __func__, event, *blank, g_raydium_ts->fb_state); + LOGD(LOG_INFO, "%s: DRM Power - %s - FB state %d ", + __func__, (*blank == DRM_PANEL_BLANK_UNBLANK)?"UP":"DOWN", g_raydium_ts->fb_state); + + if (*blank == DRM_PANEL_BLANK_UNBLANK) { + LOGD(LOG_INFO, "%s: UNBLANK!\n", __func__); + + if (event == DRM_PANEL_EARLY_EVENT_BLANK) { + LOGD(LOG_INFO, "%s: resume: event = %lu, not care\n", + __func__, event); + } else if (event == DRM_PANEL_EVENT_BLANK) { + if (g_raydium_ts->fb_state != FB_ON) { + LOGD(LOG_INFO, "%s: Resume notifier called!\n", + __func__); +#ifdef GESTURE_EN + /* clear palm status */ + g_raydium_ts->is_palm = 0; +#endif + +#if defined(CONFIG_PM) + raydium_ts_resume(&g_raydium_ts->client->dev); +#endif + g_raydium_ts->fb_state = FB_ON; + LOGD(LOG_INFO, "%s: Resume notified!\n", __func__); + } + } + } else if (*blank == DRM_PANEL_BLANK_LP || *blank == DRM_PANEL_BLANK_POWERDOWN + || *blank == DRM_PANEL_BLANK_FPS_CHANGE) { + LOGD(LOG_INFO, "%s: LOWPOWER!\n", __func__); + if (event == DRM_PANEL_EARLY_EVENT_BLANK) { + if (g_raydium_ts->fb_state != FB_OFF) { + LOGD(LOG_INFO, "%s: Suspend notifier called!\n", + __func__); +#ifdef GESTURE_EN + /* clear palm status */ + g_raydium_ts->is_palm = 0; +#endif + +#if defined(CONFIG_PM) + raydium_ts_suspend(&g_raydium_ts->client->dev); +#endif + g_raydium_ts->fb_state = FB_OFF; + LOGD(LOG_INFO, "%s: Suspend notified!\n", __func__); + } + } else if (event == DRM_PANEL_EVENT_BLANK) { + LOGD(LOG_INFO, "%s: suspend: event = %lu, not care\n", + __func__, event); + } + } else { + LOGD(LOG_INFO, "%s: DRM BLANK(%d) do not need process\n", + __func__, *blank); + } +exit: + return 0; +} + +/******************************************************************************* + * FUNCTION: raydium_setup_drm_notifier + * + * SUMMARY: Set up call back function into drm notifier. + * + * PARAMETERS: + * g_raydium_ts - pointer to core data + *******************************************************************************/ +static void raydium_setup_drm_notifier(struct raydium_ts_data *g_raydium_ts) +{ + g_raydium_ts->fb_state = FB_ON; + g_raydium_ts->fb_notif.notifier_call = drm_notifier_callback; + LOGD(LOG_INFO, "[touch]%s: Setting up drm notifier\n", __func__); + + if (!active_panel) + LOGD(LOG_ERR, "[touch]%s: Active panel not registered!\n", __func__); + + if (active_panel && drm_panel_notifier_register(active_panel, + &g_raydium_ts->fb_notif) < 0) + LOGD(LOG_ERR, "[touch]%s: Register notifier failed!\n", __func__); } #endif /*end of CONFIG_DRM*/ @@ -2240,7 +2361,7 @@ static int raydium_ts_probe(struct i2c_client *client, ret = -EPROBE_DEFER; goto exit_check_i2c; } -#ifdef CONFIG_DRM +#if defined(CONFIG_DRM) || defined(CONFIG_PANEL_NOTIFIER) /* Setup active dsi panel */ active_panel = pdata->active_panel; #endif @@ -2291,8 +2412,10 @@ static int raydium_ts_probe(struct i2c_client *client, LOGD(LOG_DEBUG, "[touch]pdata irq : %d\n", g_raydium_ts->irq_gpio); LOGD(LOG_DEBUG, "[touch]client irq : %d, pdata flags : %d\n", client->irq, pdata->irqflags); - -#if defined(CONFIG_DRM) +#if defined(CONFIG_PANEL_NOTIFIER) + LOGD(LOG_DEBUG, "%s: Probe: Setup panel event notifier\n", __func__); + raydium_setup_panel_notifier(g_raydium_ts); +#elif defined(CONFIG_DRM) LOGD(LOG_DEBUG, "%s: Probe: Setup drm notifier\n", __func__); raydium_setup_drm_notifier(g_raydium_ts); #endif/*end of CONFIG_DRM*/ @@ -2379,9 +2502,12 @@ void raydium_ts_shutdown(struct i2c_client *client) raydium_unregister_notifier(); #elif defined(CONFIG_HAS_EARLYSUSPEND) unregister_early_suspend(&g_raydium_ts->early_suspend); -#elif defined(CONFIG_DRM) +#elif defined(CONFIG_PANEL_NOTIFIER) if (active_panel) panel_event_notifier_unregister(&g_raydium_ts->fb_notif); +#elif defined(CONFIG_DRM) +if (active_panel) + drm_panel_notifier_unregister(active_panel, &g_raydium_ts->fb_notif); #endif/*end of CONFIG_FB*/ input_unregister_device(g_raydium_ts->input_dev); input_free_device(g_raydium_ts->input_dev); @@ -2415,9 +2541,12 @@ static int raydium_ts_remove(struct i2c_client *client) raydium_unregister_notifier(); #elif defined(CONFIG_HAS_EARLYSUSPEND) unregister_early_suspend(&g_raydium_ts->early_suspend); +#elif defined(CONFIG_PANEL_NOTIFIER) +if (active_panel) + panel_event_notifier_unregister(&g_raydium_ts->fb_notif); #elif defined(CONFIG_DRM) if (active_panel) - panel_event_notifier_unregister(&g_raydium_ts->fb_notif); + drm_panel_notifier_unregister(active_panel, &g_raydium_ts->fb_notif); #endif/*end of CONFIG_FB*/ input_unregister_device(g_raydium_ts->input_dev); input_free_device(g_raydium_ts->input_dev); diff --git a/raydium/raydium_driver.h b/raydium/raydium_driver.h index adc3d78..f3428a3 100644 --- a/raydium/raydium_driver.h +++ b/raydium/raydium_driver.h @@ -262,12 +262,16 @@ #define CONFIG_DRM #endif +#if IS_ENABLED(CONFIG_QCOM_PANEL_EVENT_NOTIFIER) +#define CONFIG_PANEL_NOTIFIER +#endif + #include <linux/device.h> #include <linux/fb.h> #include <linux/notifier.h> #ifdef CONFIG_HAS_EARLYSUSPEND #include <linux/earlysuspend.h> -#elif defined(CONFIG_DRM) +#elif defined(CONFIG_DRM) || defined(CONFIG_PANEL_NOTIFIER) #include <drm/drm_panel.h> #endif @@ -303,7 +307,7 @@ struct raydium_ts_data { bool irq_enabled; bool irq_wake; -#if defined(CONFIG_FB) || defined(CONFIG_DRM) +#if defined(CONFIG_FB) || defined(CONFIG_DRM) || defined(CONFIG_PANEL_NOTIFIER) struct notifier_block fb_notif; int blank; enum raydium_fb_state fb_state; |