msm-4.14: Cleanup xiaomi touchscreen drivers

Change-Id: I33607bdaef6bfe3ff388f23b0fbc16542241fa12
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
This commit is contained in:
Richard Raya 2024-07-03 02:08:54 -03:00
parent 737de0614d
commit 9869485b79
29 changed files with 6 additions and 4754 deletions

View File

@ -2,14 +2,6 @@
* TouchScreen Device Tree For Xiaomi J20 * TouchScreen Device Tree For Xiaomi J20
*/ */
&soc {
xiaomi_touch {
status = "ok";
compatible = "xiaomi-touch";
touch,name = "xiaomi-touch";
};
};
&qupv3_se0_spi { &qupv3_se0_spi {
status = "ok"; status = "ok";

View File

@ -2032,7 +2032,6 @@ CONFIG_TOUCHSCREEN_PROPERTIES=y
# CONFIG_TOUCHSCREEN_RAYDIUM_CHIPSET is not set # CONFIG_TOUCHSCREEN_RAYDIUM_CHIPSET is not set
CONFIG_TOUCHSCREEN_COMMON=y CONFIG_TOUCHSCREEN_COMMON=y
CONFIG_TOUCHSCREEN_NT36xxx_HOSTDL_SPI=y CONFIG_TOUCHSCREEN_NT36xxx_HOSTDL_SPI=y
CONFIG_TOUCHSCREEN_XIAOMI_TOUCHFEATURE=y
# CONFIG_TOUCHSCREEN_FTS is not set # CONFIG_TOUCHSCREEN_FTS is not set
CONFIG_INPUT_MISC=y CONFIG_INPUT_MISC=y
# CONFIG_INPUT_AD714X is not set # CONFIG_INPUT_AD714X is not set

View File

@ -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 * dsi_display_bind - bind dsi device with controlling device
* @dev: Pointer to base of platform device * @dev: Pointer to base of platform device
@ -5554,7 +5408,6 @@ static int dsi_display_bind(struct device *dev,
/* register te irq handler */ /* register te irq handler */
dsi_display_register_te_irq(display); dsi_display_register_te_irq(display);
set_lct_tp_lockdown_info_callback(lct_tp_lockdown_info_callback);
goto error; goto error;

View File

@ -284,11 +284,6 @@ struct dsi_display {
u32 te_source; 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_probe(struct platform_device *pdev);
int dsi_display_dev_remove(struct platform_device *pdev); int dsi_display_dev_remove(struct platform_device *pdev);

View File

@ -388,27 +388,10 @@ static void dsi_bridge_post_disable(struct drm_bridge *bridge)
atomic_set(&prim_panel_is_on, false); 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) static void prim_panel_off_delayed_work(struct work_struct *work)
{ {
mutex_lock(&gbridge->base.lock); mutex_lock(&gbridge->base.lock);
if (atomic_read(&prim_panel_is_on)) { 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); dsi_bridge_post_disable(&gbridge->base);
__pm_relax(&prim_panel_wakelock); __pm_relax(&prim_panel_wakelock);
mutex_unlock(&gbridge->base.lock); mutex_unlock(&gbridge->base.lock);

View File

@ -1297,17 +1297,16 @@ config TOUCHSCREEN_RAYDIUM_CHIPSET
If unsure, say N. If unsure, say N.
config TOUCHSCREEN_COMMON config TOUCHSCREEN_COMMON
tristate "Longcheer tp info driver" bool "Common touchscreen interface to interact with userspace"
default y default y
help 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. If unsure, say N.
source "drivers/input/touchscreen/nt36xxx_spi/Kconfig" source "drivers/input/touchscreen/nt36xxx_spi/Kconfig"
source "drivers/input/touchscreen/xiaomi/Kconfig"
source "drivers/input/touchscreen/focaltech_touch/Kconfig" source "drivers/input/touchscreen/focaltech_touch/Kconfig"
endif endif

View File

@ -108,9 +108,8 @@ obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023) += rohm_bu21023.o
obj-$(CONFIG_TOUCHSCREEN_HIMAX_CHIPSET) += hxchipset/ obj-$(CONFIG_TOUCHSCREEN_HIMAX_CHIPSET) += hxchipset/
obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_TCM) += synaptics_tcm/ obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_TCM) += synaptics_tcm/
obj-$(CONFIG_TOUCHSCREEN_RAYDIUM_CHIPSET) += raydium_wt030/ 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_NT36xxx_HOSTDL_SPI) += nt36xxx_spi/
obj-$(CONFIG_TOUCHSCREEN_XIAOMI_TOUCHFEATURE) += xiaomi/
obj-$(CONFIG_TOUCHSCREEN_RASPBERRYPI_FW) += raspberrypi-ts.o obj-$(CONFIG_TOUCHSCREEN_RASPBERRYPI_FW) += raspberrypi-ts.o
obj-$(CONFIG_TOUCHSCREEN_IQS5XX) += iqs5xx.o obj-$(CONFIG_TOUCHSCREEN_IQS5XX) += iqs5xx.o
obj-$(CONFIG_TOUCHSCREEN_ST) += st/ obj-$(CONFIG_TOUCHSCREEN_ST) += st/

View File

@ -1,232 +0,0 @@
/****************************************************************************************
*
* @File Name : lct_tp_gesture.c
* @Author : wanghan
* @E-mail : <wanghan@longcheer.com>
* @Create Time : 2018-09-30 17:34:43
* @Description : Enable/Disable touchpad.
*
****************************************************************************************/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <linux/module.h>
#include <linux/device.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <asm/uaccess.h>
#include <linux/proc_fs.h>
#include <linux/miscdevice.h>
#include <asm/uaccess.h>
/*
* 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");

View File

@ -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__

View File

@ -1,224 +0,0 @@
/****************************************************************************************
*
* @File Name : lct_tp_grip_area.c
* @Author : wanghan
* @E-mail : <wanghan@longcheer.com>
* @Create Time : 2018-08-17 17:34:43
* @Description : Display touchpad information.
*
****************************************************************************************/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <linux/module.h>
#include <linux/device.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <asm/uaccess.h>
#include <linux/proc_fs.h>
#include <linux/miscdevice.h>
/*
* 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");

View File

@ -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__

View File

@ -1,268 +0,0 @@
/****************************************************************************************
*
* @File Name : lct_tp_info.c
* @Author : wanghan
* @E-mail : <wanghan@longcheer.com>
* @Create Time : 2018-08-17 17:34:43
* @Description : Display touchpad information.
*
****************************************************************************************/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <linux/module.h>
#include <linux/device.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <asm/uaccess.h>
#include <linux/proc_fs.h>
#include <linux/miscdevice.h>
/*
* 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");

View File

@ -1,28 +0,0 @@
/****************************************************************************************
*
* @File Name : lct_tp_info.h
* @Author : wanghan
* @E-mail : <wanghan@longcheer.com>
* @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__

View File

@ -1,216 +0,0 @@
/****************************************************************************************
*
* @File Name : lct_tp_palm.c
* @Author : yanglintao
* @E-mail : <yanglintao@longcheer.com>
* @Create Time : 2019-12-26 11:15:12
* @Description : Enable/Disable touchpad.
*
****************************************************************************************/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <linux/module.h>
#include <linux/device.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <asm/uaccess.h>
#include <linux/proc_fs.h>
#include <linux/miscdevice.h>
#include <asm/uaccess.h>
/*
* 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");

View File

@ -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__

View File

@ -1,236 +0,0 @@
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/sysfs.h>
#include <linux/init.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/syscalls.h>
#include <linux/file.h>
#include <linux/fs.h>
#include <linux/fcntl.h>
#include <linux/string.h>
#include <asm/unistd.h>
#include <linux/cdev.h>
#include <asm/uaccess.h>
#include <linux/proc_fs.h>
#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");

View File

@ -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

View File

@ -1,216 +0,0 @@
/****************************************************************************************
*
* @File Name : lct_tp_work.c
* @Author : wanghan
* @E-mail : <wanghan@longcheer.com>
* @Create Time : 2018-09-30 17:34:43
* @Description : Enable/Disable touchpad.
*
****************************************************************************************/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <linux/module.h>
#include <linux/device.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <asm/uaccess.h>
#include <linux/proc_fs.h>
#include <linux/miscdevice.h>
#include <asm/uaccess.h>
/*
* 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");

View File

@ -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__

View File

@ -67,15 +67,6 @@ extern int32_t nvt_extra_proc_init(void);
extern void nvt_extra_proc_deinit(void); extern void nvt_extra_proc_deinit(void);
#endif #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; struct nvt_ts_data *ts;
//static struct device *spi_geni_master_dev; //static struct device *spi_geni_master_dev;
@ -133,35 +124,6 @@ const uint16_t gesture_key_array[] = {
#endif #endif
static uint8_t bTouchIsAwake; 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 #if WAKEUP_GESTURE
#define WAKEUP_OFF 4 #define WAKEUP_OFF 4
@ -180,55 +142,6 @@ int nvt_gesture_switch(struct input_dev *dev, unsigned int type, unsigned int co
} }
#endif #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 #ifdef CONFIG_TOUCHSCREEN_COMMON
static ssize_t double_tap_show(struct kobject *kobj, static ssize_t double_tap_show(struct kobject *kobj,
@ -760,16 +673,13 @@ info_retry:
switch (ts->touch_vendor_id) { switch (ts->touch_vendor_id) {
case TP_VENDOR_HUAXING: case TP_VENDOR_HUAXING:
snprintf(tp_info_buf, sizeof(tp_info_buf), "[Vendor]huaxing,[FW]0x%02x,[IC]nt36672c\n", ts->fw_ver); 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; break;
case TP_VENDOR_TIANMA: case TP_VENDOR_TIANMA:
snprintf(tp_info_buf, sizeof(tp_info_buf), "[Vendor]tianma,[FW]0x%02x,[IC]nt36672c\n", ts->fw_ver); 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; break;
} }
#else #else
snprintf(tp_info_buf, sizeof(tp_info_buf), "[Vendor]unknown,[FW]0x%02x,[IC]nt36672c\n", ts->fw_ver); 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 #endif
//---Get Novatek PID--- //---Get Novatek PID---
@ -1276,47 +1186,6 @@ static uint8_t nvt_wdt_fw_recovery(uint8_t *point_data)
} }
#endif /* #if NVT_TOUCH_WDT_RECOVERY */ #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 #define POINT_DATA_LEN 65
/******************************************************* /*******************************************************
Description: Description:
@ -1398,11 +1267,6 @@ static void nvt_ts_worker(struct work_struct *work)
#endif /* #if NVT_TOUCH_ESD_PROTECT */ #endif /* #if NVT_TOUCH_ESD_PROTECT */
input_id = (uint8_t)(point_data[1] >> 3); 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 WAKEUP_GESTURE
if (bTouchIsAwake == 0) { if (bTouchIsAwake == 0) {
//input_id = (uint8_t)(point_data[1] >> 3); //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 */ #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 TOUCH_KEY_NUM > 0
if (point_data[61] == 0xF8) { if (point_data[61] == 0xF8) {
#if NVT_TOUCH_ESD_PROTECT #if NVT_TOUCH_ESD_PROTECT
@ -1730,522 +1588,6 @@ exit:
} }
#endif #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: Description:
Novatek touchscreen driver probe function. Novatek touchscreen driver probe function.
@ -2510,55 +1852,6 @@ static int32_t nvt_ts_probe(struct spi_device *client)
} }
#endif #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); ts->coord_workqueue = alloc_workqueue("nvt_ts_workqueue", WQ_HIGHPRI, 0);
if (!ts->coord_workqueue) { if (!ts->coord_workqueue) {
NVT_ERR("create nvt_ts_workqueue fail"); NVT_ERR("create nvt_ts_workqueue fail");
@ -2600,32 +1893,6 @@ static int32_t nvt_ts_probe(struct spi_device *client)
} }
#endif #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; bTouchIsAwake = 1;
NVT_LOG("end\n"); NVT_LOG("end\n");
@ -2638,11 +1905,6 @@ static int32_t nvt_ts_probe(struct spi_device *client)
pm_runtime_enable(&ts->client->dev); 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 #if 0
//spi bus pm_runtime_get //spi bus pm_runtime_get
spi_geni_master_dev = lct_get_spi_geni_master_dev(ts->client->master); 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; 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: err_create_nvt_ts_workqueue_failed:
if (ts->coord_workqueue) if (ts->coord_workqueue)
destroy_workqueue(ts->coord_workqueue); destroy_workqueue(ts->coord_workqueue);
@ -2678,26 +1935,6 @@ err_register_fb_notif_failed:
unregister_early_suspend(&ts->early_suspend); unregister_early_suspend(&ts->early_suspend);
err_register_early_suspend_failed: err_register_early_suspend_failed:
#endif #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 #if NVT_TOUCH_EXT_PROC
nvt_extra_proc_deinit(); nvt_extra_proc_deinit();
err_extra_proc_init_failed: 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); unregister_early_suspend(&ts->early_suspend);
#endif #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 #if NVT_TOUCH_EXT_PROC
nvt_extra_proc_deinit(); nvt_extra_proc_deinit();
#endif #endif
@ -2889,15 +2109,6 @@ static void nvt_ts_shutdown(struct spi_device *client)
unregister_early_suspend(&ts->early_suspend); unregister_early_suspend(&ts->early_suspend);
#endif #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 #if NVT_TOUCH_EXT_PROC
nvt_extra_proc_deinit(); nvt_extra_proc_deinit();
#endif #endif
@ -3019,23 +2230,6 @@ static int32_t nvt_ts_suspend(struct device *dev)
return 0; 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: Description:
Novatek touchscreen driver resume function. Novatek touchscreen driver resume function.
@ -3094,13 +2288,6 @@ static int32_t nvt_ts_resume(struct device *dev)
NVT_LOG("bTouchIsAwake = 1\n"); NVT_LOG("bTouchIsAwake = 1\n");
mutex_unlock(&ts->lock); 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 WAKEUP_GESTURE
if (ts->delay_gesture) { if (ts->delay_gesture) {
lct_nvt_tp_gesture_callback(!ts->is_gesture_mode); lct_nvt_tp_gesture_callback(!ts->is_gesture_mode);
@ -3108,28 +2295,8 @@ static int32_t nvt_ts_resume(struct device *dev)
} }
#endif #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"); 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; return 0;
} }

View File

@ -31,16 +31,6 @@
#include "nt36xxx_mem_map.h" #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 #define NVT_DEBUG 0
//---GPIO number--- //---GPIO number---
@ -89,7 +79,6 @@ extern const uint16_t touch_key_array[TOUCH_KEY_NUM];
#if WAKEUP_GESTURE #if WAKEUP_GESTURE
extern const uint16_t gesture_key_array[]; extern const uint16_t gesture_key_array[];
#endif #endif
#define LCT_TP_PALM_EN 1
#define BOOT_UPDATE_FIRMWARE 1 #define BOOT_UPDATE_FIRMWARE 1
#define FIRMWARE_NAME_LEN 256 #define FIRMWARE_NAME_LEN 256
#define BOOT_UPDATE_FIRMWARE_NAME "novatek_ts_fw.bin" #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 //enable 'check touch vendor' feature
#define CHECK_TOUCH_VENDOR #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--- //---Touch Vendor ID---
#define TP_VENDOR_UNKNOWN 0x00 #define TP_VENDOR_UNKNOWN 0x00
#define TP_VENDOR_HUAXING 0x01 #define TP_VENDOR_HUAXING 0x01
#define TP_VENDOR_TIANMA 0x02 #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 //new qcom platform use
#define _MSM_DRM_NOTIFY_H_ #define _MSM_DRM_NOTIFY_H_
@ -200,17 +161,7 @@ struct nvt_ts_data {
struct regulator *pwr_lab; /* VSP +5V */ struct regulator *pwr_lab; /* VSP +5V */
struct regulator *pwr_ibb; /* VSN -5V */ struct regulator *pwr_ibb; /* VSN -5V */
#endif #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 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 #if NVT_TOUCH_PROC
@ -278,7 +229,6 @@ void nvt_sw_reset_idle(void);
void nvt_boot_ready(void); void nvt_boot_ready(void);
void nvt_bld_crc_enable(void); void nvt_bld_crc_enable(void);
void nvt_fw_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_update_firmware(char *firmware_name);
int32_t nvt_check_fw_reset_state(RST_COMPLETE_STATE check_reset_state); int32_t nvt_check_fw_reset_state(RST_COMPLETE_STATE check_reset_state);
int32_t nvt_get_fw_info(void); int32_t nvt_get_fw_info(void);

File diff suppressed because it is too large Load Diff

View File

@ -34,11 +34,6 @@
#define NVT_DUMP_PARTITION_LEN (1024) #define NVT_DUMP_PARTITION_LEN (1024)
#define NVT_DUMP_PARTITION_PATH "/data/local/tmp" #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; static struct timeval start, end;
const struct firmware *fw_entry; const struct firmware *fw_entry;
static size_t fw_need_write_size; static size_t fw_need_write_size;
@ -1166,12 +1161,5 @@ void Boot_Update_Firmware(struct work_struct *work)
mutex_lock(&ts->lock); mutex_lock(&ts->lock);
nvt_update_firmware(ts->boot_update_firmware_name); nvt_update_firmware(ts->boot_update_firmware_name);
mutex_unlock(&ts->lock); 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 */ #endif /* BOOT_UPDATE_FIRMWARE */

View File

@ -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:

View File

@ -1 +0,0 @@
obj-$(CONFIG_TOUCHSCREEN_XIAOMI_TOUCHFEATURE) += xiaomi_touch.o

View File

@ -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);

View File

@ -1,96 +0,0 @@
#ifndef __XIAOMI__TOUCH_H
#define __XIAOMI__TOUCH_H
#include <linux/device.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/wait.h>
#include <linux/types.h>
#include <linux/ioctl.h>
#include <linux/miscdevice.h>
#include <linux/proc_fs.h>
#include <linux/uaccess.h>
#include <linux/debugfs.h>
#include <linux/device.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/wait.h>
#include <linux/poll.h>
#include <linux/slab.h>
/*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

View File

@ -35,17 +35,6 @@
#include <linux/gpio.h> #include <linux/gpio.h>
#endif #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, ...) \ #define smblib_err(chg, fmt, ...) \
pr_err("%s: %s: " fmt, chg->name, \ pr_err("%s: %s: " fmt, chg->name, \
__func__, ##__VA_ARGS__) \ __func__, ##__VA_ARGS__) \
@ -6422,15 +6411,6 @@ void smblib_usb_plugin_locked(struct smb_charger *chg)
dual_role_instance_changed(chg->dual_role); dual_role_instance_changed(chg->dual_role);
smblib_dbg(chg, PR_INTERRUPT, "IRQ: usbin-plugin %s\n", smblib_dbg(chg, PR_INTERRUPT, "IRQ: usbin-plugin %s\n",
vbus_rising ? "attached" : "detached"); 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) irqreturn_t usb_plugin_irq_handler(int irq, void *data)

View File

@ -40,11 +40,6 @@ struct msm_drm_notifier {
void *data; void *data;
}; };
struct drm_notify_data {
bool is_primary;
void *data;
};
int msm_drm_register_client(struct notifier_block *nb); int msm_drm_register_client(struct notifier_block *nb);
int msm_drm_unregister_client(struct notifier_block *nb); int msm_drm_unregister_client(struct notifier_block *nb);
#endif #endif