summary refs log tree commit diff
path: root/include/uapi
diff options
context:
space:
mode:
authorVicki Pfau <vi@endrift.com>2022-06-30 18:43:10 -0700
committerVicki Pfau <vi@endrift.com>2023-06-02 16:47:48 -0700
commit64efacc6a7462a18bccc9616c9695ca9bcaffb6b (patch)
treebff706c4e58db672d14b14235388423889847e48 /include/uapi
parent3eed04d70af4dacb07612da523e76ccb6e5ca7b4 (diff)
downloadlinux-64efacc6a7462a18bccc9616c9695ca9bcaffb6b.tar.gz
USB: gadget: f_hid: Add Set-Feature report
While the HID gadget implementation has been sufficient for devices that only
use INTERRUPT transfers, the USB HID standard includes provisions for Set- and
Get-Feature report CONTROL transfers that go over endpoint 0. These were
previously impossible with the existing implementation, and would either send
an empty reply, or stall out.

As the feature is a standard part of USB HID, it stands to reason that devices
would use it, and that the HID gadget should support it. This patch adds
support for host-to-device Set-Feature reports through a new ioctl
interface to the hidg class dev nodes.

Signed-off-by: Vicki Pfau <vi@endrift.com>
(cherry picked from commit 3d82be0ec3aa3b947d9c927d7b06c433de15be8b)
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Diffstat (limited to 'include/uapi')
-rw-r--r--include/uapi/linux/usb/g_hid.h24
1 files changed, 4 insertions, 20 deletions
diff --git a/include/uapi/linux/usb/g_hid.h b/include/uapi/linux/usb/g_hid.h
index c6068b486354..54814c2c68d6 100644
--- a/include/uapi/linux/usb/g_hid.h
+++ b/include/uapi/linux/usb/g_hid.h
@@ -1,38 +1,22 @@
 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
-/*
- * g_hid.h -- Header file for USB HID gadget driver
- *
- * Copyright (C) 2022 Valve Software
- *
- * 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
- */
 
 #ifndef __UAPI_LINUX_USB_G_HID_H
 #define __UAPI_LINUX_USB_G_HID_H
 
 #include <linux/types.h>
 
+#define HIDG_REPORT_SIZE_MAX 64
+
 struct usb_hidg_report {
 	__u16 length;
-	__u8 data[512];
+	__u8 data[HIDG_REPORT_SIZE_MAX];
 };
 
 /* The 'g' code is also used by gadgetfs and hid gadget ioctl requests.
  * Don't add any colliding codes to either driver, and keep
  * them in unique ranges (size 0x20 for now).
  */
+#define GADGET_HID_READ_SET_REPORT	_IOR('g', 0x41, struct usb_hidg_report)
 #define GADGET_HID_WRITE_GET_REPORT	_IOW('g', 0x42, struct usb_hidg_report)
 
 #endif /* __UAPI_LINUX_USB_G_HID_H */