Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ed6a734b authored by Bingzhe Cai's avatar Bingzhe Cai Committed by Gerrit - the friendly Code Review server
Browse files

input: touchpanel: Add FB notifications support to GT9xx



Add support for FB notifications to trigger suspend/resume
based on FB blank/unblank events.

Change-Id: I61803e3a731e047d0641e3b1ccbae58b9bd1bd89
Signed-off-by: default avatarBingzhe Cai <bingzhec@codeaurora.org>
Signed-off-by: default avatarSudhakar Manapati <smanap@codeaurora.org>
parent 8b439ca7
Loading
Loading
Loading
Loading
+106 −34
Original line number Diff line number Diff line
@@ -92,7 +92,10 @@ static void gtp_reset_guitar(struct goodix_ts_data *ts, int ms);
static void gtp_int_sync(struct goodix_ts_data *ts, int ms);
static int gtp_i2c_test(struct i2c_client *client);

#ifdef CONFIG_HAS_EARLYSUSPEND
#if defined(CONFIG_FB)
static int fb_notifier_callback(struct notifier_block *self,
				 unsigned long event, void *data);
#elif defined(CONFIG_HAS_EARLYSUSPEND)
static void goodix_ts_early_suspend(struct early_suspend *h);
static void goodix_ts_late_resume(struct early_suspend *h);
#endif
@@ -767,7 +770,7 @@ static void gtp_reset_guitar(struct goodix_ts_data *ts, int ms)
#endif
}

#ifdef CONFIG_HAS_EARLYSUSPEND
#if defined(CONFIG_HAS_EARLYSUSPEND) || defined(CONFIG_FB)
#if GTP_SLIDE_WAKEUP
/*******************************************************
Function:
@@ -872,16 +875,12 @@ static s8 gtp_wakeup_sleep(struct goodix_ts_data *ts)
	GTP_DEBUG_FUNC();

#if GTP_POWER_CTRL_SLEEP
	while (retry++ < 5) {
	gtp_reset_guitar(ts, 20);

	ret = gtp_send_cfg(ts);
	if (ret > 0) {
		dev_dbg(&ts->client->dev,
			"Wakeup sleep send config success.");
			continue;
		}
		dev_dbg(&ts->client->dev, "GTP Wakeup!");
		return 1;
	}
#else
@@ -922,7 +921,7 @@ static s8 gtp_wakeup_sleep(struct goodix_ts_data *ts)
	dev_err(&ts->client->dev, "GTP wakeup sleep failed.\n");
	return ret;
}
#endif /* !CONFIG_HAS_EARLYSUSPEND */
#endif /* !CONFIG_HAS_EARLYSUSPEND && !CONFIG_FB*/

/*******************************************************
Function:
@@ -1785,6 +1784,20 @@ static int goodix_ts_probe(struct i2c_client *client,
		goto exit_free_inputdev;
	}

#if defined(CONFIG_FB)
	ts->fb_notif.notifier_call = fb_notifier_callback;
	ret = fb_register_client(&ts->fb_notif);
	if (ret)
		dev_err(&ts->client->dev,
			"Unable to register fb_notifier: %d\n",
			ret);
#elif defined(CONFIG_HAS_EARLYSUSPEND)
	ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	ts->early_suspend.suspend = goodix_ts_early_suspend;
	ts->early_suspend.resume = goodix_ts_late_resume;
	register_early_suspend(&ts->early_suspend);
#endif

	ts->goodix_wq = create_singlethread_workqueue("goodix_wq");
	INIT_WORK(&ts->work, goodix_ts_work_func);

@@ -1812,6 +1825,13 @@ static int goodix_ts_probe(struct i2c_client *client,
	init_done = true;
	return 0;
exit_free_irq:
#if defined(CONFIG_FB)
	if (fb_unregister_client(&ts->fb_notif))
		dev_err(&client->dev,
			"Error occurred while unregistering fb_notifier.\n");
#elif defined(CONFIG_HAS_EARLYSUSPEND)
	unregister_early_suspend(&ts->early_suspend);
#endif
	if (ts->use_irq)
		free_irq(client->irq, ts);
	else
@@ -1855,7 +1875,11 @@ static int goodix_ts_remove(struct i2c_client *client)
	struct goodix_ts_data *ts = i2c_get_clientdata(client);

	GTP_DEBUG_FUNC();
#ifdef CONFIG_HAS_EARLYSUSPEND
#if defined(CONFIG_FB)
	if (fb_unregister_client(&ts->fb_notif))
		dev_err(&client->dev,
			"Error occurred while unregistering fb_notifier.\n");
#elif defined(CONFIG_HAS_EARLYSUSPEND)
	unregister_early_suspend(&ts->early_suspend);
#endif

@@ -1900,7 +1924,7 @@ static int goodix_ts_remove(struct i2c_client *client)
	return 0;
}

#ifdef CONFIG_HAS_EARLYSUSPEND
#if defined(CONFIG_HAS_EARLYSUSPEND) || defined(CONFIG_FB)
/*******************************************************
Function:
	Early suspend function.
@@ -1909,12 +1933,9 @@ Input:
Output:
	None.
*******************************************************/
static void goodix_ts_early_suspend(struct early_suspend *h)
static void goodix_ts_suspend(struct goodix_ts_data *ts)
{
	struct goodix_ts_data *ts;
	s8 ret = -1;

	ts = container_of(h, struct goodix_ts_data, early_suspend);
	int ret = -1;

	GTP_DEBUG_FUNC();

@@ -1948,12 +1969,9 @@ Input:
Output:
	None.
*******************************************************/
static void goodix_ts_late_resume(struct early_suspend *h)
static void goodix_ts_resume(struct goodix_ts_data *ts)
{
	struct goodix_ts_data *ts;
	s8 ret = -1;

	ts = container_of(h, struct goodix_ts_data, early_suspend);
	int ret = -1;

	GTP_DEBUG_FUNC();

@@ -1964,7 +1982,7 @@ static void goodix_ts_late_resume(struct early_suspend *h)
#endif

	if (ret < 0)
		dev_err(&ts->client->dev, "GTP later resume failed.\n");
		dev_err(&ts->client->dev, "GTP resume failed.\n");

	if (ts->use_irq)
		gtp_irq_enable(ts);
@@ -1977,18 +1995,72 @@ static void goodix_ts_late_resume(struct early_suspend *h)
	gtp_esd_switch(ts->client, SWITCH_ON);
#endif
}

#if defined(CONFIG_FB)
static int fb_notifier_callback(struct notifier_block *self,
				 unsigned long event, void *data)
{
	struct fb_event *evdata = data;
	int *blank;
	struct goodix_ts_data *ts =
		container_of(self, struct goodix_ts_data, fb_notif);

	if (evdata && evdata->data && event == FB_EVENT_BLANK &&
			ts && ts->client) {
		blank = evdata->data;
		if (*blank == FB_BLANK_UNBLANK)
			goodix_ts_resume(ts);
		else if (*blank == FB_BLANK_POWERDOWN)
			goodix_ts_suspend(ts);
	}

	return 0;
}
#elif defined(CONFIG_HAS_EARLYSUSPEND)
/*
 * Function:
 *	Early suspend function.
 * Input:
 *	h: early_suspend struct.
 * Output:
 *	None.
 */
static void goodix_ts_early_suspend(struct early_suspend *h)
{
	struct goodix_ts_data *ts;

	ts = container_of(h, struct goodix_ts_data, early_suspend);
	goodix_ts_suspend(ts);
}

/*
 * Function:
 *	Late resume function.
 * Input:
 *	h: early_suspend struct.
 * Output:
 *	None.
 */
static void goodix_ts_late_resume(struct early_suspend *h)
{
	struct goodix_ts_data *ts;

	ts = container_of(h, struct goodix_ts_data, early_suspend);
	goodix_ts_late_resume(ts);
}
#endif
#endif /* !CONFIG_HAS_EARLYSUSPEND && !CONFIG_FB*/

#if GTP_ESD_PROTECT
/*******************************************************
Function:
	switch on & off esd delayed work
Input:
	client:  i2c device
	on:	SWITCH_ON / SWITCH_OFF
Output:
	void
*********************************************************/
/*
 * Function:
 *	switch on & off esd delayed work
 * Input:
 *	client:  i2c device
 *	on:	SWITCH_ON / SWITCH_OFF
 * Output:
 *	void
 */
void gtp_esd_switch(struct i2c_client *client, int on)
{
	struct goodix_ts_data *ts;
+11 −5
Original line number Diff line number Diff line
@@ -33,7 +33,11 @@
#include <linux/regulator/consumer.h>
#include <linux/firmware.h>
#include <linux/debugfs.h>
#if defined(CONFIG_HAS_EARLYSUSPEND)

#if defined(CONFIG_FB)
#include <linux/notifier.h>
#include <linux/fb.h>
#elif defined(CONFIG_HAS_EARLYSUSPEND)
#include <linux/earlysuspend.h>
#define GOODIX_SUSPEND_LEVEL 1
#endif
@@ -65,9 +69,6 @@ struct goodix_ts_data {
	struct hrtimer timer;
	struct workqueue_struct *goodix_wq;
	struct work_struct	work;
#if defined(CONFIG_HAS_EARLYSUSPEND)
	struct early_suspend early_suspend;
#endif
	s32 irq_is_disabled;
	s32 use_irq;
	u16 abs_x_max;
@@ -87,6 +88,11 @@ struct goodix_ts_data {
	struct regulator *avdd;
	struct regulator *vdd;
	struct regulator *vcc_i2c;
#if defined(CONFIG_FB)
	struct notifier_block fb_notif;
#elif defined(CONFIG_HAS_EARLYSUSPEND)
	struct early_suspend early_suspend;
#endif
};

extern u16 show_len;
@@ -97,7 +103,7 @@ extern u16 total_len;
#define GTP_CHANGE_X2Y			0
#define GTP_DRIVER_SEND_CFG		1
#define GTP_HAVE_TOUCH_KEY		1
#define GTP_POWER_CTRL_SLEEP	1
#define GTP_POWER_CTRL_SLEEP	0
#define GTP_ICS_SLOT_REPORT	0

/* auto updated by .bin file as default */