platform/kernel/linux-starfive.git
4 years agomedia: i2c: Add MAX9286 driver
Kieran Bingham [Fri, 12 Jun 2020 14:47:11 +0000 (16:47 +0200)]
media: i2c: Add MAX9286 driver

The MAX9286 is a 4-channel GMSL deserializer with coax or STP input and
CSI-2 output. The device supports multicamera streaming applications,
and features the ability to synchronise the attached cameras.

CSI-2 output can be configured with 1 to 4 lanes, and a control channel
is supported over I2C, which implements an I2C mux to facilitate
communications with connected cameras across the reverse control
channel.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: dt-bindings: media: i2c: Add bindings for Maxim Integrated MAX9286
Laurent Pinchart [Fri, 3 Jul 2020 13:33:32 +0000 (15:33 +0200)]
media: dt-bindings: media: i2c: Add bindings for Maxim Integrated MAX9286

The MAX9286 deserializes video data received on up to 4 Gigabit
Multimedia Serial Links (GMSL) and outputs them on a CSI-2 port using up
to 4 data lanes.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: i2c: dw9768: Add DW9768 VCM driver
Dongchun Zhu [Tue, 30 Jun 2020 06:22:11 +0000 (08:22 +0200)]
media: i2c: dw9768: Add DW9768 VCM driver

Add a V4L2 sub-device driver for DW9768 voice coil motor,
providing control to set the desired focus via IIC serial interface.

Signed-off-by: Dongchun Zhu <dongchun.zhu@mediatek.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: dt-bindings: media: i2c: Document DW9768 bindings
Dongchun Zhu [Tue, 30 Jun 2020 06:22:10 +0000 (08:22 +0200)]
media: dt-bindings: media: i2c: Document DW9768 bindings

Add DeviceTree Binding Documentation for Dongwoon Anatech DW9768
voice coil actuator.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Dongchun Zhu <dongchun.zhu@mediatek.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: i2c: imx290: replace msleep(10) with usleep_range(10000, 11000)
Andrey Konovalov [Tue, 23 Jun 2020 16:52:26 +0000 (18:52 +0200)]
media: i2c: imx290: replace msleep(10) with usleep_range(10000, 11000)

This fixes checkpatch warnings of "msleep < 20ms can sleep for up to 20ms".

Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: rkisp1: set pads array of the resizer to size 2
Dafna Hirschfeld [Mon, 29 Jun 2020 06:57:53 +0000 (08:57 +0200)]
media: staging: rkisp1: set pads array of the resizer to size 2

Currently the 'pads' and 'pad_cfg' arrays of the rkisp1_resizer
are of size 'RKISP1_ISP_PAD_MAX' which is 4. But the resizer
has only two pads. Change the size of the arrays to 2 by adding
and using 'RKISP1_RSZ_PAD_MAX' similar to the way it is done in
the isp entity.

[hverkuil: fix typos in commit log]

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: rkisp1: remove unused field alloc_ctx from struct rkisp1_device
Dafna Hirschfeld [Mon, 29 Jun 2020 06:57:52 +0000 (08:57 +0200)]
media: staging: rkisp1: remove unused field alloc_ctx from struct rkisp1_device

The field alloc_ctx in struct rkisp1_device is not used.
This patch removes it.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: rkisp1: remove unused field ctrl_handler from struct rkisp1_device
Dafna Hirschfeld [Mon, 29 Jun 2020 06:57:51 +0000 (08:57 +0200)]
media: staging: rkisp1: remove unused field ctrl_handler from struct rkisp1_device

The field ctrl_handler in struct rkisp1_device is not used.
This patch removes it.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: rkisp1: cap: in stream start, replace calls to rkisp1_handle_buffer...
Dafna Hirschfeld [Tue, 14 Jul 2020 12:38:32 +0000 (14:38 +0200)]
media: staging: rkisp1: cap: in stream start, replace calls to rkisp1_handle_buffer with rkisp1_set_next_buf

The function 'rkisp1_stream_start' calls 'rkisp1_handle_buffer'
in order to update the 'buf.curr' and 'buf.next' fields and
configure the device before streaming starts. This cause a wrong
increment of the debugs field 'frame_drop'. This patch replaces
the call to 'rkisp1_handle_buffer' with a call to
'rkisp1_set_next_buf'.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: rkisp1: cap: move code that manages the buffers to rkisp1_set_next_buf
Dafna Hirschfeld [Tue, 14 Jul 2020 12:38:31 +0000 (14:38 +0200)]
media: staging: rkisp1: cap: move code that manages the buffers to rkisp1_set_next_buf

The function 'rkisp1_set_next_buf' configures the registers
according to 'cap->buf.next'. It is called after updating
'cap->buf.next' and 'cap->buf.curr'. This patch moves the
code that updates those fields to rkisp1_set_next_buf.
This is a preparation for later patch that change a call to
'rkisp1_handle_buffer' with a call to 'rkisp1_set_next_buf'.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: rkisp1: cap: protect buf.curr and buf.next with buf.lock
Dafna Hirschfeld [Tue, 14 Jul 2020 12:38:30 +0000 (14:38 +0200)]
media: staging: rkisp1: cap: protect buf.curr and buf.next with buf.lock

The spinlock buf.lock should protect access to the buffers.
This includes the buffers in buf.queue and also buf.curr and
buf.next. The function 'rkisp1_set_next_buf' access buf.next
therefore it should also be protected with the lock.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: rkisp1: cap: don't set next buffer from rkisp1_vb2_buf_queue
Dafna Hirschfeld [Tue, 14 Jul 2020 12:38:29 +0000 (14:38 +0200)]
media: staging: rkisp1: cap: don't set next buffer from rkisp1_vb2_buf_queue

The function 'rkisp1_vb2_buf_queue' sets the next buffer directly
in case the capture is already streaming but no frame yet arrived
from the sensor. This is an optimization that tries to avoid
dropping a frame.
The call atomic_read(&cap->rkisp1->isp.frame_sequence) is used
to check if a frame arrived. Reading the 'frame_sequence' should
be avoided outside irq handlers to avoid race conditions.

This patch removes this optimization. Dropping of the first
frames can be avoided if userspace queues the buffers before
start streaming. If userspace starts queueing buffers
only after calling 'streamon' he risks frame drops anyway.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: MAINTAINERS: rectify CHRONTEL CH7322 CEC DRIVER section
Lukas Bulwahn [Tue, 14 Jul 2020 06:30:35 +0000 (08:30 +0200)]
media: MAINTAINERS: rectify CHRONTEL CH7322 CEC DRIVER section

Commit 7f52faabd2e5 ("media: dt-bindings: Add ch7322 media i2c device")
slipped in a typo in the CHRONTEL CH7322 CEC DRIVER section.

Hence, ./scripts/get_maintainer.pl --self-test=patterns complains:

    warning: no file matches    F: \
        Documentation/devicetree/bindings/media/i2c/chontel,ch7322.yaml

Fix the typo to address this warning.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: tw68: Replace http links with https ones
Alexander A. Klimov [Mon, 13 Jul 2020 16:12:38 +0000 (18:12 +0200)]
media: tw68: Replace http links with https ones

Rationale:
Reduces attack surface on kernel devs opening the links for MITM
as HTTPS traffic is much harder to manipulate.

Deterministic algorithm:
For each file:
  If not .svg:
    For each line:
      If doesn't contain `\bxmlns\b`:
  If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`:
            If both the HTTP and HTTPS versions
            return 200 OK and serve the same content:
              Replace HTTP with HTTPS.

Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: tw5864-core: Replace http links with https ones
Alexander A. Klimov [Mon, 13 Jul 2020 16:02:19 +0000 (18:02 +0200)]
media: tw5864-core: Replace http links with https ones

Rationale:
Reduces attack surface on kernel devs opening the links for MITM
as HTTPS traffic is much harder to manipulate.

Deterministic algorithm:
For each file:
  If not .svg:
    For each line:
      If doesn't contain `\bxmlns\b`:
  If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`:
            If both the HTTP and HTTPS versions
            return 200 OK and serve the same content:
              Replace HTTP with HTTPS.

Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: rtl2832_sdr: Replace HTTP links with HTTPS ones
Alexander A. Klimov [Mon, 13 Jul 2020 15:52:10 +0000 (17:52 +0200)]
media: rtl2832_sdr: Replace HTTP links with HTTPS ones

Rationale:
Reduces attack surface on kernel devs opening the links for MITM
as HTTPS traffic is much harder to manipulate.

Deterministic algorithm:
For each file:
  If not .svg:
    For each line:
      If doesn't contain `\bxmlns\b`:
  If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`:
            If both the HTTP and HTTPS versions
            return 200 OK and serve the same content:
              Replace HTTP with HTTPS.

Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ivtv: Replace http links with https ones
Alexander A. Klimov [Mon, 13 Jul 2020 15:42:01 +0000 (17:42 +0200)]
media: ivtv: Replace http links with https ones

Rationale:
Reduces attack surface on kernel devs opening the links for MITM
as HTTPS traffic is much harder to manipulate.

Deterministic algorithm:
For each file:
  If not .svg:
    For each line:
      If doesn't contain `\bxmlns\b`:
  If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`:
            If both the HTTP and HTTPS versions
            return 200 OK and serve the same content:
              Replace HTTP with HTTPS.

Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imon: Replace http links with https ones
Alexander A. Klimov [Mon, 13 Jul 2020 15:31:53 +0000 (17:31 +0200)]
media: imon: Replace http links with https ones

Rationale:
Reduces attack surface on kernel devs opening the links for MITM
as HTTPS traffic is much harder to manipulate.

Deterministic algorithm:
For each file:
  If not .svg:
    For each line:
      If doesn't contain `\bxmlns\b`:
  If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`:
            If both the HTTP and HTTPS versions
            return 200 OK and serve the same content:
              Replace HTTP with HTTPS.

Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: cx18: Replace http links with https ones
Alexander A. Klimov [Mon, 13 Jul 2020 15:21:45 +0000 (17:21 +0200)]
media: cx18: Replace http links with https ones

Rationale:
Reduces attack surface on kernel devs opening the links for MITM
as HTTPS traffic is much harder to manipulate.

Deterministic algorithm:
For each file:
  If not .svg:
    For each line:
      If doesn't contain `\bxmlns\b`:
  If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`:
            If both the HTTP and HTTPS versions
            return 200 OK and serve the same content:
              Replace HTTP with HTTPS.

Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: allegro: add support for allegro firmware 2019.2
Michael Tretter [Mon, 13 Jul 2020 14:42:29 +0000 (16:42 +0200)]
media: allegro: add support for allegro firmware 2019.2

Encode messages as necessary for the firmware 2019.2 and, thus, support
the more recent firmware version in the driver, too.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: allegro: add a version field to mcu messages
Michael Tretter [Mon, 13 Jul 2020 14:42:28 +0000 (16:42 +0200)]
media: allegro: add a version field to mcu messages

In order to distinguish the message format that is expected by the
firmware, add a version field to the message header. This allows to
encode and decode the messages for the version of the firmware that was
loaded by the driver.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: allegro: drop length field from message header
Michael Tretter [Mon, 13 Jul 2020 14:42:27 +0000 (16:42 +0200)]
media: allegro: drop length field from message header

The length of the message will be determined when the message is
encoded.  Writing the size of the struct into the message in the driver
won't be the actual length of the message that is send to the firmware.
Therefore, drop the length field from the message.

Since the header is the same for all response messages, it does not make
sense to read the header in each decoding function, but we can simply
decode it once before dispatching to the respective functions.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: allegro: set num_ref_idx using response of configured channels
Michael Tretter [Mon, 13 Jul 2020 14:42:26 +0000 (16:42 +0200)]
media: allegro: set num_ref_idx using response of configured channels

The firmware decides how many reference frames shall be used und returns
this information via the config blob. In order to set the number of
reference frames in the PPS, the driver has to read these values from
the config blob after the channel has been created in the firmware.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: allegro: add config blob for channel
Michael Tretter [Mon, 13 Jul 2020 14:42:25 +0000 (16:42 +0200)]
media: allegro: add config blob for channel

Firmware versions >= 2019.2 do not configure the channel via the mailbox
interface anymore, but use a separate chunk of memory that is only
referenced by the message. As the configuration must be in a format that
is understood by the firmware and this format can change between
firmware versions, handle it similar to the message and treat is as a
blob.

In order to support both methods in the driver, always use a separate
blob for the channel configuration and copy that blob into the mailbox
if the firmware requires it and otherwise reference it.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: allegro: encode bit fields separately
Michael Tretter [Mon, 13 Jul 2020 14:42:24 +0000 (16:42 +0200)]
media: allegro: encode bit fields separately

Even bits in bitfields do not keep their position, but move around or
move to other bitfields. Therefore, the driver has to handle bitfields
differently depending on the firmware version.

Create separate fields for the options that have been in bitfields and
handle the bitfields when encoding the message.

As a side effect, this makes the messages a bit more readable.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: allegro: support handling firmware dependent values
Michael Tretter [Mon, 13 Jul 2020 14:42:23 +0000 (16:42 +0200)]
media: allegro: support handling firmware dependent values

Like the message format, also the identifiers in the messages differ
between firmware versions. This especially affects the identifier for
the codec that shall be used. As the messages used by the driver are now
independent from the firmware, we can use the values defined by V4L2 as
identifiers in the messages.

Convert the V4L2 codec format to the respective firmware value when
encoding the messages to binary format instead beforehand.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: allegro: don't pack MCU messages
Michael Tretter [Mon, 13 Jul 2020 14:42:22 +0000 (16:42 +0200)]
media: allegro: don't pack MCU messages

The messages are now explicitly converted from the struct to the binary
representation used by the firmware. Therefore, there is no need to keep
the structs packed anymore.

Drop the attribute and avoid confusion why the mails are packed.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: allegro: add field for number of buffers
Michael Tretter [Mon, 13 Jul 2020 14:42:21 +0000 (16:42 +0200)]
media: allegro: add field for number of buffers

When pushing the buffers for the intermediate and reference frames to
the MCU, the driver relied on the message size to calculate the number
of buffers. As it is not necessary anymore to keep the messages binary
compatible to the firmware, we can just explicitly write the number of
buffers into the message.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: allegro: add explicit mail encoding and decoding
Michael Tretter [Mon, 13 Jul 2020 14:42:20 +0000 (16:42 +0200)]
media: allegro: add explicit mail encoding and decoding

The message format in the mailboxes differ between firmware versions.
Therefore, it is necessary to decouple the mailbox format of the driver
from the message format of the firmware. This allows to keep a
consistent message format in the driver while still supporting various
firmware versions.

Add an intermediate step to encode and decode message before writing the
mails to the mailboxes.

On the other hand, this allows to handle optional fields in the
messages, which is required for advanced features of the encoder and was
not possible until now.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: allegro: rework read/write to mailbox
Michael Tretter [Mon, 13 Jul 2020 14:42:19 +0000 (16:42 +0200)]
media: allegro: rework read/write to mailbox

Rework the functions that read and write the SRAM that is used to
communicate with the MCU.

As the functions will not operate on structs but on prepared binary
buffers, make the buffer stride more explicit. Also, avoid any uses of
struct mcu_msg_header to analyze messages in memory, because the header
will be made independent of the binary representation in the mailbox.
Instead explicitly access the mail size field in the mailbox.

As at it, further reduce the dependency between the mailboxes and struct
allegro_dev.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: allegro: rework mbox handling
Michael Tretter [Mon, 13 Jul 2020 14:42:18 +0000 (16:42 +0200)]
media: allegro: rework mbox handling

Add a send/notify abstraction for the mailbox and separate the message
handling in the driver from the code to read and write message to the
mailbox.

This untangles how mails are written into the MCU's SRAM and signaled to
the MCU from the protocol between the driver and the firmware.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: v4l2-subdev.h: drop duplicated word in comment
Randy Dunlap [Tue, 14 Jul 2020 22:05:53 +0000 (00:05 +0200)]
media: v4l2-subdev.h: drop duplicated word in comment

Delete the doubled words "the" in comments.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: media-entity.h: drop duplicated word in comment
Randy Dunlap [Tue, 14 Jul 2020 22:05:52 +0000 (00:05 +0200)]
media: media-entity.h: drop duplicated word in comment

Delete the doubled word "flag" in a comment.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: dvbdev.h: fix duplicated word in comment
Randy Dunlap [Tue, 14 Jul 2020 22:05:51 +0000 (00:05 +0200)]
media: dvbdev.h: fix duplicated word in comment

Change the doubled word "the" in a comment to "to the".

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: media-devnode.h: drop duplicated word in comment
Randy Dunlap [Tue, 14 Jul 2020 22:05:50 +0000 (00:05 +0200)]
media: media-devnode.h: drop duplicated word in comment

Delete the doubled word "the" in a comment.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: media-device.h: drop duplicated word in comment
Randy Dunlap [Tue, 14 Jul 2020 22:05:49 +0000 (00:05 +0200)]
media: media-device.h: drop duplicated word in comment

Delete the doubled word "the" in a comment.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agostaging/media: Remove unneeded geometry restrictions from i.MX CSI driver
Krzysztof Hałasa [Thu, 14 May 2020 10:00:47 +0000 (12:00 +0200)]
staging/media: Remove unneeded geometry restrictions from i.MX CSI driver

I don't know what minimal image dimensions are, but 32x32 appears to
be ok according to the docs.
This is needed for small sensors like 80x80 thermal imagers.

Signed-off-by: Krzysztof Halasa <khalasa@piap.pl>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: vimc: Add a control to display info on test image
Kaaira Gupta [Sun, 5 Jul 2020 13:53:06 +0000 (15:53 +0200)]
media: vimc: Add a control to display info on test image

Add a control in VIMC to display information such as the correct order of
colors for a given test pattern, counter, brightness, hue, saturation,
contrast, width and height at sensor over test image.

Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>
Acked-by: Helen Koike <helen.koike@collabora.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: tpg: Add function to return colors' order of test image
Kaaira Gupta [Sun, 5 Jul 2020 13:53:05 +0000 (15:53 +0200)]
media: tpg: Add function to return colors' order of test image

Currently there is no method to know the correct order of the colors for
a test image generated by tpg. Write a function that returns a string of
colors' order given a tpg. It returns a NULL pointer in case of test
patterns which do not have a well defined colors' order. Hence add a
NULL check for text in tpg_gen_text().

[hverkuil: white -> White (for consistency)]

Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: tpg: change char argument to const char
Kaaira Gupta [Sun, 5 Jul 2020 13:53:04 +0000 (15:53 +0200)]
media: tpg: change char argument to const char

Change the argument of type char * to const char * for function
tpg_gen_text().

This function should take in a const char * as opposed to char * as it
does not make changes to the text. This issue was found while passing
the order of colors of tpg generated test image (which is a const char
*) to this function.

Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>
Reviewed-by: Helen Koike <helen.koike@collabora.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: vpss: clean up resources in init
Evgeny Novikov [Fri, 10 Jul 2020 09:02:23 +0000 (11:02 +0200)]
media: vpss: clean up resources in init

If platform_driver_register() fails within vpss_init() resources are not
cleaned up. The patch fixes this issue by introducing the corresponding
error handling.

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

Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agohantro: h264: Refuse to decode unsupported bitstream
Ezequiel Garcia [Thu, 9 Jul 2020 16:36:35 +0000 (18:36 +0200)]
hantro: h264: Refuse to decode unsupported bitstream

The hardware only supports 4:2:0 or 4:0:0 (monochrome),
8-bit depth content.

Verify that the SPS refers to a supported bitstream, and refuse
unsupported bitstreams by failing at TRY_EXT_CTRLS time.

Given the JPEG compression level control is the only one
that needs setting, a specific ops is provided.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agorkvdec: h264: Refuse to decode unsupported bitstream
Ezequiel Garcia [Thu, 9 Jul 2020 16:36:34 +0000 (18:36 +0200)]
rkvdec: h264: Refuse to decode unsupported bitstream

The hardware only supports 4:2:2, 4:2:0 or 4:0:0 (monochrome),
8-bit or 10-bit depth content.

Verify that the SPS refers to a supported bitstream, and refuse
unsupported bitstreams by failing at TRY_EXT_CTRLS time.

The driver is currently broken on 10-bit and 4:2:2
so disallow those as well.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Reviewed-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agohantro: Make sure we don't use post-processor on an encoder
Ezequiel Garcia [Wed, 1 Jul 2020 13:16:07 +0000 (15:16 +0200)]
hantro: Make sure we don't use post-processor on an encoder

Commit 986eee3a5234 ("media: hantro: Prevent encoders from using
post-processing") fixed hantro_needs_postproc condition,
but missed one case. Encoders don't have any post-processor
hardware block, so also can't be disabled.

Fix it.

Fixes: 986eee3a5234 ("media: hantro: Prevent encoders from using post-processing")
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agohantro: Remove unused bytesused argument
Ezequiel Garcia [Wed, 1 Jul 2020 13:16:06 +0000 (15:16 +0200)]
hantro: Remove unused bytesused argument

The driver doesn't need the bytesused argument.

For decoders, the plane bytesused is known and therefore,
buf_prepare is used to set it. For encoders, it's
handled by the codec_ops.done hook.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agohantro: Move hantro_enc_buf_finish to JPEG codec_ops.done
Ezequiel Garcia [Wed, 1 Jul 2020 13:16:05 +0000 (15:16 +0200)]
hantro: Move hantro_enc_buf_finish to JPEG codec_ops.done

hantro_enc_buf_finish is used only for JPEG, and so should
be moved to JPEG codec_ops.done.

This cleanup is also taking care of addressing
a subtle issue: checking the non-NULL bounce buffer
using ctx->jpeg_enc, which is a member of a union is
confusing and error-prone.

Note that the issue is currently innocuous because an
encoder context only supports JPEG.

The codec_ops.done has an argument that codec-specific code
shouldn't need, so drop that as well.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agohantro: Rework how encoder and decoder are identified
Ezequiel Garcia [Wed, 1 Jul 2020 13:16:04 +0000 (15:16 +0200)]
hantro: Rework how encoder and decoder are identified

So far we've been using the .buf_finish hook to distinguish
decoder from encoder. This is unnecessarily obfuscated.

Moreover, we want to move the buf_finish, so use a cleaner
scheme to distinguish the driver decoder/encoder type.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agohantro: h264: Rename scaling list handling function
Ezequiel Garcia [Wed, 1 Jul 2020 13:16:03 +0000 (15:16 +0200)]
hantro: h264: Rename scaling list handling function

Commit e17f08e31666 ("media: hantro: Do not reorder
H264 scaling list") removed the scaling list reordering,
which was wrong and not needed.

However, the name of the function stayed, which is
confusing for anyone reading the code. Rename
from "reorder" to "assemble" which is cleaner.

This is just a cosmetic cleanup.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agohantro: h264: Remove unused macro definition
Ezequiel Garcia [Wed, 1 Jul 2020 13:16:02 +0000 (15:16 +0200)]
hantro: h264: Remove unused macro definition

The generic H264 reference list builder moved all
the users of this macro, but left the macro.

Remove it.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: rkisp1: fix typos in file rkisp1-config.h
Dafna Hirschfeld [Tue, 7 Jul 2020 18:16:30 +0000 (20:16 +0200)]
media: staging: rkisp1: fix typos in file rkisp1-config.h

Fix two spelling typos in file rkisp1-config.h.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: rkisp1: remove duplicate macro definition
Dafna Hirschfeld [Tue, 7 Jul 2020 18:10:53 +0000 (20:10 +0200)]
media: staging: rkisp1: remove duplicate macro definition

The macro RKISP1_CIF_ISP_AWB_MODE_YCBCR_EN is defined twice.
Remove the second define.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: rkisp1: stats: read the stats in the isr
Dafna Hirschfeld [Fri, 26 Jun 2020 08:51:41 +0000 (10:51 +0200)]
media: staging: rkisp1: stats: read the stats in the isr

Currently the stats are read in a work queue. Defering the
reading of the stats is not needed and it is fine to read them
inside the irq handler.
This patch fixes and remove the TODO item:
'Use threaded interrupt for rkisp1_stats_isr(), remove work queue.'

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: rkisp1: stats: replace locks wq_lock, irq_lock with one lock
Dafna Hirschfeld [Fri, 26 Jun 2020 08:51:40 +0000 (10:51 +0200)]
media: staging: rkisp1: stats: replace locks wq_lock, irq_lock with one lock

This patch removes two locks in the rkisp1_stats struct:
- The mutex 'wq_lock' that is used to protect the buffers list 'stat'
- The spin_lock 'irq_lock' that is used to protect the
variable 'is_streaming'

It replaces them with one spin_lock 'lock' that protects
both the buffers list and the 'is_streaming' variable.
In later patch the reading of the statistics will move to
the isr so there will be no need for the mutex 'wq_lock'

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: rkisp1: stats: replace spin_lock_irqsave with spin_lock_irq
Dafna Hirschfeld [Fri, 26 Jun 2020 08:51:39 +0000 (10:51 +0200)]
media: staging: rkisp1: stats: replace spin_lock_irqsave with spin_lock_irq

The function 'rkisp1_stats_vb2_stop_streaming' runs in user context
therefore it is enough to use spin_lock_irq

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: rkisp1: use a macro for the statistics flags mask
Dafna Hirschfeld [Fri, 26 Jun 2020 08:51:38 +0000 (10:51 +0200)]
media: staging: rkisp1: use a macro for the statistics flags mask

The mask of the ready statistics flags is used in
several places in the code using bitwise-or.
Use a macro for that to make the code more readable.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.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+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Split CAMERARX handling to cal-camerarx.c
Laurent Pinchart [Mon, 6 Jul 2020 18:36:45 +0000 (20:36 +0200)]
media: ti-vpe: cal: Split CAMERARX handling to cal-camerarx.c

Implementation of media controller centric device configuration will add
code to the CAMERARX support section, which is already quite big. Move
it to a separate file to make the code more manageable. No functional
change is included.

The cal_camerarx_init_regmap() function is kept in cal.c and renamed to
cal_init_camerarx_regmap() as it's not specific to one CAMERARX
instance, but related to the whole CAL device.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Move CAL I/O accessors to cal.h
Laurent Pinchart [Mon, 6 Jul 2020 18:36:44 +0000 (20:36 +0200)]
media: ti-vpe: cal: Move CAL I/O accessors to cal.h

To prepare for the split of the camerarx code to a separate file, move
the CAL I/O accessors to cal.h. This requires renaming the accessors
with a cal_prefix, as the current names are too generic and prone to
namespace clashes.

The reg_read() and read_write() macros, that cover both CAL and CAMERARX
register access, are split in two groups of inline functions, one for
CAL access and one for CAMERARX access.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Split video node handling to cal-video.c
Laurent Pinchart [Mon, 6 Jul 2020 18:36:43 +0000 (20:36 +0200)]
media: ti-vpe: cal: Split video node handling to cal-video.c

To prepare for implementation of media controller centric device
configuration, move all the video node handling support to a separate
file.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Use 'unsigned int' type instead of 'unsigned'
Laurent Pinchart [Mon, 6 Jul 2020 18:36:42 +0000 (20:36 +0200)]
media: ti-vpe: cal: Use 'unsigned int' type instead of 'unsigned'

Specifying 'int' explicitly is generally preferred in the kernel for
unsigned int types. Fix the only wrong occurrence.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Remove unneeded phy->sensor NULL check
Laurent Pinchart [Mon, 6 Jul 2020 18:36:41 +0000 (20:36 +0200)]
media: ti-vpe: cal: Remove unneeded phy->sensor NULL check

The phy->sensor NULL check in cal_camerarx_get_external_rate() is not
needed, as the V4L2 video devices are only registered when the sensor is
bound. Remove it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Don't store external rate in cal_camerarx
Laurent Pinchart [Mon, 6 Jul 2020 18:36:40 +0000 (20:36 +0200)]
media: ti-vpe: cal: Don't store external rate in cal_camerarx

The external pixel rate is retrieved when starting the camerarx and only
used then. There's no need to store it in the cal_camerarx structure, it
can be returned by cal_camerarx_get_external_info() and explicitly
passed to cal_camerarx_config().

While at it, rename cal_camerarx_get_external_info() to
cal_camerarx_get_external_rate() to better reflect the function's
purpose.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Refactor camerarx start and stop
Laurent Pinchart [Mon, 6 Jul 2020 18:36:39 +0000 (20:36 +0200)]
media: ti-vpe: cal: Refactor camerarx start and stop

Refactor the camerarx start and stop procedure to group all the
corresponding operations in two functions, cal_camerarx_start() and
cal_camerarx_stop() instead of splitting them in multiple steps called
from the vb2 stream start and stop functions. This reduces the coupling
between the camerarx and the contexts, and better models the camerarx
hardware.

The cal_camerarx_start() is a reworked version of cal_camerarx_init()
with the description of the start procedure updated to match the AM65x,
DRA7[124567]x and DRA80xM TRMs. The cal_camerarx_wait_ready() function
is inlined in cal_camerarx_start() to better describe the start
procedure.

No functional change is included in the camerarx start and stop
procedures themselves, but the interleaving of the start steps with the
context configuration has been changed in cal_start_streaming().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Reorder camerarx functions to prepare refactoring
Laurent Pinchart [Mon, 6 Jul 2020 18:36:38 +0000 (20:36 +0200)]
media: ti-vpe: cal: Reorder camerarx functions to prepare refactoring

To prepare for the camerarx refactoring, reorder functions without any
functional change to ease review of the refactoring itself.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Inline cal_camerarx_max_lanes() in its only caller
Laurent Pinchart [Mon, 6 Jul 2020 18:36:37 +0000 (20:36 +0200)]
media: ti-vpe: cal: Inline cal_camerarx_max_lanes() in its only caller

The cal_camerarx_max_lanes() function is a one-liner that has a single
caller. It doesn't improve readability. Inline it in its caller.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Allocate cal_ctx active_fmt array dynamically
Laurent Pinchart [Mon, 6 Jul 2020 18:36:36 +0000 (20:36 +0200)]
media: ti-vpe: cal: Allocate cal_ctx active_fmt array dynamically

To avoid making the cal_ctx structure layoug depend on the size of the
cal_formats array, allocate the active_fmt array dynamically. This
prepares for splitting the driver in multiple files.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Init formats in cal_ctx_v4l2_register()
Laurent Pinchart [Mon, 6 Jul 2020 18:36:35 +0000 (20:36 +0200)]
media: ti-vpe: cal: Init formats in cal_ctx_v4l2_register()

To prepare for splitting the V4L2 API support to a separate file, call
cal_ctx_v4l2_init_formats() from cal_ctx_v4l2_register().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Register a media device
Laurent Pinchart [Mon, 6 Jul 2020 18:36:34 +0000 (20:36 +0200)]
media: ti-vpe: cal: Register a media device

Enable the media controller API by registering a media device and
initializing the media entities corresponding to the video devices. The
context initialization is slightly refactored as a result. The media
graph will be built in a subsequent change.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Store struct device in cal_dev
Laurent Pinchart [Mon, 6 Jul 2020 18:36:33 +0000 (20:36 +0200)]
media: ti-vpe: cal: Store struct device in cal_dev

The cal_dev structure stores the platform_device pointer, but most
accesses to that field need the device pointer. Store the struct device
pointer directly to simplify the code, and use to_platform_device() in
the two locations that need the platform device.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Print revision and hwinfo in a more readable format
Laurent Pinchart [Mon, 6 Jul 2020 18:36:32 +0000 (20:36 +0200)]
media: ti-vpe: cal: Print revision and hwinfo in a more readable format

Print the hardware revision in the X.Y.R format, which is more readable
that the 32-bit hex value. For the hardware info register, only print
its value if it doesn't contain what we expect.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Read hardware revision earlier during probe
Laurent Pinchart [Mon, 6 Jul 2020 18:36:31 +0000 (20:36 +0200)]
media: ti-vpe: cal: Read hardware revision earlier during probe

Read the hardware revision and info right after allocating resources, as
there's no need to delay doing so until all initialization is complete.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Split media initialization and cleanup to functions
Laurent Pinchart [Mon, 6 Jul 2020 18:36:30 +0000 (20:36 +0200)]
media: ti-vpe: cal: Split media initialization and cleanup to functions

Create four functions to handle initialization, cleanup, registration
and unregistration of the V4L2 (and soon media controller) objects:

- init() is meant to be called early at probe time to initialize the
  objects, before they get used from within the kernel

- cleanup() is the counterpart of init, and is meant to be called at the
  end of the remove sequence to free all objects

- register() is meant to be called at the end of the probe sequence, to
  register the userspace-facing devices

- unregister() is the counterpart of register, and is meant to be called
  at the beginning for the remove sequence, to disallow access from
  userspace

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Replace number of ports numerical value by macro
Laurent Pinchart [Mon, 6 Jul 2020 18:36:29 +0000 (20:36 +0200)]
media: ti-vpe: cal: Replace number of ports numerical value by macro

Use the CAL_NUM_CSI2_PORTS macro instead of the hardcoded numerical
value 2 to iterate over the CSI-2 ports.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Remove isvcirqset() and isportirqset() macros
Laurent Pinchart [Mon, 6 Jul 2020 18:36:28 +0000 (20:36 +0200)]
media: ti-vpe: cal: Remove isvcirqset() and isportirqset() macros

The isvcirqset() isn't used. The isportirqset() doesn't increase
readability. Inline the latter and simply drop the former.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Move CAL_NUM_CSI2_PORTS from cal_regs.h to cal.c
Laurent Pinchart [Mon, 6 Jul 2020 18:36:27 +0000 (20:36 +0200)]
media: ti-vpe: cal: Move CAL_NUM_CSI2_PORTS from cal_regs.h to cal.c

The CAL_NUM_CSI2_PORTS macro isn't a register definition. Move it to
cal.c, and fix indentation of the other macros while at it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Decouple context and phy cleanup at remove time
Laurent Pinchart [Mon, 6 Jul 2020 18:36:26 +0000 (20:36 +0200)]
media: ti-vpe: cal: Decouple context and phy cleanup at remove time

The driver happens the use the same number of CAMERARX and context, but
coupling their cleanup at remove time is wrong. To prepare for the
introduction of additional contexts, decouple the two.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Operate on phy instances in cal_quickdump_regs()
Laurent Pinchart [Mon, 6 Jul 2020 18:36:25 +0000 (20:36 +0200)]
media: ti-vpe: cal: Operate on phy instances in cal_quickdump_regs()

The cal_quickdump_regs() dumps registers for the two CAMERARX instances.
Retrieve those instances from the cal_dev directly instead of going
through the contexts, and simplify the code by using a loop.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Replace context with phy in async notifier entries
Laurent Pinchart [Mon, 6 Jul 2020 18:36:24 +0000 (20:36 +0200)]
media: ti-vpe: cal: Replace context with phy in async notifier entries

The async notifier is meant to bind to subdevs connected to the CSI-2
ports. Those ports are modelled by the CAMERARX phy instances. To
prepare for additional decoupling of contexts and phys, make the
notifier operate on phys. We still initialize and register the context
V4L2 support in the async notifier complete operation as that's our
signal that the userspace API is ready to be exposed.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Move async notifiers from contexts to cal_dev
Laurent Pinchart [Mon, 6 Jul 2020 18:36:23 +0000 (20:36 +0200)]
media: ti-vpe: cal: Move async notifiers from contexts to cal_dev

There's no need to create one async notifier per CAL context. Merge them
all in a single notifier, stored in cal_dev.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Allow multiple contexts per subdev notifier
Laurent Pinchart [Mon, 6 Jul 2020 18:36:22 +0000 (20:36 +0200)]
media: ti-vpe: cal: Allow multiple contexts per subdev notifier

The subdev notifier handling assumes a 1:1 mapping between CAL contexts
and notifiers. To prepare for merging the multiple notifiers into a
single one, retrieve the CAL context from the async subdev structure
instead of from the notifier.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Move all sensor-related init to .bound() notifier
Laurent Pinchart [Mon, 6 Jul 2020 18:36:21 +0000 (20:36 +0200)]
media: ti-vpe: cal: Move all sensor-related init to .bound() notifier

The initialization of the context based on the connected sensor is split
between the async notifier .bound() and .complete() operations. Move it
all to a separate function and call it from .bound() operation to
prepare for the move of the notifiers from the contexts to the cal_dev.
Only V4L2 registration is kept in the .complete() operation.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Use ARRAY_SIZE to replace numerical value
Laurent Pinchart [Mon, 6 Jul 2020 18:36:20 +0000 (20:36 +0200)]
media: ti-vpe: cal: Use ARRAY_SIZE to replace numerical value

Use ARRAY_SIZE(cal->ctx) to iterate over the cal->ctx array instead of
using the numerical value from the CAL_NUM_CONTEXT macro (or, worse,
hardcoding the value 2). This will allow reworking contexts with less
changes in the code.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Move DT parsing to CAMERARX
Laurent Pinchart [Mon, 6 Jul 2020 18:36:19 +0000 (20:36 +0200)]
media: ti-vpe: cal: Move DT parsing to CAMERARX

The DT port nodes corresponding to the CSI-2 inputs belong to the
CAMERARX instances. Move parsing of the DT properties to a new
cal_camerarx_parse_dt() function, called by cal_camerarx_create().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Add cal_camerarx_destroy() to cleanup CAMERARX
Laurent Pinchart [Mon, 6 Jul 2020 18:36:18 +0000 (20:36 +0200)]
media: ti-vpe: cal: Add cal_camerarx_destroy() to cleanup CAMERARX

The cal_camerarx_create() function allocates resources with devm_*, and
thus doesn't need any manual cleanup. Those won't hold true for long, as
we will need to store resources that have no devm_* allocation variant
in cal_camerarx. Furthermore, devm_kzalloc() is the wrong memory
allocation API for structures that can be accessed from userspace, as
device nodes can be kept open across device removal.

Add a cal_camerarx_destroy() function to destroy a CAMERARX instance
explicitly, and switch to kzalloc() for memory allocation.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Unregister video device before cleanup
Laurent Pinchart [Mon, 6 Jul 2020 18:36:17 +0000 (20:36 +0200)]
media: ti-vpe: cal: Unregister video device before cleanup

In cal_remove(), unregister the video devices as the first operation,
before cleaning up the V4L2 objects, to avoid use-after-free. This isn't
a complete solution yet, as video nodes can be kept open across
unregistration.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Add context V4L2 cleanup and unregister functions
Laurent Pinchart [Mon, 6 Jul 2020 18:36:16 +0000 (20:36 +0200)]
media: ti-vpe: cal: Add context V4L2 cleanup and unregister functions

Create cal_ctx_v4l2_unregister() and cal_ctx_v4l2_cleanup() functions to
unregister and cleanup the V4L2-related objects from the context, and
call them in cal_remove() and in the error path of cal_probe().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Split video device initialization and registration
Laurent Pinchart [Mon, 6 Jul 2020 18:36:15 +0000 (20:36 +0200)]
media: ti-vpe: cal: Split video device initialization and registration

There's no need to delay most of the video device initialization until
the sensor subdevs are bound. Split the initialization and registration,
and perform the initialization when creating the context.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Move v4l2_device from cal_ctx to cal_dev
Laurent Pinchart [Mon, 6 Jul 2020 18:36:14 +0000 (20:36 +0200)]
media: ti-vpe: cal: Move v4l2_device from cal_ctx to cal_dev

The v4l2_device structure is meant to represent the whole device. In the
CAL case, this corresponds to the CAL, the CAMERARX instances and the
connected sensors. There should thus be a single v4l2_device instance.
Replace the per-context instance with a global instance in the cal_dev
structure.

Don't set the v4l2_device name manually as v4l2_device_register() sets
it to a value that is suitable for the driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Decouple control handler from v4l2_device
Laurent Pinchart [Mon, 6 Jul 2020 18:36:13 +0000 (20:36 +0200)]
media: ti-vpe: cal: Decouple control handler from v4l2_device

To prepare for decoupling the v4l2_device from the cal_ctx, don't set
the control handler in the v4l2_device and expect the video node to use
it automatically, but set the video node control handler directly. This
requires adding the sensor subdev controls to the control handler
manually, as that operation was performed on the v4l2_device by
v4l2_device_register_subdev().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Fix usage of v4l2_fwnode_endpoint_parse()
Laurent Pinchart [Mon, 6 Jul 2020 18:36:12 +0000 (20:36 +0200)]
media: ti-vpe: cal: Fix usage of v4l2_fwnode_endpoint_parse()

Letting the v4l2_fwnode_endpoint_parse() function determine the bus type
automatically is deprecated. Set the bus type to DPHY manually as the TI
CAL only supports DPHY.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Use of_graph_get_endpoint_by_regs() to parse OF
Laurent Pinchart [Mon, 6 Jul 2020 18:36:11 +0000 (20:36 +0200)]
media: ti-vpe: cal: Use of_graph_get_endpoint_by_regs() to parse OF

Replace the manual of_get_next_port() and of_get_next_endpoint()
implementations and the corresponding logic in the caller with a call to
of_graph_get_endpoint_by_regs(). This greatly simplifies OF parsing.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Hardcode virtual channel to 0
Laurent Pinchart [Mon, 6 Jul 2020 18:36:10 +0000 (20:36 +0200)]
media: ti-vpe: cal: Hardcode virtual channel to 0

Using the endpoint reg value to pass the CSI-2 source virtual channel ID
in DT is a hack, isn't documented in the DT bindings, and isn't used in
neither upstream DT nor TI official overlays. Hardcode the virtual
channel to 0 to simplify reworking the code, proper virtual channel
support will be implemented later.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Rename cal_create_instance() to cal_ctx_create()
Laurent Pinchart [Mon, 6 Jul 2020 18:36:09 +0000 (20:36 +0200)]
media: ti-vpe: cal: Rename cal_create_instance() to cal_ctx_create()

The cal_create_instance() function creates a CAL context. Rename it to
cal_ctx_create() to make its purpose more explicit.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Add comments to cal_probe() to delimitate sections
Laurent Pinchart [Mon, 6 Jul 2020 18:36:08 +0000 (20:36 +0200)]
media: ti-vpe: cal: Add comments to cal_probe() to delimitate sections

The cal_probe() function is a bit long, add comments to delimitate
sections in order to improve readability. The platform_set_drvdata()
call is moved to a more logical place as a result.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Inline cal_get_camerarx_regmap() in caller
Laurent Pinchart [Mon, 6 Jul 2020 18:36:07 +0000 (20:36 +0200)]
media: ti-vpe: cal: Inline cal_get_camerarx_regmap() in caller

The cal_get_camerarx_regmap() function is called in a single place.
Inline it in its caller, as it results in a clear code flow.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Use syscon_regmap_lookup_by_phandle_args()
Laurent Pinchart [Mon, 6 Jul 2020 18:36:06 +0000 (20:36 +0200)]
media: ti-vpe: cal: Use syscon_regmap_lookup_by_phandle_args()

Use the syscon_regmap_lookup_by_phandle_args() function to replace
manual lookup of the syscon regmap offset. This simplifies the
cal_camerarx_init_regmap() implementation.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Split CAMERARX syscon regmap retrieval to a function
Laurent Pinchart [Mon, 6 Jul 2020 18:36:05 +0000 (20:36 +0200)]
media: ti-vpe: cal: Split CAMERARX syscon regmap retrieval to a function

Simplify the cal_probe() function by splitting the CAMERARX syscon
regmap retrieval to a separate function. A few local variables are
renamed in the process to shorten them (syscon_camerrx_*) or to make
them more accurate (parent isn't the parent OF node but the CAL device's
own OF node).

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Drop struct cal_dev v4l2_dev field
Laurent Pinchart [Mon, 6 Jul 2020 18:36:04 +0000 (20:36 +0200)]
media: ti-vpe: cal: Drop struct cal_dev v4l2_dev field

The v4l2_dev field of the cal_dev structure is initialized but never
used. Drop it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Use a loop to create CAMERARX and context instances
Laurent Pinchart [Mon, 6 Jul 2020 18:36:03 +0000 (20:36 +0200)]
media: ti-vpe: cal: Use a loop to create CAMERARX and context instances

Replace a manually unrolled loop with an explicit for loop to increase
readability when creating the CAMERARX and context instances. The
explicit NULL initialization of cal->phy[] and cal->ctx[] is removed, as
the cal structure is zeroed when allocated.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Use ctx_info() instead of v4l2_info()
Laurent Pinchart [Mon, 6 Jul 2020 18:36:02 +0000 (20:36 +0200)]
media: ti-vpe: cal: Use ctx_info() instead of v4l2_info()

Use the context-specific print macro to replace the last usage of the
v4l2_* print macros.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: cal: Get struct device without going through v4l2_device
Laurent Pinchart [Mon, 6 Jul 2020 18:36:01 +0000 (20:36 +0200)]
media: ti-vpe: cal: Get struct device without going through v4l2_device

Instead of retrieving the struct device for the platform device from the
v4l2_device, get it from the platform device directly. This prepares for
cleanups related to v4l2_device handling.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>