grip_mp.c 17 KB

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