drivers/input/touchscreen/stmfts.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/stmfts.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/stmfts.c- Extension
.c- Size
- 20081 bytes
- Lines
- 811
- 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/i2c.hlinux/input/mt.hlinux/input/touchscreen.hlinux/interrupt.hlinux/irq.hlinux/leds.hlinux/module.hlinux/pm_runtime.hlinux/regulator/consumer.h
Detected Declarations
struct stmfts_dataenum stmfts_regulatorsfunction stmfts_brightness_setfunction stmfts_brightness_getfunction stmfts_read_eventsfunction stmfts_report_contact_eventfunction stmfts_report_contact_releasefunction stmfts_report_hover_eventfunction stmfts_report_key_eventfunction stmfts_parse_eventsfunction stmfts_irq_handlerfunction stmfts_commandfunction stmfts_input_openfunction scoped_guardfunction stmfts_input_closefunction scoped_guardfunction stmfts_sysfs_chip_idfunction stmfts_sysfs_chip_versionfunction stmfts_sysfs_fw_verfunction stmfts_sysfs_config_idfunction stmfts_sysfs_config_versionfunction stmfts_sysfs_read_statusfunction stmfts_sysfs_hover_enable_readfunction stmfts_sysfs_hover_enable_writefunction stmfts_power_onfunction stmfts_power_offfunction stmfts_enable_ledfunction stmfts_probefunction stmfts_removefunction stmfts_runtime_suspendfunction stmfts_runtime_resumefunction stmfts_suspendfunction stmfts_resume
Annotated Snippet
struct stmfts_data {
struct i2c_client *client;
struct input_dev *input;
struct led_classdev led_cdev;
struct mutex mutex;
struct touchscreen_properties prop;
struct regulator_bulk_data regulators[2];
/*
* Presence of ledvdd will be used also to check
* whether the LED is supported.
*/
struct regulator *ledvdd;
u16 chip_id;
u8 chip_ver;
u16 fw_ver;
u8 config_id;
u8 config_ver;
u8 data[STMFTS_DATA_MAX_SIZE];
struct completion cmd_done;
bool use_key;
bool led_status;
bool hover_enabled;
bool running;
};
static int stmfts_brightness_set(struct led_classdev *led_cdev,
enum led_brightness value)
{
struct stmfts_data *sdata = container_of(led_cdev,
struct stmfts_data, led_cdev);
int err;
if (value != sdata->led_status && sdata->ledvdd) {
if (!value) {
regulator_disable(sdata->ledvdd);
} else {
err = regulator_enable(sdata->ledvdd);
if (err) {
dev_warn(&sdata->client->dev,
"failed to enable ledvdd regulator: %d\n",
err);
return err;
}
}
sdata->led_status = value;
}
return 0;
}
static enum led_brightness stmfts_brightness_get(struct led_classdev *led_cdev)
{
struct stmfts_data *sdata = container_of(led_cdev,
struct stmfts_data, led_cdev);
return !!regulator_is_enabled(sdata->ledvdd);
}
/*
* We can't simply use i2c_smbus_read_i2c_block_data because we
* need to read 256 bytes, which exceeds the 255-byte SMBus block limit.
*/
static int stmfts_read_events(struct stmfts_data *sdata)
{
u8 cmd = STMFTS_READ_ALL_EVENT;
struct i2c_msg msgs[2] = {
{
.addr = sdata->client->addr,
.len = 1,
.buf = &cmd,
},
{
.addr = sdata->client->addr,
.flags = I2C_M_RD,
.len = STMFTS_DATA_MAX_SIZE,
.buf = sdata->data,
},
};
int ret;
ret = i2c_transfer(sdata->client->adapter, msgs, ARRAY_SIZE(msgs));
if (ret < 0)
return ret;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/i2c.h`, `linux/input/mt.h`, `linux/input/touchscreen.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/leds.h`, `linux/module.h`.
- Detected declarations: `struct stmfts_data`, `enum stmfts_regulators`, `function stmfts_brightness_set`, `function stmfts_brightness_get`, `function stmfts_read_events`, `function stmfts_report_contact_event`, `function stmfts_report_contact_release`, `function stmfts_report_hover_event`, `function stmfts_report_key_event`, `function stmfts_parse_events`.
- 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.