From db12c7bead4154929668badaade14db135dab6d9 Mon Sep 17 00:00:00 2001 From: kimi Date: Wed, 8 Jul 2020 11:17:48 -0400 Subject: initial commit for memory --- compile_commands.json | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) (limited to 'compile_commands.json') diff --git a/compile_commands.json b/compile_commands.json index 0ac6efe..ea1a16a 100644 --- a/compile_commands.json +++ b/compile_commands.json @@ -1,24 +1,24 @@ [ { "arguments": [ - "gcc-9", + "gcc", "-c", - "-Wp,-MD,/home/kimi/Documents/Projects/hid-tmff2/.hid-tmff2.o.d", + "-Wp,-MD,/home/kimi/Documents/tmff2/.hid-tminit.o.d", "-nostdinc", "-isystem", "/usr/lib/gcc/x86_64-linux-gnu/9/include", - "-I/usr/src/linux-headers-5.7.0-1-common/arch/x86/include", + "-I./arch/x86/include", "-I./arch/x86/include/generated", - "-I/usr/src/linux-headers-5.7.0-1-common/include", "-I./include", - "-I/usr/src/linux-headers-5.7.0-1-common/arch/x86/include/uapi", + "-I./arch/x86/include/uapi", "-I./arch/x86/include/generated/uapi", - "-I/usr/src/linux-headers-5.7.0-1-common/include/uapi", + "-I./include/uapi", "-I./include/generated/uapi", "-include", - "/usr/src/linux-headers-5.7.0-1-common/include/linux/kconfig.h", + "./include/linux/kconfig.h", + "-Iubuntu/include", "-include", - "/usr/src/linux-headers-5.7.0-1-common/include/linux/compiler_types.h", + "./include/linux/compiler_types.h", "-D__KERNEL__", "-Wall", "-Wundef", @@ -48,6 +48,15 @@ "-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", @@ -60,13 +69,14 @@ "-Wno-address-of-packed-member", "-O2", "--param=allow-store-data-races=0", - "-Wframe-larger-than=2048", + "-Wframe-larger-than=1024", "-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", @@ -88,17 +98,17 @@ "-Werror=date-time", "-Werror=incompatible-pointer-types", "-Werror=designated-init", - "-fmacro-prefix-map=/usr/src/linux-headers-5.7.0-1-common/=", + "-fmacro-prefix-map=./=", "-fcf-protection=none", "-Wno-packed-not-aligned", "-DMODULE", - "-DKBUILD_BASENAME=\"hid_tmff2\"", - "-DKBUILD_MODNAME=\"hid_tmff2\"", + "-DKBUILD_BASENAME=\"hid_tminit\"", + "-DKBUILD_MODNAME=\"hid_tminit\"", "-o", - "/home/kimi/Documents/Projects/hid-tmff2/hid-tmff2.o", - "../../../home/kimi/Documents/Projects/hid-tmff2/hid-tmff2.c" + "/home/kimi/Documents/tmff2/hid-tminit.o", + "../../../home/kimi/Documents/tmff2/hid-tminit.c" ], - "directory": "/usr/src/linux-headers-5.7.0-1-amd64", - "file": "../../../home/kimi/Documents/Projects/hid-tmff2/hid-tmff2.c" + "directory": "/usr/src/linux-headers-5.4.0-40-generic", + "file": "../../../home/kimi/Documents/tmff2/hid-tminit.c" } ] \ No newline at end of file -- cgit v1.3 From 1ce1a2445a6189637226434fb18942429679c9ef Mon Sep 17 00:00:00 2001 From: kimi Date: Wed, 8 Jul 2020 13:38:34 -0400 Subject: remove old test code --- compile_commands.json | 114 ------- hid-tmff2.c | 872 -------------------------------------------------- 2 files changed, 986 deletions(-) delete mode 100644 compile_commands.json delete mode 100644 hid-tmff2.c (limited to 'compile_commands.json') diff --git a/compile_commands.json b/compile_commands.json deleted file mode 100644 index ea1a16a..0000000 --- a/compile_commands.json +++ /dev/null @@ -1,114 +0,0 @@ -[ - { - "arguments": [ - "gcc", - "-c", - "-Wp,-MD,/home/kimi/Documents/tmff2/.hid-tminit.o.d", - "-nostdinc", - "-isystem", - "/usr/lib/gcc/x86_64-linux-gnu/9/include", - "-I./arch/x86/include", - "-I./arch/x86/include/generated", - "-I./include", - "-I./arch/x86/include/uapi", - "-I./arch/x86/include/generated/uapi", - "-I./include/uapi", - "-I./include/generated/uapi", - "-include", - "./include/linux/kconfig.h", - "-Iubuntu/include", - "-include", - "./include/linux/compiler_types.h", - "-D__KERNEL__", - "-Wall", - "-Wundef", - "-Werror=strict-prototypes", - "-Wno-trigraphs", - "-fno-strict-aliasing", - "-fno-common", - "-fshort-wchar", - "-fno-PIE", - "-Werror=implicit-function-declaration", - "-Werror=implicit-int", - "-Wno-format-security", - "-std=gnu89", - "-mno-sse", - "-mno-mmx", - "-mno-sse2", - "-mno-3dnow", - "-mno-avx", - "-m64", - "-falign-jumps=1", - "-falign-loops=1", - "-mno-80387", - "-mno-fp-ret-in-387", - "-mpreferred-stack-boundary=3", - "-mskip-rax-setup", - "-mtune=generic", - "-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", - "-mindirect-branch-register", - "-fno-jump-tables", - "-fno-delete-null-pointer-checks", - "-Wno-frame-address", - "-Wno-format-truncation", - "-Wno-format-overflow", - "-Wno-address-of-packed-member", - "-O2", - "--param=allow-store-data-races=0", - "-Wframe-larger-than=1024", - "-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", - "-pg", - "-mrecord-mcount", - "-mfentry", - "-DCC_USING_FENTRY", - "-flive-patching=inline-clone", - "-Wdeclaration-after-statement", - "-Wvla", - "-Wno-pointer-sign", - "-Wno-stringop-truncation", - "-Wno-array-bounds", - "-Wno-stringop-overflow", - "-Wno-restrict", - "-Wno-maybe-uninitialized", - "-fno-strict-overflow", - "-fno-merge-all-constants", - "-fmerge-constants", - "-fno-stack-check", - "-fconserve-stack", - "-Werror=date-time", - "-Werror=incompatible-pointer-types", - "-Werror=designated-init", - "-fmacro-prefix-map=./=", - "-fcf-protection=none", - "-Wno-packed-not-aligned", - "-DMODULE", - "-DKBUILD_BASENAME=\"hid_tminit\"", - "-DKBUILD_MODNAME=\"hid_tminit\"", - "-o", - "/home/kimi/Documents/tmff2/hid-tminit.o", - "../../../home/kimi/Documents/tmff2/hid-tminit.c" - ], - "directory": "/usr/src/linux-headers-5.4.0-40-generic", - "file": "../../../home/kimi/Documents/tmff2/hid-tminit.c" - } -] \ No newline at end of file diff --git a/hid-tmff2.c b/hid-tmff2.c deleted file mode 100644 index b26185f..0000000 --- a/hid-tmff2.c +++ /dev/null @@ -1,872 +0,0 @@ -/*This file has been modified from the Linux kernel driver drivers/hid/hid-tmff.c, starting from May 7 2020*/ - -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * Force feedback support for various HID compliant devices by ThrustMaster: - * ThrustMaster FireStorm Dual Power 2 - * and possibly others whose device ids haven't been added. - * - * Modified to support ThrustMaster devices by Zinx Verituse - * on 2003-01-25 from the Logitech force feedback driver, - * which is by Johann Deneux. - * - * Copyright (c) 2003 Zinx Verituse - * Copyright (c) 2002 Johann Deneux - */ - -/* -*/ - -#include -#include -#include -#include -#include - -#define USB_VENDOR_ID_THRUSTMASTER 0x044f -#define THRUSTMASTER_DEVICE_ID_2_IN_1_DT 0xb320 -#define URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL 0x001e - -unsigned long last = 0; - -static const signed short ff_rumble[] = { - FF_RUMBLE, - -1 -}; - -static const signed short ff_constant[] = { - FF_CONSTANT, - -1 -}; - -static const signed short ff_joystick[] = { - FF_CONSTANT, - -1 -}; - -#ifdef CONFIG_THRUSTMASTER_FF - -/* Usages for thrustmaster devices I know about */ -#define THRUSTMASTER_USAGE_FF (HID_UP_GENDESK | 0xbb) - -u16 tmff_gain = 0xffff; - -static u8 setup_0[] = { 0x42, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static u8 setup_1[] = { 0x0a, 0x04, 0x90, 0x03, 0x00, 0x00, 0x00, 0x00 }; -static u8 setup_2[] = { 0x0a, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00 }; -static u8 setup_3[] = { 0x0a, 0x04, 0x12, 0x10, 0x00, 0x00, 0x00, 0x00 }; -static u8 setup_4[] = { 0x0a, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00 }; -static u8 *setup_arr[] = { setup_0, setup_1, setup_2, setup_3, setup_4 }; -static 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) -}; - -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, 0xbf, 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, -}; - -static u8 ff_stop_array[] = { - 0x60, 0x00, 0x01, 0x0a, 0xfe, 0xff, 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, -}; - -static u8 t300rs_0[] = { - 0x42, 0x01, 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, 0x00, 0x00, 0x00, 0x00, - -}; - -static u8 t300rs_1[] = { - 0x0a, 0x04, 0x90, 0x03, 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, 0x00, 0x00, - -}; - -static u8 t300rs_2[] = { - 0x0a, 0x04, 0x00, 0x0c, 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, 0x00, 0x00, - -}; - -static u8 t300rs_3[] = { - 0x0a, 0x04, 0x12, 0x10, 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, 0x00, 0x00, - -}; - -static u8 t300rs_4[] = { - 0x0a, 0x04, 0x00, 0x06, 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, 0x00, 0x00, - -}; - -static u8 t300rs_re[] = { - 0x0a, 0x04, 0x00, 0x03, 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, 0x00, 0x00, -}; - -static u8 *t300rs_arr[] = { t300rs_0, t300rs_1, t300rs_2, t300rs_3, t300rs_4, }; -static unsigned int t300rs_arr_sizes[] = { - ARRAY_SIZE(t300rs_0), - ARRAY_SIZE(t300rs_1), - ARRAY_SIZE(t300rs_2), - ARRAY_SIZE(t300rs_3), - ARRAY_SIZE(t300rs_4), -}; - -static u8 t300rs_ctrl_out[] = { 0x41, 0x48, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, }; - -static u8 t300rs_ctrl_in_0[] = { 0xc1, 0x42, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, }; -static u8 t300rs_ctrl_in_1[] = { 0xc1, 0x4e, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, }; -static u8 t300rs_ctrl_in_2[] = { 0xc1, 0x56, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, }; -static u8 t300rs_ctrl_in_re[] = { 0xc1, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00 }; -static u8 *t300rs_ctrl_in_arr[] = {t300rs_ctrl_in_0, t300rs_ctrl_in_1, t300rs_ctrl_in_2 }; -static unsigned int t300rs_ctrl_in_sizes[] = { - ARRAY_SIZE(t300rs_ctrl_in_0), - ARRAY_SIZE(t300rs_ctrl_in_1), - ARRAY_SIZE(t300rs_ctrl_in_2) -}; - -static u8 t300rs_in_0[] = { 0xc1, 0x56, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, }; -static u8 t300rs_in_1[] = { 0xc1, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, }; -static u8 t300rs_in_2[] = { 0xc1, 0x48, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, }; -static u8 t300rs_in_3[] = { 0xc1, 0x55, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, }; -static u8 *t300rs_in_arr[] = {t300rs_in_0, t300rs_in_1, t300rs_in_2, t300rs_in_3}; -static unsigned int t300rs_in_sizes[] = { - ARRAY_SIZE(t300rs_in_0), - ARRAY_SIZE(t300rs_in_1), - ARRAY_SIZE(t300rs_in_2), - ARRAY_SIZE(t300rs_in_3) -}; - -static u8 t300rs_fin_0[] = { - 0x60, 0x09, 0x04, 0x04, 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, 0x00, 0x00, -}; -static u8 t300rs_fin_1[] = { - 0x60, 0x0b, 0x05, 0xbf, 0x03, 0xc3, 0x20, 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, -}; -static u8 t300rs_fin_2[] = { - 0x60, 0x01, 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, 0x00, 0x00, 0x00, 0x00, -}; -static u8 t300rs_fin_3[] = { - 0x60, 0x01, 0x05, 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, 0x00, 0x00, 0x00, -}; -static u8 t300rs_fin_4[] = { - 0x60, 0x00, 0x01, 0x6a, 0xfe, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4f, - 0xff, 0xff, 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, -}; -static u8 t300rs_fin_5[] = { - 0x60, 0x00, 0x02, 0x6b, 0xfc, 0x7f, 0xfe, 0xff, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x80, 0x00, 0x00, - 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x03, 0x4f, 0xff, 0xff, 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, -}; -static u8 t300rs_fin_6[] = { - 0x60, 0x00, 0x03, 0x64, 0xfd, 0x3f, 0xfd, 0x3f, 0x31, 0x03, 0xcb, 0xfc, 0xfd, 0x5f, 0xfd, 0x5f, - 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xdf, 0x58, 0xa6, 0x6a, 0x06, 0x4f, 0xff, 0xff, - 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, -}; - -static u8 t300rs_fin_7[] = { - 0x60, 0x00, 0x01, 0x89, 0x01, 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, 0x00, -}; - -static u8 *t300rs_fin_arr[] = {t300rs_fin_0, t300rs_fin_1, t300rs_fin_2, t300rs_fin_3, t300rs_fin_4, t300rs_fin_5, t300rs_fin_6, t300rs_fin_7 }; -static unsigned int t300rs_fin_sizes[] = { - ARRAY_SIZE(t300rs_fin_0), - ARRAY_SIZE(t300rs_fin_1), - ARRAY_SIZE(t300rs_fin_2), - ARRAY_SIZE(t300rs_fin_3), - ARRAY_SIZE(t300rs_fin_4), - ARRAY_SIZE(t300rs_fin_5), - ARRAY_SIZE(t300rs_fin_6), - ARRAY_SIZE(t300rs_fin_7) -}; - -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) -{ - int ret; - - ret = (in * (maximum - minimum) / 0xffff) + minimum; - if (ret < minimum) - return minimum; - if (ret > maximum) - return maximum; - return ret; -} - -/* Changes values from -0x80 to 0x7f into values from minimum to maximum */ -static inline int tmff_scale_s8(int in, int minimum, int maximum) -{ - int ret; - - ret = (((in + 0x80) * (maximum - minimum)) / 0xff) + minimum; - if (ret < minimum) - return minimum; - if (ret > maximum) - return maximum; - return ret; -} -bool transferred = true; -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); - transferred = true; -} - -static void tmff_init_ctrl(struct urb *urb){ - if(urb->status){ - hid_warn(urb->dev, "urb status %d received\n", urb->status); - ctx.status = urb->status; - } -} - - -static void tmff_t300rs_ctrl(struct urb *urb){ - if(urb->status){ - hid_warn(urb->dev, "urb status %d received\n", urb->status); - } -} - -static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length) -{ - - unsigned long expire; - int retval; - - printk("1"); - init_completion(&ctx.done); - urb->context = &ctx; - urb->actual_length = 0; - retval = usb_submit_urb(urb, GFP_ATOMIC); - if (unlikely(retval)) - goto out; - - printk("2"); - - expire = timeout ? msecs_to_jiffies(timeout) : MAX_SCHEDULE_TIMEOUT; - if (!wait_for_completion_timeout(&ctx.done, expire)) { - usb_kill_urb(urb); - retval = (ctx.status == -ENOENT ? -ETIMEDOUT : ctx.status); - - dev_dbg(&urb->dev->dev, - "%s timed out on ep%d%s len=%u/%u\n", - current->comm, - usb_endpoint_num(&urb->ep->desc), - usb_urb_dir_in(urb) ? "in" : "out", - urb->actual_length, - urb->transfer_buffer_length); - } else - retval = ctx.status; -out: - printk("3"); - if (actual_length) - *actual_length = urb->actual_length; - - usb_free_urb(urb); - return retval; -} - -bool last_stop = false; - -static int tmff_play(struct input_dev *dev, void *data, - struct ff_effect *effect) -{ - - //spin_lock_irqsave(report_lock, flags); - struct hid_device *hid = input_get_drvdata(dev); - 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 tmff_device *tmff = data; - struct hid_field *ff_field = tmff->ff_field; - struct urb *urb = usb_alloc_urb(0, GFP_ATOMIC); - u8 *send_buf = kmalloc(1024, GFP_ATOMIC); - __s16 x; - - if(!transferred){ - return 0; - } - - - memcpy(send_buf, ff_constant_array, ARRAY_SIZE(ff_constant_array)); - - ep = &usbif->cur_altsetting->endpoint[1]; - - switch (effect->type) { - case FF_CONSTANT: - // this only works with input_ff_create_memless, which clamps - // constant forces to s8 for some reason - x = tmff_scale_s8(effect->u.constant.level, - ff_field->logical_minimum, - ff_field->logical_maximum); - - send_buf[4] = x & 0xff; - send_buf[5] = x >> 8; - - usb_fill_int_urb( - urb, - usbdev, - usb_sndintpipe(usbdev, 1), - send_buf, - ARRAY_SIZE(ff_constant_array), - tmff_ctrl, - hid, - ep->desc.bInterval - ); - transferred = false; - usb_submit_urb(urb, GFP_ATOMIC); - - - break; - default: - break; - } - -// msleep(2); - kfree(send_buf); - return 0; -} - -static int tmff_init_t300rs(struct hid_device *hid){ - - int trans, b_ep, bb_ep, i, err; - u8 *send_buf, *rq_buf; - struct device *dev = &hid->dev; - struct usb_interface *usbif = to_usb_interface(dev->parent); - struct usb_device *usbdev = interface_to_usbdev(usbif); - struct usb_host_endpoint *ep; - struct urb *urb; - - ep = &usbif->cur_altsetting->endpoint[0]; - bb_ep = ep->desc.bEndpointAddress; - - ep = &usbif->cur_altsetting->endpoint[1]; - b_ep = ep->desc.bEndpointAddress; - - send_buf = kmalloc(256, GFP_ATOMIC); /* overkill but whatever */ - rq_buf = kmalloc(256, GFP_ATOMIC); - - for(i = 0; i < ARRAY_SIZE(t300rs_in_arr); ++i){ - memcpy(rq_buf, t300rs_in_arr[i], t300rs_in_sizes[i]); - urb = usb_alloc_urb(0, GFP_KERNEL); - usb_fill_control_urb(urb, - usbdev, - usb_rcvctrlpipe(usbdev, 0), - rq_buf, - send_buf, - 0, - tmff_t300rs_ctrl, - hid); - - err = usb_start_wait_urb(urb, 1, &trans); - if(err != 0){ - hid_err(hid, "Failed sending pre-ctrin with ERRNO: %i", err); - goto error; - } - } - - for(i = 0; i < ARRAY_SIZE(t300rs_ctrl_in_arr); ++i){ - memcpy(rq_buf, t300rs_ctrl_in_arr[i], t300rs_ctrl_in_sizes[i]); - urb = usb_alloc_urb(0, GFP_KERNEL); - usb_fill_control_urb(urb, - usbdev, - usb_rcvctrlpipe(usbdev, 0), - rq_buf, - send_buf, - 0, - tmff_t300rs_ctrl, - hid - ); - - err = usb_start_wait_urb(urb, 1, &trans); - if(err != 0){ - hid_err(hid, "Failed sending T300RS ctrl out with ERRNO: %i", err); - goto error; - } - - - } - printk("Sent initial ctrlouts"); - - for(i = 0; i < ARRAY_SIZE(t300rs_arr); ++i){ - memcpy(send_buf, t300rs_arr[i], t300rs_arr_sizes[i]); - - err = usb_interrupt_msg(usbdev, - usb_sndintpipe(usbdev, b_ep), - send_buf, - t300rs_arr_sizes[i], - &trans, - USB_CTRL_SET_TIMEOUT); - - if(err){ - hid_err(hid, "T300RS setup data at index %i couldn't be sent, ERRNO: %i\n", i, err); - goto error; - } - - err = usb_interrupt_msg(usbdev, - usb_rcvintpipe(usbdev, bb_ep), - send_buf, - 64, - &trans, - USB_CTRL_SET_TIMEOUT); - if(err != 0){ - hid_err(hid, "FUCK, ERRNO: %i", err); - goto error; - } - } - - memcpy(rq_buf, t300rs_ctrl_in_re, ARRAY_SIZE(t300rs_ctrl_in_re)); - for(i = 0; i < 16; ++i){ - urb = usb_alloc_urb(0, GFP_KERNEL); - usb_fill_control_urb(urb, - usbdev, - usb_rcvctrlpipe(usbdev, 0), - rq_buf, - send_buf, - 0, - tmff_t300rs_ctrl, - hid - ); - - err = usb_start_wait_urb(urb, 1, &trans); - if(err != 0){ - hid_err(hid, "Failed sending T300RS ctrl out with ERRNO: %i", err); - goto error; - } - } - - printk("Sent first 16 ctrlins"); - - memcpy(rq_buf, t300rs_ctrl_out, ARRAY_SIZE(t300rs_ctrl_out)); - urb = usb_alloc_urb(0, GFP_KERNEL); - usb_fill_control_urb(urb, - usbdev, - usb_sndctrlpipe(usbdev, 0), - rq_buf, - send_buf, - 0, - tmff_t300rs_ctrl, - hid - ); - - err = usb_start_wait_urb(urb, 1, &trans); - if(err != 0){ - hid_err(hid, "Failed sending ctrl out with ERRNO: %i", err); - goto error; - } - - memcpy(rq_buf, t300rs_ctrl_in_re, ARRAY_SIZE(t300rs_ctrl_in_re)); - for(i = 0; i < 8; ++i){ - urb = usb_alloc_urb(0, GFP_KERNEL); - usb_fill_control_urb(urb, - usbdev, - usb_rcvctrlpipe(usbdev, 0), - rq_buf, - send_buf, - 0, - tmff_t300rs_ctrl, - hid - ); - - err = usb_start_wait_urb(urb, 1, &trans); - if(err != 0){ - hid_err(hid, "Failed sending T300RS ctrl out with ERRNO: %i", err); - goto error; - } - } - - memcpy(send_buf, t300rs_re, ARRAY_SIZE(t300rs_re)); - - for(i = 0; i < 3; ++i){ - err = usb_interrupt_msg(usbdev, - usb_sndintpipe(usbdev, b_ep), - send_buf, - ARRAY_SIZE(t300rs_re), - &trans, - USB_CTRL_SET_TIMEOUT); - - if(err){ - hid_err(hid, "T300RS after-init data couldn't be sent, ERRNO: %i", err); - goto error; - } - } - - -error: - kfree(send_buf); - kfree(rq_buf); - - return 0; -} - -static int tmff_clear_init(struct hid_device *hid){ - /* die */ - - int trans, b_ep, i, err; - u8 *send_buf, *rq_buf; - struct device *dev = &hid->dev; - struct usb_interface *usbif = to_usb_interface(dev->parent); - struct usb_device *usbdev = interface_to_usbdev(usbif); - struct usb_host_endpoint *ep; - struct urb *urb; - - ep = &usbif->cur_altsetting->endpoint[1]; - b_ep = ep->desc.bEndpointAddress; - - send_buf = kmalloc(256, GFP_KERNEL); /* overkill but whatever */ - rq_buf = kmalloc(256, GFP_KERNEL); - - for(i = 0; i < ARRAY_SIZE(setup_arr); ++i){ - memcpy(send_buf, setup_arr[i], setup_arr_sizes[i]); - hid_info(hid, "Sent interrupt at %i\n", i); - err = usb_interrupt_msg(usbdev, - usb_sndintpipe(usbdev, b_ep), - send_buf, - setup_arr_sizes[i], - &trans, - USB_CTRL_SET_TIMEOUT); - - if(err){ - hid_err(hid, "Setup data at index %i couldn't be sent, ERRNO: %i\n", i, err); - goto error; - } - } - - - urb = usb_alloc_urb(0, GFP_ATOMIC); - - - memcpy(send_buf, hw_rq_in, 8); - memcpy(rq_buf, hw_rq_out, 8); - - usb_fill_control_urb(urb, - usbdev, - usb_sndctrlpipe(usbdev, 0), - rq_buf, - send_buf, - 0, - tmff_init_ctrl, - hid - ); - - err = usb_start_wait_urb(urb, 5, &trans); - if(err != 0){ - hid_err(hid, "Failed sending ctrl out with ERRNO: %i", err); - goto error; - } - hid_info(hid, "URB submission didn't fail?"); - -error: - kfree(rq_buf); - kfree(send_buf); - return err; -} - -static int tmff_delete(struct kref *kref){ - /* reserved for future use */ - /* currently the errors we get aren't pretty */ - - return 0; -}; - -static void tmff_set_gain(struct input_dev *dev, u16 gain){ - tmff_gain = gain; -} - -static int tmff_init(struct hid_device *hid, const signed short *ff_bits) -{ - - struct tmff_device *tmff; - struct hid_report *report; - struct list_head *report_list; - struct hid_input *hidinput = list_entry(hid->inputs.next, - struct hid_input, list); - struct input_dev *input_dev = hidinput->input; - struct ff_device *ff; - int error; - int i; - - if(hid->product == 0xb65d) - return tmff_clear_init(hid); - - tmff = kzalloc(sizeof(struct tmff_device), GFP_KERNEL); - if (!tmff) - return -ENOMEM; - - hid_info(hid, "what is going ong here???"); - 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; - list_for_each_entry(report, report_list, list) { - int fieldnum; - - for (fieldnum = 0; fieldnum < report->maxfield; ++fieldnum) { - struct hid_field *field = report->field[fieldnum]; - printk("found field at fieldnum %i\n", fieldnum); - - if (field->maxusage <= 0) - continue; - - switch (field->usage[0].hid) { - case 0xff00000a: - case THRUSTMASTER_USAGE_FF: - if (field->report_count < 2) { - hid_warn(hid, "ignoring FF field with report_count < 2\n"); - continue; - } - - if (field->logical_maximum == - field->logical_minimum) { - hid_warn(hid, "ignoring FF field with logical_maximum == logical_minimum\n"); - continue; - } - - if (tmff->report && tmff->report != report) { - hid_warn(hid, "ignoring FF field in other report\n"); - continue; - } - - if (tmff->ff_field && tmff->ff_field != field) { - hid_warn(hid, "ignoring duplicate FF field\n"); - continue; - } - - tmff->report = report; - tmff->ff_field = field; - - for (i = 0; ff_bits[i] >= 0; i++) - set_bit(ff_bits[i], input_dev->ffbit); - - break; - - default: - hid_warn(hid, "ignoring unknown output usage %08x\n", - field->usage[0].hid); - continue; - } - } - } - - if (!tmff->report) { - hid_err(hid, "can't find FF field in output reports\n"); - error = -ENODEV; - goto fail; - } - - error = input_ff_create_memless(input_dev, tmff, tmff_play); - if (error) - goto fail; - - ff = input_dev->ff; - ff->set_gain = tmff_set_gain; - - hid_info(hid, "force feedback for ThrustMaster devices by Zinx Verituse \n"); - return 0; - -fail: - hid_err(hid, "We have failed creating a force feedback memless device!!!\n"); - kfree(tmff); - return error; -} -#else -static inline int tmff_init(struct hid_device *hid, const signed short *ff_bits) -{ - return 0; -} -#endif -static int tmff_afterthought_t300rs(struct hid_device *hid){ - int trans, b_ep, bb_ep, i, err; - u8 *send_buf, *rq_buf; - struct device *dev = &hid->dev; - struct usb_interface *usbif = to_usb_interface(dev->parent); - struct usb_device *usbdev = interface_to_usbdev(usbif); - struct usb_host_endpoint *ep; - - ep = &usbif->cur_altsetting->endpoint[0]; - bb_ep = ep->desc.bEndpointAddress; - - ep = &usbif->cur_altsetting->endpoint[1]; - b_ep = ep->desc.bEndpointAddress; - - send_buf = kmalloc(256, GFP_ATOMIC); /* overkill but whatever */ - rq_buf = kmalloc(256, GFP_ATOMIC); - - for(i = 0; i < ARRAY_SIZE(t300rs_fin_sizes); ++i){ - memcpy(send_buf, t300rs_fin_arr[i], t300rs_fin_sizes[i]); - - err = usb_interrupt_msg(usbdev, - usb_sndintpipe(usbdev, b_ep), - send_buf, - t300rs_fin_sizes[i], - &trans, - USB_CTRL_SET_TIMEOUT); - hid_info(hid, "sent %i:th message", i); - if(err){ - hid_err(hid, "T300RS setup data at index %i couldn't be sent, ERRNO: %i\n", i, err); - goto error; - } - } - - -error: - kfree(send_buf); - kfree(rq_buf); - return err; -} - - -static int tm_probe(struct hid_device *hdev, const struct hid_device_id *id) -{ - int ret; - - ret = hid_parse(hdev); - if (ret) { - hid_err(hdev, "parse failed\n"); - goto err; - } - - if(hdev->product == 0xb66e){ - ret = tmff_init_t300rs(hdev); - - if(ret){ - hid_err(hdev, "t300rs init failed\n"); - goto err; - } - } - - printk("woot\n"); - ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); - if (ret) { - hid_err(hdev, "hw start failed\n"); - goto err; - } - printk("waat\n"); - - ret = tmff_init(hdev, (void *)id->driver_data); - - if(ret){ - hid_err(hdev, "what the fuck is going on?\n"); - if(ret == -32){ - //hid_hw_stop(hdev); - return 0; - } - goto err; - } - - if(hdev->product == 0xb66e){ - ret = tmff_afterthought_t300rs(hdev); - - if(ret){ - hid_err(hdev, "t300rs afterinit failed\n"); - goto err; - } - } - return 0; -err: - return ret; -} - -static void tm_remove(struct hid_device *hdev){ - hid_hw_stop(hdev); -} - -static __u8 t300rs_rdesc_fixed[] = {0x05, 0x01, 0x09, 0x04, 0xa1, 0x01, 0x09, 0x01, 0xa1, 0x00, 0x85, 0x07, 0x09, 0x30, 0x15, 0x00, 0x27, 0xff, 0xff, 0x00, 0x00, 0x35, 0x00, 0x47, 0xff, 0xff, 0x00, 0x00, 0x75, 0x10, 0x95, 0x01, 0x81, 0x02, 0x09, 0x31, 0x26, 0xff, 0x03, 0x46, 0xff, 0x03, 0x81, 0x02, 0x09, 0x35, 0x81, 0x02, 0x09, 0x36, 0x81, 0x02, 0x81, 0x03, 0x05, 0x09, 0x19, 0x01, 0x29, 0x0d, 0x25, 0x01, 0x45, 0x01, 0x75, 0x01, 0x95, 0x0d, 0x81, 0x02, 0x75, 0x0b, 0x95, 0x01, 0x81, 0x03, 0x05, 0x01, 0x09, 0x39, 0x25, 0x07, 0x46, 0x3b, 0x01, 0x55, 0x00, 0x65, 0x14, 0x75, 0x04, 0x81, 0x42, 0x65, 0x00, 0x81, 0x03, 0x85, 0x0a, 0x06, 0x00, 0xff, 0x09, 0x0a, 0x75, 0x08, 0x95, 0x3f, - 0x26, 0xff, 0x7f, - 0x16, 0x00, 0x80, - 0x46, 0xff, 0x7f, - 0x36, 0x00, 0x80, - 0x91, 0x02, 0x85, 0x02, 0x09, 0x02, 0x81, 0x02, 0x09, 0x14, 0x85, 0x14, 0x81, 0x02, 0xc0, 0xc0,}; - -static __u8 *tmff_t300rs_report_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int *rsize){ - if(hdev->product != 0xb66e){ - return rdesc; - } - printk("wahey"); - rdesc = t300rs_rdesc_fixed; - *rsize = sizeof(t300rs_rdesc_fixed); - return rdesc; -}; - -static const struct hid_device_id tm_devices[] = { - { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb65d), - .driver_data = (unsigned long)ff_constant }, /* die */ - { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb66e), - .driver_data = (unsigned long)ff_constant }, - { } -}; -MODULE_DEVICE_TABLE(hid, tm_devices); - -static struct hid_driver tm_driver = { - .name = "thrustmaster", - .id_table = tm_devices, - .probe = tm_probe, - .remove = tm_remove, - .report_fixup = tmff_t300rs_report_fixup, -}; -module_hid_driver(tm_driver); - -MODULE_LICENSE("GPL"); -- cgit v1.3 From e6e4ed227ec39cf07bd0e8d77f8e1be8e181080c Mon Sep 17 00:00:00 2001 From: kimi Date: Wed, 8 Jul 2020 14:28:32 -0400 Subject: added files --- compile_commands.json | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++ hid-tmt300rs.c | 1 + 2 files changed, 115 insertions(+) create mode 100644 compile_commands.json create mode 100644 hid-tmt300rs.c (limited to 'compile_commands.json') diff --git a/compile_commands.json b/compile_commands.json new file mode 100644 index 0000000..ea1a16a --- /dev/null +++ b/compile_commands.json @@ -0,0 +1,114 @@ +[ + { + "arguments": [ + "gcc", + "-c", + "-Wp,-MD,/home/kimi/Documents/tmff2/.hid-tminit.o.d", + "-nostdinc", + "-isystem", + "/usr/lib/gcc/x86_64-linux-gnu/9/include", + "-I./arch/x86/include", + "-I./arch/x86/include/generated", + "-I./include", + "-I./arch/x86/include/uapi", + "-I./arch/x86/include/generated/uapi", + "-I./include/uapi", + "-I./include/generated/uapi", + "-include", + "./include/linux/kconfig.h", + "-Iubuntu/include", + "-include", + "./include/linux/compiler_types.h", + "-D__KERNEL__", + "-Wall", + "-Wundef", + "-Werror=strict-prototypes", + "-Wno-trigraphs", + "-fno-strict-aliasing", + "-fno-common", + "-fshort-wchar", + "-fno-PIE", + "-Werror=implicit-function-declaration", + "-Werror=implicit-int", + "-Wno-format-security", + "-std=gnu89", + "-mno-sse", + "-mno-mmx", + "-mno-sse2", + "-mno-3dnow", + "-mno-avx", + "-m64", + "-falign-jumps=1", + "-falign-loops=1", + "-mno-80387", + "-mno-fp-ret-in-387", + "-mpreferred-stack-boundary=3", + "-mskip-rax-setup", + "-mtune=generic", + "-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", + "-mindirect-branch-register", + "-fno-jump-tables", + "-fno-delete-null-pointer-checks", + "-Wno-frame-address", + "-Wno-format-truncation", + "-Wno-format-overflow", + "-Wno-address-of-packed-member", + "-O2", + "--param=allow-store-data-races=0", + "-Wframe-larger-than=1024", + "-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", + "-pg", + "-mrecord-mcount", + "-mfentry", + "-DCC_USING_FENTRY", + "-flive-patching=inline-clone", + "-Wdeclaration-after-statement", + "-Wvla", + "-Wno-pointer-sign", + "-Wno-stringop-truncation", + "-Wno-array-bounds", + "-Wno-stringop-overflow", + "-Wno-restrict", + "-Wno-maybe-uninitialized", + "-fno-strict-overflow", + "-fno-merge-all-constants", + "-fmerge-constants", + "-fno-stack-check", + "-fconserve-stack", + "-Werror=date-time", + "-Werror=incompatible-pointer-types", + "-Werror=designated-init", + "-fmacro-prefix-map=./=", + "-fcf-protection=none", + "-Wno-packed-not-aligned", + "-DMODULE", + "-DKBUILD_BASENAME=\"hid_tminit\"", + "-DKBUILD_MODNAME=\"hid_tminit\"", + "-o", + "/home/kimi/Documents/tmff2/hid-tminit.o", + "../../../home/kimi/Documents/tmff2/hid-tminit.c" + ], + "directory": "/usr/src/linux-headers-5.4.0-40-generic", + "file": "../../../home/kimi/Documents/tmff2/hid-tminit.c" + } +] \ No newline at end of file diff --git a/hid-tmt300rs.c b/hid-tmt300rs.c new file mode 100644 index 0000000..3c3684c --- /dev/null +++ b/hid-tmt300rs.c @@ -0,0 +1 @@ +/* empty for now */ -- cgit v1.3 From 2031f19d346e5abcfaa1feb35103fba52dd5c55c Mon Sep 17 00:00:00 2001 From: Kimplul Date: Fri, 10 Jul 2020 00:40:09 +0300 Subject: incremental additions --- Module.symvers | 0 compile_commands.json | 44 +++++++++++++-------------------- 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 | 36 +++++++++++++-------------- hid-tmt300rs.h | 2 +- hid-tmt300rs.ko | Bin 0 -> 537752 bytes hid-tmt300rs.mod | 2 ++ hid-tmt300rs.mod.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ hid-tmt300rs.mod.o | Bin 0 -> 144040 bytes hid-tmt300rs.o | Bin 0 -> 395304 bytes modules.order | 2 ++ todo.txt | 3 +++ 16 files changed, 166 insertions(+), 47 deletions(-) create mode 100644 Module.symvers 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 create mode 100644 modules.order create mode 100644 todo.txt (limited to 'compile_commands.json') diff --git a/Module.symvers b/Module.symvers new file mode 100644 index 0000000..e69de29 diff --git a/compile_commands.json b/compile_commands.json index ea1a16a..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-tminit.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_tminit\"", - "-DKBUILD_MODNAME=\"hid_tminit\"", + "-DKBUILD_BASENAME=\"hid_tmt300rs\"", + "-DKBUILD_MODNAME=\"hid_tmt300rs\"", "-o", - "/home/kimi/Documents/tmff2/hid-tminit.o", - "../../../home/kimi/Documents/tmff2/hid-tminit.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-tminit.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 2e2609a..b8f0a30 100644 --- a/hid-tmt300rs.c +++ b/hid-tmt300rs.c @@ -451,18 +451,16 @@ static int t300rs_timer_helper(struct t300rs_device_entry *t300rs){ hid_info(t300rs->hdev, "commands stacking up, increasing timer period\n"); return current_period; } - - for(effect_id = 0; effect_id < t300rs->max_id; ++effect_id){ + + for(effect_id = 0; effect_id < T300RS_MAX_EFFECTS; ++effect_id){ state = &t300rs->states[effect_id]; - if(!test_bit(FF_EFFECT_QUEUE_START, &state->flags) && - !test_bit(FF_EFFECT_QUEUE_STOP, &state->flags)){ - continue; - } - - if(test_bit(FF_EFFECT_PLAYING, &state->flags)){ + /* + * alright, for now no count support + * if(test_bit(FF_EFFECT_PLAYING, &state->flags)){ if(JIFFIES2MS(jiffies) - state->start_time >= state->effect.replay.length){ + hid_info(t300rs->hdev, "maybe dangerous?"); __clear_bit(FF_EFFECT_PLAYING, &state->flags); if(state->count){ @@ -470,7 +468,7 @@ static int t300rs_timer_helper(struct t300rs_device_entry *t300rs){ state->count--; } } - } + }*/ if(test_bit(FF_EFFECT_QUEUE_UPLOAD, &state->flags)){ __clear_bit(FF_EFFECT_QUEUE_UPLOAD, &state->flags); @@ -537,7 +535,7 @@ static int t300rs_upload(struct input_dev *dev, struct ff_effect *effect, struct struct t300rs_effect_state *state; t300rs = t300rs_get_device(hdev); - + if(effect->type == FF_PERIODIC && effect->u.periodic.period == 0){ return -EINVAL; } @@ -566,11 +564,11 @@ static int t300rs_play(struct input_dev *dev, int effect_id, int value){ t300rs = t300rs_get_device(hdev); state = &t300rs->states[effect_id]; - + spin_lock_irqsave(&t300rs->lock, t300rs->lock_flags); if(value > 0){ - if(test_bit(FF_EFFECT_PLAYING, &state->flags)){ + if(test_bit(FF_EFFECT_QUEUE_START, &state->flags)){ __set_bit(FF_EFFECT_QUEUE_STOP, &state->flags); } else { t300rs->effects_used++; @@ -593,6 +591,7 @@ static int t300rs_play(struct input_dev *dev, int effect_id, int value){ return 0; } +/* we should set a default range */ static ssize_t t300rs_range_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count){ struct hid_device *hdev = to_hid_device(dev); @@ -728,7 +727,7 @@ err: return ret; } -static void t300rs_close(struct input_dev *dev){ +/*static void t300rs_close(struct input_dev *dev){ int ret, trans; struct hid_device *hdev = input_get_drvdata(dev); u8 *send_buffer = kzalloc(T300RS_BUFFER_LENGTH, GFP_ATOMIC); @@ -744,7 +743,7 @@ static void t300rs_close(struct input_dev *dev){ err: kfree(send_buffer); return; -} +}*/ int t300rs_init(struct hid_device *hdev, const signed short *ff_bits){ struct t300rs_device_entry *t300rs; @@ -860,19 +859,20 @@ int t300rs_init(struct hid_device *hdev, const signed short *ff_bits){ ff->set_autocenter = t300rs_set_autocenter; ff->destroy = t300rs_destroy; - input_dev->open = t300rs_open; - input_dev->close = t300rs_close; + /* input_dev->open = t300rs_open; + input_dev->close = t300rs_close; */ ret = device_create_file(&hdev->dev, &dev_attr_range); if(ret){ hid_warn(hdev, "unable to create sysfs interface for range\n"); goto out; } - + hrtimer_init(&t300rs->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); t300rs->hrtimer.function = t300rs_timer; + t300rs_open(input_dev); hid_info(hdev, "force feedback for T300RS\n"); return 0; @@ -940,7 +940,6 @@ static int t300rs_probe(struct hid_device *hdev, const struct hid_device_id *id) struct t300rs_data *drv_data; spin_lock_init(&lock); - spin_lock_irqsave(&lock, lock_flags); drv_data = kzalloc(sizeof(struct t300rs_data), GFP_ATOMIC); if(!drv_data){ @@ -973,7 +972,6 @@ static int t300rs_probe(struct hid_device *hdev, const struct hid_device_id *id) goto err; } - spin_unlock_irqrestore(&lock, lock_flags); return 0; err: kfree(drv_data); diff --git a/hid-tmt300rs.h b/hid-tmt300rs.h index bec73eb..1cc3424 100644 --- a/hid-tmt300rs.h +++ b/hid-tmt300rs.h @@ -7,7 +7,7 @@ #define T300RS_MAX_EFFECTS FF_MAX_EFFECTS #define T300RS_BUFFER_LENGTH 64 -#define DEFAULT_TIMER_PERIOD 2 +#define DEFAULT_TIMER_PERIOD 16 /* the wheel seems to be bad at stuff*/ #define FF_EFFECT_QUEUE_UPLOAD 0 #define FF_EFFECT_QUEUE_START 1 diff --git a/hid-tmt300rs.ko b/hid-tmt300rs.ko new file mode 100644 index 0000000..7ec9bb8 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..d10c5bb --- /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" }, + { 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" }, + { 0x15ba50a6, "jiffies" }, + { 0xdc21e866, "hrtimer_forward" }, + { 0x2ea2c95c, "__x86_indirect_thunk_rax" }, + { 0x59e59766, "_dev_info" }, + { 0x20000329, "simple_strtoul" }, + { 0xc27f683d, "kmem_cache_alloc_trace" }, + { 0x46a9479b, "kmalloc_caches" }, + { 0xedb8a9, "usb_submit_urb" }, + { 0x82fea2ff, "usb_alloc_urb" }, + { 0x4a0c79b0, "hid_hw_stop" }, + { 0x37a0cba, "kfree" }, + { 0xa0c6befa, "hrtimer_cancel" }, + { 0x9c59e5d5, "device_remove_file" }, + { 0xfbdfc558, "hrtimer_start_range_ns" }, + { 0xb4ff6bb6, "hrtimer_active" }, + { 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..95b6880 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..743d20b Binary files /dev/null and b/hid-tmt300rs.o differ diff --git a/modules.order b/modules.order new file mode 100644 index 0000000..a0e2376 --- /dev/null +++ b/modules.order @@ -0,0 +1,2 @@ +/home/kimi/Documents/Projects/hid-tmff2/hid-tminit.ko +/home/kimi/Documents/Projects/hid-tmff2/hid-tmt300rs.ko diff --git a/todo.txt b/todo.txt new file mode 100644 index 0000000..ea2310d --- /dev/null +++ b/todo.txt @@ -0,0 +1,3 @@ +1. set a default range for the wheel so that it syncs up correctly +2. figure out the bug where the effects suddenly stop being sent (happens in +dirt rally at least) -- cgit v1.3 From ead4ca3e9726eea7456064682c739aee74416fba Mon Sep 17 00:00:00 2001 From: kimi Date: Fri, 10 Jul 2020 12:16:08 -0400 Subject: wow? --- compile_commands.json | 40 +++++++++++++++--------- hid-tminit.ko | Bin 419984 -> 280264 bytes hid-tminit.mod | 2 +- hid-tminit.mod.c | 34 +++----------------- hid-tminit.mod.o | Bin 143264 -> 2904 bytes hid-tmt300rs.c | 85 +++++++++++++++----------------------------------- hid-tmt300rs.h | 6 ++++ hid-tmt300rs.ko | Bin 527336 -> 26560 bytes hid-tmt300rs.mod | 2 +- hid-tmt300rs.mod.c | 46 +++------------------------ hid-tmt300rs.mod.o | Bin 144040 -> 2912 bytes hid-tmt300rs.o | Bin 384888 -> 24568 bytes modules.order | 4 +-- 13 files changed, 68 insertions(+), 151 deletions(-) (limited to 'compile_commands.json') diff --git a/compile_commands.json b/compile_commands.json index a75ead3..56b8bee 100644 --- a/compile_commands.json +++ b/compile_commands.json @@ -1,24 +1,24 @@ [ { "arguments": [ - "gcc-9", + "gcc", "-c", - "-Wp,-MD,/home/kimi/Documents/Projects/hid-tmff2/.hid-tmt300rs.o.d", + "-Wp,-MD,/home/kimi/Documents/tmff2/.hid-tmt300rs.o.d", "-nostdinc", "-isystem", "/usr/lib/gcc/x86_64-linux-gnu/9/include", - "-I/usr/src/linux-headers-5.7.0-1-common/arch/x86/include", + "-I./arch/x86/include", "-I./arch/x86/include/generated", - "-I/usr/src/linux-headers-5.7.0-1-common/include", "-I./include", - "-I/usr/src/linux-headers-5.7.0-1-common/arch/x86/include/uapi", + "-I./arch/x86/include/uapi", "-I./arch/x86/include/generated/uapi", - "-I/usr/src/linux-headers-5.7.0-1-common/include/uapi", + "-I./include/uapi", "-I./include/generated/uapi", "-include", - "/usr/src/linux-headers-5.7.0-1-common/include/linux/kconfig.h", + "./include/linux/kconfig.h", + "-Iubuntu/include", "-include", - "/usr/src/linux-headers-5.7.0-1-common/include/linux/compiler_types.h", + "./include/linux/compiler_types.h", "-D__KERNEL__", "-Wall", "-Wundef", @@ -48,6 +48,15 @@ "-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", @@ -60,13 +69,14 @@ "-Wno-address-of-packed-member", "-O2", "--param=allow-store-data-races=0", - "-Wframe-larger-than=2048", + "-Wframe-larger-than=1024", "-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", @@ -88,17 +98,17 @@ "-Werror=date-time", "-Werror=incompatible-pointer-types", "-Werror=designated-init", - "-fmacro-prefix-map=/usr/src/linux-headers-5.7.0-1-common/=", + "-fmacro-prefix-map=./=", "-fcf-protection=none", "-Wno-packed-not-aligned", "-DMODULE", "-DKBUILD_BASENAME=\"hid_tmt300rs\"", "-DKBUILD_MODNAME=\"hid_tmt300rs\"", "-o", - "/home/kimi/Documents/Projects/hid-tmff2/hid-tmt300rs.o", - "../../../home/kimi/Documents/Projects/hid-tmff2/hid-tmt300rs.c" + "/home/kimi/Documents/tmff2/hid-tmt300rs.o", + "../../../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" + "directory": "/usr/src/linux-headers-5.4.0-40-generic", + "file": "../../../home/kimi/Documents/tmff2/hid-tmt300rs.c" } ] \ No newline at end of file diff --git a/hid-tminit.ko b/hid-tminit.ko index f7a0f97..763336c 100644 Binary files a/hid-tminit.ko and b/hid-tminit.ko differ diff --git a/hid-tminit.mod b/hid-tminit.mod index 821c012..858ad57 100644 --- a/hid-tminit.mod +++ b/hid-tminit.mod @@ -1,2 +1,2 @@ -/home/kimi/Documents/Projects/hid-tmff2/hid-tminit.o +/home/kimi/Documents/tmff2/hid-tminit.o diff --git a/hid-tminit.mod.c b/hid-tminit.mod.c index 7029581..dbd2e54 100644 --- a/hid-tminit.mod.c +++ b/hid-tminit.mod.c @@ -1,5 +1,5 @@ -#include #include +#include #include #include @@ -22,34 +22,8 @@ __section(.gnu.linkonce.this_module) = { 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_INFO(depends, "hid"); MODULE_ALIAS("hid:b0003g*v0000044Fp0000B65D"); + +MODULE_INFO(srcversion, "49C62A898823BBE8124B035"); diff --git a/hid-tminit.mod.o b/hid-tminit.mod.o index ae7e374..ce3c467 100644 Binary files a/hid-tminit.mod.o and b/hid-tminit.mod.o differ diff --git a/hid-tmt300rs.c b/hid-tmt300rs.c index bab04ec..8b002c7 100644 --- a/hid-tmt300rs.c +++ b/hid-tmt300rs.c @@ -38,6 +38,9 @@ static int t300rs_send_int(struct input_dev *dev, u8 *send_buffer, int *trans){ struct urb *urb = usb_alloc_urb(0, GFP_ATOMIC); t300rs = t300rs_get_device(hdev); + if(!t300rs){ + hid_err(hdev, "could not get device\n"); + } usbdev = t300rs->usbdev; usbif = t300rs->usbif; @@ -495,11 +498,11 @@ static enum hrtimer_restart t300rs_timer(struct hrtimer *t){ struct t300rs_device_entry *t300rs = container_of(t, struct t300rs_device_entry, hrtimer); int max_count; - spin_lock_irqsave(&t300rs->lock, t300rs->lock_flags); + spin_lock_irqsave(&data_lock, data_flags); max_count = t300rs_timer_helper(t300rs); - spin_unlock_irqrestore(&t300rs->lock, t300rs->lock_flags); + spin_unlock_irqrestore(&data_lock, data_flags); if(max_count > 0){ hrtimer_forward_now(&t300rs->hrtimer, ms_to_ktime(timer_msecs)); @@ -663,10 +666,13 @@ static void t300rs_destroy(struct ff_device *ff){ static int t300rs_open(struct input_dev *dev){ + struct t300rs_device_entry *t300rs; struct hid_device *hdev = input_get_drvdata(dev); u8 *send_buffer = kzalloc(T300RS_BUFFER_LENGTH, GFP_ATOMIC); int ret, trans; + t300rs = t300rs_get_device(hdev); + send_buffer[0] = 0x60; send_buffer[1] = 0x01; send_buffer[2] = 0x04; @@ -705,14 +711,17 @@ static int t300rs_open(struct input_dev *dev){ err: kfree(send_buffer); - return ret; + return t300rs->open(dev); } -/*static void t300rs_close(struct input_dev *dev){ +static void t300rs_close(struct input_dev *dev){ int ret, trans; struct hid_device *hdev = input_get_drvdata(dev); + struct t300rs_device_entry *t300rs; u8 *send_buffer = kzalloc(T300RS_BUFFER_LENGTH, GFP_ATOMIC); + t300rs = t300rs_get_device(hdev); + send_buffer[0] = 0x60; send_buffer[1] = 0x01; @@ -723,8 +732,10 @@ err: } err: kfree(send_buffer); + + t300rs->close(dev); return; -}*/ +} int t300rs_init(struct hid_device *hdev, const signed short *ff_bits){ struct t300rs_device_entry *t300rs; @@ -841,8 +852,11 @@ int t300rs_init(struct hid_device *hdev, const signed short *ff_bits){ ff->set_autocenter = t300rs_set_autocenter; ff->destroy = t300rs_destroy; - /* input_dev->open = t300rs_open; - input_dev->close = t300rs_close; */ + t300rs->open = input_dev->open; + t300rs->close = input_dev->close; + + input_dev->open = t300rs_open; + input_dev->close = t300rs_close; ret = device_create_file(&hdev->dev, &dev_attr_range); if(ret){ @@ -874,53 +888,6 @@ err: } -/* for some reason this specific command must be sent before hid_hw_start. Odd. - * */ -static int t300rs_preinit(struct hid_device *hdev){ - int ret; - u8 *setup_packet, *send_buffer; - - /* this is sort of unnecessary, as later on I compile the interfaces etc - * into one struct, but for now this will do - * */ - struct device *dev = &hdev->dev; - struct usb_interface *usbif = to_usb_interface(dev->parent); - struct usb_device *usbdev = interface_to_usbdev(usbif); - struct urb *urb; - - setup_packet = kmalloc(8, GFP_ATOMIC); - send_buffer = kzalloc(8, GFP_ATOMIC); - - memcpy(setup_packet, t300rs_ctrl_out, ARRAY_SIZE(t300rs_ctrl_out)); - urb = usb_alloc_urb(0, GFP_ATOMIC); - - usb_fill_control_urb(urb, - usbdev, - usb_sndctrlpipe(usbdev, 0), - setup_packet, - /* why is it important we have a pointer, when we send out 0 bytes? - * No clue. - * */ - send_buffer, - 0, - /* technically speaking this isn't an interrupt usb, but hey, this - * works. - * */ - t300rs_int_callback, - hdev); - - ret = usb_submit_urb(urb, GFP_ATOMIC); - if(ret != 0){ - hid_err(hdev, "Failed sending ctrl out with ERRNO: %i", ret); - goto error; - } - -error: - kfree(send_buffer); - kfree(setup_packet); - return ret; -} - static int t300rs_probe(struct hid_device *hdev, const struct hid_device_id *id){ int ret; struct t300rs_data *drv_data; @@ -943,9 +910,6 @@ static int t300rs_probe(struct hid_device *hdev, const struct hid_device_id *id) goto err; } - /* lord have mercy */ - //t300rs_preinit(hdev); - ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); if(ret){ hid_err(hdev, "hw start failed\n"); @@ -969,20 +933,21 @@ static void t300rs_remove(struct hid_device *hdev){ struct t300rs_device_entry *t300rs; struct t300rs_data *drv_data; - spin_lock_irqsave(&lock, lock_flags); device_remove_file(&hdev->dev, &dev_attr_range); drv_data = hid_get_drvdata(hdev); t300rs = t300rs_get_device(hdev); + spin_lock_irqsave(&data_lock, data_flags); + hrtimer_cancel(&t300rs->hrtimer); + hid_hw_stop(hdev); kfree(t300rs->states); kfree(drv_data); kfree(t300rs); - hid_hw_stop(hdev); - spin_unlock_irqrestore(&lock, lock_flags); + spin_unlock_irqrestore(&data_lock, data_flags); return; } diff --git a/hid-tmt300rs.h b/hid-tmt300rs.h index b308627..f3c8d97 100644 --- a/hid-tmt300rs.h +++ b/hid-tmt300rs.h @@ -21,6 +21,9 @@ spinlock_t lock; unsigned long lock_flags; +spinlock_t data_lock; +unsigned long data_flags; + static int timer_msecs = DEFAULT_TIMER_PERIOD; static const signed short t300rs_ff_effects[] = { @@ -58,6 +61,9 @@ struct t300rs_device_entry { struct t300rs_effect_state *states; struct hrtimer hrtimer; + int (*open)(struct input_dev *dev); + void (*close)(struct input_dev *dev); + spinlock_t lock; unsigned long lock_flags; diff --git a/hid-tmt300rs.ko b/hid-tmt300rs.ko index 07d01f3..4a7c06a 100644 Binary files a/hid-tmt300rs.ko and b/hid-tmt300rs.ko differ diff --git a/hid-tmt300rs.mod b/hid-tmt300rs.mod index 8a429e9..92bd18f 100644 --- a/hid-tmt300rs.mod +++ b/hid-tmt300rs.mod @@ -1,2 +1,2 @@ -/home/kimi/Documents/Projects/hid-tmff2/hid-tmt300rs.o +/home/kimi/Documents/tmff2/hid-tmt300rs.o diff --git a/hid-tmt300rs.mod.c b/hid-tmt300rs.mod.c index a114b1d..7d03495 100644 --- a/hid-tmt300rs.mod.c +++ b/hid-tmt300rs.mod.c @@ -1,5 +1,5 @@ -#include #include +#include #include #include @@ -22,46 +22,8 @@ __section(.gnu.linkonce.this_module) = { 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" }, - { 0x2ea2c95c, "__x86_indirect_thunk_rax" }, - { 0x20000329, "simple_strtoul" }, - { 0xc27f683d, "kmem_cache_alloc_trace" }, - { 0x46a9479b, "kmalloc_caches" }, - { 0xedb8a9, "usb_submit_urb" }, - { 0x82fea2ff, "usb_alloc_urb" }, - { 0x4a0c79b0, "hid_hw_stop" }, - { 0x37a0cba, "kfree" }, - { 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_INFO(depends, "hid"); MODULE_ALIAS("hid:b0003g*v0000044Fp0000B66E"); + +MODULE_INFO(srcversion, "8A85E6A9A9E4442C81CA1CE"); diff --git a/hid-tmt300rs.mod.o b/hid-tmt300rs.mod.o index 5ab5b8c..f761a52 100644 Binary files a/hid-tmt300rs.mod.o and b/hid-tmt300rs.mod.o differ diff --git a/hid-tmt300rs.o b/hid-tmt300rs.o index a01b321..bc2808c 100644 Binary files a/hid-tmt300rs.o and b/hid-tmt300rs.o differ diff --git a/modules.order b/modules.order index a0e2376..0be5217 100644 --- a/modules.order +++ b/modules.order @@ -1,2 +1,2 @@ -/home/kimi/Documents/Projects/hid-tmff2/hid-tminit.ko -/home/kimi/Documents/Projects/hid-tmff2/hid-tmt300rs.ko +/home/kimi/Documents/tmff2/hid-tminit.ko +/home/kimi/Documents/tmff2/hid-tmt300rs.ko -- cgit v1.3 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 (limited to 'compile_commands.json') 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