mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-09-06 21:14:18 +00:00
usb: gadget: uvc: Add new enable_interrupt_ep attribute
Add a new attribute to the default control config group that allows users to specify whether they want to enable the optional interrupt endpoint for the VideoControl interface. Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com> Link: https://lore.kernel.org/r/20230130105045.120886-3-dan.scally@ideasonboard.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
3078212caf
commit
a36afe7804
@ -15,11 +15,13 @@ Date: Dec 2014
|
|||||||
KernelVersion: 4.0
|
KernelVersion: 4.0
|
||||||
Description: Control descriptors
|
Description: Control descriptors
|
||||||
|
|
||||||
All attributes read only:
|
All attributes read only except enable_interrupt_ep:
|
||||||
|
|
||||||
================ =============================
|
================ =============================
|
||||||
bInterfaceNumber USB interface number for this
|
bInterfaceNumber USB interface number for this
|
||||||
streaming interface
|
streaming interface
|
||||||
|
enable_interrupt_ep flag to enable the interrupt
|
||||||
|
endpoint for the VC interface
|
||||||
================ =============================
|
================ =============================
|
||||||
|
|
||||||
What: /config/usb-gadget/gadget/functions/uvc.name/control/class
|
What: /config/usb-gadget/gadget/functions/uvc.name/control/class
|
||||||
|
@ -29,6 +29,8 @@ struct f_uvc_opts {
|
|||||||
unsigned int streaming_interface;
|
unsigned int streaming_interface;
|
||||||
char function_name[32];
|
char function_name[32];
|
||||||
|
|
||||||
|
bool enable_interrupt_ep;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Control descriptors array pointers for full-/high-speed and
|
* Control descriptors array pointers for full-/high-speed and
|
||||||
* super-speed. They point by default to the uvc_fs_control_cls and
|
* super-speed. They point by default to the uvc_fs_control_cls and
|
||||||
|
@ -716,8 +716,61 @@ static ssize_t uvcg_default_control_b_interface_number_show(
|
|||||||
|
|
||||||
UVC_ATTR_RO(uvcg_default_control_, b_interface_number, bInterfaceNumber);
|
UVC_ATTR_RO(uvcg_default_control_, b_interface_number, bInterfaceNumber);
|
||||||
|
|
||||||
|
static ssize_t uvcg_default_control_enable_interrupt_ep_show(
|
||||||
|
struct config_item *item, char *page)
|
||||||
|
{
|
||||||
|
struct config_group *group = to_config_group(item);
|
||||||
|
struct mutex *su_mutex = &group->cg_subsys->su_mutex;
|
||||||
|
struct config_item *opts_item;
|
||||||
|
struct f_uvc_opts *opts;
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
mutex_lock(su_mutex); /* for navigating configfs hierarchy */
|
||||||
|
|
||||||
|
opts_item = item->ci_parent;
|
||||||
|
opts = to_f_uvc_opts(opts_item);
|
||||||
|
|
||||||
|
mutex_lock(&opts->lock);
|
||||||
|
result += sprintf(page, "%u\n", opts->enable_interrupt_ep);
|
||||||
|
mutex_unlock(&opts->lock);
|
||||||
|
|
||||||
|
mutex_unlock(su_mutex);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t uvcg_default_control_enable_interrupt_ep_store(
|
||||||
|
struct config_item *item, const char *page, size_t len)
|
||||||
|
{
|
||||||
|
struct config_group *group = to_config_group(item);
|
||||||
|
struct mutex *su_mutex = &group->cg_subsys->su_mutex;
|
||||||
|
struct config_item *opts_item;
|
||||||
|
struct f_uvc_opts *opts;
|
||||||
|
ssize_t ret;
|
||||||
|
u8 num;
|
||||||
|
|
||||||
|
ret = kstrtou8(page, 0, &num);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
mutex_lock(su_mutex); /* for navigating configfs hierarchy */
|
||||||
|
|
||||||
|
opts_item = item->ci_parent;
|
||||||
|
opts = to_f_uvc_opts(opts_item);
|
||||||
|
|
||||||
|
mutex_lock(&opts->lock);
|
||||||
|
opts->enable_interrupt_ep = num;
|
||||||
|
mutex_unlock(&opts->lock);
|
||||||
|
|
||||||
|
mutex_unlock(su_mutex);
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
UVC_ATTR(uvcg_default_control_, enable_interrupt_ep, enable_interrupt_ep);
|
||||||
|
|
||||||
static struct configfs_attribute *uvcg_default_control_attrs[] = {
|
static struct configfs_attribute *uvcg_default_control_attrs[] = {
|
||||||
&uvcg_default_control_attr_b_interface_number,
|
&uvcg_default_control_attr_b_interface_number,
|
||||||
|
&uvcg_default_control_attr_enable_interrupt_ep,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user