Lines Matching refs:port

250 static int analog_cooked_read(struct analog_port *port)
252 struct gameport *gameport = port->gameport;
259 loopout = (ANALOG_LOOP_TIME * port->loop) / 1000;
260 timeout = ANALOG_MAX_TIME * port->speed;
268 this = port->mask;
276 this = gameport_read(gameport) & port->mask;
294 port->axes[j] = (delta(start, time[i]) << ANALOG_FUZZ_BITS) / port->loop;
297 return -(this != port->mask);
300 static int analog_button_read(struct analog_port *port, char saitek, char chf)
304 int strobe = gameport_time(port->gameport, ANALOG_SAITEK_TIME);
306 u = gameport_read(port->gameport);
309 port->buttons = (~u >> 4) & 0xf;
313 port->buttons = 0;
316 port->buttons |= 1 << analog_chf[(~u >> 4) & 0xf];
320 gameport_trigger(port->gameport);
321 while (((u = gameport_read(port->gameport)) & port->mask) && t) t--;
334 struct analog_port *port = gameport_get_drvdata(gameport);
337 char saitek = !!(port->analog[0].mask & ANALOG_SAITEK);
338 char chf = !!(port->analog[0].mask & ANALOG_ANY_CHF);
340 if (port->cooked) {
341 port->bads -= gameport_cooked_read(port->gameport, port->axes, &port->buttons);
343 port->buttons = port->buttons ? (1 << analog_chf[port->buttons]) : 0;
344 port->reads++;
346 if (!port->axtime--) {
347 port->bads -= analog_cooked_read(port);
348 port->bads -= analog_button_read(port, saitek, chf);
349 port->reads++;
350 port->axtime = ANALOG_AXIS_TIME - 1;
353 analog_button_read(port, saitek, chf);
358 if (port->analog[i].mask)
359 analog_decode(port->analog + i, port->axes, port->initial, port->buttons);
368 struct analog_port *port = input_get_drvdata(dev);
370 gameport_start_polling(port->gameport);
380 struct analog_port *port = input_get_drvdata(dev);
382 gameport_stop_polling(port->gameport);
387 * and timeout values for a joystick port.
390 static void analog_calibrate_timer(struct analog_port *port)
392 struct gameport *gameport = port->gameport;
398 port->speed = 1000000;
410 port->speed = delta(t1, t2) - delta(t2, t3);
429 port->loop = tx / 50;
461 static int analog_init_device(struct analog_port *port, struct analog *analog, int index)
469 "%s/input%d", port->gameport->phys, index);
482 input_dev->dev.parent = &port->gameport->dev;
484 input_set_drvdata(input_dev, port);
495 x = port->axes[i];
496 y = (port->axes[0] + port->axes[1]) >> 1;
497 z = y - port->axes[i];
506 if (i == 2) x = port->axes[i];
511 input_set_abs_params(input_dev, t, v, (x << 1) - v, port->fuzz, w);
538 analog_decode(analog, port->axes, port->initial, port->buttons);
553 static int analog_init_masks(struct analog_port *port)
556 struct analog *analog = port->analog;
559 if (!port->mask)
562 if ((port->mask & 3) != 3 && port->mask != 0xc) {
565 port->mask, port->gameport->phys);
575 | port->mask | ((port->mask << 8) & ANALOG_HAT_FCS)
576 | ((port->mask << 10) & ANALOG_BTNS_TLR) | ((port->mask << 12) & ANALOG_BTNS_TLR2);
593 : (((ANALOG_BTNS_STD | port->mask) & ~analog[0].mask) | ANALOG_GAMEPAD);
595 if (port->cooked) {
597 for (i = 0; i < 4; i++) max[i] = port->axes[i] << 1;
605 gameport_calibrate(port->gameport, port->axes, max);
609 port->initial[i] = port->axes[i];
614 static int analog_init_port(struct gameport *gameport, struct gameport_driver *drv, struct analog_port *port)
618 port->gameport = gameport;
620 gameport_set_drvdata(gameport, port);
624 analog_calibrate_timer(port);
629 port->mask = (gameport_read(gameport) ^ t) & t & 0xf;
630 port->fuzz = (port->speed * ANALOG_FUZZ_MAGIC) / port->loop / 1000 + ANALOG_FUZZ_BITS;
633 if (!analog_cooked_read(port))
643 while ((gameport_read(port->gameport) & port->mask) && (u < t))
648 while ((gameport_read(port->gameport) & port->mask) && (v < t))
651 if (v < (u >> 1)) { /* FIXME - more than one port */
652 analog_options[0] |= /* FIXME - more than one port */
663 if (!gameport_cooked_read(gameport, port->axes, &port->buttons))
666 if (port->axes[i] != -1)
667 port->mask |= 1 << i;
669 port->fuzz = gameport->fuzz;
670 port->cooked = 1;
679 struct analog_port *port;
683 if (!(port = kzalloc(sizeof(struct analog_port), GFP_KERNEL)))
686 err = analog_init_port(gameport, drv, port);
690 err = analog_init_masks(port);
698 if (port->analog[i].mask) {
699 err = analog_init_device(port, port->analog + i, i);
707 if (port->analog[i].mask)
708 input_unregister_device(port->analog[i].dev);
711 kfree(port);
717 struct analog_port *port = gameport_get_drvdata(gameport);
721 if (port->analog[i].mask)
722 input_unregister_device(port->analog[i].dev);
726 port->bads, port->reads, port->reads ? (port->bads * 100 / port->reads) : 0,
727 port->gameport->phys);
728 kfree(port);
770 printk(KERN_WARNING "analog.c: Bad config for port %d - \"%s\"\n", i, js[i]);