linux-2.6-block.git
7 months agomedia: staging: imx: controls are from another device, mark this
Hans Verkuil [Wed, 17 Jan 2024 11:46:45 +0000 (12:46 +0100)]
media: staging: imx: controls are from another device, mark this

The last argument of v4l2_ctrl_add_handler() indicates whether the controls
you add are from a control handler owned by another driver (true) or from
the same driver (false). In this case the last argument was incorrectly set
to false. The control handlers are from different devices.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: dvb-frontends: Clean up errors in tda8083.h
XueBing Chen [Thu, 11 Jan 2024 11:08:46 +0000 (11:08 +0000)]
media: dvb-frontends: Clean up errors in tda8083.h

Fix the following errors reported by checkpatch:

ERROR: "foo* bar" should be "foo *bar"

Signed-off-by: XueBing Chen <chenxb_99091@126.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: Clean up errors in bcm3510_priv.h
XueBing Chen [Thu, 11 Jan 2024 11:07:03 +0000 (11:07 +0000)]
media: Clean up errors in bcm3510_priv.h

Fix the following errors reported by checkpatch:

ERROR: space prohibited before that ',' (ctx:WxW)

Signed-off-by: XueBing Chen <chenxb_99091@126.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: stv6110x: Clean up errors in stv6110x.h
XueBing Chen [Thu, 11 Jan 2024 11:03:15 +0000 (11:03 +0000)]
media: stv6110x: Clean up errors in stv6110x.h

Fix the following errors reported by checkpatch:

ERROR: space prohibited before that ',' (ctx:WxW)

Signed-off-by: XueBing Chen <chenxb_99091@126.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: dvb-frontends: Clean up errors in cx24110.h
XueBing Chen [Thu, 11 Jan 2024 11:01:32 +0000 (11:01 +0000)]
media: dvb-frontends: Clean up errors in cx24110.h

Fix the following errors reported by checkpatch:

ERROR: "foo* bar" should be "foo *bar"

Signed-off-by: XueBing Chen <chenxb_99091@126.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: zl10036: Fix my email address
Matthias Schwarzott [Mon, 8 Jan 2024 16:57:14 +0000 (17:57 +0100)]
media: zl10036: Fix my email address

It has been wrong from the beginning.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Reported-by: Ulrich Mueller <ulm@gentoo.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: pvrusb2: Use wait_event_freezable() for freezable kthread
Kevin Hao [Thu, 21 Dec 2023 02:22:28 +0000 (10:22 +0800)]
media: pvrusb2: Use wait_event_freezable() for freezable kthread

A freezable kernel thread can enter frozen state during freezing by
either calling try_to_freeze() or using wait_event_freezable() and its
variants. So for the following snippet of code in a kernel thread loop:
  try_to_freeze();
  wait_event_interruptible();

We can change it to a simple wait_event_freezable() and then eliminate
a function call.

Signed-off-by: Kevin Hao <haokexin@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: msp3400: Use wait_event_freezable_timeout() in msp_sleep()
Kevin Hao [Thu, 21 Dec 2023 02:22:27 +0000 (10:22 +0800)]
media: msp3400: Use wait_event_freezable_timeout() in msp_sleep()

The msp_sleep() is nearly open-coded wait_event_interruptible_timeout(),
and a freezable kernel thread can enter frozen state during freezing by
either calling try_to_freeze() or using wait_event_freezable() and its
variants. So we can reimplement msp_sleep() to simply invoke
a wait_event_freezable_timeout() and then eliminate a call to
try_to_freeze().

Signed-off-by: Kevin Hao <haokexin@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: dvb_frontend: Use wait_event_freezable_timeout() for freezable kthread
Kevin Hao [Thu, 21 Dec 2023 02:22:26 +0000 (10:22 +0800)]
media: dvb_frontend: Use wait_event_freezable_timeout() for freezable kthread

A freezable kernel thread can enter frozen state during freezing by
either calling try_to_freeze() or using wait_event_freezable() and its
variants. So for the following snippet of code in a kernel thread loop:
  wait_event_interruptible_timeout();
  try_to_freeze();

We can change it to a simple wait_event_freezable_timeout() and
then eliminate a function call.

Signed-off-by: Kevin Hao <haokexin@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: sun8i-di: Fix chroma difference threshold
Jernej Skrabec [Sat, 16 Dec 2023 13:34:22 +0000 (14:34 +0100)]
media: sun8i-di: Fix chroma difference threshold

While there is no good explanation what this value does, vendor driver
uses value 31 for it. Align driver with it.

Fixes: a4260ea49547 ("media: sun4i: Add H3 deinterlace driver")
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: sun8i-di: Fix power on/off sequences
Jernej Skrabec [Sat, 16 Dec 2023 13:34:21 +0000 (14:34 +0100)]
media: sun8i-di: Fix power on/off sequences

According to user manual, reset line should be deasserted before clocks
are enabled. Also fix power down sequence to be reverse of that.

Fixes: a4260ea49547 ("media: sun4i: Add H3 deinterlace driver")
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: sun8i-di: Fix coefficient writes
Jernej Skrabec [Sat, 16 Dec 2023 13:34:20 +0000 (14:34 +0100)]
media: sun8i-di: Fix coefficient writes

Currently coefficients are applied only once, since they don't change.
However, this is done before enable bit is set and thus it doesn't get
applied properly.

Fix that by applying coefficients after enable bit is set. While this
means that it will be done evey time, it doesn't bring much time
penalty.

Fixes: a4260ea49547 ("media: sun4i: Add H3 deinterlace driver")
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: cedrus: h265: Fix configuring bitstream size
Jernej Skrabec [Sat, 16 Dec 2023 13:09:25 +0000 (14:09 +0100)]
media: cedrus: h265: Fix configuring bitstream size

bit_size field holds size of slice, not slice + header. Because of HW
quirks, driver can't program in just slice, but also preceding header.
But that means that currently used bit_size is wrong (too small).
Instead, just use size of whole buffer. There is no harm in doing this.

Fixes: 86caab29da78 ("media: cedrus: Add HEVC/H.265 decoding support")
Suggested-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: mediatek: vcodec: Remove unneeded semicolon
Yang Li [Mon, 27 Nov 2023 00:58:33 +0000 (08:58 +0800)]
media: mediatek: vcodec: Remove unneeded semicolon

./drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c:569:2-3: Unneeded semicolon
./drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c:583:2-3: Unneeded semicolon
./drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c:599:2-3: Unneeded semicolon
./drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c:613:2-3: Unneeded semicolon
./drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c:633:2-3: Unneeded semicolon
./drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c:647:2-3: Unneeded semicolon
./drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c:683:2-3: Unneeded semicolon

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=7632
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: platform: rzg2l-cru: rzg2l-video: Fix start reception procedure
Biju Das [Tue, 13 Feb 2024 18:12:33 +0000 (18:12 +0000)]
media: platform: rzg2l-cru: rzg2l-video: Fix start reception procedure

As per section 35.3.1 Starting Reception for the MIPI CSI-2 Input on the
latest hardware manual (R01UH0914EJ0145 Rev.1.45) we need to supply all
the clocks and then release the CRU resets. Currently we are releasing
the resets and then supplying the clocks. So, fix the start reception
procedure.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20240213181233.242316-6-biju.das.jz@bp.renesas.com
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: platform: rzg2l-cru: rzg2l-csi2: Restructure vclk handling
Biju Das [Tue, 13 Feb 2024 18:12:32 +0000 (18:12 +0000)]
media: platform: rzg2l-cru: rzg2l-csi2: Restructure vclk handling

As per section 35.3.1 Starting Reception for the MIPI CSI-2 Input on the
latest hardware manual (R01UH0914EJ0145 Rev.1.45) we need to disable the
vclk before enabling the LINK reception and enable the vclk after enabling
the link Reception. So restructure vclk handling as per the HW manual.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20240213181233.242316-5-biju.das.jz@bp.renesas.com
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: platform: rzg2l-cru: rzg2l-video: Fix image processing initialization
Biju Das [Tue, 13 Feb 2024 18:12:31 +0000 (18:12 +0000)]
media: platform: rzg2l-cru: rzg2l-video: Fix image processing initialization

As per section 35.3.1 Starting Reception for the MIPI CSI-2 Input on the
latest hardware manual (R01UH0914EJ0140 Rev.1.40) it is mentioned that
initialize the AXI master first and then initialize the image processing.
Fix the start procedure as per the hardware manual.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20240213181233.242316-4-biju.das.jz@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: platform: rzg2l-cru: rzg2l-ip: Add delay after D-PHY reset
Biju Das [Tue, 13 Feb 2024 18:12:30 +0000 (18:12 +0000)]
media: platform: rzg2l-cru: rzg2l-ip: Add delay after D-PHY reset

As per section 35.3.1 Starting Reception for the MIPI CSI-2 Input on the
latest hardware manual (R01UH0914EJ0140 Rev.1.40) it is mentioned that
after DPHY reset, we need to wait for 1 msec or more before start
receiving data from the sensor. So add a delay after pre_streamon().

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20240213181233.242316-3-biju.das.jz@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: platform: rzg2l-cru: rzg2l-csi2: Switch to RUNTIME_PM_OPS()
Biju Das [Tue, 13 Feb 2024 18:12:29 +0000 (18:12 +0000)]
media: platform: rzg2l-cru: rzg2l-csi2: Switch to RUNTIME_PM_OPS()

Replace the old SET_RUNTIME_PM_OPS() helpers with its modern alternative
RUNTIME_PM_OPS(). The usage of pm_ptr and RUNTIME_PM_OPS() allows the
compiler to see where it's used but still drop the dead code. After this
we can get rid of the unnecessary '__maybe_unused' annotations on PM
functions.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20240213181233.242316-2-biju.das.jz@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: edia: dvbdev: fix a use-after-free
Zhipeng Lu [Sat, 3 Feb 2024 13:40:43 +0000 (14:40 +0100)]
media: edia: dvbdev: fix a use-after-free

In dvb_register_device, *pdvbdev is set equal to dvbdev, which is freed
in several error-handling paths. However, *pdvbdev is not set to NULL
after dvbdev's deallocation, causing use-after-frees in many places,
for example, in the following call chain:

budget_register
  |-> dvb_dmxdev_init
        |-> dvb_register_device
  |-> dvb_dmxdev_release
        |-> dvb_unregister_device
              |-> dvb_remove_device
                    |-> dvb_device_put
                          |-> kref_put

When calling dvb_unregister_device, dmxdev->dvbdev (i.e. *pdvbdev in
dvb_register_device) could point to memory that had been freed in
dvb_register_device. Thereafter, this pointer is transferred to
kref_put and triggering a use-after-free.

Link: https://lore.kernel.org/linux-media/20240203134046.3120099-1-alexious@zju.edu.cn
Fixes: b61901024776 ("V4L/DVB (5244): Dvbdev: fix illegal re-usage of fileoperations struct")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: docs: uAPI: dvb/decoder: completing the documentation
Stefan Herdler [Sun, 28 Jan 2024 23:32:44 +0000 (00:32 +0100)]
media: docs: uAPI: dvb/decoder: completing the documentation

The existing documentation of the legacy DVB Decoder API was incomplete.

Revising the documentation, adding missing parts and arranging the
documentation files new.

This patch contains the new index file and links to it.

Link: https://lore.kernel.org/linux-media/20240128233249.32794-2-herdler@nurfuerspam.de
Signed-off-by: Stefan Herdler <herdler@nurfuerspam.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: docs: uAPI: dvb/video: completing the documentation (function calls)
Stefan Herdler [Sun, 28 Jan 2024 23:32:49 +0000 (00:32 +0100)]
media: docs: uAPI: dvb/video: completing the documentation (function calls)

The existing documentation of the legacy DVB Decoder API was incomplete.

Revising the documentation, adding missing parts and arranging the
documentation files new.

This patch contains the documentation of the function calls defined in
video.h.

Link: https://lore.kernel.org/linux-media/20240128233249.32794-7-herdler@nurfuerspam.de
Signed-off-by: Stefan Herdler <herdler@nurfuerspam.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: docs: uAPI: dvb/video: completing the documentation (data types)
Stefan Herdler [Sun, 28 Jan 2024 23:32:48 +0000 (00:32 +0100)]
media: docs: uAPI: dvb/video: completing the documentation (data types)

The existing documentation of the legacy DVB Decoder API was incomplete.

Revising the documentation, adding missing parts and arranging the
documentation files new.

This patch contains the documentation of the data types defined in
video.h.

Link: https://lore.kernel.org/linux-media/20240128233249.32794-6-herdler@nurfuerspam.de
Signed-off-by: Stefan Herdler <herdler@nurfuerspam.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: docs: uAPI: dvb/audio: completing the documentation (function calls)
Stefan Herdler [Sun, 28 Jan 2024 23:32:47 +0000 (00:32 +0100)]
media: docs: uAPI: dvb/audio: completing the documentation (function calls)

The existing documentation of the legacy DVB Decoder API was incomplete.

Revising the documentation, adding missing parts and arranging the
documentation files new.

This patch contains the documentation of the function calls defined in
audio.h.

Link: https://lore.kernel.org/linux-media/20240128233249.32794-5-herdler@nurfuerspam.de
Signed-off-by: Stefan Herdler <herdler@nurfuerspam.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: docs: uAPI: dvb/audio: completing the documentation (data types)
Stefan Herdler [Sun, 28 Jan 2024 23:32:46 +0000 (00:32 +0100)]
media: docs: uAPI: dvb/audio: completing the documentation (data types)

The existing documentation of the legacy DVB Decoder API was incomplete.

Revising the documentation, adding missing parts and arranging the
documentation files new.

This patch contains the documentation of the data types defined in
audio.h.

Link: https://lore.kernel.org/linux-media/20240128233249.32794-4-herdler@nurfuerspam.de
Signed-off-by: Stefan Herdler <herdler@nurfuerspam.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: docs: uAPI: dvb/osd: completing the documentation
Stefan Herdler [Sun, 28 Jan 2024 23:32:45 +0000 (00:32 +0100)]
media: docs: uAPI: dvb/osd: completing the documentation

The existing documentation of the legacy DVB Decoder API was incomplete.

Revising the documentation, adding missing parts and arranging the
documentation files new.

This patch contains the documentation of osd.h.

Link: https://lore.kernel.org/linux-media/20240128233249.32794-3-herdler@nurfuerspam.de
Signed-off-by: Stefan Herdler <herdler@nurfuerspam.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: dvb: remove redundant assignment to variable ret
Colin Ian King [Tue, 16 Jan 2024 11:50:02 +0000 (12:50 +0100)]
media: dvb: remove redundant assignment to variable ret

The variable ret is being assigned a value but it isn't being
read afterwards. The assignment is redundant and so ret can be
removed. Also add spaces after , to clean up checkpatch warnings.

Cleans up clang scan build warning:
warning: Although the value stored to 'ret' is used in the
enclosing expression, the value is never actually read from
'ret' [deadcode.DeadStores]

Link: https://lore.kernel.org/linux-media/20240116115002.2265367-1-colin.i.king@gmail.com
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: dvb-frontends/dvb-pll: Remove usage of the deprecated ida_simple_xx() API
Christophe JAILLET [Thu, 11 Jan 2024 21:33:44 +0000 (22:33 +0100)]
media: dvb-frontends/dvb-pll: Remove usage of the deprecated ida_simple_xx() API

ida_alloc() and ida_free() should be preferred to the deprecated
ida_simple_get() and ida_simple_remove().

Note that the upper limit of ida_simple_get() is exclusive, but the one of
ida_alloc_max() is inclusive. So a -1 has been added when needed.

Link: https://lore.kernel.org/linux-media/920639b9e05775eea56ecb9cd5ed38ad292a96a8.1705008803.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: cx24110: clean up some coding style issues
XueBing Chen [Thu, 11 Jan 2024 10:58:56 +0000 (11:58 +0100)]
media: cx24110: clean up some coding style issues

Fix the following errors reported by checkpatch:

ERROR: "foo* bar" should be "foo *bar"
ERROR: spaces required around that '=' (ctx:VxV)
ERROR: space required after that ',' (ctx:VxV)

Link: https://lore.kernel.org/linux-media/20240111105856.14655-1-chenxb_99091@126.com
Signed-off-by: XueBing Chen <chenxb_99091@126.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: drivers/media/dvb-core: copy user arrays safely
Philipp Stanner [Thu, 2 Nov 2023 19:16:34 +0000 (20:16 +0100)]
media: drivers/media/dvb-core: copy user arrays safely

At several positions in dvb_frontend.c, memdup_user() is utilized to
copy userspace arrays. This is done without overflow checks.

Use the new wrapper memdup_array_user() to copy the arrays more safely.

Link: https://lore.kernel.org/linux-media/20231102191633.52592-2-pstanner@redhat.com
Suggested-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Philipp Stanner <pstanner@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: ov08x40: Reduce start streaming time
Jason Chen [Wed, 24 Jan 2024 14:43:01 +0000 (15:43 +0100)]
media: ov08x40: Reduce start streaming time

Because video duration involves calculating the streaming time, and i2c
communication incurs too many XTALK register settings every 4 bytes with
i2c START and STOP.

So we have opted switch to the i2c burst method.
This method involves writing the XTALK registers in the order of
the register block.

The start streaming time can be reduced from around 400ms to 150ms

[Sakari Ailus: Drop unneeded dev_dbg().]

Signed-off-by: Jason Chen <jason.z.chen@intel.com>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agoRevert "media: ov08x40: Reduce start streaming time"
Sakari Ailus [Sun, 4 Feb 2024 21:50:12 +0000 (23:50 +0200)]
Revert "media: ov08x40: Reduce start streaming time"

This reverts commit feb8831be9d468ee961289c6a275536a1ee0011c.

Commit feb8831be9d468ee961289c6a275536a1ee0011c contained unintentional
changes to Documentation/devicetree/bindings/media/video-interfaces.yaml
and arch/arm/boot/dts/ti/omap/omap3-n9.dts. Revert the entire patch.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: nxp: imx8-isi: Factor out a variable
Ricardo Ribalda [Sun, 28 Jan 2024 16:13:56 +0000 (16:13 +0000)]
media: nxp: imx8-isi: Factor out a variable

gcc-11 seems to believe that the coeffs variable can be used
uninitialized. Refactor the code and remove the cscen variable to
convince gcc that we are doing a good job.

drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c:218:20: warning: 'coeffs' may be used uninitialized in this function [-Wmaybe-uninitialized]

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/r/20240128-gcc-11-warnings-v1-1-52bbdf492049@chromium.org
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: nxp: imx8-isi: Mark all crossbar sink pads as MUST_CONNECT
Laurent Pinchart [Mon, 15 Jan 2024 02:16:29 +0000 (04:16 +0200)]
media: nxp: imx8-isi: Mark all crossbar sink pads as MUST_CONNECT

All the sink pads of the crossbar switch require an active link if
they're part of the pipeline. Mark them with the
MEDIA_PAD_FL_MUST_CONNECT flag to fail pipeline validation if they're
not connected. This allows removing a manual check when translating
streams.

Cc: stable@vger.kernel.org # 6.1
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: mc: Expand MUST_CONNECT flag to always require an enabled link
Laurent Pinchart [Sun, 14 Jan 2024 23:04:52 +0000 (01:04 +0200)]
media: mc: Expand MUST_CONNECT flag to always require an enabled link

The MEDIA_PAD_FL_MUST_CONNECT flag indicates that the pad requires an
enabled link to stream, but only if it has any link at all. This makes
little sense, as if a pad is part of a pipeline, there are very few use
cases for an active link to be mandatory only if links exist at all. A
review of in-tree drivers confirms they all need an enabled link for
pads marked with the MEDIA_PAD_FL_MUST_CONNECT flag.

Expand the scope of the flag by rejecting pads that have no links at
all. This requires modifying the pipeline build code to add those pads
to the pipeline.

Cc: stable@vger.kernel.org # 6.1
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: mc: Rename pad variable to clarify intent
Laurent Pinchart [Sun, 14 Jan 2024 22:30:02 +0000 (00:30 +0200)]
media: mc: Rename pad variable to clarify intent

The pad local variable in the media_pipeline_explore_next_link()
function is used to store the pad through which the entity has been
reached. Rename it to origin to reflect that and make the code easier to
read. This will be even more important in subsequent commits when
expanding the function with additional logic.

Cc: stable@vger.kernel.org # 6.1
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: mc: Add num_links flag to media_pad
Laurent Pinchart [Sun, 14 Jan 2024 22:30:02 +0000 (00:30 +0200)]
media: mc: Add num_links flag to media_pad

Maintain a counter of the links connected to a pad in the media_pad
structure. This helps checking if a pad is connected to anything, which
will be used in the pipeline building code.

Cc: stable@vger.kernel.org # 6.1
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: nxp: imx8-isi: Check whether crossbar pad is non-NULL before access
Marek Vasut [Fri, 1 Dec 2023 15:06:04 +0000 (16:06 +0100)]
media: nxp: imx8-isi: Check whether crossbar pad is non-NULL before access

When translating source to sink streams in the crossbar subdev, the
driver tries to locate the remote subdev connected to the sink pad. The
remote pad may be NULL, if userspace tries to enable a stream that ends
at an unconnected crossbar sink. When that occurs, the driver
dereferences the NULL pad, leading to a crash.

Prevent the crash by checking if the pad is NULL before using it, and
return an error if it is.

Cc: stable@vger.kernel.org # 6.1
Fixes: cf21f328fcaf ("media: nxp: Add i.MX8 ISI driver")
Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/r/20231201150614.63300-1-marex@denx.de
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: mc: Fix flags handling when creating pad links
Laurent Pinchart [Sun, 14 Jan 2024 22:24:12 +0000 (00:24 +0200)]
media: mc: Fix flags handling when creating pad links

The media_create_pad_link() function doesn't correctly clear reject link
type flags, nor does it set the DATA_LINK flag. It only works because
the MEDIA_LNK_FL_DATA_LINK flag's value is 0.

Fix it by returning an error if any link type flag is set. This doesn't
introduce any regression, as nobody calls the media_create_pad_link()
function with link type flags (easily checked by grepping for the flag
in the source code, there are very few hits).

Set the MEDIA_LNK_FL_DATA_LINK explicitly, which is a no-op that the
compiler will optimize out, but is still useful to make the code more
explicit and easier to understand.

Cc: stable@vger.kernel.org # 6.1
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: mc: Add local pad to pipeline regardless of the link state
Laurent Pinchart [Sun, 14 Jan 2024 13:55:40 +0000 (15:55 +0200)]
media: mc: Add local pad to pipeline regardless of the link state

When building pipelines by following links, the
media_pipeline_explore_next_link() function only traverses enabled
links. The remote pad of a disabled link is not added to the pipeline,
and neither is the local pad. While the former is correct as disabled
links should not be followed, not adding the local pad breaks processing
of the MEDIA_PAD_FL_MUST_CONNECT flag.

The MEDIA_PAD_FL_MUST_CONNECT flag is checked in the
__media_pipeline_start() function that iterates over all pads after
populating the pipeline. If the pad is not present, the check gets
skipped, rendering it useless.

Fix this by adding the local pad of all links regardless of their state,
only skipping the remote pad for disabled links.

Cc: stable@vger.kernel.org # 6.1
Fixes: ae219872834a ("media: mc: entity: Rewrite media_pipeline_start()")
Reported-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Closes: https://lore.kernel.org/linux-media/7658a15a-80c5-219f-2477-2a94ba6c6ba1@kontron.de
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: media-devnode: make media_bus_type const
Ricardo B. Marliere [Sat, 3 Feb 2024 15:31:27 +0000 (12:31 -0300)]
media: media-devnode: make media_bus_type const

Now that the driver core can properly handle constant struct bus_type,
move the media_bus_type variable to be a constant structure as well,
placing it into read-only memory which can not be modified at runtime.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: cec: make cec_bus_type const
Ricardo B. Marliere [Sat, 3 Feb 2024 15:31:26 +0000 (12:31 -0300)]
media: cec: make cec_bus_type const

Now that the driver core can properly handle constant struct bus_type,
move the cec_bus_type variable to be a constant structure as well,
placing it into read-only memory which can not be modified at runtime.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agodocumentation: media: vivid: Modify typo in documentation
Dorcas Anono Litunya [Sat, 3 Feb 2024 08:58:05 +0000 (11:58 +0300)]
documentation: media: vivid: Modify typo in documentation

Correct the default value of node_type vivid parameter to 0xe1d3d.

Signed-off-by: Dorcas Anono Litunya <anonolitunya@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: dt-bindings: techwell,tw9900: Fix port schema ref
Rob Herring [Fri, 2 Feb 2024 22:23:25 +0000 (16:23 -0600)]
media: dt-bindings: techwell,tw9900: Fix port schema ref

The port@0 node doesn't define any extra properties in the port or endpoint
nodes, so the $ref should be to "/properties/port" instead as it restricts
extra properties.

Fixes: 0f82ffa9a295 ("media: dt-bindings: media: i2c: Add bindings for TW9900")
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: atomisp: don't use sizeof(NULL)
Hans Verkuil [Fri, 2 Feb 2024 10:17:30 +0000 (11:17 +0100)]
media: atomisp: don't use sizeof(NULL)

Check the size of another pointer instead of NULL. This fixes this
smatch warning:

drivers/staging/media/atomisp/pci/sh_css.c:3609 ia_css_pipe_enqueue_buffer() warn: sizeof(NUMBER)?

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: atomisp: make dbgopt static
Hans Verkuil [Fri, 2 Feb 2024 09:21:20 +0000 (10:21 +0100)]
media: atomisp: make dbgopt static

This fixes a sparse warning:

drivers/staging/media/atomisp/pci/atomisp_drvfs.c:40:14: warning: symbol 'dbgopt' was not declared. Should it be static?

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: v4l2-common.h: kerneldoc: correctly format return values
Hans Verkuil [Fri, 2 Feb 2024 08:25:44 +0000 (09:25 +0100)]
media: v4l2-common.h: kerneldoc: correctly format return values

Building the kerneldoc resulted in two errors:

Documentation/media/driver-api/v4l2-common:6: ./include/media/v4l2-common.h:566: ERROR: Unexpected indentation.
Documentation/media/driver-api/v4l2-common:6: ./include/media/v4l2-common.h:567: WARNING: Block quote ends without a blank line; unexpected unindent.

Format v4l2_link_freq_to_bitmap according to the kerneldoc standard.
The v4l2_fill_pixfmt_mp function also had incorrect return value
formatting, although that didn't report an error/warning, but it looked
ugly in the generated documentation. So fix that one as well.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Fixes: a68e88e2cf9e ("media: v4l: Add a helper for setting up link-frequencies control")
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
7 months agomedia: v4l2-mem2mem: fix a memleak in v4l2_m2m_register_entity
Zhipeng Lu [Thu, 1 Feb 2024 12:48:44 +0000 (20:48 +0800)]
media: v4l2-mem2mem: fix a memleak in v4l2_m2m_register_entity

The entity->name (i.e. name) is allocated in v4l2_m2m_register_entity
but isn't freed in its following error-handling paths. This patch
adds such deallocation to prevent memleak of entity->name.

Fixes: be2fff656322 ("media: add helpers for memory-to-memory media controller")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: v4l2-tpg: fix some memleaks in tpg_alloc
Zhipeng Lu [Thu, 1 Feb 2024 12:47:53 +0000 (20:47 +0800)]
media: v4l2-tpg: fix some memleaks in tpg_alloc

In tpg_alloc, resources should be deallocated in each and every
error-handling paths, since they are allocated in for statements.
Otherwise there would be memleaks because tpg_free is called only when
tpg_alloc return 0.

Fixes: 63881df94d3e ("[media] vivid: add the Test Pattern Generator")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agoMAINTAINERS: Add entry for Samsung MFC DT Schema
Aakarsh Jain [Wed, 31 Jan 2024 07:07:41 +0000 (12:37 +0530)]
MAINTAINERS: Add entry for Samsung MFC DT Schema

Add device tree schema entry for Samsung MFC.

Signed-off-by: Aakarsh Jain <aakarsh.jain@samsung.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: staging: meson: Fix kerneldoc
Ricardo Ribalda [Fri, 26 Jan 2024 23:16:15 +0000 (23:16 +0000)]
media: staging: meson: Fix kerneldoc

Remove documentation from missing field.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: dvb-usb: Fix kerneldoc
Ricardo Ribalda [Fri, 26 Jan 2024 23:16:13 +0000 (23:16 +0000)]
media: dvb-usb: Fix kerneldoc

Remove kerneldoc from missing fields.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: samsung: s5p-mfc: Fix kerneldoc
Ricardo Ribalda [Fri, 26 Jan 2024 23:16:12 +0000 (23:16 +0000)]
media: samsung: s5p-mfc: Fix kerneldoc

Remove doc from missing fields.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: samsung: exynos4-is: Fix kerneldoc
Ricardo Ribalda [Fri, 26 Jan 2024 23:16:11 +0000 (23:16 +0000)]
media: samsung: exynos4-is: Fix kerneldoc

Remove doc from missing fields.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: qcom: venus: Fix kerneldoc
Ricardo Ribalda [Fri, 26 Jan 2024 23:16:10 +0000 (23:16 +0000)]
media: qcom: venus: Fix kerneldoc

Remove doc for missing field.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: verisilicon: Fix kerneldoc
Ricardo Ribalda [Fri, 26 Jan 2024 23:16:09 +0000 (23:16 +0000)]
media: verisilicon: Fix kerneldoc

The field is not part of the structure. Remove the doc.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: mediatek: vcodec: Fix kerneldoc
Ricardo Ribalda [Fri, 26 Jan 2024 23:16:08 +0000 (23:16 +0000)]
media: mediatek: vcodec: Fix kerneldoc

Those fields have been removed. They do not need to be documented.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: mediatek: jpeg: Fix kerneldoc
Ricardo Ribalda [Fri, 26 Jan 2024 23:16:07 +0000 (23:16 +0000)]
media: mediatek: jpeg: Fix kerneldoc

The field is gone, remove the documentation for it.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: i2c: adv748: Fix kerneldoc
Ricardo Ribalda [Fri, 26 Jan 2024 23:16:06 +0000 (23:16 +0000)]
media: i2c: adv748: Fix kerneldoc

The field is gone, remove the documentation.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: i2c: css-quirk.h: Fix kerneldoc
Ricardo Ribalda [Fri, 26 Jan 2024 23:16:05 +0000 (23:16 +0000)]
media: i2c: css-quirk.h: Fix kerneldoc

Kerneldoc does not seem to understand that embed doc:
drivers/media/i2c/ccs/ccs-quirk.h:50: warning: Excess struct member 'write' description in 'ccs_quirk'
drivers/media/i2c/ccs/ccs-quirk.h:50: warning: Excess struct member 'reg' description in 'ccs_quirk'
drivers/media/i2c/ccs/ccs-quirk.h:50: warning: Excess struct member 'val' description in 'ccs_quirk'

Convert into a standard doc.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: pci: dt315.h: Fix kerneldoc
Ricardo Ribalda [Fri, 26 Jan 2024 23:16:04 +0000 (23:16 +0000)]
media: pci: dt315.h: Fix kerneldoc

The field is gone, remove it.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: cec.h: Fix kerneldoc
Ricardo Ribalda [Fri, 26 Jan 2024 23:16:03 +0000 (23:16 +0000)]
media: cec.h: Fix kerneldoc

The fields are gone, remove their documentation.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: videodev2.h: Fix kerneldoc
Ricardo Ribalda [Fri, 26 Jan 2024 23:16:01 +0000 (23:16 +0000)]
media: videodev2.h: Fix kerneldoc

Named nested unions need their prefix:
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#nested-structs-unions

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: cec: core: remove length check of Timer Status
Nini Song [Thu, 25 Jan 2024 13:28:45 +0000 (21:28 +0800)]
media: cec: core: remove length check of Timer Status

The valid_la is used to check the length requirements,
including special cases of Timer Status. If the length is
shorter than 5, that means no Duration Available is returned,
the message will be forced to be invalid.

However, the description of Duration Available in the spec
is that this parameter may be returned when these cases, or
that it can be optionally return when these cases. The key
words in the spec description are flexible choices.

Remove the special length check of Timer Status to fit the
spec which is not compulsory about that.

Signed-off-by: Nini Song <nini.song@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: v4l2-ctrls: show all owned controls in log_status
Hans Verkuil [Wed, 17 Jan 2024 14:52:04 +0000 (15:52 +0100)]
media: v4l2-ctrls: show all owned controls in log_status

VIDIOC_LOG_STATUS will log the controls owned by the driver. But the
code didn't take into account the case where a single driver creates
multiple control handlers. A good example is the vivid driver, but
others use it as well.

Modify v4l2_ctrl_handler_log_status() so that it really shows all
controls owned by this driver.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: cx231xx: controls are from another device, mark this
Hans Verkuil [Wed, 17 Jan 2024 11:44:03 +0000 (12:44 +0100)]
media: cx231xx: controls are from another device, mark this

The last argument of v4l2_ctrl_add_handler() indicates whether the controls
you add are from a control handler owned by another driver (true) or from
the same driver (false). In this case the last argument was incorrectly set
to false. The controls come from the cx25840 subdev.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: em28xx: annotate unchecked call to media_device_register()
Nikita Zhandarovich [Fri, 12 Jan 2024 13:42:26 +0000 (05:42 -0800)]
media: em28xx: annotate unchecked call to media_device_register()

Static analyzers generate alerts for an unchecked call to
`media_device_register()`. However, in this case, the device will work
reliably without the media controller API.

Add a comment above the call to prevent future unnecessary changes.

Suggested-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Fixes: 37ecc7b1278f ("[media] em28xx: add media controller support")
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: videobuf2: Fix doc comment
Andrzej Pietrasiewicz [Fri, 5 Jan 2024 12:54:37 +0000 (13:54 +0100)]
media: videobuf2: Fix doc comment

The documented struct member is called "planes" rather than "vb2_plane".
While at it, make the comments order follow struct members order.

Fixes: 2b1413245550 ("media: vb2-core: Improve kernel-doc markups")
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Acked-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: adv7180: Fix cppcheck errors
Bhavin Sharma [Tue, 2 Jan 2024 14:06:40 +0000 (19:36 +0530)]
media: adv7180: Fix cppcheck errors

ERROR: else should follow close brace '}'

Signed-off-by: Bhavin Sharma <bhavin.sharma@siliconsignals.io>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: xc4000: Fix atomicity violation in xc4000_get_frequency
Gui-Dong Han [Fri, 22 Dec 2023 05:50:30 +0000 (13:50 +0800)]
media: xc4000: Fix atomicity violation in xc4000_get_frequency

In xc4000_get_frequency():
*freq = priv->freq_hz + priv->freq_offset;
The code accesses priv->freq_hz and priv->freq_offset without holding any
lock.

In xc4000_set_params():
// Code that updates priv->freq_hz and priv->freq_offset
...

xc4000_get_frequency() and xc4000_set_params() may execute concurrently,
risking inconsistent reads of priv->freq_hz and priv->freq_offset. Since
these related data may update during reading, it can result in incorrect
frequency calculation, leading to atomicity violations.

This possible bug is found by an experimental static analysis tool
developed by our team, BassCheck[1]. This tool analyzes the locking APIs
to extract function pairs that can be concurrently executed, and then
analyzes the instructions in the paired functions to identify possible
concurrency bugs including data races and atomicity violations. The above
possible bug is reported when our tool analyzes the source code of
Linux 6.2.

To address this issue, it is proposed to add a mutex lock pair in
xc4000_get_frequency() to ensure atomicity. With this patch applied, our
tool no longer reports the possible bug, with the kernel configuration
allyesconfig for x86_64. Due to the lack of associated hardware, we cannot
test the patch in runtime testing, and just verify it according to the
code logic.

[1] https://sites.google.com/view/basscheck/

Fixes: 4c07e32884ab ("[media] xc4000: Fix get_frequency()")
Cc: stable@vger.kernel.org
Reported-by: BassCheck <bass@buaa.edu.cn>
Signed-off-by: Gui-Dong Han <2045gemini@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: verisilicon: Fix some typos
renjun wang [Sat, 16 Dec 2023 04:18:05 +0000 (12:18 +0800)]
media: verisilicon: Fix some typos

Function hantro_g1_h264_dec_prepare_table() does not exist,
should be replaced with hantro_h264_dec_init().

The register name av1_ulticore_tile_col confused sometimes,
although not be used corrently. The correct name should be
av1_multicore_tile_col.

Signed-off-by: renjun wang <renjunw0@foxmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: vidioc-subdev-g-client-cap.rst: document struct v4l2_subdev_client_capability
Hans Verkuil [Fri, 15 Dec 2023 09:38:29 +0000 (10:38 +0100)]
media: vidioc-subdev-g-client-cap.rst: document struct v4l2_subdev_client_capability

The struct v4l2_subdev_client_capability was never actually documented,
only the capability flags were documented.

Add this.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: pci: cx23885: check cx23885_vdev_init() return
Hans Verkuil [Thu, 19 Oct 2023 06:58:49 +0000 (08:58 +0200)]
media: pci: cx23885: check cx23885_vdev_init() return

cx23885_vdev_init() can return a NULL pointer, but that pointer
is used in the next line without a check.

Add a NULL pointer check and go to the error unwind if it is NULL.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reported-by: Sicong Huang <huangsicong@iie.ac.cn>
7 months agomedia: tc358746: fix the pll calculating function
Duc-Long, Le [Sun, 15 Oct 2023 00:19:46 +0000 (20:19 -0400)]
media: tc358746: fix the pll calculating function

Following formula of Pll_clk in 5.2 section, 50th page of
TC358746AXBG/748XBG/748IXBG Functional Specification Rev 1.1 document.
The formula of fout is as below:
fout = refclk * mul / (prediv * postdiv)

Remove "p" to avoid using 2 times of prediv in pll calculating function.

Signed-off-by: Duc-Long, Le <duclong.linux@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
7 months agomedia: ov08x40: Reduce start streaming time
Jason Chen [Wed, 24 Jan 2024 14:43:01 +0000 (15:43 +0100)]
media: ov08x40: Reduce start streaming time

Because video duration involves calculating the streaming time, and i2c
communication incurs too many XTALK register settings every 4 bytes with
i2c START and STOP.

So we have opted switch to the i2c burst method.
This method involves writing the XTALK registers in the order of
the register block.

The start streaming time can be reduced from around 400ms to 150ms

[Sakari Ailus: Drop unneeded dev_dbg().]

Signed-off-by: Jason Chen <jason.z.chen@intel.com>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: ov08x40: Modify the tline calculation in different modes
Jason Chen [Wed, 18 Oct 2023 05:58:41 +0000 (07:58 +0200)]
media: ov08x40: Modify the tline calculation in different modes

ov08x40 quad bayer sensor ISP has the following work modes:
- normal mode: full size
- 2x2 binned mode: binning size

In normal and binned modes, different tline calculations are
applied.

- normal mode: Tline value needs to be doubled as per the
vendor's update.

Tline time = 2 * HTS / SCLK
Exposure unit : 1 * HTS = 0.5 Tline

- 2x2 binned mode:

Tline time = 1 * HTS / SCLK
Exposure unit : 1 * HTS = 1 Tline

Signed-off-by: Jason Chen <jason.z.chen@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: ov08x40: Avoid sensor probing in D0 state
Jason Chen [Mon, 22 Jan 2024 02:54:34 +0000 (03:54 +0100)]
media: ov08x40: Avoid sensor probing in D0 state

When the system enters the D0 state and attempt to probe the device,
another component, such as LED, will also be pulled high due to the
hardware design. It's advisable to keep the device being probed in
a different D state.

Signed-off-by: Jason Chen <jason.z.chen@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: imx355: Use v4l2_link_freq_to_bitmap helper
Sakari Ailus [Mon, 8 Jan 2024 15:18:05 +0000 (16:18 +0100)]
media: imx355: Use v4l2_link_freq_to_bitmap helper

Use the v4l2_link_freq_to_bitmap() helper to figure out which
driver-supported link freq can be used on a given system.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: imx319: Use v4l2_link_freq_to_bitmap helper
Sakari Ailus [Mon, 8 Jan 2024 15:18:04 +0000 (16:18 +0100)]
media: imx319: Use v4l2_link_freq_to_bitmap helper

Use the v4l2_link_freq_to_bitmap() helper to figure out which
driver-supported link freq can be used on a given system.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: imx334: Use v4l2_link_freq_to_bitmap helper
Sakari Ailus [Mon, 8 Jan 2024 15:18:03 +0000 (16:18 +0100)]
media: imx334: Use v4l2_link_freq_to_bitmap helper

Use the v4l2_link_freq_to_bitmap() helper to figure out which
driver-supported link frequencies can be used on a given system.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: v4l: Add a helper for setting up link-frequencies control
Sakari Ailus [Mon, 8 Jan 2024 15:18:02 +0000 (16:18 +0100)]
media: v4l: Add a helper for setting up link-frequencies control

Add a helper for obtaining supported link frequencies in form most drivers
need them. The result is a bitmap of supported controls.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: i2c: isl7998x: convert to use maple tree register cache
Bo Liu [Wed, 17 Jan 2024 03:09:10 +0000 (04:09 +0100)]
media: i2c: isl7998x: convert to use maple tree register cache

The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.

Signed-off-by: Bo Liu <liubo03@inspur.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: i2c: max2175: convert to use maple tree register cache
Bo Liu [Wed, 17 Jan 2024 03:10:24 +0000 (04:10 +0100)]
media: i2c: max2175: convert to use maple tree register cache

The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.

Signed-off-by: Bo Liu <liubo03@inspur.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: i2c: tvp5150: convert to use maple tree register cache
Bo Liu [Wed, 17 Jan 2024 03:11:34 +0000 (04:11 +0100)]
media: i2c: tvp5150: convert to use maple tree register cache

The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.

Signed-off-by: Bo Liu <liubo03@inspur.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: i2c: mt9v032: convert to use maple tree register cache
Bo Liu [Wed, 17 Jan 2024 03:11:05 +0000 (04:11 +0100)]
media: i2c: mt9v032: convert to use maple tree register cache

The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.

Signed-off-by: Bo Liu <liubo03@inspur.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: i2c: imx274: convert to use maple tree register cache
Bo Liu [Wed, 17 Jan 2024 03:08:25 +0000 (04:08 +0100)]
media: i2c: imx274: convert to use maple tree register cache

The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.

Signed-off-by: Bo Liu <liubo03@inspur.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: i2c: imx214: convert to use maple tree register cache
Bo Liu [Wed, 17 Jan 2024 03:07:30 +0000 (04:07 +0100)]
media: i2c: imx214: convert to use maple tree register cache

The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.

Signed-off-by: Bo Liu <liubo03@inspur.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: i2c: imx415: Add more clock configurations
Alexander Stein [Wed, 17 Jan 2024 07:39:36 +0000 (08:39 +0100)]
media: i2c: imx415: Add more clock configurations

Complete the list from "INCK Setting" section in IMX415-AAQR-C
(Rev. E19504, 2019/05/21). For consistency suffix all lane rate values by
UL, which is needed for 2376000000 anyway.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: i2c: imx415: Convert to new CCI register access helpers
Alexander Stein [Wed, 17 Jan 2024 07:39:35 +0000 (08:39 +0100)]
media: i2c: imx415: Convert to new CCI register access helpers

Use the new common CCI register access helpers to replace the private
register access helpers in the imx415 driver.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: v4l2: cci: print leading 0 on error
Julien Massot [Thu, 11 Jan 2024 13:20:03 +0000 (14:20 +0100)]
media: v4l2: cci: print leading 0 on error

In some error cases leading '0' for register address
were missing.

Fixes: 613cbb91e9ce ("media: Add MIPI CCI register access helper functions")
Signed-off-by: Julien Massot <julien.massot@collabora.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: i2c: st-vgxy61: Convert to CCI register access helpers
Julien Massot [Fri, 12 Jan 2024 09:52:28 +0000 (10:52 +0100)]
media: i2c: st-vgxy61: Convert to CCI register access helpers

Use the new common CCI register access helpers to replace the private
register access helpers in the st-vgxy61 driver. This simplifies the
driver by reducing the amount of code.

st-vgxy61 devices use little endianness arrangement, therefore
the driver uses the CCI_REGx_LE registers definition.

Signed-off-by: Julien Massot <julien.massot@collabora.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: tc358743: register v4l2 async device only after successful setup
Alexander Stein [Wed, 10 Jan 2024 09:01:11 +0000 (10:01 +0100)]
media: tc358743: register v4l2 async device only after successful setup

Ensure the device has been setup correctly before registering the v4l2
async device, thus allowing userspace to access.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Robert Foss <rfoss@kernel.org>
Fixes: 4c5211a10039 ("[media] tc358743: register v4l2 asynchronous subdevice")
Cc: stable@vger.kernel.org
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: Documentation: Rework CCS driver documentation
Sakari Ailus [Fri, 5 Jan 2024 10:59:22 +0000 (11:59 +0100)]
media: Documentation: Rework CCS driver documentation

Drop duplicated UAPI specific portions of the CCS (kernel) documentation
and fix a spelling error in UAPI documentation previously fixed in driver
documentation.

Also add references both ways.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: arm64: dts: st: add video encoder support to stm32mp255
Hugues Fruchet [Wed, 10 Jan 2024 10:46:42 +0000 (11:46 +0100)]
media: arm64: dts: st: add video encoder support to stm32mp255

Add VENC hardware video encoder support to STM32MP255.

Signed-off-by: Hugues Fruchet <hugues.fruchet@foss.st.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: arm64: dts: st: add video decoder support to stm32mp255
Hugues Fruchet [Wed, 10 Jan 2024 10:46:41 +0000 (11:46 +0100)]
media: arm64: dts: st: add video decoder support to stm32mp255

Add VDEC hardware video decoder support to STM32MP255.

Signed-off-by: Hugues Fruchet <hugues.fruchet@foss.st.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: hantro: add support for STM32MP25 VENC
Hugues Fruchet [Wed, 10 Jan 2024 10:46:40 +0000 (11:46 +0100)]
media: hantro: add support for STM32MP25 VENC

Add support for STM32MP25 VENC video hardware encoder.
Support of JPEG encoding.
VENC has its own reset/clock/irq.

Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hugues Fruchet <hugues.fruchet@foss.st.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: hantro: add support for STM32MP25 VDEC
Hugues Fruchet [Wed, 10 Jan 2024 10:46:39 +0000 (11:46 +0100)]
media: hantro: add support for STM32MP25 VDEC

Add support for STM32MP25 VDEC video hardware decoder.
Support of H264/VP8 decoding.
No post-processor support.
VDEC has its own reset/clock/irq.

Successfully tested up to full HD.

Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hugues Fruchet <hugues.fruchet@foss.st.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: dt-bindings: media: Document STM32MP25 VDEC & VENC video codecs
Hugues Fruchet [Wed, 10 Jan 2024 10:46:38 +0000 (11:46 +0100)]
media: dt-bindings: media: Document STM32MP25 VDEC & VENC video codecs

Add STM32MP25 VDEC video decoder & VENC video encoder bindings.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Hugues Fruchet <hugues.fruchet@foss.st.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: platform: mtk-mdp3: add support for parallel pipe to improve FPS
Moudy Ho [Wed, 20 Dec 2023 10:18:38 +0000 (11:18 +0100)]
media: platform: mtk-mdp3: add support for parallel pipe to improve FPS

In some chips, MDP3 has the ability to utilize two pipelines to
parallelly process a single frame.
To enable this feature, multiple CMDQ clients and packets need to
be configured at the same time.

Signed-off-by: Moudy Ho <moudy.ho@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
7 months agomedia: platform: mtk-mdp3: add mt8195 MDP3 component settings
Moudy Ho [Wed, 20 Dec 2023 10:18:37 +0000 (11:18 +0100)]
media: platform: mtk-mdp3: add mt8195 MDP3 component settings

Extend the component settings used in MT8195 MDP3.
Additionally, it is crucial to read all component settings in
a specific manner to ensure that shared memory data structure lengths
are aligned across different platforms.

Signed-off-by: Moudy Ho <moudy.ho@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>