]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/linux: import hidraw.h and hid.h from linux-6.14-rc4
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 28 Feb 2025 17:54:35 +0000 (02:54 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 3 Mar 2025 17:24:49 +0000 (02:24 +0900)
src/basic/linux/hid.h [new file with mode: 0644]
src/basic/linux/hidraw.h [new file with mode: 0644]
src/basic/missing_hidraw.h [deleted file]
src/login/logind-session-device.c

diff --git a/src/basic/linux/hid.h b/src/basic/linux/hid.h
new file mode 100644 (file)
index 0000000..ad13cf8
--- /dev/null
@@ -0,0 +1,81 @@
+/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
+/*
+ *  Copyright (c) 1999 Andreas Gal
+ *  Copyright (c) 2000-2001 Vojtech Pavlik
+ *  Copyright (c) 2006-2007 Jiri Kosina
+ */
+/*
+ * 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) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Should you need to contact me, the author, you can do so either by
+ * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
+ * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
+ */
+#ifndef __HID_H
+#define __HID_H
+
+
+
+/*
+ * USB HID (Human Interface Device) interface class code
+ */
+
+#define USB_INTERFACE_CLASS_HID                3
+
+/*
+ * USB HID interface subclass and protocol codes
+ */
+
+#define USB_INTERFACE_SUBCLASS_BOOT    1
+#define USB_INTERFACE_PROTOCOL_KEYBOARD        1
+#define USB_INTERFACE_PROTOCOL_MOUSE   2
+
+/*
+ * HID report types --- Ouch! HID spec says 1 2 3!
+ */
+
+enum hid_report_type {
+       HID_INPUT_REPORT                = 0,
+       HID_OUTPUT_REPORT               = 1,
+       HID_FEATURE_REPORT              = 2,
+
+       HID_REPORT_TYPES,
+};
+
+/*
+ * HID class requests
+ */
+
+enum hid_class_request {
+       HID_REQ_GET_REPORT              = 0x01,
+       HID_REQ_GET_IDLE                = 0x02,
+       HID_REQ_GET_PROTOCOL            = 0x03,
+       HID_REQ_SET_REPORT              = 0x09,
+       HID_REQ_SET_IDLE                = 0x0A,
+       HID_REQ_SET_PROTOCOL            = 0x0B,
+};
+
+/*
+ * HID class descriptor types
+ */
+
+#define HID_DT_HID                     (USB_TYPE_CLASS | 0x01)
+#define HID_DT_REPORT                  (USB_TYPE_CLASS | 0x02)
+#define HID_DT_PHYSICAL                        (USB_TYPE_CLASS | 0x03)
+
+#define HID_MAX_DESCRIPTOR_SIZE                4096
+
+
+#endif /* __HID_H */
diff --git a/src/basic/linux/hidraw.h b/src/basic/linux/hidraw.h
new file mode 100644 (file)
index 0000000..cdbafc2
--- /dev/null
@@ -0,0 +1,59 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ *  Copyright (c) 2007 Jiri Kosina
+ */
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef _HIDRAW_H
+#define _HIDRAW_H
+
+
+
+#include <linux/hid.h>
+#include <linux/types.h>
+
+struct hidraw_report_descriptor {
+       __u32 size;
+       __u8 value[HID_MAX_DESCRIPTOR_SIZE];
+};
+
+struct hidraw_devinfo {
+       __u32 bustype;
+       __s16 vendor;
+       __s16 product;
+};
+
+/* ioctl interface */
+#define HIDIOCGRDESCSIZE       _IOR('H', 0x01, int)
+#define HIDIOCGRDESC           _IOR('H', 0x02, struct hidraw_report_descriptor)
+#define HIDIOCGRAWINFO         _IOR('H', 0x03, struct hidraw_devinfo)
+#define HIDIOCGRAWNAME(len)     _IOC(_IOC_READ, 'H', 0x04, len)
+#define HIDIOCGRAWPHYS(len)     _IOC(_IOC_READ, 'H', 0x05, len)
+/* The first byte of SFEATURE and GFEATURE is the report number */
+#define HIDIOCSFEATURE(len)    _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x06, len)
+#define HIDIOCGFEATURE(len)    _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x07, len)
+#define HIDIOCGRAWUNIQ(len)     _IOC(_IOC_READ, 'H', 0x08, len)
+/* The first byte of SINPUT and GINPUT is the report number */
+#define HIDIOCSINPUT(len)    _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x09, len)
+#define HIDIOCGINPUT(len)    _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x0A, len)
+/* The first byte of SOUTPUT and GOUTPUT is the report number */
+#define HIDIOCSOUTPUT(len)    _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x0B, len)
+#define HIDIOCGOUTPUT(len)    _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x0C, len)
+#define HIDIOCREVOKE         _IOW('H', 0x0D, int) /* Revoke device access */
+
+#define HIDRAW_FIRST_MINOR 0
+#define HIDRAW_MAX_DEVICES 64
+/* number of reports to buffer */
+#define HIDRAW_BUFFER_SIZE 64
+
+
+/* kernel-only API declarations */
+
+#endif /* _HIDRAW_H */
diff --git a/src/basic/missing_hidraw.h b/src/basic/missing_hidraw.h
deleted file mode 100644 (file)
index 98ba5c0..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#pragma once
-
-#include <linux/hidraw.h>
-
-/* b31c9d9dc343146b9f4ce67b4eee748c49296e99 (6.12) */
-#ifndef HIDIOCREVOKE
-#define HIDIOCREVOKE _IOW('H', 0x0D, int)
-#endif
index adea60aef6be64fa5e9f9d38919935f46ac208d3..035a36795447badbb8ef93220b39860a3795f376 100644 (file)
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include <fcntl.h>
+#include <linux/hidraw.h>
 #include <string.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
@@ -16,7 +17,6 @@
 #include "logind-session-dbus.h"
 #include "logind-session-device.h"
 #include "missing_drm.h"
-#include "missing_hidraw.h"
 #include "missing_input.h"
 #include "parse-util.h"