diff options
-rw-r--r-- | Documentation/ABI/obsolete/sysfs-driver-hid-roccat-koneplus | 10 | ||||
-rw-r--r-- | Documentation/ABI/testing/sysfs-driver-hid-roccat-koneplus | 19 | ||||
-rw-r--r-- | drivers/hid/hid-roccat-koneplus.c | 82 | ||||
-rw-r--r-- | drivers/hid/hid-roccat-koneplus.h | 11 |
4 files changed, 65 insertions, 57 deletions
diff --git a/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-koneplus b/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-koneplus new file mode 100644 index 000000000000..c2a270b45b03 --- /dev/null +++ b/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-koneplus | |||
@@ -0,0 +1,10 @@ | |||
1 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/startup_profile | ||
2 | Date: October 2010 | ||
3 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
4 | Description: The integer value of this attribute ranges from 0-4. | ||
5 | When read, this attribute returns the number of the actual | ||
6 | profile. This value is persistent, so its equivalent to the | ||
7 | profile that's active when the mouse is powered on next time. | ||
8 | When written, this file sets the number of the startup profile | ||
9 | and the mouse activates this profile immediately. | ||
10 | Please use actual_profile, it does the same thing. | ||
diff --git a/Documentation/ABI/testing/sysfs-driver-hid-roccat-koneplus b/Documentation/ABI/testing/sysfs-driver-hid-roccat-koneplus index 00efced73969..e5311a084a31 100644 --- a/Documentation/ABI/testing/sysfs-driver-hid-roccat-koneplus +++ b/Documentation/ABI/testing/sysfs-driver-hid-roccat-koneplus | |||
@@ -1,9 +1,12 @@ | |||
1 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/actual_profile | 1 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/actual_profile |
2 | Date: October 2010 | 2 | Date: October 2010 |
3 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 3 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
4 | Description: When read, this file returns the number of the actual profile in | 4 | Description: The integer value of this attribute ranges from 0-4. |
5 | range 0-4. | 5 | When read, this attribute returns the number of the actual |
6 | This file is readonly. | 6 | profile. This value is persistent, so its equivalent to the |
7 | profile that's active when the mouse is powered on next time. | ||
8 | When written, this file sets the number of the startup profile | ||
9 | and the mouse activates this profile immediately. | ||
7 | Users: http://roccat.sourceforge.net | 10 | Users: http://roccat.sourceforge.net |
8 | 11 | ||
9 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/firmware_version | 12 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/firmware_version |
@@ -89,16 +92,6 @@ Description: The mouse has a tracking- and a distance-control-unit. These | |||
89 | This file is writeonly. | 92 | This file is writeonly. |
90 | Users: http://roccat.sourceforge.net | 93 | Users: http://roccat.sourceforge.net |
91 | 94 | ||
92 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/startup_profile | ||
93 | Date: October 2010 | ||
94 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
95 | Description: The integer value of this attribute ranges from 0-4. | ||
96 | When read, this attribute returns the number of the profile | ||
97 | that's active when the mouse is powered on. | ||
98 | When written, this file sets the number of the startup profile | ||
99 | and the mouse activates this profile immediately. | ||
100 | Users: http://roccat.sourceforge.net | ||
101 | |||
102 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/tcu | 95 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/tcu |
103 | Date: October 2010 | 96 | Date: October 2010 |
104 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 97 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
diff --git a/drivers/hid/hid-roccat-koneplus.c b/drivers/hid/hid-roccat-koneplus.c index 33eec74e0615..5b640a7a15a7 100644 --- a/drivers/hid/hid-roccat-koneplus.c +++ b/drivers/hid/hid-roccat-koneplus.c | |||
@@ -167,28 +167,28 @@ static int koneplus_set_profile_buttons(struct usb_device *usb_dev, | |||
167 | } | 167 | } |
168 | 168 | ||
169 | /* retval is 0-4 on success, < 0 on error */ | 169 | /* retval is 0-4 on success, < 0 on error */ |
170 | static int koneplus_get_startup_profile(struct usb_device *usb_dev) | 170 | static int koneplus_get_actual_profile(struct usb_device *usb_dev) |
171 | { | 171 | { |
172 | struct koneplus_startup_profile buf; | 172 | struct koneplus_actual_profile buf; |
173 | int retval; | 173 | int retval; |
174 | 174 | ||
175 | retval = roccat_common_receive(usb_dev, KONEPLUS_USB_COMMAND_STARTUP_PROFILE, | 175 | retval = roccat_common_receive(usb_dev, KONEPLUS_USB_COMMAND_ACTUAL_PROFILE, |
176 | &buf, sizeof(struct koneplus_startup_profile)); | 176 | &buf, sizeof(struct koneplus_actual_profile)); |
177 | 177 | ||
178 | return retval ? retval : buf.startup_profile; | 178 | return retval ? retval : buf.actual_profile; |
179 | } | 179 | } |
180 | 180 | ||
181 | static int koneplus_set_startup_profile(struct usb_device *usb_dev, | 181 | static int koneplus_set_actual_profile(struct usb_device *usb_dev, |
182 | int startup_profile) | 182 | int new_profile) |
183 | { | 183 | { |
184 | struct koneplus_startup_profile buf; | 184 | struct koneplus_actual_profile buf; |
185 | 185 | ||
186 | buf.command = KONEPLUS_COMMAND_STARTUP_PROFILE; | 186 | buf.command = KONEPLUS_COMMAND_ACTUAL_PROFILE; |
187 | buf.size = sizeof(struct koneplus_startup_profile); | 187 | buf.size = sizeof(struct koneplus_actual_profile); |
188 | buf.startup_profile = startup_profile; | 188 | buf.actual_profile = new_profile; |
189 | 189 | ||
190 | return koneplus_send(usb_dev, KONEPLUS_USB_COMMAND_STARTUP_PROFILE, | 190 | return koneplus_send(usb_dev, KONEPLUS_USB_COMMAND_ACTUAL_PROFILE, |
191 | &buf, sizeof(struct koneplus_profile_buttons)); | 191 | &buf, sizeof(struct koneplus_actual_profile)); |
192 | } | 192 | } |
193 | 193 | ||
194 | static ssize_t koneplus_sysfs_read(struct file *fp, struct kobject *kobj, | 194 | static ssize_t koneplus_sysfs_read(struct file *fp, struct kobject *kobj, |
@@ -398,21 +398,22 @@ static ssize_t koneplus_sysfs_write_profile_buttons(struct file *fp, | |||
398 | return sizeof(struct koneplus_profile_buttons); | 398 | return sizeof(struct koneplus_profile_buttons); |
399 | } | 399 | } |
400 | 400 | ||
401 | static ssize_t koneplus_sysfs_show_startup_profile(struct device *dev, | 401 | static ssize_t koneplus_sysfs_show_actual_profile(struct device *dev, |
402 | struct device_attribute *attr, char *buf) | 402 | struct device_attribute *attr, char *buf) |
403 | { | 403 | { |
404 | struct koneplus_device *koneplus = | 404 | struct koneplus_device *koneplus = |
405 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); | 405 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); |
406 | return snprintf(buf, PAGE_SIZE, "%d\n", koneplus->startup_profile); | 406 | return snprintf(buf, PAGE_SIZE, "%d\n", koneplus->actual_profile); |
407 | } | 407 | } |
408 | 408 | ||
409 | static ssize_t koneplus_sysfs_set_startup_profile(struct device *dev, | 409 | static ssize_t koneplus_sysfs_set_actual_profile(struct device *dev, |
410 | struct device_attribute *attr, char const *buf, size_t size) | 410 | struct device_attribute *attr, char const *buf, size_t size) |
411 | { | 411 | { |
412 | struct koneplus_device *koneplus; | 412 | struct koneplus_device *koneplus; |
413 | struct usb_device *usb_dev; | 413 | struct usb_device *usb_dev; |
414 | unsigned long profile; | 414 | unsigned long profile; |
415 | int retval; | 415 | int retval; |
416 | struct koneplus_roccat_report roccat_report; | ||
416 | 417 | ||
417 | dev = dev->parent->parent; | 418 | dev = dev->parent->parent; |
418 | koneplus = hid_get_drvdata(dev_get_drvdata(dev)); | 419 | koneplus = hid_get_drvdata(dev_get_drvdata(dev)); |
@@ -423,20 +424,25 @@ static ssize_t koneplus_sysfs_set_startup_profile(struct device *dev, | |||
423 | return retval; | 424 | return retval; |
424 | 425 | ||
425 | mutex_lock(&koneplus->koneplus_lock); | 426 | mutex_lock(&koneplus->koneplus_lock); |
426 | retval = koneplus_set_startup_profile(usb_dev, profile); | 427 | |
427 | mutex_unlock(&koneplus->koneplus_lock); | 428 | retval = koneplus_set_actual_profile(usb_dev, profile); |
428 | if (retval) | 429 | if (retval) { |
430 | mutex_unlock(&koneplus->koneplus_lock); | ||
429 | return retval; | 431 | return retval; |
432 | } | ||
430 | 433 | ||
431 | return size; | 434 | koneplus->actual_profile = profile; |
432 | } | ||
433 | 435 | ||
434 | static ssize_t koneplus_sysfs_show_actual_profile(struct device *dev, | 436 | roccat_report.type = KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_PROFILE; |
435 | struct device_attribute *attr, char *buf) | 437 | roccat_report.data1 = profile + 1; |
436 | { | 438 | roccat_report.data2 = 0; |
437 | struct koneplus_device *koneplus = | 439 | roccat_report.profile = profile + 1; |
438 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); | 440 | roccat_report_event(koneplus->chrdev_minor, |
439 | return snprintf(buf, PAGE_SIZE, "%d\n", koneplus->actual_profile); | 441 | (uint8_t const *)&roccat_report); |
442 | |||
443 | mutex_unlock(&koneplus->koneplus_lock); | ||
444 | |||
445 | return size; | ||
440 | } | 446 | } |
441 | 447 | ||
442 | static ssize_t koneplus_sysfs_show_firmware_version(struct device *dev, | 448 | static ssize_t koneplus_sysfs_show_firmware_version(struct device *dev, |
@@ -448,11 +454,12 @@ static ssize_t koneplus_sysfs_show_firmware_version(struct device *dev, | |||
448 | } | 454 | } |
449 | 455 | ||
450 | static struct device_attribute koneplus_attributes[] = { | 456 | static struct device_attribute koneplus_attributes[] = { |
457 | __ATTR(actual_profile, 0660, | ||
458 | koneplus_sysfs_show_actual_profile, | ||
459 | koneplus_sysfs_set_actual_profile), | ||
451 | __ATTR(startup_profile, 0660, | 460 | __ATTR(startup_profile, 0660, |
452 | koneplus_sysfs_show_startup_profile, | 461 | koneplus_sysfs_show_actual_profile, |
453 | koneplus_sysfs_set_startup_profile), | 462 | koneplus_sysfs_set_actual_profile), |
454 | __ATTR(actual_profile, 0440, | ||
455 | koneplus_sysfs_show_actual_profile, NULL), | ||
456 | __ATTR(firmware_version, 0440, | 463 | __ATTR(firmware_version, 0440, |
457 | koneplus_sysfs_show_firmware_version, NULL), | 464 | koneplus_sysfs_show_firmware_version, NULL), |
458 | __ATTR_NULL | 465 | __ATTR_NULL |
@@ -557,15 +564,10 @@ static int koneplus_init_koneplus_device_struct(struct usb_device *usb_dev, | |||
557 | struct koneplus_device *koneplus) | 564 | struct koneplus_device *koneplus) |
558 | { | 565 | { |
559 | int retval, i; | 566 | int retval, i; |
560 | static uint wait = 100; /* device will freeze with just 60 */ | 567 | static uint wait = 200; |
561 | 568 | ||
562 | mutex_init(&koneplus->koneplus_lock); | 569 | mutex_init(&koneplus->koneplus_lock); |
563 | 570 | ||
564 | koneplus->startup_profile = koneplus_get_startup_profile(usb_dev); | ||
565 | if (koneplus->startup_profile < 0) | ||
566 | return koneplus->startup_profile; | ||
567 | |||
568 | msleep(wait); | ||
569 | retval = koneplus_get_info(usb_dev, &koneplus->info); | 571 | retval = koneplus_get_info(usb_dev, &koneplus->info); |
570 | if (retval) | 572 | if (retval) |
571 | return retval; | 573 | return retval; |
@@ -584,7 +586,11 @@ static int koneplus_init_koneplus_device_struct(struct usb_device *usb_dev, | |||
584 | return retval; | 586 | return retval; |
585 | } | 587 | } |
586 | 588 | ||
587 | koneplus_profile_activated(koneplus, koneplus->startup_profile); | 589 | msleep(wait); |
590 | retval = koneplus_get_actual_profile(usb_dev); | ||
591 | if (retval < 0) | ||
592 | return retval; | ||
593 | koneplus_profile_activated(koneplus, retval); | ||
588 | 594 | ||
589 | return 0; | 595 | return 0; |
590 | } | 596 | } |
diff --git a/drivers/hid/hid-roccat-koneplus.h b/drivers/hid/hid-roccat-koneplus.h index 57a5c1ab7b05..c57a376ab8ae 100644 --- a/drivers/hid/hid-roccat-koneplus.h +++ b/drivers/hid/hid-roccat-koneplus.h | |||
@@ -40,10 +40,10 @@ enum koneplus_control_values { | |||
40 | KONEPLUS_CONTROL_REQUEST_STATUS_WAIT = 3, | 40 | KONEPLUS_CONTROL_REQUEST_STATUS_WAIT = 3, |
41 | }; | 41 | }; |
42 | 42 | ||
43 | struct koneplus_startup_profile { | 43 | struct koneplus_actual_profile { |
44 | uint8_t command; /* KONEPLUS_COMMAND_STARTUP_PROFILE */ | 44 | uint8_t command; /* KONEPLUS_COMMAND_ACTUAL_PROFILE */ |
45 | uint8_t size; /* always 3 */ | 45 | uint8_t size; /* always 3 */ |
46 | uint8_t startup_profile; /* Range 0-4! */ | 46 | uint8_t actual_profile; /* Range 0-4! */ |
47 | } __attribute__ ((__packed__)); | 47 | } __attribute__ ((__packed__)); |
48 | 48 | ||
49 | struct koneplus_profile_settings { | 49 | struct koneplus_profile_settings { |
@@ -132,7 +132,7 @@ struct koneplus_tcu_image { | |||
132 | 132 | ||
133 | enum koneplus_commands { | 133 | enum koneplus_commands { |
134 | KONEPLUS_COMMAND_CONTROL = 0x4, | 134 | KONEPLUS_COMMAND_CONTROL = 0x4, |
135 | KONEPLUS_COMMAND_STARTUP_PROFILE = 0x5, | 135 | KONEPLUS_COMMAND_ACTUAL_PROFILE = 0x5, |
136 | KONEPLUS_COMMAND_PROFILE_SETTINGS = 0x6, | 136 | KONEPLUS_COMMAND_PROFILE_SETTINGS = 0x6, |
137 | KONEPLUS_COMMAND_PROFILE_BUTTONS = 0x7, | 137 | KONEPLUS_COMMAND_PROFILE_BUTTONS = 0x7, |
138 | KONEPLUS_COMMAND_MACRO = 0x8, | 138 | KONEPLUS_COMMAND_MACRO = 0x8, |
@@ -145,7 +145,7 @@ enum koneplus_commands { | |||
145 | 145 | ||
146 | enum koneplus_usb_commands { | 146 | enum koneplus_usb_commands { |
147 | KONEPLUS_USB_COMMAND_CONTROL = 0x304, | 147 | KONEPLUS_USB_COMMAND_CONTROL = 0x304, |
148 | KONEPLUS_USB_COMMAND_STARTUP_PROFILE = 0x305, | 148 | KONEPLUS_USB_COMMAND_ACTUAL_PROFILE = 0x305, |
149 | KONEPLUS_USB_COMMAND_PROFILE_SETTINGS = 0x306, | 149 | KONEPLUS_USB_COMMAND_PROFILE_SETTINGS = 0x306, |
150 | KONEPLUS_USB_COMMAND_PROFILE_BUTTONS = 0x307, | 150 | KONEPLUS_USB_COMMAND_PROFILE_BUTTONS = 0x307, |
151 | KONEPLUS_USB_COMMAND_MACRO = 0x308, | 151 | KONEPLUS_USB_COMMAND_MACRO = 0x308, |
@@ -215,7 +215,6 @@ struct koneplus_device { | |||
215 | 215 | ||
216 | struct mutex koneplus_lock; | 216 | struct mutex koneplus_lock; |
217 | 217 | ||
218 | int startup_profile; | ||
219 | struct koneplus_info info; | 218 | struct koneplus_info info; |
220 | struct koneplus_profile_settings profile_settings[5]; | 219 | struct koneplus_profile_settings profile_settings[5]; |
221 | struct koneplus_profile_buttons profile_buttons[5]; | 220 | struct koneplus_profile_buttons profile_buttons[5]; |