drivers/input/touchscreen/ad7879.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/ad7879.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/ad7879.c- Extension
.c- Size
- 15336 bytes
- Lines
- 626
- 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.
- 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/device.hlinux/delay.hlinux/export.hlinux/input.hlinux/interrupt.hlinux/irq.hlinux/property.hlinux/regmap.hlinux/slab.hlinux/gpio/driver.hlinux/input/touchscreen.hlinux/module.had7879.h
Detected Declarations
struct ad7879function ad7879_readfunction ad7879_writefunction ad7879_reportfunction ad7879_ts_event_releasefunction ad7879_timerfunction ad7879_irqfunction __ad7879_enablefunction __ad7879_disablefunction ad7879_openfunction ad7879_closefunction ad7879_suspendfunction ad7879_resumefunction ad7879_togglefunction ad7879_disable_showfunction ad7879_disable_storefunction ad7879_gpio_direction_inputfunction ad7879_gpio_direction_outputfunction ad7879_gpio_get_valuefunction ad7879_gpio_set_valuefunction ad7879_gpio_addfunction ad7879_gpio_addfunction ad7879_parse_dtfunction ad7879_probeexport ad7879_pm_opsexport ad7879_groupsexport ad7879_probe
Annotated Snippet
struct ad7879 {
struct regmap *regmap;
struct device *dev;
struct input_dev *input;
struct timer_list timer;
#ifdef CONFIG_GPIOLIB
struct gpio_chip gc;
struct mutex mutex;
#endif
unsigned int irq;
bool disabled; /* P: input->mutex */
bool suspended; /* P: input->mutex */
bool swap_xy;
u16 conversion_data[AD7879_NR_SENSE];
char phys[32];
u8 first_conversion_delay;
u8 acquisition_time;
u8 averaging;
u8 pen_down_acc_interval;
u8 median;
u16 x_plate_ohms;
u16 cmd_crtl1;
u16 cmd_crtl2;
u16 cmd_crtl3;
int x;
int y;
int Rt;
};
static int ad7879_read(struct ad7879 *ts, u8 reg)
{
unsigned int val;
int error;
error = regmap_read(ts->regmap, reg, &val);
if (error) {
dev_err(ts->dev, "failed to read register %#02x: %d\n",
reg, error);
return error;
}
return val;
}
static int ad7879_write(struct ad7879 *ts, u8 reg, u16 val)
{
int error;
error = regmap_write(ts->regmap, reg, val);
if (error) {
dev_err(ts->dev,
"failed to write %#04x to register %#02x: %d\n",
val, reg, error);
return error;
}
return 0;
}
static int ad7879_report(struct ad7879 *ts)
{
struct input_dev *input_dev = ts->input;
unsigned Rt;
u16 x, y, z1, z2;
x = ts->conversion_data[AD7879_SEQ_XPOS] & MAX_12BIT;
y = ts->conversion_data[AD7879_SEQ_YPOS] & MAX_12BIT;
z1 = ts->conversion_data[AD7879_SEQ_Z1] & MAX_12BIT;
z2 = ts->conversion_data[AD7879_SEQ_Z2] & MAX_12BIT;
if (ts->swap_xy)
swap(x, y);
/*
* The samples processed here are already preprocessed by the AD7879.
* The preprocessing function consists of a median and an averaging
* filter. The combination of these two techniques provides a robust
* solution, discarding the spurious noise in the signal and keeping
* only the data of interest. The size of both filters is
* programmable. (dev.platform_data, see linux/platform_data/ad7879.h)
* Other user-programmable conversion controls include variable
* acquisition time, and first conversion delay. Up to 16 averages can
* be taken per conversion.
*/
if (likely(x && z1)) {
/* compute touch pressure resistance using equation #1 */
Rt = (z2 - z1) * x * ts->x_plate_ohms;
Rt /= z1;
Rt = (Rt + 2047) >> 12;
Annotation
- Immediate include surface: `linux/device.h`, `linux/delay.h`, `linux/export.h`, `linux/input.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/property.h`, `linux/regmap.h`.
- Detected declarations: `struct ad7879`, `function ad7879_read`, `function ad7879_write`, `function ad7879_report`, `function ad7879_ts_event_release`, `function ad7879_timer`, `function ad7879_irq`, `function __ad7879_enable`, `function __ad7879_disable`, `function ad7879_open`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: integration 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.