drivers/input/touchscreen/tsc200x-core.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/tsc200x-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/tsc200x-core.c- Extension
.c- Size
- 14507 bytes
- Lines
- 598
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/kernel.hlinux/module.hlinux/input.hlinux/input/touchscreen.hlinux/interrupt.hlinux/delay.hlinux/pm.hlinux/of.hlinux/regulator/consumer.hlinux/regmap.hlinux/gpio/consumer.htsc200x-core.h
Detected Declarations
struct tsc200x_datastruct tsc200xfunction tsc200x_update_pen_statefunction tsc200x_irq_threadfunction scoped_guardfunction tsc200x_penup_timerfunction tsc200x_start_scanfunction tsc200x_stop_scanfunction tsc200x_resetfunction __tsc200x_disablefunction __tsc200x_enablefunction tsc200x_do_selftestfunction tsc200x_selftest_showfunction scoped_guardfunction tsc200x_attr_is_visiblefunction tsc200x_esd_workfunction scoped_guardfunction tsc200x_openfunction tsc200x_closefunction tsc200x_probefunction tsc200x_suspendfunction tsc200x_resumeexport tsc200x_regmap_configexport tsc200x_groupsexport tsc200x_probe
Annotated Snippet
struct tsc200x_data {
u16 x;
u16 y;
u16 z1;
u16 z2;
} __packed;
#define TSC200X_DATA_REGS 4
struct tsc200x {
struct device *dev;
struct regmap *regmap;
__u16 bustype;
struct input_dev *idev;
char phys[32];
struct mutex mutex;
/* raw copy of previous x,y,z */
int in_x;
int in_y;
int in_z1;
int in_z2;
struct touchscreen_properties prop;
spinlock_t lock;
struct timer_list penup_timer;
unsigned int esd_timeout;
struct delayed_work esd_work;
unsigned long last_valid_interrupt;
unsigned int x_plate_ohm;
bool opened;
bool suspended;
bool pen_down;
struct gpio_desc *reset_gpio;
int (*tsc200x_cmd)(struct device *dev, u8 cmd);
int irq;
bool wake_irq_enabled;
};
static void tsc200x_update_pen_state(struct tsc200x *ts,
int x, int y, int pressure)
{
if (pressure) {
touchscreen_report_pos(ts->idev, &ts->prop, x, y, false);
input_report_abs(ts->idev, ABS_PRESSURE, pressure);
if (!ts->pen_down) {
input_report_key(ts->idev, BTN_TOUCH, !!pressure);
ts->pen_down = true;
}
} else {
input_report_abs(ts->idev, ABS_PRESSURE, 0);
if (ts->pen_down) {
input_report_key(ts->idev, BTN_TOUCH, 0);
ts->pen_down = false;
}
}
input_sync(ts->idev);
dev_dbg(ts->dev, "point(%4d,%4d), pressure (%4d)\n", x, y,
pressure);
}
static irqreturn_t tsc200x_irq_thread(int irq, void *_ts)
{
struct tsc200x *ts = _ts;
unsigned int pressure;
struct tsc200x_data tsdata;
int error;
/* read the coordinates */
error = regmap_bulk_read(ts->regmap, TSC200X_REG_X, &tsdata,
TSC200X_DATA_REGS);
if (unlikely(error))
goto out;
/* validate position */
if (unlikely(tsdata.x > MAX_12BIT || tsdata.y > MAX_12BIT))
goto out;
/* Skip reading if the pressure components are out of range */
if (unlikely(tsdata.z1 == 0 || tsdata.z2 > MAX_12BIT))
goto out;
if (unlikely(tsdata.z1 >= tsdata.z2))
Annotation
- Immediate include surface: `linux/export.h`, `linux/kernel.h`, `linux/module.h`, `linux/input.h`, `linux/input/touchscreen.h`, `linux/interrupt.h`, `linux/delay.h`, `linux/pm.h`.
- Detected declarations: `struct tsc200x_data`, `struct tsc200x`, `function tsc200x_update_pen_state`, `function tsc200x_irq_thread`, `function scoped_guard`, `function tsc200x_penup_timer`, `function tsc200x_start_scan`, `function tsc200x_stop_scan`, `function tsc200x_reset`, `function __tsc200x_disable`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.