aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hid-tminit.c37
-rw-r--r--hid-tminit.h18
2 files changed, 43 insertions, 12 deletions
diff --git a/hid-tminit.c b/hid-tminit.c
index 464b85c..e48b419 100644
--- a/hid-tminit.c
+++ b/hid-tminit.c
@@ -1,35 +1,47 @@
-#include "hid-tm.h"
+#include "hid-tminit.h"
-u8 hw_rq_in[] = { 0xc1, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00 };
-u8 hw_rq_out[] = { 0x41, 0x53, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static void tminit_callback(struct urb *urb){ return; }
+static void tminit_callback(struct urb *urb){
+ ctx.status = urb->status;
+ hid_info(urb->dev, "urb status %d received\n", urb->status);
+}
int tminit(struct hid_device *hdev){
struct urb *urb;
+ u8 *setup_packet, *transfer_buffer;
struct device *dev = &hdev->dev;
struct usb_interface *usbif = to_usb_interface(dev->parent);
struct usb_device *usbdev = interface_to_usbdev(usbif);
+ int ret;
+
+ setup_packet = kmalloc(8, GFP_ATOMIC);
+ transfer_buffer = kmalloc(8, GFP_ATOMIC);
+
+ memcpy(setup_packet, hw_rq_out, 8);
+ memcpy(transfer_buffer, hw_rq_in, 8);
urb = usb_alloc_urb(0, GFP_ATOMIC);
usb_fill_control_urb(urb,
usbdev,
usb_sndctrlpipe(usbdev, 0),
- &hw_rq_in[0],
- &hw_rq_out[0],
+ setup_packet,
+ transfer_buffer,
0,
tminit_callback,
hdev);
/* we sort of have to go on faith that the message is sent, because the
- * wheel usually completely dies as soon as it gets the message.
+ * wheel usually completely dies as soon as it receives the message.
*/
- return usb_start_wait_urb(urb, USB_CTRL_SET_TIMEOUT, NULL);
+ ret = usb_start_wait_urb(urb, 5, NULL);
+
+ kfree(setup_packet);
+ kfree(transfer_buffer);
+ return ret;
}
static void tminit_remove(struct hid_device *hdev){
- /* we are dead */
+ /* we are dead, hopefully without any serious side effects */
hid_hw_stop(hdev);
}
@@ -50,15 +62,16 @@ static int tminit_probe(struct hid_device *hdev, const struct hid_device_id *id)
ret = tminit(hdev);
if(ret){
- hid_err(hdev, "tminit failed, possibly as it should\n");
+ hid_err(hdev, "tminit exited, error might be intended behaviour\n");
goto err;
}
+
err:
return ret;
}
static const struct hid_device_id tminit_devices[] = {
- { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb56d)},
+ { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb65d)},
{}
};
diff --git a/hid-tminit.h b/hid-tminit.h
new file mode 100644
index 0000000..cd12f9b
--- /dev/null
+++ b/hid-tminit.h
@@ -0,0 +1,18 @@
+#include "hid-tm.h"
+
+u8 hw_rq_in[] = { 0xc1, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00 };
+u8 hw_rq_out[] = { 0x41, 0x53, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+u8 setup_0[] = { 0x42, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+u8 setup_1[] = { 0x0a, 0x04, 0x90, 0x03, 0x00, 0x00, 0x00, 0x00 };
+u8 setup_2[] = { 0x0a, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00 };
+u8 setup_3[] = { 0x0a, 0x04, 0x12, 0x10, 0x00, 0x00, 0x00, 0x00 };
+u8 setup_4[] = { 0x0a, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00 };
+u8 *setup_arr[] = { setup_0, setup_1, setup_2, setup_3, setup_4 };
+unsigned int setup_arr_sizes[] = {
+ ARRAY_SIZE(setup_0),
+ ARRAY_SIZE(setup_1),
+ ARRAY_SIZE(setup_2),
+ ARRAY_SIZE(setup_3),
+ ARRAY_SIZE(setup_4)
+};