drivers/input/mouse/cyapa_gen3.c
Source file repositories/reference/linux-study-clean/drivers/input/mouse/cyapa_gen3.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/mouse/cyapa_gen3.c- Extension
.c- Size
- 36606 bytes
- Lines
- 1259
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/i2c.hlinux/input.hlinux/input/mt.hlinux/module.hlinux/slab.hlinux/unaligned.hcyapa.h
Detected Declarations
struct cyapa_touchstruct cyapa_reg_datastruct gen3_write_block_cmdstruct cyapa_cmd_lenfunction cyapa_smbus_read_blockfunction cyapa_read_bytefunction cyapa_write_bytefunction cyapa_i2c_reg_read_blockfunction cyapa_i2c_reg_write_blockfunction cyapa_read_blockfunction cyapa_gen3_state_parsefunction cyapa_gen3_bl_enterfunction cyapa_gen3_bl_activatefunction cyapa_gen3_bl_deactivatefunction cyapa_gen3_bl_exitfunction cyapa_gen3_csumfunction cyapa_gen3_check_fwfunction cyapa_gen3_write_bufferfunction cyapa_gen3_write_fw_blockfunction cyapa_gen3_write_blocksfunction cyapa_gen3_do_fw_updatefunction cyapa_gen3_do_calibratefunction cyapa_gen3_show_baselinefunction cyapa_get_wait_time_for_pwr_cmdfunction cyapa_gen3_set_power_modefunction speedfunction cyapa_gen3_set_proximityfunction cyapa_gen3_get_query_datafunction cyapa_gen3_bl_query_datafunction cyapa_gen3_do_operational_checkfunction cyapa_gen3_irq_cmd_handlerfunction cyapa_gen3_event_processfunction cyapa_gen3_irq_handlerfunction cyapa_gen3_try_poll_handlerfunction cyapa_gen3_initializefunction cyapa_gen3_bl_initiatefunction cyapa_gen3_empty_output_data
Annotated Snippet
struct cyapa_touch {
/*
* high bits or x/y position value
* bit 7 - 4: high 4 bits of x position value
* bit 3 - 0: high 4 bits of y position value
*/
u8 xy_hi;
u8 x_lo; /* low 8 bits of x position value. */
u8 y_lo; /* low 8 bits of y position value. */
u8 pressure;
/* id range is 1 - 15. It is incremented with every new touch. */
u8 id;
} __packed;
struct cyapa_reg_data {
/*
* bit 0 - 1: device status
* bit 3 - 2: power mode
* bit 6 - 4: reserved
* bit 7: interrupt valid bit
*/
u8 device_status;
/*
* bit 7 - 4: number of fingers currently touching pad
* bit 3: valid data check bit
* bit 2: middle mechanism button state if exists
* bit 1: right mechanism button state if exists
* bit 0: left mechanism button state if exists
*/
u8 finger_btn;
/* CYAPA reports up to 5 touches per packet. */
struct cyapa_touch touches[5];
} __packed;
struct gen3_write_block_cmd {
u8 checksum_seed; /* Always be 0xff */
u8 cmd_code; /* command code: 0x39 */
u8 key[8]; /* 8-byte security key */
__be16 block_num;
u8 block_data[CYAPA_FW_BLOCK_SIZE];
u8 block_checksum; /* Calculated using bytes 12 - 75 */
u8 cmd_checksum; /* Calculated using bytes 0-76 */
} __packed;
static const u8 security_key[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
static const u8 bl_activate[] = { 0x00, 0xff, 0x38, 0x00, 0x01, 0x02, 0x03,
0x04, 0x05, 0x06, 0x07 };
static const u8 bl_deactivate[] = { 0x00, 0xff, 0x3b, 0x00, 0x01, 0x02, 0x03,
0x04, 0x05, 0x06, 0x07 };
static const u8 bl_exit[] = { 0x00, 0xff, 0xa5, 0x00, 0x01, 0x02, 0x03, 0x04,
0x05, 0x06, 0x07 };
/* for byte read/write command */
#define CMD_RESET 0
#define CMD_POWER_MODE 1
#define CMD_DEV_STATUS 2
#define CMD_REPORT_MAX_BASELINE 3
#define CMD_REPORT_MIN_BASELINE 4
#define SMBUS_BYTE_CMD(cmd) (((cmd) & 0x3f) << 1)
#define CYAPA_SMBUS_RESET SMBUS_BYTE_CMD(CMD_RESET)
#define CYAPA_SMBUS_POWER_MODE SMBUS_BYTE_CMD(CMD_POWER_MODE)
#define CYAPA_SMBUS_DEV_STATUS SMBUS_BYTE_CMD(CMD_DEV_STATUS)
#define CYAPA_SMBUS_MAX_BASELINE SMBUS_BYTE_CMD(CMD_REPORT_MAX_BASELINE)
#define CYAPA_SMBUS_MIN_BASELINE SMBUS_BYTE_CMD(CMD_REPORT_MIN_BASELINE)
/* for group registers read/write command */
#define REG_GROUP_DATA 0
#define REG_GROUP_CMD 2
#define REG_GROUP_QUERY 3
#define SMBUS_GROUP_CMD(grp) (0x80 | (((grp) & 0x07) << 3))
#define CYAPA_SMBUS_GROUP_DATA SMBUS_GROUP_CMD(REG_GROUP_DATA)
#define CYAPA_SMBUS_GROUP_CMD SMBUS_GROUP_CMD(REG_GROUP_CMD)
#define CYAPA_SMBUS_GROUP_QUERY SMBUS_GROUP_CMD(REG_GROUP_QUERY)
/* for register block read/write command */
#define CMD_BL_STATUS 0
#define CMD_BL_HEAD 1
#define CMD_BL_CMD 2
#define CMD_BL_DATA 3
#define CMD_BL_ALL 4
#define CMD_BLK_PRODUCT_ID 5
#define CMD_BLK_HEAD 6
#define SMBUS_BLOCK_CMD(cmd) (0xc0 | (((cmd) & 0x1f) << 1))
/* register block read/write command in bootloader mode */
#define CYAPA_SMBUS_BL_STATUS SMBUS_BLOCK_CMD(CMD_BL_STATUS)
#define CYAPA_SMBUS_BL_HEAD SMBUS_BLOCK_CMD(CMD_BL_HEAD)
#define CYAPA_SMBUS_BL_CMD SMBUS_BLOCK_CMD(CMD_BL_CMD)
Annotation
- Immediate include surface: `linux/delay.h`, `linux/i2c.h`, `linux/input.h`, `linux/input/mt.h`, `linux/module.h`, `linux/slab.h`, `linux/unaligned.h`, `cyapa.h`.
- Detected declarations: `struct cyapa_touch`, `struct cyapa_reg_data`, `struct gen3_write_block_cmd`, `struct cyapa_cmd_len`, `function cyapa_smbus_read_block`, `function cyapa_read_byte`, `function cyapa_write_byte`, `function cyapa_i2c_reg_read_block`, `function cyapa_i2c_reg_write_block`, `function cyapa_read_block`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: source implementation candidate.
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.