grip_mp.c 17 KB

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