sfrench/cifs-2.6.git
4 years agomedia: ts2020: Variable "utmp" in function ts2020_set_tuner_rf() could be uninitialized
Yizhuo [Wed, 30 Jan 2019 17:33:30 +0000 (12:33 -0500)]
media: ts2020: Variable "utmp" in function ts2020_set_tuner_rf() could be uninitialized

In function ts2020_set_tuner_rf(), local variable "utmp" could
be uninitialized if function regmap_read() returns -EINVAL.
However, this value is used in if statement and written to
the register, which is potentially unsafe.

Signed-off-by: Yizhuo <yzhai003@ucr.edu>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: si2165: fix platform_no_drv_owner.cocci warnings
YueHaibing [Thu, 21 Mar 2019 01:45:32 +0000 (21:45 -0400)]
media: si2165: fix platform_no_drv_owner.cocci warnings

Remove .owner field if calls are used which set it automatically
Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: rc: xbox_remote: add protocol and set timeout
Matthias Reichl [Sun, 24 Mar 2019 09:43:51 +0000 (05:43 -0400)]
media: rc: xbox_remote: add protocol and set timeout

The timestamps in ir-keytable -t output showed that the Xbox DVD
IR dongle decodes scancodes every 64ms. The last scancode of a
longer button press is decodes 64ms after the last-but-one which
indicates the decoder doesn't use a timeout but decodes on the last
edge of the signal.

267.042629: lirc protocol(unknown): scancode = 0xace
267.042665: event type EV_MSC(0x04): scancode = 0xace
267.042665: event type EV_KEY(0x01) key_down: KEY_1(0x0002)
267.042665: event type EV_SYN(0x00).
267.106625: lirc protocol(unknown): scancode = 0xace
267.106643: event type EV_MSC(0x04): scancode = 0xace
267.106643: event type EV_SYN(0x00).
267.170623: lirc protocol(unknown): scancode = 0xace
267.170638: event type EV_MSC(0x04): scancode = 0xace
267.170638: event type EV_SYN(0x00).
267.234621: lirc protocol(unknown): scancode = 0xace
267.234636: event type EV_MSC(0x04): scancode = 0xace
267.234636: event type EV_SYN(0x00).
267.298623: lirc protocol(unknown): scancode = 0xace
267.298638: event type EV_MSC(0x04): scancode = 0xace
267.298638: event type EV_SYN(0x00).
267.543345: event type EV_KEY(0x01) key_down: KEY_1(0x0002)
267.543345: event type EV_SYN(0x00).
267.570015: event type EV_KEY(0x01) key_up: KEY_1(0x0002)
267.570015: event type EV_SYN(0x00).

Add a protocol with the repeat value and set the timeout in the
driver to 10ms (to have a bit of headroom for delays) so the Xbox
DVD remote performs more responsive.

Signed-off-by: Matthias Reichl <hias@horus.com>
Acked-by: Benjamin Valentin <benpicco@googlemail.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: rcar-csi2: Move setting of Field Detection Control Register
Niklas Söderlund [Wed, 10 Apr 2019 14:27:15 +0000 (10:27 -0400)]
media: rcar-csi2: Move setting of Field Detection Control Register

Later datasheet versions (rev 1.00) clarifies that the FLD register
should be set after LINKCNT.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
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-csi2: Update start procedure for H3 ES2
Niklas Söderlund [Tue, 12 Mar 2019 23:50:18 +0000 (19:50 -0400)]
media: rcar-csi2: Update start procedure for H3 ES2

Latest information from hardware engineers reveals that H3 ES2 and ES3
behave differently when working with link speeds bellow 250 Mpbs.
Add a SoC match for H3 ES2.* and use the correct startup sequence.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
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-csi2: Update V3M and E3 start procedure
Niklas Söderlund [Tue, 12 Mar 2019 23:50:17 +0000 (19:50 -0400)]
media: rcar-csi2: Update V3M and E3 start procedure

The latest datasheet (rev 1.50) updates the start procedure for V3M and
E3. Update the driver to match these changes.

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-csi2: Use standby mode instead of resetting
Niklas Söderlund [Tue, 12 Mar 2019 23:49:30 +0000 (19:49 -0400)]
media: rcar-csi2: Use standby mode instead of resetting

Later versions of the datasheet updates the reset procedure to more
closely resemble the standby mode. Update the driver to enter and exit
the standby mode instead of resetting the hardware before and after
streaming is started and stopped. This replaces the software reset
(SRST.SRST) control.

While at it break out the full start and stop procedures from
rcsi2_s_stream() into the existing helper functions.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
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: dt-bindings: rcar-csi2: List resets as a mandatory property
Niklas Söderlund [Tue, 12 Mar 2019 23:49:29 +0000 (19:49 -0400)]
media: dt-bindings: rcar-csi2: List resets as a mandatory property

The resets property will become mandatory to operate the device, list it
as such. All device tree source files have always included the reset
property so making it mandatory will not introduce any regressions.

While at it improve the description for the clocks property.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.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: coda: throw error on create_bufs with too small size
Philipp Zabel [Mon, 8 Apr 2019 12:32:55 +0000 (08:32 -0400)]
media: coda: throw error on create_bufs with too small size

If VIDIOC_CREATE_BUFS is called with a sizeimage smaller than the
queue sizeimage, fail with -EINVAL instead of correcting the size
and continuing without error. This is required by v4l2-compliance.

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 encoder to set colorimetry on the output queue
Philipp Zabel [Mon, 8 Apr 2019 12:32:54 +0000 (08:32 -0400)]
media: coda: allow encoder to set colorimetry on the output queue

v4l2-compliance sets colorimetry on the output queue and then verifies
that querying colorimetry on the capture queue returns the same
configuration. For this to work, the encoder must allow setting context
colorimetry parameters on the output 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: implement encoder frame size enumeration
Philipp Zabel [Mon, 8 Apr 2019 12:32:52 +0000 (08:32 -0400)]
media: coda: implement encoder frame size enumeration

The stateful encoder API requires VIDIOC_ENUM_FRAMESIZES to be
implemented.
Allow enumeration of supported frame sizes for encoding.

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: disable encoder command on decoder and vice versa
Philipp Zabel [Mon, 8 Apr 2019 12:32:51 +0000 (08:32 -0400)]
media: coda: disable encoder command on decoder and vice versa

Return -ENOTTY when userspace tries to call VIDIOC_(TRY_)ENCODER_CMD on
a decoder instance or VIDIOC_(TRY_)DECODER_CMD on an encoder instance.

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 min number of buffers controls
Philipp Zabel [Mon, 8 Apr 2019 12:32:50 +0000 (08:32 -0400)]
media: coda: add min number of buffers controls

Add min number of buffers for capture (decoder) and output (encoder)
controls, which are required by the stateful video decoder / encoder
interface specification.

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: clear error return value before picture run
Philipp Zabel [Mon, 8 Apr 2019 12:32:49 +0000 (08:32 -0400)]
media: coda: clear error return value before picture run

The error return value is not written by some firmware codecs, such as
MPEG-2 decode on CodaHx4. Clear the error return value before starting
the picture run to avoid misinterpreting unrelated values returned by
sequence initialization as error return value.

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: remove mask from decoder h.264 level control
Philipp Zabel [Mon, 8 Apr 2019 12:32:48 +0000 (08:32 -0400)]
media: coda: remove mask from decoder h.264 level control

Since levels are specified in terms of maximum values, there is no
reason to filter out lower levels than the supported maximum.

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: set codec earlier
Philipp Zabel [Mon, 8 Apr 2019 12:32:47 +0000 (08:32 -0400)]
media: coda: set codec earlier

The chosen codec depends on the coded format, which is known as soon as
the S_FMT call on the coded queue. This allows to use the codec in
callbacks that may be called before start_streaming, such as buf_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: vb2: add waiting_in_dqbuf flag
Hans Verkuil [Mon, 19 Nov 2018 11:09:00 +0000 (06:09 -0500)]
media: vb2: add waiting_in_dqbuf flag

Calling VIDIOC_DQBUF can release the core serialization lock pointed to
by vb2_queue->lock if it has to wait for a new buffer to arrive.

However, if userspace dup()ped the video device filehandle, then it is
possible to read or call DQBUF from two filehandles at the same time.

It is also possible to call REQBUFS from one filehandle while the other
is waiting for a buffer. This will remove all the buffers and reallocate
new ones. Removing all the buffers isn't the problem here (that's already
handled correctly by DQBUF), but the reallocating part is: DQBUF isn't
aware that the buffers have changed.

This is fixed by setting a flag whenever the lock is released while waiting
for a buffer to arrive. And checking the flag where needed so we can return
-EBUSY.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Reported-by: Syzbot <syzbot+4180ff9ca6810b06c1e9@syzkaller.appspotmail.com>
Reviewed-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: pvrusb2: Prevent a buffer overflow
Dan Carpenter [Mon, 8 Apr 2019 09:52:38 +0000 (05:52 -0400)]
media: pvrusb2: Prevent a buffer overflow

The ctrl_check_input() function is called from pvr2_ctrl_range_check().
It's supposed to validate user supplied input and return true or false
depending on whether the input is valid or not.  The problem is that
negative shifts or shifts greater than 31 are undefined in C.  In
practice with GCC they result in shift wrapping so this function returns
true for some inputs which are not valid and this could result in a
buffer overflow:

    drivers/media/usb/pvrusb2/pvrusb2-ctrl.c:205 pvr2_ctrl_get_valname()
    warn: uncapped user index 'names[val]'

The cptr->hdw->input_allowed_mask mask is configured in pvr2_hdw_create()
and the highest valid bit is BIT(4).

Fixes: 7fb20fa38caa ("V4L/DVB (7299): pvrusb2: Improve logic which handles input choice availability")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: cedrus: Fix initialization order
Jernej Skrabec [Sun, 7 Apr 2019 18:47:28 +0000 (14:47 -0400)]
media: cedrus: Fix initialization order

Currently, MEDIA_IOC_G_TOPOLOGY ioctl on cedrus fails due to incorrect
initialization order. Fix that by moving video_register_device() before
v4l2_m2m_register_media_controller() and while at it, fix error path.

Reported-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
Acked-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: vivid: use vfree() instead of kfree() for dev->bitmap_cap
Alexander Potapenko [Thu, 4 Apr 2019 14:56:46 +0000 (10:56 -0400)]
media: vivid: use vfree() instead of kfree() for dev->bitmap_cap

syzkaller reported crashes on kfree() called from
vivid_vid_cap_s_selection(). This looks like a simple typo, as
dev->bitmap_cap is allocated with vzalloc() throughout the file.

Fixes: ef834f7836ec0 ("[media] vivid: add the video capture and output
parts")

Signed-off-by: Alexander Potapenko <glider@google.com>
Reported-by: Syzbot <syzbot+6c0effb5877f6b0344e2@syzkaller.appspotmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: videobuf2-v4l2.c: move up STATE_DEQUEUED check
Hans Verkuil [Mon, 1 Apr 2019 12:41:58 +0000 (08:41 -0400)]
media: videobuf2-v4l2.c: move up STATE_DEQUEUED check

If a buffer is queued to a request, followed by an attempt to queue
the same buffer again, then the second qbuf returns an error since
the buffer is not in the DEQUEUED state anymore.

However, before it gets to that check it executes the code under the
'if (!vb->prepared)' condition. This clears previously set data needed
for request handling, and now querybuf will no longer report that this
buffer is part of a request.

Move the state check to before the 'if' and make sure to only do the
state check when called from QBUF and if V4L2_BUF_FLAG_REQUEST_FD is
set.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: mtk-vcodec: fix vp9 content playback error with show exist frame
Maoguang Meng [Mon, 1 Apr 2019 08:18:38 +0000 (04:18 -0400)]
media: mtk-vcodec: fix vp9 content playback error with show exist frame

Update referenced frame buffer's reference count when playing vp9
content which has show_existing_frame flag, and copy enough buffer
data to current shown frame.

Signed-off-by: Maoguang Meng <maoguang.meng@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: ipu3-imgu: Use %u for formatting unsigned values (not %d)
Sakari Ailus [Tue, 9 Apr 2019 08:06:54 +0000 (04:06 -0400)]
media: ipu3-imgu: Use %u for formatting unsigned values (not %d)

The driver used %d for formatting unsigned values. Use %u instead.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: staging/intel-ipu3: parameter buffer refactoring
Bingbu Cao [Fri, 22 Mar 2019 11:14:45 +0000 (07:14 -0400)]
media: staging/intel-ipu3: parameter buffer refactoring

Current ImgU driver processes and releases the parameter buffer
immediately after queued from user. This does not align with other
image buffers which are grouped in sets and used for the same frame.
If user queues multiple parameter buffers continuously, only the last
one will take effect.
To make consistent buffers usage, this patch changes the parameter
buffer handling and group parameter buffer with other image buffers
for each frame.
Each time driver will queue one more group of buffers when previous
frame processed and buffers consumed by css.

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>
4 years agomedia: st-mipid02: MIPID02 CSI-2 to PARALLEL bridge driver
Mickael Guene [Tue, 9 Apr 2019 06:15:49 +0000 (02:15 -0400)]
media: st-mipid02: MIPID02 CSI-2 to PARALLEL bridge driver

This V4L2 subdev driver enables STMicroelectronics MIPID02 device.

Signed-off-by: Mickael Guene <mickael.guene@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: dt-bindings: Document MIPID02 bindings
Mickael Guene [Tue, 9 Apr 2019 06:15:48 +0000 (02:15 -0400)]
media: dt-bindings: Document MIPID02 bindings

This adds documentation of device tree for MIPID02 CSI-2 to PARALLEL
bridge.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Mickael Guene <mickael.guene@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: uapi: Add MEDIA_BUS_FMT_BGR888_3X8 media bus format
Mickael Guene [Tue, 9 Apr 2019 06:15:47 +0000 (02:15 -0400)]
media: uapi: Add MEDIA_BUS_FMT_BGR888_3X8 media bus format

This patch adds MEDIA_BUS_FMT_BGR888_3X8 used by STM MIPID02 CSI-2 to
PARALLEL bridge driver when input format is MEDIA_BUS_FMT_BGR888_1X24.

Signed-off-by: Mickael Guene <mickael.guene@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: ov2659: fix unbalanced mutex_lock/unlock
Akinobu Mita [Sat, 30 Mar 2019 14:01:32 +0000 (10:01 -0400)]
media: ov2659: fix unbalanced mutex_lock/unlock

Avoid returning with mutex locked.

Fixes: fa8cb6444c32 ("[media] ov2659: Don't depend on subdev API")
Cc: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Acked-by: Lad, Prabhakar <prabhakar.csengg@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: ov2659: make S_FMT succeed even if requested format doesn't match
Akinobu Mita [Sat, 30 Mar 2019 14:01:31 +0000 (10:01 -0400)]
media: ov2659: make S_FMT succeed even if requested format doesn't match

This driver returns an error if unsupported media bus pixel code is
requested by VIDIOC_SUBDEV_S_FMT.

But according to Documentation/media/uapi/v4l/vidioc-subdev-g-fmt.rst,

Drivers must not return an error solely because the requested format
doesn't match the device capabilities. They must instead modify the
format to match what the hardware can provide.

So select default format code and return success in that case.

This is detected by v4l2-compliance.

Cc: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Acked-by: Lad, Prabhakar <prabhakar.csengg@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: ov6650: Register with asynchronous subdevice framework
Janusz Krzysztofik [Sat, 30 Mar 2019 01:06:10 +0000 (21:06 -0400)]
media: ov6650: Register with asynchronous subdevice framework

Register V4L2 subdevice implemented by the driver to the V4L2
asynchronous subdevice framework.

[Sakari Ailus: Remove extra call to v4l2_i2c_subdev_set_name]

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: ov6650: Move v4l2_clk_get() to ov6650_video_probe() helper
Janusz Krzysztofik [Sat, 30 Mar 2019 01:06:09 +0000 (21:06 -0400)]
media: ov6650: Move v4l2_clk_get() to ov6650_video_probe() helper

In preparation for adding asynchronous subdevice support to the driver,
don't acquire v4l2_clk from the driver .probe() callback as that may
fail if the clock is provided by a bridge driver which may be not yet
initialized.  Move the v4l2_clk_get() to ov6650_video_probe() helper
which is going to be converted to v4l2_subdev_internal_ops.registered()
callback, executed only when the bridge driver is ready.

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: ov6650: Fix sensor possibly not detected on probe
Janusz Krzysztofik [Mon, 25 Mar 2019 00:21:12 +0000 (20:21 -0400)]
media: ov6650: Fix sensor possibly not detected on probe

After removal of clock_start() from before soc_camera_init_i2c() in
soc_camera_probe() by commit 9aea470b399d ("[media] soc-camera: switch
I2C subdevice drivers to use v4l2-clk") introduced in v3.11, the ov6650
driver could no longer probe the sensor successfully because its clock
was no longer turned on in advance.  The issue was initially worked
around by adding that missing clock_start() equivalent to OMAP1 camera
interface driver - the only user of this sensor - but a propoer fix
should be rather implemented in the sensor driver code itself.

Fix the issue by inserting a delay between the clock is turned on and
the sensor I2C registers are read for the first time.

Tested on Amstrad Delta with now out of tree but still locally
maintained omap1_camera host driver.

Fixes: 9aea470b399d ("[media] soc-camera: switch I2C subdevice drivers to use v4l2-clk")
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: au0828: stop video streaming only when last user stops
Hans Verkuil [Tue, 2 Apr 2019 07:24:15 +0000 (03:24 -0400)]
media: au0828: stop video streaming only when last user stops

If the application was streaming from both videoX and vbiX, and streaming
from videoX was stopped, then the vbi streaming also stopped.

The cause being that stop_streaming for video stopped the subdevs as well,
instead of only doing that if dev->streaming_users reached 0.

au0828_stop_vbi_streaming was also wrong since it didn't stop the subdevs
at all when dev->streaming_users reached 0.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Tested-by: Shuah Khan <shuah@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: Clear devnode->media_dev holding media_devnode_lock
Shuah Khan [Tue, 2 Apr 2019 00:43:18 +0000 (20:43 -0400)]
media: Clear devnode->media_dev holding media_devnode_lock

Fix media_devnode_unregister() to clear devnode->media_dev while holding
media_devnode_lock. media_devnode_register()'s cdev_add_error handling
does this correctly.

Signed-off-by: Shuah Khan <shuah@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: au0828: Fix NULL pointer dereference in au0828_analog_stream_enable()
Shuah Khan [Tue, 2 Apr 2019 00:43:17 +0000 (20:43 -0400)]
media: au0828: Fix NULL pointer dereference in au0828_analog_stream_enable()

Fix au0828_analog_stream_enable() to check if device is in the right
state first. When unbind happens while bind is in progress, usbdev
pointer could be invalid in au0828_analog_stream_enable() and a call
to usb_ifnum_to_if() will result in the null pointer dereference.

This problem is found with the new media_dev_allocator.sh test.

kernel: [  590.359623] BUG: unable to handle kernel NULL pointer dereference at 00000000000004e8
kernel: [  590.359627] #PF error: [normal kernel read fault]
kernel: [  590.359629] PGD 0 P4D 0
kernel: [  590.359632] Oops: 0000 [#1] SMP PTI
kernel: [  590.359634] CPU: 3 PID: 1458 Comm: v4l_id Not tainted 5.1.0-rc2+ #30
kernel: [  590.359636] Hardware name: Dell Inc. OptiPlex 7 90/0HY9JP, BIOS A18 09/24/2013
kernel: [  590.359641] RIP: 0010:usb_ifnum_to_if+0x6/0x60
kernel: [  590.359643] Code: 5d 41 5e 41 5f 5d c3 48 83 c4
 10 b8 fa ff ff ff 5b 41 5c 41 5d 41 5e 41 5f 5d c3 b8 fa ff ff ff c3 0f 1f 00 6
6 66 66 66 90 55 <48> 8b 97 e8 04 00 00 48 89 e5 48 85 d2 74 41 0f b6 4a 04 84 c
9 74
kernel: [  590.359645] RSP: 0018:ffffad3cc3c1fc00 EFLAGS: 00010246
kernel: [  590.359646] RAX: 0000000000000000 RBX: ffff8ded b1f3c000 RCX: 1f377e4500000000
kernel: [  590.359648] RDX: ffff8dedfa3a6b50 RSI: 00000000 00000000 RDI: 0000000000000000
kernel: [  590.359649] RBP: ffffad3cc3c1fc28 R08: 00000000 8574acc2 R09: ffff8dedfa3a6b50
kernel: [  590.359650] R10: 0000000000000001 R11: 00000000 00000000 R12: 0000000000000000
kernel: [  590.359652] R13: ffff8dedb1f3f0f0 R14: ffffffff adcf7ec0 R15: 0000000000000000
kernel: [  590.359654] FS:  00007f7917198540(0000) GS:ffff 8dee258c0000(0000) knlGS:0000000000000000
kernel: [  590.359655] CS:  0010 DS: 0000 ES: 0000 CR0: 00 00000080050033
kernel: [  590.359657] CR2: 00000000000004e8 CR3: 00000001 a388e002 CR4: 00000000000606e0
kernel: [  590.359658] Call Trace:
kernel: [  590.359664]  ? au0828_analog_stream_enable+0x2c/0x180
kernel: [  590.359666]  au0828_v4l2_open+0xa4/0x110
kernel: [  590.359670]  v4l2_open+0x8b/0x120
kernel: [  590.359674]  chrdev_open+0xa6/0x1c0
kernel: [  590.359676]  ? cdev_put.part.3+0x20/0x20
kernel: [  590.359678]  do_dentry_open+0x1f6/0x360
kernel: [  590.359681]  vfs_open+0x2f/0x40
kernel: [  590.359684]  path_openat+0x299/0xc20
kernel: [  590.359688]  do_filp_open+0x9b/0x110
kernel: [  590.359695]  ? _raw_spin_unlock+0x27/0x40
kernel: [  590.359697]  ? __alloc_fd+0xb2/0x160
kernel: [  590.359700]  do_sys_open+0x1ba/0x260
kernel: [  590.359702]  ? do_sys_open+0x1ba/0x260
kernel: [  590.359712]  __x64_sys_openat+0x20/0x30
kernel: [  590.359715]  do_syscall_64+0x5a/0x120
kernel: [  590.359718]  entry_SYSCALL_64_after_hwframe+0x44/0xa9

Signed-off-by: Shuah Khan <shuah@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: selftests: media_dev_allocator api test
Shuah Khan [Tue, 2 Apr 2019 00:40:24 +0000 (20:40 -0400)]
media: selftests: media_dev_allocator api test

Add a new test for Media Device Allocator API.

Media Device Allocator API to allows multiple drivers share a media device.
This API solves a very common use-case for media devices where one physical
device (an USB stick) provides both audio and video. When such media device
exposes a standard USB Audio class, a proprietary Video class, two or more
independent drivers will share a single physical USB bridge. In such cases,
it is necessary to coordinate access to the shared resource.

Using this API, drivers can allocate a media device with the shared struct
device as the key. Once the media device is allocated by a driver, other
drivers can get a reference to it. The media device is released when all
the references are released.

This test does a series of unbind/bind tests to make sure media device
is released correctly when it is no longer is use and when the last
driver releases the reference.

Signed-off-by: Shuah Khan <shuah@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: au0828: fix enable and disable source audio and video inconsistencies
Shuah Khan [Tue, 2 Apr 2019 00:40:23 +0000 (20:40 -0400)]
media: au0828: fix enable and disable source audio and video inconsistencies

Enable and disable source interfaces aren't consistent in enforcing
how video and audio share the tuner resource.

Fix these issues to enforce the following rules and allow
sharing between audio and video applications.

- When DVB is streaming, audio/video/vbi/s-video/composite
  should find the resource busy. DVB holds the tuner in
  exclusive mode.
- When video/VBI is streaming, audio can share the tuner and vice versa.
- v4l2 allows multiple applications to open video device.
- Video applications call enable source multiple times during their
  run-time. Resource should stay locked until the last application
  releases it.
- A shared resource should stay in shared state and locked when it is
  in use by audio and video. More than one video application is allowed
  to use the tuner as long as video streaming protocol allows such usage.
  Resource is released when the last video/audio application releases it.
- S-Video and Composite hold the resource in exclusive mode.

Signed-off-by: Shuah Khan <shuah@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: sound/usb: Use Media Controller API to share media resources
Shuah Khan [Tue, 2 Apr 2019 00:40:22 +0000 (20:40 -0400)]
media: sound/usb: Use Media Controller API to share media resources

Media Device Allocator API to allows multiple drivers share a media device.
This API solves a very common use-case for media devices where one physical
device (an USB stick) provides both audio and video. When such media device
exposes a standard USB Audio class, a proprietary Video class, two or more
independent drivers will share a single physical USB bridge. In such cases,
it is necessary to coordinate access to the shared resource.

Using this API, drivers can allocate a media device with the shared struct
device as the key. Once the media device is allocated by a driver, other
drivers can get a reference to it. The media device is released when all
the references are released.

Change the ALSA driver to use the Media Controller API to share media
resources with DVB, and V4L2 drivers on a AU0828 media device.

The Media Controller specific initialization is done after sound card is
registered. ALSA creates Media interface and entity function graph nodes
for Control, Mixer, PCM Playback, and PCM Capture devices.

snd_usb_hw_params() will call Media Controller enable source handler
interface to request the media resource. If resource request is granted,
it will release it from snd_usb_hw_free(). If resource is busy, -EBUSY is
returned.

Media specific cleanup is done in usb_audio_disconnect().

Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Shuah Khan <shuah@kernel.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: Enable ALSA MEDIA_INTF_T* interface types
Shuah Khan [Tue, 2 Apr 2019 00:40:21 +0000 (20:40 -0400)]
media: media.h: Enable ALSA MEDIA_INTF_T* interface types

Move PCM_CAPTURE, PCM_PLAYBACK, and CONTROL ALSA MEDIA_INTF_T* interface
types back into __KERNEL__ scope to get ready for adding ALSA support for
these to the media controller.

Signed-off-by: Shuah Khan <shuah@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: change au0828 to use Media Device Allocator API
Shuah Khan [Tue, 2 Apr 2019 00:40:20 +0000 (20:40 -0400)]
media: change au0828 to use Media Device Allocator API

Media Device Allocator API to allows multiple drivers share a media device.
This API solves a very common use-case for media devices where one physical
device (an USB stick) provides both audio and video. When such media device
exposes a standard USB Audio class, a proprietary Video class, two or more
independent drivers will share a single physical USB bridge. In such cases,
it is necessary to coordinate access to the shared resource.

Using this API, drivers can allocate a media device with the shared struct
device as the key. Once the media device is allocated by a driver, other
drivers can get a reference to it. The media device is released when all
the references are released.

Change au0828 to use Media Device Allocator API to allocate media device
with the parent usb struct device as the key, so it can be shared with the
snd_usb_audio driver.

Signed-off-by: Shuah Khan <shuah@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: Media Device Allocator API
Shuah Khan [Tue, 2 Apr 2019 00:40:19 +0000 (20:40 -0400)]
media: Media Device Allocator API

Media Device Allocator API to allows multiple drivers share a media device.
This API solves a very common use-case for media devices where one physical
device (an USB stick) provides both audio and video. When such media device
exposes a standard USB Audio class, a proprietary Video class, two or more
independent drivers will share a single physical USB bridge. In such cases,
it is necessary to coordinate access to the shared resource.

Using this API, drivers can allocate a media device with the shared struct
device as the key. Once the media device is allocated by a driver, other
drivers can get a reference to it. The media device is released when all
the references are released.

Signed-off-by: Shuah Khan <shuah@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: stm32-dcmi: fix crash when subdev do not expose any formats
Hugues Fruchet [Mon, 1 Apr 2019 08:56:09 +0000 (04:56 -0400)]
media: stm32-dcmi: fix crash when subdev do not expose any formats

Do not access sd_formats[] if num_of_sd_formats is zero, ie
subdev sensor didn't expose any formats.

Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: stm32-dcmi: do not emit error trace in case of few overrun
Hugues Fruchet [Mon, 1 Apr 2019 08:55:00 +0000 (04:55 -0400)]
media: stm32-dcmi: do not emit error trace in case of few overrun

Report overrun error only when it exceeds a given threshold.

Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: stm32-dcmi: fix error messages
Hugues Fruchet [Mon, 1 Apr 2019 08:54:59 +0000 (04:54 -0400)]
media: stm32-dcmi: fix error messages

Revisit and add some error messages.

Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: dvb: clean up redundant break statements
Colin Ian King [Sat, 30 Mar 2019 15:25:03 +0000 (11:25 -0400)]
media: dvb: clean up redundant break statements

There are several places where a break statement occurs before
a following break statement; these are unnecessary and can be
removed to clean up the code a little.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Mukesh Ojha <mojha@codeaurora.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: enlarge struct vdec_pic_info fields
Yunfei Dong [Fri, 29 Mar 2019 08:37:14 +0000 (04:37 -0400)]
media: mtk-vcodec: enlarge struct vdec_pic_info fields

Enlarge the plane number to support more complex case
and add the support for fmt change case.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.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: media: Renesas R-Car IMR bindings
Sergei Shtylyov [Tue, 26 Mar 2019 16:12:19 +0000 (12:12 -0400)]
media: dt-bindings: media: Renesas R-Car IMR bindings

The image renderer (IMR), or the distortion correction engine, is a
drawing processor with a simple instruction system capable of referencing
video capture data or data in an external memory as the 2D texture data
and performing texture mapping and drawing with respect to any shape that
is split into triangular objects.

Document  the device tree bindings for the image renderer light extended 4
(IMR-LX4) found in the R-Car gen3 SoCs...

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Acked-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: staging: media: imx: imx7-mipi-csis: simplify getting .driver_data
Wolfram Sang [Tue, 19 Mar 2019 16:36:22 +0000 (12:36 -0400)]
media: staging: media: imx: imx7-mipi-csis: simplify getting .driver_data

We should get 'driver_data' 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>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: vimc: propagate pixel format in the stream
Helen Fornazier [Wed, 13 Mar 2019 18:29:37 +0000 (14:29 -0400)]
media: vimc: propagate pixel format in the stream

Media bus codes were being mapped to pixelformats, which causes a
limitation on vimc because not all pixelformats can be mapped to media
bus codes.
Also, media bus codes are an internal configuration from the device.
Userspace only assures media bus codes matches between pads and expects
the image in a given pixelformat. So we can allow almost any media bus
format to be configured between pads, except for debayer that expects a
media bus code of type bayer in the sink pad.

[hverkuil-cisco@xs4all.nl: drop use of v4l2_get_fourcc_name: not yet available]
[hverkuil-cisco@xs4all.nl: made vimc_mbus_list static]

Signed-off-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: v4l2-common: add bayer formats in v4l2_format_info
Helen Fornazier [Wed, 6 Mar 2019 22:42:40 +0000 (17:42 -0500)]
media: v4l2-common: add bayer formats in v4l2_format_info

Add bayer format information in struct v4l2_format_info table.

Signed-off-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: Introduce helpers to fill pixel format structs
Ezequiel Garcia [Thu, 28 Mar 2019 18:07:04 +0000 (14:07 -0400)]
media: Introduce helpers to fill pixel format structs

Add two new API helpers, v4l2_fill_pixfmt and v4l2_fill_pixfmt_mp,
to be used by drivers to calculate plane sizes and bytes per lines.

Note that driver-specific padding and alignment are not
taken into account, and must be done by drivers using this API.

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: rockchip/vpu: Rename pixel format helpers
Ezequiel Garcia [Thu, 28 Mar 2019 18:07:03 +0000 (14:07 -0400)]
media: rockchip/vpu: Rename pixel format helpers

The rockchip VPU driver uses generic names for its pixel format
helpers. We want to use the same names for generic versions
of these helpers, so rename the rockchip ones.

The driver will be switched to the generic helpers later.

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: vb2: Minor function naming fix
Ezequiel Garcia [Thu, 28 Mar 2019 16:16:30 +0000 (12:16 -0400)]
media: vb2: Minor function naming fix

Minor fix for helper function and comment, s/v4l2_vb2_buffer/vb2_v4l2_buffer.

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: v4l2-ctrls.h: remove spurious text
Hans Verkuil [Mon, 1 Apr 2019 07:42:05 +0000 (03:42 -0400)]
media: v4l2-ctrls.h: remove spurious text

Somehow the string "Controls name" got pasted in two places
where it doesn't belong. Remove that text.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: platform: stm32: wait end of transmission
Yannick Fertre [Fri, 29 Mar 2019 12:39:42 +0000 (08:39 -0400)]
media: platform: stm32: wait end of transmission

It is mandatory to write CEC_CFGR only when CECEN=0. To protect
transmission, a check have been added to delayed logical address
modification. This patch is necessary tp pass all tests of compliance.

Signed-off-by: Yannick Fertré <yannick.fertre@st.com>
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
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: removed ARGB32 added ABGR32 and XBGR32
Eugen Hristev [Fri, 29 Mar 2019 07:38:31 +0000 (03:38 -0400)]
media: atmel: atmel-isc: removed ARGB32 added ABGR32 and XBGR32

ISC will output the "ARGB32" configuration in byte order: B, G, R, Alpha.
This is in fact the format BGRA, aka ABGR32.
If alpha is missing, the same format is equivalent to XBGR32.
Added both formats and removed ARGB32 which is wrong.

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: reworked driver and formats
Eugen Hristev [Fri, 29 Mar 2019 07:38:28 +0000 (03:38 -0400)]
media: atmel: atmel-isc: reworked driver and formats

This change is a redesign in the formats and the way the ISC is
configured w.r.t. sensor format and the output format from the ISC.
I have changed the splitting between sensor output (which is also ISC input)
and ISC output.
The sensor format represents the way the sensor is configured, and what ISC
is receiving.
The format configuration represents the way ISC is interpreting the data and
formatting the output to the subsystem.
Now it's much easier to figure out what is the ISC configuration for input, and
what is the configuration for output.
The non-raw format can be obtained directly from sensor or it can be done
inside the ISC. The controller format list will include a configuration for
each format.
The old supported formats are still in place, if we want to dump the sensor
format directly to the output, the try format routine will detect and
configure the pipeline accordingly.
This also fixes the previous issues when the raw format was NULL which
resulted in many crashes for sensors which did not have the expected/tested
formats.

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: v4l: add I / P frame min max QP definitions
Fish Lin [Fri, 29 Mar 2019 03:20:46 +0000 (23:20 -0400)]
media: v4l: add I / P frame min max QP definitions

Add following V4L2 QP parameters for H.264:
* V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MIN_QP
* V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MAX_QP
* V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MIN_QP
* V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MAX_QP

These controls will limit QP range for intra and inter frame,
provide more manual control to improve video encode quality.

Signed-off-by: Fish Lin <linfish@google.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: index.rst: exclude Indexes section from latex/pdf output
Mauro Carvalho Chehab [Sat, 30 Mar 2019 13:33:54 +0000 (09:33 -0400)]
media: index.rst: exclude Indexes section from latex/pdf output

With LaTex, the Index at the end will always be present. Having
an extra chapter for it there will just add extra noise to the
document.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: pdf docs: adjust several tables for better display
Mauro Carvalho Chehab [Fri, 29 Mar 2019 16:13:50 +0000 (12:13 -0400)]
media: pdf docs: adjust several tables for better display

Avoid cell overlapping by changing some sizes, and changing the
font sizes when needed.

Tested with Sphinx 1.7.8.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: pixfmt-packed-yuv.rst: fix PDF output
Mauro Carvalho Chehab [Fri, 29 Mar 2019 15:58:14 +0000 (11:58 -0400)]
media: pixfmt-packed-yuv.rst: fix PDF output

Some lines inside this table has more than 34 columns, which isn't
what is expected, according to the .. tabularcolumns:: definition.

That causes the PDF output to fail.

This patch ensures that all columns will have exactly the same
size, merging the unused ones using :cpan:

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging: use strscpy() instead of strlcpy()
Mauro Carvalho Chehab [Fri, 29 Mar 2019 15:28:45 +0000 (11:28 -0400)]
media: staging: use strscpy() instead of strlcpy()

There are a few left overs at staging which were still using the
deprecated strlcpy() function.

Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: soc_camera: Remove leftover files, add TODO
Sakari Ailus [Tue, 26 Mar 2019 09:24:11 +0000 (05:24 -0400)]
media: soc_camera: Remove leftover files, add TODO

Remove a few files left over from the mt9t031 driver. While at it, add a
TODO file for the SoC camera framework as a whole.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: MAINTAINERS: Fix files for obsolete SoC camera framework
Sakari Ailus [Tue, 26 Mar 2019 09:19:28 +0000 (05:19 -0400)]
media: MAINTAINERS: Fix files for obsolete SoC camera framework

The SoC camera was moved to the staging tree but we missed updating
MAINTAINERS. Do that now.

Fixes: 280de94a6519 ("media: soc_camera: Move to the staging tree")
Reported-by: Joe Perches <joe@perches.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: ov7740: enable to get exposure control in autoexposure mode
Akinobu Mita [Mon, 18 Mar 2019 15:25:43 +0000 (11:25 -0400)]
media: ov7740: enable to get exposure control in autoexposure mode

The exposure control is clustered with the autoexposure control and
flagged as volatile, but the g_volatile_ctrl() doesn't handle
V4L2_CID_EXPOSURE_AUTO.  So, the value of the exposure control can't be
read in autoexposure mode.

This enables to get the exposure control in autoexposure mode by making
ov7740_get_volatile_ctrl() deal with V4L2_CID_EXPOSURE_AUTO.

This also sets the exposure control as volatile by specifying the
argument to v4l2_ctrl_auto_cluster() instead of manually flagging it.

Cc: Wenyou Yang <wenyou.yang@microchip.com>
Cc: Eugen Hristev <eugen.hristev@microchip.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: bt8xx: avoid a needless u8 to char conversion
Mauro Carvalho Chehab [Fri, 29 Mar 2019 14:29:40 +0000 (10:29 -0400)]
media: bt8xx: avoid a needless u8 to char conversion

Instead of doing the cast, just change the type to char.

Suggested-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: replace strncpy() by strscpy()
Mauro Carvalho Chehab [Mon, 10 Sep 2018 12:19:16 +0000 (08:19 -0400)]
media: replace strncpy() by strscpy()

The strncpy() function is being deprecated upstream. Replace
it by the safer strscpy().

While here, replace a few occurences of strlcpy() that were
recently added to also use strscpy().

Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: vim2m: Fix RGB 565 BE/LE support
Mauro Carvalho Chehab [Thu, 28 Mar 2019 19:02:23 +0000 (15:02 -0400)]
media: vim2m: Fix RGB 565 BE/LE support

The support for those two formats are archtecture-dependent.
Use the endianness to CPU macros to do it right.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: wl128x: Fix some error handling in fmc_prepare()
Dan Carpenter [Thu, 28 Mar 2019 14:41:38 +0000 (10:41 -0400)]
media: wl128x: Fix some error handling in fmc_prepare()

The st_register() returns have changed over time, but these days it
never returns -1.  We should just be checking for any negative error
codes.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: wl128x: prevent two potential buffer overflows
Dan Carpenter [Tue, 26 Mar 2019 05:12:07 +0000 (01:12 -0400)]
media: wl128x: prevent two potential buffer overflows

Smatch marks skb->data as untrusted so it warns that "evt_hdr->dlen"
can copy up to 255 bytes and we only have room for two bytes.  Even
if this comes from the firmware and we trust it, the new policy
generally is just to fix it as kernel hardenning.

I can't test this code so I tried to be very conservative.  I considered
not allowing "evt_hdr->dlen == 1" because it doesn't initialize the
whole variable but in the end I decided to allow it and manually
initialized "asic_id" and "asic_ver" to zero.

Fixes: e8454ff7b9a4 ("[media] drivers:media:radio: wl128x: FM Driver Common sources")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: tw5864: Fix possible NULL pointer dereference in tw5864_handle_frame
YueHaibing [Fri, 15 Mar 2019 02:01:24 +0000 (22:01 -0400)]
media: tw5864: Fix possible NULL pointer dereference in tw5864_handle_frame

'vb' null check should be done before dereferencing it in
tw5864_handle_frame, otherwise a NULL pointer dereference
may occur.

Fixes: 34d1324edd31 ("[media] pci: Add tw5864 driver")
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>
5 years agomedia: usbvision: fix a potential NULL pointer dereference
Kangjie Lu [Sat, 9 Mar 2019 07:42:26 +0000 (02:42 -0500)]
media: usbvision: fix a potential NULL pointer dereference

In case usb_alloc_coherent fails, the fix returns -ENOMEM to
avoid a potential NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: video-mux: fix null pointer dereferences
Kangjie Lu [Sat, 9 Mar 2019 07:20:56 +0000 (02:20 -0500)]
media: video-mux: fix null pointer dereferences

devm_kcalloc may fail and return a null pointer. The fix returns
-ENOMEM upon failures to avoid null pointer dereferences.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Reviewed-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>
5 years agomedia: mtk-vcodec: remove ready_to_display
Alexandre Courbot [Tue, 26 Mar 2019 07:44:46 +0000 (03:44 -0400)]
media: mtk-vcodec: remove ready_to_display

This member is never read throughout the code, so remove it.

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>
5 years agomedia: mtk-vcodec: fix access to incorrect planes member
Alexandre Courbot [Tue, 26 Mar 2019 07:44:23 +0000 (03:44 -0400)]
media: mtk-vcodec: fix access to incorrect planes member

Commit 0650a91499e0 ("media: mtk-vcodec: Correct return type for mem2mem
buffer helpers") fixed the return types for mem2mem buffer helper
functions by changing a few local variables from vb2_buffer to
vb2_v4l2_buffer. However, it left a few accesses to vb2_buffer::planes
as-is, accidentally turning them into accesses to
vb2_v4l2_buffer::planes and resulting in values being read from/written
to the wrong place.

Fix this by inserting vb2_buf into these accesses so they mimic their
original behavior.

Fixes: 0650a91499e0 ("media: mtk-vcodec: Correct return type for mem2mem buffer helpers")
Signed-off-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-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>
5 years agomedia: v4l2-ctrl: potential shift wrapping bugs
Dan Carpenter [Mon, 25 Mar 2019 09:06:26 +0000 (05:06 -0400)]
media: v4l2-ctrl: potential shift wrapping bugs

This code generates a static checker warning:

    drivers/media/v4l2-core/v4l2-ctrls.c:2921 v4l2_querymenu()
    warn: should '(1 << i)' be a 64 bit type?

The problem is that "ctrl->menu_skip_mask" is a u64 and we're only
testing the lower 32 bits.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: davinci-isif: avoid uninitialized variable use
Arnd Bergmann [Fri, 22 Mar 2019 14:34:22 +0000 (10:34 -0400)]
media: davinci-isif: avoid uninitialized variable use

clang warns about a possible variable use that gcc never
complained about:

drivers/media/platform/davinci/isif.c:982:32: error: variable 'frame_size' is uninitialized when used here
      [-Werror,-Wuninitialized]
                dm365_vpss_set_pg_frame_size(frame_size);
                                             ^~~~~~~~~~
drivers/media/platform/davinci/isif.c:887:2: note: variable 'frame_size' is declared here
        struct vpss_pg_frame_size frame_size;
        ^
1 error generated.

There is no initialization for this variable at all, and there
has never been one in the mainline kernel, so we really should
not put that stack data into an mmio register.

On the other hand, I suspect that gcc checks the condition
more closely and notices that the global
isif_cfg.bayer.config_params.test_pat_gen flag is initialized
to zero and never written to from any code path, so anything
depending on it can be eliminated.

To shut up the clang warning, just remove the dead code manually,
it has probably never been used because any attempt to do so
would have resulted in undefined behavior.

Fixes: 63e3ab142fa3 ("V4L/DVB: V4L - vpfe capture - source for ISIF driver on DM365")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: i2c: tda1997x: select V4L2_FWNODE
Koen Vandeputte [Mon, 18 Mar 2019 16:40:05 +0000 (12:40 -0400)]
media: i2c: tda1997x: select V4L2_FWNODE

Building tda1997x fails now unless V4L2_FWNODE is selected:

drivers/media/i2c/tda1997x.o: in function `tda1997x_parse_dt'
undefined reference to `v4l2_fwnode_endpoint_parse'

While at it, also sort the selections alphabetically

Fixes: 9ac0038db9a7 ("media: i2c: Add TDA1997x HDMI receiver driver")
Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
Cc: stable@vger.kernel.org # v4.17+
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging: media: imx7-mipi-csis: fix debugfs compilation
Arnd Bergmann [Wed, 13 Mar 2019 21:17:32 +0000 (17:17 -0400)]
media: staging: media: imx7-mipi-csis: fix debugfs compilation

When CONFIG_DEBUGFS is enabled, we get a warning about an
incorrect section annotation that can lead to undefined
behavior:

WARNING: vmlinux.o(.text+0xd3c7c4): Section mismatch in reference from the function mipi_csis_probe() to the function .init.text:mipi_csis_debugfs_init()
The function mipi_csis_probe() references
the function __init mipi_csis_debugfs_init().
This is often because mipi_csis_probe lacks a __init
annotation or the annotation of mipi_csis_debugfs_init is wrong.

The same function for an unknown reason has a different
version for !CONFIG_DEBUGFS, which does not have this problem,
but behaves the same way otherwise (it does nothing when debugfs
is disabled).
Consolidate the two versions, using the correct section from
one version, and the implementation from the other.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging: media: davinci_vpfe: fix large stack usage with clang
Arnd Bergmann [Wed, 13 Mar 2019 21:10:29 +0000 (17:10 -0400)]
media: staging: media: davinci_vpfe: fix large stack usage with clang

clang is unable to optimize the isif_ioctl() in the same way that
gcc does, as it fails to prove that the local copy of
the 'struct vpfe_isif_raw_config' argument is unnecessary:

drivers/staging/media/davinci_vpfe/dm365_isif.c:622:13: error: stack frame size of 1344 bytes in function 'isif_ioctl' [-Werror,-Wframe-larger-than=]

Marking it as 'const' while passing the data down clearly shows us that
the copy is never modified, and we can skip copying it entirely, which
reduces the stack usage to just eight bytes.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging/imx: Fix inconsistent long line breaks
Lucas Leonardo Ciancaglini [Mon, 11 Mar 2019 05:34:38 +0000 (01:34 -0400)]
media: staging/imx: Fix inconsistent long line breaks

Small readability changes to make the breaking of some lines
cleaner.

Signed-off-by: Lucas Leonardo Ciancaglini <leociancalucas@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: gspca: Kill URBs on USB device disconnect
Ezequiel Garcia [Thu, 28 Feb 2019 15:28:34 +0000 (10:28 -0500)]
media: gspca: Kill URBs on USB device disconnect

In order to prevent ISOC URBs from being infinitely resubmitted,
the driver's USB disconnect handler must kill all the in-flight URBs.

While here, change the URB packet status message to a debug level,
to avoid spamming the console too much.

This commit fixes a lockup caused by an interrupt storm coming
from the URB completion handler.

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>
5 years agomedia: dvbdev: remove double-unlock
Mauro Carvalho Chehab [Thu, 28 Mar 2019 18:36:14 +0000 (14:36 -0400)]
media: dvbdev: remove double-unlock

As warned by smatch:
drivers/media/dvb-core/dvbdev.c: drivers/media/dvb-core/dvbdev.c:529 dvb_register_device() error: double unlock 'sem:&minor_rwsem'

Reported-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: hfi_parser: don't trick gcc with a wrong expected size
Mauro Carvalho Chehab [Mon, 25 Mar 2019 21:09:05 +0000 (17:09 -0400)]
media: hfi_parser: don't trick gcc with a wrong expected size

Smatch warns about small size on two structs:

drivers/media/platform/qcom/venus/hfi_parser.c:103 parse_profile_level() error: memcpy() 'proflevel' too small (8 vs 128)
drivers/media/platform/qcom/venus/hfi_parser.c: drivers/media/platform/qcom/venus/hfi_parser.c:129 parse_caps() error: memcpy() 'cap' too small (16 vs 512)

The reason is that the hfi_parser actually expects:
    - multiple data entries on hfi_capabilities
    - multiple profile_level on hfi_profile_level_supported

However, the structs trick gcc, making it to believe that
there's just one value for each.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rcar-dma: p_set can't be NULL
Mauro Carvalho Chehab [Mon, 25 Mar 2019 20:47:13 +0000 (16:47 -0400)]
media: rcar-dma: p_set can't be NULL

The only way for p_set to be NULL would be if vin_coef_set would be an
empty array.

On such case, the driver will OOPS, as it would try to de-reference a
NULL value. So, the check if p_set is not NULL doesn't make any sense.

Solves those two smatch warnings:

drivers/media/platform/rcar-vin/rcar-dma.c:489 rvin_set_coeff() warn: variable dereferenced before check 'p_set' (see line 484)
drivers/media/platform/rcar-vin/rcar-dma.c:494 rvin_set_coeff() error: we previously assumed 'p_set' could be null (see line 489)

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: sti/delta: remove uneeded check
Mauro Carvalho Chehab [Mon, 25 Mar 2019 20:32:19 +0000 (16:32 -0400)]
media: sti/delta: remove uneeded check

At the error logic, ipc_buf was already asigned to &ctx->ipc_buf_struct,
with can't be null, as warned by smatch:

drivers/media/platform/sti/delta/delta-ipc.c:223 delta_ipc_open() warn: variable dereferenced before check 'ctx->ipc_buf' (see line 183)

So, remove the uneeded check.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: pwc-ctl: pChoose can't be NULL
Mauro Carvalho Chehab [Mon, 25 Mar 2019 20:20:47 +0000 (16:20 -0400)]
media: pwc-ctl: pChoose can't be NULL

The way the code works, compression will be a valid value (less or equal to 3)
on both set_video_mode_foo() calls at the beginning of the while() loop.

So, the value for pChoose can't be NULL.

Solves those smatch warnings:

drivers/media/usb/pwc/pwc-ctrl.c: drivers/media/usb/pwc/pwc-ctrl.c:252 set_video_mode_Timon() warn: variable dereferenced before check 'pChoose' (see line 248)
drivers/media/usb/pwc/pwc-ctrl.c: drivers/media/usb/pwc/pwc-ctrl.c:302 set_video_mode_Kiara() warn: variable dereferenced before check 'pChoose' (see line 298)

and simplifies the code a little bit.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: cx2341x: replace badly designed macros
Mauro Carvalho Chehab [Mon, 25 Mar 2019 19:09:30 +0000 (15:09 -0400)]
media: cx2341x: replace badly designed macros

There are some macros at cx2341x_update() with seemed to
be introduced in order to ensure that lines would be less
than 80 columns.

Well, the thing is that they make the code harder to be analized,
not only by humans, but also for static code analyzers:

drivers/media/common/cx2341x.c:1116 cx2341x_update() error: we previously assumed 'old' could be null (see line 1047)

So, remove the "force" var, and replace the NEQ macro to a
better designed one that makes clearer about what it is doing.

While here, also remove the "temporal" var, as it is just another
way of doing the same type of check as the new CMP_FIELD() macro
already does.

Finally, fix coding style at the block code.
 remove such macros.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: imx214: don't de-reference a NULL pointer
Mauro Carvalho Chehab [Fri, 7 Dec 2018 11:43:03 +0000 (06:43 -0500)]
media: imx214: don't de-reference a NULL pointer

As warned by smatch:
drivers/media/i2c/imx214.c:591 imx214_set_format() warn: variable dereferenced before check 'format' (see line 589)

It turns that the code at imx214_set_format() has support for being
called with the format being NULL. I've no idea why, as it is only
called internally with the pointer set, and via subdev API (with
should also set it).

Also, the entire logic there depends on having format != NULL, so
just remove the bogus broken support for a null format.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Ricardo Ribalda Delgado <ricardo@ribalda.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: v4l: rcar_fdp1: Fix indentation oddities
Laurent Pinchart [Sun, 22 Apr 2018 08:00:08 +0000 (04:00 -0400)]
media: v4l: rcar_fdp1: Fix indentation oddities

Indentation is odd in several places, especially when printing messages
to the kernel log. Fix it to match the usual coding style.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: vicodec: set pixelformat to V4L2_PIX_FMT_FWHT_STATELESS for stateless decoder
Dafna Hirschfeld [Wed, 6 Mar 2019 21:13:43 +0000 (16:13 -0500)]
media: vicodec: set pixelformat to V4L2_PIX_FMT_FWHT_STATELESS for stateless decoder

for stateless decoder, set the output pixelformat
to V4L2_PIX_FMT_FWHT_STATELESS and the pix info to
pixfmt_stateless_fwht

Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: vicodec: Add support for stateless decoder.
Dafna Hirschfeld [Wed, 6 Mar 2019 21:13:42 +0000 (16:13 -0500)]
media: vicodec: Add support for stateless decoder.

Implement a stateless decoder for the new node.

Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil-cisco@xs4all.nl: add 'return 0;' before default case in vicodec_try_ctrl()]
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: vicodec: Register another node for stateless decoder
Dafna Hirschfeld [Wed, 6 Mar 2019 21:13:41 +0000 (16:13 -0500)]
media: vicodec: Register another node for stateless decoder

Add stateless decoder instance field to the dev struct and
register another node for the statelsess decoder.
The stateless API for the node will be implemented in further patches.

Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil-cisco@xs4all.nl: fix typo: videdev-stateless-dec -> stateless-decoder]
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: v4l2-ioctl.c: add V4L2_PIX_FMT_FWHT_STATELESS to v4l_fill_fmtdesc
Hans Verkuil [Wed, 13 Mar 2019 14:44:20 +0000 (10:44 -0400)]
media: v4l2-ioctl.c: add V4L2_PIX_FMT_FWHT_STATELESS to v4l_fill_fmtdesc

Add V4L2_PIX_FMT_FWHT_STATELESS to the list of pixelformats that
v4l_fill_fmtdesc() understands.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: vicodec: Introducing stateless fwht defs and structs
Dafna Hirschfeld [Wed, 6 Mar 2019 21:13:40 +0000 (16:13 -0500)]
media: vicodec: Introducing stateless fwht defs and structs

Add structs and definitions needed to implement stateless
decoder for fwht and add I/P-frames QP controls to the
public api.

Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: vicodec: add documentation to V4L2_PIX_FMT_FWHT_STATELESS
Dafna Hirschfeld [Wed, 6 Mar 2019 21:13:39 +0000 (16:13 -0500)]
media: vicodec: add documentation to V4L2_PIX_FMT_FWHT_STATELESS

add documentation to V4L2_PIX_FMT_FWHT_STATELESS
in pixfmt-compressed.rst

Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: vicodec: add documentation to V4L2_CID_MPEG_VIDEO_FWHT_PARAMS
Dafna Hirschfeld [Wed, 6 Mar 2019 21:13:38 +0000 (16:13 -0500)]
media: vicodec: add documentation to V4L2_CID_MPEG_VIDEO_FWHT_PARAMS

add documentation to V4L2_CID_MPEG_VIDEO_FWHT_PARAMS
control and its related 'v4l2_ctrl_fwht_params' struct

[mchehab+samsung@kernel.org: remove extra blank lines]
Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: vicodec: add documentation to V4L2_CID_FWHT_I/P_FRAME_QP
Dafna Hirschfeld [Wed, 6 Mar 2019 21:13:37 +0000 (16:13 -0500)]
media: vicodec: add documentation to V4L2_CID_FWHT_I/P_FRAME_QP

add documentation to V4L2_CID_FWHT_I/P_FRAME_QP
controls in ext-ctrls-codec.rst

[mchehab+samsung@kernel.org: remove extra blank lines]
Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: vicodec: add struct for encoder/decoder instance
Dafna Hirschfeld [Wed, 6 Mar 2019 21:13:36 +0000 (16:13 -0500)]
media: vicodec: add struct for encoder/decoder instance

Add struct 'vicodec_dev_instance' for the fields in vicodec_dev
that have have both decoder and encoder versions.

Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: vicodec: Handle the case that the reference buffer is NULL
Dafna Hirschfeld [Wed, 6 Mar 2019 21:13:35 +0000 (16:13 -0500)]
media: vicodec: Handle the case that the reference buffer is NULL

In the stateless decoder the reference buffer is null if the
frame is an I-frame (flagged with FWHT_FL_I_FRAME).
Make sure not to dereference it in that case.

Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>