diff --git a/drivers/input/touchscreen/ili9882_mmi/Android.mk b/drivers/input/touchscreen/ili9882_mmi/Android.mk index 836d0ffa6f58..cb7ddfb24ea6 100644 --- a/drivers/input/touchscreen/ili9882_mmi/Android.mk +++ b/drivers/input/touchscreen/ili9882_mmi/Android.mk @@ -47,6 +47,10 @@ ifeq ($(ILITEK_PANEL_GESTURE),true) KERNEL_CFLAGS += CONFIG_ILITEK_PANEL_GESTURE=y endif +ifeq ($(ILITEK_PASSIVE_PEN),true) + KBUILD_OPTIONS += CONFIG_ILITEK_PASSIVE_PEN=y +endif + include $(CLEAR_VARS) ifneq ($(BOARD_USES_DOUBLE_TAP),) LOCAL_ADDITIONAL_DEPENDENCIES += $(KERNEL_MODULES_OUT)/sensors_class.ko diff --git a/drivers/input/touchscreen/ili9882_mmi/Kbuild b/drivers/input/touchscreen/ili9882_mmi/Kbuild index 9f941d1eb0b9..6b97be6491fb 100644 --- a/drivers/input/touchscreen/ili9882_mmi/Kbuild +++ b/drivers/input/touchscreen/ili9882_mmi/Kbuild @@ -47,6 +47,10 @@ ifneq ($(filter m y,$(CONFIG_DRM_PANEL_EVENT_NOTIFICATIONS)),) EXTRA_CFLAGS += -DCONFIG_DRM_PANEL_EVENT_NOTIFICATIONS endif +ifneq ($(filter m y,$(CONFIG_ILITEK_PASSIVE_PEN)),) +EXTRA_CFLAGS += -DILI_PASSIVE_PEN +endif + ili9882_mmi-objs += ili9882.o ili9882_mmi-objs += ili9882_spi.o ili9882_mmi-objs += ili9882_qcom.o diff --git a/drivers/input/touchscreen/ili9882_mmi/ili9882.c b/drivers/input/touchscreen/ili9882_mmi/ili9882.c index 46f329ab913a..be79048fe414 100644 --- a/drivers/input/touchscreen/ili9882_mmi/ili9882.c +++ b/drivers/input/touchscreen/ili9882_mmi/ili9882.c @@ -658,11 +658,26 @@ int ili_set_tp_data_len(int format, bool send, u8* data) switch (format) { case DATA_FORMAT_DEMO: + if (TOUCH_WIDTH) + len = P5_X_5B_LOW_RESOLUTION_LENGTH + P5_X_CUSTOMER_LENGTH; + else + len = P5_X_DEMO_MODE_PACKET_LEN; + + ctrl = DATA_FORMAT_DEMO_CMD; + break; case DATA_FORMAT_GESTURE_DEMO: len = P5_X_DEMO_MODE_PACKET_LEN; ctrl = DATA_FORMAT_DEMO_CMD; break; case DATA_FORMAT_DEBUG: + len = (2 * ilits->xch_num * ilits->ych_num) + (ilits->stx * 2) + (ilits->srx * 2); + len += 2 * self_key + (8 * 2) + 1 + 35; + if (TOUCH_WIDTH) + len += P5_X_CUSTOMER_LENGTH; + + ctrl = DATA_FORMAT_DEBUG_CMD; + break; + case DATA_FORMAT_GESTURE_DEBUG: len = (2 * ilits->xch_num * ilits->ych_num) + (ilits->stx * 2) + (ilits->srx * 2); len += 2 * self_key + (8 * 2) + 1 + 35; @@ -862,6 +877,12 @@ int ili_report_handler(void) case P5_X_DEBUG_PACKET_ID: ili_report_debug_mode(trdata, rlen); break; + case P5_X_DEMO_HIGH_RESOLUTION_PACKET_ID: + ili_report_ap_mode(trdata, rlen); + break; + case P5_X_DEBUG_HIGH_RESOLUTION_PACKET_ID: + ili_report_debug_mode(trdata, rlen); + break; case P5_X_DEBUG_LITE_PACKET_ID: ili_report_debug_lite_mode(trdata, rlen); break; @@ -943,7 +964,11 @@ int ili_reset_ctrl(int mode) atomic_set(&ilits->ice_stat, DISABLE); ilits->tp_data_format = DATA_FORMAT_DEMO; - ilits->tp_data_len = P5_X_DEMO_MODE_PACKET_LEN; + if (TOUCH_WIDTH) + ilits->tp_data_len = P5_X_5B_LOW_RESOLUTION_LENGTH + P5_X_CUSTOMER_LENGTH; + else + ilits->tp_data_len = P5_X_DEMO_MODE_PACKET_LEN; + ilits->pll_clk_wakeup = true; atomic_set(&ilits->tp_reset, END); return ret; diff --git a/drivers/input/touchscreen/ili9882_mmi/ili9882.h b/drivers/input/touchscreen/ili9882_mmi/ili9882.h index cf0fdae152a7..70f4a1ab94e6 100755 --- a/drivers/input/touchscreen/ili9882_mmi/ili9882.h +++ b/drivers/input/touchscreen/ili9882_mmi/ili9882.h @@ -138,7 +138,13 @@ #define MP_INT_TIMEOUT 5000 /*5s*/ #define MT_B_TYPE ENABLE #define TDDI_RST_BIND DISABLE +#ifdef ILI_PASSIVE_PEN +#define MT_PRESSURE ENABLE +#define TOUCH_WIDTH ENABLE +#else #define MT_PRESSURE DISABLE +#define TOUCH_WIDTH DISABLE +#endif #ifdef ILI_CONFIG_ESD #define ENABLE_WQ_ESD ENABLE #else @@ -483,7 +489,7 @@ struct report_info_block { #define CORE_VER_1430 0x01040300 #define CORE_VER_1460 0x01040600 #define CORE_VER_1470 0x01040700 -#define MAX_HEX_FILE_SIZE (160*K) +#define MAX_HEX_FILE_SIZE (256*K) #define ILI_FILE_HEADER 256 #define DLM_START_ADDRESS 0x20610 #define DLM_HEX_ADDRESS 0x10000 @@ -728,6 +734,7 @@ struct report_info_block { #define DATA_FORMAT_DEBUG_LITE_ROI_CMD 0x01 #define DATA_FORMAT_DEBUG_LITE_WINDOW_CMD 0x02 #define DATA_FORMAT_DEBUG_LITE_AREA_CMD 0x03 +#define P5_X_DEMO_MODE_PACKET_INFO_LEN 3 #define P5_X_DEMO_MODE_PACKET_LEN 43 #define P5_X_INFO_HEADER_LENGTH 3 #define P5_X_INFO_CHECKSUM_LENGTH 1 @@ -739,6 +746,8 @@ struct report_info_block { #define P5_X_DEBUG_LITE_LENGTH 300 #define P5_X_CORE_VER_THREE_LENGTH 5 #define P5_X_CORE_VER_FOUR_LENGTH 6 +#define P5_X_5B_LOW_RESOLUTION_LENGTH 62 +#define P5_X_CUSTOMER_LENGTH 50 /* Protocol */ @@ -774,6 +783,11 @@ struct report_info_block { #define P5_X_FW_RAW_DATA_MODE 0x08 #define P5_X_DEMO_PACKET_ID 0x5A #define P5_X_DEBUG_PACKET_ID 0xA7 +#define P5_X_DEMO_HIGH_RESOLUTION_PACKET_ID 0x5B +#define P5_X_DEBUG_HIGH_RESOLUTION_PACKET_ID 0xA8 +#define P5_X_DEMO_MODE_AXIS_LEN 50 +#define P5_X_DEMO_MODE_STATE_INFO 16 + #define P5_X_TEST_PACKET_ID 0xF2 #define P5_X_GESTURE_PACKET_ID 0xAA #define P5_X_GESTURE_FAIL_ID 0xAE @@ -1023,6 +1037,9 @@ struct ilitek_touch_info { u16 x; u16 y; u16 pressure; + s8 degree; + u16 width_major; + u16 width_minor; }; struct gesture_coordinate { @@ -1118,6 +1135,7 @@ extern int ili_move_gesture_code_iram(int mode); extern int ili_move_mp_code_flash(void); extern int ili_move_mp_code_iram(void); extern void ili_touch_press(u16 x, u16 y, u16 pressure, u16 id); +extern void ili_touch_press_width(u16 x, u16 y, u16 pressure, u16 id, u16 width_major, u16 width_minor, s8 degree); extern void ili_touch_release(u16 x, u16 y, u16 id); extern void ili_touch_release_all_point(void); extern void ili_report_ap_mode(u8 *buf, int len); diff --git a/drivers/input/touchscreen/ili9882_mmi/ili9882_ic.c b/drivers/input/touchscreen/ili9882_mmi/ili9882_ic.c index 22dd3101e7d8..ce4d439a96fa 100755 --- a/drivers/input/touchscreen/ili9882_mmi/ili9882_ic.c +++ b/drivers/input/touchscreen/ili9882_mmi/ili9882_ic.c @@ -35,7 +35,7 @@ static struct ilitek_protocol_info protocol_info[PROTOCL_VER_NUM] = { [7] = {PROTOCOL_VER_570, 9, 4, 14, 30, 5, 5, 3, 8, 15, 14}, }; -#define FUNC_CTRL_NUM 16 +#define FUNC_CTRL_NUM 18 static struct ilitek_ic_func_ctrl func_ctrl[FUNC_CTRL_NUM] = { /* cmd[3] = cmd, func, ctrl */ // rec_state 0:disable, 1: enable, 2: ignore record @@ -55,6 +55,8 @@ static struct ilitek_ic_func_ctrl func_ctrl[FUNC_CTRL_NUM] = { [13] = {"knock_en", {0x1, 0xA, 0x8, 0x03, 0x0, 0x0}, 6, 0xFF, 0, 0xFF}, [14] = {"int_trigger", {0x1, 0x1B, 0x0}, 3, 0x0, 2, 0xFF}, [15] = {"ear_phone", {0x1, 0x17, 0x0}, 3, 0x0, 0, 0xFF}, + [16] = {"passive_pen", {0x1, 0x27, 0x0}, 3, 0x0, 0, 0xFF}, + [17] = {"canvas", {0x1, 0x28, 0x0}, 3, 0x0, 0, 0xFF}, }; #define CHIP_SUP_NUM 5 diff --git a/drivers/input/touchscreen/ili9882_mmi/ili9882_node.c b/drivers/input/touchscreen/ili9882_mmi/ili9882_node.c index 6e557a826164..1aff8a7e1508 100755 --- a/drivers/input/touchscreen/ili9882_mmi/ili9882_node.c +++ b/drivers/input/touchscreen/ili9882_mmi/ili9882_node.c @@ -706,7 +706,75 @@ out: mutex_unlock(&ilits->touch_mutex); return size; } +static ssize_t ilitek_proc_passive_pen_write(struct file *filp, const char *buff, size_t size, loff_t *pos) +{ + char cmd[256] = { 0 }; + int glove_value =0; + if ((size - 1) > sizeof(cmd)) { + ILI_ERR("ERROR! input length is larger than local buffer\n"); + return -1; + } + + mutex_lock(&ilits->touch_mutex); + + if (buff != NULL) { + if (copy_from_user(cmd, buff, size - 1)) { + ILI_INFO("Failed to copy data from user space\n"); + size = -1; + goto out; + } + } + sscanf(cmd, "%x", &glove_value); + ILI_INFO("glove status:%x\n",glove_value); + if (!glove_value) { + if (ili_ic_func_ctrl("passive_pen", DISABLE) < 0) + ILI_ERR("Write glove disable fail\n"); + } + else { + if (ili_ic_func_ctrl("passive_pen", ENABLE) < 0) + ILI_ERR("Write glove enable fail\n"); + } + +out: + mutex_unlock(&ilits->touch_mutex); + return size; +} + +static ssize_t ilitek_proc_canvas_write(struct file *filp, const char *buff, size_t size, loff_t *pos) +{ + char cmd[256] = { 0 }; + int stylus_value =0; + + if ((size - 1) > sizeof(cmd)) { + ILI_ERR("ERROR! input length is larger than local buffer\n"); + return -1; + } + + mutex_lock(&ilits->touch_mutex); + + if (buff != NULL) { + if (copy_from_user(cmd, buff, size - 1)) { + ILI_INFO("Failed to copy data from user space\n"); + size = -1; + goto out; + } + } + sscanf(cmd, "%x", &stylus_value); + ILI_INFO("stylus status:%x\n",stylus_value); + if (!stylus_value) { + if (ili_ic_func_ctrl("canvas", DISABLE) < 0) + ILI_ERR("Write stylus disable fail\n"); + } + else { + if (ili_ic_func_ctrl("canvas", ENABLE) < 0) + ILI_ERR("Write stylus enable fail\n"); + } + +out: + mutex_unlock(&ilits->touch_mutex); + return size; +} static ssize_t ilitek_proc_debug_switch_read(struct file *pFile, char __user *buff, size_t size, loff_t *pos) { bool open; @@ -716,7 +784,7 @@ static ssize_t ilitek_proc_debug_switch_read(struct file *pFile, char __user *bu memset(g_user_buf, 0, USER_STR_BUFF * sizeof(unsigned char)); - mutex_lock(&ilits->debug_mutex); + mutex_lock(&ilits->debug_read_mutex); open = !ilits->dnp; @@ -728,7 +796,7 @@ static ssize_t ilitek_proc_debug_switch_read(struct file *pFile, char __user *bu if (copy_to_user(buff, g_user_buf, size)) ILI_ERR("Failed to copy data to user space\n"); - mutex_unlock(&ilits->debug_mutex); + mutex_unlock(&ilits->debug_read_mutex); return size; } @@ -775,6 +843,9 @@ static ssize_t ilitek_proc_debug_message_read(struct file *filp, char __user *bu if (ilits->dbl[ilits->odi].mark) { if (ilits->dbl[ilits->odi].data[0] == P5_X_DEMO_PACKET_ID) { need_read_data_len = 43; + } else if (ilits->dbl[ilits->odi].data[0] == P5_X_DEMO_HIGH_RESOLUTION_PACKET_ID) { + need_read_data_len = P5_X_5B_LOW_RESOLUTION_LENGTH; + need_read_data_len += P5_X_CUSTOMER_LENGTH; } else if (ilits->dbl[ilits->odi].data[0] == P5_X_I2CUART_PACKET_ID) { type = ilits->dbl[ilits->odi].data[3] & 0x0F; @@ -791,6 +862,11 @@ static ssize_t ilitek_proc_debug_message_read(struct file *filp, char __user *bu } else if (ilits->dbl[ilits->odi].data[0] == P5_X_DEBUG_PACKET_ID || ilits->dbl[ilits->odi].data[0] == P5_X_DEBUG_LITE_PACKET_ID) { send_data_len = 0; /* ilits->dbl[0][1] - 2; */ need_read_data_len = TR_BUF_SIZE - 8; + } else if (ilits->dbl[ilits->odi].data[0] == P5_X_I2CUART_PACKET_ID) { + need_read_data_len = P5_X_DEMO_MODE_PACKET_LEN+P5_X_DEMO_MODE_AXIS_LEN+P5_X_DEMO_MODE_STATE_INFO; + } else if (ilits->dbl[ilits->odi].data[0] == P5_X_DEBUG_HIGH_RESOLUTION_PACKET_ID) { + send_data_len = 0; /* ilits->dbl[0][1] - 2; */ + need_read_data_len = TR_BUF_SIZE - 8; } for (i = 0; i < need_read_data_len; i++) { @@ -1885,23 +1961,23 @@ static long ilitek_node_compat_ioctl(struct file *filp, unsigned int cmd, unsign return ret; case ILITEK_COMPAT_IOCTL_TP_PANEL_INFO: ILI_DBG("compat_ioctl: convert resolution\n"); - ret = filp->f_op->unlocked_ioctl(filp, ILITEK_COMPAT_IOCTL_TP_PANEL_INFO, (unsigned long)compat_ptr(arg)); + ret = filp->f_op->unlocked_ioctl(filp, ILITEK_IOCTL_TP_PANEL_INFO, (unsigned long)compat_ptr(arg)); return ret; case ILITEK_COMPAT_IOCTL_TP_INFO: ILI_DBG("compat_ioctl: convert tp info\n"); - ret = filp->f_op->unlocked_ioctl(filp, ILITEK_COMPAT_IOCTL_TP_INFO, (unsigned long)compat_ptr(arg)); + ret = filp->f_op->unlocked_ioctl(filp, ILITEK_IOCTL_TP_INFO, (unsigned long)compat_ptr(arg)); return ret; case ILITEK_COMPAT_IOCTL_WRAPPER_RW: ILI_DBG("compat_ioctl: convert wrapper\n"); - ret = filp->f_op->unlocked_ioctl(filp, ILITEK_COMPAT_IOCTL_WRAPPER_RW, (unsigned long)compat_ptr(arg)); + ret = filp->f_op->unlocked_ioctl(filp, ILITEK_IOCTL_WRAPPER_RW, (unsigned long)compat_ptr(arg)); return ret; case ILITEK_COMPAT_IOCTL_DDI_WRITE: ILI_DBG("compat_ioctl: convert ddi write\n"); - ret = filp->f_op->unlocked_ioctl(filp, ILITEK_COMPAT_IOCTL_DDI_WRITE, (unsigned long)compat_ptr(arg)); + ret = filp->f_op->unlocked_ioctl(filp, ILITEK_IOCTL_DDI_WRITE, (unsigned long)compat_ptr(arg)); return ret; case ILITEK_COMPAT_IOCTL_DDI_READ: ILI_DBG("compat_ioctl: convert ddi read\n"); - ret = filp->f_op->unlocked_ioctl(filp, ILITEK_COMPAT_IOCTL_DDI_READ, (unsigned long)compat_ptr(arg)); + ret = filp->f_op->unlocked_ioctl(filp, ILITEK_IOCTL_DDI_READ, (unsigned long)compat_ptr(arg)); return ret; default: ILI_ERR("no ioctl cmd, return ilitek_node_ioctl\n"); @@ -2204,8 +2280,9 @@ static long ilitek_node_ioctl(struct file *filp, unsigned int cmd, unsigned long ILI_DBG("ioctl: get panel resolution\n"); id_to_user[0] = ilits->panel_wid; id_to_user[1] = ilits->panel_hei; + id_to_user[2] = (ilits->trans_xy) ? 0x1 : 0x0; - if (copy_to_user((u32 *) arg, id_to_user, sizeof(u32) * 2)) { + if (copy_to_user((u32 *) arg, id_to_user, sizeof(u32) * 3)) { ILI_ERR("Failed to copy driver ver to user space\n"); ret = -ENOTTY; } @@ -2474,6 +2551,22 @@ static struct file_operations proc_rw_tp_reg_fops = { }; #endif +#if LINUX_VERSION_CODE > KERNEL_VERSION(5, 6, 0) +static struct proc_ops proc_passive_pen_ctrl_fops = { + .proc_write = ilitek_proc_passive_pen_write, +}; +static struct proc_ops proc_canvas_ctrl_fops = { + .proc_write = ilitek_proc_canvas_write, +}; +#else +static struct file_operations proc_passive_pen_ctrl_fops = { + .write = ilitek_proc_passive_pen_write, +}; +static struct file_operations proc_canvas_ctrl_fops = { + .write = ilitek_proc_canvas_write, +}; +#endif + #if LINUX_VERSION_CODE > KERNEL_VERSION(5, 6, 0) static struct proc_ops proc_fw_pc_counter_fops = { .proc_read = ilitek_proc_fw_pc_counter_read, @@ -2522,6 +2615,9 @@ proc_node iliproc[] = { {"rw_tp_reg", NULL, &proc_rw_tp_reg_fops, false}, {"ver_info", NULL, &proc_ver_info_fops, false}, {"change_list", NULL, &proc_change_list_fops, false}, + {"passive_pen_ctrl", NULL, &proc_passive_pen_ctrl_fops, false}, + {"canvas_ctrl", NULL, &proc_canvas_ctrl_fops, false}, + }; #define NETLINK_USER 21 diff --git a/drivers/input/touchscreen/ili9882_mmi/ili9882_qcom.c b/drivers/input/touchscreen/ili9882_mmi/ili9882_qcom.c index 3c9f17434ee6..cb951d5e4c4b 100755 --- a/drivers/input/touchscreen/ili9882_mmi/ili9882_qcom.c +++ b/drivers/input/touchscreen/ili9882_mmi/ili9882_qcom.c @@ -93,8 +93,15 @@ void ili_input_register(void) input_set_abs_params(ilits->input, ABS_MT_POSITION_X, TOUCH_SCREEN_X_MIN, ilits->panel_wid - 1, 0, 0); input_set_abs_params(ilits->input, ABS_MT_POSITION_Y, TOUCH_SCREEN_Y_MIN, ilits->panel_hei - 1, 0, 0); - input_set_abs_params(ilits->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); - input_set_abs_params(ilits->input, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0); + if (!TOUCH_WIDTH) { + input_set_abs_params(ilits->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); + input_set_abs_params(ilits->input, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0); + } else { + input_set_abs_params(ilits->input, ABS_MT_TOUCH_MAJOR, 0, ilits->panel_hei - 1, 0, 0); + input_set_abs_params(ilits->input, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0); + input_set_abs_params(ilits->input, ABS_MT_TOUCH_MINOR, 0, ilits->panel_wid - 1, 0, 0); + input_set_abs_params(ilits->input, ABS_MT_ORIENTATION, -90, 90, 0, 0); + } if (MT_PRESSURE) input_set_abs_params(ilits->input, ABS_MT_PRESSURE, 0, 255, 0, 0); diff --git a/drivers/input/touchscreen/ili9882_mmi/ili9882_touch.c b/drivers/input/touchscreen/ili9882_mmi/ili9882_touch.c index e65b578f72a4..3d33a1bb6d45 100755 --- a/drivers/input/touchscreen/ili9882_mmi/ili9882_touch.c +++ b/drivers/input/touchscreen/ili9882_mmi/ili9882_touch.c @@ -467,7 +467,7 @@ void ili_set_gesture_symbol(void) int ili_move_gesture_code_iram(int mode) { - int i, ret = 0, timeout = 10; + int i, ret = 0, timeout = 100; u8 cmd[2] = {0}; u8 cmd_write[3] = {0x01,0x0A,0x05}; @@ -524,6 +524,7 @@ int ili_move_gesture_code_iram(int mode) break; } } + mdelay(2); ili_irq_disable(); if (i >= timeout) { @@ -648,6 +649,9 @@ int ili_touch_esd_gesture_iram(void) int ges_pwd = ESD_GESTURE_CORE146_PWD; int ges_run = SPI_ESD_GESTURE_CORE146_RUN; int pwd_len = 2; + + if (!ilits->gesture_load_code) + ges_run = I2C_ESD_GESTURE_CORE146_RUN; if (ilits->chip->core_ver < CORE_VER_1460) { if (ilits->chip->core_ver >= CORE_VER_1420) @@ -750,6 +754,7 @@ out: return ret; fail: + ilits->actual_tp_mode = P5_X_FW_GESTURE_MODE; ili_ice_mode_ctrl(DISABLE, ON); return ret; } @@ -856,6 +861,36 @@ out: mutex_unlock(&ilits->debug_mutex); } +void ili_touch_press_width(u16 x, u16 y, u16 pressure, u16 id, u16 width_major, u16 width_minor, s8 degree) +{ + ILI_DBG("Touch Press: id = %d, x = %d, y = %d, p = %d, width_major = %d, width_minor = %d, degree = %d\n", + id, x, y, pressure, width_major, width_minor, degree); + + if (MT_B_TYPE) { + input_mt_slot(ilits->input, id); + input_mt_report_slot_state(ilits->input, MT_TOOL_FINGER, true); + input_report_abs(ilits->input, ABS_MT_POSITION_X, x); + input_report_abs(ilits->input, ABS_MT_POSITION_Y, y); + input_report_abs(ilits->input, ABS_MT_TOUCH_MAJOR, width_major); + input_report_abs(ilits->input, ABS_MT_TOUCH_MINOR, width_minor); + input_report_abs(ilits->input, ABS_MT_ORIENTATION, degree); + + if (MT_PRESSURE) + input_report_abs(ilits->input, ABS_MT_PRESSURE, pressure); + } else { + input_report_key(ilits->input, BTN_TOUCH, 1); + input_report_abs(ilits->input, ABS_MT_TRACKING_ID, id); + input_report_abs(ilits->input, ABS_MT_TOUCH_MAJOR, 1); + input_report_abs(ilits->input, ABS_MT_WIDTH_MAJOR, 1); + input_report_abs(ilits->input, ABS_MT_POSITION_X, x); + input_report_abs(ilits->input, ABS_MT_POSITION_Y, y); + if (MT_PRESSURE) + input_report_abs(ilits->input, ABS_MT_PRESSURE, pressure); + + input_mt_sync(ilits->input); + } +} + void ili_touch_press(u16 x, u16 y, u16 pressure, u16 id) { ILI_DBG("Touch Press: id = %d, x = %d, y = %d, p = %d\n", id, x, y, pressure); @@ -916,22 +951,40 @@ void ili_report_ap_mode(u8 *buf, int len) { int i = 0; u32 xop = 0, yop = 0; + int index = 0; + + if (TOUCH_WIDTH && ilits->tp_data_format == DATA_FORMAT_DEMO) { + index = 45; + } + memset(touch_info, 0x0, sizeof(touch_info)); ilits->finger = 0; for (i = 0; i < MAX_TOUCH_NUM; i++) { - if ((buf[(4 * i) + 1] == 0xFF) && (buf[(4 * i) + 2] == 0xFF) - && (buf[(4 * i) + 3] == 0xFF)) { - if (MT_B_TYPE) - ilits->curt_touch[i] = 0; - continue; + if (TOUCH_WIDTH) { + if ((buf[(4 * i) + 1 + P5_X_DEMO_MODE_PACKET_INFO_LEN] == 0xFF) + && (buf[(4 * i) + 2 + P5_X_DEMO_MODE_PACKET_INFO_LEN] == 0xFF) + && (buf[(4 * i) + 3 + P5_X_DEMO_MODE_PACKET_INFO_LEN] == 0xFF)) { + if (MT_B_TYPE) + ilits->curt_touch[i] = 0; + continue; + } + + xop = (((buf[(4 * i) + 1 + P5_X_DEMO_MODE_PACKET_INFO_LEN] & 0xF0) << 4) | (buf[(4 * i) + 2 + P5_X_DEMO_MODE_PACKET_INFO_LEN])); + yop = (((buf[(4 * i) + 1 + P5_X_DEMO_MODE_PACKET_INFO_LEN] & 0x0F) << 8) | (buf[(4 * i) + 3 + P5_X_DEMO_MODE_PACKET_INFO_LEN])); + } else { + if ((buf[(4 * i) + 1] == 0xFF) && (buf[(4 * i) + 2] == 0xFF) + && (buf[(4 * i) + 3] == 0xFF)) { + if (MT_B_TYPE) + ilits->curt_touch[i] = 0; + continue; + } + + xop = (((buf[(4 * i) + 1] & 0xF0) << 4) | (buf[(4 * i) + 2])); + yop = (((buf[(4 * i) + 1] & 0x0F) << 8) | (buf[(4 * i) + 3])); } - - xop = (((buf[(4 * i) + 1] & 0xF0) << 4) | (buf[(4 * i) + 2])); - yop = (((buf[(4 * i) + 1] & 0x0F) << 8) | (buf[(4 * i) + 3])); - if (ilits->trans_xy) { touch_info[ilits->finger].x = xop; touch_info[ilits->finger].y = yop; @@ -942,10 +995,22 @@ void ili_report_ap_mode(u8 *buf, int len) touch_info[ilits->finger].id = i; - if (MT_PRESSURE) - touch_info[ilits->finger].pressure = buf[(4 * i) + 4]; - else + if (MT_PRESSURE) { + if (TOUCH_WIDTH) { + touch_info[ilits->finger].pressure = buf[(4 * i) + 4 + P5_X_DEMO_MODE_PACKET_INFO_LEN]; + } else { + touch_info[ilits->finger].pressure = buf[(4 * i) + 4]; + } + } else { touch_info[ilits->finger].pressure = 1; + } + + if (TOUCH_WIDTH && ilits->tp_data_format == DATA_FORMAT_DEMO) { + touch_info[ilits->finger].degree = buf[(5 * i) + index]; + touch_info[ilits->finger].width_major = (((buf[(5 * i) + 1 + index]) << 8) | (buf[(5 * i) + 2 + index])); + touch_info[ilits->finger].width_minor = (((buf[(5 * i) + 3 + index]) << 8) | (buf[(5 * i) + 4 + index])); + } + ILI_DBG("original x = %d, y = %d\n", xop, yop); ilits->finger++; @@ -959,7 +1024,12 @@ void ili_report_ap_mode(u8 *buf, int len) if (MT_B_TYPE) { for (i = 0; i < ilits->finger; i++) { input_report_key(ilits->input, BTN_TOUCH, 1); - ili_touch_press(touch_info[i].x, touch_info[i].y, touch_info[i].pressure, touch_info[i].id); + if (TOUCH_WIDTH && ilits->tp_data_format == DATA_FORMAT_DEMO) { + ili_touch_press_width(touch_info[i].x, touch_info[i].y, touch_info[i].pressure, touch_info[i].id, + touch_info[i].width_major, touch_info[i].width_minor, touch_info[i].degree); + } else { + ili_touch_press(touch_info[i].x, touch_info[i].y, touch_info[i].pressure, touch_info[i].id); + } input_report_key(ilits->input, BTN_TOOL_FINGER, 1); } for (i = 0; i < MAX_TOUCH_NUM; i++) { @@ -998,6 +1068,11 @@ void ili_debug_mode_report_point(u8 *buf, int len) int i = 0; u32 xop = 0, yop = 0; static u8 p[MAX_TOUCH_NUM]; + int index = 0; + + if (TOUCH_WIDTH && ilits->tp_data_format == DATA_FORMAT_DEBUG) { + index = 35 + (2 * ilits->xch_num * ilits->ych_num) + (ilits->stx * 2) + (ilits->srx * 2) + (2 * 2) - 5; + } memset(touch_info, 0x0, sizeof(touch_info)); @@ -1037,6 +1112,12 @@ void ili_debug_mode_report_point(u8 *buf, int len) touch_info[ilits->finger].pressure = 1; } + if (TOUCH_WIDTH && ilits->tp_data_format == DATA_FORMAT_DEBUG) { + touch_info[ilits->finger].degree = buf[(5 * i) + index]; + touch_info[ilits->finger].width_major = (((buf[(5 * i) + 1 + index]) << 8) | (buf[(5 * i) + 2 + index])); + touch_info[ilits->finger].width_minor = (((buf[(5 * i) + 3 + index]) << 8) | (buf[(5 * i) + 4 + index])); + } + ILI_DBG("original x = %d, y = %d\n", xop, yop); ilits->finger++; if (MT_B_TYPE) @@ -1049,7 +1130,12 @@ void ili_debug_mode_report_point(u8 *buf, int len) if (MT_B_TYPE) { for (i = 0; i < ilits->finger; i++) { input_report_key(ilits->input, BTN_TOUCH, 1); - ili_touch_press(touch_info[i].x, touch_info[i].y, touch_info[i].pressure, touch_info[i].id); + if (TOUCH_WIDTH && ilits->tp_data_format == DATA_FORMAT_DEBUG) { + ili_touch_press_width(touch_info[i].x, touch_info[i].y, touch_info[i].pressure, touch_info[i].id, + touch_info[i].width_major, touch_info[i].width_minor, touch_info[i].degree); + } else { + ili_touch_press(touch_info[i].x, touch_info[i].y, touch_info[i].pressure, touch_info[i].id); + } input_report_key(ilits->input, BTN_TOOL_FINGER, 1); } for (i = 0; i < MAX_TOUCH_NUM; i++) {