drivers/input/touchscreen/ad7877.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/ad7877.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/ad7877.c- Extension
.c- Size
- 19760 bytes
- Lines
- 815
- 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.
- 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/device.hlinux/delay.hlinux/input.hlinux/interrupt.hlinux/pm.hlinux/slab.hlinux/spi/spi.hlinux/spi/ad7877.hlinux/module.hasm/irq.h
Detected Declarations
struct ser_reqstruct ad7877function ad7877_readfunction ad7877_writefunction ad7877_read_adcfunction ad7877_process_datafunction ad7877_ts_event_releasefunction ad7877_timerfunction ad7877_irqfunction scoped_guardfunction ad7877_disablefunction ad7877_enablefunction ad7877_disable_showfunction ad7877_disable_storefunction ad7877_dac_showfunction ad7877_dac_storefunction ad7877_gpio3_showfunction ad7877_gpio3_storefunction ad7877_gpio4_showfunction ad7877_gpio4_storefunction ad7877_attr_is_visiblefunction ad7877_setup_ts_def_msgfunction ad7877_probefunction ad7877_suspendfunction ad7877_resume
Annotated Snippet
struct ser_req {
u16 reset;
u16 ref_on;
u16 command;
struct spi_message msg;
struct spi_transfer xfer[6];
/*
* DMA (thus cache coherency maintenance) requires the
* transfer buffers to live in their own cache lines.
*/
u16 sample ____cacheline_aligned;
};
struct ad7877 {
struct input_dev *input;
char phys[32];
struct spi_device *spi;
u16 model;
u16 vref_delay_usecs;
u16 x_plate_ohms;
u16 pressure_max;
u16 cmd_crtl1;
u16 cmd_crtl2;
u16 cmd_dummy;
u16 dac;
u8 stopacq_polarity;
u8 first_conversion_delay;
u8 acquisition_time;
u8 averaging;
u8 pen_down_acc_interval;
struct spi_transfer xfer[AD7877_NR_SENSE + 2];
struct spi_message msg;
struct mutex mutex;
bool disabled; /* P: mutex */
bool gpio3; /* P: mutex */
bool gpio4; /* P: mutex */
spinlock_t lock;
struct timer_list timer; /* P: lock */
/*
* DMA (thus cache coherency maintenance) requires the
* transfer buffers to live in their own cache lines.
*/
u16 conversion_data[AD7877_NR_SENSE] ____cacheline_aligned;
};
static bool gpio3;
module_param(gpio3, bool, 0);
MODULE_PARM_DESC(gpio3, "If gpio3 is set to 1 AUX3 acts as GPIO3");
static int ad7877_read(struct spi_device *spi, u16 reg)
{
struct ser_req *req;
int status, ret;
req = kzalloc_obj(*req);
if (!req)
return -ENOMEM;
spi_message_init(&req->msg);
req->command = (u16) (AD7877_WRITEADD(AD7877_REG_CTRL1) |
AD7877_READADD(reg));
req->xfer[0].tx_buf = &req->command;
req->xfer[0].len = 2;
req->xfer[0].cs_change = 1;
req->xfer[1].rx_buf = &req->sample;
req->xfer[1].len = 2;
spi_message_add_tail(&req->xfer[0], &req->msg);
spi_message_add_tail(&req->xfer[1], &req->msg);
status = spi_sync(spi, &req->msg);
ret = status ? : req->sample;
kfree(req);
return ret;
}
static int ad7877_write(struct spi_device *spi, u16 reg, u16 val)
{
Annotation
- Immediate include surface: `linux/device.h`, `linux/delay.h`, `linux/input.h`, `linux/interrupt.h`, `linux/pm.h`, `linux/slab.h`, `linux/spi/spi.h`, `linux/spi/ad7877.h`.
- Detected declarations: `struct ser_req`, `struct ad7877`, `function ad7877_read`, `function ad7877_write`, `function ad7877_read_adc`, `function ad7877_process_data`, `function ad7877_ts_event_release`, `function ad7877_timer`, `function ad7877_irq`, `function scoped_guard`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: source 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.