drivers: 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
This commit is contained in:
parent
10e52e039e
commit
443f2fb5a8
@ -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
|
||||
|
@ -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
|
||||
|
29
drivers/input/touchscreen/tp_common.c
Normal file
29
drivers/input/touchscreen/tp_common.c
Normal file
@ -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);
|
15
include/linux/input/tp_common.h
Normal file
15
include/linux/input/tp_common.h
Normal file
@ -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);
|
Loading…
Reference in New Issue
Block a user