#include <linux/time.h>\r
#include <linux/delay.h>\r
#include <linux/device.h>\r
-#ifdef CONFIG_HAS_EARLYSUSPEND\r
-#include <linux/earlysuspend.h>\r
-#endif\r
#include <linux/hrtimer.h>\r
#include <linux/i2c.h>\r
#include <linux/input.h>\r
#include <linux/reboot.h>\r
#include <linux/proc_fs.h>\r
#include <linux/async.h>\r
-#include "rk29_i2c_goodix.h"\r
-\r
#include <linux/vmalloc.h>\r
#include <linux/fs.h>\r
#include <linux/string.h>\r
#include <linux/completion.h>\r
#include <asm/uaccess.h>\r
\r
+#include "rk29_i2c_goodix.h"\r
+\r
#define PEN_DOWN 1\r
#define PEN_RELEASE 0\r
#define PEN_DOWN_UP 2 //fjp\r
static int rk_ts_suspend(struct i2c_client *client, pm_message_t mesg)\r
{\r
int ret;\r
- struct rk_ts_data *ts = i2c_get_clientdata(client);\r
+ struct rk_ts_data *ts = i2c_get_clientdata(client); \r
+\r
+ disable_irq(ts->irq); \r
\r
- \r
- \r
- disable_irq(ts->irq);\r
- \r
-#if 1\r
if (ts->power) {\r
+ DBG("%s.....line=%d\n",__func__,__LINE__);\r
ret = ts->power(ts, 0);\r
if (ret < 0)\r
printk(KERN_ERR "goodix_ts_resume power off failed\n");\r
}\r
-#endif\r
+\r
return 0;\r
}\r
\r
{\r
int ret;\r
struct rk_ts_data *ts = i2c_get_clientdata(client);\r
- \r
-#if 1\r
+\r
if (ts->power) {\r
+ DBG("%s.....line=%d\n",__func__,__LINE__);\r
ret = ts->power(ts, 1);\r
if (ret < 0)\r
printk(KERN_ERR "goodix_ts_resume power on failed\n");\r
}\r
-#endif\r
- \r
- enable_irq(ts->irq);\r
\r
+ enable_irq(ts->irq);\r
return 0;\r
}\r
\r
\r
\r
-#ifdef CONFIG_HAS_EARLYSUSPEND\r
-static void rk_ts_early_suspend(struct early_suspend *h)\r
+static void rk_ts_early_suspend(struct tp_device *tp_d)\r
{\r
struct rk_ts_data *ts;\r
- ts = container_of(h, struct rk_ts_data, early_suspend);\r
+ ts = container_of(tp_d, struct rk_ts_data, tp);\r
rk_ts_suspend(ts->client, PMSG_SUSPEND);\r
}\r
\r
-static void rk_ts_late_resume(struct early_suspend *h)\r
+static void rk_ts_early_resume(struct tp_device *tp_d)\r
{\r
struct rk_ts_data *ts;\r
- ts = container_of(h, struct rk_ts_data, early_suspend);\r
+ ts = container_of(tp_d, struct rk_ts_data, tp);\r
rk_ts_resume(ts->client);\r
}\r
-#endif\r
+\r
\r
/*******************************************************\r
Description:\r
int ret = -1;\r
unsigned char i2c_control_buf[2] = {80, 1}; //suspend cmd\r
int retry = 0;\r
+\r
if(on != 0 && on !=1)\r
{\r
- printk(KERN_DEBUG "%s: Cant't support this command.", rk_ts_name);\r
+ printk("%s: Cant't support this command.", rk_ts_name);\r
return -EINVAL;\r
}\r
- \r
- \r
- if(on == 0) //suspend\r
+ \r
+ if(on == 0)//suspend\r
{ \r
while(retry<5)\r
{\r
ret = goodix_i2c_write_bytes(ts->client, i2c_control_buf, 2);\r
if(ret == 1)\r
{\r
- printk(KERN_DEBUG "touch goodix Send suspend cmd successed \n");\r
+ printk("touch goodix Send suspend cmd successed \n");\r
break;\r
}\r
retry++;\r
if(ret > 0)\r
ret = 0;\r
}\r
- else if(on == 1) //resume\r
+ else if(on == 1)//resume\r
{\r
- printk(KERN_DEBUG "touch goodix int resume\n");\r
+ printk("touch goodix int resume\n");\r
gpio_set_value(ts->rst_pin, ts->rst_val);\r
msleep(20);\r
gpio_set_value(ts->rst_pin, !ts->rst_val);\r
\r
i2c_connect_client = client;\r
\r
-#ifdef CONFIG_HAS_EARLYSUSPEND\r
- ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;\r
- ts->early_suspend.suspend = rk_ts_early_suspend;\r
- ts->early_suspend.resume = rk_ts_late_resume;\r
- register_early_suspend(&ts->early_suspend);\r
-#endif\r
+ ts->tp.tp_resume = rk_ts_early_resume;\r
+ ts->tp.tp_suspend = rk_ts_early_suspend;\r
+ tp_register_fb(&ts->tp);\r
+\r
i2c_set_clientdata(client, ts);\r
\r
ts->irq=gpio_to_irq(ts->irq_pin); //If not defined in client\r
printk(KERN_ALERT "Cannot allocate ts INT!ERRNO:%d\n", ret);\r
goto err;\r
}\r
+ disable_irq(ts->irq);\r
}\r
printk("goodix_ts_init: probe successfully!\n");\r
return 0;\r
\r
\r
err:\r
-#ifdef CONFIG_HAS_EARLYSUSPEND\r
- unregister_early_suspend(&ts->early_suspend);\r
-#endif\r
+ tp_unregister_fb(&ts->tp);\r
i2c_set_clientdata(client, NULL); \r
return ret;\r
}\r
*******************************************************/\r
static int rk_ts_remove(struct i2c_client *client)\r
{\r
-#ifdef CONFIG_HAS_EARLYSUSPEND\r
struct rk_ts_data *ts = i2c_get_clientdata(client);\r
- unregister_early_suspend(&ts->early_suspend);\r
-#endif\r
+ tp_unregister_fb(&ts->tp);\r
+\r
#ifdef CONFIG_TOUCHSCREEN_GOODIX_IAP\r
remove_proc_entry("goodix-update", NULL);\r
#endif\r
\r
static void rk_ts_shutdown(struct i2c_client *client)\r
{\r
-#ifdef CONFIG_HAS_EARLYSUSPEND\r
struct rk_ts_data *ts = i2c_get_clientdata(client);\r
if (ts)\r
- unregister_early_suspend(&ts->early_suspend);\r
-#endif\r
+ tp_unregister_fb(&ts->tp);\r
+\r
}\r
\r
//******************************Begin of firmware update surpport*******************************\r
.probe = rk_ts_probe,\r
.remove = rk_ts_remove,\r
.shutdown = rk_ts_shutdown,\r
-#ifndef CONFIG_HAS_EARLYSUSPEND\r
- .suspend = rk_ts_suspend,\r
- .resume = rk_ts_resume,\r
-#endif\r
.id_table = goodix_ts_id,\r
.driver = {\r
.name = "Goodix-TS",\r
--- /dev/null
+/*
+ * TP suspend Control Abstraction
+ *
+ * Copyright (C) RK Company
+ *
+ */
+#ifndef _RK_TP_SUSPEND_H
+#define _RK_TP_SUSPEND_H
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/fb.h>
+#include <linux/notifier.h>
+
+struct tp_device{
+ struct notifier_block fb_notif;
+ int(*tp_suspend)(struct tp_device*);
+ int(*tp_resume)(struct tp_device*);
+ struct mutex ops_lock;
+};
+
+static int fb_notifier_callback(struct notifier_block *self,
+ unsigned long action, void *data)
+{
+ struct tp_device *tp;
+ struct fb_event *event = data;
+ int blank_mode = *((int *)event->data);
+ int ret = 0;
+
+ tp = container_of(self, struct tp_device, fb_notif);
+
+ //printk("%s.....lin=%d tp->status=%x,blank_mode=%x\n",__func__,__LINE__,tp->status,blank_mode);
+
+ mutex_lock(&tp->ops_lock);
+
+ if (action == FB_EARLY_EVENT_BLANK) {
+ switch (blank_mode) {
+ case FB_BLANK_UNBLANK:
+ break;
+ default:
+ ret = tp->tp_suspend(tp);
+ break;
+ }
+ }
+ else if (action == FB_EVENT_BLANK) {
+ switch (blank_mode) {
+ case FB_BLANK_UNBLANK:
+ tp->tp_resume(tp);
+ break;
+ default:
+ break;
+ }
+ }
+ mutex_unlock(&tp->ops_lock);
+
+ if (ret < 0)
+ {
+ printk("TP_notifier_callback error action=%x,blank_mode=%x\n",action,blank_mode);
+ return ret;
+ }
+
+ return NOTIFY_OK;
+}
+
+static int tp_register_fb(struct tp_device *tp)
+{
+ memset(&tp->fb_notif, 0, sizeof(tp->fb_notif));
+ tp->fb_notif.notifier_call = fb_notifier_callback;
+ mutex_init(&tp->ops_lock);
+
+ return fb_register_client(&tp->fb_notif);
+}
+
+static void tp_unregister_fb(struct tp_device *tp)
+{
+ fb_unregister_client(&tp->fb_notif);
+}
+#endif _RK_TP_SUSPEND_H