Commit graph

20478 commits

Author SHA1 Message Date
Hans Verkuil 280abe474e [media] vivid-tpg: finish hor/vert downsampling support
Implement horizontal and vertical downsampling when filling in the
plane. The TPG is now ready to support such formats.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 20:41:49 -03:00
Hans Verkuil 3e14e7a82c [media] vivid-tpg: add hor/vert downsampling support to tpg_gen_text
This will just skip lines/pixels since color fidelity is not quite
as important here as it is with the test patterns themselves.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 20:40:49 -03:00
Hans Verkuil 1f088dc162 [media] vivid-tpg: correctly average the two pixels in gen_twopix()
gen_twopix() is always called twice: once for the first and once for
the second pixel. Improve the code to properly average the two if the
format requires horizontal downsampling.

This is necessary for patterns like 1x1 red/blue checkers.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 20:40:17 -03:00
Hans Verkuil 5d7c539e19 [media] vivid-tpg: precalculate downsampled lines
When dealing with vertical downsampling two successive lines have to be
averaged. In the case of the test pattern generator that only happens
if the two lines are using different patterns. So precalculate the average
between two pattern lines: one of pattern P and one of pattern P + 1.

That way there is no need to do any on-the-fly downsampling: it's all done
in the precalculate phase.

This patch also implements horizontal downsampling in the precalculate phase.
The only thing that needs to be done is to half the width since the actual
downsampling happens when two pixels at a time are generated.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 20:39:07 -03:00
Hans Verkuil ba01f673e0 [media] vivid-tpg: add hor/vert downsampling fields
This is step one of supporting horizontal and vertical downsampling.
This just adds support for the h/vdownsampling fields and it increases
the maximum number of planes to 3.

Currently none of the planar formats need horizontal or vertical
downsampling, so this change has no effect at the moment.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 20:38:04 -03:00
Hans Verkuil 4db2204189 [media] vivid-tpg: add helper functions for single buffer planar formats
Add helpers functions to determine the line widths and image sizes
for planar formats that are stores in a single buffer.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 20:37:26 -03:00
Hans Verkuil 06d1f0c2ea [media] vivid-tpg: separate planes and buffers
Add a new field that contains the number of buffers. This may be
less than the number of planes in case multiple planes are combined
into one buffer.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 20:35:37 -03:00
Hans Verkuil ba24b44203 [media] vivid: do not allow video loopback for SEQ_TB/BT
Sequential top-bottom/bottom-top fields are not supported as video loopback.
This is too much work to implement for field settings that are rarely used.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 20:33:37 -03:00
Hans Verkuil 9c35bd48d5 [media] vivid-tpg: don't add offset when switching to monochrome
The grayscale values are still full range sRGB, so don't add the
limited range offset.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 20:32:58 -03:00
Hans Verkuil 1a05d3133f [media] vivid: add new checkboard patterns
Add a 2x2 checker patterns and 1x1 and 2x2 red/blue checker patterns.

Useful for testing 4:2:2 and 4:2:0 formats.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 20:32:29 -03:00
Hans Verkuil 43047f6b74 [media] vivid: fix test pattern movement for V4L2_FIELD_ALTERNATE
The successive TOP/BOTTOM fields did not move as they should: only
every other field actually changed position.

The cause was that the tpg needs to know if it is dealing with a
FIELD_ALTERNATE case since that requires slightly different handling.

So tell the TPG whether or not the field setting is for the ALTERNATE
case or not.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 20:30:57 -03:00
Hans Verkuil c501abcfbf [media] vivid: use TPG_MAX_PLANES instead of hardcoding plane-arrays
Two arrays of size 'max number of planes' have a hardcoded size instead
of using TPG_MAX_PLANES. Fix that, since TPG_MAX_PLANES will be increased
later on.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 20:30:16 -03:00
Hans Verkuil a94e7d6e82 [media] vivid: wrong top/bottom order for FIELD_ALTERNATE
The condition to decide whether the current field is top or bottom
was inverted. Fix this.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 20:29:48 -03:00
Hans Verkuil 360565fcf7 [media] vivid: fix typo in plane size checks
The plane size check was hardcoded to plane 0 instead of using the plane
index.

This failed when using the NV61M format which has a larger plane size for
the second plane compared to the first plane.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 20:29:19 -03:00
Hans Verkuil 9832e0e013 [media] vivid: the overlay API wasn't disabled completely for multiplanar
If the vivid driver is loaded in multiplanar mode, then the capture overlay
functionality should be disabled. This wasn't fully done, which led to
v4l2-compliance errors.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 20:28:16 -03:00
Laurent Pinchart 739cfd9be9 [media] rcar-vin: Don't implement empty optional clock operations
The clock_start and clock_stop operations are now optional, don't
implement empty stubs.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:37:37 -03:00
Laurent Pinchart 3781760a3d [media] soc-camera: Make clock_start and clock_stop operations optional
Instead of forcing drivers to implement empty clock operations, make
them optional.

v4l2 clock registration in the soc-camera core should probably be
conditionned on the availability of those operations, but careful
review and/or testing of all drivers would be needed, so that should be
a separate step.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:37:19 -03:00
Laurent Pinchart 2af12f0258 [media] soc-camera: Unregister v4l2 clock in the OF bind error path
The v4l2 clock registered in soc_of_bind() must be unregistered if an
error occurs and makes the function fail.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:36:33 -03:00
Josh Wu 4e65172f7b [media] media: ov2640: add primary dt support
Add device tree support for ov2640.
In device tree, user needs to provide the master clock (xvclk).
User can add the reset/pwdn pins if they have.

Cc: devicetree@vger.kernel.org
Signed-off-by: Josh Wu <josh.wu@atmel.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:36:10 -03:00
Josh Wu f180ebae1a [media] media: ov2640: add async probe function
In async probe, there is a case that ov2640 is probed before the
host device which provided 'mclk'.
To support this async probe, we will get 'mclk' at first in the probe(),
if failed it will return -EPROBE_DEFER. That will let ov2640 wait for
the host device probed.

Signed-off-by: Josh Wu <josh.wu@atmel.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:34:42 -03:00
Josh Wu 0b9508aa03 [media] media: soc-camera: use icd->control instead of icd->pdev for reset()
icd->control is the sub device dev, i.e. i2c device.
icd->pdev is the soc camera device's device.

To be consitent with power() function, we will call reset() with
icd->control as well.

Signed-off-by: Josh Wu <josh.wu@atmel.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:34:10 -03:00
Guennadi Liakhovetski 4f528afcfb [media] V4L: add CCF support to the v4l2_clk API
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 18:33:42 -03:00
Guennadi Liakhovetski a37462b919 [media] V4L: remove clock name from v4l2_clk API
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 18:32:53 -03:00
Hans Verkuil 9b239b22df [media] v4l2-ioctl: allow all controls if ctrl_class == 0
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 18:30:36 -03:00
Hans Verkuil 2c9fc463d6 [media] v4l2-dev: disable selection ioctls for non-video devices
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 18:30:00 -03:00
Hans Verkuil 8a55ddd94c [media] au0828: fix broken streaming
Commit c5036d61e0 ("media: au0828: drop
vbi_buffer_filled() and re-use buffer_filled()") broke video and vbi streaming.

The vb2_buffer struct was copied instead of taking a pointer to it, but
vb2_buffer_done() needs the real object, not a copy, since it is hooking
the buffer into a different list.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:28:59 -03:00
Hans Verkuil 27eb5e24e0 [media] cx231xx: fix compiler warnings
If CONFIG_VIDEO_CX231XX_RC is undefined, then these compiler warnings
are generated:

In file included from drivers/media/usb/cx231xx/cx231xx-cards.c:23:0:
drivers/media/usb/cx231xx/cx231xx-cards.c: In function ‘cx231xx_release_resources’:
drivers/media/usb/cx231xx/cx231xx.h:982:30: warning: statement with no effect [-Wunused-value]
 #define cx231xx_ir_exit(dev) (0)
                              ^
drivers/media/usb/cx231xx/cx231xx-cards.c:1158:2: note: in expansion of macro ‘cx231xx_ir_exit’
  cx231xx_ir_exit(dev);
  ^
drivers/media/usb/cx231xx/cx231xx-cards.c: In function ‘cx231xx_init_dev’:
drivers/media/usb/cx231xx/cx231xx.h:981:30: warning: statement with no effect [-Wunused-value]
 #define cx231xx_ir_init(dev) (0)
                              ^
drivers/media/usb/cx231xx/cx231xx-cards.c:1351:2: note: in expansion of macro ‘cx231xx_ir_init’
  cx231xx_ir_init(dev);
  ^
drivers/media/usb/cx231xx/cx231xx-cards.c: In function ‘cx231xx_usb_probe’:
drivers/media/usb/cx231xx/cx231xx.h:982:30: warning: statement with no effect [-Wunused-value]
 #define cx231xx_ir_exit(dev) (0)
                              ^
drivers/media/usb/cx231xx/cx231xx-cards.c:1705:2: note: in expansion of macro ‘cx231xx_ir_exit’
  cx231xx_ir_exit(dev);
  ^
drivers/media/usb/cx231xx/cx231xx-cards.c: In function ‘cx231xx_usb_disconnect’:
drivers/media/usb/cx231xx/cx231xx.h:982:30: warning: statement with no effect [-Wunused-value]
 #define cx231xx_ir_exit(dev) (0)
                              ^
drivers/media/usb/cx231xx/cx231xx-cards.c:1754:3: note: in expansion of macro ‘cx231xx_ir_exit’
   cx231xx_ir_exit(dev);
   ^

Fix by using static inlines instead of defines.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:24:04 -03:00
Arnd Bergmann 78e9b7de78 [media] wl128x-radio really depends on TI_ST
All other drivers using the TI_ST infrastructure use
'depends on' for this symbol, and it makes no sense
to only enable that if CONFIG_NET is enable, because
the radio driver also depends on CONFIG_NET itself:

ERROR: "skb_queue_purge" [drivers/media/radio/wl128x/fm_drv.ko] undefined!
ERROR: "skb_push" [drivers/media/radio/wl128x/fm_drv.ko] undefined!
ERROR: "skb_pull" [drivers/media/radio/wl128x/fm_drv.ko] undefined!

Making the driver dependency explicit solves randconfig
build problems and makes it more obvious to the reader.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:23:28 -03:00
Hans Verkuil f2e37b9b73 [media] rtl2832: fix compiler warning
>From the daily build:

rtl2832.c: In function 'rtl2832_read_status':
rtl2832.c:703:12: warning: 'tmp' may be used uninitialized in this function [-Wmaybe-uninitialized]
  } else if (tmp == 10) {
            ^

The code is OK, it's just the compiler that cannot figure out what's
going on. So just init 'tmp' to 0.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:22:54 -03:00
Julia Lawall fae119bedd [media] media: pci: cx23885: don't export static symbol
The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r@
type T;
identifier f;
@@

static T f (...) { ... }

@@
identifier r.f;
declarer name EXPORT_SYMBOL;
@@

-EXPORT_SYMBOL(f);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:21:53 -03:00
Ezequiel Garcia aeff092767 [media] stk1160: Make sure current buffer is released
The available (i.e. not used) buffers are returned by stk1160_clear_queue(),
on the stop_streaming() path. However, this is insufficient and the current
buffer must be released as well. Fix it.

Cc: stable@vger.kernel.org
Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:18:37 -03:00
Lad, Prabhakar e933c6bc67 [media] media: davinci: vpif_display: embed video_device struct in channel_obj
Embed video_device struct (video_dev) in channel_obj and also the
Unregister path doesn't need to free the video_device structure,
hence, change the video_device.release callback point to
video_device_release_empty.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:12:43 -03:00
Lad, Prabhakar 8eef6669d3 [media] media: davinci: vpif_capture: embed video_device struct in channel_obj
Embed video_device struct (video_dev) in channel_obj and also the
Unregister path doesn't need to free the video_device structure,
hence, change the video_device.release callback point to
video_device_release_empty.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:11:54 -03:00
Lad, Prabhakar afb7a966b5 [media] media: blackfin: bfin_capture: embed video_device struct in bcap_device
Embed video_device struct (video_dev) in bcap_device and
Unregister path doesn't need to free the video_device
structure, hence, change the video_device.release callback
point to video_device_release_empty.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:11:50 -03:00
Lad, Prabhakar 225ccaa307 [media] media: blackfin: bfin_capture: drop bcap_get_unmapped_area()
this patch drops bcap_get_unmapped_area() and uses
vb2_fop_get_unmapped_area() helper provided by the vb2 core.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:11:49 -03:00
Lad, Prabhakar 9d490e529d [media] media: blackfin: bfin_capture: set v4l2 buffer sequence
this patch adds support to set the v4l2 buffer sequence.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Tested-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:11:48 -03:00
Lad, Prabhakar 812447e587 [media] media: blackfin: bfin_capture: add support for VIDIOC_EXPBUF
this patch adds support for VIDIOC_EXPBUF.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Tested-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:11:46 -03:00
Lad, Prabhakar 70753b5e70 [media] media: blackfin: bfin_capture: add support for VB2_DMABUF
this patch adds support for VB2_DMABUF.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Tested-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:11:45 -03:00
Lad, Prabhakar 8df229bdec [media] media: blackfin: bfin_capture: add support for vidioc_create_bufs
this patch adds support for vidioc_create_bufs.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Tested-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:11:44 -03:00
Lad, Prabhakar 116a6488d3 [media] media: blackfin: bfin_capture: return -ENODATA for *dv_timings calls
this patch adds support to return -ENODATA for *dv_timings calls
if the current output does not support it.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Tested-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:11:43 -03:00
Lad, Prabhakar fe00b716e7 [media] media: blackfin: bfin_capture: return -ENODATA for *std calls
this patch adds supports to return -ENODATA to *_std calls
if the selected output does not support it.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Tested-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:11:40 -03:00
Lad, Prabhakar 2bf34b2f09 [media] media: blackfin: bfin_capture: make sure all buffers are returned on stop_streaming() callback
In start_streaming() callback the buffer is removed from the
dma_queue list and assigned to cur_frm, this patch makes sure
that is returned to vb2 core with VB2_BUF_STATE_ERROR flag.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Tested-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:11:33 -03:00
Lad, Prabhakar d61233bf4c [media] media: blackfin: bfin_capture: use vb2_ioctl_* helpers
this patch adds support to vb2_ioctl_* helpers.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Tested-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:11:29 -03:00
Lad, Prabhakar f0e91c65a9 [media] media: blackfin: bfin_capture: use v4l2_fh_open and vb2_fop_release
this patch adds support to use v4l2_fh_open() and vb2_fop_release,
which allows to drop driver specific struct bcap_fh, as this is handled
by core.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Tested-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:11:26 -03:00
Lad, Prabhakar 8fd05b7eee [media] media: blackfin: bfin_capture: use vb2_fop_mmap/poll
No need to reinvent the wheel. Just use the already existing
functions provided by vb2.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Tested-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:11:23 -03:00
Lad, Prabhakar f314002279 [media] media: blackfin: bfin_capture: improve queue_setup() callback
This patch does the following:
a: returns -EINVAL in case format image size is less
   then current image size.
b: assigns nbuffers to two in case the total of vq->num_buffers
   and nbuffers is less then the number of buffers required by driver.
c: sets the sizes[0] of plane according to the fmt passed or which is
   being set in the device.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Tested-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:11:18 -03:00
Lad, Prabhakar cd3c38effc [media] media: blackfin: bfin_capture: set vb2 buffer field
set the vb2 buffer field in buf_prepare() callback,
alongside drop local variable buf as we already have
a pointer to vb2 buffer.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Tested-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:11:15 -03:00
Lad, Prabhakar 5f65ca81c3 [media] media: blackfin: bfin_capture: set min_buffers_needed
this patch sets the min_buffers_needed field of the vb2 queue
so that the vb2 core will make sure start_streaming() callback
is called only when we have minimum buffers queued.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Tested-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:11:12 -03:00
Lad, Prabhakar 6692871a7c [media] media: blackfin: bfin_capture: release buffers in case start_streaming() call back fails
this patch adds support to release the buffer by calling
vb2_buffer_done(), with state marked as VB2_BUF_STATE_QUEUED
if start_streaming() call back fails.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Tested-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:11:09 -03:00
Lad, Prabhakar b4e81b2378 [media] media: blackfin: bfin_capture: drop buf_init() callback
this patch drops the buf_init() callback as init
of buf list is not required.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Tested-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:11:03 -03:00
Hans Verkuil c0b50d9512 [media] vivid: BT.2020 R'G'B' is limited range
According to the standard the R'G'B' BT.2020 colorspace is limited
range, not full range. Fix this.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:11:02 -03:00
Hans Verkuil 1e8faa5945 [media] v4l2-ioctl: tidy up debug messages
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 18:10:51 -03:00
Lad, Prabhakar 8b97e0e3f4 [media] media: am437x-vpfe: embed video_device struct in vpfe_device
Embed video_device struct (video_dev) in vpfe_device and
Unregister path doesn't need to free the video_device
structure, hence, change the video_device.release callback
point to video_device_release_empty.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:10:44 -03:00
Lad, Prabhakar 7d87db3df0 [media] media: am437x-vpfe: return error in case memory allocation failure
return error in case devm_kzalloc() fails.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:10:42 -03:00
Lad, Prabhakar d37232390f [media] media: am437x-vpfe: match the OF node/i2c addr instead of name
Instead of matching the subdevs with their name, match
it with OF node/ i2c address and adapter number.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:10:40 -03:00
Tapasweni Pathak 4eaa3a6cc4 [media] drivers: media: platform: vivid: Fix possible null derefrence
Check for dev_fmt being null before derefrencing it, to assign it
to planes.

Found using Coccinelle.

Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:10:38 -03:00
Hans Verkuil ff05cb4b81 [media] vb2: check if vb2_fop_write/read is allowed
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 18:10:25 -03:00
Laurent Pinchart ee662d44a2 [media] media: am437x: Don't release OF node reference twice
The remote port reference is released both at the end of the OF graph
parsing loop, and in the error code path at the end of the function.
Those two calls will release the same reference, causing the reference
count to go negative.

Fix the problem by removing the second call.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Acked-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:10:06 -03:00
Laurent Pinchart 1cdf60c97a [media] uvcvideo: Validate index during step-wise frame intervals enumeration
Frame intervals exposed as an interval and step (so-called step-wise)
are restricted by the V4L2 API to a single enumeration entry. Return an
error when the index is not zero.

Reported-by: Alexey Smirnoff <fling@member.fsf.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[mchehab@osg.samsung.com: add a missing collon at the end of the return
 statement, in order to avoid compilation breakage]
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 17:31:48 -03:00
Laurent Pinchart fe6524719d [media] uvcvideo: Recognize the Tasco USB microscope
The device is based on an Aveo chipset, implements UVC but advertises a
vendor-specific class on all interfaces.

Support it by listing the USB VID:PID explicitly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 17:30:05 -03:00
Laurent Pinchart 9e68c53910 [media] uvcvideo: Don't call vb2 mmap and get_unmapped_area with queue lock held
videobuf2 has long been subject to AB-BA style deadlocks due to the
queue lock and mmap_sem being taken in different orders for the mmap and
get_unmapped_area operations. The problem has been fixed by making those
two operations callable without taking the queue lock, using an
mmap_lock internal to videobuf2.

The uvcvideo driver still calls the mmap and get_unmapped_area
operations with the queue lock held, resulting in a potential deadlock.
As the operations can now be called without locking the queue, fix it.

Reported-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 17:29:28 -03:00
Sakari Ailus cfa9672243 [media] smiapp: Make pixel_order_str static
pixel_order_str is only referred to in smiapp-core.c, it should be thus
static. Thanks to Hans Verkuil for pointing this out.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 17:28:36 -03:00
Sakari Ailus 3f39fb0f1e [media] smiapp: Use of_property_read_u64_array() to read a 64-bit number array
of_property_read_u64_array() wasn't yet part of the kernel tree when the
functionality was needed. Do use it now.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 17:26:30 -03:00
Sakari Ailus 152635c6ea [media] Revert "[media] smiapp: Don't compile of_read_number() if CONFIG_OF isn't defined"
This reverts commit cb88d7384e.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 17:10:43 -03:00
Marek Szyprowski 6c9fe76536 [media] media: s5p-mfc: fix broken pointer cast on 64bit arch
Unsigned int cannot be used to store casted pointer on 64bit
architecture, so correct such casts to properly use unsigned long
variables.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
[k.debski@samsung.com: removed volatile and __iomem from cast]

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 17:08:28 -03:00
Marek Szyprowski a301ea1f50 [media] media: s5p-mfc: fix mmap support for 64bit arch
TASK_SIZE is depends on the systems architecture (32 or 64 bits) and it
should not be used for defining offset boundary for mmaping buffers for
CAPTURE and OUTPUT queues. This patch fixes support for MMAP calls on
the CAPTURE queue on 64bit architectures (like ARM64).

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 16:59:40 -03:00
Sakari Ailus f95c16ea70 [media] omap3isp: Deprecate platform data support
Print a warning when the driver is used with platform data. Existing
platform data users should move to DT now.

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 16:48:07 -03:00
Sakari Ailus da7f3843d2 [media] omap3isp: Add support for the Device Tree
Add the ISP device to omap3 DT include file and add support to the driver to
use it.

Also obtain information on the external entities and the ISP configuration
related to them through the Device Tree in addition to the platform data.

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 16:47:48 -03:00
Sakari Ailus b6eec1c493 [media] v4l: of: Read lane-polarities endpoint property
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 16:46:42 -03:00
Sakari Ailus 8644cdf972 [media] omap3isp: Replace many MMIO regions by two
The omap3isp MMIO register block is contiguous in the MMIO register space
apart from the fact that the ISP IOMMU register block is in the middle of
the area. Ioremap it at two occasions, and keep the rest of the layout of
the register space internal to the omap3isp driver.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 16:45:07 -03:00
Sakari Ailus 503596a152 [media] omap3isp: Move the syscon register out of the ISP register maps
The syscon register isn't part of the ISP, use it through the syscom driver
regmap instead. The syscom block is considered to be from 343x on ISP
revision 2.0 whereas 15.0 is assumed to have 3630 syscon.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 16:44:18 -03:00
Sakari Ailus 4fcfeca833 [media] omap3isp: Replace mmio_base_phys array with the histogram block base
Only the histogram sub-block driver uses the physical address. Do not store
it for other sub-blocks.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 16:42:52 -03:00
Sakari Ailus 6387b75284 [media] omap3isp: Calculate vpclk_div for CSI-2
The video port clock is l3_ick divided by vpclk_div. This clock must be high
enough for the external pixel rate. The video port requires two clock cycles
to process a pixel.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 16:42:04 -03:00
Sakari Ailus 3494bb0594 [media] omap3isp: Rename regulators to better suit the Device Tree
Rename VDD_CSIPHY1 as vdd-csiphy1 and VDD_CSIPHY2 as vdd-csiphy2.

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 16:41:23 -03:00
Sakari Ailus 6890874772 [media] omap3isp: Refactor device configuration structs for Device Tree
Make omap3isp configuration data structures more suitable for consumption by
the DT by separating the I2C bus information of all the sub-devices in a
group and the ISP bus information from each other. The ISP bus information
is made a pointer instead of being directly embedded in the struct.

In the case of the DT only the sensor specific information on the ISP bus
configuration is retained. The structs are renamed to reflect that.

After this change the structs needed to describe device configuration can be
allocated and accessed separately without those needed only in the case of
platform data. The platform data related structs can be later removed once
the support for platform data can be removed.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Igor Grinberg <grinberg@compulab.co.il> (for cm-t35)
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 16:41:01 -03:00
Sakari Ailus 4c8f14861c [media] omap3isp: Platform data could be NULL
Only check for call platform data callback functions if there's platform
data. Also take care of a few other cases where the NULL pdata pointer could
have been accessed, and remove the check for NULL dev->platform_data
pointer.

Removing the check for NULL dev->platform_data isn't strictly needed by the
DT support but there's no harm from that either: the device now can be used
without sensors, for instance.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 16:39:14 -03:00
Laurent Pinchart 64904b574e [media] omap3isp: DT support for clocks
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 16:38:03 -03:00
Sakari Ailus 703e6f625b [media] omap3isp: Separate external link creation from platform data parsing
Move the code which connects the external entity to an ISP entity into a
separate function. This disconnects it from parsing the platform data.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 16:37:26 -03:00
Sakari Ailus 8b3aff7cdd [media] omap3isp: Avoid a BUG_ON() in media_entity_create_link()
If an uninitialised v4l2_subdev struct was passed to
media_entity_create_link(), one of the BUG_ON()'s in the function will be
hit since media_entity.num_pads will be zero. Avoid this by checking whether
the num_pads field is non-zero for the interface.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 16:37:21 -03:00
Sakari Ailus 697cca21b0 [media] omap3isp: Fix error handling in probe
The mutex was not destroyed correctly if dma_coerce_mask_and_coherent()
failed for some reason.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 16:37:17 -03:00
Laurent Pinchart 0ff4e419dc [media] media: omap3isp: hist: Move histogram DMA to DMA engine
Replace the custom OMAP DMA API usage by DMA engine. Feature-wise the
driver has lost the ability to get notified of DMA transfers failure
through the completion handler, as the DMA engine API doesn't expose
that status information.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 16:37:13 -03:00
Laurent Pinchart 32346b9cc0 [media] media: omap3isp: video: Use v4l2_get_timestamp()
Replace the open-coded copy by a function call.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 16:32:55 -03:00
Lad, Prabhakar 13dab904d5 [media] media: omap3isp: video: drop setting of vb2 buffer state to VB2_BUF_STATE_ACTIVE
There isn't a need to assign the state of vb2_buffer to active
as this is already done by the core.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 16:32:32 -03:00
Laurent Pinchart 9be2936959 [media] media: omap3isp: video: Don't call vb2 mmap with queue lock held
videobuf2 has long been subject to AB-BA style deadlocks due to the
queue lock and mmap_sem being taken in different orders for the mmap
operation. The problem has been fixed by making this operation callable
without taking the queue lock, using an mmap_lock internal to videobuf2.

The omap3isp driver still calls the mmap operation with the queue lock
held, resulting in a potential deadlock. As the operation can now be
called without locking the queue, fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 16:31:14 -03:00
Olli Salonen 18acc6ace5 [media] si2157: extend frequency range for ATSC
The Si2157 tuner supports ATSC in addition to DVB-T and DVB-C. Extend
minimum frequency range to cover the complete ATSC/QAM-B range.

Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-01 06:22:26 -03:00
Hans Verkuil 17bef88524 [media] v4l2-subdev: add support for the new enum_frame_interval 'which' field
Support the new 'which' field in the enum_frame_interval ops. Most drivers do not
need to be changed since they always returns the same enumeration regardless
of the 'which' field.

Tested for ov7670 and marvell-ccic on a OLPC XO-1 laptop.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Jonathan Corbet <corbet@lwn.net>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-23 12:01:15 -07:00
Hans Verkuil 5778e749c1 [media] v4l2-subdev: add support for the new enum_frame_size 'which' field
Support the new 'which' field in the enum_frame_size ops. Most drivers do not
need to be changed since they always returns the same enumeration regardless
of the 'which' field.

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>
Acked-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-23 11:48:55 -07:00
Hans Verkuil 3f1ccf16f3 [media] v4l2-subdev: support new 'which' field in enum_mbus_code
Support the new 'which' field in the enum_mbus_code ops. Most drivers do not
need to be changed since they always return the same enumeration regardless
of the 'which' field.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-23 11:46:38 -07:00
Hans Verkuil 20058f9091 [media] v4l2-subdev.c: add 'which' checks for enum ops
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 11:45:07 -07:00
Hans Verkuil f7234138f1 [media] v4l2-subdev: replace v4l2_subdev_fh by v4l2_subdev_pad_config
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-23 11:41:36 -07:00
Benjamin Larsson 3b786f1316 [media] mn88473: calculate the IF register values
Add xtal as a configuration parameter so it can be used
in the IF register value calculation. If not set in the
configuration then use a default value.

Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
Reviewed-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 13:07:55 -03:00
Uwe Kleine-König 269bd1324f [media] media: adv7604: improve usage of gpiod API
Since 39b2bbe3d7 (gpio: add flags argument to gpiod_get*() functions)
which appeared in v3.17-rc1, the gpiod_get* functions take an additional
parameter that allows to specify direction and initial value for output.
Simplify accordingly.

Moreover use devm_gpiod_get_index_optional instead of
devm_gpiod_get_index with ignoring all errors.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 11:26:40 -03:00
Simon Farnsworth 48ab45adcc [media] cx18: Fix bytes_per_line
Current GStreamer userspace respects the bytes_per_line from the driver. Set
it to something reasonable for the format chosen.

Signed-off-by: Simon Farnsworth <simon.farnsworth@onelan.co.uk>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 11:24:34 -03:00
Lad, Prabhakar ac0b2b3072 [media] media: omap/omap_vout: fix type of input members to omap_vout_setup_vrfb_bufs()
the declaration for omap_vout_setup_vrfb_bufs() said it
needed 'u32 static_vrfb_allocation' but definition
took 'bool static_vrfb_allocation', this patch fixes the
declaration so that it matches with the definition and
pass a bool instead of int to the call, also included
omap_vout_vrfb.h in omap_vout_vrfb.c file so that sparse doesn't
complain of making omap_vout_setup_vrfb_bufs() as static function.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 11:22:58 -03:00
Lad, Prabhakar 460eac3fee [media] media: i2c: ths7303: drop module param debug
this patch drops module param 'debug' as it was never used.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 11:21:57 -03:00
Lad, Prabhakar c3718de559 [media] media: drop call to v4l2_device_unregister_subdev()
These drivers are moved to support asynchronous probing,
v4l2_async_unregister_subdev() unregisters the subdev so
there isn't a need to explicitly call v4l2_device_unregister_subdev().

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 11:21:41 -03:00
Gilles Risch 1fe0fbd69a [media] Basic support for the Elgato EyeTV Hybrid INT 2008 USB Stick
This patch will add basic support for the Elgato EyeTV Hybrid INT
2008 USB Stick.

Signed-off-by: Gilles Risch <gilles.risch@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 11:20:50 -03:00
Wei Yongjun 03983e5db1 [media] v4l2: remove unused including <linux/version.h>
Remove including <linux/version.h> that don't need it.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 11:20:12 -03:00
Shuah Khan 41071bb8c7 [media] media: au0828 - embed vdev and vbi_dev structs in au0828_dev
Embed video_device structs vdev and vbi_dev in au0828_dev.
With this change, dynamic allocation and error path logic
in au0828_analog_register() is removed as it doesn't need
to allocate and handle allocation errors. Unregister path
doesn't need to free the now static video_device structures,
hence, changed video_device.release in au0828_video_template
to point to video_device_release_empty.

Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 11:19:52 -03:00
Lad, Prabhakar c5036d61e0 [media] media: au0828: drop vbi_buffer_filled() and re-use buffer_filled()
The vbi_buffer_filled() and buffer_filled() did the same functionality
except for incrementing the buffer sequence, this patch drops the
vbi_buffer_filled() and re-uses buffer_filled() for vbi buffers
as well by adding the check for vb2-queue type while incrementing
the sequence numbers. Along side this patch aligns the input parameters
of buffer_filled() function appropriately.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 11:17:56 -03:00
Tapasweni Pathak 48205533ba [media] drivers: media: i2c : s5c73m3: Replace dev_err with pr_err
Replace dev_err statement with pr_err to fix null dereference.

Found by Coccinelle.

Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 11:16:36 -03:00
Olli Salonen 3f845f3c4c [media] saa7164: free_irq before pci_disable_device
Free the IRQ before disabling the device. Otherwise errors like this when unloading the module:

[21135.458560] ------------[ cut here ]------------
[21135.458569] WARNING: CPU: 4 PID: 1696 at /home/apw/COD/linux/fs/proc/generic.c:521 remove_proc_entry+0x1a1/0x1b0()
[21135.458572] remove_proc_entry: removing non-empty directory 'irq/47', leaking at least 'saa7164[0]'

Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
Reviewed-by: Steven Toth <stoth@kernellabs.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 11:16:09 -03:00
Fabian Frederick f35593fdc8 [media] saa7146: replace current->state by set_current_state()
Use helper functions to access current->state.
Direct assignments are prone to races and therefore buggy.

current->state = TASK_RUNNING can be replaced by __set_current_state()

Thanks to Peter Zijlstra for the exact definition of the problem.

Suggested-By: Peter Zijlstra <peterz@infradead.org>

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 11:15:42 -03:00
Olli Salonen 809abdbf46 [media] cx231xx: Hauppauge HVR-955Q ATSC/QAM tuner
Hauppauge HVR-955Q is a ATSC/QAM USB tuner with LGDT3306A demodulator and SiLabs Si2157-A30 tuner.

Only digital TV has been tested (both ATSC and QAM256).

Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:36:12 -03:00
Olli Salonen c28aebe178 [media] si2157: IF frequency for ATSC and QAM
For supporting ATSC and QAM modes the driver should use a smaller IF frequency than 5 MHz.

Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:35:08 -03:00
Mauro Carvalho Chehab 95f22c5aae [media] lgdt3306a: Minor source code cleanups
Fix a few minor CodingStyle issues at the source code:
	- Use proper multi-line comments;
	- Align the log tables;
	- Remove the .type from dvb_frontend_ops, since this is not
	  needed anymore (since the drivers conversion to DVBv5);
	- Remove emacs format macro.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:15 -03:00
Mauro Carvalho Chehab 534f4364f9 [media] lgdt3306a: Break long lines
Fix most of checkpatch warnings like:
	WARNING: line over 80 characters

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:15 -03:00
Mauro Carvalho Chehab 9369fe012d [media] lgdt3306a: constify log tables
Ideally, we should be replacing this function by intlog10().

While we don't do that, let's at least constify the tables,
in order to remove its code footfrint, and get rid of nelems.

This also fixes a few 80-cols CodingStyle warnings.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:14 -03:00
Mauro Carvalho Chehab c9897649db [media] lbdt3306a: remove uneeded braces
WARNING: braces {} are not necessary for any arm of this statement
+		if (ret == 0) {
[...]
+		} else {
[...]

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:14 -03:00
Mauro Carvalho Chehab b4e43e959b [media] lgdt3306a: Don't use else were not needed
Get rid of the remaining checkpatch.pl warnings:
	WARNING: braces {} are not necessary for any arm of this statement

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:14 -03:00
Mauro Carvalho Chehab b1a88c713a [media] lbdt3306a: simplify the lock status check
The logic there is too complex and it looks like an inifite
loop.

So, simplify the logic and implement it as a for loop.

This gets rid of the following checkpatch.pl warnings:

WARNING: else is not generally useful after a break or return
+			return LG3306_UNLOCK;
+		} else {

WARNING: else is not generally useful after a break or return
+			return LG3306_UNLOCK;
+		} else {

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:13 -03:00
Mauro Carvalho Chehab 097117cab5 [media] lbdt3306a: rework at printk macros
Use pr_foo() where there's a direct replacement. For debug, use
custom-made macros, for now, as there are 3 different debug levels.

We should get rid of those some day, specially since several such
macros can be just removed, as Kernel trace would provide about
the same output.

This gets rid of some checkpatch errors:

WARNING: Prefer [subsystem eg: netdev]_info([subsystem]dev, ... then dev_info(dev, ... then pr_info(...  to printk(KERN_INFO ...
+#define lg_info(fmt, arg...)	printk(KERN_INFO "lgdt3306a: " fmt, ##arg)

ERROR: Macros with complex values should be enclosed in parentheses
+#define lg_dbg(fmt, arg...) if (debug & DBG_INFO)			\
+				lg_printk(KERN_DEBUG,         fmt, ##arg)

ERROR: Macros with complex values should be enclosed in parentheses
+#define lg_reg(fmt, arg...) if (debug & DBG_REG)			\
+				lg_printk(KERN_DEBUG,         fmt, ##arg)

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:13 -03:00
Mauro Carvalho Chehab e2c47fa7dd [media] lgdt3306a: Remove FSF address
Fix this CodingStyle error:

	ERROR: Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so ag$
	#56: FILE: drivers/media/dvb-frontends/lgdt3306a.c:19:
	+ *    along with this program; if not, write to the Free Software$

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:13 -03:00
Mauro Carvalho Chehab ee0133eea0 [media] lgdt3306a: properly handle I/O errors
Fixes the following smatch errors:

drivers/media/dvb-frontends/lgdt3306a.c: In function 'lgdt3306a_set_if':
drivers/media/dvb-frontends/lgdt3306a.c:695:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
  int ret;
      ^
drivers/media/dvb-frontends/lgdt3306a.c: In function 'lgdt3306a_monitor_vsb':
drivers/media/dvb-frontends/lgdt3306a.c:1033:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
  int ret;
      ^
drivers/media/dvb-frontends/lgdt3306a.c: In function 'lgdt3306a_check_oper_mode':
drivers/media/dvb-frontends/lgdt3306a.c:1082:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
  int ret;
      ^
drivers/media/dvb-frontends/lgdt3306a.c: In function 'lgdt3306a_check_lock_status':
drivers/media/dvb-frontends/lgdt3306a.c:1109:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
  int ret;
      ^
drivers/media/dvb-frontends/lgdt3306a.c: In function 'lgdt3306a_check_neverlock_status':
drivers/media/dvb-frontends/lgdt3306a.c:1185:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
  int ret;
      ^
drivers/media/dvb-frontends/lgdt3306a.c: In function 'lgdt3306a_pre_monitoring':
drivers/media/dvb-frontends/lgdt3306a.c:1199:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
  int ret;
      ^
drivers/media/dvb-frontends/lgdt3306a.c: In function 'lgdt3306a_get_packet_error':
drivers/media/dvb-frontends/lgdt3306a.c:1310:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
  int ret;
      ^

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:12 -03:00
Mauro Carvalho Chehab a132fef816 [media] lgdt3306a: don't go past the buffer
As warned by smatch:
	drivers/media/dvb-frontends/lgdt3306a.c:1354 log10_x1000() error: buffer overflow 'valx_x10' 14 <= 14
	drivers/media/dvb-frontends/lgdt3306a.c:1355 log10_x1000() error: buffer overflow 'log10x_x1000' 14 <= 14

There's a potential of returning a value out of the buffer. Fix it.

While here, remove the ugly braced block.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:12 -03:00
Mauro Carvalho Chehab 15c546e1c8 [media] lgdt3306a: one bit fields should be unsigned
Fix two smatch warnings:
	drivers/media/dvb-frontends/lgdt3306a.h:53:28: error: dubious one-bit signed bitfield
	drivers/media/dvb-frontends/lgdt3306a.h:56:33: error: dubious one-bit signed bitfield

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:12 -03:00
Mauro Carvalho Chehab c43e651205 [media] lgdt3306a: Use IS_ENABLED() for attach function
Simplify the check if CONFIG_DVB_LGDT3306A is enabled, use the
IS_ENABLED() macro, just like the other frontend modules.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:12 -03:00
Mauro Carvalho Chehab 4937ba94a0 [media] lgdt3306a: Use hexadecimal values in lowercase
While this is not a mandatory rule at the CodingStyle, we prefer
hexadecimal values in lowercase. Currently, there's a mix of lowercase
and uppercase ons at lgdt3306a. So, convert all to lowercase with this
small script:

	perl -ne 'if (m,0x([\dA-F]+),) { $o=$1; $n=lc $1; s,0x($o),0x$n, } print $_'

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:11 -03:00
Michael Ira Krufky 34a5a2f811 [media] lgdt3306a: more small whitespace cleanups
Just CodingStyle. No functional changes.

Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:11 -03:00
Michael Ira Krufky 831a91120a [media] lgdt3306a: typo fix
fix WARNING: 'supress' may be misspelled - perhaps 'suppress'?

Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:11 -03:00
Michael Ira Krufky cb4671c87f [media] lgdt3306a: fix WARNING: please, no spaces at the start of a line
Properly indent register initialization tables.

Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:10 -03:00
Michael Ira Krufky 6da7ac9857 [media] lgdt3306a: fix ERROR: do not use C99 // comments
Replace C99 comments by /* */ blocks.

Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:10 -03:00
Michael Ira Krufky f883d603d4 [media] lgdt3306a: do not add new typedefs
We should not be using typedefs at the Kernel, as this makes harder
for reviewers to understand the code.

Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:10 -03:00
Michael Ira Krufky ae21e44777 [media] lgdt3306a: fix ERROR: do not use assignment in if condition
Just CodingStyle fix.

Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:09 -03:00
Michael Ira Krufky ebd9175ea4 [media] lgdt3306a: move EXPORT_SYMBOL to be just after function
Fixes CodingStyle error:
	WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable.

Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:09 -03:00
Michael Ira Krufky c714efe458 [media] lgdt3306a: remove unnecessary 'else'
No need for an else, as the previous if will return.

Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:09 -03:00
Michael Ira Krufky 8e8cd34eaa [media] lgdt3306a: clean up whitespace & unneeded brackets
No functional changes.

Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:08 -03:00
Fred Richter b63b36fa44 [media] DVB: add support for LG Electronics LGDT3306A ATSC/QAM-B Demodulator
This ATSC/QAM-B demodulator is used by several new devices.

Add support for it. Other patches will fix CodingStyle issues.

Signed-off-by: Fred Richter <frichter@hauppauge.com>
Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:08 -03:00
Hans Verkuil 2438e78a48 [media] v4l2-core: drop g/s_priority ops
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 17:09:43 -03:00
Hans Verkuil cee05cb359 [media] pvrusb2: use struct v4l2_fh
By using struct v4l2_fh both the prio handling and the linked list
implementation in pvrusb2 can be removed since both are now done in
the v4l2 core if you use struct v4l2_fh.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Tested-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02 17:08:48 -03:00
Hans Verkuil 5cf6f7f327 [media] v4l2-core: remove the old .ioctl BKL replacement
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 17:06:56 -03:00
Hans Verkuil ab91c61129 [media] pvrusb2: replace .ioctl by .unlocked_ioctl
As far as I can tell pvrusb2 does its own locking, so there is
no need to use .ioctl.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02 17:03:42 -03:00
Pablo Anton b44b2e06ae [media] media: i2c: ADV7604: Rename adv7604 prefixes
It is confusing which parts of the driver are adv7604 specific, adv7611
specific or common for both. This patch renames any adv7604 prefixes (both
for functions and defines) to adv76xx whenever they are common.

Signed-off-by: Pablo Anton <pablo.anton@vodalys-labs.com>
Signed-off-by: Jean-Michel Hautbois <jean-michel.hautbois@vodalys.com>
[hans.verkuil@cisco.com: rebased and renamed ADV76xx_fsc to ADV76XX_FSC]
[hans.verkuil@cisco.com: kept the existing adv7604 driver name]
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02 16:59:32 -03:00
Nicholas Mc Guire c973f76e7e [media] media: radio: handle timeouts
Add handling for timeout case.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02 16:50:42 -03:00
Nicholas Mc Guire daa939db21 [media] media: radio: assign wait_for_completion_timeout to appropriately typed var
wait_for_completion_timeout() returns unsigned long not int. This assigns
the return value to an appropriately typed variable (also helps keep
static code checkers happy).

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02 16:49:58 -03:00
jean-michel.hautbois@vodalys.com 80f4944ec2 [media] media: adv7604: CP CSC uses a different register on adv7604 and adv7611
The bits are the same, but register is 0xf4 on ADV7611 instead of 0xfc.
When reading back the value in log_status, differentiate both.

Signed-off-by: Jean-Michel Hautbois <jean-michel.hautbois@vodalys.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02 14:56:21 -03:00
Nicholas Mc Guire 61765a5032 [media] si470x: fixup wait_for_completion_timeout return handling
return type of wait_for_completion_timeout is unsigned long not int. A
appropriately named variable of type unsigned long is added and the
assignments fixed up.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02 14:55:44 -03:00
jean-michel.hautbois@vodalys.com 5851462531 [media] media: i2c: ADV7604: In free run mode, signal is locked
The CP_NON_STD_VIDEO bit indicates an input not aligned with DV timings.
If there is no input, and chip is in free run mode, consider we are locked.

Signed-off-by: Jean-Michel Hautbois <jean-michel.hautbois@vodalys.com>
[hans.verkuil@cisco.com: put both conditions in one 'if']
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02 14:54:22 -03:00
Markus Elfring 8aa9eb9059 [media] au0828: Delete unnecessary checks before the function call "video_unregister_device"
The video_unregister_device() 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: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02 14:53:46 -03:00
Markus Elfring 704b3f4c11 [media] stk-webcam: Delete an unnecessary check before the function call "vfree"
The vfree() function performs also input parameter validation.
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: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02 14:53:27 -03:00
Prashant Laddha d585c1e14a [media] vivid sdr: fix broken sine tone generated for sdr FM
FM (frequency modulated) signal for SDR is generated by varying the
phase, where phase variation is proportional to input signal. It is
seen that, the larger phase increments leads to discontinuities in
the signal recovered after demodulation. Reducing the extent of phase
variation with respect to input signal, equivalent to reducing the
modulation index.

Tested using FM receiver flow graph in gnuradio-companion.

Cc: Antti Palosaari <crope@iki.fi>
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-03-02 14:53:04 -03:00
Prashant Laddha 4e30a37345 [media] vivid sdr: Use LUT based implementation for sin/cos()
The common implementation for sin/cos in include/linux/fixp-arith.h
has been improved recently to provide higher precision.

Replacing native implementation of sin/cos in vivid sdr with common
implementation. This serves two purposes:

1. Improved accuracy: the native implementation based on the Taylor
   series is more prone to rounding errors.
2. Reuse of common function: this is better compared to maintaining
   native versions for each driver.

Suggested by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Cc: Antti Palosaari <crope@iki.fi>
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-03-02 14:51:32 -03:00
Mauro Carvalho Chehab 559addc25b [media] fixp-arith: replace sin/cos table by a better precision one
The cos table used at fixp-arith.h has only 8 bits of precision.
That causes problems if it is reused on other drivers.

As some media drivers require a higher precision sin/cos
implementation, replace the current implementation by one that
will provide 32 bits precision.

The values generated by the new implementation matches the
32 bit precision of glibc's sin for an angle measured in
integer degrees.

It also provides support for fractional angles via linear
interpolation. On experimental calculus, when used a table
with a 0.001 degree angle, the maximum error for sin is
0.000038, which is likely good enough for practical purposes.

There are some logic there that seems to be specific to the
usage inside ff-memless.c. Move those logic to there, as they're
not needed elsewhere.

Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Signed-off-by: Prashant Laddha <prladdha@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02 14:50:06 -03:00
Christian Engelmayer 96df988bb9 [media] cx88: Fix possible leak in cx8802_probe()
In case allocation vb2_dma_sg_init_ctx() fails during cx8802_probe(), the
already allocated cx8802 device structure memory is not freed in the used
exit path. Thus adapt the cleanup handling accordingly. Detected by Coverity
CID 1260065.

Signed-off-by: Christian Engelmayer <cengelma@gmx.at>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02 14:47:19 -03:00
Alexey Khoroshilov 2160abb294 [media] sh_vou: fix memory leak on error paths in sh_vou_open()
Memory allocated for sh_vou_file is not deallocated
on error paths in sh_vou_open().

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02 14:46:48 -03:00
Geert Uytterhoeven 50d8e46faf [media] timberdale: VIDEO_TIMBERDALE should depend on HAS_DMA
If NO_DMA=y:

    warning: (VIDEO_OMAP2_VOUT && VIDEO_VIU && VIDEO_TIMBERDALE) selects VIDEOBUF_DMA_CONTIG which has unmet direct dependencies (MEDIA_SUPPORT && HAS_DMA)

    drivers/built-in.o: In function `__videobuf_dc_free':
    videobuf-dma-contig.c:(.text+0x6f4d32): undefined reference to `dma_free_coherent'
    drivers/built-in.o: In function `__videobuf_dc_alloc':
    videobuf-dma-contig.c:(.text+0x6f4fe6): undefined reference to `dma_alloc_coherent'
    drivers/built-in.o: In function `__videobuf_mmap_mapper':
    videobuf-dma-contig.c:(.text+0x6f518e): undefined reference to `dma_free_coherent'

Commit 244829226f ("[media] timberdale: do not select TIMB_DMA")
dropped the dependency of VIDEO_TIMBERDALE on DMADEVICES, and thus the
implicit dependency on HAS_DMA.  VIDEO_TIMBERDALE selects
VIDEOBUF_DMA_CONTIG, which bypasses its dependency on HAS_DMA.  Make
VIDEO_TIMBERDALE depend on HAS_DMA to fix this.

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-03-02 14:40:40 -03:00
Geert Uytterhoeven a5d7c92c1b [media] am437x: VIDEO_AM437X_VPFE should depend on HAS_DMA
If NO_DMA=y:

    warning: (VIDEO_AM437X_VPFE && VIDEO_DM365_VPFE && VIDEO_DT3155 && VIDEO_OMAP4) selects VIDEOBUF2_DMA_CONTIG which has unmet direct dependencies (MEDIA_SUPPORT && HAS_DMA)

    drivers/media/v4l2-core/videobuf2-dma-contig.c: In function ‘vb2_dc_mmap’:
    drivers/media/v4l2-core/videobuf2-dma-contig.c:207: error: implicit declaration of function ‘dma_mmap_coherent’
    drivers/media/v4l2-core/videobuf2-dma-contig.c: In function ‘vb2_dc_get_base_sgt’:
    drivers/media/v4l2-core/videobuf2-dma-contig.c:390: error: implicit declaration of function ‘dma_get_sgtable’

VIDEO_AM437X_VPFE selects VIDEOBUF2_DMA_CONTIG, which bypasses its
dependency on HAS_DMA.  Make VIDEO_AM437X_VPFE depend on HAS_DMA to fix
this.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02 14:40:18 -03:00
Nicholas Mc Guire 9713883b0f [media] cx231xx: drop condition with no effect
The if and the else code are identical - so the condition has no effect
on the effective code.
This patch removes the condition and the duplicated code.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02 14:39:32 -03:00
Mauro Carvalho Chehab f704eab5b6 [media] siano: avoid a linkedit error if !MC
If the media controller (MC) is not enabled, it will compile
fine, but will fail at the linkedition:

 ERROR: "media_device_unregister" [drivers/media/usb/siano/smsusb.ko] undefined!

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02 14:17:01 -03:00
Mauro Carvalho Chehab 89a2c1d60a [media] use a function for DVB media controller register
This is really a simple function, but using it avoids to have
if's inside the drivers.

Also, the kABI becomes a little more clearer.

This shouldn't generate any overhead, and the type check
will happen when compiling with MC DVB enabled.

So, let's do it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02 11:29:39 -03:00