drivers/input/touchscreen/egalax_ts.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/egalax_ts.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/egalax_ts.c- Extension
.c- Size
- 6788 bytes
- Lines
- 276
- 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/err.hlinux/module.hlinux/i2c.hlinux/interrupt.hlinux/input.hlinux/irq.hlinux/gpio/consumer.hlinux/delay.hlinux/slab.hlinux/string_choices.hlinux/bitops.hlinux/input/mt.h
Detected Declarations
struct egalax_tsfunction egalax_ts_interruptfunction egalax_wake_up_devicefunction egalax_firmware_versionfunction egalax_ts_probefunction egalax_ts_suspendfunction egalax_ts_resume
Annotated Snippet
struct egalax_ts {
struct i2c_client *client;
struct input_dev *input_dev;
};
static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
{
struct egalax_ts *ts = dev_id;
struct input_dev *input_dev = ts->input_dev;
struct i2c_client *client = ts->client;
u8 buf[MAX_I2C_DATA_LEN];
int id, ret, x, y, z;
int tries = 0;
bool down, valid;
u8 state;
do {
ret = i2c_master_recv(client, buf, MAX_I2C_DATA_LEN);
} while (ret == -EAGAIN && tries++ < EGALAX_MAX_TRIES);
if (ret < 0)
return IRQ_HANDLED;
if (buf[0] != REPORT_MODE_MTTOUCH) {
/* ignore mouse events and vendor events */
return IRQ_HANDLED;
}
state = buf[1];
x = (buf[3] << 8) | buf[2];
y = (buf[5] << 8) | buf[4];
z = (buf[7] << 8) | buf[6];
valid = state & EVENT_VALID_MASK;
id = (state & EVENT_ID_MASK) >> EVENT_ID_OFFSET;
down = state & EVENT_DOWN_UP;
if (!valid || id > MAX_SUPPORT_POINTS) {
dev_dbg(&client->dev, "point invalid\n");
return IRQ_HANDLED;
}
input_mt_slot(input_dev, id);
input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, down);
dev_dbg(&client->dev, "%s id:%d x:%d y:%d z:%d",
str_down_up(down), id, x, y, z);
if (down) {
input_report_abs(input_dev, ABS_MT_POSITION_X, x);
input_report_abs(input_dev, ABS_MT_POSITION_Y, y);
input_report_abs(input_dev, ABS_MT_PRESSURE, z);
}
input_mt_report_pointer_emulation(input_dev, true);
input_sync(input_dev);
return IRQ_HANDLED;
}
/* wake up controller by an falling edge of interrupt gpio. */
static int egalax_wake_up_device(struct i2c_client *client)
{
struct gpio_desc *gpio;
int ret;
/* wake up controller via an falling edge on IRQ gpio. */
gpio = gpiod_get(&client->dev, "wakeup", GPIOD_OUT_HIGH);
ret = PTR_ERR_OR_ZERO(gpio);
if (ret) {
if (ret != -EPROBE_DEFER)
dev_err(&client->dev,
"failed to request wakeup gpio, cannot wake up controller: %d\n",
ret);
return ret;
}
/* release the line */
gpiod_set_value_cansleep(gpio, 0);
/* controller should be woken up, return irq. */
gpiod_direction_input(gpio);
gpiod_put(gpio);
return 0;
}
static int egalax_firmware_version(struct i2c_client *client)
{
static const u8 cmd[MAX_I2C_DATA_LEN] = { 0x03, 0x03, 0xa, 0x01, 0x41 };
Annotation
- Immediate include surface: `linux/err.h`, `linux/module.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/input.h`, `linux/irq.h`, `linux/gpio/consumer.h`, `linux/delay.h`.
- Detected declarations: `struct egalax_ts`, `function egalax_ts_interrupt`, `function egalax_wake_up_device`, `function egalax_firmware_version`, `function egalax_ts_probe`, `function egalax_ts_suspend`, `function egalax_ts_resume`.
- 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.