drivers/input/touchscreen/hynitron-cst816x.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/hynitron-cst816x.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/hynitron-cst816x.c- Extension
.c- Size
- 5893 bytes
- Lines
- 254
- 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/delay.hlinux/device.hlinux/err.hlinux/gpio/consumer.hlinux/i2c.hlinux/input.hlinux/unaligned.hlinux/interrupt.hlinux/module.h
Detected Declarations
struct cst816x_touchstruct cst816x_privfunction cst816x_parse_keycodesfunction cst816x_i2c_read_registerfunction cst816x_gest_idxfunction cst816x_process_touchfunction cst816x_register_inputfunction cst816x_resetfunction cst816x_irq_cbfunction cst816x_probe
Annotated Snippet
struct cst816x_touch {
u8 gest;
u8 active;
u16 abs_x;
u16 abs_y;
} __packed;
struct cst816x_priv {
struct i2c_client *client;
struct gpio_desc *reset;
struct input_dev *input;
unsigned int keycode[CST816X_NUM_KEYS];
unsigned int keycodemax;
};
static int cst816x_parse_keycodes(struct device *dev, struct cst816x_priv *priv)
{
int count;
int error;
if (device_property_present(dev, "linux,keycodes")) {
count = device_property_count_u32(dev, "linux,keycodes");
if (count < 0) {
error = count;
dev_err(dev, "failed to count keys: %d\n", error);
return error;
} else if (count > ARRAY_SIZE(priv->keycode)) {
dev_err(dev, "too many keys defined: %d\n", count);
return -EINVAL;
}
priv->keycodemax = count;
error = device_property_read_u32_array(dev, "linux,keycodes",
priv->keycode,
priv->keycodemax);
if (error) {
dev_err(dev, "failed to read keycodes: %d\n", error);
return error;
}
}
return 0;
}
static int cst816x_i2c_read_register(struct cst816x_priv *priv, u8 reg,
void *buf, size_t len)
{
struct i2c_msg xfer[] = {
{
.addr = priv->client->addr,
.flags = 0,
.buf = ®,
.len = sizeof(reg),
},
{
.addr = priv->client->addr,
.flags = I2C_M_RD,
.buf = buf,
.len = len,
},
};
int error;
int ret;
ret = i2c_transfer(priv->client->adapter, xfer, ARRAY_SIZE(xfer));
if (ret != ARRAY_SIZE(xfer)) {
error = ret < 0 ? ret : -EIO;
dev_err(&priv->client->dev, "i2c rx err: %d\n", error);
return error;
}
return 0;
}
static u8 cst816x_gest_idx(u8 gest)
{
u8 index;
switch (gest) {
case 0x01: /* Slide up gesture */
case 0x02: /* Slide down gesture */
case 0x03: /* Slide left gesture */
case 0x04: /* Slide right gesture */
index = gest;
break;
case 0x0c: /* Long press gesture */
default:
index = CST816X_NUM_KEYS;
break;
}
Annotation
- Immediate include surface: `linux/delay.h`, `linux/device.h`, `linux/err.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/input.h`, `linux/unaligned.h`, `linux/interrupt.h`.
- Detected declarations: `struct cst816x_touch`, `struct cst816x_priv`, `function cst816x_parse_keycodes`, `function cst816x_i2c_read_register`, `function cst816x_gest_idx`, `function cst816x_process_touch`, `function cst816x_register_input`, `function cst816x_reset`, `function cst816x_irq_cb`, `function cst816x_probe`.
- 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.