]> www.infradead.org Git - linux.git/log
linux.git
10 months agomedia: atomisp: Use clamp() in ia_css_eed1_8_vmem_encode()
Christophe JAILLET [Sat, 27 Jul 2024 12:51:56 +0000 (14:51 +0200)]
media: atomisp: Use clamp() in ia_css_eed1_8_vmem_encode()

Using clamp() instead of min_t(max_t()) is easier to read.

It also reduces the size of the preprocessed files by ~ 193 ko.
(see [1] for a discussion about it)

$ ls -l ia_css_eed1_8.host*.i
 4829993 27 juil. 14:36 ia_css_eed1_8.host.old.i
 4636649 27 juil. 14:42 ia_css_eed1_8.host.new.i

[1]: https://lore.kernel.org/all/23bdb6fc8d884ceebeb6e8b8653b8cfe@AcuMS.aculab.com/

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/155aba6ab759e98f66349e6bb4f69e2410486c09.1722084704.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: atomisp: Fix eed1_8 code assigning signed values to an unsigned variable
Hans de Goede [Sat, 7 Sep 2024 11:17:01 +0000 (13:17 +0200)]
media: atomisp: Fix eed1_8 code assigning signed values to an unsigned variable

ia_css_eed1_8_vmem_encode() is assigning values with a range of -8192 -
8191 to e_dew_enh_y and e_dew_enh_a both of which are of the VMEM_ARRAY
type which maps to u16.

This causes the following smatch warnings:

drivers/staging/media/atomisp/pci/isp/kernels/eed1_8/ia_css_eed1_8.host.c: drivers/staging/media/atomisp/pci/isp/kernels/eed1_8/ia_css_eed1_8.host.c:177 ia_css_eed1_8_vmem_encode() warn: assigning (-8192) to unsigned variable 'to->e_dew_enh_y[0][base + j]'
drivers/staging/media/atomisp/pci/isp/kernels/eed1_8/ia_css_eed1_8.host.c: drivers/staging/media/atomisp/pci/isp/kernels/eed1_8/ia_css_eed1_8.host.c:182 ia_css_eed1_8_vmem_encode() warn: assigning (-8192) to unsigned variable 'to->e_dew_enh_a[0][base + j]'

Convert the e_dew_enh_y and e_dew_enh_a arrays to a new SVMEM_ARRAY type
which maps to s16 to fix this.

Link: https://lore.kernel.org/linux-media/20240907111701.8493-1-hdegoede@redhat.com
Reported-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Closes: https://lore.kernel.org/linux-media/20240906081542.5cb0c142@foz.lan/
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: atomisp: set lock before calling vb2_queue_init()
Hans Verkuil [Mon, 2 Sep 2024 14:04:47 +0000 (16:04 +0200)]
media: atomisp: set lock before calling vb2_queue_init()

The vb2_queue_init() will expect the vb2_queue lock pointer to be set in
the future. So for those drivers that set the lock later, move it up to
before the vb2_queue_init() call.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Link: https://lore.kernel.org/r/90b8e7a40c3ed306cbeb96c2f4dad97eb7e53bfd.1725285495.git.hverkuil-cisco@xs4all.nl
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: atomisp: Improve binary finding debug logging
Hans de Goede [Mon, 2 Sep 2024 09:52:29 +0000 (11:52 +0200)]
media: atomisp: Improve binary finding debug logging

The atomisp firmware contains a number of different pipeline binaries
inside its firmware file and the driver selects the right one depending
on the selected pipeline configuration.

Sometimes (e.g. when the selected output resolution is too big) it fails
to find a binary. This happens especially when adding support for new
sensors.

Improve the logging when this happens to make debugging easier:

1. Replace ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, ...) with standard
   dev_dbg() calls so that the logs can be enabled with dyndbg

2. Do not dump_stack() when this fails, doing so adds no useful extra
   info

3. With the dump_stack() call gone, remove the wrapper and rename
   __ia_css_binary_find() to ia_css_binary_find()

4. On error use dev_err() instead of dev_dbg() so that when things
   fail it is clear why they fail without needing to enable dyndbg

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20240902095229.59059-3-hdegoede@redhat.com
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: atomisp: Drop dev_dbg() calls from hmm_[alloc|free]()
Hans de Goede [Mon, 2 Sep 2024 09:52:28 +0000 (11:52 +0200)]
media: atomisp: Drop dev_dbg() calls from hmm_[alloc|free]()

Debug logging every alloc + free just polutes the debug logs without
adding much value, remove the alloc + free dev_dbg() calls.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://lore.kernel.org/r/20240902095229.59059-2-hdegoede@redhat.com
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: atomisp: csi2-bridge: Add DMI quirk for t4ka3 on Xiaomi Mipad2
Hans de Goede [Mon, 2 Sep 2024 09:52:27 +0000 (11:52 +0200)]
media: atomisp: csi2-bridge: Add DMI quirk for t4ka3 on Xiaomi Mipad2

The t4ka3 sensor on the Xiaomi Mipad2 is used as a back facing sensor,
it uses 4 CSI lanes, but the _DSM has CsiLanes set to 2. Extend
the existing Xiaomi Mipad2 DMI quirk to override the wrong _DSM setting.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://lore.kernel.org/r/20240902095229.59059-1-hdegoede@redhat.com
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: atomisp: add missing wait_prepare/finish ops
Hans Verkuil [Mon, 2 Sep 2024 08:31:21 +0000 (10:31 +0200)]
media: atomisp: add missing wait_prepare/finish ops

Without these ops the v4l2-compliance blocking wait test will fail.
These ops are required to ensure that when VIDIOC_DQBUF has to
wait for buffers to arrive, the queue lock is correctly released
and retaken. Otherwise the wait for a buffer would block all other
queue ioctls.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Link: https://lore.kernel.org/r/9f401f3732dd728e3d2ca508002c97b80a2eae30.1725265884.git.hverkuil-cisco@xs4all.nl
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: atomisp: Remove unused declaration
Zhang Zekun [Fri, 30 Aug 2024 03:00:35 +0000 (05:00 +0200)]
media: atomisp: Remove unused declaration

v4l2_get_acpi_sensor_info() has been removed since commit d80be6a10cd3
("media: atomisp: Drop v4l2_get_acpi_sensor_info() function"), remain
the declaration untouched in the header file. So, let's remove this
unused declartion.

Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
Reviewed-by: Changhuang Liang <changhuang.liang@starfivetech.com>
Link: https://lore.kernel.org/r/20240830030035.15686-1-zhangzekun11@huawei.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: atomisp: use clamp() in compute_coring()
Li Zetao [Fri, 30 Aug 2024 01:17:52 +0000 (03:17 +0200)]
media: atomisp: use clamp() in compute_coring()

When it needs to get a value within a certain interval, using clamp()
makes the code easier to understand than min(max()).

Signed-off-by: Li Zetao <lizetao1@huawei.com>
Link: https://lore.kernel.org/r/20240830011752.603433-3-lizetao1@huawei.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: atomisp: use clamp() in ia_css_eed1_8_encode()
Li Zetao [Fri, 30 Aug 2024 01:17:51 +0000 (03:17 +0200)]
media: atomisp: use clamp() in ia_css_eed1_8_encode()

When it needs to get a value within a certain interval, using clamp()
makes the code easier to understand than min(max()).

Signed-off-by: Li Zetao <lizetao1@huawei.com>
Link: https://lore.kernel.org/r/20240830011752.603433-2-lizetao1@huawei.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: atomisp: Simplify ia_css_pipe_create_cas_scaler_desc_single_output()
Andy Shevchenko [Tue, 13 Aug 2024 08:56:15 +0000 (10:56 +0200)]
media: atomisp: Simplify ia_css_pipe_create_cas_scaler_desc_single_output()

Make ia_css_pipe_create_cas_scaler_desc_single_output() easier to read by
shortening parameter names.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240813085615.1546111-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: atomisp: Replace rarely used macro from math_support.h
Andy Shevchenko [Tue, 13 Aug 2024 13:12:25 +0000 (15:12 +0200)]
media: atomisp: Replace rarely used macro from math_support.h

Replace rarely used macro by generic ones from Linux kernel headers.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240813131225.2232817-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: atomisp: Remove duplicated leftover, i.e. sh_css_dvs_info.h
Andy Shevchenko [Tue, 13 Aug 2024 08:54:58 +0000 (10:54 +0200)]
media: atomisp: Remove duplicated leftover, i.e. sh_css_dvs_info.h

The contents of sh_css_dvs_info.h are already included in the solely user
of this header, drop the former for good.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240813085458.1545949-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: atomisp: bnr: fix trailing statement
Kartik Kulkarni [Wed, 31 Jul 2024 10:33:53 +0000 (12:33 +0200)]
media: atomisp: bnr: fix trailing statement

Fix checkpatch error trailing statements should be on next line in
ia_css_bnr.host.c:48

Signed-off-by: Kartik Kulkarni <kartik.koolks@gmail.com>
Link: https://lore.kernel.org/r/20240731103353.39245-1-kartik.koolks@gmail.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: atomisp: move trailing */ to separate lines
Sergio de Almeida Cipriano Junior [Tue, 30 Jul 2024 07:19:04 +0000 (09:19 +0200)]
media: atomisp: move trailing */ to separate lines

Fix checkpatch diagnostic "WARNING: Block comments use a trailing */ on
a separate line" in assert_support.h file.

Signed-off-by: Sergio de Almeida Cipriano Junior <sergiosacj@riseup.net>
Link: https://lore.kernel.org/r/20240730071904.1047-1-sergiosacj@riseup.net
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: atomisp: move trailing statement to next line.
Sakirnth Nagarasa [Tue, 30 Jul 2024 08:42:20 +0000 (10:42 +0200)]
media: atomisp: move trailing statement to next line.

Fix checkpath error "ERROR: trailing statements should be on next line"
in ia_css_fpn.host.c:46.

Signed-off-by: Sakirnth Nagarasa <sakirnth@gmail.com>
Link: https://lore.kernel.org/r/20240730084220.38204-1-sakirnth@gmail.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: atomisp: Fix trailing statement in ia_css_de.host.c
Kathara Sasikumar [Tue, 30 Jul 2024 08:27:25 +0000 (10:27 +0200)]
media: atomisp: Fix trailing statement in ia_css_de.host.c

Fix checkpatch diagostic of Error : Trailing statements should be on the
next line

Signed-off-by: Kathara Sasikumar <katharasasikumar007@gmail.com>
Link: https://lore.kernel.org/r/20240730082725.2524-1-katharasasikumar007@gmail.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: atomisp: Fix spelling mistakes in atomisp.h
Roshan Khatri [Wed, 22 May 2024 16:18:30 +0000 (18:18 +0200)]
media: atomisp: Fix spelling mistakes in atomisp.h

codespell reported misspelled coefficients and vector in atomisp.h. This
patch corrects the spellings to increase readability and searching.

Signed-off-by: Roshan Khatri <topofeverest8848@gmail.com>
Link: https://lore.kernel.org/r/20240522161830.57434-1-topofeverest8848@gmail.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: atomisp: Fix spelling mistakes in atomisp_platform.h
Roshan Khatri [Fri, 10 May 2024 13:40:00 +0000 (15:40 +0200)]
media: atomisp: Fix spelling mistakes in atomisp_platform.h

Codespell reported misspelled "streams" and "corresponding" in
atomisp_platform.h. This patch fixes the misspellings.

Signed-off-by: Roshan Khatri <topofeverest8848@gmail.com>
Link: https://lore.kernel.org/r/20240510134000.23848-1-topofeverest8848@gmail.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: atomisp: Fix spelling mistake in csi_rx_public.h
Roshan Khatri [Thu, 2 May 2024 04:34:15 +0000 (06:34 +0200)]
media: atomisp: Fix spelling mistake in csi_rx_public.h

codespell reported misspelled "register" in csi_rx_public.h,
fix misspellings.

Signed-off-by: Roshan Khatri <topofeverest8848@gmail.com>
Link: https://lore.kernel.org/r/20240502043415.88434-1-topofeverest8848@gmail.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: cec: extron-da-hd-4k-plus: add the Extron DA HD 4K Plus CEC driver
Hans Verkuil [Wed, 6 Oct 2021 11:29:30 +0000 (13:29 +0200)]
media: cec: extron-da-hd-4k-plus: add the Extron DA HD 4K Plus CEC driver

Add support for the Extron DA HD 4K Plus series of 4K HDMI
Distrubution Amplifiers (aka HDMI Splitters).

These devices support CEC and this driver adds support for the
CEC protocol for both the input and all outputs (2, 4 or 6 outputs,
depending on the model).

It also exports the EDID from the outputs and allows reading and
setting the EDID of the input.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: cec: move cec_get/put_device to header
Hans Verkuil [Fri, 2 Aug 2024 10:19:48 +0000 (12:19 +0200)]
media: cec: move cec_get/put_device to header

Move cec_get/put_device to the media/cec.h header. This
allows CEC drivers to use this.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: input: serio.h: add SERIO_EXTRON_DA_HD_PLUS
Hans Verkuil [Wed, 12 Aug 2020 12:20:10 +0000 (14:20 +0200)]
media: input: serio.h: add SERIO_EXTRON_DA_HD_PLUS

Add a new serio ID for the Extron DA HD 4K Plus series of 4K HDMI
Distribution Amplifiers. These devices support CEC over the serial
port, so a new serio ID is needed to be able to associate the CEC
driver.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: docs: Add V4L2_CAP_EDID
Erling Ljunggren [Fri, 11 Nov 2022 13:29:03 +0000 (14:29 +0100)]
media: docs: Add V4L2_CAP_EDID

Add documentation for the new edid capability.

Signed-off-by: Erling Ljunggren <hljunggr@cisco.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: v4l2-dev: handle V4L2_CAP_EDID
Erling Ljunggren [Wed, 28 Sep 2022 11:21:47 +0000 (13:21 +0200)]
media: v4l2-dev: handle V4L2_CAP_EDID

When the V4L2_CAP_EDID capability flag is set,
ioctls for enum inputs/outputs and get/set edid are automatically set.

Signed-off-by: Erling Ljunggren <hljunggr@cisco.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: videodev2.h: add V4L2_CAP_EDID
Erling Ljunggren [Wed, 28 Sep 2022 11:21:43 +0000 (13:21 +0200)]
media: videodev2.h: add V4L2_CAP_EDID

Add capability flag to indicate that the device is an EDID-only device.

Signed-off-by: Erling Ljunggren <hljunggr@cisco.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
10 months agomedia: MAINTAINERS: Add "qcom," substring for Qualcomm Camera Subsystem
Changhuang Liang [Tue, 20 Aug 2024 11:20:53 +0000 (04:20 -0700)]
media: MAINTAINERS: Add "qcom," substring for Qualcomm Camera Subsystem

Commit f5502cd25ac0 ("media: dt-bindings: Add JH7110 Camera Subsystem")
adds the StarFive Camera Subsystem parts, also complies with Qualcomm's
rules. Add "qcom," substring restrcting this condition.

Signed-off-by: Changhuang Liang <changhuang.liang@starfivetech.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
[Sakari Ailus: Add media: prefix to the subject.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: mt9v111: Drop redundant comma
Liao Chen [Thu, 29 Aug 2024 12:52:03 +0000 (12:52 +0000)]
media: i2c: mt9v111: Drop redundant comma

Drop the redundant comma from mt9v111_of_match array to make the code
clean.

Signed-off-by: Liao Chen <liaochen4@huawei.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: mt9v111: Enable module autoloading
Liao Chen [Thu, 29 Aug 2024 12:52:02 +0000 (12:52 +0000)]
media: i2c: mt9v111: Enable module autoloading

Add MODULE_DEVICE_TABLE(), so modules could be properly autoloaded based
on the alias from of_device_id table.

Signed-off-by: Liao Chen <liaochen4@huawei.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: imx335: Fix reset-gpio handling
Umang Jain [Fri, 30 Aug 2024 06:11:52 +0000 (11:41 +0530)]
media: imx335: Fix reset-gpio handling

Rectify the logical value of reset-gpio so that it is set to
0 (disabled) during power-on and to 1 (enabled) during power-off.

Set the reset-gpio to GPIO_OUT_HIGH at initialization time to make
sure it starts off in reset. Also drop the "Set XCLR" comment which
is not-so-informative.

The existing usage of imx335 had reset-gpios polarity inverted
(GPIO_ACTIVE_HIGH) in their device-tree sources. With this patch
included, those DTS will not be able to stream imx335 anymore. The
reset-gpio polarity will need to be rectified in the device-tree
sources as shown in [1] example, in order to get imx335 functional
again (as it remains in reset prior to this fix).

Cc: stable@vger.kernel.org
Fixes: 45d19b5fb9ae ("media: i2c: Add imx335 camera sensor driver")
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/linux-media/20240729110437.199428-1-umang.jain@ideasonboard.com/
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agodt-bindings: media: imx335: Add reset-gpios to the DT example
Umang Jain [Fri, 30 Aug 2024 06:11:51 +0000 (11:41 +0530)]
dt-bindings: media: imx335: Add reset-gpios to the DT example

It's easy to get the polarity of GPIOs in the device tree wrong, as
shown by a recently fixed bug in the imx335 driver. To lower the chance
of future mistakes, especially in new bindings that would take the
imx335 binding as a starting point, add the reset-gpios property to the
DT example. This showcases the correct polarity of the XCLR signal for
Sony sensors in the most common case of the signal not being inverted on
the board.

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: og01a1b: Add management of optional sensor supply lines
Vladimir Zapolskiy [Fri, 30 Aug 2024 06:34:59 +0000 (09:34 +0300)]
media: i2c: og01a1b: Add management of optional sensor supply lines

Omnivision OG01A1B camera sensor is supplied by three power rails,
if supplies are present as device properties, include them into
sensor power up sequence.

Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: og01a1b: Add management of optional reset GPIO
Vladimir Zapolskiy [Fri, 30 Aug 2024 06:34:58 +0000 (09:34 +0300)]
media: i2c: og01a1b: Add management of optional reset GPIO

Omnivision OG01A1B camera sensor may have a connected active low GPIO
to XSHUTDOWN pad, and if so, include it into sensor power up sequence.

Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: og01a1b: Add support of xvclk supply clock in power management
Vladimir Zapolskiy [Fri, 30 Aug 2024 06:34:57 +0000 (09:34 +0300)]
media: i2c: og01a1b: Add support of xvclk supply clock in power management

The OmniVision OG01A1B camera sensor has an xvclk supply clock, which
could be described and then explicitly controlled on OF platforms.

Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
[Sakari Ailus: Use UL specifier for power-up delay cycle value.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: og01a1b: Add stubs of runtime power management functions
Vladimir Zapolskiy [Fri, 30 Aug 2024 06:34:56 +0000 (09:34 +0300)]
media: i2c: og01a1b: Add stubs of runtime power management functions

Rearrange initializations and checks in probe before population of
the power management functions.

Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: og01a1b: Add OF support to the image sensor driver
Vladimir Zapolskiy [Fri, 30 Aug 2024 06:34:55 +0000 (09:34 +0300)]
media: i2c: og01a1b: Add OF support to the image sensor driver

The OmniVision  OG01A1B image sensor driver currently supports probing
only on ACPI platforms, the changes adds support of OF platforms to
the driver.

Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: dt-bindings: Add OmniVision OG01A1B image sensor
Vladimir Zapolskiy [Fri, 30 Aug 2024 06:34:54 +0000 (09:34 +0300)]
media: dt-bindings: Add OmniVision OG01A1B image sensor

Add device tree bindings documentation for OmniVision OG01A1B image
sensor.

Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: siano: Remove unused declarations
Yue Haibing [Fri, 23 Aug 2024 09:48:39 +0000 (17:48 +0800)]
media: siano: Remove unused declarations

There is no caller and implementation in tree, so can remove them.

Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: ccs: Remove unused declarations
Yue Haibing [Fri, 23 Aug 2024 09:49:35 +0000 (17:49 +0800)]
media: ccs: Remove unused declarations

Commit 2989a457171d ("media: ccs: Refactor register reading a little")
removed ccs_read_addr_no_quirk() but left declaration.

Commit 529322112a3b ("media: ccs: Use V4L2 CCI for accessing sensor
registers") removed ccs_write_addr_no_quirk() and ccs_reg_width() but
leave their declarations.

Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: ar0521: Use cansleep version of gpiod_set_value()
Alexander Shiyan [Thu, 29 Aug 2024 05:48:49 +0000 (08:48 +0300)]
media: i2c: ar0521: Use cansleep version of gpiod_set_value()

If we use GPIO reset from I2C port expander, we must use *_cansleep()
variant of GPIO functions.
This was not done in ar0521_power_on()/ar0521_power_off() functions.
Let's fix that.

------------[ cut here ]------------
WARNING: CPU: 0 PID: 11 at drivers/gpio/gpiolib.c:3496 gpiod_set_value+0x74/0x7c
Modules linked in:
CPU: 0 PID: 11 Comm: kworker/u16:0 Not tainted 6.10.0 #53
Hardware name: Diasom DS-RK3568-SOM-EVB (DT)
Workqueue: events_unbound deferred_probe_work_func
pstate: 80400009 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : gpiod_set_value+0x74/0x7c
lr : ar0521_power_on+0xcc/0x290
sp : ffffff8001d7ab70
x29: ffffff8001d7ab70 x28: ffffff80027dcc90 x27: ffffff8003c82000
x26: ffffff8003ca9250 x25: ffffffc080a39c60 x24: ffffff8003ca9088
x23: ffffff8002402720 x22: ffffff8003ca9080 x21: ffffff8003ca9088
x20: 0000000000000000 x19: ffffff8001eb2a00 x18: ffffff80efeeac80
x17: 756d2d6332692f30 x16: 0000000000000000 x15: 0000000000000000
x14: ffffff8001d91d40 x13: 0000000000000016 x12: ffffffc080e98930
x11: ffffff8001eb2880 x10: 0000000000000890 x9 : ffffff8001d7a9f0
x8 : ffffff8001d92570 x7 : ffffff80efeeac80 x6 : 000000003fc6e780
x5 : ffffff8001d91c80 x4 : 0000000000000002 x3 : 0000000000000000
x2 : 0000000000000000 x1 : 0000000000000000 x0 : 0000000000000001
Call trace:
 gpiod_set_value+0x74/0x7c
 ar0521_power_on+0xcc/0x290
...

Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
Fixes: 852b50aeed15 ("media: On Semi AR0521 sensor driver")
Cc: stable@vger.kernel.org
Acked-by: Krzysztof Hałasa <khalasa@piap.pl>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: intel/ipu6: make use of dev_err_cast_probe()
Hongbo Li [Wed, 28 Aug 2024 12:09:48 +0000 (20:09 +0800)]
media: intel/ipu6: make use of dev_err_cast_probe()

Using dev_err_cast_probe() to simplify the code.

No functional change.

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: ov5675: Fix power on/off delay timings
Bryan O'Donoghue [Sat, 13 Jul 2024 22:33:29 +0000 (23:33 +0100)]
media: ov5675: Fix power on/off delay timings

The ov5675 specification says that the gap between XSHUTDN deassert and the
first I2C transaction should be a minimum of 8192 XVCLK cycles.

Right now we use a usleep_rage() that gives a sleep time of between about
430 and 860 microseconds.

On the Lenovo X13s we have observed that in about 1/20 cases the current
timing is too tight and we start transacting before the ov5675's reset
cycle completes, leading to I2C bus transaction failures.

The reset racing is sometimes triggered at initial chip probe but, more
usually on a subsequent power-off/power-on cycle e.g.

[   71.451662] ov5675 24-0010: failed to write reg 0x0103. error = -5
[   71.451686] ov5675 24-0010: failed to set plls

The current quiescence period we have is too tight. Instead of expressing
the post reset delay in terms of the current XVCLK this patch converts the
power-on and power-off delays to the maximum theoretical delay @ 6 MHz with
an additional buffer.

1.365 milliseconds on the power-on path is 1.5 milliseconds with grace.
85.3 microseconds on the power-off path is 90 microseconds with grace.

Fixes: 49d9ad719e89 ("media: ov5675: add device-tree support and support runtime PM")
Cc: stable@vger.kernel.org
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Tested-by: Johan Hovold <johan+linaro@kernel.org>
Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
Tested-by: Quentin Schulz <quentin.schulz@cherry.de> # RK3399 Puma with
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: imx355: Parse and register properties
Robert Mader [Sun, 11 Aug 2024 11:17:04 +0000 (13:17 +0200)]
media: i2c: imx355: Parse and register properties

Analogous to e.g. the imx219 driver. This enables propagating the
V4L2_CID_CAMERA_SENSOR_ROTATION and V4L2_CID_CAMERA_ORIENTATION
values so that userspace - e.g. libcamera - can detect the
correct rotation and orientation from the device tree.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: max96714: coding style fixes
Julien Massot [Mon, 1 Jul 2024 09:31:43 +0000 (11:31 +0200)]
media: i2c: max96714: coding style fixes

Coding style fixes suggested by Sakari during the
driver review.

Reviewed-by: Tommaso Merciai <tomm.merciai@gmail.com>
Tested-by: Tommaso Merciai <tomm.merciai@gmail.com>
Signed-off-by: Julien Massot <julien.massot@collabora.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: max96717: coding style fixes
Julien Massot [Mon, 1 Jul 2024 09:31:42 +0000 (11:31 +0200)]
media: i2c: max96717: coding style fixes

Coding style fixes suggested by Sakari during the
driver review.

Signed-off-by: Julien Massot <julien.massot@collabora.com>
Reviewed-by: Tommaso Merciai <tomm.merciai@gmail.com>
Tested-by: Tommaso Merciai <tomm.merciai@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: max96717: add test pattern ctrl
Tommaso Merciai [Thu, 27 Jun 2024 15:18:06 +0000 (17:18 +0200)]
media: i2c: max96717: add test pattern ctrl

Add v4l2 test pattern control.

Signed-off-by: Tommaso Merciai <tomm.merciai@gmail.com>
Reviewed-by: Julien Massot <julien.massot@collabora.com>
Tested-by: Julien Massot <julien.massot@collabora.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: meson: vdec: hevc: Refactor vdec_hevc_start and vdec_hevc_stop
Ricardo Ribalda [Fri, 16 Aug 2024 12:32:04 +0000 (12:32 +0000)]
media: meson: vdec: hevc: Refactor vdec_hevc_start and vdec_hevc_stop

Make a new function __vdec_hevc_start(), that does all the
initialization, except the clock initialization for G12A and SM1.

Factor out all the stop logic, except the clk_disable_unprepare(), to a
new function __vdec_hevc_stop. This allows vdec_hevc_start() to
explicitly celan-out the clock during the error-path.

The following smatch warnings are fixed:

drivers/staging/media/meson/vdec/vdec_hevc.c:227 vdec_hevc_start() warn: 'core->vdec_hevc_clk' from clk_prepare_enable() not released on lines: 227.
drivers/staging/media/meson/vdec/vdec_hevc.c:227 vdec_hevc_start() warn: 'core->vdec_hevcf_clk' from clk_prepare_enable() not released on lines: 227.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: meson: vdec_1: Refactor vdec_1_stop()
Ricardo Ribalda [Fri, 16 Aug 2024 12:32:03 +0000 (12:32 +0000)]
media: meson: vdec_1: Refactor vdec_1_stop()

Factor out all the power off logic, except the clk_disable_unprepare(),
to a new function __vdec_1_stop().

This allows vdec_1_start() to explicitly clean-out the clock during the
error-path.

The following smatch warning is fixed:
drivers/staging/media/meson/vdec/vdec_1.c:239 vdec_1_start() warn: 'core->vdec_1_clk' from clk_prepare_enable() not released on lines: 239.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: tc358746: Move clk_prepare to its own function
Ricardo Ribalda [Fri, 16 Aug 2024 12:32:02 +0000 (12:32 +0000)]
media: tc358746: Move clk_prepare to its own function

Smatch is very confused by a clk_prepare_enable() being called in an
error-path. Fix this warning by moving the clk_prepare_enable() to its
own function.

drivers/media/i2c/tc358746.c:1631 tc358746_suspend() warn: 'tc358746->refclk' from clk_prepare_enable() not released on lines: 1631.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: s5c73m3: Move clk_prepare to its own function
Ricardo Ribalda [Fri, 16 Aug 2024 12:32:01 +0000 (12:32 +0000)]
media: i2c: s5c73m3: Move clk_prepare to its own function

Smatch is very confused by a clk_prepare_enable() being called in an
error-path. Fix this warning by moving the clk_prepare_enable() to its
own function.

drivers/media/i2c/s5c73m3/s5c73m3-core.c:1425 __s5c73m3_power_off() warn: 'state->clock' from clk_prepare_enable() not released on lines: 1425.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: ov5645: Refactor ov5645_set_power_off()
Ricardo Ribalda [Fri, 16 Aug 2024 12:32:00 +0000 (12:32 +0000)]
media: i2c: ov5645: Refactor ov5645_set_power_off()

Factor out all the power off logic, except clk_disable_unprepare(), to a
new function __ov5645_set_power_off().

This allows ov5645_set_power_on() to excplicitly clean-out the clock
during the error-path.

The following smatch warning is fixed:
drivers/media/i2c/ov5645.c:690 ov5645_set_power_on() warn: 'ov5645->xclk' from clk_prepare_enable() not released on lines: 690.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: ar0521: Refactor ar0521_power_off()
Ricardo Ribalda [Fri, 16 Aug 2024 12:31:59 +0000 (12:31 +0000)]
media: ar0521: Refactor ar0521_power_off()

Factor out all the power off logic, except the clk_disable_unprepare(),
to a new function __ar0521_power_off().

This allows ar0521_power_on() to explicitly clean-out the clock during
the error-path.

The following smatch warning is fixed:
drivers/media/i2c/ar0521.c:912 ar0521_power_on() warn: 'sensor->extclk' from clk_prepare_enable() not released on lines: 912.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agostaging: media: ipu3: Stop streaming in inverse order of starting
Max Staudt [Thu, 20 Jun 2024 14:45:43 +0000 (23:45 +0900)]
staging: media: ipu3: Stop streaming in inverse order of starting

imgu_vb2_stop_streaming() did not order shutdown items in the inverse
order and count of what imgu_vb2_start_streaming() does. Consequently,
v6.7's new WARN_ON in call_s_stream() started screaming because it was
called multiple times on the entire pipe, yet it should only be called
when the pipe is interrupted by any first node being taken offline.

This reorders streamoff to be the inverse of streamon, and uses
analogous conditions to decide when and how often to call additional
teardown functions.

v4l2_subdev_call(s_stream, 0) remains outside the streaming_lock,
analogously to imgu_vb2_start_streaming().

Signed-off-by: Max Staudt <mstaudt@chromium.org>
Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agostaging: media: ipu3: Return buffers outside of needless locking
Max Staudt [Thu, 20 Jun 2024 14:45:42 +0000 (23:45 +0900)]
staging: media: ipu3: Return buffers outside of needless locking

In imgu_vb2_start_streaming()'s error path, imgu_return_all_buffers()
is outside the streaming_lock and after the call to
video_device_pipeline_stop().

Let's apply the same order in imgu_vb2_stop_streaming() as well.

Signed-off-by: Max Staudt <mstaudt@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agostaging: media: ipu3: Drop superfluous check in imgu_vb2_stop_streaming()
Max Staudt [Thu, 20 Jun 2024 14:45:41 +0000 (23:45 +0900)]
staging: media: ipu3: Drop superfluous check in imgu_vb2_stop_streaming()

The check for imgu_all_nodes_streaming() seems superfluous, since
imgu->streaming can only become true once imgu_all_nodes_streaming()
has been true. Hence, checking for imgu->streaming == true should
imply imgu_all_nodes_streaming(), and therefore suffice.

Signed-off-by: Max Staudt <mstaudt@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: imx283: Add 3/3 binning mode
Umang Jain [Tue, 13 Aug 2024 05:52:00 +0000 (11:22 +0530)]
media: imx283: Add 3/3 binning mode

IMX283 supports 12-bit 3/3 binning mode with 1824x1216 resolution.
Introduce the mode config for the same.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agoMerge tag 'tags/next-media-videobuf-20240827' of git://git.kernel.org/pub/scm/linux...
Hans Verkuil [Wed, 28 Aug 2024 11:11:49 +0000 (13:11 +0200)]
Merge tag 'tags/next-media-videobuf-20240827' of git://git.kernel.org/pub/scm/linux/kernel/git/pinchartl/linux.git

- videobuf2 regression fix

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://patchwork.linuxtv.org/project/linux-media/patch/20240827122125.GA17846@pendragon.ideasonboard.com/
11 months agoMerge tag 'next-media-20240826' of git://git.kernel.org/pub/scm/linux/kernel/git...
Hans Verkuil [Wed, 28 Aug 2024 11:10:55 +0000 (13:10 +0200)]
Merge tag 'next-media-20240826' of git://git.kernel.org/pub/scm/linux/kernel/git/pinchartl/linux.git

Improvements to link validation in media graph.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://patchwork.linuxtv.org/project/linux-media/patch/20240826141040.GC11033@pendragon.ideasonboard.com/
11 months agoMerge tag 'tags/next-media-renesas-20240825' of git://git.kernel.org/pub/scm/linux...
Hans Verkuil [Wed, 28 Aug 2024 11:10:10 +0000 (13:10 +0200)]
Merge tag 'tags/next-media-renesas-20240825' of git://git.kernel.org/pub/scm/linux/kernel/git/pinchartl/linux.git

Improvements to Renesas media drivers:

- R-Car V4M support for VIN
- Fix rzg2l-csi2 module auto-loading

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://patchwork.linuxtv.org/project/linux-media/patch/20240824234307.GC9543@pendragon.ideasonboard.com/
11 months agoMerge tag 'tags/next-media-imx-20240825' of git://git.kernel.org/pub/scm/linux/kernel...
Hans Verkuil [Wed, 28 Aug 2024 11:09:24 +0000 (13:09 +0200)]
Merge tag 'tags/next-media-imx-20240825' of git://git.kernel.org/pub/scm/linux/kernel/git/pinchartl/linux.git

Improvements to i.MX media drivers:

- Switch to RUNTIME/SYSTEM_SLEEP_PM_OPS() for better compile testing of
  the imx-mipi-csis and imx8mq-mipi-csi2 drivers
- Improve real time behaviour of imx-mipi-csis by avoiding logging while
  holding a spin lock

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://patchwork.linuxtv.org/project/linux-media/patch/20240824233233.GB9543@pendragon.ideasonboard.com/
11 months agoMerge tag 'tags/next-media-misc-20240825' of git://git.kernel.org/pub/scm/linux/kerne...
Hans Verkuil [Wed, 28 Aug 2024 11:08:12 +0000 (13:08 +0200)]
Merge tag 'tags/next-media-misc-20240825' of git://git.kernel.org/pub/scm/linux/kernel/git/pinchartl/linux.git

Miscellaneous changes: mt9p031, starfive and v4l2-mc.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://patchwork.linuxtv.org/project/linux-media/patch/20240824233140.GA9543@pendragon.ideasonboard.com/
11 months agomedia: imagination: VIDEO_E5010_JPEG_ENC should depend on ARCH_K3
Geert Uytterhoeven [Mon, 22 Jul 2024 15:25:53 +0000 (17:25 +0200)]
media: imagination: VIDEO_E5010_JPEG_ENC should depend on ARCH_K3

Currently, the Imagination E5010 JPEG Encoder is only present on Texas
Instruments K3 SoCs.  Hence add a dependency on ARCH_K3, to prevent
asking the user about this driver when configuring a kernel without TI
K3 SoC support.  The dependency can be relaxed if/when the encoder
appears on other SoC families.

Fixes: a1e294045885 ("media: imagination: Add E5010 JPEG Encoder driver")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: hantro: Add RK3588 VEPU121
Sebastian Reichel [Tue, 18 Jun 2024 18:18:35 +0000 (20:18 +0200)]
media: hantro: Add RK3588 VEPU121

RK3588 handling is exactly the same as RK3568. This is not
handled using fallback compatibles to avoid exposing multiple
video devices on kernels not having the multicore disable
patch.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: hantro: Disable multicore support
Sebastian Reichel [Tue, 18 Jun 2024 18:18:34 +0000 (20:18 +0200)]
media: hantro: Disable multicore support

Avoid exposing equal Hantro video codecs to userspace. Equal video
codecs allow scheduling work between the cores. For that kernel support
is required, which does not yet exist. Until that is implemented avoid
exposing each core separately to userspace so that multicore can be
added in the future without breaking userspace ABI.

This was written with Rockchip RK3588 in mind (which has 4 Hantro H1
cores), but applies to all SoCs.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: dt-bindings: rockchip-vpu: Add RK3588 VPU121
Jianfeng Liu [Tue, 18 Jun 2024 18:18:33 +0000 (20:18 +0200)]
media: dt-bindings: rockchip-vpu: Add RK3588 VPU121

RK3588 has four Hantro H1 VEPUs (encoder-only) modules and one combined
Hantro H1/G1 VPU (decoder and encoder). These are not described as
separate IP, since they are sharing an internal cache. This adds the
RK3588 specific compatible string for the combined VPU, which seems to
be identical to the version found in the RK3568.

Signed-off-by: Jianfeng Liu <liujianfeng1994@gmail.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: dt-bindings: rk3568-vepu: Add RK3588 VEPU121
Emmanuel Gil Peyrot [Tue, 18 Jun 2024 18:18:32 +0000 (20:18 +0200)]
media: dt-bindings: rk3568-vepu: Add RK3588 VEPU121

This encoder-only device is present four times on this SoC, and should
support everything the rk3568 vepu supports (so JPEG, H.264 and VP8
encoding). No fallback compatible has been added, since the operating
systems might already support RK3568 VEPU and want to avoid registering
four of them separately considering they can be used as a cluster.

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agodt-bindings: media: rockchip,vpu: Document RK3128 compatible
Alex Bee [Thu, 23 May 2024 18:56:31 +0000 (20:56 +0200)]
dt-bindings: media: rockchip,vpu: Document RK3128 compatible

The integration for this SoC is similar to RK3066/RK3188.

Document it's compatible.

Signed-off-by: Alex Bee <knaerzche@gmail.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agoDocumentation: media: Fix AV1 struct documentation
Fritz Koenig [Fri, 31 May 2024 17:10:06 +0000 (10:10 -0700)]
Documentation: media: Fix AV1 struct documentation

- v4l2_av1_segmentation table formatting
- incorrect member name uv_sec_strength
- incorrect struct name v4l2_av1_global_motion
- incorrect link label for v4l2_av1_loop_filter
- add max_frame_height_minus_1
- struct ordering

Signed-off-by: Fritz Koenig <frkoenig@chromium.org>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: verisilicon: Add reference buffer compression feature
Benjamin Gaignard [Thu, 16 May 2024 08:41:07 +0000 (10:41 +0200)]
media: verisilicon: Add reference buffer compression feature

Reference frame compression is a feature added in the G2 decoder to
compress frame buffers so that the bandwidth of storing/loading
reference frames can be reduced, especially with high resolution decoded
streams.

The impact of compressed frames is confirmed when using perf to monitor
the number of memory accesses with or without the compression feature.
The following command:

perf stat -a -e \
imx8_ddr0/cycles/,imx8_ddr0/read-cycles/,imx8_ddr0/write-cycles/ \
gst-launch-1.0 filesrc \
location=Jockey_3840x2160_120fps_420_8bit_HEVC_RAW.hevc ! queue ! \
h265parse ! v4l2slh265dec ! video/x-raw,format=NV12 ! fakesink

Gives us these results without the compression feature:
Performance counter stats for 'system wide':

        1711300345      imx8_ddr0/cycles/
         892207924      imx8_ddr0/read-cycles/
        1291785864      imx8_ddr0/write-cycles/

      13.760048353 seconds time elapsed

With the compression feature:
Performance counter stats for 'system wide':

         274526799      imx8_ddr0/cycles/
         453120194      imx8_ddr0/read-cycles/
         833391434      imx8_ddr0/write-cycles/

      18.257831534 seconds time elapsed

As expected the number of read/write cycles are really lower when
compression is used.

Since storing the compression data requires more memory a module
parameter named 'hevc_use_compression' is used to enable/disable
this feature and, by default, compression isn't used.

Enabling the compression feature means that the output-frames of the
decoder
are stored with a specific compression pixel-format. Since this
pixel format is unknown, this patch restrains the compression feature
usage to the cases where post-processor pixel-formats (NV12 or NV15)
are selected by the applications.

The Fluster compliance HEVC test suite score is still 141/147 with this
patch.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Tested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: mediatek: vcodec: Constify struct vb2_ops
Christophe JAILLET [Sun, 16 Jun 2024 06:29:53 +0000 (08:29 +0200)]
media: mediatek: vcodec: Constify struct vb2_ops

"struct vb2_ops" are not modified in this driver.

Constifying this structure moves some data to a read-only section, so
increase overall security.

On a x86_64, with allmodconfig:
Before:
======
   text    data     bss     dec     hex filename
  18059    3096      16   21171    52b3 drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateful.o

After:
=====
   text    data     bss     dec     hex filename
  18171    2968      16   21155    52a3 drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateful.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: mediatek: vcodec: Fix H264 stateless decoder smatch warning
Yunfei Dong [Thu, 13 Jun 2024 09:33:57 +0000 (17:33 +0800)]
media: mediatek: vcodec: Fix H264 stateless decoder smatch warning

Fix a smatch static checker warning on vdec_h264_req_if.c.
Which leads to a kernel crash when fb is NULL.

Fixes: 06fa5f757dc5 ("media: mtk-vcodec: vdec: support stateless H.264 decoding")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: mediatek: vcodec: Fix VP8 stateless decoder smatch warning
Yunfei Dong [Thu, 13 Jun 2024 09:33:56 +0000 (17:33 +0800)]
media: mediatek: vcodec: Fix VP8 stateless decoder smatch warning

Fix a smatch static checker warning on vdec_vp8_req_if.c.
Which leads to a kernel crash when fb is NULL.

Fixes: 7a7ae26fd458 ("media: mediatek: vcodec: support stateless VP8 decoding")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: mediatek: vcodec: Fix H264 multi stateless decoder smatch warning
Yunfei Dong [Thu, 13 Jun 2024 09:33:55 +0000 (17:33 +0800)]
media: mediatek: vcodec: Fix H264 multi stateless decoder smatch warning

Fix a smatch static checker warning on vdec_h264_req_multi_if.c.
Which leads to a kernel crash when fb is NULL.

Fixes: 397edc703a10 ("media: mediatek: vcodec: add h264 decoder driver for mt8186")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: videobuf2: Drop minimum allocation requirement of 2 buffers
Laurent Pinchart [Sun, 25 Aug 2024 23:24:49 +0000 (02:24 +0300)]
media: videobuf2: Drop minimum allocation requirement of 2 buffers

When introducing the ability for drivers to indicate the minimum number
of buffers they require an application to allocate, commit 6662edcd32cc
("media: videobuf2: Add min_reqbufs_allocation field to vb2_queue
structure") also introduced a global minimum of 2 buffers. It turns out
this breaks the Renesas R-Car VSP test suite, where a test that
allocates a single buffer fails when two buffers are used.

One may consider debatable whether test suite failures without failures
in production use cases should be considered as a regression, but
operation with a single buffer is a valid use case. While full frame
rate can't be maintained, memory-to-memory devices can still be used
with a decent efficiency, and requiring applications to allocate
multiple buffers for single-shot use cases with capture devices would
just waste memory.

For those reasons, fix the regression by dropping the global minimum of
buffers. Individual drivers can still set their own minimum.

Fixes: 6662edcd32cc ("media: videobuf2: Add min_reqbufs_allocation field to vb2_queue structure")
Cc: stable@vger.kernel.org
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Acked-by: Tomasz Figa <tfiga@chromium.org>
Link: https://lore.kernel.org/r/20240825232449.25905-1-laurent.pinchart+renesas@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
11 months agomedia: renesas: vsp1: Implement .link_validate() for video devices
Laurent Pinchart [Tue, 18 Jun 2024 18:46:44 +0000 (21:46 +0300)]
media: renesas: vsp1: Implement .link_validate() for video devices

The v4l2_subdev_link_validate() helper prints a warning if the
.link_validate() operation is not implemented for video devices
connected to the subdevs. Implement the operation to silence the
warning.

Ideally validation of the link between the video device and the subdev
should be implemented in that operation. That would however break
userspace that does not configure formats on all video devices before
starting streaming. While this mode of operation may not be considered
valid by the V4L2 API specification (interpretation differ), it is
nonetheless supported by the vsp1 driver at the moment and used by at
least the vsp1 unit test suite, and possibly other userspace
applications. Removing it would be a regression.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
11 months agomedia: v4l2-subdev: Support hybrid links in v4l2_subdev_link_validate()
Laurent Pinchart [Wed, 19 Jun 2024 00:02:42 +0000 (03:02 +0300)]
media: v4l2-subdev: Support hybrid links in v4l2_subdev_link_validate()

The v4l2_subdev_link_validate() helper function is meant to be used as a
drop-in implementation of a V4L2 subdev entity .link_validate() handler.
It supports subdev-to-subdev links only, and complains if one end of the
link is not a subdev. This forces drivers that have video output devices
connected to subdevs to implement a custom .link_validate() handler,
calling v4l2_subdev_link_validate() for the subdev-to-subdev links, and
performing manual link validation for the video-to-subdev links.

Video devices embed a media entity, and therefore also have a
.link_validate() operation. For video capture devices, the operation
should be manually implemented by drivers for validate the
subdev-to-video links. For video output devices, on the other hand, that
operation is never called, as link validation is performed in the
context of the sink entity.

As a result, we end up forcing drivers to implement a custom
.link_validate() handler for subdevs connected to video output devices,
when the video devices provide an operation that could be used for that
purpose.

To improve that situation, make v4l2_subdev_link_validate() delegate
link validation to the source's .link_validate() operation when the link
source is a video device and the link sink is a subdev. This allows
broader usage of v4l2_subdev_link_validate(), and simplifies drivers by
making video device link validation easy to implement in the video
device .link_validate(), regardless of whether the video device is an
output device or a capture device.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
11 months agomedia: v4l2-subdev: Refactor warnings in v4l2_subdev_link_validate()
Laurent Pinchart [Tue, 18 Jun 2024 23:56:01 +0000 (02:56 +0300)]
media: v4l2-subdev: Refactor warnings in v4l2_subdev_link_validate()

The v4l2_subdev_link_validate() function prints a one-time warning if it
gets called on a link whose source or sink is not a subdev. As links get
validated in the context of their sink, a call to the helper when the
link's sink is not a subdev indicates that the driver has set its
.link_validate() handler to v4l2_subdev_link_validate() on a non-subdev
entity, which is a clear driver bug. On the other hand, the link's
source not being a subdev indicates that the helper is used for a subdev
connected to a video output device, which is a lesser issue, if only
because this is currently common practice.

There are no drivers left in the kernel that use
v4l2_subdev_link_validate() in a context where it may get called on a
non-subdev sink. Replace the pr_warn_once() with a WARN_ON_ONCE() in
this case to make sure that new offenders won't be introduced.

A subsequent change will improve the v4l2_subdev_link_validate() helper
to properly support validating video device to subdev links.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
11 months agomedia: sun4i_csi: Don't use v4l2_subdev_link_validate() for video device
Laurent Pinchart [Tue, 18 Jun 2024 23:46:16 +0000 (02:46 +0300)]
media: sun4i_csi: Don't use v4l2_subdev_link_validate() for video device

The v4l2_subdev_link_validate() function is a helper designed to
validate links whose sink is a subdev. When called on a link whose sink
is a video device, it only prints a warning and returns. Its usage in
the sun4i_csi driver is wrong, leaving the link from the sub4i_csi
subdev to the capture video device unvalidated.

Planned improvements to the v4l2_subdev_link_validate() function will
turn the warning into an error, breaking the sun4i_csi driver. As an
interim measure, move the warning to the sun4i_csi driver in a custom
validation handler, and drop the call to the helper.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
11 months agomedia: sun4i_csi: Implement link validate for sun4i_csi subdev
Laurent Pinchart [Tue, 18 Jun 2024 23:46:16 +0000 (02:46 +0300)]
media: sun4i_csi: Implement link validate for sun4i_csi subdev

The sun4i_csi driver doesn't implement link validation for the subdev it
registers, leaving the link between the subdev and its source
unvalidated. Fix it, using the v4l2_subdev_link_validate() helper.

Fixes: 577bbf23b758 ("media: sunxi: Add A10 CSI driver")
Cc: stable@vger.kernel.org
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
11 months agomedia: microchip-isc: Drop v4l2_subdev_link_validate() for video devices
Laurent Pinchart [Tue, 18 Jun 2024 23:42:34 +0000 (02:42 +0300)]
media: microchip-isc: Drop v4l2_subdev_link_validate() for video devices

The v4l2_subdev_link_validate() function is a helper designed to
validate links whose sink is a subdev. When called on a link whose sink
is a video device, it only prints a warning and returns. As the
microchip-isc driver implements manual validate of the subdev to video
device link, we can just drop the v4l2_subdev_link_validate() to avoid
the warning.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
11 months agomedia: dt-bindings: qcom,sc7280-venus: Allow one IOMMU entry
Luca Weiss [Fri, 12 Apr 2024 14:19:50 +0000 (16:19 +0200)]
media: dt-bindings: qcom,sc7280-venus: Allow one IOMMU entry

Some SC7280-based boards crash when providing the "secure_non_pixel"
context bank, so allow only one iommu in the bindings also.

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: venus: firmware: Use iommu_paging_domain_alloc()
Lu Baolu [Mon, 12 Aug 2024 07:21:05 +0000 (15:21 +0800)]
media: venus: firmware: Use iommu_paging_domain_alloc()

An iommu domain is allocated in venus_firmware_init() and is attached to
core->fw.dev in the same function. Use iommu_paging_domain_alloc() to
make it explicit.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20240610085555.88197-10-baolu.lu@linux.intel.com
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: venus: Convert one-element-arrays to flex-arrays
Ricardo Ribalda [Wed, 14 Aug 2024 11:39:30 +0000 (11:39 +0000)]
media: venus: Convert one-element-arrays to flex-arrays

This structures are not used, and have a single element array at the end
of them.

This fix the following cocci warnings:
drivers/media/platform/qcom/venus/hfi_helper.h:764:5-15: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_helper.h:1041:5-15: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_helper.h:1088:39-51: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_helper.h:1093:5-22: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_helper.h:1144:4-8: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_helper.h:1239:4-8: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_helper.h:1272:4-13: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_cmds.h:85:5-16: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_cmds.h:180:5-9: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/media/platform/qcom/venus/hfi_cmds.h:189:5-9: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: venus: Refactor hfi_buffer_alloc_mode_supported
Ricardo Ribalda [Wed, 14 Aug 2024 11:39:29 +0000 (11:39 +0000)]
media: venus: Refactor hfi_buffer_alloc_mode_supported

Replace the old style single element array at the end of the struct with
a flex array.

The code does not allocate this structure, so the size change should not
be a problem.

This fixes the following cocci warning:
drivers/media/platform/qcom/venus/hfi_helper.h:1233:5-9: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Acked-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: venus: Refactor hfi_session_fill_buffer_pkt
Ricardo Ribalda [Wed, 14 Aug 2024 11:39:28 +0000 (11:39 +0000)]
media: venus: Refactor hfi_session_fill_buffer_pkt

The single data array data[1] is only used to save the extradata_size.
Replace it with a single element field.

This fixes the following cocci warning:
drivers/media/platform/qcom/venus/hfi_cmds.h:175:5-9: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Acked-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: venus: Refactor hfi_sys_get_property_pkt
Ricardo Ribalda [Wed, 14 Aug 2024 11:39:27 +0000 (11:39 +0000)]
media: venus: Refactor hfi_sys_get_property_pkt

Replace a single length element array with an element.

This fixes the following cocci warning:
drivers/media/platform/qcom/venus/hfi_cmds.h:77:5-9: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Acked-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: venus: Refactor hfi_session_empty_buffer_compressed_pkt
Ricardo Ribalda [Wed, 14 Aug 2024 11:39:26 +0000 (11:39 +0000)]
media: venus: Refactor hfi_session_empty_buffer_compressed_pkt

The single element array data[1] is never used. Replace it with a
padding field of the same size.

This fixes the following cocci warning:
drivers/media/platform/qcom/venus/hfi_cmds.h:146:5-9: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Acked-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: venus: Refactor hfi_session_empty_buffer_uncompressed_plane0_pkt
Ricardo Ribalda [Wed, 14 Aug 2024 11:39:25 +0000 (11:39 +0000)]
media: venus: Refactor hfi_session_empty_buffer_uncompressed_plane0_pkt

The single element array data[1] is never used. Replace it with a
padding field of the same size.

This fixes the following cocci error:
drivers/media/platform/qcom/venus/hfi_cmds.h:163:5-9: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Acked-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: venus: Refactor struct hfi_uncompressed_format_supported
Ricardo Ribalda [Wed, 14 Aug 2024 11:39:24 +0000 (11:39 +0000)]
media: venus: Refactor struct hfi_uncompressed_format_supported

plane_info is not a typical array, the data is not contiguous:
pinfo = (void *)pinfo + sizeof(*constr) * num_planes +
2 * sizeof(u32);

Replace the single element array with a single element field.

This fixes the following cocci warning:
drivers/media/platform/qcom/venus/hfi_helper.h:1009:36-46: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Acked-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: venus: Refactor struct hfi_session_get_property_pkt
Ricardo Ribalda [Wed, 14 Aug 2024 11:39:23 +0000 (11:39 +0000)]
media: venus: Refactor struct hfi_session_get_property_pkt

The struct hfi_session_get_property_pkt is always used to fetch a
single property. Make that explicit in the code and avoid a single
element array at the end of the struct.

This change fixes the following cocci warning:
drivers/media/platform/qcom/venus/hfi_cmds.h:194:5-9: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Acked-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: venus: Refactor struct hfi_uncompressed_plane_info
Ricardo Ribalda [Wed, 14 Aug 2024 11:39:22 +0000 (11:39 +0000)]
media: venus: Refactor struct hfi_uncompressed_plane_info

This field is never used, but if we remove it we would change the size
of the struct and can lead to behavior change. Stay on the safe side by
replacing the single element array with a single element field.

This fixes the following cocci warning:
drivers/media/platform/qcom/venus/hfi_helper.h:1003:43-60: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Acked-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: venus: Constify struct dec_bufsize_ops and enc_bufsize_ops
Christophe JAILLET [Sun, 2 Jun 2024 14:27:34 +0000 (16:27 +0200)]
media: venus: Constify struct dec_bufsize_ops and enc_bufsize_ops

"struct dec_bufsize_ops and "struct enc_bufsize_ops" are not modified in
this driver.

Constifying these structures moves some data to a read-only section, so
increase overall security.

On a x86_64, with allmodconfig:
Before:
   text    data     bss     dec     hex filename
  12494     822       0   13316    3404 drivers/media/platform/qcom/venus/hfi_plat_bufs_v6.o

After:
   text    data     bss     dec     hex filename
  12766     566       0   13332    3414 drivers/media/platform/qcom/venus/hfi_plat_bufs_v6.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: venus: fix use after free bug in venus_remove due to race condition
Zheng Wang [Tue, 18 Jun 2024 09:25:59 +0000 (14:55 +0530)]
media: venus: fix use after free bug in venus_remove due to race condition

in venus_probe, core->work is bound with venus_sys_error_handler, which is
used to handle error. The code use core->sys_err_done to make sync work.
The core->work is started in venus_event_notify.

If we call venus_remove, there might be an unfished work. The possible
sequence is as follows:

CPU0                  CPU1

                     |venus_sys_error_handler
venus_remove         |
hfi_destroy    |
venus_hfi_destroy  |
kfree(hdev);      |
                     |hfi_reinit
 |venus_hfi_queues_reinit
                     |//use hdev

Fix it by canceling the work in venus_remove.

Cc: stable@vger.kernel.org
Fixes: af2c3834c8ca ("[media] media: venus: adding core part and helper functions")
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: verisilicon: Move Rockchip AV1 hardware drivers to the corresponding option
Alexander Stein [Fri, 21 Jun 2024 10:50:23 +0000 (12:50 +0200)]
media: verisilicon: Move Rockchip AV1 hardware drivers to the corresponding option

There is no need to compile the Rockchip specific AV1 drivers if
CONFIG_VIDEO_HANTRO_ROCKCHIP is not set.
All the driver functions are only referenced by rockchip_vpu_hw.c which
is already under this option.

Fixes: 727a400686a2 ("media: verisilicon: Add Rockchip AV1 decoder")
Fixes: d8ebe59e7b36 ("media: verisilicon: Add film grain feature to AV1 driver")
Fixes: c0d0e579db4e ("media: verisilicon: Add AV1 entropy helpers")
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: verisilicon: Move Rockchip hardware drivers to the corresponding option
Alexander Stein [Fri, 21 Jun 2024 10:50:22 +0000 (12:50 +0200)]
media: verisilicon: Move Rockchip hardware drivers to the corresponding option

There is no need to compile the Rockchip specific drivers if
CONFIG_VIDEO_HANTRO_ROCKCHIP is not set.
All the driver functions are only referenced by rockchip_vpu_hw.c which
is already under this option.

Fixes: c9caebd57b3a ("media: hantro: merge Rockchip platform drivers")
Fixes: c07665f99386 ("media: hantro: Add H.264 support for Rockchip VDPU2")
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: verisilicon: AV1: Correct some sizes/positions on register fields
Benjamin Gaignard [Tue, 21 May 2024 15:26:03 +0000 (17:26 +0200)]
media: verisilicon: AV1: Correct some sizes/positions on register fields

Some fields aren't well positioned or with an incorrect size inside the
hardware registers. Fix them.

This doesn't impact the Fluster score.

Fixes: 727a400686a2 ("media: verisilicon: Add Rockchip AV1 decoder")
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: verisilicon: Fix auxiliary buffer allocation size
Benjamin Gaignard [Thu, 28 Mar 2024 09:34:39 +0000 (10:34 +0100)]
media: verisilicon: Fix auxiliary buffer allocation size

Use v4l2_av1_tile_info->tile_cols to get the number of columns
in the frame and make auxiliary buffer memory size computation
more accurate.

Fixes: 727a400686a2 ("media: verisilicon: Add Rockchip AV1 decoder")
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: verisilicon: AV1: Be more flexible with postproc capabilities
Benjamin Gaignard [Thu, 28 Mar 2024 09:34:38 +0000 (10:34 +0100)]
media: verisilicon: AV1: Be more flexible with postproc capabilities

The RK3588 post-processor block is able to convert 10-bit pixel-formats
into 8-bit pixel-formats.

Fixes: 003afda97c65 ("media: verisilicon: Enable AV1 decoder on rk3588")
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: coda: cast an operand of multiplication to a larger type
Anastasia Belova [Mon, 5 Feb 2024 15:23:50 +0000 (18:23 +0300)]
media: coda: cast an operand of multiplication to a larger type

If the width and height are 0xffff (or close), the result of a
multiplication will overflow.
Cast to a larger type to avoid undefined behavior.

Such values are possible in CODA7, but unlikely.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 918c66fd4126 ("[media] coda: add CODA7541 decoding support")
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: vicodec: allow en/decoder cmd w/o CAPTURE
Deborah Brouwer [Thu, 9 Nov 2023 18:48:38 +0000 (10:48 -0800)]
media: vicodec: allow en/decoder cmd w/o CAPTURE

Vicodec will ignore en/decoder commands if the CAPTURE queue is not
streaming. But this prevents CMD_STOP from being used during a dynamic
resolution change to mark the last source buffer. Since CMD_STOP is
ignored, but doesn’t fail, there is no warning that the command needs to
be resent, and CAPTURE will continue to attempt to dequeue buffers
waiting, futilely, for one with V4L2_BUF_FLAG_LAST.

Fix this problem by carrying out en/decoder commands even if CAPTURE is
not streaming.

Fixes: d17589afa9706 vicodec: improve handling of ENC_CMD_STOP/START
Reported by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>