diff options
| author | Stefan Achatz <erazor_de@users.sourceforge.net> | 2011-04-13 11:17:52 -0400 |
|---|---|---|
| committer | Jiri Kosina <jkosina@suse.cz> | 2011-05-18 10:34:06 -0400 |
| commit | b50f315cbb865079a16a12fd9ae6083f98fd592c (patch) | |
| tree | 794cf42e85434ff785531efda78490f123d3d258 /drivers/hid | |
| parent | dd2ed487fdd78b50549b2ca8418875c0d9f4a30e (diff) | |
HID: roccat: fix actual/startup profile sysfs attribute in koneplus
startup_profile and actual_profile didn't work as expected. Also
as the actual profile is persistent, the distinction between the
two was ambiguous, so both use the same code now and startup_profile
has been deprecated. Also the event is now propagated through
chardev. The userland tool has been updated to support this change.
Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
| -rw-r--r-- | drivers/hid/hid-roccat-koneplus.c | 82 | ||||
| -rw-r--r-- | drivers/hid/hid-roccat-koneplus.h | 11 |
2 files changed, 49 insertions, 44 deletions
diff --git a/drivers/hid/hid-roccat-koneplus.c b/drivers/hid/hid-roccat-koneplus.c index 33eec74e061..5b640a7a15a 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 57a5c1ab7b0..c57a376ab8a 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]; |
