drivers/input/touchscreen.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen.c- Extension
.c- Size
- 6198 bytes
- Lines
- 209
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/property.hlinux/input.hlinux/input/mt.hlinux/input/touchscreen.hlinux/module.h
Detected Declarations
function Copyrightfunction touchscreen_set_paramsfunction touchscreen_parse_propertiesfunction touchscreen_apply_prop_to_x_yfunction touchscreen_set_mt_posfunction touchscreen_report_posexport touchscreen_parse_propertiesexport touchscreen_set_mt_posexport touchscreen_report_pos
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Generic helper functions for touchscreens and other two-dimensional
* pointing devices
*
* Copyright (c) 2014 Sebastian Reichel <sre@kernel.org>
*/
#include <linux/export.h>
#include <linux/property.h>
#include <linux/input.h>
#include <linux/input/mt.h>
#include <linux/input/touchscreen.h>
#include <linux/module.h>
static bool touchscreen_get_prop_u32(struct device *dev,
const char *property,
unsigned int default_value,
unsigned int *value)
{
u32 val;
int error;
error = device_property_read_u32(dev, property, &val);
if (error) {
*value = default_value;
return false;
}
*value = val;
return true;
}
static void touchscreen_set_params(struct input_dev *dev,
unsigned long axis,
int min, int max, int fuzz)
{
struct input_absinfo *absinfo;
if (!test_bit(axis, dev->absbit)) {
dev_warn(&dev->dev,
"Parameters are specified but the axis %lu is not set up\n",
axis);
return;
}
absinfo = &dev->absinfo[axis];
absinfo->minimum = min;
absinfo->maximum = max;
absinfo->fuzz = fuzz;
}
/**
* touchscreen_parse_properties - parse common touchscreen properties
* @input: input device that should be parsed
* @multitouch: specifies whether parsed properties should be applied to
* single-touch or multi-touch axes
* @prop: pointer to a struct touchscreen_properties into which to store
* axis swap and invert info for use with touchscreen_report_x_y();
* or %NULL
*
* This function parses common properties for touchscreens and sets up the
* input device accordingly. The function keeps previously set up default
* values if no value is specified.
*/
void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
struct touchscreen_properties *prop)
{
struct device *dev = input->dev.parent;
struct input_absinfo *absinfo;
unsigned int axis, axis_x, axis_y;
unsigned int minimum, maximum, fuzz;
bool data_present;
input_alloc_absinfo(input);
if (!input->absinfo)
return;
axis_x = multitouch ? ABS_MT_POSITION_X : ABS_X;
axis_y = multitouch ? ABS_MT_POSITION_Y : ABS_Y;
data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-x",
input_abs_get_min(input, axis_x),
&minimum);
data_present |= touchscreen_get_prop_u32(dev, "touchscreen-size-x",
input_abs_get_max(input,
axis_x) + 1,
&maximum);
data_present |= touchscreen_get_prop_u32(dev, "touchscreen-fuzz-x",
input_abs_get_fuzz(input, axis_x),
Annotation
- Immediate include surface: `linux/export.h`, `linux/property.h`, `linux/input.h`, `linux/input/mt.h`, `linux/input/touchscreen.h`, `linux/module.h`.
- Detected declarations: `function Copyright`, `function touchscreen_set_params`, `function touchscreen_parse_properties`, `function touchscreen_apply_prop_to_x_y`, `function touchscreen_set_mt_pos`, `function touchscreen_report_pos`, `export touchscreen_parse_properties`, `export touchscreen_set_mt_pos`, `export touchscreen_report_pos`.
- 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.