Skip to contentSkip to conversation

HID: add chardev to propagate special events of Roccat hardware to userland

PATCH In review Stefan Achatz 2 participants 4 messages May 6, 2010 – May 18, 2010

Subsystems (2)
lore
Share & tools
lore

Stefan Achatz

author maintainer
#0 lore raw

PATCH 1/1 HID: add chardev to propagate special events of Roccat hardware to userland

Quoted 1 line

From 0692c53dfb745df62fd805fe089786951a8d96ec Mon Sep 17 00:00:00 2001

From: Stefan Achatz <[email protected]>
Date: Thu, 15 Apr 2010 17:24:45 +0200
Subject: [PATCH] HID: add chardev to propagate special events of Roccat hardware to userland This mail was first sent on april 15th but was not noticed.

This Patch adds a chardev that is used to report special events like request for on-screen-display of actual mouse-setting informations, request for execution of macro sequences not stored in mouse. The device is as generic as possible so that the functionality is usable by all (kone and upcomming) roccat device drivers.

Also small improvements in kone driver are implemented as understanding of the device and kernel programming increases.

---
 drivers/hid/Kconfig           |    8 +
 drivers/hid/Makefile          |    1 +
 drivers/hid/hid-roccat-kone.c |  127 ++++++++-----
 drivers/hid/hid-roccat-kone.h |   33 +++-
 drivers/hid/hid-roccat.c      |  428 +++++++++++++++++++++++++++++++++++++++++
 drivers/hid/hid-roccat.h      |   31 +++
 6 files changed, 576 insertions(+), 52 deletions(-)
 create mode 100644 drivers/hid/hid-roccat.c
 create mode 100644 drivers/hid/hid-roccat.h
drivers/hid/Kconfig +8 -0
index 44b4691..2c7018b 100644
@@ -268,6 +268,14 @@ config HID_QUANTA
 	---help---
 	Support for Quanta Optical Touch dual-touch panels.
 
+config HID_ROCCAT
+	tristate "Roccat special event support"
+	depends on USB_HID
+	---help---
+	Support for Roccat special events.
+	Say Y here if you have a Roccat mouse or keyboard and want OSD or
+	macro execution support.
+
 config HID_ROCCAT_KONE
 	tristate "Roccat Kone Mouse support"
 	depends on USB_HID
drivers/hid/Makefile +1 -0
index 08b83cc..77fad93 100644
@@ -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)	+= hid-roccat.o
 obj-$(CONFIG_HID_ROCCAT_KONE)	+= hid-roccat-kone.o
 obj-$(CONFIG_HID_SAMSUNG)	+= hid-samsung.o
 obj-$(CONFIG_HID_SMARTJOYPLUS)	+= hid-sjoy.o
drivers/hid/hid-roccat-kone.c +82 -45

185 lines not on this page · raw message

drivers/hid/hid-roccat-kone.h +26 -7
index ee6898c..003e6f8 100644
@@ -14,10 +14,7 @@
 
 #include <linux/types.h>
 
-#define DRIVER_VERSION "v0.3.0"
-#define DRIVER_AUTHOR "Stefan Achatz"
-#define DRIVER_DESC "USB Roccat Kone driver"
-#define DRIVER_LICENSE "GPL v2"
+#define ROCCAT_KONE_DRIVER_VERSION "v0.3.1"
 
 #pragma pack(push)
 #pragma pack(1)
@@ -83,6 +80,17 @@ enum kone_button_info_types {
 	kone_button_info_type_multimedia_volume_down = 0x27
 };
 
+enum kone_button_info_numbers {
+	kone_button_top = 1,
+	kone_button_wheel_tilt_left = 2,
+	kone_button_wheel_tilt_right = 3,
+	kone_button_forward = 4,
+	kone_button_backward = 5,
+	kone_button_middle = 6,
+	kone_button_plus = 7,
+	kone_button_minus = 8,
+};
+
 struct kone_light_info {
 	uint8_t number; /* number of light 1-5 */
 	uint8_t mod;   /* 1 = on, 2 = off */
@@ -120,6 +128,7 @@ struct kone_profile {
 	uint8_t light_effect_speed; /* range 0-255 */
 
 	struct kone_light_info light_infos[5];
+	/* offset is kone_button_info_numbers - 1 */
 	struct kone_button_info button_infos[8];
 
 	uint16_t checksum; /* \brief holds checksum of struct */
@@ -165,7 +174,7 @@ enum kone_mouse_events {
 	/* TODO clarify meaning and occurence of kone_mouse_event_calibration */
 	kone_mouse_event_calibration = 0xc0,
 	kone_mouse_event_call_overlong_macro = 0xe0,
-	/* switch events notify if user changed values wiht mousebutton click */
+	/* switch events notify if user changed values with mousebutton click */
 	kone_mouse_event_switch_dpi = 0xf0,
 	kone_mouse_event_switch_profile = 0xf1
 };
@@ -180,6 +189,12 @@ enum kone_commands {
 	kone_command_firmware = 0xe5a
 };
 
+struct kone_roccat_report {
+	uint8_t event;
+	uint8_t value; /* holds dpi or profile value */
+	uint8_t key; /* macro key on overlong macro execution */
+};
+
 #pragma pack(pop)
 
 struct kone_device {
@@ -188,8 +203,9 @@ struct kone_device {
 	 * is no way of getting this information from the device on demand
 	 */
 	int actual_profile, actual_dpi;
-	/* Used for neutralizing abnormal tilt button behaviour */
-	int last_tilt_state;
+	/* Used for neutralizing abnormal button behaviour */
+	struct kone_mouse_event last_mouse_event;
+
 	/*
 	 * It's unlikely that multiple sysfs attributes are accessed at a time,
 	 * so only one mutex is used to secure hardware access and profiles and
@@ -209,6 +225,9 @@ struct kone_device {
 	 * so it's read only once
 	 */
 	int firmware_version;
+
+	int roccat_claimed;
+	int chrdev_minor;
 };
 
 #endif
drivers/hid/hid-roccat.c new file +428 -0

428 lines not on this page · raw message

drivers/hid/hid-roccat.h new file +31 -0
new file mode 100644
index 0000000..40cca5b
@@ -0,0 +1,31 @@
+#ifndef __HID_ROCCAT_H
+#define __HID_ROCCAT_H
+
+/*
+ * Copyright (c) 2010 Stefan Achatz <[email protected]>
+ */
+
+/*
+ * 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/hid.h>
+#include <linux/types.h>
+
+#ifdef CONFIG_HID_ROCCAT
+int roccat_connect(struct hid_device *hid);
+void roccat_disconnect(int minor);
+int roccat_report_event(int minor, u8 const *data, int len);
+#else
+static inline int roccat_connect(struct hid_device *hid) { return -1; }
+static inline void roccat_disconnect(int minor) {}
+static inline int roccat_report_event(int minor, u8 const *data, int len)
+{
+	return 0;
+}
+#endif
+
+#endif
Signature · 1 line
1.6.6.1
#1 lore raw
Quoted 5 lines · Stefan Achatz

This Patch adds a chardev that is used to report special events like request for on-screen-display of actual mouse-setting informations, request for execution of macro sequences not stored in mouse. The device is as generic as possible so that the functionality is usable by all (kone and upcomming) roccat device drivers.

Hi Stefan,

what userspace application is supposed to process these events?

Quoted 2 lines

Also small improvements in kone driver are implemented as understanding of the device and kernel programming increases.

It would be nice to separate those out to standalone patches, please.

Quoted 11 lines
drivers/hid/hid-roccat-kone.c +1 -0
@@ -37,6 +37,7 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include "hid-ids.h"
+#include "hid-roccat.h"
 #include "hid-roccat-kone.h"
 
 static void kone_set_settings_checksum(struct kone_settings *settings)

drivers/hid/hid-roccat-kone.c static ssize_t kone_sysfs_set_startup_profile(struct device *dev, · line 634

Quoted 5 lines
drivers/hid/hid-roccat-kone.c +1 -1
@@ -630,7 +631,7 @@ static ssize_t kone_sysfs_set_startup_profile(struct device *dev,
 static ssize_t kone_sysfs_show_driver_version(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
-	return snprintf(buf, PAGE_SIZE, DRIVER_VERSION "\n");
+	return snprintf(buf, PAGE_SIZE, ROCCAT_KONE_DRIVER_VERSION "\n");

Do we really want to keep this kind of driver versioning? Git provided much more fine-graned versioning anyway. What is it needed for?

Quoted 16 lines

new file mode 100644
index 0000000..e05d48e

drivers/hid/hid-roccat.c new file +11 -0
@@ -0,0 +1,428 @@
+/*
+ * Roccat driver for Linux
+ *
+ * Copyright (c) 2010 Stefan Achatz <[email protected]>
+ */
+
+/*
+ * 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.

drivers/hid/hid-roccat.c line 21

Quoted 10 lines
drivers/hid/hid-roccat.c new file +10 -0
+ */
+
+/*
+ * Module roccat is a char device used to report special events of roccat
+ * hardware to userland. These events include requests for on-screen-display of
+ * profile or dpi settings or requests for execution of macro sequences that are
+ * not stored in device. The information in these events depends on hid device
+ * implementation and contains data that is not available in a single hid event
+ * or else hidraw could have been used.
+ * It is inspired by hidraw, but uses only one circular buffer for all readers.

This information could maybe go into the kernel changelog as well. For someone not familiar with the driver layout, the difference between 'roccat' and 'roccat-kone' might be very difficult to understand.

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs, Novell Inc.
author maintainer
#2 lore raw

Am Freitag, den 07.05.2010, 13:10 +0200 schrieb Jiri Kosina:

Quoted 11 lines · Stefan Achatz
Quoted 6 lines

This Patch adds a chardev that is used to report special events like request for on-screen-display of actual mouse-setting informations, request for execution of macro sequences not stored in mouse. The device is as generic as possible so that the functionality is usable by all (kone and upcomming) roccat device drivers.

Hi Stefan,

what userspace application is supposed to process these events?

Mine. It could be found at http://sourceforge.net/projects/roccat/

Quoted 4 lines
Quoted 2 lines

Also small improvements in kone driver are implemented as understanding of the device and kernel programming increases.

It would be nice to separate those out to standalone patches, please.

Will rerelease as patchset after all points in this mail are addressed.

Quoted 9 lines
Quoted 9 lines
drivers/hid/hid-roccat-kone.c +1 -0
@@ -37,6 +37,7 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include "hid-ids.h"
+#include "hid-roccat.h"
 #include "hid-roccat-kone.h"
 
Quoted 10 lines

drivers/hid/hid-roccat-kone.c static ssize_t kone_sysfs_set_startup_profile(struct device *dev, · line 634

Quoted 7 lines
drivers/hid/hid-roccat-kone.c +1 -1
 static void kone_set_settings_checksum(struct kone_settings *settings)
@@ -630,7 +631,7 @@ static ssize_t kone_sysfs_set_startup_profile(struct device *dev,
 static ssize_t kone_sysfs_show_driver_version(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
-	return snprintf(buf, PAGE_SIZE, DRIVER_VERSION "\n");
+	return snprintf(buf, PAGE_SIZE, ROCCAT_KONE_DRIVER_VERSION "\n");

Do we really want to keep this kind of driver versioning? Git provided much more fine-graned versioning anyway. What is it needed for?

My comment to function kone_sysfs_show_driver_version states:
/*
* This file is used by userland software to find devices that are handled by
* this driver. This provides a consistent way for actual and older kernels
* where this driver replaced usbhid instead of generic-usb.
* Driver capabilities are determined by version number.
*/

Quoted 22 lines
Quoted 22 lines

new file mode 100644
index 0000000..e05d48e

drivers/hid/hid-roccat.c new file +17 -0
@@ -0,0 +1,428 @@
+/*
+ * Roccat driver for Linux
+ *
+ * Copyright (c) 2010 Stefan Achatz <[email protected]>
+ */
+
+/*
+ * 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.
+ */
+
+/*
+ * Module roccat is a char device used to report special events of roccat
+ * hardware to userland. These events include requests for on-screen-display of
+ * profile or dpi settings or requests for execution of macro sequences that are
Quoted 8 lines

drivers/hid/hid-roccat.c line 21

Quoted 4 lines
drivers/hid/hid-roccat.c new file +4 -0
+ * not stored in device. The information in these events depends on hid device
+ * implementation and contains data that is not available in a single hid event
+ * or else hidraw could have been used.
+ * It is inspired by hidraw, but uses only one circular buffer for all readers.

This information could maybe go into the kernel changelog as well. For someone not familiar with the driver layout, the difference between 'roccat' and 'roccat-kone' might be very difficult to understand.

How or where do I do this?

Quoted 1 line

Thanks,

Also thanks.
Stefan

#3 lore raw
Quoted 11 lines · Stefan Achatz
Quoted 10 lines

drivers/hid/hid-roccat-kone.c static ssize_t kone_sysfs_set_startup_profile(struct device *dev, · line 634

Quoted 7 lines

static void kone_set_settings_checksum(struct kone_settings *settings)

drivers/hid/hid-roccat-kone.c +1 -1
@@ -630,7 +631,7 @@ static ssize_t kone_sysfs_set_startup_profile(struct device *dev,
 static ssize_t kone_sysfs_show_driver_version(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
-	return snprintf(buf, PAGE_SIZE, DRIVER_VERSION "\n");
+	return snprintf(buf, PAGE_SIZE, ROCCAT_KONE_DRIVER_VERSION "\n");

Do we really want to keep this kind of driver versioning? Git provided much more fine-graned versioning anyway. What is it needed for?

Quoted 7 lines

My comment to function kone_sysfs_show_driver_version states:
/*
* This file is used by userland software to find devices that are handled by
* this driver. This provides a consistent way for actual and older kernels
* where this driver replaced usbhid instead of generic-usb.
* Driver capabilities are determined by version number.
*/

Hmm, I don't seem to get it. Is it some kind of ABI versioning? What role does legacy usbhid play in it, as it didn't provide this file at all?

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
drivers/hid/hid-roccat.c new file +8 -0
+/*
+ * Module roccat is a char device used to report special events of roccat
+ * hardware to userland. These events include requests for on-screen-display of
+ * profile or dpi settings or requests for execution of macro sequences that are
+ * not stored in device. The information in these events depends on hid device
+ * implementation and contains data that is not available in a single hid event
+ * or else hidraw could have been used.
+ * It is inspired by hidraw, but uses only one circular buffer for all readers.
Quoted 5 lines
Quoted 3 lines

This information could maybe go into the kernel changelog as well. For someone not familiar with the driver layout, the difference between 'roccat' and 'roccat-kone' might be very difficult to understand.

How or where do I do this?

Just put it as an "explanation" text accompanying the patch. That will be then propagated into the changelog once comitted.

Signature · 2 lines
Jiri Kosina
SUSE Labs, Novell Inc.