drivers/input/mouse/alps.c
Source file repositories/reference/linux-study-clean/drivers/input/mouse/alps.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/mouse/alps.c- Extension
.c- Size
- 88985 bytes
- Lines
- 3237
- 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/workqueue.hlinux/slab.hlinux/input.hlinux/input/mt.hlinux/serio.hlinux/libps2.hlinux/dmi.hpsmouse.halps.htrackpoint.h
Detected Declarations
function alps_is_valid_first_bytefunction alps_report_buttonsfunction alps_process_packet_v1_v2function fromfunction alps_get_bitmap_pointsfunction alps_process_bitmapfunction cornerfunction alps_set_slotfunction alps_report_mt_datafunction alps_report_semi_mt_datafunction alps_process_trackstick_packet_v3function alps_decode_buttons_v3function alps_decode_pinnaclefunction alps_decode_rushmorefunction alps_decode_dolphinfunction alps_process_touchpad_packet_v3_v5function alps_process_packet_v3function alps_process_packet_v6function alps_process_packet_v4function alps_is_valid_package_v7function alps_get_packet_id_v7function alps_get_finger_coordinate_v7function alps_get_mt_countfunction alps_decode_packet_v7function alps_process_trackstick_packet_v7function alps_process_touchpad_packet_v7function alps_process_packet_v7function alps_get_pkt_id_ss4_v2function alps_decode_ss4_v2function alps_process_packet_ss4_v2function alps_is_valid_package_ss4_v2function alps_do_register_bare_ps2_mousefunction alps_register_bare_ps2_mousefunction alps_report_bare_ps2_packetfunction alps_handle_interleaved_ps2function alps_flush_packetfunction alps_process_bytefunction alps_command_mode_send_nibblefunction alps_command_mode_set_addrfunction __alps_command_mode_read_regfunction alps_command_mode_read_regfunction __alps_command_mode_write_regfunction alps_command_mode_write_regfunction alps_rpt_cmdfunction alps_check_valid_firmware_idfunction alps_enter_command_modefunction alps_exit_command_modefunction alps_passthrough_mode_v2
Annotated Snippet
if (bit) {
if (!prev_bit) {
point->start_bit = i;
point->num_bits = 0;
(*fingers)++;
}
point->num_bits++;
} else {
if (prev_bit)
point = high;
}
prev_bit = bit;
}
}
/*
* Process bitmap data from semi-mt protocols. Returns the number of
* fingers detected. A return value of 0 means at least one of the
* bitmaps was empty.
*
* The bitmaps don't have enough data to track fingers, so this function
* only generates points representing a bounding box of all contacts.
* These points are returned in fields->mt when the return value
* is greater than 0.
*/
static int alps_process_bitmap(struct alps_data *priv,
struct alps_fields *fields)
{
int i, fingers_x = 0, fingers_y = 0, fingers, closest;
struct alps_bitmap_point x_low = {0,}, x_high = {0,};
struct alps_bitmap_point y_low = {0,}, y_high = {0,};
struct input_mt_pos corner[4];
if (!fields->x_map || !fields->y_map)
return 0;
alps_get_bitmap_points(fields->x_map, &x_low, &x_high, &fingers_x);
alps_get_bitmap_points(fields->y_map, &y_low, &y_high, &fingers_y);
/*
* Fingers can overlap, so we use the maximum count of fingers
* on either axis as the finger count.
*/
fingers = max(fingers_x, fingers_y);
/*
* If an axis reports only a single contact, we have overlapping or
* adjacent fingers. Divide the single contact between the two points.
*/
if (fingers_x == 1) {
i = (x_low.num_bits - 1) / 2;
x_low.num_bits = x_low.num_bits - i;
x_high.start_bit = x_low.start_bit + i;
x_high.num_bits = max(i, 1);
}
if (fingers_y == 1) {
i = (y_low.num_bits - 1) / 2;
y_low.num_bits = y_low.num_bits - i;
y_high.start_bit = y_low.start_bit + i;
y_high.num_bits = max(i, 1);
}
/* top-left corner */
corner[0].x =
(priv->x_max * (2 * x_low.start_bit + x_low.num_bits - 1)) /
(2 * (priv->x_bits - 1));
corner[0].y =
(priv->y_max * (2 * y_low.start_bit + y_low.num_bits - 1)) /
(2 * (priv->y_bits - 1));
/* top-right corner */
corner[1].x =
(priv->x_max * (2 * x_high.start_bit + x_high.num_bits - 1)) /
(2 * (priv->x_bits - 1));
corner[1].y =
(priv->y_max * (2 * y_low.start_bit + y_low.num_bits - 1)) /
(2 * (priv->y_bits - 1));
/* bottom-right corner */
corner[2].x =
(priv->x_max * (2 * x_high.start_bit + x_high.num_bits - 1)) /
(2 * (priv->x_bits - 1));
corner[2].y =
(priv->y_max * (2 * y_high.start_bit + y_high.num_bits - 1)) /
(2 * (priv->y_bits - 1));
/* bottom-left corner */
corner[3].x =
(priv->x_max * (2 * x_low.start_bit + x_low.num_bits - 1)) /
(2 * (priv->x_bits - 1));
Annotation
- Immediate include surface: `linux/workqueue.h`, `linux/slab.h`, `linux/input.h`, `linux/input/mt.h`, `linux/serio.h`, `linux/libps2.h`, `linux/dmi.h`, `psmouse.h`.
- Detected declarations: `function alps_is_valid_first_byte`, `function alps_report_buttons`, `function alps_process_packet_v1_v2`, `function from`, `function alps_get_bitmap_points`, `function alps_process_bitmap`, `function corner`, `function alps_set_slot`, `function alps_report_mt_data`, `function alps_report_semi_mt_data`.
- 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.