summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordianlujitao <dianlujitao@lineageos.org>2020-02-19 16:48:25 +0800
committerMichael Bestas <mkbestas@lineageos.org>2020-05-01 18:21:37 +0300
commitcadbe2358ed1191c73b0d754a0c280e9de9b7359 (patch)
tree1b25a5ced67abfe08aa848197b04b22bf3a20658
parentf93cd93934503ff4d68fa72c9abadeb9a0df4a91 (diff)
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
-rw-r--r--drivers/input/touchscreen/Kconfig9
-rw-r--r--drivers/input/touchscreen/Makefile1
-rw-r--r--drivers/input/touchscreen/tp_common.c29
-rw-r--r--include/linux/input/tp_common.h15
4 files changed, 54 insertions, 0 deletions
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 <linux/input/tp_common.h>
+
+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 <linux/kobject.h>
+
+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);