drivers/input/touchscreen/ads7846.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/ads7846.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/ads7846.c- Extension
.c- Size
- 35116 bytes
- Lines
- 1427
- 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/types.hlinux/hwmon.hlinux/err.hlinux/sched.hlinux/delay.hlinux/input.hlinux/input/touchscreen.hlinux/interrupt.hlinux/slab.hlinux/pm.hlinux/property.hlinux/gpio/consumer.hlinux/spi/spi.hlinux/spi/ads7846.hlinux/regulator/consumer.hlinux/module.hlinux/unaligned.h
Detected Declarations
struct ads7846_bufstruct ads7846_buf_layoutstruct ads7846_packetstruct ads7846struct ser_reqstruct ads7845_ser_reqenum ads7846_filterenum ads7846_cmdsfunction get_pendown_statefunction ads7846_report_pen_upfunction ads7846_stopfunction ads7846_restartfunction __ads7846_disablefunction __ads7846_enablefunction ads7846_disablefunction ads7846_enablefunction ads7846_read12_serfunction scoped_guardfunction ads7845_read12_serfunction scoped_guardfunction null_adjustfunction vaux_adjustfunction vbatt_adjustfunction ads7846_is_visiblefunction ads784x_hwmon_registerfunction ads784x_hwmon_registerfunction ads7846_pen_down_showfunction ads7846_disable_showfunction ads7846_disable_storefunction ads7846_debounce_filterfunction ads7846_no_filterfunction ads7846_get_valuefunction ads7846_set_cmd_valfunction ads7846_get_cmdfunction ads7846_cmd_need_settlefunction ads7846_filterfunction ads7846_wait_for_hsyncfunction ads7846_read_statefunction ads7846_report_statefunction statefunction ads7846_hard_irqfunction ads7846_irqfunction ads7846_suspendfunction ads7846_resumefunction ads7846_setup_pendownfunction ads7846_setup_spi_msgfunction ads7846_regulator_disablefunction ads7846_probe
Annotated Snippet
struct ads7846_buf {
u8 cmd;
__be16 data;
} __packed;
struct ads7846_buf_layout {
unsigned int offset;
unsigned int count;
unsigned int skip;
};
/*
* We allocate this separately to avoid cache line sharing issues when
* driver is used with DMA-based SPI controllers (like atmel_spi) on
* systems where main memory is not DMA-coherent (most non-x86 boards).
*/
struct ads7846_packet {
unsigned int count;
unsigned int count_skip;
unsigned int cmds;
unsigned int last_cmd_idx;
struct ads7846_buf_layout l[5];
struct ads7846_buf *rx;
struct ads7846_buf *tx;
struct ads7846_buf pwrdown_cmd;
bool ignore;
u16 x, y, z1, z2;
};
struct ads7846 {
struct input_dev *input;
char phys[32];
char name[32];
struct spi_device *spi;
struct regulator *reg;
u16 model;
u16 vref_mv;
u16 vref_delay_usecs;
u16 x_plate_ohms;
u16 pressure_max;
bool swap_xy;
bool use_internal;
struct ads7846_packet *packet;
struct spi_transfer xfer[18];
struct spi_message msg[5];
int msg_count;
wait_queue_head_t wait;
bool pendown;
int read_cnt;
int read_rep;
int last_read;
u16 debounce_max;
u16 debounce_tol;
u16 debounce_rep;
u16 penirq_recheck_delay_usecs;
struct touchscreen_properties core_prop;
struct mutex lock;
bool stopped; /* P: lock */
bool disabled; /* P: lock */
bool suspended; /* P: lock */
int (*filter)(void *data, int data_idx, int *val);
void *filter_data;
int (*get_pendown_state)(void);
struct gpio_desc *gpio_pendown;
struct gpio_desc *gpio_hsync;
void (*wait_for_sync)(void);
};
enum ads7846_filter {
ADS7846_FILTER_OK,
ADS7846_FILTER_REPEAT,
ADS7846_FILTER_IGNORE,
};
/* leave chip selected when we're done, for quicker re-select? */
Annotation
- Immediate include surface: `linux/types.h`, `linux/hwmon.h`, `linux/err.h`, `linux/sched.h`, `linux/delay.h`, `linux/input.h`, `linux/input/touchscreen.h`, `linux/interrupt.h`.
- Detected declarations: `struct ads7846_buf`, `struct ads7846_buf_layout`, `struct ads7846_packet`, `struct ads7846`, `struct ser_req`, `struct ads7845_ser_req`, `enum ads7846_filter`, `enum ads7846_cmds`, `function get_pendown_state`, `function ads7846_report_pen_up`.
- 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.