diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 32e1fea5ce02..8275f49db276 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -1368,4 +1368,13 @@ config TOUCHSCREEN_SYNAPTICS_TCM To compile this driver as a module, choose M here: the module will be called synaptics_tcm. +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. + endif diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index cb7f3843f3ff..25c8efc14c01 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -115,3 +115,4 @@ obj-$(CONFIG_TOUCHSCREEN_FTS) += focaltech_touch/ obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_TCM) += synaptics_tcm/ obj-$(CONFIG_TOUCHSCREEN_NT36XXX) += nt36xxx/ obj-$(CONFIG_TOUCHSCREEN_XIAOMI_TOUCHFEATURE) += xiaomi/ +obj-$(CONFIG_TOUCHSCREEN_COMMON) += tp_common.o 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);