drivers/hid/hid-ntrig.c
Source file repositories/reference/linux-study-clean/drivers/hid/hid-ntrig.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/hid-ntrig.c- Extension
.c- Size
- 27191 bytes
- Lines
- 1034
- 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/device.hlinux/hid.hlinux/usb.husbhid/usbhid.hlinux/module.hlinux/slab.hhid-ids.h
Detected Declarations
struct ntrig_datafunction ntrig_version_stringfunction ntrig_get_modefunction ntrig_set_modefunction ntrig_report_versionfunction show_phys_widthfunction show_phys_heightfunction show_log_widthfunction show_log_heightfunction show_min_widthfunction set_min_widthfunction show_min_heightfunction set_min_heightfunction show_activate_slackfunction set_activate_slackfunction show_activation_widthfunction set_activation_widthfunction show_activation_heightfunction set_activation_heightfunction show_deactivate_slackfunction set_deactivate_slackfunction ntrig_input_mappingfunction ntrig_input_mappedfunction ntrig_eventfunction normalfunction ntrig_input_configuredfunction ntrig_probefunction ntrig_remove
Annotated Snippet
struct ntrig_data {
/* Incoming raw values for a single contact */
__u16 x, y, w, h;
__u16 id;
bool tipswitch;
bool confidence;
bool first_contact_touch;
bool reading_mt;
__u8 mt_footer[4];
__u8 mt_foot_count;
/* The current activation state. */
__s8 act_state;
/* Empty frames to ignore before recognizing the end of activity */
__s8 deactivate_slack;
/* Frames to ignore before acknowledging the start of activity */
__s8 activate_slack;
/* Minimum size contact to accept */
__u16 min_width;
__u16 min_height;
/* Threshold to override activation slack */
__u16 activation_width;
__u16 activation_height;
__u16 sensor_logical_width;
__u16 sensor_logical_height;
__u16 sensor_physical_width;
__u16 sensor_physical_height;
};
/*
* This function converts the 4 byte raw firmware code into
* a string containing 5 comma separated numbers.
*/
static int ntrig_version_string(unsigned char *raw, char *buf)
{
__u8 a = (raw[1] & 0x0e) >> 1;
__u8 b = (raw[0] & 0x3c) >> 2;
__u8 c = ((raw[0] & 0x03) << 3) | ((raw[3] & 0xe0) >> 5);
__u8 d = ((raw[3] & 0x07) << 3) | ((raw[2] & 0xe0) >> 5);
__u8 e = raw[2] & 0x07;
/*
* As yet unmapped bits:
* 0b11000000 0b11110001 0b00011000 0b00011000
*/
return sprintf(buf, "%u.%u.%u.%u.%u", a, b, c, d, e);
}
static inline int ntrig_get_mode(struct hid_device *hdev)
{
struct hid_report *report = hdev->report_enum[HID_FEATURE_REPORT].
report_id_hash[0x0d];
if (!report || report->maxfield < 1 ||
report->field[0]->report_count < 1)
return -EINVAL;
hid_hw_request(hdev, report, HID_REQ_GET_REPORT);
hid_hw_wait(hdev);
return (int)report->field[0]->value[0];
}
static inline void ntrig_set_mode(struct hid_device *hdev, const int mode)
{
struct hid_report *report;
__u8 mode_commands[4] = { 0xe, 0xf, 0x1b, 0x10 };
if (mode < 0 || mode > 3)
return;
report = hdev->report_enum[HID_FEATURE_REPORT].
report_id_hash[mode_commands[mode]];
if (!report)
return;
hid_hw_request(hdev, report, HID_REQ_GET_REPORT);
}
static void ntrig_report_version(struct hid_device *hdev)
Annotation
- Immediate include surface: `linux/device.h`, `linux/hid.h`, `linux/usb.h`, `usbhid/usbhid.h`, `linux/module.h`, `linux/slab.h`, `hid-ids.h`.
- Detected declarations: `struct ntrig_data`, `function ntrig_version_string`, `function ntrig_get_mode`, `function ntrig_set_mode`, `function ntrig_report_version`, `function show_phys_width`, `function show_phys_height`, `function show_log_width`, `function show_log_height`, `function show_min_width`.
- 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.