Merge branches 'intel_pstate', 'pm-cpufreq' and 'pm-cpufreq-sched'
[sfrench/cifs-2.6.git] / Documentation / input / devices / joystick-parport.rst
1 .. include:: <isonum.txt>
2
3 .. _joystick-parport:
4
5 ==============================
6 Parallel Port Joystick Drivers
7 ==============================
8
9 :Copyright: |copy| 1998-2000 Vojtech Pavlik <vojtech@ucw.cz>
10 :Copyright: |copy| 1998 Andree Borrmann <a.borrmann@tu-bs.de>
11
12
13 Sponsored by SuSE
14
15 Disclaimer
16 ==========
17
18 Any information in this file is provided as-is, without any guarantee that
19 it will be true. So, use it at your own risk. The possible damages that can
20 happen include burning your parallel port, and/or the sticks and joystick
21 and maybe even more. Like when a lightning kills you it is not our problem.
22
23 Introduction
24 ============
25
26 The joystick parport drivers are used for joysticks and gamepads not
27 originally designed for PCs and other computers Linux runs on. Because of
28 that, PCs usually lack the right ports to connect these devices to. Parallel
29 port, because of its ability to change single bits at will, and providing
30 both output and input bits is the most suitable port on the PC for
31 connecting such devices.
32
33 Devices supported
34 =================
35
36 Many console and 8-bit computer gamepads and joysticks are supported. The
37 following subsections discuss usage of each.
38
39 NES and SNES
40 ------------
41
42 The Nintendo Entertainment System and Super Nintendo Entertainment System
43 gamepads are widely available, and easy to get. Also, they are quite easy to
44 connect to a PC, and don't need much processing speed (108 us for NES and
45 165 us for SNES, compared to about 1000 us for PC gamepads) to communicate
46 with them.
47
48 All NES and SNES use the same synchronous serial protocol, clocked from
49 the computer's side (and thus timing insensitive). To allow up to 5 NES
50 and/or SNES gamepads and/or SNES mice connected to the parallel port at once,
51 the output lines of the parallel port are shared, while one of 5 available
52 input lines is assigned to each gamepad.
53
54 This protocol is handled by the gamecon.c driver, so that's the one
55 you'll use for NES, SNES gamepads and SNES mice.
56
57 The main problem with PC parallel ports is that they don't have +5V power
58 source on any of their pins. So, if you want a reliable source of power
59 for your pads, use either keyboard or joystick port, and make a pass-through
60 cable. You can also pull the power directly from the power supply (the red
61 wire is +5V).
62
63 If you want to use the parallel port only, you can take the power is from
64 some data pin. For most gamepad and parport implementations only one pin is
65 needed, and I'd recommend pin 9 for that, the highest data bit. On the other
66 hand, if you are not planning to use anything else than NES / SNES on the
67 port, anything between and including pin 4 and pin 9 will work::
68
69     (pin 9) -----> Power
70
71 Unfortunately, there are pads that need a lot more of power, and parallel
72 ports that can't give much current through the data pins. If this is your
73 case, you'll need to use diodes (as a prevention of destroying your parallel
74 port), and combine the currents of two or more data bits together::
75
76               Diodes
77     (pin 9) ----|>|-------+------> Power
78                         |
79     (pin 8) ----|>|-------+
80                         |
81     (pin 7) ----|>|-------+
82                         |
83     <and so on>         :
84                         |
85     (pin 4) ----|>|-------+
86
87 Ground is quite easy. On PC's parallel port the ground is on any of the
88 pins from pin 18 to pin 25. So use any pin of these you like for the ground::
89
90     (pin 18) -----> Ground
91
92 NES and SNES pads have two input bits, Clock and Latch, which drive the
93 serial transfer. These are connected to pins 2 and 3 of the parallel port,
94 respectively::
95
96     (pin 2) -----> Clock
97     (pin 3) -----> Latch
98
99 And the last thing is the NES / SNES data wire. Only that isn't shared and
100 each pad needs its own data pin. The parallel port pins are::
101
102     (pin 10) -----> Pad 1 data
103     (pin 11) -----> Pad 2 data
104     (pin 12) -----> Pad 3 data
105     (pin 13) -----> Pad 4 data
106     (pin 15) -----> Pad 5 data
107
108 Note that pin 14 is not used, since it is not an input pin on the parallel
109 port.
110
111 This is everything you need on the PC's side of the connection, now on to
112 the gamepads side. The NES and SNES have different connectors. Also, there
113 are quite a lot of NES clones, and because Nintendo used proprietary
114 connectors for their machines, the cloners couldn't and used standard D-Cannon
115 connectors. Anyway, if you've got a gamepad, and it has buttons A, B, Turbo
116 A, Turbo B, Select and Start, and is connected through 5 wires, then it is
117 either a NES or NES clone and will work with this connection. SNES gamepads
118 also use 5 wires, but have more buttons. They will work as well, of course::
119
120   Pinout for NES gamepads                 Pinout for SNES gamepads and mice
121
122              +----> Power                   +-----------------------\
123              |                            7 | o  o  o  o |  x  x  o  | 1
124    5 +---------+  7                         +-----------------------/
125      | x  x  o   \                            |  |  |  |          |
126      | o  o  o  o |                           |  |  |  |          +-> Ground
127    4 +------------+ 1                         |  |  |  +------------> Data
128        |  |  |  |                             |  |  +---------------> Latch
129        |  |  |  +-> Ground                    |  +------------------> Clock
130        |  |  +----> Clock                     +---------------------> Power
131        |  +-------> Latch
132        +----------> Data
133
134   Pinout for NES clone (db9) gamepads     Pinout for NES clone (db15) gamepads
135
136         +---------> Clock                    +-----------------> Data
137         | +-------> Latch                    |             +---> Ground
138         | | +-----> Data                     |             |
139         | | |                              ___________________
140     _____________                        8 \ o x x x x x x o / 1
141   5 \ x o o o x / 1                         \ o x x o x x o /
142      \ x o x o /                          15 `~~~~~~~~~~~~~' 9
143     9 `~~~~~~~' 6                             |     |     |
144          |   |                                |     |     +----> Clock
145          |   +----> Power                     |     +----------> Latch
146          +--------> Ground                    +----------------> Power
147
148 Multisystem joysticks
149 ---------------------
150
151 In the era of 8-bit machines, there was something like de-facto standard
152 for joystick ports. They were all digital, and all used D-Cannon 9 pin
153 connectors (db9). Because of that, a single joystick could be used without
154 hassle on Atari (130, 800XE, 800XL, 2600, 7200), Amiga, Commodore C64,
155 Amstrad CPC, Sinclair ZX Spectrum and many other machines. That's why these
156 joysticks are called "Multisystem".
157
158 Now their pinout::
159
160         +---------> Right
161         | +-------> Left
162         | | +-----> Down
163         | | | +---> Up
164         | | | |
165     _____________
166   5 \ x o o o o / 1
167      \ x o x o /
168     9 `~~~~~~~' 6
169          |   |
170          |   +----> Button
171          +--------> Ground
172
173 However, as time passed, extensions to this standard developed, and these
174 were not compatible with each other::
175
176
177           Atari 130, 800/XL/XE                   MSX
178
179                                            +-----------> Power
180         +---------> Right                  | +---------> Right
181         | +-------> Left                   | | +-------> Left
182         | | +-----> Down                   | | | +-----> Down
183         | | | +---> Up                     | | | | +---> Up
184         | | | |                            | | | | |
185     _____________                        _____________
186   5 \ x o o o o / 1                    5 \ o o o o o / 1
187      \ x o o o /                          \ o o o o /
188     9 `~~~~~~~' 6                        9 `~~~~~~~' 6
189          | | |                              | | | |
190          | | +----> Button                  | | | +----> Button 1
191          | +------> Power                   | | +------> Button 2
192          +--------> Ground                  | +--------> Output 3
193                                             +----------> Ground
194
195           Amstrad CPC                           Commodore C64
196
197                                            +-----------> Analog Y
198         +---------> Right                  | +---------> Right
199         | +-------> Left                   | | +-------> Left
200         | | +-----> Down                   | | | +-----> Down
201         | | | +---> Up                     | | | | +---> Up
202         | | | |                            | | | | |
203     _____________                        _____________
204   5 \ x o o o o / 1                    5 \ o o o o o / 1
205      \ x o o o /                          \ o o o o /
206     9 `~~~~~~~' 6                        9 `~~~~~~~' 6
207          | | |                              | | | |
208          | | +----> Button 1                | | | +----> Button
209          | +------> Button 2                | | +------> Power
210          +--------> Ground                  | +--------> Ground
211                                             +----------> Analog X
212
213           Sinclair Spectrum +2A/+3           Amiga 1200
214
215       +-----------> Up                     +-----------> Button 3
216       | +---------> Fire                   | +---------> Right
217       | |                                  | | +-------> Left
218       | |   +-----> Ground                 | | | +-----> Down
219       | |   |                              | | | | +---> Up
220       | |   |                              | | | | |
221     _____________                        _____________
222   5 \ o o x o x / 1                    5 \ o o o o o / 1
223      \ o o o o /                          \ o o o o /
224     9 `~~~~~~~' 6                        9 `~~~~~~~' 6
225        | | | |                              | | | |
226        | | | +----> Right                   | | | +----> Button 1
227        | | +------> Left                    | | +------> Power
228        | +--------> Ground                  | +--------> Ground
229        +----------> Down                    +----------> Button 2
230
231   And there were many others.
232
233 Multisystem joysticks using db9.c
234 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
235
236 For the Multisystem joysticks, and their derivatives, the db9.c driver
237 was written. It allows only one joystick / gamepad per parallel port, but
238 the interface is easy to build and works with almost anything.
239
240 For the basic 1-button Multisystem joystick you connect its wires to the
241 parallel port like this::
242
243     (pin  1) -----> Power
244     (pin 18) -----> Ground
245
246     (pin  2) -----> Up
247     (pin  3) -----> Down
248     (pin  4) -----> Left
249     (pin  5) -----> Right
250     (pin  6) -----> Button 1
251
252 However, if the joystick is switch based (eg. clicks when you move it),
253 you might or might not, depending on your parallel port, need 10 kOhm pullup
254 resistors on each of the direction and button signals, like this::
255
256     (pin 2) ------------+------> Up
257               Resistor  |
258     (pin 1) --[10kOhm]--+
259
260 Try without, and if it doesn't work, add them. For TTL based joysticks /
261 gamepads the pullups are not needed.
262
263 For joysticks with two buttons you connect the second button to pin 7 on
264 the parallel port::
265
266     (pin 7) -----> Button 2
267
268 And that's it.
269
270 On a side note, if you have already built a different adapter for use with
271 the digital joystick driver 0.8.0.2, this is also supported by the db9.c
272 driver, as device type 8. (See section 3.2)
273
274 Multisystem joysticks using gamecon.c
275 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
276
277 For some people just one joystick per parallel port is not enough, and/or
278 want to use them on one parallel port together with NES/SNES/PSX pads. This is
279 possible using the gamecon.c. It supports up to 5 devices of the above types,
280 including 1 and 2 buttons Multisystem joysticks.
281
282 However, there is nothing for free. To allow more sticks to be used at
283 once, you need the sticks to be purely switch based (that is non-TTL), and
284 not to need power. Just a plain simple six switches inside. If your
285 joystick can do more (eg. turbofire) you'll need to disable it totally first
286 if you want to use gamecon.c.
287
288 Also, the connection is a bit more complex. You'll need a bunch of diodes,
289 and one pullup resistor. First, you connect the Directions and the button
290 the same as for db9, however with the diodes between::
291
292                 Diodes
293     (pin 2) -----|<|----> Up
294     (pin 3) -----|<|----> Down
295     (pin 4) -----|<|----> Left
296     (pin 5) -----|<|----> Right
297     (pin 6) -----|<|----> Button 1
298
299 For two button sticks you also connect the other button::
300
301     (pin 7) -----|<|----> Button 2
302
303 And finally, you connect the Ground wire of the joystick, like done in
304 this little schematic to Power and Data on the parallel port, as described
305 for the NES / SNES pads in section 2.1 of this file - that is, one data pin
306 for each joystick. The power source is shared::
307
308     Data    ------------+-----> Ground
309               Resistor  |
310     Power   --[10kOhm]--+
311
312 And that's all, here we go!
313
314 Multisystem joysticks using turbografx.c
315 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
316
317 The TurboGraFX interface, designed by
318
319         Steffen Schwenke <schwenke@burg-halle.de>
320
321 allows up to 7 Multisystem joysticks connected to the parallel port. In
322 Steffen's version, there is support for up to 5 buttons per joystick.  However,
323 since this doesn't work reliably on all parallel ports, the turbografx.c driver
324 supports only one button per joystick. For more information on how to build the
325 interface, see:
326
327         http://www2.burg-halle.de/~schwenke/parport.html
328
329 Sony Playstation
330 ----------------
331
332 The PSX controller is supported by the gamecon.c. Pinout of the PSX
333 controller (compatible with DirectPadPro)::
334
335     +---------+---------+---------+
336   9 | o  o  o | o  o  o | o  o  o | 1               parallel
337      \________|_________|________/                  port pins
338       |  |      |  |  |   |
339       |  |      |  |  |   +-------->  Clock    ---  (4)
340       |  |      |  |  +------------>  Select   ---  (3)
341       |  |      |  +--------------->  Power    ---  (5-9)
342       |  |      +------------------>  Ground   ---  (18-25)
343       |  +------------------------->  Command  ---  (2)
344       +---------------------------->  Data     ---  (one of 10,11,12,13,15)
345
346 The driver supports these controllers:
347
348  * Standard PSX Pad
349  * NegCon PSX Pad
350  * Analog PSX Pad (red mode)
351  * Analog PSX Pad (green mode)
352  * PSX Rumble Pad
353  * PSX DDR Pad
354
355 Sega
356 ----
357
358 All the Sega controllers are more or less based on the standard 2-button
359 Multisystem joystick. However, since they don't use switches and use TTL
360 logic, the only driver usable with them is the db9.c driver.
361
362 Sega Master System
363 ~~~~~~~~~~~~~~~~~~
364
365 The SMS gamepads are almost exactly the same as normal 2-button
366 Multisystem joysticks. Set the driver to Multi2 mode, use the corresponding
367 parallel port pins, and the following schematic::
368
369       +-----------> Power
370       | +---------> Right
371       | | +-------> Left
372       | | | +-----> Down
373       | | | | +---> Up
374       | | | | |
375     _____________
376   5 \ o o o o o / 1
377      \ o o x o /
378     9 `~~~~~~~' 6
379        | |   |
380        | |   +----> Button 1
381        | +--------> Ground
382        +----------> Button 2
383
384 Sega Genesis aka MegaDrive
385 ~~~~~~~~~~~~~~~~~~~~~~~~~~
386
387 The Sega Genesis (in Europe sold as Sega MegaDrive) pads are an extension
388 to the Sega Master System pads. They use more buttons (3+1, 5+1, 6+1).  Use
389 the following schematic::
390
391         +-----------> Power
392         | +---------> Right
393         | | +-------> Left
394         | | | +-----> Down
395         | | | | +---> Up
396         | | | | |
397       _____________
398     5 \ o o o o o / 1
399        \ o o o o /
400       9 `~~~~~~~' 6
401         | | | |
402         | | | +----> Button 1
403         | | +------> Select
404         | +--------> Ground
405         +----------> Button 2
406
407 The Select pin goes to pin 14 on the parallel port::
408
409     (pin 14) -----> Select
410
411 The rest is the same as for Multi2 joysticks using db9.c
412
413 Sega Saturn
414 ~~~~~~~~~~~
415
416 Sega Saturn has eight buttons, and to transfer that, without hacks like
417 Genesis 6 pads use, it needs one more select pin. Anyway, it is still
418 handled by the db9.c driver. Its pinout is very different from anything
419 else.  Use this schematic::
420
421       +-----------> Select 1
422       | +---------> Power
423       | | +-------> Up
424       | | | +-----> Down
425       | | | | +---> Ground
426       | | | | |
427     _____________
428   5 \ o o o o o / 1
429      \ o o o o /
430     9 `~~~~~~~' 6
431        | | | |
432        | | | +----> Select 2
433        | | +------> Right
434        | +--------> Left
435        +----------> Power
436
437 Select 1 is pin 14 on the parallel port, Select 2 is pin 16 on the
438 parallel port::
439
440     (pin 14) -----> Select 1
441     (pin 16) -----> Select 2
442
443 The other pins (Up, Down, Right, Left, Power, Ground) are the same as for
444 Multi joysticks using db9.c
445
446 Amiga CD32
447 ----------
448
449 Amiga CD32 joypad uses the following pinout::
450
451         +-----------> Button 3
452         | +---------> Right
453         | | +-------> Left
454         | | | +-----> Down
455         | | | | +---> Up
456         | | | | |
457       _____________
458     5 \ o o o o o / 1
459        \ o o o o /
460       9 `~~~~~~~' 6
461         | | | |
462         | | | +----> Button 1
463         | | +------> Power
464         | +--------> Ground
465         +----------> Button 2
466
467 It can be connected to the parallel port and driven by db9.c driver. It needs the following wiring:
468
469         ============    =============
470         CD32 pad        Parallel port
471         ============    =============
472         1 (Up)           2 (D0)
473         2 (Down)         3 (D1)
474         3 (Left)         4 (D2)
475         4 (Right)        5 (D3)
476         5 (Button 3)    14 (AUTOFD)
477         6 (Button 1)    17 (SELIN)
478         7 (+5V)          1 (STROBE)
479         8 (Gnd)         18 (Gnd)
480         9 (Button 2)     7 (D5)
481         ============    =============
482
483 The drivers
484 ===========
485
486 There are three drivers for the parallel port interfaces. Each, as
487 described above, allows to connect a different group of joysticks and pads.
488 Here are described their command lines:
489
490 gamecon.c
491 ---------
492
493 Using gamecon.c you can connect up to five devices to one parallel port. It
494 uses the following kernel/module command line::
495
496         gamecon.map=port,pad1,pad2,pad3,pad4,pad5
497
498 Where ``port`` the number of the parport interface (eg. 0 for parport0).
499
500 And ``pad1`` to ``pad5`` are pad types connected to different data input pins
501 (10,11,12,13,15), as described in section 2.1 of this file.
502
503 The types are:
504
505         ===== =============================
506         Type  Joystick/Pad
507         ===== =============================
508           0   None
509           1   SNES pad
510           2   NES pad
511           4   Multisystem 1-button joystick
512           5   Multisystem 2-button joystick
513           6   N64 pad
514           7   Sony PSX controller
515           8   Sony PSX DDR controller
516           9   SNES mouse
517         ===== =============================
518
519 The exact type of the PSX controller type is autoprobed when used, so
520 hot swapping should work (but is not recommended).
521
522 Should you want to use more than one of parallel ports at once, you can use
523 gamecon.map2 and gamecon.map3 as additional command line parameters for two
524 more parallel ports.
525
526 There are two options specific to PSX driver portion.  gamecon.psx_delay sets
527 the command delay when talking to the controllers. The default of 25 should
528 work but you can try lowering it for better performance. If your pads don't
529 respond try raising it until they work. Setting the type to 8 allows the
530 driver to be used with Dance Dance Revolution or similar games. Arrow keys are
531 registered as key presses instead of X and Y axes.
532
533 db9.c
534 -----
535
536 Apart from making an interface, there is nothing difficult on using the
537 db9.c driver. It uses the following kernel/module command line::
538
539         db9.dev=port,type
540
541 Where ``port`` is the number of the parport interface (eg. 0 for parport0).
542
543 Caveat here: This driver only works on bidirectional parallel ports. If
544 your parallel port is recent enough, you should have no trouble with this.
545 Old parallel ports may not have this feature.
546
547 ``Type`` is the type of joystick or pad attached:
548
549         ===== ======================================================
550         Type  Joystick/Pad
551         ===== ======================================================
552           0   None
553           1   Multisystem 1-button joystick
554           2   Multisystem 2-button joystick
555           3   Genesis pad (3+1 buttons)
556           5   Genesis pad (5+1 buttons)
557           6   Genesis pad (6+2 buttons)
558           7   Saturn pad (8 buttons)
559           8   Multisystem 1-button joystick (v0.8.0.2 pin-out)
560           9   Two Multisystem 1-button joysticks (v0.8.0.2 pin-out)
561          10   Amiga CD32 pad
562         ===== ======================================================
563
564 Should you want to use more than one of these joysticks/pads at once, you
565 can use db9.dev2 and db9.dev3 as additional command line parameters for two
566 more joysticks/pads.
567
568 turbografx.c
569 ------------
570
571 The turbografx.c driver uses a very simple kernel/module command line::
572
573         turbografx.map=port,js1,js2,js3,js4,js5,js6,js7
574
575 Where ``port`` is the number of the parport interface (eg. 0 for parport0).
576
577 ``jsX`` is the number of buttons the Multisystem joysticks connected to the
578 interface ports 1-7 have. For a standard multisystem joystick, this is 1.
579
580 Should you want to use more than one of these interfaces at once, you can
581 use turbografx.map2 and turbografx.map3 as additional command line parameters
582 for two more interfaces.
583
584 PC parallel port pinout
585 =======================
586
587 ::
588
589                   .----------------------------------------.
590    At the PC:     \ 13 12 11 10  9  8  7  6  5  4  3  2  1 /
591                    \  25 24 23 22 21 20 19 18 17 16 15 14 /
592                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
593
594 ======  =======  =============
595    Pin  Name     Description
596 ======  =======  =============
597      1  /STROBE  Strobe
598    2-9  D0-D7    Data Bit 0-7
599     10  /ACK     Acknowledge
600     11  BUSY     Busy
601     12  PE       Paper End
602     13  SELIN    Select In
603     14  /AUTOFD  Autofeed
604     15  /ERROR   Error
605     16  /INIT    Initialize
606     17  /SEL     Select
607  18-25  GND      Signal Ground
608 ======  =======  =============
609
610
611 That's all, folks! Have fun!