2009-01-28 10:24:14

by Henrik Rydberg

[permalink] [raw]
Subject: [PATCH 0/6] input: resend of pending patches

Hi Dmitry,

here are the outstanding input patches.

Cheers,
Henrik

Henrik Rydberg (6):
input: bcm5974: Prepare for a new trackpad header type
input: bcm5974: Add quad-finger tapping
input: bcm5974: Add support for the Macbook 5 (Unibody)
input: bcm5974: Augmented debug information
input: Allow certain EV_ABS events to bypass all filtering
input: Add a detailed multi-touch finger data report protocol (rev2)

drivers/input/input.c | 36 +++++++++++++++
drivers/input/mouse/bcm5974.c | 99 ++++++++++++++++++++++++++++++----------
include/linux/input.h | 29 ++++++++++++
3 files changed, 139 insertions(+), 25 deletions(-)


2009-01-28 10:24:31

by Henrik Rydberg

[permalink] [raw]
Subject: [PATCH 1/6] input: bcm5974: Prepare for a new trackpad header type

The new unibody Macbooks are equipped with an integrated button and
trackpad. The package header of the trackpad interface has changed to
also contain information about the integrated button. This patch
performs the necessary preparations to allow for the new package
header.

Signed-off-by: Henrik Rydberg <[email protected]>
---
drivers/input/mouse/bcm5974.c | 42 ++++++++++++++++++++++------------------
1 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
index 2998a6a..e97462e 100644
--- a/drivers/input/mouse/bcm5974.c
+++ b/drivers/input/mouse/bcm5974.c
@@ -96,13 +96,14 @@ struct bt_data {
u8 rel_y; /* relative y coordinate */
};

-/* trackpad header structure */
-struct tp_header {
- u8 unknown1[16]; /* constants, timers, etc */
- u8 fingers; /* number of fingers on trackpad */
- u8 unknown2[9]; /* constants, timers, etc */
+/* trackpad header types */
+enum tp_type {
+ TYPE1 /* plain trackpad */
};

+/* trackpad finger data offsets */
+#define FINGER_TYPE1 26
+
/* trackpad finger structure */
struct tp_finger {
__le16 origin; /* zero when switching track finger */
@@ -119,11 +120,9 @@ struct tp_finger {
__le16 multi; /* one finger: varies, more fingers: constant */
};

-/* trackpad data structure, empirically at least ten fingers */
-struct tp_data {
- struct tp_header header;
- struct tp_finger finger[16];
-};
+/* trackpad finger data size, empirically at least ten fingers */
+#define SIZEOF_FINGER sizeof(struct tp_finger)
+#define SIZEOF_ALL_FINGERS (16 * SIZEOF_FINGER)

/* device-specific parameters */
struct bcm5974_param {
@@ -139,6 +138,8 @@ struct bcm5974_config {
int bt_ep; /* the endpoint of the button interface */
int bt_datalen; /* data length of the button interface */
int tp_ep; /* the endpoint of the trackpad interface */
+ enum tp_type tp_type; /* type of trackpad interface */
+ int tp_offset; /* offset to trackpad finger data */
int tp_datalen; /* data length of the trackpad interface */
struct bcm5974_param p; /* finger pressure limits */
struct bcm5974_param w; /* finger width limits */
@@ -158,7 +159,7 @@ struct bcm5974 {
struct urb *bt_urb; /* button usb request block */
struct bt_data *bt_data; /* button transferred data */
struct urb *tp_urb; /* trackpad usb request block */
- struct tp_data *tp_data; /* trackpad transferred data */
+ u8 *tp_data; /* trackpad transferred data */
int fingers; /* number of fingers on trackpad */
};

@@ -184,7 +185,7 @@ static const struct bcm5974_config bcm5974_config_table[] = {
USB_DEVICE_ID_APPLE_WELLSPRING_ISO,
USB_DEVICE_ID_APPLE_WELLSPRING_JIS,
0x84, sizeof(struct bt_data),
- 0x81, sizeof(struct tp_data),
+ 0x81, TYPE1, FINGER_TYPE1, FINGER_TYPE1 + SIZEOF_ALL_FINGERS,
{ DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 256 },
{ DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
{ DIM_X, DIM_X / SN_COORD, -4824, 5342 },
@@ -195,7 +196,7 @@ static const struct bcm5974_config bcm5974_config_table[] = {
USB_DEVICE_ID_APPLE_WELLSPRING2_ISO,
USB_DEVICE_ID_APPLE_WELLSPRING2_JIS,
0x84, sizeof(struct bt_data),
- 0x81, sizeof(struct tp_data),
+ 0x81, TYPE1, FINGER_TYPE1, FINGER_TYPE1 + SIZEOF_ALL_FINGERS,
{ DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 256 },
{ DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
{ DIM_X, DIM_X / SN_COORD, -4824, 4824 },
@@ -276,18 +277,20 @@ static int report_bt_state(struct bcm5974 *dev, int size)
static int report_tp_state(struct bcm5974 *dev, int size)
{
const struct bcm5974_config *c = &dev->cfg;
- const struct tp_finger *f = dev->tp_data->finger;
+ const struct tp_finger *f;
struct input_dev *input = dev->input;
- const int fingers = (size - 26) / 28;
- int raw_p, raw_w, raw_x, raw_y;
+ int raw_p, raw_w, raw_x, raw_y, raw_n;
int ptest = 0, origin = 0, nmin = 0, nmax = 0;
int abs_p = 0, abs_w = 0, abs_x = 0, abs_y = 0;

- if (size < 26 || (size - 26) % 28 != 0)
+ if (size < c->tp_offset || (size - c->tp_offset) % SIZEOF_FINGER != 0)
return -EIO;

+ f = (const struct tp_finger *)(dev->tp_data + c->tp_offset);
+ raw_n = (size - c->tp_offset) / SIZEOF_FINGER;
+
/* always track the first finger; when detached, start over */
- if (fingers) {
+ if (raw_n) {
raw_p = raw2int(f->force_major);
raw_w = raw2int(f->size_major);
raw_x = raw2int(f->abs_x);
@@ -307,12 +310,13 @@ static int report_tp_state(struct bcm5974 *dev, int size)
abs_w = int2bound(&c->w, raw_w);
abs_x = int2bound(&c->x, raw_x - c->x.devmin);
abs_y = int2bound(&c->y, c->y.devmax - raw_y);
- for (; f != dev->tp_data->finger + fingers; f++) {
+ while (raw_n--) {
ptest = int2bound(&c->p, raw2int(f->force_major));
if (ptest > PRESSURE_LOW)
nmax++;
if (ptest > PRESSURE_HIGH)
nmin++;
+ f++;
}
}

--
1.5.6.3

2009-01-28 10:24:48

by Henrik Rydberg

[permalink] [raw]
Subject: [PATCH 2/6] input: bcm5974: Add quad-finger tapping

The integrated button on the new unibody Macbooks presents a need to
report explicit four-finger actions. Evidently, the finger pressing
the button is also touching the trackpad, so in order to fully support
three-finger actions, the driver must be able to report four-finger
actions. This patch adds a new button, BTN_TOOL_QUADTAP, which
achieves this.

Signed-off-by: Henrik Rydberg <[email protected]>
---
drivers/input/mouse/bcm5974.c | 4 +++-
include/linux/input.h | 1 +
2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
index e97462e..a170574 100644
--- a/drivers/input/mouse/bcm5974.c
+++ b/drivers/input/mouse/bcm5974.c
@@ -258,6 +258,7 @@ static void setup_events_to_report(struct input_dev *input_dev,
__set_bit(BTN_TOOL_FINGER, input_dev->keybit);
__set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
__set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit);
+ __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit);
__set_bit(BTN_LEFT, input_dev->keybit);
}

@@ -328,7 +329,8 @@ static int report_tp_state(struct bcm5974 *dev, int size)
input_report_key(input, BTN_TOUCH, dev->fingers > 0);
input_report_key(input, BTN_TOOL_FINGER, dev->fingers == 1);
input_report_key(input, BTN_TOOL_DOUBLETAP, dev->fingers == 2);
- input_report_key(input, BTN_TOOL_TRIPLETAP, dev->fingers > 2);
+ input_report_key(input, BTN_TOOL_TRIPLETAP, dev->fingers == 3);
+ input_report_key(input, BTN_TOOL_QUADTAP, dev->fingers > 3);

input_report_abs(input, ABS_PRESSURE, abs_p);
input_report_abs(input, ABS_TOOL_WIDTH, abs_w);
diff --git a/include/linux/input.h b/include/linux/input.h
index 1249a0c..ee5754a 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -445,6 +445,7 @@ struct input_absinfo {
#define BTN_STYLUS2 0x14c
#define BTN_TOOL_DOUBLETAP 0x14d
#define BTN_TOOL_TRIPLETAP 0x14e
+#define BTN_TOOL_QUADTAP 0x14f /* Four fingers on trackpad */

#define BTN_WHEEL 0x150
#define BTN_GEAR_DOWN 0x150
--
1.5.6.3

2009-01-28 10:25:14

by Henrik Rydberg

[permalink] [raw]
Subject: [PATCH 3/6] input: bcm5974: Add support for the Macbook 5 (Unibody)

This patch adds support for the new unibody Macbook, with physically
integrated button and trackpad. A new button, BTN_TOOL_PRESS, is
introduced to allow for non-trivial handling of this device in user
space.

Signed-off-by: Henrik Rydberg <[email protected]>
Tested-by: David M. Lary <[email protected]>
---
drivers/input/mouse/bcm5974.c | 42 +++++++++++++++++++++++++++++++++++++++-
include/linux/input.h | 1 +
2 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
index a170574..f85a296 100644
--- a/drivers/input/mouse/bcm5974.c
+++ b/drivers/input/mouse/bcm5974.c
@@ -51,6 +51,10 @@
#define USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI 0x0230
#define USB_DEVICE_ID_APPLE_WELLSPRING2_ISO 0x0231
#define USB_DEVICE_ID_APPLE_WELLSPRING2_JIS 0x0232
+/* Macbook5,1 (unibody), aka wellspring3 */
+#define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI 0x0236
+#define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO 0x0237
+#define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS 0x0238

#define BCM5974_DEVICE(prod) { \
.match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \
@@ -72,6 +76,10 @@ static const struct usb_device_id bcm5974_table[] = {
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI),
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_ISO),
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_JIS),
+ /* Macbook5,1 */
+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI),
+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ISO),
+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_JIS),
/* Terminating entry */
{}
};
@@ -98,11 +106,19 @@ struct bt_data {

/* trackpad header types */
enum tp_type {
- TYPE1 /* plain trackpad */
+ TYPE1, /* plain trackpad */
+ TYPE2 /* button integrated in trackpad */
};

/* trackpad finger data offsets */
#define FINGER_TYPE1 26
+#define FINGER_TYPE2 30
+
+/* trackpad button data offsets */
+#define BUTTON_TYPE2 15
+
+/* integrated button capability by configuration */
+#define HAS_INTEGRATED_BUTTON(c) (c->tp_type == TYPE2)

/* trackpad finger structure */
struct tp_finger {
@@ -202,6 +218,17 @@ static const struct bcm5974_config bcm5974_config_table[] = {
{ DIM_X, DIM_X / SN_COORD, -4824, 4824 },
{ DIM_Y, DIM_Y / SN_COORD, -172, 4290 }
},
+ {
+ USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI,
+ USB_DEVICE_ID_APPLE_WELLSPRING3_ISO,
+ USB_DEVICE_ID_APPLE_WELLSPRING3_JIS,
+ 0x84, sizeof(struct bt_data),
+ 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
+ { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 },
+ { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
+ { DIM_X, DIM_X / SN_COORD, -4460, 5166 },
+ { DIM_Y, DIM_Y / SN_COORD, -75, 6700 }
+ },
{}
};

@@ -259,6 +286,8 @@ static void setup_events_to_report(struct input_dev *input_dev,
__set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
__set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit);
__set_bit(BTN_TOOL_QUADTAP, input_dev->keybit);
+ if (HAS_INTEGRATED_BUTTON(cfg))
+ __set_bit(BTN_TOOL_PRESS, input_dev->keybit);
__set_bit(BTN_LEFT, input_dev->keybit);
}

@@ -281,7 +310,7 @@ static int report_tp_state(struct bcm5974 *dev, int size)
const struct tp_finger *f;
struct input_dev *input = dev->input;
int raw_p, raw_w, raw_x, raw_y, raw_n;
- int ptest = 0, origin = 0, nmin = 0, nmax = 0;
+ int ptest = 0, origin = 0, ibt = 0, nmin = 0, nmax = 0;
int abs_p = 0, abs_w = 0, abs_x = 0, abs_y = 0;

if (size < c->tp_offset || (size - c->tp_offset) % SIZEOF_FINGER != 0)
@@ -303,6 +332,10 @@ static int report_tp_state(struct bcm5974 *dev, int size)

ptest = int2bound(&c->p, raw_p);
origin = raw2int(f->origin);
+
+ /* set the integrated button if applicable */
+ if (c->tp_type == TYPE2)
+ ibt = raw2int(dev->tp_data[BUTTON_TYPE2]);
}

/* while tracking finger still valid, count all fingers */
@@ -346,6 +379,11 @@ static int report_tp_state(struct bcm5974 *dev, int size)

}

+ if (HAS_INTEGRATED_BUTTON(c)) {
+ input_report_key(input, BTN_TOOL_PRESS, ibt);
+ input_report_key(input, BTN_LEFT, ibt);
+ }
+
input_sync(input);

return 0;
diff --git a/include/linux/input.h b/include/linux/input.h
index ee5754a..ccc8a9b 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -440,6 +440,7 @@ struct input_absinfo {
#define BTN_TOOL_FINGER 0x145
#define BTN_TOOL_MOUSE 0x146
#define BTN_TOOL_LENS 0x147
+#define BTN_TOOL_PRESS 0x148 /* The trackpad is a physical button */
#define BTN_TOUCH 0x14a
#define BTN_STYLUS 0x14b
#define BTN_STYLUS2 0x14c
--
1.5.6.3

2009-01-28 10:25:38

by Henrik Rydberg

[permalink] [raw]
Subject: [PATCH 4/6] input: bcm5974: Augmented debug information

This patch adds more button and finger data to the debug output.

Signed-off-by: Henrik Rydberg <[email protected]>
---
drivers/input/mouse/bcm5974.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
index f85a296..874ae11 100644
--- a/drivers/input/mouse/bcm5974.c
+++ b/drivers/input/mouse/bcm5974.c
@@ -297,6 +297,11 @@ static int report_bt_state(struct bcm5974 *dev, int size)
if (size != sizeof(struct bt_data))
return -EIO;

+ dprintk(7,
+ "bcm5974: button data: %x %x %x %x\n",
+ dev->bt_data->unknown1, dev->bt_data->button,
+ dev->bt_data->rel_x, dev->bt_data->rel_y);
+
input_report_key(dev->input, BTN_LEFT, dev->bt_data->button);
input_sync(dev->input);

@@ -327,8 +332,8 @@ static int report_tp_state(struct bcm5974 *dev, int size)
raw_y = raw2int(f->abs_y);

dprintk(9,
- "bcm5974: raw: p: %+05d w: %+05d x: %+05d y: %+05d\n",
- raw_p, raw_w, raw_x, raw_y);
+ "bcm5974: raw: p: %+05d w: %+05d x: %+05d y: %+05d "
+ "n: %d\n", raw_p, raw_w, raw_x, raw_y, raw_n);

ptest = int2bound(&c->p, raw_p);
origin = raw2int(f->origin);
@@ -374,8 +379,8 @@ static int report_tp_state(struct bcm5974 *dev, int size)

dprintk(8,
"bcm5974: abs: p: %+05d w: %+05d x: %+05d y: %+05d "
- "nmin: %d nmax: %d n: %d\n",
- abs_p, abs_w, abs_x, abs_y, nmin, nmax, dev->fingers);
+ "nmin: %d nmax: %d n: %d ibt: %d\n", abs_p, abs_w,
+ abs_x, abs_y, nmin, nmax, dev->fingers, ibt);

}

--
1.5.6.3

2009-01-28 10:25:57

by Henrik Rydberg

[permalink] [raw]
Subject: [PATCH 5/6] input: Allow certain EV_ABS events to bypass all filtering

With the upcoming multi-touch interface as an example, there is
a need to make certain that all reported events actually get passed
to the event handler. This patch equips the input core with the
ability to bypass all filtering for certain EV_ABS events.

Signed-off-by: Henrik Rydberg <[email protected]>
---
drivers/input/input.c | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index 1730d73..7f9180c 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -29,6 +29,13 @@ MODULE_LICENSE("GPL");

#define INPUT_DEVICES 256

+/*
+ * EV_ABS events which should not be cached are listed here.
+ */
+static __initdata unsigned int input_abs_bypass_init_data[] = {
+ 0
+};
+
static LIST_HEAD(input_dev_list);
static LIST_HEAD(input_handler_list);

@@ -42,6 +49,8 @@ static DEFINE_MUTEX(input_mutex);

static struct input_handler *input_table[8];

+static unsigned long input_abs_bypass[BITS_TO_LONGS(ABS_CNT)];
+
static inline int is_event_supported(unsigned int code,
unsigned long *bm, unsigned int max)
{
@@ -185,6 +194,11 @@ static void input_handle_event(struct input_dev *dev,
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 +1644,19 @@ static const struct file_operations input_fops = {
.open = input_open_file,
};

+static void __init input_init_abs_bypass()
+{
+ 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");
--
1.5.6.3

2009-01-28 10:26:19

by Henrik Rydberg

[permalink] [raw]
Subject: [PATCH 6/6] input: Add a detailed multi-touch finger data report protocol (rev2)

In order to utilize the full power of the new multi-touch devices, a
way to report detailed finger data to user space is needed. This patch
adds a multi-touch (MT) protocol which allows drivers to report details
for an arbitrary number of fingers.

The driver sends a SYN_MT_REPORT event via the input_mt_sync() function
when a complete finger has been reported.

In order to stay compatible with existing applications, the data
reported in a finger packet must not be recognized as single-touch
events. In addition, all finger data must bypass input filtering,
since subsequent events of the same type refer to different fingers.

A set of ABS_MT events with the desired properties are defined. The
events are divided into categories, to allow for partial implementation.
The minimum set consists of ABS_MT_TOUCH_MAJOR, ABS_MT_POSITION_X and
ABS_MT_POSITION_Y, which allows for multiple fingers to be tracked.
If the device supports it, the ABS_MT_WIDTH_MAJOR may be used to provide
the size of the approaching finger. Anisotropy and direction may be
specified with ABS_MT_TOUCH_MINOR, ABS_MT_WIDTH_MINOR and
ABS_MT_ORIENTATION. Devices with more granular information may specify
general shapes as blobs, i.e., as a sequence of rectangular shapes
grouped together by a ABS_MT_BLOB_ID. Finally, the ABS_MT_TOOL_TYPE
may be used to specify whether the touching tool is a finger or a pen.

Signed-off-by: Henrik Rydberg <[email protected]>
---
drivers/input/input.c | 13 +++++++++++++
include/linux/input.h | 27 +++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index 7f9180c..ccf1756 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -33,6 +33,15 @@ MODULE_LICENSE("GPL");
* EV_ABS events which should not be cached are listed here.
*/
static __initdata unsigned int input_abs_bypass_init_data[] = {
+ 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,
0
};

@@ -165,6 +174,10 @@ static void input_handle_event(struct input_dev *dev,
disposition = INPUT_PASS_TO_HANDLERS;
}
break;
+ case SYN_MT_REPORT:
+ dev->sync = 0;
+ disposition = INPUT_PASS_TO_HANDLERS;
+ break;
}
break;

diff --git a/include/linux/input.h b/include/linux/input.h
index ccc8a9b..4799aba 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -106,6 +106,7 @@ struct input_absinfo {

#define SYN_REPORT 0
#define SYN_CONFIG 1
+#define SYN_MT_REPORT 2

/*
* Keys and buttons
@@ -646,6 +647,19 @@ struct input_absinfo {
#define ABS_TOOL_WIDTH 0x1c
#define ABS_VOLUME 0x20
#define ABS_MISC 0x28
+
+#define ABS_MT_TOUCH 0x30 /* Diameter of touching circle */
+#define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */
+#define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis of touching ellipse */
+#define ABS_MT_WIDTH 0x32 /* Diameter of approaching circle */
+#define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */
+#define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis of approaching ellipse */
+#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_MAX 0x3f
#define ABS_CNT (ABS_MAX+1)

@@ -744,6 +758,14 @@ struct input_absinfo {
#define BUS_ATARI 0x1B

/*
+ * MT_TOOL types
+ */
+#define MT_TOOL_FINGER 0
+#define MT_TOOL_PEN 1
+#define MT_TOOL_MAX 9
+#define MT_TOOL_CNT (MT_TOOL_MAX + 1)
+
+/*
* Values describing the status of a force-feedback effect
*/
#define FF_STATUS_STOPPED 0x00
@@ -1312,6 +1334,11 @@ static inline void input_sync(struct input_dev *dev)
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);

static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat)
--
1.5.6.3

2009-01-29 08:30:41

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH 5/6] input: Allow certain EV_ABS events to bypass all filtering

On Wed, 28 Jan 2009 11:23:48 +0100 "Henrik Rydberg" <[email protected]> wrote:

> With the upcoming multi-touch interface as an example, there is
> a need to make certain that all reported events actually get passed
> to the event handler. This patch equips the input core with the
> ability to bypass all filtering for certain EV_ABS events.

This patch doesn't include Randy's fix, below.

It's unchanged from v1, so I did nothing with this one.


From: Randy Dunlap <[email protected]>

Fix function args build warning:

mmotm-2008-1230-1605/drivers/input/input.c:1661: warning: function declaration isn't a prototype

Signed-off-by: Randy Dunlap <[email protected]>
Cc: Dmitry Torokhov <[email protected]>
Cc: Henrik Rydberg <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
---

drivers/input/input.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN drivers/input/input.c~es-input-allow-certain-ev_abs-events-to-bypass-all-filtering-fix drivers/input/input.c
--- a/drivers/input/input.c~es-input-allow-certain-ev_abs-events-to-bypass-all-filtering-fix
+++ a/drivers/input/input.c
@@ -1644,7 +1644,7 @@ static const struct file_operations inpu
.open = input_open_file,
};

-static void __init input_init_abs_bypass()
+static void __init input_init_abs_bypass(void)
{
const unsigned int *p;
for (p = input_abs_bypass_init_data; *p; p++)
_

2009-01-29 08:34:12

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH 1/6] input: bcm5974: Prepare for a new trackpad header type

On Wed, 28 Jan 2009 11:23:44 +0100 "Henrik Rydberg" <[email protected]> wrote:

> static int report_tp_state(struct bcm5974 *dev, int size)
> {
> const struct bcm5974_config *c = &dev->cfg;
> - const struct tp_finger *f = dev->tp_data->finger;
> + const struct tp_finger *f;
> struct input_dev *input = dev->input;
> - const int fingers = (size - 26) / 28;
> - int raw_p, raw_w, raw_x, raw_y;
> + int raw_p, raw_w, raw_x, raw_y, raw_n;
> int ptest = 0, origin = 0, nmin = 0, nmax = 0;
> int abs_p = 0, abs_w = 0, abs_x = 0, abs_y = 0;
>
> - if (size < 26 || (size - 26) % 28 != 0)
> + if (size < c->tp_offset || (size - c->tp_offset) % SIZEOF_FINGER != 0)
> return -EIO;
>
> + f = (const struct tp_finger *)(dev->tp_data + c->tp_offset);

Is there anything which guarantees that `f' is sufficiently aligned?
If not, the code might cause unaligned exceptions on some
architectures?

2009-01-29 22:31:17

by Henrik Rydberg

[permalink] [raw]
Subject: Re: [PATCH 1/6] input: bcm5974: Prepare for a new trackpad header type

Andrew Morton wrote:
> On Wed, 28 Jan 2009 11:23:44 +0100 "Henrik Rydberg" <[email protected]> wrote:

Thanks for taking care of the patches, and for spotting the surplus
patches 5/6 and 6/6 - my mistake.

>> + f = (const struct tp_finger *)(dev->tp_data + c->tp_offset);
>
> Is there anything which guarantees that `f' is sufficiently aligned?
> If not, the code might cause unaligned exceptions on some
> architectures?
>

I believe it is - I will send a patch in reply to this message that
ought to make it clearer.

Thanks,
Henrik

2009-01-30 05:54:59

by Joonyoung Shim

[permalink] [raw]
Subject: Re: [PATCH 6/6] input: Add a detailed multi-touch finger data report protocol (rev2)

2009/1/28 Henrik Rydberg <[email protected]>:
> In order to utilize the full power of the new multi-touch devices, a
> way to report detailed finger data to user space is needed. This patch
> adds a multi-touch (MT) protocol which allows drivers to report details
> for an arbitrary number of fingers.
>
> The driver sends a SYN_MT_REPORT event via the input_mt_sync() function
> when a complete finger has been reported.
>
> In order to stay compatible with existing applications, the data
> reported in a finger packet must not be recognized as single-touch
> events. In addition, all finger data must bypass input filtering,
> since subsequent events of the same type refer to different fingers.
>
> A set of ABS_MT events with the desired properties are defined. The
> events are divided into categories, to allow for partial implementation.
> The minimum set consists of ABS_MT_TOUCH_MAJOR, ABS_MT_POSITION_X and
> ABS_MT_POSITION_Y, which allows for multiple fingers to be tracked.
> If the device supports it, the ABS_MT_WIDTH_MAJOR may be used to provide
> the size of the approaching finger. Anisotropy and direction may be
> specified with ABS_MT_TOUCH_MINOR, ABS_MT_WIDTH_MINOR and
> ABS_MT_ORIENTATION. Devices with more granular information may specify
> general shapes as blobs, i.e., as a sequence of rectangular shapes
> grouped together by a ABS_MT_BLOB_ID. Finally, the ABS_MT_TOOL_TYPE
> may be used to specify whether the touching tool is a finger or a pen.


Hi Henrik,

I want to know how calculates touch coordinates at user space using a
set of ABS_MT.
If i do dual touch, can i get correct two coordinates through ABS_MT report?


Joonyoung

2009-01-30 06:11:15

by Joonyoung Shim

[permalink] [raw]
Subject: Re: [PATCH 6/6] input: Add a detailed multi-touch finger data report protocol (rev2)

2009/1/28 Henrik Rydberg <[email protected]>:
> In order to utilize the full power of the new multi-touch devices, a
> way to report detailed finger data to user space is needed. This patch
> adds a multi-touch (MT) protocol which allows drivers to report details
> for an arbitrary number of fingers.
>
> The driver sends a SYN_MT_REPORT event via the input_mt_sync() function
> when a complete finger has been reported.
>
> In order to stay compatible with existing applications, the data
> reported in a finger packet must not be recognized as single-touch
> events. In addition, all finger data must bypass input filtering,
> since subsequent events of the same type refer to different fingers.
>
> A set of ABS_MT events with the desired properties are defined. The
> events are divided into categories, to allow for partial implementation.
> The minimum set consists of ABS_MT_TOUCH_MAJOR, ABS_MT_POSITION_X and
> ABS_MT_POSITION_Y, which allows for multiple fingers to be tracked.
> If the device supports it, the ABS_MT_WIDTH_MAJOR may be used to provide
> the size of the approaching finger. Anisotropy and direction may be
> specified with ABS_MT_TOUCH_MINOR, ABS_MT_WIDTH_MINOR and
> ABS_MT_ORIENTATION. Devices with more granular information may specify
> general shapes as blobs, i.e., as a sequence of rectangular shapes
> grouped together by a ABS_MT_BLOB_ID. Finally, the ABS_MT_TOOL_TYPE
> may be used to specify whether the touching tool is a finger or a pen.
>

Hi Henrik,

Sorry for multiple posts.

I want to know how calculates touch coordinates at user space using a
set of ABS_MT.
If i do dual touch, can i get correct two coordinates through ABS_MT report?


Joonyoung

2009-01-30 13:10:32

by Henrik Rydberg

[permalink] [raw]
Subject: Re: [PATCH 6/6] input: Add a detailed multi-touch finger data report protocol (rev2)

Joon Young Shim wrote:
> 2009/1/28 Henrik Rydberg <[email protected]>:
[snip]
>
> Hi Henrik,
>
> Sorry for multiple posts.
>
> I want to know how calculates touch coordinates at user space using a
> set of ABS_MT.
> If i do dual touch, can i get correct two coordinates through ABS_MT report?

The coordinates for the two fingers are sent from the driver in sequence
as two separate finger packets. What then happens with it depends on the
kind of application. For normal desktop usage, the packets are read from
the input device by the multitouch X driver (a modified version of the
synaptics driver), which does finger matching and transforms the
messages into gestures, reported as X events. It is of course also
possible to read the input device directly. It goes without saying that
further development is needed before the multitouch X driver hits the
repos, but none of this can really become reality without basic support
in the kernel.

Henrik

2009-04-27 22:51:47

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH 6/6] input: Add a detailed multi-touch finger data report protocol (rev2)

Hi Henrik,

On Wed, Jan 28, 2009 at 11:23:49AM +0100, Henrik Rydberg wrote:
> +
> +#define ABS_MT_TOUCH 0x30 /* Diameter of touching circle */
> +#define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching
> ellipse */

It looks like we are overriding the same event code to trasnmit 2
slightly different kinds of data. I Am concerned that people would get
confused, maybe we should get rid of ABS_MT_TOUCH and either require
drvices always transmit ABS_MT_TOUCH_MAJOR and ABS_MT_TOUCH_MINOR or
document that for curcular objects ABS_MT_TOUCH_MINOR may be omitted.

> +#define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis of touching
> ellipse */
> +#define ABS_MT_WIDTH 0x32 /* Diameter of approaching
> circle */
> +#define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching
> ellipse */
> +#define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis of approaching
> ellipse */

Same here...

> +#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_MAX 0x3f
> #define ABS_CNT (ABS_MAX+1)
>
> @@ -744,6 +758,14 @@ struct input_absinfo {
> #define BUS_ATARI 0x1B
>
> /*
> + * MT_TOOL types
> + */
> +#define MT_TOOL_FINGER 0
> +#define MT_TOOL_PEN 1
> +#define MT_TOOL_MAX 9
> +#define MT_TOOL_CNT (MT_TOOL_MAX + 1)

MT_TOOL_FINGER/MT_TOOL_PEN are documented values of ABS_MT_TOOL_TYPE, so
I don't understand why we need MT_TOOL_MAX/MT_TOOL_CNT definitions.

Thanks.

--
Dmitry

2009-04-28 08:01:20

by Henrik Rydberg

[permalink] [raw]
Subject: Re: [PATCH 6/6] input: Add a detailed multi-touch finger data report protocol (rev2)

Dmitry Torokhov wrote:
> Hi Henrik,
>
> On Wed, Jan 28, 2009 at 11:23:49AM +0100, Henrik Rydberg wrote:
>> +
>> +#define ABS_MT_TOUCH 0x30 /* Diameter of touching circle */
>> +#define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching
>> ellipse */
>
> It looks like we are overriding the same event code to trasnmit 2
> slightly different kinds of data. I Am concerned that people would get
> confused, maybe we should get rid of ABS_MT_TOUCH and either require
> drvices always transmit ABS_MT_TOUCH_MAJOR and ABS_MT_TOUCH_MINOR or
> document that for curcular objects ABS_MT_TOUCH_MINOR may be omitted.

Done.

>> @@ -744,6 +758,14 @@ struct input_absinfo {
>> #define BUS_ATARI 0x1B
>>
>> /*
>> + * MT_TOOL types
>> + */
>> +#define MT_TOOL_FINGER 0
>> +#define MT_TOOL_PEN 1
>> +#define MT_TOOL_MAX 9
>> +#define MT_TOOL_CNT (MT_TOOL_MAX + 1)
>
> MT_TOOL_FINGER/MT_TOOL_PEN are documented values of ABS_MT_TOOL_TYPE, so
> I don't understand why we need MT_TOOL_MAX/MT_TOOL_CNT definitions.

Ah! It is a remnant from a much earlier version which used a separate MT
event type. It slipped through, my bad. Remedied. Thanks.

Revision three of the patch has been sent.

Cheers,
Henrik