platform/kernel/linux-starfive.git
3 years agomedia: vidtv: cleanup SDT string identifiers
Mauro Carvalho Chehab [Sun, 20 Sep 2020 07:40:45 +0000 (09:40 +0200)]
media: vidtv: cleanup SDT string identifiers

In order to better test userspace applications, add an encoding
for the strings. The original channel string is also too big.
As we're just playing the first compasses of the 5th Beethoven
Symphony, change the service name to just "Beethoven". Also,
add a provider's name. For such purpose, let's point it to
the Linux media community website.

With such changes, the SDT table now looks more like one got
from a real digital TV channel:

SDT
| table_id         0x42
| section_length      44
| one                 2
| zero                1
| syntax              1
| transport_stream_id 1860
| current_next        1
| version             0
| one2                3
| section_number      0
| last_section_number 0
| network_id          65281
| reserved            255
|\
|- service 0x0880
|   EIT schedule          0
|   EIT present following 0
|   free CA mode          0
|   running status        4
|   descriptor length     27
|        0x48: service_descriptor
|           service type  1
|           provider      'LinuxTV.org'
|           name          'Beethoven'
|_  1 services

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: cleanup PSI version numbers
Mauro Carvalho Chehab [Sun, 20 Sep 2020 07:17:45 +0000 (09:17 +0200)]
media: vidtv: cleanup PSI version numbers

There's no reason to use static vars to store PSI version
numbers.

Also, currently, version numbers are starting with 0x01,
because there's a code being called that increases it to
1 for all table initializer code, as the code may support
dynamic changes at the PS tables on some future.

So, let's just initialize them to 0x1f, in order for the
versions to be reported as starting from 0.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: fix initialization of the network_id field at SDT
Mauro Carvalho Chehab [Sun, 20 Sep 2020 06:34:55 +0000 (08:34 +0200)]
media: vidtv: fix initialization of the network_id field at SDT

This field should point to the network ID, and has different
ranges for cable, terrestrial or satellite. It also has
an special range for temporary private usage.

For now, let's use the temporary private one. Once the
Network Information Table (NIT) gets added, this should be
reviewed.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: remove more ENDIAN_BITFIELD nonsense
Mauro Carvalho Chehab [Sun, 20 Sep 2020 06:25:49 +0000 (08:25 +0200)]
media: vidtv: remove more ENDIAN_BITFIELD nonsense

Changeset 870e350d4e39 ("media: vidtv: get rid of ENDIAN_BITFIELD nonsense")
was incomplete. There are still some wrong endannes logic at
the driver. Get rid of them.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vidtv: simplify PCR logic to get jiffies
Mauro Carvalho Chehab [Sun, 20 Sep 2020 06:22:20 +0000 (08:22 +0200)]
media: vidtv: simplify PCR logic to get jiffies

There's no need to have a check when setting timing.past_jiffies,
as we can simply do the initialization earlier at vidtv_mux_init().

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: hist-v4l2.rst: remove :c:`type` from structs and enums
Mauro Carvalho Chehab [Mon, 28 Sep 2020 06:16:02 +0000 (08:16 +0200)]
media: hist-v4l2.rst: remove :c:`type` from structs and enums

Using struct|enum :c:`type` here sounds a bad idea, as it may be
documenting data types that were already removed. Also, it makes
the file harder to read.

As automarkup.py should be able to handle those cases, let's
just get rid of the markup.

While not required by automarkup, in order to make easier for
grep, both type and names are now at the same line.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: hist-v4l2.rst: remove struct duplication
Mauro Carvalho Chehab [Mon, 28 Sep 2020 06:11:34 +0000 (08:11 +0200)]
media: hist-v4l2.rst: remove struct duplication

There are several places there where struct was used twice,
on multiple lines, like:

struct
struct ``v4l2_zoomcap``

That's probably done during the DocBook to ReSt conversion.

Probably the cases where "struct struct" were at the same line
was addressed back then, but the multi-line cases are still
there.

Get rid of them.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: v4l2-subdev.h: fix a kernel-doc markup
Mauro Carvalho Chehab [Tue, 29 Sep 2020 09:15:36 +0000 (11:15 +0200)]
media: v4l2-subdev.h: fix a kernel-doc markup

As reported by Sphinx:

./Documentation/driver-api/media/v4l2-subdev:490: ./include/media/v4l2-subdev.h:384: WARNING: Unparseable C cross-reference: 'struct'
Invalid C declaration: Expected identifier in nested name, got keyword: struct [error at 6]
  struct
  ------^

The markup there is wrong:
&struct &v4l2_input -> &struct v4l2_input

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: cec-core.rst: fix warnings with Sphinx 3.0+
Mauro Carvalho Chehab [Sat, 26 Sep 2020 07:08:38 +0000 (09:08 +0200)]
media: cec-core.rst: fix warnings with Sphinx 3.0+

The new C domain code on Sphinx 3 is a lot more pedantic.
It only accepts real functions declared as c:function.

So, declarations like this are not valid:

.. c:function::
        int (*adap_enable)(struct cec_adapter *adap, bool enable);

Also, no blank lines are allowed after ".. c:function:", and
continuation lines should be like:

.. c:function:
int (void foo, \
     int bar);

Change the logic there, in order to avoid lots of warnings
when built with Sphinx 3.x.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: v4l2-subdev.rst: get rid of a duplicatd kernel-doc markup
Mauro Carvalho Chehab [Mon, 28 Sep 2020 14:21:00 +0000 (16:21 +0200)]
media: v4l2-subdev.rst: get rid of a duplicatd kernel-doc markup

There are two kernel-doc markups for include/media/v4l2-async.h,
one at v4l2-async.rst and another one at v4l2-subdev.rst.

Sphinx 3.x checks it and complains for duplicated symbols.

So, get rid of one of them.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: dvb-frontends: remove a clone of a kernel-doc markup at zd1301_demod.h
Mauro Carvalho Chehab [Fri, 25 Sep 2020 11:08:01 +0000 (13:08 +0200)]
media: dvb-frontends: remove a clone of a kernel-doc markup at zd1301_demod.h

The same markup are there twice, causing warnings with
Sphinx 3.x. Drop the second copy.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: docs: ipu3.rst: rely at automarkup extension
Mauro Carvalho Chehab [Fri, 25 Sep 2020 09:48:40 +0000 (11:48 +0200)]
media: docs: ipu3.rst: rely at automarkup extension

There are several :c:type: definitions there, in order to
do cross-references with the driver's documentation.

Those are broken when docs are built with Sphinx 3.x, as
it would require :c:struct: instead.

For Sphinx < 3.x, the automarkup.py extension is able to do the
replacement already, and a future improvement on it should make
it also work with Sphinx 3.x.

So, get rid of the usage of the :c:type: macro there.

Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: glossary.rst: use the right case for glossary entries
Mauro Carvalho Chehab [Fri, 25 Sep 2020 06:48:32 +0000 (08:48 +0200)]
media: glossary.rst: use the right case for glossary entries

Sphinx 3.x is pedantic with glossary entries:

    Documentation/userspace-api/media/glossary.rst:17: WARNING: term device driver not found in case sensitive match.made a reference to Device Driver instead.
    Documentation/userspace-api/media/glossary.rst:59: WARNING: term media hardware not found in case sensitive match.made a reference to Media Hardware instead.
    Documentation/userspace-api/media/glossary.rst:59: WARNING: term IP block not found in case sensitive match.made a reference to IP Block instead.
    Documentation/userspace-api/media/glossary.rst:64: WARNING: term hardware component not found in case sensitive match.made a reference to Hardware Component instead.
    Documentation/userspace-api/media/glossary.rst:64: WARNING: term ip block not found in case sensitive match.made a reference to IP Block instead.
    Documentation/userspace-api/media/glossary.rst:70: WARNING: term peripheral not found in case sensitive match.made a reference to Peripheral instead.
    Documentation/userspace-api/media/glossary.rst:130: WARNING: term V4L2 hardware not found in case sensitive match.made a reference to V4L2 Hardware instead.
    Documentation/userspace-api/media/glossary.rst:151: WARNING: term hardware peripheral not found in case sensitive match.made a reference to Hardware Peripheral instead.
    Documentation/userspace-api/media/glossary.rst:183: WARNING: term device node not found in case sensitive match.made a reference to Device Node instead.
    Documentation/userspace-api/media/glossary.rst:191: WARNING: term bridge driver not found in case sensitive match.made a reference to Bridge Driver instead.

While it works with case-insensitive entires, it complains.

Let's fix it, in order to cleanup the warnings. Also, I won't
doubt that a later change on Sphinx will end breaking support
for it.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: camera-sensor.rst: fix a doc build warning
Mauro Carvalho Chehab [Wed, 9 Sep 2020 13:05:31 +0000 (15:05 +0200)]
media: camera-sensor.rst: fix a doc build warning

Documentation/driver-api/media/camera-sensor.rst:123: WARNING: Inline literal start-string without end-string.

There's a missing blank space over there.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: MAINTAINERS: remove Maxime Jourdan as maintainer of Amlogic VDEC
Neil Armstrong [Wed, 23 Sep 2020 16:09:10 +0000 (18:09 +0200)]
media: MAINTAINERS: remove Maxime Jourdan as maintainer of Amlogic VDEC

Maxime is no more a BayLibre employee, and his e-mail address is now
invalid.

I'll be happy to add him back using another e-mail address if he wants
to continue maintaining this driver.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: staging: rkisp1: cap: protect access to buf with the spin lock
Dafna Hirschfeld [Tue, 22 Sep 2020 11:34:02 +0000 (13:34 +0200)]
media: staging: rkisp1: cap: protect access to buf with the spin lock

The function 'rkisp1_stream_start' calls 'rkisp1_set_next_buf'
which access the buffers, so the call should be protected by
taking the cap->buf.lock.
After this patch, all locks are reviewed and commented so remove
the TODO item "review and comment every lock"

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: staging: rkisp1: use the right variants of spin_lock
Dafna Hirschfeld [Tue, 22 Sep 2020 11:34:01 +0000 (13:34 +0200)]
media: staging: rkisp1: use the right variants of spin_lock

When locking, use either 'spin_lock' or 'spin_lock_irq'
according to the context. There is nowhere need to
use 'spin_lock_irqsave'.
Outside of irq context, always use 'spin_lock_irq'
to be on the safe side.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: staging: rkisp1: params: no need to lock default config
Dafna Hirschfeld [Tue, 22 Sep 2020 11:34:00 +0000 (13:34 +0200)]
media: staging: rkisp1: params: no need to lock default config

In the function 'rkisp1_params_config_parameter' the lock
is taken while applying the default config. But the lock
only needs to protect the buffers list and the 'is_streaming'
field, so move the locking to lock only what is needed.

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>
3 years agomedia: staging: rkisp1: stats: protect write to 'is_streaming' in start_streaming cb
Dafna Hirschfeld [Tue, 22 Sep 2020 11:33:59 +0000 (13:33 +0200)]
media: staging: rkisp1: stats: protect write to 'is_streaming' in start_streaming cb

The field stats->is_streaming is written in 'start_streaming' callback
without the stats->lock protection.
The isr might run together with the callback so 'spin_lock_irq'
should be used.

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>
3 years agomedia: staging: rkisp1: isp: don't enable signal RKISP1_CIF_ISP_FRAME_IN
Dafna Hirschfeld [Tue, 22 Sep 2020 11:33:58 +0000 (13:33 +0200)]
media: staging: rkisp1: isp: don't enable signal RKISP1_CIF_ISP_FRAME_IN

The signal RKISP1_CIF_ISP_FRAME_IN is not used in the isr so
there is no need to enable 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>
3 years agomedia: staging: rkisp1: isp: add a warning and debugfs var for irq delay
Dafna Hirschfeld [Tue, 22 Sep 2020 11:33:57 +0000 (13:33 +0200)]
media: staging: rkisp1: isp: add a warning and debugfs var for irq delay

The signal RKISP1_CIF_ISP_FRAME is set when the ISP completes
outputting the frame to the next block in the pipeline.
In order to keep buffer synchronization we assume that the
RKISP1_CIF_ISP_V_START signal never arrives together with the
RKISP1_CIF_ISP_FRAME signal.
In case those signals arrive together then the code is not able to
tell if the RKISP1_CIF_ISP_FRAME signal relates to the frame of
the current v-start or the previous. This patch adds a WARN_ONCE
and a debugfs var to catch it.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: staging: rkisp1: remove atomic operations for frame sequence
Dafna Hirschfeld [Tue, 22 Sep 2020 11:33:56 +0000 (13:33 +0200)]
media: staging: rkisp1: remove atomic operations for frame sequence

The isp.frame_sequence is now read only from the irq handlers
that are all fired from the same interrupt, so there is not need
for atomic operation.
In addition, the frame seq incrementation is moved from
rkisp1_isp_queue_event_sof to rkisp1_isp_isr to make the code
clearer and the incorrect inline comment is removed.

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>
3 years agomedia: staging: rkisp1: params: set vb.sequence to be the isp's frame_sequence + 1
Dafna Hirschfeld [Tue, 22 Sep 2020 11:33:55 +0000 (13:33 +0200)]
media: staging: rkisp1: params: set vb.sequence to be the isp's frame_sequence + 1

The params isr is called when the ISP finishes processing a frame
(RKISP1_CIF_ISP_FRAME). Configurations performed in the params isr
will be applied on the next frame. Since frame_sequence is updated
on the vertical sync signal, we should use frame_sequence + 1 as
the vb.sequence of the params buffer to indicate to userspace on
which frame these parameters are being applied.

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>
3 years agomedia: staging: rkisp1: params: avoid using buffer if params is not streaming
Dafna Hirschfeld [Tue, 22 Sep 2020 11:33:54 +0000 (13:33 +0200)]
media: staging: rkisp1: params: avoid using buffer if params is not streaming

Currently, the first buffer queued in the params node is returned
immediately to userspace and a copy of it is saved in the field
'cur_params'. The copy is later used for the first configuration
when the stream is initiated by one of selfpath/mainpath capture nodes.

There are 3 problems with this implementation:
- The first params buffer is applied and returned to userspace even if
userspace never calls to streamon on the params node.
- If the first params buffer is queued after the stream started on the
params node then it will return to userspace but will never be used.
- The frame_sequence of the first buffer is set to -1 if the main/selfpath
did not start streaming.

A correct implementation is to apply the first params buffer when stream
is started from mainpath/selfpath and only if params is also streaming.

The patch adds a new function 'rkisp1_params_apply_params_cfg' which takes
a buffer from the buffers queue, apply it and returns it to userspace.
The function is called from the irq handler and when main/selfpath stream
starts - in the function 'rkisp1_params_config_parameter'

Also remove the fields 'cur_params', 'is_first_params' which are no
more needed.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Reported-by: kernel test robot <lkp@intel.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>
3 years agomedia: staging: rkisp1: params: use the new effect value in cproc config
Dafna Hirschfeld [Tue, 22 Sep 2020 11:33:53 +0000 (13:33 +0200)]
media: staging: rkisp1: params: use the new effect value in cproc config

The cproc (color processing) configuration needs to know if
an image effect is configured. The code uses the image effect
in 'cur_params' which is the first params buffer queued in the stream.
This is the wrong place to read the value. The value should be
taken from the current params buffer.

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>
3 years agomedia: staging: rkisp1: params: in the isr, return if buffer list is empty
Dafna Hirschfeld [Tue, 22 Sep 2020 11:33:52 +0000 (13:33 +0200)]
media: staging: rkisp1: params: in the isr, return if buffer list is empty

Currently the code in the isr checks if the buffer list is not
empty before referencing a buffer and then check again if the
buffer is not NULL. Instead we can save one 'if' statement by
returning if the buffers list is empty.
Also remove non-helpful inline doc 'get one empty buffer'

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>
3 years agomedia: staging: rkisp1: params: upon stream stop, iterate a local list to return...
Dafna Hirschfeld [Tue, 22 Sep 2020 11:33:51 +0000 (13:33 +0200)]
media: staging: rkisp1: params: upon stream stop, iterate a local list to return the buffers

The code in '.stop_streaming' callback releases and acquire the lock
at each iteration when returning the buffers.
Holding the lock disables interrupts so it should be minimized.
To make the code cleaner and still minimize holding the lock,
the buffer list is first moved to a local list and
then can be iterated without 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>
3 years agomedia: docs: v4l2-subdev: move calling ops to a subsection
Luca Ceresoli [Mon, 21 Sep 2020 20:21:34 +0000 (22:21 +0200)]
media: docs: v4l2-subdev: move calling ops to a subsection

Documentation on how to call the subdev ops is currently in the middle of
synchronous and asynchronous registration. Move it to a dedicated
subsection after the registration methods.

Also move the final paragraph "The advantage of using v4l2_subdev..." to
the beginning of the new section as it has an introductory content.

[hverkuil: correct accidental deletion of the last part of a sentence]

Suggested-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: docs: v4l2-subdev: move "Subdev registration" to a subsection
Luca Ceresoli [Mon, 21 Sep 2020 20:21:33 +0000 (22:21 +0200)]
media: docs: v4l2-subdev: move "Subdev registration" to a subsection

The subdev registration topic is pretty lengthy, and takes more than
half of the "V4L2 sub-devices" section. Help readers in finding their
way through the document by dedicating a subsection to
"Subdev registration".

Each of the two registration methods takes many paragraphs, but since
adding a subsubsection would be overkill, just emphasize them in bold.

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: docs: v4l2-subdev: fix typo
Luca Ceresoli [Mon, 21 Sep 2020 20:21:32 +0000 (22:21 +0200)]
media: docs: v4l2-subdev: fix typo

Fix "Helper functions exists" -> "Helper functions exist".

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: docs: v4l2-subdev: fix typo
Luca Ceresoli [Mon, 21 Sep 2020 20:21:31 +0000 (22:21 +0200)]
media: docs: v4l2-subdev: fix typo

Fix "will to" -> "will do".

Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: saa7146: drop double zeroing
Julia Lawall [Sun, 20 Sep 2020 11:26:24 +0000 (13:26 +0200)]
media: saa7146: drop double zeroing

sg_init_table zeroes its first argument, so the allocation of that argument
doesn't have to.

the semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x,n,flags;
@@

x =
- kcalloc
+ kmalloc_array
  (n,sizeof(struct scatterlist),flags)
...
sg_init_table(x,n)
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: firewire: fix memory leak
Pavel Machek [Sun, 20 Sep 2020 09:01:37 +0000 (11:01 +0200)]
media: firewire: fix memory leak

Fix memory leak in node_probe.

Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: rcar-vin: Extend RAW8 support to all RGB layouts
Niklas Söderlund [Tue, 15 Sep 2020 23:01:40 +0000 (01:01 +0200)]
media: rcar-vin: Extend RAW8 support to all RGB layouts

Extend the list of supported formats to include all RGB layouts of RAW8.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: rcar-csi2: Extend RAW8 support to all RGB layouts
Niklas Söderlund [Tue, 15 Sep 2020 23:01:39 +0000 (01:01 +0200)]
media: rcar-csi2: Extend RAW8 support to all RGB layouts

Extend the list of supported formats to include all RGB layouts of RAW8.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: bindings: media: gpio-ir-receiver: add linux,autosuspend-period property
Joakim Zhang [Tue, 22 Sep 2020 19:08:06 +0000 (21:08 +0200)]
media: bindings: media: gpio-ir-receiver: add linux,autosuspend-period property

Add linux,autosuspend-period property for gpio ir receiver. Some cpuidle
systems wake from idle may take a bit long time, for such case, need
disable cpuidle temporarily.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: rc: gpio-ir-recv: add QoS support for cpuidle system
Joakim Zhang [Tue, 22 Sep 2020 19:08:07 +0000 (21:08 +0200)]
media: rc: gpio-ir-recv: add QoS support for cpuidle system

GPIO IR receive is much rely on interrupt response, uneven interrupt
latency will lead to incorrect timing, so the decoder fails to decode
it. The issue is particularly acute on some systems which support
cpuidle, not all, dynamically disable and enable cpuidle can solve this
problem to a great extent.

However, there is a downside to this approach, the measurement of header
on the first frame may incorrect. Test on i.MX8M serials, when enable
cpuidle, interrupt latency could be about 500us.

With this patch:
1. has no side effect on non-cpuidle system, even runtime pm api won't
be invoked to avoid a bunch of pm busy work for devices that do not need
it, including spinlocks, ktime, etc.
2. latency is still much longer for the first gpio interrupt on cpuidle
system, so the first frame may not be decoded. Generally, RC would transmit
multiple frames at once press, we can sacrifice the first frame.
3. add "linux,autosuspend-period" property in device tree if you also
suffer this cpuidle issue.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: dvb-frontends: tda18271c2dd: Constify static structs
Rikard Falkeborn [Mon, 21 Sep 2020 22:13:43 +0000 (00:13 +0200)]
media: dvb-frontends: tda18271c2dd: Constify static structs

Constify a number of static structs that were not modified. In order to
be able to do that, const input arguments to a couple of functions that
not modify their argument. This allows the compiler to put them in
read-only memory, resulting in about 6k memory being read-only, and the
resulting module is 400 bytes smaller.

Before:
   text    data     bss     dec     hex filename
  15492    6873       0   22365    575d drivers/media/dvb-frontends/tda18271c2dd.ko

After:
   text    data     bss     dec     hex filename
  21021     897       0   21918    559e drivers/media/dvb-frontends/tda18271c2dd.ko

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: flexcop-usb: remove needless check before usb_free_coherent()
Qinglang Miao [Mon, 14 Sep 2020 06:15:13 +0000 (08:15 +0200)]
media: flexcop-usb: remove needless check before usb_free_coherent()

usb_free_coherent() is safe with NULL addr and this check is
not required.

Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: flexcop-usb: sanity checking of endpoint type
Oliver Neukum [Thu, 24 Sep 2020 11:37:40 +0000 (13:37 +0200)]
media: flexcop-usb: sanity checking of endpoint type

Make sure the endpoint is ISOC in and do not hard code USB_DIR_IN.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: netup_unidvb: drop initialization of PM pointers
Vaibhav Gupta [Sun, 30 Aug 2020 09:44:14 +0000 (11:44 +0200)]
media: netup_unidvb: drop initialization of PM pointers

The .suspend() and .resume() callbacks are not defined for this driver.
Thus, just the unlisting of PM pointers in the struct initializer will make
no change in its behavior. Still unlisting is necessary so as to get rid of
.suspend and .resume pointers as they are part of the legacy framework and
should not be used in the driver code explicitly.

Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: ati_remote: sanity check for both endpoints
Oliver Neukum [Wed, 16 Sep 2020 13:50:51 +0000 (15:50 +0200)]
media: ati_remote: sanity check for both endpoints

If you do sanity checks, you should do them for both endpoints.
Hence introduce checking for endpoint type for the output
endpoint, too.

Reported-by: syzbot+998261c2ae5932458f6c@syzkaller.appspotmail.com
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: dvb-frontends: rtl2832_sdr: set error code in probe
Evgeny Novikov [Mon, 21 Sep 2020 12:30:06 +0000 (14:30 +0200)]
media: dvb-frontends: rtl2832_sdr: set error code in probe

If rtl2832_sdr_probe() encounters an unsupported tuner it cleans up
everything and returns 0. This can result in various bad things later.
The patch sets the error code on the corresponding path.

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

Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: cedrus: Propagate OUTPUT resolution to CAPTURE
Nicolas Dufresne [Fri, 18 Sep 2020 00:27:51 +0000 (02:27 +0200)]
media: cedrus: Propagate OUTPUT resolution to CAPTURE

As per spec, the CAPTURE resolution should be automatically set based on
the OUTPUT resolution. This patch properly propagate width/height to the
capture when the OUTPUT format is set and override the user provided
width/height with configured OUTPUT resolution when the CAPTURE fmt is
updated.

This also prevents userspace from selecting a CAPTURE resolution that is
too small, avoiding kernel oops.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Acked-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Tested-by: Ondrej Jirman <megous@megous.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: MAINTAINERS: add documentation files for rkisp1
Dafna Hirschfeld [Thu, 17 Sep 2020 15:04:08 +0000 (17:04 +0200)]
media: MAINTAINERS: add documentation files for rkisp1

Add the files:
Documentation/admin-guide/media/rkisp1.rst
Documentation/userspace-api/media/v4l/pixfmt-meta-rkisp1.rst

to the Rockchip ISP driver entry in the MAINTAINERS file.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: admin-guide: add documentation file rkisp1.rst
Dafna Hirschfeld [Tue, 18 Aug 2020 10:27:03 +0000 (12:27 +0200)]
media: admin-guide: add documentation file rkisp1.rst

Add the file 'rkisp1.rst' that documents the rkisp1 driver.

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>
3 years agomedia: pixfmt-meta-rkisp1.rst: add description of rkisp1 metadata formats in pixfmt...
Dafna Hirschfeld [Tue, 18 Aug 2020 10:27:02 +0000 (12:27 +0200)]
media: pixfmt-meta-rkisp1.rst: add description of rkisp1 metadata formats in pixfmt-meta-rkisp1.rst

The metadata formats V4L2_META_FMT_RK_ISP1_PARAMS,
V4L2_META_FMT_RK_ISP1_STAT_3A are currently described in
two files under
drivers/staging/media/rkisp1/Documentation/media/uapi/v4l

This patch moves the description to one file:
Documentation/userspace-api/media/v4l/pixfmt-meta-rkisp1.rst
The patch also extends the description and adds the rst file to
toctree.

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>
3 years agomedia: staging: rkisp1: fix configuration for GREY pixelformat
Dafna Hirschfeld [Tue, 1 Sep 2020 11:16:12 +0000 (13:16 +0200)]
media: staging: rkisp1: fix configuration for GREY pixelformat

This patch changes the device configuration to support capture
of V4L2_PIX_FMT_GREY video. The 'write_format' field of the format
description should be planar.
Also the array 'pixm->plane_fmt' that describes the planes should
be memset to 0 before filling it since the the cb, cr planes should
be 0.

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>
3 years agomedia: staging: rkisp1: cap: simplify link validation by comparing media bus code
Dafna Hirschfeld [Tue, 1 Sep 2020 11:16:11 +0000 (13:16 +0200)]
media: staging: rkisp1: cap: simplify link validation by comparing media bus code

The capture has a mapping of the mbus code needed for each pixelformat.
This can be used to simplify the link validation by comparing the mbus
code in the capture with the code in the resizer.

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>
3 years agomedia: staging: rkisp1: rsz: Add support to more YUV encoded mbus codes on src pad
Dafna Hirschfeld [Tue, 1 Sep 2020 11:16:10 +0000 (13:16 +0200)]
media: staging: rkisp1: rsz: Add support to more YUV encoded mbus codes on src pad

Add support to more YUV encoded media bus formats on the resizer's
source pad. The patch defines an array rkisp1_rsz_yuv_formats[]
with the list of supported YUV media bus formats and their {hv}div
values. The {hv}div are used in the function 'rkisp1_rsz_config'
instead of the macros RKISP1_MBUS_FMT_(HV)DIV, and instead of
checking the capture format.

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>
3 years agomedia: staging: rkisp1: rsz: enumerate the formats on the src pad according to the...
Dafna Hirschfeld [Tue, 1 Sep 2020 11:16:09 +0000 (13:16 +0200)]
media: staging: rkisp1: rsz: enumerate the formats on the src pad according to the capture

Currently the resizer outputs the same media bus format
as the input. This is wrong since the resizer is also used
to downscale YUV formats. This patch changes the enumeration
of the supported formats. The supported formats on the sink pad
should be taken from the isp entity and the supported formats on
the source pad should be taken from the capture entity.

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>
3 years agomedia: staging: rkisp1: add a helper function to enumerate supported mbus formats...
Dafna Hirschfeld [Tue, 1 Sep 2020 11:16:08 +0000 (13:16 +0200)]
media: staging: rkisp1: add a helper function to enumerate supported mbus formats on capture

Add a function 'rkisp1_cap_enum_mbus_codes' that receive
a pointer to 'v4l2_subdev_mbus_code_enum' and returns the
next supported mbus format of the capture. The function
assumes that pixel formats with identical 'mbus' are grouped
together in the hardcoded arrays, therefore the order of the
entries in the array 'rkisp1_sp_fmts' are adjusted.
This function is a helper for the media bus enumeration of
the source pad of the resizer entity.

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>
3 years agomedia: staging: rkisp1: add capability V4L2_CAP_IO_MC to capture devices
Dafna Hirschfeld [Tue, 1 Sep 2020 11:16:07 +0000 (13:16 +0200)]
media: staging: rkisp1: add capability V4L2_CAP_IO_MC to capture devices

The capture devices supports YUV, RGB, and Bayer formats.
Adding V4L2_CAP_IO_MC capability will reflect userspace
what format should be set on the resizer in order to stream
each of the video formats.

The patch adds a 'mbus' field to the struct
'rkisp1_capture_fmt_cfg' which maps the video format
to the needed mbus format.

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>
3 years agomedia: staging: rkisp1: don't support bayer format on selfpath resizer
Dafna Hirschfeld [Tue, 1 Sep 2020 11:16:06 +0000 (13:16 +0200)]
media: staging: rkisp1: don't support bayer format on selfpath resizer

The selfpath capture does not support bayer formats.
Therefore there is no reason to support bayer formats
on the selfpath resizer. The selfpath resizer should
support only MEDIA_BUS_FMT_YUYV8_2X8.

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>
3 years agomedia: staging: rkisp1: cap: remove unsupported format YUV444
Dafna Hirschfeld [Tue, 1 Sep 2020 11:16:05 +0000 (13:16 +0200)]
media: staging: rkisp1: cap: remove unsupported format YUV444

It is not clear if the device is able to support format
V4L2_PIX_FMT_YUV444M so remove 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>
3 years agomedia: staging: rkisp1: cap: remove unsupported formats
Dafna Hirschfeld [Tue, 1 Sep 2020 11:16:04 +0000 (13:16 +0200)]
media: staging: rkisp1: cap: remove unsupported formats

For Ycbcr packed formats only YUYV can be supported by
the driver. This patch removes the other formats.

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>
3 years agomedia: staging: rkisp1: cap: change RGB24 format to XBGR32
Dafna Hirschfeld [Tue, 1 Sep 2020 11:16:03 +0000 (13:16 +0200)]
media: staging: rkisp1: cap: change RGB24 format to XBGR32

According to the TRM [1], the YUV->RGB conversion outputs
RGB 888 format with 4 bytes, where the last byte is ignored,
using big endian representation:

|___X___|___R___|___G___|___B___|
31      24      16      8       0

Which matches format V4L2_PIX_FMT_XBGR32 in little endian
representation, so replace it accordingly.

"24 bit word". What it means is that 4 bytes are used with
24bit for the RGB and the last byte is ignored.
This matches format V4L2_PIX_FMT_XBGR32.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: st-delta: Fix reference count leak in delta_run_work
Aditya Pakki [Sun, 14 Jun 2020 03:58:41 +0000 (05:58 +0200)]
media: st-delta: Fix reference count leak in delta_run_work

delta_run_work() calls delta_get_sync() that increments
the reference counter. In case of failure, decrement the reference
count by calling delta_put_autosuspend().

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: sti: Fix reference count leaks
Qiushi Wu [Sun, 14 Jun 2020 03:31:06 +0000 (05:31 +0200)]
media: sti: Fix reference count leaks

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code, causing incorrect ref count if
pm_runtime_put_noidle() is not called in error handling paths.
Thus call pm_runtime_put_noidle() if pm_runtime_get_sync() fails.

Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: exynos4-is: Fix several reference count leaks due to pm_runtime_get_sync
Qiushi Wu [Sun, 14 Jun 2020 03:18:29 +0000 (05:18 +0200)]
media: exynos4-is: Fix several reference count leaks due to pm_runtime_get_sync

On calling pm_runtime_get_sync() the reference count of the device
is incremented. In case of failure, decrement the
reference count before returning the error.

Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: exynos4-is: Fix a reference count leak due to pm_runtime_get_sync
Qiushi Wu [Sun, 14 Jun 2020 03:10:58 +0000 (05:10 +0200)]
media: exynos4-is: Fix a reference count leak due to pm_runtime_get_sync

On calling pm_runtime_get_sync() the reference count of the device
is incremented. In case of failure, decrement the
reference count before returning the error.

Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: exynos4-is: Fix a reference count leak
Qiushi Wu [Sun, 14 Jun 2020 03:01:11 +0000 (05:01 +0200)]
media: exynos4-is: Fix a reference count leak

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code, causing incorrect ref count if
pm_runtime_put_noidle() is not called in error handling paths.
Thus call pm_runtime_put_noidle() if pm_runtime_get_sync() fails.

Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: ti-vpe: Fix a missing check and reference count leak
Qiushi Wu [Sun, 14 Jun 2020 02:56:05 +0000 (04:56 +0200)]
media: ti-vpe: Fix a missing check and reference count leak

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code, causing incorrect ref count if
pm_runtime_put_noidle() is not called in error handling paths.
And also, when the call of function vpe_runtime_get() failed,
we won't call vpe_runtime_put().
Thus call pm_runtime_put_noidle() if pm_runtime_get_sync() fails
inside vpe_runtime_get().

Fixes: 4571912743ac ("[media] v4l: ti-vpe: Add VPE mem to mem driver")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: stm32-dcmi: Fix a reference count leak
Qiushi Wu [Sun, 14 Jun 2020 02:36:59 +0000 (04:36 +0200)]
media: stm32-dcmi: Fix a reference count leak

Calling pm_runtime_get_sync increments the counter even in case of
failure, causing incorrect ref count if pm_runtime_put is not
called in error handling paths. Thus replace the jump target
"err_release_buffers" by "err_pm_putw".

Fixes: 152e0bf60219 ("media: stm32-dcmi: add power saving support")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: s5p-mfc: Fix a reference count leak
Qiushi Wu [Sun, 14 Jun 2020 02:31:22 +0000 (04:31 +0200)]
media: s5p-mfc: Fix a reference count leak

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code, causing incorrect ref count if
pm_runtime_put_noidle() is not called in error handling paths.
Thus call pm_runtime_put_noidle() if pm_runtime_get_sync() fails.

Fixes: c5086f130a77 ("[media] s5p-mfc: Use clock gating only on MFC v5 hardware")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: camss: Fix a reference count leak.
Qiushi Wu [Sat, 13 Jun 2020 23:27:12 +0000 (01:27 +0200)]
media: camss: Fix a reference count leak.

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code, causing incorrect ref count if
PM runtime put is not called in error handling paths.
Thus call pm_runtime_put_sync() if pm_runtime_get_sync() fails.

Fixes: 02afa816dbbf ("media: camss: Add basic runtime PM support")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: platform: fcp: Fix a reference count leak.
Qiushi Wu [Sat, 13 Jun 2020 23:19:44 +0000 (01:19 +0200)]
media: platform: fcp: Fix a reference count leak.

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code, causing incorrect ref count if
pm_runtime_put_noidle() is not called in error handling paths.
Thus call pm_runtime_put_noidle() if pm_runtime_get_sync() fails.

Fixes: 6eaafbdb668b ("[media] v4l: rcar-fcp: Keep the coding style consistent")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: rockchip/rga: Fix a reference count leak.
Qiushi Wu [Sat, 13 Jun 2020 23:13:49 +0000 (01:13 +0200)]
media: rockchip/rga: Fix a reference count leak.

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code. Thus call pm_runtime_put_noidle()
if pm_runtime_get_sync() fails.

Fixes: f7e7b48e6d79 ("[media] rockchip/rga: v4l2 m2m support")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: rcar-vin: Fix a reference count leak.
Qiushi Wu [Sat, 13 Jun 2020 23:04:32 +0000 (01:04 +0200)]
media: rcar-vin: Fix a reference count leak.

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code. Thus call pm_runtime_put_noidle()
if pm_runtime_get_sync() fails.

Fixes: 2a18fbec1dab ("media: rcar-vin: Move pm_runtime_{get,put} out of helpers")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: rcar-vin: Fix a reference count leak.
Qiushi Wu [Sat, 13 Jun 2020 22:30:08 +0000 (00:30 +0200)]
media: rcar-vin: Fix a reference count leak.

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code. Thus call pm_runtime_put_noidle()
if pm_runtime_get_sync() fails.

Fixes: 90dedce9bc54 ("media: rcar-vin: add function to manipulate Gen3 chsel value")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vsp1: Fix runtime PM imbalance on error
Dinghao Liu [Mon, 8 Jun 2020 05:29:19 +0000 (07:29 +0200)]
media: vsp1: Fix runtime PM imbalance on error

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code. Thus a pairing decrement is needed on
the error handling path to keep the counter balanced.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
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+huawei@kernel.org>
3 years agomedia: coda: Fix runtime PM imbalance in coda_probe
Dinghao Liu [Mon, 25 May 2020 13:02:06 +0000 (15:02 +0200)]
media: coda: Fix runtime PM imbalance in coda_probe

When coda_firmware_request() returns an error code,
a pairing runtime PM usage counter decrement is needed
to keep the counter balanced.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: platform: s3c-camif: Fix runtime PM imbalance on error
Dinghao Liu [Thu, 21 May 2020 13:29:33 +0000 (15:29 +0200)]
media: platform: s3c-camif: Fix runtime PM imbalance on error

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code. Thus a pairing decrement is needed on
the error handling path to keep the counter balanced.

Also, call pm_runtime_disable() when pm_runtime_get_sync() returns
an error code.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Reviewed-by: Sylwester Nawrocki <snawrocki@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: platform: sti: hva: Fix runtime PM imbalance on error
Dinghao Liu [Thu, 21 May 2020 10:05:02 +0000 (12:05 +0200)]
media: platform: sti: hva: Fix runtime PM imbalance on error

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code. Thus a pairing decrement is needed on
the error handling path to keep the counter balanced.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: bdisp: Fix runtime PM imbalance on error
Dinghao Liu [Thu, 21 May 2020 10:00:21 +0000 (12:00 +0200)]
media: bdisp: Fix runtime PM imbalance on error

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code. Thus a pairing decrement is needed on
the error handling path to keep the counter balanced.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Reviewed-by: Fabien Dessenne <fabien.dessenne@st.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: rcar-vin: Enable YDS bit depending on bus_width and data_shift
Lad Prabhakar [Sun, 13 Sep 2020 18:16:08 +0000 (20:16 +0200)]
media: rcar-vin: Enable YDS bit depending on bus_width and data_shift

Enable YDS bit if bus_width and data_shift is set to 8 in parallel mode
for MEDIA_BUS_FMT_UYVY8_2X8 format.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.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>
3 years agomedia: rcar-vin: Enable support for R8A774E1
Lad Prabhakar [Thu, 16 Jul 2020 17:18:34 +0000 (19:18 +0200)]
media: rcar-vin: Enable support for R8A774E1

Add the SoC specific information for RZ/G2H (R8A774E1) SoC. Also add
the routing information between CSI2 and VIN (which is similar to
R-Car H3 except it lacks CSI41).

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Marian-Cristian Rotariu <marian-cristian.rotariu.rb@bp.renesas.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: rcar-csi2: Enable support for R8A774E1
Lad Prabhakar [Thu, 16 Jul 2020 17:18:33 +0000 (19:18 +0200)]
media: rcar-csi2: Enable support for R8A774E1

Add the MIPI CSI-2 driver support for RZ/G2H (R8A774E1) SoC.
The CSI-2 module of RZ/G2H is similar to R-Car H3.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Marian-Cristian Rotariu <marian-cristian.rotariu.rb@bp.renesas.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: dt-bindings: media: renesas,vin: Add R8A774E1 support
Lad Prabhakar [Thu, 16 Jul 2020 17:18:32 +0000 (19:18 +0200)]
media: dt-bindings: media: renesas,vin: Add R8A774E1 support

Document support for the VIN module in the Renesas RZ/G2H (R8A774E1) SoC.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Marian-Cristian Rotariu <marian-cristian.rotariu.rb@bp.renesas.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: dt-bindings: media: renesas,csi2: Add R8A774E1 support
Lad Prabhakar [Thu, 16 Jul 2020 17:18:31 +0000 (19:18 +0200)]
media: dt-bindings: media: renesas,csi2: Add R8A774E1 support

Add the compatible string for RZ/G2H (R8A774E1) to the list of supported
SoCs.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Marian-Cristian Rotariu <marian-cristian.rotariu.rb@bp.renesas.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: media/pci: prevent memory leak in bttv_probe
Xiaolong Huang [Fri, 17 Apr 2020 09:52:30 +0000 (11:52 +0200)]
media: media/pci: prevent memory leak in bttv_probe

In bttv_probe if some functions such as pci_enable_device,
pci_set_dma_mask and request_mem_region fails the allocated
 memory for btv should be released.

Signed-off-by: Xiaolong Huang <butterflyhuangxx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: saa7134: use generic power management
Vaibhav Gupta [Mon, 22 Jun 2020 12:02:30 +0000 (14:02 +0200)]
media: saa7134: use generic power management

With the support of generic PM callbacks, drivers no longer need to use
legacy .suspend() and .resume() in which they had to maintain PCI states
changes and device's power state themselves. The required operations are
done by PCI core.

Compile-tested only.

Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: rcar-vin: Kconfig: Update help description for VIDEO_RCAR_VIN config
Lad Prabhakar [Tue, 15 Sep 2020 18:20:27 +0000 (20:20 +0200)]
media: rcar-vin: Kconfig: Update help description for VIDEO_RCAR_VIN config

The rcar-vin driver also supports RZ/G{1,2} SoC's, update the description
to reflect this.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Chris Paterson <Chris.Paterson2@renesas.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: rcar-vin: Kconfig: Update help description for VIDEO_RCAR_CSI2 config
Lad Prabhakar [Tue, 15 Sep 2020 18:20:26 +0000 (20:20 +0200)]
media: rcar-vin: Kconfig: Update help description for VIDEO_RCAR_CSI2 config

The rcar-csi2 driver also supports RZ/G2 SoC's, update the description
to reflect this.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Chris Paterson <Chris.Paterson2@renesas.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: rcar-fcp: Update description for VIDEO_RENESAS_FCP Kconfig entry
Lad Prabhakar [Fri, 11 Sep 2020 10:10:46 +0000 (12:10 +0200)]
media: rcar-fcp: Update description for VIDEO_RENESAS_FCP Kconfig entry

The rcar-fcp driver is also used on Renesas RZ/G2 SoCs. Update the
Kconfig entry description to reflect this.

[hverkuil: incorporated Laurent's suggestions for subject and commit log]

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Chris Paterson <Chris.Paterson2@renesas.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>
3 years agomedia: dt-bindings: media: renesas,vin: Add device tree support for r8a7742
Lad Prabhakar [Mon, 7 Sep 2020 14:45:08 +0000 (16:45 +0200)]
media: dt-bindings: media: renesas,vin: Add device tree support for r8a7742

Add compatible string for r8a7742. No driver change is needed as
"renesas,rcar-gen2-vin" will activate the right code.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: videobuf2: use sgtable-based scatterlist wrappers
Marek Szyprowski [Fri, 4 Sep 2020 13:17:11 +0000 (15:17 +0200)]
media: videobuf2: use sgtable-based scatterlist wrappers

Use recently introduced common wrappers operating directly on the struct
sg_table objects and scatterlist page iterators to make the code a bit
more compact, robust, easier to follow and copy/paste safe.

No functional change, because the code already properly did all the
scatterlist related calls.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: pci: fix common ALSA DMA-mapping related codes
Marek Szyprowski [Fri, 4 Sep 2020 13:17:10 +0000 (15:17 +0200)]
media: pci: fix common ALSA DMA-mapping related codes

The Documentation/DMA-API-HOWTO.txt states that dma_map_sg returns the
numer of the created entries in the DMA address space. However the
subsequent calls to dma_sync_sg_for_{device,cpu} and dma_unmap_sg must be
called with the original number of entries passed to dma_map_sg. The
sg_table->nents in turn holds the result of the dma_map_sg call as stated
in include/linux/scatterlist.h. Adapt the code to obey those rules.

While touching this code, update it to use the modern DMA_FROM_DEVICE
definitions.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: marvell-ccic: mmp: mark PM functions as __maybe_unused
Wei Yongjun [Wed, 9 Sep 2020 11:29:21 +0000 (13:29 +0200)]
media: marvell-ccic: mmp: mark PM functions as __maybe_unused

The suspend/resume functions have no callers depending on
configuration, so they must be marked __maybe_unused to
avoid these harmless warnings:

drivers/media/platform/marvell-ccic/mmp-driver.c:347:12: warning:
 'mmpcam_resume' defined but not used [-Wunused-function]
  347 | static int mmpcam_resume(struct device *dev)
      |            ^~~~~~~~~~~~~
drivers/media/platform/marvell-ccic/mmp-driver.c:338:12: warning:
 'mmpcam_suspend' defined but not used [-Wunused-function]
  338 | static int mmpcam_suspend(struct device *dev)
      |            ^~~~~~~~~~~~~~

Fixes: 55cd34524aa3 ("media: marvell-ccic: add support for runtime PM")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: MAINTAINERS: media: cec: fix files location
Corentin Labbe [Fri, 4 Sep 2020 11:27:54 +0000 (13:27 +0200)]
media: MAINTAINERS: media: cec: fix files location

Files have moved, fixes their paths.

Fixes: 4be5e8648b0c ("media: move CEC platform drivers to a separate directory")
Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: tc358743: cleanup tc358743_cec_isr
Tom Rix [Wed, 2 Sep 2020 18:32:12 +0000 (20:32 +0200)]
media: tc358743: cleanup tc358743_cec_isr

tc358743_cec_isr is misnammed, it is not the main isr.
So rename it to be consistent with its siblings,
tc358743_cec_handler.

It also does not check if its input parameter 'handled' is
is non NULL like its siblings, so add a check.

Fixes: a0ec8d1dc42e ("media: tc358743: add CEC support")
Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: cec-adap.c: add 'unregistered' checks
Hans Verkuil [Tue, 8 Sep 2020 10:26:11 +0000 (12:26 +0200)]
media: cec-adap.c: add 'unregistered' checks

Make the code a bit more robust by checking if the adapter has
been unregistered at the start of cec_transmit_msg_fh() and
cec_received_msg_ts(). If it is unregistered, then just return.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: cec-core.c: stop kthread_config before kthread
Hans Verkuil [Tue, 8 Sep 2020 10:26:10 +0000 (12:26 +0200)]
media: cec-core.c: stop kthread_config before kthread

The kthread_config relies on the main kthread (message processing
loop) to be present, so stop kthread_config before kthread.

It's unlikely to be a problem (and I've never seen any issues), but
if nothing else it makes sense to stop the threads in this order.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: tegra-video: Fix compilation warning of unused variable
Sowjanya Komatineni [Mon, 31 Aug 2020 15:37:38 +0000 (17:37 +0200)]
media: tegra-video: Fix compilation warning of unused variable

vi_pattern_strings is used only when CONFIG_VIDEO_TEGRA_TPG is
enabled and V4L2 control operations currently are used only in
TPG mode.

So when tegra-video is build for non TPG, warnings of unused
variable is reported for v4l2 control operation variable.

This patch fixes it.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Sowjanya Komatineni <skomatineni@nvidia.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: tc358743: initialize variable
Tom Rix [Sun, 30 Aug 2020 16:30:43 +0000 (18:30 +0200)]
media: tc358743: initialize variable

clang static analysis flags this error

tc358743.c:1468:9: warning: Branch condition evaluates
  to a garbage value
        return handled ? IRQ_HANDLED : IRQ_NONE;
               ^~~~~~~
handled should be initialized to false.

Fixes: d747b806abf4 ("[media] tc358743: add direct interrupt handling")
Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: mtk-mdp: Fix Null pointer dereference when calling list_add
Dafna Hirschfeld [Fri, 28 Aug 2020 13:55:41 +0000 (15:55 +0200)]
media: mtk-mdp: Fix Null pointer dereference when calling list_add

In list_add, the first variable is the new node and the second
is the list head. The function is called with a wrong order causing
NULL dereference:

[   15.527030] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008
[   15.542317] Mem abort info:
[   15.545152]   ESR = 0x96000044
[   15.548248]   EC = 0x25: DABT (current EL), IL = 32 bits
[   15.553624]   SET = 0, FnV = 0
[   15.556715]   EA = 0, S1PTW = 0
[   15.559892] Data abort info:
[   15.562799]   ISV = 0, ISS = 0x00000044
[   15.566678]   CM = 0, WnR = 1
[   15.569683] user pgtable: 4k pages, 48-bit VAs, pgdp=00000001373f0000
[   15.576196] [0000000000000008] pgd=0000000000000000, p4d=0000000000000000
[   15.583101] Internal error: Oops: 96000044 [#1] PREEMPT SMP
[   15.588747] Modules linked in: mtk_mdp(+) cfg80211 v4l2_mem2mem videobuf2_vmalloc videobuf2_dma_contig videobuf2_memops videobuf2_v4l2 videobuf2_common vide
odev mt8173_rt5650 smsc95xx usbnet ecdh_generic ecc snd_soc_rt5645 mc mt8173_afe_pcm rfkill cros_ec_sensors snd_soc_mtk_common elan_i2c crct10dif_ce cros_ec_se
nsors_core snd_soc_rl6231 elants_i2c industrialio_triggered_buffer kfifo_buf mtk_vpu cros_ec_chardev cros_usbpd_charger cros_usbpd_logger sbs_battery display_c
onnector pwm_bl ip_tables x_tables ipv6
[   15.634295] CPU: 0 PID: 188 Comm: systemd-udevd Not tainted 5.9.0-rc2+ #69
[   15.641242] Hardware name: Google Elm (DT)
[   15.645381] pstate: 20000005 (nzCv daif -PAN -UAO BTYPE=--)
[   15.651022] pc : mtk_mdp_probe+0x134/0x3a8 [mtk_mdp]
[   15.656041] lr : mtk_mdp_probe+0x128/0x3a8 [mtk_mdp]
[   15.661055] sp : ffff80001255b910
[   15.669548] x29: ffff80001255b910 x28: 0000000000000000
[   15.679973] x27: ffff800009089bf8 x26: ffff0000fafde800
[   15.690347] x25: ffff0000ff7d2768 x24: ffff800009089010
[   15.700670] x23: ffff0000f01a7cd8 x22: ffff0000fafde810
[   15.710940] x21: ffff0000f01a7c80 x20: ffff0000f0c3c180
[   15.721148] x19: ffff0000ff7f1618 x18: 0000000000000010
[   15.731289] x17: 0000000000000000 x16: 0000000000000000
[   15.741375] x15: 0000000000aaaaaa x14: 0000000000000020
[   15.751399] x13: 00000000ffffffff x12: 0000000000000020
[   15.761363] x11: 0000000000000028 x10: 0101010101010101
[   15.771279] x9 : 0000000000000004 x8 : 7f7f7f7f7f7f7f7f
[   15.781148] x7 : 646bff6171606b2b x6 : 0000000000806d65
[   15.790981] x5 : ffff0000ff7f8360 x4 : 0000000000000000
[   15.800767] x3 : 0000000000000004 x2 : 0000000000000001
[   15.810501] x1 : 0000000000000005 x0 : 0000000000000000
[   15.820171] Call trace:
[   15.826944]  mtk_mdp_probe+0x134/0x3a8 [mtk_mdp]
[   15.835908]  platform_drv_probe+0x54/0xa8
[   15.844247]  really_probe+0xe4/0x3b0
[   15.852104]  driver_probe_device+0x58/0xb8
[   15.860457]  device_driver_attach+0x74/0x80
[   15.868854]  __driver_attach+0x58/0xe0
[   15.876770]  bus_for_each_dev+0x70/0xc0
[   15.884726]  driver_attach+0x24/0x30
[   15.892374]  bus_add_driver+0x14c/0x1f0
[   15.900295]  driver_register+0x64/0x120
[   15.908168]  __platform_driver_register+0x48/0x58
[   15.916864]  mtk_mdp_driver_init+0x20/0x1000 [mtk_mdp]
[   15.925943]  do_one_initcall+0x54/0x1b4
[   15.933662]  do_init_module+0x54/0x200
[   15.941246]  load_module+0x1cf8/0x22d0
[   15.948798]  __do_sys_finit_module+0xd8/0xf0
[   15.956829]  __arm64_sys_finit_module+0x20/0x30
[   15.965082]  el0_svc_common.constprop.0+0x6c/0x168
[   15.973527]  do_el0_svc+0x24/0x90
[   15.980403]  el0_sync_handler+0x90/0x198
[   15.987867]  el0_sync+0x158/0x180
[   15.994653] Code: 9400014b 2a0003fc 35000920 f9400280 (f9000417)
[   16.004299] ---[ end trace 76fee0203f9898e5 ]---

Fixes: 86698b9505bbc ("media: mtk-mdp: convert mtk_mdp_dev.comp array to list")
Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Tested-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: staging: rkisp1: rsz: set flags to 0 in enum_mbus_code cb
Dafna Hirschfeld [Thu, 27 Aug 2020 19:46:12 +0000 (21:46 +0200)]
media: staging: rkisp1: rsz: set flags to 0 in enum_mbus_code cb

The resizer calls the enum_mbus_code cb on the source pad of
the isp entity since they support the same formats.
The only difference is that the isp entity allows setting the
quantization and sets the flag V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION.
The resizer should therefore set the flags to 0.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: staging: rkisp1: allow quantization setting by userspace on the isp source pad
Dafna Hirschfeld [Thu, 27 Aug 2020 19:46:11 +0000 (21:46 +0200)]
media: staging: rkisp1: allow quantization setting by userspace on the isp source pad

The isp entity has hardware support to force full range quantization
for YUV formats. Use the subdev CSC API to allow userspace to set the
quantization for YUV formats on the isp entity.

- The flag V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION is set for
YUV formats during enumeration of the isp formats on the source pad.
- The full quantization is set on YUV formats if userspace asks it
on the isp entity using the flag V4L2_MBUS_FRAMEFMT_SET_CSC.

On the capture and the resizer, the quantization is read-only
and always set to the default quantization.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: v4l2: extend the CSC API to subdevice.
Dafna Hirschfeld [Thu, 27 Aug 2020 19:46:10 +0000 (21:46 +0200)]
media: v4l2: extend the CSC API to subdevice.

This patch extends the CSC API in video devices to be supported
also on sub-devices. The flag V4L2_MBUS_FRAMEFMT_SET_CSC set by
the application when calling VIDIOC_SUBDEV_S_FMT ioctl.
The flags:

V4L2_SUBDEV_MBUS_CODE_CSC_COLORSPACE,
V4L2_SUBDEV_MBUS_CODE_CSC_XFER_FUNC,
V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC/V4L2_SUBDEV_MBUS_CODE_CSC_HSV_ENC
V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION

are set by the driver in the VIDIOC_SUBDEV_ENUM_MBUS_CODE ioctl.

New 'flags' fields were added to the structs
v4l2_subdev_mbus_code_enum, v4l2_mbus_framefmt which are borrowed
from the 'reserved' field

The patch also replaces the 'ycbcr_enc' field in
'struct v4l2_mbus_framefmt' with a union that includes 'hsv_enc'

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
3 years agomedia: vivid: Add support to the CSC API
Dafna Hirschfeld [Thu, 27 Aug 2020 19:46:09 +0000 (21:46 +0200)]
media: vivid: Add support to the CSC API

The CSC API (Colorspace conversion) allows userspace to try
to configure the colorspace, transfer function, Y'CbCr/HSV encoding
and the quantization for capture devices. This patch adds support
to the CSC API in vivid.
Using the CSC API, userspace is allowed to do the following:

- Set the colorspace.
- Set the xfer_func.
- Set the ycbcr_enc function for YUV formats.
- Set the hsv_enc function for HSV formats
- Set the quantization for YUV and RGB formats.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>