drivers/input/touchscreen/apple_z2.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/apple_z2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/apple_z2.c- Extension
.c- Size
- 13103 bytes
- Lines
- 482
- 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/firmware.hlinux/input.hlinux/input/mt.hlinux/input/touchscreen.hlinux/interrupt.hlinux/module.hlinux/of.hlinux/spi/spi.hlinux/unaligned.h
Detected Declarations
struct apple_z2struct apple_z2_fingerstruct apple_z2_hbpp_blob_hdrstruct apple_z2_fw_hdrstruct apple_z2_read_interrupt_cmdfunction apple_z2_parse_touchesfunction apple_z2_read_packetfunction apple_z2_irqfunction apple_z2_send_firmware_blobfunction apple_z2_upload_firmwarefunction apple_z2_bootfunction apple_z2_probefunction apple_z2_shutdownfunction apple_z2_suspendfunction apple_z2_resume
Annotated Snippet
struct apple_z2 {
struct spi_device *spidev;
struct gpio_desc *reset_gpio;
struct input_dev *input_dev;
struct completion boot_irq;
bool booted;
int index_parity;
struct touchscreen_properties props;
const char *fw_name;
u8 *tx_buf;
u8 *rx_buf;
};
struct apple_z2_finger {
u8 finger;
u8 state;
__le16 unknown2;
__le16 abs_x;
__le16 abs_y;
__le16 rel_x;
__le16 rel_y;
__le16 tool_major;
__le16 tool_minor;
__le16 orientation;
__le16 touch_major;
__le16 touch_minor;
__le16 unused[2];
__le16 pressure;
__le16 multi;
} __packed;
struct apple_z2_hbpp_blob_hdr {
__le16 cmd;
__le16 len;
__le32 addr;
__le16 checksum;
};
struct apple_z2_fw_hdr {
__le32 magic;
__le32 version;
};
struct apple_z2_read_interrupt_cmd {
u8 cmd;
u8 counter;
u8 unused[12];
__le16 checksum;
};
static void apple_z2_parse_touches(struct apple_z2 *z2,
const u8 *msg, size_t msg_len)
{
int i;
int nfingers;
int slot;
int slot_valid;
struct apple_z2_finger *fingers;
if (msg_len <= APPLE_Z2_NUM_FINGERS_OFFSET)
return;
nfingers = msg[APPLE_Z2_NUM_FINGERS_OFFSET];
fingers = (struct apple_z2_finger *)(msg + APPLE_Z2_FINGERS_OFFSET);
for (i = 0; i < nfingers; i++) {
slot = input_mt_get_slot_by_key(z2->input_dev, fingers[i].finger);
if (slot < 0) {
dev_warn(&z2->spidev->dev, "unable to get slot for finger\n");
continue;
}
slot_valid = fingers[i].state == APPLE_Z2_TOUCH_STARTED ||
fingers[i].state == APPLE_Z2_TOUCH_MOVED;
input_mt_slot(z2->input_dev, slot);
if (!input_mt_report_slot_state(z2->input_dev, MT_TOOL_FINGER, slot_valid))
continue;
touchscreen_report_pos(z2->input_dev, &z2->props,
le16_to_cpu(fingers[i].abs_x),
le16_to_cpu(fingers[i].abs_y),
true);
input_report_abs(z2->input_dev, ABS_MT_WIDTH_MAJOR,
le16_to_cpu(fingers[i].tool_major));
input_report_abs(z2->input_dev, ABS_MT_WIDTH_MINOR,
le16_to_cpu(fingers[i].tool_minor));
input_report_abs(z2->input_dev, ABS_MT_ORIENTATION,
le16_to_cpu(fingers[i].orientation));
input_report_abs(z2->input_dev, ABS_MT_TOUCH_MAJOR,
le16_to_cpu(fingers[i].touch_major));
input_report_abs(z2->input_dev, ABS_MT_TOUCH_MINOR,
le16_to_cpu(fingers[i].touch_minor));
}
input_mt_sync_frame(z2->input_dev);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/firmware.h`, `linux/input.h`, `linux/input/mt.h`, `linux/input/touchscreen.h`, `linux/interrupt.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct apple_z2`, `struct apple_z2_finger`, `struct apple_z2_hbpp_blob_hdr`, `struct apple_z2_fw_hdr`, `struct apple_z2_read_interrupt_cmd`, `function apple_z2_parse_touches`, `function apple_z2_read_packet`, `function apple_z2_irq`, `function apple_z2_send_firmware_blob`, `function apple_z2_upload_firmware`.
- 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.