From cadbe2358ed1191c73b0d754a0c280e9de9b7359 Mon Sep 17 00:00:00 2001 From: dianlujitao Date: Wed, 19 Feb 2020 16:48:25 +0800 Subject: input: touchscreen: Add an interface to expose TP features to userspace * Needs to implement and register ops from TP driver * Access them via /sys/touchpanel/* * Export capacitive keys status Change-Id: I2baa61c6055ca6f6207ac0d6f627fe03048ccfb6 --- drivers/input/touchscreen/Kconfig | 9 +++++++++ drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/tp_common.c | 29 +++++++++++++++++++++++++++++ include/linux/input/tp_common.h | 15 +++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 drivers/input/touchscreen/tp_common.c create mode 100644 include/linux/input/tp_common.h diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 4164678c225d..9a52f260acb4 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -1273,6 +1273,15 @@ config TOUCHSCREEN_ST If unsure, say N. +config TOUCHSCREEN_COMMON + bool "Common touchscreen interface to interact with userspace" + default y + help + Say Y here if you want to control touchpanel features via + /sys/touchpanel. + + If unsure, say N. + config TOUCHSCREEN_FOCAL_FT8719 bool "Focaltech Touchscreen" depends on I2C diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 5102c5ca1063..875020e301db 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -104,6 +104,7 @@ obj-$(CONFIG_TOUCHSCREEN_ZFORCE) += zforce_ts.o obj-$(CONFIG_TOUCHSCREEN_COLIBRI_VF50) += colibri-vf50-ts.o obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023) += rohm_bu21023.o obj-$(CONFIG_TOUCHSCREEN_ST) += st/ +obj-$(CONFIG_TOUCHSCREEN_COMMON) += tp_common.o # HMI_L6653_A01 obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_DSX_E7S) += synaptics_dsx_e7s/ diff --git a/drivers/input/touchscreen/tp_common.c b/drivers/input/touchscreen/tp_common.c new file mode 100644 index 000000000000..194a03e06aa8 --- /dev/null +++ b/drivers/input/touchscreen/tp_common.c @@ -0,0 +1,29 @@ +#include + +bool capacitive_keys_enabled; +struct kobject *touchpanel_kobj; + +#define TS_ENABLE_FOPS(type) \ + int tp_common_set_##type##_ops(struct tp_common_ops *ops) \ + { \ + static struct kobj_attribute kattr = \ + __ATTR(type, (S_IWUSR | S_IRUGO), NULL, NULL); \ + kattr.show = ops->show; \ + kattr.store = ops->store; \ + return sysfs_create_file(touchpanel_kobj, &kattr.attr); \ + } + +TS_ENABLE_FOPS(capacitive_keys) +TS_ENABLE_FOPS(double_tap) +TS_ENABLE_FOPS(reversed_keys) + +static int __init tp_common_init(void) +{ + touchpanel_kobj = kobject_create_and_add("touchpanel", NULL); + if (!touchpanel_kobj) + return -ENOMEM; + + return 0; +} + +core_initcall(tp_common_init); diff --git a/include/linux/input/tp_common.h b/include/linux/input/tp_common.h new file mode 100644 index 000000000000..4b038a579fe3 --- /dev/null +++ b/include/linux/input/tp_common.h @@ -0,0 +1,15 @@ +#include + +extern bool capacitive_keys_enabled; +extern struct kobject *touchpanel_kobj; + +struct tp_common_ops { + ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr, + char *buf); + ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t count); +}; + +int tp_common_set_capacitive_keys_ops(struct tp_common_ops *ops); +int tp_common_set_double_tap_ops(struct tp_common_ops *ops); +int tp_common_set_reversed_keys_ops(struct tp_common_ops *ops); -- cgit v1.2.3