mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
UPSTREAM: usb: gadget: uvc: configfs: Add bFormatIndex attributes
The UVC format description are numbered using the descriptor's
bFormatIndex field. The index is used in UVC requests, and is thus
needed to handle requests in userspace. Make it dynamically discoverable
by exposing it in a bFormatIndex configfs attribute of the uncompressed
and mjpeg format config items.
The bFormatIndex value exposed through the attribute is stored in the
config item private data. However, that value is never set: the driver
instead computes the bFormatIndex value when linking the stream class
header in the configfs hierarchy and stores it directly in the class
descriptors in a separate structure. In order to expose the value
through the configfs attribute, store it in the config item private data
as well. This results in a small code simplification.
Change-Id: I537f24242d4cf63efab72b96437193b665f44a60
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: William Wu <william.wu@rock-chips.com>
(cherry picked from commit 61ff10e0ea)
This commit is contained in:
committed by
Tao Huang
parent
91f0677d2c
commit
068cd84209
@@ -168,6 +168,10 @@ Description: Specific MJPEG format descriptors
|
||||
|
||||
All attributes read only,
|
||||
except bmaControls and bDefaultFrameIndex:
|
||||
bFormatIndex - unique id for this format descriptor;
|
||||
only defined after parent header is
|
||||
linked into the streaming class;
|
||||
read-only
|
||||
bmaControls - this format's data for bmaControls in
|
||||
the streaming header
|
||||
bmInterfaceFlags - specifies interlace information,
|
||||
@@ -212,6 +216,10 @@ Date: Dec 2014
|
||||
KernelVersion: 4.0
|
||||
Description: Specific uncompressed format descriptors
|
||||
|
||||
bFormatIndex - unique id for this format descriptor;
|
||||
only defined after parent header is
|
||||
linked into the streaming class;
|
||||
read-only
|
||||
bmaControls - this format's data for bmaControls in
|
||||
the streaming header
|
||||
bmInterfaceFlags - specifies interlace information,
|
||||
|
||||
@@ -1554,6 +1554,7 @@ UVC_ATTR(uvcg_uncompressed_, cname, aname);
|
||||
|
||||
#define identity_conv(x) (x)
|
||||
|
||||
UVCG_UNCOMPRESSED_ATTR_RO(b_format_index, bFormatIndex, identity_conv);
|
||||
UVCG_UNCOMPRESSED_ATTR(b_bits_per_pixel, bBitsPerPixel, identity_conv);
|
||||
UVCG_UNCOMPRESSED_ATTR(b_default_frame_index, bDefaultFrameIndex,
|
||||
identity_conv);
|
||||
@@ -1584,6 +1585,7 @@ uvcg_uncompressed_bma_controls_store(struct config_item *item,
|
||||
UVC_ATTR(uvcg_uncompressed_, bma_controls, bmaControls);
|
||||
|
||||
static struct configfs_attribute *uvcg_uncompressed_attrs[] = {
|
||||
&uvcg_uncompressed_attr_b_format_index,
|
||||
&uvcg_uncompressed_attr_guid_format,
|
||||
&uvcg_uncompressed_attr_b_bits_per_pixel,
|
||||
&uvcg_uncompressed_attr_b_default_frame_index,
|
||||
@@ -1754,6 +1756,7 @@ UVC_ATTR(uvcg_mjpeg_, cname, aname)
|
||||
|
||||
#define identity_conv(x) (x)
|
||||
|
||||
UVCG_MJPEG_ATTR_RO(b_format_index, bFormatIndex, identity_conv);
|
||||
UVCG_MJPEG_ATTR(b_default_frame_index, bDefaultFrameIndex,
|
||||
identity_conv);
|
||||
UVCG_MJPEG_ATTR_RO(bm_flags, bmFlags, identity_conv);
|
||||
@@ -1784,6 +1787,7 @@ uvcg_mjpeg_bma_controls_store(struct config_item *item,
|
||||
UVC_ATTR(uvcg_mjpeg_, bma_controls, bmaControls);
|
||||
|
||||
static struct configfs_attribute *uvcg_mjpeg_attrs[] = {
|
||||
&uvcg_mjpeg_attr_b_format_index,
|
||||
&uvcg_mjpeg_attr_b_default_frame_index,
|
||||
&uvcg_mjpeg_attr_bm_flags,
|
||||
&uvcg_mjpeg_attr_b_aspect_ratio_x,
|
||||
@@ -2095,24 +2099,22 @@ static int __uvcg_fill_strm(void *priv1, void *priv2, void *priv3, int n,
|
||||
struct uvcg_format *fmt = priv1;
|
||||
|
||||
if (fmt->type == UVCG_UNCOMPRESSED) {
|
||||
struct uvc_format_uncompressed *unc = *dest;
|
||||
struct uvcg_uncompressed *u =
|
||||
container_of(fmt, struct uvcg_uncompressed,
|
||||
fmt);
|
||||
|
||||
u->desc.bFormatIndex = n + 1;
|
||||
u->desc.bNumFrameDescriptors = fmt->num_frames;
|
||||
memcpy(*dest, &u->desc, sizeof(u->desc));
|
||||
*dest += sizeof(u->desc);
|
||||
unc->bNumFrameDescriptors = fmt->num_frames;
|
||||
unc->bFormatIndex = n + 1;
|
||||
} else if (fmt->type == UVCG_MJPEG) {
|
||||
struct uvc_format_mjpeg *mjp = *dest;
|
||||
struct uvcg_mjpeg *m =
|
||||
container_of(fmt, struct uvcg_mjpeg, fmt);
|
||||
|
||||
m->desc.bFormatIndex = n + 1;
|
||||
m->desc.bNumFrameDescriptors = fmt->num_frames;
|
||||
memcpy(*dest, &m->desc, sizeof(m->desc));
|
||||
*dest += sizeof(m->desc);
|
||||
mjp->bNumFrameDescriptors = fmt->num_frames;
|
||||
mjp->bFormatIndex = n + 1;
|
||||
} else {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user