drivers/hid/hid-alps.c
Source file repositories/reference/linux-study-clean/drivers/hid/hid-alps.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/hid-alps.c- Extension
.c- Size
- 20425 bytes
- Lines
- 855
- 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/kernel.hlinux/hid.hlinux/input.hlinux/input/mt.hlinux/module.hlinux/unaligned.hhid-ids.h
Detected Declarations
struct alps_devstruct t4_contact_datastruct t4_input_reportenum dev_numfunction t4_calc_check_sumfunction t4_read_write_registerfunction u1_read_write_registerfunction t4_raw_eventfunction u1_raw_eventfunction alps_raw_eventfunction alps_post_resetfunction alps_post_resumefunction u1_initfunction T4_initfunction alps_sp_openfunction alps_sp_closefunction alps_input_configuredfunction alps_input_mappingfunction alps_probe
Annotated Snippet
struct alps_dev {
struct input_dev *input;
struct input_dev *input2;
struct hid_device *hdev;
enum dev_num dev_type;
u8 max_fingers;
u8 has_sp;
u8 sp_btn_info;
u32 x_active_len_mm;
u32 y_active_len_mm;
u32 x_max;
u32 y_max;
u32 x_min;
u32 y_min;
u32 btn_cnt;
u32 sp_btn_cnt;
};
struct t4_contact_data {
u8 palm;
u8 x_lo;
u8 x_hi;
u8 y_lo;
u8 y_hi;
};
struct t4_input_report {
u8 reportID;
u8 numContacts;
struct t4_contact_data contact[5];
u8 button;
u8 track[5];
u8 zx[5], zy[5];
u8 palmTime[5];
u8 kilroy;
u16 timeStamp;
};
static u16 t4_calc_check_sum(u8 *buffer,
unsigned long offset, unsigned long length)
{
u16 sum1 = 0xFF, sum2 = 0xFF;
unsigned long i = 0;
if (offset + length >= 50)
return 0;
while (length > 0) {
u32 tlen = length > 20 ? 20 : length;
length -= tlen;
do {
sum1 += buffer[offset + i];
sum2 += sum1;
i++;
} while (--tlen > 0);
sum1 = (sum1 & 0xFF) + (sum1 >> 8);
sum2 = (sum2 & 0xFF) + (sum2 >> 8);
}
sum1 = (sum1 & 0xFF) + (sum1 >> 8);
sum2 = (sum2 & 0xFF) + (sum2 >> 8);
return(sum2 << 8 | sum1);
}
static int t4_read_write_register(struct hid_device *hdev, u32 address,
u8 *read_val, u8 write_val, bool read_flag)
{
int ret;
u16 check_sum;
u8 *input;
u8 *readbuf = NULL;
input = kzalloc(T4_FEATURE_REPORT_LEN, GFP_KERNEL);
if (!input)
return -ENOMEM;
input[0] = T4_FEATURE_REPORT_ID;
if (read_flag) {
input[1] = T4_CMD_REGISTER_READ;
input[8] = 0x00;
} else {
input[1] = T4_CMD_REGISTER_WRITE;
input[8] = write_val;
}
put_unaligned_le32(address, input + 2);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/hid.h`, `linux/input.h`, `linux/input/mt.h`, `linux/module.h`, `linux/unaligned.h`, `hid-ids.h`.
- Detected declarations: `struct alps_dev`, `struct t4_contact_data`, `struct t4_input_report`, `enum dev_num`, `function t4_calc_check_sum`, `function t4_read_write_register`, `function u1_read_write_register`, `function t4_raw_event`, `function u1_raw_event`, `function alps_raw_event`.
- 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.