mirror of
https://github.com/torvalds/linux.git
synced 2024-11-14 16:12:02 +00:00
usb: gadget: uvc: Use custom strings if available
If the user has defined a custom string descriptor for the IAD or the VideoStreaming interfaces then set their index field to point to the custom descriptor instead of the hardcoded defaults. If no custom descriptors have been linked to, then use the default ones. Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com> Link: https://lore.kernel.org/r/20230206161802.892954-12-dan.scally@ideasonboard.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
fe62575537
commit
cf13d6e4a9
@ -745,6 +745,10 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
|
||||
if (xu->string_descriptor_index)
|
||||
xu->desc.iExtension = cdev->usb_strings[xu->string_descriptor_index].id;
|
||||
|
||||
/*
|
||||
* We attach the hard-coded defaults incase the user does not provide
|
||||
* any more appropriate strings through configfs.
|
||||
*/
|
||||
uvc_en_us_strings[UVC_STRING_CONTROL_IDX].s = opts->function_name;
|
||||
us = usb_gstrings_attach(cdev, uvc_function_strings,
|
||||
ARRAY_SIZE(uvc_en_us_strings));
|
||||
@ -752,11 +756,15 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
|
||||
ret = PTR_ERR(us);
|
||||
goto error;
|
||||
}
|
||||
uvc_iad.iFunction = us[UVC_STRING_CONTROL_IDX].id;
|
||||
uvc_control_intf.iInterface = us[UVC_STRING_CONTROL_IDX].id;
|
||||
ret = us[UVC_STRING_STREAMING_IDX].id;
|
||||
uvc_streaming_intf_alt0.iInterface = ret;
|
||||
uvc_streaming_intf_alt1.iInterface = ret;
|
||||
|
||||
uvc_iad.iFunction = opts->iad_index ? cdev->usb_strings[opts->iad_index].id :
|
||||
us[UVC_STRING_CONTROL_IDX].id;
|
||||
uvc_streaming_intf_alt0.iInterface = opts->vs0_index ?
|
||||
cdev->usb_strings[opts->vs0_index].id :
|
||||
us[UVC_STRING_STREAMING_IDX].id;
|
||||
uvc_streaming_intf_alt1.iInterface = opts->vs1_index ?
|
||||
cdev->usb_strings[opts->vs1_index].id :
|
||||
us[UVC_STRING_STREAMING_IDX].id;
|
||||
|
||||
/* Allocate interface IDs. */
|
||||
if ((ret = usb_interface_id(c, f)) < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user