Sitronix ST9RM01 multitouch panel
PATCH 1/1 Sitronix ST9RM01 multitouch panel
From: Rudy Huang <[email protected]>
USB HID support for the Sitronix ST9RM01 multi-touch panel as an input device.
---
drivers/hid/Kconfig | 6 + drivers/hid/Makefile | 1 drivers/hid/hid-core.c | 1 drivers/hid/hid-ids.h | 3 drivers/hid/hid-sitronix.c | 286 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 297 insertions(+), 0 deletions(-) create mode 100644 drivers/hid/hid-sitronix.c
drivers/hid/Kconfig +6 -0
@@ -382,6 +382,12 @@ config HID_SAMSUNG ---help--- Support for Samsung InfraRed remote control or keyboards. +config HID_SITRONIX + tristate "Sitronix" + depends on USB_HID + ---help--- + Say Y here if you have a Sitronix ST9RM01 multitouch panel. + config HID_SONY tristate "Sony" depends on USB_HID
drivers/hid/Makefile +1 -0
@@ -53,6 +53,7 @@ obj-$(CONFIG_HID_PICOLCD) += hid-picolcd.o obj-$(CONFIG_HID_ROCCAT) += hid-roccat.o obj-$(CONFIG_HID_ROCCAT_KONE) += hid-roccat-kone.o obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o +obj-$(CONFIG_HID_SITRONIX) += hid-sitronix.o obj-$(CONFIG_HID_SMARTJOYPLUS) += hid-sjoy.o obj-$(CONFIG_HID_SONY) += hid-sony.o obj-$(CONFIG_HID_STANTUM) += hid-stantum.o
drivers/hid/hid-core.c +1 -0
@@ -1369,6 +1369,7 @@ static const struct hid_device_id hid_blacklist[] = { { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) }, { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) }, + { HID_USB_DEVICE(USB_VENDOR_ID_SITRONIX, USB_DEVICE_ID_ST9RM01) }, { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
drivers/hid/hid-ids.h +3 -0
@@ -467,6 +467,9 @@#define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001#define USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE 0x0600 +#define USB_VENDOR_ID_SITRONIX 0x1403 +#define USB_DEVICE_ID_ST9RM01 0x5001 +#define USB_VENDOR_ID_SONY 0x054c#define USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE 0x024b#define USB_DEVICE_ID_SONY_PS3_CONTROLLER 0x0268
drivers/hid/hid-sitronix.c new file +286 -0
286 lines not on this page · raw message
Quoted 5 lines · Alan Cox
From: Rudy Huang <[email protected]>
USB HID support for the Sitronix ST9RM01 multi-touch panel as an input device.
The Sitronix ST9RM01 appears to be based on Stantum's design and firmware (see http://www.stantum.com/en/supply-chain/icdesigners/
Sitronix). Actually, the submitted driver still contains an error message from the original hid-stantum.c :-) Are there differences that force the creation of a new driver?
Cheers,
St.--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Everyone,
Sitronix uses Stantum design, but I do not believe there is any need for another driver for this. VID and PID have to be added to the existing Stantum driver (hid-stantum) - there should not be another driver needed. I believe sitronix probably wrote the driver as they thought the existing driver does not work with their device. In my opinion it should be removed and the original should be updated to include the sitronix vid and pid
I have added rudy_huang to this mail : Rudy please let me know if you want to update the driver or if you want us to do it.
Regards
Gowri
-----Message d'origine-----
De : Stéphane Chatty [mailto:[email protected]]
Envoyé : mardi 28 septembre 2010 19:51
À : Alan Cox
Cc : linux-input; Jiri Kosina; Gowri Ries - Stantum; Henrik Rydberg Objet : Re: Sitronix ST9RM01 multitouch panel
Quoted 5 lines · Alan Cox
From: Rudy Huang <[email protected]>
USB HID support for the Sitronix ST9RM01 multi-touch panel as an input device.
The Sitronix ST9RM01 appears to be based on Stantum's design and firmware (see http://www.stantum.com/en/supply-chain/icdesigners/
Sitronix). Actually, the submitted driver still contains an error message from the original hid-stantum.c :-) Are there differences that force the creation of a new driver?
Cheers,
St.
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Rudy,
drivers/hid/hid-sitronix.c line 4
Quoted 10 lines
drivers/hid/hid-sitronix.c new file +4
-0@@ -0,0 +1,286 @@ +/* +* HID driver for Sitronix ST9RM01 multitouch panels +* +* Copyright (c) 2010 Gaggery Tsai <[email protected]>
Since this driver is heavily based on the other MT hid drivers, it would be nice with a recognition here. Or better, as Stephane said, perhaps this driver could simply be merged with hid-stantum.c?
Quoted 25 lines
drivers/hid/hid-sitronix.c new file +25
-0+* +*/ + +/* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the Free +* Software Foundation; either version 2 of the License, or (at your option) +* any later version. +*/ + +#include <linux/device.h> +#include <linux/hid.h> +#include <linux/module.h> + +#define DRIVER_AUTHOR "Sitronix, Inc." +#define DRIVER_NAME "sitronix" +#define DRIVER_DESC "Sitronix USB touch" +#define DRIVER_DATE "20100903" +#define DRIVER_MAJOR 1 +#define DRIVER_MINOR 2 +#define DRIVER_PATCHLEVEL 0 + +MODULE_AUTHOR ("Gaggery Tsai <[email protected]>" ); +MODULE_DESCRIPTION ("Sitronix HID multitouch panels" ); +MODULE_LICENSE ("GPL" );
drivers/hid/hid-sitronix.c line 39
Quoted 10 lines
drivers/hid/hid-sitronix.c new file +10
-0+ +#include "hid-ids.h" + +struct sitronix_data { +s32 x, y, z, w, h;/* x, y, pressure, width, height */ +u16 id;/* touch id */ +bool valid;/* valid finger data, or just placeholder? */ +bool first;/* first finger in the HID packet? */ +bool activity;/* at least one active finger so far? */ +};
How many contacts does the device support?
Quoted 43 lines
drivers/hid/hid-sitronix.c new file +43
-0+ +static int sitronix_input_mapping (struct hid_device *hdev,struct hid_input *hi, +struct hid_field *field,struct hid_usage *usage, +unsigned long **bit,int *max) +{ +switch (usage->hid &HID_USAGE_PAGE ) { + +case HID_UP_GENDESK : +switch (usage->hid) { +case HID_GD_X : +hid_map_usage (hi, usage, bit, max, +EV_ABS ,ABS_MT_POSITION_X ); +/* touchscreen emulation */ +input_set_abs_params (hi->input,ABS_X , + field->logical_minimum, + field->logical_maximum,0 ,0 ); +return 1 ; +case HID_GD_Y : +hid_map_usage (hi, usage, bit, max, +EV_ABS ,ABS_MT_POSITION_Y ); +/* touchscreen emulation */ +input_set_abs_params (hi->input,ABS_Y , + field->logical_minimum, + field->logical_maximum,0 ,0 ); +return 1 ; + } +return 0 ; + +case HID_UP_DIGITIZER : +switch (usage->hid) { +case HID_DG_INRANGE : +case HID_DG_CONFIDENCE : +case HID_DG_INPUTMODE : +case HID_DG_DEVICEINDEX : +case HID_DG_CONTACTCOUNT : +case HID_DG_CONTACTMAX : + +return -1 ; + +case HID_DG_TIPSWITCH : +/* touchscreen emulation */ +hid_map_usage (hi, usage, bit, max,EV_KEY ,BTN_TOUCH ); +return 1 ;
drivers/hid/hid-sitronix.c line 92
Quoted 10 lines
drivers/hid/hid-sitronix.c new file +10
-0+ +case HID_DG_WIDTH : +hid_map_usage (hi, usage, bit, max, +EV_ABS ,ABS_MT_TOUCH_MAJOR ); +return 1 ; +case HID_DG_HEIGHT : +hid_map_usage (hi, usage, bit, max, +EV_ABS ,ABS_MT_TOUCH_MINOR ); +input_set_abs_params (hi->input,ABS_MT_ORIENTATION , +1 ,1 ,0 ,0 );
This line is copying an error that there is a recent patch for.
drivers/hid/hid-sitronix.c line 96
Quoted 4 lines
drivers/hid/hid-sitronix.c new file +4
-0+return 1 ; +case HID_DG_CONTACTID : +hid_map_usage (hi, usage, bit, max, +EV_ABS ,ABS_MT_TRACKING_ID );
This usage of ABS_MT_TRACKING_ID is not ideal. The HID contact id normally maps to a slot number, which suggests the MT slots protocol be used instead.
On a completely different note, there is a new virtual testing project,
https://wiki.ubuntu.com/Multitouch/Testing/uTouchEvEmu, which could be of interest to those seeking to formalize driver capabilities beyond the driver code.
Quoted 34 lines
drivers/hid/hid-sitronix.c new file +34
-0+return 1 ; + + } +return 0 ; + +case 0xff000000 : +/* no input-oriented meaning */ +return -1 ; + } + +return 0 ; +} + +static int sitronix_input_mapped (struct hid_device *hdev,struct hid_input *hi, +struct hid_field *field,struct hid_usage *usage, +unsigned long **bit,int *max) +{ +if (usage->type ==EV_KEY || usage->type ==EV_ABS ) +clear_bit (usage->code, *bit); + +return 0 ; + +} + +/* +* this function is called when a whole finger has been parsed, +* so that it can decide what to send to the input layer. +*/ +static void sitronix_filter_event (struct sitronix_data *sd, +struct input_dev *input) +{ +bool wide; + +if (!sd->valid) {
drivers/hid/hid-sitronix.c line 140
Quoted 10 lines
drivers/hid/hid-sitronix.c new file +10
-0+/* +* touchscreen emulation: if the first finger is not valid and +* there previously was finger activity, this is a release +*/ +if (sd->first && sd->activity) { +input_event (input,EV_KEY ,BTN_TOUCH ,0 ); + sd->activity = false; + } +return ; + }
I believe this touch construction is error prone.
Quoted 13 lines
drivers/hid/hid-sitronix.c new file +13
-0+ +input_event (input,EV_ABS ,ABS_MT_TRACKING_ID , sd->id); +input_event (input,EV_ABS ,ABS_MT_POSITION_X , sd->x); +input_event (input,EV_ABS ,ABS_MT_POSITION_Y , sd->y); + + wide = (sd->w > sd->h); +input_event (input,EV_ABS ,ABS_MT_ORIENTATION , wide); +input_event (input,EV_ABS ,ABS_MT_TOUCH_MAJOR , wide ? sd->w : sd->h); +input_event (input,EV_ABS ,ABS_MT_TOUCH_MINOR , wide ? sd->h : sd->w); + +input_mt_sync (input); + sd->valid = false; +
drivers/hid/hid-sitronix.c line 163
Quoted 10 lines
drivers/hid/hid-sitronix.c new file +10
-0+/* touchscreen emulation */ +if (sd->first) { +if (!sd->activity) { +input_event (input,EV_KEY ,BTN_TOUCH ,1 ); + sd->activity = true; + } +input_event (input,EV_ABS ,ABS_X , sd->x); +input_event (input,EV_ABS ,ABS_Y , sd->y); + } + sd->first = false;
Same here. How about is_touch = number_of_fingers > 0? Works nicely in many other drivers.
Quoted 9 lines
drivers/hid/hid-sitronix.c new file +9
-0+} + + +static int sitronix_event (struct hid_device *hid,struct hid_field *field, +struct hid_usage *usage,s32 value) +{ +struct sitronix_data *sd =hid_get_drvdata (hid); + +if (hid->claimed &HID_CLAIMED_INPUT ) {
drivers/hid/hid-sitronix.c line 182
Quoted 10 lines
drivers/hid/hid-sitronix.c new file +10
-0+struct input_dev *input = field->hidinput->input; + +switch (usage->hid) { +case HID_DG_INRANGE : +/* this is the last field in a finger */ +if (value >0 ) + sd->valid = true; +else + sd->valid = false; +break ;
sd->valid = value would suffice.
drivers/hid/hid-sitronix.c line 188
Quoted 6 lines
drivers/hid/hid-sitronix.c new file +6
-0+case HID_DG_WIDTH : + sd->w = value; +break ; +case HID_DG_HEIGHT : + sd->h = value; +sitronix_filter_event (sd, input);
This kind of construction is unfortunate, because similar devices may have a different attribute set, of the attributes may appear in a different order. Better would be to allow to first collect all attributes in random order, then perform the contact update.
drivers/hid/hid-sitronix.c line 200
Quoted 12 lines
drivers/hid/hid-sitronix.c new file +12
-0+break ; +case HID_GD_X : + sd->x = value; +break ; +case HID_GD_Y : + sd->y = value; +break ; +case HID_DG_CONTACTID : +if (value ==4 ) + sd->first = true; + sd->id = value; +break ;
Is contact ID == 4 a special value of some sorts?
Quoted 24 lines
drivers/hid/hid-sitronix.c new file +23
-0+case HID_DG_CONFIDENCE : +break ; +case HID_DG_CONTACTCOUNT : +/* this comes only before the first finger */ +break ; + +default : +/* ignore the others */ +return 1 ; + } + } + +/* we have handled the hidinput part, now remains hiddev */ +if ((hid->claimed &HID_CLAIMED_HIDDEV ) && hid->hiddev_hid_event) + hid->hiddev_hid_event (hid, field, usage, value); +return 1 ; +} + +static int sitronix_probe (struct hid_device *hdev, +const struct hid_device_id *id) +{ +int ret; +struct sitronix_data *sd;
drivers/hid/hid-sitronix.c line 233
Quoted 10 lines
drivers/hid/hid-sitronix.c new file +10
-0+ + sd =kmalloc (sizeof (struct sitronix_data ),GFP_KERNEL ); +if (!sd) { +dev_err (&hdev->dev,"cannot allocate Stantum data\n" ); +return -ENOMEM ; + } + sd->valid = false; + sd->first = false; + sd->activity = false; +hid_set_drvdata (hdev, sd);
Please use kzalloc() instead of manually setting variables to zero.
Quoted 43 lines
drivers/hid/hid-sitronix.c new file +43
-0+ + ret =hid_parse (hdev); +if (!ret) + ret =hid_hw_start (hdev,HID_CONNECT_DEFAULT ); + +if (ret) +kfree (sd); + +return ret; +} + +static void sitronix_remove (struct hid_device *hdev) +{ +hid_hw_stop (hdev); +kfree (hid_get_drvdata (hdev)); +hid_set_drvdata (hdev,NULL ); +} + +static const struct hid_device_id sitronix_devices[] = { + {HID_USB_DEVICE (USB_VENDOR_ID_SITRONIX ,USB_DEVICE_ID_ST9RM01 ) }, + { } +}; +MODULE_DEVICE_TABLE (hid, sitronix_devices); + +static const struct hid_usage_id sitronix_grabbed_usages[] = { + {HID_ANY_ID ,HID_ANY_ID ,HID_ANY_ID }, + {HID_ANY_ID -1 ,HID_ANY_ID -1 ,HID_ANY_ID -1 } +}; + +static struct hid_driver sitronix_driver = { + .name ="sitronix" , + .id_table = sitronix_devices, + .probe = sitronix_probe, + .remove = sitronix_remove, + .input_mapping = sitronix_input_mapping, + .input_mapped = sitronix_input_mapped, + .usage_table = sitronix_grabbed_usages, + .event = sitronix_event, +}; + +static int __init sitronix_init (void ) +{ +return hid_register_driver (&sitronix_driver);
drivers/hid/hid-sitronix.c line 286
Quoted 10 lines
drivers/hid/hid-sitronix.c new file +10
-0+} + +static void __exit sitronix_exit(void) +{ +hid_unregister_driver (&sitronix_driver); +} + +module_init (sitronix_init); +module_exit (sitronix_exit); +
Thanks,
Henrik
Quoted 12 lines · Henrik Rydberg
drivers/hid/hid-sitronix.c line 96
Quoted 6 lines
drivers/hid/hid-sitronix.c new file +4
-0+return 1 ; +case HID_DG_CONTACTID : +hid_map_usage (hi, usage, bit, max, +EV_ABS ,ABS_MT_TRACKING_ID );This usage of
ABS_MT_TRACKING_IDis not ideal. The HID contact id normally maps
to a slot number, which suggests the MT slots protocol be used instead.
I'm working on a slot-based version of the Stantum driver, and have had a look into this. The Stantum firmware actually cycles over 8-bit values for its ContactID. In this, it conforms more to the definition you gave for ABS_MT_TRACKING_ID ("The slot protocol requires the use of the ABS_MT_TRACKING_ID, either provided by the hardware or computed from the raw data [5]") than to a slot number, doesn't it? Nevertheless, given our recent exchanges about the 3M driver, I planned to use the driver's own tracking ID.
Your thoughts?
St.
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
On 09/28/2010 08:49 PM, Stéphane Chatty wrote:
[...]
Quoted 13 lines
Quoted 4 lines
This usage of
ABS_MT_TRACKING_IDis not ideal. The HID contact id normally maps to a slot number, which suggests the MT slots protocol be used instead.I'm working on a slot-based version of the Stantum driver, and have had a look into this. The Stantum firmware actually cycles over 8-bit values for its ContactID. In this, it conforms more to the definition you gave for
ABS_MT_TRACKING_ID("The slot protocol requires the use of theABS_MT_TRACKING_ID, either provided by the hardware or computed from the raw data [5]") than to a slot number, doesn't it? Nevertheless, given our recent exchanges about the 3M driver, I planned to use the driver's own tracking ID.
Quoted 1 line
Your thoughts?
Excellent. :-) Speaking of drivers and multiplication, I think many of the current drivers could in fact be merged. It seems we have two or three different types so far, and different manufacturers may well be served by the same driver.
Henrik
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 25 lines · Henrik Rydberg
On 09/28/2010 08:49 PM, Stéphane Chatty wrote:
[...]Quoted 20 lines
Quoted 6 lines
This usage of
ABS_MT_TRACKING_IDis not ideal. The HID contact id normally maps
to a slot number, which suggests the MT slots protocol be used instead.I'm working on a slot-based version of the Stantum driver, and have had a look
into this. The Stantum firmware actually cycles over 8-bit values for its
ContactID. In this, it conforms more to the definition you gave forABS_MT_TRACKING_ID("The slot protocol requires the use of theABS_MT_TRACKING_ID, either provided by the hardware or computed from the raw
data [5]") than to a slot number, doesn't it? Nevertheless, given our recent
exchanges about the 3M driver, I planned to use the driver's own tracking ID.Quoted 1 line
Your thoughts?
Quoted 6 lines
Excellent. :-) Speaking of drivers and multiplication, I think many of the
current drivers could in fact be merged. It seems we have two or three different
types so far, and different manufacturers may well be served by the same driver.
Yes, I have started reviewing all devices and making a summary of their differences in that very purpose. Among the things we'll need is some standard way for calling the filtering function at the end of a set of fingers. CONTACTCOUNT is a good candidate, but I need to check some devices. One thing bothers me though. It is that hid-core has the whole information, then is splits it and calls us repeatedly, then we more or less undo that by storing the information and trying to determine the last time it calls us.
St.
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 25 lines · Stéphane Chatty
Quoted 15 lines · Henrik Rydberg
On 09/28/2010 08:49 PM, Stéphane Chatty wrote:
[...]Quoted 13 lines
Quoted 4 lines
This usage of
ABS_MT_TRACKING_IDis not ideal. The HID contact id normally maps to a slot number, which suggests the MT slots protocol be used instead.I'm working on a slot-based version of the Stantum driver, and have had a look into this. The Stantum firmware actually cycles over 8-bit values for its ContactID. In this, it conforms more to the definition you gave for
ABS_MT_TRACKING_ID("The slot protocol requires the use of theABS_MT_TRACKING_ID, either provided by the hardware or computed from the raw data [5]") than to a slot number, doesn't it? Nevertheless, given our recent exchanges about the 3M driver, I planned to use the driver's own tracking ID.Quoted 6 lines
Quoted 1 line
Your thoughts?
Excellent. :-) Speaking of drivers and multiplication, I think many of the current drivers could in fact be merged. It seems we have two or three different types so far, and different manufacturers may well be served by the same driver.
Quoted 7 lines
Yes, I have started reviewing all devices and making a summary of their differences in that very purpose. Among the things we'll need is some standard way for calling the filtering function at the end of a set of fingers. CONTACTCOUNT is a good candidate, but I need to check some devices. One thing bothers me though. It is that hid-core has the whole information, then is splits it and calls us repeatedly, then we more or less undo that by storing the information and trying to determine the last time it calls us.
Right. A hid-mt device based on the raw protocol could be a good idea - after we reduced the current set a bit. :-)
Cheers,
Henrik
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 24 lines · Henrik Rydberg
Quoted 15 lines
Quoted 8 lines
Quoted 8 lines
I'm working on a slot-based version of the Stantum driver, and have had a look into this. The Stantum firmware actually cycles over 8-bit values for its ContactID. In this, it conforms more to the definition you gave for
ABS_MT_TRACKING_ID("The slot protocol requires the use of theABS_MT_TRACKING_ID, either provided by the hardware or computed from the raw data [5]") than to a slot number, doesn't it? Nevertheless, given our recent exchanges about the 3M driver, I planned to use the driver's own tracking ID.Quoted 6 lines
Quoted 1 line
Your thoughts?
Excellent. :-) Speaking of drivers and multiplication, I think many of the current drivers could in fact be merged. It seems we have two or three different types so far, and different manufacturers may well be served by the same driver.
Quoted 7 lines
Yes, I have started reviewing all devices and making a summary of their differences in that very purpose. Among the things we'll need is some standard way for calling the filtering function at the end of a set of fingers. CONTACTCOUNT is a good candidate, but I need to check some devices. One thing bothers me though. It is that hid-core has the whole information, then is splits it and calls us repeatedly, then we more or less undo that by storing the information and trying to determine the last time it calls us.
Quoted 2 lines
Right. A hid-mt device based on the raw protocol could be a good idea - after we reduced the current set a bit. :-)
Guys, that would be great, thanks in advance for the effort :)
Signature · 2 lines
Jiri Kosina SUSE Labs, Novell Inc.