/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
* User-space I/O driver support for HID subsystem
* Copyright (c) 2012 David Herrmann
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* Public header for user-space communication. We try to keep every structure
* aligned but to be safe we also use __attribute__((__packed__)). Therefore,
* the communication should be ABI compatible even between architectures.
struct uhid_create2_req {
__u8 rd_data[HID_MAX_DESCRIPTOR_SIZE];
} __attribute__((__packed__));
UHID_DEV_NUMBERED_FEATURE_REPORTS = (1ULL << 0),
UHID_DEV_NUMBERED_OUTPUT_REPORTS = (1ULL << 1),
UHID_DEV_NUMBERED_INPUT_REPORTS = (1ULL << 2),
#define UHID_DATA_MAX 4096
__u8 data[UHID_DATA_MAX];
} __attribute__((__packed__));
__u8 data[UHID_DATA_MAX];
} __attribute__((__packed__));
struct uhid_get_report_req {
} __attribute__((__packed__));
struct uhid_get_report_reply_req {
__u8 data[UHID_DATA_MAX];
} __attribute__((__packed__));
struct uhid_set_report_req {
__u8 data[UHID_DATA_MAX];
} __attribute__((__packed__));
struct uhid_set_report_reply_req {
} __attribute__((__packed__));
* All these commands and requests are obsolete. You should avoid using them in
* new code. We support them for backwards-compatibility, but you might not get
* access to new feature in case you use them.
enum uhid_legacy_event_type {
UHID_CREATE = __UHID_LEGACY_CREATE,
UHID_OUTPUT_EV = __UHID_LEGACY_OUTPUT_EV,
UHID_INPUT = __UHID_LEGACY_INPUT,
UHID_FEATURE = UHID_GET_REPORT,
UHID_FEATURE_ANSWER = UHID_GET_REPORT_REPLY,
/* Obsolete! Use UHID_CREATE2. */
} __attribute__((__packed__));
/* Obsolete! Use UHID_INPUT2. */
__u8 data[UHID_DATA_MAX];
} __attribute__((__packed__));
/* Obsolete! Kernel uses UHID_OUTPUT exclusively now. */
struct uhid_output_ev_req {
} __attribute__((__packed__));
/* Obsolete! Kernel uses ABI compatible UHID_GET_REPORT. */
struct uhid_feature_req {
} __attribute__((__packed__));
/* Obsolete! Use ABI compatible UHID_GET_REPORT_REPLY. */
struct uhid_feature_answer_req {
__u8 data[UHID_DATA_MAX];
} __attribute__((__packed__));
* All UHID events from and to the kernel are encoded as "struct uhid_event".
* The "type" field contains a UHID_* type identifier. All payload depends on
* that type and can be accessed via ev->u.XYZ accordingly.
* If user-space writes short events, they're extended with 0s by the kernel. If
* the kernel writes short events, user-space shall extend them with 0s.
struct uhid_create_req create;
struct uhid_input_req input;
struct uhid_output_req output;
struct uhid_output_ev_req output_ev;
struct uhid_feature_req feature;
struct uhid_get_report_req get_report;
struct uhid_feature_answer_req feature_answer;
struct uhid_get_report_reply_req get_report_reply;
struct uhid_create2_req create2;
struct uhid_input2_req input2;
struct uhid_set_report_req set_report;
struct uhid_set_report_reply_req set_report_reply;
struct uhid_start_req start;
} __attribute__((__packed__));