drivers/input/touchscreen/st1232.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/st1232.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/st1232.c- Extension
.c- Size
- 12029 bytes
- Lines
- 487
- 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/gpio/consumer.hlinux/i2c.hlinux/input.hlinux/input/mt.hlinux/input/touch-overlay.hlinux/input/touchscreen.hlinux/interrupt.hlinux/module.hlinux/of.hlinux/pm_qos.hlinux/slab.hlinux/types.hasm/byteorder.h
Detected Declarations
struct st_chip_infostruct st1232_ts_datafunction fw_version_showfunction fw_revision_showfunction st1232_ts_read_datafunction st1232_ts_wait_readyfunction st1232_ts_read_fw_versionfunction st1232_ts_read_resolutionfunction st1232_ts_parse_and_reportfunction st1232_ts_irq_handlerfunction st1232_ts_powerfunction st1232_ts_power_offfunction st1232_ts_probefunction st1232_ts_suspendfunction st1232_ts_resume
Annotated Snippet
struct st_chip_info {
bool have_z;
u16 max_area;
u16 max_fingers;
};
struct st1232_ts_data {
struct i2c_client *client;
struct input_dev *input_dev;
struct touchscreen_properties prop;
struct dev_pm_qos_request low_latency_req;
struct gpio_desc *reset_gpio;
const struct st_chip_info *chip_info;
struct list_head touch_overlay_list;
int read_buf_len;
u8 *read_buf;
u8 fw_version;
u32 fw_revision;
};
static ssize_t fw_version_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct i2c_client *client = to_i2c_client(dev);
struct st1232_ts_data *st1232_ts = i2c_get_clientdata(client);
return sysfs_emit(buf, "%u\n", st1232_ts->fw_version);
}
static ssize_t fw_revision_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct i2c_client *client = to_i2c_client(dev);
struct st1232_ts_data *st1232_ts = i2c_get_clientdata(client);
return sysfs_emit(buf, "%08x\n", st1232_ts->fw_revision);
}
static DEVICE_ATTR_RO(fw_version);
static DEVICE_ATTR_RO(fw_revision);
static struct attribute *st1232_attrs[] = {
&dev_attr_fw_version.attr,
&dev_attr_fw_revision.attr,
NULL,
};
ATTRIBUTE_GROUPS(st1232);
static int st1232_ts_read_data(struct st1232_ts_data *ts, u8 reg,
unsigned int n)
{
struct i2c_client *client = ts->client;
struct i2c_msg msg[] = {
{
.addr = client->addr,
.len = sizeof(reg),
.buf = ®,
},
{
.addr = client->addr,
.flags = I2C_M_RD | I2C_M_DMA_SAFE,
.len = n,
.buf = ts->read_buf,
}
};
int ret;
ret = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg));
if (ret != ARRAY_SIZE(msg))
return ret < 0 ? ret : -EIO;
return 0;
}
static int st1232_ts_wait_ready(struct st1232_ts_data *ts)
{
unsigned int retries;
int error;
for (retries = 100; retries; retries--) {
error = st1232_ts_read_data(ts, REG_STATUS, 1);
if (!error) {
switch (ts->read_buf[0]) {
case STATUS_NORMAL | ERROR_NONE:
case STATUS_IDLE | ERROR_NONE:
return 0;
}
}
usleep_range(1000, 2000);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/input.h`, `linux/input/mt.h`, `linux/input/touch-overlay.h`, `linux/input/touchscreen.h`, `linux/interrupt.h`.
- Detected declarations: `struct st_chip_info`, `struct st1232_ts_data`, `function fw_version_show`, `function fw_revision_show`, `function st1232_ts_read_data`, `function st1232_ts_wait_ready`, `function st1232_ts_read_fw_version`, `function st1232_ts_read_resolution`, `function st1232_ts_parse_and_report`, `function st1232_ts_irq_handler`.
- 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.