drivers/input/touchscreen/migor_ts.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/migor_ts.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/migor_ts.c- Extension
.c- Size
- 5501 bytes
- Lines
- 234
- 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/kernel.hlinux/input.hlinux/interrupt.hlinux/pm.hlinux/slab.hasm/io.hlinux/i2c.hlinux/timer.h
Detected Declarations
struct migor_ts_privfunction migor_ts_isrfunction migor_ts_openfunction migor_ts_closefunction migor_ts_probefunction migor_ts_removefunction migor_ts_suspendfunction migor_ts_resume
Annotated Snippet
struct migor_ts_priv {
struct i2c_client *client;
struct input_dev *input;
int irq;
};
static const u_int8_t migor_ts_ena_seq[17] = { 0x33, 0x22, 0x11,
0x01, 0x06, 0x07, };
static const u_int8_t migor_ts_dis_seq[17] = { };
static irqreturn_t migor_ts_isr(int irq, void *dev_id)
{
struct migor_ts_priv *priv = dev_id;
unsigned short xpos, ypos;
unsigned char event;
u_int8_t buf[16];
/*
* The touch screen controller chip is hooked up to the CPU
* using I2C and a single interrupt line. The interrupt line
* is pulled low whenever someone taps the screen. To deassert
* the interrupt line we need to acknowledge the interrupt by
* communicating with the controller over the slow i2c bus.
*
* Since I2C bus controller may sleep we are using threaded
* IRQ here.
*/
memset(buf, 0, sizeof(buf));
/* Set Index 0 */
buf[0] = 0;
if (i2c_master_send(priv->client, buf, 1) != 1) {
dev_err(&priv->client->dev, "Unable to write i2c index\n");
goto out;
}
/* Now do Page Read */
if (i2c_master_recv(priv->client, buf, sizeof(buf)) != sizeof(buf)) {
dev_err(&priv->client->dev, "Unable to read i2c page\n");
goto out;
}
ypos = ((buf[9] & 0x03) << 8 | buf[8]);
xpos = ((buf[11] & 0x03) << 8 | buf[10]);
event = buf[12];
switch (event) {
case EVENT_PENDOWN:
case EVENT_REPEAT:
input_report_key(priv->input, BTN_TOUCH, 1);
input_report_abs(priv->input, ABS_X, ypos); /*X-Y swap*/
input_report_abs(priv->input, ABS_Y, xpos);
input_sync(priv->input);
break;
case EVENT_PENUP:
input_report_key(priv->input, BTN_TOUCH, 0);
input_sync(priv->input);
break;
}
out:
return IRQ_HANDLED;
}
static int migor_ts_open(struct input_dev *dev)
{
struct migor_ts_priv *priv = input_get_drvdata(dev);
struct i2c_client *client = priv->client;
int count;
/* enable controller */
count = i2c_master_send(client, migor_ts_ena_seq,
sizeof(migor_ts_ena_seq));
if (count != sizeof(migor_ts_ena_seq)) {
dev_err(&client->dev, "Unable to enable touchscreen.\n");
return -ENXIO;
}
return 0;
}
static void migor_ts_close(struct input_dev *dev)
{
struct migor_ts_priv *priv = input_get_drvdata(dev);
struct i2c_client *client = priv->client;
disable_irq(priv->irq);
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/input.h`, `linux/interrupt.h`, `linux/pm.h`, `linux/slab.h`, `asm/io.h`, `linux/i2c.h`.
- Detected declarations: `struct migor_ts_priv`, `function migor_ts_isr`, `function migor_ts_open`, `function migor_ts_close`, `function migor_ts_probe`, `function migor_ts_remove`, `function migor_ts_suspend`, `function migor_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.