227
228
229
230static int analog_cooked_read(struct analog_port *port)
231{
232 struct gameport *gameport = port->gameport;
233 unsigned int time[4], start, loop, now, loopout, timeout;
234 unsigned char data[4], this, last;
235 unsigned long flags;
236 int i, j;
237
238 loopout = (ANALOG_LOOP_TIME * port->loop) / 1000;
239 timeout = ANALOG_MAX_TIME * port->speed;
240
241 local_irq_save(flags);
242 gameport_trigger(gameport);
243 GET_TIME(now);
244 local_irq_restore(flags);
245
246 start = now;
247 this = port->mask;
248 i = 0;
249
250 do {
251 loop = now;
252 last = this;
253
254 local_irq_disable();
255 this = gameport_read(gameport) & port->mask;
256 GET_TIME(now);
257 local_irq_restore(flags);
258
259 if ((last ^ this) && (DELTA(loop, now) < loopout)) {
260 data[i] = last ^ this;
261 time[i] = now;
262 i++;
263 }
264
265 } while (this && (i < 4) && (DELTA(start, now) < timeout));
266
267 this <<= 4;