1 From: Dan Streetman <ddstreet@ieee.org>
2 Subject: Input: usbtouchscreen - allow reporting calibrated data
3 Patch-mainline: queued in input tree, will be in 2.6.29
6 Input: usbtouchscreen - allow reporting calibrated data
8 This patch adds a module parameter to report either the raw
9 coordinate data or the hardware-calibrated coordinate data for
10 MicroTouch/3M touchscreens. The default is set to the raw
11 coordinates for backwards compatibilty.
13 Signed-off-by: Dan Streetman <ddstreet@ieee.org>
14 Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
15 Signed-off-by: Jiri Kosina <jkosina@suse.cz>
18 diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
19 index 5080b26..6d27a1d 100644
20 --- a/drivers/input/touchscreen/usbtouchscreen.c
21 +++ b/drivers/input/touchscreen/usbtouchscreen.c
22 @@ -60,6 +60,10 @@ static int swap_xy;
23 module_param(swap_xy, bool, 0644);
24 MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
26 +static int hwcalib_xy;
27 +module_param(hwcalib_xy, bool, 0644);
28 +MODULE_PARM_DESC(hwcalib_xy, "If set hw-calibrated X/Y are used if available");
30 /* device specifc data/functions */
32 struct usbtouch_device_info {
33 @@ -260,8 +264,13 @@ static int panjit_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
35 static int mtouch_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
37 - dev->x = (pkt[8] << 8) | pkt[7];
38 - dev->y = (pkt[10] << 8) | pkt[9];
40 + dev->x = (pkt[4] << 8) | pkt[3];
41 + dev->y = 0xffff - ((pkt[6] << 8) | pkt[5]);
43 + dev->x = (pkt[8] << 8) | pkt[7];
44 + dev->y = (pkt[10] << 8) | pkt[9];
46 dev->touch = (pkt[2] & 0x40) ? 1 : 0;
49 @@ -294,6 +303,12 @@ static int mtouch_init(struct usbtouch_usb *usbtouch)
53 + /* Default min/max xy are the raw values, override if using hw-calib */
55 + input_set_abs_params(usbtouch->input, ABS_X, 0, 0xffff, 0, 0);
56 + input_set_abs_params(usbtouch->input, ABS_Y, 0, 0xffff, 0, 0);