HID: add driver for Roccat Kone gaming mouse 2nd Attempt
Subsystems (2)
Stefan Achatz
maintainerPATCH 1/1 HID: add driver for Roccat Kone gaming mouse 2nd Attempt
This Patch adds support for Kone gaming mouse from Roccat. It provides access to profiles, settings, firmware, weight, actual settings etc. through sysfs attributes.
Event handling of this mouse differs from standard hid behaviour in that tilt button press is reported in each move event which results in strange behaviour if not handled by the driver.
This is a heavily reworked version of the previously introduced driver. The changes include most of the previously raised concerns, memory leak and other fixes, code cleanups, adoption of additional achieved knowlege about the hardware and is (IMHO) a much better version than before even when I exchanged reduced USB-IO with a bigger memory consumption.
I refused to implement one mentioned point:
Removing the 'just-because-we-can' attributes. Motivation:
Reading the clipped in weight: I'm no gamer and can't determine the usefulness of this feature but if the manufacturer implements such a feature it might make sense to someone and I would unwillingly limit the functionality besides its such a small feature.
Reading the actual profile and dpi settings: Here I can testify that one can get lost of the actual settings when switching back and forth. The manufacturers windows driver has the ability for on-screen-display of the values and there is a mouse in the market that has an lcd on the underside of it to show these values. So I think this feature makes sense not only for me and shouldn't be removed.
--- .../ABI/testing/sysfs-driver-hid-roccat-kone | 111 +++ drivers/hid/Kconfig | 7 + drivers/hid/Makefile | 1 + drivers/hid/hid-ids.h | 3 + drivers/hid/hid-roccat-kone.c | 1001 ++++++++++++++++++++ drivers/hid/hid-roccat-kone.h | 214 +++++ 6 files changed, 1337 insertions(+), 0 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-driver-hid-roccat-kone create mode 100644 drivers/hid/hid-roccat-kone.c create mode 100644 drivers/hid/hid-roccat-kone.h
Documentation/ABI/testing/sysfs-driver-hid-roccat-kone new file +111 -0
@@ -0,0 +1,111 @@ +What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/actual_dpi +Date: March 2010 +Contact: Stefan Achatz <[email protected]> +Description: It is possible to switch the dpi setting of the mouse with the + press of a button. + When read, this file returns the raw number of the actual dpi + setting reported by the mouse. This number has to be further + processed to receive the real dpi value. + + VALUE DPI + 1 800 + 2 1200 + 3 1600 + 4 2000 + 5 2400 + 6 3200 + + This file is readonly. + +What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/actual_profile +Date: March 2010 +Contact: Stefan Achatz <[email protected]> +Description: When read, this file returns the number of the actual profile. + This file is readonly. + +What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/firmware_version +Date: March 2010 +Contact: Stefan Achatz <[email protected]> +Description: When read, this file returns the raw integer version number of the + firmware reported by the mouse. Using the integer value eases + further usage in other programs. To receive the real version + number the decimal point has to be shifted 2 positions to the + left. E.g. a returned value of 138 means 1.38 + This file is readonly. + +What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/kone_driver_version +Date: March 2010 +Contact: Stefan Achatz <[email protected]> +Description: When read, this file returns the driver version. + The format of the string is "v<major>.<minor>.<patchlevel>". + This attribute is used by the userland tools to find the sysfs- + paths of installed kone-mice and determine the capabilites of + the driver. Versions of this driver for old kernels replace + usbhid instead of generic-usb. The way to scan for this file + has been chosen to provide a consistent way for all supported + kernel versions. + This file is readonly. + +What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/profile[1-5] +Date: March 2010 +Contact: Stefan Achatz <[email protected]> +Description: The mouse can store 5 profiles which can be switched by the + press of a button. A profile holds informations like button + mappings, sensitivity, the colors of the 5 leds and light + effects. + When read, these files return the respective profile. The + returned data is 975 bytes in size. + When written, this file lets one write the respective profile + data back to the mouse. The data has to be 975 bytes long. + The mouse will reject invalid data, whereas the profile number + stored in the profile doesn't need to fit the number of the + store. + +What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/settings +Date: March 2010 +Contact: Stefan Achatz <[email protected]> +Description: When read, this file returns the settings stored in the mouse. + The size of the data is 36 bytes and holds information like the + startup_profile, tcu state and calibration_data. + When written, this file lets write settings back to the mouse. + The data has to be 36 bytes long. The mouse will reject invalid + data. + +What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/startup_profile +Date: March 2010 +Contact: Stefan Achatz <[email protected]> +Description: The integer value of this attribute ranges from 1 to 5. + When read, this attribute returns the number of the profile + that's active when the mouse is powered on. + When written, this file sets the number of the startup profile + and the mouse activates this profile immediately. + +What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/tcu +Date: March 2010 +Contact: Stefan Achatz <[email protected]> +Description: The mouse has a "Tracking Control Unit" which lets the user + calibrate the laser power to fit the mousepad surface. + When read, this file returns the current state of the TCU, + where 0 means off and 1 means on. + Writing 0 in this file will switch the TCU off. + Writing 1 in this file will start the calibration which takes + around 6 seconds to complete and activates the TCU. + +What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/weight +Date: March 2010 +Contact: Stefan Achatz <[email protected]> +Description: The mouse can be equipped with one of four supplied weights + ranging from 5 to 20 grams which are recognized by the mouse + and its value can be read out. When read, this file returns the + raw value returned by the mouse which eases further processing + in other software. + The values map to the weights as follows: + + VALUE WEIGHT + 0 none + 1 5g + 2 10g + 3 15g + 4 20g + + This file is readonly.
drivers/hid/Kconfig +7 -0
@@ -268,6 +268,13 @@ config HID_QUANTA ---help--- Support for Quanta Optical Touch dual-touch panels. +config HID_ROCCAT_KONE + tristate "Roccat Kone" if EMBEDDED + depends on USB_HID + default !EMBEDDED + ---help--- + Support for Roccat Kone mouse. + config HID_SAMSUNG tristate "Samsung" if EMBEDDED depends on USB_HID
drivers/hid/Makefile +1 -0
@@ -44,6 +44,7 @@ obj-$(CONFIG_HID_ORTEK) += hid-ortek.o obj-$(CONFIG_HID_QUANTA) += hid-quanta.o obj-$(CONFIG_HID_PANTHERLORD) += hid-pl.o obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o +obj-$(CONFIG_HID_ROCCAT_KONE) += hid-roccat-kone.o obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o obj-$(CONFIG_HID_SMARTJOYPLUS) += hid-sjoy.o obj-$(CONFIG_HID_SONY) += hid-sony.o
drivers/hid/hid-ids.h +3 -0
@@ -399,6 +399,9 @@#define USB_VENDOR_ID_PRODIGE 0x05af#define USB_DEVICE_ID_PRODIGE_CORDLESS 0x3062 +#define USB_VENDOR_ID_ROCCAT 0x1e7d +#define USB_DEVICE_ID_ROCCAT_KONE 0x2ced +#define USB_VENDOR_ID_SAITEK 0x06a3#define USB_DEVICE_ID_SAITEK_RUMBLEPAD 0xff17
drivers/hid/hid-roccat-kone.c new file +1001 -0
1,001 lines not on this page · raw message
drivers/hid/hid-roccat-kone.h new file +214 -0
214 lines not on this page · raw message
Signature · 1 line
1.6.6.1
drivers/hid/hid-ids.h line 404
Quoted 9 lines · Stefan Achatz
drivers/hid/hid-ids.h +3
-0@@ -399,6 +399,9 @@#define USB_VENDOR_ID_PRODIGE 0x05af#define USB_DEVICE_ID_PRODIGE_CORDLESS 0x3062 +#define USB_VENDOR_ID_ROCCAT 0x1e7d +#define USB_DEVICE_ID_ROCCAT_KONE 0x2ced +
Hi Stefan,
I guess you also need hid_blacklist[] entry for these device IDs, so that generic HID driver doesn't grab the device before your driver gets to it, right?
drivers/hid/hid-ids.h line 407
Quoted 3 lines
drivers/hid/hid-ids.h +3
-0+static struct hid_driver kone_driver = { .name ="kone" , + .id_table = kone_devices, .probe = kone_probe, + .remove = kone_remove, .raw_event = kone_raw_event, };
Could you please put each filed that is being initialized on a separate line?
Other than that, the patch looks quite fine to me.
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs, Novell Inc.
Stefan Achatz
maintainerPATCH 2/2 Updated hid_blacklist, reformatted code and removed unused variable
Updated hid_blacklist[] so that generic driver keeps his hands off. Reformatted code so that definition of kone_driver and kone_devices[] have one initialization per line and closing brace is on extra line. Removed an unused variable declaration.
--- drivers/hid/hid-core.c | 1 + drivers/hid/hid-roccat-kone.c | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-)
drivers/hid/hid-core.c +1 -0
@@ -1346,6 +1346,7 @@ static const struct hid_device_id hid_blacklist[] = { { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) }, + { 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_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
drivers/hid/hid-roccat-kone.c +10 -5
@@ -509,7 +509,7 @@ static ssize_t kone_sysfs_set_tcu(struct device *dev, {struct kone_device *kone =hid_get_drvdata (dev_get_drvdata (dev));struct usb_device *usb_dev =interface_to_usbdev (to_usb_interface (dev)); -int retval, checksum; +int retval;unsigned long state; retval =strict_strtoul (buf,10 , &state);
@@ -975,13 +975,18 @@ static int kone_raw_event(struct hid_device *hdev, struct hid_report *report,static const struct hid_device_id kone_devices[] = { {HID_USB_DEVICE (USB_VENDOR_ID_ROCCAT ,USB_DEVICE_ID_ROCCAT_KONE ) }, - { } }; + { } +};MODULE_DEVICE_TABLE (hid, kone_devices); -static struct hid_driver kone_driver = { .name ="kone" , - .id_table = kone_devices, .probe = kone_probe, - .remove = kone_remove, .raw_event = kone_raw_event, }; +static struct hid_driver kone_driver = { + .name ="kone" , + .id_table = kone_devices, + .probe = kone_probe, + .remove = kone_remove, + .raw_event = kone_raw_event +};static int kone_init (void ) {
Signature · 1 line
1.6.6.1
Re: [PATCH 2/2] Updated hid_blacklist, reformatted code and removed unused variable
Quoted 16 lines · Stefan Achatz
Updated hid_blacklist[] so that generic driver keeps his hands off. Reformatted code so that definition of
kone_driverand kone_devices[] have one initialization per line and closing brace is on extra line. Removed an unused variable declaration.Signed-off-by Stefan Achatz <[email protected]>--- drivers/hid/hid-core.c | 1 + drivers/hid/hid-roccat-kone.c | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-)drivers/hid/hid-core.c +0
-0
drivers/hid/hid-core.c static const struct hid_device_id hid_blacklist[] = { · line 1352
Quoted 7 lines
drivers/hid/hid-core.c +1
-0@@ -1346,6 +1346,7 @@ static const struct hid_device_id hid_blacklist[] = { { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) }, + { 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_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
Thanks for the fix. I only wonder how well has the driver been tested, as without this change it couldn't get to operate the device at all ... ?
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs, Novell Inc.
Stefan Achatz
maintainerRe: [PATCH 2/2] Updated hid_blacklist, reformatted code and removed unused variable
Am Montag, 22. März 2010 schrieb Jiri Kosina:
Quoted 31 lines · Stefan Achatz
Quoted 22 lines
Updated hid_blacklist[] so that generic driver keeps his hands off. Reformatted code so that definition of
kone_driverand kone_devices[] have one initialization per line and closing brace is on extra line. Removed an unused variable declaration.Signed-off-by Stefan Achatz <[email protected]>--- drivers/hid/hid-core.c | 1 + drivers/hid/hid-roccat-kone.c | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-)drivers/hid/hid-core.c +0
-0@@ -1346,6 +1346,7 @@ static const struct hid_device_id hid_blacklist[] = { {HID_USB_DEVICE (USB_VENDOR_ID_PETALYNX , USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, {HID_USB_DEVICE (USB_VENDOR_ID_QUANTA ,USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH ) }, { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) }, {Quoted 4 lines
HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE)}, {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)},Thanks for the fix. I only wonder how well has the driver been tested, as without this change it couldn't get to operate the device at all ... ?
Quoted 1 line
Thanks,
Hi,
As most testing was done with external module compilation on different kernel versions with generic hid compiled as internal or as module I have a script that uses the drivers sysfs bind/unbind funtionality to switch from generic hid to kone driver. Thats issued via udev and was active all the time.
Have a nice day,
Stefan
Re: [PATCH 2/2] Updated hid_blacklist, reformatted code and removed unused variable
Quoted 19 lines · Stefan Achatz
Quoted 19 lines
Quoted 11 lines
drivers/hid/hid-core.c +0
-0@@ -1346,6 +1346,7 @@ static const struct hid_device_id hid_blacklist[] = { {HID_USB_DEVICE (USB_VENDOR_ID_PETALYNX , USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, {HID_USB_DEVICE (USB_VENDOR_ID_QUANTA ,USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH ) }, { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) }, {Quoted 4 lines
HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE)}, {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)},Thanks for the fix. I only wonder how well has the driver been tested, as without this change it couldn't get to operate the device at all ... ?
Quoted 8 lines
Quoted 1 line
Thanks,
Hi,
As most testing was done with external module compilation on different kernel versions with generic hid compiled as internal or as module I have a script that uses the drivers sysfs bind/unbind funtionality to switch from generic hid to kone driver. Thats issued via udev and was active all the time.
OK, thanks.
I will fold the patches into one, and I will also make the driver independent on CONFIG_EMBEDDED, to be comopatible with other HID drivers which are not simple quirks, but rather full, stand-alone HID device drivers.
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs, Novell Inc.