mirror of
https://github.com/jetkvm/rv1106-system.git
synced 2026-06-20 05:24:41 +00:00
* usb: gadget: f_hid: add wakeup_on_write support Add an opt-in wakeup_on_write configfs attribute to the HID function driver. When enabled, each write to /dev/hidgN calls usb_gadget_wakeup() before queuing the USB request, allowing HID input to wake a suspended host. The configuration descriptor must also advertise remote wakeup capability (bmAttributes bit 5) for the host to arm the feature during enumeration. This is useful for KVM-over-IP devices that need to wake a sleeping host machine by sending keyboard or mouse input. Tested on JetKVM v2 (RV1106 SoC, DWC3 v3.30a) waking a Windows 11 host from S3 sleep via Intel xHCI USB 3.1 controller. Host wakes in ~4 seconds from HID keystroke. Closes: https://github.com/jetkvm/kvm/issues/120 Closes: https://github.com/jetkvm/kvm/issues/674 * fix: guard func.config dereference in f_hidg_write Move the hidg->func.config->cdev dereference inside the wakeup_on_write guard block and add a NULL check on func.config before accessing cdev. This prevents a potential NULL pointer dereference if f_hidg_write races with unbind, where func.config can be NULL before the spinlock is acquired. The cdev variable was only used for the wakeup call, so scoping it to the guard block is safe.
42 lines
891 B
C
42 lines
891 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* u_hid.h
|
|
*
|
|
* Utility definitions for the hid function
|
|
*
|
|
* Copyright (c) 2014 Samsung Electronics Co., Ltd.
|
|
* http://www.samsung.com
|
|
*
|
|
* Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
|
|
*/
|
|
|
|
#ifndef U_HID_H
|
|
#define U_HID_H
|
|
|
|
#include <linux/usb/composite.h>
|
|
|
|
struct f_hid_opts {
|
|
struct usb_function_instance func_inst;
|
|
int minor;
|
|
unsigned char subclass;
|
|
unsigned char protocol;
|
|
unsigned char no_out_endpoint;
|
|
unsigned char wakeup_on_write;
|
|
unsigned short report_length;
|
|
unsigned short report_desc_length;
|
|
unsigned char *report_desc;
|
|
bool report_desc_alloc;
|
|
|
|
/*
|
|
* Protect the data form concurrent access by read/write
|
|
* and create symlink/remove symlink.
|
|
*/
|
|
struct mutex lock;
|
|
int refcnt;
|
|
};
|
|
|
|
int ghid_setup(struct usb_gadget *g, int count);
|
|
void ghid_cleanup(void);
|
|
|
|
#endif /* U_HID_H */
|