Lines Matching refs:sw
98 struct sw { struct
199 #define GB(pos,num) sw_get_bits(buf, pos, num, sw->bits)
285 static int sw_parse(unsigned char *buf, struct sw *sw) in sw_parse() argument
290 switch (sw->type) { in sw_parse()
297 dev = sw->dev[0]; in sw_parse()
319 for (i = 0; i < sw->number; i ++) { in sw_parse()
324 input_report_abs(sw->dev[i], ABS_X, GB(i*15+3,1) - GB(i*15+2,1)); in sw_parse()
325 input_report_abs(sw->dev[i], ABS_Y, GB(i*15+0,1) - GB(i*15+1,1)); in sw_parse()
328 input_report_key(sw->dev[i], sw_btn[SW_ID_GP][j], !GB(i*15+j+4,1)); in sw_parse()
330 input_sync(sw->dev[i]); in sw_parse()
341 dev = sw->dev[0]; in sw_parse()
362 dev = sw->dev[0]; in sw_parse()
387 dev = sw->dev[0]; in sw_parse()
409 static int sw_read(struct sw *sw) in sw_read() argument
414 i = sw_read_packet(sw->gameport, buf, sw->length, 0); in sw_read()
416 if (sw->type == SW_ID_3DP && sw->length == 66 && i != 66) { /* Broken packet, try to fix */ in sw_read()
420 " - going to reinitialize.\n", sw->gameport->phys); in sw_read()
421 sw->fail = SW_FAIL; /* Reinitialize */ in sw_read()
437 if (i == sw->length && !sw_parse(buf, sw)) { /* Parse data */ in sw_read()
439 sw->fail = 0; in sw_read()
440 sw->ok++; in sw_read()
442 if (sw->type == SW_ID_3DP && sw->length == 66 /* Many packets OK */ in sw_read()
443 && sw->ok > SW_OK) { in sw_read()
446 " - enabling optimization again.\n", sw->gameport->phys); in sw_read()
447 sw->length = 22; in sw_read()
453 sw->ok = 0; in sw_read()
454 sw->fail++; in sw_read()
456 if (sw->type == SW_ID_3DP && sw->length == 22 && sw->fail > SW_BAD) { /* Consecutive bad packets */ in sw_read()
459 " - disabling optimization.\n", sw->gameport->phys); in sw_read()
460 sw->length = 66; in sw_read()
463 if (sw->fail < SW_FAIL) in sw_read()
467 " - reinitializing joystick.\n", sw->gameport->phys); in sw_read()
469 if (!i && sw->type == SW_ID_3DP) { /* 3D Pro can be in analog mode */ in sw_read()
471 sw_init_digital(sw->gameport); in sw_read()
475 i = sw_read_packet(sw->gameport, buf, SW_LENGTH, 0); /* Read normal data packet */ in sw_read()
477 sw_read_packet(sw->gameport, buf, SW_LENGTH, i); /* Read ID packet, this initializes the stick */ in sw_read()
479 sw->fail = SW_FAIL; in sw_read()
486 struct sw *sw = gameport_get_drvdata(gameport); in sw_poll() local
488 sw->reads++; in sw_poll()
489 if (sw_read(sw)) in sw_poll()
490 sw->bads++; in sw_poll()
495 struct sw *sw = input_get_drvdata(dev); in sw_open() local
497 gameport_start_polling(sw->gameport); in sw_open()
503 struct sw *sw = input_get_drvdata(dev); in sw_close() local
505 gameport_stop_polling(sw->gameport); in sw_close()
572 struct sw *sw; in sw_connect() local
583 sw = kzalloc(sizeof(struct sw), GFP_KERNEL); in sw_connect()
586 if (!sw || !buf || !idbuf) { in sw_connect()
591 sw->gameport = gameport; in sw_connect()
593 gameport_set_drvdata(gameport, sw); in sw_connect()
636 sw->type = -1; in sw_connect()
650 sw->number = 1; in sw_connect()
651 sw->gameport = gameport; in sw_connect()
652 sw->length = i; in sw_connect()
653 sw->bits = m; in sw_connect()
659 sw->number++; in sw_connect()
664 sw->type = SW_ID_FSP; in sw_connect()
667 sw->number++; in sw_connect()
670 sw->number++; in sw_connect()
673 sw->type = SW_ID_GP; in sw_connect()
677 sw->type = SW_ID_FFW; in sw_connect()
681 sw->type = SW_ID_FFP; in sw_connect()
684 sw->type = SW_ID_PP; in sw_connect()
687 sw->bits = 3; in sw_connect()
690 sw->length = 22; in sw_connect()
693 sw->type = SW_ID_3DP; in sw_connect()
700 } while (k && sw->type == -1); in sw_connect()
702 if (sw->type == -1) { in sw_connect()
722 for (i = 0; i < sw->number; i++) { in sw_connect()
725 snprintf(sw->name, sizeof(sw->name), in sw_connect()
726 "Microsoft SideWinder %s", sw_name[sw->type]); in sw_connect()
727 snprintf(sw->phys[i], sizeof(sw->phys[i]), in sw_connect()
730 sw->dev[i] = input_dev = input_allocate_device(); in sw_connect()
736 input_dev->name = sw->name; in sw_connect()
737 input_dev->phys = sw->phys[i]; in sw_connect()
740 input_dev->id.product = sw->type; in sw_connect()
744 input_set_drvdata(input_dev, sw); in sw_connect()
751 for (j = 0; (bits = sw_bit[sw->type][j]); j++) { in sw_connect()
754 code = sw_abs[sw->type][j]; in sw_connect()
765 for (j = 0; (code = sw_btn[sw->type][j]); j++) in sw_connect()
768 dbg("%s%s [%d-bit id %d data %d]\n", sw->name, comment, m, l, k); in sw_connect()
770 err = input_register_device(sw->dev[i]); in sw_connect()
780 fail4: input_free_device(sw->dev[i]); in sw_connect()
782 input_unregister_device(sw->dev[i]); in sw_connect()
785 kfree(sw); in sw_connect()
791 struct sw *sw = gameport_get_drvdata(gameport); in sw_disconnect() local
794 for (i = 0; i < sw->number; i++) in sw_disconnect()
795 input_unregister_device(sw->dev[i]); in sw_disconnect()
798 kfree(sw); in sw_disconnect()