/*****************************************************************************
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* ft5306_driver.c
*
* Project:
* --------
* W900
*
* Author:
* -------
* cheehwa,"yuanjianhua@konka.com"
*
* Description:
* ------------
* CTP's driver for FocalTech's chip FT5306
*
*
*============================================================================
* History:
* Sun Feb 12 2012, creat
*
*============================================================================
****************************************************************************/
#include "tpd.h"
#include <linux/interrupt.h>
#include <cust_eint.h>
#include <linux/i2c.h>
#include <linux/sched.h>
#include <linux/kthread.h>
#include <linux/rtpm_prio.h>
#include <linux/wait.h>
#include <linux/time.h>
#include <linux/delay.h>
#include "tpd_custom_ft5306.h"
#include "cust_gpio_usage.h"
#ifdef MT6575
#include <mach/mt6575_pm_ldo.h>
#include <mach/mt6575_typedefs.h>
#include <mach/mt6575_boot.h>
#endif
#include <mach/mt6573_boot.h>
/*****************************************************************************
* E X T E R N A L R E F E R E N C E S
******************************************************************************
*/
extern struct tpd_device *tpd;
extern int tpd_firmware_version[2];
struct i2c_client *i2c_client = NULL;
struct task_struct *thread = NULL;
/*****************************************************************************
* F U N C T I O N D E L A R A T I O N
******************************************************************************
*/
void tpd_button(unsigned int x, unsigned int y, unsigned int down);
static DECLARE_WAIT_QUEUE_HEAD(waiter);
static void tpd_eint_interrupt_handler(void);
extern void mt65xx_eint_unmask(unsigned int line);
extern void mt65xx_eint_mask(unsigned int line);
extern void mt65xx_eint_set_hw_debounce(kal_uint8 eintno, kal_uint32 ms);
extern kal_uint32 mt65xx_eint_set_sens(kal_uint8 eintno, kal_bool sens);
extern void mt65xx_eint_registration(kal_uint8 eintno, kal_bool Dbounce_En,
kal_bool ACT_Polarity, void (EINT_FUNC_PTR)(void),
kal_bool auto_umask);
static int __devinit tpd_probe(struct i2c_client *client, const struct i2c_device_id *id);
static int tpd_detect(struct i2c_client *client, int kind, struct i2c_board_info *info);
static int __devexit tpd_remove(struct i2c_client *client);
static int touch_event_handler(void *unused);
/*****************************************************************************
* C O N S T A N T S
******************************************************************************
*/
static int boot_mode = 0;
static int tpd_flag = 0;
static int point_num = 0;
static int p_point_num = 0;
#define TP_DEBUG
//#define TP_LIB_UPGRADE_SWITCH del by zhy
#define TP_LIB_NAME "IT_BM_Konka_W900_V11_20120306_app.i"
#define TP_LIB_VERSION 0x14
#define FT5X0X_REG_FIRMID 0xA6
#define FT5X06_MOD_ID 0xA8
#define I2C_CTP_ADDRESS 0x70
#define FTS_PACKET_LENGTH 2
#define TPD_OK 0
#define DEVICE_MODE 0x00
#define GEST_ID 0x01
#define TD_STATUS 0x02
#define TOUCH1_XH 0x03
#define TOUCH1_XL 0x04
#define TOUCH1_YH 0x05
#define TOUCH1_YL 0x06
#define TOUCH2_XH 0x09
#define TOUCH2_XL 0x0A
#define TOUCH2_YH 0x0B
#define TOUCH2_YL 0x0C
#define TOUCH3_XH 0x0F
#define TOUCH3_XL 0x10
#define TOUCH3_YH 0x11
#define TOUCH3_YL 0x12
#define FTS_NULL 0x0
#define FTS_TRUE 0x1
#define FTS_FALSE 0x0
#if defined(TP_DEBUG)
#define pr_tp(format, args...) printk("<0>" format, ##args)
#define pr_ch(format, arg...) \
printk("<0>" "%s <%d>,%s(),cheehwa_print:\n\t" \
format,__FILE__,__LINE__,__func__, ##arg)
#else
#define pr_tp(format, args...) do {} while (0)
#define pr_ch(format, arg...) do {} while (0)
#undef pr_k(format, arg...)
#define pr_k(format, arg...) do {} while (0)
#endif
/*****************************************************************************
* D A T A T Y P E S
******************************************************************************
*/
typedef unsigned char FTS_BYTE;
typedef unsigned short FTS_WORD;
typedef unsigned int FTS_DWRD;
typedef unsigned char FTS_BOOL;
#ifdef TPD_HAVE_BUTTON
static int tpd_keys_local[TPD_KEY_COUNT] = TPD_KEYS;
static int tpd_keys_dim_local[TPD_KEY_COUNT][4] = TPD_KEYS_DIM;
#endif
#if (defined(TPD_WARP_START) && defined(TPD_WARP_END))
static int tpd_wb_start_local[TPD_WARP_CNT] = TPD_WARP_START;
static int tpd_wb_end_local[TPD_WARP_CNT] = TPD_WARP_END;
#endif
#if (defined(TPD_HAVE_CALIBRATION) && !defined(TPD_CUSTOM_CALIBRATION))
static int tpd_calmat_local[8] = TPD_CALIBRATION_MATRIX;
static int tpd_def_calmat_local[8] = TPD_CALIBRATION_MATRIX;
#endif
typedef struct _REPORT_FINGER_INFO_T
{
short ui2_id; /* ID information, from 0 to CFG_MAX_POINT_NUM - 1*/
short u2_pressure; /* ***pressure information, valid from 0 -63 **********/
short i2_x; /*********** X coordinate, 0 - 2047 ****************/
short i2_y; /* **********Y coordinate, 0 - 2047 ****************/
} REPORT_FINGER_INFO_T;
struct touch_info
{
int y[3];
int x[3];
int p[3];
int count;
};
int ft5206_keycodes[4] =
{
KEY_HOME,
KEY_MENU,
KEY_BACK,
KEY_SEARCH
};
typedef enum
{
ERR_OK,
ERR_MODE,
ERR_READID,
ERR_ERASE,
ERR_STATUS,
ERR_ECC,
ERR_DL_ERASE_FAIL,
ERR_DL_PROGRAM_FAIL,
ERR_DL_VERIFY_FAIL
} E_UPGRADE_ERR_TYPE;
static const struct i2c_device_id tpd_id[] = {{TPD_DEVICE, 0}, {}};
unsigned short force[] = {0, I2C_CTP_ADDRESS, I2C_CLIENT_END, I2C_CLIENT_END};
static const unsigned short *const forces[] = { force, NULL };
static struct i2c_client_address_data addr_data = { .forces = forces, };
/*****************************************************************************
* F U N C T I O N D E F I N I T I O N
******************************************************************************
*/
static struct i2c_driver tpd_i2c_driver =
{
.driver = {
.name = TPD_DEVICE,
.owner = THIS_MODULE,
},
.probe = tpd_probe,
.remove = __devexit_p(tpd_remove),
.id_table = tpd_id,
.detect = tpd_detect,
.address_data = &addr_data,
};
//#ifdef TP_LIB_UPGRADE_SWITCH
static unsigned char CTPM_FW[] =
{
//#include TP_LIB_NAME del by zhy
};
//#endif
static int fts_i2c_txdata(u8 *txdata, int length)
{
int ret;
struct i2c_msg msg;
msg.addr = i2c_client->addr;
msg.flags = 0;
msg.len = length;
msg.buf = txdata;
ret = i2c_transfer(i2c_client->adapter, &msg, 1);
if(ret < 0)
{
pr_err("%s i2c write error: %d\n", __func__, ret);
}
return ret;
}
static bool i2c_write_interface(u8 *pbt_buf, int dw_lenth)
{
int ret;
ret = i2c_master_send(i2c_clie
ft5306_driver.rar_FT5306_平板_电容 FT
版权申诉
159 浏览量
2022-09-14
20:09:02
上传
评论
收藏 8KB RAR 举报
小波思基
- 粉丝: 74
- 资源: 1万+