• Home
  • Raw
  • Download

Lines Matching +full:x +full:- +full:mask

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 1996-2001 Vojtech Pavlik
99 int mask; member
108 unsigned char mask; member
130 #define GET_TIME(x) do { if (boot_cpu_has(X86_FEATURE_TSC)) x = (unsigned int)rdtsc(); else x = get… argument
131 #define DELTA(x,y) (boot_cpu_has(X86_FEATURE_TSC) ? ((y) - (x)) : ((x) - (y) + ((x) < (y) ? PIT_TIC… argument
147 #define GET_TIME(x) do { x = (unsigned int)rdtsc(); } while (0) argument
148 #define DELTA(x,y) ((y)-(x)) argument
151 #define GET_TIME(x) do { x = get_cycles(); } while (0) argument
152 #define DELTA(x,y) ((y)-(x)) argument
157 #define GET_TIME(x) do { x = analog_faketime++; } while(0) argument
158 #define DELTA(x,y) ((y)-(x)) argument
168 unsigned int x; in get_time() local
169 GET_TIME(x); in get_time()
170 return x; in get_time()
174 static inline unsigned int delta(u64 x, u64 y) in delta() argument
177 return y - x; in delta()
179 return DELTA((unsigned int)x, (unsigned int)y); in delta()
188 struct input_dev *dev = analog->dev; in analog_decode()
191 if (analog->mask & ANALOG_HAT_FCS) in analog_decode()
199 if (analog->mask & (0x10 << i)) in analog_decode()
200 input_report_key(dev, analog->buttons[j++], (buttons >> i) & 1); in analog_decode()
202 if (analog->mask & ANALOG_HBTN_CHF) in analog_decode()
204 input_report_key(dev, analog->buttons[j++], (buttons >> (i + 10)) & 1); in analog_decode()
206 if (analog->mask & ANALOG_BTN_TL) in analog_decode()
208 if (analog->mask & ANALOG_BTN_TR) in analog_decode()
210 if (analog->mask & ANALOG_BTN_TL2) in analog_decode()
212 if (analog->mask & ANALOG_BTN_TR2) in analog_decode()
216 if (analog->mask & (1 << i)) in analog_decode()
220 if (analog->mask & analog_exts[i]) { in analog_decode()
222 ((buttons >> ((i << 2) + 7)) & 1) - ((buttons >> ((i << 2) + 9)) & 1)); in analog_decode()
224 ((buttons >> ((i << 2) + 8)) & 1) - ((buttons >> ((i << 2) + 6)) & 1)); in analog_decode()
236 struct gameport *gameport = port->gameport; in analog_cooked_read()
243 loopout = (ANALOG_LOOP_TIME * port->loop) / 1000; in analog_cooked_read()
244 timeout = ANALOG_MAX_TIME * port->speed; in analog_cooked_read()
252 this = port->mask; in analog_cooked_read()
260 this = gameport_read(gameport) & port->mask; in analog_cooked_read()
274 for (--i; i >= 0; i--) { in analog_cooked_read()
278 port->axes[j] = (delta(start, time[i]) << ANALOG_FUZZ_BITS) / port->loop; in analog_cooked_read()
281 return -(this != port->mask); in analog_cooked_read()
288 int strobe = gameport_time(port->gameport, ANALOG_SAITEK_TIME); in analog_button_read()
290 u = gameport_read(port->gameport); in analog_button_read()
293 port->buttons = (~u >> 4) & 0xf; in analog_button_read()
297 port->buttons = 0; in analog_button_read()
300 port->buttons |= 1 << analog_chf[(~u >> 4) & 0xf]; in analog_button_read()
304 gameport_trigger(port->gameport); in analog_button_read()
305 while (((u = gameport_read(port->gameport)) & port->mask) && t) t--; in analog_button_read()
309 return -(!t || (i == 16)); in analog_button_read()
321 char saitek = !!(port->analog[0].mask & ANALOG_SAITEK); in analog_poll()
322 char chf = !!(port->analog[0].mask & ANALOG_ANY_CHF); in analog_poll()
324 if (port->cooked) { in analog_poll()
325 port->bads -= gameport_cooked_read(port->gameport, port->axes, &port->buttons); in analog_poll()
327 port->buttons = port->buttons ? (1 << analog_chf[port->buttons]) : 0; in analog_poll()
328 port->reads++; in analog_poll()
330 if (!port->axtime--) { in analog_poll()
331 port->bads -= analog_cooked_read(port); in analog_poll()
332 port->bads -= analog_button_read(port, saitek, chf); in analog_poll()
333 port->reads++; in analog_poll()
334 port->axtime = ANALOG_AXIS_TIME - 1; in analog_poll()
342 if (port->analog[i].mask) in analog_poll()
343 analog_decode(port->analog + i, port->axes, port->initial, port->buttons); in analog_poll()
354 gameport_start_polling(port->gameport); in analog_open()
366 gameport_stop_polling(port->gameport); in analog_close()
376 struct gameport *gameport = port->gameport; in analog_calibrate_timer()
382 port->speed = 1000000; in analog_calibrate_timer()
394 port->speed = delta(t1, t2) - delta(t2, t3); in analog_calibrate_timer()
409 t = delta(t1, t2) - delta(t2, t3); in analog_calibrate_timer()
413 port->loop = tx / 50; in analog_calibrate_timer()
422 snprintf(analog->name, sizeof(analog->name), "Analog %d-axis %d-button", in analog_name()
423 hweight8(analog->mask & ANALOG_AXES_STD), in analog_name()
424 hweight8(analog->mask & ANALOG_BTNS_STD) + !!(analog->mask & ANALOG_BTNS_CHF) * 2 + in analog_name()
425 hweight16(analog->mask & ANALOG_BTNS_GAMEPAD) + !!(analog->mask & ANALOG_HBTN_CHF) * 4); in analog_name()
427 if (analog->mask & ANALOG_HATS_ALL) in analog_name()
428 snprintf(analog->name, sizeof(analog->name), "%s %d-hat", in analog_name()
429 analog->name, hweight16(analog->mask & ANALOG_HATS_ALL)); in analog_name()
431 if (analog->mask & ANALOG_HAT_FCS) in analog_name()
432 strlcat(analog->name, " FCS", sizeof(analog->name)); in analog_name()
433 if (analog->mask & ANALOG_ANY_CHF) in analog_name()
434 strlcat(analog->name, (analog->mask & ANALOG_SAITEK) ? " Saitek" : " CHF", in analog_name()
435 sizeof(analog->name)); in analog_name()
437 strlcat(analog->name, (analog->mask & ANALOG_GAMEPAD) ? " gamepad": " joystick", in analog_name()
438 sizeof(analog->name)); in analog_name()
448 int i, j, t, v, w, x, y, z; in analog_init_device() local
452 snprintf(analog->phys, sizeof(analog->phys), in analog_init_device()
453 "%s/input%d", port->gameport->phys, index); in analog_init_device()
454 analog->buttons = (analog->mask & ANALOG_GAMEPAD) ? analog_pad_btn : analog_joy_btn; in analog_init_device()
456 analog->dev = input_dev = input_allocate_device(); in analog_init_device()
458 return -ENOMEM; in analog_init_device()
460 input_dev->name = analog->name; in analog_init_device()
461 input_dev->phys = analog->phys; in analog_init_device()
462 input_dev->id.bustype = BUS_GAMEPORT; in analog_init_device()
463 input_dev->id.vendor = GAMEPORT_ID_VENDOR_ANALOG; in analog_init_device()
464 input_dev->id.product = analog->mask >> 4; in analog_init_device()
465 input_dev->id.version = 0x0100; in analog_init_device()
466 input_dev->dev.parent = &port->gameport->dev; in analog_init_device()
470 input_dev->open = analog_open; in analog_init_device()
471 input_dev->close = analog_close; in analog_init_device()
473 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); in analog_init_device()
476 if (analog->mask & (1 << i)) { in analog_init_device()
479 x = port->axes[i]; in analog_init_device()
480 y = (port->axes[0] + port->axes[1]) >> 1; in analog_init_device()
481 z = y - port->axes[i]; in analog_init_device()
482 z = z > 0 ? z : -z; in analog_init_device()
483 v = (x >> 3); in analog_init_device()
484 w = (x >> 3); in analog_init_device()
487 x = y; in analog_init_device()
489 if (analog->mask & ANALOG_SAITEK) { in analog_init_device()
490 if (i == 2) x = port->axes[i]; in analog_init_device()
491 v = x - (x >> 2); in analog_init_device()
492 w = (x >> 4); in analog_init_device()
495 input_set_abs_params(input_dev, t, v, (x << 1) - v, port->fuzz, w); in analog_init_device()
500 if (analog->mask & analog_exts[i]) in analog_init_device()
501 for (x = 0; x < 2; x++) { in analog_init_device()
503 input_set_abs_params(input_dev, t, -1, 1, 0, 0); in analog_init_device()
507 if (analog->mask & (0x10 << i)) in analog_init_device()
508 set_bit(analog->buttons[j++], input_dev->keybit); in analog_init_device()
510 if (analog->mask & ANALOG_BTNS_CHF) in analog_init_device()
512 set_bit(analog->buttons[j++], input_dev->keybit); in analog_init_device()
514 if (analog->mask & ANALOG_HBTN_CHF) in analog_init_device()
516 set_bit(analog->buttons[j++], input_dev->keybit); in analog_init_device()
519 if (analog->mask & (ANALOG_BTN_TL << i)) in analog_init_device()
520 set_bit(analog_pads[i], input_dev->keybit); in analog_init_device()
522 analog_decode(analog, port->axes, port->initial, port->buttons); in analog_init_device()
524 error = input_register_device(analog->dev); in analog_init_device()
526 input_free_device(analog->dev); in analog_init_device()
534 * analog_init_devices() sets up device-specific values and registers the input devices.
540 struct analog *analog = port->analog; in analog_init_masks()
543 if (!port->mask) in analog_init_masks()
544 return -1; in analog_init_masks()
546 if ((port->mask & 3) != 3 && port->mask != 0xc) { in analog_init_masks()
548 "(data=%#x, %s), probably not analog joystick.\n", in analog_init_masks()
549 port->mask, port->gameport->phys); in analog_init_masks()
550 return -1; in analog_init_masks()
554 i = analog_options[0]; /* FIXME !!! - need to specify options for different ports */ in analog_init_masks()
556 analog[0].mask = i & 0xfffff; in analog_init_masks()
558 analog[0].mask &= ~(ANALOG_AXES_STD | ANALOG_HAT_FCS | ANALOG_BTNS_GAMEPAD) in analog_init_masks()
559 | port->mask | ((port->mask << 8) & ANALOG_HAT_FCS) in analog_init_masks()
560 | ((port->mask << 10) & ANALOG_BTNS_TLR) | ((port->mask << 12) & ANALOG_BTNS_TLR2); in analog_init_masks()
562 analog[0].mask &= ~(ANALOG_HAT2_CHF) in analog_init_masks()
563 | ((analog[0].mask & ANALOG_HBTN_CHF) ? 0 : ANALOG_HAT2_CHF); in analog_init_masks()
565 analog[0].mask &= ~(ANALOG_THROTTLE | ANALOG_BTN_TR | ANALOG_BTN_TR2) in analog_init_masks()
566 | ((~analog[0].mask & ANALOG_HAT_FCS) >> 8) in analog_init_masks()
567 | ((~analog[0].mask & ANALOG_HAT_FCS) << 2) in analog_init_masks()
568 | ((~analog[0].mask & ANALOG_HAT_FCS) << 4); in analog_init_masks()
570 analog[0].mask &= ~(ANALOG_THROTTLE | ANALOG_RUDDER) in analog_init_masks()
571 | (((~analog[0].mask & ANALOG_BTNS_TLR ) >> 10) in analog_init_masks()
572 & ((~analog[0].mask & ANALOG_BTNS_TLR2) >> 12)); in analog_init_masks()
574 analog[1].mask = ((i >> 20) & 0xff) | ((i >> 12) & 0xf0000); in analog_init_masks()
576 analog[1].mask &= (analog[0].mask & ANALOG_EXTENSIONS) ? ANALOG_GAMEPAD in analog_init_masks()
577 : (((ANALOG_BTNS_STD | port->mask) & ~analog[0].mask) | ANALOG_GAMEPAD); in analog_init_masks()
579 if (port->cooked) { in analog_init_masks()
581 for (i = 0; i < 4; i++) max[i] = port->axes[i] << 1; in analog_init_masks()
583 if ((analog[0].mask & 0x7) == 0x7) max[2] = (max[0] + max[1]) >> 1; in analog_init_masks()
584 if ((analog[0].mask & 0xb) == 0xb) max[3] = (max[0] + max[1]) >> 1; in analog_init_masks()
585 if ((analog[0].mask & ANALOG_BTN_TL) && !(analog[0].mask & ANALOG_BTN_TL2)) max[2] >>= 1; in analog_init_masks()
586 if ((analog[0].mask & ANALOG_BTN_TR) && !(analog[0].mask & ANALOG_BTN_TR2)) max[3] >>= 1; in analog_init_masks()
587 if ((analog[0].mask & ANALOG_HAT_FCS)) max[3] >>= 1; in analog_init_masks()
589 gameport_calibrate(port->gameport, port->axes, max); in analog_init_masks()
593 port->initial[i] = port->axes[i]; in analog_init_masks()
595 return -!(analog[0].mask || analog[1].mask); in analog_init_masks()
602 port->gameport = gameport; in analog_init_port()
613 port->mask = (gameport_read(gameport) ^ t) & t & 0xf; in analog_init_port()
614 port->fuzz = (port->speed * ANALOG_FUZZ_MAGIC) / port->loop / 1000 + ANALOG_FUZZ_BITS; in analog_init_port()
627 while ((gameport_read(port->gameport) & port->mask) && (u < t)) in analog_init_port()
632 while ((gameport_read(port->gameport) & port->mask) && (v < t)) in analog_init_port()
635 if (v < (u >> 1)) { /* FIXME - more than one port */ in analog_init_port()
636 analog_options[0] |= /* FIXME - more than one port */ in analog_init_port()
647 if (!gameport_cooked_read(gameport, port->axes, &port->buttons)) in analog_init_port()
650 if (port->axes[i] != -1) in analog_init_port()
651 port->mask |= 1 << i; in analog_init_port()
653 port->fuzz = gameport->fuzz; in analog_init_port()
654 port->cooked = 1; in analog_init_port()
668 return - ENOMEM; in analog_connect()
682 if (port->analog[i].mask) { in analog_connect()
683 err = analog_init_device(port, port->analog + i, i); in analog_connect()
690 fail3: while (--i >= 0) in analog_connect()
691 if (port->analog[i].mask) in analog_connect()
692 input_unregister_device(port->analog[i].dev); in analog_connect()
705 if (port->analog[i].mask) in analog_disconnect()
706 input_unregister_device(port->analog[i].dev); in analog_disconnect()
710 port->bads, port->reads, port->reads ? (port->bads * 100 / port->reads) : 0, in analog_disconnect()
711 port->gameport->phys); in analog_disconnect()
724 { "y-joy", 0x0cc00033 },
725 { "y-pad", 0x8cc80033 },
754 printk(KERN_WARNING "analog.c: Bad config for port %d - \"%s\"\n", i, js[i]); in analog_parse_options()