drivers/input/mouse/focaltech.c
Source file repositories/reference/linux-study-clean/drivers/input/mouse/focaltech.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/mouse/focaltech.c- Extension
.c- Size
- 11431 bytes
- Lines
- 456
- 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.
- 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/device.hlinux/libps2.hlinux/input/mt.hlinux/serio.hlinux/slab.hpsmouse.hfocaltech.h
Detected Declarations
struct focaltech_finger_statestruct focaltech_hw_statestruct focaltech_datafunction focaltech_detectfunction focaltech_report_statefunction focaltech_process_touch_packetfunction focaltech_process_abs_packetfunction focaltech_process_rel_packetfunction focaltech_process_packetfunction focaltech_process_bytefunction focaltech_switch_protocolfunction focaltech_resetfunction focaltech_disconnectfunction focaltech_reconnectfunction focaltech_set_input_paramsfunction focaltech_read_registerfunction focaltech_read_sizefunction focaltech_set_resolution
Annotated Snippet
struct focaltech_finger_state {
/* The touchpad has generated a touch event for the finger */
bool active;
/*
* The touchpad has sent position data for the finger. The
* flag is 0 when the finger is not active, and there is a
* time between the first touch event for the finger and the
* following absolute position packet for the finger where the
* touchpad has declared the finger to be valid, but we do not
* have any valid position yet.
*/
bool valid;
/*
* Absolute position (from the bottom left corner) of the
* finger.
*/
unsigned int x;
unsigned int y;
};
/*
* Description of the current state of the touchpad hardware.
*/
struct focaltech_hw_state {
/*
* The touchpad tracks the positions of the fingers for us,
* the array indices correspond to the finger indices returned
* in the report packages.
*/
struct focaltech_finger_state fingers[FOC_MAX_FINGERS];
/*
* Finger width 0-7 and 15 for a very big contact area.
* 15 value stays until the finger is released.
* Width is reported only in absolute packets.
* Since hardware reports width only for last touching finger,
* there is no need to store width for every specific finger,
* so we keep only last value reported.
*/
unsigned int width;
/* True if the clickpad has been pressed. */
bool pressed;
};
struct focaltech_data {
unsigned int x_max, y_max;
struct focaltech_hw_state state;
};
static void focaltech_report_state(struct psmouse *psmouse)
{
struct focaltech_data *priv = psmouse->private;
struct focaltech_hw_state *state = &priv->state;
struct input_dev *dev = psmouse->dev;
int i;
for (i = 0; i < FOC_MAX_FINGERS; i++) {
struct focaltech_finger_state *finger = &state->fingers[i];
bool active = finger->active && finger->valid;
input_mt_slot(dev, i);
input_mt_report_slot_state(dev, MT_TOOL_FINGER, active);
if (active) {
unsigned int clamped_x, clamped_y;
/*
* The touchpad might report invalid data, so we clamp
* the resulting values so that we do not confuse
* userspace.
*/
clamped_x = clamp(finger->x, 0U, priv->x_max);
clamped_y = clamp(finger->y, 0U, priv->y_max);
input_report_abs(dev, ABS_MT_POSITION_X, clamped_x);
input_report_abs(dev, ABS_MT_POSITION_Y,
priv->y_max - clamped_y);
input_report_abs(dev, ABS_TOOL_WIDTH, state->width);
}
}
input_mt_report_pointer_emulation(dev, true);
input_report_key(dev, BTN_LEFT, state->pressed);
input_sync(dev);
}
static void focaltech_process_touch_packet(struct psmouse *psmouse,
unsigned char *packet)
{
struct focaltech_data *priv = psmouse->private;
Annotation
- Immediate include surface: `linux/device.h`, `linux/libps2.h`, `linux/input/mt.h`, `linux/serio.h`, `linux/slab.h`, `psmouse.h`, `focaltech.h`.
- Detected declarations: `struct focaltech_finger_state`, `struct focaltech_hw_state`, `struct focaltech_data`, `function focaltech_detect`, `function focaltech_report_state`, `function focaltech_process_touch_packet`, `function focaltech_process_abs_packet`, `function focaltech_process_rel_packet`, `function focaltech_process_packet`, `function focaltech_process_byte`.
- 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.