^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Roccat Kone driver for Linux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2010 Stefan Achatz <erazor_de@users.sourceforge.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Roccat Kone is a gamer mouse which consists of a mouse part and a keyboard
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * part. The keyboard part enables the mouse to execute stored macros with mixed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * key- and button-events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * TODO implement on-the-fly polling-rate change
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * The windows driver has the ability to change the polling rate of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * device on the press of a mousebutton.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * Is it possible to remove and reinstall the urb in raw-event- or any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * other handler, or to defer this action to be executed somewhere else?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * TODO is it possible to overwrite group for sysfs attributes via udev?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/hid.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <linux/hid-roccat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include "hid-ids.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include "hid-roccat-common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include "hid-roccat-kone.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static uint profile_numbers[5] = {0, 1, 2, 3, 4};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static void kone_profile_activated(struct kone_device *kone, uint new_profile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) kone->actual_profile = new_profile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) kone->actual_dpi = kone->profiles[new_profile - 1].startup_dpi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) static void kone_profile_report(struct kone_device *kone, uint new_profile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct kone_roccat_report roccat_report;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) roccat_report.event = kone_mouse_event_switch_profile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) roccat_report.value = new_profile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) roccat_report.key = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) roccat_report_event(kone->chrdev_minor, (uint8_t *)&roccat_report);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) static int kone_receive(struct usb_device *usb_dev, uint usb_command,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) void *data, uint size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) char *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) buf = kmalloc(size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) if (buf == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) len = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) HID_REQ_GET_REPORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) usb_command, 0, buf, size, USB_CTRL_SET_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) memcpy(data, buf, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) return ((len < 0) ? len : ((len != size) ? -EIO : 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) static int kone_send(struct usb_device *usb_dev, uint usb_command,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) void const *data, uint size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) char *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) buf = kmemdup(data, size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) if (buf == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) len = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) HID_REQ_SET_REPORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) usb_command, 0, buf, size, USB_CTRL_SET_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) return ((len < 0) ? len : ((len != size) ? -EIO : 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) /* kone_class is used for creating sysfs attributes via roccat char device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) static struct class *kone_class;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) static void kone_set_settings_checksum(struct kone_settings *settings)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) uint16_t checksum = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) unsigned char *address = (unsigned char *)settings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) for (i = 0; i < sizeof(struct kone_settings) - 2; ++i, ++address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) checksum += *address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) settings->checksum = cpu_to_le16(checksum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * Checks success after writing data to mouse
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * On success returns 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * On failure returns errno
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) static int kone_check_write(struct usb_device *usb_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) uint8_t data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) * Mouse needs 50 msecs until it says ok, but there are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * 30 more msecs needed for next write to work.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) msleep(80);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) retval = kone_receive(usb_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) kone_command_confirm_write, &data, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) * value of 3 seems to mean something like
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * "not finished yet, but it looks good"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * So check again after a moment.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) } while (data == 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) if (data == 1) /* everything alright */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) /* unknown answer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) dev_err(&usb_dev->dev, "got retval %d when checking write\n", data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) * Reads settings from mouse and stores it in @buf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) * On success returns 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) * On failure returns errno
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) static int kone_get_settings(struct usb_device *usb_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) struct kone_settings *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) return kone_receive(usb_dev, kone_command_settings, buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) sizeof(struct kone_settings));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * Writes settings from @buf to mouse
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) * On success returns 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) * On failure returns errno
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) static int kone_set_settings(struct usb_device *usb_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) struct kone_settings const *settings)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) retval = kone_send(usb_dev, kone_command_settings,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) settings, sizeof(struct kone_settings));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) return kone_check_write(usb_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) * Reads profile data from mouse and stores it in @buf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) * @number: profile number to read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * On success returns 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) * On failure returns errno
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) static int kone_get_profile(struct usb_device *usb_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) struct kone_profile *buf, int number)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) if (number < 1 || number > 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) len = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) USB_REQ_CLEAR_FEATURE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) kone_command_profile, number, buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) sizeof(struct kone_profile), USB_CTRL_SET_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) if (len != sizeof(struct kone_profile))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) * Writes profile data to mouse.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) * @number: profile number to write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) * On success returns 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) * On failure returns errno
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) static int kone_set_profile(struct usb_device *usb_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) struct kone_profile const *profile, int number)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) if (number < 1 || number > 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) len = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) USB_REQ_SET_CONFIGURATION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) kone_command_profile, number, (void *)profile,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) sizeof(struct kone_profile),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) USB_CTRL_SET_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) if (len != sizeof(struct kone_profile))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) if (kone_check_write(usb_dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) * Reads value of "fast-clip-weight" and stores it in @result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) * On success returns 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) * On failure returns errno
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) static int kone_get_weight(struct usb_device *usb_dev, int *result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) uint8_t data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) retval = kone_receive(usb_dev, kone_command_weight, &data, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) *result = (int)data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) * Reads firmware_version of mouse and stores it in @result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * On success returns 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) * On failure returns errno
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) static int kone_get_firmware_version(struct usb_device *usb_dev, int *result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) uint16_t data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) retval = kone_receive(usb_dev, kone_command_firmware_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) &data, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) *result = le16_to_cpu(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) static ssize_t kone_sysfs_read_settings(struct file *fp, struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) struct bin_attribute *attr, char *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) loff_t off, size_t count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) struct device *dev = kobj_to_dev(kobj)->parent->parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) if (off >= sizeof(struct kone_settings))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) if (off + count > sizeof(struct kone_settings))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) count = sizeof(struct kone_settings) - off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) mutex_lock(&kone->kone_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) memcpy(buf, ((char const *)&kone->settings) + off, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) mutex_unlock(&kone->kone_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) * Writing settings automatically activates startup_profile.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) * This function keeps values in kone_device up to date and assumes that in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) * case of error the old data is still valid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) static ssize_t kone_sysfs_write_settings(struct file *fp, struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) struct bin_attribute *attr, char *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) loff_t off, size_t count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) struct device *dev = kobj_to_dev(kobj)->parent->parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) int retval = 0, difference, old_profile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) struct kone_settings *settings = (struct kone_settings *)buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) /* I need to get my data in one piece */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) if (off != 0 || count != sizeof(struct kone_settings))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) mutex_lock(&kone->kone_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) difference = memcmp(settings, &kone->settings,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) sizeof(struct kone_settings));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) if (difference) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) if (settings->startup_profile < 1 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) settings->startup_profile > 5) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) retval = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) retval = kone_set_settings(usb_dev, settings);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) old_profile = kone->settings.startup_profile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) memcpy(&kone->settings, settings, sizeof(struct kone_settings));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) kone_profile_activated(kone, kone->settings.startup_profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) if (kone->settings.startup_profile != old_profile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) kone_profile_report(kone, kone->settings.startup_profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) mutex_unlock(&kone->kone_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) return sizeof(struct kone_settings);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) static BIN_ATTR(settings, 0660, kone_sysfs_read_settings,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) kone_sysfs_write_settings, sizeof(struct kone_settings));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) static ssize_t kone_sysfs_read_profilex(struct file *fp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) struct kobject *kobj, struct bin_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) char *buf, loff_t off, size_t count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) struct device *dev = kobj_to_dev(kobj)->parent->parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) if (off >= sizeof(struct kone_profile))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) if (off + count > sizeof(struct kone_profile))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) count = sizeof(struct kone_profile) - off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) mutex_lock(&kone->kone_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) memcpy(buf, ((char const *)&kone->profiles[*(uint *)(attr->private)]) + off, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) mutex_unlock(&kone->kone_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) /* Writes data only if different to stored data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) static ssize_t kone_sysfs_write_profilex(struct file *fp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) struct kobject *kobj, struct bin_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) char *buf, loff_t off, size_t count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) struct device *dev = kobj_to_dev(kobj)->parent->parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) struct kone_profile *profile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) int retval = 0, difference;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) /* I need to get my data in one piece */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) if (off != 0 || count != sizeof(struct kone_profile))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) profile = &kone->profiles[*(uint *)(attr->private)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) mutex_lock(&kone->kone_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) difference = memcmp(buf, profile, sizeof(struct kone_profile));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) if (difference) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) retval = kone_set_profile(usb_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) (struct kone_profile const *)buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) *(uint *)(attr->private) + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) if (!retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) memcpy(profile, buf, sizeof(struct kone_profile));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) mutex_unlock(&kone->kone_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) return sizeof(struct kone_profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) #define PROFILE_ATTR(number) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) static struct bin_attribute bin_attr_profile##number = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) .attr = { .name = "profile" #number, .mode = 0660 }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) .size = sizeof(struct kone_profile), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) .read = kone_sysfs_read_profilex, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) .write = kone_sysfs_write_profilex, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) .private = &profile_numbers[number-1], \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) PROFILE_ATTR(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) PROFILE_ATTR(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) PROFILE_ATTR(3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) PROFILE_ATTR(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) PROFILE_ATTR(5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) static ssize_t kone_sysfs_show_actual_profile(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) struct kone_device *kone =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) return snprintf(buf, PAGE_SIZE, "%d\n", kone->actual_profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) static DEVICE_ATTR(actual_profile, 0440, kone_sysfs_show_actual_profile, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) static ssize_t kone_sysfs_show_actual_dpi(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) struct kone_device *kone =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) return snprintf(buf, PAGE_SIZE, "%d\n", kone->actual_dpi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) static DEVICE_ATTR(actual_dpi, 0440, kone_sysfs_show_actual_dpi, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) /* weight is read each time, since we don't get informed when it's changed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) static ssize_t kone_sysfs_show_weight(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) struct kone_device *kone;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) struct usb_device *usb_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) int weight = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) dev = dev->parent->parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) kone = hid_get_drvdata(dev_get_drvdata(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) usb_dev = interface_to_usbdev(to_usb_interface(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) mutex_lock(&kone->kone_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) retval = kone_get_weight(usb_dev, &weight);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) mutex_unlock(&kone->kone_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) return snprintf(buf, PAGE_SIZE, "%d\n", weight);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) static DEVICE_ATTR(weight, 0440, kone_sysfs_show_weight, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) static ssize_t kone_sysfs_show_firmware_version(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) struct kone_device *kone =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) return snprintf(buf, PAGE_SIZE, "%d\n", kone->firmware_version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) static DEVICE_ATTR(firmware_version, 0440, kone_sysfs_show_firmware_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) static ssize_t kone_sysfs_show_tcu(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) struct kone_device *kone =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) return snprintf(buf, PAGE_SIZE, "%d\n", kone->settings.tcu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) static int kone_tcu_command(struct usb_device *usb_dev, int number)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) unsigned char value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) value = number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) return kone_send(usb_dev, kone_command_calibrate, &value, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) * Calibrating the tcu is the only action that changes settings data inside the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) * mouse, so this data needs to be reread
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) static ssize_t kone_sysfs_set_tcu(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) struct device_attribute *attr, char const *buf, size_t size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) struct kone_device *kone;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) struct usb_device *usb_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) unsigned long state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) dev = dev->parent->parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) kone = hid_get_drvdata(dev_get_drvdata(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) usb_dev = interface_to_usbdev(to_usb_interface(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) retval = kstrtoul(buf, 10, &state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) if (state != 0 && state != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) mutex_lock(&kone->kone_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) if (state == 1) { /* state activate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) retval = kone_tcu_command(usb_dev, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) goto exit_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) retval = kone_tcu_command(usb_dev, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) goto exit_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) ssleep(5); /* tcu needs this time for calibration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) retval = kone_tcu_command(usb_dev, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) goto exit_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) retval = kone_tcu_command(usb_dev, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) goto exit_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) retval = kone_tcu_command(usb_dev, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) goto exit_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) * Kone needs this time to settle things.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) * Reading settings too early will result in invalid data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) * Roccat's driver waits 1 sec, maybe this time could be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) * shortened.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) ssleep(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) /* calibration changes values in settings, so reread */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) retval = kone_get_settings(usb_dev, &kone->settings);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) goto exit_no_settings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) /* only write settings back if activation state is different */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) if (kone->settings.tcu != state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) kone->settings.tcu = state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) kone_set_settings_checksum(&kone->settings);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) retval = kone_set_settings(usb_dev, &kone->settings);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) if (retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) dev_err(&usb_dev->dev, "couldn't set tcu state\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) * try to reread valid settings into buffer overwriting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) * first error code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) retval = kone_get_settings(usb_dev, &kone->settings);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) goto exit_no_settings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) goto exit_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) /* calibration resets profile */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) kone_profile_activated(kone, kone->settings.startup_profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) retval = size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) exit_no_settings:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) dev_err(&usb_dev->dev, "couldn't read settings\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) exit_unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) mutex_unlock(&kone->kone_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) static DEVICE_ATTR(tcu, 0660, kone_sysfs_show_tcu, kone_sysfs_set_tcu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) static ssize_t kone_sysfs_show_startup_profile(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) struct kone_device *kone =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) return snprintf(buf, PAGE_SIZE, "%d\n", kone->settings.startup_profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) static ssize_t kone_sysfs_set_startup_profile(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) struct device_attribute *attr, char const *buf, size_t size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) struct kone_device *kone;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) struct usb_device *usb_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) unsigned long new_startup_profile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) dev = dev->parent->parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) kone = hid_get_drvdata(dev_get_drvdata(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) usb_dev = interface_to_usbdev(to_usb_interface(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) retval = kstrtoul(buf, 10, &new_startup_profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) if (new_startup_profile < 1 || new_startup_profile > 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) mutex_lock(&kone->kone_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) kone->settings.startup_profile = new_startup_profile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) kone_set_settings_checksum(&kone->settings);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) retval = kone_set_settings(usb_dev, &kone->settings);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) if (retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) mutex_unlock(&kone->kone_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) /* changing the startup profile immediately activates this profile */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) kone_profile_activated(kone, new_startup_profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) kone_profile_report(kone, new_startup_profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) mutex_unlock(&kone->kone_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) return size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) static DEVICE_ATTR(startup_profile, 0660, kone_sysfs_show_startup_profile,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) kone_sysfs_set_startup_profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) static struct attribute *kone_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) * Read actual dpi settings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) * Returns raw value for further processing. Refer to enum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) * kone_polling_rates to get real value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) &dev_attr_actual_dpi.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) &dev_attr_actual_profile.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) * The mouse can be equipped with one of four supplied weights from 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) * to 20 grams which are recognized and its value can be read out.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) * This returns the raw value reported by the mouse for easy evaluation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) * by software. Refer to enum kone_weights to get corresponding real
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) * weight.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) &dev_attr_weight.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) * Prints firmware version stored in mouse as integer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) * The raw value reported by the mouse is returned for easy evaluation,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) * to get the real version number the decimal point has to be shifted 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) * positions to the left. E.g. a value of 138 means 1.38.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) &dev_attr_firmware_version.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) * Prints state of Tracking Control Unit as number where 0 = off and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) * 1 = on. Writing 0 deactivates tcu and writing 1 calibrates and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) * activates the tcu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) &dev_attr_tcu.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) /* Prints and takes the number of the profile the mouse starts with */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) &dev_attr_startup_profile.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) static struct bin_attribute *kone_bin_attributes[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) &bin_attr_settings,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) &bin_attr_profile1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) &bin_attr_profile2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) &bin_attr_profile3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) &bin_attr_profile4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) &bin_attr_profile5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) static const struct attribute_group kone_group = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) .attrs = kone_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) .bin_attrs = kone_bin_attributes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) static const struct attribute_group *kone_groups[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) &kone_group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) static int kone_init_kone_device_struct(struct usb_device *usb_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) struct kone_device *kone)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) uint i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) mutex_init(&kone->kone_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) for (i = 0; i < 5; ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) retval = kone_get_profile(usb_dev, &kone->profiles[i], i + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) retval = kone_get_settings(usb_dev, &kone->settings);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) retval = kone_get_firmware_version(usb_dev, &kone->firmware_version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) kone_profile_activated(kone, kone->settings.startup_profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) * Since IGNORE_MOUSE quirk moved to hid-apple, there is no way to bind only to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) * mousepart if usb_hid is compiled into the kernel and kone is compiled as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) * module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) * Secial behaviour is bound only to mousepart since only mouseevents contain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) * additional notifications.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) static int kone_init_specials(struct hid_device *hdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) struct usb_device *usb_dev = interface_to_usbdev(intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) struct kone_device *kone;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) if (intf->cur_altsetting->desc.bInterfaceProtocol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) == USB_INTERFACE_PROTOCOL_MOUSE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) kone = kzalloc(sizeof(*kone), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) if (!kone)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) hid_set_drvdata(hdev, kone);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) retval = kone_init_kone_device_struct(usb_dev, kone);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) if (retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) hid_err(hdev, "couldn't init struct kone_device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) goto exit_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) retval = roccat_connect(kone_class, hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) sizeof(struct kone_roccat_report));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) if (retval < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) hid_err(hdev, "couldn't init char dev\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) /* be tolerant about not getting chrdev */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) kone->roccat_claimed = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) kone->chrdev_minor = retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) hid_set_drvdata(hdev, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) exit_free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) kfree(kone);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) static void kone_remove_specials(struct hid_device *hdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) struct kone_device *kone;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) if (intf->cur_altsetting->desc.bInterfaceProtocol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) == USB_INTERFACE_PROTOCOL_MOUSE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) kone = hid_get_drvdata(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) if (kone->roccat_claimed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) roccat_disconnect(kone->chrdev_minor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) kfree(hid_get_drvdata(hdev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) static int kone_probe(struct hid_device *hdev, const struct hid_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) if (!hid_is_usb(hdev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) retval = hid_parse(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) if (retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) hid_err(hdev, "parse failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) if (retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) hid_err(hdev, "hw start failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) retval = kone_init_specials(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) if (retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) hid_err(hdev, "couldn't install mouse\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) goto exit_stop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) exit_stop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) hid_hw_stop(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) static void kone_remove(struct hid_device *hdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) kone_remove_specials(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) hid_hw_stop(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) /* handle special events and keep actual profile and dpi values up to date */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) static void kone_keep_values_up_to_date(struct kone_device *kone,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) struct kone_mouse_event const *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) switch (event->event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) case kone_mouse_event_switch_profile:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) kone->actual_dpi = kone->profiles[event->value - 1].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) startup_dpi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) case kone_mouse_event_osd_profile:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) kone->actual_profile = event->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) case kone_mouse_event_switch_dpi:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) case kone_mouse_event_osd_dpi:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) kone->actual_dpi = event->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) static void kone_report_to_chrdev(struct kone_device const *kone,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) struct kone_mouse_event const *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) struct kone_roccat_report roccat_report;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) switch (event->event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) case kone_mouse_event_switch_profile:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) case kone_mouse_event_switch_dpi:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) case kone_mouse_event_osd_profile:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) case kone_mouse_event_osd_dpi:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) roccat_report.event = event->event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) roccat_report.value = event->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) roccat_report.key = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) roccat_report_event(kone->chrdev_minor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) (uint8_t *)&roccat_report);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) case kone_mouse_event_call_overlong_macro:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) case kone_mouse_event_multimedia:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) if (event->value == kone_keystroke_action_press) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) roccat_report.event = event->event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) roccat_report.value = kone->actual_profile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) roccat_report.key = event->macro_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) roccat_report_event(kone->chrdev_minor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) (uint8_t *)&roccat_report);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) * Is called for keyboard- and mousepart.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) * Only mousepart gets informations about special events in its extended event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) * structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) static int kone_raw_event(struct hid_device *hdev, struct hid_report *report,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) u8 *data, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) struct kone_device *kone = hid_get_drvdata(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) struct kone_mouse_event *event = (struct kone_mouse_event *)data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) /* keyboard events are always processed by default handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) if (size != sizeof(struct kone_mouse_event))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) if (kone == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) * Firmware 1.38 introduced new behaviour for tilt and special buttons.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) * Pressed button is reported in each movement event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) * Workaround sends only one event per press.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) if (memcmp(&kone->last_mouse_event.tilt, &event->tilt, 5))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) memcpy(&kone->last_mouse_event, event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) sizeof(struct kone_mouse_event));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) memset(&event->tilt, 0, 5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) kone_keep_values_up_to_date(kone, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) if (kone->roccat_claimed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) kone_report_to_chrdev(kone, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) return 0; /* always do further processing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) static const struct hid_device_id kone_devices[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) MODULE_DEVICE_TABLE(hid, kone_devices);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) static struct hid_driver kone_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) .name = "kone",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) .id_table = kone_devices,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) .probe = kone_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) .remove = kone_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) .raw_event = kone_raw_event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) static int __init kone_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) /* class name has to be same as driver name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) kone_class = class_create(THIS_MODULE, "kone");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) if (IS_ERR(kone_class))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) return PTR_ERR(kone_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) kone_class->dev_groups = kone_groups;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) retval = hid_register_driver(&kone_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) class_destroy(kone_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) static void __exit kone_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) hid_unregister_driver(&kone_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) class_destroy(kone_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) module_init(kone_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) module_exit(kone_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) MODULE_AUTHOR("Stefan Achatz");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) MODULE_DESCRIPTION("USB Roccat Kone driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) MODULE_LICENSE("GPL v2");