History log of /drivers/media/v4l2-core/v4l2-ioctl.c
Revision Date Author Comments
017ab36a8bce08ebdca741ea636f0b2e5006a143 21-Sep-2014 Hans Verkuil <hverkuil@xs4all.nl> [media] v4l2-ioctl.c: fix inverted condition

v4l_print_ext_controls() would print the 'size' if it was 0 and
'value' if size was non-zero, but it should have been the other
way around.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
4d1afa51e957a48db9663e74816c411e70b8d15e 21-Aug-2014 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl: fix sparse warnings

drivers/media/v4l2-core/v4l2-ioctl.c:1156:53: warning: incorrect type in initializer (different address spaces)
drivers/media/v4l2-core/v4l2-ioctl.c:1158:42: warning: incorrect type in initializer (different address spaces)
drivers/media/v4l2-core/v4l2-ioctl.c:1161:34: warning: incorrect type in assignment (different address spaces)
drivers/media/v4l2-core/v4l2-ioctl.c:1163:35: warning: incorrect type in assignment (different address spaces)

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
48f2650a87ae462598cf0a3b4b34ee5f52c34869 21-Jul-2014 Hans Verkuil <hverkuil@xs4all.nl> [media] v4l2-ioctl: don't set PRIV_MAGIC unconditionally in g_fmt()

Regression fix:

V4L2_PIX_FMT_PRIV_MAGIC should only be set for the VIDEO_CAPTURE and
VIDEO_OUTPUT buffer types, and not for any others. In the case of
the win format this overwrote a pointer value that is passed in from
userspace.

Just set it for V4L2_BUF_TYPE_VIDEO_CAPTURE and OUTPUT only. Set
it before the callback is called, just as is done for try/s_fmt, and
again afterwards in case the driver zeroed it. The latter was missing
in try/s_fmt, so add it there as well. Currently it is quite likely
that drivers clear priv (that was needed for a long time), so it makes
sense to set it twice.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
796a2bd25b4fc3c4a1d6f04373ef2af1e12489b5 21-Jul-2014 Hans Verkuil <hverkuil@xs4all.nl> [media] v4l2-ioctl: set V4L2_CAP_EXT_PIX_FORMAT for device_caps

V4L2_CAP_EXT_PIX_FORMAT is set for capabilities, but it needs to be set for
device_caps as well: device_caps should report all caps relevant to the
device node, and this is one of them.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
e5ce558a6157e49374ba762471b77ce89ada4df0 17-Jul-2014 Hans Verkuil <hverkuil@xs4all.nl> [media] v4l2-ioctl: clips, clipcount and bitmap should not be zeroed

Otherwise you cannot get the current clip and bitmap information from
an overlay.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9409945c7ff7ba39727df8ede2551bd22e76b58b 13-Jun-2014 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl: call g_selection before calling cropcap

If the vidioc_cropcap op is implemented by the driver then the v4l2
core will call that directly.

If g_selection is available, then the core cropcap implementation
uses g_selection to fill in the bounds and defrect and it sets the
pixelaspect to 1x1.

But if both are available, then I would like to use g_selection to
fill in defrect and bounds before calling cropcap. That way the
driver's cropcap implementation doesn't have to set defrect or
bounds.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
865c4642e3750a257e4e199c2eb60495fd66f530 24-Mar-2014 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl: clear reserved field of G/S_SELECTION

Be sure that the reserved fields are cleared.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
f9402a94e7ca0df34e7dc17d763bb49afbd89c3a 14-Mar-2014 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl: remove pointless INFO_FL_CLEAR

The edid field is the last field of the struct, so there is nothing to clear.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
a7f404af8a435b940055a04be19a3304da93a76d 11-Jul-2014 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl.c: fix enum_freq_bands handling

If the driver supports enum_freq_bands, but only for certain device
nodes, then it may return -ENOTTY. But in that case the code should
fall into the fall-back case where the current tuner/modulator range
is returned.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
ce71bbc91e2440a399f2f96b96cfbf263a6629c1 12-Jul-2014 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl.c: check vfl_type in ENUM_FMT

The other format ioctls (g/s/try_fmt) all check if the passed buffer type
makes sense for the device node's vfl_type. E.g. it makes no sense for a
VBI buffer type to be passed through a video node instead of a vbi node.

But this check was missing in ENUM_FMT which can cause a problem if you
have both video and sdr device nodes.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
c96fd46afb34a554406bce9784126b96ad09091e 27-May-2014 Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> [media] v4l: Add premultiplied alpha flag for pixel formats

When set, the new V4L2_PIX_FMT_FLAG_PREMUL_ALPHA flag indicates that the
pixel values are premultiplied by the alpha channel value.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
d52e23813672c3c72f92e7b39c7408d4b9a40a96 27-May-2014 Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> [media] v4l: Support extending the v4l2_pix_format structure

The v4l2_pix_format structure has no reserved field. It is embedded in
the v4l2_framebuffer structure which has no reserved fields either, and
in the v4l2_format structure which has reserved fields that were not
previously required to be zeroed out by applications.

To allow extending v4l2_pix_format, inline it in the v4l2_framebuffer
structure, and use the priv field as a magic value to indicate that the
application has set all v4l2_pix_format extended fields and zeroed all
reserved fields following the v4l2_pix_format field in the v4l2_format
structure.

The availability of this API extension is reported to userspace through
the new V4L2_CAP_EXT_PIX_FORMAT capability flag. Just checking that the
priv field is still set to the magic value at [GS]_FMT return wouldn't
be enough, as older kernels don't zero the priv field on return.

To simplify the internal API towards drivers zero the extended fields
and set the priv field to the magic value for applications not aware of
the extensions.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
0176077a813933a547b7a913377a87d615b7c108 27-Apr-2014 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ctrls: create type_ops

Since compound controls can have non-standard types we need to be able to do
type-specific checks etc. In order to make that easy type operations are added.
There are four operations:

- equal: check if two values are equal
- init: initialize a value
- log: log the value
- validate: validate a new value

The v4l2_ctrl struct adds p_new and p_cur unions at the end of the struct.
This union provides a standard way of accessing control types through a pointer,
which greatly simplifies internal control processing.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
e6bee3685e732df82f48698254a36754cf15f0b0 10-Jun-2014 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2: integrate support for VIDIOC_QUERY_EXT_CTRL

Add the v4l2 core plumbing for the new VIDIOC_QUERY_EXT_CTRL ioctl.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
b7284bb0be49441805ae7db0fc419ab7ee882bff 19-Jun-2014 Ramakrishnan Muthukrishnan <ramakrmu@cisco.com> [media] media: v4l2-core: remove the use of V4L2_FL_USE_FH_PRIO flag

Since all the drivers that use `struct v4l2_fh' use the core priority
checking instead of doing it themselves, this flag can be removed.

This patch removes the usage of the flag from v4l2-core.

Signed-off-by: Ramakrishnan Muthukrishnan <ramakrmu@cisco.com>
Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
a112fbaf782f08cc837ee6bbd10ca8900d0e4b91 09-May-2014 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl: drop spurious newline in string

The message logged by v4l_print_cropcap should be a single line withouti
linebreaks, just like all the other v4l_print_<ioctl> functions.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
ba2d35c14b6fc554547cf647bedb71cd9ead3cab 17-Mar-2014 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl.c: fix sparse __user-related warnings

Fix the use of __user in the check_array_args() prototype: instead of
using 'void * __user *' you should use 'void __user **' for sparse to
understand this correctly.

This also required the use of __force in the '*kernel_ptr = user_ptr'
assignment.

Also replace a wrong cast (void *) with the correct one (void **)
in check_array_args().

This fixes these sparse warnings:

drivers/media/v4l2-core/v4l2-ioctl.c:2284:35: warning: incorrect type in assignment (different address spaces)
drivers/media/v4l2-core/v4l2-ioctl.c:2301:35: warning: incorrect type in assignment (different address spaces)
drivers/media/v4l2-core/v4l2-ioctl.c:2319:35: warning: incorrect type in assignment (different address spaces)
drivers/media/v4l2-core/v4l2-ioctl.c:2386:57: warning: incorrect type in argument 4 (different address spaces)
drivers/media/v4l2-core/v4l2-ioctl.c:2420:29: warning: incorrect type in assignment (different address spaces)

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
87185c958de9cd4acd8392f00d6161f4e11807ff 10-Mar-2014 Antti Palosaari <crope@iki.fi> [media] v4l: rename v4l2_format_sdr to v4l2_sdr_format

Rename v4l2_format_sdr to v4l2_sdr_format in order to keep it in
line with other formats.

Reported-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
dd519bb34a09d86db720f8a65e7dee1a85b2e90f 07-Mar-2014 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2: add VIDIOC_G/S_EDID support to the v4l2 core

Support this ioctl as part of the v4l2 core. Use the new ioctl
name and struct v4l2_edid type in the existing core code.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
582c52cb9cd2616ab0d41127b22ad56ee49d40b4 12-Dec-2013 Antti Palosaari <crope@iki.fi> [media] v4l: enable some IOCTLs for SDR receiver

Enable stream format (FMT) IOCTLs for SDR use. These are used for negotiate
used data stream format.

Reorganise some some IOCTL selection logic.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
6f3073b8dcdcf7a0eabbdd60ec3706bb9d4a131c 12-Dec-2013 Antti Palosaari <crope@iki.fi> [media] v4l: add stream format for SDR receiver

Add new V4L2 stream format definition, V4L2_BUF_TYPE_SDR_CAPTURE,
for SDR receiver.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
84099a282e1ba0facf7eee5108031a8f38f4b4fe 12-Dec-2013 Antti Palosaari <crope@iki.fi> [media] v4l: add new tuner types for SDR

Define tuner types V4L2_TUNER_ADC and V4L2_TUNER_RF for SDR usage.

ADC is used for setting sampling rate (sampling frequency) to SDR
device.

Another tuner type, named as V4L2_TUNER_RF, is possible RF tuner.
Is is used to down-convert RF frequency to range ADC could sample.
Having RF tuner is optional, whilst in practice it is almost always
there.

Also add checks to VIDIOC_G_FREQUENCY, VIDIOC_S_FREQUENCY and
VIDIOC_ENUM_FREQ_BANDS only allow these two tuner types when device
type is SDR (VFL_TYPE_SDR). For VIDIOC_G_FREQUENCY we do not check
tuner type, instead override type with V4L2_TUNER_ADC in every
case (requested by Hans in order to keep functionality in line with
existing tuners and existing API does not specify it).

Prohibit VIDIOC_S_HW_FREQ_SEEK explicitly when device type is SDR,
as device cannot do hardware seek without a hardware demodulator.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
aa32f4c0bcce7dac55bf2639f4a6cf37c5c96934 16-Dec-2013 Hans Verkuil <hverkuil@xs4all.nl> [media] v4l2: move tracepoints to video_usercopy

The (d)qbuf ioctls were traced in the low-level v4l2 ioctl function. The
trace was outside the serialization lock, so that can affect the usefulness
of the timing. In addition, the __user pointer was expected instead of a
proper kernel pointer.

By moving the tracepoints to video_usercopy we ensure that the trace calls
use the correct kernel pointer, and that it happens right after the ioctl
call to the driver, so certainly inside the serialization lock.

In addition, we only trace if the call was successful.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Wade Farnsworth <wade_farnsworth@mentor.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
1c1d86a1ea07506c070cfb217a009d53990bdeb0 12-Jun-2013 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2: always require v4l2_dev, rename parent to dev_parent

The last set of drivers still using the parent field of video_device instead
of the v4l2_dev field have been converted, so v4l2_dev is now always set.
A proper pointer to v4l2_dev is necessary these days otherwise the advanced
debugging ioctls will not work when addressing sub-devices. It also ensures
that the core can always go from a video_device struct to the top-level
v4l2_device struct.
There is still one single use case for the parent pointer: if there are
multiple busses, each being the parent of one or more video nodes, and if
they all share the same v4l2_device struct. In that case one still needs a
parent pointer since the v4l2_device struct can only refer to a single
parent device. The cx88 driver is one such case. Unfortunately, the cx88
failed to set the parent pointer since 3.6. The next patch will correct this.
In order to support this use-case the parent pointer is only renamed to
dev_parent, not removed altogether. It has been renamed to ensure that the
compiler will catch any (possibly out-of-tree) drivers that were missed during
the conversion.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
b71c99801e18eb172ae34851daf25044a3bf644a 26-May-2013 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-core: remove support for obsolete VIDIOC_DBG_G_CHIP_IDENT

This has been replaced by the new and much better VIDIOC_DBG_G_CHIP_INFO.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
1a2c6866e35058c8808af37659e0f344f7f79381 29-May-2013 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl: clarify querystd comment

Improve the querystd comment.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
ca37157506ef53dcf41132aaedab70659509ccee 03-Jun-2013 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2: remove deprecated current_norm support completely

The use of current_norm to keep track of the current standard has been
deprecated for quite some time. Now that all drivers that were using it
have been converted to use g_std we can drop it from the core.
It was a bad idea to introduce this at the time: since it is a per-device
node field it didn't work for drivers that create multiple nodes, all sharing
the same tuner (e.g. video and vbi nodes, or a raw video node and a compressed
video node). In addition it was very surprising behavior that g_std was
implemented in the core. Often drivers implemented both g_std and current_norm,
because they didn't understand how it should be used.
Since the benefits were very limited (if they were there at all), it is better
to just drop it and require that drivers just implement g_std.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
191b79b0883cb0e604ba63fb3f85cf50ecfc9dc3 29-May-2013 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl: dbg_g/s_register: only match BRIDGE and SUBDEV types

Drop support for V4L2_CHIP_MATCH_I2C_DRIVER/ADDR and V4L2_CHIP_MATCH_AC97
types. The following patches will remove support for those in the drivers
as well.
This means that bridge drivers no longer have to check for the match.type
field in their g/s_register implementations. Only if they also implement
g_chip_info do they still have to check the match.addr field, otherwise the
core will check for that as well.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
560dde24adfdc9dbcd141c75faecc5e0402fe531 03-Jun-2013 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl: don't print the clips list

The clips pointer is a userspace pointer, not a kernelspace pointer,
so you can't dereference the clips pointer.
Also add a few missing commas and newlines.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
96b03d2a3078d5e95a8b106634faa7cea88ebe5e 06-Apr-2013 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2: rename VIDIOC_DBG_G_CHIP_NAME to _CHIP_INFO

This ioctl will be extended to return more information than just the name.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
0f0fe4b9f6f32b90c82345b97da2977b84e14414 06-Apr-2013 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl: fill in name before calling vidioc_g_chip_name

That way drivers do not need to fill in the name themselves for bridge address 0.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
3eef25107cab65a1158b11ba373fb9b4fc25b4b8 03-Apr-2013 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2: drop V4L2_CHIP_MATCH_SUBDEV_NAME

After using the new VIDIOC_DBG_G_CHIP_NAME ioctl I realized that the matching
by name possibility is useless. Just drop it and rename MATCH_SUBDEV_IDX to
just MATCH_SUBDEV.
The v4l2-dbg utility is much better placed to match by name by just enumerating
all bridge and subdev devices until chip_name.name matches.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
cd634f1bfc182e564f33809fdca33027bb99fceb 27-Mar-2013 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2: put VIDIOC_DBG_G_CHIP_NAME under ADV_DEBUG

Only enable this ioctl if the VIDEO_ADV_DEBUG config option is set. This
prevents abuse from both userspace and kernelspace (some bridge drivers
abuse DBG_G_CHIP_IDENT, lets prevent that from happening again with this
ioctl).

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
79b0c6400517456935f84f8d46c8bb0cf73f1813 18-Mar-2013 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2: add new VIDIOC_DBG_G_CHIP_NAME ioctl

Simplify the debugging ioctls by creating the VIDIOC_DBG_G_CHIP_NAME ioctl.
This will eventually replace VIDIOC_DBG_G_CHIP_IDENT. Chip matching is done
by the name or index of subdevices or an index to a bridge chip. Most of this
can all be done automatically, so most drivers just need to provide get/set
register ops.
In particular, it is now possible to get/set subdev registers without
requiring assistance of the bridge driver.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
02fa628217e995bd7b1fe8c1b7cc7a510f6b8349 15-Feb-2013 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2 core: remove the obsolete dv_preset support

These ioctls are no longer used by any drivers, so remove them.

[mchehab@redhat.com: Fix merge conflict]
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
73f35418a1e921443b5c9f4c58ae70df8b9d1bb6 10-Mar-2013 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl: check if an ioctl is valid

Just checking if the op exists isn't correct, you should check if the ioctl
is valid (which implies that the op exists as well).
One exception is g_std: if current_norm is non-zero, then the g_std op may be
absent. This sort of weird behavior is one of the reasons why I am trying to
get rid of current_norm.
This patch fixes the case where the g/s_std op is set, but these ioctls are
disabled. This can happen in drivers supporting multiple models, some that
have TV input (and support the STD API) and some that have a sensor (and do
not support the STD API). In the latter case qv4l2 would still show the
Standards combobox.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
505d04bdc43a6a6c828835e90ab5fcb380d631d5 14-Mar-2013 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl: simplify debug code

The core debug code can now be simplified since all the write-only ioctls are
now const and will not modify the data they pass to the drivers.
So instead of logging write-only ioctls before the driver is called this can
now be done afterwards, which is cleaner when it comes to error reporting as
well.
This also fixes a logic error in the debugging code where there was one 'else'
too many.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
977ba3b1b73f24fae2d0c8bd59d7a4696f1e0ccc 24-Mar-2013 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2: add const to argument of write-only s_register ioctl

This ioctl is defined as IOW, so pass the argument as const.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
27d5a87cf4b44cbcbd0f4706a433e4a68d496236 18-Mar-2013 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl: add precision when printing names

Never print more than the size of the buffer containing the name.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
314527acbbb3f33f72c2ef19d8cfabcada9912a5 15-Mar-2013 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2: pass std by value to the write-only s_std ioctl

This ioctl is defined as IOW, so pass the argument by value instead of by
reference. I could have chosen to add const instead, but this is 1) easier
to handle in drivers and 2) consistent with the s_std subdev operation.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Jonathan Corbet <corbet@lwn.net>
Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
b530a447bb588fdf43fdf4eb909e4ee1921d47ac 19-Mar-2013 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2: add const to argument of write-only s_frequency ioctl

This ioctl is defined as IOW, so pass the argument as const.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
b799d09a157da71566e8013a62073435550cab6d 14-Jun-2012 Tomasz Stanislawski <t.stanislaws@samsung.com> [media] v4l: add buffer exporting via dmabuf

This patch adds extension to V4L2 api. A new ioctl VIDIOC_EXPBUF is added. The
ioctl is used to export an mmap buffer as a DMABUF file descriptor.

Signed-off-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Tested-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
051c7788bcb92f2e98ef86e86651e0420765b121 14-Jun-2012 Sumit Semwal <sumit.semwal@ti.com> [media] v4l: Add DMABUF as a memory type

Adds DMABUF memory type to v4l framework. Also adds the related file
descriptor in v4l2_plane and v4l2_buffer.
[original work in the PoC for buffer sharing]

Signed-off-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
Signed-off-by: Sumit Semwal <sumit.semwal@ti.com>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Tested-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
d92462401dde1effa04a51d0a15000e6246d2a43 02-Oct-2012 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl: fix W=1 warnings

Since the prt_names() macro is always called with an unsigned index the
((a) >= 0) condition is always true and gives a compiler warning when
compiling with W=1.
Rewrite the macro to avoid that warning, but cast the index to unsigned
just in case it is ever called with a signed argument.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
1b8b10cc7e6bd9bf017c58e32b1e7f632e23850d 02-Oct-2012 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl: add blocks check for VIDIOC_SUBDEV_G/S_EDID

The maximum size of an EDID is 32768 bytes, which is 32768 / 128 = 256 blocks.
Return -EINVAL if blocks > 256 to ensure that the memory allocation is sane.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
96b1a70226cd43f69c63a7ba2a769bece08cf64e 19-Sep-2012 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl.c: handle PREPARE_BUF like QUERYBUF

The core code for PREPARE_BUF didn't take the multiplanar case into account,
which might cause page faults. Handle PREPARE_BUF just like QUERYBUF and
QBUF/DQBUF.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
737c097b9aed92906b4bb9f90f05eb4d5696f572 04-Sep-2012 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-ioctl.c: fix overlay support

The vidioc_overlay op needs an unsigned int, not an unsigned int pointer.
So we need a small function that dereferences the unsigned int pointer.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
4b20259fa642d6f7a2dabef0b3adc14ca9dadbde 14-Sep-2012 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-dev: improve ioctl validity checks

The ioctl validity checks have been improved and now take vfl_type
and vfl_dir into account.
During the 2012 Media Workshop it was decided that these improved
v4l2 core checks should be added as they simplified drivers and
made drivers behave consistently.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
1c4f3c987f44a6653ac49f93d8cbd3adb539be10 03-Sep-2012 Hans Verkuil <hans.verkuil@cisco.com> [media] Rename V4L2_(IN|OUT)_CAP_CUSTOM_TIMINGS

The 'custom' timings are no longer just for custom timings, but also for standard
CEA/VESA timings. So rename to V4L2_IN/OUT_CAP_DV_TIMINGS.
The old define is still kept for backwards compatibility.
This decision was taken during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
a5338190efc7cfa8c99a6856342a77d21c9a05cf 14-Sep-2012 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-core: tvnorms may be 0 for a given input, handle that case

Currently the core code looks at tvnorms to see whether ENUMSTD
or G_PARM should be enabled. This is not a good check for drivers
that support the STD API on one input and the DV Timings API on another.
In that case tvnorms may be 0.
Instead check whether s_std is present (for ENUMSTD) or whether g_std or
current_norm is present for g_parm.
Also, in the enumstd core function return ENODATA if tvnorms is 0,
because in that case the current input does not support the STD API
and ENUMSTD should return ENODATA for that.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
633c98e52a64ac8548b5d27dca1497cd4f0a6d4c 17-Sep-2012 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-core: deprecate V4L2_BUF_TYPE_PRIVATE

This buffer type isn't used at all, and since it is effectively undefined
what it should do it is deprecated. The define still exists, but any
internal support for such buffers is removed.
The decisions to deprecate this was taken during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
ed45ce2cc0b31cb442685934b627916f83d1d7c6 10-Aug-2012 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2-subdev: add support for the new edid ioctls

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
5bc3cb743bbab408792c1b4ef31adf6268aa4b7e 14-Jun-2012 Mauro Carvalho Chehab <mchehab@redhat.com> [media] v4l: move v4l2 core into a separate directory

Currently, the v4l2 core is mixed together with other non-core drivers.
Move them into a separate directory.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>