mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 19:08:57 +09:00
UPSTREAM: usb: gadget: uvc: default the ctrl request interface offsets
For the userspace it is needed to distinguish between requests for the
control or streaming interface. The userspace would have to parse the
configfs to know which interface index it has to compare the ctrl
requests against. Since the interface numbers are not fixed, e.g. for
composite gadgets, the interface offset depends on the setup.
The kernel has this information when handing over the ctrl request to
the userspace. This patch removes the offset from the interface numbers
and expose the default interface defines in the uapi g_uvc.h.
Change-Id: Idb6845c962d3da6d2a96c5d5e0083b39e5bba8af
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Link: https://lore.kernel.org/r/20221011075348.1786897-1-m.grzeschik@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: William Wu <william.wu@rock-chips.com>
(cherry picked from commit d182bf156c)
This commit is contained in:
committed by
Tao Huang
parent
fb9e41b3bf
commit
3237d532d5
@@ -39,9 +39,6 @@ MODULE_PARM_DESC(trace, "Trace level bitmask");
|
||||
|
||||
/* string IDs are assigned dynamically */
|
||||
|
||||
#define UVC_STRING_CONTROL_IDX 0
|
||||
#define UVC_STRING_STREAMING_IDX 1
|
||||
|
||||
static struct usb_string uvc_en_us_strings[] = {
|
||||
/* [UVC_STRING_CONTROL_IDX].s = DYNAMIC, */
|
||||
[UVC_STRING_STREAMING_IDX].s = "Video Streaming",
|
||||
@@ -300,6 +297,8 @@ uvc_function_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
|
||||
struct uvc_device *uvc = to_uvc(f);
|
||||
struct v4l2_event v4l2_event;
|
||||
struct uvc_event *uvc_event = (void *)&v4l2_event.u.data;
|
||||
unsigned int interface = le16_to_cpu(ctrl->wIndex) & 0xff;
|
||||
struct usb_ctrlrequest *mctrl;
|
||||
|
||||
uvc_trace(UVC_TRACE_CONTROL,
|
||||
"setup request %02x %02x value %04x index %04x %04x\n",
|
||||
@@ -325,6 +324,16 @@ uvc_function_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
|
||||
memset(&v4l2_event, 0, sizeof(v4l2_event));
|
||||
v4l2_event.type = UVC_EVENT_SETUP;
|
||||
memcpy(&uvc_event->req, ctrl, sizeof(uvc_event->req));
|
||||
|
||||
/* check for the interface number, fixup the interface number in
|
||||
* the ctrl request so the userspace doesn't have to bother with
|
||||
* offset and configfs parsing
|
||||
*/
|
||||
mctrl = &uvc_event->req;
|
||||
mctrl->wIndex &= ~cpu_to_le16(0xff);
|
||||
if (interface == uvc->streaming_intf)
|
||||
mctrl->wIndex = cpu_to_le16(UVC_STRING_STREAMING_IDX);
|
||||
|
||||
v4l2_event_queue(&uvc->vdev, &v4l2_event);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
#define UVC_EVENT_RESUME (V4L2_EVENT_PRIVATE_START + 7)
|
||||
#define UVC_EVENT_LAST (V4L2_EVENT_PRIVATE_START + 7)
|
||||
|
||||
#define UVC_STRING_CONTROL_IDX 0
|
||||
#define UVC_STRING_STREAMING_IDX 1
|
||||
|
||||
struct uvc_request_data {
|
||||
__s32 length;
|
||||
__u8 data[60];
|
||||
|
||||
Reference in New Issue
Block a user