summaryrefslogtreecommitdiff
path: root/drivers/media/video/v4l2-ioctl.c
AgeCommit message (Collapse)Author
2012-08-14[media] v4l: move v4l2 core into a separate directoryMauro Carvalho Chehab
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>
2012-07-31[media] Use a named union in struct v4l2_ioctl_infoHans Verkuil
Hi Mauro, struct v4l2_ioctl_info uses an anonymous union, which is initialized in the v4l2_ioctls table. Unfortunately gcc < 4.6 uses a non-standard syntax for that, so trying to compile v4l2-ioctl.c with an older gcc will fail. It is possible to work around this by testing the gcc version, but in this case it is easier to make the union named since it is used in only a few places. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Reported-by: Randy Dunlap <rdunlap@xenotime.net> Acked-by: Randy Dunlap <rdunlap@xenotime.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-30[media] v4l2: add core support for the new VIDIOC_ENUM_FREQ_BANDS ioctlHans Verkuil
This adds the usual core support code for this new ioctl. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-30[media] v4l2-ioctl.c: zero the v4l2_dv_timings_cap structHans Verkuil
Zero all fields after the first type field. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Cc: stable@kernel.org Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-30[media] v4l2-ioctl: Don't assume file->private_data always points to a v4l2_fhHans Verkuil
Commit efbceecd4522a41b8442c6b4f68b4508d57d1ccf, adds a number of helper functions for ctrl related ioctls to v4l2-ioctl.c, these helpers assume that if file->private_data != NULL, it points to a v4l2_fh, which is only the case for drivers which actually use v4l2_fh. This breaks for example bttv which use the "filedata" pointer for its own uses, and now all the ctrl ioctls try to use whatever its filedata points to as v4l2_fh and think it has a ctrl_handler, leading to: [ 142.499214] BUG: unable to handle kernel NULL pointer dereference at 0000000000000021 [ 142.499270] IP: [<ffffffffa01cb959>] v4l2_queryctrl+0x29/0x230 [videodev] [ 142.514649] [<ffffffffa01c7a77>] v4l_queryctrl+0x47/0x90 [videodev] [ 142.517417] [<ffffffffa01c58b1>] __video_do_ioctl+0x2c1/0x420 [videodev] [ 142.520116] [<ffffffffa01c7ee6>] video_usercopy+0x1a6/0x470 [videodev] ... This patch adds the missing test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) tests to the ctrl ioctl helpers v4l2_fh paths, fixing the issues with for example the bttv driver. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-30[media] Fix VIDIOC_TRY_EXT_CTRLS regressionHans Verkuil
Fixes an omission in the new v4l2_ioctls table: VIDIOC_TRY_EXT_CTRLS must get the INFO_FL_CTRL flag, just like all the other control related ioctls, otherwise the ioctl core won't know it also has to check whether v4l2_fh->ctrl_handler is non-zero before it can decide that this ioctl is not implemented. Caught by v4l2-compliance while I was testing the mem2mem_testdev driver. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-06[media] v4l2-dev/ioctl.c: add vb2_queue support to video_deviceHans Verkuil
This prepares struct video_device for easier integration with vb2. It also introduces a new lock that protects the vb2_queue. It is up to the driver to use it or not. And the driver can associate an owner filehandle with the queue to check whether queuing requests are permitted for the calling filehandle. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-06[media] v4l2-ioctl: remove v4l_(i2c_)print_ioctlHans Verkuil
v4l_i2c_print_ioctl wasn't used and v4l_print_ioctl could be replaced by v4l_printk_ioctl. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-06[media] v4l2-dev.c: add debug sysfs entryHans Verkuil
Since this could theoretically change the debug value while in the middle of v4l2-ioctl.c, we make a copy of vfd->debug to ensure consistent debug behavior. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-06[media] v4l2-ioctl.c: finalize table conversionHans Verkuil
Implement the default case which finalizes the table conversion and allows us to remove the last part of the switch. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-06[media] v4l2-ioctl.c: use the new table for the remaining ioctlsHans Verkuil
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-06[media] v4l2-ioctl.c: use the new table for preset/timings ioctlsHans Verkuil
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-06[media] v4l2-ioctl.c: use the new table for debug ioctlsHans Verkuil
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-06[media] v4l2-ioctl.c: use the new table for compression ioctlsHans Verkuil
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-06[media] v4l2-ioctl.c: use the new table for selection ioctlsHans Verkuil
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-06[media] v4l2-ioctl.c: use the new table for control ioctlsHans Verkuil
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-06[media] v4l2-ioctl.c: use the new table for queuing/parm ioctlsHans Verkuil
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-06[media] v4l2-ioctl.c: use the new table for std/tuner/modulator ioctlsHans Verkuil
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-06[media] v4l2-ioctl.c: use the new table for overlay/streamon/off ioctlsHans Verkuil
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-06[media] v4l2-ioctl.c: use the new table for format/framebuffer ioctlsHans Verkuil
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-06[media] v4l2-ioctl.c: use the new table for priority ioctlsHans Verkuil
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-06[media] v4l2-ioctl.c: use the new table for querycap and i/o ioctlsHans Verkuil
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-06[media] v4l2-ioctl.c: remove an unnecessary #ifdefHans Verkuil
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-06[media] v4l2-ioctl.c: v4l2-ioctl: add debug and callback/offset functionalityHans Verkuil
Add the necessary plumbing to make it possible to replace the switch by a table driven implementation. The ioctls ops can either be called directly, or by calling a small function that does some additional work if needed. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-06[media] v4l2-ioctl.c: introduce INFO_FL_CLEAR to replace switchHans Verkuil
The switch statement that determines how much data should be copied from userspace is replaced by a table lookup. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-06[media] v4l2-ioctl.c: move a block of code down, no other changesHans Verkuil
A block of code is moved down in the code to make later changes easier. Do just the move without other changes to keep the diff readable for the upcoming patch. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-06-11[media] v4l2-ioctl: set readbuffers to 2 in g_parmHans Verkuil
If g_parm is handled automatically, then set readbuffers to 2, which is the minimum number of buffers videobuf uses. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-05-20[media] v4l2 framework: add support for the new dv_timings ioctlsHans Verkuil
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Reviewed-by: Mauro Carvalho Chehab <mchehab@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-05-14[media] v4l2-ioctl: handle priority handling based on a table lookupHans Verkuil
Rather than checking the priority for each ioctl that needs to, just mark such ioctls in the table and do it only once. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-05-14[media] v4l2-dev/ioctl: determine the valid ioctls upfrontHans Verkuil
Rather than testing whether an ioctl is implemented in the driver or not every time the ioctl is called, do it upfront when the device is registered. This also allows a driver to disable certain ioctls based on the capabilities of the detected board, something you can't do today without creating separate v4l2_ioctl_ops structs for each new variation. For the most part it is pretty straightforward, but for control ioctls a flag is needed since it is possible that you have per-filehandle controls, and that can't be determined upfront of course. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-05-14[media] v4l2-dev: make it possible to skip locking for selected ioctlsHans Verkuil
Using the V4L2 core lock is a very robust method that is usually very good at doing the right thing. But some drivers, particularly USB drivers, may want to prevent the core from taking the lock for specific ioctls, particularly buffer queuing ioctls. The reason is that certain commands like S_CTRL can take a long time to process over USB and all the time the core has the lock, preventing VIDIOC_DQBUF from proceeding, even though a frame may be ready in the queue. This introduces unwanted latency. Since the buffer queuing commands often have their own internal lock it is often not necessary to take the core lock. Drivers can now say that they don't want the core to take the lock for specific ioctls. As it is a specific opt-out it makes it clear to the reviewer that those ioctls will need more care when reviewing. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-03-20[media] -EINVAL -> -ENOTTYHans Verkuil
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>
2012-02-14[media] v4l2: standardize log start/end messageHans Verkuil
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>
2012-02-14[media] v4l2: add VIDIOC_(TRY_)DECODER_CMDHans Verkuil
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>
2012-01-23[media] V4L2: Add per-device-node capabilitiesHans Verkuil
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>
2012-01-16[media] v4l2-ioctl: make tuner 'type' check more strict for S_FREQUENCYHans Verkuil
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>
2012-01-11[media] v4l: emulate old crop API using extended crop/compose APITomasz Stanislawski
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>
2012-01-11[media] v4l: add support for selection apiTomasz Stanislawski
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>
2012-01-07[media] V4L/DVB: v4l2-ioctl: integer overflow in video_usercopy()Dan Carpenter
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>
2011-11-03[media] V4L: add two new ioctl()s for multi-size videobuffer managementGuennadi Liakhovetski
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>
2011-10-08[media] v4l2-ioctl: Fill the default value for VIDIOC_QUERYSTDMauro Carvalho Chehab
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>
2011-09-06[media] media: v4l: remove single to multiplane conversionTomasz Stanislawski
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>
2011-09-06[media] v4l2-ioctl: more -ENOTTY fixesHans Verkuil
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>
2011-07-31v4l2-ioctl: properly return -EINVAL when parameters are wrongMauro Carvalho Chehab
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>
2011-07-27[media] v4l2 core: return -ENOTTY if an ioctl doesn't existMauro Carvalho Chehab
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>
2011-07-27[media] v4l2-ctrls: add v4l2_fh pointer to the set control functionsHans Verkuil
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>
2011-07-27[media] v4l2-ioctl: add ctrl_handler to v4l2_fhHans Verkuil
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>
2011-07-27[media] v4l2-ioctl: Add a default value for kernel versionMauro Carvalho Chehab
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>
2011-07-27[media] Fix compile warning: Dereferencing type-punned pointer will break ↵Hans Petter Selasky
strict-aliasing rules Signed-off-by: Hans Petter Selasky <hselasky@c2i.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-07-07[media] v4l2-ioctl.c: check for valid tuner type in S_HW_FREQ_SEEKHans Verkuil
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>