1
0
Fork 0
mirror of https://github.com/linux-usb-gadgets/libusbgx.git synced 2025-07-26 06:55:05 +03:00

uvc: add more controls

When using uncompressed video formats other then the default
YUYV, the user of the uvc gadget needs to set the proper GUID
format. Together with that GUID format it is needed to set
an corresponding BitsPerPixel value. This patch is adding
support to set the values via libusbgx/gadget-tool.
This commit is contained in:
Michael Grzeschik 2023-12-01 00:01:51 +01:00
parent 48b96808ca
commit 3642d9c7a4
7 changed files with 117 additions and 0 deletions

View file

@ -87,6 +87,7 @@ struct {
};
#undef UVC_DEC_ATTR
#undef UVC_STRING_ATTR
#define UVC_DEC_ATTR(_name) \
{ \
@ -138,6 +139,28 @@ struct {
.export = usbg_set_config_node_int, \
}
static inline int usbg_get_guid(const char *path, const char *name,
const char *attr, void *val)
{
return usbg_read_buf_alloc(path, name, attr, (char **)val, GUID_BIN_LENGTH);
}
static inline int usbg_set_guid(const char *path, const char *name,
const char *attr, void *val)
{
return usbg_write_guid(path, name, attr, *(char **)val);
}
#define UVC_GUID_ATTR(_name) \
{ \
.name = #_name, \
.offset = offsetof(struct usbg_f_uvc_format_attrs, _name), \
.get = usbg_get_guid, \
.set = usbg_set_guid, \
.export = usbg_set_config_node_guid, \
.import = usbg_get_config_node_string, \
}
struct {
const char *name;
size_t offset;
@ -152,6 +175,8 @@ struct {
[USBG_F_UVC_FORMAT_ASPECTRATIO_X] = UVC_DEC_ATTR_RO(bAspectRatioX),
[USBG_F_UVC_FORMAT_ASPECTRATIO_Y] = UVC_DEC_ATTR_RO(bAspectRatioY),
[USBG_F_UVC_FORMAT_DEFAULT_FRAME_INDEX] = UVC_DEC_ATTR(bDefaultFrameIndex),
[USBG_F_UVC_FORMAT_GUID_FORMAT] = UVC_GUID_ATTR(guidFormat),
[USBG_F_UVC_FORMAT_BITS_PER_PIXEL] = UVC_DEC_ATTR(bBitsPerPixel),
[USBG_F_UVC_FORMAT_FORMAT_INDEX] = UVC_DEC_ATTR_RO(bFormatIndex),
};