From 9869485b79440abed1a90ea7cf276bb101a58ef8 Mon Sep 17 00:00:00 2001 From: Richard Raya Date: Wed, 3 Jul 2024 02:08:54 -0300 Subject: [PATCH] msm-4.14: Cleanup xiaomi touchscreen drivers Change-Id: I33607bdaef6bfe3ff388f23b0fbc16542241fa12 Signed-off-by: Richard Raya --- arch/arm64/boot/dts/qcom/touchscreen.dtsi | 8 - arch/arm64/configs/surya_defconfig | 1 - drivers/gpu/drm/msm/dsi-staging/dsi_display.c | 147 -- drivers/gpu/drm/msm/dsi-staging/dsi_display.h | 5 - drivers/gpu/drm/msm/dsi-staging/dsi_drm.c | 17 - drivers/input/touchscreen/Kconfig | 7 +- drivers/input/touchscreen/Makefile | 3 +- drivers/input/touchscreen/lct_tp_gesture.c | 232 --- drivers/input/touchscreen/lct_tp_gesture.h | 12 - drivers/input/touchscreen/lct_tp_grip_area.c | 224 --- drivers/input/touchscreen/lct_tp_grip_area.h | 13 - drivers/input/touchscreen/lct_tp_info.c | 268 --- drivers/input/touchscreen/lct_tp_info.h | 28 - drivers/input/touchscreen/lct_tp_palm.c | 216 --- drivers/input/touchscreen/lct_tp_palm.h | 12 - drivers/input/touchscreen/lct_tp_selftest.c | 236 --- drivers/input/touchscreen/lct_tp_selftest.h | 36 - drivers/input/touchscreen/lct_tp_work.c | 216 --- drivers/input/touchscreen/lct_tp_work.h | 12 - .../input/touchscreen/nt36xxx_spi/nt36xxx.c | 833 -------- .../input/touchscreen/nt36xxx_spi/nt36xxx.h | 50 - .../nt36xxx_spi/nt36xxx_ext_proc.c | 1669 +---------------- .../nt36xxx_spi/nt36xxx_fw_update.c | 12 - drivers/input/touchscreen/xiaomi/Kconfig | 9 - drivers/input/touchscreen/xiaomi/Makefile | 1 - .../input/touchscreen/xiaomi/xiaomi_touch.c | 372 ---- .../input/touchscreen/xiaomi/xiaomi_touch.h | 96 - drivers/power/supply/qcom/smb5-lib.c | 20 - include/linux/msm_drm_notify.h | 5 - 29 files changed, 6 insertions(+), 4754 deletions(-) delete mode 100644 drivers/input/touchscreen/lct_tp_gesture.c delete mode 100644 drivers/input/touchscreen/lct_tp_gesture.h delete mode 100644 drivers/input/touchscreen/lct_tp_grip_area.c delete mode 100644 drivers/input/touchscreen/lct_tp_grip_area.h delete mode 100644 drivers/input/touchscreen/lct_tp_info.c delete mode 100644 drivers/input/touchscreen/lct_tp_info.h delete mode 100755 drivers/input/touchscreen/lct_tp_palm.c delete mode 100644 drivers/input/touchscreen/lct_tp_palm.h delete mode 100644 drivers/input/touchscreen/lct_tp_selftest.c delete mode 100644 drivers/input/touchscreen/lct_tp_selftest.h delete mode 100644 drivers/input/touchscreen/lct_tp_work.c delete mode 100644 drivers/input/touchscreen/lct_tp_work.h delete mode 100644 drivers/input/touchscreen/xiaomi/Kconfig delete mode 100644 drivers/input/touchscreen/xiaomi/Makefile delete mode 100644 drivers/input/touchscreen/xiaomi/xiaomi_touch.c delete mode 100644 drivers/input/touchscreen/xiaomi/xiaomi_touch.h diff --git a/arch/arm64/boot/dts/qcom/touchscreen.dtsi b/arch/arm64/boot/dts/qcom/touchscreen.dtsi index 00ba593c19ff..760df3897341 100644 --- a/arch/arm64/boot/dts/qcom/touchscreen.dtsi +++ b/arch/arm64/boot/dts/qcom/touchscreen.dtsi @@ -2,14 +2,6 @@ * TouchScreen Device Tree For Xiaomi J20 */ -&soc { - xiaomi_touch { - status = "ok"; - compatible = "xiaomi-touch"; - touch,name = "xiaomi-touch"; - }; -}; - &qupv3_se0_spi { status = "ok"; diff --git a/arch/arm64/configs/surya_defconfig b/arch/arm64/configs/surya_defconfig index 3bbbc9ad084e..1d220be8edbb 100644 --- a/arch/arm64/configs/surya_defconfig +++ b/arch/arm64/configs/surya_defconfig @@ -2032,7 +2032,6 @@ CONFIG_TOUCHSCREEN_PROPERTIES=y # CONFIG_TOUCHSCREEN_RAYDIUM_CHIPSET is not set CONFIG_TOUCHSCREEN_COMMON=y CONFIG_TOUCHSCREEN_NT36xxx_HOSTDL_SPI=y -CONFIG_TOUCHSCREEN_XIAOMI_TOUCHFEATURE=y # CONFIG_TOUCHSCREEN_FTS is not set CONFIG_INPUT_MISC=y # CONFIG_INPUT_AD714X is not set diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_display.c b/drivers/gpu/drm/msm/dsi-staging/dsi_display.c index 45bd1d287476..b4a5dc481213 100644 --- a/drivers/gpu/drm/msm/dsi-staging/dsi_display.c +++ b/drivers/gpu/drm/msm/dsi-staging/dsi_display.c @@ -5191,152 +5191,6 @@ static int dsi_display_sysfs_deinit(struct dsi_display *display) } -static char dcs_cmd[2] = {0x00, 0x00}; /* DTYPE_DCS_READ */ -static struct dsi_cmd_desc dcs_read_cmd = { - {0, 6, MIPI_DSI_MSG_REQ_ACK, 0, 5, sizeof(dcs_cmd), dcs_cmd, 0, 0}, - 1, - 5, -}; - -static int dsi_display_read_reg(struct dsi_display_ctrl *ctrl, char cmd0, - char cmd1, char *rbuf, int len) -{ - int rc = 0; - struct dsi_cmd_desc *cmds; - u32 flags = 0; - - if (!ctrl || !ctrl->ctrl) - return -EINVAL; - - /* - * When DSI controller is not in initialized state, we do not want to - * report a false failure and hence we defer until next read - * happen. - */ - if (!dsi_ctrl_validate_host_state(ctrl->ctrl)) - return 1; - - dcs_cmd[0] = cmd0; - dcs_cmd[1] = cmd1; - - cmds = &dcs_read_cmd; - flags |= (DSI_CTRL_CMD_FETCH_MEMORY | DSI_CTRL_CMD_READ); - - memset(rbuf, 0x0, SZ_4K); - if (cmds->last_command) { - cmds->msg.flags |= MIPI_DSI_MSG_LASTCOMMAND; - flags |= DSI_CTRL_CMD_LAST_COMMAND; - } - cmds->msg.rx_buf = rbuf; - cmds->msg.rx_len = len; - rc = dsi_ctrl_cmd_transfer(ctrl->ctrl, &cmds->msg, flags); - if (rc <= 0) { - pr_err("rx cmd transfer failed rc=%d\n", rc); - return rc; - } - pr_debug("rbuf[0]=%x,rbuf[1]=%x,rbuf[2]=%x,rbuf[3]=%x,rbuf[4]=%x,rbuf[5]=%x,rbuf[6]=%x,rbuf[7]=%x\n", - rbuf[0], rbuf[1], rbuf[2], rbuf[3], rbuf[4], rbuf[5], rbuf[6], rbuf[7]); - return rc; -} - -static char dcs_cmd_page[2] = {0x00, 0x00}; /* DTYPE_DCS_READ */ -static struct dsi_cmd_desc dcs_read_cmd_page = { - {0, 0x15, MIPI_DSI_MSG_REQ_ACK, 0, 5, sizeof(dcs_cmd_page), dcs_cmd_page, 0, 0}, - 1, - 5, -}; - -static int dsi_display_write_reg_page(struct dsi_display_ctrl *ctrl, char cmd0, - char cmd1, char *rbuf, int len) -{ - int rc = 0; - struct dsi_cmd_desc *cmds; - u32 flags = 0; - - if (!ctrl || !ctrl->ctrl) - return -EINVAL; - - if (!dsi_ctrl_validate_host_state(ctrl->ctrl)) - return 1; - - dcs_cmd_page[0] = cmd0; - dcs_cmd_page[1] = cmd1; - cmds = &dcs_read_cmd_page; - flags |= (DSI_CTRL_CMD_FETCH_MEMORY); - - memset(rbuf, 0x0, SZ_4K); - if (cmds->last_command) { - cmds->msg.flags |= MIPI_DSI_MSG_LASTCOMMAND; - flags |= DSI_CTRL_CMD_LAST_COMMAND; - } - cmds->msg.rx_buf = NULL; - cmds->msg.rx_len = 0; - rc = dsi_ctrl_cmd_transfer(ctrl->ctrl, &cmds->msg, flags); - if (rc < 0) { - pr_err("rx cmd transfer failed rc=%d\n", rc); - return rc; - } - - return rc; -} - -int lct_tp_lockdown_info_callback(void) -{ - bool is_already_read = false; - ssize_t rc = 0; - char *buf = NULL; - struct dsi_display *display; - struct dsi_display_ctrl *ctrl = NULL; - - if (is_already_read) - return 0; - - if (!display) { - pr_err("Invalid display\n"); - return -EINVAL; - } - - if (display->tx_cmd_buf == NULL) { - rc = dsi_host_alloc_cmd_tx_buffer(display); - if (rc) { - pr_err("failed to allocate cmd tx buffer memory\n"); - goto done; - } - } - - rc = dsi_display_cmd_engine_enable(display); - if (rc) { - pr_err("cmd engine enable failed\n"); - return -EPERM; - } - - buf = kzalloc(PAGE_SIZE, GFP_KERNEL); - if (IS_ERR_OR_NULL(buf)) { - pr_err("%s: kzalloc() request memory failed!\n", __func__); - return -ENOMEM; - } - - ctrl = &display->ctrl[display->cmd_master_idx]; - rc = dsi_display_write_reg_page(ctrl, 0xFF, 0x21, buf, sizeof(buf)); - rc = dsi_display_read_reg(ctrl, 0xF1, 0x00, buf, sizeof(buf)); - if (rc < 0) { - pr_err("get lockdown failed rc=%d\n", rc); - goto exit; - } - - rc = snprintf(buf, PAGE_SIZE, "%02X%02X%02X%02X%02X%02X%02X%02X\n", - buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]); - - update_lct_tp_info(NULL, buf); - is_already_read = true; - -exit: - kfree(buf); - dsi_display_cmd_engine_disable(display); -done: - return rc; -} - /** * dsi_display_bind - bind dsi device with controlling device * @dev: Pointer to base of platform device @@ -5554,7 +5408,6 @@ static int dsi_display_bind(struct device *dev, /* register te irq handler */ dsi_display_register_te_irq(display); - set_lct_tp_lockdown_info_callback(lct_tp_lockdown_info_callback); goto error; diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_display.h b/drivers/gpu/drm/msm/dsi-staging/dsi_display.h index 2f57b47982bf..50be64576c21 100644 --- a/drivers/gpu/drm/msm/dsi-staging/dsi_display.h +++ b/drivers/gpu/drm/msm/dsi-staging/dsi_display.h @@ -284,11 +284,6 @@ struct dsi_display { u32 te_source; }; -//Update /proc/tp_info & /proc/tp_lockdown_info node -extern void update_lct_tp_info(char *tp_info_buf, char *tp_lockdown_info_buf); -//Set tp_lockdown_info node callback funcation -extern void set_lct_tp_lockdown_info_callback(int (*pfun)(void)); - int dsi_display_dev_probe(struct platform_device *pdev); int dsi_display_dev_remove(struct platform_device *pdev); diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_drm.c b/drivers/gpu/drm/msm/dsi-staging/dsi_drm.c index 5dbb1fd04d68..a73d881b0b37 100644 --- a/drivers/gpu/drm/msm/dsi-staging/dsi_drm.c +++ b/drivers/gpu/drm/msm/dsi-staging/dsi_drm.c @@ -388,27 +388,10 @@ static void dsi_bridge_post_disable(struct drm_bridge *bridge) atomic_set(&prim_panel_is_on, false); } -#if CONFIG_TOUCHSCREEN_COMMON -typedef int(*touchpanel_recovery_cb_p_t)(void); -static touchpanel_recovery_cb_p_t touchpanel_recovery_cb_p; -int set_touchpanel_recovery_callback(touchpanel_recovery_cb_p_t cb) -{ - if (IS_ERR_OR_NULL(cb)) - return -EINVAL; - touchpanel_recovery_cb_p = cb; - return 0; -} -EXPORT_SYMBOL(set_touchpanel_recovery_callback); -#endif - static void prim_panel_off_delayed_work(struct work_struct *work) { mutex_lock(&gbridge->base.lock); if (atomic_read(&prim_panel_is_on)) { -#if CONFIG_TOUCHSCREEN_COMMON - if (!IS_ERR_OR_NULL(touchpanel_recovery_cb_p)) - touchpanel_recovery_cb_p(); -#endif dsi_bridge_post_disable(&gbridge->base); __pm_relax(&prim_panel_wakelock); mutex_unlock(&gbridge->base.lock); diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 36c39cca978f..aa55eb6b34fb 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -1297,17 +1297,16 @@ config TOUCHSCREEN_RAYDIUM_CHIPSET If unsure, say N. config TOUCHSCREEN_COMMON - tristate "Longcheer tp info driver" + bool "Common touchscreen interface to interact with userspace" default y help - Say Y here if you have lct tp info connected. + Say Y here if you want to control touchpanel features via + /sys/touchpanel. If unsure, say N. source "drivers/input/touchscreen/nt36xxx_spi/Kconfig" -source "drivers/input/touchscreen/xiaomi/Kconfig" - source "drivers/input/touchscreen/focaltech_touch/Kconfig" endif diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 7b9222361892..41e34ee169f6 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -108,9 +108,8 @@ obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023) += rohm_bu21023.o obj-$(CONFIG_TOUCHSCREEN_HIMAX_CHIPSET) += hxchipset/ obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_TCM) += synaptics_tcm/ obj-$(CONFIG_TOUCHSCREEN_RAYDIUM_CHIPSET) += raydium_wt030/ -obj-$(CONFIG_TOUCHSCREEN_COMMON) += lct_tp_palm.o lct_tp_info.o lct_tp_gesture.o lct_tp_grip_area.o lct_tp_work.o tp_common.o +obj-$(CONFIG_TOUCHSCREEN_COMMON) += tp_common.o obj-$(CONFIG_TOUCHSCREEN_NT36xxx_HOSTDL_SPI) += nt36xxx_spi/ -obj-$(CONFIG_TOUCHSCREEN_XIAOMI_TOUCHFEATURE) += xiaomi/ obj-$(CONFIG_TOUCHSCREEN_RASPBERRYPI_FW) += raspberrypi-ts.o obj-$(CONFIG_TOUCHSCREEN_IQS5XX) += iqs5xx.o obj-$(CONFIG_TOUCHSCREEN_ST) += st/ diff --git a/drivers/input/touchscreen/lct_tp_gesture.c b/drivers/input/touchscreen/lct_tp_gesture.c deleted file mode 100644 index f80b17036e73..000000000000 --- a/drivers/input/touchscreen/lct_tp_gesture.c +++ /dev/null @@ -1,232 +0,0 @@ -/**************************************************************************************** - * - * @File Name : lct_tp_gesture.c - * @Author : wanghan - * @E-mail : - * @Create Time : 2018-09-30 17:34:43 - * @Description : Enable/Disable touchpad. - * - ****************************************************************************************/ - -/* - * INCLUDE FILES - **************************************************************************************** - */ -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * DEFINE CONFIGURATION - **************************************************************************************** - */ -#define TP_GESTURE_NAME "tp_gesture" -#define TP_GESTURE_TAG "LCT_TP_GESTURE" - -#ifdef TP_GESTURE_LOG_ENABLE -#define TP_LOGW(log, ...) printk(KERN_WARNING "[%s] %s (line %d): " log, TP_GESTURE_TAG, __func__, __LINE__, ##__VA_ARGS__) -#define TP_LOGE(log, ...) printk(KERN_ERR "[%s] %s ERROR (line %d): " log, TP_GESTURE_TAG, __func__, __LINE__, ##__VA_ARGS__) -#else -#define TP_LOGW(log, ...) {} -#define TP_LOGE(log, ...) {} -#endif - -/* - * DATA STRUCTURES - **************************************************************************************** - */ -typedef int (*tp_gesture_cb_t) (bool enable_tp); - -typedef struct lct_tp { - bool enable_tp_gesture_flag; - struct proc_dir_entry *proc_entry_tp; - tp_gesture_cb_t pfun; -} lct_tp_t; - -/* - * GLOBAL VARIABLE DEFINITIONS - **************************************************************************************** - */ -static lct_tp_t *lct_tp_p; - -/* - * FUNCTION DEFINITIONS - **************************************************************************************** - */ -// --- proc --- -static int lct_creat_proc_tp_entry(void); -static ssize_t lct_proc_tp_gesture_read(struct file *file, char __user *buf, - size_t size, loff_t *ppos); -static ssize_t lct_proc_tp_gesture_write(struct file *file, - const char __user *buf, size_t size, - loff_t *ppos); -static const struct file_operations lct_proc_tp_gesture_fops = { - .read = lct_proc_tp_gesture_read, - .write = lct_proc_tp_gesture_write, -}; - -int init_lct_tp_gesture(tp_gesture_cb_t callback) -{ - if (NULL == callback) { - TP_LOGE("callback is NULL!\n"); - return -EINVAL; - } - - TP_LOGW("Initialization tp_gesture node!\n"); - lct_tp_p = kzalloc(sizeof(lct_tp_t), GFP_KERNEL); - if (IS_ERR_OR_NULL(lct_tp_p)) { - TP_LOGE("kzalloc() request memory failed!\n"); - return -ENOMEM; - } - lct_tp_p->pfun = callback; - lct_tp_p->enable_tp_gesture_flag = false; - - if (lct_creat_proc_tp_entry() < 0) { - kfree(lct_tp_p); - return -EPERM; - } - - return 0; -} - -EXPORT_SYMBOL(init_lct_tp_gesture); - -void uninit_lct_tp_gesture(void) -{ - TP_LOGW("uninit /proc/%s ...\n", TP_GESTURE_NAME); - if (IS_ERR_OR_NULL(lct_tp_p)) - return; - if (lct_tp_p->proc_entry_tp != NULL) { - remove_proc_entry(TP_GESTURE_NAME, NULL); - lct_tp_p->proc_entry_tp = NULL; - TP_LOGW("remove /proc/%s\n", TP_GESTURE_NAME); - } - kfree(lct_tp_p); - return; -} - -EXPORT_SYMBOL(uninit_lct_tp_gesture); - -void set_lct_tp_gesture_status(bool en) -{ - lct_tp_p->enable_tp_gesture_flag = en; -} - -EXPORT_SYMBOL(set_lct_tp_gesture_status); - -bool get_lct_tp_gesture_status(void) -{ - return lct_tp_p->enable_tp_gesture_flag; -} - -EXPORT_SYMBOL(get_lct_tp_gesture_status); - -static int lct_creat_proc_tp_entry(void) -{ - lct_tp_p->proc_entry_tp = - proc_create_data(TP_GESTURE_NAME, 0444, NULL, - &lct_proc_tp_gesture_fops, NULL); - if (IS_ERR_OR_NULL(lct_tp_p->proc_entry_tp)) { - TP_LOGE("add /proc/%s error!\n", TP_GESTURE_NAME); - return -EPERM; - } - TP_LOGW("/proc/%s is okay!\n", TP_GESTURE_NAME); - return 0; -} - -static ssize_t lct_proc_tp_gesture_read(struct file *file, char __user *buf, - size_t size, loff_t *ppos) -{ - ssize_t cnt; - char *page = NULL; - - if (*ppos) - return 0; - - page = kzalloc(128, GFP_KERNEL); - if (IS_ERR_OR_NULL(page)) - return -ENOMEM; - - cnt = - snprintf(page, PAGE_SIZE, "%s", - (lct_tp_p->enable_tp_gesture_flag ? "1\n" : "0\n")); - - cnt = simple_read_from_buffer(buf, size, ppos, page, cnt); - if (*ppos != cnt) - *ppos = cnt; - TP_LOGW("Touchpad status : %s", page); - - kfree(page); - return cnt; -} - -static ssize_t lct_proc_tp_gesture_write(struct file *file, - const char __user *buf, size_t size, - loff_t *ppos) -{ - int ret; - ssize_t cnt = 0; - char *page = NULL; - unsigned int input = 0; - - page = kzalloc(128, GFP_KERNEL); - if (IS_ERR_OR_NULL(page)) - return -ENOMEM; - cnt = simple_write_to_buffer(page, 128, ppos, buf, size); - if (cnt <= 0) - return -EINVAL; - if (sscanf(page, "%u", &input) != 1) - return -EINVAL; - - if (input > 0) { - if (lct_tp_p->enable_tp_gesture_flag) - goto exit; - TP_LOGW("Enbale Touchpad Gesture ...\n"); - ret = lct_tp_p->pfun(true); - if (ret) { - TP_LOGW("Enable Touchpad Gesture Failed! ret=%d\n", - ret); - goto exit; - } - lct_tp_p->enable_tp_gesture_flag = true; - } else { - if (!lct_tp_p->enable_tp_gesture_flag) - goto exit; - TP_LOGW("Disable Touchpad Gesture ...\n"); - ret = lct_tp_p->pfun(false); - if (ret) { - TP_LOGW("Disable Touchpad Gesture Failed! ret=%d\n", - ret); - goto exit; - } - lct_tp_p->enable_tp_gesture_flag = false; - } - TP_LOGW("Set Touchpad Gesture successfully!\n"); - -exit: - kfree(page); - return cnt; -} - -static int __init tp_gesture_init(void) -{ - TP_LOGW("init"); - return 0; -} - -static void __exit tp_gesture_exit(void) -{ - TP_LOGW("exit"); - return; -} - -module_init(tp_gesture_init); -module_exit(tp_gesture_exit); - -MODULE_DESCRIPTION("Touchpad Work Controller Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/input/touchscreen/lct_tp_gesture.h b/drivers/input/touchscreen/lct_tp_gesture.h deleted file mode 100644 index 97bae020e656..000000000000 --- a/drivers/input/touchscreen/lct_tp_gesture.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef __LCT_TP_GESTURE_H__ -#define __LCT_TP_GESTURE_H__ - -typedef int (*tp_gesture_cb_t)(bool enable_tp); - -extern int init_lct_tp_gesture(tp_gesture_cb_t callback); -extern void uninit_lct_tp_gesture(void); -extern void set_lct_tp_gesture_status(bool en); -extern bool get_lct_tp_gesture_status(void); - -#endif //__LCT_TP_GESTURE_H__ - diff --git a/drivers/input/touchscreen/lct_tp_grip_area.c b/drivers/input/touchscreen/lct_tp_grip_area.c deleted file mode 100644 index 9701dae07df1..000000000000 --- a/drivers/input/touchscreen/lct_tp_grip_area.c +++ /dev/null @@ -1,224 +0,0 @@ -/**************************************************************************************** - * - * @File Name : lct_tp_grip_area.c - * @Author : wanghan - * @E-mail : - * @Create Time : 2018-08-17 17:34:43 - * @Description : Display touchpad information. - * - ****************************************************************************************/ - -/* - * INCLUDE FILES - **************************************************************************************** - */ -#include -#include -#include -#include -#include -#include -#include - -/* - * DEFINE CONFIGURATION - **************************************************************************************** - */ -#define TP_GRIP_AREA_NAME "tp_grip_area" -#define TP_GRIP_AREA_TAG "LCT_TP_GRIP_AREA" - -#ifdef TP_GRIP_AREA_LOG_ENABLE -#define TP_LOGW(log, ...) printk(KERN_WARNING "[%s] %s (line %d): " log, TP_GRIP_AREA_TAG, __func__, __LINE__, ##__VA_ARGS__) -#define TP_LOGE(log, ...) printk(KERN_ERR "[%s] %s ERROR (line %d): " log, TP_GRIP_AREA_TAG, __func__, __LINE__, ##__VA_ARGS__) -#else -#define TP_LOGW(log, ...) {} -#define TP_LOGE(log, ...) {} -#endif - -typedef int (*get_screen_angle_callback) (void); -typedef int (*set_screen_angle_callback) (int angle); - -/* - * DATA STRUCTURES - **************************************************************************************** - */ -typedef struct lct_tp { - struct kobject *tp_device; - int screen_angle; - struct proc_dir_entry *proc_entry_tp_grip_area; - set_screen_angle_callback lct_grip_area_set_screen_angle_callback; - get_screen_angle_callback lct_grip_area_get_screen_angle_callback; -} lct_tp_t; - -/* - * GLOBAL VARIABLE DEFINITIONS - **************************************************************************************** - */ -static lct_tp_t *lct_tp_p; - -/* - * FUNCTION DEFINITIONS - **************************************************************************************** - */ -// --- proc --- -static int lct_proc_tp_grip_area_open(struct inode *node, struct file *file); -static ssize_t lct_proc_tp_grip_area_read(struct file *file, char __user *buf, - size_t size, loff_t *ppos); -static ssize_t lct_proc_tp_grip_area_write(struct file *file, - const char __user *buf, size_t size, - loff_t *ppos); -static const struct file_operations lct_proc_tp_grip_area_fops = { - .open = lct_proc_tp_grip_area_open, - .read = lct_proc_tp_grip_area_read, - .write = lct_proc_tp_grip_area_write, -}; - -int init_lct_tp_grip_area(set_screen_angle_callback set_fun, - get_screen_angle_callback get_fun) -{ - if (NULL == set_fun) - return -EPERM; - - TP_LOGW("Initialization /proc/%s node!\n", TP_GRIP_AREA_NAME); - lct_tp_p = kzalloc(sizeof(lct_tp_t), GFP_KERNEL); - if (IS_ERR_OR_NULL(lct_tp_p)) { - TP_LOGE("kzalloc() request memory failed!\n"); - return -ENOMEM; - } - - lct_tp_p->lct_grip_area_set_screen_angle_callback = set_fun; - lct_tp_p->lct_grip_area_get_screen_angle_callback = get_fun; - - lct_tp_p->proc_entry_tp_grip_area = - proc_create_data(TP_GRIP_AREA_NAME, 0444, NULL, - &lct_proc_tp_grip_area_fops, NULL); - if (IS_ERR_OR_NULL(lct_tp_p->proc_entry_tp_grip_area)) { - TP_LOGE("add /proc/%s error\n", TP_GRIP_AREA_NAME); - kfree(lct_tp_p); - return -EPERM; - } - TP_LOGW("/proc/%s is okay!\n", TP_GRIP_AREA_NAME); - - return 0; -} - -EXPORT_SYMBOL(init_lct_tp_grip_area); - -void uninit_lct_tp_grip_area(void) -{ - TP_LOGW("uninit /proc/%s ...\n", TP_GRIP_AREA_NAME); - - if (IS_ERR_OR_NULL(lct_tp_p)) - return; - - if (lct_tp_p->proc_entry_tp_grip_area != NULL) { - remove_proc_entry(TP_GRIP_AREA_NAME, NULL); - lct_tp_p->proc_entry_tp_grip_area = NULL; - TP_LOGW("remove /proc/%s\n", TP_GRIP_AREA_NAME); - } - - kfree(lct_tp_p); -} - -EXPORT_SYMBOL(uninit_lct_tp_grip_area); - -int set_tp_grip_area_angle(int screen_angle) -{ - lct_tp_p->screen_angle = screen_angle; - return 0; -} - -EXPORT_SYMBOL(set_tp_grip_area_angle); - -int get_tp_grip_area_angle(void) -{ - return lct_tp_p->screen_angle; -} - -EXPORT_SYMBOL(get_tp_grip_area_angle); - -static int lct_proc_tp_grip_area_open(struct inode *node, struct file *file) -{ - return 0; -} - -static ssize_t lct_proc_tp_grip_area_read(struct file *file, char __user *buf, - size_t size, loff_t *ppos) -{ - int ret = -EIO; - ssize_t cnt = 0; - char *page = NULL; - - if (*ppos) - return 0; - - page = kzalloc(size + 1, GFP_KERNEL); - if (IS_ERR_OR_NULL(page)) - return ret; - - if (NULL != lct_tp_p->lct_grip_area_get_screen_angle_callback) { - ret = lct_tp_p->lct_grip_area_get_screen_angle_callback(); - if (ret < 0) { - TP_LOGE("get screen angle failed!\n"); - goto out; - } - lct_tp_p->screen_angle = ret; - } - cnt = snprintf(page, PAGE_SIZE, "%d\n", lct_tp_p->screen_angle); - cnt = simple_read_from_buffer(buf, size, ppos, page, cnt); - if (*ppos != cnt) - *ppos = cnt; - TP_LOGW("screen_angle = %s", page); - ret = cnt; - -out: - kfree(page); - return ret; -} - -static ssize_t lct_proc_tp_grip_area_write(struct file *file, - const char __user *buf, size_t size, - loff_t *ppos) -{ - int ret = -EIO; - ssize_t cnt = 0; - char *cmd = NULL; - int angle = 0; - - cmd = kzalloc(size + 1, GFP_KERNEL); - if (IS_ERR_OR_NULL(cmd)) - return -ENOMEM; - - cnt = simple_write_to_buffer(cmd, size + 1, ppos, buf, size); - if (cnt <= 0) - goto out; - - cmd[size] = '\0'; - if (sscanf(cmd, "%d", &angle) < 0) - goto out; - - if (angle < 0 || angle > 360) { - TP_LOGE("screen_angle range: 0 ~ 360 !\n"); - goto out; - } - TP_LOGW("Set screen angle = %u\n", angle); - - if (NULL == lct_tp_p->lct_grip_area_set_screen_angle_callback) { - TP_LOGE("none callback!\n"); - goto out; - } - ret = lct_tp_p->lct_grip_area_set_screen_angle_callback(angle); - if (ret < 0) { - TP_LOGE("Set screen angle failed! ret = %d\n", ret); - goto out; - } - lct_tp_p->screen_angle = angle; - ret = cnt; - -out: - kfree(cmd); - return ret; -} - -MODULE_DESCRIPTION("Touchpad Grip Area Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/input/touchscreen/lct_tp_grip_area.h b/drivers/input/touchscreen/lct_tp_grip_area.h deleted file mode 100644 index 5278f3e29cf3..000000000000 --- a/drivers/input/touchscreen/lct_tp_grip_area.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef __LCT_TP_GRIP_AREA_H__ -#define __LCT_TP_GRIP_AREA_H__ - -typedef int (*get_screen_angle_callback)(void); -typedef int (*set_screen_angle_callback)(int angle); - -extern int init_lct_tp_grip_area(set_screen_angle_callback set_fun, get_screen_angle_callback get_fun); -extern void uninit_lct_tp_grip_area(void); -extern int set_tp_grip_area_angle(int screen_angle); -extern int get_tp_grip_area_angle(void); - -#endif//__LCT_TP_GRIP_AREA_H__ - diff --git a/drivers/input/touchscreen/lct_tp_info.c b/drivers/input/touchscreen/lct_tp_info.c deleted file mode 100644 index 65d6f2bedbb8..000000000000 --- a/drivers/input/touchscreen/lct_tp_info.c +++ /dev/null @@ -1,268 +0,0 @@ -/**************************************************************************************** - * - * @File Name : lct_tp_info.c - * @Author : wanghan - * @E-mail : - * @Create Time : 2018-08-17 17:34:43 - * @Description : Display touchpad information. - * - ****************************************************************************************/ - -/* - * INCLUDE FILES - **************************************************************************************** - */ -#include -#include -#include -#include -#include -#include -#include - -/* - * DEFINE CONFIGURATION - **************************************************************************************** - */ -#define TP_INFO_NAME "tp_info" -#define TP_LOCKDOWN_INFO_NAME "tp_lockdown_info" -#define TP_INFO_TAG "LCT_TP_INFO" -#define LCT_STRING_SIZE 128 -#define TP_CALLBACK_CMD_INFO "CMD_INFO" -#define TP_CALLBACK_CMD_LOCKDOWN "CMD_LOCKDOWN" - -#ifdef TP_INFO_LOG_ENABLE -#define TP_LOGW(log, ...) printk(KERN_WARNING "[%s] %s (line %d): " log, TP_INFO_TAG, __func__, __LINE__, ##__VA_ARGS__) -#define TP_LOGE(log, ...) printk(KERN_ERR "[%s] %s ERROR (line %d): " log, TP_INFO_TAG, __func__, __LINE__, ##__VA_ARGS__) -#else -#define TP_LOGW(log, ...) {} -#define TP_LOGE(log, ...) {} -#endif - -/* - * DATA STRUCTURES - **************************************************************************************** - */ -typedef struct lct_tp { - struct kobject *tp_device; - char tp_info_buf[LCT_STRING_SIZE]; - char tp_lockdown_info_buf[LCT_STRING_SIZE]; - struct proc_dir_entry *proc_entry_tp_info; - struct proc_dir_entry *proc_entry_tp_lockdown_info; - int (*pfun_info_cb) (const char *); -} lct_tp_t; - -/* - * GLOBAL VARIABLE DEFINITIONS - **************************************************************************************** - */ -static lct_tp_t *lct_tp_p; -static int (*pfun_lockdown_cb) (void); - -/* - * FUNCTION DEFINITIONS - **************************************************************************************** - */ -// --- proc --- -static ssize_t lct_proc_tp_info_read(struct file *file, char __user *buf, - size_t size, loff_t *ppos); -static ssize_t lct_proc_tp_lockdown_info_read(struct file *file, - char __user *buf, size_t size, - loff_t *ppos); -static const struct file_operations lct_proc_tp_info_fops = { - .read = lct_proc_tp_info_read, -}; - -static const struct file_operations lct_proc_tp_lockdown_info_fops = { - .read = lct_proc_tp_lockdown_info_read, -}; - -int init_lct_tp_info(char *tp_info_buf, char *tp_lockdown_info_buf) -{ - TP_LOGW("init /proc/%s and /proc/%s ...\n", TP_INFO_NAME, - TP_LOCKDOWN_INFO_NAME); - lct_tp_p = kzalloc(sizeof(lct_tp_t), GFP_KERNEL); - if (IS_ERR_OR_NULL(lct_tp_p)) { - TP_LOGE("kzalloc() request memory failed!\n"); - return -ENOMEM; - } - - if (NULL != tp_info_buf) - strlcpy(lct_tp_p->tp_info_buf, tp_info_buf, - sizeof(lct_tp_p->tp_info_buf)); - if (NULL != tp_lockdown_info_buf) - strlcpy(lct_tp_p->tp_lockdown_info_buf, tp_lockdown_info_buf, - sizeof(lct_tp_p->tp_lockdown_info_buf)); - - lct_tp_p->proc_entry_tp_info = - proc_create_data(TP_INFO_NAME, 0444, NULL, &lct_proc_tp_info_fops, - NULL); - if (IS_ERR_OR_NULL(lct_tp_p->proc_entry_tp_info)) { - TP_LOGE("add /proc/%s error\n", TP_INFO_NAME); - goto err_tp_info; - } - lct_tp_p->proc_entry_tp_lockdown_info = - proc_create_data(TP_LOCKDOWN_INFO_NAME, 0444, NULL, - &lct_proc_tp_lockdown_info_fops, NULL); - if (IS_ERR_OR_NULL(lct_tp_p->proc_entry_tp_lockdown_info)) { - TP_LOGE("add /proc/%s error\n", TP_LOCKDOWN_INFO_NAME); - goto err_tp_lockdown; - } - - TP_LOGW("done\n"); - - return 0; - -err_tp_lockdown: - remove_proc_entry(TP_INFO_NAME, NULL); -err_tp_info: - kfree(lct_tp_p); - return -EPERM; -} - -EXPORT_SYMBOL(init_lct_tp_info); - -void uninit_lct_tp_info(void) -{ - TP_LOGW("uninit /proc/%s and /proc/%s ...\n", TP_INFO_NAME, - TP_LOCKDOWN_INFO_NAME); - - if (IS_ERR_OR_NULL(lct_tp_p)) - return; - - if (lct_tp_p->proc_entry_tp_info != NULL) { - remove_proc_entry(TP_INFO_NAME, NULL); - lct_tp_p->proc_entry_tp_info = NULL; - TP_LOGW("remove /proc/%s\n", TP_INFO_NAME); - } - - if (lct_tp_p->proc_entry_tp_lockdown_info != NULL) { - remove_proc_entry(TP_LOCKDOWN_INFO_NAME, NULL); - lct_tp_p->proc_entry_tp_lockdown_info = NULL; - TP_LOGW("remove /proc/%s\n", TP_LOCKDOWN_INFO_NAME); - } - - kfree(lct_tp_p); - TP_LOGW("done\n"); -} - -EXPORT_SYMBOL(uninit_lct_tp_info); - -void update_lct_tp_info(char *tp_info_buf, char *tp_lockdown_info_buf) -{ - if (NULL != tp_info_buf) { - memset(lct_tp_p->tp_info_buf, 0, sizeof(lct_tp_p->tp_info_buf)); - strlcpy(lct_tp_p->tp_info_buf, tp_info_buf, - sizeof(lct_tp_p->tp_info_buf)); - } - if (NULL != tp_lockdown_info_buf) { - memset(lct_tp_p->tp_lockdown_info_buf, 0, - sizeof(lct_tp_p->tp_lockdown_info_buf)); - strlcpy(lct_tp_p->tp_lockdown_info_buf, tp_lockdown_info_buf, - sizeof(lct_tp_p->tp_lockdown_info_buf)); - } - return; -} - -EXPORT_SYMBOL(update_lct_tp_info); - -void set_lct_tp_info_callback(int (*pfun) (const char *)) -{ - if (NULL != lct_tp_p) - lct_tp_p->pfun_info_cb = pfun; - return; -} - -EXPORT_SYMBOL(set_lct_tp_info_callback); - -void set_lct_tp_lockdown_info_callback(int (*pfun) (void)) -{ - pfun_lockdown_cb = pfun; - return; -} - -EXPORT_SYMBOL(set_lct_tp_lockdown_info_callback); - -static ssize_t lct_proc_tp_info_read(struct file *file, char __user *buf, - size_t size, loff_t *ppos) -{ - int cnt = 0; - char *page = NULL; - - //TP_LOGW("size = %lu, pos = %lld\n", size, *ppos); - if (*ppos) - return 0; - - if (NULL != lct_tp_p->pfun_info_cb) - lct_tp_p->pfun_info_cb(TP_CALLBACK_CMD_INFO); - - page = kzalloc(128, GFP_KERNEL); - - if (NULL == lct_tp_p->tp_info_buf) - cnt = snprintf(page, PAGE_SIZE, "No touchpad\n"); - else - cnt = - snprintf(page, PAGE_SIZE, "%s", - (strlen(lct_tp_p->tp_info_buf) ? lct_tp_p->tp_info_buf : "Unknown touchpad")); - - cnt = simple_read_from_buffer(buf, size, ppos, page, cnt); - if (*ppos != cnt) - *ppos = cnt; - TP_LOGW("page=%s", page); - - kfree(page); - return cnt; -} - -static ssize_t lct_proc_tp_lockdown_info_read(struct file *file, - char __user *buf, size_t size, - loff_t *ppos) -{ - int cnt = 0; - char *page = NULL; - - if (*ppos) - return 0; - - if (NULL != lct_tp_p->pfun_info_cb) - lct_tp_p->pfun_info_cb(TP_CALLBACK_CMD_LOCKDOWN); - - if (NULL != pfun_lockdown_cb) - pfun_lockdown_cb(); - - page = kzalloc(128, GFP_KERNEL); - - if (NULL == lct_tp_p->tp_lockdown_info_buf) - cnt = snprintf(page, PAGE_SIZE, "No touchpad\n"); - else - cnt = - snprintf(page, PAGE_SIZE, "%s", - (strlen(lct_tp_p->tp_lockdown_info_buf) ? - lct_tp_p->tp_lockdown_info_buf : "Unknown touchpad")); - - cnt = simple_read_from_buffer(buf, size, ppos, page, cnt); - if (*ppos != cnt) - *ppos = cnt; - TP_LOGW("page=%s", page); - - kfree(page); - return cnt; -} - -static int __init tp_info_init(void) -{ - TP_LOGW("init"); - return 0; -} - -static void __exit tp_info_exit(void) -{ - TP_LOGW("exit"); - return; -} - -module_init(tp_info_init); -module_exit(tp_info_exit); - -MODULE_DESCRIPTION("Touchpad Information Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/input/touchscreen/lct_tp_info.h b/drivers/input/touchscreen/lct_tp_info.h deleted file mode 100644 index 0ae86ca22652..000000000000 --- a/drivers/input/touchscreen/lct_tp_info.h +++ /dev/null @@ -1,28 +0,0 @@ -/**************************************************************************************** - * - * @File Name : lct_tp_info.h - * @Author : wanghan - * @E-mail : - * @Create Time : 2018-08-17 17:34:43 - * @Description : Display touchpad information. - * - ****************************************************************************************/ - -#ifndef __LCT_TP_INFO_H__ -#define __LCT_TP_INFO_H__ - -#define TP_CALLBACK_CMD_INFO "CMD_INFO" -#define TP_CALLBACK_CMD_LOCKDOWN "CMD_LOCKDOWN" - -//init /proc/tp_info & /proc/tp_lockdown_info node -extern int init_lct_tp_info(char *tp_info_buf, char *tp_lockdown_info_buf); -//uninit /proc/tp_info & /proc/tp_lockdown_info node -extern void uninit_lct_tp_info(void); -//Update /proc/tp_info & /proc/tp_lockdown_info node -extern void update_lct_tp_info(char *tp_info_buf, char *tp_lockdown_info_buf); -//Set tp_info node callback funcation -extern void set_lct_tp_info_callback(int (*pfun)(const char *)); -//Set tp_lockdown_info node callback funcation -extern void set_lct_tp_lockdown_info_callback(int (*pfun)(void)); - -#endif //__LCT_TP_INFO_H__ diff --git a/drivers/input/touchscreen/lct_tp_palm.c b/drivers/input/touchscreen/lct_tp_palm.c deleted file mode 100755 index 4a3783da17fd..000000000000 --- a/drivers/input/touchscreen/lct_tp_palm.c +++ /dev/null @@ -1,216 +0,0 @@ -/**************************************************************************************** - * - * @File Name : lct_tp_palm.c - * @Author : yanglintao - * @E-mail : - * @Create Time : 2019-12-26 11:15:12 - * @Description : Enable/Disable touchpad. - * - ****************************************************************************************/ - -/* - * INCLUDE FILES - **************************************************************************************** - */ -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * DEFINE CONFIGURATION - **************************************************************************************** - */ -#define TP_PALM_NAME "tp_palm" -#define TP_PALM_TAG "LCT_TP_PALM" - -#ifdef TP_PALM_LOG_ENABLE -#define TP_LOGW(log, ...) printk(KERN_WARNING "[%s] %s (line %d): " log, TP_PALM_TAG, __func__, __LINE__, ##__VA_ARGS__) -#define TP_LOGE(log, ...) printk(KERN_ERR "[%s] %s ERROR (line %d): " log, TP_PALM_TAG, __func__, __LINE__, ##__VA_ARGS__) -#else -#define TP_LOGW(log, ...) {} -#define TP_LOGE(log, ...) {} -#endif - -/* - * DATA STRUCTURES - **************************************************************************************** - */ -typedef int (*tp_palm_cb_t) (bool enable_tp); - -typedef struct lct_tp { - bool enable_tp_palm_flag; - struct proc_dir_entry *proc_entry_tp; - tp_palm_cb_t pfun; -} lct_tp_t; - -/* - * GLOBAL VARIABLE DEFINITIONS - **************************************************************************************** - */ -static lct_tp_t *lct_tp_p; - -/* - * FUNCTION DEFINITIONS - **************************************************************************************** - */ -// --- proc --- -static int lct_creat_proc_tp_entry(void); -static ssize_t lct_proc_tp_palm_read(struct file *file, char __user *buf, - size_t size, loff_t *ppos); -static ssize_t lct_proc_tp_palm_write(struct file *file, - const char __user *buf, size_t size, - loff_t *ppos); -static const struct file_operations lct_proc_tp_palm_fops = { - .read = lct_proc_tp_palm_read, - .write = lct_proc_tp_palm_write, -}; - -int init_lct_tp_palm(tp_palm_cb_t callback) -{ - if (NULL == callback) { - TP_LOGE("callback is NULL!\n"); - return -EINVAL; - } - - TP_LOGW("Initialization tp_palm node!\n"); - lct_tp_p = kzalloc(sizeof(lct_tp_t), GFP_KERNEL); - if (IS_ERR_OR_NULL(lct_tp_p)) { - TP_LOGE("kzalloc() request memory failed!\n"); - return -ENOMEM; - } - lct_tp_p->pfun = callback; - lct_tp_p->enable_tp_palm_flag = true; - - if (lct_creat_proc_tp_entry() < 0) { - kfree(lct_tp_p); - return -EPERM; - } - - return 0; -} - -EXPORT_SYMBOL(init_lct_tp_palm); - -void uninit_lct_tp_palm(void) -{ - TP_LOGW("uninit /proc/%s ...\n", TP_PALM_NAME); - if (IS_ERR_OR_NULL(lct_tp_p)) - return; - if (lct_tp_p->proc_entry_tp != NULL) { - remove_proc_entry(TP_PALM_NAME, NULL); - lct_tp_p->proc_entry_tp = NULL; - TP_LOGW("remove /proc/%s\n", TP_PALM_NAME); - } - kfree(lct_tp_p); - return; -} - -EXPORT_SYMBOL(uninit_lct_tp_palm); - -void set_lct_tp_palm_status(bool en) -{ - lct_tp_p->enable_tp_palm_flag = en; -} - -EXPORT_SYMBOL(set_lct_tp_palm_status); - -bool get_lct_tp_palm_status(void) -{ - return lct_tp_p->enable_tp_palm_flag; -} - -EXPORT_SYMBOL(get_lct_tp_palm_status); - -static int lct_creat_proc_tp_entry(void) -{ - lct_tp_p->proc_entry_tp = - proc_create_data(TP_PALM_NAME, 0444, NULL, &lct_proc_tp_palm_fops, - NULL); - if (IS_ERR_OR_NULL(lct_tp_p->proc_entry_tp)) { - TP_LOGE("add /proc/tp_palm error \n"); - return -EPERM; - } - TP_LOGW("/proc/tp_palm is okay!\n"); - - return 0; -} - -static ssize_t lct_proc_tp_palm_read(struct file *file, char __user *buf, - size_t size, loff_t *ppos) -{ - ssize_t cnt = 0; - char *page = NULL; - - if (*ppos) - return 0; - - page = kzalloc(128, GFP_KERNEL); - if (IS_ERR_OR_NULL(page)) - return -ENOMEM; - - cnt = - snprintf(page, PAGE_SIZE, "%s", - (lct_tp_p->enable_tp_palm_flag ? "1\n" : "0\n")); - - cnt = simple_read_from_buffer(buf, size, ppos, page, cnt); - if (*ppos != cnt) - *ppos = cnt; - TP_LOGW("Touchpad Palm status : %s", page); - - kfree(page); - return cnt; -} - -static ssize_t lct_proc_tp_palm_write(struct file *file, - const char __user *buf, size_t size, - loff_t *ppos) -{ - int ret; - ssize_t cnt = 0; - char *page = NULL; - unsigned int input = 0; - - page = kzalloc(128, GFP_KERNEL); - if (IS_ERR_OR_NULL(page)) - return -ENOMEM; - cnt = simple_write_to_buffer(page, 128, ppos, buf, size); - if (cnt <= 0) - return -EINVAL; - if (sscanf(page, "%u", &input) != 1) - return -EINVAL; - - if (input > 0) { - //if (lct_tp_p->enable_tp_palm_flag) - // goto exit; - TP_LOGW("Enbale Touchpad Palm...\n"); - ret = lct_tp_p->pfun(false); - if (ret) { - TP_LOGW("Enable Touchpad Palm Failed! ret=%d\n", ret); - goto exit; - } - lct_tp_p->enable_tp_palm_flag = true; - } else { - //if (!lct_tp_p->enable_tp_palm_flag) - // goto exit; - TP_LOGW("Disable Touchpad Palm...\n"); - ret = lct_tp_p->pfun(true); - if (ret) { - TP_LOGW("Disable Touchpad Palm Failed! ret=%d\n", ret); - goto exit; - } - lct_tp_p->enable_tp_palm_flag = false; - } - TP_LOGW("Set Touchpad Palm successfully!\n"); - -exit: - kfree(page); - return cnt; -} - -MODULE_DESCRIPTION("Touchpad Palm Controller Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/input/touchscreen/lct_tp_palm.h b/drivers/input/touchscreen/lct_tp_palm.h deleted file mode 100644 index e25d43fe2e41..000000000000 --- a/drivers/input/touchscreen/lct_tp_palm.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef __LCT_TP_PALM_H__ -#define __LCT_TP_PALM_H__ - -typedef int (*tp_palm_cb_t)(bool enable_tp); - -extern int init_lct_tp_palm(tp_palm_cb_t callback); -extern void uninit_lct_tp_palm(void); -extern void set_lct_tp_palm_status(bool en); -extern bool get_lct_tp_palm_status(void); - -#endif //__LCT_TP_PALM_H__ - diff --git a/drivers/input/touchscreen/lct_tp_selftest.c b/drivers/input/touchscreen/lct_tp_selftest.c deleted file mode 100644 index a594e73b4e46..000000000000 --- a/drivers/input/touchscreen/lct_tp_selftest.c +++ /dev/null @@ -1,236 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define TP_SELF_TEST_RETROY_COUNT 3 -#define TP_SELF_TEST_CHECK_STATE_COUNT 30 - -#define TP_SELF_TEST_PROC_FILE "tp_selftest" - -#define TP_SELF_TEST_RESULT_UNKNOWN "0\n" -#define TP_SELF_TEST_RESULT_FAIL "1\n" -#define TP_SELF_TEST_RESULT_PASS "2\n" - -#define TP_SELF_TEST_LONGCHEER_MMI_CMD "mmi" -#define TP_SELF_TEST_XIAOMI_I2C_CMD "i2c" -#define TP_SELF_TEST_XIAOMI_OPEN_CMD "open" -#define TP_SELF_TEST_XIAOMI_SHORT_CMD "short" - -enum lct_tp_selftest_cmd { - TP_SELFTEST_CMD_LONGCHEER_MMI = 0x00, - TP_SELFTEST_CMD_XIAOMI_I2C = 0x01, - TP_SELFTEST_CMD_XIAOMI_OPEN = 0x02, - TP_SELFTEST_CMD_XIAOMI_SHORT = 0x03, -}; - -// Debug log -#define TP_INFO_TAG "LCT_TP_SELFTEST" - -#ifdef TP_INFO_LOG_ENABLE -#define TP_LOGW(log, ...) printk(KERN_WARNING "[%s] %s (line %d): " log, TP_INFO_TAG, __func__, __LINE__, ##__VA_ARGS__) -#define TP_LOGE(log, ...) printk(KERN_ERR "[%s] %s ERROR (line %d): " log, TP_INFO_TAG, __func__, __LINE__, ##__VA_ARGS__) -#else -#define TP_LOGW(log, ...) {} -#define TP_LOGE(log, ...) {} -#endif - -/* - * GLOBAL VARIABLE DEFINITIONS - **************************************************************************************** - */ - -//define touchpad self-test callback type -typedef int (*tp_selftest_callback_t) (unsigned char cmd); -static tp_selftest_callback_t tp_selftest_callback_func; - -static struct proc_dir_entry *tp_selftest_proc; - -static char ft_tp_selftest_status[15] = { 0 }; - -static bool is_in_self_test; -static int lct_tp_selftest_cmd; - -/* - * FUNCTION DEFINITIONS - **************************************************************************************** - */ - -static int tp_chip_self_test(void); -static void tp_selftest_work_func(void); - -static ssize_t tp_selftest_proc_write(struct file *file, - const char __user *buf, size_t size, - loff_t *ppos) -{ - char tmp_data[64] = { 0 }; - - if (copy_from_user(tmp_data, buf, size)) { - TP_LOGE("copy_from_user() fail.\n"); - return -EFAULT; - } - - if ((strncmp - (tmp_data, TP_SELF_TEST_LONGCHEER_MMI_CMD, - strlen(TP_SELF_TEST_LONGCHEER_MMI_CMD)) == 0) - && (!is_in_self_test)) { //mmi - - TP_LOGW("Longcheer MMI TP self-test ...\n"); - lct_tp_selftest_cmd = TP_SELFTEST_CMD_LONGCHEER_MMI; - - } else if ((strncmp - (tmp_data, TP_SELF_TEST_XIAOMI_I2C_CMD, - strlen(TP_SELF_TEST_XIAOMI_I2C_CMD)) == 0) - && (!is_in_self_test)) { //i2c - - TP_LOGW("Xiaomi TP i2c self-test ...\n"); - lct_tp_selftest_cmd = TP_SELFTEST_CMD_XIAOMI_I2C; - - } else if ((strncmp - (tmp_data, TP_SELF_TEST_XIAOMI_OPEN_CMD, - strlen(TP_SELF_TEST_XIAOMI_OPEN_CMD)) == 0) - && (!is_in_self_test)) { //open - - TP_LOGW("Xiaomi TP open self-test ...\n"); - lct_tp_selftest_cmd = TP_SELFTEST_CMD_XIAOMI_OPEN; - - } else if ((strncmp - (tmp_data, TP_SELF_TEST_XIAOMI_SHORT_CMD, - strlen(TP_SELF_TEST_XIAOMI_SHORT_CMD)) == 0) - && (!is_in_self_test)) { //short - - TP_LOGW("Xiaomi TP short self-test ...\n"); - lct_tp_selftest_cmd = TP_SELFTEST_CMD_XIAOMI_SHORT; - - } else { - - TP_LOGW("Unknown command\n"); - is_in_self_test = false; - return size; - - } - - is_in_self_test = true; - - return size; -} - -static ssize_t tp_selftest_proc_read(struct file *file, char __user *buf, - size_t size, loff_t *ppos) -{ - int cnt = 0; - char *page = NULL; - - if (*ppos) - return 0; - - if (is_in_self_test) - tp_selftest_work_func(); - - page = kzalloc(128, GFP_KERNEL); - cnt = snprintf(page, PAGE_SIZE, "%s", ft_tp_selftest_status); - cnt = simple_read_from_buffer(buf, size, ppos, page, cnt); - if (*ppos != cnt) - *ppos = cnt; - TP_LOGW("page=%s, cnt=%d\n", page, cnt); - kfree(page); - - return cnt; -} - -static int tp_chip_self_test(void) -{ - unsigned char cmd = lct_tp_selftest_cmd; - if (tp_selftest_callback_func == NULL) { - TP_LOGW("The TP is not support self test func\n"); - return 0; - } else { - TP_LOGW("Testing ...\n"); - return tp_selftest_callback_func(cmd); - } - -} - -static void tp_selftest_work_func(void) -{ - int i = 0; - int val = 0; - - for (i = 0; i < TP_SELF_TEST_RETROY_COUNT; i++) { - TP_LOGW("tp self test count = %d\n", i); - val = tp_chip_self_test(); - if (val == 2) { - strlcpy(ft_tp_selftest_status, TP_SELF_TEST_RESULT_PASS, - sizeof(ft_tp_selftest_status)); - TP_LOGW("self test success\n"); - break; - } else if (val == 1) { - strlcpy(ft_tp_selftest_status, TP_SELF_TEST_RESULT_FAIL, - sizeof(ft_tp_selftest_status)); - TP_LOGW("self test failed\n"); - } else { - strlcpy(ft_tp_selftest_status, - TP_SELF_TEST_RESULT_UNKNOWN, - sizeof(ft_tp_selftest_status)); - TP_LOGW("self test result Unknown\n"); - break; - } - } - is_in_self_test = false; -} - -void lct_tp_selftest_init(tp_selftest_callback_t callback) -{ - tp_selftest_callback_func = callback; -} - -EXPORT_SYMBOL(lct_tp_selftest_init); - -static const struct file_operations tp_selftest_proc_fops = { - .read = tp_selftest_proc_read, - .write = tp_selftest_proc_write, -}; - -static int __init tp_selftest_init(void) -{ - tp_selftest_proc = - proc_create_data(TP_SELF_TEST_PROC_FILE, 0444, NULL, - &tp_selftest_proc_fops, NULL); - if (IS_ERR_OR_NULL(tp_selftest_proc)) { - TP_LOGW("create /proc/%s failed\n", TP_SELF_TEST_PROC_FILE); - return -EPERM; - } else { - TP_LOGW("create /proc/%s success\n", TP_SELF_TEST_PROC_FILE); - } - return 0; -} - -static void __exit tp_selftest_exit(void) -{ - if (tp_selftest_proc != NULL) { - remove_proc_entry(TP_SELF_TEST_PROC_FILE, NULL); - tp_selftest_proc = NULL; - TP_LOGW("remove /proc/%s\n", TP_SELF_TEST_PROC_FILE); - } - return; -} - -module_init(tp_selftest_init); -module_exit(tp_selftest_exit); - -MODULE_DESCRIPTION("TP selftest driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/input/touchscreen/lct_tp_selftest.h b/drivers/input/touchscreen/lct_tp_selftest.h deleted file mode 100644 index 238e8eb3ead3..000000000000 --- a/drivers/input/touchscreen/lct_tp_selftest.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef _LCT_CTP_SELFTEST_H -#define _LCT_CTP_SELFTEST_H - -#define TP_FELF_TEST_RETROY_COUNT 3 -#define TP_SELF_TEST_CHECK_STATE_COUNT 30 - -#define TP_SELF_TEST_PROC_FILE "tp_selftest" - -#define TP_SELF_TEST_TESTING "Testing" -#define TP_SELF_TEST_RESULT_UNKNOWN "0\n" -#define TP_SELF_TEST_RESULT_FAIL "1\n" -#define TP_SELF_TEST_RESULT_PASS "2\n" - -#define TP_SELF_TEST_LONGCHEER_MMI_CMD "mmi" -#define TP_SELF_TEST_XIAOMI_I2C_CMD "i2c" -#define TP_SELF_TEST_XIAOMI_OPEN_CMD "open" -#define TP_SELF_TEST_XIAOMI_SHORT_CMD "short" - -enum lct_tp_selftest_cmd { - TP_SELFTEST_CMD_LONGCHEER_MMI = 0x00, - TP_SELFTEST_CMD_XIAOMI_I2C = 0x01, - TP_SELFTEST_CMD_XIAOMI_OPEN = 0x02, - TP_SELFTEST_CMD_XIAOMI_SHORT = 0x03, -}; - -//return 1;//selftest result is 'failed' -//return 2;//selftest result is 'success' -//return other-number;//selftest result is 'unknown' -//define touchpad self-test callback type -typedef int (*tp_selftest_callback_t)(unsigned char cmd); - -//set touchpad self-test callback funcation -extern void lct_tp_selftest_init(tp_selftest_callback_t callback); - -#endif - diff --git a/drivers/input/touchscreen/lct_tp_work.c b/drivers/input/touchscreen/lct_tp_work.c deleted file mode 100644 index ae092823afdb..000000000000 --- a/drivers/input/touchscreen/lct_tp_work.c +++ /dev/null @@ -1,216 +0,0 @@ -/**************************************************************************************** - * - * @File Name : lct_tp_work.c - * @Author : wanghan - * @E-mail : - * @Create Time : 2018-09-30 17:34:43 - * @Description : Enable/Disable touchpad. - * - ****************************************************************************************/ - -/* - * INCLUDE FILES - **************************************************************************************** - */ -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * DEFINE CONFIGURATION - **************************************************************************************** - */ -#define TP_WORK_NAME "tp_work" -#define TP_WORK_TAG "LCT_TP_WORK" - -#ifdef TP_WORK_LOG_ENABLE -#define TP_LOGW(log, ...) printk(KERN_WARNING "[%s] %s (line %d): " log, TP_WORK_TAG, __func__, __LINE__, ##__VA_ARGS__) -#define TP_LOGE(log, ...) printk(KERN_ERR "[%s] %s ERROR (line %d): " log, TP_WORK_TAG, __func__, __LINE__, ##__VA_ARGS__) -#else -#define TP_LOGW(log, ...) {} -#define TP_LOGE(log, ...) {} -#endif - -/* - * DATA STRUCTURES - **************************************************************************************** - */ -typedef int (*tp_work_cb_t) (bool enable_tp); - -typedef struct lct_tp { - bool enable_tp_work_flag; - struct proc_dir_entry *proc_entry_tp; - tp_work_cb_t pfun; -} lct_tp_t; - -/* - * GLOBAL VARIABLE DEFINITIONS - **************************************************************************************** - */ -static lct_tp_t *lct_tp_p; - -/* - * FUNCTION DEFINITIONS - **************************************************************************************** - */ -// --- proc --- -static int lct_creat_proc_tp_entry(void); -static ssize_t lct_proc_tp_work_read(struct file *file, char __user *buf, - size_t size, loff_t *ppos); -static ssize_t lct_proc_tp_work_write(struct file *file, - const char __user *buf, size_t size, - loff_t *ppos); -static const struct file_operations lct_proc_tp_work_fops = { - .read = lct_proc_tp_work_read, - .write = lct_proc_tp_work_write, -}; - -int init_lct_tp_work(tp_work_cb_t callback) -{ - if (NULL == callback) { - TP_LOGE("callback is NULL!\n"); - return -EINVAL; - } - - TP_LOGW("Initialization tp_work node!\n"); - lct_tp_p = kzalloc(sizeof(lct_tp_t), GFP_KERNEL); - if (IS_ERR_OR_NULL(lct_tp_p)) { - TP_LOGE("kzalloc() request memory failed!\n"); - return -ENOMEM; - } - lct_tp_p->pfun = callback; - lct_tp_p->enable_tp_work_flag = true; - - if (lct_creat_proc_tp_entry() < 0) { - kfree(lct_tp_p); - return -EPERM; - } - - return 0; -} - -EXPORT_SYMBOL(init_lct_tp_work); - -void uninit_lct_tp_work(void) -{ - TP_LOGW("uninit /proc/%s ...\n", TP_WORK_NAME); - if (IS_ERR_OR_NULL(lct_tp_p)) - return; - if (lct_tp_p->proc_entry_tp != NULL) { - remove_proc_entry(TP_WORK_NAME, NULL); - lct_tp_p->proc_entry_tp = NULL; - TP_LOGW("remove /proc/%s\n", TP_WORK_NAME); - } - kfree(lct_tp_p); - return; -} - -EXPORT_SYMBOL(uninit_lct_tp_work); - -void set_lct_tp_work_status(bool en) -{ - lct_tp_p->enable_tp_work_flag = en; -} - -EXPORT_SYMBOL(set_lct_tp_work_status); - -bool get_lct_tp_work_status(void) -{ - return lct_tp_p->enable_tp_work_flag; -} - -EXPORT_SYMBOL(get_lct_tp_work_status); - -static int lct_creat_proc_tp_entry(void) -{ - lct_tp_p->proc_entry_tp = - proc_create_data(TP_WORK_NAME, 0444, NULL, &lct_proc_tp_work_fops, - NULL); - if (IS_ERR_OR_NULL(lct_tp_p->proc_entry_tp)) { - TP_LOGE("add /proc/tp_work error \n"); - return -EPERM; - } - TP_LOGW("/proc/tp_work is okay!\n"); - - return 0; -} - -static ssize_t lct_proc_tp_work_read(struct file *file, char __user *buf, - size_t size, loff_t *ppos) -{ - ssize_t cnt = 0; - char *page = NULL; - - if (*ppos) - return 0; - - page = kzalloc(128, GFP_KERNEL); - if (IS_ERR_OR_NULL(page)) - return -ENOMEM; - - cnt = - snprintf(page, PAGE_SIZE, "%s", - (lct_tp_p->enable_tp_work_flag ? "1\n" : "0\n")); - - cnt = simple_read_from_buffer(buf, size, ppos, page, cnt); - if (*ppos != cnt) - *ppos = cnt; - TP_LOGW("Touchpad status : %s", page); - - kfree(page); - return cnt; -} - -static ssize_t lct_proc_tp_work_write(struct file *file, - const char __user *buf, size_t size, - loff_t *ppos) -{ - int ret; - ssize_t cnt = 0; - char *page = NULL; - unsigned int input = 0; - - page = kzalloc(128, GFP_KERNEL); - if (IS_ERR_OR_NULL(page)) - return -ENOMEM; - cnt = simple_write_to_buffer(page, 128, ppos, buf, size); - if (cnt <= 0) - return -EINVAL; - if (sscanf(page, "%u", &input) != 1) - return -EINVAL; - - if (input > 0) { - if (lct_tp_p->enable_tp_work_flag) - goto exit; - TP_LOGW("Enbale Touchpad ...\n"); - ret = lct_tp_p->pfun(true); - if (ret) { - TP_LOGW("Enable Touchpad Failed! ret=%d\n", ret); - goto exit; - } - lct_tp_p->enable_tp_work_flag = true; - } else { - if (!lct_tp_p->enable_tp_work_flag) - goto exit; - TP_LOGW("Disable Touchpad ...\n"); - ret = lct_tp_p->pfun(false); - if (ret) { - TP_LOGW("Disable Touchpad Failed! ret=%d\n", ret); - goto exit; - } - lct_tp_p->enable_tp_work_flag = false; - } - TP_LOGW("Set Touchpad successfully!\n"); - -exit: - kfree(page); - return cnt; -} - -MODULE_DESCRIPTION("Touchpad Work Controller Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/input/touchscreen/lct_tp_work.h b/drivers/input/touchscreen/lct_tp_work.h deleted file mode 100644 index 7dc95780df83..000000000000 --- a/drivers/input/touchscreen/lct_tp_work.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef __LCT_TP_WORK_H__ -#define __LCT_TP_WORK_H__ - -typedef int (*tp_work_cb_t)(bool enable_tp); - -extern int init_lct_tp_work(tp_work_cb_t callback); -extern void uninit_lct_tp_work(void); -extern void set_lct_tp_work_status(bool en); -extern bool get_lct_tp_work_status(void); - -#endif //__LCT_TP_WORK_H__ - diff --git a/drivers/input/touchscreen/nt36xxx_spi/nt36xxx.c b/drivers/input/touchscreen/nt36xxx_spi/nt36xxx.c index beecae7bd2d8..35f5a2184ddf 100755 --- a/drivers/input/touchscreen/nt36xxx_spi/nt36xxx.c +++ b/drivers/input/touchscreen/nt36xxx_spi/nt36xxx.c @@ -67,15 +67,6 @@ extern int32_t nvt_extra_proc_init(void); extern void nvt_extra_proc_deinit(void); #endif -/*2019.12.06 longcheer taocheng add charger mode begin*/ -/*function description*/ -#if NVT_USB_PLUGIN -static void nvt_ts_usb_plugin_work_func(struct work_struct *work); -DECLARE_WORK(nvt_usb_plugin_work, nvt_ts_usb_plugin_work_func); -extern touchscreen_usb_plugin_data_t g_touchscreen_usb_pulgin; -#endif -/*2019.12.06 longcheer taocheng add charger mode end*/ - struct nvt_ts_data *ts; //static struct device *spi_geni_master_dev; @@ -133,35 +124,6 @@ const uint16_t gesture_key_array[] = { #endif static uint8_t bTouchIsAwake; -static uint8_t open_pocket_fail; -static uint8_t close_pocket_fail; - -static int lyb_override = 2; -module_param(lyb_override, int, 0644); - -static int lyb_ts_param = 1; -module_param(lyb_ts_param, int, 0644); - -static int lyb_angle_callback = 270; -module_param(lyb_angle_callback, int, 0644); - -static int lyb_palm_status = 0; -module_param(lyb_palm_status, int, 0644); - -static int lyb_touch_game_mode = 1; -module_param(lyb_touch_game_mode, int, 0644); - -static int lyb_touch_active_mode = 1; -module_param(lyb_touch_active_mode, int, 0644); - -static int lyb_touch_up_thresh = 41; -module_param(lyb_touch_up_thresh, int, 0644); - -static int lyb_touch_tolerance = 255; -module_param(lyb_touch_tolerance, int, 0644); - -static int lyb_touch_edge = 1; -module_param(lyb_touch_edge, int, 0644); #if WAKEUP_GESTURE #define WAKEUP_OFF 4 @@ -180,55 +142,6 @@ int nvt_gesture_switch(struct input_dev *dev, unsigned int type, unsigned int co } #endif -/*2019.12.6 longcheer taocheng add charger mode begin*/ -/*function description*/ -#if NVT_USB_PLUGIN -void nvt_ts_usb_event_callback(void) -{ - schedule_work(&nvt_usb_plugin_work); -} - -static void nvt_ts_usb_plugin_work_func(struct work_struct *work) -{ - uint8_t buf[8] = {0}; - int32_t ret = 0; - - if (!bTouchIsAwake) { - NVT_ERR("tp is suspended, can not to set\n"); - return; - } - - NVT_LOG("++\n"); - mutex_lock(&ts->lock); - NVT_LOG("usb_plugged_in = %d\n", g_touchscreen_usb_pulgin.usb_plugged_in); - - msleep(35); - - //---set xdata index to EVENT BUF ADDR--- - ret = nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_HOST_CMD); - if (ret < 0) { - NVT_ERR("Set event buffer index fail!\n"); - goto exit; - } - - buf[0] = EVENT_MAP_HOST_CMD; - if (g_touchscreen_usb_pulgin.usb_plugged_in) - buf[1] = 0x53;// power plug ac on - else - buf[1] = 0x51;// power plug off - - ret = CTP_SPI_WRITE(ts->client, buf, 2); - if (ret < 0) { - NVT_ERR("Write pwr plug switch command fail!\n"); - goto exit; - } - -exit: - mutex_unlock(&ts->lock); - NVT_LOG("--\n"); -} -#endif -/*2019.12.6 longcheer taocheng add charger mode end*/ #ifdef CONFIG_TOUCHSCREEN_COMMON static ssize_t double_tap_show(struct kobject *kobj, @@ -760,16 +673,13 @@ info_retry: switch (ts->touch_vendor_id) { case TP_VENDOR_HUAXING: snprintf(tp_info_buf, sizeof(tp_info_buf), "[Vendor]huaxing,[FW]0x%02x,[IC]nt36672c\n", ts->fw_ver); - update_lct_tp_info(tp_info_buf, NULL); break; case TP_VENDOR_TIANMA: snprintf(tp_info_buf, sizeof(tp_info_buf), "[Vendor]tianma,[FW]0x%02x,[IC]nt36672c\n", ts->fw_ver); - update_lct_tp_info(tp_info_buf, NULL); break; } #else snprintf(tp_info_buf, sizeof(tp_info_buf), "[Vendor]unknown,[FW]0x%02x,[IC]nt36672c\n", ts->fw_ver); - update_lct_tp_info(tp_info_buf, NULL); #endif //---Get Novatek PID--- @@ -1276,47 +1186,6 @@ static uint8_t nvt_wdt_fw_recovery(uint8_t *point_data) } #endif /* #if NVT_TOUCH_WDT_RECOVERY */ -#if LCT_TP_PALM_EN -/*2020.228 longcheer taocheng add for pocket mode start*/ -#define FUNCPAGE_PALM 4 -#define PACKET_PALM_ON 3 -#define PACKET_PALM_OFF 4 -int32_t nvt_check_palm(uint8_t input_id, uint8_t *data) -{ - int32_t ret = 0; - uint8_t func_type = data[2]; - uint8_t palm_state = data[3]; - uint8_t keycode = 0; - - if (get_lct_tp_palm_status()) { - if ((input_id == DATA_PROTOCOL) && (func_type == FUNCPAGE_PALM)) { - ret = palm_state; - if (palm_state == PACKET_PALM_ON) { - NVT_LOG("get packet palm on event.\n"); - keycode = gesture_key_array[13]; - } else if (palm_state == PACKET_PALM_OFF) { - NVT_LOG("get packet palm off event.\n"); - } else { - NVT_ERR("invalid palm state %d!\n", palm_state); - ret = -1; - } - } else { - ret = 0; - } - if (keycode > 0) { - NVT_LOG("powerkey.\n"); - input_report_key(ts->input_dev, keycode, 1); - input_sync(ts->input_dev); - input_report_key(ts->input_dev, keycode, 0); - input_sync(ts->input_dev); - set_lct_tp_palm_status(false); - } - } - return ret; -} -/*2020.2.28 longcheer taocheng add for pocket mode end*/ -#endif - #define POINT_DATA_LEN 65 /******************************************************* Description: @@ -1398,11 +1267,6 @@ static void nvt_ts_worker(struct work_struct *work) #endif /* #if NVT_TOUCH_ESD_PROTECT */ input_id = (uint8_t)(point_data[1] >> 3); -#if LCT_TP_PALM_EN - if (nvt_check_palm(input_id, point_data)) { - goto XFER_ERROR; - } -#endif #if WAKEUP_GESTURE if (bTouchIsAwake == 0) { //input_id = (uint8_t)(point_data[1] >> 3); @@ -1485,12 +1349,6 @@ static void nvt_ts_worker(struct work_struct *work) } #endif /* MT_PROTOCOL_B */ -#if LCT_TP_PALM_EN - //nvt_check_palm(input_id, point_data); - //mutex_unlock(&ts->lock); - //return IRQ_HANDLED; -#endif - #if TOUCH_KEY_NUM > 0 if (point_data[61] == 0xF8) { #if NVT_TOUCH_ESD_PROTECT @@ -1730,522 +1588,6 @@ exit: } #endif -#if LCT_TP_WORK_EN -static void nvt_ts_release_all_finger(void) -{ - struct input_dev *input_dev = ts->input_dev; -#if MT_PROTOCOL_B - u32 finger_count = 0; - u32 max_touches = ts->max_touch_num; -#endif - - mutex_lock(&ts->lock); -#if MT_PROTOCOL_B - for (finger_count = 0; finger_count < max_touches; finger_count++) { - input_mt_slot(input_dev, finger_count); - input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, false); - } -#else - input_mt_sync(input_dev); -#endif - input_report_key(input_dev, BTN_TOUCH, 0); - input_sync(input_dev); - mutex_unlock(&ts->lock); - NVT_LOG("release all finger\n"); -} - -int lct_nvt_tp_work_callback(bool en) -{ - nvt_irq_enable(en); - if (!en) - nvt_ts_release_all_finger(); - set_lct_tp_work_status(en); - NVT_LOG("%s Touchpad\n", en?"Enable":"Disable"); - return 0; -} -#endif -/*2020.2.28 longcheer taocheng add for pocket mode start*/ -#if LCT_TP_PALM_EN -int lct_nvt_tp_palm_callback(bool en) -{ - uint8_t buf[8] = {0}; - int32_t ret = 0; - - if (en) { - msleep(30); - NVT_LOG("sleep 30ms"); - } else { - if (!open_pocket_fail) { - msleep(10); - NVT_LOG("sleep 10ms"); - } else { - msleep(20); - NVT_LOG("sleep 20ms"); - } - } - - if (!bTouchIsAwake) { - NVT_ERR("tp is suspended, can not to set!"); - if (!en) { - open_pocket_fail = 1; - } else { - msleep(450); - NVT_LOG("sleep 450ms"); - NVT_LOG("bTouchIsAwake=%d", bTouchIsAwake); - if (!bTouchIsAwake) { - close_pocket_fail = 0; - } else { - close_pocket_fail = 1; - } - } - return ret; - } - NVT_LOG("init write_buf[8] = {0}"); - NVT_LOG("en=%d", en); - mutex_lock(&ts->lock); - msleep(35); - - //---set xdata index to EVENT BUF ADDR--- - ret = nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_HOST_CMD); - if (ret < 0) { - NVT_ERR("Set event buffer index fail!"); - goto exit; - } - buf[0] = EVENT_MAP_HOST_CMD; - buf[1] = 0x74; - buf[2] = 0x00; - if (en) { - NVT_LOG("screen is not locked"); - } else { - NVT_LOG("screen is locked"); - buf[1] = 0x73; - } - ret = CTP_SPI_WRITE(ts->client, buf, 3); - if (ret < 0) { - NVT_ERR("Write palm command fail!"); - goto exit; - } - if (!en) { - open_pocket_fail = 0; - } else { - close_pocket_fail = 0; - } - //set_lct_tp_palm_status(en); - NVT_LOG("%s PALM", en ? "Disable" : "Enable"); - -exit: - mutex_unlock(&ts->lock); - return ret; - -} -#endif -/*2020.2.28 longcheer taocheng add for pocket mode end*/ - -#if LCT_TP_GRIP_AREA_EN -static int lct_tp_get_screen_angle_callback(void) -{ - uint8_t tmp[8] = {0}; - int32_t ret = -EIO; - uint8_t edge_reject_switch; - - if (!bTouchIsAwake) { - NVT_ERR("tp is suspended\n"); - return ret; - } - - NVT_LOG("++\n"); - - mutex_lock(&ts->lock); - - msleep(35); - - //--set xdata index to EVENT_BUF_ADDR --- - ret = nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_HOST_CMD); - if (ret < 0) { - NVT_ERR("Set event buffer index fail!\n"); - goto out; - } - - tmp[0] = 0x5C; - tmp[1] = 0x00; - ret = CTP_SPI_READ(ts->client, tmp, 2); - if (ret < 0) { - NVT_ERR("Read edge reject switch status fail!\n"); - goto out; - } - - edge_reject_switch = ((tmp[1] >> 5) & 0x03); - switch (edge_reject_switch) { - case 1: - ret = 0; - break; - case 2: - ret = 270; - break; - case 3: - ret = 90; - break; - default: - break; - } - NVT_LOG("edge_reject_switch = %d, angle = %d\n", edge_reject_switch, ret); - -out: - mutex_unlock(&ts->lock); - NVT_LOG("--\n"); - return ret; -} - -static int lct_tp_set_screen_angle_callback(int angle) -{ - uint8_t tmp[3]; - int ret = -EIO; - - if (!bTouchIsAwake) { - NVT_ERR("tp is suspended\n"); - return ret; - } - - NVT_LOG("++\n"); - - mutex_lock(&ts->lock); - - //--set xdata index to EVENT_BUF_ADDR --- - ret = nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_HOST_CMD); - if (ret < 0) { - NVT_ERR("Set event buffer index fail!\n"); - goto out; - } - - tmp[0] = EVENT_MAP_HOST_CMD; - if (angle == 90) { - tmp[1] = 0xBC; - } else if (angle == 270) { - tmp[1] = 0xBB; - } else { - tmp[1] = 0xBA; - } - ret = CTP_SPI_WRITE(ts->client, tmp, 2); - if (ret < 0) { - NVT_LOG("i2c read error!\n"); - goto out; - } - ret = 0; - -out: - mutex_unlock(&ts->lock); - NVT_LOG("--\n"); - return ret; -} -#endif - -/* 2019.12.6 longcheer taocheng add (xiaomi game mode) start */ -/*function description*/ -#ifdef CONFIG_TOUCHSCREEN_XIAOMI_TOUCHFEATURE - -static struct xiaomi_touch_interface xiaomi_touch_interfaces; - -int32_t nvt_xiaomi_read_reg(uint8_t *read_buf) -{ - uint8_t buf[8] = {0}; - int32_t ret = 0; - msleep(35); - - mutex_lock(&ts->reg_lock); - - //---set xdata index to EVENT BUF ADDR--- - nvt_set_page(ts->mmap->EVENT_BUF_ADDR | 0x5C); - - // read reg_addr:0x21C5C - buf[0] = 0x5C; - buf[1] = 0x00; - - ret = CTP_SPI_READ(ts->client, buf, 2); - - *read_buf = ((buf[1] >> 2) & 0xFF); // 0x21C5C 的內容會讀取放在 buf[1] - NVT_LOG("read_buf = %d\n", *read_buf); - - mutex_unlock(&ts->reg_lock); - - return ret; - -} - - -int32_t nvt_xiaomi_write_reg(uint8_t write_buf_high, uint8_t write_buf_low) -{ - - int32_t ret = 0; - uint8_t buf[8] = {0}; - - NVT_LOG("write_buf[1] = 0x%x, write_buf[2] = 0x%x,\n", write_buf_high, write_buf_low); - mutex_lock(&ts->reg_lock); - - //---set xdata index to EVENT BUF ADDR--- - nvt_set_page(ts->mmap->EVENT_BUF_ADDR | 0X50); - - // Write 0x7D@offset 0x50, 0x51@offset 0x51 - buf[0] = EVENT_MAP_HOST_CMD; // write from 0x50 - buf[1] = write_buf_high; //write into 0x50 - buf[2] = write_buf_low; //write info 0x51 - - NVT_LOG("buf[0] = 0x%x, buf[1] = 0x%x, buf[2] = 0x%x\n", buf[0], buf[1], buf[2]); - ret = CTP_SPI_WRITE(ts->client, buf, 3); - - mutex_unlock(&ts->reg_lock); - - return ret; - -} - -static void nvt_init_touchmode_data(void) -{ - int i; - - NVT_LOG("%s,ENTER\n", __func__); - /* Touch Game Mode Switch */ - xiaomi_touch_interfaces.touch_mode[Touch_Game_Mode][GET_DEF_VALUE] = 0; - xiaomi_touch_interfaces.touch_mode[Touch_Game_Mode][GET_MAX_VALUE] = 1; - xiaomi_touch_interfaces.touch_mode[Touch_Game_Mode][GET_MIN_VALUE] = 0; - xiaomi_touch_interfaces.touch_mode[Touch_Game_Mode][SET_CUR_VALUE] = 0; - xiaomi_touch_interfaces.touch_mode[Touch_Game_Mode][GET_CUR_VALUE] = 0; - - /* Active Mode */ - xiaomi_touch_interfaces.touch_mode[Touch_Active_MODE][GET_MAX_VALUE] = 1; - xiaomi_touch_interfaces.touch_mode[Touch_Active_MODE][GET_MIN_VALUE] = 0; - xiaomi_touch_interfaces.touch_mode[Touch_Active_MODE][GET_DEF_VALUE] = 0; - xiaomi_touch_interfaces.touch_mode[Touch_Active_MODE][SET_CUR_VALUE] = 0; - xiaomi_touch_interfaces.touch_mode[Touch_Active_MODE][GET_CUR_VALUE] = 0; - - /* sensivity */ - xiaomi_touch_interfaces.touch_mode[Touch_UP_THRESHOLD][GET_MAX_VALUE] = 50; - xiaomi_touch_interfaces.touch_mode[Touch_UP_THRESHOLD][GET_MIN_VALUE] = 35; - xiaomi_touch_interfaces.touch_mode[Touch_UP_THRESHOLD][GET_DEF_VALUE] = 0; - xiaomi_touch_interfaces.touch_mode[Touch_UP_THRESHOLD][SET_CUR_VALUE] = 0; - xiaomi_touch_interfaces.touch_mode[Touch_UP_THRESHOLD][GET_CUR_VALUE] = 0; - - /* Tolerance */ - xiaomi_touch_interfaces.touch_mode[Touch_Tolerance][GET_MAX_VALUE] = 255; - xiaomi_touch_interfaces.touch_mode[Touch_Tolerance][GET_MIN_VALUE] = 64; - xiaomi_touch_interfaces.touch_mode[Touch_Tolerance][GET_DEF_VALUE] = 0; - xiaomi_touch_interfaces.touch_mode[Touch_Tolerance][SET_CUR_VALUE] = 0; - xiaomi_touch_interfaces.touch_mode[Touch_Tolerance][GET_CUR_VALUE] = 0; - /* edge filter orientation*/ - xiaomi_touch_interfaces.touch_mode[Touch_Panel_Orientation][GET_MAX_VALUE] = 3; - xiaomi_touch_interfaces.touch_mode[Touch_Panel_Orientation][GET_MIN_VALUE] = 0; - xiaomi_touch_interfaces.touch_mode[Touch_Panel_Orientation][GET_DEF_VALUE] = 0; - xiaomi_touch_interfaces.touch_mode[Touch_Panel_Orientation][SET_CUR_VALUE] = 0; - xiaomi_touch_interfaces.touch_mode[Touch_Panel_Orientation][GET_CUR_VALUE] = 0; - - /* edge filter area*/ - xiaomi_touch_interfaces.touch_mode[Touch_Edge_Filter][GET_MAX_VALUE] = 3; - xiaomi_touch_interfaces.touch_mode[Touch_Edge_Filter][GET_MIN_VALUE] = 0; - xiaomi_touch_interfaces.touch_mode[Touch_Edge_Filter][GET_DEF_VALUE] = 2; - xiaomi_touch_interfaces.touch_mode[Touch_Edge_Filter][SET_CUR_VALUE] = 0; - xiaomi_touch_interfaces.touch_mode[Touch_Edge_Filter][GET_CUR_VALUE] = 0; - - - for (i = 0; i < Touch_Mode_NUM; i++) { - NVT_LOG("mode:%d, set cur:%d, get cur:%d, def:%d min:%d max:%d\n", - i, - xiaomi_touch_interfaces.touch_mode[i][SET_CUR_VALUE], - xiaomi_touch_interfaces.touch_mode[i][GET_CUR_VALUE], - xiaomi_touch_interfaces.touch_mode[i][GET_DEF_VALUE], - xiaomi_touch_interfaces.touch_mode[i][GET_MIN_VALUE], - xiaomi_touch_interfaces.touch_mode[i][GET_MAX_VALUE]); - } - - return; -} - -static int nvt_set_cur_value_actual(int nvt_mode, int nvt_value) -{ - - uint8_t nvt_game_value[2] = {0}; - uint8_t temp_value = 0; - uint8_t reg_value = 0; - uint8_t ret = 0; - - if (nvt_mode >= Touch_Mode_NUM && nvt_mode < 0) { - NVT_ERR("%s, nvt mode is error:%d", __func__, nvt_mode); - return -EINVAL; - } else if (xiaomi_touch_interfaces.touch_mode[nvt_mode][SET_CUR_VALUE] > - xiaomi_touch_interfaces.touch_mode[nvt_mode][GET_MAX_VALUE]) { - - xiaomi_touch_interfaces.touch_mode[nvt_mode][SET_CUR_VALUE] = - xiaomi_touch_interfaces.touch_mode[nvt_mode][GET_MAX_VALUE]; - - } else if (xiaomi_touch_interfaces.touch_mode[nvt_mode][SET_CUR_VALUE] < - xiaomi_touch_interfaces.touch_mode[nvt_mode][GET_MIN_VALUE]) { - - xiaomi_touch_interfaces.touch_mode[nvt_mode][SET_CUR_VALUE] = - xiaomi_touch_interfaces.touch_mode[nvt_mode][GET_MIN_VALUE]; - } - - xiaomi_touch_interfaces.touch_mode[nvt_mode][SET_CUR_VALUE] = nvt_value; - - NVT_LOG("%s,nvt_mode:%d,nvt_vlue:%d", __func__, nvt_mode, nvt_value); - - switch (nvt_mode) { - case Touch_Game_Mode: - break; - case Touch_Active_MODE: - break; - case Touch_UP_THRESHOLD: - /* 0,1,2 = default,no hover,strong hover reject*/ - temp_value = xiaomi_touch_interfaces.touch_mode[Touch_UP_THRESHOLD][SET_CUR_VALUE]; - if (temp_value >= 0 && temp_value < 35) - reg_value = 3; - else if (temp_value > 35 && temp_value <= 40) - reg_value = 0; - else if (temp_value > 40 && temp_value <= 45) - reg_value = 1; - else if (temp_value > 45 && temp_value <= 50) - reg_value = 2; - else - reg_value = 3; - - nvt_game_value[0] = 0x71; - nvt_game_value[1] = reg_value; - break; - case Touch_Tolerance: - /* jitter 0,1,2,3,4,5 = default,weakest,weak,mediea,strong,strongest*/ - temp_value = xiaomi_touch_interfaces.touch_mode[Touch_Tolerance][SET_CUR_VALUE]; - if (lyb_ts_param == 1) - { - // expose more values - if (temp_value >= 0 && temp_value <= 80) - reg_value = 0; - else if (temp_value > 80 && temp_value <= 150) - reg_value = 1; - else if (temp_value > 150 && temp_value <= 200) - reg_value = 2; - else if (temp_value > 200 && temp_value <= 225) - reg_value = 3; - else if (temp_value > 225 && temp_value <= 235) - reg_value = 4; - else if (temp_value > 235 && temp_value <= 255) - reg_value = 5; - } else { - // default behaviour - if (temp_value >= 0 && temp_value <= 80) - reg_value = 0; - else if (temp_value > 80 && temp_value <= 150) - reg_value = 1; - else if (temp_value > 150 && temp_value <= 255) - reg_value = 2; - } - nvt_game_value[0] = 0x70; - nvt_game_value[1] = reg_value; - break; - case Touch_Edge_Filter: - /* filter 0,1,2,3,4,5,6,7,8 = default,1,2,3,4,5,6,7,8 level*/ - temp_value = xiaomi_touch_interfaces.touch_mode[Touch_Edge_Filter][SET_CUR_VALUE]; - reg_value = temp_value; - - nvt_game_value[0] = 0x72; - nvt_game_value[1] = reg_value; - break; - case Touch_Panel_Orientation: - /* 0,1,2,3 = 0, 90, 180,270 */ - /* - temp_value = xiaomi_touch_interfaces.touch_mode[Touch_Panel_Orientation][SET_CUR_VALUE]; - if (temp_value == 0 || temp_value == 2) { - nvt_game_value[0] = 0xBA; - nvt_game_value[1] = 0x00; - } else if (temp_value == 3) { - nvt_game_value[0] = 0xBB; - nvt_game_value[1] = 0x00; - } else if (temp_value == 1) { - nvt_game_value[0] = 0xBC; - nvt_game_value[1] = 0x00; - } - */ - break; - default: - /* Don't support */ - break; - - }; - - NVT_LOG("0000 mode:%d, value:%d,temp_value:%d, game value:0x%x,0x%x", - nvt_mode, nvt_value, temp_value, nvt_game_value[0], nvt_game_value[1]); - - xiaomi_touch_interfaces.touch_mode[nvt_mode][GET_CUR_VALUE] = - xiaomi_touch_interfaces.touch_mode[nvt_mode][SET_CUR_VALUE]; - if (xiaomi_touch_interfaces.touch_mode[Touch_Game_Mode][SET_CUR_VALUE]) { - - ret = nvt_xiaomi_write_reg(nvt_game_value[0], nvt_game_value[1]); - if (ret < 0) { - NVT_ERR("change game mode fail"); - } - } - return 0; -} - -static int nvt_set_cur_value(int nvt_mode, int nvt_value) -{ - // make sure userspace didn't set anything when overriden - if (lyb_override != 2) - return nvt_set_cur_value_actual(nvt_mode, nvt_value); - return 0; -} - -static int nvt_get_mode_value(int mode, int value_type) -{ - int value = -1; - - if (mode < Touch_Mode_NUM && mode >= 0) - value = xiaomi_touch_interfaces.touch_mode[mode][value_type]; - else - NVT_ERR("%s, don't support\n", __func__); - - return value; -} - -static int nvt_get_mode_all(int mode, int *value) -{ - if (mode < Touch_Mode_NUM && mode >= 0) { - value[0] = xiaomi_touch_interfaces.touch_mode[mode][GET_CUR_VALUE]; - value[1] = xiaomi_touch_interfaces.touch_mode[mode][GET_DEF_VALUE]; - value[2] = xiaomi_touch_interfaces.touch_mode[mode][GET_MIN_VALUE]; - value[3] = xiaomi_touch_interfaces.touch_mode[mode][GET_MAX_VALUE]; - } else { - NVT_ERR("%s, don't support\n", __func__); - } - NVT_LOG("%s, mode:%d, value:%d:%d:%d:%d\n", __func__, mode, value[0], - value[1], value[2], value[3]); - - return 0; -} - -static int nvt_reset_mode(int mode) -{ - int i = 0; - - NVT_LOG("enter reset mode\n"); - - if (mode < Touch_Mode_NUM && mode > 0) { - xiaomi_touch_interfaces.touch_mode[mode][SET_CUR_VALUE] = - xiaomi_touch_interfaces.touch_mode[mode][GET_DEF_VALUE]; - nvt_set_cur_value(mode, xiaomi_touch_interfaces.touch_mode[mode][SET_CUR_VALUE]); - } else if (mode == 0) { - for (i = Touch_Mode_NUM-1; i >= 0; i--) { - xiaomi_touch_interfaces.touch_mode[i][SET_CUR_VALUE] = - xiaomi_touch_interfaces.touch_mode[i][GET_DEF_VALUE]; - nvt_set_cur_value(i, xiaomi_touch_interfaces.touch_mode[mode][SET_CUR_VALUE]); - } - } else { - NVT_ERR("%s, don't support\n", __func__); - } - - NVT_ERR("%s, mode:%d\n", __func__, mode); - - return 0; -} -#endif -/* 2019.12.16 longcheer taocheng add (xiaomi game mode) end */ - /******************************************************* Description: Novatek touchscreen driver probe function. @@ -2510,55 +1852,6 @@ static int32_t nvt_ts_probe(struct spi_device *client) } #endif - //create longcheer procfs node - ret = init_lct_tp_info("[Vendor]unknown,[FW]unknown,[IC]unknown\n", NULL); - if (ret < 0) { - NVT_ERR("init_lct_tp_info Failed!\n"); - goto err_init_lct_tp_info_failed; - } else { - NVT_LOG("init_lct_tp_info Succeeded!\n"); - } - -#if WAKEUP_GESTURE - ret = init_lct_tp_gesture(lct_nvt_tp_gesture_callback); - if (ret < 0) { - NVT_ERR("init_lct_tp_gesture Failed!\n"); - goto err_init_lct_tp_gesture_failed; - } else { - NVT_LOG("init_lct_tp_gesture Succeeded!\n"); - } -#endif - -#if LCT_TP_GRIP_AREA_EN - ret = init_lct_tp_grip_area(lct_tp_set_screen_angle_callback, lct_tp_get_screen_angle_callback); - if (ret < 0) { - NVT_ERR("init_lct_tp_grip_area Failed!\n"); - goto err_init_lct_tp_grip_area_failed; - } else { - NVT_LOG("init_lct_tp_grip_area Succeeded!\n"); - } -#endif - -#if LCT_TP_WORK_EN - ret = init_lct_tp_work(lct_nvt_tp_work_callback); - if (ret < 0) { - NVT_ERR("init_lct_tp_work Failed!\n"); - goto err_init_lct_tp_work_failed; - } else { - NVT_LOG("init_lct_tp_work Succeeded!\n"); - } -#endif - -#if LCT_TP_PALM_EN - ret = init_lct_tp_palm(lct_nvt_tp_palm_callback); - if (ret < 0) { - NVT_ERR("init_lct_tp_palm Failed!"); - goto err_init_lct_tp_palm_failed; - } else { - NVT_LOG("init_lct_tp_palm Succeeded!"); - } -#endif - ts->coord_workqueue = alloc_workqueue("nvt_ts_workqueue", WQ_HIGHPRI, 0); if (!ts->coord_workqueue) { NVT_ERR("create nvt_ts_workqueue fail"); @@ -2600,32 +1893,6 @@ static int32_t nvt_ts_probe(struct spi_device *client) } #endif - /* 2019.12.16 longcheer taocheng add (xiaomi game mode) start */ - /*function description*/ - if (ts->nvt_tp_class == NULL) { -#ifdef CONFIG_TOUCHSCREEN_XIAOMI_TOUCHFEATURE - ts->nvt_tp_class = get_xiaomi_touch_class(); -#endif - if (ts->nvt_tp_class) { - ts->nvt_touch_dev = device_create(ts->nvt_tp_class, NULL, 0x38, ts, "tp_dev"); - if (IS_ERR(ts->nvt_touch_dev)) { - NVT_ERR("Failed to create device !\n"); - goto err_class_create; - } - dev_set_drvdata(ts->nvt_touch_dev, ts); -#ifdef CONFIG_TOUCHSCREEN_XIAOMI_TOUCHFEATURE - memset(&xiaomi_touch_interfaces, 0x00, sizeof(struct xiaomi_touch_interface)); - xiaomi_touch_interfaces.getModeValue = nvt_get_mode_value; - xiaomi_touch_interfaces.setModeValue = nvt_set_cur_value; - xiaomi_touch_interfaces.resetMode = nvt_reset_mode; - xiaomi_touch_interfaces.getModeAll = nvt_get_mode_all; - nvt_init_touchmode_data(); - xiaomitouch_register_modedata(&xiaomi_touch_interfaces); -#endif - } - } - /* 2019.12.16 longcheer taocheng add (xiaomi game mode) end */ - bTouchIsAwake = 1; NVT_LOG("end\n"); @@ -2638,11 +1905,6 @@ static int32_t nvt_ts_probe(struct spi_device *client) pm_runtime_enable(&ts->client->dev); -//2019.12.06 longcheer taocheng add for charger mode -#if NVT_USB_PLUGIN - g_touchscreen_usb_pulgin.event_callback = nvt_ts_usb_event_callback; -#endif - #if 0 //spi bus pm_runtime_get spi_geni_master_dev = lct_get_spi_geni_master_dev(ts->client->master); @@ -2654,11 +1916,6 @@ static int32_t nvt_ts_probe(struct spi_device *client) return 0; -//2019.12.16 longcheer taocheng add (xiaomi game mode) -err_class_create: - class_destroy(ts->nvt_tp_class); - ts->nvt_tp_class = NULL; - err_create_nvt_ts_workqueue_failed: if (ts->coord_workqueue) destroy_workqueue(ts->coord_workqueue); @@ -2678,26 +1935,6 @@ err_register_fb_notif_failed: unregister_early_suspend(&ts->early_suspend); err_register_early_suspend_failed: #endif -#if LCT_TP_WORK_EN -err_init_lct_tp_work_failed: -uninit_lct_tp_work(); -#endif - -#if LCT_TP_PALM_EN -err_init_lct_tp_palm_failed: -uninit_lct_tp_palm(); -#endif - -#if LCT_TP_GRIP_AREA_EN -err_init_lct_tp_grip_area_failed: -uninit_lct_tp_grip_area(); -#endif -#if WAKEUP_GESTURE -err_init_lct_tp_gesture_failed: -uninit_lct_tp_gesture(); -#endif -err_init_lct_tp_info_failed: -uninit_lct_tp_info(); #if NVT_TOUCH_EXT_PROC nvt_extra_proc_deinit(); err_extra_proc_init_failed: @@ -2791,23 +2028,6 @@ static int32_t nvt_ts_remove(struct spi_device *client) unregister_early_suspend(&ts->early_suspend); #endif - //remove longcheer procfs -#if LCT_TP_WORK_EN - uninit_lct_tp_work(); -#endif - -#if LCT_TP_PALM_EN - uninit_lct_tp_palm(); -#endif - -#if LCT_TP_GRIP_AREA_EN - uninit_lct_tp_grip_area(); -#endif -#if WAKEUP_GESTURE - uninit_lct_tp_gesture(); -#endif - uninit_lct_tp_info(); - #if NVT_TOUCH_EXT_PROC nvt_extra_proc_deinit(); #endif @@ -2889,15 +2109,6 @@ static void nvt_ts_shutdown(struct spi_device *client) unregister_early_suspend(&ts->early_suspend); #endif - //remove longcheer procfs -#if LCT_TP_WORK_EN - uninit_lct_tp_work(); -#endif -#if WAKEUP_GESTURE - uninit_lct_tp_gesture(); -#endif - uninit_lct_tp_info(); - #if NVT_TOUCH_EXT_PROC nvt_extra_proc_deinit(); #endif @@ -3019,23 +2230,6 @@ static int32_t nvt_ts_suspend(struct device *dev) return 0; } -void lyb_apply_changes(void) -{ - if (lyb_override >= 1) { - // 1 == AOSP with touch profile - lct_tp_set_screen_angle_callback(lyb_angle_callback); - if (lyb_override >= 2) { - // 2 == AOSP without touch profile - set_lct_tp_palm_status((lyb_palm_status == 0)); - nvt_set_cur_value_actual(Touch_Game_Mode, lyb_touch_game_mode); - nvt_set_cur_value_actual(Touch_Active_MODE, lyb_touch_active_mode); - nvt_set_cur_value_actual(Touch_UP_THRESHOLD, lyb_touch_up_thresh); - nvt_set_cur_value_actual(Touch_Tolerance, lyb_touch_tolerance); - nvt_set_cur_value_actual(Touch_Edge_Filter, lyb_touch_edge); - } - } -} - /******************************************************* Description: Novatek touchscreen driver resume function. @@ -3094,13 +2288,6 @@ static int32_t nvt_ts_resume(struct device *dev) NVT_LOG("bTouchIsAwake = 1\n"); mutex_unlock(&ts->lock); -#if LCT_TP_PALM_EN - if (open_pocket_fail) { - NVT_LOG("re-open pocket mode\n"); - lct_nvt_tp_palm_callback(false); - } -#endif - #if WAKEUP_GESTURE if (ts->delay_gesture) { lct_nvt_tp_gesture_callback(!ts->is_gesture_mode); @@ -3108,28 +2295,8 @@ static int32_t nvt_ts_resume(struct device *dev) } #endif -#if LCT_TP_WORK_EN - if (!get_lct_tp_work_status()) - nvt_irq_enable(false); -#endif - -//2019.12.06 longcheer taocheng add for charger mode -#if NVT_USB_PLUGIN - if (g_touchscreen_usb_pulgin.valid && g_touchscreen_usb_pulgin.usb_plugged_in) - g_touchscreen_usb_pulgin.event_callback(); -#endif - NVT_LOG("end\n"); -#if LCT_TP_PALM_EN - msleep(100); - if (close_pocket_fail) { - NVT_LOG("re-close pocket mode\n"); - lct_nvt_tp_palm_callback(true); - } -#endif - lyb_apply_changes(); - return 0; } diff --git a/drivers/input/touchscreen/nt36xxx_spi/nt36xxx.h b/drivers/input/touchscreen/nt36xxx_spi/nt36xxx.h index d98e90cc29e9..d090ff00e125 100755 --- a/drivers/input/touchscreen/nt36xxx_spi/nt36xxx.h +++ b/drivers/input/touchscreen/nt36xxx_spi/nt36xxx.h @@ -31,16 +31,6 @@ #include "nt36xxx_mem_map.h" -// include longcheer header -#include "../lct_tp_info.h" -#include "../lct_tp_selftest.h" -#include "../lct_tp_gesture.h" -#include "../lct_tp_grip_area.h" -#include "../lct_tp_work.h" -#include "../lct_tp_palm.h" -#ifdef CONFIG_TOUCHSCREEN_XIAOMI_TOUCHFEATURE -#include "../xiaomi/xiaomi_touch.h" -#endif #define NVT_DEBUG 0 //---GPIO number--- @@ -89,7 +79,6 @@ extern const uint16_t touch_key_array[TOUCH_KEY_NUM]; #if WAKEUP_GESTURE extern const uint16_t gesture_key_array[]; #endif -#define LCT_TP_PALM_EN 1 #define BOOT_UPDATE_FIRMWARE 1 #define FIRMWARE_NAME_LEN 256 #define BOOT_UPDATE_FIRMWARE_NAME "novatek_ts_fw.bin" @@ -108,39 +97,11 @@ extern const uint16_t gesture_key_array[]; //enable 'check touch vendor' feature #define CHECK_TOUCH_VENDOR -//enable tp work feature -#define LCT_TP_WORK_EN 1 - -//enable tp grip area feature -#define LCT_TP_GRIP_AREA_EN 1 - -/*2019.12.06 longcheer taocheng add for charger mode begin*/ -/*functions description*/ -//enable tp usb plugin feature -#define NVT_USB_PLUGIN 1 - -#if NVT_USB_PLUGIN -typedef struct touchscreen_usb_plugin_data { - bool valid; - bool usb_plugged_in; - void (*event_callback)(void); -} touchscreen_usb_plugin_data_t; -#endif -/*2019.12.06 longcheer taocheng add charger mode end*/ - //---Touch Vendor ID--- #define TP_VENDOR_UNKNOWN 0x00 #define TP_VENDOR_HUAXING 0x01 #define TP_VENDOR_TIANMA 0x02 -/* 2019.12.16 longcheer taocheng add (xiaomi game mode) start */ -#define NVT_REG_MONITOR_MODE 0x7000 -#define NVT_REG_THDIFF 0x7100 -#define NVT_REG_SENSIVITY 0x7200 -#define NVT_REG_EDGE_FILTER_LEVEL 0xBA00 -#define NVT_REG_EDGE_FILTER_ORIENTATION 0xBC00 -/* 2019.12.16 longcheer taocheng add (xiaomi game mode) end */ - //new qcom platform use #define _MSM_DRM_NOTIFY_H_ @@ -200,17 +161,7 @@ struct nvt_ts_data { struct regulator *pwr_lab; /* VSP +5V */ struct regulator *pwr_ibb; /* VSN -5V */ #endif - -/*2019.12.16 longcheer taocheng add (xiaomi game mode) start*/ -#ifdef CONFIG_TOUCHSCREEN_XIAOMI_TOUCHFEATURE - u8 palm_sensor_switch; - bool palm_sensor_changed; - bool gamemode_enabled; -#endif struct mutex reg_lock; - struct device *nvt_touch_dev; - struct class *nvt_tp_class; -/*2019.12.16 longcheer taocheng add (xiaomi game mode) end*/ }; #if NVT_TOUCH_PROC @@ -278,7 +229,6 @@ void nvt_sw_reset_idle(void); void nvt_boot_ready(void); void nvt_bld_crc_enable(void); void nvt_fw_crc_enable(void); -void lyb_apply_changes(void); int32_t nvt_update_firmware(char *firmware_name); int32_t nvt_check_fw_reset_state(RST_COMPLETE_STATE check_reset_state); int32_t nvt_get_fw_info(void); diff --git a/drivers/input/touchscreen/nt36xxx_spi/nt36xxx_ext_proc.c b/drivers/input/touchscreen/nt36xxx_spi/nt36xxx_ext_proc.c index 1c51c7e7f977..ef5f154429e9 100644 --- a/drivers/input/touchscreen/nt36xxx_spi/nt36xxx_ext_proc.c +++ b/drivers/input/touchscreen/nt36xxx_spi/nt36xxx_ext_proc.c @@ -23,20 +23,11 @@ #include "nt36xxx.h" #if NVT_TOUCH_EXT_PROC + #define NVT_FW_VERSION "nvt_fw_version" #define NVT_BASELINE "nvt_baseline" #define NVT_RAW "nvt_raw" #define NVT_DIFF "nvt_diff" -#define NVT_XIAOMI_CONFIG_INFO "nvt_xiaomi_config_info" -#define NVT_PF_SWITCH "nvt_pf_switch" -#define NVT_SENSITIVITY_SWITCH "nvt_sensitivity_switch" -#define NVT_ER_RANGE_SWITCH "nvt_er_range_switch" -#define NVT_MAX_POWER_SWITCH "nvt_max_power_switch" -#define NVT_EDGE_REJECT_SWITCH "nvt_edge_reject_switch" -#define NVT_POCKET_PALM_SWITCH "nvt_pocket_palm_switch" -#define NVT_CHARGER_SWITCH "nvt_charger_switch" -#define NVT_LYB_APPLY_CHANGES "nvt_lyb_apply_changes" -#define LCT_TP_DATA_DUMP "tp_data_dump" #define SPI_TANSFER_LENGTH 256 @@ -54,22 +45,8 @@ static struct proc_dir_entry *NVT_proc_fw_version_entry; static struct proc_dir_entry *NVT_proc_baseline_entry; static struct proc_dir_entry *NVT_proc_raw_entry; static struct proc_dir_entry *NVT_proc_diff_entry; -static struct proc_dir_entry *NVT_proc_xiaomi_config_info_entry; -static struct proc_dir_entry *NVT_proc_pf_switch_entry; -static struct proc_dir_entry *NVT_proc_sensitivity_switch_entry; -static struct proc_dir_entry *NVT_proc_er_range_switch_entry; -static struct proc_dir_entry *NVT_proc_max_power_switch_entry; -static struct proc_dir_entry *NVT_proc_edge_reject_switch_entry; -static struct proc_dir_entry *NVT_proc_pocket_palm_switch_entry; -static struct proc_dir_entry *NVT_proc_charger_switch_entry; -static struct proc_dir_entry *NVT_proc_lyb_apply_changes; -static int32_t diff_data[2048] = {0}; -static struct proc_dir_entry *LCT_proc_tp_data_dump_entry; -// Xiaomi Config Info. -static uint8_t nvt_xiaomi_conf_info_fw_ver; -static uint8_t nvt_xiaomi_conf_info_fae_id; -static uint64_t nvt_xiaomi_conf_info_reservation; +static int32_t diff_data[2048] = {0}; /******************************************************* Description: @@ -117,8 +94,6 @@ uint8_t nvt_get_fw_pipe(void) buf[1] = 0x00; CTP_SPI_READ(ts->client, buf, 2); - //NVT_LOG("FW pipe=%d, buf[1]=0x%02X\n", (buf[1]&0x01), buf[1]); - return (buf[1] & 0x01); } @@ -146,9 +121,6 @@ void nvt_read_mdata(uint32_t xdata_addr, uint32_t xdata_btn_addr) data_len = ts->x_num * ts->y_num * 2; residual_len = (head_addr + dummy_len + data_len) % XDATA_SECTOR_SIZE; - //printk("head_addr=0x%05X, dummy_len=0x%05X, data_len=0x%05X, - //residual_len=0x%05X\n", head_addr, dummy_len, data_len, residual_len); - //read xdata : step 1 for (i = 0; i < ((dummy_len + data_len) / XDATA_SECTOR_SIZE); i++) { //---read xdata by SPI_TANSFER_LENGTH @@ -166,7 +138,6 @@ void nvt_read_mdata(uint32_t xdata_addr, uint32_t xdata_btn_addr) //printk("0x%02X, 0x%04X\n", buf[k+1], (XDATA_SECTOR_SIZE*i + SPI_TANSFER_LENGTH*j + k)); } } - //printk("addr=0x%05X\n", (head_addr+XDATA_SECTOR_SIZE*i)); } //read xdata : step2 @@ -183,11 +154,8 @@ void nvt_read_mdata(uint32_t xdata_addr, uint32_t xdata_btn_addr) //---copy buf to xdata_tmp--- for (k = 0; k < SPI_TANSFER_LENGTH; k++) { xdata_tmp[(dummy_len + data_len - residual_len) + SPI_TANSFER_LENGTH * j + k] = buf[k + 1]; - //printk("0x%02X, 0x%04x\n", buf[k+1], - //((dummy_len+data_len-residual_len) + SPI_TANSFER_LENGTH*j + k)); } } - //printk("addr=0x%05X\n", (xdata_addr+data_len-residual_len)); } //---remove dummy data and 2bytes-to-1data--- @@ -539,57 +507,6 @@ static const struct file_operations nvt_diff_fops = { .release = seq_release, }; -static int nvt_xiaomi_config_info_show(struct seq_file *m, void *v) -{ - seq_printf(m, "FW version/Config version, Debug version: 0x%02X\n", nvt_xiaomi_conf_info_fw_ver); - seq_printf(m, "FAE ID: 0x%02X\n", nvt_xiaomi_conf_info_fae_id); - seq_printf(m, "Reservation byte: 0x%012llX\n", nvt_xiaomi_conf_info_reservation); - - return 0; -} - -static int32_t nvt_xiaomi_config_info_open(struct inode *inode, struct file *file) -{ - uint8_t buf[16] = {0}; - - if (mutex_lock_interruptible(&ts->lock)) { - return -ERESTARTSYS; - } - - NVT_LOG("++\n"); - -#if NVT_TOUCH_ESD_PROTECT - nvt_esd_check_enable(false); -#endif /* #if NVT_TOUCH_ESD_PROTECT */ - - //---set xdata index to EVENT BUF ADDR--- - nvt_set_page(ts->mmap->EVENT_BUF_ADDR | 0x9C); - - buf[0] = 0x9C; - CTP_SPI_READ(ts->client, buf, 9); - - nvt_xiaomi_conf_info_fw_ver = buf[1]; - nvt_xiaomi_conf_info_fae_id = buf[2]; - nvt_xiaomi_conf_info_reservation = - (((uint64_t)buf[3] << 40) | ((uint64_t)buf[4] << 32) | - ((uint64_t)buf[5] << 24) | ((uint64_t)buf[6] << 16) | - ((uint64_t)buf[7] << 8) | (uint64_t)buf[8]); - - mutex_unlock(&ts->lock); - - NVT_LOG("--\n"); - - return single_open(file, nvt_xiaomi_config_info_show, NULL); -} - -static const struct file_operations nvt_xiaomi_config_info_fops = { - .owner = THIS_MODULE, - .open = nvt_xiaomi_config_info_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - /******************************************************* Description: Novatek touchscreen read diff meta data function. @@ -614,9 +531,6 @@ void nvt_read_diff_mdata(uint32_t xdata_addr, uint32_t xdata_btn_addr) data_len = ts->x_num * ts->y_num * 2; residual_len = (head_addr + dummy_len + data_len) % XDATA_SECTOR_SIZE; - //printk("head_addr=0x%05X, dummy_len=0x%05X, data_len=0x%05X, - //residual_len=0x%05X\n", head_addr, dummy_len, data_len, residual_len); - //read diff_data : step 1 for (i = 0; i < ((dummy_len + data_len) / XDATA_SECTOR_SIZE); i++) { //---read diff_data by SPI_TANSFER_LENGTH @@ -631,11 +545,8 @@ void nvt_read_diff_mdata(uint32_t xdata_addr, uint32_t xdata_btn_addr) //---copy buf to xdata_tmp--- for (k = 0; k < SPI_TANSFER_LENGTH; k++) { xdata_tmp[XDATA_SECTOR_SIZE * i + SPI_TANSFER_LENGTH * j + k] = buf[k + 1]; - //printk("0x%02X, 0x%04X\n", buf[k+1], - //(XDATA_SECTOR_SIZE*i + SPI_TANSFER_LENGTH*j + k)); } } - //printk("addr=0x%05X\n", (head_addr+XDATA_SECTOR_SIZE*i)); } //read diff_data : step2 @@ -652,11 +563,8 @@ void nvt_read_diff_mdata(uint32_t xdata_addr, uint32_t xdata_btn_addr) //---copy buf to xdata_tmp--- for (k = 0; k < SPI_TANSFER_LENGTH; k++) { xdata_tmp[(dummy_len + data_len - residual_len) + SPI_TANSFER_LENGTH * j + k] = buf[k + 1]; - //printk("0x%02X, 0x%04x\n", buf[k+1], - //((dummy_len+data_len-residual_len) + SPI_TANSFER_LENGTH*j + k)); } } - //printk("addr=0x%05X\n", (xdata_addr+data_len-residual_len)); } //---remove dummy data and 2bytes-to-1data--- @@ -682,1436 +590,6 @@ void nvt_read_diff_mdata(uint32_t xdata_addr, uint32_t xdata_btn_addr) nvt_set_page(ts->mmap->EVENT_BUF_ADDR); } -/******************************************************* -Description: - Novatek touchscreen tp_data_dump sequence print show - function. - -return: - Executive outcomes. 0---succeed. -*******************************************************/ -static int32_t c_tp_data_dump_show(struct seq_file *m, void *v) -{ - int32_t i = 0; - int32_t j = 0; - - seq_printf(m, "\nRAW DATA\n"); -#if 0 //0 - for (i = 0; i < ts->y_num; i++) { - for (j = 0; j < ts->x_num; j++) { - seq_printf(m, "%6d", xdata[ts->x_num * i + j]); - } - seq_puts(m, "\n"); - } -#endif -#if 1 //90 - for (i = 0; i < ts->x_num; i++) { - for (j = 0; j < ts->y_num; j++) { - seq_printf(m, "%6d", xdata[ts->x_num * j + (ts->x_num - 1 - i)]); - } - seq_puts(m, "\n"); - } -#endif -#if 0 //180 - for (i = 0; i < ts->y_num; i++) { - for (j = 0; j < ts->x_num; j++) { - seq_printf(m, "%6d", xdata[ts->x_num * (ts->y_num - 1 - i) + j]); - } - seq_puts(m, "\n"); - } -#endif -#if 0 //270 - for (i = 0; i < ts->x_num; i++) { - for (j = 0; j < ts->y_num; j++) { - seq_printf(m, "%6d", xdata[ts->x_num * (ts->y_num - 1 - j) + i]); - } - seq_puts(m, "\n"); - } -#endif - - -#if TOUCH_KEY_NUM > 0 - for (i = 0; i < TOUCH_KEY_NUM; i++) { - seq_printf(m, "%6d", xdata[ts->x_num * ts->y_num + i]); - } - seq_puts(m, "\n"); -#endif - - seq_printf(m, "\nDIFF DATA\n"); -#if 0 //0 - for (i = 0; i < ts->y_num; i++) { - for (j = 0; j < ts->x_num; j++) { - seq_printf(m, "%6d", diff_data[ts->x_num * i + j]); - } - seq_puts(m, "\n"); - } -#endif -#if 1 //90 - for (i = 0; i < ts->x_num; i++) { - for (j = 0; j < ts->y_num; j++) { - seq_printf(m, "%6d", diff_data[ts->x_num * j + (ts->x_num - 1 - i)]); - } - seq_puts(m, "\n"); - } -#endif -#if 0 //180 - for (i = 0; i < ts->y_num; i++) { - for (j = 0; j < ts->x_num; j++) { - seq_printf(m, "%6d", diff_data[ts->x_num * (ts->y_num - 1 - i) + j]); - } - seq_puts(m, "\n"); - } -#endif -#if 0 //270 - for (i = 0; i < ts->x_num; i++) { - for (j = 0; j < ts->y_num; j++) { - seq_printf(m, "%6d", diff_data[ts->x_num * (ts->y_num - 1 - j) + i]); - } - seq_puts(m, "\n"); - } -#endif - -#if TOUCH_KEY_NUM > 0 - for (i = 0; i < TOUCH_KEY_NUM; i++) { - seq_printf(m, "%6d", diff_data[ts->x_num * ts->y_num + i]); - } - seq_puts(m, "\n"); -#endif - - return 0; -} - -const struct seq_operations lct_tp_data_dump_seq_ops = { - .start = c_start, - .next = c_next, - .stop = c_stop, - .show = c_tp_data_dump_show -}; - -/******************************************************* -Description: - Novatek touchscreen /proc/tp_data_dump open function. - -return: - Executive outcomes. 0---succeed. -*******************************************************/ -static int32_t lct_tp_data_dump_open(struct inode *inode, struct file *file) -{ - if (mutex_lock_interruptible(&ts->lock)) { - return -ERESTARTSYS; - } - - NVT_LOG("++\n"); - -#if NVT_TOUCH_ESD_PROTECT - nvt_esd_check_enable(false); -#endif /* #if NVT_TOUCH_ESD_PROTECT */ - - if (nvt_clear_fw_status()) { - mutex_unlock(&ts->lock); - return -EAGAIN; - } - - nvt_change_mode(TEST_MODE_2); - - if (nvt_check_fw_status()) { - mutex_unlock(&ts->lock); - return -EAGAIN; - } - - if (nvt_get_fw_info()) { - mutex_unlock(&ts->lock); - return -EAGAIN; - } - - if (nvt_get_fw_pipe() == 0) - nvt_read_mdata(ts->mmap->RAW_PIPE0_ADDR, ts->mmap->RAW_BTN_PIPE0_ADDR); - else - nvt_read_mdata(ts->mmap->RAW_PIPE1_ADDR, ts->mmap->RAW_BTN_PIPE1_ADDR); - - if (nvt_get_fw_pipe() == 0) - nvt_read_diff_mdata(ts->mmap->DIFF_PIPE0_ADDR, ts->mmap->DIFF_BTN_PIPE0_ADDR); - else - nvt_read_diff_mdata(ts->mmap->DIFF_PIPE1_ADDR, ts->mmap->DIFF_BTN_PIPE1_ADDR); - - nvt_change_mode(NORMAL_MODE); - - mutex_unlock(&ts->lock); - - NVT_LOG("--\n"); - - return seq_open(file, &lct_tp_data_dump_seq_ops); -} - -static const struct file_operations lct_tp_data_dump_fops = { - .owner = THIS_MODULE, - .open = lct_tp_data_dump_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, -}; -/*2019.12.10 longcheer taocheng add for charger mode & other node start*/ -/*function description*/ -int32_t nvt_set_pf_switch(uint8_t pf_switch) -{ - uint8_t buf[8] = {0}; - int32_t ret = 0; - - NVT_LOG("++\n"); - NVT_LOG("set pf switch: %d\n", pf_switch); - - msleep(35); - - //---set xdata index to EVENT BUF ADDR--- - ret = nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_HOST_CMD); - if (ret < 0) { - NVT_ERR("Set event buffer index fail!\n"); - goto nvt_set_pf_switch_out; - } - - buf[0] = EVENT_MAP_HOST_CMD; - buf[1] = 0x70; - buf[2] = pf_switch; - ret = CTP_SPI_WRITE(ts->client, buf, 3); - if (ret < 0) { - NVT_ERR("Write pf switch command fail!\n"); - goto nvt_set_pf_switch_out; - } - -nvt_set_pf_switch_out: - NVT_LOG("--\n"); - return ret; -} - -int32_t nvt_get_pf_switch(uint8_t *pf_switch) -{ - uint8_t buf[8] = {0}; - int32_t ret = 0; - - NVT_LOG("++\n"); - - msleep(35); - - //---set xdata index to EVENT BUF ADDR--- - ret = nvt_set_page(ts->mmap->EVENT_BUF_ADDR | 0x5D); - if (ret < 0) { - NVT_ERR("Set event buffer index fail!\n"); - goto nvt_get_pf_switch_out; - } - - buf[0] = 0x5D; - buf[1] = 0x00; - ret = CTP_SPI_READ(ts->client, buf, 2); - if (ret < 0) { - NVT_ERR("Read pf switch status fail!\n"); - goto nvt_get_pf_switch_out; - } - - *pf_switch = (buf[1] & 0x03); - NVT_LOG("pf_switch = %d\n", *pf_switch); - -nvt_get_pf_switch_out: - NVT_LOG("--\n"); - return ret; -} - -static ssize_t nvt_pf_switch_proc_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) -{ - static int finished; - int32_t cnt = 0; - int32_t len = 0; - uint8_t pf_switch; - char tmp_buf[64]; - - NVT_LOG("++\n"); - /* - * We return 0 to indicate end of file, that we have - * no more information. Otherwise, processes will - * continue to read from us in an endless loop. - */ - if (finished) { - NVT_LOG("read END\n"); - finished = 0; - return 0; - } - finished = 1; - - if (mutex_lock_interruptible(&ts->lock)) { - return -ERESTARTSYS; - } - -#if NVT_TOUCH_ESD_PROTECT - nvt_esd_check_enable(false); -#endif /* #if NVT_TOUCH_ESD_PROTECT */ - - nvt_get_pf_switch(&pf_switch); - - mutex_unlock(&ts->lock); -//2019.12.21 longcheer taocheng edit for enable pf_proc - cnt = snprintf(tmp_buf, sizeof(tmp_buf), "pf_switch: %d\n", pf_switch); - if (copy_to_user(buf, tmp_buf, sizeof(tmp_buf))) { - NVT_ERR("copy_to_user() error!\n"); - return -EFAULT; - } - buf += cnt; - len += cnt; - - NVT_LOG("--\n"); - return len; -} - -static ssize_t nvt_pf_switch_proc_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) -{ - int32_t ret; - int32_t tmp; - uint8_t pf_switch; - char *tmp_buf; - - NVT_LOG("++\n"); - - if (count == 0 || count > 2) { - NVT_ERR("Invalid value! count = %zu\n", count); - ret = -EINVAL; - goto out; - } - - /*2019.12.21 longcheer taocheng add for enable pf_proc start*/ - /*function description*/ - tmp_buf = kzalloc(count, GFP_KERNEL); - if (!tmp_buf) { - NVT_ERR("Allocate tmp_buf fail!\n"); - ret = -ENOMEM; - goto out; - } - if (copy_from_user(tmp_buf, buf, count)) { - NVT_ERR("copy_from_user() error!\n"); - ret = -EFAULT; - goto out; - } - /*2019.12.21 longcheer taocheng add for enable pf_proc end*/ - - ret = sscanf(tmp_buf, "%d", &tmp); - if (ret != 1) { - NVT_ERR("Invalid value! ret = %d\n", ret); - ret = -EINVAL; - goto out; - } - if (tmp < 0 || tmp > 2) { - NVT_ERR("Invalid value! tmp = %d\n", tmp); - ret = -EINVAL; - goto out; - } - pf_switch = (uint8_t)tmp; - NVT_LOG("pf_switch = %d\n", pf_switch); - - if (mutex_lock_interruptible(&ts->lock)) { - return -ERESTARTSYS; - } - -#if NVT_TOUCH_ESD_PROTECT - nvt_esd_check_enable(false); -#endif /* #if NVT_TOUCH_ESD_PROTECT */ - - nvt_set_pf_switch(pf_switch); - - mutex_unlock(&ts->lock); - - ret = count; -out: - kfree(tmp_buf); - NVT_LOG("--\n"); - return ret; -} - -static const struct file_operations nvt_pf_switch_fops = { - .owner = THIS_MODULE, - .read = nvt_pf_switch_proc_read, - .write = nvt_pf_switch_proc_write, -}; - -int32_t nvt_set_sensitivity_switch(uint8_t sensitivity_switch) -{ - uint8_t buf[8] = {0}; - int32_t ret = 0; - - NVT_LOG("++\n"); - NVT_LOG("set sensitivity switch: %d\n", sensitivity_switch); - - msleep(35); - - //---set xdata index to EVENT BUF ADDR--- - ret = nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_HOST_CMD); - if (ret < 0) { - NVT_ERR("Set event buffer index fail!\n"); - goto nvt_set_sensitivity_switch_out; - } - - buf[0] = EVENT_MAP_HOST_CMD; - buf[1] = 0x71; - buf[2] = sensitivity_switch; - ret = CTP_SPI_WRITE(ts->client, buf, 3); - if (ret < 0) { - NVT_ERR("Write sensitivity switch command fail!\n"); - goto nvt_set_sensitivity_switch_out; - } - -nvt_set_sensitivity_switch_out: - NVT_LOG("--\n"); - return ret; -} - -int32_t nvt_get_sensitivity_switch(uint8_t *sensitivity_switch) -{ - uint8_t buf[8] = {0}; - int32_t ret = 0; - - NVT_LOG("++\n"); - - msleep(35); - - //---set xdata index to EVENT BUF ADDR--- - ret = nvt_set_page(ts->mmap->EVENT_BUF_ADDR | 0x5D); - if (ret < 0) { - NVT_ERR("Set event buffer index fail!\n"); - goto nvt_get_sensitivity_switch_out; - } - - buf[0] = 0x5D; - buf[1] = 0x00; - ret = CTP_SPI_READ(ts->client, buf, 2); - if (ret < 0) { - NVT_ERR("Read sensitivity switch status fail!\n"); - goto nvt_get_sensitivity_switch_out; - } - - *sensitivity_switch = ((buf[1] >> 2) & 0x03); - NVT_LOG("sensitivity_switch = %d\n", *sensitivity_switch); - -nvt_get_sensitivity_switch_out: - NVT_LOG("--\n"); - return ret; -} - -static ssize_t nvt_sensitivity_switch_proc_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) -{ - static int finished; - int32_t cnt = 0; - int32_t len = 0; - uint8_t sensitivity_switch; - char tmp_buf[64]; - - NVT_LOG("++\n"); - - /* - * We return 0 to indicate end of file, that we have - * no more information. Otherwise, processes will - * continue to read from us in an endless loop. - */ - if (finished) { - NVT_LOG("read END\n"); - finished = 0; - return 0; - } - finished = 1; - - if (mutex_lock_interruptible(&ts->lock)) { - return -ERESTARTSYS; - } - -#if NVT_TOUCH_ESD_PROTECT - nvt_esd_check_enable(false); -#endif /* #if NVT_TOUCH_ESD_PROTECT */ - - nvt_get_sensitivity_switch(&sensitivity_switch); - - mutex_unlock(&ts->lock); - - cnt = snprintf(tmp_buf, sizeof(tmp_buf), "sensitivity_switch: %d\n", sensitivity_switch); - if (copy_to_user(buf, tmp_buf, sizeof(tmp_buf))) { - NVT_ERR("copy_to_user() error!\n"); - return -EFAULT; - } - buf += cnt; - len += cnt; - - NVT_LOG("--\n"); - return len; -} - -static ssize_t nvt_sensitivity_switch_proc_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) -{ - int32_t ret; - int32_t tmp; - uint8_t sensitivity_switch; - char *tmp_buf; - - NVT_LOG("++\n"); - - if (count == 0 || count > 2) { - NVT_ERR("Invalid value! count = %zu\n", count); - ret = -EINVAL; - goto out; - } - /*2019.12.21 longcheer taocheng add for enable sensitivity_proc start*/ - /*function description*/ - tmp_buf = kzalloc(count, GFP_KERNEL); - if (!tmp_buf) { - NVT_ERR("Allocate tmp_buf fail!\n"); - ret = -ENOMEM; - goto out; - } - if (copy_from_user(tmp_buf, buf, count)) { - NVT_ERR("copy_from_user() error!\n"); - ret = -EFAULT; - goto out; - } - /*2019.12.21 longcheer taocheng add for enable sensitivity_proc end*/ - - ret = sscanf(tmp_buf, "%d", &tmp); - if (ret != 1) { - NVT_ERR("Invalid value! ret = %d\n", ret); - ret = -EINVAL; - goto out; - } - if (tmp < 0 || tmp > 3) { - NVT_ERR("Invalid value! tmp = %d\n", tmp); - ret = -EINVAL; - goto out; - } - sensitivity_switch = (uint8_t)tmp; - NVT_LOG("sensitivity_switch = %d\n", sensitivity_switch); - - if (mutex_lock_interruptible(&ts->lock)) { - return -ERESTARTSYS; - } - -#if NVT_TOUCH_ESD_PROTECT - nvt_esd_check_enable(false); -#endif /* #if NVT_TOUCH_ESD_PROTECT */ - - nvt_set_sensitivity_switch(sensitivity_switch); - - mutex_unlock(&ts->lock); - - ret = count; -out: - //2019.12.21 longcheer taocheng add for enable sensitivity_proc - kfree(tmp_buf); - NVT_LOG("--\n"); - return ret; -} - -static const struct file_operations nvt_sensitivity_switch_fops = { - .owner = THIS_MODULE, - .read = nvt_sensitivity_switch_proc_read, - .write = nvt_sensitivity_switch_proc_write, -}; - -int32_t nvt_set_er_range_switch(uint8_t er_range_switch) -{ - uint8_t buf[8] = {0}; - int32_t ret = 0; - - NVT_LOG("++\n"); - NVT_LOG("set er range switch: %d\n", er_range_switch); - - msleep(35); - - //---set xdata index to EVENT BUF ADDR--- - ret = nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_HOST_CMD); - if (ret < 0) { - NVT_ERR("Set event buffer index fail!\n"); - goto nvt_set_er_range_switch_out; - } - - buf[0] = EVENT_MAP_HOST_CMD; - buf[1] = 0x72; - buf[2] = er_range_switch; - ret = CTP_SPI_WRITE(ts->client, buf, 3); - if (ret < 0) { - NVT_ERR("Write er range switch command fail!\n"); - goto nvt_set_er_range_switch_out; - } - -nvt_set_er_range_switch_out: - NVT_LOG("--\n"); - return ret; -} - -int32_t nvt_get_er_range_switch(uint8_t *er_range_switch) -{ - uint8_t buf[8] = {0}; - int32_t ret = 0; - - NVT_LOG("++\n"); - - msleep(35); - - //---set xdata index to EVENT BUF ADDR--- - ret = nvt_set_page(ts->mmap->EVENT_BUF_ADDR | 0x5D); - if (ret < 0) { - NVT_ERR("Set event buffer index fail!\n"); - goto nvt_get_er_range_switch_out; - } - - buf[0] = 0x5D; - buf[1] = 0x00; - ret = CTP_SPI_READ(ts->client, buf, 2); - if (ret < 0) { - NVT_ERR("Read er range switch status fail!\n"); - goto nvt_get_er_range_switch_out; - } - - *er_range_switch = ((buf[1] >> 4) & 0x03); - NVT_LOG("er_range_switch = %d\n", *er_range_switch); - -nvt_get_er_range_switch_out: - NVT_LOG("--\n"); - return ret; -} - -static ssize_t nvt_er_range_switch_proc_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) -{ - static int finished; - int32_t cnt = 0; - int32_t len = 0; - uint8_t er_range_switch; - char tmp_buf[64]; - - NVT_LOG("++\n"); - - /* - * We return 0 to indicate end of file, that we have - * no more information. Otherwise, processes will - * continue to read from us in an endless loop. - */ - if (finished) { - NVT_LOG("read END\n"); - finished = 0; - return 0; - } - finished = 1; - - if (mutex_lock_interruptible(&ts->lock)) { - return -ERESTARTSYS; - } - -#if NVT_TOUCH_ESD_PROTECT - nvt_esd_check_enable(false); -#endif /* #if NVT_TOUCH_ESD_PROTECT */ - - nvt_get_er_range_switch(&er_range_switch); - - mutex_unlock(&ts->lock); - - cnt = snprintf(tmp_buf, sizeof(tmp_buf), "er_range_switch: %d\n", er_range_switch); - if (copy_to_user(buf, tmp_buf, sizeof(tmp_buf))) { - NVT_ERR("copy_to_user() error!\n"); - return -EFAULT; - } - buf += cnt; - len += cnt; - - NVT_LOG("--\n"); - return len; -} - -static ssize_t nvt_er_range_switch_proc_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) -{ - int32_t ret; - int32_t tmp; - uint8_t er_range_switch; - char *tmp_buf; - - NVT_LOG("++\n"); - - if (count == 0 || count > 2) { - NVT_ERR("Invalid value! count = %zu\n", count); - ret = -EINVAL; - goto out; - } - - /*2019.12.21 longcheer taocheng add for enable er_range_proc start*/ - /*function description*/ - tmp_buf = kzalloc(count, GFP_KERNEL); - if (!tmp_buf) { - NVT_ERR("Allocate tmp_buf fail!\n"); - ret = -ENOMEM; - goto out; - } - if (copy_from_user(tmp_buf, buf, count)) { - NVT_ERR("copy_from_user() error!\n"); - ret = -EFAULT; - goto out; - } - /*2019.12.21 longcheer taocheng add for enable er_range_proc end*/ - ret = sscanf(tmp_buf, "%d", &tmp); - if (ret != 1) { - NVT_ERR("Invalid value! ret = %d\n", ret); - ret = -EINVAL; - goto out; - } - if (tmp < 0 || tmp > 3) { - NVT_ERR("Invalid value! tmp = %d\n", tmp); - ret = -EINVAL; - goto out; - } - er_range_switch = (uint8_t)tmp; - NVT_LOG("er_range_switch = %d\n", er_range_switch); - - if (mutex_lock_interruptible(&ts->lock)) { - return -ERESTARTSYS; - } - -#if NVT_TOUCH_ESD_PROTECT - nvt_esd_check_enable(false); -#endif /* #if NVT_TOUCH_ESD_PROTECT */ - - nvt_set_er_range_switch(er_range_switch); - - mutex_unlock(&ts->lock); - - ret = count; -out: - kfree(tmp_buf); - NVT_LOG("--\n"); - return ret; -} - -static const struct file_operations nvt_er_range_switch_fops = { - .owner = THIS_MODULE, - .read = nvt_er_range_switch_proc_read, - .write = nvt_er_range_switch_proc_write, -}; - -int32_t nvt_set_max_power_switch(uint8_t max_power_switch) -{ - uint8_t buf[8] = {0}; - int32_t ret = 0; - - NVT_LOG("++\n"); - NVT_LOG("set max power switch: %d\n", max_power_switch); - - msleep(35); - - //---set xdata index to EVENT BUF ADDR--- - ret = nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_HOST_CMD); - if (ret < 0) { - NVT_ERR("Set event buffer index fail!\n"); - goto nvt_set_max_power_switch_out; - } - - buf[0] = EVENT_MAP_HOST_CMD; - if (max_power_switch == 1) { - buf[1] = 0x75; - } else if (max_power_switch == 0) { - buf[1] = 0x76; - } else { - NVT_ERR("Invalid max power switch: %d\n", max_power_switch); - ret = -EINVAL; - goto nvt_set_max_power_switch_out; - } - ret = CTP_SPI_WRITE(ts->client, buf, 2); - if (ret < 0) { - NVT_ERR("Write max power switch command fail!\n"); - goto nvt_set_max_power_switch_out; - } - -nvt_set_max_power_switch_out: - NVT_LOG("--\n"); - return ret; -} - -int32_t nvt_get_max_power_switch(uint8_t *max_power_switch) -{ - uint8_t buf[8] = {0}; - int32_t ret = 0; - - NVT_LOG("++\n"); - - msleep(35); - - //---set xdata index to EVENT BUF ADDR--- - ret = nvt_set_page(ts->mmap->EVENT_BUF_ADDR | 0x5D); - if (ret < 0) { - NVT_ERR("Set event buffer index fail!\n"); - goto nvt_get_max_power_switch_out; - } - - buf[0] = 0x5D; - buf[1] = 0x00; - ret = CTP_SPI_READ(ts->client, buf, 2); - if (ret < 0) { - NVT_ERR("Read max power switch status fail!\n"); - goto nvt_get_max_power_switch_out; - } - - *max_power_switch = ((buf[1] >> 7) & 0x01); - NVT_LOG("max_power_switch = %d\n", *max_power_switch); - -nvt_get_max_power_switch_out: - NVT_LOG("--\n"); - return ret; -} - -static ssize_t nvt_max_power_switch_proc_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) -{ - static int finished; - int32_t cnt = 0; - int32_t len = 0; - uint8_t max_power_switch; - - NVT_LOG("++\n"); - - /* - * We return 0 to indicate end of file, that we have - * no more information. Otherwise, processes will - * continue to read from us in an endless loop. - */ - if (finished) { - NVT_LOG("read END\n"); - finished = 0; - return 0; - } - finished = 1; - - if (mutex_lock_interruptible(&ts->lock)) { - return -ERESTARTSYS; - } - -#if NVT_TOUCH_ESD_PROTECT - nvt_esd_check_enable(false); -#endif /* #if NVT_TOUCH_ESD_PROTECT */ - - nvt_get_max_power_switch(&max_power_switch); - - mutex_unlock(&ts->lock); - - cnt = snprintf(buf, PAGE_SIZE - len, "max_power_switch: %d\n", max_power_switch); - buf += cnt; - len += cnt; - - NVT_LOG("--\n"); - return len; -} - -static ssize_t nvt_max_power_switch_proc_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) -{ - int32_t ret; - int32_t tmp; - uint8_t max_power_switch; - - NVT_LOG("++\n"); - - if (count == 0 || count > 2) { - NVT_ERR("Invalid value! count = %zu\n", count); - ret = -EINVAL; - goto out; - } - - ret = sscanf(buf, "%d", &tmp); - if (ret != 1) { - NVT_ERR("Invalid value! ret = %d\n", ret); - ret = -EINVAL; - goto out; - } - if (tmp < 0 || tmp > 1) { - NVT_ERR("Invalid value! tmp = %d\n", tmp); - ret = -EINVAL; - goto out; - } - max_power_switch = (uint8_t)tmp; - NVT_LOG("max_power_switch = %d\n", max_power_switch); - - if (mutex_lock_interruptible(&ts->lock)) { - return -ERESTARTSYS; - } - -#if NVT_TOUCH_ESD_PROTECT - nvt_esd_check_enable(false); -#endif /* #if NVT_TOUCH_ESD_PROTECT */ - - nvt_set_max_power_switch(max_power_switch); - - mutex_unlock(&ts->lock); - - ret = count; -out: - NVT_LOG("--\n"); - return ret; -} - -static const struct file_operations nvt_max_power_switch_fops = { - .owner = THIS_MODULE, - .read = nvt_max_power_switch_proc_read, - .write = nvt_max_power_switch_proc_write, -}; - -int32_t nvt_set_edge_reject_switch(uint8_t edge_reject_switch) -{ - uint8_t buf[8] = {0}; - int32_t ret = 0; - - NVT_LOG("++\n"); - NVT_LOG("set edge reject switch: %d\n", edge_reject_switch); - - msleep(35); - - //---set xdata index to EVENT BUF ADDR--- - ret = nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_HOST_CMD); - if (ret < 0) { - NVT_ERR("Set event buffer index fail!\n"); - goto nvt_set_edge_reject_switch_out; - } - - buf[0] = EVENT_MAP_HOST_CMD; - if (edge_reject_switch == 1) { - // vertical - buf[1] = 0xBA; - } else if (edge_reject_switch == 2) { - // left up - buf[1] = 0xBB; - } else if (edge_reject_switch == 3) { - // righ up - buf[1] = 0xBC; - } else { - NVT_ERR("Invalid value! edge_reject_switch = %d\n", edge_reject_switch); - ret = -EINVAL; - goto nvt_set_edge_reject_switch_out; - } - ret = CTP_SPI_WRITE(ts->client, buf, 2); - if (ret < 0) { - NVT_ERR("Write edge reject switch command fail!\n"); - goto nvt_set_edge_reject_switch_out; - } - -nvt_set_edge_reject_switch_out: - NVT_LOG("--\n"); - return ret; -} - -int32_t nvt_get_edge_reject_switch(uint8_t *edge_reject_switch) -{ - uint8_t buf[8] = {0}; - int32_t ret = 0; - - NVT_LOG("++\n"); - - msleep(35); - - //---set xdata index to EVENT BUF ADDR--- - ret = nvt_set_page(ts->mmap->EVENT_BUF_ADDR | 0x5C); - if (ret < 0) { - NVT_ERR("Set event buffer index fail!\n"); - goto nvt_get_edge_reject_switch_out; - } - - buf[0] = 0x5C; - buf[1] = 0x00; - ret = CTP_SPI_READ(ts->client, buf, 2); - if (ret < 0) { - NVT_ERR("Read edge reject switch status fail!\n"); - goto nvt_get_edge_reject_switch_out; - } - - *edge_reject_switch = ((buf[1] >> 5) & 0x03); - NVT_LOG("edge_reject_switch = %d\n", *edge_reject_switch); - -nvt_get_edge_reject_switch_out: - NVT_LOG("--\n"); - return ret; -} - -static ssize_t nvt_edge_reject_switch_proc_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) -{ - static int finished; - int32_t cnt = 0; - int32_t len = 0; - uint8_t edge_reject_switch; - - NVT_LOG("++\n"); - - /* - * We return 0 to indicate end of file, that we have - * no more information. Otherwise, processes will - * continue to read from us in an endless loop. - */ - if (finished) { - NVT_LOG("read END\n"); - finished = 0; - return 0; - } - finished = 1; - - if (mutex_lock_interruptible(&ts->lock)) { - return -ERESTARTSYS; - } - -#if NVT_TOUCH_ESD_PROTECT - nvt_esd_check_enable(false); -#endif /* #if NVT_TOUCH_ESD_PROTECT */ - - nvt_get_edge_reject_switch(&edge_reject_switch); - - mutex_unlock(&ts->lock); - - cnt = snprintf(buf, PAGE_SIZE - len, "edge_reject_switch: %d\n", edge_reject_switch); - buf += cnt; - len += cnt; - - NVT_LOG("--\n"); - return len; -} - -static ssize_t nvt_edge_reject_switch_proc_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) -{ - int32_t ret; - int32_t tmp; - uint8_t edge_reject_switch; - - NVT_LOG("++\n"); - - if (count == 0 || count > 2) { - NVT_ERR("Invalid value! count = %zu\n", count); - ret = -EINVAL; - goto out; - } - - ret = sscanf(buf, "%d", &tmp); - if (ret != 1) { - NVT_ERR("Invalid value! ret = %d\n", ret); - ret = -EINVAL; - goto out; - } - if (tmp < 1 || tmp > 3) { - NVT_ERR("Invalid value! tmp = %d\n", tmp); - ret = -EINVAL; - goto out; - } - edge_reject_switch = (uint8_t)tmp; - NVT_LOG("edge_reject_switch = %d\n", edge_reject_switch); - - if (mutex_lock_interruptible(&ts->lock)) { - return -ERESTARTSYS; - } - -#if NVT_TOUCH_ESD_PROTECT - nvt_esd_check_enable(false); -#endif /* #if NVT_TOUCH_ESD_PROTECT */ - - nvt_set_edge_reject_switch(edge_reject_switch); - - mutex_unlock(&ts->lock); - - ret = count; -out: - NVT_LOG("--\n"); - return ret; -} - -static const struct file_operations nvt_edge_reject_switch_fops = { - .owner = THIS_MODULE, - .read = nvt_edge_reject_switch_proc_read, - .write = nvt_edge_reject_switch_proc_write, -}; - -int32_t nvt_set_pocket_palm_switch(uint8_t pocket_palm_switch) -{ - uint8_t buf[8] = {0}; - int32_t ret = 0; - - NVT_LOG("++\n"); - NVT_LOG("set pocket palm switch: %d\n", pocket_palm_switch); - - msleep(35); - - //---set xdata index to EVENT BUF ADDR--- - ret = nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_HOST_CMD); - if (ret < 0) { - NVT_ERR("Set event buffer index fail!\n"); - goto nvt_set_pocket_palm_switch_out; - } - - buf[0] = EVENT_MAP_HOST_CMD; - if (pocket_palm_switch == 0) { - // pocket palm disable - buf[1] = 0x74; - } else if (pocket_palm_switch == 1) { - // pocket palm enable - buf[1] = 0x73; - } else { - NVT_ERR("Invalid value! pocket_palm_switch = %d\n", pocket_palm_switch); - ret = -EINVAL; - goto nvt_set_pocket_palm_switch_out; - } - ret = CTP_SPI_WRITE(ts->client, buf, 2); - if (ret < 0) { - NVT_ERR("Write pocket palm switch command fail!\n"); - goto nvt_set_pocket_palm_switch_out; - } - -nvt_set_pocket_palm_switch_out: - NVT_LOG("--\n"); - return ret; -} - -int32_t nvt_get_pocket_palm_switch(uint8_t *pocket_palm_switch) -{ - uint8_t buf[8] = {0}; - int32_t ret = 0; - - NVT_LOG("++\n"); - - msleep(35); - - //---set xdata index to EVENT BUF ADDR--- - ret = nvt_set_page(ts->mmap->EVENT_BUF_ADDR | 0x5D); - if (ret < 0) { - NVT_ERR("Set event buffer index fail!\n"); - goto nvt_get_pocket_palm_switch_out; - } - - buf[0] = 0x5D; - buf[1] = 0x00; - ret = CTP_SPI_READ(ts->client, buf, 2); - if (ret < 0) { - NVT_ERR("Read pocket palm switch status fail!\n"); - goto nvt_get_pocket_palm_switch_out; - } - - *pocket_palm_switch = ((buf[1] >> 6) & 0x01); - NVT_LOG("pocket_palm_switch = %d\n", *pocket_palm_switch); - -nvt_get_pocket_palm_switch_out: - NVT_LOG("--\n"); - return ret; -} - -static ssize_t nvt_pocket_palm_switch_proc_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) -{ - static int finished; - int32_t cnt = 0; - int32_t len = 0; - uint8_t pocket_palm_switch; - char tmp_buf[64]; - - NVT_LOG("++\n"); - - /* - * We return 0 to indicate end of file, that we have - * no more information. Otherwise, processes will - * continue to read from us in an endless loop. - */ - if (finished) { - NVT_LOG("read END\n"); - finished = 0; - return 0; - } - finished = 1; - - if (mutex_lock_interruptible(&ts->lock)) { - return -ERESTARTSYS; - } - -#if NVT_TOUCH_ESD_PROTECT - nvt_esd_check_enable(false); -#endif /* #if NVT_TOUCH_ESD_PROTECT */ - - nvt_get_pocket_palm_switch(&pocket_palm_switch); - - mutex_unlock(&ts->lock); -//2020.01.02 longcheer taocheng edit for enable pocket_proc - cnt = snprintf(tmp_buf, sizeof(tmp_buf), "pocket_palm_switch: %d\n", pocket_palm_switch); - if (copy_to_user(buf, tmp_buf, sizeof(tmp_buf))) { - NVT_LOG("copy_to_user() error!\n"); - return -EFAULT; - } - buf += cnt; - len += cnt; - - NVT_LOG("--\n"); - return len; -} - -static ssize_t nvt_pocket_palm_switch_proc_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) -{ - int32_t ret; - int32_t tmp; - uint8_t pocket_palm_switch; - char *tmp_buf; - - NVT_LOG("++\n"); - - if (count == 0 || count > 2) { - NVT_ERR("Invalid value!, count = %zu\n", count); - ret = -EINVAL; - goto out; - } - /*2020.01.02 longcheer taocheng add for enable pocket_palm_proc start*/ - /*function description*/ - tmp_buf = kzalloc(count, GFP_KERNEL); - if (!tmp_buf) { - NVT_ERR("Allocate tmp_buf fail!\n"); - ret = -ENOMEM; - goto out; - } - if (copy_from_user(tmp_buf, buf, count)) { - NVT_ERR("copy_from_user() error!\n"); - ret = -EFAULT; - goto out; - } - /*2020.01.02 longcheer taocheng add for enable pocket_palm_proc end*/ - - ret = sscanf(tmp_buf, "%d", &tmp); - if (ret != 1) { - NVT_ERR("Invalid value!, ret = %d\n", ret); - ret = -EINVAL; - goto out; - } - if ((tmp < 0) || (tmp > 1)) { - NVT_ERR("Invalid value!, tmp = %d\n", tmp); - ret = -EINVAL; - goto out; - } - pocket_palm_switch = (uint8_t)tmp; - NVT_LOG("pocket_palm_switch = %d\n", pocket_palm_switch); - - if (mutex_lock_interruptible(&ts->lock)) { - return -ERESTARTSYS; - } - -#if NVT_TOUCH_ESD_PROTECT - nvt_esd_check_enable(false); -#endif /* #if NVT_TOUCH_ESD_PROTECT */ - - nvt_set_pocket_palm_switch(pocket_palm_switch); - - mutex_unlock(&ts->lock); - - ret = count; -out: - kfree(tmp_buf); - NVT_LOG("--\n"); - return ret; -} - -static const struct file_operations nvt_pocket_palm_switch_fops = { - .owner = THIS_MODULE, - .read = nvt_pocket_palm_switch_proc_read, - .write = nvt_pocket_palm_switch_proc_write, -}; - -int32_t nvt_set_charger_switch(uint8_t charger_switch) -{ - uint8_t buf[8] = {0}; - int32_t ret = 0; - - NVT_LOG("++\n"); - NVT_LOG("set charger switch: %d\n", charger_switch); - - msleep(35); - - //---set xdata index to EVENT BUF ADDR--- - ret = nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_HOST_CMD); - if (ret < 0) { - NVT_ERR("Set event buffer index fail!\n"); - goto nvt_set_charger_switch_out; - } - - buf[0] = EVENT_MAP_HOST_CMD; - if (charger_switch == 0) { - // charger off - buf[1] = 0x51; - } else if (charger_switch == 1) { - // charger on - buf[1] = 0x53; - } else { - NVT_ERR("Invalid value! charger_switch = %d\n", charger_switch); - ret = -EINVAL; - goto nvt_set_charger_switch_out; - } - ret = CTP_SPI_WRITE(ts->client, buf, 2); - if (ret < 0) { - NVT_ERR("Write charger switch command fail!\n"); - goto nvt_set_charger_switch_out; - } - -nvt_set_charger_switch_out: - NVT_LOG("--\n"); - return ret; -} - -int32_t nvt_get_charger_switch(uint8_t *charger_switch) -{ - uint8_t buf[8] = {0}; - int32_t ret = 0; - - NVT_LOG("++\n"); - - msleep(35); - - //---set xdata index to EVENT BUF ADDR--- - ret = nvt_set_page(ts->mmap->EVENT_BUF_ADDR | 0x5D); - if (ret < 0) { - NVT_ERR("Set event buffer index fail!\n"); - goto nvt_get_charger_switch_out; - } - - buf[0] = 0x5C; - buf[1] = 0x00; - ret = CTP_SPI_READ(ts->client, buf, 2); - if (ret < 0) { - NVT_ERR("Read charger switch status fail!\n"); - goto nvt_get_charger_switch_out; - } - - *charger_switch = ((buf[1] >> 2) & 0x01); - NVT_LOG("charger_switch = %d\n", *charger_switch); - -nvt_get_charger_switch_out: - NVT_LOG("--\n"); - return ret; -} - -static ssize_t nvt_charger_switch_proc_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) -{ - static int finished; - int32_t cnt = 0; - int32_t len = 0; - uint8_t charger_switch; - char tmp_buf[64]; - - NVT_LOG("++\n"); - - /* - * We return 0 to indicate end of file, that we have - * no more information. Otherwise, processes will - * continue to read from us in an endless loop. - */ - if (finished) { - NVT_LOG("read END\n"); - finished = 0; - return 0; - } - finished = 1; - - if (mutex_lock_interruptible(&ts->lock)) { - return -ERESTARTSYS; - } - -#if NVT_TOUCH_ESD_PROTECT - nvt_esd_check_enable(false); -#endif /* #if NVT_TOUCH_ESD_PROTECT */ - - nvt_get_charger_switch(&charger_switch); - - mutex_unlock(&ts->lock); - - cnt = snprintf(tmp_buf, sizeof(tmp_buf), "charger_switch: %d\n", charger_switch); - if (copy_to_user(buf, tmp_buf, sizeof(tmp_buf))) { - NVT_ERR("copy_to_user() error!\n"); - return -EFAULT; - } - buf += cnt; - len += cnt; - - NVT_LOG("--\n"); - return len; -} - -static ssize_t nvt_charger_switch_proc_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) -{ - int32_t ret; - int32_t tmp; - uint8_t charger_switch; - char *tmp_buf; - - NVT_LOG("++\n"); - - if (count == 0 || count > 2) { - NVT_ERR("Invalid value!, count = %zu\n", count); - ret = -EINVAL; - goto out; - } - - tmp_buf = kzalloc(count, GFP_KERNEL); - if (!tmp_buf) { - NVT_ERR("Allocate tmp_buf fail!\n"); - ret = -ENOMEM; - goto out; - } - if (copy_from_user(tmp_buf, buf, count)) { - NVT_ERR("copy_from_user() error!\n"); - ret = -EFAULT; - goto out; - } - ret = sscanf(tmp_buf, "%d", &tmp); - if (ret != 1) { - NVT_ERR("Invalid value!, ret = %d\n", ret); - ret = -EINVAL; - goto out; - } - if ((tmp < 0) || (tmp > 1)) { - NVT_ERR("Invalid value!, tmp = %d\n", tmp); - ret = -EINVAL; - goto out; - } - charger_switch = (uint8_t)tmp; - NVT_LOG("charger_switch = %d\n", charger_switch); - - if (mutex_lock_interruptible(&ts->lock)) { - return -ERESTARTSYS; - } - -#if NVT_TOUCH_ESD_PROTECT - nvt_esd_check_enable(false); -#endif /* #if NVT_TOUCH_ESD_PROTECT */ - - nvt_set_charger_switch(charger_switch); - - mutex_unlock(&ts->lock); - - ret = count; -out: - kfree(tmp_buf); - NVT_LOG("--\n"); - return ret; -} - -static const struct file_operations nvt_charger_switch_fops = { - .owner = THIS_MODULE, - .read = nvt_charger_switch_proc_read, - .write = nvt_charger_switch_proc_write, -}; - -static ssize_t nvt_lyb_apply_proc_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) -{ - int32_t ret; - NVT_LOG("applying lyb changes\n"); - - ret = 0; - lyb_apply_changes(); - return ret; -} - -static ssize_t nvt_lyb_apply_proc_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) -{ - int32_t ret; - NVT_LOG("applying lyb changes\n"); - - ret = 0; - lyb_apply_changes(); - return ret; -} - -static const struct file_operations nvt_lyb_apply_fops = { - .owner = THIS_MODULE, - .read = nvt_lyb_apply_proc_read, - .write = nvt_lyb_apply_proc_write, -}; - -/*2019.12.10 longcheer taocheng add for charger mode & other nodes end*/ - /******************************************************* Description: Novatek touchscreen extra function proc. file node @@ -2154,89 +632,8 @@ int32_t nvt_extra_proc_init(void) NVT_LOG("create proc/%s Succeeded!\n", NVT_DIFF); } - NVT_proc_xiaomi_config_info_entry = proc_create(NVT_XIAOMI_CONFIG_INFO, 0444, NULL, &nvt_xiaomi_config_info_fops); - if (NVT_proc_xiaomi_config_info_entry == NULL) { - NVT_ERR("create proc/%s Failed!\n", NVT_XIAOMI_CONFIG_INFO); - return -ENOMEM; - } else { - NVT_LOG("create proc/%s Succeeded!\n", NVT_XIAOMI_CONFIG_INFO); - } -/*2019.12.10 longcheer taocheng add for creating nodes begin*/ -/*function description*/ - NVT_proc_pf_switch_entry = proc_create(NVT_PF_SWITCH, 0666, NULL, &nvt_pf_switch_fops); - if (NVT_proc_pf_switch_entry == NULL) { - NVT_ERR("create proc/%s Failed!\n", NVT_PF_SWITCH); - return -ENOMEM; - } else { - NVT_LOG("create proc/%s Succeeded!\n", NVT_PF_SWITCH); - } - - NVT_proc_sensitivity_switch_entry = proc_create(NVT_SENSITIVITY_SWITCH, 0666, NULL, &nvt_sensitivity_switch_fops); - if (NVT_proc_sensitivity_switch_entry == NULL) { - NVT_ERR("create proc/%s Failed!\n", NVT_SENSITIVITY_SWITCH); - return -ENOMEM; - } else { - NVT_LOG("create proc/%s Succeeded!\n", NVT_SENSITIVITY_SWITCH); - } - - NVT_proc_er_range_switch_entry = proc_create(NVT_ER_RANGE_SWITCH, 0666, NULL, &nvt_er_range_switch_fops); - if (NVT_proc_er_range_switch_entry == NULL) { - NVT_ERR("create proc/%s Failed!\n", NVT_ER_RANGE_SWITCH); - return -ENOMEM; - } else { - NVT_LOG("create proc/%s Succeeded!\n", NVT_ER_RANGE_SWITCH); - } - - NVT_proc_max_power_switch_entry = proc_create(NVT_MAX_POWER_SWITCH, 0666, NULL, &nvt_max_power_switch_fops); - if (NVT_proc_max_power_switch_entry == NULL) { - NVT_ERR("create proc/%s Failed!\n", NVT_MAX_POWER_SWITCH); - return -ENOMEM; - } else { - NVT_LOG("create proc/%s Succeeded!\n", NVT_MAX_POWER_SWITCH); - } - - NVT_proc_edge_reject_switch_entry = proc_create(NVT_EDGE_REJECT_SWITCH, 0666, NULL, &nvt_edge_reject_switch_fops); - if (NVT_proc_edge_reject_switch_entry == NULL) { - NVT_ERR("create proc/%s Failed!\n", NVT_EDGE_REJECT_SWITCH); - return -ENOMEM; - } else { - NVT_LOG("create proc/%s Succeeded!\n", NVT_EDGE_REJECT_SWITCH); - } - - NVT_proc_pocket_palm_switch_entry = proc_create(NVT_POCKET_PALM_SWITCH, 0666, NULL, &nvt_pocket_palm_switch_fops); - if (NVT_proc_pocket_palm_switch_entry == NULL) { - NVT_ERR("create proc/nvt_pocket_palm_switch Failed!\n"); - return -ENOMEM; - } else { - NVT_LOG("create proc/nvt_pocket_palm_switch Succeeded!\n"); - } - - NVT_proc_charger_switch_entry = proc_create(NVT_CHARGER_SWITCH, 0666, NULL, &nvt_charger_switch_fops); - if (NVT_proc_charger_switch_entry == NULL) { - NVT_ERR("create proc/nvt_charger_switch Failed!\n"); - return -ENOMEM; - } else { - NVT_LOG("create proc/nvt_charger_switch Succeeded!\n"); - } - - NVT_proc_lyb_apply_changes = proc_create(NVT_LYB_APPLY_CHANGES, 0666, NULL, &nvt_lyb_apply_fops); - if (NVT_proc_lyb_apply_changes == NULL) { - NVT_ERR("create proc/nvt_lyb_apply_changes Failed!\n"); - return -ENOMEM; - } else { - NVT_LOG("create proc/nvt_lyb_apply_changes Succeeded!\n"); - } - - LCT_proc_tp_data_dump_entry = proc_create(LCT_TP_DATA_DUMP, 0444, NULL, &lct_tp_data_dump_fops); - if (LCT_proc_tp_data_dump_entry == NULL) { - NVT_ERR("create proc/%s Failed!\n", LCT_TP_DATA_DUMP); - return -ENOMEM; - } else { - NVT_LOG("create proc/%s Succeeded!\n", LCT_TP_DATA_DUMP); - } return 0; } -/*2019.12.10 longcheer taocheng add for creating nodes end*/ /******************************************************* Description: @@ -2271,67 +668,5 @@ void nvt_extra_proc_deinit(void) NVT_proc_diff_entry = NULL; NVT_LOG("Removed /proc/%s\n", NVT_DIFF); } - - if (NVT_proc_xiaomi_config_info_entry != NULL) { - remove_proc_entry(NVT_XIAOMI_CONFIG_INFO, NULL); - NVT_proc_xiaomi_config_info_entry = NULL; - NVT_LOG("Removed /proc/%s\n", NVT_XIAOMI_CONFIG_INFO); - } -/*2019.12.10 longcheer taocheng add for charger extra proc begin*/ -/*function description*/ - if (NVT_proc_pf_switch_entry != NULL) { - remove_proc_entry(NVT_PF_SWITCH, NULL); - NVT_proc_pf_switch_entry = NULL; - NVT_LOG("Removed /proc/%s\n", NVT_PF_SWITCH); - } - - if (NVT_proc_sensitivity_switch_entry != NULL) { - remove_proc_entry(NVT_SENSITIVITY_SWITCH, NULL); - NVT_proc_sensitivity_switch_entry = NULL; - NVT_LOG("Removed /proc/%s\n", NVT_SENSITIVITY_SWITCH); - } - - if (NVT_proc_er_range_switch_entry != NULL) { - remove_proc_entry(NVT_ER_RANGE_SWITCH, NULL); - NVT_proc_er_range_switch_entry = NULL; - NVT_LOG("Removed /proc/%s\n", NVT_ER_RANGE_SWITCH); - } - - if (NVT_proc_max_power_switch_entry != NULL) { - remove_proc_entry(NVT_MAX_POWER_SWITCH, NULL); - NVT_proc_max_power_switch_entry = NULL; - NVT_LOG("Removed /proc/%s\n", NVT_MAX_POWER_SWITCH); - } - - if (NVT_proc_edge_reject_switch_entry != NULL) { - remove_proc_entry(NVT_EDGE_REJECT_SWITCH, NULL); - NVT_proc_edge_reject_switch_entry = NULL; - NVT_LOG("Removed /proc/%s\n", NVT_EDGE_REJECT_SWITCH); - } - - if (NVT_proc_pocket_palm_switch_entry != NULL) { - remove_proc_entry(NVT_POCKET_PALM_SWITCH, NULL); - NVT_proc_pocket_palm_switch_entry = NULL; - NVT_LOG("Removed /proc/%s\n", NVT_POCKET_PALM_SWITCH); - } - - if (NVT_proc_charger_switch_entry != NULL) { - remove_proc_entry(NVT_CHARGER_SWITCH, NULL); - NVT_proc_charger_switch_entry = NULL; - NVT_LOG("Removed /proc/%s\n", NVT_CHARGER_SWITCH); - } - - if (NVT_proc_lyb_apply_changes != NULL) { - remove_proc_entry(NVT_LYB_APPLY_CHANGES, NULL); - NVT_proc_lyb_apply_changes = NULL; - NVT_LOG("Removed /proc/%s\n", NVT_LYB_APPLY_CHANGES); - } - -/*2019.12.10 longcheer taocheng add for charger extra proc end*/ - if (LCT_proc_tp_data_dump_entry != NULL) { - remove_proc_entry(LCT_TP_DATA_DUMP, NULL); - LCT_proc_tp_data_dump_entry = NULL; - NVT_LOG("Removed /proc/%s\n", LCT_TP_DATA_DUMP); - } } #endif diff --git a/drivers/input/touchscreen/nt36xxx_spi/nt36xxx_fw_update.c b/drivers/input/touchscreen/nt36xxx_spi/nt36xxx_fw_update.c index 1c7beddc6411..6d2974d1fcd9 100755 --- a/drivers/input/touchscreen/nt36xxx_spi/nt36xxx_fw_update.c +++ b/drivers/input/touchscreen/nt36xxx_spi/nt36xxx_fw_update.c @@ -34,11 +34,6 @@ #define NVT_DUMP_PARTITION_LEN (1024) #define NVT_DUMP_PARTITION_PATH "/data/local/tmp" -//2019.12.06 longcheer taocheng add for charger mode -#if NVT_USB_PLUGIN -extern touchscreen_usb_plugin_data_t g_touchscreen_usb_pulgin; -#endif - static struct timeval start, end; const struct firmware *fw_entry; static size_t fw_need_write_size; @@ -1166,12 +1161,5 @@ void Boot_Update_Firmware(struct work_struct *work) mutex_lock(&ts->lock); nvt_update_firmware(ts->boot_update_firmware_name); mutex_unlock(&ts->lock); -//2019.12.06 longcheer taocheng add for charger mode -#if NVT_USB_PLUGIN - if (!IS_ERR_OR_NULL(g_touchscreen_usb_pulgin.event_callback)) - g_touchscreen_usb_pulgin.valid = true; - if (g_touchscreen_usb_pulgin.valid && g_touchscreen_usb_pulgin.usb_plugged_in) - g_touchscreen_usb_pulgin.event_callback(); -#endif } #endif /* BOOT_UPDATE_FIRMWARE */ diff --git a/drivers/input/touchscreen/xiaomi/Kconfig b/drivers/input/touchscreen/xiaomi/Kconfig deleted file mode 100644 index bab7644f364e..000000000000 --- a/drivers/input/touchscreen/xiaomi/Kconfig +++ /dev/null @@ -1,9 +0,0 @@ -config TOUCHSCREEN_XIAOMI_TOUCHFEATURE - tristate "Xiaomi Touch Feature" - depends on INPUT_TOUCHSCREEN - help - Say Y here if you enable xiaomi touch feature. - - If unsure, say N. - - To compile this driver as a module, choose M here: diff --git a/drivers/input/touchscreen/xiaomi/Makefile b/drivers/input/touchscreen/xiaomi/Makefile deleted file mode 100644 index 9ed31b6c4a73..000000000000 --- a/drivers/input/touchscreen/xiaomi/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-$(CONFIG_TOUCHSCREEN_XIAOMI_TOUCHFEATURE) += xiaomi_touch.o diff --git a/drivers/input/touchscreen/xiaomi/xiaomi_touch.c b/drivers/input/touchscreen/xiaomi/xiaomi_touch.c deleted file mode 100644 index 3a124a451d14..000000000000 --- a/drivers/input/touchscreen/xiaomi/xiaomi_touch.c +++ /dev/null @@ -1,372 +0,0 @@ -#include "xiaomi_touch.h" - -static struct xiaomi_touch_pdata *touch_pdata; - -static int xiaomi_touch_dev_open(struct inode *inode, struct file *file) -{ - struct xiaomi_touch *dev = NULL; - int i = MINOR(inode->i_rdev); - struct xiaomi_touch_pdata *touch_pdata; - - pr_info("%s\n", __func__); - dev = xiaomi_touch_dev_get(i); - if (!dev) { - pr_err("%s cant get dev\n", __func__); - return -ENOMEM; - } - touch_pdata = dev_get_drvdata(dev->dev); - - file->private_data = touch_pdata; - return 0; -} - -static ssize_t xiaomi_touch_dev_read(struct file *file, char __user *buf, - size_t count, loff_t *pos) -{ - return 0; -} - -static ssize_t xiaomi_touch_dev_write(struct file *file, - const char __user *buf, size_t count, loff_t *pos) -{ - return 0; -} - -static unsigned int xiaomi_touch_dev_poll(struct file *file, - poll_table *wait) -{ - return 0; -} - -static long xiaomi_touch_dev_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - int ret = -EINVAL; - int buf[VALUE_TYPE_SIZE] = {0,}; - struct xiaomi_touch_pdata *pdata = file->private_data; - void __user *argp = (void __user *) arg; - struct xiaomi_touch_interface *touch_data = pdata->touch_data; - struct xiaomi_touch *dev = pdata->device; - int user_cmd = _IOC_NR(cmd); - - if (!pdata || !touch_data || !dev) { - pr_err("%s invalid memory\n", __func__); - return -ENOMEM; - } - - mutex_lock(&dev->mutex); - ret = copy_from_user(&buf, (int __user *)argp, sizeof(buf)); - - pr_info("%s cmd:%d, mode:%d, value:%d\n", __func__, user_cmd, buf[0], buf[1]); - - switch (user_cmd) { - case SET_CUR_VALUE: - if (touch_data->setModeValue) - buf[0] = touch_data->setModeValue(buf[0], buf[1]); - break; - case GET_CUR_VALUE: - case GET_DEF_VALUE: - case GET_MIN_VALUE: - case GET_MAX_VALUE: - if (touch_data->getModeValue) - buf[0] = touch_data->getModeValue(buf[0], user_cmd); - break; - case RESET_MODE: - if (touch_data->resetMode) - buf[0] = touch_data->resetMode(buf[0]); - break; - case GET_MODE_VALUE: - if (touch_data->getModeValue) - ret = touch_data->getModeAll(buf[0], buf); - break; - default: - pr_err("%s don't support mode\n", __func__); - ret = -EINVAL; - break; - } - - if (ret >= 0) - ret = copy_to_user((int __user *)argp, &buf, sizeof(buf)); - else - pr_err("%s can't get data from touch driver\n", __func__); - - mutex_unlock(&dev->mutex); - - return ret; -} - -static int xiaomi_touch_dev_release(struct inode *inode, struct file *file) -{ - return 0; -} - -static const struct file_operations xiaomitouch_dev_fops = { - .owner = THIS_MODULE, - .open = xiaomi_touch_dev_open, - .read = xiaomi_touch_dev_read, - .write = xiaomi_touch_dev_write, - .poll = xiaomi_touch_dev_poll, - .unlocked_ioctl = xiaomi_touch_dev_ioctl, - .compat_ioctl = xiaomi_touch_dev_ioctl, - .release = xiaomi_touch_dev_release, - .llseek = no_llseek, -}; - -static struct xiaomi_touch xiaomi_touch_dev = { - .misc_dev = { - .minor = MISC_DYNAMIC_MINOR, - .name = "xiaomi-touch", - .fops = &xiaomitouch_dev_fops, - .parent = NULL, - }, - .mutex = __MUTEX_INITIALIZER(xiaomi_touch_dev.mutex), - .palm_mutex = __MUTEX_INITIALIZER(xiaomi_touch_dev.palm_mutex), - .psensor_mutex = __MUTEX_INITIALIZER(xiaomi_touch_dev.psensor_mutex), - .wait_queue = __WAIT_QUEUE_HEAD_INITIALIZER(xiaomi_touch_dev.wait_queue), -}; - -struct xiaomi_touch *xiaomi_touch_dev_get(int minor) -{ - if (xiaomi_touch_dev.misc_dev.minor == minor) - return &xiaomi_touch_dev; - else - return NULL; -} - -struct class *get_xiaomi_touch_class(void) -{ - return xiaomi_touch_dev.class; -} - -struct device *get_xiaomi_touch_dev(void) -{ - return xiaomi_touch_dev.dev; -} - -int xiaomitouch_register_modedata(struct xiaomi_touch_interface *data) -{ - int ret = 0; - struct xiaomi_touch_interface *touch_data = NULL; - - if (!touch_pdata) - ret = -ENOMEM; - - touch_data = touch_pdata->touch_data; - pr_info("%s\n", __func__); - - mutex_lock(&xiaomi_touch_dev.mutex); - - touch_data->setModeValue = data->setModeValue; - touch_data->getModeValue = data->getModeValue; - touch_data->resetMode = data->resetMode; - touch_data->getModeAll = data->getModeAll; - touch_data->palm_sensor_read = data->palm_sensor_read; - touch_data->palm_sensor_write = data->palm_sensor_write; - //touch_data->p_sensor_read = data->p_sensor_read; - //touch_data->p_sensor_write = data->p_sensor_write; - //touch_data->panel_vendor_read = data->panel_vendor_read; - //touch_data->panel_color_read = data->panel_color_read; - //touch_data->panel_display_read = data->panel_display_read; - //touch_data->touch_vendor_read = data->touch_vendor_read; - - mutex_unlock(&xiaomi_touch_dev.mutex); - - return ret; -} - -int update_palm_sensor_value(int value) -{ - struct xiaomi_touch *dev = NULL; - - mutex_lock(&xiaomi_touch_dev.palm_mutex); - - if (!touch_pdata) { - mutex_unlock(&xiaomi_touch_dev.palm_mutex); - return -ENODEV; - } - - dev = touch_pdata->device; - - if (value != touch_pdata->palm_value) { - pr_info("%s value:%d\n", __func__, value); - touch_pdata->palm_value = value; - touch_pdata->palm_changed = true; - sysfs_notify(&xiaomi_touch_dev.dev->kobj, NULL, - "palm_sensor"); - } - - mutex_unlock(&xiaomi_touch_dev.palm_mutex); - return 0; -} - -static ssize_t palm_sensor_show(struct device *dev, -struct device_attribute *attr, char *buf) -{ - struct xiaomi_touch_pdata *pdata = dev_get_drvdata(dev); - - pdata->palm_changed = false; - - return snprintf(buf, PAGE_SIZE, "%d\n", pdata->palm_value); -} - -static ssize_t palm_sensor_store(struct device *dev, -struct device_attribute *attr, const char *buf, size_t count) -{ - unsigned int input; - struct xiaomi_touch_pdata *pdata = dev_get_drvdata(dev); - - if (sscanf(buf, "%d", &input) < 0) - return -EINVAL; - - if (pdata->touch_data->palm_sensor_write) - pdata->touch_data->palm_sensor_write(!!input); - else { - pr_err("%s has not implement\n", __func__); - } - pr_info("%s value:%d\n", __func__, !!input); - - return count; -} - - -static DEVICE_ATTR(palm_sensor, (0664), - palm_sensor_show, palm_sensor_store); - - -static struct attribute *touch_attr_group[] = { - &dev_attr_palm_sensor.attr, - - NULL, -}; - -static const struct of_device_id xiaomi_touch_of_match[] = { - { .compatible = "xiaomi-touch", }, - { }, -}; - -static int xiaomi_touch_parse_dt(struct device *dev, struct xiaomi_touch_pdata *data) -{ - int ret; - struct device_node *np; - - np = dev->of_node; - if (!np) - return -ENODEV; - - ret = of_property_read_string(np, "touch,name", &data->name); - if (ret) - return ret; - - pr_info("%s touch,name:%s\n", __func__, data->name); - - return 0; -} - -static int xiaomi_touch_probe(struct platform_device *pdev) -{ - int ret = 0; - struct device *dev = &pdev->dev; - struct xiaomi_touch_pdata *pdata; - - pdata = devm_kzalloc(dev, sizeof(struct xiaomi_touch_pdata), GFP_KERNEL); - if (!pdata) - return -ENOMEM; - - pr_info("%s enter\n", __func__); - - ret = xiaomi_touch_parse_dt(dev, pdata); - if (ret < 0) { - pr_err("%s parse dt error:%d\n", __func__, ret); - goto parse_dt_err; - } - - ret = misc_register(&xiaomi_touch_dev.misc_dev); - if (ret) { - pr_err("%s create misc device err:%d\n", __func__, ret); - goto parse_dt_err; - } - - if (!xiaomi_touch_dev.class) - xiaomi_touch_dev.class = class_create(THIS_MODULE, "touch"); - - if (!xiaomi_touch_dev.class) { - pr_err("%s create device class err\n", __func__); - goto class_create_err; - } - - xiaomi_touch_dev.dev = device_create(xiaomi_touch_dev.class, NULL, 'T', NULL, "touch_dev"); - if (!xiaomi_touch_dev.dev) { - pr_err("%s create device dev err\n", __func__); - goto device_create_err; - } - - pdata->touch_data = (struct xiaomi_touch_interface *)kzalloc(sizeof(struct xiaomi_touch_interface), GFP_KERNEL); - if (pdata->touch_data == NULL) { - ret = -ENOMEM; - pr_err("%s alloc mem for touch_data\n", __func__); - goto data_mem_err; - } - - pdata->device = &xiaomi_touch_dev; - dev_set_drvdata(xiaomi_touch_dev.dev, pdata); - - touch_pdata = pdata; - - xiaomi_touch_dev.attrs.attrs = touch_attr_group; - ret = sysfs_create_group(&xiaomi_touch_dev.dev->kobj, &xiaomi_touch_dev.attrs); - if (ret) { - pr_err("%s ERROR: Cannot create sysfs structure!:%d\n", __func__, ret); - ret = -ENODEV; - goto sys_group_err; - } - - pr_info("%s over\n", __func__); - - return ret; - -sys_group_err: - kfree(pdata->touch_data); - pdata->touch_data = NULL; -data_mem_err: - device_destroy(xiaomi_touch_dev.class, 0); -device_create_err: - class_destroy(xiaomi_touch_dev.class); -class_create_err: - misc_deregister(&xiaomi_touch_dev.misc_dev); -parse_dt_err: - pr_err("%s fail!\n", __func__); - return ret; -} - -static int xiaomi_touch_remove(struct platform_device *pdev) -{ - device_destroy(xiaomi_touch_dev.class, 0); - class_destroy(xiaomi_touch_dev.class); - misc_deregister(&xiaomi_touch_dev.misc_dev); - kfree(touch_pdata->touch_data); - touch_pdata->touch_data = NULL; - return 0; -} - -static struct platform_driver xiaomi_touch_device_driver = { - .probe = xiaomi_touch_probe, - .remove = xiaomi_touch_remove, - .driver = { - .name = "xiaomi-touch", - .of_match_table = of_match_ptr(xiaomi_touch_of_match), - } -}; - -static int __init xiaomi_touch_init(void) -{ - return platform_driver_register(&xiaomi_touch_device_driver); - -} - -static void __exit xiaomi_touch_exit(void) -{ - platform_driver_unregister(&xiaomi_touch_device_driver); -} - -subsys_initcall(xiaomi_touch_init); -module_exit(xiaomi_touch_exit); diff --git a/drivers/input/touchscreen/xiaomi/xiaomi_touch.h b/drivers/input/touchscreen/xiaomi/xiaomi_touch.h deleted file mode 100644 index 1dce280d772e..000000000000 --- a/drivers/input/touchscreen/xiaomi/xiaomi_touch.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef __XIAOMI__TOUCH_H -#define __XIAOMI__TOUCH_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -/*CUR,DEFAULT,MIN,MAX*/ -#define VALUE_TYPE_SIZE 6 -#define VALUE_GRIP_SIZE 9 -enum MODE_CMD { - SET_CUR_VALUE = 0, - GET_CUR_VALUE, - GET_DEF_VALUE, - GET_MIN_VALUE, - GET_MAX_VALUE, - GET_MODE_VALUE, - RESET_MODE, -}; - -enum MODE_TYPE { - Touch_Game_Mode = 0, - Touch_Active_MODE = 1, - Touch_UP_THRESHOLD = 2, - Touch_Tolerance = 3, - Touch_Wgh_Min = 4, - Touch_Wgh_Max = 5, - Touch_Wgh_Step = 6, - Touch_Edge_Filter = 7, - Touch_Panel_Orientation = 8, - Touch_Report_Rate = 9, - Touch_Fod_Enable = 10, - Touch_Aod_Enable = 11, - Touch_Resist_RF = 12, - Touch_Idle_Time = 13, - Touch_Doubletap_Mode = 14, - Touch_Mode_NUM = 15, -}; - -struct xiaomi_touch_interface { - int touch_mode[Touch_Mode_NUM][VALUE_TYPE_SIZE]; - int (*setModeValue)(int Mode, int value); - int (*getModeValue)(int Mode, int value_type); - int (*getModeAll)(int Mode, int *modevalue); - int (*resetMode)(int Mode); - int (*palm_sensor_read)(void); - int (*palm_sensor_write)(int on); - -}; - -struct xiaomi_touch { - struct miscdevice misc_dev; - struct device *dev; - struct class *class; - struct attribute_group attrs; - struct mutex mutex; - struct mutex palm_mutex; - struct mutex psensor_mutex; - wait_queue_head_t wait_queue; -}; - -struct xiaomi_touch_pdata{ - struct xiaomi_touch *device; - struct xiaomi_touch_interface *touch_data; - int palm_value; - bool palm_changed; - const char *name; -}; - -struct xiaomi_touch *xiaomi_touch_dev_get(int minor); - -extern struct class *get_xiaomi_touch_class(void); - -extern struct device *get_xiaomi_touch_dev(void); - -extern int update_palm_sensor_value(int value); - -int xiaomitouch_register_modedata(struct xiaomi_touch_interface *data); - -#endif diff --git a/drivers/power/supply/qcom/smb5-lib.c b/drivers/power/supply/qcom/smb5-lib.c index 2a67cdb09429..ae1474e01b8c 100644 --- a/drivers/power/supply/qcom/smb5-lib.c +++ b/drivers/power/supply/qcom/smb5-lib.c @@ -35,17 +35,6 @@ #include #endif -#if CONFIG_TOUCHSCREEN_COMMON -typedef struct touchscreen_usb_piugin_data{ - bool valid; - bool usb_plugged_in; - void (*event_callback)(void); -} touchscreen_usb_piugin_data_t; - -touchscreen_usb_piugin_data_t g_touchscreen_usb_pulgin = {0}; -EXPORT_SYMBOL(g_touchscreen_usb_pulgin); -#endif - #define smblib_err(chg, fmt, ...) \ pr_err("%s: %s: " fmt, chg->name, \ __func__, ##__VA_ARGS__) \ @@ -6422,15 +6411,6 @@ void smblib_usb_plugin_locked(struct smb_charger *chg) dual_role_instance_changed(chg->dual_role); smblib_dbg(chg, PR_INTERRUPT, "IRQ: usbin-plugin %s\n", vbus_rising ? "attached" : "detached"); - -#if CONFIG_TOUCHSCREEN_COMMON - g_touchscreen_usb_pulgin.usb_plugged_in = vbus_rising; - if (g_touchscreen_usb_pulgin.valid){ - g_touchscreen_usb_pulgin.event_callback(); - } - -#endif - } irqreturn_t usb_plugin_irq_handler(int irq, void *data) diff --git a/include/linux/msm_drm_notify.h b/include/linux/msm_drm_notify.h index 4cb7fed0d865..924ba852c99c 100644 --- a/include/linux/msm_drm_notify.h +++ b/include/linux/msm_drm_notify.h @@ -40,11 +40,6 @@ struct msm_drm_notifier { void *data; }; -struct drm_notify_data { - bool is_primary; - void *data; -}; - int msm_drm_register_client(struct notifier_block *nb); int msm_drm_unregister_client(struct notifier_block *nb); #endif