drivers/input/input-mt.c
Source file repositories/reference/linux-study-clean/drivers/input/input-mt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/input-mt.c- Extension
.c- Size
- 13688 bytes
- Lines
- 535
- Domain
- Driver Families
- Bucket
- drivers/input
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/input/mt.hlinux/export.hlinux/slab.hinput-core-private.h
Detected Declarations
function Copyrightfunction input_mt_init_slotsfunction input_mt_destroy_slotsfunction input_mt_report_slot_statefunction input_mt_report_finger_countfunction input_mt_report_pointer_emulationfunction __input_mt_drop_unusedfunction input_mt_drop_unusedfunction input_mt_release_slotsfunction input_mt_sync_framefunction adjust_dualfunction find_reduced_matrixfunction input_mt_set_matrixfunction input_mt_set_slotsfunction input_mt_assign_slotsfunction input_mt_get_slot_by_keyexport input_mt_init_slotsexport input_mt_destroy_slotsexport input_mt_report_slot_stateexport input_mt_report_finger_countexport input_mt_report_pointer_emulationexport input_mt_drop_unusedexport input_mt_sync_frameexport input_mt_assign_slotsexport input_mt_get_slot_by_key
Annotated Snippet
if ((id - oldid) & TRKID_SGN) {
oldest = ps;
oldid = id;
}
if (test_bit(ABS_MT_PRESSURE, dev->absbit)) {
p = input_mt_get_value(ps, ABS_MT_PRESSURE);
if (mt->flags & INPUT_MT_TOTAL_FORCE)
reported_p += p;
else if (oldid == id)
reported_p = p;
}
count++;
}
input_event(dev, EV_KEY, BTN_TOUCH, count > 0);
if (use_count) {
if (count == 0 &&
!test_bit(ABS_MT_DISTANCE, dev->absbit) &&
test_bit(ABS_DISTANCE, dev->absbit) &&
input_abs_get_val(dev, ABS_DISTANCE) != 0) {
/*
* Force reporting BTN_TOOL_FINGER for devices that
* only report general hover (and not per-contact
* distance) when contact is in proximity but not
* on the surface.
*/
count = 1;
}
input_mt_report_finger_count(dev, count);
}
if (oldest) {
int x = input_mt_get_value(oldest, ABS_MT_POSITION_X);
int y = input_mt_get_value(oldest, ABS_MT_POSITION_Y);
input_event(dev, EV_ABS, ABS_X, x);
input_event(dev, EV_ABS, ABS_Y, y);
if (test_bit(ABS_MT_PRESSURE, dev->absbit))
input_event(dev, EV_ABS, ABS_PRESSURE, reported_p);
} else {
if (test_bit(ABS_MT_PRESSURE, dev->absbit))
input_event(dev, EV_ABS, ABS_PRESSURE, 0);
}
}
EXPORT_SYMBOL(input_mt_report_pointer_emulation);
static void __input_mt_drop_unused(struct input_dev *dev, struct input_mt *mt)
{
int i;
lockdep_assert_held(&dev->event_lock);
for (i = 0; i < mt->num_slots; i++) {
if (input_mt_is_active(&mt->slots[i]) &&
!input_mt_is_used(mt, &mt->slots[i])) {
input_handle_event(dev, EV_ABS, ABS_MT_SLOT, i);
input_handle_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1);
}
}
}
/**
* input_mt_drop_unused() - Inactivate slots not seen in this frame
* @dev: input device with allocated MT slots
*
* Lift all slots not seen since the last call to this function.
*/
void input_mt_drop_unused(struct input_dev *dev)
{
struct input_mt *mt = dev->mt;
if (mt) {
guard(spinlock_irqsave)(&dev->event_lock);
__input_mt_drop_unused(dev, mt);
mt->frame++;
}
}
EXPORT_SYMBOL(input_mt_drop_unused);
/**
* input_mt_release_slots() - Deactivate all slots
* @dev: input device with allocated MT slots
*
* Lift all active slots.
*/
void input_mt_release_slots(struct input_dev *dev)
Annotation
- Immediate include surface: `linux/input/mt.h`, `linux/export.h`, `linux/slab.h`, `input-core-private.h`.
- Detected declarations: `function Copyright`, `function input_mt_init_slots`, `function input_mt_destroy_slots`, `function input_mt_report_slot_state`, `function input_mt_report_finger_count`, `function input_mt_report_pointer_emulation`, `function __input_mt_drop_unused`, `function input_mt_drop_unused`, `function input_mt_release_slots`, `function input_mt_sync_frame`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: integration 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.