* GNU General Public License for more details.
*/
+
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/earlysuspend.h>
#define TOUCH_NUMBER 2
#endif
-#define TOUCH_REG_NUM 5 //ÿ×é×ø±êÐèÒªµÄ¼Ä´æÆ÷ÊýĿ
+#define TOUCH_REG_NUM 5 //ÿ�������Ҫ�ļĴ�����Ŀ
const unsigned char GT801_RegData[GT801_REGS_NUM]={
- 0x19,0x05,0x06,0x28,0x02,0x14,0x14,0x10,0x40,0xB0,0x01,0xE0,0x03,0x4C,0x78,0x9A,0xBC,0xDE,0x65,0x43,0x20,0x11,0x00,0x00,0x00,0x00,0x05,0xCF,0x20,0x0B,0x0D,0x8D,0x32,0x3C,0x1E,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01
+ 0x19,0x05,0x06,0x28,0x02,0x14,0x14,0x10,0x40,0xB0,0x01,0xE0,0x03,0x4C,0x78,
+ 0x9A,0xBC,0xDE,0x65,0x43,0x20,0x11,0x00,0x00,0x00,0x00,0x05,0xCF,0x20,0x0B,
+ 0x0D,0x8D,0x32,0x3C,0x1E,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01
};
struct gt801_ts_data {
}
else{
x = ((( ((unsigned short)buf[i+ptxh] )<< 8) ) | buf[i+ptxl]);
- y= (((((unsigned short)buf[i+ptyh] )<< 8) )| buf[i+ptyl]);
-
- if (ts->swap_xy)
+ y = (((((unsigned short)buf[i+ptyh] )<< 8) )| buf[i+ptyl]);
+ /* adjust the x and y to proper value added by hhb@rock-chips.com*/
+ if(x < 480){
+ x = 480-x;
+ }
+
+ if(y < 800){
+ y = 800-y;
+ }
+
+ if (ts->swap_xy){
swap(x, y);
+ }
- if (verify_coord(ts,&x,&y))
- ;//goto out;
+ if (verify_coord(ts,&x,&y));//goto out;
gt801printk("input_report_abs--%d-%d-(%d/%d)\n", i,touch_state_index, x, y);
input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 1); //Finger Size
#endif
- if(syn_flag)
+ if(syn_flag){
input_sync(ts->input_dev);
+ }
+
out:
- if (ts->use_irq)
- enable_irq(ts->client->irq);
-
+ if (ts->use_irq) {
+ enable_irq(ts->client->irq);
+ }
return;
}
static enum hrtimer_restart gt801_ts_timer_func(struct hrtimer *timer)
static irqreturn_t gt801_ts_irq_handler(int irq, void *dev_id)
{
struct gt801_ts_data *ts = dev_id;
- gt801printk("%s=%d,%d\n",__FUNCTION__,ts->client->irq,ts->use_irq);
+ gt801printk("%s=%d,%d\n",__FUNCTION__,ts->client->irq,ts->use_irq);
- //if (ts->use_irq)
+ if(ts->use_irq){
disable_irq_nosync(ts->client->irq);
- queue_work(gt801_wq, &ts->work);
+ }
+ queue_work(gt801_wq, &ts->work);
return IRQ_HANDLED;
}
static int __devinit setup_resetPin(struct i2c_client *client, struct gt801_ts_data *ts)
return err;
}
- gpio_set_value(ts->gpio_reset, ts->gpio_reset_active_low? GPIO_LOW:GPIO_HIGH);
-
err = gpio_direction_output(ts->gpio_reset, ts->gpio_reset_active_low? GPIO_LOW:GPIO_HIGH);
if (err) {
dev_err(&client->dev, "failed to pulldown resetPin GPIO%d,err%d\n",
gpio_free(ts->gpio_reset);
return err;
}
-
- mdelay(100);
-
+ mdelay(100);
gpio_set_value(ts->gpio_reset, ts->gpio_reset_active_low? GPIO_HIGH:GPIO_LOW);
-
mdelay(100);
-
+
return 0;
}
+
static int __devinit setup_pendown(struct i2c_client *client, struct gt801_ts_data *ts)
{
int err;
}
return 0;
}
+
static int gt801_chip_Init(struct i2c_client *client)
{
u8 i,j;
return ret;
}
+
static int gt801_ts_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
struct gt801_ts_data *ts;
return 0;
}
+
+static void gt801_ts_resume_work_func(struct work_struct *work)
+{
+ struct gt801_ts_data *ts = container_of(work, struct gt801_ts_data, work);
+ msleep(50); //touch panel will generate an interrupt when it sleeps out,so as to avoid tihs by delaying 50ms
+ enable_irq(ts->client->irq);
+ PREPARE_WORK(&ts->work, gt801_ts_work_func);
+ printk("enabling gt801_ts IRQ %d\n", ts->client->irq);
+}
+
+
static int gt801_ts_resume(struct i2c_client *client)
{
struct gt801_ts_data *ts = i2c_get_clientdata(client);
gpio_set_value(ts->gpio_reset, ts->gpio_reset_active_low? GPIO_HIGH:GPIO_LOW);
if (ts->use_irq) {
- printk("enabling IRQ %d\n", client->irq);
- enable_irq(client->irq);
+ if(!work_pending(&ts->work)){
+ PREPARE_WORK(&ts->work, gt801_ts_resume_work_func);
+ queue_work(gt801_wq, &ts->work);
+ }
}
- else
+ else {
hrtimer_start(&ts->timer, ktime_set(1, 0), HRTIMER_MODE_REL);
+ }
return 0;
}