Corsair Vengeance K90 driver
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 Corsair Vengeance K90 driver
--- Documentation/ABI/testing/sysfs-class-k90_profile | 55 ++ .../ABI/testing/sysfs-driver-hid-corsair-k90 | 15 + drivers/hid/Kconfig | 10 + drivers/hid/Makefile | 1 + drivers/hid/hid-core.c | 1 + drivers/hid/hid-corsair-k90.c | 690 +++++++++++++++++++++ drivers/hid/hid-ids.h | 3 + 7 files changed, 775 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-k90_profile create mode 100644 Documentation/ABI/testing/sysfs-driver-hid-corsair-k90 create mode 100644 drivers/hid/hid-corsair-k90.c
Documentation/ABI/testing/sysfs-class-k90_profile new file +55 -0
@@ -0,0 +1,55 @@ +What: /sys/class/k90_profile/<profile>/profile_number +Date: August 2015 +KernelVersion: 4.2 +Contact: Clement Vuchener <[email protected]> +Description: Get the number of the profile. + +What: /sys/class/k90_profile/<profile>/bindings +Date: August 2015 +KernelVersion: 4.2 +Contact: Clement Vuchener <[email protected]> +Description: Write bindings to the keyboard on-board profile. + The data structure is: + - number of bindings in this structure (1 byte) + - size of this data structure (2 bytes big endian) + - size of the macro data written to + /sys/class/k90_profile/<profile>/data (2 bytes big endian) + - array of bindings referencing the data from + /sys/class/k90_profile/<profile>/data, each containing: + * 0x10 for a key usage, 0x20 for a macro (1 byte) + * offset of the key usage/macro data (2 bytes big endian) + * length of the key usage/macro data (2 bytes big endian) + +What: /sys/class/k90_profile/<profile>/keys +Date: August 2015 +KernelVersion: 4.2 +Contact: Clement Vuchener <[email protected]> +Description: Write the list of the keys used by the bindings and how + the macros are repeated. + The data struct is: + - number of keys in this structure (1 byte) + - array of keys and repeat mode: + * key usage (G1 to G16 are 0xD0 to 0xDF, G17 and + G18 are 0xE8 and 0xE9) (1 byte) + * repeat mode (1 byte): + 1: play when pressed + 2: repeat while key is pressed + 3: repeat until the key is pressed again + +What: /sys/class/k90_profile/<profile>/data +Date: August 2015 +KernelVersion: 4.2 +Contact: Clement Vuchener <[email protected]> +Description: Write the key usage and macros used by + /sys/class/k90_profile/<profile>/bindings + Macro items are: + - Key event: + * item type: 0x84 (1 byte) + * HID usage (1 byte) + * new state: 0 released, 1 pressed (1 byte) + - Delay + * item type: 0x87 (1 byte) + * delay in milliseconds (2 bytes big endian) + - Macro end + * item type: 0x86 (1 byte) + * repeat count (2 bytes big endian)
Documentation/ABI/testing/sysfs-driver-hid-corsair-k90 new file +15 -0
@@ -0,0 +1,15 @@ +What: /sys/bus/drivers/k90/<dev>/macro_mode +Date: August 2015 +KernelVersion: 4.2 +Contact: Clement Vuchener <[email protected]> +Description: Get/set the current playback mode. "SW" for software mode + where G-keys triggers their regular key codes. "HW" for + hardware playback mode where the G-keys play their macro + from the on-board memory. + + +What: /sys/bus/drivers/k90/<dev>/current_profile +Date: August 2015 +KernelVersion: 4.2 +Contact: Clement Vuchener <[email protected]> +Description: Get/set the current selected profile. Values are from 1 to 3.
drivers/hid/Kconfig +9 -0
@@ -171,6 +171,16 @@ config HID_CHICONY ---help--- Support for Chicony Tactical pad. +config HID_CORSAIR + tristate "Corsair devices" + depends on HID + ---help--- + Support for Corsair devices that are not fully compliant with the + HID standard. + + Supported devices: + - Vengeance K90 + config HID_PRODIKEYS tristate "Prodikeys PC-MIDI Keyboard support" depends on HID && SND
drivers/hid/Makefile +1 -0
@@ -29,6 +29,7 @@ obj-$(CONFIG_HID_BELKIN) += hid-belkin.o obj-$(CONFIG_HID_BETOP_FF) += hid-betopff.o obj-$(CONFIG_HID_CHERRY) += hid-cherry.o obj-$(CONFIG_HID_CHICONY) += hid-chicony.o +obj-$(CONFIG_HID_CORSAIR) += hid-corsair-k90.o obj-$(CONFIG_HID_CP2112) += hid-cp2112.o obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o obj-$(CONFIG_HID_DRAGONRISE) += hid-dr.o
drivers/hid/hid-core.c +0 -0
@@ -1807,6 +1807,7 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY,
USB_DEVICE_ID_CHICONY_WIRELESS) },
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY,USB_DEVICE_ID_CHICONY_WIRELESS2) },
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_AK1D) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K90) },
{ HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS,USB_DEVICE_ID_PRODIKEYS_PCMIDI) },
{ HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_CP2112) }, { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS,USB_DEVICE_ID_CYPRESS_BARCODE_1) },
drivers/hid/hid-corsair-k90.c new file +690 -0
690 lines not on this page · raw message
drivers/hid/hid-ids.h +2 -0
@@ -246,6 +246,9 @@#define USB_DEVICE_ID_CODEMERCS_IOW_FIRST 0x1500#define USB_DEVICE_ID_CODEMERCS_IOW_LAST 0x15ff +#define USB_VENDOR_ID_CORSAIR 0x1b1c +#define USB_DEVICE_ID_CORSAIR_K90 0x1b02 +#define USB_VENDOR_ID_CREATIVELABS 0x041e#define USB_DEVICE_ID_PRODIKEYS_PCMIDI 0x2801 -- 2.4.3
Jiri Kosina
maintainerOn Sat, 29 Aug 2015, Clément Vuchener wrote:
This is missing changelog and Signed-off-by: line. I know that you have provided that in your cover letter, but cover letter never make it to the actual GIT commits.
So please fix that and resend the patch, thanks.
Quoted 33 lines
--- Documentation/ABI/testing/sysfs-class-k90_profile | 55 ++ .../ABI/testing/sysfs-driver-hid-corsair-k90 | 15 + drivers/hid/Kconfig | 10 + drivers/hid/Makefile | 1 + drivers/hid/hid-core.c | 1 + drivers/hid/hid-corsair-k90.c | 690 +++++++++++++++++++++ drivers/hid/hid-ids.h | 3 + 7 files changed, 775 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-k90_profile create mode 100644 Documentation/ABI/testing/sysfs-driver-hid-corsair-k90 create mode 100644 drivers/hid/hid-corsair-k90.cDocumentation/ABI/testing/sysfs-class-k90_profile new file +12
-0@@ -0,0 +1,55 @@ +What: /sys/class/k90_profile/<profile>/profile_number +Date: August 2015 +KernelVersion: 4.2 +Contact: Clement Vuchener <[email protected]> +Description: Get the number of the profile. + +What: /sys/class/k90_profile/<profile>/bindings +Date: August 2015 +KernelVersion: 4.2 +Contact: Clement Vuchener <[email protected]> +Description: Write bindings to the keyboard on-board profile. + The data structure is:
Documentation/ABI/testing/sysfs-class-k90_profile line 22
Quoted 10 lines
Documentation/ABI/testing/sysfs-class-k90_profile new file +10
-0+ - number of bindings in this structure (1 byte) + - size of this data structure (2 bytes big endian) + - size of the macro data written to + /sys/class/k90_profile/<profile>/data (2 bytes big endian) + - array of bindings referencing the data from + /sys/class/k90_profile/<profile>/data, each containing: + * 0x10 for a key usage, 0x20 for a macro (1 byte) + * offset of the key usage/macro data (2 bytes big endian) + * length of the key usage/macro data (2 bytes big endian) +
This looks like violation of one-value-per-attribute rule for sysfs ABI. Could you please think about it once again with this aspect on mind?
[ ... snip ... ]
Quoted 16 lines
drivers/hid/hid-core.c +1
-0@@ -1807,6 +1807,7 @@ static const struct hid_device_id hid_have_special_driver[] = { {HID_USB_DEVICE (USB_VENDOR_ID_CHICONY , USB_DEVICE_ID_CHICONY_WIRELESS) }, { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) }, { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_AK1D) }, + { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K90) },{ HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS,
USB_DEVICE_ID_PRODIKEYS_PCMIDI) },drivers/hid/hid-core.c +0
-0{ HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_CP2112) }, { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS,
Quoted 1 line
USB_DEVICE_ID_CYPRESS_BARCODE_1) },
Your mail client is corrupting long lines, making tha patch application impossible. Please fix that for your following submissions.
drivers/hid/hid-corsair-k90.c line 2
Quoted 8 lines
drivers/hid/hid-corsair-k90.c new file +2
-0@@ -0,0 +1,690 @@ +/* +* HID driver for Corsair Vengeance K90 Keyboard
Usually we try to be a little bit more generic, and name the driver according to the vendor (and fold all the vedor-specific stuff into the one driver).
So my suggestion would be to name the driver hid-corsair, keeping the possibility for adding more devices later open.
[ ... snip ... ]
Quoted 14 lines
drivers/hid/hid-corsair-k90.c new file +14
-0+static int k90_init_special_functions (struct hid_device *dev) +{ +int ret, i; +struct usb_interface *usbif =to_usb_interface (dev->dev.parent); +struct usb_device *usbdev =interface_to_usbdev (usbif); +char data[8 ]; +struct k90_drvdata *drvdata = +kzalloc (sizeof (struct k90_drvdata ),GFP_KERNEL ); +size_t name_sz; +char *name; +struct k90_led *led; + +if (!drvdata) { + ret = -ENOMEM ;
drivers/hid/hid-corsair-k90.c line 421
Quoted 10 lines
drivers/hid/hid-corsair-k90.c new file +10
-0+ goto fail_drvdata; + } +hid_set_drvdata (dev, drvdata); + +/* Get current status */ + ret =usb_control_msg (usbdev,usb_rcvctrlpipe (usbdev,0 ), +K90_REQUEST_STATUS , +USB_DIR_IN |USB_TYPE_VENDOR | +USB_RECIP_DEVICE ,0 ,0 , data,8 , +USB_CTRL_SET_TIMEOUT );
So you apparently also depend on USB ...
Quoted 39 lines
drivers/hid/hid-corsair-k90.c new file +39
-0+if (ret <0 ) { +hid_warn (dev,"Failed to get K90 initial state (error %d).\n" , + ret); + drvdata->backlight.brightness =0 ; + drvdata->current_profile =1 ; + }else { + drvdata->backlight.brightness = data[4 ]; + drvdata->current_profile = data[7 ]; + } +/* Get current mode */ + ret =usb_control_msg (usbdev,usb_rcvctrlpipe (usbdev,0 ), +K90_REQUEST_GET_MODE , +USB_DIR_IN |USB_TYPE_VENDOR | +USB_RECIP_DEVICE ,0 ,0 , data,2 , +USB_CTRL_SET_TIMEOUT ); +if (ret <0 ) +hid_warn (dev,"Failed to get K90 initial mode (error %d).\n" , + ret); +else { +switch (data[0 ]) { +case K90_MACRO_MODE_HW : + drvdata->macro_mode =1 ; +break ; +case K90_MACRO_MODE_SW : + drvdata->macro_mode =0 ; +break ; +default : +hid_warn (dev,"K90 in unknown mode: %02x.\n" , + data[0 ]); + } + } + +/* Init LED device for backlight */ + name_sz = +strlen (dev_name (&dev->dev)) +sizeof (K90_BACKLIGHT_LED_SUFFIX ); + name =devm_kzalloc (&dev->dev, name_sz,GFP_KERNEL ); +if (!name) { + ret = -ENOMEM ; + goto fail_backlight;
drivers/hid/hid-corsair-k90.c line 470
Quoted 10 lines
drivers/hid/hid-corsair-k90.c new file +10
-0+ } +snprintf (name, name_sz,"%s" K90_BACKLIGHT_LED_SUFFIX , +dev_name (&dev->dev)); + led = &drvdata->backlight; + led->cdev.name = name; + led->cdev.max_brightness =3 ; + led->cdev.brightness_set = k90_brightness_set; + led->cdev.brightness_get = k90_brightness_get; +INIT_WORK (&led->work, k90_backlight_work); + ret =led_classdev_register (&dev->dev, &led->cdev);
... and also on LED subsystem, but this dependency is not expressed in Kconfig.
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs
Quoted 46 lines · Jiri Kosina
On Sat, 29 Aug 2015, Clément Vuchener wrote:
This is missing changelog and Signed-off-by: line. I know that you have provided that in your cover letter, but cover letter never make it to the actual GIT commits.
So please fix that and resend the patch, thanks.
Quoted 37 lines
--- Documentation/ABI/testing/sysfs-class-k90_profile | 55 ++ .../ABI/testing/sysfs-driver-hid-corsair-k90 | 15 + drivers/hid/Kconfig | 10 + drivers/hid/Makefile | 1 + drivers/hid/hid-core.c | 1 + drivers/hid/hid-corsair-k90.c | 690 +++++++++++++++++++++ drivers/hid/hid-ids.h | 3 + 7 files changed, 775 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-k90_profile create mode 100644 Documentation/ABI/testing/sysfs-driver-hid-corsair-k90 create mode 100644 drivers/hid/hid-corsair-k90.cDocumentation/ABI/testing/sysfs-class-k90_profile new file +16
-0@@ -0,0 +1,55 @@ +What: /sys/class/k90_profile/<profile>/profile_number +Date: August 2015 +KernelVersion: 4.2 +Contact: Clement Vuchener <[email protected]> +Description: Get the number of the profile. + +What: /sys/class/k90_profile/<profile>/bindings +Date: August 2015 +KernelVersion: 4.2 +Contact: Clement Vuchener <[email protected]> +Description: Write bindings to the keyboard on-board profile. + The data structure is: + - number of bindings in this structure (1 byte) + - size of this data structure (2 bytes big endian) + - size of the macro data written to + /sys/class/k90_profile/<profile>/data (2 bytes big endian)
Quoted 8 lines
Documentation/ABI/testing/sysfs-class-k90_profile line 22
Quoted 6 lines
Documentation/ABI/testing/sysfs-class-k90_profile new file +6
-0+ - array of bindings referencing the data from + /sys/class/k90_profile/<profile>/data, each containing: + * 0x10 for a key usage, 0x20 for a macro (1 byte) + * offset of the key usage/macro data (2 bytes big endian) + * length of the key usage/macro data (2 bytes big endian) +This looks like violation of one-value-per-attribute rule for sysfs ABI. Could you please think about it once again with this aspect on mind?
Per key attributes would be nice but I don't think I can do that. The profile must be written all at once and I don't know any way to read it from the hardware (the windows driver I studied does not do it). So writing one value only would erase all the others. I think I will remove this part from the driver. The same thing can easily be done in user space through libusb and writing profile should be exceptional enough that it is not a problem to detach the driver while doing it. That part of the driver is not really useful with the current ABI.
Quoted 118 lines
[ ... snip ... ]
Quoted 16 lines
drivers/hid/hid-core.c +1
-0@@ -1807,6 +1807,7 @@ static const struct hid_device_id hid_have_special_driver[] = { {HID_USB_DEVICE (USB_VENDOR_ID_CHICONY , USB_DEVICE_ID_CHICONY_WIRELESS) }, { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) }, { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_AK1D) }, + { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K90) },{ HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS,
USB_DEVICE_ID_PRODIKEYS_PCMIDI) },drivers/hid/hid-core.c +0
-0{ HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_CP2112) }, { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS,Quoted 1 line
USB_DEVICE_ID_CYPRESS_BARCODE_1) },Your mail client is corrupting long lines, making tha patch application impossible. Please fix that for your following submissions.
drivers/hid/hid-corsair-k90.c line 2
Quoted 8 lines
drivers/hid/hid-corsair-k90.c new file +2
-0@@ -0,0 +1,690 @@ +/* +* HID driver for Corsair Vengeance K90 Keyboard Usually we try to be a little bit more generic, and name the driver according to the vendor (and fold all the vedor-specific stuff into the one driver).
So my suggestion would be to name the driver hid-corsair, keeping the possibility for adding more devices later open.
[ ... snip ... ]
Quoted 14 lines
drivers/hid/hid-corsair-k90.c new file +14
-0+static int k90_init_special_functions (struct hid_device *dev) +{ +int ret, i; +struct usb_interface *usbif =to_usb_interface (dev->dev.parent); +struct usb_device *usbdev =interface_to_usbdev (usbif); +char data[8 ]; +struct k90_drvdata *drvdata = +kzalloc (sizeof (struct k90_drvdata ),GFP_KERNEL ); +size_t name_sz; +char *name; +struct k90_led *led; + +if (!drvdata) { + ret = -ENOMEM ;drivers/hid/hid-corsair-k90.c line 421
Quoted 10 lines
drivers/hid/hid-corsair-k90.c new file +10
-0+ goto fail_drvdata; + } +hid_set_drvdata (dev, drvdata); + +/* Get current status */ + ret =usb_control_msg (usbdev,usb_rcvctrlpipe (usbdev,0 ), +K90_REQUEST_STATUS , +USB_DIR_IN |USB_TYPE_VENDOR | +USB_RECIP_DEVICE ,0 ,0 , data,8 , +USB_CTRL_SET_TIMEOUT );So you apparently also depend on USB ...
Quoted 39 lines
drivers/hid/hid-corsair-k90.c new file +39
-0+if (ret <0 ) { +hid_warn (dev,"Failed to get K90 initial state (error %d).\n" , + ret); + drvdata->backlight.brightness =0 ; + drvdata->current_profile =1 ; + }else { + drvdata->backlight.brightness = data[4 ]; + drvdata->current_profile = data[7 ]; + } +/* Get current mode */ + ret =usb_control_msg (usbdev,usb_rcvctrlpipe (usbdev,0 ), +K90_REQUEST_GET_MODE , +USB_DIR_IN |USB_TYPE_VENDOR | +USB_RECIP_DEVICE ,0 ,0 , data,2 , +USB_CTRL_SET_TIMEOUT ); +if (ret <0 ) +hid_warn (dev,"Failed to get K90 initial mode (error %d).\n" , + ret); +else { +switch (data[0 ]) { +case K90_MACRO_MODE_HW : + drvdata->macro_mode =1 ; +break ; +case K90_MACRO_MODE_SW : + drvdata->macro_mode =0 ; +break ; +default : +hid_warn (dev,"K90 in unknown mode: %02x.\n" , + data[0 ]); + } + } + +/* Init LED device for backlight */ + name_sz = +strlen (dev_name (&dev->dev)) +sizeof (K90_BACKLIGHT_LED_SUFFIX ); + name =devm_kzalloc (&dev->dev, name_sz,GFP_KERNEL ); +if (!name) { + ret = -ENOMEM ; + goto fail_backlight;drivers/hid/hid-corsair-k90.c line 470
Quoted 10 lines
drivers/hid/hid-corsair-k90.c new file +10
-0+ } +snprintf (name, name_sz,"%s" K90_BACKLIGHT_LED_SUFFIX , +dev_name (&dev->dev)); + led = &drvdata->backlight; + led->cdev.name = name; + led->cdev.max_brightness =3 ; + led->cdev.brightness_set = k90_brightness_set; + led->cdev.brightness_get = k90_brightness_get; +INIT_WORK (&led->work, k90_backlight_work); + ret =led_classdev_register (&dev->dev, &led->cdev);... and also on LED subsystem, but this dependency is not expressed in
Kconfig.Thanks,