aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile7
-rw-r--r--Module.symvers0
-rw-r--r--hid-tmff2.c155
-rw-r--r--hid-tmff2.kobin0 -> 15384 bytes
-rw-r--r--hid-tmff2.mod2
-rw-r--r--hid-tmff2.mod.c40
-rw-r--r--hid-tmff2.mod.obin0 -> 3776 bytes
-rw-r--r--hid-tmff2.obin0 -> 12552 bytes
-rw-r--r--modules.order1
9 files changed, 151 insertions, 54 deletions
diff --git a/Makefile b/Makefile
index 296c24f..ba704a9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,8 @@
obj-m += hid-tmff2.o
all:
- make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
-
+ make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) modules
+install:
+ make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) modules_install
clean:
- make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
+ make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) clean
diff --git a/Module.symvers b/Module.symvers
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Module.symvers
diff --git a/hid-tmff2.c b/hid-tmff2.c
index bb03df4..7b1a4f7 100644
--- a/hid-tmff2.c
+++ b/hid-tmff2.c
@@ -62,17 +62,28 @@ static unsigned int setup_arr_sizes[] = {
static u8 hw_rq_in[] = { 0xc1, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00 };
static u8 hw_rq_out[] = { 0x41, 0x53, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static u8 ff_constant_array[] = {
+ 0x60, 0x00, 0x01, 0x0a, 0xff, 0xdf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
struct tmff_device {
struct hid_report *report;
struct hid_field *ff_field;
+ spinlock_t report_lock;
};
+static spinlock_t *report_lock;
+static int flags;
+
struct api_context {
struct completion done;
int status;
};
+static struct api_context ctx;
+
/* Changes values from 0 to 0xffff into values from minimum to maximum */
static inline int tmff_scale_u16(unsigned int in, int minimum, int maximum)
{
@@ -99,71 +110,24 @@ static inline int tmff_scale_s8(int in, int minimum, int maximum)
return ret;
}
-static int tmff_play(struct input_dev *dev, void *data,
- struct ff_effect *effect)
-{
- struct hid_device *hid = input_get_drvdata(dev);
- struct tmff_device *tmff = data;
- struct hid_field *ff_field = tmff->ff_field;
- int x, y;
- int left, right; /* Rumbling */
- int motor_swap;
-
- switch (effect->type) {
- case FF_CONSTANT:
- x = tmff_scale_s8(effect->u.ramp.start_level,
- ff_field->logical_minimum,
- ff_field->logical_maximum);
- y = tmff_scale_s8(effect->u.ramp.end_level,
- ff_field->logical_minimum,
- ff_field->logical_maximum);
-
- dbg_hid("(x, y)=(%04x, %04x)\n", x, y);
- ff_field->value[0] = x;
- ff_field->value[1] = y;
- hid_hw_request(hid, tmff->report, HID_REQ_SET_REPORT);
- break;
-
- case FF_RUMBLE:
- left = tmff_scale_u16(effect->u.rumble.weak_magnitude,
- ff_field->logical_minimum,
- ff_field->logical_maximum);
- right = tmff_scale_u16(effect->u.rumble.strong_magnitude,
- ff_field->logical_minimum,
- ff_field->logical_maximum);
-
- /* 2-in-1 strong motor is left */
- if (hid->product == THRUSTMASTER_DEVICE_ID_2_IN_1_DT) {
- motor_swap = left;
- left = right;
- right = motor_swap;
- }
-
- dbg_hid("(left,right)=(%08x, %08x)\n", left, right);
- ff_field->value[0] = left;
- ff_field->value[1] = right;
- hid_hw_request(hid, tmff->report, HID_REQ_SET_REPORT);
- break;
- }
- return 0;
-}
-
static void tmff_ctrl(struct urb *urb){
if(urb->status){
hid_warn(urb->dev, "urb status %d received\n", urb->status);
}
+ usb_free_urb(urb);
+ spin_unlock_irqrestore(report_lock, flags);
}
static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length)
{
- struct api_context ctx;
+
unsigned long expire;
int retval;
init_completion(&ctx.done);
urb->context = &ctx;
urb->actual_length = 0;
- retval = usb_submit_urb(urb, GFP_NOIO);
+ retval = usb_submit_urb(urb, GFP_ATOMIC);
if (unlikely(retval))
goto out;
@@ -189,6 +153,93 @@ out:
return retval;
}
+static int tmff_play(struct input_dev *dev, void *data,
+ struct ff_effect *effect)
+{
+ spin_lock_irqsave(report_lock, flags);
+ printk("Reached debug point 1");
+ struct hid_device *hid = input_get_drvdata(dev);
+ struct tmff_device *tmff = data;
+ struct hid_field *ff_field = tmff->ff_field;
+ int x, y;
+ int left, right; /* Rumbling */
+
+ printk("Reached debug point 2");
+ int trans, b_ep, err;
+ unsigned long flags;
+ struct device *d_dev = &hid->dev;
+ struct usb_interface *usbif = to_usb_interface(d_dev->parent);
+ struct usb_device *usbdev = interface_to_usbdev(usbif);
+ struct usb_host_endpoint *ep;
+
+ struct urb *urb = usb_alloc_urb(0, GFP_ATOMIC);
+
+ printk("Reached debug point 3");
+ u8 *send_buf = kmalloc(1024, GFP_ATOMIC);
+ memcpy(send_buf, ff_constant_array, ARRAY_SIZE(ff_constant_array));
+
+ ep = &usbif->cur_altsetting->endpoint[1];
+ b_ep = ep->desc.bEndpointAddress;
+
+ printk("Reached debug point 4");
+ switch (effect->type) {
+ case FF_CONSTANT:
+
+ printk("Reached debug point 5");
+
+ x = tmff_scale_s8(effect->u.ramp.start_level,
+ ff_field->logical_minimum,
+ ff_field->logical_maximum);
+ y = tmff_scale_s8(effect->u.ramp.end_level,
+ ff_field->logical_minimum,
+ ff_field->logical_maximum);
+
+ printk("(x, y)=(%04x, %04x)\n", x, y);
+ //send_buf[4] = x;
+ //send_buf[5] = y;
+
+ printk("Reached debug point 6");
+
+ usb_fill_int_urb(
+ urb,
+ usbdev,
+ usb_sndintpipe(usbdev, 1),
+ send_buf,
+ ARRAY_SIZE(ff_constant_array),
+ tmff_ctrl,
+ hid,
+ ep->desc.bInterval
+ );
+
+ printk("Reached debug point yeet");
+ /*err = usb_start_wait_urb(urb, 1, &trans);
+ if(err){
+ hid_err(hid, "Failed sending thing with ERRNO: %i", err);
+ }*/
+ usb_submit_urb(urb, GFP_KERNEL);
+
+ printk("Reached debug point wooot");
+
+ /*usb_interrupt_msg(usbdev,
+ usb_sndintpipe(usbdev, b_ep),
+ send_buf,
+ ARRAY_SIZE(ff_constant_array),
+ &trans,
+ USB_CTRL_SET_TIMEOUT);*/
+
+ printk("Reached debug point 7");
+ break;
+ }
+ printk("Reached debug point X");
+ kfree(send_buf);
+ return 0;
+}
+
+static int tmff_init_t300rs(struct hid_device *hid){
+
+ return 0;
+}
+
static int tmff_clear_init(struct hid_device *hid){
/* die */
@@ -278,6 +329,8 @@ static int tmff_init(struct hid_device *hid, const signed short *ff_bits)
if (!tmff)
return -ENOMEM;
+ spin_lock_init(&tmff->report_lock);
+ report_lock = &tmff->report_lock;
/* Find the report to use */
report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
diff --git a/hid-tmff2.ko b/hid-tmff2.ko
new file mode 100644
index 0000000..c2141d9
--- /dev/null
+++ b/hid-tmff2.ko
Binary files differ
diff --git a/hid-tmff2.mod b/hid-tmff2.mod
new file mode 100644
index 0000000..97abfee
--- /dev/null
+++ b/hid-tmff2.mod
@@ -0,0 +1,2 @@
+/home/kimi/Documents/tmff2/hid-tmff2.o
+
diff --git a/hid-tmff2.mod.c b/hid-tmff2.mod.c
new file mode 100644
index 0000000..68341e4
--- /dev/null
+++ b/hid-tmff2.mod.c
@@ -0,0 +1,40 @@
+#include <linux/build-salt.h>
+#include <linux/module.h>
+#include <linux/vermagic.h>
+#include <linux/compiler.h>
+
+BUILD_SALT;
+
+MODULE_INFO(vermagic, VERMAGIC_STRING);
+MODULE_INFO(name, KBUILD_MODNAME);
+
+__visible struct module __this_module
+__section(.gnu.linkonce.this_module) = {
+ .name = KBUILD_MODNAME,
+ .init = init_module,
+#ifdef CONFIG_MODULE_UNLOAD
+ .exit = cleanup_module,
+#endif
+ .arch = MODULE_ARCH_INIT,
+};
+
+#ifdef CONFIG_RETPOLINE
+MODULE_INFO(retpoline, "Y");
+#endif
+
+MODULE_INFO(depends, "hid,ff-memless");
+
+MODULE_ALIAS("hid:b0003g*v0000044Fp0000B300");
+MODULE_ALIAS("hid:b0003g*v0000044Fp0000B304");
+MODULE_ALIAS("hid:b0003g*v0000044Fp0000B320");
+MODULE_ALIAS("hid:b0003g*v0000044Fp0000B323");
+MODULE_ALIAS("hid:b0003g*v0000044Fp0000B324");
+MODULE_ALIAS("hid:b0003g*v0000044Fp0000B605");
+MODULE_ALIAS("hid:b0003g*v0000044Fp0000B651");
+MODULE_ALIAS("hid:b0003g*v0000044Fp0000B653");
+MODULE_ALIAS("hid:b0003g*v0000044Fp0000B654");
+MODULE_ALIAS("hid:b0003g*v0000044Fp0000B65A");
+MODULE_ALIAS("hid:b0003g*v0000044Fp0000B65D");
+MODULE_ALIAS("hid:b0003g*v0000044Fp0000B66E");
+
+MODULE_INFO(srcversion, "091792E1528C81AB03360D4");
diff --git a/hid-tmff2.mod.o b/hid-tmff2.mod.o
new file mode 100644
index 0000000..ee5ef47
--- /dev/null
+++ b/hid-tmff2.mod.o
Binary files differ
diff --git a/hid-tmff2.o b/hid-tmff2.o
new file mode 100644
index 0000000..7d74c0e
--- /dev/null
+++ b/hid-tmff2.o
Binary files differ
diff --git a/modules.order b/modules.order
new file mode 100644
index 0000000..6c3d9bd
--- /dev/null
+++ b/modules.order
@@ -0,0 +1 @@
+/home/kimi/Documents/tmff2/hid-tmff2.ko