summaryrefslogtreecommitdiffstats
path: root/drivers/media/v4l2-core
Commit message (Collapse)AuthorAgeFilesLines
...
| * | [media] v4l: vb2: Add fatal error condition flagLaurent Pinchart2014-07-171-3/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a fatal error occurs that render the device unusable, the only options for a driver to signal the error condition to userspace is to set the V4L2_BUF_FLAG_ERROR flag when dequeuing buffers and to return an error from the buffer prepare handler when queuing buffers. The buffer error flag indicates a transient error and can't be used by applications to detect fatal errors. Returning an error from vb2_qbuf() is thus the only real indication that a fatal error occurred. However, this is difficult to handle for multithreaded applications that requeue buffers from a thread other than the control thread. In particular the poll() call in the control thread will not notify userspace of the error. This patch adds an explicit mechanism to report fatal errors to userspace. Drivers can call the vb2_queue_error() function to signal a fatal error. From this moment on, buffer preparation will return -EIO to userspace, and vb2_poll() will set the POLLERR flag and return immediately. The error flag is cleared when cancelling the queue, either at stream off time (through vb2_streamoff) or when releasing the queue with vb2_queue_release(). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
| * | [media] v4l: vb2: Don't return POLLERR during transient buffer underrunsLaurent Pinchart2014-07-171-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The V4L2 specification states that "When the application did not call VIDIOC_QBUF or VIDIOC_STREAMON yet the poll() function succeeds, but sets the POLLERR flag in the revents field." The vb2_poll() function sets POLLERR when the queued buffers list is empty, regardless of whether this is caused by the stream not being active yet, or by a transient buffer underrun. Bring the implementation in line with the specification by returning POLLERR if no buffer has been queued only when the queue is not streaming. Buffer underruns during streaming are not treated specially anymore and just result in poll() blocking until the next event. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Pawel Osciak <pawel@osciak.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
| * | [media] v4l: vb2: Fix stream start and buffer completion raceLaurent Pinchart2014-07-171-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | videobuf2 stores the driver streaming state internally in the queue in the start_streaming_called variable. The state is set right after the driver start_stream operation returns, and checked in the vb2_buffer_done() function, typically called from the frame completion interrupt handler. A race condition exists if the hardware finishes processing the first frame before the start_stream operation returns. Fix this by setting start_streaming_called to 1 before calling the start_stream operation, and resetting it to 0 if the operation fails. Cc: stable@vger.kernel.org # for v3.15 and up Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
| * | [media] v4l: Add premultiplied alpha flag for pixel formatsLaurent Pinchart2014-07-171-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | [media] v4l: Support extending the v4l2_pix_format structureLaurent Pinchart2014-07-172-9/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | [media] Fix 64-bit division fall-out from 64-bit control rangesHans Verkuil2014-07-171-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 0ba2aeb6dab80920edd9cf5b93b1ea4d6913b8f3 increased the internal control ranges to 64 bit, but that caused problems in drivers that use the minimum/maximum/step/default_value control values in a division or modulus operations since not all architectures support those natively. Luckily, in almost all cases it is possible to just cast to 32 bits (the control value is known to be 32 bits, so it is safe to cast). Only in v4l2-ctrls.c was it necessary to use do_div in one function. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
| * | [media] v4l2-ctrls/v4l2-controls.h: add MD controlsHans Verkuil2014-07-171-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | Add the 'Detect' control class and the new motion detection controls. Those controls will be used by the solo6x10 and go7007 drivers. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
| * | [media] v4l2-ctrls: fix commentsHans Verkuil2014-07-171-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Various comments referred to videodev2.h, but the control definitions have been moved to v4l2-controls.h. Also add the same reminder message to each class of controls. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
| * | [media] v4l2-ctrls/videodev2.h: add u8 and u16 typesHans Verkuil2014-07-171-4/+41
| | | | | | | | | | | | | | | | | | | | | | | | These are needed by the upcoming patches for the motion detection matrices. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
| * | [media] v4l2-ctrl: fix error return of copy_to/from_userHans Verkuil2014-07-171-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | copy_to/from_user returns the number of bytes not copied, it does not return a 'normal' linux error code. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
| * | [media] v4l2-ctrls: return elem_size instead of strlenHans Verkuil2014-07-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When getting a string and the size given by the application is too short return the max length the string can have (elem_size) instead of the string length + 1. That makes more sense. 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>
| * | [media] v4l2-ctrls: add array supportHans Verkuil2014-07-171-46/+63
| | | | | | | | | | | | | | | | | | | | | Finish the userspace-facing array support. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
| * | [media] v4l2-ctrls: type_ops can handle array elementsHans Verkuil2014-07-171-18/+22
| | | | | | | | | | | | | | | | | | | | | Extend the control type operations to handle N-dimensional array elements. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
| * | [media] v4l2-ctrls: prepare for array supportHans Verkuil2014-07-171-19/+39
| | | | | | | | | | | | | | | | | | | | | Add core support for N-dimensional arrays. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
| * | [media] v4l2-ctrls: prepare for array supportHans Verkuil2014-07-171-9/+24
| | | | | | | | | | | | | | | | | | | | | | | | Add dims, nr_of_dims and elems fields to the core control structures in preparation for N-dimensional array support. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
| * | [media] v4l2-ctrls: use ptrs for all but the s32 typeHans Verkuil2014-07-171-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than having two unions for all types just keep 'val' and 'cur.val' and use the p_cur and p_new unions to access all others. The only reason for keeping 'val' and 'cur.val' is that it is used all over, so converting this as well would be a huge job. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
| * | [media] v4l2-ctrls: compare values only onceHans Verkuil2014-07-171-6/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When setting a control the control's new value is compared to the current value twice: once by new_to_cur(), once by cluster_changed(). Not a big deal when dealing with simple values, but it can be a problem when dealing with compound types or arrays. So fix this: cluster_changed() sets the has_changed flag, which is used by new_to_cur() instead of having to do another compare. 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>
| * | [media] v4l2-ctrls: rewrite copy routines to operate on union v4l2_ctrl_ptrHans Verkuil2014-07-171-73/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to implement array support and (for the future) configuration stores we need to have more generic copy routines that all operate on the v4l2_ctrl_ptr union. So instead of e.g. using ctrl->cur.string it uses ptr.p_char. This makes e.g. cur_to_user generic so it can be used to copy any v4l2_ctrl_ptr value to userspace, not just the (hardcoded) current value. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
| * | [media] v4l2-ctrls: create type_opsHans Verkuil2014-07-172-103/+175
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | [media] v4l2: integrate support for VIDIOC_QUERY_EXT_CTRLHans Verkuil2014-07-173-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | [media] v4l2-ctrls: add support for compound typesHans Verkuil2014-07-171-56/+168
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements initial support for compound types. The changes are fairly obvious: basic support for is_ptr types, the type_is_int function is replaced by a is_int bitfield, and v4l2_query_ext_ctrl is added. Note that this patch does not yet add support for N-dimensional arrays, that comes later. So v4l2_query_ext_ctrl just sets elems to 1 and nr_of_dims and dims[] are all zero. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
| * | [media] v4l2-ctrls: use pr_info/cont instead of printkHans Verkuil2014-07-171-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | Codingstyle fix. 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>
| * | [media] v4l2-ctrls: increase internal min/max/step/def to 64 bitHans Verkuil2014-07-172-37/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While VIDIOC_QUERYCTRL is limited to 32 bit min/max/step/def values for controls, the upcoming VIDIOC_QUERY_EXT_CTRL isn't. So increase the internal representation to 64 bits in preparation. Because of these changes the msi3101 driver has been modified slightly to fix a formatting issue (%d becomes %lld), vivi had to be modified as well to cope with the new 64-bit min/max values and the PIXEL_RATE control in a few sensor drivers required proper min/max/def values. 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>
| * | [media] media: v4l2-core: remove the use of V4L2_FL_USE_FH_PRIO flagRamakrishnan Muthukrishnan2014-07-043-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | [media] videobuf2-dma-contig: allow to vmap contiguous dma buffersPhilipp Zabel2014-07-041-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows drivers to vmap contiguous dma buffers so they can inspect the buffer contents with the CPU. This will be needed for the CODA driver's JPEG handling. On CODA960, the header parsing has to be done on the CPU. The hardware modules can only process the entropy coded segment after all registers and tables are set up. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
| * | [media] mem2mem: make queue lock in v4l2_m2m_poll interruptiblePhilipp Zabel2014-07-041-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | This patch makes the queue lock taken in v4l2_m2m_poll interruptible. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* | | Merge tag 'driver-core-3.17-rc1' of ↵Linus Torvalds2014-08-041-1/+1
|\ \ \ | |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core Pull driver core updates from Greg KH: "Here's the big driver-core pull request for 3.17-rc1. Largest thing in here is the dma-buf rework and fence code, that touched many different subsystems so it was agreed it should go through this tree to handle merge issues. There's also some firmware loading updates, as well as tests added, and a few other tiny changes, the changelog has the details. All have been in linux-next for a long time" * tag 'driver-core-3.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (32 commits) ARM: imx: Remove references to platform_bus in mxc code firmware loader: Fix _request_firmware_load() return val for fw load abort platform: Remove most references to platform_bus device test: add firmware_class loader test doc: fix minor typos in firmware_class README staging: android: Cleanup style issues Documentation: devres: Sort managed interfaces Documentation: devres: Add devm_kmalloc() et al fs: debugfs: remove trailing whitespace kernfs: kernel-doc warning fix debugfs: Fix corrupted loop in debugfs_remove_recursive stable_kernel_rules: Add pointer to netdev-FAQ for network patches driver core: platform: add device binding path 'driver_override' driver core/platform: remove unused implicit padding in platform_object firmware loader: inform direct failure when udev loader is disabled firmware: replace ALIGN(PAGE_SIZE) by PAGE_ALIGN firmware: read firmware size using i_size_read() firmware loader: allow disabling of udev as firmware loader reservation: add suppport for read-only access using rcu reservation: update api and add some helpers ... Conflicts: drivers/base/platform.c
| * | dma-buf: use reservation objectsMaarten Lankhorst2014-07-081-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | This allows reservation objects to be used in dma-buf. it's required for implementing polling support on the fences that belong to a dma-buf. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com> Acked-by: Mauro Carvalho Chehab <m.chehab@samsung.com> #drivers/media/v4l2-core/ Acked-by: Thomas Hellstrom <thellstrom@vmware.com> #drivers/gpu/drm/ttm Acked-by: Sumit Semwal <sumit.semwal@linaro.org> Acked-by: Daniel Vetter <daniel@ffwll.ch> Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net> #drivers/gpu/drm/armada/ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | Merge branch 'v4l_for_linus' of ↵Linus Torvalds2014-07-211-2/+2
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media Pull media fixes from Mauro Carvalho Chehab: "A series of driver fixes: - fix DVB-S tuning with tda1071 - fix tuner probe on af9035 when the device has a bad eeprom - some fixes for the new si2168/2157 drivers - one Kconfig build fix (for omap4iss) - fixes at vpif error path - don't lock saa7134 ioctl at driver's base core level, as it now uses V4L2 and VB2 locking schema - fix audio at hdpvr driver - fix the aspect ratio at the digital timings table - one new USB ID (at gspca_pac7302): Genius i-Look 317 webcam" * 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: [media] gspca_pac7302: Add new usb-id for Genius i-Look 317 [media] tda10071: fix returned symbol rate calculation [media] tda10071: fix spec inversion reporting [media] tda10071: add missing DVB-S2/PSK-8 FEC AUTO [media] tda10071: force modulation to QPSK on DVB-S [media] hdpvr: fix two audio bugs [media] davinci: vpif: missing unlocks on error [media] af9035: override tuner id when bad value set into eeprom [media] saa7134: use unlocked_ioctl instead of ioctl [media] media: v4l2-core: v4l2-dv-timings.c: Cleaning up code wrong value used in aspect ratio [media] si2168: firmware download fix [media] si2157: add one missing parenthesis [media] si2168: add one missing parenthesis [media] staging: tighten omap4iss dependencies
| * [media] media: v4l2-core: v4l2-dv-timings.c: Cleaning up code wrong value ↵Rickard Strandqvist2014-06-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | used in aspect ratio Wrong value used in same cases for the aspect ratio. Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Cc: stable@vger.kernel.org # for v3.12 and up Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* | Merge branch 'topic/omap3isp' of ↵Linus Torvalds2014-06-121-0/+24
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media Pull OMAP3 updates from Mauro Carvalho Chehab: "Some driver improvements on OMAP3. This series depend on some iommu patches already merged" * 'topic/omap3isp' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (26 commits) [media] omap3isp: Rename isp_buffer isp_addr field to dma [media] omap3isp: Move to videobuf2 [media] v4l: vb2: Add a function to discard all DONE buffers [media] omap3isp: Cancel all queued buffers when stopping the video stream [media] omap3isp: Move buffer irqlist to isp_buffer structure [media] omap3isp: Move queue irqlock to isp_video structure [media] omap3isp: Move queue mutex to isp_video structure [media] omap3isp: queue: Don't build scatterlist for kernel buffer [media] omap3isp: Use the ARM DMA IOMMU-aware operations [media] omap3isp: queue: Use sg_alloc_table_from_pages() [media] omap3isp: queue: Map PFNMAP buffers to device [media] omap3isp: queue: Fix the dma_map_sg() return value check [media] omap3isp: queue: Allocate kernel buffers with dma_alloc_coherent [media] omap3isp: queue: Inline the ispmmu_v(un)map functions [media] omap3isp: queue: Merge the prepare and sglist functions [media] omap3isp: queue: Use sg_table structure [media] omap3isp: queue: Move IOMMU handling code to the queue [media] omap3isp: video: Set the buffer bytesused field at completion time [media] omap3isp: ccdc: Use the DMA API for FPC [media] omap3isp: ccdc: Use the DMA API for LSC ...
| * [media] v4l: vb2: Add a function to discard all DONE buffersLaurent Pinchart2014-05-251-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When suspending a device while a video stream is active all buffers marked as done but not dequeued yet will be kept across suspend and given back to userspace after resume. This will result in outdated buffers being dequeued. Introduce a new vb2 function to mark all done buffers as erroneous instead, to be used by drivers at resume time. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* | [media] v4l: Validate fields in the core code for subdev EDID ioctlsLaurent Pinchart2014-05-251-4/+20
| | | | | | | | | | | | | | | | | | | | | | | | The subdev EDID ioctls receive a pad field that must reference an existing pad and an EDID field that must point to a buffer. Validate both fields in the core code instead of duplicating validation in all drivers. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* | [media] v4l: Add support for DV timings ioctls on subdev nodesLaurent Pinchart2014-05-251-0/+27
|/ | | | | | | | Validate the pad field in the core code whenever specified. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] v4l: subdev: Move [gs]_std operation to video opsLaurent Pinchart2014-05-241-1/+5
| | | | | | | | | | | | The g_std and s_std operations are video-related, move them to the video ops where they belong. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] videobuf2-core: remove duplicated codeVictor Lambret2014-05-241-4/+0
| | | | | | | | | Remove duplicated test of buffer presence at streamon Signed-off-by: Victor Lambret <victor.lambret.ext@parrot.com> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] v4l: Add source change eventArun Kumar K2014-05-231-0/+36
| | | | | | | | | | | | | | | | | This event indicates that the video device has encountered a source parameter change during runtime. This can typically be a resolution change detected by a video decoder OR a format change detected by an input connector. This needs to be nofified to the userspace and the application may be expected to reallocate buffers before proceeding. The application can subscribe to events on a specific pad or input port which it is interested in. Signed-off-by: Arun Kumar K <arun.kk@samsung.com> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] vb2: fix num_buffers calculation if req->count > VIDEO_MAX_FRAMESPhilipp Zabel2014-05-231-1/+1
| | | | | | | | | | | | | | | | | num_buffers can't be bigger than VIDEO_MAX_FRAME. This is assured by: num_buffers = min_t(unsigned int, req->count, VIDEO_MAX_FRAME); However, this value is overriden by: num_buffers = max_t(unsigned int, req->count, q->min_buffers_needed); It should, instead, use the previously calculated value as an input to max_t: num_buffers = max_t(unsigned int, num_buffers, q->min_buffers_needed); Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> 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>
* [media] v4l: vb2: Avoid double WARN_ON when stopping streamingLaurent Pinchart2014-05-231-3/+4
| | | | | | | | | | | | | | | | | The __vb2_queue_cancel function marks the queue as not streaming and then WARNs when buffers are still owned by the driver. It proceeds to complete all active buffers by calling vb2_buffer_done with the new buffer state set to VB2_BUF_STATE_ERROR in that case. This triggers another WARN_ON due to as new state not being VB2_BUF_STATE_QUEUED while the queue is not streaming. Check buffer ownership and complete all active buffers before marking the queue as not streaming to avoid the double WARN_on. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.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>
* [media] v4l2-ioctl: drop spurious newline in stringHans Verkuil2014-05-231-1/+1
| | | | | | | | 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>
* [media] videobuf-dma-contig: fix incorrect argument to vm_iomap_memory() callMa Haijun2014-05-231-1/+1
| | | | | | | | The second argument should be physical address rather than virtual address. Signed-off-by: Ma Haijun <mahaijuns@gmail.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] videobuf2-dma-sg: Fix NULL pointer dereference BUGRicardo Ribalda2014-05-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | vb2_get_vma() copy the content of the vma to a new structure but set some of its pointers to NULL. One of this pointer is used by follow_pte() called by follow_pfn() on io memory. This can lead to a NULL pointer derreference. The version of vma that has not been cleared must be used. [ 406.143320] BUG: unable to handle kernel NULL pointer dereference at 0000000000000040 [ 406.143427] IP: [<ffffffff8115204c>] follow_pfn+0x2c/0x70 [ 406.143491] PGD 6c3f0067 PUD 6c3ef067 PMD 0 [ 406.143546] Oops: 0000 [#1] SMP [ 406.143587] Modules linked in: qtec_mem qt5023_video qtec_testgen qtec_xform videobuf2_core gpio_xilinx videobuf2_vmalloc videobuf2_dma_sg qtec_cmosis videobuf2_memops qtec_pcie qtec_white fglrx(PO) qt5023 spi_xilinx spi_bitbang [ 406.143852] CPU: 0 PID: 299 Comm: tracker Tainted: P O 3.13.0-qtec-standard #10 [ 406.143927] Hardware name: QTechnology QT5022/QT5022, BIOS PM_2.1.0.309 X64 04/04/2013 [ 406.144000] task: ffff880085c82d60 ti: ffff880085abe000 task.ti: ffff880085abe000 [ 406.144067] RIP: 0010:[<ffffffff8115204c>] [<ffffffff8115204c>] follow_pfn+0x2c/0x70 [ 406.144145] RSP: 0018:ffff880085abf888 EFLAGS: 00010296 [ 406.144195] RAX: 0000000000000000 RBX: ffff880085abf8e0 RCX: ffff880085abf888 [ 406.144260] RDX: ffff880085abf890 RSI: 00007fc52e173000 RDI: ffff8800863cbe40 [ 406.144325] RBP: ffff880085abf8a8 R08: 0000000000000018 R09: ffff8800863cbf00 [ 406.144388] R10: ffff880086703b80 R11: 00000000000001e0 R12: 0000000000018000 [ 406.144452] R13: 0000000000000000 R14: ffffea0000000000 R15: ffff88015922fea0 [ 406.144517] FS: 00007fc536e7c740(0000) GS:ffff88015ec00000(0000) knlGS:0000000000000000 [ 406.144591] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 406.144644] CR2: 0000000000000040 CR3: 0000000066c9d000 CR4: 00000000000007f0 [ 406.144708] Stack: [ 406.144731] 0000000000018000 00007fc52e18b000 0000000000000000 00007fc52e173000 [ 406.144813] ffff880085abf918 ffffffffa083b2fd ffff880085ab1ba8 0000000000000000 [ 406.144894] 0000000000000000 0000000100000000 ffff880085abf928 ffff880159a20800 [ 406.144976] Call Trace: [ 406.145011] [<ffffffffa083b2fd>] vb2_dma_sg_get_userptr+0x14d/0x310 [videobuf2_dma_sg] [ 406.145089] [<ffffffffa08507df>] __qbuf_userptr+0xbf/0x3e0 [videobuf2_core] [ 406.147229] [<ffffffffa0041454>] ? mc_heap_lock_memory+0x1f4/0x490 [fglrx] [ 406.149234] [<ffffffff813428f3>] ? cpumask_next_and+0x23/0x50 [ 406.151223] [<ffffffff810b2e38>] ? enqueue_task_fair+0x658/0xde0 [ 406.153199] [<ffffffff81061888>] ? native_smp_send_reschedule+0x48/0x60 [ 406.155184] [<ffffffff815836b9>] ? get_ctrl+0xa9/0xd0 [ 406.157161] [<ffffffff8116f4e4>] ? __kmalloc+0x1a4/0x1b0 [ 406.159135] [<ffffffffa0850b9c>] ? __vb2_queue_alloc+0x9c/0x4a0 [videobuf2_core] [ 406.161130] [<ffffffffa0852d08>] __buf_prepare+0x1a8/0x210 [videobuf2_core] [ 406.163171] [<ffffffffa0854c57>] __vb2_qbuf+0x27/0xcc [videobuf2_core] [ 406.165229] [<ffffffffa0851dfd>] vb2_queue_or_prepare_buf+0x1ed/0x270 [videobuf2_core] [ 406.167325] [<ffffffffa0854c30>] ? vb2_ioctl_querybuf+0x30/0x30 [videobuf2_core] [ 406.169419] [<ffffffffa0851e9c>] vb2_qbuf+0x1c/0x20 [videobuf2_core] [ 406.171508] [<ffffffffa0851ef8>] vb2_ioctl_qbuf+0x58/0x70 [videobuf2_core] [ 406.173604] [<ffffffff8157d3a8>] v4l_qbuf+0x48/0x60 [ 406.175681] [<ffffffff8157b29c>] __video_do_ioctl+0x2bc/0x340 [ 406.177779] [<ffffffff8116f43c>] ? __kmalloc+0xfc/0x1b0 [ 406.179883] [<ffffffff8157cd0e>] ? video_usercopy+0x7e/0x470 [ 406.181961] [<ffffffff8157ce81>] video_usercopy+0x1f1/0x470 [ 406.184021] [<ffffffff8157afe0>] ? v4l_printk_ioctl+0xb0/0xb0 [ 406.186085] [<ffffffff810ae1ed>] ? account_system_time+0x8d/0x190 [ 406.188149] [<ffffffff8157d115>] video_ioctl2+0x15/0x20 [ 406.190216] [<ffffffff815781b3>] v4l2_ioctl+0x123/0x160 [ 406.192251] [<ffffffff810ce415>] ? rcu_eqs_enter+0x65/0xa0 [ 406.194256] [<ffffffff81186b28>] do_vfs_ioctl+0x88/0x560 [ 406.196258] [<ffffffff810ae145>] ? account_user_time+0x95/0xb0 [ 406.198262] [<ffffffff810ae6a4>] ? vtime_account_user+0x44/0x70 [ 406.200215] [<ffffffff81187091>] SyS_ioctl+0x91/0xb0 [ 406.202107] [<ffffffff817be109>] tracesys+0xd0/0xd5 [ 406.203946] Code: 66 66 66 90 48 f7 47 50 00 44 00 00 b8 ea ff ff ff 74 52 55 48 89 e5 53 48 89 d3 48 8d 4d e0 48 8d 55 e8 48 83 ec 18 48 8b 47 40 <48> 8b 78 40 e8 8b fe ff ff 85 c0 75 27 48 8b 55 e8 48 b9 00 f0 [ 406.208011] RIP [<ffffffff8115204c>] follow_pfn+0x2c/0x70 [ 406.209908] RSP <ffff880085abf888> [ 406.211760] CR2: 0000000000000040 [ 406.213676] ---[ end trace 996d9f64e6739a04 ]--- Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] V4L2: fix VIDIOC_CREATE_BUFS in 64- / 32-bit compatibility modeGuennadi Liakhovetski2014-05-131-5/+7
| | | | | | | | | | | | | | | | | | | | | | If a struct contains 64-bit fields, it is aligned on 64-bit boundaries within containing structs in 64-bit compilations. This is the case with struct v4l2_window, which contains pointers and is embedded into struct v4l2_format, and that one is embedded into struct v4l2_create_buffers. Unlike some other structs, used as a part of the kernel ABI as ioctl() arguments, that are packed, these structs aren't packed. This isn't a problem per se, but the ioctl-compat code for VIDIOC_CREATE_BUFS contains a bug, that triggers in such 64-bit builds. That code wrongly assumes, that in struct v4l2_create_buffers, struct v4l2_format immediately follows the __u32 memory field, which in fact isn't the case. This bug wasn't visible until now, because until recently hardly any applications used this ioctl() and mostly embedded 32-bit only drivers implemented it. This is changing now with addition of this ioctl() to some USB drivers, e.g. UVC. This patch fixes the bug by copying parts of struct v4l2_create_buffers separately. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] v4l: Only get module if it's different than the driver for v4l2_devSakari Ailus2014-05-131-3/+15
| | | | | | | | | | | When the sub-device is registered, increment the use count of the sub-device owner only if it's different from the owner of the driver for the media device. This avoids increasing the use count by the module itself and thus making it possible to unload it when it's not in use. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] v4l: Check pad arguments for [gs]_frame_intervalSakari Ailus2014-05-131-2/+14
| | | | | | | | | | VIDIOC_SUBDEV_[GS]_FRAME_INTERVAL IOCTLs argument structs contain the pad field but the validity check was missing. There should be no implications security-wise from this since no driver currently uses the pad field in the struct. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] vb2: fix compiler warningHans Verkuil2014-04-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When compiling this for older kernels using the compatibility build the compiler complains about uninitialized variables: In file included from include/linux/kernel.h:20:0, from include/linux/cache.h:4, from include/linux/time.h:7, from include/linux/input.h:13, from /home/hans/work/build/media_build/v4l/compat.h:9, from <command-line>:0: /home/hans/work/build/media_build/v4l/videobuf2-core.c: In function 'vb2_mmap': include/linux/dynamic_debug.h:60:9: warning: 'plane' may be used uninitialized in this function [-Wmaybe-uninitialized] printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \ ^ /home/hans/work/build/media_build/v4l/videobuf2-core.c:2381:23: note: 'plane' was declared here unsigned int buffer, plane; ^ In file included from include/linux/kernel.h:20:0, from include/linux/cache.h:4, from include/linux/time.h:7, from include/linux/input.h:13, from /home/hans/work/build/media_build/v4l/compat.h:9, from <command-line>:0: include/linux/dynamic_debug.h:60:9: warning: 'buffer' may be used uninitialized in this function [-Wmaybe-uninitialized] printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \ ^ /home/hans/work/build/media_build/v4l/videobuf2-core.c:2381:15: note: 'buffer' was declared here unsigned int buffer, plane; ^ While these warnings are bogus (the call to __find_plane_by_offset will set buffer and plane), it doesn't hurt to initialize these variables. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] vb2: stop_streaming should return voidHans Verkuil2014-04-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The vb2 core ignores any return code from the stop_streaming op. And there really isn't anything it can do anyway in case of an error. So change the return type to void and update any drivers that implement it. The int return gave drivers the idea that this operation could actually fail, but that's really not the case. The pwc amd sdr-msi3101 drivers both had this construction: if (mutex_lock_interruptible(&s->v4l2_lock)) return -ERESTARTSYS; This has been updated to just call mutex_lock(). The stop_streaming op expects this to really stop streaming and I very much doubt this will work reliably if stop_streaming just returns without really stopping the DMA. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Pawel Osciak <pawel@osciak.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] vb2: Add videobuf2-dvb supportHans Verkuil2014-04-163-0/+341
| | | | | | | | | With the new vb2_thread_start/stop core code it is very easy to implement videobuf2-dvb. This should simplify converting existing videobuf drivers to vb2. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] vb2: add thread supportHans Verkuil2014-04-161-0/+146
| | | | | | | | | | | | | In order to implement vb2 DVB support you need to be able to start a kernel thread that queues and dequeues buffers, calling a callback function for every buffer. This patch adds support for that. It's based on drivers/media/v4l2-core/videobuf-dvb.c, but with all the DVB specific stuff stripped out, thus making it much more generic. 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>
* [media] vb2: start messages with a lower-case for consistencyHans Verkuil2014-04-161-29/+29
| | | | | | | | | | | The kernel debug messages produced by vb2 started either with a lower or an upper case character. Switched all to use lower-case which seemed to be what was used in the majority of the messages. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Pawel Osciak <pawel@osciak.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
OpenPOWER on IntegriCloud