Lines Matching refs:xpad

357 static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)  in xpad_process_packet()  argument
359 struct input_dev *dev = xpad->dev; in xpad_process_packet()
361 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad_process_packet()
376 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad_process_packet()
385 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad_process_packet()
427 static void xpad360_process_packet(struct usb_xpad *xpad, in xpad360_process_packet() argument
430 struct input_dev *dev = xpad->dev; in xpad360_process_packet()
433 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad360_process_packet()
447 if (!(xpad->mapping & MAP_DPAD_TO_BUTTONS) || in xpad360_process_packet()
448 xpad->xtype == XTYPE_XBOX360W) { in xpad360_process_packet()
472 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad360_process_packet()
487 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad360_process_packet()
498 static void xpad_identify_controller(struct usb_xpad *xpad);
514 static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) in xpad360w_process_packet() argument
519 xpad->pad_present = 1; in xpad360w_process_packet()
524 xpad_identify_controller(xpad); in xpad360w_process_packet()
526 xpad->pad_present = 0; in xpad360w_process_packet()
533 xpad360_process_packet(xpad, cmd, &data[4]); in xpad360w_process_packet()
541 static void xpadone_process_buttons(struct usb_xpad *xpad, in xpadone_process_buttons() argument
556 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpadone_process_buttons()
577 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpadone_process_buttons()
592 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpadone_process_buttons()
617 static void xpadone_process_packet(struct usb_xpad *xpad, in xpadone_process_packet() argument
620 struct input_dev *dev = xpad->dev; in xpadone_process_packet()
624 xpadone_process_buttons(xpad, dev, data); in xpadone_process_packet()
637 struct usb_xpad *xpad = urb->context; in xpad_irq_in() local
638 struct device *dev = &xpad->intf->dev; in xpad_irq_in()
660 switch (xpad->xtype) { in xpad_irq_in()
662 xpad360_process_packet(xpad, 0, xpad->idata); in xpad_irq_in()
665 xpad360w_process_packet(xpad, 0, xpad->idata); in xpad_irq_in()
668 xpadone_process_packet(xpad, 0, xpad->idata); in xpad_irq_in()
671 xpad_process_packet(xpad, 0, xpad->idata); in xpad_irq_in()
683 struct usb_xpad *xpad = urb->context; in xpad_irq_out() local
684 struct device *dev = &xpad->intf->dev; in xpad_irq_out()
715 static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad) in xpad_init_output() argument
721 if (xpad->xtype == XTYPE_UNKNOWN) in xpad_init_output()
724 xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_init_output()
725 GFP_KERNEL, &xpad->odata_dma); in xpad_init_output()
726 if (!xpad->odata) { in xpad_init_output()
731 mutex_init(&xpad->odata_mutex); in xpad_init_output()
733 xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL); in xpad_init_output()
734 if (!xpad->irq_out) { in xpad_init_output()
740 ep_irq_out_idx = xpad->xtype == XTYPE_XBOXONE ? 0 : 1; in xpad_init_output()
743 usb_fill_int_urb(xpad->irq_out, xpad->udev, in xpad_init_output()
744 usb_sndintpipe(xpad->udev, ep_irq_out->bEndpointAddress), in xpad_init_output()
745 xpad->odata, XPAD_PKT_LEN, in xpad_init_output()
746 xpad_irq_out, xpad, ep_irq_out->bInterval); in xpad_init_output()
747 xpad->irq_out->transfer_dma = xpad->odata_dma; in xpad_init_output()
748 xpad->irq_out->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in xpad_init_output()
752 fail2: usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma); in xpad_init_output()
756 static void xpad_stop_output(struct usb_xpad *xpad) in xpad_stop_output() argument
758 if (xpad->xtype != XTYPE_UNKNOWN) in xpad_stop_output()
759 usb_kill_urb(xpad->irq_out); in xpad_stop_output()
762 static void xpad_deinit_output(struct usb_xpad *xpad) in xpad_deinit_output() argument
764 if (xpad->xtype != XTYPE_UNKNOWN) { in xpad_deinit_output()
765 usb_free_urb(xpad->irq_out); in xpad_deinit_output()
766 usb_free_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_deinit_output()
767 xpad->odata, xpad->odata_dma); in xpad_deinit_output()
771 static int xpad_inquiry_pad_presence(struct usb_xpad *xpad) in xpad_inquiry_pad_presence() argument
775 mutex_lock(&xpad->odata_mutex); in xpad_inquiry_pad_presence()
777 xpad->odata[0] = 0x08; in xpad_inquiry_pad_presence()
778 xpad->odata[1] = 0x00; in xpad_inquiry_pad_presence()
779 xpad->odata[2] = 0x0F; in xpad_inquiry_pad_presence()
780 xpad->odata[3] = 0xC0; in xpad_inquiry_pad_presence()
781 xpad->odata[4] = 0x00; in xpad_inquiry_pad_presence()
782 xpad->odata[5] = 0x00; in xpad_inquiry_pad_presence()
783 xpad->odata[6] = 0x00; in xpad_inquiry_pad_presence()
784 xpad->odata[7] = 0x00; in xpad_inquiry_pad_presence()
785 xpad->odata[8] = 0x00; in xpad_inquiry_pad_presence()
786 xpad->odata[9] = 0x00; in xpad_inquiry_pad_presence()
787 xpad->odata[10] = 0x00; in xpad_inquiry_pad_presence()
788 xpad->odata[11] = 0x00; in xpad_inquiry_pad_presence()
789 xpad->irq_out->transfer_buffer_length = 12; in xpad_inquiry_pad_presence()
791 retval = usb_submit_urb(xpad->irq_out, GFP_KERNEL); in xpad_inquiry_pad_presence()
793 mutex_unlock(&xpad->odata_mutex); in xpad_inquiry_pad_presence()
801 struct usb_xpad *xpad = input_get_drvdata(dev); in xpad_play_effect() local
811 switch (xpad->xtype) { in xpad_play_effect()
813 xpad->odata[0] = 0x00; in xpad_play_effect()
814 xpad->odata[1] = 0x06; in xpad_play_effect()
815 xpad->odata[2] = 0x00; in xpad_play_effect()
816 xpad->odata[3] = strong / 256; /* left actuator */ in xpad_play_effect()
817 xpad->odata[4] = 0x00; in xpad_play_effect()
818 xpad->odata[5] = weak / 256; /* right actuator */ in xpad_play_effect()
819 xpad->irq_out->transfer_buffer_length = 6; in xpad_play_effect()
823 xpad->odata[0] = 0x00; in xpad_play_effect()
824 xpad->odata[1] = 0x08; in xpad_play_effect()
825 xpad->odata[2] = 0x00; in xpad_play_effect()
826 xpad->odata[3] = strong / 256; /* left actuator? */ in xpad_play_effect()
827 xpad->odata[4] = weak / 256; /* right actuator? */ in xpad_play_effect()
828 xpad->odata[5] = 0x00; in xpad_play_effect()
829 xpad->odata[6] = 0x00; in xpad_play_effect()
830 xpad->odata[7] = 0x00; in xpad_play_effect()
831 xpad->irq_out->transfer_buffer_length = 8; in xpad_play_effect()
835 xpad->odata[0] = 0x00; in xpad_play_effect()
836 xpad->odata[1] = 0x01; in xpad_play_effect()
837 xpad->odata[2] = 0x0F; in xpad_play_effect()
838 xpad->odata[3] = 0xC0; in xpad_play_effect()
839 xpad->odata[4] = 0x00; in xpad_play_effect()
840 xpad->odata[5] = strong / 256; in xpad_play_effect()
841 xpad->odata[6] = weak / 256; in xpad_play_effect()
842 xpad->odata[7] = 0x00; in xpad_play_effect()
843 xpad->odata[8] = 0x00; in xpad_play_effect()
844 xpad->odata[9] = 0x00; in xpad_play_effect()
845 xpad->odata[10] = 0x00; in xpad_play_effect()
846 xpad->odata[11] = 0x00; in xpad_play_effect()
847 xpad->irq_out->transfer_buffer_length = 12; in xpad_play_effect()
851 xpad->odata[0] = 0x09; /* activate rumble */ in xpad_play_effect()
852 xpad->odata[1] = 0x08; in xpad_play_effect()
853 xpad->odata[2] = 0x00; in xpad_play_effect()
854 xpad->odata[3] = 0x08; /* continuous effect */ in xpad_play_effect()
855 xpad->odata[4] = 0x00; /* simple rumble mode */ in xpad_play_effect()
856 xpad->odata[5] = 0x03; /* L and R actuator only */ in xpad_play_effect()
857 xpad->odata[6] = 0x00; /* TODO: LT actuator */ in xpad_play_effect()
858 xpad->odata[7] = 0x00; /* TODO: RT actuator */ in xpad_play_effect()
859 xpad->odata[8] = strong / 256; /* left actuator */ in xpad_play_effect()
860 xpad->odata[9] = weak / 256; /* right actuator */ in xpad_play_effect()
861 xpad->odata[10] = 0x80; /* length of pulse */ in xpad_play_effect()
862 xpad->odata[11] = 0x00; /* stop period of pulse */ in xpad_play_effect()
863 xpad->irq_out->transfer_buffer_length = 12; in xpad_play_effect()
867 dev_dbg(&xpad->dev->dev, in xpad_play_effect()
869 __func__, xpad->xtype); in xpad_play_effect()
873 return usb_submit_urb(xpad->irq_out, GFP_ATOMIC); in xpad_play_effect()
876 static int xpad_init_ff(struct usb_xpad *xpad) in xpad_init_ff() argument
878 if (xpad->xtype == XTYPE_UNKNOWN) in xpad_init_ff()
881 input_set_capability(xpad->dev, EV_FF, FF_RUMBLE); in xpad_init_ff()
883 return input_ff_create_memless(xpad->dev, NULL, xpad_play_effect); in xpad_init_ff()
887 static int xpad_init_ff(struct usb_xpad *xpad) { return 0; } in xpad_init_ff() argument
899 struct usb_xpad *xpad; member
922 static void xpad_send_led_command(struct usb_xpad *xpad, int command) in xpad_send_led_command() argument
926 mutex_lock(&xpad->odata_mutex); in xpad_send_led_command()
928 switch (xpad->xtype) { in xpad_send_led_command()
930 xpad->odata[0] = 0x01; in xpad_send_led_command()
931 xpad->odata[1] = 0x03; in xpad_send_led_command()
932 xpad->odata[2] = command; in xpad_send_led_command()
933 xpad->irq_out->transfer_buffer_length = 3; in xpad_send_led_command()
936 xpad->odata[0] = 0x00; in xpad_send_led_command()
937 xpad->odata[1] = 0x00; in xpad_send_led_command()
938 xpad->odata[2] = 0x08; in xpad_send_led_command()
939 xpad->odata[3] = 0x40 + command; in xpad_send_led_command()
940 xpad->odata[4] = 0x00; in xpad_send_led_command()
941 xpad->odata[5] = 0x00; in xpad_send_led_command()
942 xpad->odata[6] = 0x00; in xpad_send_led_command()
943 xpad->odata[7] = 0x00; in xpad_send_led_command()
944 xpad->odata[8] = 0x00; in xpad_send_led_command()
945 xpad->odata[9] = 0x00; in xpad_send_led_command()
946 xpad->odata[10] = 0x00; in xpad_send_led_command()
947 xpad->odata[11] = 0x00; in xpad_send_led_command()
948 xpad->irq_out->transfer_buffer_length = 12; in xpad_send_led_command()
952 usb_submit_urb(xpad->irq_out, GFP_KERNEL); in xpad_send_led_command()
953 mutex_unlock(&xpad->odata_mutex); in xpad_send_led_command()
960 static void xpad_identify_controller(struct usb_xpad *xpad) in xpad_identify_controller() argument
962 xpad_send_led_command(xpad, (xpad->pad_nr % 4) + 2); in xpad_identify_controller()
971 xpad_send_led_command(xpad_led->xpad, value); in xpad_led_set()
974 static int xpad_led_probe(struct usb_xpad *xpad) in xpad_led_probe() argument
980 if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX360W) in xpad_led_probe()
983 xpad->led = led = kzalloc(sizeof(struct xpad_led), GFP_KERNEL); in xpad_led_probe()
987 xpad->pad_nr = ida_simple_get(&xpad_pad_seq, 0, 0, GFP_KERNEL); in xpad_led_probe()
988 if (xpad->pad_nr < 0) { in xpad_led_probe()
989 error = xpad->pad_nr; in xpad_led_probe()
993 snprintf(led->name, sizeof(led->name), "xpad%d", xpad->pad_nr); in xpad_led_probe()
994 led->xpad = xpad; in xpad_led_probe()
1000 error = led_classdev_register(&xpad->udev->dev, led_cdev); in xpad_led_probe()
1004 if (xpad->xtype == XTYPE_XBOX360) { in xpad_led_probe()
1010 xpad_identify_controller(xpad); in xpad_led_probe()
1016 ida_simple_remove(&xpad_pad_seq, xpad->pad_nr); in xpad_led_probe()
1019 xpad->led = NULL; in xpad_led_probe()
1023 static void xpad_led_disconnect(struct usb_xpad *xpad) in xpad_led_disconnect() argument
1025 struct xpad_led *xpad_led = xpad->led; in xpad_led_disconnect()
1029 ida_simple_remove(&xpad_pad_seq, xpad->pad_nr); in xpad_led_disconnect()
1034 static int xpad_led_probe(struct usb_xpad *xpad) { return 0; } in xpad_led_probe() argument
1035 static void xpad_led_disconnect(struct usb_xpad *xpad) { } in xpad_led_disconnect() argument
1036 static void xpad_identify_controller(struct usb_xpad *xpad) { } in xpad_identify_controller() argument
1041 struct usb_xpad *xpad = input_get_drvdata(dev); in xpad_open() local
1044 if (xpad->xtype == XTYPE_XBOX360W) in xpad_open()
1047 xpad->irq_in->dev = xpad->udev; in xpad_open()
1048 if (usb_submit_urb(xpad->irq_in, GFP_KERNEL)) in xpad_open()
1051 if (xpad->xtype == XTYPE_XBOXONE) { in xpad_open()
1053 xpad->odata[0] = 0x05; in xpad_open()
1054 xpad->odata[1] = 0x20; in xpad_open()
1055 xpad->irq_out->transfer_buffer_length = 2; in xpad_open()
1056 return usb_submit_urb(xpad->irq_out, GFP_KERNEL); in xpad_open()
1064 struct usb_xpad *xpad = input_get_drvdata(dev); in xpad_close() local
1066 if (xpad->xtype != XTYPE_XBOX360W) in xpad_close()
1067 usb_kill_urb(xpad->irq_in); in xpad_close()
1069 xpad_stop_output(xpad); in xpad_close()
1074 struct usb_xpad *xpad = input_get_drvdata(input_dev); in xpad_set_up_abs() local
1086 if (xpad->xtype == XTYPE_XBOXONE) in xpad_set_up_abs()
1098 static void xpad_deinit_input(struct usb_xpad *xpad) in xpad_deinit_input() argument
1100 xpad_led_disconnect(xpad); in xpad_deinit_input()
1101 input_unregister_device(xpad->dev); in xpad_deinit_input()
1104 static int xpad_init_input(struct usb_xpad *xpad) in xpad_init_input() argument
1113 xpad->dev = input_dev; in xpad_init_input()
1114 input_dev->name = xpad->name; in xpad_init_input()
1115 input_dev->phys = xpad->phys; in xpad_init_input()
1116 usb_to_input_id(xpad->udev, &input_dev->id); in xpad_init_input()
1117 input_dev->dev.parent = &xpad->intf->dev; in xpad_init_input()
1119 input_set_drvdata(input_dev, xpad); in xpad_init_input()
1126 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad_init_input()
1138 if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W || in xpad_init_input()
1139 xpad->xtype == XTYPE_XBOXONE) { in xpad_init_input()
1147 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad_init_input()
1158 if (!(xpad->mapping & MAP_DPAD_TO_BUTTONS) || in xpad_init_input()
1159 xpad->xtype == XTYPE_XBOX360W) { in xpad_init_input()
1164 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad_init_input()
1172 error = xpad_init_ff(xpad); in xpad_init_input()
1176 error = xpad_led_probe(xpad); in xpad_init_input()
1180 error = input_register_device(xpad->dev); in xpad_init_input()
1187 xpad_led_disconnect(xpad); in xpad_init_input()
1198 struct usb_xpad *xpad; in xpad_probe() local
1219 xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL); in xpad_probe()
1220 if (!xpad) in xpad_probe()
1223 usb_make_path(udev, xpad->phys, sizeof(xpad->phys)); in xpad_probe()
1224 strlcat(xpad->phys, "/input0", sizeof(xpad->phys)); in xpad_probe()
1226 xpad->idata = usb_alloc_coherent(udev, XPAD_PKT_LEN, in xpad_probe()
1227 GFP_KERNEL, &xpad->idata_dma); in xpad_probe()
1228 if (!xpad->idata) { in xpad_probe()
1233 xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); in xpad_probe()
1234 if (!xpad->irq_in) { in xpad_probe()
1239 xpad->udev = udev; in xpad_probe()
1240 xpad->intf = intf; in xpad_probe()
1241 xpad->mapping = xpad_device[i].mapping; in xpad_probe()
1242 xpad->xtype = xpad_device[i].xtype; in xpad_probe()
1243 xpad->name = xpad_device[i].name; in xpad_probe()
1245 if (xpad->xtype == XTYPE_UNKNOWN) { in xpad_probe()
1248 xpad->xtype = XTYPE_XBOX360W; in xpad_probe()
1250 xpad->xtype = XTYPE_XBOX360; in xpad_probe()
1252 xpad->xtype = XTYPE_XBOX; in xpad_probe()
1256 xpad->mapping |= MAP_DPAD_TO_BUTTONS; in xpad_probe()
1258 xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS; in xpad_probe()
1260 xpad->mapping |= MAP_STICKS_TO_NULL; in xpad_probe()
1263 error = xpad_init_output(intf, xpad); in xpad_probe()
1268 ep_irq_in_idx = xpad->xtype == XTYPE_XBOXONE ? 1 : 0; in xpad_probe()
1271 usb_fill_int_urb(xpad->irq_in, udev, in xpad_probe()
1273 xpad->idata, XPAD_PKT_LEN, xpad_irq_in, in xpad_probe()
1274 xpad, ep_irq_in->bInterval); in xpad_probe()
1275 xpad->irq_in->transfer_dma = xpad->idata_dma; in xpad_probe()
1276 xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in xpad_probe()
1278 usb_set_intfdata(intf, xpad); in xpad_probe()
1280 error = xpad_init_input(xpad); in xpad_probe()
1284 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_probe()
1292 xpad->irq_in->dev = xpad->udev; in xpad_probe()
1293 error = usb_submit_urb(xpad->irq_in, GFP_KERNEL); in xpad_probe()
1304 error = xpad_inquiry_pad_presence(xpad); in xpad_probe()
1311 usb_kill_urb(xpad->irq_in); in xpad_probe()
1313 xpad_deinit_input(xpad); in xpad_probe()
1315 xpad_deinit_output(xpad); in xpad_probe()
1317 usb_free_urb(xpad->irq_in); in xpad_probe()
1319 usb_free_coherent(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); in xpad_probe()
1321 kfree(xpad); in xpad_probe()
1328 struct usb_xpad *xpad = usb_get_intfdata (intf); in xpad_disconnect() local
1330 xpad_deinit_input(xpad); in xpad_disconnect()
1331 xpad_deinit_output(xpad); in xpad_disconnect()
1333 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_disconnect()
1334 usb_kill_urb(xpad->irq_in); in xpad_disconnect()
1337 usb_free_urb(xpad->irq_in); in xpad_disconnect()
1338 usb_free_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_disconnect()
1339 xpad->idata, xpad->idata_dma); in xpad_disconnect()
1341 kfree(xpad); in xpad_disconnect()