From 5ae25b0620e2601244114ac795598df1392f2f38 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Fri, 10 Jul 2020 20:24:23 +0300 Subject: usable state --- compile_commands.json | 40 +++++++++++------------------- hid-tminit.ko | Bin 0 -> 419984 bytes hid-tminit.mod | 2 ++ hid-tminit.mod.c | 55 +++++++++++++++++++++++++++++++++++++++++ hid-tminit.mod.o | Bin 0 -> 143264 bytes hid-tminit.o | Bin 0 -> 278312 bytes hid-tmt300rs.c | 41 ++++++++++++++++++++++++------ hid-tmt300rs.ko | Bin 0 -> 533720 bytes hid-tmt300rs.mod | 2 ++ hid-tmt300rs.mod.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ hid-tmt300rs.mod.o | Bin 0 -> 144040 bytes hid-tmt300rs.o | Bin 0 -> 391280 bytes modules.order | 4 +-- 13 files changed, 176 insertions(+), 35 deletions(-) create mode 100644 hid-tminit.ko create mode 100644 hid-tminit.mod create mode 100644 hid-tminit.mod.c create mode 100644 hid-tminit.mod.o create mode 100644 hid-tminit.o create mode 100644 hid-tmt300rs.ko create mode 100644 hid-tmt300rs.mod create mode 100644 hid-tmt300rs.mod.c create mode 100644 hid-tmt300rs.mod.o create mode 100644 hid-tmt300rs.o diff --git a/compile_commands.json b/compile_commands.json index 56b8bee..a75ead3 100644 --- a/compile_commands.json +++ b/compile_commands.json @@ -1,24 +1,24 @@ [ { "arguments": [ - "gcc", + "gcc-9", "-c", - "-Wp,-MD,/home/kimi/Documents/tmff2/.hid-tmt300rs.o.d", + "-Wp,-MD,/home/kimi/Documents/Projects/hid-tmff2/.hid-tmt300rs.o.d", "-nostdinc", "-isystem", "/usr/lib/gcc/x86_64-linux-gnu/9/include", - "-I./arch/x86/include", + "-I/usr/src/linux-headers-5.7.0-1-common/arch/x86/include", "-I./arch/x86/include/generated", + "-I/usr/src/linux-headers-5.7.0-1-common/include", "-I./include", - "-I./arch/x86/include/uapi", + "-I/usr/src/linux-headers-5.7.0-1-common/arch/x86/include/uapi", "-I./arch/x86/include/generated/uapi", - "-I./include/uapi", + "-I/usr/src/linux-headers-5.7.0-1-common/include/uapi", "-I./include/generated/uapi", "-include", - "./include/linux/kconfig.h", - "-Iubuntu/include", + "/usr/src/linux-headers-5.7.0-1-common/include/linux/kconfig.h", "-include", - "./include/linux/compiler_types.h", + "/usr/src/linux-headers-5.7.0-1-common/include/linux/compiler_types.h", "-D__KERNEL__", "-Wall", "-Wundef", @@ -48,15 +48,6 @@ "-mno-red-zone", "-mcmodel=kernel", "-DCONFIG_X86_X32_ABI", - "-DCONFIG_AS_CFI=1", - "-DCONFIG_AS_CFI_SIGNAL_FRAME=1", - "-DCONFIG_AS_CFI_SECTIONS=1", - "-DCONFIG_AS_SSSE3=1", - "-DCONFIG_AS_AVX=1", - "-DCONFIG_AS_AVX2=1", - "-DCONFIG_AS_AVX512=1", - "-DCONFIG_AS_SHA1_NI=1", - "-DCONFIG_AS_SHA256_NI=1", "-Wno-sign-compare", "-fno-asynchronous-unwind-tables", "-mindirect-branch=thunk-extern", @@ -69,14 +60,13 @@ "-Wno-address-of-packed-member", "-O2", "--param=allow-store-data-races=0", - "-Wframe-larger-than=1024", + "-Wframe-larger-than=2048", "-fstack-protector-strong", "-Wno-unused-but-set-variable", "-Wimplicit-fallthrough", "-Wno-unused-const-variable", - "-fno-omit-frame-pointer", - "-fno-optimize-sibling-calls", "-fno-var-tracking-assignments", + "-g", "-pg", "-mrecord-mcount", "-mfentry", @@ -98,17 +88,17 @@ "-Werror=date-time", "-Werror=incompatible-pointer-types", "-Werror=designated-init", - "-fmacro-prefix-map=./=", + "-fmacro-prefix-map=/usr/src/linux-headers-5.7.0-1-common/=", "-fcf-protection=none", "-Wno-packed-not-aligned", "-DMODULE", "-DKBUILD_BASENAME=\"hid_tmt300rs\"", "-DKBUILD_MODNAME=\"hid_tmt300rs\"", "-o", - "/home/kimi/Documents/tmff2/hid-tmt300rs.o", - "../../../home/kimi/Documents/tmff2/hid-tmt300rs.c" + "/home/kimi/Documents/Projects/hid-tmff2/hid-tmt300rs.o", + "../../../home/kimi/Documents/Projects/hid-tmff2/hid-tmt300rs.c" ], - "directory": "/usr/src/linux-headers-5.4.0-40-generic", - "file": "../../../home/kimi/Documents/tmff2/hid-tmt300rs.c" + "directory": "/usr/src/linux-headers-5.7.0-1-amd64", + "file": "../../../home/kimi/Documents/Projects/hid-tmff2/hid-tmt300rs.c" } ] \ No newline at end of file diff --git a/hid-tminit.ko b/hid-tminit.ko new file mode 100644 index 0000000..f7a0f97 Binary files /dev/null and b/hid-tminit.ko differ diff --git a/hid-tminit.mod b/hid-tminit.mod new file mode 100644 index 0000000..821c012 --- /dev/null +++ b/hid-tminit.mod @@ -0,0 +1,2 @@ +/home/kimi/Documents/Projects/hid-tmff2/hid-tminit.o + diff --git a/hid-tminit.mod.c b/hid-tminit.mod.c new file mode 100644 index 0000000..7029581 --- /dev/null +++ b/hid-tminit.mod.c @@ -0,0 +1,55 @@ +#include +#include +#include +#include + +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 + +static const struct modversion_info ____versions[] +__used __section(__versions) = { + { 0x7ca88ad8, "module_layout" }, + { 0x817489f6, "hid_unregister_driver" }, + { 0xb7aa9422, "__hid_register_driver" }, + { 0x414fc2a1, "hid_hw_start" }, + { 0xcd9e657d, "hid_open_report" }, + { 0x316d1bda, "_dev_err" }, + { 0xdecd0b29, "__stack_chk_fail" }, + { 0x37a0cba, "kfree" }, + { 0x82fea2ff, "usb_alloc_urb" }, + { 0xc30561e7, "usb_interrupt_msg" }, + { 0x69acdf38, "memcpy" }, + { 0xc27f683d, "kmem_cache_alloc_trace" }, + { 0x46a9479b, "kmalloc_caches" }, + { 0x70bce9a, "__dynamic_dev_dbg" }, + { 0xfeba7354, "current_task" }, + { 0x648538a5, "usb_kill_urb" }, + { 0x7f02188f, "__msecs_to_jiffies" }, + { 0xadd72fe9, "usb_free_urb" }, + { 0x4a3ad70e, "wait_for_completion_timeout" }, + { 0xedb8a9, "usb_submit_urb" }, + { 0x608741b5, "__init_swait_queue_head" }, + { 0x4a0c79b0, "hid_hw_stop" }, + { 0x59e59766, "_dev_info" }, + { 0xbdfb6dbb, "__fentry__" }, +}; + +MODULE_INFO(depends, "hid,usbcore"); + +MODULE_ALIAS("hid:b0003g*v0000044Fp0000B65D"); diff --git a/hid-tminit.mod.o b/hid-tminit.mod.o new file mode 100644 index 0000000..ae7e374 Binary files /dev/null and b/hid-tminit.mod.o differ diff --git a/hid-tminit.o b/hid-tminit.o new file mode 100644 index 0000000..ae3404b Binary files /dev/null and b/hid-tminit.o differ diff --git a/hid-tmt300rs.c b/hid-tmt300rs.c index e29ede8..39747cd 100644 --- a/hid-tmt300rs.c +++ b/hid-tmt300rs.c @@ -124,10 +124,15 @@ static int t300rs_upload_constant(struct t300rs_device_entry *t300rs, struct t30 u16 duration, le_offset, le_duration; int ret, trans; - + + /* currently this driver doesn't support dynamic effect updating quite like + * many games would assume. There's not a huge drawback to this method, the + * wheel maybe feels a bit more jittery because of this but it's not a + * massive downside. At some point in the future I'd like to improve the + * dynamic updating, but this will do for now. + * */ if(test_bit(FF_EFFECT_PLAYING, &state->flags)){ t300rs_stop_effect(t300rs, state); - __clear_bit(FF_EFFECT_PLAYING, &state->flags); } level = (constant.level * fixp_sin16(effect.direction * 360 / 0x10000)) / 0x7fff; @@ -162,6 +167,11 @@ static int t300rs_upload_constant(struct t300rs_device_entry *t300rs, struct t30 if(ret){ hid_err(t300rs->hdev, "failed uploading constant effect\n"); } + + if(test_bit(FF_EFFECT_PLAYING, &state->flags)){ + t300rs_play_effect(t300rs, state); + } + kfree(send_buffer); return ret; } @@ -176,7 +186,6 @@ static int t300rs_upload_ramp(struct t300rs_device_entry *t300rs, struct t300rs_ if(test_bit(FF_EFFECT_PLAYING, &state->flags)){ t300rs_stop_effect(t300rs, state); - __clear_bit(FF_EFFECT_PLAYING, &state->flags); } top = ramp.end_level > ramp.start_level ? ramp.end_level : ramp.start_level; @@ -225,6 +234,11 @@ static int t300rs_upload_ramp(struct t300rs_device_entry *t300rs, struct t300rs_ if(ret){ hid_err(t300rs->hdev, "failed uploading ramp"); } + + if(test_bit(FF_EFFECT_PLAYING, &state->flags)){ + t300rs_play_effect(t300rs, state); + } + kfree(send_buffer); return ret; } @@ -240,7 +254,6 @@ static int t300rs_upload_spring(struct t300rs_device_entry *t300rs, struct t300r if(test_bit(FF_EFFECT_PLAYING, &state->flags)){ t300rs_stop_effect(t300rs, state); - __clear_bit(FF_EFFECT_PLAYING, &state->flags); } send_buffer[0] = 0x60; @@ -284,6 +297,11 @@ static int t300rs_upload_spring(struct t300rs_device_entry *t300rs, struct t300r if(ret){ hid_err(t300rs->hdev, "failed uploading spring\n"); } + + if(test_bit(FF_EFFECT_PLAYING, &state->flags)){ + t300rs_play_effect(t300rs, state); + } + kfree(send_buffer); return ret; } @@ -299,7 +317,6 @@ static int t300rs_upload_damper(struct t300rs_device_entry *t300rs, struct t300r if(test_bit(FF_EFFECT_PLAYING, &state->flags)){ t300rs_stop_effect(t300rs, state); - __clear_bit(FF_EFFECT_PLAYING, &state->flags); } send_buffer[0] = 0x60; @@ -343,6 +360,11 @@ static int t300rs_upload_damper(struct t300rs_device_entry *t300rs, struct t300r if(ret){ hid_err(t300rs->hdev, "failed uploading spring\n"); } + + if(test_bit(FF_EFFECT_PLAYING, &state->flags)){ + t300rs_play_effect(t300rs, state); + } + kfree(send_buffer); return ret; } @@ -357,7 +379,6 @@ static int t300rs_upload_periodic(struct t300rs_device_entry *t300rs, struct t30 if(test_bit(FF_EFFECT_PLAYING, &state->flags)){ t300rs_stop_effect(t300rs, state); - __clear_bit(FF_EFFECT_PLAYING, &state->flags); } magnitude = (periodic.magnitude * fixp_sin16(effect.direction * 360 / 0x10000)) / 0x7fff; @@ -406,7 +427,11 @@ static int t300rs_upload_periodic(struct t300rs_device_entry *t300rs, struct t30 if(ret){ hid_err(t300rs->hdev, "failed uploading periodic effect"); } - + + if(test_bit(FF_EFFECT_PLAYING, &state->flags)){ + t300rs_play_effect(t300rs, state); + } + kfree(send_buffer); return ret; } @@ -426,7 +451,7 @@ static int t300rs_upload_effect(struct t300rs_device_entry *t300rs, struct t300r case FF_PERIODIC: return t300rs_upload_periodic(t300rs, state); default: - hid_err(t300rs->hdev, "invalid effect type"); + hid_err(t300rs->hdev, "invalid effect type: %x", state->effect.type); return -1; } } diff --git a/hid-tmt300rs.ko b/hid-tmt300rs.ko new file mode 100644 index 0000000..39f2a45 Binary files /dev/null and b/hid-tmt300rs.ko differ diff --git a/hid-tmt300rs.mod b/hid-tmt300rs.mod new file mode 100644 index 0000000..8a429e9 --- /dev/null +++ b/hid-tmt300rs.mod @@ -0,0 +1,2 @@ +/home/kimi/Documents/Projects/hid-tmff2/hid-tmt300rs.o + diff --git a/hid-tmt300rs.mod.c b/hid-tmt300rs.mod.c new file mode 100644 index 0000000..25ad51d --- /dev/null +++ b/hid-tmt300rs.mod.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include + +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 + +static const struct modversion_info ____versions[] +__used __section(__versions) = { + { 0x7ca88ad8, "module_layout" }, + { 0x817489f6, "hid_unregister_driver" }, + { 0xb7aa9422, "__hid_register_driver" }, + { 0x414fc2a1, "hid_hw_start" }, + { 0xcd9e657d, "hid_open_report" }, + { 0x59e59766, "_dev_info" }, + { 0x1ee7d3cd, "hrtimer_init" }, + { 0x7d42edf, "device_create_file" }, + { 0xb3e1146a, "input_ff_create" }, + { 0x70bce9a, "__dynamic_dev_dbg" }, + { 0xfeba7354, "current_task" }, + { 0x648538a5, "usb_kill_urb" }, + { 0x7f02188f, "__msecs_to_jiffies" }, + { 0x4a3ad70e, "wait_for_completion_timeout" }, + { 0x608741b5, "__init_swait_queue_head" }, + { 0xdecd0b29, "__stack_chk_fail" }, + { 0xdc21e866, "hrtimer_forward" }, + { 0x20000329, "simple_strtoul" }, + { 0x2ea2c95c, "__x86_indirect_thunk_rax" }, + { 0xc27f683d, "kmem_cache_alloc_trace" }, + { 0x46a9479b, "kmalloc_caches" }, + { 0xedb8a9, "usb_submit_urb" }, + { 0x82fea2ff, "usb_alloc_urb" }, + { 0x37a0cba, "kfree" }, + { 0x4a0c79b0, "hid_hw_stop" }, + { 0xa0c6befa, "hrtimer_cancel" }, + { 0x9c59e5d5, "device_remove_file" }, + { 0xfbdfc558, "hrtimer_start_range_ns" }, + { 0xb4ff6bb6, "hrtimer_active" }, + { 0x15ba50a6, "jiffies" }, + { 0xc85d768e, "_dev_warn" }, + { 0xadd72fe9, "usb_free_urb" }, + { 0x316d1bda, "_dev_err" }, + { 0x3812050a, "_raw_spin_unlock_irqrestore" }, + { 0x51760917, "_raw_spin_lock_irqsave" }, + { 0xbdfb6dbb, "__fentry__" }, +}; + +MODULE_INFO(depends, "hid,usbcore"); + +MODULE_ALIAS("hid:b0003g*v0000044Fp0000B66E"); diff --git a/hid-tmt300rs.mod.o b/hid-tmt300rs.mod.o new file mode 100644 index 0000000..6f6c16d Binary files /dev/null and b/hid-tmt300rs.mod.o differ diff --git a/hid-tmt300rs.o b/hid-tmt300rs.o new file mode 100644 index 0000000..7cf277f Binary files /dev/null and b/hid-tmt300rs.o differ diff --git a/modules.order b/modules.order index 0be5217..a0e2376 100644 --- a/modules.order +++ b/modules.order @@ -1,2 +1,2 @@ -/home/kimi/Documents/tmff2/hid-tminit.ko -/home/kimi/Documents/tmff2/hid-tmt300rs.ko +/home/kimi/Documents/Projects/hid-tmff2/hid-tminit.ko +/home/kimi/Documents/Projects/hid-tmff2/hid-tmt300rs.ko -- cgit v1.3