29内核输入子系统多点上报机制实现 .
公告:CSDN 搜索第二版正式上线! Hadoop与大数据精彩议题发布 2000元大奖征异构开发博文
CSDN博客频道搬家功能改版正式上线! 【免费】解读海外市场营销奥秘 CSDN博客频道推出TAG功能
CSDN博客频道搬家功能改版正式上线! 【免费】解读海外市场营销奥秘 CSDN博客频道推出TAG功能
电容屏被广泛使用,多点触摸机制也随之发展,可惜29内核不支持多点上报,30以后内核才支持。
特此记录移植过程。
1、修改include/linux/input.h
- Index: include/linux/input.h
- ===================================================================
- --- include/linux/input.h (revision 1550)
- +++ include/linux/input.h (working copy)
- @@ -106,6 +106,7 @@
- #define SYN_REPORT 0
- #define SYN_CONFIG 1
- +#define SYN_MT_REPORT 2
- /*
- * Keys and buttons
- @@ -644,6 +645,18 @@
- #define ABS_TOOL_WIDTH 0x1c
- #define ABS_VOLUME 0x20
- #define ABS_MISC 0x28
- +
- +#define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */
- +#define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */
- +#define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */
- +#define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */
- +#define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */
- +#define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */
- +#define ABS_MT_POSITION_Y 0x36 /* Center Y ellipse position */
- +#define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */
- +#define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */
- +#define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */
- +
- #define ABS_MAX 0x3f
- #define ABS_CNT (ABS_MAX+1)
- @@ -742,6 +755,12 @@
- #define BUS_ATARI 0x1B
- /*
- + * MT_TOOL types
- + */
- +#define MT_TOOL_FINGER 0
- +#define MT_TOOL_PEN 1
- +
- +/*
- * Values describing the status of a force-feedback effect
- */
- #define FF_STATUS_STOPPED 0x00
- @@ -1310,6 +1329,11 @@
- input_event(dev, EV_SYN, SYN_REPORT, 0);
- }
- +static inline void input_mt_sync(struct input_dev *dev)
- +{
- + input_event(dev, EV_SYN, SYN_MT_REPORT, 0);
- +}
- +
- void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code);
2、修改drivers/input/input.c
- Index: drivers/input/input.c
- ===================================================================
- --- drivers/input/input.c (revision 1550)
- +++ drivers/input/input.c (working copy)
- @@ -29,6 +29,25 @@
- #define INPUT_DEVICES 256
- +/*
- + * EV_ABS events which should not be cached are listed here.
- + */
- +static unsigned int input_abs_bypass_init_data[] __initdata = {
- + ABS_MT_TOUCH_MAJOR,
- + ABS_MT_TOUCH_MINOR,
- + ABS_MT_WIDTH_MAJOR,
- + ABS_MT_WIDTH_MINOR,
- + ABS_MT_ORIENTATION,
- + ABS_MT_POSITION_X,
- + ABS_MT_POSITION_Y,
- + ABS_MT_TOOL_TYPE,
- + ABS_MT_BLOB_ID,
- + ABS_MT_TRACKING_ID,
- + 0
- +};
- +static unsigned long input_abs_bypass[BITS_TO_LONGS(ABS_CNT)];
- +
- +
- static LIST_HEAD(input_dev_list);
- static LIST_HEAD(input_handler_list);
- @@ -149,13 +168,17 @@
- case SYN_CONFIG:
- disposition = INPUT_PASS_TO_ALL;
- break;
- -
- +
- case SYN_REPORT:
- if (!dev->sync) {
- dev->sync = 1;
- disposition = INPUT_PASS_TO_HANDLERS;
- }
- break;
- + case SYN_MT_REPORT:
- + dev->sync = 0;
- + disposition = INPUT_PASS_TO_HANDLERS;
- + break;
- }
- break;
- @@ -185,6 +208,11 @@
- case EV_ABS:
- if (is_event_supported(code, dev->absbit, ABS_MAX)) {
- + if (test_bit(code, input_abs_bypass)) {
- + disposition = INPUT_PASS_TO_HANDLERS;
- + break;
- + }
- +
- value = input_defuzz_abs_event(value,
- dev->abs[code], dev->absfuzz[code]);
- @@ -1630,10 +1658,20 @@
- .open = input_open_file,
- };
- +static void __init input_init_abs_bypass(void)
- +{
- + const unsigned int *p;
- +
- + for (p = input_abs_bypass_init_data; *p; p++)
- + input_abs_bypass[BIT_WORD(*p)] |= BIT_MASK(*p);
- +}
- +
- static int __init input_init(void)
- {
- int err;
- + input_init_abs_bypass();
- +
- err = class_register(&input_class);
- if (err) {
- printk(KERN_ERR "input: unable to register input_dev class/n");
3、输入子系统的初始化
- input_dev->evbit[0] = BIT(EV_SYN) | BIT(EV_KEY) | BIT(EV_ABS);
- input_dev->absbit[0] =
- BIT_MASK(ABS_X) |
- BIT_MASK(ABS_Y) |
- BIT_MASK(ABS_MT_TOUCH_MAJOR) |
- BIT_MASK(ABS_MT_WIDTH_MAJOR) |
- BIT_MASK(ABS_MT_POSITION_X) |
- BIT_MASK(ABS_MT_POSITION_Y) |
- BIT_MASK(ABS_MT_TRACKING_ID);
4、子系统上报
- input_report_key(ts->input, ABS_MT_TRACKING_ID, touch_num);
- input_report_abs(ts->input, ABS_MT_POSITION_X, mxt224_datablock.T_point[touch_num].x);
- input_report_abs(ts->input, ABS_MT_POSITION_Y, mxt224_datablock.T_point[touch_num].y);
- input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, mxt224_datablock.T_point[touch_num].amplitude);
- input_report_abs(ts->input, ABS_MT_WIDTH_MAJOR, mxt224_datablock.T_point[touch_num].area);
- input_report_abs(ts->input, ABS_PRESSURE,mxt224_datablock.T_gesture[touch_num].value);
- /*input_report_key(ts->input, BTN_TOUCH, 1);*/
- input_mt_sync(ts->input);
注: 原文出处 http://blog.csdn.net/tjd0227/article/details/5669620