ia64/linux-2.6.18-xen.hg

view Documentation/input/gameport-programming.txt @ 452:c7ed6fe5dca0

kexec: dont initialise regions in reserve_memory()

There is no need to initialise efi_memmap_res and boot_param_res in
reserve_memory() for the initial xen domain as it is done in
machine_kexec_setup_resources() using values from the kexec hypercall.

Signed-off-by: Simon Horman <horms@verge.net.au>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Feb 28 10:55:18 2008 +0000 (2008-02-28)
parents 831230e53067
children
line source
1 $Id: gameport-programming.txt,v 1.3 2001/04/24 13:51:37 vojtech Exp $
3 Programming gameport drivers
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6 1. A basic classic gameport
7 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 If the gameport doesn't provide more than the inb()/outb() functionality,
10 the code needed to register it with the joystick drivers is simple:
12 struct gameport gameport;
14 gameport.io = MY_IO_ADDRESS;
15 gameport_register_port(&gameport);
17 Make sure struct gameport is initialized to 0 in all other fields. The
18 gameport generic code will take care of the rest.
20 If your hardware supports more than one io address, and your driver can
21 choose which one program the hardware to, starting from the more exotic
22 addresses is preferred, because the likelyhood of clashing with the standard
23 0x201 address is smaller.
25 Eg. if your driver supports addresses 0x200, 0x208, 0x210 and 0x218, then
26 0x218 would be the address of first choice.
28 If your hardware supports a gameport address that is not mapped to ISA io
29 space (is above 0x1000), use that one, and don't map the ISA mirror.
31 Also, always request_region() on the whole io space occupied by the
32 gameport. Although only one ioport is really used, the gameport usually
33 occupies from one to sixteen addresses in the io space.
35 Please also consider enabling the gameport on the card in the ->open()
36 callback if the io is mapped to ISA space - this way it'll occupy the io
37 space only when something really is using it. Disable it again in the
38 ->close() callback. You also can select the io address in the ->open()
39 callback, so that it doesn't fail if some of the possible addresses are
40 already occupied by other gameports.
42 2. Memory mapped gameport
43 ~~~~~~~~~~~~~~~~~~~~~~~~~
45 When a gameport can be accessed through MMIO, this way is preferred, because
46 it is faster, allowing more reads per second. Registering such a gameport
47 isn't as easy as a basic IO one, but not so much complex:
49 struct gameport gameport;
51 void my_trigger(struct gameport *gameport)
52 {
53 my_mmio = 0xff;
54 }
56 unsigned char my_read(struct gameport *gameport)
57 {
58 return my_mmio;
59 }
61 gameport.read = my_read;
62 gameport.trigger = my_trigger;
63 gameport_register_port(&gameport);
65 3. Cooked mode gameport
66 ~~~~~~~~~~~~~~~~~~~~~~~
68 There are gameports that can report the axis values as numbers, that means
69 the driver doesn't have to measure them the old way - an ADC is built into
70 the gameport. To register a cooked gameport:
72 struct gameport gameport;
74 int my_cooked_read(struct gameport *gameport, int *axes, int *buttons)
75 {
76 int i;
78 for (i = 0; i < 4; i++)
79 axes[i] = my_mmio[i];
80 buttons[i] = my_mmio[4];
81 }
83 int my_open(struct gameport *gameport, int mode)
84 {
85 return -(mode != GAMEPORT_MODE_COOKED);
86 }
88 gameport.cooked_read = my_cooked_read;
89 gameport.open = my_open;
90 gameport.fuzz = 8;
91 gameport_register_port(&gameport);
93 The only confusing thing here is the fuzz value. Best determined by
94 experimentation, it is the amount of noise in the ADC data. Perfect
95 gameports can set this to zero, most common have fuzz between 8 and 32.
96 See analog.c and input.c for handling of fuzz - the fuzz value determines
97 the size of a gaussian filter window that is used to eliminate the noise
98 in the data.
100 4. More complex gameports
101 ~~~~~~~~~~~~~~~~~~~~~~~~~
103 Gameports can support both raw and cooked modes. In that case combine either
104 examples 1+2 or 1+3. Gameports can support internal calibration - see below,
105 and also lightning.c and analog.c on how that works. If your driver supports
106 more than one gameport instance simultaneously, use the ->private member of
107 the gameport struct to point to your data.
109 5. Unregistering a gameport
110 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
112 Simple:
114 gameport_unregister_port(&gameport);
116 6. The gameport structure
117 ~~~~~~~~~~~~~~~~~~~~~~~~~
119 struct gameport {
121 void *private;
123 A private pointer for free use in the gameport driver. (Not the joystick
124 driver!)
126 int number;
128 Number assigned to the gameport when registered. Informational purpose only.
130 int io;
132 I/O address for use with raw mode. You have to either set this, or ->read()
133 to some value if your gameport supports raw mode.
135 int speed;
137 Raw mode speed of the gameport reads in thousands of reads per second.
139 int fuzz;
141 If the gameport supports cooked mode, this should be set to a value that
142 represents the amount of noise in the data. See section 3.
144 void (*trigger)(struct gameport *);
146 Trigger. This function should trigger the ns558 oneshots. If set to NULL,
147 outb(0xff, io) will be used.
149 unsigned char (*read)(struct gameport *);
151 Read the buttons and ns558 oneshot bits. If set to NULL, inb(io) will be
152 used instead.
154 int (*cooked_read)(struct gameport *, int *axes, int *buttons);
156 If the gameport supports cooked mode, it should point this to its cooked
157 read function. It should fill axes[0..3] with four values of the joystick axes
158 and buttons[0] with four bits representing the buttons.
160 int (*calibrate)(struct gameport *, int *axes, int *max);
162 Function for calibrating the ADC hardware. When called, axes[0..3] should be
163 pre-filled by cooked data by the caller, max[0..3] should be pre-filled with
164 expected maximums for each axis. The calibrate() function should set the
165 sensitivity of the ADC hardware so that the maximums fit in its range and
166 recompute the axes[] values to match the new sensitivity or re-read them from
167 the hardware so that they give valid values.
169 int (*open)(struct gameport *, int mode);
171 Open() serves two purposes. First a driver either opens the port in raw or
172 in cooked mode, the open() callback can decide which modes are supported.
173 Second, resource allocation can happen here. The port can also be enabled
174 here. Prior to this call, other fields of the gameport struct (namely the io
175 member) need not to be valid.
177 void (*close)(struct gameport *);
179 Close() should free the resources allocated by open, possibly disabling the
180 gameport.
182 struct gameport_dev *dev;
183 struct gameport *next;
185 For internal use by the gameport layer.
187 };
189 Enjoy!