Lines Matching refs:xpad
359 static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) in xpad_process_packet() argument
361 struct input_dev *dev = xpad->dev; in xpad_process_packet()
363 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad_process_packet()
378 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad_process_packet()
387 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad_process_packet()
429 static void xpad360_process_packet(struct usb_xpad *xpad, in xpad360_process_packet() argument
432 struct input_dev *dev = xpad->dev; in xpad360_process_packet()
435 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad360_process_packet()
465 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad360_process_packet()
480 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad360_process_packet()
506 static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) in xpad360w_process_packet() argument
511 xpad->pad_present = 1; in xpad360w_process_packet()
512 usb_submit_urb(xpad->bulk_out, GFP_ATOMIC); in xpad360w_process_packet()
514 xpad->pad_present = 0; in xpad360w_process_packet()
521 xpad360_process_packet(xpad, cmd, &data[4]); in xpad360w_process_packet()
529 static void xpadone_process_buttons(struct usb_xpad *xpad, in xpadone_process_buttons() argument
544 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpadone_process_buttons()
565 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpadone_process_buttons()
580 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpadone_process_buttons()
605 static void xpadone_process_packet(struct usb_xpad *xpad, in xpadone_process_packet() argument
608 struct input_dev *dev = xpad->dev; in xpadone_process_packet()
612 xpadone_process_buttons(xpad, dev, data); in xpadone_process_packet()
625 struct usb_xpad *xpad = urb->context; in xpad_irq_in() local
626 struct device *dev = &xpad->intf->dev; in xpad_irq_in()
648 switch (xpad->xtype) { in xpad_irq_in()
650 xpad360_process_packet(xpad, 0, xpad->idata); in xpad_irq_in()
653 xpad360w_process_packet(xpad, 0, xpad->idata); in xpad_irq_in()
656 xpadone_process_packet(xpad, 0, xpad->idata); in xpad_irq_in()
659 xpad_process_packet(xpad, 0, xpad->idata); in xpad_irq_in()
671 struct usb_xpad *xpad = urb->context; in xpad_bulk_out() local
672 struct device *dev = &xpad->intf->dev; in xpad_bulk_out()
693 struct usb_xpad *xpad = urb->context; in xpad_irq_out() local
694 struct device *dev = &xpad->intf->dev; in xpad_irq_out()
725 static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad) in xpad_init_output() argument
731 if (xpad->xtype == XTYPE_UNKNOWN) in xpad_init_output()
734 xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_init_output()
735 GFP_KERNEL, &xpad->odata_dma); in xpad_init_output()
736 if (!xpad->odata) { in xpad_init_output()
741 mutex_init(&xpad->odata_mutex); in xpad_init_output()
743 xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL); in xpad_init_output()
744 if (!xpad->irq_out) { in xpad_init_output()
750 ep_irq_out_idx = xpad->xtype == XTYPE_XBOXONE ? 0 : 1; in xpad_init_output()
753 usb_fill_int_urb(xpad->irq_out, xpad->udev, in xpad_init_output()
754 usb_sndintpipe(xpad->udev, ep_irq_out->bEndpointAddress), in xpad_init_output()
755 xpad->odata, XPAD_PKT_LEN, in xpad_init_output()
756 xpad_irq_out, xpad, ep_irq_out->bInterval); in xpad_init_output()
757 xpad->irq_out->transfer_dma = xpad->odata_dma; in xpad_init_output()
758 xpad->irq_out->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in xpad_init_output()
762 fail2: usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma); in xpad_init_output()
766 static void xpad_stop_output(struct usb_xpad *xpad) in xpad_stop_output() argument
768 if (xpad->xtype != XTYPE_UNKNOWN) in xpad_stop_output()
769 usb_kill_urb(xpad->irq_out); in xpad_stop_output()
772 static void xpad_deinit_output(struct usb_xpad *xpad) in xpad_deinit_output() argument
774 if (xpad->xtype != XTYPE_UNKNOWN) { in xpad_deinit_output()
775 usb_free_urb(xpad->irq_out); in xpad_deinit_output()
776 usb_free_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_deinit_output()
777 xpad->odata, xpad->odata_dma); in xpad_deinit_output()
784 struct usb_xpad *xpad = input_get_drvdata(dev); in xpad_play_effect() local
790 switch (xpad->xtype) { in xpad_play_effect()
793 xpad->odata[0] = 0x00; in xpad_play_effect()
794 xpad->odata[1] = 0x06; in xpad_play_effect()
795 xpad->odata[2] = 0x00; in xpad_play_effect()
796 xpad->odata[3] = strong / 256; /* left actuator */ in xpad_play_effect()
797 xpad->odata[4] = 0x00; in xpad_play_effect()
798 xpad->odata[5] = weak / 256; /* right actuator */ in xpad_play_effect()
799 xpad->irq_out->transfer_buffer_length = 6; in xpad_play_effect()
801 return usb_submit_urb(xpad->irq_out, GFP_ATOMIC); in xpad_play_effect()
804 xpad->odata[0] = 0x00; in xpad_play_effect()
805 xpad->odata[1] = 0x08; in xpad_play_effect()
806 xpad->odata[2] = 0x00; in xpad_play_effect()
807 xpad->odata[3] = strong / 256; /* left actuator? */ in xpad_play_effect()
808 xpad->odata[4] = weak / 256; /* right actuator? */ in xpad_play_effect()
809 xpad->odata[5] = 0x00; in xpad_play_effect()
810 xpad->odata[6] = 0x00; in xpad_play_effect()
811 xpad->odata[7] = 0x00; in xpad_play_effect()
812 xpad->irq_out->transfer_buffer_length = 8; in xpad_play_effect()
814 return usb_submit_urb(xpad->irq_out, GFP_ATOMIC); in xpad_play_effect()
817 xpad->odata[0] = 0x00; in xpad_play_effect()
818 xpad->odata[1] = 0x01; in xpad_play_effect()
819 xpad->odata[2] = 0x0F; in xpad_play_effect()
820 xpad->odata[3] = 0xC0; in xpad_play_effect()
821 xpad->odata[4] = 0x00; in xpad_play_effect()
822 xpad->odata[5] = strong / 256; in xpad_play_effect()
823 xpad->odata[6] = weak / 256; in xpad_play_effect()
824 xpad->odata[7] = 0x00; in xpad_play_effect()
825 xpad->odata[8] = 0x00; in xpad_play_effect()
826 xpad->odata[9] = 0x00; in xpad_play_effect()
827 xpad->odata[10] = 0x00; in xpad_play_effect()
828 xpad->odata[11] = 0x00; in xpad_play_effect()
829 xpad->irq_out->transfer_buffer_length = 12; in xpad_play_effect()
831 return usb_submit_urb(xpad->irq_out, GFP_ATOMIC); in xpad_play_effect()
834 xpad->odata[0] = 0x09; /* activate rumble */ in xpad_play_effect()
835 xpad->odata[1] = 0x08; in xpad_play_effect()
836 xpad->odata[2] = 0x00; in xpad_play_effect()
837 xpad->odata[3] = 0x08; /* continuous effect */ in xpad_play_effect()
838 xpad->odata[4] = 0x00; /* simple rumble mode */ in xpad_play_effect()
839 xpad->odata[5] = 0x03; /* L and R actuator only */ in xpad_play_effect()
840 xpad->odata[6] = 0x00; /* TODO: LT actuator */ in xpad_play_effect()
841 xpad->odata[7] = 0x00; /* TODO: RT actuator */ in xpad_play_effect()
842 xpad->odata[8] = strong / 256; /* left actuator */ in xpad_play_effect()
843 xpad->odata[9] = weak / 256; /* right actuator */ in xpad_play_effect()
844 xpad->odata[10] = 0x80; /* length of pulse */ in xpad_play_effect()
845 xpad->odata[11] = 0x00; /* stop period of pulse */ in xpad_play_effect()
846 xpad->irq_out->transfer_buffer_length = 12; in xpad_play_effect()
848 return usb_submit_urb(xpad->irq_out, GFP_ATOMIC); in xpad_play_effect()
851 dev_dbg(&xpad->dev->dev, in xpad_play_effect()
853 __func__, xpad->xtype); in xpad_play_effect()
861 static int xpad_init_ff(struct usb_xpad *xpad) in xpad_init_ff() argument
863 if (xpad->xtype == XTYPE_UNKNOWN) in xpad_init_ff()
866 input_set_capability(xpad->dev, EV_FF, FF_RUMBLE); in xpad_init_ff()
868 return input_ff_create_memless(xpad->dev, NULL, xpad_play_effect); in xpad_init_ff()
872 static int xpad_init_ff(struct usb_xpad *xpad) { return 0; } in xpad_init_ff() argument
881 struct usb_xpad *xpad; member
884 static void xpad_send_led_command(struct usb_xpad *xpad, int command) in xpad_send_led_command() argument
887 mutex_lock(&xpad->odata_mutex); in xpad_send_led_command()
888 xpad->odata[0] = 0x01; in xpad_send_led_command()
889 xpad->odata[1] = 0x03; in xpad_send_led_command()
890 xpad->odata[2] = command; in xpad_send_led_command()
891 xpad->irq_out->transfer_buffer_length = 3; in xpad_send_led_command()
892 usb_submit_urb(xpad->irq_out, GFP_KERNEL); in xpad_send_led_command()
893 mutex_unlock(&xpad->odata_mutex); in xpad_send_led_command()
903 xpad_send_led_command(xpad_led->xpad, value); in xpad_led_set()
906 static int xpad_led_probe(struct usb_xpad *xpad) in xpad_led_probe() argument
914 if (xpad->xtype != XTYPE_XBOX360) in xpad_led_probe()
917 xpad->led = led = kzalloc(sizeof(struct xpad_led), GFP_KERNEL); in xpad_led_probe()
924 led->xpad = xpad; in xpad_led_probe()
930 error = led_classdev_register(&xpad->udev->dev, led_cdev); in xpad_led_probe()
933 xpad->led = NULL; in xpad_led_probe()
940 xpad_send_led_command(xpad, (led_no % 4) + 2); in xpad_led_probe()
945 static void xpad_led_disconnect(struct usb_xpad *xpad) in xpad_led_disconnect() argument
947 struct xpad_led *xpad_led = xpad->led; in xpad_led_disconnect()
955 static int xpad_led_probe(struct usb_xpad *xpad) { return 0; } in xpad_led_probe() argument
956 static void xpad_led_disconnect(struct usb_xpad *xpad) { } in xpad_led_disconnect() argument
962 struct usb_xpad *xpad = input_get_drvdata(dev); in xpad_open() local
965 if (xpad->xtype == XTYPE_XBOX360W) in xpad_open()
968 xpad->irq_in->dev = xpad->udev; in xpad_open()
969 if (usb_submit_urb(xpad->irq_in, GFP_KERNEL)) in xpad_open()
972 if (xpad->xtype == XTYPE_XBOXONE) { in xpad_open()
974 xpad->odata[0] = 0x05; in xpad_open()
975 xpad->odata[1] = 0x20; in xpad_open()
976 xpad->irq_out->transfer_buffer_length = 2; in xpad_open()
977 return usb_submit_urb(xpad->irq_out, GFP_KERNEL); in xpad_open()
985 struct usb_xpad *xpad = input_get_drvdata(dev); in xpad_close() local
987 if (xpad->xtype != XTYPE_XBOX360W) in xpad_close()
988 usb_kill_urb(xpad->irq_in); in xpad_close()
990 xpad_stop_output(xpad); in xpad_close()
995 struct usb_xpad *xpad = input_get_drvdata(input_dev); in xpad_set_up_abs() local
1007 if (xpad->xtype == XTYPE_XBOXONE) in xpad_set_up_abs()
1022 struct usb_xpad *xpad; in xpad_probe() local
1044 xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL); in xpad_probe()
1046 if (!xpad || !input_dev) { in xpad_probe()
1051 xpad->idata = usb_alloc_coherent(udev, XPAD_PKT_LEN, in xpad_probe()
1052 GFP_KERNEL, &xpad->idata_dma); in xpad_probe()
1053 if (!xpad->idata) { in xpad_probe()
1058 xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); in xpad_probe()
1059 if (!xpad->irq_in) { in xpad_probe()
1064 xpad->udev = udev; in xpad_probe()
1065 xpad->intf = intf; in xpad_probe()
1066 xpad->mapping = xpad_device[i].mapping; in xpad_probe()
1067 xpad->xtype = xpad_device[i].xtype; in xpad_probe()
1069 if (xpad->xtype == XTYPE_UNKNOWN) { in xpad_probe()
1072 xpad->xtype = XTYPE_XBOX360W; in xpad_probe()
1074 xpad->xtype = XTYPE_XBOX360; in xpad_probe()
1076 xpad->xtype = XTYPE_XBOX; in xpad_probe()
1079 xpad->mapping |= MAP_DPAD_TO_BUTTONS; in xpad_probe()
1081 xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS; in xpad_probe()
1083 xpad->mapping |= MAP_STICKS_TO_NULL; in xpad_probe()
1086 xpad->dev = input_dev; in xpad_probe()
1087 usb_make_path(udev, xpad->phys, sizeof(xpad->phys)); in xpad_probe()
1088 strlcat(xpad->phys, "/input0", sizeof(xpad->phys)); in xpad_probe()
1091 input_dev->phys = xpad->phys; in xpad_probe()
1095 input_set_drvdata(input_dev, xpad); in xpad_probe()
1102 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad_probe()
1114 if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W || in xpad_probe()
1115 xpad->xtype == XTYPE_XBOXONE) { in xpad_probe()
1123 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad_probe()
1131 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad_probe()
1139 error = xpad_init_output(intf, xpad); in xpad_probe()
1143 error = xpad_init_ff(xpad); in xpad_probe()
1147 error = xpad_led_probe(xpad); in xpad_probe()
1152 ep_irq_in_idx = xpad->xtype == XTYPE_XBOXONE ? 1 : 0; in xpad_probe()
1155 usb_fill_int_urb(xpad->irq_in, udev, in xpad_probe()
1157 xpad->idata, XPAD_PKT_LEN, xpad_irq_in, in xpad_probe()
1158 xpad, ep_irq_in->bInterval); in xpad_probe()
1159 xpad->irq_in->transfer_dma = xpad->idata_dma; in xpad_probe()
1160 xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in xpad_probe()
1162 error = input_register_device(xpad->dev); in xpad_probe()
1166 usb_set_intfdata(intf, xpad); in xpad_probe()
1168 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_probe()
1173 xpad->bulk_out = usb_alloc_urb(0, GFP_KERNEL); in xpad_probe()
1174 if (!xpad->bulk_out) { in xpad_probe()
1179 xpad->bdata = kzalloc(XPAD_PKT_LEN, GFP_KERNEL); in xpad_probe()
1180 if (!xpad->bdata) { in xpad_probe()
1185 xpad->bdata[2] = 0x08; in xpad_probe()
1188 xpad->bdata[3] = 0x42; in xpad_probe()
1191 xpad->bdata[3] = 0x43; in xpad_probe()
1194 xpad->bdata[3] = 0x44; in xpad_probe()
1197 xpad->bdata[3] = 0x45; in xpad_probe()
1202 usb_fill_bulk_urb(xpad->bulk_out, udev, in xpad_probe()
1205 xpad->bdata, XPAD_PKT_LEN, in xpad_probe()
1206 xpad_bulk_out, xpad); in xpad_probe()
1208 usb_fill_int_urb(xpad->bulk_out, udev, in xpad_probe()
1211 xpad->bdata, XPAD_PKT_LEN, in xpad_probe()
1212 xpad_bulk_out, xpad, 0); in xpad_probe()
1222 xpad->irq_in->dev = xpad->udev; in xpad_probe()
1223 error = usb_submit_urb(xpad->irq_in, GFP_KERNEL); in xpad_probe()
1230 fail9: kfree(xpad->bdata); in xpad_probe()
1231 fail8: usb_free_urb(xpad->bulk_out); in xpad_probe()
1234 fail6: xpad_led_disconnect(xpad); in xpad_probe()
1237 fail4: xpad_deinit_output(xpad); in xpad_probe()
1238 fail3: usb_free_urb(xpad->irq_in); in xpad_probe()
1239 fail2: usb_free_coherent(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); in xpad_probe()
1241 kfree(xpad); in xpad_probe()
1248 struct usb_xpad *xpad = usb_get_intfdata (intf); in xpad_disconnect() local
1250 xpad_led_disconnect(xpad); in xpad_disconnect()
1251 input_unregister_device(xpad->dev); in xpad_disconnect()
1252 xpad_deinit_output(xpad); in xpad_disconnect()
1254 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_disconnect()
1255 usb_kill_urb(xpad->bulk_out); in xpad_disconnect()
1256 usb_free_urb(xpad->bulk_out); in xpad_disconnect()
1257 usb_kill_urb(xpad->irq_in); in xpad_disconnect()
1260 usb_free_urb(xpad->irq_in); in xpad_disconnect()
1261 usb_free_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_disconnect()
1262 xpad->idata, xpad->idata_dma); in xpad_disconnect()
1264 kfree(xpad->bdata); in xpad_disconnect()
1265 kfree(xpad); in xpad_disconnect()