Commit 755801cb authored by Felipe Balbi's avatar Felipe Balbi

Merge tag 'uvcg-20180925' of git://linuxtv.org/pinchartl/media into testing/next

UVC gadget updates for v4.20

- configfs cleanups, fixes and extensions
- Endianness fixes
- Miscellaneous cleanups
parents 17b57b18 3fb2fd76
...@@ -12,6 +12,10 @@ Date: Dec 2014 ...@@ -12,6 +12,10 @@ Date: Dec 2014
KernelVersion: 4.0 KernelVersion: 4.0
Description: Control descriptors Description: Control descriptors
All attributes read only:
bInterfaceNumber - USB interface number for this
streaming interface
What: /config/usb-gadget/gadget/functions/uvc.name/control/class What: /config/usb-gadget/gadget/functions/uvc.name/control/class
Date: Dec 2014 Date: Dec 2014
KernelVersion: 4.0 KernelVersion: 4.0
...@@ -109,6 +113,10 @@ Date: Dec 2014 ...@@ -109,6 +113,10 @@ Date: Dec 2014
KernelVersion: 4.0 KernelVersion: 4.0
Description: Streaming descriptors Description: Streaming descriptors
All attributes read only:
bInterfaceNumber - USB interface number for this
streaming interface
What: /config/usb-gadget/gadget/functions/uvc.name/streaming/class What: /config/usb-gadget/gadget/functions/uvc.name/streaming/class
Date: Dec 2014 Date: Dec 2014
KernelVersion: 4.0 KernelVersion: 4.0
...@@ -160,6 +168,10 @@ Description: Specific MJPEG format descriptors ...@@ -160,6 +168,10 @@ Description: Specific MJPEG format descriptors
All attributes read only, All attributes read only,
except bmaControls and bDefaultFrameIndex: 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 bmaControls - this format's data for bmaControls in
the streaming header the streaming header
bmInterfaceFlags - specifies interlace information, bmInterfaceFlags - specifies interlace information,
...@@ -177,6 +189,10 @@ Date: Dec 2014 ...@@ -177,6 +189,10 @@ Date: Dec 2014
KernelVersion: 4.0 KernelVersion: 4.0
Description: Specific MJPEG frame descriptors Description: Specific MJPEG frame descriptors
bFrameIndex - unique id for this framedescriptor;
only defined after parent format is
linked into the streaming header;
read-only
dwFrameInterval - indicates how frame interval can be dwFrameInterval - indicates how frame interval can be
programmed; a number of values programmed; a number of values
separated by newline can be specified separated by newline can be specified
...@@ -204,6 +220,10 @@ Date: Dec 2014 ...@@ -204,6 +220,10 @@ Date: Dec 2014
KernelVersion: 4.0 KernelVersion: 4.0
Description: Specific uncompressed format descriptors 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 bmaControls - this format's data for bmaControls in
the streaming header the streaming header
bmInterfaceFlags - specifies interlace information, bmInterfaceFlags - specifies interlace information,
...@@ -224,6 +244,10 @@ Date: Dec 2014 ...@@ -224,6 +244,10 @@ Date: Dec 2014
KernelVersion: 4.0 KernelVersion: 4.0
Description: Specific uncompressed frame descriptors Description: Specific uncompressed frame descriptors
bFrameIndex - unique id for this framedescriptor;
only defined after parent format is
linked into the streaming header;
read-only
dwFrameInterval - indicates how frame interval can be dwFrameInterval - indicates how frame interval can be
programmed; a number of values programmed; a number of values
separated by newline can be specified separated by newline can be specified
......
...@@ -197,12 +197,6 @@ static const struct usb_descriptor_header * const uvc_ss_streaming[] = { ...@@ -197,12 +197,6 @@ static const struct usb_descriptor_header * const uvc_ss_streaming[] = {
NULL, NULL,
}; };
void uvc_set_trace_param(unsigned int trace)
{
uvc_gadget_trace_param = trace;
}
EXPORT_SYMBOL(uvc_set_trace_param);
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
* Control requests * Control requests
*/ */
...@@ -232,13 +226,8 @@ uvc_function_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl) ...@@ -232,13 +226,8 @@ uvc_function_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
struct v4l2_event v4l2_event; struct v4l2_event v4l2_event;
struct uvc_event *uvc_event = (void *)&v4l2_event.u.data; struct uvc_event *uvc_event = (void *)&v4l2_event.u.data;
/* printk(KERN_INFO "setup request %02x %02x value %04x index %04x %04x\n",
* ctrl->bRequestType, ctrl->bRequest, le16_to_cpu(ctrl->wValue),
* le16_to_cpu(ctrl->wIndex), le16_to_cpu(ctrl->wLength));
*/
if ((ctrl->bRequestType & USB_TYPE_MASK) != USB_TYPE_CLASS) { if ((ctrl->bRequestType & USB_TYPE_MASK) != USB_TYPE_CLASS) {
INFO(f->config->cdev, "invalid request type\n"); uvcg_info(f, "invalid request type\n");
return -EINVAL; return -EINVAL;
} }
...@@ -272,7 +261,7 @@ uvc_function_get_alt(struct usb_function *f, unsigned interface) ...@@ -272,7 +261,7 @@ uvc_function_get_alt(struct usb_function *f, unsigned interface)
{ {
struct uvc_device *uvc = to_uvc(f); struct uvc_device *uvc = to_uvc(f);
INFO(f->config->cdev, "uvc_function_get_alt(%u)\n", interface); uvcg_info(f, "%s(%u)\n", __func__, interface);
if (interface == uvc->control_intf) if (interface == uvc->control_intf)
return 0; return 0;
...@@ -291,13 +280,13 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt) ...@@ -291,13 +280,13 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
struct uvc_event *uvc_event = (void *)&v4l2_event.u.data; struct uvc_event *uvc_event = (void *)&v4l2_event.u.data;
int ret; int ret;
INFO(cdev, "uvc_function_set_alt(%u, %u)\n", interface, alt); uvcg_info(f, "%s(%u, %u)\n", __func__, interface, alt);
if (interface == uvc->control_intf) { if (interface == uvc->control_intf) {
if (alt) if (alt)
return -EINVAL; return -EINVAL;
INFO(cdev, "reset UVC Control\n"); uvcg_info(f, "reset UVC Control\n");
usb_ep_disable(uvc->control_ep); usb_ep_disable(uvc->control_ep);
if (!uvc->control_ep->desc) if (!uvc->control_ep->desc)
...@@ -348,7 +337,7 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt) ...@@ -348,7 +337,7 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
if (!uvc->video.ep) if (!uvc->video.ep)
return -EINVAL; return -EINVAL;
INFO(cdev, "reset UVC\n"); uvcg_info(f, "reset UVC\n");
usb_ep_disable(uvc->video.ep); usb_ep_disable(uvc->video.ep);
ret = config_ep_by_speed(f->config->cdev->gadget, ret = config_ep_by_speed(f->config->cdev->gadget,
...@@ -373,7 +362,7 @@ uvc_function_disable(struct usb_function *f) ...@@ -373,7 +362,7 @@ uvc_function_disable(struct usb_function *f)
struct uvc_device *uvc = to_uvc(f); struct uvc_device *uvc = to_uvc(f);
struct v4l2_event v4l2_event; struct v4l2_event v4l2_event;
INFO(f->config->cdev, "uvc_function_disable\n"); uvcg_info(f, "%s()\n", __func__);
memset(&v4l2_event, 0, sizeof(v4l2_event)); memset(&v4l2_event, 0, sizeof(v4l2_event));
v4l2_event.type = UVC_EVENT_DISCONNECT; v4l2_event.type = UVC_EVENT_DISCONNECT;
...@@ -392,21 +381,19 @@ uvc_function_disable(struct usb_function *f) ...@@ -392,21 +381,19 @@ uvc_function_disable(struct usb_function *f)
void void
uvc_function_connect(struct uvc_device *uvc) uvc_function_connect(struct uvc_device *uvc)
{ {
struct usb_composite_dev *cdev = uvc->func.config->cdev;
int ret; int ret;
if ((ret = usb_function_activate(&uvc->func)) < 0) if ((ret = usb_function_activate(&uvc->func)) < 0)
INFO(cdev, "UVC connect failed with %d\n", ret); uvcg_info(&uvc->func, "UVC connect failed with %d\n", ret);
} }
void void
uvc_function_disconnect(struct uvc_device *uvc) uvc_function_disconnect(struct uvc_device *uvc)
{ {
struct usb_composite_dev *cdev = uvc->func.config->cdev;
int ret; int ret;
if ((ret = usb_function_deactivate(&uvc->func)) < 0) if ((ret = usb_function_deactivate(&uvc->func)) < 0)
INFO(cdev, "UVC disconnect failed with %d\n", ret); uvcg_info(&uvc->func, "UVC disconnect failed with %d\n", ret);
} }
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
...@@ -605,7 +592,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -605,7 +592,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
struct f_uvc_opts *opts; struct f_uvc_opts *opts;
int ret = -EINVAL; int ret = -EINVAL;
INFO(cdev, "uvc_function_bind\n"); uvcg_info(f, "%s()\n", __func__);
opts = fi_to_f_uvc_opts(f->fi); opts = fi_to_f_uvc_opts(f->fi);
/* Sanity check the streaming endpoint module parameters. /* Sanity check the streaming endpoint module parameters.
...@@ -618,7 +605,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -618,7 +605,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
if (opts->streaming_maxburst && if (opts->streaming_maxburst &&
(opts->streaming_maxpacket % 1024) != 0) { (opts->streaming_maxpacket % 1024) != 0) {
opts->streaming_maxpacket = roundup(opts->streaming_maxpacket, 1024); opts->streaming_maxpacket = roundup(opts->streaming_maxpacket, 1024);
INFO(cdev, "overriding streaming_maxpacket to %d\n", uvcg_info(f, "overriding streaming_maxpacket to %d\n",
opts->streaming_maxpacket); opts->streaming_maxpacket);
} }
...@@ -658,7 +645,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -658,7 +645,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
/* Allocate endpoints. */ /* Allocate endpoints. */
ep = usb_ep_autoconfig(cdev->gadget, &uvc_control_ep); ep = usb_ep_autoconfig(cdev->gadget, &uvc_control_ep);
if (!ep) { if (!ep) {
INFO(cdev, "Unable to allocate control EP\n"); uvcg_info(f, "Unable to allocate control EP\n");
goto error; goto error;
} }
uvc->control_ep = ep; uvc->control_ep = ep;
...@@ -672,7 +659,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -672,7 +659,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
ep = usb_ep_autoconfig(cdev->gadget, &uvc_fs_streaming_ep); ep = usb_ep_autoconfig(cdev->gadget, &uvc_fs_streaming_ep);
if (!ep) { if (!ep) {
INFO(cdev, "Unable to allocate streaming EP\n"); uvcg_info(f, "Unable to allocate streaming EP\n");
goto error; goto error;
} }
uvc->video.ep = ep; uvc->video.ep = ep;
...@@ -699,12 +686,14 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -699,12 +686,14 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
uvc_iad.bFirstInterface = ret; uvc_iad.bFirstInterface = ret;
uvc_control_intf.bInterfaceNumber = ret; uvc_control_intf.bInterfaceNumber = ret;
uvc->control_intf = ret; uvc->control_intf = ret;
opts->control_interface = ret;
if ((ret = usb_interface_id(c, f)) < 0) if ((ret = usb_interface_id(c, f)) < 0)
goto error; goto error;
uvc_streaming_intf_alt0.bInterfaceNumber = ret; uvc_streaming_intf_alt0.bInterfaceNumber = ret;
uvc_streaming_intf_alt1.bInterfaceNumber = ret; uvc_streaming_intf_alt1.bInterfaceNumber = ret;
uvc->streaming_intf = ret; uvc->streaming_intf = ret;
opts->streaming_interface = ret;
/* Copy descriptors */ /* Copy descriptors */
f->fs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL); f->fs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL);
...@@ -743,19 +732,19 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -743,19 +732,19 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
uvc->control_req->context = uvc; uvc->control_req->context = uvc;
if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) { if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) {
printk(KERN_INFO "v4l2_device_register failed\n"); uvcg_err(f, "failed to register V4L2 device\n");
goto error; goto error;
} }
/* Initialise video. */ /* Initialise video. */
ret = uvcg_video_init(&uvc->video); ret = uvcg_video_init(&uvc->video, uvc);
if (ret < 0) if (ret < 0)
goto error; goto error;
/* Register a V4L2 device. */ /* Register a V4L2 device. */
ret = uvc_register_video(uvc); ret = uvc_register_video(uvc);
if (ret < 0) { if (ret < 0) {
printk(KERN_INFO "Unable to register video device\n"); uvcg_err(f, "failed to register video device\n");
goto error; goto error;
} }
...@@ -792,6 +781,7 @@ static struct usb_function_instance *uvc_alloc_inst(void) ...@@ -792,6 +781,7 @@ static struct usb_function_instance *uvc_alloc_inst(void)
struct uvc_output_terminal_descriptor *od; struct uvc_output_terminal_descriptor *od;
struct uvc_color_matching_descriptor *md; struct uvc_color_matching_descriptor *md;
struct uvc_descriptor_header **ctl_cls; struct uvc_descriptor_header **ctl_cls;
int ret;
opts = kzalloc(sizeof(*opts), GFP_KERNEL); opts = kzalloc(sizeof(*opts), GFP_KERNEL);
if (!opts) if (!opts)
...@@ -868,7 +858,12 @@ static struct usb_function_instance *uvc_alloc_inst(void) ...@@ -868,7 +858,12 @@ static struct usb_function_instance *uvc_alloc_inst(void)
opts->streaming_interval = 1; opts->streaming_interval = 1;
opts->streaming_maxpacket = 1024; opts->streaming_maxpacket = 1024;
uvcg_attach_configfs(opts); ret = uvcg_attach_configfs(opts);
if (ret < 0) {
kfree(opts);
return ERR_PTR(ret);
}
return &opts->func_inst; return &opts->func_inst;
} }
...@@ -886,7 +881,7 @@ static void uvc_unbind(struct usb_configuration *c, struct usb_function *f) ...@@ -886,7 +881,7 @@ static void uvc_unbind(struct usb_configuration *c, struct usb_function *f)
struct usb_composite_dev *cdev = c->cdev; struct usb_composite_dev *cdev = c->cdev;
struct uvc_device *uvc = to_uvc(f); struct uvc_device *uvc = to_uvc(f);
INFO(cdev, "%s\n", __func__); uvcg_info(f, "%s\n", __func__);
device_remove_file(&uvc->vdev.dev, &dev_attr_function_name); device_remove_file(&uvc->vdev.dev, &dev_attr_function_name);
video_unregister_device(&uvc->vdev); video_unregister_device(&uvc->vdev);
......
...@@ -25,6 +25,9 @@ struct f_uvc_opts { ...@@ -25,6 +25,9 @@ struct f_uvc_opts {
unsigned int streaming_maxpacket; unsigned int streaming_maxpacket;
unsigned int streaming_maxburst; unsigned int streaming_maxburst;
unsigned int control_interface;
unsigned int streaming_interface;
/* /*
* 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
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
struct usb_ep; struct usb_ep;
struct usb_request; struct usb_request;
struct uvc_descriptor_header; struct uvc_descriptor_header;
struct uvc_device;
/* ------------------------------------------------------------------------ /* ------------------------------------------------------------------------
* Debugging, printing and logging * Debugging, printing and logging
...@@ -51,14 +52,12 @@ extern unsigned int uvc_gadget_trace_param; ...@@ -51,14 +52,12 @@ extern unsigned int uvc_gadget_trace_param;
printk(KERN_DEBUG "uvcvideo: " msg); \ printk(KERN_DEBUG "uvcvideo: " msg); \
} while (0) } while (0)
#define uvc_warn_once(dev, warn, msg...) \ #define uvcg_dbg(f, fmt, args...) \
do { \ dev_dbg(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args)
if (!test_and_set_bit(warn, &dev->warnings)) \ #define uvcg_info(f, fmt, args...) \
printk(KERN_INFO "uvcvideo: " msg); \ dev_info(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args)
} while (0) #define uvcg_err(f, fmt, args...) \
dev_err(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args)
#define uvc_printk(level, msg...) \
printk(level "uvcvideo: " msg)
/* ------------------------------------------------------------------------ /* ------------------------------------------------------------------------
* Driver specific constants * Driver specific constants
...@@ -73,6 +72,7 @@ extern unsigned int uvc_gadget_trace_param; ...@@ -73,6 +72,7 @@ extern unsigned int uvc_gadget_trace_param;
*/ */
struct uvc_video { struct uvc_video {
struct uvc_device *uvc;
struct usb_ep *ep; struct usb_ep *ep;
/* Frame parameters */ /* Frame parameters */
......
This diff is collapsed.
...@@ -115,7 +115,7 @@ uvc_v4l2_set_format(struct file *file, void *fh, struct v4l2_format *fmt) ...@@ -115,7 +115,7 @@ uvc_v4l2_set_format(struct file *file, void *fh, struct v4l2_format *fmt)
} }
if (i == ARRAY_SIZE(uvc_formats)) { if (i == ARRAY_SIZE(uvc_formats)) {
printk(KERN_INFO "Unsupported format 0x%08x.\n", uvcg_info(&uvc->func, "Unsupported format 0x%08x.\n",
fmt->fmt.pix.pixelformat); fmt->fmt.pix.pixelformat);
return -EINVAL; return -EINVAL;
} }
......
...@@ -125,6 +125,23 @@ uvc_video_encode_isoc(struct usb_request *req, struct uvc_video *video, ...@@ -125,6 +125,23 @@ uvc_video_encode_isoc(struct usb_request *req, struct uvc_video *video,
* Request handling * Request handling
*/ */
static int uvcg_video_ep_queue(struct uvc_video *video, struct usb_request *req)
{
int ret;
ret = usb_ep_queue(video->ep, req, GFP_ATOMIC);
if (ret < 0) {
uvcg_err(&video->uvc->func, "Failed to queue request (%d).\n",
ret);
/* Isochronous endpoints can't be halted. */
if (usb_endpoint_xfer_bulk(video->ep->desc))
usb_ep_set_halt(video->ep);
}
return ret;
}
/* /*
* I somehow feel that synchronisation won't be easy to achieve here. We have * I somehow feel that synchronisation won't be easy to achieve here. We have
* three events that control USB requests submission: * three events that control USB requests submission:
...@@ -169,12 +186,13 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req) ...@@ -169,12 +186,13 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req)
break; break;
case -ESHUTDOWN: /* disconnect from host. */ case -ESHUTDOWN: /* disconnect from host. */
printk(KERN_DEBUG "VS request cancelled.\n"); uvcg_dbg(&video->uvc->func, "VS request cancelled.\n");
uvcg_queue_cancel(queue, 1); uvcg_queue_cancel(queue, 1);
goto requeue; goto requeue;
default: default:
printk(KERN_INFO "VS request completed with status %d.\n", uvcg_info(&video->uvc->func,
"VS request completed with status %d.\n",
req->status); req->status);
uvcg_queue_cancel(queue, 0); uvcg_queue_cancel(queue, 0);
goto requeue; goto requeue;
...@@ -189,14 +207,13 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req) ...@@ -189,14 +207,13 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req)
video->encode(req, video, buf); video->encode(req, video, buf);
if ((ret = usb_ep_queue(ep, req, GFP_ATOMIC)) < 0) { ret = uvcg_video_ep_queue(video, req);
printk(KERN_INFO "Failed to queue request (%d).\n", ret);
usb_ep_set_halt(ep);
spin_unlock_irqrestore(&video->queue.irqlock, flags); spin_unlock_irqrestore(&video->queue.irqlock, flags);
if (ret < 0) {
uvcg_queue_cancel(queue, 0); uvcg_queue_cancel(queue, 0);
goto requeue; goto requeue;
} }
spin_unlock_irqrestore(&video->queue.irqlock, flags);
return; return;
...@@ -316,15 +333,13 @@ int uvcg_video_pump(struct uvc_video *video) ...@@ -316,15 +333,13 @@ int uvcg_video_pump(struct uvc_video *video)
video->encode(req, video, buf); video->encode(req, video, buf);
/* Queue the USB request */ /* Queue the USB request */
ret = usb_ep_queue(video->ep, req, GFP_ATOMIC); ret = uvcg_video_ep_queue(video, req);
if (ret < 0) {
printk(KERN_INFO "Failed to queue request (%d)\n", ret);
usb_ep_set_halt(video->ep);
spin_unlock_irqrestore(&queue->irqlock, flags); spin_unlock_irqrestore(&queue->irqlock, flags);
if (ret < 0) {
uvcg_queue_cancel(queue, 0); uvcg_queue_cancel(queue, 0);
break; break;
} }
spin_unlock_irqrestore(&queue->irqlock, flags);
} }
spin_lock_irqsave(&video->req_lock, flags); spin_lock_irqsave(&video->req_lock, flags);
...@@ -342,8 +357,8 @@ int uvcg_video_enable(struct uvc_video *video, int enable) ...@@ -342,8 +357,8 @@ int uvcg_video_enable(struct uvc_video *video, int enable)
int ret; int ret;
if (video->ep == NULL) { if (video->ep == NULL) {
printk(KERN_INFO "Video enable failed, device is " uvcg_info(&video->uvc->func,
"uninitialized.\n"); "Video enable failed, device is uninitialized.\n");
return -ENODEV; return -ENODEV;
} }
...@@ -375,11 +390,12 @@ int uvcg_video_enable(struct uvc_video *video, int enable) ...@@ -375,11 +390,12 @@ int uvcg_video_enable(struct uvc_video *video, int enable)
/* /*
* Initialize the UVC video stream. * Initialize the UVC video stream.
*/ */
int uvcg_video_init(struct uvc_video *video) int uvcg_video_init(struct uvc_video *video, struct uvc_device *uvc)
{ {
INIT_LIST_HEAD(&video->req_free); INIT_LIST_HEAD(&video->req_free);
spin_lock_init(&video->req_lock); spin_lock_init(&video->req_lock);
video->uvc = uvc;
video->fcc = V4L2_PIX_FMT_YUYV; video->fcc = V4L2_PIX_FMT_YUYV;
video->bpp = 16; video->bpp = 16;
video->width = 320; video->width = 320;
......
...@@ -18,6 +18,6 @@ int uvcg_video_pump(struct uvc_video *video); ...@@ -18,6 +18,6 @@ int uvcg_video_pump(struct uvc_video *video);
int uvcg_video_enable(struct uvc_video *video, int enable); int uvcg_video_enable(struct uvc_video *video, int enable);
int uvcg_video_init(struct uvc_video *video); int uvcg_video_init(struct uvc_video *video, struct uvc_device *uvc);
#endif /* __UVC_VIDEO_H__ */ #endif /* __UVC_VIDEO_H__ */
...@@ -195,9 +195,9 @@ struct uvc_header_descriptor { ...@@ -195,9 +195,9 @@ struct uvc_header_descriptor {
__u8 bLength; __u8 bLength;
__u8 bDescriptorType; __u8 bDescriptorType;
__u8 bDescriptorSubType; __u8 bDescriptorSubType;
__u16 bcdUVC; __le16 bcdUVC;
__u16 wTotalLength; __le16 wTotalLength;
__u32 dwClockFrequency; __le32 dwClockFrequency;
__u8 bInCollection; __u8 bInCollection;
__u8 baInterfaceNr[]; __u8 baInterfaceNr[];
} __attribute__((__packed__)); } __attribute__((__packed__));
...@@ -212,9 +212,9 @@ struct UVC_HEADER_DESCRIPTOR(n) { \ ...@@ -212,9 +212,9 @@ struct UVC_HEADER_DESCRIPTOR(n) { \
__u8 bLength; \ __u8 bLength; \
__u8 bDescriptorType; \ __u8 bDescriptorType; \
__u8 bDescriptorSubType; \ __u8 bDescriptorSubType; \
__u16 bcdUVC; \ __le16 bcdUVC; \
__u16 wTotalLength; \ __le16 wTotalLength; \
__u32 dwClockFrequency; \ __le32 dwClockFrequency; \
__u8 bInCollection; \ __u8 bInCollection; \
__u8 baInterfaceNr[n]; \ __u8 baInterfaceNr[n]; \
} __attribute__ ((packed)) } __attribute__ ((packed))
...@@ -225,7 +225,7 @@ struct uvc_input_terminal_descriptor { ...@@ -225,7 +225,7 @@ struct uvc_input_terminal_descriptor {
__u8 bDescriptorType; __u8 bDescriptorType;
__u8 bDescriptorSubType; __u8 bDescriptorSubType;
__u8 bTerminalID; __u8 bTerminalID;
__u16 wTerminalType; __le16 wTerminalType;
__u8 bAssocTerminal; __u8 bAssocTerminal;
__u8 iTerminal; __u8 iTerminal;
} __attribute__((__packed__)); } __attribute__((__packed__));
...@@ -238,7 +238,7 @@ struct uvc_output_terminal_descriptor { ...@@ -238,7 +238,7 @@ struct uvc_output_terminal_descriptor {
__u8 bDescriptorType; __u8 bDescriptorType;
__u8 bDescriptorSubType; __u8 bDescriptorSubType;
__u8 bTerminalID; __u8 bTerminalID;
__u16 wTerminalType; __le16 wTerminalType;
__u8 bAssocTerminal; __u8 bAssocTerminal;
__u8 bSourceID; __u8 bSourceID;
__u8 iTerminal; __u8 iTerminal;
...@@ -252,12 +252,12 @@ struct uvc_camera_terminal_descriptor { ...@@ -252,12 +252,12 @@ struct uvc_camera_terminal_descriptor {
__u8 bDescriptorType; __u8 bDescriptorType;
__u8 bDescriptorSubType; __u8 bDescriptorSubType;
__u8 bTerminalID; __u8 bTerminalID;
__u16 wTerminalType; __le16 wTerminalType;
__u8 bAssocTerminal; __u8 bAssocTerminal;
__u8 iTerminal; __u8 iTerminal;
__u16 wObjectiveFocalLengthMin; __le16 wObjectiveFocalLengthMin;
__u16 wObjectiveFocalLengthMax; __le16 wObjectiveFocalLengthMax;
__u16 wOcularFocalLength; __le16 wOcularFocalLength;
__u8 bControlSize; __u8 bControlSize;
__u8 bmControls[3]; __u8 bmControls[3];
} __attribute__((__packed__)); } __attribute__((__packed__));
...@@ -298,7 +298,7 @@ struct uvc_processing_unit_descriptor { ...@@ -298,7 +298,7 @@ struct uvc_processing_unit_descriptor {
__u8 bDescriptorSubType; __u8 bDescriptorSubType;
__u8 bUnitID; __u8 bUnitID;
__u8 bSourceID; __u8 bSourceID;
__u16 wMaxMultiplier; __le16 wMaxMultiplier;
__u8 bControlSize; __u8 bControlSize;
__u8 bmControls[2]; __u8 bmControls[2];
__u8 iProcessing; __u8 iProcessing;
...@@ -346,7 +346,7 @@ struct uvc_control_endpoint_descriptor { ...@@ -346,7 +346,7 @@ struct uvc_control_endpoint_descriptor {
__u8 bLength; __u8 bLength;
__u8 bDescriptorType; __u8 bDescriptorType;
__u8 bDescriptorSubType; __u8 bDescriptorSubType;
__u16 wMaxTransferSize; __le16 wMaxTransferSize;
} __attribute__((__packed__)); } __attribute__((__packed__));
#define UVC_DT_CONTROL_ENDPOINT_SIZE 5 #define UVC_DT_CONTROL_ENDPOINT_SIZE 5
...@@ -357,7 +357,7 @@ struct uvc_input_header_descriptor { ...@@ -357,7 +357,7 @@ struct uvc_input_header_descriptor {
__u8 bDescriptorType; __u8 bDescriptorType;
__u8 bDescriptorSubType; __u8 bDescriptorSubType;
__u8 bNumFormats; __u8 bNumFormats;
__u16 wTotalLength; __le16 wTotalLength;
__u8 bEndpointAddress; __u8 bEndpointAddress;
__u8 bmInfo; __u8 bmInfo;
__u8 bTerminalLink; __u8 bTerminalLink;
...@@ -379,7 +379,7 @@ struct UVC_INPUT_HEADER_DESCRIPTOR(n, p) { \ ...@@ -379,7 +379,7 @@ struct UVC_INPUT_HEADER_DESCRIPTOR(n, p) { \
__u8 bDescriptorType; \ __u8 bDescriptorType; \
__u8 bDescriptorSubType; \ __u8 bDescriptorSubType; \
__u8 bNumFormats; \ __u8 bNumFormats; \
__u16 wTotalLength; \ __le16 wTotalLength; \
__u8 bEndpointAddress; \ __u8 bEndpointAddress; \
__u8 bmInfo; \ __u8 bmInfo; \
__u8 bTerminalLink; \ __u8 bTerminalLink; \
...@@ -396,7 +396,7 @@ struct uvc_output_header_descriptor { ...@@ -396,7 +396,7 @@ struct uvc_output_header_descriptor {
__u8 bDescriptorType; __u8 bDescriptorType;
__u8 bDescriptorSubType; __u8 bDescriptorSubType;
__u8 bNumFormats; __u8 bNumFormats;
__u16 wTotalLength; __le16 wTotalLength;
__u8 bEndpointAddress; __u8 bEndpointAddress;
__u8 bTerminalLink; __u8 bTerminalLink;
__u8 bControlSize; __u8 bControlSize;
...@@ -414,7 +414,7 @@ struct UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) { \ ...@@ -414,7 +414,7 @@ struct UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) { \
__u8 bDescriptorType; \ __u8 bDescriptorType; \
__u8 bDescriptorSubType; \ __u8 bDescriptorSubType; \
__u8 bNumFormats; \ __u8 bNumFormats; \
__u16 wTotalLength; \ __le16 wTotalLength; \
__u8 bEndpointAddress; \ __u8 bEndpointAddress; \
__u8 bTerminalLink; \ __u8 bTerminalLink; \
__u8 bControlSize; \ __u8 bControlSize; \
...@@ -478,14 +478,14 @@ struct uvc_frame_uncompressed { ...@@ -478,14 +478,14 @@ struct uvc_frame_uncompressed {
__u8 bDescriptorSubType; __u8 bDescriptorSubType;
__u8 bFrameIndex; __u8 bFrameIndex;
__u8 bmCapabilities; __u8 bmCapabilities;
__u16 wWidth; __le16 wWidth;
__u16 wHeight; __le16 wHeight;
__u32 dwMinBitRate; __le32 dwMinBitRate;
__u32 dwMaxBitRate; __le32 dwMaxBitRate;
__u32 dwMaxVideoFrameBufferSize; __le32 dwMaxVideoFrameBufferSize;
__u32 dwDefaultFrameInterval; __le32 dwDefaultFrameInterval;
__u8 bFrameIntervalType; __u8 bFrameIntervalType;
__u32 dwFrameInterval[]; __le32 dwFrameInterval[];
} __attribute__((__packed__)); } __attribute__((__packed__));
#define UVC_DT_FRAME_UNCOMPRESSED_SIZE(n) (26+4*(n)) #define UVC_DT_FRAME_UNCOMPRESSED_SIZE(n) (26+4*(n))
...@@ -500,14 +500,14 @@ struct UVC_FRAME_UNCOMPRESSED(n) { \ ...@@ -500,14 +500,14 @@ struct UVC_FRAME_UNCOMPRESSED(n) { \
__u8 bDescriptorSubType; \ __u8 bDescriptorSubType; \
__u8 bFrameIndex; \ __u8 bFrameIndex; \
__u8 bmCapabilities; \ __u8 bmCapabilities; \
__u16 wWidth; \ __le16 wWidth; \
__u16 wHeight; \ __le16 wHeight; \
__u32 dwMinBitRate; \ __le32 dwMinBitRate; \
__u32 dwMaxBitRate; \ __le32 dwMaxBitRate; \
__u32 dwMaxVideoFrameBufferSize; \ __le32 dwMaxVideoFrameBufferSize; \
__u32 dwDefaultFrameInterval; \ __le32 dwDefaultFrameInterval; \
__u8 bFrameIntervalType; \ __u8 bFrameIntervalType; \
__u32 dwFrameInterval[n]; \ __le32 dwFrameInterval[n]; \
} __attribute__ ((packed)) } __attribute__ ((packed))
/* MJPEG Payload - 3.1.1. MJPEG Video Format Descriptor */ /* MJPEG Payload - 3.1.1. MJPEG Video Format Descriptor */
...@@ -534,14 +534,14 @@ struct uvc_frame_mjpeg { ...@@ -534,14 +534,14 @@ struct uvc_frame_mjpeg {
__u8 bDescriptorSubType; __u8 bDescriptorSubType;
__u8 bFrameIndex; __u8 bFrameIndex;
__u8 bmCapabilities; __u8 bmCapabilities;
__u16 wWidth; __le16 wWidth;
__u16 wHeight; __le16 wHeight;
__u32 dwMinBitRate; __le32 dwMinBitRate;
__u32 dwMaxBitRate; __le32 dwMaxBitRate;
__u32 dwMaxVideoFrameBufferSize; __le32 dwMaxVideoFrameBufferSize;
__u32 dwDefaultFrameInterval; __le32 dwDefaultFrameInterval;
__u8 bFrameIntervalType; __u8 bFrameIntervalType;
__u32 dwFrameInterval[]; __le32 dwFrameInterval[];
} __attribute__((__packed__)); } __attribute__((__packed__));
#define UVC_DT_FRAME_MJPEG_SIZE(n) (26+4*(n)) #define UVC_DT_FRAME_MJPEG_SIZE(n) (26+4*(n))
...@@ -556,14 +556,14 @@ struct UVC_FRAME_MJPEG(n) { \ ...@@ -556,14 +556,14 @@ struct UVC_FRAME_MJPEG(n) { \
__u8 bDescriptorSubType; \ __u8 bDescriptorSubType; \
__u8 bFrameIndex; \ __u8 bFrameIndex; \
__u8 bmCapabilities; \ __u8 bmCapabilities; \
__u16 wWidth; \ __le16 wWidth; \
__u16 wHeight; \ __le16 wHeight; \
__u32 dwMinBitRate; \ __le32 dwMinBitRate; \
__u32 dwMaxBitRate; \ __le32 dwMaxBitRate; \
__u32 dwMaxVideoFrameBufferSize; \ __le32 dwMaxVideoFrameBufferSize; \
__u32 dwDefaultFrameInterval; \ __le32 dwDefaultFrameInterval; \
__u8 bFrameIntervalType; \ __u8 bFrameIntervalType; \
__u32 dwFrameInterval[n]; \ __le32 dwFrameInterval[n]; \
} __attribute__ ((packed)) } __attribute__ ((packed))
#endif /* __LINUX_USB_VIDEO_H */ #endif /* __LINUX_USB_VIDEO_H */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment