hid-roccat-pyra.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. /*
  2. * Roccat Pyra driver for Linux
  3. *
  4. * Copyright (c) 2010 Stefan Achatz <erazor_de@users.sourceforge.net>
  5. */
  6. /*
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the Free
  9. * Software Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. */
  12. /*
  13. * Roccat Pyra is a mobile gamer mouse which comes in wired and wireless
  14. * variant. Wireless variant is not tested.
  15. * Userland tools can be found at http://sourceforge.net/projects/roccat
  16. */
  17. #include <linux/device.h>
  18. #include <linux/input.h>
  19. #include <linux/hid.h>
  20. #include <linux/module.h>
  21. #include <linux/slab.h>
  22. #include <linux/hid-roccat.h>
  23. #include "hid-ids.h"
  24. #include "hid-roccat-common.h"
  25. #include "hid-roccat-pyra.h"
  26. static uint profile_numbers[5] = {0, 1, 2, 3, 4};
  27. /* pyra_class is used for creating sysfs attributes via roccat char device */
  28. static struct class *pyra_class;
  29. static void profile_activated(struct pyra_device *pyra,
  30. unsigned int new_profile)
  31. {
  32. pyra->actual_profile = new_profile;
  33. pyra->actual_cpi = pyra->profile_settings[pyra->actual_profile].y_cpi;
  34. }
  35. static int pyra_send_control(struct usb_device *usb_dev, int value,
  36. enum pyra_control_requests request)
  37. {
  38. struct roccat_common2_control control;
  39. if ((request == PYRA_CONTROL_REQUEST_PROFILE_SETTINGS ||
  40. request == PYRA_CONTROL_REQUEST_PROFILE_BUTTONS) &&
  41. (value < 0 || value > 4))
  42. return -EINVAL;
  43. control.command = ROCCAT_COMMON_COMMAND_CONTROL;
  44. control.value = value;
  45. control.request = request;
  46. return roccat_common2_send(usb_dev, ROCCAT_COMMON_COMMAND_CONTROL,
  47. &control, sizeof(struct roccat_common2_control));
  48. }
  49. static int pyra_get_profile_settings(struct usb_device *usb_dev,
  50. struct pyra_profile_settings *buf, int number)
  51. {
  52. int retval;
  53. retval = pyra_send_control(usb_dev, number,
  54. PYRA_CONTROL_REQUEST_PROFILE_SETTINGS);
  55. if (retval)
  56. return retval;
  57. return roccat_common2_receive(usb_dev, PYRA_COMMAND_PROFILE_SETTINGS,
  58. buf, PYRA_SIZE_PROFILE_SETTINGS);
  59. }
  60. static int pyra_get_settings(struct usb_device *usb_dev,
  61. struct pyra_settings *buf)
  62. {
  63. return roccat_common2_receive(usb_dev, PYRA_COMMAND_SETTINGS,
  64. buf, PYRA_SIZE_SETTINGS);
  65. }
  66. static int pyra_set_settings(struct usb_device *usb_dev,
  67. struct pyra_settings const *settings)
  68. {
  69. return roccat_common2_send_with_status(usb_dev,
  70. PYRA_COMMAND_SETTINGS, settings,
  71. PYRA_SIZE_SETTINGS);
  72. }
  73. static ssize_t pyra_sysfs_read(struct file *fp, struct kobject *kobj,
  74. char *buf, loff_t off, size_t count,
  75. size_t real_size, uint command)
  76. {
  77. struct device *dev =
  78. container_of(kobj, struct device, kobj)->parent->parent;
  79. struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev));
  80. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  81. int retval;
  82. if (off >= real_size)
  83. return 0;
  84. if (off != 0 || count != real_size)
  85. return -EINVAL;
  86. mutex_lock(&pyra->pyra_lock);
  87. retval = roccat_common2_receive(usb_dev, command, buf, real_size);
  88. mutex_unlock(&pyra->pyra_lock);
  89. if (retval)
  90. return retval;
  91. return real_size;
  92. }
  93. static ssize_t pyra_sysfs_write(struct file *fp, struct kobject *kobj,
  94. void const *buf, loff_t off, size_t count,
  95. size_t real_size, uint command)
  96. {
  97. struct device *dev =
  98. container_of(kobj, struct device, kobj)->parent->parent;
  99. struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev));
  100. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  101. int retval;
  102. if (off != 0 || count != real_size)
  103. return -EINVAL;
  104. mutex_lock(&pyra->pyra_lock);
  105. retval = roccat_common2_send_with_status(usb_dev, command, (void *)buf, real_size);
  106. mutex_unlock(&pyra->pyra_lock);
  107. if (retval)
  108. return retval;
  109. return real_size;
  110. }
  111. #define PYRA_SYSFS_W(thingy, THINGY) \
  112. static ssize_t pyra_sysfs_write_ ## thingy(struct file *fp, \
  113. struct kobject *kobj, struct bin_attribute *attr, char *buf, \
  114. loff_t off, size_t count) \
  115. { \
  116. return pyra_sysfs_write(fp, kobj, buf, off, count, \
  117. PYRA_SIZE_ ## THINGY, PYRA_COMMAND_ ## THINGY); \
  118. }
  119. #define PYRA_SYSFS_R(thingy, THINGY) \
  120. static ssize_t pyra_sysfs_read_ ## thingy(struct file *fp, \
  121. struct kobject *kobj, struct bin_attribute *attr, char *buf, \
  122. loff_t off, size_t count) \
  123. { \
  124. return pyra_sysfs_read(fp, kobj, buf, off, count, \
  125. PYRA_SIZE_ ## THINGY, PYRA_COMMAND_ ## THINGY); \
  126. }
  127. #define PYRA_SYSFS_RW(thingy, THINGY) \
  128. PYRA_SYSFS_W(thingy, THINGY) \
  129. PYRA_SYSFS_R(thingy, THINGY)
  130. #define PYRA_BIN_ATTRIBUTE_RW(thingy, THINGY) \
  131. { \
  132. .attr = { .name = #thingy, .mode = 0660 }, \
  133. .size = PYRA_SIZE_ ## THINGY, \
  134. .read = pyra_sysfs_read_ ## thingy, \
  135. .write = pyra_sysfs_write_ ## thingy \
  136. }
  137. #define PYRA_BIN_ATTRIBUTE_R(thingy, THINGY) \
  138. { \
  139. .attr = { .name = #thingy, .mode = 0440 }, \
  140. .size = PYRA_SIZE_ ## THINGY, \
  141. .read = pyra_sysfs_read_ ## thingy, \
  142. }
  143. #define PYRA_BIN_ATTRIBUTE_W(thingy, THINGY) \
  144. { \
  145. .attr = { .name = #thingy, .mode = 0220 }, \
  146. .size = PYRA_SIZE_ ## THINGY, \
  147. .write = pyra_sysfs_write_ ## thingy \
  148. }
  149. PYRA_SYSFS_RW(info, INFO)
  150. PYRA_SYSFS_W(profile_settings, PROFILE_SETTINGS)
  151. PYRA_SYSFS_W(profile_buttons, PROFILE_BUTTONS)
  152. PYRA_SYSFS_R(settings, SETTINGS)
  153. static ssize_t pyra_sysfs_read_profilex_settings(struct file *fp,
  154. struct kobject *kobj, struct bin_attribute *attr, char *buf,
  155. loff_t off, size_t count)
  156. {
  157. struct device *dev =
  158. container_of(kobj, struct device, kobj)->parent->parent;
  159. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  160. ssize_t retval;
  161. retval = pyra_send_control(usb_dev, *(uint *)(attr->private),
  162. PYRA_CONTROL_REQUEST_PROFILE_SETTINGS);
  163. if (retval)
  164. return retval;
  165. return pyra_sysfs_read(fp, kobj, buf, off, count,
  166. PYRA_SIZE_PROFILE_SETTINGS,
  167. PYRA_COMMAND_PROFILE_SETTINGS);
  168. }
  169. static ssize_t pyra_sysfs_read_profilex_buttons(struct file *fp,
  170. struct kobject *kobj, struct bin_attribute *attr, char *buf,
  171. loff_t off, size_t count)
  172. {
  173. struct device *dev =
  174. container_of(kobj, struct device, kobj)->parent->parent;
  175. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  176. ssize_t retval;
  177. retval = pyra_send_control(usb_dev, *(uint *)(attr->private),
  178. PYRA_CONTROL_REQUEST_PROFILE_BUTTONS);
  179. if (retval)
  180. return retval;
  181. return pyra_sysfs_read(fp, kobj, buf, off, count,
  182. PYRA_SIZE_PROFILE_BUTTONS,
  183. PYRA_COMMAND_PROFILE_BUTTONS);
  184. }
  185. static ssize_t pyra_sysfs_write_settings(struct file *fp,
  186. struct kobject *kobj, struct bin_attribute *attr, char *buf,
  187. loff_t off, size_t count)
  188. {
  189. struct device *dev =
  190. container_of(kobj, struct device, kobj)->parent->parent;
  191. struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev));
  192. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  193. int retval = 0;
  194. struct pyra_roccat_report roccat_report;
  195. struct pyra_settings const *settings;
  196. if (off != 0 || count != PYRA_SIZE_SETTINGS)
  197. return -EINVAL;
  198. mutex_lock(&pyra->pyra_lock);
  199. settings = (struct pyra_settings const *)buf;
  200. retval = pyra_set_settings(usb_dev, settings);
  201. if (retval) {
  202. mutex_unlock(&pyra->pyra_lock);
  203. return retval;
  204. }
  205. profile_activated(pyra, settings->startup_profile);
  206. roccat_report.type = PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_2;
  207. roccat_report.value = settings->startup_profile + 1;
  208. roccat_report.key = 0;
  209. roccat_report_event(pyra->chrdev_minor,
  210. (uint8_t const *)&roccat_report);
  211. mutex_unlock(&pyra->pyra_lock);
  212. return PYRA_SIZE_SETTINGS;
  213. }
  214. static ssize_t pyra_sysfs_show_actual_cpi(struct device *dev,
  215. struct device_attribute *attr, char *buf)
  216. {
  217. struct pyra_device *pyra =
  218. hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
  219. return snprintf(buf, PAGE_SIZE, "%d\n", pyra->actual_cpi);
  220. }
  221. static ssize_t pyra_sysfs_show_actual_profile(struct device *dev,
  222. struct device_attribute *attr, char *buf)
  223. {
  224. struct pyra_device *pyra =
  225. hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
  226. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  227. struct pyra_settings settings;
  228. mutex_lock(&pyra->pyra_lock);
  229. roccat_common2_receive(usb_dev, PYRA_COMMAND_SETTINGS,
  230. &settings, PYRA_SIZE_SETTINGS);
  231. mutex_unlock(&pyra->pyra_lock);
  232. return snprintf(buf, PAGE_SIZE, "%d\n", settings.startup_profile);
  233. }
  234. static ssize_t pyra_sysfs_show_firmware_version(struct device *dev,
  235. struct device_attribute *attr, char *buf)
  236. {
  237. struct pyra_device *pyra;
  238. struct usb_device *usb_dev;
  239. struct pyra_info info;
  240. dev = dev->parent->parent;
  241. pyra = hid_get_drvdata(dev_get_drvdata(dev));
  242. usb_dev = interface_to_usbdev(to_usb_interface(dev));
  243. mutex_lock(&pyra->pyra_lock);
  244. roccat_common2_receive(usb_dev, PYRA_COMMAND_INFO,
  245. &info, PYRA_SIZE_INFO);
  246. mutex_unlock(&pyra->pyra_lock);
  247. return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version);
  248. }
  249. static struct device_attribute pyra_attributes[] = {
  250. __ATTR(actual_cpi, 0440, pyra_sysfs_show_actual_cpi, NULL),
  251. __ATTR(actual_profile, 0440, pyra_sysfs_show_actual_profile, NULL),
  252. __ATTR(firmware_version, 0440,
  253. pyra_sysfs_show_firmware_version, NULL),
  254. __ATTR(startup_profile, 0440,
  255. pyra_sysfs_show_actual_profile, NULL),
  256. __ATTR_NULL
  257. };
  258. static struct bin_attribute pyra_bin_attributes[] = {
  259. PYRA_BIN_ATTRIBUTE_RW(info, INFO),
  260. PYRA_BIN_ATTRIBUTE_W(profile_settings, PROFILE_SETTINGS),
  261. PYRA_BIN_ATTRIBUTE_W(profile_buttons, PROFILE_BUTTONS),
  262. PYRA_BIN_ATTRIBUTE_RW(settings, SETTINGS),
  263. {
  264. .attr = { .name = "profile1_settings", .mode = 0440 },
  265. .size = PYRA_SIZE_PROFILE_SETTINGS,
  266. .read = pyra_sysfs_read_profilex_settings,
  267. .private = &profile_numbers[0]
  268. },
  269. {
  270. .attr = { .name = "profile2_settings", .mode = 0440 },
  271. .size = PYRA_SIZE_PROFILE_SETTINGS,
  272. .read = pyra_sysfs_read_profilex_settings,
  273. .private = &profile_numbers[1]
  274. },
  275. {
  276. .attr = { .name = "profile3_settings", .mode = 0440 },
  277. .size = PYRA_SIZE_PROFILE_SETTINGS,
  278. .read = pyra_sysfs_read_profilex_settings,
  279. .private = &profile_numbers[2]
  280. },
  281. {
  282. .attr = { .name = "profile4_settings", .mode = 0440 },
  283. .size = PYRA_SIZE_PROFILE_SETTINGS,
  284. .read = pyra_sysfs_read_profilex_settings,
  285. .private = &profile_numbers[3]
  286. },
  287. {
  288. .attr = { .name = "profile5_settings", .mode = 0440 },
  289. .size = PYRA_SIZE_PROFILE_SETTINGS,
  290. .read = pyra_sysfs_read_profilex_settings,
  291. .private = &profile_numbers[4]
  292. },
  293. {
  294. .attr = { .name = "profile1_buttons", .mode = 0440 },
  295. .size = PYRA_SIZE_PROFILE_BUTTONS,
  296. .read = pyra_sysfs_read_profilex_buttons,
  297. .private = &profile_numbers[0]
  298. },
  299. {
  300. .attr = { .name = "profile2_buttons", .mode = 0440 },
  301. .size = PYRA_SIZE_PROFILE_BUTTONS,
  302. .read = pyra_sysfs_read_profilex_buttons,
  303. .private = &profile_numbers[1]
  304. },
  305. {
  306. .attr = { .name = "profile3_buttons", .mode = 0440 },
  307. .size = PYRA_SIZE_PROFILE_BUTTONS,
  308. .read = pyra_sysfs_read_profilex_buttons,
  309. .private = &profile_numbers[2]
  310. },
  311. {
  312. .attr = { .name = "profile4_buttons", .mode = 0440 },
  313. .size = PYRA_SIZE_PROFILE_BUTTONS,
  314. .read = pyra_sysfs_read_profilex_buttons,
  315. .private = &profile_numbers[3]
  316. },
  317. {
  318. .attr = { .name = "profile5_buttons", .mode = 0440 },
  319. .size = PYRA_SIZE_PROFILE_BUTTONS,
  320. .read = pyra_sysfs_read_profilex_buttons,
  321. .private = &profile_numbers[4]
  322. },
  323. __ATTR_NULL
  324. };
  325. static int pyra_init_pyra_device_struct(struct usb_device *usb_dev,
  326. struct pyra_device *pyra)
  327. {
  328. struct pyra_settings settings;
  329. int retval, i;
  330. mutex_init(&pyra->pyra_lock);
  331. retval = pyra_get_settings(usb_dev, &settings);
  332. if (retval)
  333. return retval;
  334. for (i = 0; i < 5; ++i) {
  335. retval = pyra_get_profile_settings(usb_dev,
  336. &pyra->profile_settings[i], i);
  337. if (retval)
  338. return retval;
  339. }
  340. profile_activated(pyra, settings.startup_profile);
  341. return 0;
  342. }
  343. static int pyra_init_specials(struct hid_device *hdev)
  344. {
  345. struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
  346. struct usb_device *usb_dev = interface_to_usbdev(intf);
  347. struct pyra_device *pyra;
  348. int retval;
  349. if (intf->cur_altsetting->desc.bInterfaceProtocol
  350. == USB_INTERFACE_PROTOCOL_MOUSE) {
  351. pyra = kzalloc(sizeof(*pyra), GFP_KERNEL);
  352. if (!pyra) {
  353. hid_err(hdev, "can't alloc device descriptor\n");
  354. return -ENOMEM;
  355. }
  356. hid_set_drvdata(hdev, pyra);
  357. retval = pyra_init_pyra_device_struct(usb_dev, pyra);
  358. if (retval) {
  359. hid_err(hdev, "couldn't init struct pyra_device\n");
  360. goto exit_free;
  361. }
  362. retval = roccat_connect(pyra_class, hdev,
  363. sizeof(struct pyra_roccat_report));
  364. if (retval < 0) {
  365. hid_err(hdev, "couldn't init char dev\n");
  366. } else {
  367. pyra->chrdev_minor = retval;
  368. pyra->roccat_claimed = 1;
  369. }
  370. } else {
  371. hid_set_drvdata(hdev, NULL);
  372. }
  373. return 0;
  374. exit_free:
  375. kfree(pyra);
  376. return retval;
  377. }
  378. static void pyra_remove_specials(struct hid_device *hdev)
  379. {
  380. struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
  381. struct pyra_device *pyra;
  382. if (intf->cur_altsetting->desc.bInterfaceProtocol
  383. == USB_INTERFACE_PROTOCOL_MOUSE) {
  384. pyra = hid_get_drvdata(hdev);
  385. if (pyra->roccat_claimed)
  386. roccat_disconnect(pyra->chrdev_minor);
  387. kfree(hid_get_drvdata(hdev));
  388. }
  389. }
  390. static int pyra_probe(struct hid_device *hdev, const struct hid_device_id *id)
  391. {
  392. int retval;
  393. retval = hid_parse(hdev);
  394. if (retval) {
  395. hid_err(hdev, "parse failed\n");
  396. goto exit;
  397. }
  398. retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
  399. if (retval) {
  400. hid_err(hdev, "hw start failed\n");
  401. goto exit;
  402. }
  403. retval = pyra_init_specials(hdev);
  404. if (retval) {
  405. hid_err(hdev, "couldn't install mouse\n");
  406. goto exit_stop;
  407. }
  408. return 0;
  409. exit_stop:
  410. hid_hw_stop(hdev);
  411. exit:
  412. return retval;
  413. }
  414. static void pyra_remove(struct hid_device *hdev)
  415. {
  416. pyra_remove_specials(hdev);
  417. hid_hw_stop(hdev);
  418. }
  419. static void pyra_keep_values_up_to_date(struct pyra_device *pyra,
  420. u8 const *data)
  421. {
  422. struct pyra_mouse_event_button const *button_event;
  423. switch (data[0]) {
  424. case PYRA_MOUSE_REPORT_NUMBER_BUTTON:
  425. button_event = (struct pyra_mouse_event_button const *)data;
  426. switch (button_event->type) {
  427. case PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_2:
  428. profile_activated(pyra, button_event->data1 - 1);
  429. break;
  430. case PYRA_MOUSE_EVENT_BUTTON_TYPE_CPI:
  431. pyra->actual_cpi = button_event->data1;
  432. break;
  433. }
  434. break;
  435. }
  436. }
  437. static void pyra_report_to_chrdev(struct pyra_device const *pyra,
  438. u8 const *data)
  439. {
  440. struct pyra_roccat_report roccat_report;
  441. struct pyra_mouse_event_button const *button_event;
  442. if (data[0] != PYRA_MOUSE_REPORT_NUMBER_BUTTON)
  443. return;
  444. button_event = (struct pyra_mouse_event_button const *)data;
  445. switch (button_event->type) {
  446. case PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_2:
  447. case PYRA_MOUSE_EVENT_BUTTON_TYPE_CPI:
  448. roccat_report.type = button_event->type;
  449. roccat_report.value = button_event->data1;
  450. roccat_report.key = 0;
  451. roccat_report_event(pyra->chrdev_minor,
  452. (uint8_t const *)&roccat_report);
  453. break;
  454. case PYRA_MOUSE_EVENT_BUTTON_TYPE_MACRO:
  455. case PYRA_MOUSE_EVENT_BUTTON_TYPE_SHORTCUT:
  456. case PYRA_MOUSE_EVENT_BUTTON_TYPE_QUICKLAUNCH:
  457. if (button_event->data2 == PYRA_MOUSE_EVENT_BUTTON_PRESS) {
  458. roccat_report.type = button_event->type;
  459. roccat_report.key = button_event->data1;
  460. /*
  461. * pyra reports profile numbers with range 1-5.
  462. * Keeping this behaviour.
  463. */
  464. roccat_report.value = pyra->actual_profile + 1;
  465. roccat_report_event(pyra->chrdev_minor,
  466. (uint8_t const *)&roccat_report);
  467. }
  468. break;
  469. }
  470. }
  471. static int pyra_raw_event(struct hid_device *hdev, struct hid_report *report,
  472. u8 *data, int size)
  473. {
  474. struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
  475. struct pyra_device *pyra = hid_get_drvdata(hdev);
  476. if (intf->cur_altsetting->desc.bInterfaceProtocol
  477. != USB_INTERFACE_PROTOCOL_MOUSE)
  478. return 0;
  479. if (pyra == NULL)
  480. return 0;
  481. pyra_keep_values_up_to_date(pyra, data);
  482. if (pyra->roccat_claimed)
  483. pyra_report_to_chrdev(pyra, data);
  484. return 0;
  485. }
  486. static const struct hid_device_id pyra_devices[] = {
  487. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT,
  488. USB_DEVICE_ID_ROCCAT_PYRA_WIRED) },
  489. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT,
  490. USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS) },
  491. { }
  492. };
  493. MODULE_DEVICE_TABLE(hid, pyra_devices);
  494. static struct hid_driver pyra_driver = {
  495. .name = "pyra",
  496. .id_table = pyra_devices,
  497. .probe = pyra_probe,
  498. .remove = pyra_remove,
  499. .raw_event = pyra_raw_event
  500. };
  501. static int __init pyra_init(void)
  502. {
  503. int retval;
  504. /* class name has to be same as driver name */
  505. pyra_class = class_create(THIS_MODULE, "pyra");
  506. if (IS_ERR(pyra_class))
  507. return PTR_ERR(pyra_class);
  508. pyra_class->dev_attrs = pyra_attributes;
  509. pyra_class->dev_bin_attrs = pyra_bin_attributes;
  510. retval = hid_register_driver(&pyra_driver);
  511. if (retval)
  512. class_destroy(pyra_class);
  513. return retval;
  514. }
  515. static void __exit pyra_exit(void)
  516. {
  517. hid_unregister_driver(&pyra_driver);
  518. class_destroy(pyra_class);
  519. }
  520. module_init(pyra_init);
  521. module_exit(pyra_exit);
  522. MODULE_AUTHOR("Stefan Achatz");
  523. MODULE_DESCRIPTION("USB Roccat Pyra driver");
  524. MODULE_LICENSE("GPL v2");