sfrench/cifs-2.6.git
5 years agomedia: cec-gpio.txt: add v5-gpios for testing the 5V line
Hans Verkuil [Thu, 28 Jun 2018 11:42:57 +0000 (07:42 -0400)]
media: cec-gpio.txt: add v5-gpios for testing the 5V line

In order to debug the HDMI 5V line we need to add a new v5-gpios
property.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: v4l: rcar_fdp1: Enable compilation on Gen2 platforms
Laurent Pinchart [Wed, 11 Jul 2018 14:23:32 +0000 (10:23 -0400)]
media: v4l: rcar_fdp1: Enable compilation on Gen2 platforms

Commit 1d3897143815 ("[media] v4l: rcar_fdp1: add FCP dependency") fixed
a compilation breakage when the optional VIDEO_RENESAS_FCP dependency is
compiled as a module while the rcar_fdp1 driver is built in. As a side
effect it disabled compilation on Gen2 by disallowing the valid
combination ARCH_RENESAS && !VIDEO_RENESAS_FCP. Fix it by handling the
dependency the same way the vsp1 driver did in commit 199946731fa4
("[media] vsp1: clarify FCP dependency").

Fixes: 1d3897143815 ("[media] v4l: rcar_fdp1: add FCP dependency")
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: platform: meson-ao-cec: make busy TX warning silent
Neil Armstrong [Tue, 10 Jul 2018 13:44:57 +0000 (09:44 -0400)]
media: platform: meson-ao-cec: make busy TX warning silent

Switch to dev_dbg for the busy TX message to avoid having a flood of:
[  228.064570] meson-ao-cec c8100100.cec: meson_ao_cec_transmit: busy TX: aborting
[  230.368489] meson-ao-cec c8100100.cec: meson_ao_cec_transmit: busy TX: aborting
[  234.208655] meson-ao-cec c8100100.cec: meson_ao_cec_transmit: busy TX: aborting
[  236.512558] meson-ao-cec c8100100.cec: meson_ao_cec_transmit: busy TX: aborting

This message is only a debug hint and not an error.

Fixes: 7ec2c0f72cb1 ("media: platform: Add Amlogic Meson AO CEC Controller driver")
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: videobuf2-core: check for q->error in vb2_core_qbuf()
Hans Verkuil [Thu, 5 Jul 2018 08:25:19 +0000 (04:25 -0400)]
media: videobuf2-core: check for q->error in vb2_core_qbuf()

The vb2_core_qbuf() function didn't check if q->error was set. It is
checked in __buf_prepare(), but that function isn't called if the buffer
was already prepared before with VIDIOC_PREPARE_BUF.

So check it at the start of vb2_core_qbuf() as well.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: sh: migor: Remove stale soc_camera include
Jacopo Mondi [Wed, 4 Jul 2018 10:15:46 +0000 (06:15 -0400)]
media: sh: migor: Remove stale soc_camera include

Remove a stale inclusion for the soc_camera header.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: mem2mem: Make .job_abort optional
Ezequiel Garcia [Mon, 18 Jun 2018 04:38:52 +0000 (00:38 -0400)]
media: mem2mem: Make .job_abort optional

Implementing job_abort() does not make sense on some drivers.
This is not a problem, as the abort is not required to
wait for the job to finish. Quite the opposite, drivers
are encouraged not to wait.

Demote v4l2_m2m_ops.job_abort from required to optional, and
clean all drivers with dummy implementations.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: s5p-g2d: Remove unrequired wait in .job_abort
Ezequiel Garcia [Mon, 18 Jun 2018 04:38:51 +0000 (00:38 -0400)]
media: s5p-g2d: Remove unrequired wait in .job_abort

As per the documentation, job_abort is not required
to wait until the current job finishes. It is redundant
to do so, as the core will perform the wait operation.

Remove the wait infrastructure completely.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rcar_jpu: Remove unrequired wait in .job_abort
Ezequiel Garcia [Mon, 18 Jun 2018 04:38:50 +0000 (00:38 -0400)]
media: rcar_jpu: Remove unrequired wait in .job_abort

As per the documentation, job_abort is not required
to wait until the current job finishes. It is redundant
to do so, as the core will perform the wait operation.

Remove the wait infrastructure completely.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Acked-by: Mikhail Ulyanov <mikhail.ulyanov@cogentembedded.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: video-mux: fix compliance failures
Philipp Zabel [Thu, 24 May 2018 14:50:44 +0000 (10:50 -0400)]
media: video-mux: fix compliance failures

Limit frame sizes to the [1, 65536] interval, media bus formats to
the available list of formats, and initialize pad and try formats.

Reported-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Tested-by: Rui Miguel Silva <rui.silva@linaro.org>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: v4l: Add support for STD ioctls on subdev nodes
Niklas Söderlund [Thu, 17 May 2018 14:30:16 +0000 (10:30 -0400)]
media: v4l: Add support for STD ioctls on subdev nodes

There is no way to control the standard of subdevices which are part of
a media device. The ioctls which exists all target video devices
explicitly and the idea is that the video device should talk to the
subdevice. For subdevices part of a media graph this is not possible and
the standard must be controlled on the subdev device directly.

Add four new ioctls to be able to directly interact with subdevices and
control the video standard; VIDIOC_SUBDEV_ENUMSTD, VIDIOC_SUBDEV_G_STD,
VIDIOC_SUBDEV_S_STD and VIDIOC_SUBDEV_QUERYSTD.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: v4l: i2c: Replace "sensor-level" by "sensor"
Sakari Ailus [Mon, 16 Jul 2018 15:20:33 +0000 (11:20 -0400)]
media: v4l: i2c: Replace "sensor-level" by "sensor"

A lot of sensor drivers are labelled as "sensor-level" drivers. That's
odd and somewhat confusing as the term isn't used elsewhere: these are
just sensor drivers. Call them such.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: i2c: ov7670: Put ep fwnode after use
Jacopo Mondi [Thu, 31 May 2018 17:35:03 +0000 (13:35 -0400)]
media: i2c: ov7670: Put ep fwnode after use

The just parsed endpoint fwnode has to be put after use.
Currently this is done only in error handling path. Fix that by
putting node unconditionally after use.

Fixes: 01b8444828fc ("media: v4l2: i2c: ov7670: Implement OF mbus configuration")
Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: ov5645: Supported external clock is 24MHz
Todor Tomov [Mon, 18 Jun 2018 08:06:58 +0000 (04:06 -0400)]
media: ov5645: Supported external clock is 24MHz

The external clock frequency was set to 23.88MHz by mistake
because of a platform which cannot get closer to 24MHz.
The supported by the driver external clock is 24MHz so
set it correctly and also fix the values of the pixel
clock and link clock.
However allow 1% tolerance to the external clock as this
difference is small enough to be insignificant.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rcar-vin: Handle data-enable polarity
Jacopo Mondi [Mon, 9 Jul 2018 14:19:21 +0000 (10:19 -0400)]
media: rcar-vin: Handle data-enable polarity

Handle data-enable signal polarity. If the polarity is not specifically
requested to be active low, use the active high default.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: dt-bindings: media: rcar-vin: Add 'data-enable-active'
Jacopo Mondi [Mon, 9 Jul 2018 14:19:20 +0000 (10:19 -0400)]
media: dt-bindings: media: rcar-vin: Add 'data-enable-active'

Describe optional endpoint property 'data-enable-active' for R-Car VIN.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: v4l2-fwnode: parse 'data-enable-active' prop
Jacopo Mondi [Mon, 9 Jul 2018 14:19:19 +0000 (10:19 -0400)]
media: v4l2-fwnode: parse 'data-enable-active' prop

Parse the newly defined 'data-enable-active' property in parallel
endpoint parsing function.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: dt-bindings: media: Document data-enable-active property
Jacopo Mondi [Mon, 9 Jul 2018 14:19:18 +0000 (10:19 -0400)]
media: dt-bindings: media: Document data-enable-active property

Add 'data-enable-active' property to endpoint node properties list.

The property allows to specify the polarity of the data-enable signal,
which when in active state determinates when data lines have to sampled
for valid pixel data.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: dt-bindings: media: rcar-vin: Describe optional ep properties
Jacopo Mondi [Mon, 9 Jul 2018 14:19:17 +0000 (10:19 -0400)]
media: dt-bindings: media: rcar-vin: Describe optional ep properties

Describe the optional endpoint properties for endpoint nodes of the R-Car
VIN interface device tree bindings documentation.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: dt-bindings: media: rcar-vin: Align Gen2 and Gen3
Jacopo Mondi [Mon, 9 Jul 2018 14:19:16 +0000 (10:19 -0400)]
media: dt-bindings: media: rcar-vin: Align Gen2 and Gen3

Align description of the Gen2 and Gen3 bindings for parallel input.
This commit prepares for description of optional endpoint properties in ports
subnodes accepting parallel video connections.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: smiapp: fix debug message
Luca Ceresoli [Thu, 5 Jul 2018 14:41:11 +0000 (10:41 -0400)]
media: smiapp: fix debug message

ask_h gets printed here instead of ask_w.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: ov5640: do not change mode if format or frame interval is unchanged
Hugues Fruchet [Wed, 4 Jul 2018 13:04:38 +0000 (09:04 -0400)]
media: ov5640: do not change mode if format or frame interval is unchanged

Save load of mode registers array when V4L2 client sets a format or a
frame interval which selects the same mode than the current one.

Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: smiapp: Set correct MODULE_LICENSE
Sakari Ailus [Tue, 3 Jul 2018 13:54:39 +0000 (09:54 -0400)]
media: smiapp: Set correct MODULE_LICENSE

The smiapp driver is licensed under GNU GPL v2 only, as stated by the
header. Reflect this in the MODULE_LICENSE macro.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: bpf: ensure bpf program is freed on detach
Sean Young [Wed, 4 Jul 2018 14:57:58 +0000 (10:57 -0400)]
media: bpf: ensure bpf program is freed on detach

Currently we are leaking bpf programs when they are detached from the
lirc device; the refcount never reaches zero.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: exynos4-is: Prevent NULL pointer dereference in __isp_video_try_fmt()
Sylwester Nawrocki [Tue, 15 May 2018 09:21:45 +0000 (05:21 -0400)]
media: exynos4-is: Prevent NULL pointer dereference in __isp_video_try_fmt()

This patch fixes potential NULL pointer dereference as indicated
by the following static checker warning:

drivers/media/platform/exynos4-is/fimc-isp-video.c:408 isp_video_try_fmt_mplane()
error: NULL dereference inside function '__isp_video_try_fmt(isp, &f->fmt.pix_mp, (0))()'.

Fixes: 34947b8aebe3: ("[media] exynos4-is: Add the FIMC-IS ISP capture DMA driver")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: platform: s5p-mfc: simplify getting .drvdata
Wolfram Sang [Thu, 19 Apr 2018 14:05:57 +0000 (10:05 -0400)]
media: platform: s5p-mfc: simplify getting .drvdata

We should get drvdata from struct device directly. Going via
platform_device is an unneeded step back and forth.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: platform: exynos4-is: simplify getting .drvdata
Wolfram Sang [Thu, 19 Apr 2018 14:05:56 +0000 (10:05 -0400)]
media: platform: exynos4-is: simplify getting .drvdata

We should get drvdata from struct device directly. Going via
platform_device is an unneeded step back and forth.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: tuner-simple: allow setting mono radio mode
Maciej S. Szmigiero [Mon, 2 Jul 2018 21:23:24 +0000 (17:23 -0400)]
media: tuner-simple: allow setting mono radio mode

For some types of tuners (Philips FMD1216ME(X) MK3 currently) we know that
letting TDA9887 output port 1 remain high (inactive) will switch FM radio
to mono mode.
Let's make use of this functionality - nothing changes for the default
stereo radio mode.

Tested on a Medion 95700 board which has a FMD1216ME tuner.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: cx25840: add kernel-doc description of struct cx25840_state
Maciej S. Szmigiero [Mon, 2 Jul 2018 21:23:22 +0000 (17:23 -0400)]
media: cx25840: add kernel-doc description of struct cx25840_state

This commit describes a device instance private data of the driver
(struct cx25840_state) in a kernel-doc style comment.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: ivtv: zero-initialize cx25840 platform data
Maciej S. Szmigiero [Mon, 2 Jul 2018 21:23:21 +0000 (17:23 -0400)]
media: ivtv: zero-initialize cx25840 platform data

We need to zero-initialize cx25840 platform data structure to make sure
that its future members do not contain random stack garbage.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: mtk-vcodec: Support VP9 profile in decoder
Keiichi Watanabe [Mon, 18 Jun 2018 07:58:54 +0000 (03:58 -0400)]
media: mtk-vcodec: Support VP9 profile in decoder

Add V4L2_CID_MPEG_VIDEO_VP9_PROFILE control in MediaTek decoder's
driver. MediaTek decoder only supports profile 0 for now.

Signed-off-by: Keiichi Watanabe <keiichiw@chromium.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: v4l2-ctrl: Add control for VP9 profile
Keiichi Watanabe [Mon, 18 Jun 2018 07:58:53 +0000 (03:58 -0400)]
media: v4l2-ctrl: Add control for VP9 profile

Add a new control V4L2_CID_MPEG_VIDEO_VP9_PROFILE for VP9 profiles. This control
allows selecting the desired profile for VP9 encoder and querying for supported
profiles by VP9 encoder/decoder.

Though this control is similar to V4L2_CID_MPEG_VIDEO_VP8_PROFILE, we need to
separate this control from it because supported profiles usually differ between
VP8 and VP9.

Signed-off-by: Keiichi Watanabe <keiichiw@chromium.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: v4l2-ctrl: Change control for VP8 profile to menu control
Keiichi Watanabe [Mon, 18 Jun 2018 07:58:52 +0000 (03:58 -0400)]
media: v4l2-ctrl: Change control for VP8 profile to menu control

Add a menu control V4L2_CID_MPEG_VIDEO_VP8_PROFILE for VP8 profile and make
V4L2_CID_MPEG_VIDEO_VPX_PROFILE an alias of it. This new control is used to
select the desired profile for VP8 encoder and query for supported profiles by
VP8 encoder/decoder.

Though we have originally a control V4L2_CID_MPEG_VIDEO_VPX_PROFILE and its name
contains 'VPX', it works only for VP8 because supported profiles usually differ
between VP8 and VP9. In addition, this control cannot be used for querying since
it is not a menu control but an integer control, which cannot return an
arbitrary set of supported profiles.

The new control V4L2_CID_MPEG_VIDEO_VP8_PROFILE is a menu control as with
controls for other codec profiles. (e.g. H264)

In addition, this patch also fixes the use of V4L2_CID_MPEG_VIDEO_VPX_PROFILE in
drivers of Qualcomm's venus and Samsung's s5p-mfc.

Signed-off-by: Keiichi Watanabe <keiichiw@chromium.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: imx: add support for RGB565_2X8 on parallel bus
Jan Luebbe [Fri, 18 May 2018 13:56:39 +0000 (09:56 -0400)]
media: imx: add support for RGB565_2X8 on parallel bus

The IPU can only capture RGB565 with two 8-bit cycles in bayer/generic
mode on the parallel bus, compared to a specific mode on MIPI CSI-2.
To handle this, we extend imx_media_pixfmt with a cycles per pixel
field, which is used for generic formats on the parallel bus.

Based on the selected format and bus, we then update the width to
account for the multiple cycles per pixel.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: imx: capture: refactor enum_/try_fmt
Jan Luebbe [Fri, 18 May 2018 13:56:38 +0000 (09:56 -0400)]
media: imx: capture: refactor enum_/try_fmt

By checking and handling the internal IPU formats (ARGB or AYUV) first,
we don't need to check whether it's a bayer format, as we can default to
passing the input format on in all other cases.

This simplifies handling the different configurations for RGB565 between
parallel and MIPI CSI-2, as we don't need to check the details of the
format anymore.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Steve Longerbeam <steve_longerbeam@mentor.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging/imx: fill vb2_v4l2_buffer sequence entry
Peter Seiderer [Thu, 15 Mar 2018 19:13:23 +0000 (15:13 -0400)]
media: staging/imx: fill vb2_v4l2_buffer sequence entry

- enables gstreamer v4l2src lost frame detection, e.g:

  0:00:08.685185668  348  0x54f520 WARN  v4l2src gstv4l2src.c:970:gst_v4l2src_create:<v4l2src0> lost frames detected: count = 141 - ts: 0:00:08.330177332

- fixes v4l2-compliance test failure:

  Streaming ioctls:
          test read/write: OK (Not Supported)
              Video Capture:
                  Buffer: 0 Sequence: 0 Field: None Timestamp: 92.991450s
                  Buffer: 1 Sequence: 0 Field: None Timestamp: 93.008135s
                  fail: v4l2-test-buffers.cpp(294): (int)g_sequence() < seq.last_seq + 1
                  fail: v4l2-test-buffers.cpp(707): buf.check(q, last_seq)

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
Reviewed-by: Steve Longerbeam <steve_longerbeam@mentor.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging/imx: fill vb2_v4l2_buffer field entry
Peter Seiderer [Thu, 15 Mar 2018 19:13:22 +0000 (15:13 -0400)]
media: staging/imx: fill vb2_v4l2_buffer field entry

- fixes gstreamer v4l2src warning:

  0:00:00.716640334  349  0x164f720 WARN  v4l2bufferpool gstv4l2bufferpool.c:1195:gst_v4l2_buffer_pool_dqbuf:<v4l2src0:pool:src> Driver should never set v4l2_buffer.field to ANY

- fixes v4l2-compliance test failure:

  Streaming ioctls:
          test read/write: OK (Not Supported)
              Video Capture:
                  Buffer: 0 Sequence: 0 Field: Any Timestamp: 58.383658s
                  fail: v4l2-test-buffers.cpp(297): g_field() == V4L2_FIELD_ANY

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
Reviewed-by: Steve Longerbeam <steve_longerbeam@mentor.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: dt-bindings: media: rcar-vin: Add R8A77995 support
Jacopo Mondi [Wed, 4 Jul 2018 08:51:36 +0000 (04:51 -0400)]
media: dt-bindings: media: rcar-vin: Add R8A77995 support

Add compatible string for R-Car D3 R8A7795 to list of SoCs supported by
rcar-vin driver.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rcar-vin: Add support for R-Car R8A77995 SoC
Jacopo Mondi [Tue, 12 Jun 2018 09:43:32 +0000 (05:43 -0400)]
media: rcar-vin: Add support for R-Car R8A77995 SoC

Add R-Car R8A77995 SoC to the rcar-vin supported ones.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rcar-vin: Rename _rcar_info to rcar_info
Jacopo Mondi [Tue, 12 Jun 2018 09:43:31 +0000 (05:43 -0400)]
media: rcar-vin: Rename _rcar_info to rcar_info

Remove leading underscore to align all rcar_group_route structure
declarations.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rcar-vin: Handle parallel subdev in link_notify
Jacopo Mondi [Tue, 12 Jun 2018 09:43:30 +0000 (05:43 -0400)]
media: rcar-vin: Handle parallel subdev in link_notify

Handle parallel subdevices in link_notify callback. If the notified link
involves a parallel subdevice, do not change routing of the VIN-CSI-2
devices and mark the VIN instance as using a parallel input. If the
CSI-2 link setup succeeds instead, mark the VIN instance as using CSI-2.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rcar-vin: Link parallel input media entities
Jacopo Mondi [Tue, 12 Jun 2018 09:43:29 +0000 (05:43 -0400)]
media: rcar-vin: Link parallel input media entities

When running with media-controller link the parallel input
media entities with the VIN entities at 'complete' callback time.

To create media links the v4l2_device should be registered first.
Check if the device is already registered, to avoid double registrations.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rcar-vin: Parse parallel input on Gen3
Jacopo Mondi [Tue, 12 Jun 2018 09:43:28 +0000 (05:43 -0400)]
media: rcar-vin: Parse parallel input on Gen3

The rcar-vin driver so far had a mutually exclusive code path for
handling parallel and CSI-2 video input subdevices, with only the CSI-2
use case supporting media-controller. As we add support for parallel
inputs to Gen3 media-controller compliant code path now parse both port@0
and port@1, handling the media-controller use case in the parallel
bound/unbind notifier operations.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rcar-vin: Cache the mbus configuration flags
Jacopo Mondi [Tue, 12 Jun 2018 09:43:27 +0000 (05:43 -0400)]
media: rcar-vin: Cache the mbus configuration flags

Media bus configuration flags and media bus type were so far a property
of each VIN instance, as the subdevice they were connected to was
immutable during the whole system life time.

With the forth-coming introduction of parallel input devices support,
a VIN instance can have the subdevice it is connected to switched at
runtime, from a CSI-2 subdevice to a parallel one and viceversa, through
the modification of links between media entities in the media controller
graph. To avoid discarding the per-subdevice configuration flags retrieved by
v4l2_fwnode parsing facilities, cache them in the 'rvin_graph_entity'
member of each VIN instance, opportunely renamed to 'rvin_parallel_entity'.

Also modify the register configuration function to take mbus flags into
account when running on a bus type that supports them.

The media bus type currently in use will be updated in a follow-up patch
to the link state change notification function.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rcar-vin: Cleanup notifier in error path
Jacopo Mondi [Tue, 12 Jun 2018 09:43:26 +0000 (05:43 -0400)]
media: rcar-vin: Cleanup notifier in error path

During the notifier initialization, memory for the list of associated async
subdevices is reserved during the fwnode endpoint parsing from the v4l2-async
framework. If the notifier registration fails, that memory should be released
and the notifier 'cleaned up'.

Catch the notifier registration error and perform the cleanup both for the
group and the parallel notifiers.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rcar-vin: Create a group notifier
Jacopo Mondi [Tue, 12 Jun 2018 09:43:25 +0000 (05:43 -0400)]
media: rcar-vin: Create a group notifier

As CSI-2 subdevices are shared between several VIN instances, a shared
notifier to collect the CSI-2 async subdevices is required. So far, the
rcar-vin driver used the notifier of the last VIN instance to probe but
with the forth-coming introduction of parallel input subdevices support
in mc-compliant code path, each VIN may register its own notifier if any
parallel subdevice is connected there.

To avoid registering a notifier twice (once for parallel subdev and one
for the CSI-2 subdevs) create a group notifier, shared by all the VIN
instances.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rcar-vin: Remove two empty lines
Jacopo Mondi [Tue, 12 Jun 2018 09:43:24 +0000 (05:43 -0400)]
media: rcar-vin: Remove two empty lines

Remove un-necessary empty lines.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rcar-vin: Rename 'digital' to 'parallel'
Jacopo Mondi [Tue, 12 Jun 2018 09:43:23 +0000 (05:43 -0400)]
media: rcar-vin: Rename 'digital' to 'parallel'

As the term 'digital' is used all over the rcar-vin code in place of
'parallel', rename all the occurrencies.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: vim2m: add media device
Hans Verkuil [Mon, 2 Jul 2018 15:36:06 +0000 (11:36 -0400)]
media: vim2m: add media device

Request API requires a media node. Add one to the vim2m driver so we can
use requests with it.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: add helpers for memory-to-memory media controller
Ezequiel Garcia [Mon, 2 Jul 2018 15:36:05 +0000 (11:36 -0400)]
media: add helpers for memory-to-memory media controller

A memory-to-memory pipeline device consists in three
entities: two DMA engine and one video processing entities.
The DMA engine entities are linked to a V4L interface.

This commit add a new v4l2_m2m_{un}register_media_controller
API to register this topology.

For instance, a typical mem2mem device topology would
look like this:

Device topology
- entity 1: source (1 pad, 1 link)
            type Node subtype V4L flags 0
pad0: Source
-> "proc":1 [ENABLED,IMMUTABLE]

- entity 3: proc (2 pads, 2 links)
            type Node subtype Unknown flags 0
pad0: Source
-> "sink":0 [ENABLED,IMMUTABLE]
pad1: Sink
<- "source":0 [ENABLED,IMMUTABLE]

- entity 6: sink (1 pad, 1 link)
            type Node subtype V4L flags 0
pad0: Sink
<- "proc":0 [ENABLED,IMMUTABLE]

[hans.verkuil@cisco.com: mark interface links as IMMUTABLE]

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: mark entity-intf links as IMMUTABLE
Hans Verkuil [Mon, 2 Jul 2018 12:43:02 +0000 (08:43 -0400)]
media: mark entity-intf links as IMMUTABLE

Currently links between entities and an interface are just marked as
ENABLED. But (at least today) these links cannot be disabled by userspace
or the driver, so they should also be marked as IMMUTABLE.

It might become possible that drivers can disable such links (if for some
reason the device node cannot be used), so we might need to add a new link
flag at some point to mark interface links that can be changed by the driver
but not by userspace.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: v4l2-ctrls.c: fix broken auto cluster handling
Hans Verkuil [Fri, 29 Jun 2018 10:12:43 +0000 (06:12 -0400)]
media: v4l2-ctrls.c: fix broken auto cluster handling

When you switch from auto to manual mode for an auto-cluster (e.g.
autogain+gain controls), then the current HW value has to be copied
to the current control value. However, has_changed was never set to
true, so new_to_cur didn't actually copy this value.

Reported-by: Hugues FRUCHET <hugues.fruchet@st.com>
Tested-by: Hugues FRUCHET <hugues.fruchet@st.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: fsl-viu: fix error handling in viu_of_probe()
Alexey Khoroshilov [Fri, 29 Jun 2018 21:49:22 +0000 (17:49 -0400)]
media: fsl-viu: fix error handling in viu_of_probe()

viu_of_probe() ignores fails in i2c_get_adapter(),
tries to unlock uninitialized mutex on error path.

The patch streamlining the error handling in viu_of_probe().

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+samsung@kernel.org>
5 years agomedia: coda: mark CODA960 firmware version 2.1.9 as supported
Philipp Zabel [Fri, 29 Jun 2018 12:47:20 +0000 (08:47 -0400)]
media: coda: mark CODA960 firmware version 2.1.9 as supported

This patch adds the i.MX6 CODA960 firmware versions 2.1.9
(revision 32515) to the list of supported firmware versions.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: coda: jpeg: explicitly disable thumbnails in SEQ_INIT
Philipp Zabel [Fri, 29 Jun 2018 12:46:48 +0000 (08:46 -0400)]
media: coda: jpeg: explicitly disable thumbnails in SEQ_INIT

Explicitly clear DEC_SEQ_JPG_THUMB_EN during sequence initialization.
Not clearing the register does not cause problems, since the only other
codec (MPEG-4 decode) that writes to this register happens to always
write 0 as well.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: coda: jpeg: only queue two buffers into the bitstream for JPEG on CODA7541
Philipp Zabel [Fri, 29 Jun 2018 12:46:47 +0000 (08:46 -0400)]
media: coda: jpeg: only queue two buffers into the bitstream for JPEG on CODA7541

Padding the bitstream buffer is not enough to reliably avoid prefetch
failures.  Picture runs with the next buffer's header already visible to
the CODA7541 succeed much more reliably, so always queue two JPEG frames
into the bitstream buffer.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: coda: jpeg: allow non-JPEG colorspace
Philipp Zabel [Fri, 29 Jun 2018 12:46:46 +0000 (08:46 -0400)]
media: coda: jpeg: allow non-JPEG colorspace

The hardware codec is not colorspace aware. We should trust userspace to
set the correct colorimetry information on the OUTPUT queue and mirror
the exact same setting on the CAPTURE queue.

There is no reason to restrict colorspace to JPEG for JPEG images, if
userspace injects the correct colorspace information into the JPEG
headers after encoding.

Fixes: b14ac545688d ("[media] coda: improve colorimetry handling")
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: coda: clear hold flag on streamoff
Philipp Zabel [Fri, 29 Jun 2018 12:42:08 +0000 (08:42 -0400)]
media: coda: clear hold flag on streamoff

If new buffers are queued after streamoff, the flag will be cleared
anyway, so this is mostly for the purpose of correctness.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: vivid: fix gain when autogain is on
Hans Verkuil [Fri, 29 Jun 2018 09:40:41 +0000 (05:40 -0400)]
media: vivid: fix gain when autogain is on

In the vivid driver you want gain to continuous change while autogain
is on. However, dev->jiffies_vid_cap doesn't actually change. It probably
did in the past, but changes in the code caused this to be a fixed value
that is only set when you start streaming.

Replace it by jiffies, which is always changing.

[mchehab@kernel.org: use jiffies_to_msecs() instead of dividing by HZ]

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: coda: fix reorder detection for unknown levels
Philipp Zabel [Thu, 28 Jun 2018 15:47:09 +0000 (11:47 -0400)]
media: coda: fix reorder detection for unknown levels

Whether reordering should be enabled only depends on the h.264 profile.
Stop parsing the level and drop the debug message, profile and level
can now be determined via read-only decoder controls.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: coda: add read-only h.264 decoder profile/level controls
Philipp Zabel [Thu, 28 Jun 2018 15:47:08 +0000 (11:47 -0400)]
media: coda: add read-only h.264 decoder profile/level controls

The decoder profile/level controls initially can be used to determine
supported profiles and levels. The values are set for a given stream
once the headers are parsed.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: coda: fix encoder source stride
Philipp Zabel [Thu, 28 Jun 2018 15:44:12 +0000 (11:44 -0400)]
media: coda: fix encoder source stride

The encoder picture run command takes a picture source stride parameter.
This must be set to the output queue's bytesperline, not width.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: v4l2-ctrls: Fix CID base conflict between MAX217X and IMX
Steve Longerbeam [Wed, 27 Jun 2018 18:39:43 +0000 (14:39 -0400)]
media: v4l2-ctrls: Fix CID base conflict between MAX217X and IMX

When the imx-media driver was initially merged, there was a conflict
with 8d67ae25 ("media: v4l2-ctrls: Reserve controls for MAX217X") which
was not fixed up correctly, resulting in V4L2_CID_USER_MAX217X_BASE and
V4L2_CID_USER_IMX_BASE taking on the same value. Fix by assigning imx
CID base the next available range at 0x10b0.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: stk1160: Set the vb2_queue lock before calling vb2_queue_init
Ezequiel Garcia [Fri, 15 Jun 2018 19:07:32 +0000 (15:07 -0400)]
media: stk1160: Set the vb2_queue lock before calling vb2_queue_init

The vb2_queue will soon be mandatory. The videobuf2 core
will throw a verbose warning if it's not set.

The stk1160 driver is setting the queue lock, but after
the vb2_queue_init call. Avoid the warning by setting
the lock before the queue initialization.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: m2m-deinterlace: Implement wait_prepare and wait_finish
Ezequiel Garcia [Fri, 15 Jun 2018 19:07:31 +0000 (15:07 -0400)]
media: m2m-deinterlace: Implement wait_prepare and wait_finish

This driver is currently specifying a video_device lock,
which means it is protecting all the ioctls (including
queue ioctls) with a single mutex.

It's therefore straightforward to implement wait_prepare
and wait_finish, by explicitly setting the vb2_queue lock.

Having these callbacks releases the queue lock while blocking,
which improves latency by allowing for example streamoff
or qbuf operations while waiting in dqbuf.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: mx_emmaprp: Implement wait_prepare and wait_finish
Ezequiel Garcia [Fri, 15 Jun 2018 19:07:30 +0000 (15:07 -0400)]
media: mx_emmaprp: Implement wait_prepare and wait_finish

This driver is currently specifying a video_device lock,
which means it is protecting all the ioctls (including
queue ioctls) with a single mutex.

It's therefore straightforward to implement wait_prepare
and wait_finish, by explicitly setting the vb2_queue lock.

Having these callbacks releases the queue lock while blocking,
which improves latency by allowing for example streamoff
or qbuf operations while waiting in dqbuf.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: davinci_vpfe: Add video_device and vb2_queue locks
Ezequiel Garcia [Fri, 15 Jun 2018 19:07:29 +0000 (15:07 -0400)]
media: davinci_vpfe: Add video_device and vb2_queue locks

Currently, this driver does not serialize its video4linux
ioctls, which is a bug, as race conditions might appear.

In addition, video_device and vb2_queue locks are now both
mandatory. Add them, and implement wait_prepare and
wait_finish.

To stay on the safe side, this commit uses a single mutex
for both locks. Better latency can be obtained by separating
these if needed.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging: bcm2835-camera: Provide lock for vb2_queue
Ezequiel Garcia [Fri, 15 Jun 2018 19:07:27 +0000 (15:07 -0400)]
media: staging: bcm2835-camera: Provide lock for vb2_queue

Use the device mutex to protect the vb2_queue.
This allows to replace the ad-hoc wait_{prepare, finish}
with vb2_ops_wait_{prepare, finish}.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: s5p-g2d: Implement wait_prepare and wait_finish
Ezequiel Garcia [Fri, 15 Jun 2018 19:07:26 +0000 (15:07 -0400)]
media: s5p-g2d: Implement wait_prepare and wait_finish

This driver is currently specifying a vb2_queue lock,
which means it straightforward to implement wait_prepare
and wait_finish.

Having these callbacks releases the queue lock while blocking,
which improves latency by allowing for example streamoff
or qbuf operations while waiting in dqbuf.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: mtk-mdp: Add locks for capture and output vb2_queues
Ezequiel Garcia [Fri, 15 Jun 2018 19:07:25 +0000 (15:07 -0400)]
media: mtk-mdp: Add locks for capture and output vb2_queues

Use the mutex in struct mtk_mdp_ctx to protect the
capture and output  vb2_queues. This allows to replace
the ad-hoc wait_{prepare, finish} with
vb2_ops_wait_{prepare, finish}.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: sta2x11: Add video_device and vb2_queue locks
Ezequiel Garcia [Fri, 15 Jun 2018 19:07:22 +0000 (15:07 -0400)]
media: sta2x11: Add video_device and vb2_queue locks

Currently, this driver does not serialize its video4linux
ioctls, which is a bug, as race conditions might appear.

In addition, video_device and vb2_queue locks are now both
mandatory. Add them, and implement wait_prepare and
wait_finish.

To stay on the safe side, this commit uses a single mutex
for both locks. Better latency can be obtained by separating
these if needed.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: v4l2-ioctl.c: use correct vb2_queue lock for m2m devices
Hans Verkuil [Fri, 15 Jun 2018 19:07:21 +0000 (15:07 -0400)]
media: v4l2-ioctl.c: use correct vb2_queue lock for m2m devices

For m2m devices the vdev->queue lock was always taken instead of the
lock for the specific capture or output queue. Now that we pushed
the locking down into __video_do_ioctl() we can pick the correct
lock and potentially improve the performance of m2m devices.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: imx274: fix typo
Luca Ceresoli [Mon, 11 Jun 2018 11:35:38 +0000 (07:35 -0400)]
media: imx274: fix typo

pd -> pad

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: imx274: simplify imx274_write_table()
Luca Ceresoli [Mon, 11 Jun 2018 11:35:36 +0000 (07:35 -0400)]
media: imx274: simplify imx274_write_table()

imx274_write_table() is a mere wrapper (and the only user) to
imx274_regmap_util_write_table_8(). Remove this useless indirection by
merging the two functions into one.

Also get rid of the wait_ms_addr and end_addr parameters since it does
not make any sense to give them any values other than
IMX274_TABLE_WAIT_MS and IMX274_TABLE_END.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: imx274: actually use IMX274_DEFAULT_MODE
Luca Ceresoli [Mon, 11 Jun 2018 11:35:35 +0000 (07:35 -0400)]
media: imx274: actually use IMX274_DEFAULT_MODE

IMX274_DEFAULT_MODE is defined but not used. Start using it, so the
default can be more easily changed without digging into the code.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: imx274: get rid of mode_index
Luca Ceresoli [Mon, 11 Jun 2018 11:35:34 +0000 (07:35 -0400)]
media: imx274: get rid of mode_index

After restructuring struct imx274_frmfmt, the mode_index field is
still in use only for two dev_dbg() calls in imx274_s_stream(). Let's
remove it and avoid duplicated information.

Replacing the first usage requires some rather annoying but trivial
pointer math. The other one can be removed entirely since it would
print the same value anyway.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: imx274: consolidate per-mode data in imx274_frmfmt
Luca Ceresoli [Mon, 11 Jun 2018 11:35:33 +0000 (07:35 -0400)]
media: imx274: consolidate per-mode data in imx274_frmfmt

Data about the implemented readout modes is partially stored in
imx274_formats[], the rest is scattered in several arrays. The latter
are then accessed using the mode index, e.g.:

  min_frame_len[priv->mode_index]

Consolidate all these data in imx274_formats[], and store a pointer to
the selected mode (i.e. imx274_formats[priv->mode_index]) in the main
device struct. This way code to use these data becomes more readable,
e.g.:

  priv->mode->min_frame_len

This removes lots of scaffolding code and keeps data about each mode
in a unique place.

Also remove a parameter to imx274_mode_regs() that is now unused.

While this adds the mode pointer to the device struct, it does not
remove the mode_index from it because mode_index is still used in two
dev_dbg() calls.  This will be handled in a follow-up commit.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: imx274: initialize format before v4l2 controls
Luca Ceresoli [Mon, 11 Jun 2018 11:35:32 +0000 (07:35 -0400)]
media: imx274: initialize format before v4l2 controls

The current probe function calls v4l2_ctrl_handler_setup() before
initializing the format info. This triggers call paths such as:
imx274_probe -> v4l2_ctrl_handler_setup -> imx274_s_ctrl ->
imx274_set_exposure, where priv->mode_index is accessed before being
assigned.

This is wrong but does not trigger a visible bug because priv is
zero-initialized and 0 is the default value for priv->mode_index. But
this would become a crash in follow-up commits when mode_index is
replaced by a pointer that must always be valid.

Fix the bug before it shows up by initializing struct members early.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: ak7375: Add ak7375 lens voice coil driver
Bingbu Cao [Tue, 19 Jun 2018 06:01:47 +0000 (02:01 -0400)]
media: ak7375: Add ak7375 lens voice coil driver

Add a v4l2 sub-device driver for the ak7375 lens voice coil.
This is a voice coil module using the i2c bus to control the
focus position.

ak7375 can write multiple bytes of data at a time. If more
data is received instead of the stop condition after receiving
one byte of data, the address inside the chip is automatically
incremented and the data is written into the next address.

The ak7375 can control the position with 12 bits value and
consists of two 8 bit registers show as below:
register 0x00(AK7375_REG_POSITION):
    +---+---+---+---+---+---+---+---+
    |D11|D10|D09|D08|D07|D06|D05|D04|
    +---+---+---+---+---+---+---+---+
register 0x01:
    +---+---+---+---+---+---+---+---+
    |D03|D02|D01|D00|---|---|---|---|
    +---+---+---+---+---+---+---+---+

This driver support :
    - set ak7375 to standby mode once suspend and
      turn it back to active if resume
    - set the position via V4L2_CID_FOCUS_ABSOLUTE ctrl

[Sakari Ailus: Rename val as ret in probe, drop redundant error message]

Signed-off-by: Tianshu Qiu <tian.shu.qiu@intel.com>
Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: dt-bindings: Add bindings for AKM ak7375 voice coil lens
Bingbu Cao [Tue, 19 Jun 2018 06:01:46 +0000 (02:01 -0400)]
media: dt-bindings: Add bindings for AKM ak7375 voice coil lens

Add device tree bindings for AKM ak7375 voice coil lens
driver. This chip is used to drive a lens in a camera module.

Signed-off-by: Tianshu Qiu <tian.shu.qiu@intel.com>
Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: ov5640: fix frame interval enumeration
Hugues Fruchet [Wed, 20 Jun 2018 08:40:57 +0000 (04:40 -0400)]
media: ov5640: fix frame interval enumeration

Driver must reject frame interval enumeration of unsupported resolution.
This was detected by v4l2-compliance format ioctl test:
v4l2-compliance Format ioctls:
    info: found 2 frameintervals for pixel format 4745504a and size 176x144
  fail: v4l2-test-formats.cpp(123):
                           found frame intervals for invalid size 177x144
    test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: FAIL

Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: v4l-common: Make v4l2_find_nearest_size more sparse-friendly
Sakari Ailus [Thu, 21 Jun 2018 09:41:21 +0000 (05:41 -0400)]
media: v4l-common: Make v4l2_find_nearest_size more sparse-friendly

This sparse warning is emitted by using v4l2_find_nearest_size in some
cases. Fix it in the framework.

>> drivers/media/i2c/ov5640.c:1394:14: sparse: incorrect type in assignment
+(different base types) @@    expected struct ov5640_mode_info const *mode @@
+got ststruct ov5640_mode_info const *mode @@
   drivers/media/i2c/ov5640.c:1394:14:    expected struct ov5640_mode_info const
+*mode
   drivers/media/i2c/ov5640.c:1394:14:    got struct ov5640_mode_info const ( *<
+noident> )[9]

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: ov5640: adjust xclk_max
Philipp Puschmann [Wed, 6 Jun 2018 09:11:38 +0000 (05:11 -0400)]
media: ov5640: adjust xclk_max

According to ov5640 datasheet xvclk is allowed to be between 6 and 54 MHz.
I run a successful test with 27 MHz.

Signed-off-by: Philipp Puschmann <pp@emlix.com>
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: soc_camera: ov772x: correct setting of banding filter
Akinobu Mita [Sun, 10 Jun 2018 15:42:26 +0000 (11:42 -0400)]
media: soc_camera: ov772x: correct setting of banding filter

The banding filter ON/OFF is controlled via bit 5 of COM8 register.  It
is attempted to be enabled in ov772x_set_params() by the following line.

ret = ov772x_mask_set(client, COM8, BNDF_ON_OFF, 1);

But this unexpectedly results disabling the banding filter, because the
mask and set bits are exclusive.

On the other hand, ov772x_s_ctrl() correctly sets the bit by:

ret = ov772x_mask_set(client, COM8, BNDF_ON_OFF, BNDF_ON_OFF);

The same fix was already applied to non-soc_camera version of ov772x
driver in the commit commit a024ee14cd36 ("media: ov772x: correct setting
of banding filter")

Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: s3c-camif: ignore -ENOIOCTLCMD from v4l2_subdev_call for s_power
Akinobu Mita [Sun, 10 Jun 2018 15:42:01 +0000 (11:42 -0400)]
media: s3c-camif: ignore -ENOIOCTLCMD from v4l2_subdev_call for s_power

When the subdevice doesn't provide s_power core ops callback, the
v4l2_subdev_call for s_power returns -ENOIOCTLCMD.  If the subdevice
doesn't have the special handling for its power saving mode, the s_power
isn't required.  So -ENOIOCTLCMD from the v4l2_subdev_call should be
ignored.

Cc: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Acked-by: Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: omap3isp: zero-initialize the isp cam_xclk{a,b} initial data
Javier Martinez Canillas [Sat, 9 Jun 2018 12:22:45 +0000 (08:22 -0400)]
media: omap3isp: zero-initialize the isp cam_xclk{a,b} initial data

The struct clk_init_data init variable is declared in the isp_xclk_init()
function so is an automatic variable allocated in the stack. But it's not
explicitly zero-initialized, so some init fields are left uninitialized.

This causes the data structure to have undefined values that may confuse
the common clock framework when the clock is registered.

For example, the uninitialized .flags field could have the CLK_IS_CRITICAL
bit set, causing the framework to wrongly prepare the clk on registration.
This leads to the isp_xclk_prepare() callback being called, which in turn
calls to the omap3isp_get() function that increments the isp dev refcount.

Since this omap3isp_get() call is unexpected, this leads to an unbalanced
omap3isp_get() call that prevents the requested IRQ to be later enabled,
due the refcount not being 0 when the correct omap3isp_get() call happens.

Fixes: 9b28ee3c9122 ("[media] omap3isp: Use the common clock framework")
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: dw9807: Add dw9807 vcm driver
Alan Chiang [Wed, 25 Apr 2018 02:12:08 +0000 (22:12 -0400)]
media: dw9807: Add dw9807 vcm driver

DW9807 is a 10 bit DAC from Dongwoon, designed for linear
control of voice coil motor.

This driver creates a V4L2 subdevice and
provides control to set the desired focus.

Signed-off-by: Alan Chiang <alanx.chiang@intel.com>
Signed-off-by: Andy Yeh <andy.yeh@intel.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: dt-bindings: Add bindings for Dongwoon DW9807 voice coil
Alan Chiang [Wed, 25 Apr 2018 02:12:07 +0000 (22:12 -0400)]
media: dt-bindings: Add bindings for Dongwoon DW9807 voice coil

Dongwoon DW9807 is a voice coil lens driver.

Signed-off-by: Alan Chiang <alanx.chiang@intel.com>
Signed-off-by: Andy Yeh <andy.yeh@intel.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: MAINTAINERS: Update entry for Intel IPU3 cio2 driver
Yong Zhi [Wed, 30 May 2018 22:51:17 +0000 (18:51 -0400)]
media: MAINTAINERS: Update entry for Intel IPU3 cio2 driver

This patch adds Bingbu as additional maintainer, and both Tian Shu and Jian Xu
as reviewers for IPU3 CIO2 driver.

Signed-off-by: Yong Zhi <yong.zhi@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: omap3isp: fix warning for !CONFIG_PM
Arnd Bergmann [Fri, 25 May 2018 15:25:08 +0000 (11:25 -0400)]
media: omap3isp: fix warning for !CONFIG_PM

The final version of the COMPILE_TEST patch for this driver missed
one warning about suspend/resume functions that can now appear
on platforms that don't always set CONFIG_PM:

drivers/media/platform/omap3isp/isp.c:1008:13: error: 'isp_resume_modules' defined but not used [-Werror=unused-function]
 static void isp_resume_modules(struct isp_device *isp)
             ^~~~~~~~~~~~~~~~~~
drivers/media/platform/omap3isp/isp.c:974:12: error: 'isp_suspend_modules' defined but not used [-Werror=unused-function]
 static int isp_suspend_modules(struct isp_device *isp)

This marks the respective functions as __maybe_unused as an easy
workaround.

Fixes: 243131134be4 ("media: omap3isp: Allow it to build with COMPILE_TEST")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: ov772x: create subdevice device node
Akinobu Mita [Sun, 6 May 2018 14:19:29 +0000 (10:19 -0400)]
media: ov772x: create subdevice device node

Set the V4L2_SUBDEV_FL_HAS_DEVNODE flag for the subdevice so that the
subdevice device node is created.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: ov772x: make set_fmt() and s_frame_interval() return -EBUSY while streaming
Akinobu Mita [Sun, 6 May 2018 14:19:28 +0000 (10:19 -0400)]
media: ov772x: make set_fmt() and s_frame_interval() return -EBUSY while streaming

The ov772x driver is going to offer a V4L2 sub-device interface, so
changing the output data format and the frame interval on this sub-device
can be made anytime.  However, these requests are preferred to fail while
the video stream on the device is active.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: ov772x: avoid accessing registers under power saving mode
Akinobu Mita [Sun, 6 May 2018 14:19:27 +0000 (10:19 -0400)]
media: ov772x: avoid accessing registers under power saving mode

The set_fmt() in subdev pad ops, the s_ctrl() for subdev control handler,
and the s_frame_interval() in subdev video ops could be called when the
device is under power saving mode.  These callbacks for ov772x driver
cause updating H/W registers that will fail under power saving mode.

This avoids it by not apply any changes to H/W if the device is not powered
up.  Instead the changes will be restored right after power-up.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: ov772x: use v4l2_ctrl to get current control value
Akinobu Mita [Sun, 6 May 2018 14:19:26 +0000 (10:19 -0400)]
media: ov772x: use v4l2_ctrl to get current control value

The ov772x driver provides three V4L2 controls and the current value of
each control is saved as a variable in the private data structure.

We don't need to keep track of the current value by ourself, if we use
v4l2_ctrl returned from v4l2_ctrl_new_std() instead.

This is a preparatory change to avoid accessing registers under power
saving mode.  This simplifies s_ctrl() by making it just return without
saving the current control value in private area when it is called under
power saving mode.

Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: ov772x: reconstruct s_frame_interval()
Akinobu Mita [Sun, 6 May 2018 14:19:25 +0000 (10:19 -0400)]
media: ov772x: reconstruct s_frame_interval()

This splits the s_frame_interval() in subdev video ops into selecting the
frame interval and setting up the registers.

This is a preparatory change to avoid accessing registers under power
saving mode.

Cc: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: ov772x: handle nested s_power() calls
Akinobu Mita [Sun, 6 May 2018 14:19:24 +0000 (10:19 -0400)]
media: ov772x: handle nested s_power() calls

Depending on the v4l2 driver, calling s_power() could be nested.  So the
actual transitions between power saving mode and normal operation mode
should only happen at the first power on and the last power off.

This adds an s_power() nesting counter and updates the power state if the
counter is modified from 0 to != 0 or from != 0 to 0.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: ov772x: support device tree probing
Akinobu Mita [Sun, 6 May 2018 14:19:23 +0000 (10:19 -0400)]
media: ov772x: support device tree probing

The ov772x driver currently only supports legacy platform data probe.
This change enables device tree probing.

Note that the platform data probe can select auto or manual edge control
mode, but the device tree probling can only select auto edge control mode
for now.

[Sakari Ailus: Remove direct OF dependencies from device ID table]

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: ov772x: omit consumer ID when getting clock reference
Akinobu Mita [Sun, 6 May 2018 14:19:22 +0000 (10:19 -0400)]
media: ov772x: omit consumer ID when getting clock reference

Currently the ov772x driver obtains a clock with a specific consumer ID.
As there's a single clock for this driver, we could omit clock-names
property in device tree by passing NULL as a consumer ID to clk_get().

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: ov772x: use generic names for reset and powerdown gpios
Akinobu Mita [Sun, 6 May 2018 14:19:21 +0000 (10:19 -0400)]
media: ov772x: use generic names for reset and powerdown gpios

The ov772x driver uses "rstb-gpios" and "pwdn-gpios" for reset and
powerdown pins.  However, using generic names for these gpios is
preferred.  ("reset-gpios" and "powerdown-gpios" respectively)

There is only one mainline user for these gpios, so rename to generic
names.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: ov772x: add media controller support
Akinobu Mita [Sun, 6 May 2018 14:19:20 +0000 (10:19 -0400)]
media: ov772x: add media controller support

Create a source pad and set the media controller type to the sensor.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: ov772x: add checks for register read errors
Akinobu Mita [Sun, 6 May 2018 14:19:19 +0000 (10:19 -0400)]
media: ov772x: add checks for register read errors

This change adds checks for register read errors and returns correct
error code.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>