13 #include <linux/kernel.h>
14 #include <linux/device.h>
15 #include <linux/errno.h>
16 #include <linux/list.h>
18 #include <linux/videodev2.h>
20 #include <linux/wait.h>
40 return usb_ep_set_halt(cdev->
gadget->ep0);
67 uvc_v4l2_get_format(
struct uvc_video *video,
struct v4l2_format *
fmt)
69 fmt->
fmt.
pix.pixelformat = video->fcc;
70 fmt->
fmt.
pix.width = video->width;
71 fmt->
fmt.
pix.height = video->height;
73 fmt->
fmt.
pix.bytesperline = video->bpp * video->width / 8;
74 fmt->
fmt.
pix.sizeimage = video->imagesize;
82 uvc_v4l2_set_format(
struct uvc_video *video,
struct v4l2_format *
fmt)
85 unsigned int imagesize;
90 format = &uvc_formats[
i];
91 if (format->
fcc == fmt->
fmt.
pix.pixelformat)
101 bpl = format->
bpp * fmt->
fmt.
pix.width / 8;
102 imagesize = bpl ? bpl * fmt->
fmt.
pix.height : fmt->
fmt.
pix.sizeimage;
104 video->fcc = format->
fcc;
105 video->bpp = format->
bpp;
106 video->width = fmt->
fmt.
pix.width;
107 video->height = fmt->
fmt.
pix.height;
108 video->imagesize = imagesize;
111 fmt->
fmt.
pix.bytesperline = bpl;
112 fmt->
fmt.
pix.sizeimage = imagesize;
123 struct uvc_device *uvc = video_get_drvdata(vdev);
124 struct uvc_file_handle *
handle;
126 handle = kzalloc(
sizeof(*handle),
GFP_KERNEL);
133 handle->device = &uvc->video;
141 uvc_v4l2_release(
struct file *file)
144 struct uvc_device *uvc = video_get_drvdata(vdev);
145 struct uvc_file_handle *handle = to_uvc_file_handle(file->
private_data);
146 struct uvc_video *video = handle->device;
165 uvc_v4l2_do_ioctl(
struct file *file,
unsigned int cmd,
void *
arg)
168 struct uvc_device *uvc = video_get_drvdata(vdev);
169 struct uvc_file_handle *handle = to_uvc_file_handle(file->
private_data);
171 struct uvc_video *video = &uvc->video;
180 memset(cap, 0,
sizeof *cap);
185 cap->
version = DRIVER_VERSION_NUMBER;
195 if (fmt->
type != video->queue.type)
198 return uvc_v4l2_get_format(video, fmt);
205 if (fmt->
type != video->queue.type)
208 return uvc_v4l2_set_format(video, fmt);
216 if (rb->
type != video->queue.type ||
234 if (buf->
type != video->queue.type)
244 return uvc_video_pump(video);
254 if (*type != video->queue.type)
264 if (*type != video->queue.type)
284 uvc->event_setup_out =
286 uvc->event_length = uvc_event->
req.wLength;
306 ret = uvc_send_response(uvc, arg);
317 uvc_v4l2_ioctl(
struct file *file,
unsigned int cmd,
unsigned long arg)
326 struct uvc_device *uvc = video_get_drvdata(vdev);
335 struct uvc_device *uvc = video_get_drvdata(vdev);
336 struct uvc_file_handle *handle = to_uvc_file_handle(file->
private_data);
337 unsigned int mask = 0;
339 poll_wait(file, &handle->vfh.wait, wait);
350 .open = uvc_v4l2_open,
351 .release = uvc_v4l2_release,
352 .ioctl = uvc_v4l2_ioctl,
353 .mmap = uvc_v4l2_mmap,
354 .poll = uvc_v4l2_poll,