drivers/input/touchscreen/himax_hx852x.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/himax_hx852x.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/himax_hx852x.c- Extension
.c- Size
- 12863 bytes
- Lines
- 504
- 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/touchscreen.hlinux/interrupt.hlinux/kernel.hlinux/mod_devicetable.hlinux/module.hlinux/of.hlinux/regulator/consumer.hlinux/unaligned.h
Detected Declarations
struct hx852xstruct hx852x_configstruct hx852x_coordstruct hx852x_touch_infofunction hx852x_i2c_readfunction hx852x_power_onfunction hx852x_startfunction hx852x_stopfunction hx852x_power_offfunction hx852x_read_configfunction hx852x_handle_eventsfunction for_each_set_bitfunction hx852x_interruptfunction hx852x_input_openfunction hx852x_input_closefunction hx852x_parse_propertiesfunction hx852x_probefunction hx852x_suspendfunction hx852x_resume
Annotated Snippet
struct hx852x {
struct i2c_client *client;
struct input_dev *input_dev;
struct touchscreen_properties props;
struct gpio_desc *reset_gpiod;
struct regulator_bulk_data supplies[2];
unsigned int max_fingers;
unsigned int keycount;
unsigned int keycodes[HX852X_MAX_KEY_COUNT];
};
struct hx852x_config {
u8 rx_num;
u8 tx_num;
u8 max_pt;
u8 padding1[3];
__be16 x_res;
__be16 y_res;
u8 padding2[2];
} __packed __aligned(4);
struct hx852x_coord {
__be16 x;
__be16 y;
} __packed __aligned(4);
struct hx852x_touch_info {
u8 finger_num;
__le16 finger_pressed;
u8 padding;
} __packed __aligned(4);
static int hx852x_i2c_read(struct hx852x *hx, u8 cmd, void *data, u16 len)
{
struct i2c_client *client = hx->client;
int error;
int ret;
struct i2c_msg msg[] = {
{
.addr = client->addr,
.flags = 0,
.len = 1,
.buf = &cmd,
},
{
.addr = client->addr,
.flags = I2C_M_RD,
.len = len,
.buf = data,
},
};
ret = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg));
if (ret != ARRAY_SIZE(msg)) {
error = ret < 0 ? ret : -EIO;
dev_err(&client->dev, "failed to read %#x: %d\n", cmd, error);
return error;
}
return 0;
}
static int hx852x_power_on(struct hx852x *hx)
{
struct device *dev = &hx->client->dev;
int error;
error = regulator_bulk_enable(ARRAY_SIZE(hx->supplies), hx->supplies);
if (error) {
dev_err(dev, "failed to enable regulators: %d\n", error);
return error;
}
gpiod_set_value_cansleep(hx->reset_gpiod, 1);
msleep(20);
gpiod_set_value_cansleep(hx->reset_gpiod, 0);
msleep(50);
return 0;
}
static int hx852x_start(struct hx852x *hx)
{
struct device *dev = &hx->client->dev;
int error;
error = i2c_smbus_write_byte(hx->client, HX852X_TS_SLEEP_OUT);
if (error) {
dev_err(dev, "failed to send TS_SLEEP_OUT: %d\n", error);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/input.h`, `linux/input/mt.h`, `linux/input/touchscreen.h`, `linux/interrupt.h`, `linux/kernel.h`.
- Detected declarations: `struct hx852x`, `struct hx852x_config`, `struct hx852x_coord`, `struct hx852x_touch_info`, `function hx852x_i2c_read`, `function hx852x_power_on`, `function hx852x_start`, `function hx852x_stop`, `function hx852x_power_off`, `function hx852x_read_config`.
- 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.