drivers/hid/wacom_wac.c
Source file repositories/reference/linux-study-clean/drivers/hid/wacom_wac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/wacom_wac.c- Extension
.c- Size
- 163673 bytes
- Lines
- 5138
- Domain
- Driver Families
- Bucket
- drivers/hid
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
wacom_wac.hwacom.hlinux/input/mt.hlinux/jiffies.h
Detected Declarations
function wacom_force_proxoutfunction wacom_idleprox_timeoutfunction __wacom_notify_batteryfunction wacom_notify_batteryfunction wacom_penpartner_irqfunction wacom_pl_irqfunction wacom_ptu_irqfunction wacom_dtu_irqfunction wacom_dtus_irqfunction wacom_graphire_irqfunction wacom_intuos_schedule_prox_eventfunction wacom_intuos_padfunction wacom_intuos_id_manglefunction wacom_is_art_penfunction wacom_intuos_get_tool_typefunction wacom_exit_reportfunction wacom_intuos_inoutfunction touch_is_mutedfunction report_touch_eventsfunction delay_pen_eventsfunction wacom_intuos_generalfunction wacom_intuos_irqfunction wacom_remote_irqfunction wacom_remote_status_irqfunction int_distfunction wacom_intuos_bt_process_datafunction wacom_intuos_bt_irqfunction wacom_wac_finger_count_touchesfunction wacom_intuos_pro2_bt_penfunction wacom_intuos_pro2_bt_touchfunction wacom_intuos_pro2_bt_padfunction wacom_intuos_pro2_bt_batteryfunction wacom_intuos_gen3_bt_padfunction wacom_intuos_gen3_bt_batteryfunction wacom_intuos_pro2_bt_irqfunction wacom_24hdt_irqfunction wacom_mt_touchfunction wacom_tpc_mt_touchfunction wacom_tpc_single_touchfunction wacom_tpc_penfunction wacom_tpc_irqfunction wacom_offset_rotationfunction wacom_equivalent_usagefunction wacom_map_usagefunction wacom_wac_battery_usage_mappingfunction wacom_wac_battery_eventfunction wacom_wac_battery_pre_reportfunction wacom_wac_battery_report
Annotated Snippet
if (data[5] & 0x80) {
wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
input_report_key(input, wacom->tool[0], 1);
input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
} else {
input_report_key(input, wacom->tool[0], 0);
input_report_abs(input, ABS_MISC, 0); /* report tool id */
input_report_abs(input, ABS_PRESSURE, -1);
input_report_key(input, BTN_TOUCH, 0);
}
break;
case 2:
input_report_key(input, BTN_TOOL_PEN, 1);
input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
break;
default:
dev_dbg(input->dev.parent,
"%s: received unknown report #%d\n", __func__, data[0]);
return 0;
}
return 1;
}
static int wacom_pl_irq(struct wacom_wac *wacom)
{
struct wacom_features *features = &wacom->features;
unsigned char *data = wacom->data;
struct input_dev *input = wacom->pen_input;
int prox, pressure;
if (data[0] != WACOM_REPORT_PENABLED) {
dev_dbg(input->dev.parent,
"%s: received unknown report #%d\n", __func__, data[0]);
return 0;
}
prox = data[1] & 0x40;
if (!wacom->id[0]) {
if ((data[0] & 0x10) || (data[4] & 0x20)) {
wacom->tool[0] = BTN_TOOL_RUBBER;
wacom->id[0] = ERASER_DEVICE_ID;
}
else {
wacom->tool[0] = BTN_TOOL_PEN;
wacom->id[0] = STYLUS_DEVICE_ID;
}
}
/* If the eraser is in prox, STYLUS2 is always set. If we
* mis-detected the type and notice that STYLUS2 isn't set
* then force the eraser out of prox and let the pen in.
*/
if (wacom->tool[0] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
input_report_key(input, BTN_TOOL_RUBBER, 0);
input_report_abs(input, ABS_MISC, 0);
input_sync(input);
wacom->tool[0] = BTN_TOOL_PEN;
wacom->id[0] = STYLUS_DEVICE_ID;
}
if (prox) {
pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
if (features->pressure_max > 255)
pressure = (pressure << 1) | ((data[4] >> 6) & 1);
pressure += (features->pressure_max + 1) / 2;
input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
input_report_abs(input, ABS_PRESSURE, pressure);
input_report_key(input, BTN_TOUCH, data[4] & 0x08);
input_report_key(input, BTN_STYLUS, data[4] & 0x10);
/* Only allow the stylus2 button to be reported for the pen tool. */
input_report_key(input, BTN_STYLUS2, (wacom->tool[0] == BTN_TOOL_PEN) && (data[4] & 0x20));
}
Annotation
- Immediate include surface: `wacom_wac.h`, `wacom.h`, `linux/input/mt.h`, `linux/jiffies.h`.
- Detected declarations: `function wacom_force_proxout`, `function wacom_idleprox_timeout`, `function __wacom_notify_battery`, `function wacom_notify_battery`, `function wacom_penpartner_irq`, `function wacom_pl_irq`, `function wacom_ptu_irq`, `function wacom_dtu_irq`, `function wacom_dtus_irq`, `function wacom_graphire_irq`.
- Atlas domain: Driver Families / drivers/hid.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.