History log of /drivers/media/video/v4l2-ioctl.c
Revision Date Author Comments
02bbb814d8db7b632458fcf8651267798eeef985 08-Feb-2012 Hans Verkuil <hverkuil@xs4all.nl> [media] -EINVAL -> -ENOTTY

I found one more place where -EINVAL is used instead of -ENOTTY:

Note that drivers/media/dvb/dvb-core/dvbdev.c has the same code, but as far as
I can tell DVB is still using -EINVAL for unknown ioctls so I didn't change
that.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
e2ecb257eebd8525029f43fcb4f922c4976dba53 02-Feb-2012 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2: standardize log start/end message

For drivers that properly use the v4l2 framework (i.e. set v4l2_dev in the
video_device struct), the start and end messages of VIDIOC_LOG_STATUS are
now generated automatically. People tended to forget these, but the v4l2-ctl
tool scans for these messages, and it also makes it easier to read the status
output in the kernel log.

The cx18, ivtv and bttv drivers were changed since they no longer need to
log these start/end messages.

In saa7164 two empty log_status functions were removed.

Also added a helper function to v4l2-ctrl.c that can be used as the
vidioc_log_status callback if all you need to do is to log the current control
values. This is now used by pwc and vivi.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Steven Toth <stoth@kernellabs.com>
Cc: Andy Walls <awalls@md.metrocast.net>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
a45c0ad51d344dad18c6fb67304b4f87cf0ffd59 24-Nov-2011 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2: add VIDIOC_(TRY_)DECODER_CMD

As discussed during the 2011 V4L-DVB workshop, the API in dvb/video.h should
be replaced by a proper V4L2 API. This patch turns the VIDEO_(TRY_)DECODER_CMD
ioctls into proper V4L2 ioctls.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
583aa3a9b5ca846a84f7dd87bdc4b75dca07b011 11-Jan-2012 Hans Verkuil <hans.verkuil@cisco.com> [media] V4L2: Add per-device-node capabilities

If V4L2_CAP_DEVICE_CAPS is set, then the new device_caps field is filled with
the capabilities of the opened device node.

The capabilities field traditionally contains the capabilities of the physical
device, being a superset of all capabilities available at the several device
nodes. E.g., if you open /dev/video0, then if it contains VBI caps then that means
that there is a corresponding vbi node as well. And the capabilities field of
both the video and vbi nodes should contain identical caps.

However, it would be very useful to also have a capabilities field that contains
just the caps for the currently open device, hence the new CAP bit and field.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
aa07eec5320cf1793062c03b8409e7541ca37c31 11-Oct-2011 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl: make tuner 'type' check more strict for S_FREQUENCY

As per the feature removal document, make the tuner type check more strict
so that it is no longer possible to set the radio frequency through a video
node or the TV frequency through a radio node.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
992efeff79fe8de44d4e8b7636bb2e5d9dcf698d 22-Mar-2011 Tomasz Stanislawski <t.stanislaws@samsung.com> [media] v4l: emulate old crop API using extended crop/compose API

This patch allows new video drivers to work correctly with applications that
use the old-style crop API. The old crop ioctl is emulated by using selection
callbacks.

Signed-off-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
0e8caaceff160ad821c83d798fc03812cb810560 10-Aug-2011 Tomasz Stanislawski <t.stanislaws@samsung.com> [media] v4l: add support for selection api

This patch introduces new api for a precise control of cropping and composing
features for video devices. The new ioctls are VIDIOC_S_SELECTION and
VIDIOC_G_SELECTION.

Signed-off-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
6c06108be53ca5e94d8b0e93883d534dd9079646 05-Jan-2012 Dan Carpenter <dan.carpenter@oracle.com> [media] V4L/DVB: v4l2-ioctl: integer overflow in video_usercopy()

If ctrls->count is too high the multiplication could overflow and
array_size would be lower than expected. Mauro and Hans Verkuil
suggested that we cap it at 1024. That comes from the maximum
number of controls with lots of room for expantion.

$ grep V4L2_CID include/linux/videodev2.h | wc -l
211

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2150158b31a3290cc883cf6dea4f5d6803b6b811 28-Sep-2011 Guennadi Liakhovetski <g.liakhovetski@gmx.de> [media] V4L: add two new ioctl()s for multi-size videobuffer management

A possibility to preallocate and initialise buffers of different sizes
in V4L2 is required for an efficient implementation of a snapshot
mode. This patch adds two new ioctl()s: VIDIOC_CREATE_BUFS and
VIDIOC_PREPARE_BUF and defines respective data structures.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
8715e6cbae2ec8b451920496a73786402a5d879d 04-Oct-2011 Mauro Carvalho Chehab <mchehab@redhat.com> [media] v4l2-ioctl: Fill the default value for VIDIOC_QUERYSTD

According with the V4L2 API spec:

"When detection is not possible or fails, the set must contain
all standards supported by the current video input or output."

The V4L2 core has the mask with all supported standards already. So,
apply it. Driver and subdevs can then just remove standards from the
mask, as they're able of detecting audio, video and frames frequency.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
1d0c86cad38678fa42f6d048a7b9e4057c8c16fc 01-Jul-2011 Tomasz Stanislawski <t.stanislaws@samsung.com> [media] media: v4l: remove single to multiplane conversion

This patch removes an implicit conversion between multi and single plane
formats from V4L2 framework. The conversion is to be performed by libv4l2.

Signed-off-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
93d5a30bcabb49a3179d68f5714d43ae1560ede8 09-Aug-2011 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl: more -ENOTTY fixes

explicitly instead of using a macro.
ioctls and the ENUMSTD, S_STD and G_PARM ioctls.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
a5f2db539bd2a977cdee3fecc5c15dd0941c1ab3 31-Jul-2011 Mauro Carvalho Chehab <mchehab@redhat.com> v4l2-ioctl: properly return -EINVAL when parameters are wrong

Whan an ioctl is implemented, but the parameters are invalid,
the error code should be -EINVAL. However, if the ioctl is
not defined, it should return -ENOTTY instead.

Reported-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
9190d191b1b814dfb488125b54cf0de6eedd9220 06-Jul-2011 Mauro Carvalho Chehab <mchehab@redhat.com> [media] v4l2 core: return -ENOTTY if an ioctl doesn't exist

Currently, -EINVAL is used to return either when an IOCTL is not
implemented, or if the ioctl was not implemented.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
ab892bac8438c5c2ff09a60d765d9b0c14941ba9 07-Jun-2011 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ctrls: add v4l2_fh pointer to the set control functions

When an application changes a control you want to generate an event.
However, you want to avoid sending such an event back to the application
(file handle) that caused the change.

Add the filehandle to the various set control functions.

The filehandle isn't used yet, but the control event patches will need
this.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2d28b686adc18567b388362e1f7b86658cfd81fc 12-Mar-2011 Hans Verkuil <hverkuil@xs4all.nl> [media] v4l2-ioctl: add ctrl_handler to v4l2_fh

This is required to implement control events and is also needed to allow
for per-filehandle control handlers.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
ae6db5154671759426046c2cbc2e20a82ff0feed 24-Jun-2011 Mauro Carvalho Chehab <mchehab@redhat.com> [media] v4l2-ioctl: Add a default value for kernel version

Most drivers don't increase kernel versions as newer features are added or
bug fixes are solved. So, vidioc_querycap returned value for cap->version is
meaningless. Instead of keeping this situation forever, let's add a default
value matching the current Linux version.

Drivers that want to keep their own version control can still do it, as they
can override the default value for cap->version.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2ef403708880c6e00854fb81bbffb9a4036327e6 23-May-2011 Hans Petter Selasky <hselasky@c2i.net> [media] Fix compile warning: Dereferencing type-punned pointer will break strict-aliasing rules

Signed-off-by: Hans Petter Selasky <hselasky@c2i.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
a6cf90a91551c767bed78a4418c26f41aed60cde 14-Jun-2011 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl.c: check for valid tuner type in S_HW_FREQ_SEEK

Prohibit attempts to change the tuner to a type that is different
from the device node the ioctl is called from. I.e. the type must
be RADIO for a radio node and ANALOG_TV for a video/vbi node.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
227690df75382e46a4f6ea1bbc5df855a674b47f 12-Jun-2011 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl.c: prefill tuner type for g_frequency and g/s_tuner

The subdevs are supposed to receive a valid tuner type for the g_frequency
and g/s_tuner subdev ops. Some drivers do this, others don't. So prefill
this in v4l2-ioctl.c based on whether the device node from which this is
called is a radio node or not.

The spec does not require applications to fill in the type, and if they
leave it at 0 then the 'check_mode' call in tuner-core.c will return
an error and the ioctl does nothing.

Cc: stable@kernel.org
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
25985edcedea6396277003854657b5f3cb31a628 31-Mar-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Fix common misspellings

Fixes generated by 'codespell' and manually reviewed.

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
b1a873a37b6551a214ad37d1eee7654a9d65fd6e 22-Mar-2011 Hans Verkuil <hverkuil@xs4all.nl> [media] v4l2: use new flag to enable core priority handling

Rather than guess which driver supports core priority handling, require drivers
that do to explicitly set the V4L2_FL_USE_FH_PRIO flag in video_device.

Updated the core prio handling accordingly and set the flag in the three
drivers that do.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
99cd47bc733436da282016e629eef6baa0f6047c 11-Mar-2011 Hans Verkuil <hverkuil@xs4all.nl> [media] v4l2-ioctl: add priority handling support

Drivers that use v4l2_fh can now use the core framework support of g/s_priority.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
fc0a80798576f80ca10b3f6c9c7097f12fd1d64e 12-Jul-2010 Laurent Pinchart <laurent.pinchart@ideasonboard.com> [media] v4l: Share code between video_usercopy and video_ioctl2

The two functions are mostly identical. They handle the copy_from_user
and copy_to_user operations related with V4L2 ioctls and call the real
ioctl handler.

Create a __video_usercopy function that implements the core of
video_usercopy and video_ioctl2, and call that function from both.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
7ee40aadabd59b6cab60835f0ef9cdbe385df438 05-Feb-2011 Hans Verkuil <hverkuil@xs4all.nl> [media] v4l: removal of old, obsolete ioctls

Some ioctl's were defined wrong on 2.6.2 and 2.6.6, using the wrong
type of R/W arguments. They were fixed, but the old ioctl names are
still there, maintained to avoid breaking binary compatibility:

There's no sense on preserving those forever, as it is very doubtful
that someone would try to use a such old binary with a modern kernel.
Removing them will allow us to remove some magic done at the V4L ioctl
handler.

Note that any application compiled with a videodev2.h from 2.6.7 or later
will be using the correct ioctls.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
d14e6d76ebf740fd0d0bd296933993a555938896 23-Dec-2010 Pawel Osciak <p.osciak@samsung.com> [media] v4l: Add multi-planar ioctl handling code

Add multi-planar API core ioctl handling and conversion functions.

[mchehab@redhat.com: CondingStyle fixup]
Signed-off-by: Pawel Osciak <p.osciak@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
f8f3914cf922f5f9e1d60e9e10f6fb92742907ad 29-Jul-2010 Pawel Osciak <p.osciak@samsung.com> [media] v4l: Add multi-planar API definitions to the V4L2 API

Multi-planar API is as a backwards-compatible extension of the V4L2 API,
which allows video buffers to consist of one or more planes. Planes are
separate memory buffers; each has its own mapping, backed by usually
separate physical memory buffers.

Many different uses for the multi-planar API are possible, examples
include:
- embedded devices requiring video components to be placed in physically
separate buffers, e.g. for Samsung S3C/S5P SoC series' video codec,
Y and interleaved Cb/Cr components reside in buffers in different
memory banks;
- applications may receive (or choose to store) video data of one video
buffer in separate memory buffers; such data would have to be temporarily
copied together into one buffer before passing it to a V4L2 device;
- applications or drivers may want to pass metadata related to a buffer and
it may not be possible to place it in the same buffer, together with video
data.

[mchehab@redhat.com: CodingStyle fixes]
Signed-off-by: Pawel Osciak <p.osciak@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
a1198ccf9c52922e66a3372b0045ebe335a127dd 08-Jan-2011 Hans Verkuil <hverkuil@xs4all.nl> [media] v4l2-ioctl: fix incorrect error code if VIDIOC_DBG_G/S_REGISTER are unsupported

The ioctls VIDIOC_DBG_S_REGISTER and VIDIOC_DBG_G_REGISTER should return -EINVAL
if the driver didn't implement them. Currently they return -EPERM if called as
non-root user. However, this check should only be done if the driver actually
implemented these ioctls. Otherwise, just return -EINVAL as we do with all
unimplemented ioctls.

This bug make the v4l2-compliance test suite fail.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
08af245de0cf6ab5f4ed008ee2bb99273774fce0 24-Dec-2010 Hans Verkuil <hverkuil@xs4all.nl> [media] V4L: remove V4L1 compatibility mode

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
11bbc1cadb638aaccb4764c6e16807b36b53cf19 16-May-2010 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB: v4l2: hook up the new control framework into the core framework

Add the calls needed to automatically merge subdev controls into a bridge
control handler.

Hook up the control framework in __video_ioctl2 and video_register_device.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
d3d7c963562adad92e968df23c425ae964fe9ce2 27-Mar-2010 Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> V4L/DVB: V4L: Events: Support event handling in do_ioctl

Add support for event handling to do_ioctl.

Signed-off-by: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
fda1021477b390506ebed0225eaa6d31a903e2b7 24-Feb-2010 Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> V4L/DVB: V4L: Events: Add new ioctls for events

This patch adds a set of new ioctls to the V4L2 API. The ioctls conform to
V4L2 Events RFC version 2.3:

<URL:http://www.spinics.net/lists/linux-media/msg12033.html>

Signed-off-by: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
6a717883e720f75dec252c8af2a2d6dd049af254 06-Apr-2010 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB: video_ioctl2: handle the v4l1 compat bit first and move VIDIOCGMBUF into the switch

Try to make a more sensible sequence of events in __video_do_ioctl: first
check for a valid ops pointer, then get the compat part done. The VIDIOCGMBUF
command is now part of the big switch.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
3f5e18249ce0d71a900bfdb8df327269483e730d 06-Apr-2010 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB: video_ioctl2: don't return, use break

You want to be able to reach the debug code at the end of this function,
so don't use return, use break.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
1d94aa369da073acff26fa98ad6b2168cb028ab1 06-Apr-2010 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB: video_ioctl2: do not replace arg with NULL for _IO() ioctls

If the ioctl was defined without direction (e.g. _IO('o', 25)), then
the arg as passed to vidioc_default was NULL instead of the original
argument.

Several ioctls in e.g. include/linux/dvb/video.h and audio.h use this type
of ioctl to pass simple numerical values to the driver.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
5a0e3ad6af8660be21ca98a971cd00f331318c05 24-Mar-2010 Tejun Heo <tj@kernel.org> 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>
b6456c0cfe9d94e6d2bf684e6e6c031fc0b10031 19-Nov-2009 Muralidharan Karicheri <m-karicheri2@ti.com> V4L/DVB (13571): v4l: Adding Digital Video Timings APIs

This adds the above APIs to the v4l2 core. This is based on version v1.2
of the RFC titled "V4L - Support for video timings at the input/output interface"
Following new ioctls are added:-

- VIDIOC_ENUM_DV_PRESETS
- VIDIOC_S_DV_PRESET
- VIDIOC_G_DV_PRESET
- VIDIOC_QUERY_DV_PRESET
- VIDIOC_S_DV_TIMINGS
- VIDIOC_G_DV_TIMINGS

Please refer to the RFC for the details. This code was tested using vpfe
capture driver on TI's DM365. Following is the test configuration used :-

Blu-Ray HD DVD source -> TVP7002 -> DM365 (VPFE) ->DDR

A draft version of the TVP7002 driver (currently being reviewed in the mailing
list) was used that supports V4L2_DV_1080I60 & V4L2_DV_720P60 presets.

A loopback video capture application was used for testing these APIs. This calls
following IOCTLS :-

- verify the new v4l2_input capabilities flag added
- Enumerate available presets using VIDIOC_ENUM_DV_PRESETS
- Set one of the supported preset using VIDIOC_S_DV_PRESET
- Get current preset using VIDIOC_G_DV_PRESET
- Detect current preset using VIDIOC_QUERY_DV_PRESET
- Using stub functions in tvp7002, verify VIDIOC_S_DV_TIMINGS
and VIDIOC_G_DV_TIMINGS ioctls are received at the sub device.
- Tested on 64bit platform by Hans Verkuil

Signed-off-by: Muralidharan Karicheri <m-karicheri2@ti.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Reviewed-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
6b5a9492ca0c991bab1ac495624e17520e9edf18 11-Aug-2009 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (12543): v4l: introduce string control support.

The upcoming RDS encoder needs support for string controls. This patch
implements the core implementation.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
d33fbcbb21ba53358ba8a83765cfd1401e06d883 02-Jul-2009 Mauro Carvalho Chehab <mchehab@redhat.com> V4L/DVB (12168): v4l2-ioctl: avoid flooding log with unasked debug messages

Thanks to Hans Verkuil <hverkuil@xs4all.nl> for pointing this issue on
my last patch.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
d1afe4250a0aecf7ee92fa3d563a2f2aabf6cc0b 22-Jun-2009 Mauro Carvalho Chehab <mchehab@redhat.com> V4L/DVB (12124): v4l2-ioctl: better output debug messages for VIDIOC_ENUM_FRAMESIZES

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
9bedc7f7fe803c17d26b5fcf5786b50a7cf40def 07-Aug-2009 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (12429): v4l2-ioctl: fix G_STD and G_PARM default handlers

The v4l core supplies default handlers for G_STD and G_PARM. However, both
default handlers are buggy.

This patch fixes the following:

1) If no g_std is supplied and current_norm == 0, then this driver does not
support TV video standards (e.g. a radio or webcam driver). Return
-EINVAL. This ensures that there is no bogus VIDIOC_G_STD support for
such drivers.

2) The default VIDIOC_G_PARM handler used current_norm instead of first
checking if the driver supported g_std and calling that to get the norm.
It also didn't check if current_norm was 0, since in that case the driver
does not support TV standards (or no standard was set at all) and the
default handler should return -EINVAL.

Note that I am very unhappy with these default handlers: I think they
basically behave like some very strange and unexpected side-effect.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
7ecc0cf937e97b6116db09cd13c32467b34c164a 01-May-2009 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (11662): v4l2-ioctl: Clear buffer type specific trailing fields/padding

Some ioctls have structs that are a different size depending on what type
of buffer is being used. If the buffer type leaves a field unused or has
padding space at the end, this space should be zeroed out.

The problems with S_FMT and REQBUFS were original identified and patched by
Marton Nemeth <nm127@freemail.hu>.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
1175d6131f7a89c163227169325ca77a22b18cb2 01-May-2009 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (11661): v4l2-ioctl: Check buffer types using g_fmt instead of try_fmt

For a number of different ioctls, the v4l2-ioctl code checks that the
passed buffer type is supported by the driver. It did this by checking
that the driver defined a method for the try_fmt handler for that buffer
type. However, try_fmt is optional and a driver might not provide it even
though it does support that type. So use g_fmt instead, since that isn't
optional.

This should fix a problem with VBI capture with saa7146.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
78a3b4db2e53a1903c86e2856e175d85a3849e84 01-Apr-2009 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (11367): v4l2-common: remove legacy code

Now that all drivers are converted to v4l2_subdev we can remove legacy code
in v4l2-common. Also move the documentation of the internal API to
v4l2-subdev.h where it really belongs.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
34796bc009565ea72643087b7d69c9fa748bce9b 29-Mar-2009 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (11260): v4l2-ioctl: Check format for S_PARM and G_PARM

Return EINVAL if VIDIOC_S/G_PARM is called for a buffer type that the
driver doesn't define a ->vidioc_try_fmt_XXX() method for. Several other
ioctls, like QUERYBUF, QBUF, and DQBUF, etc. do this too. It saves each
driver from having to check if the buffer type is one that it supports.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
9f1a693f76700018d921cd7af86f7c994a300613 08-Mar-2009 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (10920): v4l2-ioctl: fix partial-copy code.

The code to optimize the usercopy only checked the ioctl NR field. However,
this code is also called for non-V4L2 ioctls (either private or ioctls from
linux/dvb/audio.h and linux/dvb/video.h for decoder drivers like ivtv).

If such an ioctl has the same NR as a V4L2 ioctl, then disaster strikes.

Modified the code to check on the full command ID.

Thanks to Martin Dauskardt for tracing the ivtv breakage to this particular
change.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
fbc9fa4e8781170e2fbca2859feda114d4758132 06-Mar-2009 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (10910): videodev2.h: remove deprecated VIDIOC_G_CHIP_IDENT_OLD

As announced VIDIOC_G_CHIP_IDENT_OLD is now removed for 2.6.30.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
7e0a16f6118a297dd467c1e5a0908429fcdf56af 10-Mar-2009 Mauro Carvalho Chehab <mchehab@redhat.com> V4L/DVB (10907): avoid loading the entire videodev.h header on V4L2 drivers

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
bd894b590ef45297c941b7af0e8de13a2fd306d6 10-Mar-2009 Mauro Carvalho Chehab <mchehab@redhat.com> V4L/DVB (10870): v4l2-ioctl: get rid of video_decoder.h

The V4L1 obsoleted header video_decoder.h is not used anymore by any driver. Only
a name decoding function at v4l2-ioctl still implements it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
51f0b8d57af501624ee55e8ca15d09d5bdc2b0dd 04-Mar-2009 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (10813): v4l2: New function v4l2_video_std_frame_period

Some code was calling v4l2_video_std_construct() when all it cared about
was the frame period. So make a function that just returns that and have
v4l2_video_std_construct() use it.

At this point there are no users of v4l2_video_std_construct() left outside
of v4l2-ioctl, so it could be un-exported and made static.

Change v4l2_video_std_construct() so that it doesn't zero out the struct
v4l2_standard passed in. It's already been zeroed out in the common ioctl
code.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
337f9d205972bfe1cb7982384fd0f4caa4af001d 04-Mar-2009 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (10812): v4l2: Zero out read-only ioctls in one place

If an ioctl is read-only then the driver fills in all the fields. Lots of
times drivers only care about some fields so it's best if video_ioctl2
takes care of zeroing out the entire structure before handing it to the
driver. This saves code in each driver to do it and driver authors often
forget.

The existing memset code in some of the read-only ioctl handlers
can be deleted.

Convert a case statement to a single if statement.

Deleted a debug line from ENUMAUDOUT that was copy-and-pasted to G_AUDOUT
by mistake.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
19c96e4b7d3c80071982a052e4a921c1a39875d9 04-Mar-2009 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (10811): videodev: only copy needed part of RW ioctl's parameter

There are many RW ioctls() in v4l2 where userspace only supplies one or two
of the first fields in the structure passed to the ioctl. The driver then
fills in the rest of the fields.

Instead of copying the entire structure from userspace to the kernel we
only need to copy those fields that userspace is actually supposed to
supply.

What's more, the fields that are meant to be only be output from the driver
can be zeroed out in the videodev code, in case the driver doesn't fill
them all in. Many of the ioctl handlers in v4l2_ioctl do this already, but
my patch does this at one common point and so all the memsets for each
ioctl can be deleted.

For VIDIOC_G_SLICED_VBI_CAP, which has one input field ('type') and other
output-only fields, the input field is near the end of the structure
instead of at the beginning. So there is still a memset in it's ioctl
handler to zero out the beginning of the struct.

There were a couple mistakes with the existing code:
For VIDIOC_G_AUDIO the index field was preserved, but G_AUDIO is a read
only ioctl so nothing is copied from userspace to preserve.

For VIDIOC_G_FREQUENCY the tuner field was not preserved like it should
have been. This would be a problem if there was any hardware with more
than one tuner/modulator.

For VIDIOC_ENUM_FRAMESIZES and VIDIOC_ENUM_FRAMEINTERVALS, none of the
fields were preserved even though each ioctl has several field that are
supposed to be inputs to the driver! Obviously these ioctls don't get
used much. The index field is needed if the driver has multiple
discrete sizes/rates and other fields can be used too, e.g. if the size
depends on pixel format or frame rate depends on image size for
example.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
9cfb6a3f1b16e82fab97831265858aa2d1983883 04-Mar-2009 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (10794): v4l2: Move code to zero querybuf output struct to v4l2_ioctl

For VIDIOC_QUERYBUF only the first two fields, size and type, are used as
input. The rest can be filled in by the driver as output. Most drivers do
not actually use all the field and unused ones should be zeroed out. Some
drivers have code to do this and some drivers should but don't. So put
some zero out code in v4l2_ioctl so that all drivers using that system get
it.

The drivers that have zeroing code get that code removed.

Some drivers checked that the type field was valid, but v4l2_ioctl already
does this so those checks can be removed as well.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
80b36e0fcfe7520ee92f648148d091ad880ae711 07-Feb-2009 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (10490): v4l2: prefill ident and revision from v4l2_dbg_chip_ident.

Drivers that implement this always have to set the ident and revision
to V4L2_IDENT_NONE and 0. Do this in the v4l2 core so drivers don't have
to do this.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
aecde8b53b8ee1330a5a8206200f0d6b8845a6e0 30-Dec-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (10141): v4l2: debugging API changed to match against driver name instead of ID.

Since the i2c driver ID will be removed in the near future we have to
modify the v4l2 debugging API to use the driver name instead of driver ID.

Note that this API is not used in applications other than v4l2-dbg.cpp
as it is for debugging and testing only.

Should anyone use the old VIDIOC_G_CHIP_IDENT, then this will be logged
with a warning that it is deprecated and will be removed in 2.6.30.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
069b747931f13eda289c1d59a09ecc8162281a76 30-Dec-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (10138): v4l2-ioctl: change to long return type to match unlocked_ioctl.

Since internal to v4l2 the ioctl prototype is the same regardless of it
being called through .ioctl or .unlocked_ioctl, we need to convert it all
to the long return type of unlocked_ioctl.

Thanks to Jean-Francois Moine for posting an initial patch for this and
thus bringing it to our attention.

Cc: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
bec43661b1dc0075b7445223ba775674133b164d 30-Dec-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (10135): v4l2: introduce v4l2_file_operations.

Introduce a struct v4l2_file_operations for v4l2 drivers.

Remove the unnecessary inode argument.

Move compat32 handling (and llseek) into the v4l2-dev core: this is now
handled in the v4l2 core and no longer in the drivers themselves.

Note that this changeset reverts an earlier patch that changed the return
type of__video_ioctl2 from int to long. This change will be reinstated
later in a much improved version.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
92ab7886119da6375a983713eedab444e32094f6 29-Dec-2008 Mauro Carvalho Chehab <mchehab@redhat.com> V4L/DVB (10110): v4l2-ioctl: Fix warnings when using .unlocked_ioctl = __video_ioctl2

This patch fixes this warning:

drivers/media/video/gspca/gspca.c:1811: warning: initialization from incompatible pointer type

The reason is that the returned argument should be a long, not an
integer.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
1958578da6f3971227fca94a62429cdf0bd3c699 12-Nov-2008 Mauro Carvalho Chehab <mchehab@redhat.com> V4L/DVB (9591): v4l core: fix debug printk for enumberating framerates

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
a56a18c3ed3442a0c049c9b5f0dda918a6e83726 12-Nov-2008 Mauro Carvalho Chehab <mchehab@redhat.com> V4L/DVB (9579): v4l core: a few get ioctls were lacking memory clean

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
74d83fa0241f603a4067f071a88ef8b9a7c415a0 12-Nov-2008 Mauro Carvalho Chehab <mchehab@redhat.com> V4L/DVB (9578): v4l core: add support for enumerating frame sizes and intervals

video_ioctl2 lacks implementation of those two ioctls:
- VIDIOC_ENUM_FRAMESIZES and VIDIOC_ENUM_FRAMEINTERVALS

Adds implementation for those.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
f473bf76c71ca734a16f9331ce6b6e9603641888 01-Nov-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (9503): v4l: remove inode argument from video_usercopy

The inode argument was never used. Removing it from video_usercopy
brings the function pointer type of video_usercopy in line with similar
v4l2 functions, thus simplifying several drivers.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
d9b01449e75d1351296595e28d2af72993bcc3dc 27-Oct-2008 Alan Cox <alan@lxorguk.ukuu.org.uk> V4L/DVB (9491): rationalise addresses to one common one

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
8a522c916d3c3b29a38bd3c8fc3df826d22a9444 21-Oct-2008 Mauro Carvalho Chehab <mchehab@redhat.com> V4L/DVB (9331): Remove unused inode parameter from video_ioctl2

inode is never used on video_ioctl2. Remove it and rename the function to
__video_ioctl2. This allows its usage directly as a callback at
fops.unlocked_ioctl.

Since we still need a callback with inode to be used with fops.ioctl,
this patch adds video_ioctl2() that is just a call to __video_ioctl2().

Also, this patch adds some comments about video_ioctl2 and __video_ioctl2
usage at v4l2-ioctl.h.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
b1f88407f3767f924cae1d521e815e568996a4ef 21-Oct-2008 Mauro Carvalho Chehab <mchehab@redhat.com> V4L/DVB (9330): Get rid of inode parameter at v4l_compat_translate_ioctl()

The inode parameter at v4l_compat_translate_ioctl() were just passed over several
places just to keep compatible with fops.ioctl. However, it weren't used anywere.

This patch gets hid of this unused parameter.

Cc: Laurent Pinchart <laurent.pinchart@skynet.be>
Cc: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
d5fbf32f381ad841d9d9537aa1b6f74796703361 18-Oct-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (9324): v4l2: add video_ioctl2_unlocked for unlocked_ioctl support.

Based on an older patch from Sakari Ailus.

Cc: Sakari Ailus <sakari.ailus@nokia.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
3c7b933bea2ee380d54b57b99dee42b1726a4eaa 03-Oct-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (9160): v4l: remove vidioc_enum_fmt_vbi_cap

Remove the vidioc_enum_fmt_vbi_cap ops: it was scheduled for removal in
2.6.28 since the v4l2 specification says that V4L2_BUF_TYPE_VBI_CAPTURE should
not support VIDIOC_ENUM_FMT. It's also pretty pointless.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
b045979d61b235cd9cc8347760fcfb44fc8ecbd6 03-Sep-2008 Alexander Beregalov <a.beregalov@gmail.com> V4L/DVB (8681): v4l2-ioctl.c: fix warning

drivers/media/video/v4l2-ioctl.c:496: warning: format '%08ld' expects
type 'long int', but argument 5 has type 'suseconds_t'

Signed-off-by: Alexander Beregalov <a.beregalov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
888fe747b5d134e2f3b5c2d3ecc25e1c6dcad4c3 03-Sep-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (8629): v4l2-ioctl: do not try to handle private V4L1 ioctls

Some drivers (e.g. zoran) have private V4L1 ioctls. Do not try to
pass them to v4l1_compat_translate because then the driver will
never see them.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
a399810ca69d9d4bd30ab8c1678c7439e567f90b 21-Jul-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (8482): videodev: move all ioctl callbacks to a new v4l2_ioctl_ops struct

All ioctl callbacks are now stored in a new v4l2_ioctl_ops struct. Drivers fill in
a const struct v4l2_ioctl_ops and video_device just contains a const pointer to it.

This ensures a clean separation between the const ops struct and the non-const
video_device struct.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
35ea11ff84719b1bfab2909903a9640a86552fd1 20-Jul-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (8430): videodev: move some functions from v4l2-dev.h to v4l2-common.h or v4l2-ioctl.h

The functions in a header should not belong to another module. The prio functions
belong to v4l2-common.c, so move them to v4l2-common.h.

The ioctl functions belong to v4l2-ioctl.c, so create a new v4l2-ioctl.h header
and move those functions to it.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>