|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区
您需要 登录 才可以下载或查看,没有账号?立即注册
×
/* drivers/input/touchscreen/gt811.c * * Copyright (C) 2010 - 2011 Goodix, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * *Any problem,please contact andrew@goodix.com,+86 755-33338828 * */#include <linux/kernel.h>#include <linux/module.h>#include <linux/time.h>#include <linux/delay.h>#include <linux/device.h>#include <linux/earlysuspend.h>#include <linux/hrtimer.h>#include <linux/i2c.h>#include <linux/input.h>#include <linux/interrupt.h>#include <linux/io.h>#include <linux/platform_device.h>#include <mach/gpio.h>//#include <plat/gpio-cfg.h>//#include <plat/gpio-bank-l.h>//#include <plat/gpio-bank-f.h>#include <linux/irq.h>#include <linux/syscalls.h>#include <linux/reboot.h>#include <linux/proc_fs.h>#include "86v_gt811_ts.h"#include "gt811_firmware.h"#include <linux/vmalloc.h>#include <linux/fs.h>#include <linux/string.h>#include <linux/completion.h>#include <asm/uaccess.h>#include <linux/input/mt.h>#include <mach/iomux.h>static struct workqueue_struct *goodix_wq;static const char *s3c_ts_name = "gt811_ts";//static struct point_queue finger_list;struct i2c_client * i2c_connect_client = NULL;//EXPORT_SYMBOL(i2c_connect_client);static struct proc_dir_entry *goodix_proc_entry;static short goodix_read_version(struct gt811_ts_data *ts);//static int tpd_button(struct gt811_ts_data *ts, unsigned int x, unsigned int y, unsigned int down);#ifdef CONFIG_HAS_EARLYSUSPENDstatic void goodix_ts_early_suspend(struct early_suspend *h);static void goodix_ts_late_resume(struct early_suspend *h);int gt811_downloader( struct gt811_ts_data *ts, unsigned char * data);#endif//used by firmware update CRCunsigned int oldcrc32 = 0xFFFFFFFF;unsigned int crc32_table[256];unsigned int ulPolynomial = 0x04c11db7;unsigned int raw_data_ready = RAW_DATA_NON_ACTIVE;#ifdef DEBUGint sum = 0;int access_count = 0;int int_count = 0;#endif#define HAVE_TOUCH_KEY //#define READ_KEY_VALUE //#define READ_KEY_COOR#ifdef HAVE_TOUCH_KEY const uint16_t touch_key_array[]={ KEY_MENU, //MENU KEY_HOMEPAGE, KEY_BACK, KEY_SEARCH };#define MAX_KEY_NUM (sizeof(touch_key_array)/sizeof(touch_key_array[0]))#endif/******************************************************* Function: Read data from the slave Each read operation with two i2c_msg composition, for the first message sent from the machine address, Article 2 reads the address used to send and retrieve data; each message sent before the start signalParameters: client: i2c devices, including device address buf [0]: The first byte to read Address buf [1] ~ buf [len]: data buffer len: the length of read datareturn: Execution messages*********************************************************//*Function as i2c_master_send */static int i2c_read_bytes(struct i2c_client *client, uint8_t *buf, int len){ struct i2c_msg msgs[2]; int ret=-1; msgs[0].flags=!I2C_M_RD; msgs[0].addr=client->addr; msgs[0].len=2; msgs[0].buf=&buf[0]; msgs[0].scl_rate=200000; msgs[1].flags=I2C_M_RD; msgs[1].addr=client->addr; msgs[1].len=len-2; msgs[1].buf=&buf[2]; msgs[1].scl_rate=200000; ret=i2c_transfer(client->adapter,msgs, 2); return ret;}/******************************************************* Function: Write data to a slaveParameters: client: i2c devices, including device address buf [0]: The first byte of the write address buf [1] ~ buf [len]: data buffer len: data lengthreturn: Execution messages*******************************************************//*Function as i2c_master_send */static int i2c_write_bytes(struct i2c_client *client,uint8_t *data,int len){ struct i2c_msg msg; int ret=-1; //发送设备地址 msg.flags=!I2C_M_RD;//写消�? msg.addr=client->addr; msg.len=len; msg.buf=data; msg.scl_rate=200000; msg.addr=client->addr; ret=i2c_transfer(client->adapter,&msg, 1); return ret;}/*******************************************************Function: Send a prefix command Parameters: ts: client private data structure return: Results of the implementation code, 0 for normal execution*******************************************************/static int i2c_pre_cmd(struct gt811_ts_data *ts){ int ret; uint8_t pre_cmd_data[2]={0}; pre_cmd_data[0]=0x0f; pre_cmd_data[1]=0xff; ret=i2c_write_bytes(ts->client,pre_cmd_data,2); //msleep(2); return ret;}/*******************************************************Function: Send a suffix command Parameters: ts: client private data structure return: Results of the implementation code, 0 for normal execution*******************************************************/static int i2c_end_cmd(struct gt811_ts_data *ts){ int ret; uint8_t end_cmd_data[2]={0}; end_cmd_data[0]=0x80; end_cmd_data[1]=0x00; ret=i2c_write_bytes(ts->client,end_cmd_data,2); //msleep(2); return ret;}/*****************************************************************************************************************************************/#ifdef COOR_TO_KEYstatic int list_key(s32 x_value, s32 y_value, u8* key){ s32 i;#ifdef AREA_Y if (y_value <= AREA_Y)#else if (x_value <= AREA_X)#endif { return 0; } for (i = 0; i < MAX_KEY_NUM; i++) { if (abs(key_center[x] - x_value) < KEY_X && abs(key_center[y] - y_value) < KEY_Y) { (*key) |= (0x01<<i); } } return 1;}#endif /*******************************************************Function: Guitar initialization function, used to send configuration information, access to version informationParameters: ts: client private data structurereturn: Results of the implementation code, 0 for normal execution*******************************************************/static int goodix_init_panel(struct gt811_ts_data *ts){ |
|