grip_mp.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. /*
  2. * $Id: grip_mp.c,v 1.9 2002/07/20 19:28:45 bonnland Exp $
  3. *
  4. * Driver for the Gravis Grip Multiport, a gamepad "hub" that
  5. * connects up to four 9-pin digital gamepads/joysticks.
  6. * Driver tested on SMP and UP kernel versions 2.4.18-4 and 2.4.18-5.
  7. *
  8. * Thanks to Chris Gassib for helpful advice.
  9. *
  10. * Copyright (c) 2002 Brian Bonnlander, Bill Soudan
  11. * Copyright (c) 1998-2000 Vojtech Pavlik
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/module.h>
  15. #include <linux/init.h>
  16. #include <linux/slab.h>
  17. #include <linux/gameport.h>
  18. #include <linux/input.h>
  19. #include <linux/delay.h>
  20. #include <linux/proc_fs.h>
  21. #include <linux/jiffies.h>
  22. #define DRIVER_DESC "Gravis Grip Multiport driver"
  23. MODULE_AUTHOR("Brian Bonnlander");
  24. MODULE_DESCRIPTION(DRIVER_DESC);
  25. MODULE_LICENSE("GPL");
  26. #ifdef GRIP_DEBUG
  27. #define dbg(format, arg...) printk(KERN_ERR __FILE__ ": " format "\n" , ## arg)
  28. #else
  29. #define dbg(format, arg...) do {} while (0)
  30. #endif
  31. #define GRIP_MAX_PORTS 4
  32. /*
  33. * Grip multiport state
  34. */
  35. struct grip_port {
  36. struct input_dev *dev;
  37. int mode;
  38. int registered;
  39. /* individual gamepad states */
  40. int buttons;
  41. int xaxes;
  42. int yaxes;
  43. int dirty; /* has the state been updated? */
  44. };
  45. struct grip_mp {
  46. struct gameport *gameport;
  47. struct grip_port *port[GRIP_MAX_PORTS];
  48. int reads;
  49. int bads;
  50. };
  51. /*
  52. * Multiport packet interpretation
  53. */
  54. #define PACKET_FULL 0x80000000 /* packet is full */
  55. #define PACKET_IO_FAST 0x40000000 /* 3 bits per gameport read */
  56. #define PACKET_IO_SLOW 0x20000000 /* 1 bit per gameport read */
  57. #define PACKET_MP_MORE 0x04000000 /* multiport wants to send more */
  58. #define PACKET_MP_DONE 0x02000000 /* multiport done sending */
  59. /*
  60. * Packet status code interpretation
  61. */
  62. #define IO_GOT_PACKET 0x0100 /* Got a packet */
  63. #define IO_MODE_FAST 0x0200 /* Used 3 data bits per gameport read */
  64. #define IO_SLOT_CHANGE 0x0800 /* Multiport physical slot status changed */
  65. #define IO_DONE 0x1000 /* Multiport is done sending packets */
  66. #define IO_RETRY 0x4000 /* Try again later to get packet */
  67. #define IO_RESET 0x8000 /* Force multiport to resend all packets */
  68. /*
  69. * Gamepad configuration data. Other 9-pin digital joystick devices
  70. * may work with the multiport, so this may not be an exhaustive list!
  71. * Commodore 64 joystick remains untested.
  72. */
  73. #define GRIP_INIT_DELAY 2000 /* 2 ms */
  74. #define GRIP_MODE_NONE 0
  75. #define GRIP_MODE_RESET 1
  76. #define GRIP_MODE_GP 2
  77. #define GRIP_MODE_C64 3
  78. static const int grip_btn_gp[] = { BTN_TR, BTN_TL, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, -1 };
  79. static const int grip_btn_c64[] = { BTN_JOYSTICK, -1 };
  80. static const int grip_abs_gp[] = { ABS_X, ABS_Y, -1 };
  81. static const int grip_abs_c64[] = { ABS_X, ABS_Y, -1 };
  82. static const int *grip_abs[] = { NULL, NULL, grip_abs_gp, grip_abs_c64 };
  83. static const int *grip_btn[] = { NULL, NULL, grip_btn_gp, grip_btn_c64 };
  84. static const char *grip_name[] = { NULL, NULL, "Gravis Grip Pad", "Commodore 64 Joystick" };
  85. static const int init_seq[] = {
  86. 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1,
  87. 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1,
  88. 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1,
  89. 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1 };
  90. /* Maps multiport directional values to X,Y axis values (each axis encoded in 3 bits) */
  91. static const int axis_map[] = { 5, 9, 1, 5, 6, 10, 2, 6, 4, 8, 0, 4, 5, 9, 1, 5 };
  92. static int register_slot(int i, struct grip_mp *grip);
  93. /*
  94. * Returns whether an odd or even number of bits are on in pkt.
  95. */
  96. static int bit_parity(u32 pkt)
  97. {
  98. int x = pkt ^ (pkt >> 16);
  99. x ^= x >> 8;
  100. x ^= x >> 4;
  101. x ^= x >> 2;
  102. x ^= x >> 1;
  103. return x & 1;
  104. }
  105. /*
  106. * Poll gameport; return true if all bits set in 'onbits' are on and
  107. * all bits set in 'offbits' are off.
  108. */
  109. static inline int poll_until(u8 onbits, u8 offbits, int u_sec, struct gameport* gp, u8 *data)
  110. {
  111. int i, nloops;
  112. nloops = gameport_time(gp, u_sec);
  113. for (i = 0; i < nloops; i++) {
  114. *data = gameport_read(gp);
  115. if ((*data & onbits) == onbits &&
  116. (~(*data) & offbits) == offbits)
  117. return 1;
  118. }
  119. dbg("gameport timed out after %d microseconds.\n", u_sec);
  120. return 0;
  121. }
  122. /*
  123. * Gets a 28-bit packet from the multiport.
  124. *
  125. * After getting a packet successfully, commands encoded by sendcode may
  126. * be sent to the multiport.
  127. *
  128. * The multiport clock value is reflected in gameport bit B4.
  129. *
  130. * Returns a packet status code indicating whether packet is valid, the transfer
  131. * mode, and any error conditions.
  132. *
  133. * sendflags: current I/O status
  134. * sendcode: data to send to the multiport if sendflags is nonzero
  135. */
  136. static int mp_io(struct gameport* gameport, int sendflags, int sendcode, u32 *packet)
  137. {
  138. u8 raw_data; /* raw data from gameport */
  139. u8 data_mask; /* packet data bits from raw_data */
  140. u32 pkt; /* packet temporary storage */
  141. int bits_per_read; /* num packet bits per gameport read */
  142. int portvals = 0; /* used for port value sanity check */
  143. int i;
  144. /* Gameport bits B0, B4, B5 should first be off, then B4 should come on. */
  145. *packet = 0;
  146. raw_data = gameport_read(gameport);
  147. if (raw_data & 1)
  148. return IO_RETRY;
  149. for (i = 0; i < 64; i++) {
  150. raw_data = gameport_read(gameport);
  151. portvals |= 1 << ((raw_data >> 4) & 3); /* Demux B4, B5 */
  152. }
  153. if (portvals == 1) { /* B4, B5 off */
  154. raw_data = gameport_read(gameport);
  155. portvals = raw_data & 0xf0;
  156. if (raw_data & 0x31)
  157. return IO_RESET;
  158. gameport_trigger(gameport);
  159. if (!poll_until(0x10, 0, 308, gameport, &raw_data))
  160. return IO_RESET;
  161. } else
  162. return IO_RETRY;
  163. /* Determine packet transfer mode and prepare for packet construction. */
  164. if (raw_data & 0x20) { /* 3 data bits/read */
  165. portvals |= raw_data >> 4; /* Compare B4-B7 before & after trigger */
  166. if (portvals != 0xb)
  167. return 0;
  168. data_mask = 7;
  169. bits_per_read = 3;
  170. pkt = (PACKET_FULL | PACKET_IO_FAST) >> 28;
  171. } else { /* 1 data bit/read */
  172. data_mask = 1;
  173. bits_per_read = 1;
  174. pkt = (PACKET_FULL | PACKET_IO_SLOW) >> 28;
  175. }
  176. /* Construct a packet. Final data bits must be zero. */
  177. while (1) {
  178. if (!poll_until(0, 0x10, 77, gameport, &raw_data))
  179. return IO_RESET;
  180. raw_data = (raw_data >> 5) & data_mask;
  181. if (pkt & PACKET_FULL)
  182. break;
  183. pkt = (pkt << bits_per_read) | raw_data;
  184. if (!poll_until(0x10, 0, 77, gameport, &raw_data))
  185. return IO_RESET;
  186. }
  187. if (raw_data)
  188. return IO_RESET;
  189. /* If 3 bits/read used, drop from 30 bits to 28. */
  190. if (bits_per_read == 3) {
  191. pkt = (pkt & 0xffff0000) | ((pkt << 1) & 0xffff);
  192. pkt = (pkt >> 2) | 0xf0000000;
  193. }
  194. if (bit_parity(pkt) == 1)
  195. return IO_RESET;
  196. /* Acknowledge packet receipt */
  197. if (!poll_until(0x30, 0, 77, gameport, &raw_data))
  198. return IO_RESET;
  199. raw_data = gameport_read(gameport);
  200. if (raw_data & 1)
  201. return IO_RESET;
  202. gameport_trigger(gameport);
  203. if (!poll_until(0, 0x20, 77, gameport, &raw_data))
  204. return IO_RESET;
  205. /* Return if we just wanted the packet or multiport wants to send more */
  206. *packet = pkt;
  207. if ((sendflags == 0) || ((sendflags & IO_RETRY) && !(pkt & PACKET_MP_DONE)))
  208. return IO_GOT_PACKET;
  209. if (pkt & PACKET_MP_MORE)
  210. return IO_GOT_PACKET | IO_RETRY;
  211. /* Multiport is done sending packets and is ready to receive data */
  212. if (!poll_until(0x20, 0, 77, gameport, &raw_data))
  213. return IO_GOT_PACKET | IO_RESET;
  214. raw_data = gameport_read(gameport);
  215. if (raw_data & 1)
  216. return IO_GOT_PACKET | IO_RESET;
  217. /* Trigger gameport based on bits in sendcode */
  218. gameport_trigger(gameport);
  219. do {
  220. if (!poll_until(0x20, 0x10, 116, gameport, &raw_data))
  221. return IO_GOT_PACKET | IO_RESET;
  222. if (!poll_until(0x30, 0, 193, gameport, &raw_data))
  223. return IO_GOT_PACKET | IO_RESET;
  224. if (raw_data & 1)
  225. return IO_GOT_PACKET | IO_RESET;
  226. if (sendcode & 1)
  227. gameport_trigger(gameport);
  228. sendcode >>= 1;
  229. } while (sendcode);
  230. return IO_GOT_PACKET | IO_MODE_FAST;
  231. }
  232. /*
  233. * Disables and restores interrupts for mp_io(), which does the actual I/O.
  234. */
  235. static int multiport_io(struct gameport* gameport, int sendflags, int sendcode, u32 *packet)
  236. {
  237. int status;
  238. unsigned long flags;
  239. local_irq_save(flags);
  240. status = mp_io(gameport, sendflags, sendcode, packet);
  241. local_irq_restore(flags);
  242. return status;
  243. }
  244. /*
  245. * Puts multiport into digital mode. Multiport LED turns green.
  246. *
  247. * Returns true if a valid digital packet was received, false otherwise.
  248. */
  249. static int dig_mode_start(struct gameport *gameport, u32 *packet)
  250. {
  251. int i, seq_len = sizeof(init_seq)/sizeof(int);
  252. int flags, tries = 0, bads = 0;
  253. for (i = 0; i < seq_len; i++) { /* Send magic sequence */
  254. if (init_seq[i])
  255. gameport_trigger(gameport);
  256. udelay(GRIP_INIT_DELAY);
  257. }
  258. for (i = 0; i < 16; i++) /* Wait for multiport to settle */
  259. udelay(GRIP_INIT_DELAY);
  260. while (tries < 64 && bads < 8) { /* Reset multiport and try getting a packet */
  261. flags = multiport_io(gameport, IO_RESET, 0x27, packet);
  262. if (flags & IO_MODE_FAST)
  263. return 1;
  264. if (flags & IO_RETRY)
  265. tries++;
  266. else
  267. bads++;
  268. }
  269. return 0;
  270. }
  271. /*
  272. * Packet structure: B0-B15 => gamepad state
  273. * B16-B20 => gamepad device type
  274. * B21-B24 => multiport slot index (1-4)
  275. *
  276. * Known device types: 0x1f (grip pad), 0x0 (no device). Others may exist.
  277. *
  278. * Returns the packet status.
  279. */
  280. static int get_and_decode_packet(struct grip_mp *grip, int flags)
  281. {
  282. struct grip_port *port;
  283. u32 packet;
  284. int joytype = 0;
  285. int slot;
  286. /* Get a packet and check for validity */
  287. flags &= IO_RESET | IO_RETRY;
  288. flags = multiport_io(grip->gameport, flags, 0, &packet);
  289. grip->reads++;
  290. if (packet & PACKET_MP_DONE)
  291. flags |= IO_DONE;
  292. if (flags && !(flags & IO_GOT_PACKET)) {
  293. grip->bads++;
  294. return flags;
  295. }
  296. /* Ignore non-gamepad packets, e.g. multiport hardware version */
  297. slot = ((packet >> 21) & 0xf) - 1;
  298. if ((slot < 0) || (slot > 3))
  299. return flags;
  300. port = grip->port[slot];
  301. /*
  302. * Handle "reset" packets, which occur at startup, and when gamepads
  303. * are removed or plugged in. May contain configuration of a new gamepad.
  304. */
  305. joytype = (packet >> 16) & 0x1f;
  306. if (!joytype) {
  307. if (port->registered) {
  308. printk(KERN_INFO "grip_mp: removing %s, slot %d\n",
  309. grip_name[port->mode], slot);
  310. input_unregister_device(port->dev);
  311. port->registered = 0;
  312. }
  313. dbg("Reset: grip multiport slot %d\n", slot);
  314. port->mode = GRIP_MODE_RESET;
  315. flags |= IO_SLOT_CHANGE;
  316. return flags;
  317. }
  318. /* Interpret a grip pad packet */
  319. if (joytype == 0x1f) {
  320. int dir = (packet >> 8) & 0xf; /* eight way directional value */
  321. port->buttons = (~packet) & 0xff;
  322. port->yaxes = ((axis_map[dir] >> 2) & 3) - 1;
  323. port->xaxes = (axis_map[dir] & 3) - 1;
  324. port->dirty = 1;
  325. if (port->mode == GRIP_MODE_RESET)
  326. flags |= IO_SLOT_CHANGE;
  327. port->mode = GRIP_MODE_GP;
  328. if (!port->registered) {
  329. dbg("New Grip pad in multiport slot %d.\n", slot);
  330. register_slot(slot, grip);
  331. }
  332. return flags;
  333. }
  334. /* Handle non-grip device codes. For now, just print diagnostics. */
  335. {
  336. static int strange_code = 0;
  337. if (strange_code != joytype) {
  338. printk(KERN_INFO "Possible non-grip pad/joystick detected.\n");
  339. printk(KERN_INFO "Got joy type 0x%x and packet 0x%x.\n", joytype, packet);
  340. strange_code = joytype;
  341. }
  342. }
  343. return flags;
  344. }
  345. /*
  346. * Returns true if all multiport slot states appear valid.
  347. */
  348. static int slots_valid(struct grip_mp *grip)
  349. {
  350. int flags, slot, invalid = 0, active = 0;
  351. flags = get_and_decode_packet(grip, 0);
  352. if (!(flags & IO_GOT_PACKET))
  353. return 0;
  354. for (slot = 0; slot < 4; slot++) {
  355. if (grip->port[slot]->mode == GRIP_MODE_RESET)
  356. invalid = 1;
  357. if (grip->port[slot]->mode != GRIP_MODE_NONE)
  358. active = 1;
  359. }
  360. /* Return true if no active slot but multiport sent all its data */
  361. if (!active)
  362. return (flags & IO_DONE) ? 1 : 0;
  363. /* Return false if invalid device code received */
  364. return invalid ? 0 : 1;
  365. }
  366. /*
  367. * Returns whether the multiport was placed into digital mode and
  368. * able to communicate its state successfully.
  369. */
  370. static int multiport_init(struct grip_mp *grip)
  371. {
  372. int dig_mode, initialized = 0, tries = 0;
  373. u32 packet;
  374. dig_mode = dig_mode_start(grip->gameport, &packet);
  375. while (!dig_mode && tries < 4) {
  376. dig_mode = dig_mode_start(grip->gameport, &packet);
  377. tries++;
  378. }
  379. if (dig_mode)
  380. dbg("multiport_init(): digital mode activated.\n");
  381. else {
  382. dbg("multiport_init(): unable to activate digital mode.\n");
  383. return 0;
  384. }
  385. /* Get packets, store multiport state, and check state's validity */
  386. for (tries = 0; tries < 4096; tries++) {
  387. if (slots_valid(grip)) {
  388. initialized = 1;
  389. break;
  390. }
  391. }
  392. dbg("multiport_init(): initialized == %d\n", initialized);
  393. return initialized;
  394. }
  395. /*
  396. * Reports joystick state to the linux input layer.
  397. */
  398. static void report_slot(struct grip_mp *grip, int slot)
  399. {
  400. struct grip_port *port = grip->port[slot];
  401. int i;
  402. /* Store button states with linux input driver */
  403. for (i = 0; i < 8; i++)
  404. input_report_key(port->dev, grip_btn_gp[i], (port->buttons >> i) & 1);
  405. /* Store axis states with linux driver */
  406. input_report_abs(port->dev, ABS_X, port->xaxes);
  407. input_report_abs(port->dev, ABS_Y, port->yaxes);
  408. /* Tell the receiver of the events to process them */
  409. input_sync(port->dev);
  410. port->dirty = 0;
  411. }
  412. /*
  413. * Get the multiport state.
  414. */
  415. static void grip_poll(struct gameport *gameport)
  416. {
  417. struct grip_mp *grip = gameport_get_drvdata(gameport);
  418. int i, npkts, flags;
  419. for (npkts = 0; npkts < 4; npkts++) {
  420. flags = IO_RETRY;
  421. for (i = 0; i < 32; i++) {
  422. flags = get_and_decode_packet(grip, flags);
  423. if ((flags & IO_GOT_PACKET) || !(flags & IO_RETRY))
  424. break;
  425. }
  426. if (flags & IO_DONE)
  427. break;
  428. }
  429. for (i = 0; i < 4; i++)
  430. if (grip->port[i]->dirty)
  431. report_slot(grip, i);
  432. }
  433. /*
  434. * Called when a joystick device file is opened
  435. */
  436. static int grip_open(struct input_dev *dev)
  437. {
  438. struct grip_mp *grip = dev->private;
  439. gameport_start_polling(grip->gameport);
  440. return 0;
  441. }
  442. /*
  443. * Called when a joystick device file is closed
  444. */
  445. static void grip_close(struct input_dev *dev)
  446. {
  447. struct grip_mp *grip = dev->private;
  448. gameport_start_polling(grip->gameport);
  449. }
  450. /*
  451. * Tell the linux input layer about a newly plugged-in gamepad.
  452. */
  453. static int register_slot(int slot, struct grip_mp *grip)
  454. {
  455. struct grip_port *port = grip->port[slot];
  456. struct input_dev *input_dev;
  457. int j, t;
  458. port->dev = input_dev = input_allocate_device();
  459. if (!input_dev)
  460. return -ENOMEM;
  461. input_dev->name = grip_name[port->mode];
  462. input_dev->id.bustype = BUS_GAMEPORT;
  463. input_dev->id.vendor = GAMEPORT_ID_VENDOR_GRAVIS;
  464. input_dev->id.product = 0x0100 + port->mode;
  465. input_dev->id.version = 0x0100;
  466. input_dev->cdev.dev = &grip->gameport->dev;
  467. input_dev->private = grip;
  468. input_dev->open = grip_open;
  469. input_dev->close = grip_close;
  470. input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
  471. for (j = 0; (t = grip_abs[port->mode][j]) >= 0; j++)
  472. input_set_abs_params(input_dev, t, -1, 1, 0, 0);
  473. for (j = 0; (t = grip_btn[port->mode][j]) >= 0; j++)
  474. if (t > 0)
  475. set_bit(t, input_dev->keybit);
  476. input_register_device(port->dev);
  477. port->registered = 1;
  478. if (port->dirty) /* report initial state, if any */
  479. report_slot(grip, slot);
  480. return 0;
  481. }
  482. static int grip_connect(struct gameport *gameport, struct gameport_driver *drv)
  483. {
  484. struct grip_mp *grip;
  485. int err;
  486. if (!(grip = kzalloc(sizeof(struct grip_mp), GFP_KERNEL)))
  487. return -ENOMEM;
  488. grip->gameport = gameport;
  489. gameport_set_drvdata(gameport, grip);
  490. err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
  491. if (err)
  492. goto fail1;
  493. gameport_set_poll_handler(gameport, grip_poll);
  494. gameport_set_poll_interval(gameport, 20);
  495. if (!multiport_init(grip)) {
  496. err = -ENODEV;
  497. goto fail2;
  498. }
  499. if (!grip->port[0]->mode && !grip->port[1]->mode && !grip->port[2]->mode && !grip->port[3]->mode) {
  500. /* nothing plugged in */
  501. err = -ENODEV;
  502. goto fail2;
  503. }
  504. return 0;
  505. fail2: gameport_close(gameport);
  506. fail1: gameport_set_drvdata(gameport, NULL);
  507. kfree(grip);
  508. return err;
  509. }
  510. static void grip_disconnect(struct gameport *gameport)
  511. {
  512. struct grip_mp *grip = gameport_get_drvdata(gameport);
  513. int i;
  514. for (i = 0; i < 4; i++)
  515. if (grip->port[i]->registered)
  516. input_unregister_device(grip->port[i]->dev);
  517. gameport_close(gameport);
  518. gameport_set_drvdata(gameport, NULL);
  519. kfree(grip);
  520. }
  521. static struct gameport_driver grip_drv = {
  522. .driver = {
  523. .name = "grip_mp",
  524. },
  525. .description = DRIVER_DESC,
  526. .connect = grip_connect,
  527. .disconnect = grip_disconnect,
  528. };
  529. static int __init grip_init(void)
  530. {
  531. gameport_register_driver(&grip_drv);
  532. return 0;
  533. }
  534. static void __exit grip_exit(void)
  535. {
  536. gameport_unregister_driver(&grip_drv);
  537. }
  538. module_init(grip_init);
  539. module_exit(grip_exit);