drivers/input/touchscreen/melfas_mip4.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/melfas_mip4.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/melfas_mip4.c- Extension
.c- Size
- 37702 bytes
- Lines
- 1560
- 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/acpi.hlinux/delay.hlinux/firmware.hlinux/gpio/consumer.hlinux/i2c.hlinux/input.hlinux/input/mt.hlinux/interrupt.hlinux/module.hlinux/of.hlinux/slab.hlinux/unaligned.h
Detected Declarations
struct mip4_fw_versionstruct mip4_tsstruct mip4_bin_tailfunction mip4_i2c_xferfunction mip4_parse_fw_versionfunction mip4_get_fw_versionfunction mip4_query_devicefunction mip4_power_onfunction mip4_power_offfunction mip4_clear_inputfunction mip4_enablefunction mip4_disablefunction mip4_report_keysfunction mip4_report_touchfunction mip4_handle_packetfunction mip4_interruptfunction mip4_input_openfunction mip4_input_closefunction mip4_bl_read_statusfunction mip4_bl_change_modefunction mip4_bl_enterfunction mip4_bl_exitfunction mip4_bl_get_addressfunction mip4_bl_program_pagefunction mip4_bl_verify_pagefunction mip4_flash_fwfunction mip4_parse_firmwarefunction mip4_execute_fw_updatefunction mip4_sysfs_fw_updatefunction mip4_sysfs_read_fw_versionfunction mip4_sysfs_read_hw_versionfunction mip4_sysfs_read_product_idfunction mip4_sysfs_read_ic_namefunction mip4_probefunction mip4_suspendfunction mip4_resume
Annotated Snippet
struct mip4_fw_version {
u16 boot;
u16 core;
u16 app;
u16 param;
};
struct mip4_ts {
struct i2c_client *client;
struct input_dev *input;
struct gpio_desc *gpio_ce;
char phys[32];
char product_name[16];
u16 product_id;
char ic_name[4];
char fw_name[32];
unsigned int max_x;
unsigned int max_y;
u8 node_x;
u8 node_y;
u8 node_key;
unsigned int ppm_x;
unsigned int ppm_y;
struct mip4_fw_version fw_version;
unsigned int event_size;
unsigned int event_format;
unsigned int key_num;
unsigned short key_code[MIP4_MAX_KEYS];
bool wake_irq_enabled;
u8 buf[MIP4_BUF_SIZE];
};
static int mip4_i2c_xfer(struct mip4_ts *ts,
char *write_buf, unsigned int write_len,
char *read_buf, unsigned int read_len)
{
struct i2c_msg msg[] = {
{
.addr = ts->client->addr,
.flags = 0,
.buf = write_buf,
.len = write_len,
}, {
.addr = ts->client->addr,
.flags = I2C_M_RD,
.buf = read_buf,
.len = read_len,
},
};
int retry = I2C_RETRY_COUNT;
int res;
int error;
do {
res = i2c_transfer(ts->client->adapter, msg, ARRAY_SIZE(msg));
if (res == ARRAY_SIZE(msg))
return 0;
error = res < 0 ? res : -EIO;
dev_err(&ts->client->dev,
"%s - i2c_transfer failed: %d (%d)\n",
__func__, error, res);
} while (--retry);
return error;
}
static void mip4_parse_fw_version(const u8 *buf, struct mip4_fw_version *v)
{
v->boot = get_unaligned_le16(buf + 0);
v->core = get_unaligned_le16(buf + 2);
v->app = get_unaligned_le16(buf + 4);
v->param = get_unaligned_le16(buf + 6);
}
/*
* Read chip firmware version
*/
static int mip4_get_fw_version(struct mip4_ts *ts)
{
u8 cmd[] = { MIP4_R0_INFO, MIP4_R1_INFO_VERSION_BOOT };
u8 buf[sizeof(ts->fw_version)];
int error;
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/delay.h`, `linux/firmware.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/input.h`, `linux/input/mt.h`, `linux/interrupt.h`.
- Detected declarations: `struct mip4_fw_version`, `struct mip4_ts`, `struct mip4_bin_tail`, `function mip4_i2c_xfer`, `function mip4_parse_fw_version`, `function mip4_get_fw_version`, `function mip4_query_device`, `function mip4_power_on`, `function mip4_power_off`, `function mip4_clear_input`.
- 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.