drivers/input/touch-overlay.c
Source file repositories/reference/linux-study-clean/drivers/input/touch-overlay.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touch-overlay.c- Extension
.c- Size
- 7763 bytes
- Lines
- 279
- 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/export.hlinux/input.hlinux/input/mt.hlinux/input/touch-overlay.hlinux/list.hlinux/module.hlinux/property.h
Detected Declarations
struct touch_overlay_segmentfunction touch_overlay_get_segmentfunction touch_overlay_mapfunction fwnode_for_each_available_child_nodefunction touch_overlay_get_touchscreen_absfunction list_for_eachfunction touch_overlay_segment_eventfunction touch_overlay_mapped_touchscreenfunction list_for_eachfunction touch_overlay_event_on_tsfunction list_for_eachfunction touch_overlay_button_eventfunction touch_overlay_sync_framefunction list_for_eachfunction processedexport touch_overlay_mapexport touch_overlay_get_touchscreen_absexport touch_overlay_mapped_touchscreenexport touch_overlay_sync_frameexport touch_overlay_process_contact
Annotated Snippet
struct touch_overlay_segment {
struct list_head list;
u32 x_origin;
u32 y_origin;
u32 x_size;
u32 y_size;
u32 key;
bool pressed;
int slot;
};
static int touch_overlay_get_segment(struct fwnode_handle *segment_node,
struct touch_overlay_segment *segment,
struct input_dev *input)
{
int error;
error = fwnode_property_read_u32(segment_node, "x-origin",
&segment->x_origin);
if (error)
return error;
error = fwnode_property_read_u32(segment_node, "y-origin",
&segment->y_origin);
if (error)
return error;
error = fwnode_property_read_u32(segment_node, "x-size",
&segment->x_size);
if (error)
return error;
error = fwnode_property_read_u32(segment_node, "y-size",
&segment->y_size);
if (error)
return error;
error = fwnode_property_read_u32(segment_node, "linux,code",
&segment->key);
if (!error)
input_set_capability(input, EV_KEY, segment->key);
else if (error != -EINVAL)
return error;
return 0;
}
/**
* touch_overlay_map - map overlay objects from the device tree and set
* key capabilities if buttons are defined.
* @list: pointer to the list that will hold the segments
* @input: pointer to the already allocated input_dev
*
* Returns 0 on success and error number otherwise.
*
* If buttons are defined, key capabilities are set accordingly.
*/
int touch_overlay_map(struct list_head *list, struct input_dev *input)
{
struct fwnode_handle *fw_segment;
struct device *dev = input->dev.parent;
struct touch_overlay_segment *segment;
int error;
struct fwnode_handle *overlay __free(fwnode_handle) =
device_get_named_child_node(dev, "touch-overlay");
if (!overlay)
return 0;
fwnode_for_each_available_child_node(overlay, fw_segment) {
segment = devm_kzalloc(dev, sizeof(*segment), GFP_KERNEL);
if (!segment) {
fwnode_handle_put(fw_segment);
return -ENOMEM;
}
error = touch_overlay_get_segment(fw_segment, segment, input);
if (error) {
fwnode_handle_put(fw_segment);
return error;
}
list_add_tail(&segment->list, list);
}
return 0;
}
EXPORT_SYMBOL(touch_overlay_map);
/**
* touch_overlay_get_touchscreen_abs - get abs size from the touchscreen area.
* @list: pointer to the list that holds the segments
Annotation
- Immediate include surface: `linux/export.h`, `linux/input.h`, `linux/input/mt.h`, `linux/input/touch-overlay.h`, `linux/list.h`, `linux/module.h`, `linux/property.h`.
- Detected declarations: `struct touch_overlay_segment`, `function touch_overlay_get_segment`, `function touch_overlay_map`, `function fwnode_for_each_available_child_node`, `function touch_overlay_get_touchscreen_abs`, `function list_for_each`, `function touch_overlay_segment_event`, `function touch_overlay_mapped_touchscreen`, `function list_for_each`, `function touch_overlay_event_on_ts`.
- 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.