diff options
Diffstat (limited to 'drivers/hid/hid-roccat-kone.c')
-rw-r--r-- | drivers/hid/hid-roccat-kone.c | 73 |
1 files changed, 61 insertions, 12 deletions
diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c index 66e694054ba2..17f2dc04f883 100644 --- a/drivers/hid/hid-roccat-kone.c +++ b/drivers/hid/hid-roccat-kone.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/module.h> | 37 | #include <linux/module.h> |
38 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
39 | #include "hid-ids.h" | 39 | #include "hid-ids.h" |
40 | #include "hid-roccat.h" | ||
40 | #include "hid-roccat-kone.h" | 41 | #include "hid-roccat-kone.h" |
41 | 42 | ||
42 | static void kone_set_settings_checksum(struct kone_settings *settings) | 43 | static void kone_set_settings_checksum(struct kone_settings *settings) |
@@ -263,7 +264,7 @@ static int kone_get_firmware_version(struct usb_device *usb_dev, int *result) | |||
263 | return 0; | 264 | return 0; |
264 | } | 265 | } |
265 | 266 | ||
266 | static ssize_t kone_sysfs_read_settings(struct kobject *kobj, | 267 | static ssize_t kone_sysfs_read_settings(struct file *fp, struct kobject *kobj, |
267 | struct bin_attribute *attr, char *buf, | 268 | struct bin_attribute *attr, char *buf, |
268 | loff_t off, size_t count) { | 269 | loff_t off, size_t count) { |
269 | struct device *dev = container_of(kobj, struct device, kobj); | 270 | struct device *dev = container_of(kobj, struct device, kobj); |
@@ -287,7 +288,7 @@ static ssize_t kone_sysfs_read_settings(struct kobject *kobj, | |||
287 | * This function keeps values in kone_device up to date and assumes that in | 288 | * This function keeps values in kone_device up to date and assumes that in |
288 | * case of error the old data is still valid | 289 | * case of error the old data is still valid |
289 | */ | 290 | */ |
290 | static ssize_t kone_sysfs_write_settings(struct kobject *kobj, | 291 | static ssize_t kone_sysfs_write_settings(struct file *fp, struct kobject *kobj, |
291 | struct bin_attribute *attr, char *buf, | 292 | struct bin_attribute *attr, char *buf, |
292 | loff_t off, size_t count) { | 293 | loff_t off, size_t count) { |
293 | struct device *dev = container_of(kobj, struct device, kobj); | 294 | struct device *dev = container_of(kobj, struct device, kobj); |
@@ -342,31 +343,31 @@ static ssize_t kone_sysfs_read_profilex(struct kobject *kobj, | |||
342 | return count; | 343 | return count; |
343 | } | 344 | } |
344 | 345 | ||
345 | static ssize_t kone_sysfs_read_profile1(struct kobject *kobj, | 346 | static ssize_t kone_sysfs_read_profile1(struct file *fp, struct kobject *kobj, |
346 | struct bin_attribute *attr, char *buf, | 347 | struct bin_attribute *attr, char *buf, |
347 | loff_t off, size_t count) { | 348 | loff_t off, size_t count) { |
348 | return kone_sysfs_read_profilex(kobj, attr, buf, off, count, 1); | 349 | return kone_sysfs_read_profilex(kobj, attr, buf, off, count, 1); |
349 | } | 350 | } |
350 | 351 | ||
351 | static ssize_t kone_sysfs_read_profile2(struct kobject *kobj, | 352 | static ssize_t kone_sysfs_read_profile2(struct file *fp, struct kobject *kobj, |
352 | struct bin_attribute *attr, char *buf, | 353 | struct bin_attribute *attr, char *buf, |
353 | loff_t off, size_t count) { | 354 | loff_t off, size_t count) { |
354 | return kone_sysfs_read_profilex(kobj, attr, buf, off, count, 2); | 355 | return kone_sysfs_read_profilex(kobj, attr, buf, off, count, 2); |
355 | } | 356 | } |
356 | 357 | ||
357 | static ssize_t kone_sysfs_read_profile3(struct kobject *kobj, | 358 | static ssize_t kone_sysfs_read_profile3(struct file *fp, struct kobject *kobj, |
358 | struct bin_attribute *attr, char *buf, | 359 | struct bin_attribute *attr, char *buf, |
359 | loff_t off, size_t count) { | 360 | loff_t off, size_t count) { |
360 | return kone_sysfs_read_profilex(kobj, attr, buf, off, count, 3); | 361 | return kone_sysfs_read_profilex(kobj, attr, buf, off, count, 3); |
361 | } | 362 | } |
362 | 363 | ||
363 | static ssize_t kone_sysfs_read_profile4(struct kobject *kobj, | 364 | static ssize_t kone_sysfs_read_profile4(struct file *fp, struct kobject *kobj, |
364 | struct bin_attribute *attr, char *buf, | 365 | struct bin_attribute *attr, char *buf, |
365 | loff_t off, size_t count) { | 366 | loff_t off, size_t count) { |
366 | return kone_sysfs_read_profilex(kobj, attr, buf, off, count, 4); | 367 | return kone_sysfs_read_profilex(kobj, attr, buf, off, count, 4); |
367 | } | 368 | } |
368 | 369 | ||
369 | static ssize_t kone_sysfs_read_profile5(struct kobject *kobj, | 370 | static ssize_t kone_sysfs_read_profile5(struct file *fp, struct kobject *kobj, |
370 | struct bin_attribute *attr, char *buf, | 371 | struct bin_attribute *attr, char *buf, |
371 | loff_t off, size_t count) { | 372 | loff_t off, size_t count) { |
372 | return kone_sysfs_read_profilex(kobj, attr, buf, off, count, 5); | 373 | return kone_sysfs_read_profilex(kobj, attr, buf, off, count, 5); |
@@ -404,31 +405,31 @@ static ssize_t kone_sysfs_write_profilex(struct kobject *kobj, | |||
404 | return sizeof(struct kone_profile); | 405 | return sizeof(struct kone_profile); |
405 | } | 406 | } |
406 | 407 | ||
407 | static ssize_t kone_sysfs_write_profile1(struct kobject *kobj, | 408 | static ssize_t kone_sysfs_write_profile1(struct file *fp, struct kobject *kobj, |
408 | struct bin_attribute *attr, char *buf, | 409 | struct bin_attribute *attr, char *buf, |
409 | loff_t off, size_t count) { | 410 | loff_t off, size_t count) { |
410 | return kone_sysfs_write_profilex(kobj, attr, buf, off, count, 1); | 411 | return kone_sysfs_write_profilex(kobj, attr, buf, off, count, 1); |
411 | } | 412 | } |
412 | 413 | ||
413 | static ssize_t kone_sysfs_write_profile2(struct kobject *kobj, | 414 | static ssize_t kone_sysfs_write_profile2(struct file *fp, struct kobject *kobj, |
414 | struct bin_attribute *attr, char *buf, | 415 | struct bin_attribute *attr, char *buf, |
415 | loff_t off, size_t count) { | 416 | loff_t off, size_t count) { |
416 | return kone_sysfs_write_profilex(kobj, attr, buf, off, count, 2); | 417 | return kone_sysfs_write_profilex(kobj, attr, buf, off, count, 2); |
417 | } | 418 | } |
418 | 419 | ||
419 | static ssize_t kone_sysfs_write_profile3(struct kobject *kobj, | 420 | static ssize_t kone_sysfs_write_profile3(struct file *fp, struct kobject *kobj, |
420 | struct bin_attribute *attr, char *buf, | 421 | struct bin_attribute *attr, char *buf, |
421 | loff_t off, size_t count) { | 422 | loff_t off, size_t count) { |
422 | return kone_sysfs_write_profilex(kobj, attr, buf, off, count, 3); | 423 | return kone_sysfs_write_profilex(kobj, attr, buf, off, count, 3); |
423 | } | 424 | } |
424 | 425 | ||
425 | static ssize_t kone_sysfs_write_profile4(struct kobject *kobj, | 426 | static ssize_t kone_sysfs_write_profile4(struct file *fp, struct kobject *kobj, |
426 | struct bin_attribute *attr, char *buf, | 427 | struct bin_attribute *attr, char *buf, |
427 | loff_t off, size_t count) { | 428 | loff_t off, size_t count) { |
428 | return kone_sysfs_write_profilex(kobj, attr, buf, off, count, 4); | 429 | return kone_sysfs_write_profilex(kobj, attr, buf, off, count, 4); |
429 | } | 430 | } |
430 | 431 | ||
431 | static ssize_t kone_sysfs_write_profile5(struct kobject *kobj, | 432 | static ssize_t kone_sysfs_write_profile5(struct file *fp, struct kobject *kobj, |
432 | struct bin_attribute *attr, char *buf, | 433 | struct bin_attribute *attr, char *buf, |
433 | loff_t off, size_t count) { | 434 | loff_t off, size_t count) { |
434 | return kone_sysfs_write_profilex(kobj, attr, buf, off, count, 5); | 435 | return kone_sysfs_write_profilex(kobj, attr, buf, off, count, 5); |
@@ -849,6 +850,16 @@ static int kone_init_specials(struct hid_device *hdev) | |||
849 | "couldn't init struct kone_device\n"); | 850 | "couldn't init struct kone_device\n"); |
850 | goto exit_free; | 851 | goto exit_free; |
851 | } | 852 | } |
853 | |||
854 | retval = roccat_connect(hdev); | ||
855 | if (retval < 0) { | ||
856 | dev_err(&hdev->dev, "couldn't init char dev\n"); | ||
857 | /* be tolerant about not getting chrdev */ | ||
858 | } else { | ||
859 | kone->roccat_claimed = 1; | ||
860 | kone->chrdev_minor = retval; | ||
861 | } | ||
862 | |||
852 | retval = kone_create_sysfs_attributes(intf); | 863 | retval = kone_create_sysfs_attributes(intf); |
853 | if (retval) { | 864 | if (retval) { |
854 | dev_err(&hdev->dev, "cannot create sysfs files\n"); | 865 | dev_err(&hdev->dev, "cannot create sysfs files\n"); |
@@ -868,10 +879,14 @@ exit_free: | |||
868 | static void kone_remove_specials(struct hid_device *hdev) | 879 | static void kone_remove_specials(struct hid_device *hdev) |
869 | { | 880 | { |
870 | struct usb_interface *intf = to_usb_interface(hdev->dev.parent); | 881 | struct usb_interface *intf = to_usb_interface(hdev->dev.parent); |
882 | struct kone_device *kone; | ||
871 | 883 | ||
872 | if (intf->cur_altsetting->desc.bInterfaceProtocol | 884 | if (intf->cur_altsetting->desc.bInterfaceProtocol |
873 | == USB_INTERFACE_PROTOCOL_MOUSE) { | 885 | == USB_INTERFACE_PROTOCOL_MOUSE) { |
874 | kone_remove_sysfs_attributes(intf); | 886 | kone_remove_sysfs_attributes(intf); |
887 | kone = hid_get_drvdata(hdev); | ||
888 | if (kone->roccat_claimed) | ||
889 | roccat_disconnect(kone->chrdev_minor); | ||
875 | kfree(hid_get_drvdata(hdev)); | 890 | kfree(hid_get_drvdata(hdev)); |
876 | } | 891 | } |
877 | } | 892 | } |
@@ -930,6 +945,37 @@ static void kone_keep_values_up_to_date(struct kone_device *kone, | |||
930 | } | 945 | } |
931 | } | 946 | } |
932 | 947 | ||
948 | static void kone_report_to_chrdev(struct kone_device const *kone, | ||
949 | struct kone_mouse_event const *event) | ||
950 | { | ||
951 | struct kone_roccat_report roccat_report; | ||
952 | |||
953 | switch (event->event) { | ||
954 | case kone_mouse_event_switch_profile: | ||
955 | case kone_mouse_event_switch_dpi: | ||
956 | case kone_mouse_event_osd_profile: | ||
957 | case kone_mouse_event_osd_dpi: | ||
958 | roccat_report.event = event->event; | ||
959 | roccat_report.value = event->value; | ||
960 | roccat_report.key = 0; | ||
961 | roccat_report_event(kone->chrdev_minor, | ||
962 | (uint8_t *)&roccat_report, | ||
963 | sizeof(struct kone_roccat_report)); | ||
964 | break; | ||
965 | case kone_mouse_event_call_overlong_macro: | ||
966 | if (event->value == kone_keystroke_action_press) { | ||
967 | roccat_report.event = kone_mouse_event_call_overlong_macro; | ||
968 | roccat_report.value = kone->actual_profile; | ||
969 | roccat_report.key = event->macro_key; | ||
970 | roccat_report_event(kone->chrdev_minor, | ||
971 | (uint8_t *)&roccat_report, | ||
972 | sizeof(struct kone_roccat_report)); | ||
973 | } | ||
974 | break; | ||
975 | } | ||
976 | |||
977 | } | ||
978 | |||
933 | /* | 979 | /* |
934 | * Is called for keyboard- and mousepart. | 980 | * Is called for keyboard- and mousepart. |
935 | * Only mousepart gets informations about special events in its extended event | 981 | * Only mousepart gets informations about special events in its extended event |
@@ -958,6 +1004,9 @@ static int kone_raw_event(struct hid_device *hdev, struct hid_report *report, | |||
958 | 1004 | ||
959 | kone_keep_values_up_to_date(kone, event); | 1005 | kone_keep_values_up_to_date(kone, event); |
960 | 1006 | ||
1007 | if (kone->roccat_claimed) | ||
1008 | kone_report_to_chrdev(kone, event); | ||
1009 | |||
961 | return 0; /* always do further processing */ | 1010 | return 0; /* always do further processing */ |
962 | } | 1011 | } |
963 | 1012 | ||