Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Roccat Pyra driver for Linux |
| 3 | * |
| 4 | * Copyright (c) 2010 Stefan Achatz <erazor_de@users.sourceforge.net> |
| 5 | */ |
| 6 | |
| 7 | /* |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License as published by the Free |
| 10 | * Software Foundation; either version 2 of the License, or (at your option) |
| 11 | * any later version. |
| 12 | */ |
| 13 | |
| 14 | /* |
| 15 | * Roccat Pyra is a mobile gamer mouse which comes in wired and wireless |
| 16 | * variant. Wireless variant is not tested. |
| 17 | * Userland tools can be found at http://sourceforge.net/projects/roccat |
| 18 | */ |
| 19 | |
| 20 | #include <linux/device.h> |
| 21 | #include <linux/input.h> |
| 22 | #include <linux/hid.h> |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 23 | #include <linux/module.h> |
| 24 | #include <linux/slab.h> |
Stefan Achatz | 5dc0c98 | 2011-02-03 16:14:43 +0100 | [diff] [blame] | 25 | #include <linux/hid-roccat.h> |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 26 | #include "hid-ids.h" |
Stefan Achatz | 5772f63 | 2011-01-30 13:38:23 +0100 | [diff] [blame] | 27 | #include "hid-roccat-common.h" |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 28 | #include "hid-roccat-pyra.h" |
| 29 | |
Stefan Achatz | 14a057f | 2010-11-26 19:57:38 +0000 | [diff] [blame] | 30 | static uint profile_numbers[5] = {0, 1, 2, 3, 4}; |
| 31 | |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 32 | /* pyra_class is used for creating sysfs attributes via roccat char device */ |
| 33 | static struct class *pyra_class; |
| 34 | |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 35 | static void profile_activated(struct pyra_device *pyra, |
| 36 | unsigned int new_profile) |
| 37 | { |
| 38 | pyra->actual_profile = new_profile; |
| 39 | pyra->actual_cpi = pyra->profile_settings[pyra->actual_profile].y_cpi; |
| 40 | } |
| 41 | |
| 42 | static int pyra_send_control(struct usb_device *usb_dev, int value, |
| 43 | enum pyra_control_requests request) |
| 44 | { |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 45 | struct pyra_control control; |
| 46 | |
| 47 | if ((request == PYRA_CONTROL_REQUEST_PROFILE_SETTINGS || |
| 48 | request == PYRA_CONTROL_REQUEST_PROFILE_BUTTONS) && |
| 49 | (value < 0 || value > 4)) |
| 50 | return -EINVAL; |
| 51 | |
| 52 | control.command = PYRA_COMMAND_CONTROL; |
| 53 | control.value = value; |
| 54 | control.request = request; |
| 55 | |
Stefan Achatz | 1edd5b4 | 2011-06-01 15:54:17 +0200 | [diff] [blame] | 56 | return roccat_common_send(usb_dev, PYRA_COMMAND_CONTROL, |
Stefan Achatz | 5772f63 | 2011-01-30 13:38:23 +0100 | [diff] [blame] | 57 | &control, sizeof(struct pyra_control)); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | static int pyra_receive_control_status(struct usb_device *usb_dev) |
| 61 | { |
Stefan Achatz | 5772f63 | 2011-01-30 13:38:23 +0100 | [diff] [blame] | 62 | int retval; |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 63 | struct pyra_control control; |
| 64 | |
| 65 | do { |
| 66 | msleep(10); |
Stefan Achatz | 1edd5b4 | 2011-06-01 15:54:17 +0200 | [diff] [blame] | 67 | retval = roccat_common_receive(usb_dev, PYRA_COMMAND_CONTROL, |
Stefan Achatz | 5772f63 | 2011-01-30 13:38:23 +0100 | [diff] [blame] | 68 | &control, sizeof(struct pyra_control)); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 69 | |
| 70 | /* requested too early, try again */ |
Stefan Achatz | 5772f63 | 2011-01-30 13:38:23 +0100 | [diff] [blame] | 71 | } while (retval == -EPROTO); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 72 | |
Stefan Achatz | 5772f63 | 2011-01-30 13:38:23 +0100 | [diff] [blame] | 73 | if (!retval && control.command == PYRA_COMMAND_CONTROL && |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 74 | control.request == PYRA_CONTROL_REQUEST_STATUS && |
| 75 | control.value == 1) |
Stefan Achatz | 5772f63 | 2011-01-30 13:38:23 +0100 | [diff] [blame] | 76 | return 0; |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 77 | else { |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 78 | hid_err(usb_dev, "receive control status: unknown response 0x%x 0x%x\n", |
| 79 | control.request, control.value); |
Stefan Achatz | 5772f63 | 2011-01-30 13:38:23 +0100 | [diff] [blame] | 80 | return retval ? retval : -EINVAL; |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 81 | } |
| 82 | } |
| 83 | |
| 84 | static int pyra_get_profile_settings(struct usb_device *usb_dev, |
| 85 | struct pyra_profile_settings *buf, int number) |
| 86 | { |
| 87 | int retval; |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 88 | retval = pyra_send_control(usb_dev, number, |
| 89 | PYRA_CONTROL_REQUEST_PROFILE_SETTINGS); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 90 | if (retval) |
| 91 | return retval; |
Stefan Achatz | 1edd5b4 | 2011-06-01 15:54:17 +0200 | [diff] [blame] | 92 | return roccat_common_receive(usb_dev, PYRA_COMMAND_PROFILE_SETTINGS, |
Stefan Achatz | 5772f63 | 2011-01-30 13:38:23 +0100 | [diff] [blame] | 93 | buf, sizeof(struct pyra_profile_settings)); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | static int pyra_get_profile_buttons(struct usb_device *usb_dev, |
| 97 | struct pyra_profile_buttons *buf, int number) |
| 98 | { |
| 99 | int retval; |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 100 | retval = pyra_send_control(usb_dev, number, |
| 101 | PYRA_CONTROL_REQUEST_PROFILE_BUTTONS); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 102 | if (retval) |
| 103 | return retval; |
Stefan Achatz | 1edd5b4 | 2011-06-01 15:54:17 +0200 | [diff] [blame] | 104 | return roccat_common_receive(usb_dev, PYRA_COMMAND_PROFILE_BUTTONS, |
Stefan Achatz | 5772f63 | 2011-01-30 13:38:23 +0100 | [diff] [blame] | 105 | buf, sizeof(struct pyra_profile_buttons)); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | static int pyra_get_settings(struct usb_device *usb_dev, |
| 109 | struct pyra_settings *buf) |
| 110 | { |
Stefan Achatz | 1edd5b4 | 2011-06-01 15:54:17 +0200 | [diff] [blame] | 111 | return roccat_common_receive(usb_dev, PYRA_COMMAND_SETTINGS, |
Stefan Achatz | 5772f63 | 2011-01-30 13:38:23 +0100 | [diff] [blame] | 112 | buf, sizeof(struct pyra_settings)); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | static int pyra_get_info(struct usb_device *usb_dev, struct pyra_info *buf) |
| 116 | { |
Stefan Achatz | 1edd5b4 | 2011-06-01 15:54:17 +0200 | [diff] [blame] | 117 | return roccat_common_receive(usb_dev, PYRA_COMMAND_INFO, |
Stefan Achatz | 5772f63 | 2011-01-30 13:38:23 +0100 | [diff] [blame] | 118 | buf, sizeof(struct pyra_info)); |
| 119 | } |
| 120 | |
| 121 | static int pyra_send(struct usb_device *usb_dev, uint command, |
| 122 | void const *buf, uint size) |
| 123 | { |
| 124 | int retval; |
| 125 | retval = roccat_common_send(usb_dev, command, buf, size); |
| 126 | if (retval) |
| 127 | return retval; |
| 128 | return pyra_receive_control_status(usb_dev); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | static int pyra_set_profile_settings(struct usb_device *usb_dev, |
| 132 | struct pyra_profile_settings const *settings) |
| 133 | { |
Stefan Achatz | 1edd5b4 | 2011-06-01 15:54:17 +0200 | [diff] [blame] | 134 | return pyra_send(usb_dev, PYRA_COMMAND_PROFILE_SETTINGS, settings, |
Stefan Achatz | 5772f63 | 2011-01-30 13:38:23 +0100 | [diff] [blame] | 135 | sizeof(struct pyra_profile_settings)); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | static int pyra_set_profile_buttons(struct usb_device *usb_dev, |
| 139 | struct pyra_profile_buttons const *buttons) |
| 140 | { |
Stefan Achatz | 1edd5b4 | 2011-06-01 15:54:17 +0200 | [diff] [blame] | 141 | return pyra_send(usb_dev, PYRA_COMMAND_PROFILE_BUTTONS, buttons, |
Stefan Achatz | 5772f63 | 2011-01-30 13:38:23 +0100 | [diff] [blame] | 142 | sizeof(struct pyra_profile_buttons)); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | static int pyra_set_settings(struct usb_device *usb_dev, |
| 146 | struct pyra_settings const *settings) |
| 147 | { |
Stefan Achatz | 1edd5b4 | 2011-06-01 15:54:17 +0200 | [diff] [blame] | 148 | return pyra_send(usb_dev, PYRA_COMMAND_SETTINGS, settings, |
Stefan Achatz | 5772f63 | 2011-01-30 13:38:23 +0100 | [diff] [blame] | 149 | sizeof(struct pyra_settings)); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | static ssize_t pyra_sysfs_read_profilex_settings(struct file *fp, |
| 153 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
Stefan Achatz | 14a057f | 2010-11-26 19:57:38 +0000 | [diff] [blame] | 154 | loff_t off, size_t count) |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 155 | { |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 156 | struct device *dev = |
| 157 | container_of(kobj, struct device, kobj)->parent->parent; |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 158 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); |
| 159 | |
| 160 | if (off >= sizeof(struct pyra_profile_settings)) |
| 161 | return 0; |
| 162 | |
| 163 | if (off + count > sizeof(struct pyra_profile_settings)) |
| 164 | count = sizeof(struct pyra_profile_settings) - off; |
| 165 | |
| 166 | mutex_lock(&pyra->pyra_lock); |
Stefan Achatz | 14a057f | 2010-11-26 19:57:38 +0000 | [diff] [blame] | 167 | memcpy(buf, ((char const *)&pyra->profile_settings[*(uint *)(attr->private)]) + off, |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 168 | count); |
| 169 | mutex_unlock(&pyra->pyra_lock); |
| 170 | |
| 171 | return count; |
| 172 | } |
| 173 | |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 174 | static ssize_t pyra_sysfs_read_profilex_buttons(struct file *fp, |
| 175 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
Stefan Achatz | 14a057f | 2010-11-26 19:57:38 +0000 | [diff] [blame] | 176 | loff_t off, size_t count) |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 177 | { |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 178 | struct device *dev = |
| 179 | container_of(kobj, struct device, kobj)->parent->parent; |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 180 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); |
| 181 | |
| 182 | if (off >= sizeof(struct pyra_profile_buttons)) |
| 183 | return 0; |
| 184 | |
| 185 | if (off + count > sizeof(struct pyra_profile_buttons)) |
| 186 | count = sizeof(struct pyra_profile_buttons) - off; |
| 187 | |
| 188 | mutex_lock(&pyra->pyra_lock); |
Stefan Achatz | 14a057f | 2010-11-26 19:57:38 +0000 | [diff] [blame] | 189 | memcpy(buf, ((char const *)&pyra->profile_buttons[*(uint *)(attr->private)]) + off, |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 190 | count); |
| 191 | mutex_unlock(&pyra->pyra_lock); |
| 192 | |
| 193 | return count; |
| 194 | } |
| 195 | |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 196 | static ssize_t pyra_sysfs_write_profile_settings(struct file *fp, |
| 197 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
| 198 | loff_t off, size_t count) |
| 199 | { |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 200 | struct device *dev = |
| 201 | container_of(kobj, struct device, kobj)->parent->parent; |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 202 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); |
| 203 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 204 | int retval = 0; |
| 205 | int difference; |
| 206 | int profile_number; |
| 207 | struct pyra_profile_settings *profile_settings; |
| 208 | |
| 209 | if (off != 0 || count != sizeof(struct pyra_profile_settings)) |
| 210 | return -EINVAL; |
| 211 | |
| 212 | profile_number = ((struct pyra_profile_settings const *)buf)->number; |
| 213 | profile_settings = &pyra->profile_settings[profile_number]; |
| 214 | |
| 215 | mutex_lock(&pyra->pyra_lock); |
| 216 | difference = memcmp(buf, profile_settings, |
| 217 | sizeof(struct pyra_profile_settings)); |
| 218 | if (difference) { |
| 219 | retval = pyra_set_profile_settings(usb_dev, |
| 220 | (struct pyra_profile_settings const *)buf); |
| 221 | if (!retval) |
| 222 | memcpy(profile_settings, buf, |
| 223 | sizeof(struct pyra_profile_settings)); |
| 224 | } |
| 225 | mutex_unlock(&pyra->pyra_lock); |
| 226 | |
| 227 | if (retval) |
| 228 | return retval; |
| 229 | |
| 230 | return sizeof(struct pyra_profile_settings); |
| 231 | } |
| 232 | |
| 233 | static ssize_t pyra_sysfs_write_profile_buttons(struct file *fp, |
| 234 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
| 235 | loff_t off, size_t count) |
| 236 | { |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 237 | struct device *dev = |
| 238 | container_of(kobj, struct device, kobj)->parent->parent; |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 239 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); |
| 240 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 241 | int retval = 0; |
| 242 | int difference; |
| 243 | int profile_number; |
| 244 | struct pyra_profile_buttons *profile_buttons; |
| 245 | |
| 246 | if (off != 0 || count != sizeof(struct pyra_profile_buttons)) |
| 247 | return -EINVAL; |
| 248 | |
| 249 | profile_number = ((struct pyra_profile_buttons const *)buf)->number; |
| 250 | profile_buttons = &pyra->profile_buttons[profile_number]; |
| 251 | |
| 252 | mutex_lock(&pyra->pyra_lock); |
| 253 | difference = memcmp(buf, profile_buttons, |
| 254 | sizeof(struct pyra_profile_buttons)); |
| 255 | if (difference) { |
| 256 | retval = pyra_set_profile_buttons(usb_dev, |
| 257 | (struct pyra_profile_buttons const *)buf); |
| 258 | if (!retval) |
| 259 | memcpy(profile_buttons, buf, |
| 260 | sizeof(struct pyra_profile_buttons)); |
| 261 | } |
| 262 | mutex_unlock(&pyra->pyra_lock); |
| 263 | |
| 264 | if (retval) |
| 265 | return retval; |
| 266 | |
| 267 | return sizeof(struct pyra_profile_buttons); |
| 268 | } |
| 269 | |
| 270 | static ssize_t pyra_sysfs_read_settings(struct file *fp, |
| 271 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
| 272 | loff_t off, size_t count) |
| 273 | { |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 274 | struct device *dev = |
| 275 | container_of(kobj, struct device, kobj)->parent->parent; |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 276 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); |
| 277 | |
| 278 | if (off >= sizeof(struct pyra_settings)) |
| 279 | return 0; |
| 280 | |
| 281 | if (off + count > sizeof(struct pyra_settings)) |
| 282 | count = sizeof(struct pyra_settings) - off; |
| 283 | |
| 284 | mutex_lock(&pyra->pyra_lock); |
| 285 | memcpy(buf, ((char const *)&pyra->settings) + off, count); |
| 286 | mutex_unlock(&pyra->pyra_lock); |
| 287 | |
| 288 | return count; |
| 289 | } |
| 290 | |
| 291 | static ssize_t pyra_sysfs_write_settings(struct file *fp, |
| 292 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
| 293 | loff_t off, size_t count) |
| 294 | { |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 295 | struct device *dev = |
| 296 | container_of(kobj, struct device, kobj)->parent->parent; |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 297 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); |
| 298 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 299 | int retval = 0; |
| 300 | int difference; |
Stefan Achatz | dc186b6 | 2011-08-27 15:24:41 +0200 | [diff] [blame] | 301 | struct pyra_roccat_report roccat_report; |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 302 | |
| 303 | if (off != 0 || count != sizeof(struct pyra_settings)) |
| 304 | return -EINVAL; |
| 305 | |
| 306 | mutex_lock(&pyra->pyra_lock); |
| 307 | difference = memcmp(buf, &pyra->settings, sizeof(struct pyra_settings)); |
| 308 | if (difference) { |
| 309 | retval = pyra_set_settings(usb_dev, |
| 310 | (struct pyra_settings const *)buf); |
Stefan Achatz | dc186b6 | 2011-08-27 15:24:41 +0200 | [diff] [blame] | 311 | if (retval) { |
| 312 | mutex_unlock(&pyra->pyra_lock); |
| 313 | return retval; |
| 314 | } |
| 315 | |
| 316 | memcpy(&pyra->settings, buf, |
| 317 | sizeof(struct pyra_settings)); |
| 318 | |
| 319 | profile_activated(pyra, pyra->settings.startup_profile); |
| 320 | |
| 321 | roccat_report.type = PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_2; |
| 322 | roccat_report.value = pyra->settings.startup_profile + 1; |
| 323 | roccat_report.key = 0; |
| 324 | roccat_report_event(pyra->chrdev_minor, |
| 325 | (uint8_t const *)&roccat_report); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 326 | } |
| 327 | mutex_unlock(&pyra->pyra_lock); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 328 | return sizeof(struct pyra_settings); |
| 329 | } |
| 330 | |
| 331 | |
| 332 | static ssize_t pyra_sysfs_show_actual_cpi(struct device *dev, |
| 333 | struct device_attribute *attr, char *buf) |
| 334 | { |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 335 | struct pyra_device *pyra = |
| 336 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 337 | return snprintf(buf, PAGE_SIZE, "%d\n", pyra->actual_cpi); |
| 338 | } |
| 339 | |
| 340 | static ssize_t pyra_sysfs_show_actual_profile(struct device *dev, |
| 341 | struct device_attribute *attr, char *buf) |
| 342 | { |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 343 | struct pyra_device *pyra = |
| 344 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 345 | return snprintf(buf, PAGE_SIZE, "%d\n", pyra->actual_profile); |
| 346 | } |
| 347 | |
| 348 | static ssize_t pyra_sysfs_show_firmware_version(struct device *dev, |
| 349 | struct device_attribute *attr, char *buf) |
| 350 | { |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 351 | struct pyra_device *pyra = |
| 352 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 353 | return snprintf(buf, PAGE_SIZE, "%d\n", pyra->firmware_version); |
| 354 | } |
| 355 | |
| 356 | static ssize_t pyra_sysfs_show_startup_profile(struct device *dev, |
| 357 | struct device_attribute *attr, char *buf) |
| 358 | { |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 359 | struct pyra_device *pyra = |
| 360 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 361 | return snprintf(buf, PAGE_SIZE, "%d\n", pyra->settings.startup_profile); |
| 362 | } |
| 363 | |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 364 | static struct device_attribute pyra_attributes[] = { |
| 365 | __ATTR(actual_cpi, 0440, pyra_sysfs_show_actual_cpi, NULL), |
| 366 | __ATTR(actual_profile, 0440, pyra_sysfs_show_actual_profile, NULL), |
| 367 | __ATTR(firmware_version, 0440, |
| 368 | pyra_sysfs_show_firmware_version, NULL), |
| 369 | __ATTR(startup_profile, 0440, |
| 370 | pyra_sysfs_show_startup_profile, NULL), |
| 371 | __ATTR_NULL |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 372 | }; |
| 373 | |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 374 | static struct bin_attribute pyra_bin_attributes[] = { |
| 375 | { |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 376 | .attr = { .name = "profile_settings", .mode = 0220 }, |
| 377 | .size = sizeof(struct pyra_profile_settings), |
| 378 | .write = pyra_sysfs_write_profile_settings |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 379 | }, |
| 380 | { |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 381 | .attr = { .name = "profile1_settings", .mode = 0440 }, |
| 382 | .size = sizeof(struct pyra_profile_settings), |
Stefan Achatz | 14a057f | 2010-11-26 19:57:38 +0000 | [diff] [blame] | 383 | .read = pyra_sysfs_read_profilex_settings, |
| 384 | .private = &profile_numbers[0] |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 385 | }, |
| 386 | { |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 387 | .attr = { .name = "profile2_settings", .mode = 0440 }, |
| 388 | .size = sizeof(struct pyra_profile_settings), |
Stefan Achatz | 14a057f | 2010-11-26 19:57:38 +0000 | [diff] [blame] | 389 | .read = pyra_sysfs_read_profilex_settings, |
| 390 | .private = &profile_numbers[1] |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 391 | }, |
| 392 | { |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 393 | .attr = { .name = "profile3_settings", .mode = 0440 }, |
| 394 | .size = sizeof(struct pyra_profile_settings), |
Stefan Achatz | 14a057f | 2010-11-26 19:57:38 +0000 | [diff] [blame] | 395 | .read = pyra_sysfs_read_profilex_settings, |
| 396 | .private = &profile_numbers[2] |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 397 | }, |
| 398 | { |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 399 | .attr = { .name = "profile4_settings", .mode = 0440 }, |
| 400 | .size = sizeof(struct pyra_profile_settings), |
Stefan Achatz | 14a057f | 2010-11-26 19:57:38 +0000 | [diff] [blame] | 401 | .read = pyra_sysfs_read_profilex_settings, |
| 402 | .private = &profile_numbers[3] |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 403 | }, |
| 404 | { |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 405 | .attr = { .name = "profile5_settings", .mode = 0440 }, |
| 406 | .size = sizeof(struct pyra_profile_settings), |
Stefan Achatz | 14a057f | 2010-11-26 19:57:38 +0000 | [diff] [blame] | 407 | .read = pyra_sysfs_read_profilex_settings, |
| 408 | .private = &profile_numbers[4] |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 409 | }, |
| 410 | { |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 411 | .attr = { .name = "profile_buttons", .mode = 0220 }, |
| 412 | .size = sizeof(struct pyra_profile_buttons), |
| 413 | .write = pyra_sysfs_write_profile_buttons |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 414 | }, |
| 415 | { |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 416 | .attr = { .name = "profile1_buttons", .mode = 0440 }, |
| 417 | .size = sizeof(struct pyra_profile_buttons), |
Stefan Achatz | 14a057f | 2010-11-26 19:57:38 +0000 | [diff] [blame] | 418 | .read = pyra_sysfs_read_profilex_buttons, |
| 419 | .private = &profile_numbers[0] |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 420 | }, |
| 421 | { |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 422 | .attr = { .name = "profile2_buttons", .mode = 0440 }, |
| 423 | .size = sizeof(struct pyra_profile_buttons), |
Stefan Achatz | 14a057f | 2010-11-26 19:57:38 +0000 | [diff] [blame] | 424 | .read = pyra_sysfs_read_profilex_buttons, |
| 425 | .private = &profile_numbers[1] |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 426 | }, |
| 427 | { |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 428 | .attr = { .name = "profile3_buttons", .mode = 0440 }, |
| 429 | .size = sizeof(struct pyra_profile_buttons), |
Stefan Achatz | 14a057f | 2010-11-26 19:57:38 +0000 | [diff] [blame] | 430 | .read = pyra_sysfs_read_profilex_buttons, |
| 431 | .private = &profile_numbers[2] |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 432 | }, |
| 433 | { |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 434 | .attr = { .name = "profile4_buttons", .mode = 0440 }, |
| 435 | .size = sizeof(struct pyra_profile_buttons), |
Stefan Achatz | 14a057f | 2010-11-26 19:57:38 +0000 | [diff] [blame] | 436 | .read = pyra_sysfs_read_profilex_buttons, |
| 437 | .private = &profile_numbers[3] |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 438 | }, |
| 439 | { |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 440 | .attr = { .name = "profile5_buttons", .mode = 0440 }, |
| 441 | .size = sizeof(struct pyra_profile_buttons), |
Stefan Achatz | 14a057f | 2010-11-26 19:57:38 +0000 | [diff] [blame] | 442 | .read = pyra_sysfs_read_profilex_buttons, |
| 443 | .private = &profile_numbers[4] |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 444 | }, |
| 445 | { |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 446 | .attr = { .name = "settings", .mode = 0660 }, |
| 447 | .size = sizeof(struct pyra_settings), |
| 448 | .read = pyra_sysfs_read_settings, |
| 449 | .write = pyra_sysfs_write_settings |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 450 | }, |
| 451 | __ATTR_NULL |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 452 | }; |
| 453 | |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 454 | static int pyra_init_pyra_device_struct(struct usb_device *usb_dev, |
| 455 | struct pyra_device *pyra) |
| 456 | { |
Stefan Achatz | 5772f63 | 2011-01-30 13:38:23 +0100 | [diff] [blame] | 457 | struct pyra_info info; |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 458 | int retval, i; |
| 459 | |
| 460 | mutex_init(&pyra->pyra_lock); |
| 461 | |
Stefan Achatz | 5772f63 | 2011-01-30 13:38:23 +0100 | [diff] [blame] | 462 | retval = pyra_get_info(usb_dev, &info); |
| 463 | if (retval) |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 464 | return retval; |
Stefan Achatz | 5772f63 | 2011-01-30 13:38:23 +0100 | [diff] [blame] | 465 | |
| 466 | pyra->firmware_version = info.firmware_version; |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 467 | |
| 468 | retval = pyra_get_settings(usb_dev, &pyra->settings); |
| 469 | if (retval) |
| 470 | return retval; |
| 471 | |
| 472 | for (i = 0; i < 5; ++i) { |
| 473 | retval = pyra_get_profile_settings(usb_dev, |
| 474 | &pyra->profile_settings[i], i); |
| 475 | if (retval) |
| 476 | return retval; |
| 477 | |
| 478 | retval = pyra_get_profile_buttons(usb_dev, |
| 479 | &pyra->profile_buttons[i], i); |
| 480 | if (retval) |
| 481 | return retval; |
| 482 | } |
| 483 | |
| 484 | profile_activated(pyra, pyra->settings.startup_profile); |
| 485 | |
| 486 | return 0; |
| 487 | } |
| 488 | |
| 489 | static int pyra_init_specials(struct hid_device *hdev) |
| 490 | { |
| 491 | struct usb_interface *intf = to_usb_interface(hdev->dev.parent); |
| 492 | struct usb_device *usb_dev = interface_to_usbdev(intf); |
| 493 | struct pyra_device *pyra; |
| 494 | int retval; |
| 495 | |
| 496 | if (intf->cur_altsetting->desc.bInterfaceProtocol |
| 497 | == USB_INTERFACE_PROTOCOL_MOUSE) { |
| 498 | |
| 499 | pyra = kzalloc(sizeof(*pyra), GFP_KERNEL); |
| 500 | if (!pyra) { |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 501 | hid_err(hdev, "can't alloc device descriptor\n"); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 502 | return -ENOMEM; |
| 503 | } |
| 504 | hid_set_drvdata(hdev, pyra); |
| 505 | |
| 506 | retval = pyra_init_pyra_device_struct(usb_dev, pyra); |
| 507 | if (retval) { |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 508 | hid_err(hdev, "couldn't init struct pyra_device\n"); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 509 | goto exit_free; |
| 510 | } |
| 511 | |
Stefan Achatz | 8211e46 | 2011-01-30 13:38:25 +0100 | [diff] [blame] | 512 | retval = roccat_connect(pyra_class, hdev, |
| 513 | sizeof(struct pyra_roccat_report)); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 514 | if (retval < 0) { |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 515 | hid_err(hdev, "couldn't init char dev\n"); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 516 | } else { |
| 517 | pyra->chrdev_minor = retval; |
| 518 | pyra->roccat_claimed = 1; |
| 519 | } |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 520 | } else { |
| 521 | hid_set_drvdata(hdev, NULL); |
| 522 | } |
| 523 | |
| 524 | return 0; |
| 525 | exit_free: |
| 526 | kfree(pyra); |
| 527 | return retval; |
| 528 | } |
| 529 | |
| 530 | static void pyra_remove_specials(struct hid_device *hdev) |
| 531 | { |
| 532 | struct usb_interface *intf = to_usb_interface(hdev->dev.parent); |
| 533 | struct pyra_device *pyra; |
| 534 | |
| 535 | if (intf->cur_altsetting->desc.bInterfaceProtocol |
| 536 | == USB_INTERFACE_PROTOCOL_MOUSE) { |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 537 | pyra = hid_get_drvdata(hdev); |
| 538 | if (pyra->roccat_claimed) |
| 539 | roccat_disconnect(pyra->chrdev_minor); |
| 540 | kfree(hid_get_drvdata(hdev)); |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | static int pyra_probe(struct hid_device *hdev, const struct hid_device_id *id) |
| 545 | { |
| 546 | int retval; |
| 547 | |
| 548 | retval = hid_parse(hdev); |
| 549 | if (retval) { |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 550 | hid_err(hdev, "parse failed\n"); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 551 | goto exit; |
| 552 | } |
| 553 | |
| 554 | retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
| 555 | if (retval) { |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 556 | hid_err(hdev, "hw start failed\n"); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 557 | goto exit; |
| 558 | } |
| 559 | |
| 560 | retval = pyra_init_specials(hdev); |
| 561 | if (retval) { |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 562 | hid_err(hdev, "couldn't install mouse\n"); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 563 | goto exit_stop; |
| 564 | } |
| 565 | return 0; |
| 566 | |
| 567 | exit_stop: |
| 568 | hid_hw_stop(hdev); |
| 569 | exit: |
| 570 | return retval; |
| 571 | } |
| 572 | |
| 573 | static void pyra_remove(struct hid_device *hdev) |
| 574 | { |
| 575 | pyra_remove_specials(hdev); |
| 576 | hid_hw_stop(hdev); |
| 577 | } |
| 578 | |
| 579 | static void pyra_keep_values_up_to_date(struct pyra_device *pyra, |
| 580 | u8 const *data) |
| 581 | { |
| 582 | struct pyra_mouse_event_button const *button_event; |
| 583 | |
| 584 | switch (data[0]) { |
| 585 | case PYRA_MOUSE_REPORT_NUMBER_BUTTON: |
| 586 | button_event = (struct pyra_mouse_event_button const *)data; |
| 587 | switch (button_event->type) { |
| 588 | case PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_2: |
| 589 | profile_activated(pyra, button_event->data1 - 1); |
| 590 | break; |
| 591 | case PYRA_MOUSE_EVENT_BUTTON_TYPE_CPI: |
| 592 | pyra->actual_cpi = button_event->data1; |
| 593 | break; |
| 594 | } |
| 595 | break; |
| 596 | } |
| 597 | } |
| 598 | |
| 599 | static void pyra_report_to_chrdev(struct pyra_device const *pyra, |
| 600 | u8 const *data) |
| 601 | { |
| 602 | struct pyra_roccat_report roccat_report; |
| 603 | struct pyra_mouse_event_button const *button_event; |
| 604 | |
| 605 | if (data[0] != PYRA_MOUSE_REPORT_NUMBER_BUTTON) |
| 606 | return; |
| 607 | |
| 608 | button_event = (struct pyra_mouse_event_button const *)data; |
| 609 | |
| 610 | switch (button_event->type) { |
| 611 | case PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_2: |
| 612 | case PYRA_MOUSE_EVENT_BUTTON_TYPE_CPI: |
| 613 | roccat_report.type = button_event->type; |
| 614 | roccat_report.value = button_event->data1; |
| 615 | roccat_report.key = 0; |
| 616 | roccat_report_event(pyra->chrdev_minor, |
Stefan Achatz | 8211e46 | 2011-01-30 13:38:25 +0100 | [diff] [blame] | 617 | (uint8_t const *)&roccat_report); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 618 | break; |
| 619 | case PYRA_MOUSE_EVENT_BUTTON_TYPE_MACRO: |
| 620 | case PYRA_MOUSE_EVENT_BUTTON_TYPE_SHORTCUT: |
| 621 | case PYRA_MOUSE_EVENT_BUTTON_TYPE_QUICKLAUNCH: |
| 622 | if (button_event->data2 == PYRA_MOUSE_EVENT_BUTTON_PRESS) { |
| 623 | roccat_report.type = button_event->type; |
| 624 | roccat_report.key = button_event->data1; |
Stefan Achatz | d2b570a | 2010-09-01 12:42:23 +0200 | [diff] [blame] | 625 | /* |
| 626 | * pyra reports profile numbers with range 1-5. |
| 627 | * Keeping this behaviour. |
| 628 | */ |
| 629 | roccat_report.value = pyra->actual_profile + 1; |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 630 | roccat_report_event(pyra->chrdev_minor, |
Stefan Achatz | 8211e46 | 2011-01-30 13:38:25 +0100 | [diff] [blame] | 631 | (uint8_t const *)&roccat_report); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 632 | } |
| 633 | break; |
| 634 | } |
| 635 | } |
| 636 | |
| 637 | static int pyra_raw_event(struct hid_device *hdev, struct hid_report *report, |
| 638 | u8 *data, int size) |
| 639 | { |
| 640 | struct usb_interface *intf = to_usb_interface(hdev->dev.parent); |
| 641 | struct pyra_device *pyra = hid_get_drvdata(hdev); |
| 642 | |
| 643 | if (intf->cur_altsetting->desc.bInterfaceProtocol |
| 644 | != USB_INTERFACE_PROTOCOL_MOUSE) |
| 645 | return 0; |
| 646 | |
Stefan Achatz | 901e64d | 2011-06-12 10:02:44 +0200 | [diff] [blame] | 647 | if (pyra == NULL) |
| 648 | return 0; |
| 649 | |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 650 | pyra_keep_values_up_to_date(pyra, data); |
| 651 | |
| 652 | if (pyra->roccat_claimed) |
| 653 | pyra_report_to_chrdev(pyra, data); |
| 654 | |
| 655 | return 0; |
| 656 | } |
| 657 | |
| 658 | static const struct hid_device_id pyra_devices[] = { |
| 659 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, |
| 660 | USB_DEVICE_ID_ROCCAT_PYRA_WIRED) }, |
Stefan Achatz | 3fce224 | 2011-03-23 18:11:36 +0100 | [diff] [blame] | 661 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, |
| 662 | USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS) }, |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 663 | { } |
| 664 | }; |
| 665 | |
| 666 | MODULE_DEVICE_TABLE(hid, pyra_devices); |
| 667 | |
| 668 | static struct hid_driver pyra_driver = { |
| 669 | .name = "pyra", |
| 670 | .id_table = pyra_devices, |
| 671 | .probe = pyra_probe, |
| 672 | .remove = pyra_remove, |
| 673 | .raw_event = pyra_raw_event |
| 674 | }; |
| 675 | |
| 676 | static int __init pyra_init(void) |
| 677 | { |
Stefan Achatz | 5012aad | 2010-11-26 19:57:33 +0000 | [diff] [blame] | 678 | int retval; |
| 679 | |
| 680 | /* class name has to be same as driver name */ |
| 681 | pyra_class = class_create(THIS_MODULE, "pyra"); |
| 682 | if (IS_ERR(pyra_class)) |
| 683 | return PTR_ERR(pyra_class); |
| 684 | pyra_class->dev_attrs = pyra_attributes; |
| 685 | pyra_class->dev_bin_attrs = pyra_bin_attributes; |
| 686 | |
| 687 | retval = hid_register_driver(&pyra_driver); |
| 688 | if (retval) |
| 689 | class_destroy(pyra_class); |
| 690 | return retval; |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 691 | } |
| 692 | |
| 693 | static void __exit pyra_exit(void) |
| 694 | { |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 695 | hid_unregister_driver(&pyra_driver); |
Stefan Achatz | 74b643d | 2011-01-30 13:38:27 +0100 | [diff] [blame] | 696 | class_destroy(pyra_class); |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 697 | } |
| 698 | |
| 699 | module_init(pyra_init); |
| 700 | module_exit(pyra_exit); |
| 701 | |
| 702 | MODULE_AUTHOR("Stefan Achatz"); |
| 703 | MODULE_DESCRIPTION("USB Roccat Pyra driver"); |
| 704 | MODULE_LICENSE("GPL v2"); |