drivers/hid/hid-thrustmaster.c
Source file repositories/reference/linux-study-clean/drivers/hid/hid-thrustmaster.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/hid-thrustmaster.c- Extension
.c- Size
- 10905 bytes
- Lines
- 399
- Domain
- Driver Families
- Bucket
- drivers/hid
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/hid.hlinux/usb.hlinux/input.hlinux/slab.hlinux/module.h
Detected Declarations
struct tm_wheel_infostruct __packedstruct __packedstruct tm_wheelfunction thrustmaster_interruptsfunction thrustmaster_change_handlerfunction thrustmaster_model_handlerfunction thrustmaster_removefunction thrustmaster_probe
Annotated Snippet
struct tm_wheel_info {
uint16_t wheel_type;
/*
* See when the USB control out packet is prepared...
* @TODO The TMX seems to require multiple control codes to switch.
*/
uint16_t switch_value;
char const *const wheel_name;
};
/*
* Known wheels.
* Note: TMX does not work as it requires 2 control packets
*/
static const struct tm_wheel_info tm_wheels_infos[] = {
{0x0306, 0x0006, "Thrustmaster T150RS"},
{0x0200, 0x0005, "Thrustmaster T300RS (Missing Attachment)"},
{0x0206, 0x0005, "Thrustmaster T300RS"},
{0x0209, 0x0005, "Thrustmaster T300RS (Open Wheel Attachment)"},
{0x020a, 0x0005, "Thrustmaster T300RS (Sparco R383 Mod)"},
{0x0204, 0x0005, "Thrustmaster T300 Ferrari Alcantara Edition"},
{0x0002, 0x0002, "Thrustmaster T500RS"}
//{0x0407, 0x0001, "Thrustmaster TMX"}
};
static const uint8_t tm_wheels_infos_length = 7;
/*
* This structs contains (in little endian) the response data
* of the wheel to the request 73
*
* A sufficient research to understand what each field does is not
* beign conducted yet. The position and meaning of fields are a
* just a very optimistic guess based on instinct....
*/
struct __packed tm_wheel_response
{
/*
* Seems to be the type of packet
* - 0x0049 if is data.a (15 bytes)
* - 0x0047 if is data.b (7 bytes)
*/
uint16_t type;
union {
struct __packed {
uint16_t field0;
uint16_t field1;
/*
* Seems to be the model code of the wheel
* Read table thrustmaster_wheels to values
*/
uint16_t model;
uint16_t field2;
uint16_t field3;
uint16_t field4;
uint16_t field5;
} a;
struct __packed {
uint16_t field0;
uint16_t field1;
uint16_t model;
} b;
} data;
};
struct tm_wheel {
struct usb_device *usb_dev;
struct urb *urb;
struct usb_ctrlrequest *model_request;
struct tm_wheel_response *response;
struct usb_ctrlrequest *change_request;
};
/* The control packet to send to wheel */
static const struct usb_ctrlrequest model_request = {
.bRequestType = 0xc1,
.bRequest = 73,
.wValue = 0,
.wIndex = 0,
.wLength = cpu_to_le16(0x0010)
};
static const struct usb_ctrlrequest change_request = {
.bRequestType = 0x41,
Annotation
- Immediate include surface: `linux/hid.h`, `linux/usb.h`, `linux/input.h`, `linux/slab.h`, `linux/module.h`.
- Detected declarations: `struct tm_wheel_info`, `struct __packed`, `struct __packed`, `struct tm_wheel`, `function thrustmaster_interrupts`, `function thrustmaster_change_handler`, `function thrustmaster_model_handler`, `function thrustmaster_remove`, `function thrustmaster_probe`.
- Atlas domain: Driver Families / drivers/hid.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.