2008-07-01 01:04:50 +07:00
|
|
|
/*
|
|
|
|
* uvc_v4l2.c -- USB Video Class driver - V4L2 API
|
|
|
|
*
|
2010-09-20 16:10:10 +07:00
|
|
|
* Copyright (C) 2005-2010
|
|
|
|
* Laurent Pinchart (laurent.pinchart@ideasonboard.com)
|
2008-07-01 01:04:50 +07:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-12-19 06:45:39 +07:00
|
|
|
#include <linux/compat.h>
|
2008-07-01 01:04:50 +07:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/module.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2008-07-01 01:04:50 +07:00
|
|
|
#include <linux/usb.h>
|
|
|
|
#include <linux/videodev2.h>
|
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/wait.h>
|
2011-07-27 06:09:06 +07:00
|
|
|
#include <linux/atomic.h>
|
2008-07-01 01:04:50 +07:00
|
|
|
|
|
|
|
#include <media/v4l2-common.h>
|
2012-04-08 22:59:51 +07:00
|
|
|
#include <media/v4l2-ctrls.h>
|
|
|
|
#include <media/v4l2-event.h>
|
2008-07-20 18:12:02 +07:00
|
|
|
#include <media/v4l2-ioctl.h>
|
2008-07-01 01:04:50 +07:00
|
|
|
|
|
|
|
#include "uvcvideo.h"
|
|
|
|
|
2010-02-19 02:38:52 +07:00
|
|
|
/* ------------------------------------------------------------------------
|
|
|
|
* UVC ioctls
|
|
|
|
*/
|
2010-09-20 15:53:21 +07:00
|
|
|
static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,
|
2011-07-31 02:19:49 +07:00
|
|
|
struct uvc_xu_control_mapping *xmap)
|
2010-02-19 02:38:52 +07:00
|
|
|
{
|
|
|
|
struct uvc_control_mapping *map;
|
|
|
|
unsigned int size;
|
|
|
|
int ret;
|
|
|
|
|
2018-01-17 00:45:36 +07:00
|
|
|
map = kzalloc(sizeof(*map), GFP_KERNEL);
|
2010-02-19 02:38:52 +07:00
|
|
|
if (map == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
map->id = xmap->id;
|
2018-01-17 00:45:36 +07:00
|
|
|
memcpy(map->name, xmap->name, sizeof(map->name));
|
|
|
|
memcpy(map->entity, xmap->entity, sizeof(map->entity));
|
2010-02-19 02:38:52 +07:00
|
|
|
map->selector = xmap->selector;
|
|
|
|
map->size = xmap->size;
|
|
|
|
map->offset = xmap->offset;
|
|
|
|
map->v4l2_type = xmap->v4l2_type;
|
|
|
|
map->data_type = xmap->data_type;
|
|
|
|
|
|
|
|
switch (xmap->v4l2_type) {
|
|
|
|
case V4L2_CTRL_TYPE_INTEGER:
|
|
|
|
case V4L2_CTRL_TYPE_BOOLEAN:
|
|
|
|
case V4L2_CTRL_TYPE_BUTTON:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case V4L2_CTRL_TYPE_MENU:
|
2011-11-30 04:32:25 +07:00
|
|
|
/* Prevent excessive memory consumption, as well as integer
|
|
|
|
* overflows.
|
|
|
|
*/
|
|
|
|
if (xmap->menu_count == 0 ||
|
|
|
|
xmap->menu_count > UVC_MAX_CONTROL_MENU_ENTRIES) {
|
|
|
|
ret = -EINVAL;
|
2016-11-25 17:28:35 +07:00
|
|
|
goto free_map;
|
2011-11-30 04:32:25 +07:00
|
|
|
}
|
|
|
|
|
2010-02-19 02:38:52 +07:00
|
|
|
size = xmap->menu_count * sizeof(*map->menu_info);
|
2016-08-19 15:50:05 +07:00
|
|
|
map->menu_info = memdup_user(xmap->menu_info, size);
|
|
|
|
if (IS_ERR(map->menu_info)) {
|
|
|
|
ret = PTR_ERR(map->menu_info);
|
2016-11-25 17:28:35 +07:00
|
|
|
goto free_map;
|
2010-02-19 02:38:52 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
map->menu_count = xmap->menu_count;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-09-20 15:53:21 +07:00
|
|
|
uvc_trace(UVC_TRACE_CONTROL, "Unsupported V4L2 control type "
|
|
|
|
"%u.\n", xmap->v4l2_type);
|
2011-06-26 20:18:03 +07:00
|
|
|
ret = -ENOTTY;
|
2016-11-25 17:28:35 +07:00
|
|
|
goto free_map;
|
2010-02-19 02:38:52 +07:00
|
|
|
}
|
|
|
|
|
2010-09-20 15:53:21 +07:00
|
|
|
ret = uvc_ctrl_add_mapping(chain, map);
|
2010-02-19 02:38:52 +07:00
|
|
|
|
2010-09-20 15:53:21 +07:00
|
|
|
kfree(map->menu_info);
|
2016-11-25 17:28:35 +07:00
|
|
|
free_map:
|
2010-09-20 15:53:21 +07:00
|
|
|
kfree(map);
|
2010-02-19 02:38:52 +07:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-07-01 01:04:50 +07:00
|
|
|
/* ------------------------------------------------------------------------
|
|
|
|
* V4L2 interface
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find the frame interval closest to the requested frame interval for the
|
|
|
|
* given frame format and size. This should be done by the device as part of
|
|
|
|
* the Video Probe and Commit negotiation, but some hardware don't implement
|
|
|
|
* that feature.
|
|
|
|
*/
|
2018-01-17 00:45:36 +07:00
|
|
|
static u32 uvc_try_frame_interval(struct uvc_frame *frame, u32 interval)
|
2008-07-01 01:04:50 +07:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (frame->bFrameIntervalType) {
|
2018-01-17 00:45:36 +07:00
|
|
|
u32 best = -1, dist;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
|
|
|
for (i = 0; i < frame->bFrameIntervalType; ++i) {
|
|
|
|
dist = interval > frame->dwFrameInterval[i]
|
|
|
|
? interval - frame->dwFrameInterval[i]
|
|
|
|
: frame->dwFrameInterval[i] - interval;
|
|
|
|
|
|
|
|
if (dist > best)
|
|
|
|
break;
|
|
|
|
|
|
|
|
best = dist;
|
|
|
|
}
|
|
|
|
|
|
|
|
interval = frame->dwFrameInterval[i-1];
|
|
|
|
} else {
|
2018-01-17 00:45:36 +07:00
|
|
|
const u32 min = frame->dwFrameInterval[0];
|
|
|
|
const u32 max = frame->dwFrameInterval[1];
|
|
|
|
const u32 step = frame->dwFrameInterval[2];
|
2008-07-01 01:04:50 +07:00
|
|
|
|
|
|
|
interval = min + (interval - min + step/2) / step * step;
|
|
|
|
if (interval > max)
|
|
|
|
interval = max;
|
|
|
|
}
|
|
|
|
|
|
|
|
return interval;
|
|
|
|
}
|
|
|
|
|
2018-01-17 00:45:36 +07:00
|
|
|
static u32 uvc_v4l2_get_bytesperline(const struct uvc_format *format,
|
2016-01-08 03:43:48 +07:00
|
|
|
const struct uvc_frame *frame)
|
|
|
|
{
|
|
|
|
switch (format->fcc) {
|
|
|
|
case V4L2_PIX_FMT_NV12:
|
|
|
|
case V4L2_PIX_FMT_YVU420:
|
|
|
|
case V4L2_PIX_FMT_YUV420:
|
|
|
|
case V4L2_PIX_FMT_M420:
|
|
|
|
return frame->wWidth;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return format->bpp * frame->wWidth / 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-28 18:37:50 +07:00
|
|
|
static int uvc_v4l2_try_format(struct uvc_streaming *stream,
|
2008-07-01 01:04:50 +07:00
|
|
|
struct v4l2_format *fmt, struct uvc_streaming_control *probe,
|
|
|
|
struct uvc_format **uvc_format, struct uvc_frame **uvc_frame)
|
|
|
|
{
|
|
|
|
struct uvc_format *format = NULL;
|
|
|
|
struct uvc_frame *frame = NULL;
|
2018-01-17 00:45:36 +07:00
|
|
|
u16 rw, rh;
|
2008-07-01 01:04:50 +07:00
|
|
|
unsigned int d, maxd;
|
|
|
|
unsigned int i;
|
2018-01-17 00:45:36 +07:00
|
|
|
u32 interval;
|
2008-07-01 01:04:50 +07:00
|
|
|
int ret = 0;
|
2018-01-17 00:45:36 +07:00
|
|
|
u8 *fcc;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2009-06-28 18:37:50 +07:00
|
|
|
if (fmt->type != stream->type)
|
2008-07-01 01:04:50 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2018-01-17 00:45:36 +07:00
|
|
|
fcc = (u8 *)&fmt->fmt.pix.pixelformat;
|
2008-07-01 01:04:50 +07:00
|
|
|
uvc_trace(UVC_TRACE_FORMAT, "Trying format 0x%08x (%c%c%c%c): %ux%u.\n",
|
|
|
|
fmt->fmt.pix.pixelformat,
|
|
|
|
fcc[0], fcc[1], fcc[2], fcc[3],
|
|
|
|
fmt->fmt.pix.width, fmt->fmt.pix.height);
|
|
|
|
|
2012-08-29 04:38:58 +07:00
|
|
|
/* Check if the hardware supports the requested format, use the default
|
|
|
|
* format otherwise.
|
|
|
|
*/
|
2009-06-28 18:37:50 +07:00
|
|
|
for (i = 0; i < stream->nformats; ++i) {
|
|
|
|
format = &stream->format[i];
|
2008-07-01 01:04:50 +07:00
|
|
|
if (format->fcc == fmt->fmt.pix.pixelformat)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-08-29 04:38:58 +07:00
|
|
|
if (i == stream->nformats) {
|
|
|
|
format = stream->def_format;
|
|
|
|
fmt->fmt.pix.pixelformat = format->fcc;
|
2008-07-01 01:04:50 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Find the closest image size. The distance between image sizes is
|
|
|
|
* the size in pixels of the non-overlapping regions between the
|
|
|
|
* requested size and the frame-specified size.
|
|
|
|
*/
|
|
|
|
rw = fmt->fmt.pix.width;
|
|
|
|
rh = fmt->fmt.pix.height;
|
|
|
|
maxd = (unsigned int)-1;
|
|
|
|
|
|
|
|
for (i = 0; i < format->nframes; ++i) {
|
2018-01-17 00:45:36 +07:00
|
|
|
u16 w = format->frame[i].wWidth;
|
|
|
|
u16 h = format->frame[i].wHeight;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
|
|
|
d = min(w, rw) * min(h, rh);
|
|
|
|
d = w*h + rw*rh - 2*d;
|
|
|
|
if (d < maxd) {
|
|
|
|
maxd = d;
|
|
|
|
frame = &format->frame[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (maxd == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (frame == NULL) {
|
|
|
|
uvc_trace(UVC_TRACE_FORMAT, "Unsupported size %ux%u.\n",
|
|
|
|
fmt->fmt.pix.width, fmt->fmt.pix.height);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Use the default frame interval. */
|
|
|
|
interval = frame->dwDefaultFrameInterval;
|
|
|
|
uvc_trace(UVC_TRACE_FORMAT, "Using default frame interval %u.%u us "
|
|
|
|
"(%u.%u fps).\n", interval/10, interval%10, 10000000/interval,
|
|
|
|
(100000000/interval)%10);
|
|
|
|
|
|
|
|
/* Set the format index, frame index and frame interval. */
|
2018-01-17 00:45:36 +07:00
|
|
|
memset(probe, 0, sizeof(*probe));
|
2008-07-01 01:04:50 +07:00
|
|
|
probe->bmHint = 1; /* dwFrameInterval */
|
|
|
|
probe->bFormatIndex = format->index;
|
|
|
|
probe->bFrameIndex = frame->bFrameIndex;
|
|
|
|
probe->dwFrameInterval = uvc_try_frame_interval(frame, interval);
|
|
|
|
/* Some webcams stall the probe control set request when the
|
|
|
|
* dwMaxVideoFrameSize field is set to zero. The UVC specification
|
|
|
|
* clearly states that the field is read-only from the host, so this
|
|
|
|
* is a webcam bug. Set dwMaxVideoFrameSize to the value reported by
|
|
|
|
* the webcam to work around the problem.
|
|
|
|
*
|
|
|
|
* The workaround could probably be enabled for all webcams, so the
|
|
|
|
* quirk can be removed if needed. It's currently useful to detect
|
|
|
|
* webcam bugs and fix them before they hit the market (providing
|
|
|
|
* developers test their webcams with the Linux driver as well as with
|
|
|
|
* the Windows driver).
|
|
|
|
*/
|
2010-11-21 23:36:34 +07:00
|
|
|
mutex_lock(&stream->mutex);
|
2009-06-28 18:37:50 +07:00
|
|
|
if (stream->dev->quirks & UVC_QUIRK_PROBE_EXTRAFIELDS)
|
2008-07-01 01:04:50 +07:00
|
|
|
probe->dwMaxVideoFrameSize =
|
2009-06-28 18:37:50 +07:00
|
|
|
stream->ctrl.dwMaxVideoFrameSize;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2009-01-04 05:12:40 +07:00
|
|
|
/* Probe the device. */
|
2009-06-28 18:37:50 +07:00
|
|
|
ret = uvc_probe_video(stream, probe);
|
2010-11-21 23:36:34 +07:00
|
|
|
mutex_unlock(&stream->mutex);
|
2009-06-28 18:37:50 +07:00
|
|
|
if (ret < 0)
|
2008-07-01 01:04:50 +07:00
|
|
|
goto done;
|
|
|
|
|
|
|
|
fmt->fmt.pix.width = frame->wWidth;
|
|
|
|
fmt->fmt.pix.height = frame->wHeight;
|
|
|
|
fmt->fmt.pix.field = V4L2_FIELD_NONE;
|
2016-01-08 03:43:48 +07:00
|
|
|
fmt->fmt.pix.bytesperline = uvc_v4l2_get_bytesperline(format, frame);
|
2008-07-01 01:04:50 +07:00
|
|
|
fmt->fmt.pix.sizeimage = probe->dwMaxVideoFrameSize;
|
|
|
|
fmt->fmt.pix.colorspace = format->colorspace;
|
|
|
|
fmt->fmt.pix.priv = 0;
|
|
|
|
|
|
|
|
if (uvc_format != NULL)
|
|
|
|
*uvc_format = format;
|
|
|
|
if (uvc_frame != NULL)
|
|
|
|
*uvc_frame = frame;
|
|
|
|
|
|
|
|
done:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-06-28 18:37:50 +07:00
|
|
|
static int uvc_v4l2_get_format(struct uvc_streaming *stream,
|
2008-07-01 01:04:50 +07:00
|
|
|
struct v4l2_format *fmt)
|
|
|
|
{
|
2010-11-21 23:36:34 +07:00
|
|
|
struct uvc_format *format;
|
|
|
|
struct uvc_frame *frame;
|
|
|
|
int ret = 0;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2009-06-28 18:37:50 +07:00
|
|
|
if (fmt->type != stream->type)
|
2008-07-01 01:04:50 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2010-11-21 23:36:34 +07:00
|
|
|
mutex_lock(&stream->mutex);
|
|
|
|
format = stream->cur_format;
|
|
|
|
frame = stream->cur_frame;
|
|
|
|
|
|
|
|
if (format == NULL || frame == NULL) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto done;
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
|
|
|
fmt->fmt.pix.pixelformat = format->fcc;
|
|
|
|
fmt->fmt.pix.width = frame->wWidth;
|
|
|
|
fmt->fmt.pix.height = frame->wHeight;
|
|
|
|
fmt->fmt.pix.field = V4L2_FIELD_NONE;
|
2016-01-08 03:43:48 +07:00
|
|
|
fmt->fmt.pix.bytesperline = uvc_v4l2_get_bytesperline(format, frame);
|
2009-06-28 18:37:50 +07:00
|
|
|
fmt->fmt.pix.sizeimage = stream->ctrl.dwMaxVideoFrameSize;
|
2008-07-01 01:04:50 +07:00
|
|
|
fmt->fmt.pix.colorspace = format->colorspace;
|
|
|
|
fmt->fmt.pix.priv = 0;
|
|
|
|
|
2010-11-21 23:36:34 +07:00
|
|
|
done:
|
|
|
|
mutex_unlock(&stream->mutex);
|
|
|
|
return ret;
|
2008-07-01 01:04:50 +07:00
|
|
|
}
|
|
|
|
|
2009-06-28 18:37:50 +07:00
|
|
|
static int uvc_v4l2_set_format(struct uvc_streaming *stream,
|
2008-07-01 01:04:50 +07:00
|
|
|
struct v4l2_format *fmt)
|
|
|
|
{
|
|
|
|
struct uvc_streaming_control probe;
|
|
|
|
struct uvc_format *format;
|
|
|
|
struct uvc_frame *frame;
|
|
|
|
int ret;
|
|
|
|
|
2009-06-28 18:37:50 +07:00
|
|
|
if (fmt->type != stream->type)
|
2008-07-01 01:04:50 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2009-06-28 18:37:50 +07:00
|
|
|
ret = uvc_v4l2_try_format(stream, fmt, &probe, &format, &frame);
|
2008-07-01 01:04:50 +07:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2010-11-21 23:36:34 +07:00
|
|
|
mutex_lock(&stream->mutex);
|
|
|
|
|
|
|
|
if (uvc_queue_allocated(&stream->queue)) {
|
|
|
|
ret = -EBUSY;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2013-01-15 01:22:55 +07:00
|
|
|
stream->ctrl = probe;
|
2009-06-28 18:37:50 +07:00
|
|
|
stream->cur_format = format;
|
|
|
|
stream->cur_frame = frame;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-11-21 23:36:34 +07:00
|
|
|
done:
|
|
|
|
mutex_unlock(&stream->mutex);
|
|
|
|
return ret;
|
2008-07-01 01:04:50 +07:00
|
|
|
}
|
|
|
|
|
2009-06-28 18:37:50 +07:00
|
|
|
static int uvc_v4l2_get_streamparm(struct uvc_streaming *stream,
|
2008-07-01 01:04:50 +07:00
|
|
|
struct v4l2_streamparm *parm)
|
|
|
|
{
|
2018-01-17 00:35:17 +07:00
|
|
|
u32 numerator, denominator;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2009-06-28 18:37:50 +07:00
|
|
|
if (parm->type != stream->type)
|
2008-07-01 01:04:50 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2010-11-21 23:36:34 +07:00
|
|
|
mutex_lock(&stream->mutex);
|
2009-06-28 18:37:50 +07:00
|
|
|
numerator = stream->ctrl.dwFrameInterval;
|
2010-11-21 23:36:34 +07:00
|
|
|
mutex_unlock(&stream->mutex);
|
|
|
|
|
2008-07-01 01:04:50 +07:00
|
|
|
denominator = 10000000;
|
|
|
|
uvc_simplify_fraction(&numerator, &denominator, 8, 333);
|
|
|
|
|
2018-01-17 00:45:36 +07:00
|
|
|
memset(parm, 0, sizeof(*parm));
|
2009-06-28 18:37:50 +07:00
|
|
|
parm->type = stream->type;
|
2008-12-29 08:32:29 +07:00
|
|
|
|
2009-06-28 18:37:50 +07:00
|
|
|
if (stream->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
|
2008-12-29 08:32:29 +07:00
|
|
|
parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
|
|
|
|
parm->parm.capture.capturemode = 0;
|
|
|
|
parm->parm.capture.timeperframe.numerator = numerator;
|
|
|
|
parm->parm.capture.timeperframe.denominator = denominator;
|
|
|
|
parm->parm.capture.extendedmode = 0;
|
|
|
|
parm->parm.capture.readbuffers = 0;
|
|
|
|
} else {
|
|
|
|
parm->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
|
|
|
|
parm->parm.output.outputmode = 0;
|
|
|
|
parm->parm.output.timeperframe.numerator = numerator;
|
|
|
|
parm->parm.output.timeperframe.denominator = denominator;
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-06-28 18:37:50 +07:00
|
|
|
static int uvc_v4l2_set_streamparm(struct uvc_streaming *stream,
|
2008-07-01 01:04:50 +07:00
|
|
|
struct v4l2_streamparm *parm)
|
|
|
|
{
|
|
|
|
struct uvc_streaming_control probe;
|
2008-12-29 08:32:29 +07:00
|
|
|
struct v4l2_fract timeperframe;
|
2018-01-05 05:51:29 +07:00
|
|
|
struct uvc_format *format;
|
|
|
|
struct uvc_frame *frame;
|
2018-01-17 00:45:36 +07:00
|
|
|
u32 interval, maxd;
|
2018-01-05 05:51:29 +07:00
|
|
|
unsigned int i;
|
2008-07-01 01:04:50 +07:00
|
|
|
int ret;
|
|
|
|
|
2009-06-28 18:37:50 +07:00
|
|
|
if (parm->type != stream->type)
|
2008-07-01 01:04:50 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2008-12-29 08:32:29 +07:00
|
|
|
if (parm->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
|
|
|
timeperframe = parm->parm.capture.timeperframe;
|
|
|
|
else
|
|
|
|
timeperframe = parm->parm.output.timeperframe;
|
|
|
|
|
|
|
|
interval = uvc_fraction_to_interval(timeperframe.numerator,
|
|
|
|
timeperframe.denominator);
|
2008-07-01 01:04:50 +07:00
|
|
|
uvc_trace(UVC_TRACE_FORMAT, "Setting frame interval to %u/%u (%u).\n",
|
2008-12-29 08:32:29 +07:00
|
|
|
timeperframe.numerator, timeperframe.denominator, interval);
|
2010-11-21 23:36:34 +07:00
|
|
|
|
|
|
|
mutex_lock(&stream->mutex);
|
|
|
|
|
|
|
|
if (uvc_queue_streaming(&stream->queue)) {
|
|
|
|
mutex_unlock(&stream->mutex);
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
2018-01-05 05:51:29 +07:00
|
|
|
format = stream->cur_format;
|
|
|
|
frame = stream->cur_frame;
|
2013-01-15 01:22:55 +07:00
|
|
|
probe = stream->ctrl;
|
2018-01-05 05:51:29 +07:00
|
|
|
probe.dwFrameInterval = uvc_try_frame_interval(frame, interval);
|
2018-01-17 00:45:36 +07:00
|
|
|
maxd = abs((s32)probe.dwFrameInterval - interval);
|
2018-01-05 05:51:29 +07:00
|
|
|
|
|
|
|
/* Try frames with matching size to find the best frame interval. */
|
|
|
|
for (i = 0; i < format->nframes && maxd != 0; i++) {
|
2018-01-17 00:45:36 +07:00
|
|
|
u32 d, ival;
|
2018-01-05 05:51:29 +07:00
|
|
|
|
|
|
|
if (&format->frame[i] == stream->cur_frame)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (format->frame[i].wWidth != stream->cur_frame->wWidth ||
|
|
|
|
format->frame[i].wHeight != stream->cur_frame->wHeight)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ival = uvc_try_frame_interval(&format->frame[i], interval);
|
2018-01-17 00:45:36 +07:00
|
|
|
d = abs((s32)ival - interval);
|
2018-01-05 05:51:29 +07:00
|
|
|
if (d >= maxd)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
frame = &format->frame[i];
|
|
|
|
probe.bFrameIndex = frame->bFrameIndex;
|
|
|
|
probe.dwFrameInterval = ival;
|
|
|
|
maxd = d;
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
|
|
|
/* Probe the device with the new settings. */
|
2009-06-28 18:37:50 +07:00
|
|
|
ret = uvc_probe_video(stream, &probe);
|
2010-11-21 23:36:34 +07:00
|
|
|
if (ret < 0) {
|
|
|
|
mutex_unlock(&stream->mutex);
|
2008-07-01 01:04:50 +07:00
|
|
|
return ret;
|
2010-11-21 23:36:34 +07:00
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2013-01-15 01:22:55 +07:00
|
|
|
stream->ctrl = probe;
|
2018-01-05 05:51:29 +07:00
|
|
|
stream->cur_frame = frame;
|
2010-11-21 23:36:34 +07:00
|
|
|
mutex_unlock(&stream->mutex);
|
2008-07-01 01:04:50 +07:00
|
|
|
|
|
|
|
/* Return the actual frame period. */
|
2008-12-29 08:32:29 +07:00
|
|
|
timeperframe.numerator = probe.dwFrameInterval;
|
|
|
|
timeperframe.denominator = 10000000;
|
|
|
|
uvc_simplify_fraction(&timeperframe.numerator,
|
|
|
|
&timeperframe.denominator, 8, 333);
|
|
|
|
|
|
|
|
if (parm->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
|
|
|
parm->parm.capture.timeperframe = timeperframe;
|
|
|
|
else
|
|
|
|
parm->parm.output.timeperframe = timeperframe;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------
|
|
|
|
* Privilege management
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Privilege management is the multiple-open implementation basis. The current
|
|
|
|
* implementation is completely transparent for the end-user and doesn't
|
|
|
|
* require explicit use of the VIDIOC_G_PRIORITY and VIDIOC_S_PRIORITY ioctls.
|
|
|
|
* Those ioctls enable finer control on the device (by making possible for a
|
|
|
|
* user to request exclusive access to a device), but are not mature yet.
|
|
|
|
* Switching to the V4L2 priority mechanism might be considered in the future
|
|
|
|
* if this situation changes.
|
|
|
|
*
|
|
|
|
* Each open instance of a UVC device can either be in a privileged or
|
|
|
|
* unprivileged state. Only a single instance can be in a privileged state at
|
2009-01-04 05:12:40 +07:00
|
|
|
* a given time. Trying to perform an operation that requires privileges will
|
2008-07-01 01:04:50 +07:00
|
|
|
* automatically acquire the required privileges if possible, or return -EBUSY
|
2009-09-02 13:12:26 +07:00
|
|
|
* otherwise. Privileges are dismissed when closing the instance or when
|
|
|
|
* freeing the video buffers using VIDIOC_REQBUFS.
|
2008-07-01 01:04:50 +07:00
|
|
|
*
|
2009-01-04 05:12:40 +07:00
|
|
|
* Operations that require privileges are:
|
2008-07-01 01:04:50 +07:00
|
|
|
*
|
|
|
|
* - VIDIOC_S_INPUT
|
|
|
|
* - VIDIOC_S_PARM
|
|
|
|
* - VIDIOC_S_FMT
|
|
|
|
* - VIDIOC_REQBUFS
|
|
|
|
*/
|
|
|
|
static int uvc_acquire_privileges(struct uvc_fh *handle)
|
|
|
|
{
|
|
|
|
/* Always succeed if the handle is already privileged. */
|
|
|
|
if (handle->state == UVC_HANDLE_ACTIVE)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Check if the device already has a privileged handle. */
|
2009-06-28 18:37:50 +07:00
|
|
|
if (atomic_inc_return(&handle->stream->active) != 1) {
|
|
|
|
atomic_dec(&handle->stream->active);
|
2009-09-30 07:07:19 +07:00
|
|
|
return -EBUSY;
|
2008-07-01 01:04:50 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
handle->state = UVC_HANDLE_ACTIVE;
|
2009-09-30 07:07:19 +07:00
|
|
|
return 0;
|
2008-07-01 01:04:50 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void uvc_dismiss_privileges(struct uvc_fh *handle)
|
|
|
|
{
|
|
|
|
if (handle->state == UVC_HANDLE_ACTIVE)
|
2009-06-28 18:37:50 +07:00
|
|
|
atomic_dec(&handle->stream->active);
|
2008-07-01 01:04:50 +07:00
|
|
|
|
|
|
|
handle->state = UVC_HANDLE_PASSIVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int uvc_has_privileges(struct uvc_fh *handle)
|
|
|
|
{
|
|
|
|
return handle->state == UVC_HANDLE_ACTIVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------
|
|
|
|
* V4L2 file operations
|
|
|
|
*/
|
|
|
|
|
2008-12-30 16:58:20 +07:00
|
|
|
static int uvc_v4l2_open(struct file *file)
|
2008-07-01 01:04:50 +07:00
|
|
|
{
|
2009-06-28 18:37:50 +07:00
|
|
|
struct uvc_streaming *stream;
|
2008-07-01 01:04:50 +07:00
|
|
|
struct uvc_fh *handle;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_open\n");
|
2009-06-28 18:37:50 +07:00
|
|
|
stream = video_drvdata(file);
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2009-06-28 18:37:50 +07:00
|
|
|
ret = usb_autopm_get_interface(stream->dev->intf);
|
2008-07-01 01:04:50 +07:00
|
|
|
if (ret < 0)
|
2009-09-30 07:07:19 +07:00
|
|
|
return ret;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
|
|
|
/* Create the device handle. */
|
2018-01-17 00:45:36 +07:00
|
|
|
handle = kzalloc(sizeof(*handle), GFP_KERNEL);
|
2008-07-01 01:04:50 +07:00
|
|
|
if (handle == NULL) {
|
2009-06-28 18:37:50 +07:00
|
|
|
usb_autopm_put_interface(stream->dev->intf);
|
2009-09-30 07:07:19 +07:00
|
|
|
return -ENOMEM;
|
2008-07-01 01:04:50 +07:00
|
|
|
}
|
|
|
|
|
2013-04-26 08:28:51 +07:00
|
|
|
mutex_lock(&stream->dev->lock);
|
|
|
|
if (stream->dev->users == 0) {
|
|
|
|
ret = uvc_status_start(stream->dev, GFP_KERNEL);
|
2009-06-28 18:37:50 +07:00
|
|
|
if (ret < 0) {
|
2013-04-26 08:28:51 +07:00
|
|
|
mutex_unlock(&stream->dev->lock);
|
2013-01-10 17:04:55 +07:00
|
|
|
usb_autopm_put_interface(stream->dev->intf);
|
2009-05-19 20:08:03 +07:00
|
|
|
kfree(handle);
|
2009-09-30 07:07:19 +07:00
|
|
|
return ret;
|
2009-05-19 20:08:03 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-26 08:28:51 +07:00
|
|
|
stream->dev->users++;
|
|
|
|
mutex_unlock(&stream->dev->lock);
|
|
|
|
|
2015-03-09 23:34:11 +07:00
|
|
|
v4l2_fh_init(&handle->vfh, &stream->vdev);
|
2012-04-08 22:59:51 +07:00
|
|
|
v4l2_fh_add(&handle->vfh);
|
2009-07-02 06:24:47 +07:00
|
|
|
handle->chain = stream->chain;
|
2009-06-28 18:37:50 +07:00
|
|
|
handle->stream = stream;
|
2008-07-01 01:04:50 +07:00
|
|
|
handle->state = UVC_HANDLE_PASSIVE;
|
|
|
|
file->private_data = handle;
|
|
|
|
|
2009-09-30 07:07:19 +07:00
|
|
|
return 0;
|
2008-07-01 01:04:50 +07:00
|
|
|
}
|
|
|
|
|
2008-12-30 16:58:20 +07:00
|
|
|
static int uvc_v4l2_release(struct file *file)
|
2008-07-01 01:04:50 +07:00
|
|
|
{
|
2010-07-13 03:50:03 +07:00
|
|
|
struct uvc_fh *handle = file->private_data;
|
2009-06-28 18:37:50 +07:00
|
|
|
struct uvc_streaming *stream = handle->stream;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
|
|
|
uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_release\n");
|
|
|
|
|
|
|
|
/* Only free resources if this is a privileged handle. */
|
2014-10-22 02:07:15 +07:00
|
|
|
if (uvc_has_privileges(handle))
|
|
|
|
uvc_queue_release(&stream->queue);
|
2008-07-01 01:04:50 +07:00
|
|
|
|
|
|
|
/* Release the file handle. */
|
|
|
|
uvc_dismiss_privileges(handle);
|
2012-04-08 22:59:51 +07:00
|
|
|
v4l2_fh_del(&handle->vfh);
|
|
|
|
v4l2_fh_exit(&handle->vfh);
|
2008-07-01 01:04:50 +07:00
|
|
|
kfree(handle);
|
|
|
|
file->private_data = NULL;
|
|
|
|
|
2013-04-26 08:28:51 +07:00
|
|
|
mutex_lock(&stream->dev->lock);
|
|
|
|
if (--stream->dev->users == 0)
|
2009-06-28 18:37:50 +07:00
|
|
|
uvc_status_stop(stream->dev);
|
2013-04-26 08:28:51 +07:00
|
|
|
mutex_unlock(&stream->dev->lock);
|
2009-05-19 20:08:03 +07:00
|
|
|
|
2009-06-28 18:37:50 +07:00
|
|
|
usb_autopm_put_interface(stream->dev->intf);
|
2008-07-01 01:04:50 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_querycap(struct file *file, void *fh,
|
|
|
|
struct v4l2_capability *cap)
|
2008-07-01 01:04:50 +07:00
|
|
|
{
|
|
|
|
struct video_device *vdev = video_devdata(file);
|
2010-07-13 03:50:03 +07:00
|
|
|
struct uvc_fh *handle = file->private_data;
|
2009-07-02 06:24:47 +07:00
|
|
|
struct uvc_video_chain *chain = handle->chain;
|
2009-06-28 18:37:50 +07:00
|
|
|
struct uvc_streaming *stream = handle->stream;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
strlcpy(cap->driver, "uvcvideo", sizeof(cap->driver));
|
|
|
|
strlcpy(cap->card, vdev->name, sizeof(cap->card));
|
|
|
|
usb_make_path(stream->dev->udev, cap->bus_info, sizeof(cap->bus_info));
|
|
|
|
cap->capabilities = V4L2_CAP_DEVICE_CAPS | V4L2_CAP_STREAMING
|
|
|
|
| chain->caps;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2012-08-29 06:29:56 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_enum_fmt(struct uvc_streaming *stream,
|
|
|
|
struct v4l2_fmtdesc *fmt)
|
|
|
|
{
|
|
|
|
struct uvc_format *format;
|
|
|
|
enum v4l2_buf_type type = fmt->type;
|
2018-01-17 00:45:36 +07:00
|
|
|
u32 index = fmt->index;
|
2012-08-29 06:29:56 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
if (fmt->type != stream->type || fmt->index >= stream->nformats)
|
|
|
|
return -EINVAL;
|
2012-08-29 06:29:56 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
memset(fmt, 0, sizeof(*fmt));
|
|
|
|
fmt->index = index;
|
|
|
|
fmt->type = type;
|
|
|
|
|
|
|
|
format = &stream->format[fmt->index];
|
|
|
|
fmt->flags = 0;
|
|
|
|
if (format->flags & UVC_FMT_FLAG_COMPRESSED)
|
|
|
|
fmt->flags |= V4L2_FMT_FLAG_COMPRESSED;
|
|
|
|
strlcpy(fmt->description, format->name, sizeof(fmt->description));
|
|
|
|
fmt->description[sizeof(fmt->description) - 1] = 0;
|
|
|
|
fmt->pixelformat = format->fcc;
|
|
|
|
return 0;
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_enum_fmt_vid_cap(struct file *file, void *fh,
|
|
|
|
struct v4l2_fmtdesc *fmt)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
return uvc_ioctl_enum_fmt(stream, fmt);
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_enum_fmt_vid_out(struct file *file, void *fh,
|
|
|
|
struct v4l2_fmtdesc *fmt)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
2009-06-12 23:51:03 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
return uvc_ioctl_enum_fmt(stream, fmt);
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_g_fmt_vid_cap(struct file *file, void *fh,
|
|
|
|
struct v4l2_format *fmt)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
return uvc_v4l2_get_format(stream, fmt);
|
|
|
|
}
|
2012-08-29 06:29:56 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_g_fmt_vid_out(struct file *file, void *fh,
|
|
|
|
struct v4l2_format *fmt)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
return uvc_v4l2_get_format(stream, fmt);
|
|
|
|
}
|
2009-06-12 23:51:03 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_s_fmt_vid_cap(struct file *file, void *fh,
|
|
|
|
struct v4l2_format *fmt)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
|
|
|
int ret;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
ret = uvc_acquire_privileges(handle);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
return uvc_v4l2_set_format(stream, fmt);
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_s_fmt_vid_out(struct file *file, void *fh,
|
|
|
|
struct v4l2_format *fmt)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
|
|
|
int ret;
|
2009-06-12 23:51:03 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
ret = uvc_acquire_privileges(handle);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
return uvc_v4l2_set_format(stream, fmt);
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_try_fmt_vid_cap(struct file *file, void *fh,
|
|
|
|
struct v4l2_format *fmt)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
|
|
|
struct uvc_streaming_control probe;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
return uvc_v4l2_try_format(stream, fmt, &probe, NULL, NULL);
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_try_fmt_vid_out(struct file *file, void *fh,
|
|
|
|
struct v4l2_format *fmt)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
|
|
|
struct uvc_streaming_control probe;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
return uvc_v4l2_try_format(stream, fmt, &probe, NULL, NULL);
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_reqbufs(struct file *file, void *fh,
|
|
|
|
struct v4l2_requestbuffers *rb)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
|
|
|
int ret;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
ret = uvc_acquire_privileges(handle);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
mutex_lock(&stream->mutex);
|
2014-10-22 02:02:00 +07:00
|
|
|
ret = uvc_request_buffers(&stream->queue, rb);
|
2010-09-30 20:17:54 +07:00
|
|
|
mutex_unlock(&stream->mutex);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
if (ret == 0)
|
|
|
|
uvc_dismiss_privileges(handle);
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_querybuf(struct file *file, void *fh,
|
|
|
|
struct v4l2_buffer *buf)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
if (!uvc_has_privileges(handle))
|
|
|
|
return -EBUSY;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
return uvc_query_buffer(&stream->queue, buf);
|
|
|
|
}
|
2012-08-29 06:29:56 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
if (!uvc_has_privileges(handle))
|
|
|
|
return -EBUSY;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
return uvc_queue_buffer(&stream->queue, buf);
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2015-04-14 14:19:51 +07:00
|
|
|
static int uvc_ioctl_expbuf(struct file *file, void *fh,
|
|
|
|
struct v4l2_exportbuffer *exp)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
|
|
|
|
|
|
|
if (!uvc_has_privileges(handle))
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
return uvc_export_buffer(&stream->queue, exp);
|
|
|
|
}
|
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
if (!uvc_has_privileges(handle))
|
|
|
|
return -EBUSY;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
return uvc_dequeue_buffer(&stream->queue, buf,
|
|
|
|
file->f_flags & O_NONBLOCK);
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_create_bufs(struct file *file, void *fh,
|
|
|
|
struct v4l2_create_buffers *cb)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
|
|
|
int ret;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
ret = uvc_acquire_privileges(handle);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
return uvc_create_buffers(&stream->queue, cb);
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_streamon(struct file *file, void *fh,
|
|
|
|
enum v4l2_buf_type type)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
|
|
|
int ret;
|
2012-08-29 06:29:56 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
if (!uvc_has_privileges(handle))
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
mutex_lock(&stream->mutex);
|
2014-10-22 02:19:04 +07:00
|
|
|
ret = uvc_queue_streamon(&stream->queue, type);
|
2010-09-30 20:17:54 +07:00
|
|
|
mutex_unlock(&stream->mutex);
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
return ret;
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_streamoff(struct file *file, void *fh,
|
|
|
|
enum v4l2_buf_type type)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
if (!uvc_has_privileges(handle))
|
|
|
|
return -EBUSY;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
mutex_lock(&stream->mutex);
|
2014-10-22 02:19:04 +07:00
|
|
|
uvc_queue_streamoff(&stream->queue, type);
|
2010-09-30 20:17:54 +07:00
|
|
|
mutex_unlock(&stream->mutex);
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2014-10-13 20:11:35 +07:00
|
|
|
return 0;
|
2010-09-30 20:17:54 +07:00
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_enum_input(struct file *file, void *fh,
|
|
|
|
struct v4l2_input *input)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_video_chain *chain = handle->chain;
|
|
|
|
const struct uvc_entity *selector = chain->selector;
|
|
|
|
struct uvc_entity *iterm = NULL;
|
|
|
|
u32 index = input->index;
|
|
|
|
int pin = 0;
|
|
|
|
|
|
|
|
if (selector == NULL ||
|
|
|
|
(chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) {
|
|
|
|
if (index != 0)
|
2008-07-01 01:04:50 +07:00
|
|
|
return -EINVAL;
|
2010-09-30 20:17:54 +07:00
|
|
|
list_for_each_entry(iterm, &chain->entities, chain) {
|
|
|
|
if (UVC_ENTITY_IS_ITERM(iterm))
|
2008-07-01 01:04:50 +07:00
|
|
|
break;
|
|
|
|
}
|
2010-09-30 20:17:54 +07:00
|
|
|
pin = iterm->id;
|
|
|
|
} else if (index < selector->bNrInPins) {
|
|
|
|
pin = selector->baSourceID[index];
|
|
|
|
list_for_each_entry(iterm, &chain->entities, chain) {
|
|
|
|
if (!UVC_ENTITY_IS_ITERM(iterm))
|
|
|
|
continue;
|
|
|
|
if (iterm->id == pin)
|
|
|
|
break;
|
2008-07-01 01:04:50 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
if (iterm == NULL || iterm->id != pin)
|
|
|
|
return -EINVAL;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
memset(input, 0, sizeof(*input));
|
|
|
|
input->index = index;
|
|
|
|
strlcpy(input->name, iterm->name, sizeof(input->name));
|
|
|
|
if (UVC_ENTITY_TYPE(iterm) == UVC_ITT_CAMERA)
|
|
|
|
input->type = V4L2_INPUT_TYPE_CAMERA;
|
2012-08-29 06:29:56 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_g_input(struct file *file, void *fh, unsigned int *input)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_video_chain *chain = handle->chain;
|
|
|
|
int ret;
|
|
|
|
u8 i;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
if (chain->selector == NULL ||
|
|
|
|
(chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) {
|
|
|
|
*input = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR, chain->selector->id,
|
|
|
|
chain->dev->intfnum, UVC_SU_INPUT_SELECT_CONTROL,
|
|
|
|
&i, 1);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
*input = i - 1;
|
|
|
|
return 0;
|
|
|
|
}
|
2010-11-21 23:36:34 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_s_input(struct file *file, void *fh, unsigned int input)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_video_chain *chain = handle->chain;
|
|
|
|
int ret;
|
|
|
|
u32 i;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
ret = uvc_acquire_privileges(handle);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
if (chain->selector == NULL ||
|
|
|
|
(chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) {
|
|
|
|
if (input)
|
|
|
|
return -EINVAL;
|
|
|
|
return 0;
|
2008-07-01 01:04:50 +07:00
|
|
|
}
|
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
if (input >= chain->selector->bNrInPins)
|
|
|
|
return -EINVAL;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
i = input + 1;
|
|
|
|
return uvc_query_ctrl(chain->dev, UVC_SET_CUR, chain->selector->id,
|
|
|
|
chain->dev->intfnum, UVC_SU_INPUT_SELECT_CONTROL,
|
|
|
|
&i, 1);
|
|
|
|
}
|
2012-08-29 06:29:56 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_queryctrl(struct file *file, void *fh,
|
|
|
|
struct v4l2_queryctrl *qc)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_video_chain *chain = handle->chain;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
return uvc_query_v4l2_ctrl(chain, qc);
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2015-03-15 00:04:00 +07:00
|
|
|
static int uvc_ioctl_query_ext_ctrl(struct file *file, void *fh,
|
|
|
|
struct v4l2_query_ext_ctrl *qec)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_video_chain *chain = handle->chain;
|
|
|
|
struct v4l2_queryctrl qc = { qec->id };
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = uvc_query_v4l2_ctrl(chain, &qc);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
qec->id = qc.id;
|
|
|
|
qec->type = qc.type;
|
|
|
|
strlcpy(qec->name, qc.name, sizeof(qec->name));
|
|
|
|
qec->minimum = qc.minimum;
|
|
|
|
qec->maximum = qc.maximum;
|
|
|
|
qec->step = qc.step;
|
|
|
|
qec->default_value = qc.default_value;
|
|
|
|
qec->flags = qc.flags;
|
|
|
|
qec->elem_size = 4;
|
|
|
|
qec->elems = 1;
|
|
|
|
qec->nr_of_dims = 0;
|
|
|
|
memset(qec->dims, 0, sizeof(qec->dims));
|
|
|
|
memset(qec->reserved, 0, sizeof(qec->reserved));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_g_ctrl(struct file *file, void *fh,
|
|
|
|
struct v4l2_control *ctrl)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_video_chain *chain = handle->chain;
|
|
|
|
struct v4l2_ext_control xctrl;
|
|
|
|
int ret;
|
2009-09-02 13:12:26 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
memset(&xctrl, 0, sizeof(xctrl));
|
|
|
|
xctrl.id = ctrl->id;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
ret = uvc_ctrl_begin(chain);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
ret = uvc_ctrl_get(chain, &xctrl);
|
|
|
|
uvc_ctrl_rollback(handle);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
ctrl->value = xctrl.value;
|
|
|
|
return 0;
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_s_ctrl(struct file *file, void *fh,
|
|
|
|
struct v4l2_control *ctrl)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_video_chain *chain = handle->chain;
|
|
|
|
struct v4l2_ext_control xctrl;
|
|
|
|
int ret;
|
2014-01-29 23:13:52 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
memset(&xctrl, 0, sizeof(xctrl));
|
|
|
|
xctrl.id = ctrl->id;
|
|
|
|
xctrl.value = ctrl->value;
|
2014-01-29 23:13:52 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
ret = uvc_ctrl_begin(chain);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = uvc_ctrl_set(chain, &xctrl);
|
|
|
|
if (ret < 0) {
|
|
|
|
uvc_ctrl_rollback(handle);
|
|
|
|
return ret;
|
2014-01-29 23:13:52 +07:00
|
|
|
}
|
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
ret = uvc_ctrl_commit(handle, &xctrl, 1);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
ctrl->value = xctrl.value;
|
|
|
|
return 0;
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh,
|
|
|
|
struct v4l2_ext_controls *ctrls)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_video_chain *chain = handle->chain;
|
|
|
|
struct v4l2_ext_control *ctrl = ctrls->controls;
|
|
|
|
unsigned int i;
|
|
|
|
int ret;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2015-10-29 17:10:30 +07:00
|
|
|
if (ctrls->which == V4L2_CTRL_WHICH_DEF_VAL) {
|
|
|
|
for (i = 0; i < ctrls->count; ++ctrl, ++i) {
|
|
|
|
struct v4l2_queryctrl qc = { .id = ctrl->id };
|
|
|
|
|
|
|
|
ret = uvc_query_v4l2_ctrl(chain, &qc);
|
|
|
|
if (ret < 0) {
|
|
|
|
ctrls->error_idx = i;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctrl->value = qc.default_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
ret = uvc_ctrl_begin(chain);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
for (i = 0; i < ctrls->count; ++ctrl, ++i) {
|
|
|
|
ret = uvc_ctrl_get(chain, ctrl);
|
|
|
|
if (ret < 0) {
|
|
|
|
uvc_ctrl_rollback(handle);
|
|
|
|
ctrls->error_idx = i;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
ctrls->error_idx = 0;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
return uvc_ctrl_rollback(handle);
|
|
|
|
}
|
2012-08-29 06:29:56 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_s_try_ext_ctrls(struct uvc_fh *handle,
|
|
|
|
struct v4l2_ext_controls *ctrls,
|
|
|
|
bool commit)
|
|
|
|
{
|
|
|
|
struct v4l2_ext_control *ctrl = ctrls->controls;
|
|
|
|
struct uvc_video_chain *chain = handle->chain;
|
|
|
|
unsigned int i;
|
|
|
|
int ret;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2015-10-29 17:10:30 +07:00
|
|
|
/* Default value cannot be changed */
|
|
|
|
if (ctrls->which == V4L2_CTRL_WHICH_DEF_VAL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
ret = uvc_ctrl_begin(chain);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
for (i = 0; i < ctrls->count; ++ctrl, ++i) {
|
|
|
|
ret = uvc_ctrl_set(chain, ctrl);
|
|
|
|
if (ret < 0) {
|
|
|
|
uvc_ctrl_rollback(handle);
|
|
|
|
ctrls->error_idx = commit ? ctrls->count : i;
|
2008-07-01 01:04:50 +07:00
|
|
|
return ret;
|
2010-09-30 20:17:54 +07:00
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
}
|
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
ctrls->error_idx = 0;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
if (commit)
|
|
|
|
return uvc_ctrl_commit(handle, ctrls->controls, ctrls->count);
|
|
|
|
else
|
|
|
|
return uvc_ctrl_rollback(handle);
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_s_ext_ctrls(struct file *file, void *fh,
|
|
|
|
struct v4l2_ext_controls *ctrls)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
2012-08-29 06:29:56 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
return uvc_ioctl_s_try_ext_ctrls(handle, ctrls, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int uvc_ioctl_try_ext_ctrls(struct file *file, void *fh,
|
|
|
|
struct v4l2_ext_controls *ctrls)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
|
|
|
|
return uvc_ioctl_s_try_ext_ctrls(handle, ctrls, false);
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_querymenu(struct file *file, void *fh,
|
|
|
|
struct v4l2_querymenu *qm)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_video_chain *chain = handle->chain;
|
|
|
|
|
|
|
|
return uvc_query_v4l2_menu(chain, qm);
|
|
|
|
}
|
|
|
|
|
2015-04-03 16:53:42 +07:00
|
|
|
static int uvc_ioctl_g_selection(struct file *file, void *fh,
|
|
|
|
struct v4l2_selection *sel)
|
2010-09-30 20:17:54 +07:00
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
|
|
|
|
2015-04-03 16:53:42 +07:00
|
|
|
if (sel->type != stream->type)
|
2010-09-30 20:17:54 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2015-04-03 16:53:42 +07:00
|
|
|
switch (sel->target) {
|
|
|
|
case V4L2_SEL_TGT_CROP_DEFAULT:
|
|
|
|
case V4L2_SEL_TGT_CROP_BOUNDS:
|
|
|
|
if (stream->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
|
|
|
return -EINVAL;
|
|
|
|
break;
|
|
|
|
case V4L2_SEL_TGT_COMPOSE_DEFAULT:
|
|
|
|
case V4L2_SEL_TGT_COMPOSE_BOUNDS:
|
|
|
|
if (stream->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
|
|
|
|
return -EINVAL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
sel->r.left = 0;
|
|
|
|
sel->r.top = 0;
|
2010-09-30 20:17:54 +07:00
|
|
|
mutex_lock(&stream->mutex);
|
2015-04-03 16:53:42 +07:00
|
|
|
sel->r.width = stream->cur_frame->wWidth;
|
|
|
|
sel->r.height = stream->cur_frame->wHeight;
|
2010-09-30 20:17:54 +07:00
|
|
|
mutex_unlock(&stream->mutex);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int uvc_ioctl_g_parm(struct file *file, void *fh,
|
|
|
|
struct v4l2_streamparm *parm)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
|
|
|
|
|
|
|
return uvc_v4l2_get_streamparm(stream, parm);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int uvc_ioctl_s_parm(struct file *file, void *fh,
|
|
|
|
struct v4l2_streamparm *parm)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = uvc_acquire_privileges(handle);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return uvc_v4l2_set_streamparm(stream, parm);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int uvc_ioctl_enum_framesizes(struct file *file, void *fh,
|
|
|
|
struct v4l2_frmsizeenum *fsize)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
|
|
|
struct uvc_format *format = NULL;
|
2018-03-23 19:23:23 +07:00
|
|
|
struct uvc_frame *frame = NULL;
|
2018-01-05 05:51:29 +07:00
|
|
|
unsigned int index;
|
|
|
|
unsigned int i;
|
2010-09-30 20:17:54 +07:00
|
|
|
|
|
|
|
/* Look for the given pixel format */
|
|
|
|
for (i = 0; i < stream->nformats; i++) {
|
|
|
|
if (stream->format[i].fcc == fsize->pixel_format) {
|
|
|
|
format = &stream->format[i];
|
|
|
|
break;
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
}
|
2010-09-30 20:17:54 +07:00
|
|
|
if (format == NULL)
|
|
|
|
return -EINVAL;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2018-01-05 05:51:29 +07:00
|
|
|
/* Skip duplicate frame sizes */
|
|
|
|
for (i = 0, index = 0; i < format->nframes; i++) {
|
2018-03-23 19:23:23 +07:00
|
|
|
if (frame && frame->wWidth == format->frame[i].wWidth &&
|
2018-01-05 05:51:29 +07:00
|
|
|
frame->wHeight == format->frame[i].wHeight)
|
|
|
|
continue;
|
|
|
|
frame = &format->frame[i];
|
|
|
|
if (index == fsize->index)
|
|
|
|
break;
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == format->nframes)
|
2010-09-30 20:17:54 +07:00
|
|
|
return -EINVAL;
|
2012-04-08 22:59:51 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
|
|
|
|
fsize->discrete.width = frame->wWidth;
|
|
|
|
fsize->discrete.height = frame->wHeight;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int uvc_ioctl_enum_frameintervals(struct file *file, void *fh,
|
|
|
|
struct v4l2_frmivalenum *fival)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
|
|
|
struct uvc_format *format = NULL;
|
|
|
|
struct uvc_frame *frame = NULL;
|
2018-01-05 05:51:29 +07:00
|
|
|
unsigned int nintervals;
|
|
|
|
unsigned int index;
|
|
|
|
unsigned int i;
|
2010-09-30 20:17:54 +07:00
|
|
|
|
|
|
|
/* Look for the given pixel format and frame size */
|
|
|
|
for (i = 0; i < stream->nformats; i++) {
|
|
|
|
if (stream->format[i].fcc == fival->pixel_format) {
|
|
|
|
format = &stream->format[i];
|
|
|
|
break;
|
2012-04-08 22:59:51 +07:00
|
|
|
}
|
|
|
|
}
|
2010-09-30 20:17:54 +07:00
|
|
|
if (format == NULL)
|
|
|
|
return -EINVAL;
|
2012-04-08 22:59:51 +07:00
|
|
|
|
2018-01-05 05:51:29 +07:00
|
|
|
index = fival->index;
|
2010-09-30 20:17:54 +07:00
|
|
|
for (i = 0; i < format->nframes; i++) {
|
|
|
|
if (format->frame[i].wWidth == fival->width &&
|
|
|
|
format->frame[i].wHeight == fival->height) {
|
|
|
|
frame = &format->frame[i];
|
2018-01-05 05:51:29 +07:00
|
|
|
nintervals = frame->bFrameIntervalType ?: 1;
|
|
|
|
if (index < nintervals)
|
|
|
|
break;
|
|
|
|
index -= nintervals;
|
2010-09-30 20:17:54 +07:00
|
|
|
}
|
|
|
|
}
|
2018-01-05 05:51:29 +07:00
|
|
|
if (i == format->nframes)
|
2010-09-30 20:17:54 +07:00
|
|
|
return -EINVAL;
|
2012-04-08 22:59:51 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
if (frame->bFrameIntervalType) {
|
|
|
|
fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
|
|
|
|
fival->discrete.numerator =
|
2018-01-05 05:51:29 +07:00
|
|
|
frame->dwFrameInterval[index];
|
2010-09-30 20:17:54 +07:00
|
|
|
fival->discrete.denominator = 10000000;
|
|
|
|
uvc_simplify_fraction(&fival->discrete.numerator,
|
|
|
|
&fival->discrete.denominator, 8, 333);
|
|
|
|
} else {
|
|
|
|
fival->type = V4L2_FRMIVAL_TYPE_STEPWISE;
|
|
|
|
fival->stepwise.min.numerator = frame->dwFrameInterval[0];
|
|
|
|
fival->stepwise.min.denominator = 10000000;
|
|
|
|
fival->stepwise.max.numerator = frame->dwFrameInterval[1];
|
|
|
|
fival->stepwise.max.denominator = 10000000;
|
|
|
|
fival->stepwise.step.numerator = frame->dwFrameInterval[2];
|
|
|
|
fival->stepwise.step.denominator = 10000000;
|
|
|
|
uvc_simplify_fraction(&fival->stepwise.min.numerator,
|
|
|
|
&fival->stepwise.min.denominator, 8, 333);
|
|
|
|
uvc_simplify_fraction(&fival->stepwise.max.numerator,
|
|
|
|
&fival->stepwise.max.denominator, 8, 333);
|
|
|
|
uvc_simplify_fraction(&fival->stepwise.step.numerator,
|
|
|
|
&fival->stepwise.step.denominator, 8, 333);
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static int uvc_ioctl_subscribe_event(struct v4l2_fh *fh,
|
|
|
|
const struct v4l2_event_subscription *sub)
|
|
|
|
{
|
|
|
|
switch (sub->type) {
|
|
|
|
case V4L2_EVENT_CTRL:
|
|
|
|
return v4l2_event_subscribe(fh, sub, 0, &uvc_ctrl_sub_ev_ops);
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
static long uvc_ioctl_default(struct file *file, void *fh, bool valid_prio,
|
|
|
|
unsigned int cmd, void *arg)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = fh;
|
|
|
|
struct uvc_video_chain *chain = handle->chain;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
switch (cmd) {
|
|
|
|
/* Dynamic controls. */
|
2008-07-01 01:04:50 +07:00
|
|
|
case UVCIOC_CTRL_MAP:
|
2011-07-31 02:19:49 +07:00
|
|
|
return uvc_ioctl_ctrl_map(chain, arg);
|
2010-10-03 05:10:16 +07:00
|
|
|
|
|
|
|
case UVCIOC_CTRL_QUERY:
|
|
|
|
return uvc_xu_ctrl_query(chain, arg);
|
2008-07-01 01:04:50 +07:00
|
|
|
|
|
|
|
default:
|
2011-12-19 06:22:50 +07:00
|
|
|
return -ENOTTY;
|
2008-07-01 01:04:50 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-19 06:45:39 +07:00
|
|
|
#ifdef CONFIG_COMPAT
|
|
|
|
struct uvc_xu_control_mapping32 {
|
2018-01-17 00:45:36 +07:00
|
|
|
u32 id;
|
|
|
|
u8 name[32];
|
|
|
|
u8 entity[16];
|
|
|
|
u8 selector;
|
2011-12-19 06:45:39 +07:00
|
|
|
|
2018-01-17 00:45:36 +07:00
|
|
|
u8 size;
|
|
|
|
u8 offset;
|
|
|
|
u32 v4l2_type;
|
|
|
|
u32 data_type;
|
2011-12-19 06:45:39 +07:00
|
|
|
|
|
|
|
compat_caddr_t menu_info;
|
2018-01-17 00:45:36 +07:00
|
|
|
u32 menu_count;
|
2011-12-19 06:45:39 +07:00
|
|
|
|
2018-01-17 00:45:36 +07:00
|
|
|
u32 reserved[4];
|
2011-12-19 06:45:39 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static int uvc_v4l2_get_xu_mapping(struct uvc_xu_control_mapping *kp,
|
|
|
|
const struct uvc_xu_control_mapping32 __user *up)
|
|
|
|
{
|
2017-12-30 04:25:30 +07:00
|
|
|
struct uvc_xu_control_mapping32 *p = (void *)kp;
|
|
|
|
compat_caddr_t info;
|
|
|
|
u32 count;
|
2011-12-19 06:45:39 +07:00
|
|
|
|
2017-12-30 04:25:30 +07:00
|
|
|
if (copy_from_user(p, up, sizeof(*p)))
|
2011-12-19 06:45:39 +07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2017-12-30 04:25:30 +07:00
|
|
|
count = p->menu_count;
|
|
|
|
info = p->menu_info;
|
2011-12-19 06:45:39 +07:00
|
|
|
|
2017-12-30 04:25:30 +07:00
|
|
|
memset(kp->reserved, 0, sizeof(kp->reserved));
|
|
|
|
kp->menu_info = count ? compat_ptr(info) : NULL;
|
|
|
|
kp->menu_count = count;
|
2011-12-19 06:45:39 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int uvc_v4l2_put_xu_mapping(const struct uvc_xu_control_mapping *kp,
|
|
|
|
struct uvc_xu_control_mapping32 __user *up)
|
|
|
|
{
|
2017-12-30 04:25:30 +07:00
|
|
|
if (copy_to_user(up, kp, offsetof(typeof(*up), menu_info)) ||
|
|
|
|
put_user(kp->menu_count, &up->menu_count))
|
2011-12-19 06:45:39 +07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2017-12-30 04:25:30 +07:00
|
|
|
if (clear_user(up->reserved, sizeof(up->reserved)))
|
2012-04-08 22:59:48 +07:00
|
|
|
return -EFAULT;
|
2011-12-19 06:45:39 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct uvc_xu_control_query32 {
|
2018-01-17 00:45:36 +07:00
|
|
|
u8 unit;
|
|
|
|
u8 selector;
|
|
|
|
u8 query;
|
|
|
|
u16 size;
|
2011-12-19 06:45:39 +07:00
|
|
|
compat_caddr_t data;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int uvc_v4l2_get_xu_query(struct uvc_xu_control_query *kp,
|
|
|
|
const struct uvc_xu_control_query32 __user *up)
|
|
|
|
{
|
2017-12-30 04:25:30 +07:00
|
|
|
struct uvc_xu_control_query32 v;
|
2011-12-19 06:45:39 +07:00
|
|
|
|
2017-12-30 04:25:30 +07:00
|
|
|
if (copy_from_user(&v, up, sizeof(v)))
|
2011-12-19 06:45:39 +07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2017-12-30 04:25:30 +07:00
|
|
|
*kp = (struct uvc_xu_control_query){
|
|
|
|
.unit = v.unit,
|
|
|
|
.selector = v.selector,
|
|
|
|
.query = v.query,
|
|
|
|
.size = v.size,
|
|
|
|
.data = v.size ? compat_ptr(v.data) : NULL
|
|
|
|
};
|
2011-12-19 06:45:39 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int uvc_v4l2_put_xu_query(const struct uvc_xu_control_query *kp,
|
|
|
|
struct uvc_xu_control_query32 __user *up)
|
|
|
|
{
|
2017-12-30 04:25:30 +07:00
|
|
|
if (copy_to_user(up, kp, offsetof(typeof(*up), data)))
|
2011-12-19 06:45:39 +07:00
|
|
|
return -EFAULT;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define UVCIOC_CTRL_MAP32 _IOWR('u', 0x20, struct uvc_xu_control_mapping32)
|
|
|
|
#define UVCIOC_CTRL_QUERY32 _IOWR('u', 0x21, struct uvc_xu_control_query32)
|
|
|
|
|
|
|
|
static long uvc_v4l2_compat_ioctl32(struct file *file,
|
|
|
|
unsigned int cmd, unsigned long arg)
|
|
|
|
{
|
2016-05-25 05:13:02 +07:00
|
|
|
struct uvc_fh *handle = file->private_data;
|
2011-12-19 06:45:39 +07:00
|
|
|
union {
|
|
|
|
struct uvc_xu_control_mapping xmap;
|
|
|
|
struct uvc_xu_control_query xqry;
|
|
|
|
} karg;
|
|
|
|
void __user *up = compat_ptr(arg);
|
|
|
|
long ret;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case UVCIOC_CTRL_MAP32:
|
|
|
|
ret = uvc_v4l2_get_xu_mapping(&karg.xmap, up);
|
2016-05-25 05:13:02 +07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
ret = uvc_ioctl_ctrl_map(handle->chain, &karg.xmap);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
ret = uvc_v4l2_put_xu_mapping(&karg.xmap, up);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2011-12-19 06:45:39 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case UVCIOC_CTRL_QUERY32:
|
|
|
|
ret = uvc_v4l2_get_xu_query(&karg.xqry, up);
|
2016-05-25 05:13:02 +07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
ret = uvc_xu_ctrl_query(handle->chain, &karg.xqry);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
ret = uvc_v4l2_put_xu_query(&karg.xqry, up);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2011-12-19 06:45:39 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return -ENOIOCTLCMD;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-07-01 01:04:50 +07:00
|
|
|
static ssize_t uvc_v4l2_read(struct file *file, char __user *data,
|
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
|
|
|
uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_read: not implemented.\n");
|
2009-11-04 21:53:49 +07:00
|
|
|
return -EINVAL;
|
2008-07-01 01:04:50 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int uvc_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
|
|
|
|
{
|
2010-07-13 03:50:03 +07:00
|
|
|
struct uvc_fh *handle = file->private_data;
|
2009-06-28 18:37:50 +07:00
|
|
|
struct uvc_streaming *stream = handle->stream;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
|
|
|
uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_mmap\n");
|
|
|
|
|
2010-11-22 01:18:08 +07:00
|
|
|
return uvc_queue_mmap(&stream->queue, vma);
|
2008-07-01 01:04:50 +07:00
|
|
|
}
|
|
|
|
|
2017-07-03 14:02:56 +07:00
|
|
|
static __poll_t uvc_v4l2_poll(struct file *file, poll_table *wait)
|
2008-07-01 01:04:50 +07:00
|
|
|
{
|
2010-07-13 03:50:03 +07:00
|
|
|
struct uvc_fh *handle = file->private_data;
|
2009-06-28 18:37:50 +07:00
|
|
|
struct uvc_streaming *stream = handle->stream;
|
2008-07-01 01:04:50 +07:00
|
|
|
|
|
|
|
uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_poll\n");
|
|
|
|
|
2009-06-28 18:37:50 +07:00
|
|
|
return uvc_queue_poll(&stream->queue, file, wait);
|
2008-07-01 01:04:50 +07:00
|
|
|
}
|
|
|
|
|
2011-04-29 17:11:35 +07:00
|
|
|
#ifndef CONFIG_MMU
|
|
|
|
static unsigned long uvc_v4l2_get_unmapped_area(struct file *file,
|
|
|
|
unsigned long addr, unsigned long len, unsigned long pgoff,
|
|
|
|
unsigned long flags)
|
|
|
|
{
|
|
|
|
struct uvc_fh *handle = file->private_data;
|
|
|
|
struct uvc_streaming *stream = handle->stream;
|
|
|
|
|
|
|
|
uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_get_unmapped_area\n");
|
|
|
|
|
|
|
|
return uvc_queue_get_unmapped_area(&stream->queue, pgoff);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-09-30 20:17:54 +07:00
|
|
|
const struct v4l2_ioctl_ops uvc_ioctl_ops = {
|
|
|
|
.vidioc_querycap = uvc_ioctl_querycap,
|
|
|
|
.vidioc_enum_fmt_vid_cap = uvc_ioctl_enum_fmt_vid_cap,
|
|
|
|
.vidioc_enum_fmt_vid_out = uvc_ioctl_enum_fmt_vid_out,
|
|
|
|
.vidioc_g_fmt_vid_cap = uvc_ioctl_g_fmt_vid_cap,
|
|
|
|
.vidioc_g_fmt_vid_out = uvc_ioctl_g_fmt_vid_out,
|
|
|
|
.vidioc_s_fmt_vid_cap = uvc_ioctl_s_fmt_vid_cap,
|
|
|
|
.vidioc_s_fmt_vid_out = uvc_ioctl_s_fmt_vid_out,
|
|
|
|
.vidioc_try_fmt_vid_cap = uvc_ioctl_try_fmt_vid_cap,
|
|
|
|
.vidioc_try_fmt_vid_out = uvc_ioctl_try_fmt_vid_out,
|
|
|
|
.vidioc_reqbufs = uvc_ioctl_reqbufs,
|
|
|
|
.vidioc_querybuf = uvc_ioctl_querybuf,
|
|
|
|
.vidioc_qbuf = uvc_ioctl_qbuf,
|
2015-04-14 14:19:51 +07:00
|
|
|
.vidioc_expbuf = uvc_ioctl_expbuf,
|
2010-09-30 20:17:54 +07:00
|
|
|
.vidioc_dqbuf = uvc_ioctl_dqbuf,
|
|
|
|
.vidioc_create_bufs = uvc_ioctl_create_bufs,
|
|
|
|
.vidioc_streamon = uvc_ioctl_streamon,
|
|
|
|
.vidioc_streamoff = uvc_ioctl_streamoff,
|
|
|
|
.vidioc_enum_input = uvc_ioctl_enum_input,
|
|
|
|
.vidioc_g_input = uvc_ioctl_g_input,
|
|
|
|
.vidioc_s_input = uvc_ioctl_s_input,
|
|
|
|
.vidioc_queryctrl = uvc_ioctl_queryctrl,
|
2015-03-15 00:04:00 +07:00
|
|
|
.vidioc_query_ext_ctrl = uvc_ioctl_query_ext_ctrl,
|
2010-09-30 20:17:54 +07:00
|
|
|
.vidioc_g_ctrl = uvc_ioctl_g_ctrl,
|
|
|
|
.vidioc_s_ctrl = uvc_ioctl_s_ctrl,
|
|
|
|
.vidioc_g_ext_ctrls = uvc_ioctl_g_ext_ctrls,
|
|
|
|
.vidioc_s_ext_ctrls = uvc_ioctl_s_ext_ctrls,
|
|
|
|
.vidioc_try_ext_ctrls = uvc_ioctl_try_ext_ctrls,
|
|
|
|
.vidioc_querymenu = uvc_ioctl_querymenu,
|
2015-04-03 16:53:42 +07:00
|
|
|
.vidioc_g_selection = uvc_ioctl_g_selection,
|
2010-09-30 20:17:54 +07:00
|
|
|
.vidioc_g_parm = uvc_ioctl_g_parm,
|
|
|
|
.vidioc_s_parm = uvc_ioctl_s_parm,
|
|
|
|
.vidioc_enum_framesizes = uvc_ioctl_enum_framesizes,
|
|
|
|
.vidioc_enum_frameintervals = uvc_ioctl_enum_frameintervals,
|
|
|
|
.vidioc_subscribe_event = uvc_ioctl_subscribe_event,
|
|
|
|
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
|
|
|
|
.vidioc_default = uvc_ioctl_default,
|
|
|
|
};
|
|
|
|
|
2008-12-30 16:58:20 +07:00
|
|
|
const struct v4l2_file_operations uvc_fops = {
|
2008-07-01 01:04:50 +07:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = uvc_v4l2_open,
|
|
|
|
.release = uvc_v4l2_release,
|
2010-09-30 20:17:54 +07:00
|
|
|
.unlocked_ioctl = video_ioctl2,
|
2011-12-19 06:45:39 +07:00
|
|
|
#ifdef CONFIG_COMPAT
|
|
|
|
.compat_ioctl32 = uvc_v4l2_compat_ioctl32,
|
|
|
|
#endif
|
2008-07-01 01:04:50 +07:00
|
|
|
.read = uvc_v4l2_read,
|
|
|
|
.mmap = uvc_v4l2_mmap,
|
|
|
|
.poll = uvc_v4l2_poll,
|
2011-04-29 17:11:35 +07:00
|
|
|
#ifndef CONFIG_MMU
|
|
|
|
.get_unmapped_area = uvc_v4l2_get_unmapped_area,
|
|
|
|
#endif
|
2008-07-01 01:04:50 +07:00
|
|
|
};
|
2008-07-18 10:50:58 +07:00
|
|
|
|