aboutsummaryrefslogtreecommitdiff
path: root/hid-tminit.c
diff options
context:
space:
mode:
authorkimi <kimi.h.kuparinen@gmail.com>2020-07-08 13:38:00 -0400
committerkimi <kimi.h.kuparinen@gmail.com>2020-07-08 13:38:00 -0400
commit9d17b5ed83e46122966d663b0bb05e82fb9dd01c (patch)
tree48ddbdad82f97c863a94a3445d8316e11c81dbf2 /hid-tminit.c
parentdb12c7bead4154929668badaade14db135dab6d9 (diff)
downloadhid-tmff2-9d17b5ed83e46122966d663b0bb05e82fb9dd01c.tar.gz
hid-tmff2-9d17b5ed83e46122966d663b0bb05e82fb9dd01c.zip
added first version of generic Thrustmaster FFB device driver
Diffstat (limited to 'hid-tminit.c')
-rw-r--r--hid-tminit.c37
1 files changed, 25 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)},
{}
};