drivers/input/touchscreen/tsc2007_core.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/tsc2007_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/tsc2007_core.c- Extension
.c- Size
- 10578 bytes
- Lines
- 436
- Domain
- Driver Families
- Bucket
- drivers/input
- 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.
- 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/module.hlinux/slab.hlinux/gpio/consumer.hlinux/input.hlinux/interrupt.hlinux/i2c.hlinux/math64.hlinux/mod_devicetable.hlinux/property.hlinux/platform_data/tsc2007.htsc2007.h
Detected Declarations
function Copyrightfunction tsc2007_read_valuesfunction tsc2007_calculate_resistancefunction tsc2007_is_pen_downfunction tsc2007_soft_irqfunction tsc2007_stopfunction tsc2007_openfunction tsc2007_closefunction tsc2007_get_pendown_state_gpiofunction tsc2007_probe_propertiesfunction tsc2007_probe_pdevfunction tsc2007_call_exit_platform_hwfunction tsc2007_probe
Annotated Snippet
scoped_guard(mutex, &ts->mlock) {
tsc2007_read_values(ts, &tc);
}
rt = tsc2007_calculate_resistance(ts, &tc);
if (!rt && !ts->get_pendown_state) {
/*
* If pressure reported is 0 and we don't have
* callback to check pendown state, we have to
* assume that pen was lifted up.
*/
break;
}
if (rt <= ts->max_rt) {
dev_dbg(&ts->client->dev,
"DOWN point(%4d,%4d), resistance (%4u)\n",
tc.x, tc.y, rt);
rt = ts->max_rt - rt;
input_report_key(input, BTN_TOUCH, 1);
touchscreen_report_pos(input, &ts->prop, tc.x, tc.y, false);
input_report_abs(input, ABS_PRESSURE, rt);
input_sync(input);
} else {
/*
* Sample found inconsistent by debouncing or pressure is
* beyond the maximum. Don't report it to user space,
* repeat at least once more the measurement.
*/
dev_dbg(&ts->client->dev, "ignored pressure %d\n", rt);
}
wait_event_timeout(ts->wait, ts->stopped, ts->poll_period);
}
dev_dbg(&ts->client->dev, "UP\n");
input_report_key(input, BTN_TOUCH, 0);
input_report_abs(input, ABS_PRESSURE, 0);
input_sync(input);
if (ts->clear_penirq)
ts->clear_penirq();
return IRQ_HANDLED;
}
static void tsc2007_stop(struct tsc2007 *ts)
{
ts->stopped = true;
mb();
wake_up(&ts->wait);
if (ts->irq)
disable_irq(ts->irq);
}
static int tsc2007_open(struct input_dev *input_dev)
{
struct tsc2007 *ts = input_get_drvdata(input_dev);
int err;
ts->stopped = false;
mb();
if (ts->irq)
enable_irq(ts->irq);
/* Prepare for touch readings - power down ADC and enable PENIRQ */
err = tsc2007_xfer(ts, PWRDOWN);
if (err < 0) {
tsc2007_stop(ts);
return err;
}
return 0;
}
static void tsc2007_close(struct input_dev *input_dev)
{
struct tsc2007 *ts = input_get_drvdata(input_dev);
tsc2007_stop(ts);
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/gpio/consumer.h`, `linux/input.h`, `linux/interrupt.h`, `linux/i2c.h`, `linux/math64.h`, `linux/mod_devicetable.h`.
- Detected declarations: `function Copyright`, `function tsc2007_read_values`, `function tsc2007_calculate_resistance`, `function tsc2007_is_pen_down`, `function tsc2007_soft_irq`, `function tsc2007_stop`, `function tsc2007_open`, `function tsc2007_close`, `function tsc2007_get_pendown_state_gpio`, `function tsc2007_probe_properties`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: source implementation candidate.
- 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.