linux-2.6-microblaze.git
4 years agomedia: coda: mark the last output buffer on decoder stop command
Philipp Zabel [Tue, 18 Jun 2019 16:45:24 +0000 (12:45 -0400)]
media: coda: mark the last output buffer on decoder stop command

Mark the last output buffer to be decoded and only copy pending queued
output buffers into the bitstream ring buffer in the BIT processor
decoder case.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: coda: allow flagging last output buffer internally
Philipp Zabel [Tue, 18 Jun 2019 16:45:23 +0000 (12:45 -0400)]
media: coda: allow flagging last output buffer internally

Since V4L2_BUF_FLAG_LAST is a CAPTURE only flag, clear it from OUTPUT
buffers in QBUF and DQBUF. This allows to use the flag internally to
signal the last buffer to decode after a decoder stop command was
issued.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: coda: increment sequence offset for the last returned frame
Philipp Zabel [Tue, 18 Jun 2019 16:45:22 +0000 (12:45 -0400)]
media: coda: increment sequence offset for the last returned frame

If no more frames are decoded in bitstream end mode, and a previously
decoded frame has been returned, the firmware still increments the frame
number. To avoid a sequence number mismatch after decoder restart,
increment the sequence_offset correction parameter.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: coda: flush bitstream ring buffer on decoder restart
Philipp Zabel [Tue, 18 Jun 2019 16:45:21 +0000 (12:45 -0400)]
media: coda: flush bitstream ring buffer on decoder restart

The bitstream ringbuffer might be in an underrun state after draining,
or it might still contain unread data if the previous decoder stop
command was flagged as immediate. Flush the bitstream ring buffer
during V4L2_DEC_CMD_START to get into a well defined state. Also fill
the bitstream with buffers that have been queued during draining,
to resume decoding immediately.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: coda: do not enforce 512-byte initial bitstream payload on CODA960
Philipp Zabel [Tue, 18 Jun 2019 16:45:20 +0000 (12:45 -0400)]
media: coda: do not enforce 512-byte initial bitstream payload on CODA960

On CODA960, sequence initialization can succeed if less than 512 bytes
are ready in the bitstream ring buffer.
On other variants, warn about too small payload in start_streaming.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: coda: pad first buffer with repeated MPEG headers to fix sequence init
Philipp Zabel [Tue, 18 Jun 2019 16:45:19 +0000 (12:45 -0400)]
media: coda: pad first buffer with repeated MPEG headers to fix sequence init

If the first buffer contains only headers, the sequence initialization
command fails. On CodaHx4 the buffer must be padded to at least 512
bytes, on CODA960 it seems to be enough to just repeat the sequence and
extension headers (MPEG-2) or the VOS and VO headers (MPEG-4) once for
for sequence initialization to succeed without further bitstream data.
On CodaHx4 the headers can be repeated multiple times until the 512 byte
mark is reached.

A similar issue was solved for h.264 by padding with a filler NAL in
commit 0eef89403ece ("[media] coda: pad first h.264 buffer to 512
bytes").

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: coda: make coda_bitstream_queue more versatile
Philipp Zabel [Tue, 18 Jun 2019 16:45:18 +0000 (12:45 -0400)]
media: coda: make coda_bitstream_queue more versatile

Pass vaddr and size to coda_bitstream_queue instead of a struct
vb2_v4l2_buffer to make it reusable for queueing data that is
not exactly a whole v4l2 buffer into the bitstream ringbuffer.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: coda: integrate internal frame metadata into a structure
Philipp Zabel [Tue, 18 Jun 2019 16:45:17 +0000 (12:45 -0400)]
media: coda: integrate internal frame metadata into a structure

Combine the separate auxiliary buffer, buffer meta, frame type, and
decode error arrays into an array of struct coda_internal_frame.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: coda: implement decoder source change event
Philipp Zabel [Tue, 18 Jun 2019 16:45:16 +0000 (12:45 -0400)]
media: coda: implement decoder source change event

The stateful decoder API requires decoders to signal detection
of stream dimensions via the V4L2_EVENT_SOURCE_CHANGE event.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: coda: add sequence initialization work
Philipp Zabel [Tue, 18 Jun 2019 16:45:15 +0000 (12:45 -0400)]
media: coda: add sequence initialization work

Add a sequence initialization work item to be run when OUTPUT buffers
are queued in the initialization state.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: coda: split decoder sequence initialization out of start decoding
Philipp Zabel [Tue, 18 Jun 2019 16:45:14 +0000 (12:45 -0400)]
media: coda: split decoder sequence initialization out of start decoding

The sequence initialization already has to happen during the
initialization phase, after headers have been queued on the OUTPUT
queue. This means that sequence initialization has to be queued as
a work item from QBUF on the OUTPUT queue. The internal framebuffer
setup should be done later during VIDIOC_REQBUFS() on the CAPTURE
queue.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: coda: fix V4L2_DEC_CMD_STOP when all buffers are already consumed
Marco Felsch [Tue, 18 Jun 2019 16:45:13 +0000 (12:45 -0400)]
media: coda: fix V4L2_DEC_CMD_STOP when all buffers are already consumed

When the DEC_CMD_STOP command is issued after the context has already
consumed all the queued buffers, we need to make sure to wake the
destination queue with last_buffer_dequeued set, to allow userspace to
make progress in its EOS handling.

As there might still be picture run workers pending at that point, we
need to synchronize with them, so the sequence number comparison reads
stable values.

 reword commit message]

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: coda: add coda_wake_up_capture_queue
Philipp Zabel [Tue, 18 Jun 2019 16:45:12 +0000 (12:45 -0400)]
media: coda: add coda_wake_up_capture_queue

Combine setting the last_buffer_dequeued flag on the capture video
queue and waking up its done workqueue into a helper function.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: coda: fix last buffer handling in V4L2_ENC_CMD_STOP
Marco Felsch [Tue, 18 Jun 2019 16:45:11 +0000 (12:45 -0400)]
media: coda: fix last buffer handling in V4L2_ENC_CMD_STOP

coda_encoder_cmd() is racy, as the last scheduled picture run worker can
still be in-flight while the ENC_CMD_STOP command is issued. Depending
on the exact timing the sequence numbers might already be changed, but
the last buffer might not have been put on the destination queue yet.

In this case the current implementation would prematurely wake the
destination queue with last_buffer_dequeued=true, causing userspace to
call streamoff before the last buffer is handled.

Close this race window by synchronizing with the pic_run_worker before
doing the sequence check.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
[l.stach@pengutronix.de: switch to flush_work, reword commit message]
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: coda: fix mpeg2 sequence number handling
Philipp Zabel [Tue, 18 Jun 2019 16:45:10 +0000 (12:45 -0400)]
media: coda: fix mpeg2 sequence number handling

Sequence number handling assumed that the BIT processor frame number
starts counting at 1, but this is not true for the MPEG-2 decoder,
which starts at 0. Fix the sequence counter offset detection to handle
this.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: coda: use mem2mem try_en/decoder_cmd helpers
Philipp Zabel [Tue, 18 Jun 2019 16:45:09 +0000 (12:45 -0400)]
media: coda: use mem2mem try_en/decoder_cmd helpers

Use mem2mem try_en/decoder_cmd helpers to ensure consistent behaviour
with other video codec drivers.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: coda: implement CMD_START to restart decoding
Michael Tretter [Tue, 18 Jun 2019 16:45:08 +0000 (12:45 -0400)]
media: coda: implement CMD_START to restart decoding

The CMD_START shall be used to start the processing after a drain that
was initiated with CMD_STOP.

Up until now, a drain on coda could only be finished with a
STREAMOFF-STREAMON, which resulted in a reset of the device.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: cafe-driver: mark an static var as such
Mauro Carvalho Chehab [Mon, 24 Jun 2019 17:08:59 +0000 (13:08 -0400)]
media: cafe-driver: mark an static var as such

As warned by sparse:

drivers/media/platform/marvell-ccic/cafe-driver.c:475:23:  warning: symbol 'ov7670_info' was not declared. Should it be static?

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: staging: media: fix style problem
Aliasgar Surti [Fri, 21 Jun 2019 06:39:52 +0000 (02:39 -0400)]
media: staging: media: fix style problem

checkpatch reported "WARNING: line over 80 characters".
This patch fixes the warning for file soc_camera/soc_ov5642.c

Signed-off-by: Aliasgar Surti <aliasgar.surti500@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: marvell-ccic: mmp: don't chicken out w/o pdata
Lubomir Rintel [Thu, 20 Jun 2019 14:49:04 +0000 (10:49 -0400)]
media: marvell-ccic: mmp: don't chicken out w/o pdata

It's impossible for mmpcam_calc_dphy() to be called without it.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: marvell-ccic: only calculate the DPHY registers when needed
Lubomir Rintel [Thu, 20 Jun 2019 14:49:03 +0000 (10:49 -0400)]
media: marvell-ccic: only calculate the DPHY registers when needed

Avoid pointlessly calling calc_dphy() when the bus is not
V4L2_MBUS_CSI2_DPHY. This will make it easier to replace the platform data
with devicetree.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: st-mipid02: add support of JPEG
Hugues Fruchet [Mon, 17 Jun 2019 13:43:58 +0000 (09:43 -0400)]
media: st-mipid02: add support of JPEG

Add support of JPEG pixel format.
This requires auto detection of data type from CSI-2 stream.

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>
4 years agomedia: st-mipid02: add support of YUYV8 and UYVY8
Hugues Fruchet [Mon, 17 Jun 2019 13:43:57 +0000 (09:43 -0400)]
media: st-mipid02: add support of YUYV8 and UYVY8

Add support of YUYV8 and UYVY8 pixel formats.

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>
4 years agomedia: st-mipid02: add support of RGB565
Hugues Fruchet [Mon, 17 Jun 2019 13:43:56 +0000 (09:43 -0400)]
media: st-mipid02: add support of RGB565

Add support of RGB565 pixel format.

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>
4 years agomedia: st-mipid02: add support of V4L2_CID_LINK_FREQ
Hugues Fruchet [Mon, 17 Jun 2019 13:43:31 +0000 (09:43 -0400)]
media: st-mipid02: add support of V4L2_CID_LINK_FREQ

Ask device connected on sink pad for link frequency
in order to configure CLK_LANE_REG1 (ui_x4).
If not available, ask for pixel rate information to compute it.

This is needed to deal with compressed format such as JPEG
where number of bits per pixel is unknown: computation of
link frequency from pixel rate is not possible.

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>
4 years agomedia: marvell-ccic: provide a clock for the sensor
Lubomir Rintel [Tue, 28 May 2019 09:07:31 +0000 (05:07 -0400)]
media: marvell-ccic: provide a clock for the sensor

The sensor needs the MCLK clock running when it's being probed. On
platforms where the sensor is instantiated from a DT (MMP2) it is going
to happen asynchronously.

Therefore, the current modus operandi, where the bridge driver fiddles
with the sensor power and clock itself is not going to fly. As the comments
wisely note, this doesn't even belong there.

Luckily, the ov7670 driver is already able to control its power and
reset lines, we can just drop the MMP platform glue altogether.

It also requests the clock via the standard clock subsystem. Good -- let's
set up a clock instance so that the sensor can ask us to enable the clock.
Note that this is pretty dumb at the moment: the clock is hardwired to a
particular frequency and parent. It was always the case.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: marvell-ccic: use async notifier to get the sensor
Lubomir Rintel [Tue, 28 May 2019 09:07:30 +0000 (05:07 -0400)]
media: marvell-ccic: use async notifier to get the sensor

An instance of a sensor on DT-based MMP2 platform is always going to be
created asynchronously.

Let's move the manual device creation away from the core to the Cafe
driver (used on OLPC XO-1, not present in DT) and set up appropriate
async matches: I2C on Cafe, FWNODE on MMP (OLPC XO-1.75).

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: marvell-ccic/mmp: add devicetree support
Lubomir Rintel [Tue, 28 May 2019 09:07:29 +0000 (05:07 -0400)]
media: marvell-ccic/mmp: add devicetree support

The platform data is actually not used anywhere (along with the CSI
support) and should be safe to remove.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: marvell-ccic: rename the clocks
Lubomir Rintel [Tue, 28 May 2019 09:07:28 +0000 (05:07 -0400)]
media: marvell-ccic: rename the clocks

Use the names more suitable for devicetree bindings.

There are no board files utilizing this, thus we seem to be at liberty
at renaming this without consequences.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: marvell-ccic/mmp: enable clock before accessing registers
Lubomir Rintel [Tue, 28 May 2019 09:07:27 +0000 (05:07 -0400)]
media: marvell-ccic/mmp: enable clock before accessing registers

The access to REG_CLKCTRL or REG_CTRL1 without the clock enabled hangs
the machine. Enable the clock first.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: marvell-ccic: drop unused stuff
Lubomir Rintel [Tue, 28 May 2019 09:07:26 +0000 (05:07 -0400)]
media: marvell-ccic: drop unused stuff

Remove structure members and headers that are not actually used. Saves
us from some noise in subsequent cleanup commits.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: Revert "[media] marvell-ccic: reset ccic phy when stop streaming for stability"
Lubomir Rintel [Tue, 28 May 2019 09:07:25 +0000 (05:07 -0400)]
media: Revert "[media] marvell-ccic: reset ccic phy when stop streaming for stability"

This accesses the clock registers directly and thus is going to stay in the
way of making the driver devicetree friendly.

No boards seems to actually use this. If it's somehow actually needed it
needs to be done differently.

This reverts commit 7c269f454e7a51b151d94f99344120efa1cd0acb.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: mt9m111: fix fw-node refactoring
Robert Jarzmik [Mon, 3 Jun 2019 20:01:55 +0000 (16:01 -0400)]
media: mt9m111: fix fw-node refactoring

In the patch refactoring the fw-node, the mt9m111 was broken for all
platform_data based platforms, which were the first aim of this
driver. Only the devicetree platform are still functional, probably
because the testing was done on these.

The result is that -EINVAL is systematically return for such platforms,
what this patch fixes.

[Sakari Ailus: Rework this to resolve a merge conflict and use dev_fwnode]

Fixes: 98480d65c48c ("media: mt9m111: allow to setup pixclk polarity")
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: staging: media: soc_camera: soc_mt9v022: simplify getting the adapter of a...
Wolfram Sang [Sat, 8 Jun 2019 10:56:12 +0000 (06:56 -0400)]
media: staging: media: soc_camera: soc_mt9v022: simplify getting the adapter of a client

We have a dedicated pointer for that, so use it. Much easier to read and
less computation involved.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: staging: media: soc_camera: mt9t031: simplify getting the adapter of a client
Wolfram Sang [Sat, 8 Jun 2019 10:56:11 +0000 (06:56 -0400)]
media: staging: media: soc_camera: mt9t031: simplify getting the adapter of a client

We have a dedicated pointer for that, so use it. Much easier to read and
less computation involved.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: staging: media: soc_camera: imx074: simplify getting the adapter of a client
Wolfram Sang [Sat, 8 Jun 2019 10:56:10 +0000 (06:56 -0400)]
media: staging: media: soc_camera: imx074: simplify getting the adapter of a client

We have a dedicated pointer for that, so use it. Much easier to read and
less computation involved.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: i2c: tw9910: simplify getting the adapter of a client
Wolfram Sang [Sat, 8 Jun 2019 10:55:50 +0000 (06:55 -0400)]
media: i2c: tw9910: simplify getting the adapter of a client

We have a dedicated pointer for that, so use it. Much easier to read and
less computation involved.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: i2c: ov2640: simplify getting the adapter of a client
Wolfram Sang [Sat, 8 Jun 2019 10:55:49 +0000 (06:55 -0400)]
media: i2c: ov2640: simplify getting the adapter of a client

We have a dedicated pointer for that, so use it. Much easier to read and
less computation involved.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: i2c: mt9m111: simplify getting the adapter of a client
Wolfram Sang [Sat, 8 Jun 2019 10:55:47 +0000 (06:55 -0400)]
media: i2c: mt9m111: simplify getting the adapter of a client

We have a dedicated pointer for that, so use it. Much easier to read and
less computation involved.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: i2c: mt9m001: simplify getting the adapter of a client
Wolfram Sang [Sat, 8 Jun 2019 10:55:46 +0000 (06:55 -0400)]
media: i2c: mt9m001: simplify getting the adapter of a client

We have a dedicated pointer for that, so use it. Much easier to read and
less computation involved.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: i2c: ak881x: simplify getting the adapter of a client
Wolfram Sang [Sat, 8 Jun 2019 10:55:45 +0000 (06:55 -0400)]
media: i2c: ak881x: simplify getting the adapter of a client

We have a dedicated pointer for that, so use it. Much easier to read and
less computation involved.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: mt9m111: Fix error handling in mt9m111_power_on
Sakari Ailus [Fri, 31 May 2019 20:12:49 +0000 (16:12 -0400)]
media: mt9m111: Fix error handling in mt9m111_power_on

The mt9m111_power_on function did not properly clean up whenever it
encountered an error. Do that now.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: mt9m111: No need to check for the regulator
Sakari Ailus [Fri, 31 May 2019 20:11:35 +0000 (16:11 -0400)]
media: mt9m111: No need to check for the regulator

The regulator_get() function returns a regulator when it succeeds. There's
no need to check whether the regulator is NULL later on.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: mt9m111: add regulator support
Robert Jarzmik [Wed, 29 May 2019 19:25:18 +0000 (15:25 -0400)]
media: mt9m111: add regulator support

In the soc_camera removal, the board specific power callback was
dropped. This at least will remove the power optimization from ezx and
em-x270 pxa based boards.

As to recreate the same level of functionality, make the mt9m111 have a
regulator providing it its power, so that board designers can plug in a
gpio based or ldo regulator, mimicking their former soc_camera power
hook.

[sakari.ailus@linux.intel.com: fix a build warning]
Fixes: 5c10113cc668 ("media: mt9m111: make a standalone v4l2 subdevice")
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Tested-by: Akinobu Mita <akinobu.mita@gmail.com>
Tested-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: ov9640: Don't check for NULL on devm_gpiod_get return values
Sakari Ailus [Thu, 6 Jun 2019 14:21:25 +0000 (10:21 -0400)]
media: ov9640: Don't check for NULL on devm_gpiod_get return values

devm_gpiod_get never returns NULL; therefore it's not necessary to check
for that. PTR_ERR(NULL) also yields zero, which is confusing to smatch.

Reported-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: v4l2-fwnode: Avoid using PTR_ERR(NULL)
Sakari Ailus [Thu, 6 Jun 2019 14:18:42 +0000 (10:18 -0400)]
media: v4l2-fwnode: Avoid using PTR_ERR(NULL)

PTR_ERR(NULL) yields 0 which is commonly used to denote success. This is
the case here, and PTR_ERR(NULL) is apparently shunned upon. Fix this by
explicitly returning 0 if fwnode == NULL.

Reported-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: ov6650: Fix device node exposed without proper locking
Janusz Krzysztofik [Sun, 2 Jun 2019 21:22:15 +0000 (17:22 -0400)]
media: ov6650: Fix device node exposed without proper locking

Commit c62b96050bee ("media: ov6650: Register with asynchronous
subdevice framework") carelessly requested creation of a video device
node by setting a V4L2_SUBDEV_FL_HAS_DEVNODE flag.  The driver is not
ready for that as it doesn't implement proper locking required for
serialization of IOCTLs.

Fix it by dropping the flag assignment.

Fixes: c62b96050bee ("media: ov6650: Register with asynchronous subdevice framework")
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: i2c: Fix Unnecessary Semicolon Warning Reported by coccicheck
Shobhit Kukreti [Sat, 1 Jun 2019 15:27:34 +0000 (11:27 -0400)]
media: i2c: Fix Unnecessary Semicolon Warning Reported by coccicheck

Removed the warning from the following files:

drivers/media/i2c/ov13858.c
drivers/media/i2c/ov2685.c
drivers/media/i2c/ov5695.c

Signed-off-by: Shobhit Kukreti <shobhitkukreti@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: vivid.rst: describe display present control
Johan Korsnes [Tue, 18 Jun 2019 07:37:26 +0000 (03:37 -0400)]
media: vivid.rst: describe display present control

Signed-off-by: Johan Korsnes <johan.korsnes@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: vivid: add CEC support to display present ctrl
Johan Korsnes [Tue, 18 Jun 2019 07:37:25 +0000 (03:37 -0400)]
media: vivid: add CEC support to display present ctrl

Set/invalidate physical addresses based on the configuration of the
display present control. This is relevant not only when the display
present control is modified, but also when the Vivid instance EDID is
set/cleared.

Signed-off-by: Johan Korsnes <johan.korsnes@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: vivid: reorder CEC allocation and control set-up
Johan Korsnes [Tue, 18 Jun 2019 07:37:24 +0000 (03:37 -0400)]
media: vivid: reorder CEC allocation and control set-up

CEC adapters and controllers (handlers) are now set up as follows:

1. Allocate CEC adapters: setup of control handlers in next step
   requires these adapters to be allocated.
2. Setup of control handlers: This must be done prior to registering
   and exposing the adapters to user space to avoid a race condition.
3. Register CEC adapters: make them available to user space.

Signed-off-by: Johan Korsnes <johan.korsnes@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil-cisco@xs4all.nl: PTR_ERR -> PTR_ERR_OR_ZERO]
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: vivid: add HDMI (dis)connect RX emulation
Johan Korsnes [Tue, 18 Jun 2019 07:37:23 +0000 (03:37 -0400)]
media: vivid: add HDMI (dis)connect RX emulation

Adds the following bitmask control:
-V4L2_CID_DV_RX_POWER_PRESENT

The RX_POWER_PRESENT bitmask is set based on the digital video timings
signal mode. This also removes 1/1 warnings for v4l2-compliance test on
vivid instance with HDMI input.

Signed-off-by: Johan Korsnes <johan.korsnes@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: vivid: add HDMI (dis)connect TX emulation
Johan Korsnes [Tue, 18 Jun 2019 07:37:22 +0000 (03:37 -0400)]
media: vivid: add HDMI (dis)connect TX emulation

Adds the following bitmask controls:
-V4L2_CID_DV_TX_EDID_PRESENT
-V4L2_CID_DV_TX_HOTPLUG
-V4L2_CID_DV_TX_RXSENSE

The bitmasks are all set based on the custom vivid DISPLAY_PRESENT
control. This also removes 2/2 v4l2-compliance warnings for vivid
output device.

Signed-off-by: Johan Korsnes <johan.korsnes@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: vivid: add number of HDMI ports to device state
Johan Korsnes [Tue, 18 Jun 2019 07:37:21 +0000 (03:37 -0400)]
media: vivid: add number of HDMI ports to device state

This will be used for HDMI-specific controls such as hotplug detection
and power present.

Signed-off-by: Johan Korsnes <johan.korsnes@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: vivid: add display present control
Johan Korsnes [Tue, 18 Jun 2019 07:37:20 +0000 (03:37 -0400)]
media: vivid: add display present control

Add a custom control for selecting the presence of a display connected
to the active output. This control is part of an effort to implement
proper HDMI (dis)connect behavior for vivid.

Signed-off-by: Johan Korsnes <johan.korsnes@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: vivid: make input std_signal per-input
Johan Korsnes [Tue, 18 Jun 2019 07:37:19 +0000 (03:37 -0400)]
media: vivid: make input std_signal per-input

Make the following properties per-input:

-Standard Signal Mode
-Standard

These properties need to be per-input in order to implement proper HDMI
(dis)connect-behavior, where the signal mode will be used to signify
whether or not there is an inpute device connected.

Signed-off-by: Johan Korsnes <johan.korsnes@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: vivid: make input dv_timings per-input
Johan Korsnes [Tue, 18 Jun 2019 07:37:18 +0000 (03:37 -0400)]
media: vivid: make input dv_timings per-input

Make the following properties per-input

-DV Timings Signal Mode
-DV Timings

These properties need to be per-input in order to implement proper
HDMI (dis)connect-behavior, where the signal mode will be used to
signify whether or not there is an input device connected.

Signed-off-by: Johan Korsnes <johan.korsnes@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: staging: media: tegra-vde: Manually pack UAPI structures
Dmitry Osipenko [Sun, 2 Jun 2019 21:37:10 +0000 (17:37 -0400)]
media: staging: media: tegra-vde: Manually pack UAPI structures

The __packed macro isn't available in userspace with the kernel headers.
Checkpatch asks to use the macro, which is unwanted in a case of a UAPI
header. There is no much benefit in a tight packing of the structures,
hence let's pack them manually to cleanup things a tad. Note that there
is no old-stable userspace that will suffer from this change, hence it's
fine to change the ABI. In a result also more space is reserved for a
possible future expansion of the UAPI as it was already shown that more
fields will be needed for a later SoC generations.

Suggested-by: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: staging: media: tegra-vde: Remove BIT() macro from UAPI header
Dmitry Osipenko [Sun, 2 Jun 2019 21:37:09 +0000 (17:37 -0400)]
media: staging: media: tegra-vde: Remove BIT() macro from UAPI header

The BIT macro isn't available in userspace. Checkpatch complains about
shifts being used instead of the macro and people are starting to send
patches without realizing that it's a UAPI header file. Hence let's
replace the BIT macro with a hex values to make everyone happy.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: coda: Use devm_platform_ioremap_resource()
Fabio Estevam [Wed, 5 Jun 2019 18:05:43 +0000 (14:05 -0400)]
media: coda: Use devm_platform_ioremap_resource()

Use devm_platform_ioremap_resource() to simplify the code a bit.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: aspeed: add a workaround to fix a silicon bug
Jae Hyun Yoo [Fri, 31 May 2019 22:15:48 +0000 (18:15 -0400)]
media: aspeed: add a workaround to fix a silicon bug

AST2500 silicon revision A1 and A2 have a silicon bug which causes
extremly long capturing time on specific resolutions (1680 width).
To fix the bug, this commit adjusts the capturing window register
setting to 1728 if detected width is 1680. The compression window
register setting will be kept as the original width so output
result will be the same.

Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
Reviewed-by: Eddie James <eajames@linux.ibm.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: dt-bindings: imx7-csi: Document a single CSI clock
Fabio Estevam [Sat, 4 May 2019 14:40:25 +0000 (10:40 -0400)]
media: dt-bindings: imx7-csi: Document a single CSI clock

As per the i.MX7D Reference Manual only the MCLK is used for
the CSI block, so only document this single clock.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Tested-by: Rui Miguel Silva <rmfrfs@gmail.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: docs: create vimc documentation
André Almeida [Sun, 16 Jun 2019 02:09:59 +0000 (22:09 -0400)]
media: docs: create vimc documentation

Create vimc documentation file to explain its basic features, its
topology, how to configure it and to document vimc's subdevices.

Signed-off-by: André Almeida <andrealmeid@collabora.com>
Suggested-by: Helen Koike <helen.koike@collabora.com>
[hverkuil-cisco@xs4all.nl: Fix typo: The ``v4l2-utils`` -> The ``v4l-utils`` package]
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: vimc: stream: add missing function documentation
André Almeida [Sun, 16 Jun 2019 02:09:58 +0000 (22:09 -0400)]
media: vimc: stream: add missing function documentation

Add comments at vimc_streamer_s_stream and vimc_streamer_thread, making
the vimc-stream totally documented.

Signed-off-by: André Almeida <andrealmeid@collabora.com>
[hverkuil-cisco@xs4all.nl: fix typo: in a fixed framerate -> at a fixed framerate]
[hverkuil-cisco@xs4all.nl: fix typo: stops the thread -> stop the thread]
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: video-i2c: use V4L2_FRACT_COMPARE
Akinobu Mita [Sat, 15 Jun 2019 15:00:57 +0000 (11:00 -0400)]
media: video-i2c: use V4L2_FRACT_COMPARE

Use V4L2_FRACT_COMPARE to check whether two v4l2_fract structs are equal.

Cc: Matt Ranostay <matt.ranostay@konsulko.com>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: meye: Fix build COMPILE_TEST error
YueHaibing [Sat, 15 Jun 2019 07:45:53 +0000 (03:45 -0400)]
media: meye: Fix build COMPILE_TEST error

If COMPILE_TEST is y and SONY_LAPTOP is m,
building fails as below:

Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: 6159e12e1177 ("media: meye: allow building it with COMPILE_TEST on non-x86")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: docs: v4l2-controls: fix sentence rendered in a nonsense way
Luca Ceresoli [Fri, 14 Jun 2019 15:14:29 +0000 (11:14 -0400)]
media: docs: v4l2-controls: fix sentence rendered in a nonsense way

This sentence renders as:

> Since such compound controls need to expose more information about
> themselves than is possible with ioctls VIDIOC_QUERYCTRL,
> VIDIOC_QUERY_EXT_CTRL and VIDIOC_QUERYMENU the VIDIOC_QUERY_EXT_CTRL
  ^^^^^^^^^^^^^^^^^^^^^                          ^^^^^^^^^^^^^^^^^^^^^
> ioctl was added.

This does not make sense. Fix by providing an explicit link text. This
results in:

> Since such compound controls need to expose more information about
> themselves than is possible with VIDIOC_QUERYCTRL the
> VIDIOC_QUERY_EXT_CTRL ioctl was added.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: vivid: remove unnecessary min and max timeperframe constants
Akinobu Mita [Fri, 14 Jun 2019 14:09:06 +0000 (10:09 -0400)]
media: vivid: remove unnecessary min and max timeperframe constants

The tpf_min (1/100) and tpf_max (100/1) are used as the lowest and the
highest allowable value for the desired frame period in
vivid_vid_cap_s_parm().

But the comparison between these values is unnecessary because the compared
value is already chosen from webcam_intervals[] (from 1/60 to 1/1).

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: mtk-vcodec: remove unneeded proxy functions
Alexandre Courbot [Fri, 14 Jun 2019 07:56:40 +0000 (03:56 -0400)]
media: mtk-vcodec: remove unneeded proxy functions

We were getting the codec interface through a proxy function that does
not bring anything compared to just accessing the interface definition
directly, so just do that. Also make the decoder interfaces const.

Signed-off-by: Alexandre Courbot <acourbot@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: mtk-vcodec: avoid unneeded pointer-to-long conversions
Alexandre Courbot [Fri, 14 Jun 2019 07:56:21 +0000 (03:56 -0400)]
media: mtk-vcodec: avoid unneeded pointer-to-long conversions

The interface used to communicate with the firmware casts pointers
into unsigned longs and back again in order to store private
references, all of this for pointers that remain purely in the kernel.
Replace these unsigned longs with void pointers to make the code a bit
sturdier and easier to follow.

Also simplify some interfaces by removing arguments that could be
infered from others.

Signed-off-by: Alexandre Courbot <acourbot@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil-cisco@xs4all.nl: fix checkpatch alignment warning]
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: vimc: Makefile: file cleanup
André Almeida [Thu, 13 Jun 2019 15:06:14 +0000 (11:06 -0400)]
media: vimc: Makefile: file cleanup

Remove redundant Makefile rules (vimc_capture-objs, ...).

Stop exposing vimc-{common, streamer} as modules, since there's no use
case where they would be individually added/removed from Vimc. As
consequence, remove MODULE_ macros from vimc-{common, streamer}.

`-objs` is fitted for building host programs, change to `-y`, more
straightforward for device drivers.

Signed-off-by: André Almeida <andrealmeid@collabora.com>
Suggested-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: vimc: debayer: Fix typos
André Almeida [Thu, 13 Jun 2019 15:06:13 +0000 (11:06 -0400)]
media: vimc: debayer: Fix typos

Fix typo on "tranforming". Add a line break so it keeps under 80 columns.
Fix typo on "[it] need".

Signed-off-by: André Almeida <andrealmeid@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: docs: v4l2-controls: remove outdated paragraph
Luca Ceresoli [Thu, 13 Jun 2019 14:18:26 +0000 (10:18 -0400)]
media: docs: v4l2-controls: remove outdated paragraph

This paragraph was added by commit a42b57f5aacf ("V4L/DVB: Documentation:
add v4l2-controls.txt documenting the new controls API") back in 2010, when
the controls API has been improved. Nowadays it is a bit anachronistic, so
remove it.

The same information is stated in up-to-date wording a few paragraphs later

> You’re done! And this is sufficient for most of the drivers we have. No
> need to do any validation of control values, or implement QUERYCTRL,
> QUERY_EXT_CTRL and QUERYMENU. And G/S_CTRL as well as G/TRY/S_EXT_CTRLS
> are automatically supported.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: docs: v4l2-controls: document file to include
Luca Ceresoli [Thu, 13 Jun 2019 14:18:25 +0000 (10:18 -0400)]
media: docs: v4l2-controls: document file to include

The tutorial in this section is almost complete, add the one missing bit.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: docs: v4l2-controls: convert code blocks to C
Luca Ceresoli [Thu, 13 Jun 2019 14:18:24 +0000 (10:18 -0400)]
media: docs: v4l2-controls: convert code blocks to C

All these code blocks contain C code, enable C formatting for a nicer
reading.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: docs: v4l2-controls: add links to functions
Luca Ceresoli [Thu, 13 Jun 2019 14:18:23 +0000 (10:18 -0400)]
media: docs: v4l2-controls: add links to functions

This section lacks links to functions. Add one to simplify reading.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: docs: v4l2-controls: rearrange control initialization sequence
Luca Ceresoli [Thu, 13 Jun 2019 14:18:22 +0000 (10:18 -0400)]
media: docs: v4l2-controls: rearrange control initialization sequence

The code snippet showing how to add controls to the driver’s top-level
struct is present twice, but only the second time it is split in the V4L2
and subdev cases. Consolidate everything at the beginning.

Also remove the "Where foo->bar is of type struct baz" sentences, this
obvious from the code.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: docs: v4l2-controls: add links to structs
Luca Ceresoli [Thu, 13 Jun 2019 14:18:21 +0000 (10:18 -0400)]
media: docs: v4l2-controls: add links to structs

This section lacks links to struct definitions. Add one where each struct
is introduced.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: docs: v4l2-controls: fix indentation
Luca Ceresoli [Thu, 13 Jun 2019 14:18:20 +0000 (10:18 -0400)]
media: docs: v4l2-controls: fix indentation

Fix indentation in example C code.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: docs: v4l2-controls: remove repeated ioctl names
Luca Ceresoli [Thu, 13 Jun 2019 14:18:19 +0000 (10:18 -0400)]
media: docs: v4l2-controls: remove repeated ioctl names

Mentioning :ref:`VIDIOC_QUERYCTRL` renders all the three related ioctls.
Explicitly adding VIDIOC_QUERY_EXT_CTRL and VIDIOC_QUERYMENU will make
them render twice, so remove them

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: s5p-mfc: Make additional clocks optional
Marek Szyprowski [Thu, 13 Jun 2019 10:48:34 +0000 (06:48 -0400)]
media: s5p-mfc: Make additional clocks optional

Since the beginning the second clock ('special', 'sclk') was optional and
it is not available on some variants of Exynos SoCs (i.e. Exynos5420 with
v7 of MFC hardware).

However commit 1bce6fb3edf1 ("[media] s5p-mfc: Rework clock handling")
made handling of all specified clocks mandatory. This patch restores
original behavior of the driver and fixes its operation on
Exynos5420 SoCs.

Fixes: 1bce6fb3edf1 ("[media] s5p-mfc: Rework clock handling")
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: MAINTAINERS: fix linux-media mailing list for meson drivers
Maxime Jourdan [Thu, 13 Jun 2019 09:51:02 +0000 (05:51 -0400)]
media: MAINTAINERS: fix linux-media mailing list for meson drivers

Both MESON AO CEC and MESON VIDEO DECODER point to the wrong linux-media
mailing list. Update it to linux-media@vger.kernel.org.

Signed-off-by: Maxime Jourdan <mjourdan@baylibre.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: videodev2.h: Fix shifting signed 32-bit value by 31 bits problem
Shuah Khan [Thu, 13 Jun 2019 00:56:52 +0000 (20:56 -0400)]
media: videodev2.h: Fix shifting signed 32-bit value by 31 bits problem

Fix v4l2_fourcc define to use "U" cast to avoid shifting signed 32-bit
value by 31 bits problem. This isn't a problem for kernel builds with
gcc.

This could be problem since this header is part of public API which
could be included for builds using compilers that don't handle this
condition safely resulting in undefined behavior.

Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: media.h: Fix shifting signed 32-bit value by 31 bits problem
Shuah Khan [Thu, 13 Jun 2019 00:56:20 +0000 (20:56 -0400)]
media: media.h: Fix shifting signed 32-bit value by 31 bits problem

Fix MEDIA_ENT_ID_FLAG_NEXT to use "U" cast to avoid shifting signed
32-bit value by 31 bits problem. This isn't a problem for kernel builds
with gcc.

This could be problem since this header is part of public API which
could be included for builds using compilers that don't handle this
condition safely resulting in undefined behavior.

Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: rcar-vin: Merge Gen2 and Gen3 file operations
Niklas Söderlund [Wed, 12 Jun 2019 23:45:47 +0000 (19:45 -0400)]
media: rcar-vin: Merge Gen2 and Gen3 file operations

After the rework of the Gen2 file operations it's now trivial to merge
the Gen2 and Gen3 versions.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: rcar-vin: Fold rvin_initialize_device() into rvin_open()
Niklas Söderlund [Wed, 12 Jun 2019 23:45:46 +0000 (19:45 -0400)]
media: rcar-vin: Fold rvin_initialize_device() into rvin_open()

The function no longer serve a purpose as most tasks it performed have
been refactored, fold what remains of it into the only caller. While at
it add error checking for v4l2_ctrl_handler_setup().

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: rcar-vin: Merge helpers dealing with powering the parallel subdevice
Niklas Söderlund [Wed, 12 Jun 2019 23:45:45 +0000 (19:45 -0400)]
media: rcar-vin: Merge helpers dealing with powering the parallel subdevice

The two power helpers are now only dealing with the parallel subdevice,
merge them into a single rvin_power_parallel() helper to reduce code
duplication.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: rcar-vin: Move pm_runtime_{get,put} out of helpers
Niklas Söderlund [Wed, 12 Jun 2019 23:45:44 +0000 (19:45 -0400)]
media: rcar-vin: Move pm_runtime_{get,put} out of helpers

The helpers rvin_power_{on,off} deal with both VIN and the parallel
subdevice power. This makes it hard to merge the Gen2 and Gen3
open/release functions. Move the VIN power handling directly to the
open/release functions to prepare for the merge.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: rcar-vin: Do not sync subdevice format when opening the video device
Niklas Söderlund [Wed, 12 Jun 2019 23:45:43 +0000 (19:45 -0400)]
media: rcar-vin: Do not sync subdevice format when opening the video device

The format is already synced when the subdevice is bound, there is no
need to do do it every time the video device is opened.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: rcar-vin: Allow interrupting lock when trying to open the video device
Niklas Söderlund [Wed, 12 Jun 2019 23:45:42 +0000 (19:45 -0400)]
media: rcar-vin: Allow interrupting lock when trying to open the video device

The user should be allowed to break waiting for the lock when opening
the video device.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: rcar-vin: Remove unneeded calls to pm_runtime_{enable, disable}
Niklas Söderlund [Wed, 12 Jun 2019 23:45:41 +0000 (19:45 -0400)]
media: rcar-vin: Remove unneeded calls to pm_runtime_{enable, disable}

Runtime PM is already enabled unconditionally when the driver is probed
and disabled when it's removed. There is no point in doing it again for
Gen2 when opening and closing the video device.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: rcar-vin: Do not call pm_runtime_{resume,suspend}()
Niklas Söderlund [Wed, 12 Jun 2019 23:45:40 +0000 (19:45 -0400)]
media: rcar-vin: Do not call pm_runtime_{resume,suspend}()

The driver does not implement runtime resume and suspend function so
there is little point in trying to call them. This is a leftover from
the drivers soc_camera beginnings.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: i2c: fix warning same module names
Anders Roxell [Wed, 12 Jun 2019 16:19:35 +0000 (12:19 -0400)]
media: i2c: fix warning same module names

When building with CONFIG_VIDEO_ADV7511 and CONFIG_DRM_I2C_ADV7511
enabled as loadable modules, we see the following warning:

  drivers/gpu/drm/bridge/adv7511/adv7511.ko
  drivers/media/i2c/adv7511.ko

Rework so that the file is named adv7511-v4l2.c.

Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: staging: media: meson: remove redundant initialization of mpeg12
Colin Ian King [Wed, 12 Jun 2019 14:42:18 +0000 (10:42 -0400)]
media: staging: media: meson: remove redundant initialization of mpeg12

The pointer mpeg12 is being initialized however that value is never
read and mpeg12 is being re-assigned almost immediately afterwards.
Remove the redundant initialization.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Maxime Jourdan <mjourdan@baylibre.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: atmel: atmel-isc: fix and cleanup potential bugs
Eugen Hristev [Wed, 12 Jun 2019 12:00:35 +0000 (08:00 -0400)]
media: atmel: atmel-isc: fix and cleanup potential bugs

Fixed issues that can lead to potential bugs.
Cleanup order in the driver
Taking into consideration std control creation can fail
mutex_destroy call
changing controller_formats with const specifier
some cosmetic cleanups

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: atmel: atmel-isc: split driver into driver base and isc
Eugen Hristev [Wed, 12 Jun 2019 12:00:31 +0000 (08:00 -0400)]
media: atmel: atmel-isc: split driver into driver base and isc

This splits the Atmel ISC driver into a common base: atmel-isc-base.c
and the driver probe/dt part , atmel-sama5d2-isc.c
This is needed to keep a common ground for the sensor controller which will
be reused.
The atmel-isc will use the common symbols inside the atmel-isc-base
Future driver will also use the same symbols and redefine different aspects,
for a different version of the ISC.
This is done to avoid complete code duplication by creating a totally
different driver for the new variant of the ISC.

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil-cisco@xs4all.nl: folded 'atmel: atmel-sama5d2-isc: fixed checkpatch warnings' into this patch]
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: imx7-media-csi: get csi upstream endpoint
Rui Miguel Silva [Wed, 12 Jun 2019 10:00:28 +0000 (06:00 -0400)]
media: imx7-media-csi: get csi upstream endpoint

When the upstream endpoint is neither a mux nor a CSI2 module, just get
the source pad directly upstream from the CSI.

Reported-by: Sebastien Szymanski <sebastien.szymanski@armadeus.com>
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: Clarify the meaning of file descriptors in VIDIOC_DQBUF
Tomasz Figa [Wed, 12 Jun 2019 09:36:48 +0000 (05:36 -0400)]
media: Clarify the meaning of file descriptors in VIDIOC_DQBUF

When the application calls VIDIOC_DQBUF with the DMABUF memory type, the
v4l2_buffer structure (or v4l2_plane structures) are filled with DMA-buf
file descriptors. However, the current documentation does not explain
whether those are new file descriptors referring to the same DMA-bufs or
just the same integers as passed to VIDIOC_QBUF back in time. Clarify
the documentation that it's the latter.

Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: sti: Use vb2_get_buffer
Ezequiel Garcia [Mon, 10 Jun 2019 20:55:25 +0000 (16:55 -0400)]
media: sti: Use vb2_get_buffer

Use the newly introduced vb2_get_buffer API and avoid
accessing buffers in the queue directly.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: mtk-vcodec: Use vb2_get_buffer
Ezequiel Garcia [Mon, 10 Jun 2019 20:55:24 +0000 (16:55 -0400)]
media: mtk-vcodec: Use vb2_get_buffer

Use the newly introduced vb2_get_buffer API and avoid
accessing buffers in the queue directly.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil-cisco@xs4all.nl: fixed checkpatch alignment warning]
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>