dlkm: Cyprus: touch: ili7807s bringup

- Support ili9882 driver for kernel 5.4.0
- Improve touch driver

Change-Id: I340bec19ac48f3fde166a17da8a060f5dee1eac5
Signed-off-by: wengjun1 <wengjun1@motorola.com>
Reviewed-on: https://gerrit.mot.com/1950206
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
wengjun1 2021-05-17 13:16:53 +08:00 • committed by Jun Weng
commit d30cb29b96
11 changed files with 139 additions and 24 deletions

View file

@ -1,8 +1,8 @@
# add -Wall to try to catch everything we can.
EXTRA_CFLAGS += -Wall
EXTRA_CFLAGS += -I$(TOP)/motorola/kernel/modules/include \
-I$(TOP)/motorola/kernel/modules/drivers/input/touchscreen/ili9882_mmi \
-I$(TOP)/motorola/kernel/modules/drivers/input/touchscreen/ili9882_mmi/firmware
EXTRA_CFLAGS += -I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/include \
-I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/drivers/input/touchscreen/ili9882_mmi \
-I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/drivers/input/touchscreen/ili9882_mmi/firmware
ifeq ($(filter m y, $(CONFIG_TOUCHSCREEN_ILITEK_CHIPSET)),)
obj-m += ili9882_mmi.o

View file

@ -119,6 +119,14 @@ static unsigned char CTPM_FW_TM_9882H[] = {
0xFF,
};
#define TM_7807S_INI_NAME_PATH "/sdcard/mp_tm_7807s.ini"
#define TM_7807S_FW_FILP_PATH "/sdcard/ILITEK_FW_TM_7807S"
#define TM_7807S_INI_REQUEST_PATH "mp_tm_7807s.ini"
#define TM_7807S_FW_REQUEST_PATH "ILITEK_FW_TM_7807S"
static unsigned char CTPM_FW_TM_7807S[] = {
0xFF,
};
#define TIANMA_9882N_INI_NAME_PATH "/sdcard/mp_tianma_9882n.ini"
#define TIANMA_9882N_FW_FILP_PATH "/sdcard/ILITEK_FW_TIANMA_9882N"
#define TIANMA_9882N_INI_REQUEST_PATH "mp_tianma_9882n.ini"
@ -142,4 +150,4 @@ static unsigned char CTPM_FW_TM[] = {
static unsigned char CTPM_FW_HLT[] = {
};
#endif
#endif

View file

@ -250,7 +250,26 @@ static void ilitek_tddi_wq_esd_check(struct work_struct *work)
complete_all(&ilits->esd_done);
ili_wq_ctrl(WQ_ESD, ENABLE);
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
static int read_power_status(u8 *buf)
{
struct file *f = NULL;
ssize_t byte = 0;
loff_t pos = 0;
f = filp_open(POWER_STATUS_PATH, O_RDONLY, 0);
if (ERR_ALLOC_MEM(f)) {
ILI_ERR("Failed to open %s\n", POWER_STATUS_PATH);
return -1;
}
kernel_read(f, buf, 20, &pos);
ILI_DBG("Read %d bytes\n", (int)byte);
filp_close(f, NULL);
return 0;
}
#else
static int read_power_status(u8 *buf)
{
struct file *f = NULL;
@ -275,6 +294,7 @@ static int read_power_status(u8 *buf)
filp_close(f, NULL);
return 0;
}
#endif
static void ilitek_tddi_wq_bat_check(struct work_struct *work)
{
@ -1009,6 +1029,15 @@ static void ili_update_tp_module_info(void)
ilits->md_fw_ili = CTPM_FW_TM_9882H;
ilits->md_fw_ili_size = sizeof(CTPM_FW_TM_9882H);
break;
case MODEL_TM_7807S:
ilits->md_name = "TM_7807S";
ilits->md_fw_filp_path = TM_7807S_FW_FILP_PATH;
ilits->md_fw_rq_path = TM_7807S_FW_REQUEST_PATH;
ilits->md_ini_path = TM_7807S_INI_NAME_PATH;
ilits->md_ini_rq_path = TM_7807S_FW_REQUEST_PATH;
ilits->md_fw_ili = CTPM_FW_TM_7807S;
ilits->md_fw_ili_size = sizeof(CTPM_FW_TM_7807S);
break;
case MODEL_TIANMA_9882N:
ilits->md_name = "TIANMA_9882N";
ilits->md_fw_filp_path = TIANMA_9882N_FW_FILP_PATH;

View file

@ -90,7 +90,9 @@
#ifdef CONFIG_FB
#include <linux/notifier.h>
#include <linux/fb.h>
#else
#endif
#ifdef CONFIG_HAS_EARLYSUSPEND
#include <linux/earlysuspend.h>
#endif
@ -350,6 +352,7 @@ enum TP_MODEL {
MODEL_TM,
MODEL_TM_9882N,
MODEL_TM_9882H,
MODEL_TM_7807S,
MODEL_TIANMA_9882N,
MODEL_TM_END, //For tianma panel check
MODEL_HLT
@ -797,9 +800,9 @@ struct ilitek_ts_data {
struct regulator *vdd;
struct regulator *vcc;
#ifdef CONFIG_FB
#if defined(CONFIG_FB) || defined(CONFIG_DRM)
struct notifier_block notifier_fb;
#else
#elif defined(CONFIG_HAS_EARLYSUSPEND)
struct early_suspend early_suspend;
#endif
#if CHARGER_NOTIFIER_CALLBACK

View file

@ -136,7 +136,9 @@ static int ilitek_tddi_fw_iram_read(u8 *buf, u32 start, int len)
int ili_fw_dump_iram_data(u32 start, u32 end, bool save)
{
struct file *f = NULL;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0))
mm_segment_t old_fs;
#endif
loff_t pos = 0;
int i, ret, len;
u8 *fw_buf = NULL;
@ -176,12 +178,16 @@ int ili_fw_dump_iram_data(u32 start, u32 end, bool save)
goto out;
}
pos = 0;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
kernel_write(f, fw_buf, len, &pos);
#else
old_fs = get_fs();
set_fs(get_ds());
set_fs(KERNEL_DS);
pos = 0;
vfs_write(f, fw_buf, len, &pos);
set_fs(old_fs);
#endif
filp_close(f, NULL);
ILI_INFO("Save iram data to %s\n", DUMP_IRAM_PATH);
@ -490,7 +496,11 @@ int ili_fw_dump_flash_data(u32 start, u32 end, bool user)
{
struct file *f = NULL;
u8 *buf = NULL;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0))
mm_segment_t old_fs;
#endif
loff_t pos = 0;
u32 start_addr, end_addr;
int ret, length;
@ -529,12 +539,16 @@ int ili_fw_dump_flash_data(u32 start, u32 end, bool user)
if (ret < 0)
goto out;
pos = 0;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
kernel_write(f, buf, length, &pos);
#else
old_fs = get_fs();
set_fs(get_ds());
set_fs(KERNEL_DS);
pos = 0;
vfs_write(f, buf, length, &pos);
set_fs(old_fs);
#endif
filp_close(f, NULL);
ipio_vfree((void **)&buf);
@ -1190,7 +1204,11 @@ static int ilitek_tdd_fw_hex_open(u8 op, u8 *pfw)
int ret =0, fsize = 0;
const struct firmware *fw = NULL;
struct file *f = NULL;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0))
mm_segment_t old_fs;
#endif
loff_t pos = 0;
ILI_INFO("Open file method = %s, path = %s\n",
@ -1267,12 +1285,17 @@ static int ilitek_tdd_fw_hex_open(u8 op, u8 *pfw)
}
/* ready to map user's memory to obtain data by reading files */
pos = 0;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
kernel_read(f, (u8 *)ilits->tp_fw.data, fsize, &pos);
#else
old_fs = get_fs();
set_fs(get_ds());
set_fs(KERNEL_DS);
pos = 0;
vfs_read(f, (u8 *)ilits->tp_fw.data, fsize, &pos);
set_fs(old_fs);
#endif
filp_close(f, NULL);
ilits->tp_fw.size = fsize;
break;

View file

@ -197,7 +197,9 @@ static int ilitek_tddi_fw_iram_read(u8 *buf, u32 start, int len)
int ili_fw_dump_iram_data(u32 start, u32 end, bool save)
{
struct file *f = NULL;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0))
mm_segment_t old_fs;
#endif
loff_t pos = 0;
int i, ret = 0;
int len, tmp = debug_en;
@ -236,12 +238,16 @@ int ili_fw_dump_iram_data(u32 start, u32 end, bool save)
goto out;
}
pos = 0;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
kernel_write(f, ilits->update_buf, len, &pos);
#else
old_fs = get_fs();
set_fs(get_ds());
set_fs(KERNEL_DS);
pos = 0;
vfs_write(f, ilits->update_buf, len, &pos);
set_fs(old_fs);
#endif
filp_close(f, NULL);
ILI_INFO("Save iram data to %s\n", DUMP_IRAM_PATH);
} else {
@ -709,7 +715,9 @@ static int ilitek_tdd_fw_hex_open(u8 op, u8 *pfw)
int ret =0, fsize = 0;
const struct firmware *fw = NULL;
struct file *f = NULL;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0))
mm_segment_t old_fs;
#endif
loff_t pos = 0;
ILI_INFO("Open file method = %s, path = %s\n",
@ -785,12 +793,16 @@ static int ilitek_tdd_fw_hex_open(u8 op, u8 *pfw)
}
/* ready to map user's memory to obtain data by reading files */
pos = 0;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
kernel_read(f, (u8 *)ilits->tp_fw.data, fsize, &pos);
#else
old_fs = get_fs();
set_fs(get_ds());
set_fs(KERNEL_DS);
pos = 0;
vfs_read(f, (u8 *)ilits->tp_fw.data, fsize, &pos);
set_fs(old_fs);
#endif
filp_close(f, NULL);
ilits->tp_fw.size = fsize;
break;

View file

@ -799,7 +799,9 @@ static int ilitek_tddi_mp_ini_parser(const char *path)
char *tmp = NULL;
const struct firmware *ini = NULL;
struct file *f = NULL;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0))
mm_segment_t old_fs;
#endif
loff_t pos = 0;
ILI_INFO("ini file path = %s\n", path);
@ -847,10 +849,14 @@ static int ilitek_tddi_mp_ini_parser(const char *path)
}
if (f != NULL) {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
kernel_read(f, tmp, fsize, &pos);
#else
old_fs = get_fs();
set_fs(get_ds());
vfs_read(f, tmp, fsize, &pos);
set_fs(old_fs);
#endif
tmp[fsize] = 0x0;
} else {
memcpy(tmp, ini->data, fsize);
@ -3059,7 +3065,9 @@ static int mp_show_result(bool lcm_on)
char *csv = NULL;
char *ret_pass_name = NULL, *ret_fail_name = NULL;
struct file *f = NULL;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0))
mm_segment_t fs;
#endif
loff_t pos;
csv = vmalloc(CSV_FILE_SIZE);
@ -3304,11 +3312,15 @@ static int mp_show_result(bool lcm_on)
goto fail_open;
}
pos = 0;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
kernel_write(f, csv, csv_len, &pos);
#else
fs = get_fs();
set_fs(KERNEL_DS);
pos = 0;
vfs_write(f, csv, csv_len, &pos);
set_fs(fs);
#endif
filp_close(f, NULL);
ILI_INFO("Writing Data into CSV succeed\n");

View file

@ -190,7 +190,9 @@ struct file_buffer {
static int file_write(struct file_buffer *file, bool new_open)
{
struct file *f = NULL;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0))
mm_segment_t fs;
#endif
loff_t pos;
if (file->ptr == NULL) {
@ -217,12 +219,15 @@ static int file_write(struct file_buffer *file, bool new_open)
ILI_ERR("Failed to open %s file\n", file->fname);
return -1;
}
pos = 0;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
kernel_write(f, file->ptr, file->wlen, &pos);
#else
fs = get_fs();
set_fs(KERNEL_DS);
pos = 0;
vfs_write(f, file->ptr, file->flen, &pos);
set_fs(fs);
#endif
filp_close(f, NULL);
return 0;
}
@ -344,6 +349,10 @@ out:
static int dev_mkdir(char *name, umode_t mode)
{
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
int err = -1;
return err;
#else
#if 0
struct dentry *dentry;
struct path path;
@ -367,6 +376,7 @@ static int dev_mkdir(char *name, umode_t mode)
return err;
#endif
#endif //#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
}
static ssize_t ilitek_proc_get_delta_data_read(struct file *pFile, char __user *buf, size_t size, loff_t *pos)
@ -1392,9 +1402,16 @@ int ili_tp_data_mode_ctrl(u8* cmd)
ret = -ENOTTY;
}
} else {
if (ili_switch_tp_mode(P5_X_FW_AP_MODE) < 0) {
ILI_ERR("Failed to switch demo mode\n");
ret = -ENOTTY;
if (ilits->actual_tp_mode == P5_X_FW_TEST_MODE) {
if (ili_switch_tp_mode(P5_X_FW_AP_MODE) < 0) {
ILI_ERR("Failed to switch demo mode\n");
ret = -ENOTTY;
}
} else {
if (ili_set_tp_data_len(DATA_FORMAT_DEMO, false, NULL) < 0) {
ILI_ERR("Failed to switch demo mode\n");
ret = -ENOTTY;
}
}
}
break;

View file

@ -569,7 +569,7 @@ static int ilitek_plat_notifier_fb(struct notifier_block *self, unsigned long ev
}
return NOTIFY_OK;
}
#else
#elif defined(CONFIG_HAS_EARLYSUSPEND)
static void ilitek_plat_early_suspend(struct early_suspend *h)
{
if (ili_sleep_handler(TP_SUSPEND) < 0)
@ -614,7 +614,8 @@ static void ilitek_plat_sleep_init(void)
ILI_ERR("Unable to register notifier_fb\n");
#endif /* CONFIG_PLAT_SPRD */
#endif /* CONFIG_DRM_MSM */
#else
#elif defined(CONFIG_HAS_EARLYSUSPEND)
ILI_INFO("Init eqarly_suspend struct\n");
ilits->early_suspend.suspend = ilitek_plat_early_suspend;
ilits->early_suspend.resume = ilitek_plat_late_resume;
@ -794,5 +795,8 @@ static void __exit ilitek_plat_dev_exit(void)
//module_init(ilitek_plat_dev_init);
late_initcall(ilitek_plat_dev_init);
module_exit(ilitek_plat_dev_exit);
#if KERNEL_VERSION(5, 4, 0) <= LINUX_VERSION_CODE
MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);
#endif
MODULE_AUTHOR("ILITEK");
MODULE_LICENSE("GPL");

View file

@ -268,7 +268,7 @@ static int ili_spi_pll_clk_wakeup(void)
ILI_INFO("spi slave write error\n");
return -1;
}
mdelay(1);
return 0;
}
@ -354,6 +354,12 @@ static int ili_spi_wrapper(u8 *txbuf, u32 wlen, u8 *rxbuf, u32 rlen, bool spi_ir
}
ret = ilits->spi_write_then_read(ilits->spi, wdata, wlen, txbuf, 0);
if (!ice) {
ILI_INFO("send cmd delay 1ms\n");
mdelay(1);
}
if (ret < 0) {
ILI_INFO("spi-wrapper write error\n");
break;
@ -459,6 +465,8 @@ static int ili_parse_tp_module()
tp_module = MODEL_TM_9882N;
} else if (strstr(active_panel_name, "ili9882h")) {
tp_module = MODEL_TM_9882H;
} else if (strstr(active_panel_name, "ili7807s")) {
tp_module = MODEL_TM_7807S;
}
} else if (strstr(active_panel_name, "tianma") && strstr(active_panel_name, "ili9882n")) {
tp_module = MODEL_TIANMA_9882N;

View file

@ -1098,14 +1098,13 @@ void ili_report_debug_lite_mode(u8 *buf, int len)
void ili_report_gesture_mode(u8 *buf, int len)
{
int i, lu_x = 0, lu_y = 0, rd_x = 0, rd_y = 0, score = 0;
int lu_x = 0, lu_y = 0, rd_x = 0, rd_y = 0, score = 0;
u8 ges[P5_X_GESTURE_INFO_LENGTH] = {0};
struct gesture_coordinate *gc = ilits->gcoord;
struct input_dev *input = ilits->input;
bool transfer = ilits->trans_xy;
for (i = 0; i < len; i++)
ges[i] = buf[i];
ipio_memcpy(ges, buf, len, P5_X_GESTURE_INFO_LENGTH);
memset(gc, 0x0, sizeof(struct gesture_coordinate));