Lines Matching refs:sw
95 struct sw { struct
196 #define GB(pos,num) sw_get_bits(buf, pos, num, sw->bits)
282 static int sw_parse(unsigned char *buf, struct sw *sw) in sw_parse() argument
287 switch (sw->type) { in sw_parse()
294 dev = sw->dev[0]; in sw_parse()
316 for (i = 0; i < sw->number; i ++) { in sw_parse()
321 input_report_abs(sw->dev[i], ABS_X, GB(i*15+3,1) - GB(i*15+2,1)); in sw_parse()
322 input_report_abs(sw->dev[i], ABS_Y, GB(i*15+0,1) - GB(i*15+1,1)); in sw_parse()
325 input_report_key(sw->dev[i], sw_btn[SW_ID_GP][j], !GB(i*15+j+4,1)); in sw_parse()
327 input_sync(sw->dev[i]); in sw_parse()
338 dev = sw->dev[0]; in sw_parse()
359 dev = sw->dev[0]; in sw_parse()
384 dev = sw->dev[0]; in sw_parse()
406 static int sw_read(struct sw *sw) in sw_read() argument
411 i = sw_read_packet(sw->gameport, buf, sw->length, 0); in sw_read()
413 if (sw->type == SW_ID_3DP && sw->length == 66 && i != 66) { /* Broken packet, try to fix */ in sw_read()
417 " - going to reinitialize.\n", sw->gameport->phys); in sw_read()
418 sw->fail = SW_FAIL; /* Reinitialize */ in sw_read()
434 if (i == sw->length && !sw_parse(buf, sw)) { /* Parse data */ in sw_read()
436 sw->fail = 0; in sw_read()
437 sw->ok++; in sw_read()
439 if (sw->type == SW_ID_3DP && sw->length == 66 /* Many packets OK */ in sw_read()
440 && sw->ok > SW_OK) { in sw_read()
443 " - enabling optimization again.\n", sw->gameport->phys); in sw_read()
444 sw->length = 22; in sw_read()
450 sw->ok = 0; in sw_read()
451 sw->fail++; in sw_read()
453 if (sw->type == SW_ID_3DP && sw->length == 22 && sw->fail > SW_BAD) { /* Consecutive bad packets */ in sw_read()
456 " - disabling optimization.\n", sw->gameport->phys); in sw_read()
457 sw->length = 66; in sw_read()
460 if (sw->fail < SW_FAIL) in sw_read()
464 " - reinitializing joystick.\n", sw->gameport->phys); in sw_read()
466 if (!i && sw->type == SW_ID_3DP) { /* 3D Pro can be in analog mode */ in sw_read()
468 sw_init_digital(sw->gameport); in sw_read()
472 i = sw_read_packet(sw->gameport, buf, SW_LENGTH, 0); /* Read normal data packet */ in sw_read()
474 sw_read_packet(sw->gameport, buf, SW_LENGTH, i); /* Read ID packet, this initializes the stick */ in sw_read()
476 sw->fail = SW_FAIL; in sw_read()
483 struct sw *sw = gameport_get_drvdata(gameport); in sw_poll() local
485 sw->reads++; in sw_poll()
486 if (sw_read(sw)) in sw_poll()
487 sw->bads++; in sw_poll()
492 struct sw *sw = input_get_drvdata(dev); in sw_open() local
494 gameport_start_polling(sw->gameport); in sw_open()
500 struct sw *sw = input_get_drvdata(dev); in sw_close() local
502 gameport_stop_polling(sw->gameport); in sw_close()
569 struct sw *sw; in sw_connect() local
580 sw = kzalloc(sizeof(*sw), GFP_KERNEL); in sw_connect()
583 if (!sw || !buf || !idbuf) { in sw_connect()
588 sw->gameport = gameport; in sw_connect()
590 gameport_set_drvdata(gameport, sw); in sw_connect()
633 sw->type = -1; in sw_connect()
647 sw->number = 1; in sw_connect()
648 sw->gameport = gameport; in sw_connect()
649 sw->length = i; in sw_connect()
650 sw->bits = m; in sw_connect()
656 sw->number++; in sw_connect()
662 sw->type = SW_ID_FSP; in sw_connect()
665 sw->number++; in sw_connect()
668 sw->number++; in sw_connect()
671 sw->type = SW_ID_GP; in sw_connect()
675 sw->type = SW_ID_FFW; in sw_connect()
679 sw->type = SW_ID_FFP; in sw_connect()
682 sw->type = SW_ID_PP; in sw_connect()
685 sw->bits = 3; in sw_connect()
688 sw->length = 22; in sw_connect()
691 sw->type = SW_ID_3DP; in sw_connect()
698 } while (k && sw->type == -1); in sw_connect()
700 if (sw->type == -1) { in sw_connect()
720 for (i = 0; i < sw->number; i++) { in sw_connect()
723 snprintf(sw->name, sizeof(sw->name), in sw_connect()
724 "Microsoft SideWinder %s", sw_name[sw->type]); in sw_connect()
725 snprintf(sw->phys[i], sizeof(sw->phys[i]), in sw_connect()
728 sw->dev[i] = input_dev = input_allocate_device(); in sw_connect()
734 input_dev->name = sw->name; in sw_connect()
735 input_dev->phys = sw->phys[i]; in sw_connect()
738 input_dev->id.product = sw->type; in sw_connect()
742 input_set_drvdata(input_dev, sw); in sw_connect()
749 for (j = 0; (bits = sw_bit[sw->type][j]); j++) { in sw_connect()
752 code = sw_abs[sw->type][j]; in sw_connect()
763 for (j = 0; (code = sw_btn[sw->type][j]); j++) in sw_connect()
766 dbg("%s%s [%d-bit id %d data %d]\n", sw->name, comment, m, l, k); in sw_connect()
768 err = input_register_device(sw->dev[i]); in sw_connect()
778 fail4: input_free_device(sw->dev[i]); in sw_connect()
780 input_unregister_device(sw->dev[i]); in sw_connect()
783 kfree(sw); in sw_connect()
789 struct sw *sw = gameport_get_drvdata(gameport); in sw_disconnect() local
792 for (i = 0; i < sw->number; i++) in sw_disconnect()
793 input_unregister_device(sw->dev[i]); in sw_disconnect()
796 kfree(sw); in sw_disconnect()