• Home
  • Raw
  • Download

Lines Matching full:sw

110 struct sw {  struct
211 #define GB(pos,num) sw_get_bits(buf, pos, num, sw->bits)
297 static int sw_parse(unsigned char *buf, struct sw *sw) in sw_parse() argument
302 switch (sw->type) { in sw_parse()
309 dev = sw->dev[0]; in sw_parse()
331 for (i = 0; i < sw->number; i ++) { in sw_parse()
336 input_report_abs(sw->dev[i], ABS_X, GB(i*15+3,1) - GB(i*15+2,1)); in sw_parse()
337 input_report_abs(sw->dev[i], ABS_Y, GB(i*15+0,1) - GB(i*15+1,1)); in sw_parse()
340 input_report_key(sw->dev[i], sw_btn[SW_ID_GP][j], !GB(i*15+j+4,1)); in sw_parse()
342 input_sync(sw->dev[i]); in sw_parse()
353 dev = sw->dev[0]; in sw_parse()
374 dev = sw->dev[0]; in sw_parse()
399 dev = sw->dev[0]; in sw_parse()
421 static int sw_read(struct sw *sw) in sw_read() argument
426 i = sw_read_packet(sw->gameport, buf, sw->length, 0); in sw_read()
428 if (sw->type == SW_ID_3DP && sw->length == 66 && i != 66) { /* Broken packet, try to fix */ in sw_read()
432 " - going to reinitialize.\n", sw->gameport->phys); in sw_read()
433 sw->fail = SW_FAIL; /* Reinitialize */ in sw_read()
449 if (i == sw->length && !sw_parse(buf, sw)) { /* Parse data */ in sw_read()
451 sw->fail = 0; in sw_read()
452 sw->ok++; in sw_read()
454 if (sw->type == SW_ID_3DP && sw->length == 66 /* Many packets OK */ in sw_read()
455 && sw->ok > SW_OK) { in sw_read()
458 " - enabling optimization again.\n", sw->gameport->phys); in sw_read()
459 sw->length = 22; in sw_read()
465 sw->ok = 0; in sw_read()
466 sw->fail++; in sw_read()
468 if (sw->type == SW_ID_3DP && sw->length == 22 && sw->fail > SW_BAD) { /* Consecutive bad packets */ in sw_read()
471 " - disabling optimization.\n", sw->gameport->phys); in sw_read()
472 sw->length = 66; in sw_read()
475 if (sw->fail < SW_FAIL) in sw_read()
479 " - reinitializing joystick.\n", sw->gameport->phys); in sw_read()
481 if (!i && sw->type == SW_ID_3DP) { /* 3D Pro can be in analog mode */ in sw_read()
483 sw_init_digital(sw->gameport); in sw_read()
487 i = sw_read_packet(sw->gameport, buf, SW_LENGTH, 0); /* Read normal data packet */ in sw_read()
489 sw_read_packet(sw->gameport, buf, SW_LENGTH, i); /* Read ID packet, this initializes the stick */ in sw_read()
491 sw->fail = SW_FAIL; in sw_read()
498 struct sw *sw = gameport_get_drvdata(gameport); in sw_poll() local
500 sw->reads++; in sw_poll()
501 if (sw_read(sw)) in sw_poll()
502 sw->bads++; in sw_poll()
507 struct sw *sw = input_get_drvdata(dev); in sw_open() local
509 gameport_start_polling(sw->gameport); in sw_open()
515 struct sw *sw = input_get_drvdata(dev); in sw_close() local
517 gameport_stop_polling(sw->gameport); in sw_close()
536 * Unfortunately I don't know how to do this for the other SW types.
584 struct sw *sw; in sw_connect() local
595 sw = kzalloc(sizeof(struct sw), GFP_KERNEL); in sw_connect()
598 if (!sw || !buf || !idbuf) { in sw_connect()
603 sw->gameport = gameport; in sw_connect()
605 gameport_set_drvdata(gameport, sw); in sw_connect()
648 sw->type = -1; in sw_connect()
662 sw->number = 1; in sw_connect()
663 sw->gameport = gameport; in sw_connect()
664 sw->length = i; in sw_connect()
665 sw->bits = m; in sw_connect()
671 sw->number++; /* fall through */ in sw_connect()
675 sw->type = SW_ID_FSP; in sw_connect()
678 sw->number++; /* fall through */ in sw_connect()
680 sw->number++; /* fall through */ in sw_connect()
682 sw->type = SW_ID_GP; in sw_connect()
686 sw->type = SW_ID_FFW; in sw_connect()
690 sw->type = SW_ID_FFP; in sw_connect()
693 sw->type = SW_ID_PP; in sw_connect()
696 sw->bits = 3; /* fall through */ in sw_connect()
698 sw->length = 22; /* fall through */ in sw_connect()
700 sw->type = SW_ID_3DP; in sw_connect()
707 } while (k && sw->type == -1); in sw_connect()
709 if (sw->type == -1) { in sw_connect()
729 for (i = 0; i < sw->number; i++) { in sw_connect()
732 snprintf(sw->name, sizeof(sw->name), in sw_connect()
733 "Microsoft SideWinder %s", sw_name[sw->type]); in sw_connect()
734 snprintf(sw->phys[i], sizeof(sw->phys[i]), in sw_connect()
737 sw->dev[i] = input_dev = input_allocate_device(); in sw_connect()
743 input_dev->name = sw->name; in sw_connect()
744 input_dev->phys = sw->phys[i]; in sw_connect()
747 input_dev->id.product = sw->type; in sw_connect()
751 input_set_drvdata(input_dev, sw); in sw_connect()
758 for (j = 0; (bits = sw_bit[sw->type][j]); j++) { in sw_connect()
761 code = sw_abs[sw->type][j]; in sw_connect()
772 for (j = 0; (code = sw_btn[sw->type][j]); j++) in sw_connect()
775 dbg("%s%s [%d-bit id %d data %d]\n", sw->name, comment, m, l, k); in sw_connect()
777 err = input_register_device(sw->dev[i]); in sw_connect()
787 fail4: input_free_device(sw->dev[i]); in sw_connect()
789 input_unregister_device(sw->dev[i]); in sw_connect()
792 kfree(sw); in sw_connect()
798 struct sw *sw = gameport_get_drvdata(gameport); in sw_disconnect() local
801 for (i = 0; i < sw->number; i++) in sw_disconnect()
802 input_unregister_device(sw->dev[i]); in sw_disconnect()
805 kfree(sw); in sw_disconnect()