Lines Matching +full:hw +full:- +full:settle +full:- +full:time
1 // SPDX-License-Identifier: GPL-2.0-or-later
14 * key- and button-events.
16 * TODO implement on-the-fly polling-rate change
19 * Is it possible to remove and reinstall the urb in raw-event- or any
30 #include <linux/hid-roccat.h>
31 #include "hid-ids.h"
32 #include "hid-roccat-common.h"
33 #include "hid-roccat-kone.h"
39 kone->actual_profile = new_profile; in kone_profile_activated()
40 kone->actual_dpi = kone->profiles[new_profile - 1].startup_dpi; in kone_profile_activated()
50 roccat_report_event(kone->chrdev_minor, (uint8_t *)&roccat_report); in kone_profile_report()
61 return -ENOMEM; in kone_receive()
70 return ((len < 0) ? len : ((len != size) ? -EIO : 0)); in kone_receive()
81 return -ENOMEM; in kone_send()
89 return ((len < 0) ? len : ((len != size) ? -EIO : 0)); in kone_send()
98 for (i = 0; i < sizeof(struct kone_settings) - 2; ++i, ++address) in kone_set_settings_checksum()
100 settings->checksum = cpu_to_le16(checksum); in kone_set_settings_checksum()
136 dev_err(&usb_dev->dev, "got retval %d when checking write\n", data); in kone_check_write()
137 return -EIO; in kone_check_write()
181 return -EINVAL; in kone_get_profile()
190 return -EIO; in kone_get_profile()
207 return -EINVAL; in kone_set_profile()
220 return -EIO; in kone_set_profile()
226 * Reads value of "fast-clip-weight" and stores it in @result
266 struct device *dev = kobj_to_dev(kobj)->parent->parent; in kone_sysfs_read_settings()
273 count = sizeof(struct kone_settings) - off; in kone_sysfs_read_settings()
275 mutex_lock(&kone->kone_lock); in kone_sysfs_read_settings()
276 memcpy(buf, ((char const *)&kone->settings) + off, count); in kone_sysfs_read_settings()
277 mutex_unlock(&kone->kone_lock); in kone_sysfs_read_settings()
290 struct device *dev = kobj_to_dev(kobj)->parent->parent; in kone_sysfs_write_settings()
298 return -EINVAL; in kone_sysfs_write_settings()
300 mutex_lock(&kone->kone_lock); in kone_sysfs_write_settings()
301 difference = memcmp(settings, &kone->settings, in kone_sysfs_write_settings()
304 if (settings->startup_profile < 1 || in kone_sysfs_write_settings()
305 settings->startup_profile > 5) { in kone_sysfs_write_settings()
306 retval = -EINVAL; in kone_sysfs_write_settings()
314 old_profile = kone->settings.startup_profile; in kone_sysfs_write_settings()
315 memcpy(&kone->settings, settings, sizeof(struct kone_settings)); in kone_sysfs_write_settings()
317 kone_profile_activated(kone, kone->settings.startup_profile); in kone_sysfs_write_settings()
319 if (kone->settings.startup_profile != old_profile) in kone_sysfs_write_settings()
320 kone_profile_report(kone, kone->settings.startup_profile); in kone_sysfs_write_settings()
323 mutex_unlock(&kone->kone_lock); in kone_sysfs_write_settings()
336 struct device *dev = kobj_to_dev(kobj)->parent->parent; in kone_sysfs_read_profilex()
343 count = sizeof(struct kone_profile) - off; in kone_sysfs_read_profilex()
345 mutex_lock(&kone->kone_lock); in kone_sysfs_read_profilex()
346 memcpy(buf, ((char const *)&kone->profiles[*(uint *)(attr->private)]) + off, count); in kone_sysfs_read_profilex()
347 mutex_unlock(&kone->kone_lock); in kone_sysfs_read_profilex()
356 struct device *dev = kobj_to_dev(kobj)->parent->parent; in kone_sysfs_write_profilex()
364 return -EINVAL; in kone_sysfs_write_profilex()
366 profile = &kone->profiles[*(uint *)(attr->private)]; in kone_sysfs_write_profilex()
368 mutex_lock(&kone->kone_lock); in kone_sysfs_write_profilex()
373 *(uint *)(attr->private) + 1); in kone_sysfs_write_profilex()
377 mutex_unlock(&kone->kone_lock); in kone_sysfs_write_profilex()
390 .private = &profile_numbers[number-1], \
402 hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); in kone_sysfs_show_actual_profile()
403 return sysfs_emit(buf, "%d\n", kone->actual_profile); in kone_sysfs_show_actual_profile()
411 hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); in kone_sysfs_show_actual_dpi()
412 return sysfs_emit(buf, "%d\n", kone->actual_dpi); in kone_sysfs_show_actual_dpi()
416 /* weight is read each time, since we don't get informed when it's changed */
425 dev = dev->parent->parent; in kone_sysfs_show_weight()
429 mutex_lock(&kone->kone_lock); in kone_sysfs_show_weight()
431 mutex_unlock(&kone->kone_lock); in kone_sysfs_show_weight()
443 hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); in kone_sysfs_show_firmware_version()
444 return sysfs_emit(buf, "%d\n", kone->firmware_version); in kone_sysfs_show_firmware_version()
453 hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); in kone_sysfs_show_tcu()
454 return sysfs_emit(buf, "%d\n", kone->settings.tcu); in kone_sysfs_show_tcu()
477 dev = dev->parent->parent; in kone_sysfs_set_tcu()
486 return -EINVAL; in kone_sysfs_set_tcu()
488 mutex_lock(&kone->kone_lock); in kone_sysfs_set_tcu()
497 ssleep(5); /* tcu needs this time for calibration */ in kone_sysfs_set_tcu()
508 * Kone needs this time to settle things. in kone_sysfs_set_tcu()
510 * Roccat's driver waits 1 sec, maybe this time could be in kone_sysfs_set_tcu()
517 retval = kone_get_settings(usb_dev, &kone->settings); in kone_sysfs_set_tcu()
522 if (kone->settings.tcu != state) { in kone_sysfs_set_tcu()
523 kone->settings.tcu = state; in kone_sysfs_set_tcu()
524 kone_set_settings_checksum(&kone->settings); in kone_sysfs_set_tcu()
526 retval = kone_set_settings(usb_dev, &kone->settings); in kone_sysfs_set_tcu()
528 dev_err(&usb_dev->dev, "couldn't set tcu state\n"); in kone_sysfs_set_tcu()
533 retval = kone_get_settings(usb_dev, &kone->settings); in kone_sysfs_set_tcu()
539 kone_profile_activated(kone, kone->settings.startup_profile); in kone_sysfs_set_tcu()
544 dev_err(&usb_dev->dev, "couldn't read settings\n"); in kone_sysfs_set_tcu()
546 mutex_unlock(&kone->kone_lock); in kone_sysfs_set_tcu()
555 hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); in kone_sysfs_show_startup_profile()
556 return sysfs_emit(buf, "%d\n", kone->settings.startup_profile); in kone_sysfs_show_startup_profile()
567 dev = dev->parent->parent; in kone_sysfs_set_startup_profile()
576 return -EINVAL; in kone_sysfs_set_startup_profile()
578 mutex_lock(&kone->kone_lock); in kone_sysfs_set_startup_profile()
580 kone->settings.startup_profile = new_startup_profile; in kone_sysfs_set_startup_profile()
581 kone_set_settings_checksum(&kone->settings); in kone_sysfs_set_startup_profile()
583 retval = kone_set_settings(usb_dev, &kone->settings); in kone_sysfs_set_startup_profile()
585 mutex_unlock(&kone->kone_lock); in kone_sysfs_set_startup_profile()
593 mutex_unlock(&kone->kone_lock); in kone_sysfs_set_startup_profile()
669 mutex_init(&kone->kone_lock); in kone_init_kone_device_struct()
672 retval = kone_get_profile(usb_dev, &kone->profiles[i], i + 1); in kone_init_kone_device_struct()
677 retval = kone_get_settings(usb_dev, &kone->settings); in kone_init_kone_device_struct()
681 retval = kone_get_firmware_version(usb_dev, &kone->firmware_version); in kone_init_kone_device_struct()
685 kone_profile_activated(kone, kone->settings.startup_profile); in kone_init_kone_device_struct()
691 * Since IGNORE_MOUSE quirk moved to hid-apple, there is no way to bind only to
699 struct usb_interface *intf = to_usb_interface(hdev->dev.parent); in kone_init_specials()
704 if (intf->cur_altsetting->desc.bInterfaceProtocol in kone_init_specials()
709 return -ENOMEM; in kone_init_specials()
724 kone->roccat_claimed = 1; in kone_init_specials()
725 kone->chrdev_minor = retval; in kone_init_specials()
739 struct usb_interface *intf = to_usb_interface(hdev->dev.parent); in kone_remove_specials()
742 if (intf->cur_altsetting->desc.bInterfaceProtocol in kone_remove_specials()
745 if (kone->roccat_claimed) in kone_remove_specials()
746 roccat_disconnect(kone->chrdev_minor); in kone_remove_specials()
756 return -EINVAL; in kone_probe()
766 hid_err(hdev, "hw start failed\n"); in kone_probe()
794 switch (event->event) { in kone_keep_values_up_to_date()
796 kone->actual_dpi = kone->profiles[event->value - 1]. in kone_keep_values_up_to_date()
800 kone->actual_profile = event->value; in kone_keep_values_up_to_date()
804 kone->actual_dpi = event->value; in kone_keep_values_up_to_date()
814 switch (event->event) { in kone_report_to_chrdev()
819 roccat_report.event = event->event; in kone_report_to_chrdev()
820 roccat_report.value = event->value; in kone_report_to_chrdev()
822 roccat_report_event(kone->chrdev_minor, in kone_report_to_chrdev()
827 if (event->value == kone_keystroke_action_press) { in kone_report_to_chrdev()
828 roccat_report.event = event->event; in kone_report_to_chrdev()
829 roccat_report.value = kone->actual_profile; in kone_report_to_chrdev()
830 roccat_report.key = event->macro_key; in kone_report_to_chrdev()
831 roccat_report_event(kone->chrdev_minor, in kone_report_to_chrdev()
840 * Is called for keyboard- and mousepart.
862 if (memcmp(&kone->last_mouse_event.tilt, &event->tilt, 5)) in kone_raw_event()
863 memcpy(&kone->last_mouse_event, event, in kone_raw_event()
866 memset(&event->wipe, 0, sizeof(event->wipe)); in kone_raw_event()
870 if (kone->roccat_claimed) in kone_raw_event()