input: ili9882_mmi: add pen notify and palm settings

ili9882_mmi:
- add pen notify for passive pen pull and plug
- add palm settings node for canvas
- add usb detection function

Change-Id: Idec5779bf1ff7ddc5d27cae13052b85f84bd9c19
Signed-off-by: wangyq13 <wangyq13@lenovo.com>
Reviewed-on: https://gerrit.mot.com/2396006
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: <lvxj4@motorola.com>
Reviewed-by: Jing Hu <hujing3@lenovo.com>
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
wangyq13 2022-10-01 17:14:18 +08:00 • committed by Yeqing Wang
commit 78b1a4e533
7 changed files with 122 additions and 1 deletions

View file

@ -29,6 +29,10 @@ ifeq ($(ILITEK_SUSPEND_PWROFF),true)
KERNEL_CFLAGS += CONFIG_ILITEK_SUSPEND_PWROFF=y
endif
ifneq ($(BOARD_USES_PEN_NOTIFIER),)
KBUILD_OPTIONS += CONFIG_INPUT_ILITEK_MMI_PEN_NOTIFIER=y
endif
ifeq ($(ILITEK_CHARGER),true)
KERNEL_CFLAGS += CONFIG_ILITEK_CHARGER=y
endif
@ -55,6 +59,9 @@ include $(CLEAR_VARS)
ifneq ($(BOARD_USES_DOUBLE_TAP),)
LOCAL_ADDITIONAL_DEPENDENCIES += $(KERNEL_MODULES_OUT)/sensors_class.ko
endif
ifneq ($(BOARD_USES_PEN_NOTIFIER),)
LOCAL_ADDITIONAL_DEPENDENCIES += $(KERNEL_MODULES_OUT)/bu520xx_pen.ko
endif
LOCAL_MODULE := ili9882_mmi.ko
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)

View file

@ -39,6 +39,11 @@ ifneq ($(filter m y,$(CONFIG_ILITEK_GESTURE)),)
EXTRA_CFLAGS += -DILI_CONFIG_GESTURE
endif
ifneq ($(filter m y,$(CONFIG_INPUT_ILITEK_MMI_PEN_NOTIFIER)),)
KBUILD_EXTRA_SYMBOLS += $(CURDIR)/$(KBUILD_EXTMOD)/../../../misc/pen/$(GKI_OBJ_MODULE_DIR)/Module.symvers
EXTRA_CFLAGS += -DILITEK_PEN_NOTIFIER
endif
ifneq ($(filter m y,$(CONFIG_ILITEK_PANEL_GESTURE)),)
EXTRA_CFLAGS += -DILI_CONFIG_PANEL_GESTURE
endif

View file

@ -15,4 +15,4 @@ clean:
KBUILD_EXTRA_SYMBOLS += $(M)/../../../mmi_info/$(GKI_OBJ_MODULE_DIR)/Module.symvers
KBUILD_EXTRA_SYMBOLS += $(M)/../touchscreen_mmi/$(GKI_OBJ_MODULE_DIR)/Module.symvers
KBUILD_EXTRA_SYMBOLS += $(M)/../../../misc/pen/$(GKI_OBJ_MODULE_DIR)/Module.symvers

View file

@ -119,6 +119,10 @@
#include <linux/touchscreen_mmi.h>
#endif
#ifdef ILITEK_PEN_NOTIFIER
#include <linux/pen_detection_notify.h>
#endif
#define DRIVER_VERSION "3.0.3.0.200610"
/* Options */
@ -935,6 +939,10 @@ struct ilitek_ts_data {
int gesture_demo_ctrl;
struct gesture_symbol ges_sym;
struct report_info_block rib;
int canvas_value;
#ifdef ILITEK_PEN_NOTIFIER
struct notifier_block pen_notif;
#endif
u16 flash_mid;
u16 flash_devid;

View file

@ -111,8 +111,10 @@ static unsigned char g_user_buf[USER_STR_BUFF] = {0};
#define ILI_SPI_NAME_TM "ilitek_tm"
#define ILI_SPI_NAME_CSOT "ilitek_csot"
#define ILI_SPI_NAME_TXD "ilitek_txd"
#ifndef CONFIG_INPUT_TOUCHSCREEN_MMI
static struct class *touchscreen_class;
static struct device *touchscreen_class_dev;
#endif
int ili_str2hex(char *str)
{
@ -2705,6 +2707,7 @@ static int netlink_init(void)
return ret;
}
#ifndef CONFIG_INPUT_TOUCHSCREEN_MMI
static ssize_t path_show(struct device *pDevice, struct device_attribute *pAttr, char *pBuf)
{
ssize_t blen;
@ -2802,6 +2805,7 @@ device_destroy:
return -ENODEV;
}
#endif
void ili_node_init(void)
{
@ -2822,5 +2826,7 @@ void ili_node_init(void)
}
}
netlink_init();
#ifndef CONFIG_INPUT_TOUCHSCREEN_MMI
ilitek_sys_init();
#endif
}

View file

@ -608,6 +608,20 @@ static int parse_dt(struct device_node *np)
}
#endif
#ifdef ILITEK_PEN_NOTIFIER
static int pen_notifier_callback(struct notifier_block *self,
unsigned long event, void *data)
{
ILI_INFO("Received event(%lu) for pen detection\n", event);
mutex_lock(&ilits->touch_mutex);
ili_ic_func_ctrl("passive_pen", event);
mutex_unlock(&ilits->touch_mutex);
return 0;
}
#endif
static int ilitek_spi_probe(struct spi_device *spi)
{
struct touch_bus_info *info =
@ -782,6 +796,11 @@ static int ilitek_spi_probe(struct spi_device *spi)
if (ili_core_spi_setup(SPI_CLK) < 0)
return -EINVAL;
#ifdef ILITEK_PEN_NOTIFIER
ilits->pen_notif.notifier_call = pen_notifier_callback;
pen_detection_register_client(&ilits->pen_notif);
#endif
#ifdef CONFIG_INPUT_TOUCHSCREEN_MMI
ili_mmi_init(ilits, true);
#endif

View file

@ -71,9 +71,84 @@ static int ili_mmi_methods_drv_irq(struct device *dev, int state)
static int ili_mmi_charger_mode(struct device *dev, int mode)
{
int ret = 0;
mutex_lock(&ilits->touch_mutex);
ret = ili_ic_func_ctrl("plug", mode);
if(ret<0) {
ILI_ERR("Write plug in failed\n");
}
ILI_INFO("%s: %d\n", __func__, mode);
mutex_unlock(&ilits->touch_mutex);
return 0;
}
#define MAX_ATTRS_ENTRIES 10
#define ADD_ATTR(name) { \
if (idx < MAX_ATTRS_ENTRIES) { \
dev_info(dev, "%s: [%d] adding %p\n", __func__, idx, &dev_attr_##name.attr); \
ext_attributes[idx] = &dev_attr_##name.attr; \
idx++; \
} else { \
dev_err(dev, "%s: cannot add attribute '%s'\n", __func__, #name); \
} \
}
static struct attribute *ext_attributes[MAX_ATTRS_ENTRIES];
static struct attribute_group ext_attr_group = {
.attrs = ext_attributes,
};
static ssize_t ili_palm_settings_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
return scnprintf(buf, PAGE_SIZE, "%d", ilits->canvas_value);
}
static ssize_t ili_palm_settings_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
int value;
int err = 0;
mutex_lock(&ilits->touch_mutex);
if (count > 2)
return -EINVAL;
if (sscanf(buf, "%d", &value) != 1)
return -EINVAL;
err = count;
if (ili_ic_func_ctrl("canvas", value) < 0)
ILI_ERR("Write canvas enable fail\n");
else
ilits->canvas_value = value;
ILI_INFO("%s: %d\n", __func__, ilits->canvas_value);
mutex_unlock(&ilits->touch_mutex);
return err;
}
static DEVICE_ATTR(palm_settings, S_IRUGO | S_IWUSR | S_IWGRP, ili_palm_settings_show, ili_palm_settings_store);
static int ili_mmi_extend_attribute_group(struct device *dev, struct attribute_group **group)
{
int idx = 0;
ADD_ATTR(palm_settings);
if (idx) {
ext_attributes[idx] = NULL;
*group = &ext_attr_group;
} else
*group = NULL;
return 0;
}
static int ili_mmi_methods_reset(struct device *dev, int type)
{
return 0;
@ -122,6 +197,7 @@ static struct ts_mmi_methods ili_mmi_methods = {
.charger_mode = ili_mmi_charger_mode,
/* Firmware */
.firmware_update = ili_mmi_firmware_update,
.extend_attribute_group = ili_mmi_extend_attribute_group,
/* PM callback */
.pre_resume = ili_mmi_pre_resume,
.post_resume = ili_mmi_post_resume,