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>
This commit is contained in:
Surya Teja Kudiri
2023-01-03 11:00:56 +05:30
bovenliggende 302815ce7e
commit 3574f26e7e
2 gewijzigde bestanden met toevoegingen van 173 en 40 verwijderingen

Bestand weergeven

@@ -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,10 +1604,122 @@ 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) {
} else {
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 (notification->notif_type == DRM_PANEL_EVENT_BLANK_LP ||
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
/* 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 {
LOGD(LOG_INFO, "%s: suspend: event = %d not care\n",
__func__, notification->notif_type);
}
} else {
LOGD(LOG_INFO, "%s: Undefined notif type (%d) do not need process\n",
__func__, notification->notif_type);
}
return ;
}
/*******************************************************************************
* 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_panel_notifier(struct raydium_ts_data *g_raydium_ts)
{
void *cookie = NULL;
if (!active_panel)
LOGD(LOG_ERR, "[touch]%s: Active panel not registered!\n", __func__);
cookie = panel_event_notifier_register(PANEL_EVENT_NOTIFICATION_PRIMARY,
PANEL_EVENT_NOTIFIER_CLIENT_PRIMARY_TOUCH,
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__);
@@ -1617,10 +1735,10 @@ static void drm_notifier_callback(enum panel_event_notifier_tag tag,
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) {
} 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 (notification->notif_type == DRM_PANEL_EVENT_BLANK) {
if (event == DRM_PANEL_EARLY_EVENT_BLANK) {
if (g_raydium_ts->fb_state != FB_OFF) {
LOGD(LOG_INFO, "%s: Suspend notifier called!\n",
__func__);
@@ -1635,16 +1753,16 @@ static void drm_notifier_callback(enum panel_event_notifier_tag tag,
g_raydium_ts->fb_state = FB_OFF;
LOGD(LOG_INFO, "%s: Suspend notified!\n", __func__);
}
} else if (notification->notif_type == DRM_PANEL_EVENT_BLANK) {
LOGD(LOG_INFO, "%s: suspend: event = %d not care\n",
__func__, notification->notif_type);
} 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__, notification->notif_type);
__func__, *blank);
}
exit:
return ;
return 0;
}
/*******************************************************************************
@@ -1657,13 +1775,16 @@ exit:
*******************************************************************************/
static void raydium_setup_drm_notifier(struct raydium_ts_data *g_raydium_ts)
{
void *cookie = NULL;
if (!active_panel)
LOGD(LOG_ERR, "[touch]%s: Active panel not registered!\n", __func__);
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__);
cookie = panel_event_notifier_register(PANEL_EVENT_NOTIFICATION_PRIMARY,
PANEL_EVENT_NOTIFIER_CLIENT_PRIMARY_TOUCH,
active_panel,&drm_notifier_callback, g_raydium_ts);
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);

Bestand weergeven

@@ -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;