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()
101 for (i = 0; i < sizeof(struct kone_settings) - 2; ++i, ++address) in kone_set_settings_checksum()
103 settings->checksum = cpu_to_le16(checksum); in kone_set_settings_checksum()
139 dev_err(&usb_dev->dev, "got retval %d when checking write\n", data); in kone_check_write()
140 return -EIO; in kone_check_write()
184 return -EINVAL; in kone_get_profile()
193 return -EIO; in kone_get_profile()
210 return -EINVAL; in kone_set_profile()
223 return -EIO; in kone_set_profile()
229 * Reads value of "fast-clip-weight" and stores it in @result
269 struct device *dev = kobj_to_dev(kobj)->parent->parent; in kone_sysfs_read_settings()
276 count = sizeof(struct kone_settings) - off; in kone_sysfs_read_settings()
278 mutex_lock(&kone->kone_lock); in kone_sysfs_read_settings()
279 memcpy(buf, ((char const *)&kone->settings) + off, count); in kone_sysfs_read_settings()
280 mutex_unlock(&kone->kone_lock); in kone_sysfs_read_settings()
293 struct device *dev = kobj_to_dev(kobj)->parent->parent; in kone_sysfs_write_settings()
301 return -EINVAL; in kone_sysfs_write_settings()
303 mutex_lock(&kone->kone_lock); in kone_sysfs_write_settings()
304 difference = memcmp(settings, &kone->settings, in kone_sysfs_write_settings()
307 if (settings->startup_profile < 1 || in kone_sysfs_write_settings()
308 settings->startup_profile > 5) { in kone_sysfs_write_settings()
309 retval = -EINVAL; in kone_sysfs_write_settings()
317 old_profile = kone->settings.startup_profile; in kone_sysfs_write_settings()
318 memcpy(&kone->settings, settings, sizeof(struct kone_settings)); in kone_sysfs_write_settings()
320 kone_profile_activated(kone, kone->settings.startup_profile); in kone_sysfs_write_settings()
322 if (kone->settings.startup_profile != old_profile) in kone_sysfs_write_settings()
323 kone_profile_report(kone, kone->settings.startup_profile); in kone_sysfs_write_settings()
326 mutex_unlock(&kone->kone_lock); in kone_sysfs_write_settings()
339 struct device *dev = kobj_to_dev(kobj)->parent->parent; in kone_sysfs_read_profilex()
346 count = sizeof(struct kone_profile) - off; in kone_sysfs_read_profilex()
348 mutex_lock(&kone->kone_lock); in kone_sysfs_read_profilex()
349 memcpy(buf, ((char const *)&kone->profiles[*(uint *)(attr->private)]) + off, count); in kone_sysfs_read_profilex()
350 mutex_unlock(&kone->kone_lock); in kone_sysfs_read_profilex()
359 struct device *dev = kobj_to_dev(kobj)->parent->parent; in kone_sysfs_write_profilex()
367 return -EINVAL; in kone_sysfs_write_profilex()
369 profile = &kone->profiles[*(uint *)(attr->private)]; in kone_sysfs_write_profilex()
371 mutex_lock(&kone->kone_lock); in kone_sysfs_write_profilex()
376 *(uint *)(attr->private) + 1); in kone_sysfs_write_profilex()
380 mutex_unlock(&kone->kone_lock); in kone_sysfs_write_profilex()
393 .private = &profile_numbers[number-1], \
405 hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); in kone_sysfs_show_actual_profile()
406 return snprintf(buf, PAGE_SIZE, "%d\n", kone->actual_profile); in kone_sysfs_show_actual_profile()
414 hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); in kone_sysfs_show_actual_dpi()
415 return snprintf(buf, PAGE_SIZE, "%d\n", kone->actual_dpi); in kone_sysfs_show_actual_dpi()
419 /* weight is read each time, since we don't get informed when it's changed */
428 dev = dev->parent->parent; in kone_sysfs_show_weight()
432 mutex_lock(&kone->kone_lock); in kone_sysfs_show_weight()
434 mutex_unlock(&kone->kone_lock); in kone_sysfs_show_weight()
446 hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); in kone_sysfs_show_firmware_version()
447 return snprintf(buf, PAGE_SIZE, "%d\n", kone->firmware_version); in kone_sysfs_show_firmware_version()
456 hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); in kone_sysfs_show_tcu()
457 return snprintf(buf, PAGE_SIZE, "%d\n", kone->settings.tcu); in kone_sysfs_show_tcu()
480 dev = dev->parent->parent; in kone_sysfs_set_tcu()
489 return -EINVAL; in kone_sysfs_set_tcu()
491 mutex_lock(&kone->kone_lock); in kone_sysfs_set_tcu()
500 ssleep(5); /* tcu needs this time for calibration */ in kone_sysfs_set_tcu()
511 * Kone needs this time to settle things. in kone_sysfs_set_tcu()
513 * Roccat's driver waits 1 sec, maybe this time could be in kone_sysfs_set_tcu()
520 retval = kone_get_settings(usb_dev, &kone->settings); in kone_sysfs_set_tcu()
525 if (kone->settings.tcu != state) { in kone_sysfs_set_tcu()
526 kone->settings.tcu = state; in kone_sysfs_set_tcu()
527 kone_set_settings_checksum(&kone->settings); in kone_sysfs_set_tcu()
529 retval = kone_set_settings(usb_dev, &kone->settings); in kone_sysfs_set_tcu()
531 dev_err(&usb_dev->dev, "couldn't set tcu state\n"); in kone_sysfs_set_tcu()
536 retval = kone_get_settings(usb_dev, &kone->settings); in kone_sysfs_set_tcu()
542 kone_profile_activated(kone, kone->settings.startup_profile); in kone_sysfs_set_tcu()
547 dev_err(&usb_dev->dev, "couldn't read settings\n"); in kone_sysfs_set_tcu()
549 mutex_unlock(&kone->kone_lock); in kone_sysfs_set_tcu()
558 hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); in kone_sysfs_show_startup_profile()
559 return snprintf(buf, PAGE_SIZE, "%d\n", kone->settings.startup_profile); in kone_sysfs_show_startup_profile()
570 dev = dev->parent->parent; in kone_sysfs_set_startup_profile()
579 return -EINVAL; in kone_sysfs_set_startup_profile()
581 mutex_lock(&kone->kone_lock); in kone_sysfs_set_startup_profile()
583 kone->settings.startup_profile = new_startup_profile; in kone_sysfs_set_startup_profile()
584 kone_set_settings_checksum(&kone->settings); in kone_sysfs_set_startup_profile()
586 retval = kone_set_settings(usb_dev, &kone->settings); in kone_sysfs_set_startup_profile()
588 mutex_unlock(&kone->kone_lock); in kone_sysfs_set_startup_profile()
596 mutex_unlock(&kone->kone_lock); in kone_sysfs_set_startup_profile()
666 mutex_init(&kone->kone_lock); in kone_init_kone_device_struct()
669 retval = kone_get_profile(usb_dev, &kone->profiles[i], i + 1); in kone_init_kone_device_struct()
674 retval = kone_get_settings(usb_dev, &kone->settings); in kone_init_kone_device_struct()
678 retval = kone_get_firmware_version(usb_dev, &kone->firmware_version); in kone_init_kone_device_struct()
682 kone_profile_activated(kone, kone->settings.startup_profile); in kone_init_kone_device_struct()
688 * Since IGNORE_MOUSE quirk moved to hid-apple, there is no way to bind only to
696 struct usb_interface *intf = to_usb_interface(hdev->dev.parent); in kone_init_specials()
701 if (intf->cur_altsetting->desc.bInterfaceProtocol in kone_init_specials()
706 return -ENOMEM; in kone_init_specials()
721 kone->roccat_claimed = 1; in kone_init_specials()
722 kone->chrdev_minor = retval; in kone_init_specials()
736 struct usb_interface *intf = to_usb_interface(hdev->dev.parent); in kone_remove_specials()
739 if (intf->cur_altsetting->desc.bInterfaceProtocol in kone_remove_specials()
742 if (kone->roccat_claimed) in kone_remove_specials()
743 roccat_disconnect(kone->chrdev_minor); in kone_remove_specials()
760 hid_err(hdev, "hw start failed\n"); in kone_probe()
788 switch (event->event) { in kone_keep_values_up_to_date()
790 kone->actual_dpi = kone->profiles[event->value - 1]. in kone_keep_values_up_to_date()
794 kone->actual_profile = event->value; in kone_keep_values_up_to_date()
798 kone->actual_dpi = event->value; in kone_keep_values_up_to_date()
808 switch (event->event) { in kone_report_to_chrdev()
813 roccat_report.event = event->event; in kone_report_to_chrdev()
814 roccat_report.value = event->value; in kone_report_to_chrdev()
816 roccat_report_event(kone->chrdev_minor, in kone_report_to_chrdev()
821 if (event->value == kone_keystroke_action_press) { in kone_report_to_chrdev()
822 roccat_report.event = event->event; in kone_report_to_chrdev()
823 roccat_report.value = kone->actual_profile; in kone_report_to_chrdev()
824 roccat_report.key = event->macro_key; in kone_report_to_chrdev()
825 roccat_report_event(kone->chrdev_minor, in kone_report_to_chrdev()
834 * Is called for keyboard- and mousepart.
856 if (memcmp(&kone->last_mouse_event.tilt, &event->tilt, 5)) in kone_raw_event()
857 memcpy(&kone->last_mouse_event, event, in kone_raw_event()
860 memset(&event->tilt, 0, 5); in kone_raw_event()
864 if (kone->roccat_claimed) in kone_raw_event()
893 kone_class->dev_groups = kone_groups; in kone_init()