Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/dtor/input

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
  Input: document the multi-touch (MT) protocol
  Input: add detailed multi-touch finger data report protocol
  Input: allow certain EV_ABS events to bypass all filtering
  Input: bcm5974 - add documentation for the driver
  Input: bcm5974 - augment debug information
  Input: bcm5974 - Add support for the Macbook 5 (Unibody)
  Input: bcm5974 - add quad-finger tapping
  Input: bcm5974 - prepare for a new trackpad header type
  Input: appletouch - fix DMA to/from stack buffer
  Input: wacom - fix TabletPC touch bug
  Input: lifebook - add DMI entry for Fujitsu B-2130
  Input: ALPS - add signature for Toshiba Satellite Pro M10
  Input: elantech - make sure touchpad is really in absolute mode
  Input: elantech - provide a workaround for jumpy cursor on firmware 2.34
  Input: ucb1400 - use disable_irq_nosync() in irq handler
  Input: tsc2007 - use disable_irq_nosync() in irq handler
  Input: sa1111ps2 - use disable_irq_nosync() in irq handlers
  Input: omap-keypad - use disable_irq_nosync() in irq handler
  • Loading branch information
Linus Torvalds committed May 2, 2009
2 parents f75e674 + eacaad0 commit 8c0c3f7
Show file tree
Hide file tree
Showing 16 changed files with 446 additions and 51 deletions.
65 changes: 65 additions & 0 deletions Documentation/input/bcm5974.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
BCM5974 Driver (bcm5974)
------------------------
Copyright (C) 2008-2009 Henrik Rydberg <rydberg@euromail.se>

The USB initialization and package decoding was made by Scott Shawcroft as
part of the touchd user-space driver project:
Copyright (C) 2008 Scott Shawcroft (scott.shawcroft@gmail.com)

The BCM5974 driver is based on the appletouch driver:
Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com)
Copyright (C) 2005 Johannes Berg (johannes@sipsolutions.net)
Copyright (C) 2005 Stelian Pop (stelian@popies.net)
Copyright (C) 2005 Frank Arnold (frank@scirocco-5v-turbo.de)
Copyright (C) 2005 Peter Osterlund (petero2@telia.com)
Copyright (C) 2005 Michael Hanselmann (linux-kernel@hansmi.ch)
Copyright (C) 2006 Nicolas Boichat (nicolas@boichat.ch)

This driver adds support for the multi-touch trackpad on the new Apple
Macbook Air and Macbook Pro laptops. It replaces the appletouch driver on
those computers, and integrates well with the synaptics driver of the Xorg
system.

Known to work on Macbook Air, Macbook Pro Penryn and the new unibody
Macbook 5 and Macbook Pro 5.

Usage
-----

The driver loads automatically for the supported usb device ids, and
becomes available both as an event device (/dev/input/event*) and as a
mouse via the mousedev driver (/dev/input/mice).

USB Race
--------

The Apple multi-touch trackpads report both mouse and keyboard events via
different interfaces of the same usb device. This creates a race condition
with the HID driver, which, if not told otherwise, will find the standard
HID mouse and keyboard, and claim the whole device. To remedy, the usb
product id must be listed in the mouse_ignore list of the hid driver.

Debug output
------------

To ease the development for new hardware version, verbose packet output can
be switched on with the debug kernel module parameter. The range [1-9]
yields different levels of verbosity. Example (as root):

echo -n 9 > /sys/module/bcm5974/parameters/debug

tail -f /var/log/debug

echo -n 0 > /sys/module/bcm5974/parameters/debug

Trivia
------

The driver was developed at the ubuntu forums in June 2008 [1], and now has
a more permanent home at bitmath.org [2].

Links
-----

[1] http://ubuntuforums.org/showthread.php?t=840040
[2] http://http://bitmath.org/code/
140 changes: 140 additions & 0 deletions Documentation/input/multi-touch-protocol.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
Multi-touch (MT) Protocol
-------------------------
Copyright (C) 2009 Henrik Rydberg <rydberg@euromail.se>


Introduction
------------

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 document
describes the multi-touch (MT) protocol which allows kernel drivers to
report details for an arbitrary number of fingers.


Usage
-----

Anonymous finger details are sent sequentially as separate packets of ABS
events. Only the ABS_MT events are recognized as part of a finger
packet. The end of a packet is marked by calling the input_mt_sync()
function, which generates a SYN_MT_REPORT event. The end of multi-touch
transfer is marked by calling the usual input_sync() function.

A set of ABS_MT events with the desired properties is 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 an
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 or something else.


Event Semantics
---------------

The word "contact" is used to describe a tool which is in direct contact
with the surface. A finger, a pen or a rubber all classify as contacts.

ABS_MT_TOUCH_MAJOR

The length of the major axis of the contact. The length should be given in
surface units. If the surface has an X times Y resolution, the largest
possible value of ABS_MT_TOUCH_MAJOR is sqrt(X^2 + Y^2), the diagonal.

ABS_MT_TOUCH_MINOR

The length, in surface units, of the minor axis of the contact. If the
contact is circular, this event can be omitted.

ABS_MT_WIDTH_MAJOR

The length, in surface units, of the major axis of the approaching
tool. This should be understood as the size of the tool itself. The
orientation of the contact and the approaching tool are assumed to be the
same.

ABS_MT_WIDTH_MINOR

The length, in surface units, of the minor axis of the approaching
tool. Omit if circular.

The above four values can be used to derive additional information about
the contact. The ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR approximates
the notion of pressure. The fingers of the hand and the palm all have
different characteristic widths [1].

ABS_MT_ORIENTATION

The orientation of the ellipse. The value should describe half a revolution
clockwise around the touch center. The scale of the value is arbitrary, but
zero should be returned for an ellipse aligned along the Y axis of the
surface. As an example, an index finger placed straight onto the axis could
return zero orientation, something negative when twisted to the left, and
something positive when twisted to the right. This value can be omitted if
the touching object is circular, or if the information is not available in
the kernel driver.

ABS_MT_POSITION_X

The surface X coordinate of the center of the touching ellipse.

ABS_MT_POSITION_Y

The surface Y coordinate of the center of the touching ellipse.

ABS_MT_TOOL_TYPE

The type of approaching tool. A lot of kernel drivers cannot distinguish
between different tool types, such as a finger or a pen. In such cases, the
event should be omitted. The protocol currently supports MT_TOOL_FINGER and
MT_TOOL_PEN [2].

ABS_MT_BLOB_ID

The BLOB_ID groups several packets together into one arbitrarily shaped
contact. This is a low-level anonymous grouping, and should not be confused
with the high-level contactID, explained below. Most kernel drivers will
not have this capability, and can safely omit the event.


Finger Tracking
---------------

The kernel driver should generate an arbitrary enumeration of the set of
anonymous contacts currently on the surface. The order in which the packets
appear in the event stream is not important.

The process of finger tracking, i.e., to assign a unique contactID to each
initiated contact on the surface, is left to user space; preferably the
multi-touch X driver [3]. In that driver, the contactID stays the same and
unique until the contact vanishes (when the finger leaves the surface). The
problem of assigning a set of anonymous fingers to a set of identified
fingers is a euclidian bipartite matching problem at each event update, and
relies on a sufficiently rapid update rate.

Notes
-----

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.

The first kernel driver to utilize the MT protocol is the bcm5974 driver,
where examples can be found.

[1] With the extension ABS_MT_APPROACH_X and ABS_MT_APPROACH_Y, the
difference between the contact position and the approaching tool position
could be used to derive tilt.
[2] The list can of course be extended.
[3] The multi-touch X driver is currently in the prototyping stage. At the
time of writing (April 2009), the MT protocol is not yet merged, and the
prototype implements finger matching, basic mouse support and two-finger
scrolling. The project aims at improving the quality of current multi-touch
functionality available in the synaptics X driver, and in addition
implement more advanced gestures.
36 changes: 36 additions & 0 deletions drivers/input/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ MODULE_LICENSE("GPL");

#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,
0
};
static unsigned long input_abs_bypass[BITS_TO_LONGS(ABS_CNT)];

static LIST_HEAD(input_dev_list);
static LIST_HEAD(input_handler_list);

Expand Down Expand Up @@ -161,6 +178,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;

Expand Down Expand Up @@ -192,6 +213,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]);

Expand Down Expand Up @@ -1634,10 +1660,20 @@ static const struct file_operations input_fops = {
.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");
Expand Down
16 changes: 14 additions & 2 deletions drivers/input/keyboard/omap-keypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,20 @@ static irqreturn_t omap_kp_interrupt(int irq, void *dev_id)
/* disable keyboard interrupt and schedule for handling */
if (cpu_is_omap24xx()) {
int i;
for (i = 0; i < omap_kp->rows; i++)
disable_irq(gpio_to_irq(row_gpios[i]));

for (i = 0; i < omap_kp->rows; i++) {
int gpio_irq = gpio_to_irq(row_gpios[i]);
/*
* The interrupt which we're currently handling should
* be disabled _nosync() to avoid deadlocks waiting
* for this handler to complete. All others should
* be disabled the regular way for SMP safety.
*/
if (gpio_irq == irq)
disable_irq_nosync(gpio_irq);
else
disable_irq(gpio_irq);
}
} else
/* disable keyboard interrupt and schedule for handling */
omap_writew(1, OMAP_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
Expand Down
1 change: 1 addition & 0 deletions drivers/input/mouse/alps.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#define ALPS_FW_BK_2 0x40

static const struct alps_model_info alps_model_data[] = {
{ { 0x32, 0x02, 0x14 }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Toshiba Salellite Pro M10 */
{ { 0x33, 0x02, 0x0a }, 0x88, 0xf8, ALPS_OLDPROTO }, /* UMAX-530T */
{ { 0x53, 0x02, 0x0a }, 0xf8, 0xf8, 0 },
{ { 0x53, 0x02, 0x14 }, 0xf8, 0xf8, 0 },
Expand Down
24 changes: 18 additions & 6 deletions drivers/input/mouse/appletouch.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,23 +255,31 @@ MODULE_PARM_DESC(debug, "Activate debugging output");
*/
static int atp_geyser_init(struct usb_device *udev)
{
char data[8];
char *data;
int size;
int i;
int ret;

data = kmalloc(8, GFP_KERNEL);
if (!data) {
err("Out of memory");
return -ENOMEM;
}

size = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
ATP_GEYSER_MODE_READ_REQUEST_ID,
USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
ATP_GEYSER_MODE_REQUEST_VALUE,
ATP_GEYSER_MODE_REQUEST_INDEX, &data, 8, 5000);
ATP_GEYSER_MODE_REQUEST_INDEX, data, 8, 5000);

if (size != 8) {
dprintk("atp_geyser_init: read error\n");
for (i = 0; i < 8; i++)
dprintk("appletouch[%d]: %d\n", i, data[i]);

err("Failed to read mode from device.");
return -EIO;
ret = -EIO;
goto out_free;
}

/* Apply the mode switch */
Expand All @@ -281,17 +289,21 @@ static int atp_geyser_init(struct usb_device *udev)
ATP_GEYSER_MODE_WRITE_REQUEST_ID,
USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
ATP_GEYSER_MODE_REQUEST_VALUE,
ATP_GEYSER_MODE_REQUEST_INDEX, &data, 8, 5000);
ATP_GEYSER_MODE_REQUEST_INDEX, data, 8, 5000);

if (size != 8) {
dprintk("atp_geyser_init: write error\n");
for (i = 0; i < 8; i++)
dprintk("appletouch[%d]: %d\n", i, data[i]);

err("Failed to request geyser raw mode");
return -EIO;
ret = -EIO;
goto out_free;
}
return 0;
ret = 0;
out_free:
kfree(data);
return ret;
}

/*
Expand Down
Loading

0 comments on commit 8c0c3f7

Please sign in to comment.