aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/v4l2-core (follow)
AgeCommit message (Collapse)AuthorFilesLines
2015-05-01[media] v4l2-dv-timings: fix rounding in hblank and hsync calculationPrashant Laddha1-4/+5
Changed the rounding calculation for hblank and hsync to match it to equations in cvt and gtf standards. In cvt calculation, hsync needs to be rounded down. In gtf calculations, hblank needs to be rounded to nearest multiple of twice the cell granularity and hsync needs to be rounded to the nearest multiple of cell granularity. Cc: Martin Bugge <marbugge@cisco.com> Signed-off-by: Prashant Laddha <prladdha@cisco.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-05-01[media] v4l2-dv-timings: fix rounding error in vsync_bp calculationPrashant Laddha1-3/+4
Changed the rounding offsets used in vsync_bp calculation in cvt and gtf timings. The results for vsync_bp should now match with results from timing generator spreadsheets for cvt and gtf standards. In the vsync_bp calculation for cvt, always round down the value of (CVT_MIN_VSYNC_BP / h_period_est) and then add 1. It thus, reflects the equation used in timing generator spreadsheet. Using 1999999 as rounding offset, could pontentially lead to bumping up the vsync_bp value by extra 1. In the vsync_bp calculations for gtf, instead of round up or round down, round the (CVT_MIN_VSYNC_BP / h_period_est) to the nearest integer. Thanks to Martin Bugge <marbugge@cisco.com> for validating with standards and suggestions on equations. Cc: Martin Bugge <marbugge@cisco.com> Signed-off-by: Prashant Laddha <prladdha@cisco.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-05-01[media] v4l: VIDEOBUF2_DMA_SG should depend on HAS_DMAGeert Uytterhoeven1-1/+1
If NO_DMA=y: ERROR: "dma_unmap_sg" [drivers/media/v4l2-core/videobuf2-dma-sg.ko] undefined! ERROR: "dma_map_sg" [drivers/media/v4l2-core/videobuf2-dma-sg.ko] undefined! ERROR: "dma_sync_sg_for_cpu" [drivers/media/v4l2-core/videobuf2-dma-sg.ko] undefined! VIDEOBUF2_DMA_SG cannot be enabled manually by the user, it's always selected automatically by drivers that need it. Several of those drivers already have an explicit dependency on HAS_DMA. Make VIDEOBUF2_DMA_SG depend on HAS_DMA. This makes it easier to find drivers that select VIDEOBUF2_DMA_SG without depending on HAS_DMA, as Kconfig will give a warning. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-05-01v4l2-ioctl: add a missing break at v4l_fill_fmtdesc()Mauro Carvalho Chehab1-1/+1
The changeset ba3002045f8022 added a logic at the core to fill the format description, however, a break is missing on one of the formats, as reported by smatch: drivers/media/v4l2-core/v4l2-ioctl.c:1211 v4l_fill_fmtdesc() warn: missing break? reassigning 'descr' Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-05-01[media] v4l2-ioctl: fill in the description for VIDIOC_ENUM_FMTHans Verkuil1-7/+192
The descriptions used in drivers for the formats returned with ENUM_FMT are all over the place. So instead allow the core to fill them in if the driver didn't. This allows drivers to drop the description and flags. Based on an earlier patch from Philipp Zabel: http://comments.gmane.org/gmane.linux.drivers.video-input-infrastructure/81411 Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-27[media] v4l: of: Parse variable length properties --- link-frequenciesSakari Ailus1-0/+87
The link-frequencies property is a variable length array of link frequencies in an endpoint. The array is needed by an increasing number of drivers, so it makes sense to add it to struct v4l2_of_endpoint. However, the length of the array is variable and the size of struct v4l2_of_endpoint is fixed since it is allocated by the caller. The options here are 1. to define a fixed maximum limit of link frequencies that has to be the global maximum of all boards. This is seen as problematic since the maximum could be largish, and everyone hitting the problem would need to submit a patch to fix it, or 2. parse the property in every driver. This doesn't sound appealing as two of the three implementations submitted to linux-media were wrong, and one of them was even merged before this was noticed, or 3. change the interface so that allocating and releasing memory according to the size of the array is possible. This is what the patch does. v4l2_of_alloc_parse_endpoint() is just like v4l2_of_parse_endpoint(), but it will allocate the memory resources needed to store struct v4l2_of_endpoint and the additional arrays pointed to by this struct. A corresponding release function v4l2_of_free_endpoint() is provided to release the memory allocated by v4l2_of_alloc_parse_endpoint(). In addition to this, the link-frequencies property is parsed as well, and the result is stored to struct v4l2_of_endpoint field link_frequencies. Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Tested-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-27[media] v4l: of: Instead of zeroing bus_type and bus field separately, unify thisSakari Ailus1-2/+3
Zero the entire struct starting from bus_type. As more fields are added, no changes will be needed in the function to reset their value explicitly. Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-24Merge tag 'dma-buf-for-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/sumits/dma-bufLinus Torvalds3-3/+21
Pull dma-buf updates from Sumit Semwal: "Minor cleanup only; this could've gone in for the 4.0 merge window, but for a copy-paste stupidity from me. It has been in the for-next since then, and no issues reported. - cleanup of dma_buf_export() - correction of copy-paste stupidity while doing the cleanup" * tag 'dma-buf-for-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/sumits/dma-buf: staging: android: ion: fix wrong init of dma_buf_export_info dma-buf: cleanup dma_buf_export() to make it easily extensible
2015-04-21media: remove unused variable that causes a warningLinus Torvalds1-1/+0
My 'allmodconfig' build is _almost_ free of warnings, and most of the remaining ones are for legacy drivers that just do bad things that I can't find it in my black heart to care too much about. But this one was just annoying me: drivers/media/v4l2-core/videobuf2-core.c:3256:26: warning: unused variable ‘fileio’ [-Wunused-variable] because commit 0e661006370b ("[media] vb2: fix 'UNBALANCED' warnings when calling vb2_thread_stop()") removed all users of 'fileio' and instead calls "__vb2_cleanup_fileio(q)" to clean up q->fileio. But the now unused 'fileio' variable was left around. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-21dma-buf: cleanup dma_buf_export() to make it easily extensibleSumit Semwal3-3/+21
At present, dma_buf_export() takes a series of parameters, which makes it difficult to add any new parameters for exporters, if required. Make it simpler by moving all these parameters into a struct, and pass the struct * as parameter to dma_buf_export(). While at it, unite dma_buf_export_named() with dma_buf_export(), and change all callers accordingly. Reviewed-by: Maarten Lankhorst <maarten.lankhorst@canonical.com> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> Acked-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com> Acked-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
2015-04-21Merge branch 'patchwork' into v4l_for_linusMauro Carvalho Chehab11-115/+287
* patchwork: (404 commits) [media] uvcvideo: add support for VIDIOC_QUERY_EXT_CTRL [media] uvcvideo: fix cropcap v4l2-compliance failure [media] media: omap3isp: remove unused clkdev [media] coda: Add tracing support [media] coda: drop dma_sync_single_for_device in coda_bitstream_queue [media] coda: fix fill bitstream errors in nonstreaming case [media] coda: call SEQ_END when the first queue is stopped [media] coda: fail to start streaming if userspace set invalid formats [media] coda: remove duplicate error messages for buffer allocations [media] coda: move parameter buffer in together with context buffer allocation [media] coda: allocate bitstream buffer from REQBUFS, size depends on the format [media] coda: allocate per-context buffers from REQBUFS [media] coda: use strlcpy instead of snprintf [media] coda: bitstream payload is unsigned [media] coda: fix double call to debugfs_remove [media] coda: check kasprintf return value in coda_open [media] coda: bitrate can only be set in kbps steps [media] v4l2-mem2mem: no need to initialize b in v4l2_m2m_next_buf and v4l2_m2m_buf_remove [media] s5p-mfc: set allow_zero_bytesused flag for vb2_queue_init [media] coda: set allow_zero_bytesused flag for vb2_queue_init ...
2015-04-10[media] v4l2-mem2mem: no need to initialize b in v4l2_m2m_next_buf and v4l2_m2m_buf_removePhilipp Zabel1-2/+2
The first time b is used, it is assigned to the first element of the rdy_queue list. There is no need to set it to NULL before. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Kamil Debski <k.debski@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-10[media] vb2: add allow_zero_bytesused flag to the vb2_queue structKamil Debski1-6/+33
The vb2: fix bytesused == 0 handling (8a75ffb) patch changed the behavior of __fill_vb2_buffer function, so that if bytesused is 0 it is set to the size of the buffer. However, bytesused set to 0 is used by older codec drivers as as indication used to mark the end of stream. To keep backward compatibility, this patch adds a flag passed to the vb2_queue_init function - allow_zero_bytesused. If the flag is set upon initialization of the queue, the videobuf2 keeps the value of bytesused intact in the OUTPUT queue and passes it to the driver. Reported-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Signed-off-by: Kamil Debski <k.debski@samsung.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-10[media] vb2: split the io_flags member of vb2_queue into a bit fieldKamil Debski1-8/+9
This patch splits the io_flags member of vb2_queue into a bit field. Instead of an enum with flags separate bit fields were introduced. Signed-off-by: Kamil Debski <k.debski@samsung.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-08Revert "[media] v4l: vb2-memops: use vma slab when vma allocation"Mauro Carvalho Chehab1-2/+2
Please revert this patch: vm_area_cachep is not exported, so you cannot use this in a module. This reverts commit 5ed1c328ea077d70e1ebcd5188dc77cdc754df3a. Reported-by: Hans Verkuil <hverkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-08[media] v4l: vb2-memops: use vma slab when vma allocationKyongHo Cho1-2/+2
The slab for vm_area_struct which is vm_area_cachep is already prepared for the general use. Instead of kmalloc() for the vma copy for userptr, allocation from vm_area_cachep is more beneficial. CC: Hans Verkuil <hans.verkuil@cisco.com> CC: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Cho KyongHo <pullip.cho@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-08[media] V4L2: Delete an unnecessary check before the function call "media_entity_put"Markus Elfring1-2/+1
The media_entity_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-08[media] v4l2-dv-timings: log new V4L2_DV_FL_IS_CE_VIDEO flagHans Verkuil1-2/+4
Add support for the new flag to v4l2_print_dv_timings(). Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-08[media] media/v4l2-ctrls: Always execute EXECUTE_ON_WRITE ctrlsRicardo Ribalda1-0/+4
Any control with V4L2_CTRL_FLAG_EXECUTE_ON_WRITE set should return changed == true in cluster_changed. This forces the value to be passed to the driver even if it has not changed. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-08[media] media/v4l2-ctrls: Add execute flags to write_only controlsRicardo Ribalda1-3/+6
Any control that sets FLAG_WRITE_ONLY should OR it with FLAG_EXECUTE_ON_WRITE. So we can keep the current meaning of WRITE_ONLY. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-08[media] media/v4l2-ctrls: volatiles should not generate CH_VALUERicardo Ribalda1-0/+9
Volatile controls should not generate CH_VALUE events. Set has_changed to false to prevent this happening. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-03[media] v4l: of: Add v4l2_of_parse_link() functionLaurent Pinchart1-0/+61
The function fills a link data structure with the device node and port number at both the local and remote ends of a link defined by one of its endpoint nodes. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02[media] V4L: add CCF support to the v4l2_clk APIGuennadi Liakhovetski1-3/+45
V4L2 clocks, e.g. used by camera sensors for their master clock, do not have to be supplied by a different V4L2 driver, they can also be supplied by an independent source. In this case the standart kernel clock API should be used to handle such clocks. This patch adds support for such cases. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Josh Wu <josh.wu@atmel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02[media] V4L: remove clock name from v4l2_clk APIGuennadi Liakhovetski1-20/+13
All uses of the v4l2_clk API so far only register one clock with a fixed name. This allows us to get rid of it, which also will make CCF and DT integration easier. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Josh Wu <josh.wu@atmel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02[media] v4l2-ioctl: allow all controls if ctrl_class == 0Hans Verkuil1-0/+2
The check_ext_ctrls() function in v4l2-ioctl.c checks if all controls in the control array are from the same control class as c->ctrl_class. However, that check should only be done if c->ctrl_class != 0. A 0 value means that this restriction does not apply. So return 1 (OK) if c->ctrl_class == 0. Found by running v4l2-compliance on the uvc driver. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02[media] v4l2-dev: disable selection ioctls for non-video devicesHans Verkuil1-8/+8
The selection/cropping ioctls are only valid for video nodes, not for vbi. Found by v4l2-compliance when run on a VBI device node. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02[media] v4l2-ioctl: tidy up debug messagesHans Verkuil1-2/+2
Make sure the format fields are reported consistently. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02[media] vb2: check if vb2_fop_write/read is allowedHans Verkuil1-0/+4
Return -EINVAL if read() or write() is not supported by the queue. This makes it possible to provide both vb2_fop_read and vb2_fop_write in a struct v4l2_file_operations since the vb2_fop_* function will check if the file operation is allowed. A similar check exists in __vb2_init_fileio() which is called from __vb2_perform_fileio(), but that check is only done if no file I/O is active. So the sequence of read() followed by write() would be allowed, which is obviously a bug. In addition, vb2_fop_write/read should always return -EINVAL if the operation is not allowed, and by putting the check in the lower levels of the code it is possible that other error codes are returned (EBUSY or ERESTARTSYS). All these issues are avoided by just doing a quick explicit check. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02[media] v4l: of: Read lane-polarities endpoint propertySakari Ailus1-9/+32
Add lane_polarities field to struct v4l2_of_bus_mipi_csi2 and write the contents of the lane-polarities property to it. The field tells the polarity of the physical lanes starting from the first one. Any unused lanes are ignored, i.e. only the polarity of the used lanes is specified. Also rework reading the "data-lanes" property a little. Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02[media] vb2: Fix dma_dir setting for dma-contig mem typeSakari Ailus1-2/+1
The last argument of vb2_dc_get_user_pages() is of type enum dma_data_direction, but the caller, vb2_dc_get_userptr() passes a value which is the result of comparison dma_dir == DMA_FROM_DEVICE. This results in the write parameter to get_user_pages() being zero in all cases, i.e. that the caller has no intent to write there. This was broken by patch "vb2: replace 'write' by 'dma_dir'". Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Cc: stable@vger.kernel.org # for v3.19 Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-23[media] v4l2-subdev.c: add 'which' checks for enum opsHans Verkuil1-0/+12
Return an error if an invalid 'which' valid is passed in. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Tested-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-23[media] v4l2-subdev: replace v4l2_subdev_fh by v4l2_subdev_pad_configHans Verkuil1-9/+9
If a subdevice pad op is called from a bridge driver, then there is no v4l2_subdev_fh struct that can be passed to the subdevice. This made it hard to use such subdevs from a bridge driver. This patch replaces the v4l2_subdev_fh pointer by a v4l2_subdev_pad_config pointer in the pad ops. This allows bridge drivers to use the various try_ pad ops by creating a v4l2_subdev_pad_config struct and passing it along to the pad op. The v4l2_subdev_get_try_* macros had to be changed because of this, so I also took the opportunity to use the full name of the v4l2_subdev_get_try_* functions in the __V4L2_SUBDEV_MK_GET_TRY macro arguments: if you now do 'git grep v4l2_subdev_get_try_format' you will actually find the header where it is defined. One remark regarding the drivers/staging/media/davinci_vpfe patches: the *_init_formats() functions assumed that fh could be NULL. However, that's not true for this driver, it's always set. This is almost certainly a copy and paste from the omap3isp driver. I've updated the code to reflect the fact that fh is never NULL. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Tested-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02[media] v4l2-core: drop g/s_priority opsHans Verkuil2-8/+5
The handling of VIDIOC_G/S_PRIORITY is now entirely done by the V4L2 core, so we can drop the g/s_priority ioctl ops. We do have to make sure though that when S_PRIORITY is called we check that the driver used struct v4l2_fh. This check can be removed once all drivers are converted to that structure. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02[media] v4l2-core: remove the old .ioctl BKL replacementHans Verkuil2-29/+0
To keep V4L2 drivers that did not yet convert to unlocked_ioctl happy, the v4l2 core had a .ioctl file operation that took a V4L2 lock. The last drivers are now converted to unlocked_ioctl, so all this old code can now be removed. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02[media] vb2: fix 'UNBALANCED' warnings when calling vb2_thread_stop()Hans Verkuil1-8/+3
Stopping the vb2 thread (as used by several DVB devices) can result in an 'UNBALANCED' warning such as this: vb2: counters for queue ffff880407ee9828: UNBALANCED! vb2: setup: 1 start_streaming: 1 stop_streaming: 1 vb2: wait_prepare: 249333 wait_finish: 249334 This is due to a race condition between stopping the thread and calling vb2_internal_streamoff(). While I have not been able to deduce the exact mechanism how this race condition can produce this warning, I can see that the way the stream is stopped is likely to lead to a race somewhere. This patch simplifies how this is done by first ensuring that the thread is completely stopped before cleaning up the vb2 queue. It does that by setting threadio->stop to true, followed by a call to vb2_queue_error() which will wake up the thread. The thread sees that 'stop' is true and it will exit. The call to kthread_stop() waits until the thread has exited, and only then is the queue cleaned up by calling __vb2_cleanup_fileio(). This is a much cleaner sequence and the warning has now disappeared. Reported-by: Jurgen Kramer <gtmkramer@xs4all.nl> Tested-by: Jurgen Kramer <gtmkramer@xs4all.nl> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Cc: <stable@vger.kernel.org> # for v3.18 and up Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-26[media] tuner-core: fix compilation if the media controller is not definedMauro Carvalho Chehab1-0/+2
drivers/media/v4l2-core/tuner-core.c:440:7: error: 'struct v4l2_subdev' has no member named 'entity' t->sd.entity.name = t->name; Reported-by: kbuild test robot <fengguang.wu@intel.com> Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-13[media] tuner-core: properly initialize media controller subdevMauro Carvalho Chehab1-0/+20
Properly initialize tuner core subdev at the media controller. That requires a new subtype at the media controller API. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-13[media] media: Fix DVB devnode representation at media controllerMauro Carvalho Chehab2-4/+4
The previous provision for DVB media controller support were to define an ID (likely meaning the adapter number) for the DVB devnodes. This is just plain wrong. Just like V4L, DVB devices (and any other device node)) are uniquely identified via a (major, minor) tuple. This is enough to uniquely identify a devnode, no matter what API it implements. So, before we go too far, let's mark the old v4l, fb, dvb and alsa "devnode" info as deprecated, and just call it as "dev". We can latter add fields specific to each API if needed. As we don't want to break compilation on already existing apps, let's just keep the old definitions as-is, adding a note that those are deprecated at media-entity.h. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-01-27[media] videobuf: make unused exported functions staticHans Verkuil1-10/+5
The videobuf_dma_init* and videobuf_dma_map() functions are no longer used except in videobuf-dma-sg.c itself. Make them static. These functions were abused in various drivers. All those drivers have now been fixed, so by no longer exporting these functions future abuse is now prevented. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-01-27Merge tag 'v3.19-rc6' into patchworkMauro Carvalho Chehab1-10/+9
This is needed in order to get the media fixes applied on -rc6. Linux 3.19-rc6 * tag 'v3.19-rc6': (891 commits) Linux 3.19-rc6 dm: fix handling of multiple internal suspends hwmon: (i5500_temp) Convert to use ATTRIBUTE_GROUPS macro hwmon: (i5500_temp) Convert to module_pci_driver hwmon: (i5500_temp) Don't bind to disabled sensors hwmon: (i5500_temp) Convert to devm_hwmon_device_register_with_groups hwmon: (i5500_temp) New driver for the Intel 5500/5520/X58 chipsets arm64: dts: add baud rate to Juno stdout-path Revert "platform: x86: dell-laptop: Add support for keyboard backlight" Revert "Documentation: Add entry for dell-laptop sysfs interface" dm cache: fix problematic dual use of a single migration count variable dm cache: share cache-metadata object across inactive and active DM tables of/unittest: Overlays with sub-devices tests KVM: x86: SYSENTER emulation is broken KVM: x86: Fix of previously incomplete fix for CVE-2014-8480 arm64: dump: Fix implicit inclusion of definition for PCI_IOBASE x86/tsc: Change Fast TSC calibration failed from error to info x86/apic: Re-enable PCI_MSI support for non-SMP X86_32 x86, mm: Change cachemode exports to non-gpl x86, tls: Interpret an all-zero struct user_desc as "no segment" ... Conflicts: drivers/media/pci/cx23885/cx23885.h
2015-01-21[media] vb2: fix vb2_thread_stop race conditionsHans Verkuil1-10/+9
The locking scheme inside the vb2 thread is unsafe when stopping the thread. In particular kthread_stop was called *after* internal data structures were cleaned up instead of doing that before. In addition, internal vb2 functions were called after threadio->stop was set to true and vb2_internal_streamoff was called. This is also not allowed. All this led to a variety of race conditions and kernel warnings and/or oopses. Fixed by moving the kthread_stop call up before the cleanup takes place, and by checking threadio->stop before calling internal vb2 queuing operations. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Cc: <stable@vger.kernel.org> # for v3.16 and up Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-12-23[media] vb2-vmalloc: Protect DMA-specific code by #ifdef CONFIG_HAS_DMAGeert Uytterhoeven1-0/+5
If NO_DMA=y: drivers/built-in.o: In function `vb2_vmalloc_dmabuf_ops_detach': videobuf2-vmalloc.c:(.text+0x6f11b0): undefined reference to `dma_unmap_sg' drivers/built-in.o: In function `vb2_vmalloc_dmabuf_ops_map': videobuf2-vmalloc.c:(.text+0x6f1266): undefined reference to `dma_unmap_sg' videobuf2-vmalloc.c:(.text+0x6f1282): undefined reference to `dma_map_sg' As we don't want to make the core VIDEOBUF2_VMALLOC depend on HAS_DMA (it's v4l2 core code, and selected by a lot of drivers), stub out the DMA support if HAS_DMA is not set. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-12-23[media] videobuf2-vmalloc: fix sparse warningHans Verkuil1-2/+2
Fix this warning: drivers/media/v4l2-core/videobuf2-vmalloc.c:98:28: warning: incorrect type in assignment (different address spaces) drivers/media/v4l2-core/videobuf2-vmalloc.c:158:28: warning: incorrect type in argument 1 (different address spaces) The warning is correct, but we have no other choice here to forcibly cast. At least it is now explicit that such a cast is needed. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-12-23[media] v4l2 core: improve debug flag handlingHans Verkuil2-16/+22
The old debug field is renamed to dev_debug to ensure that existing drivers (including out-of-tree drivers) that try to use the old name will no longer compile. A comment has also been added that makes it explicit that drivers shouldn't use this field. Additional bits have been added to the debug flag to be more fine-grained when debugging, especially when dealing with streaming ioctls and read, write and poll. You want to enable those explicitly to prevent flooding the log when streaming unless you actually want to do that. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-12-22[media] v4l2-subdev: drop get/set_crop pad opsHans Verkuil1-8/+0
Drop the duplicate get/set_crop pad ops and only use get/set_selection. It makes no sense to have two duplicate ops in the internal subdev API. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-12-22[media] media: remove emacs editor variablesHans Verkuil1-7/+0
1) This is not allowed by the kernel coding style 2) Just configure your editor correctly 3) It's really ugly Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-12-16[media] v4l2-ioctl: WARN_ON if querycap didn't fill device_capsHans Verkuil1-0/+6
This is easy to forget to do in drivers. While v4l2-compliance will check for it, not everyone remembers to run it. So warn about it. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-12-04[media] v4l: vb2: Fix race condition in _vb2_fop_releaseLaurent Pinchart1-4/+4
The function releases the queue if the file being released is the queue owner. The check reads the queue->owner field without taking the queue lock, creating a race condition with functions that set the queue owner, such as vb2_ioctl_reqbufs() for instance. Fix this by moving the queue->owner check within the mutex protected section. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-12-04[media] v4l: vb2: Fix race condition in vb2_fop_pollLaurent Pinchart1-19/+8
The vb2_fop_poll() implementation tries to be clever on whether it needs to lock the queue mutex by checking whether polling might start fileio. The test requires reading the q->num_buffer field, which is racy if we don't hold the queue mutex in the first place. Remove the extra cleverness and just lock the mutex. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-12-02[media] V4L2: Deletion of an unnecessary check before the function call "vb2_put_vma"Markus Elfring1-2/+1
The vb2_put_vma() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>