platform/kernel/linux-starfive.git
10 months agomedia: ov2680: Fix ov2680_bayer_order()
Hans de Goede [Thu, 3 Aug 2023 09:33:17 +0000 (11:33 +0200)]
media: ov2680: Fix ov2680_bayer_order()

The index into ov2680_hv_flip_bayer_order[] should be 0-3, but
ov2680_bayer_order() was using 0 + BIT(2) + (BIT(2) << 1) as
max index, while the intention was to use: 0 + 1 + 2 as max index.

Fix the index calculation in ov2680_bayer_order(), while at it
also just use the ctrl values rather then reading them back using
a slow i2c-read transaction.

This also allows making the function void, since there now are
no more i2c-reads to error check.

Note the check for the ctrls being NULL is there to allow
adding an ov2680_fill_format() helper later, which will call
ov2680_set_bayer_order() during probe() before the ctrls are created.

[Sakari Ailus: Change all users of ov2680_set_bayer_order() here]

Fixes: 3ee47cad3e69 ("media: ov2680: Add Omnivision OV2680 sensor driver")
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-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>
10 months agomedia: ov2680: Remove auto-gain and auto-exposure controls
Hans de Goede [Thu, 3 Aug 2023 09:33:16 +0000 (11:33 +0200)]
media: ov2680: Remove auto-gain and auto-exposure controls

Quoting the OV2680 datasheet:

"3.2 exposure and gain control

In the OV2680, the exposure time and gain are set manually from an external
controller. The OV2680 supports manual gain and exposure control only for
normal applications, no auto mode."

And indeed testing with the atomisp_ov2680 fork of ov2680.c has shown that
auto-exposure and auto-gain do not work.

Note that the code setting the auto-exposure flag was broken, callers
of ov2680_exposure_set() were directly passing !!ctrls->auto_exp->val as
"bool auto_exp" value, but ctrls->auto_exp is a menu control with:

enum  v4l2_exposure_auto_type {
        V4L2_EXPOSURE_AUTO = 0,
        V4L2_EXPOSURE_MANUAL = 1,
...

So instead of passing !!ctrls->auto_exp->val they should have been passing
ctrls->auto_exp->val == V4L2_EXPOSURE_AUTO, iow the passed value was
inverted of what it should have been.

Also remove ov2680_g_volatile_ctrl() since without auto support the gain
and exposure controls are not volatile.

This also fixes the control values not being properly applied in
ov2680_mode_set(). The 800x600 mode register-list also sets gain,
exposure and vflip overriding the last set ctrl values.

ov2680_mode_set() does call ov2680_gain_set() and ov2680_exposure_set()
but did this before writing the mode register-list, so these values
would still be overridden by the mode register-list.

Add a v4l2_ctrl_handler_setup() call after writing the mode register-list
to restore all ctrl values. Also remove the ctrls->gain->is_new check from
ov2680_gain_set() so that the gain always gets restored properly.

Last since ov2680_mode_set() now calls v4l2_ctrl_handler_setup(), remove
the v4l2_ctrl_handler_setup() call after ov2680_mode_restore() since
ov2680_mode_restore() calls ov2680_mode_set().

Fixes: 3ee47cad3e69 ("media: ov2680: Add Omnivision OV2680 sensor driver")
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-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>
10 months agomedia: Documentation: Fix [GS]_ROUTING documentation
Tomi Valkeinen [Thu, 20 Jul 2023 08:08:28 +0000 (10:08 +0200)]
media: Documentation: Fix [GS]_ROUTING documentation

Add mention that successful VIDIOC_SUBDEV_G_ROUTING call will update
'num_routes' and remove mention about non-existing streams, which is
incorrect.

Fixes: ea73eda50813 ("media: Documentation: Add GS_ROUTING documentation")
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: ov5640: Fix initial RESETB state and annotate timings
Marek Vasut [Mon, 24 Jul 2023 22:21:16 +0000 (00:21 +0200)]
media: ov5640: Fix initial RESETB state and annotate timings

The initial state of RESETB input signal of OV5640 should be
asserted, i.e. the sensor should be in reset. This is not the
case, make it so.

Since the subsequent assertion of RESETB signal is no longer
necessary and the timing of the power sequencing could be
slightly adjusted, add annotations to the delays which match
OV5640 datasheet rev. 2.03, both:
  figure 2-3 power up timing with internal DVDD
  figure 2-4 power up timing with external DVDD source

The 5..10ms delay between PWDN assertion and RESETB assertion
is not even documented in the power sequencing diagram, and
with this reset fix, it is no longer even necessary.

Fixes: 19a81c1426c1 ("[media] add Omnivision OV5640 sensor driver")
Reported-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Tested-by: Jai Luthra <j-luthra@ti.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: platform: ti: fix the return value handle for platform_get_irq()
Ruan Jinjie [Mon, 31 Jul 2023 12:02:12 +0000 (14:02 +0200)]
media: platform: ti: fix the return value handle for platform_get_irq()

There is no possible for platform_get_irq() to return 0,
and the return value of platform_get_irq() is more sensible
to show the error reason.

Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.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>
10 months agomedia: verisilicon: Do not check for 0 return after calling platform_get_irq()
Ruan Jinjie [Thu, 3 Aug 2023 02:46:45 +0000 (04:46 +0200)]
media: verisilicon: Do not check for 0 return after calling platform_get_irq()

It is not possible for platform_get_irq() or platform_get_irq_byname()
to return 0. Use the return value from platform_get_irq()
or platform_get_irq_byname().

Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: camif-core: Do not check for 0 return after calling platform_get_irq()
Ruan Jinjie [Thu, 3 Aug 2023 02:46:44 +0000 (04:46 +0200)]
media: camif-core: Do not check for 0 return after calling platform_get_irq()

It is not possible for platform_get_irq() to return 0. Use the
return value from platform_get_irq().

Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: davinci: vpif_capture: fix error return code in vpif_probe()
Yang Yingliang [Thu, 3 Aug 2023 02:18:35 +0000 (04:18 +0200)]
media: davinci: vpif_capture: fix error return code in vpif_probe()

Set error return code, when get platform data failed.

Fixes: b4a4547371b9 ("media: davinci: Init async notifier after registering V4L2 device")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Lad Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: ov5640: Enable MIPI interface in ov5640_set_power_mipi()
Marek Vasut [Wed, 2 Aug 2023 14:47:25 +0000 (16:47 +0200)]
media: ov5640: Enable MIPI interface in ov5640_set_power_mipi()

Set OV5640_REG_IO_MIPI_CTRL00 bit 2 to 1 instead of 0, since 1 means
MIPI CSI2 interface, while 0 means CPI parallel interface.

In the ov5640_set_power_mipi() the interface should obviously be set
to MIPI CSI2 since this functions is used to power up the sensor when
operated in MIPI CSI2 mode. The sensor should not be in CPI mode in
that case.

This fixes a corner case where capturing the first frame on i.MX8MN
with CSI/ISI resulted in corrupted frame.

Fixes: aa4bb8b8838f ("media: ov5640: Re-work MIPI startup sequence")
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> # [Test on imx6q]
Signed-off-by: Marek Vasut <marex@denx.de>
Tested-by: Jai Luthra <j-luthra@ti.com> # [Test on bplay, sk-am62]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: pci: intel: Add IVSC support for IPU bridge driver
Wentong Wu [Thu, 3 Aug 2023 05:38:14 +0000 (07:38 +0200)]
media: pci: intel: Add IVSC support for IPU bridge driver

Previously on ACPI platforms, sensors that are intended to be connected
to an IPU device for use with the ipu3-cio2 driver lacking the necessary
connection information in firmware. IPU bridge driver is to connect
sensors to IPU device via software nodes.

Currently IVSC located between IPU device and sensors is available in
existing commercial platforms from multiple OEMs. But the connection
information between them in firmware is also not enough to build V4L2
connection graph. This patch parses the connection properties from the
SSDB buffer in DSDT and build the connection using software nodes.

IVSC driver is based on MEI framework (previously known as HECI), it
has two MEI clients, MEI CSI and MEI ACE. Both clients are used to
communicate messages with IVSC firmware. Linux abstracts MEI client
as a device, whose bus type is MEI. And the device is addressed by a
GUID/UUID which is part of the device name of MEI client. After figured
out MEI CSI via the UUID composed device name, this patch setup the
connection between MEI CSI and IPU, and the connection between MEI CSI
and sensor via software nodes.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: pci: intel: ivsc: Add ACE submodule
Wentong Wu [Sat, 29 Jul 2023 11:52:54 +0000 (13:52 +0200)]
media: pci: intel: ivsc: Add ACE submodule

ACE is a submodule of IVSC which controls camera sensor's
ownership, belonging to host or IVSC. When IVSC owns camera
sensor, it is for algorithm computing. When host wants to
control camera sensor, ACE module needs to be informed of
ownership with defined interface.

The interface is via MEI. There is a separate MEI UUID, which
this driver uses to enumerate.

To switch ownership of camera sensor between IVSC and host,
the caller specifies the defined ownership information which
will be sent to firmware by sending MEI command.

Device link(device_link_add) is used to set the right camera
sensor ownership before accessing the sensor via I2C. With
DL_FLAG_PM_RUNTIME and DL_FLAG_RPM_ACTIVE, the supplier device
will be PM runtime resumed before the consumer(camera sensor).
So use runtime PM callbacks to transfer the ownership between
host and IVSC.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: pci: intel: ivsc: Add CSI submodule
Wentong Wu [Sat, 8 Jul 2023 14:52:14 +0000 (16:52 +0200)]
media: pci: intel: ivsc: Add CSI submodule

CSI is a submodule of IVSC which can route camera sensor data
to the outbound MIPI CSI-2 interface.

The interface communicating with firmware is via MEI. There is
a separate MEI UUID, which this driver uses to enumerate.

To route camera sensor data to host, the information of link
frequency and number of data lanes is sent to firmware by
sending MEI command when starting stream.

CSI also provides a privacy mode. When privacy mode is turned
on, camera sensor can't be used. This means that both IVSC and
host Image Processing Unit(IPU) can't get image data. And when
this mode is turned on, user is notified via v4l2 control
callback.

Link: https://lore.kernel.org/linux-media/20230803115550.1601965-2-sakari.ailus@linux.intel.com
Signed-off-by: Wentong Wu <wentong.wu@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: i2c: Add driver for DW9719 VCM
Daniel Scally [Sat, 8 Jul 2023 14:52:14 +0000 (16:52 +0200)]
media: i2c: Add driver for DW9719 VCM

Add a driver for the DW9719 VCM. The driver creates a v4l2 subdevice
and registers a control to set the desired focus.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Daniel Scally <djrscally@gmail.com>
Signed-off-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>
10 months agomedia: atomisp: csi2-bridge: Add support for VCM I2C-client instantiation
Hans de Goede [Wed, 5 Jul 2023 21:30:10 +0000 (23:30 +0200)]
media: atomisp: csi2-bridge: Add support for VCM I2C-client instantiation

Fill sensor->vcm_type and call intel_cio2_bridge_instantiate_vcm() from
the v4l2-async bound op so that an I2C-client will be instatiated for
the VCM.

Note unfortunately on atomisp the _DSM to get the VCM type sometimes
returns a VCM even though there is none. Since VCMs are typically only
used together with certain sensors, work around this by adding a vcm
field to atomisp_sensor_config and only check for a VCM when that is set.

Signed-off-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>
10 months agomedia: atomisp: csi2-bridge: Add dev_name() to acpi_handle_info() logging
Hans de Goede [Wed, 5 Jul 2023 21:30:09 +0000 (23:30 +0200)]
media: atomisp: csi2-bridge: Add dev_name() to acpi_handle_info() logging

acpi_handle_info() uses the ACPI path to the handle as prefix for messages
e.g. : "\_SB_.I2C2.CAM8".

This makes it hard for users to figure out which csi2-bridge messages
belong to which sensor since the actual sensor drivers uses the ACPI
device name (typically "HID:00") for logging.

Extend the acpi_handle_info() (and err and warn) logging to also log
the device name to make it easier to match csi2-bridge messages with
sensor driver log messages.

Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: atomisp: csi2-bridge: Switch to new common ipu_bridge_init()
Hans de Goede [Wed, 5 Jul 2023 21:30:08 +0000 (23:30 +0200)]
media: atomisp: csi2-bridge: Switch to new common ipu_bridge_init()

Remove the duplicate IPU ACPI bridge code and use the new
shared ipu_bridge_init() functionality.

Note this will also use / assume v4l2-async device instantiation for
ov5693 sensors on atomisp devices since ipu_supported_sensors[]
already contains a match for this.

This is fine since recent atomisp improvements allow the atomisp code
to work with generic v4l2 sensor drivers and using an unmodified
drivers/media/i2c/ov5693.c has been successfully tested on
an Acer Iconia W4 820 tablet with an ISP2400 + OV5693 sensor.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-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>
10 months agomedia: ipu-bridge: Add a runtime-pm device-link between VCM and sensor
Hans de Goede [Wed, 5 Jul 2023 21:30:05 +0000 (23:30 +0200)]
media: ipu-bridge: Add a runtime-pm device-link between VCM and sensor

In most cases when a VCM is used there is a single integrated module
with the sensor + VCM + lens. This means that the sensor and VCM often
share regulators and possibly also something like a powerdown pin.

In the ACPI tables this is modelled as a single ACPI device with
multiple I2cSerialBus resources.

On atomisp devices the regulators and clks are modelled as ACPI
power-resources, which are controlled by the (ACPI) power state
of the sensor. So the sensor must be in D0 power state for the VCM
to work.

To make this work add a device-link with DL_FLAG_PM_RUNTIME flag
so that the sensor will automatically be runtime-resumed whenever
the VCM is runtime-resumed.

This requires the probing of the VCM and thus the creation of the VCM
I2C-client to be delayed till after the sensor driver has bound.

Move the instantiation of the VCM I2C-client to the v4l2_async_notifier
bound op, so that it is done after the sensor driver has bound; and
add code to add the device-link.

This fixes the problem with the shared ACPI power-resources on atomisp2
and this avoids the need for VCM related workarounds on IPU3 / IPU6.

E.g. until now the dw9719 driver needed to get and control a Vsio
(V sensor IO) regulator since that needs to be enabled to enable I2C
pass-through on the PMIC on the sensor module. So the driver was
controlling this regulator even though the actual dw9719 chip has no
Vsio pin / power-plane.

This also removes the need for ipu_bridge_init() to return
-EPROBE_DEFER since the VCM is now instantiated later.

Reviewed-by: Andy Shevchenko <andy@kernel.org>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Tested-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-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>
10 months agomedia: ipu-bridge: Add GalaxyCore GC0310 to ipu_supported_sensors[]
Hans de Goede [Wed, 5 Jul 2023 21:30:04 +0000 (23:30 +0200)]
media: ipu-bridge: Add GalaxyCore GC0310 to ipu_supported_sensors[]

The GalaxyCore GC0310 is used together with the atomisp on various
devices, add it to ipu_supported_sensors[].

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-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>
10 months agomedia: ipu-bridge: Move ipu-bridge.h to include/media/
Hans de Goede [Wed, 5 Jul 2023 21:30:03 +0000 (23:30 +0200)]
media: ipu-bridge: Move ipu-bridge.h to include/media/

Move ipu-bridge.h to include/media/, so that it can also be used by
the atomisp code.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-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>
10 months agomedia: ipu-bridge: Add a parse_sensor_fwnode callback to ipu_bridge_init()
Hans de Goede [Wed, 5 Jul 2023 21:30:02 +0000 (23:30 +0200)]
media: ipu-bridge: Add a parse_sensor_fwnode callback to ipu_bridge_init()

Add a parse_sensor_fwnode() callback to ipu_bridge_init(), so that
ipu_bridge_init() can be used with other sensor fwnode parse functions
then just ipu_bridge_parse_ssdb().

This will allow the ipu3-bridge code to also be used by the atomisp
driver.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: ipu-bridge: Drop early setting of sensor->adev
Hans de Goede [Wed, 5 Jul 2023 21:30:01 +0000 (23:30 +0200)]
media: ipu-bridge: Drop early setting of sensor->adev

sensor->adev is no longer dereferenced before it is permanently set by:

sensor->adev = acpi_dev_get(adev);

So the early assignment with a borrowed reference can be dropped.

Signed-off-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>
10 months agomedia: ipu-bridge: Add a ipu_bridge_parse_ssdb() helper function
Hans de Goede [Wed, 5 Jul 2023 21:30:00 +0000 (23:30 +0200)]
media: ipu-bridge: Add a ipu_bridge_parse_ssdb() helper function

The code to go from ACPI sensor info to a fwnode-tree with connector
nodes and endpoint properties is 99% the same for the atomisp2 and
the IPU3.

The main difference is that atomisp2 devices do not have a SSDB table
with various info.

Abstract out the parsing of the sensor's ACPI fwnode into a helper
function and store the parsed results, rather then the raw SSDB
in struct ipu_sensor.

This is a preparation patch for making the ipu-bridge code more generic
so that it can be shared with the atomisp driver.

Reviewed-by: Andy Shevchenko <andy@kernel.org>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-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>
10 months agomedia: ipu-bridge: Only keep PLD around while parsing
Hans de Goede [Wed, 5 Jul 2023 21:29:59 +0000 (23:29 +0200)]
media: ipu-bridge: Only keep PLD around while parsing

There is no need to keep a reference to the PLD struct around,
it is only used once the get the sensor orientation.

Make ipu_bridge_parse_orientation() also get + put the PLD.

This is a preparation patch for making the ipu-bridge code more generic
so that it can be shared with the atomisp driver.

Reviewed-by: Andy Shevchenko <andy@kernel.org>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-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>
10 months agomedia: ipu-bridge: Store dev pointer in struct ipu_bridge
Hans de Goede [Wed, 5 Jul 2023 21:29:58 +0000 (23:29 +0200)]
media: ipu-bridge: Store dev pointer in struct ipu_bridge

Store the dev pointer in struct ipu_bridge instead of passing it
around 3 levels deep.

This takes up slightly more memory but further patches in this series
add more data which needs to be passed around making passing
everything as arguments cumbersome and those further patches also
add data to struct ipu_bridge.

To be consistent with these upcoming patches also add
the dev pointer to struct ipu_bridge.

Reviewed-by: Andy Shevchenko <andy@kernel.org>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-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>
10 months agomedia: ipu-bridge: Move initialization of node_names.vcm to ipu_bridge_init_swnode_na...
Hans de Goede [Wed, 5 Jul 2023 21:29:55 +0000 (23:29 +0200)]
media: ipu-bridge: Move initialization of node_names.vcm to ipu_bridge_init_swnode_names()

Move initialization of node_names.vcm to ipu_bridge_init_swnode_names()
where it belongs.

And make the initialization of nodes[SWNODE_VCM] unconditional,
ipu_bridge_init_swnode_group() takes care of not registering it
when there is no VCM.

Reviewed-by: Andy Shevchenko <andy@kernel.org>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-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>
10 months agomedia: ipu-bridge: Move initialization of node_names.vcm to ipu_bridge_init_swnode_na...
Hans de Goede [Wed, 5 Jul 2023 21:29:55 +0000 (23:29 +0200)]
media: ipu-bridge: Move initialization of node_names.vcm to ipu_bridge_init_swnode_names()

Move initialization of node_names.vcm to ipu_bridge_init_swnode_names()
where it belongs.

And make the initialization of nodes[SWNODE_VCM] unconditional,
ipu_bridge_init_swnode_group() takes care of not registering it
when there is no VCM.

Reviewed-by: Andy Shevchenko <andy@kernel.org>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-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>
10 months agomedia: ipu-bridge: Do not use on stack memory for software_node.name field
Hans de Goede [Wed, 5 Jul 2023 21:29:54 +0000 (23:29 +0200)]
media: ipu-bridge: Do not use on stack memory for software_node.name field

Commit 567f97bd381f ("media: ipu3-cio2: support multiple sensors and VCMs
with same HID") introduced an on stack vcm_name and then uses this for
the name field of the software_node struct used for the vcm.

But the software_node struct is much longer lived then the current
stack-frame, so this is no good.

Instead extend the ipu_node_names struct with an extra field to store
the vcm software_node name and use that.

Note this also changes the length of the allocated buffer from
ACPI_ID_LEN + 4 to 16. the name is filled with "<ipu_vcm_types[x]>-%u"
where ipu_vcm_types[x] is not an ACPI_ID. The maximum length of
the strings in the ipu_vcm_types[] array is 11 + 5 bytes for "-255\0"
means 16 bytes are needed in the worst case scenario.

Fixes: 567f97bd381f ("media: ipu3-cio2: support multiple sensors and VCMs with same HID")
Cc: Bingbu Cao <bingbu.cao@intel.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-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>
10 months agomedia: ipu-bridge: Fix null pointer deref on SSDB/PLD parsing warnings
Hans de Goede [Wed, 5 Jul 2023 21:29:53 +0000 (23:29 +0200)]
media: ipu-bridge: Fix null pointer deref on SSDB/PLD parsing warnings

When ipu_bridge_parse_rotation() and ipu_bridge_parse_orientation() run
sensor->adev is not set yet.

So if either of the dev_warn() calls about unknown values are hit this
will lead to a NULL pointer deref.

Set sensor->adev earlier, with a borrowed ref to avoid making unrolling
on errors harder, to fix this.

Fixes: 485aa3df0dff ("media: ipu3-cio2: Parse sensor orientation and rotation")
Cc: Fabian Wüthrich <me@fabwu.ch>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: v4l: async: Avoid a goto in loop implementation
Sakari Ailus [Sat, 29 Jul 2023 11:52:14 +0000 (13:52 +0200)]
media: v4l: async: Avoid a goto in loop implementation

Replace a goto-based loop by a while loop.

Suggested-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: rcar-csi2: Add support for C-PHY on R-Car V4H
Niklas Söderlund [Sat, 15 Jul 2023 20:12:39 +0000 (22:12 +0200)]
media: rcar-csi2: Add support for C-PHY on R-Car V4H

Add support for C-PHY on R-Car V4H. While the V4H supports both D-PHY
and C-PHY this patch only adds support for the C-PHY mode due to lack of
documentation and hardware to test on.

The V4H is the first Gen4 device that is enabled in the rcar-csi2
driver. There is much overlap with the Gen3 driver, the primary
difference is in how the receiver is started. The V4H have a much larger
register space and some addresses overlap with Gen3.

[Sakari Ailus: Use div_u64() to divide a 64-bit integer.]

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: i2c: imx219: Simplify code handling in s_fmt
Jacopo Mondi [Mon, 10 Jul 2023 15:52:03 +0000 (17:52 +0200)]
media: i2c: imx219: Simplify code handling in s_fmt

The imx219_set_pad_format() function adjusts the media bus code provided
through the v4l2_subdev_format parameter to a media bus code known
to be supported by the sensor.

The same exact operation is performed by the imx219_get_format_code()
function which called by imx219_update_pad_format(), which is in the
imx219_set_pad_format() call path.

Remove the duplicated operation and simplify imx219_set_pad_format().

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.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>
10 months agomedia: i2c: imx219: Simplify format assignment
Jacopo Mondi [Mon, 10 Jul 2023 15:52:02 +0000 (17:52 +0200)]
media: i2c: imx219: Simplify format assignment

The set_fmt and init_cfg functions both fills a v4l2_mbus_framefmt
instance, passing in the mode and the media bus code. While set_fmt
uses function helpers, init_cfg open-codes the assignments.

Simplify the format initialization by moving it to a common helper.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.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>
10 months agomedia: i2c: imx219: Use subdev active state
Jacopo Mondi [Mon, 10 Jul 2023 15:52:01 +0000 (17:52 +0200)]
media: i2c: imx219: Use subdev active state

Port the imx219 sensor driver to use the subdev active state.

Move all the format configuration to the subdevice state and simplify
the format handling, locking and initialization.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.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>
10 months agomedia: i2c: imx219: Fix colorspace info
Jacopo Mondi [Mon, 10 Jul 2023 15:52:00 +0000 (17:52 +0200)]
media: i2c: imx219: Fix colorspace info

The IMX219 is a RAW sensor. Fix the colorspace configuration by
using V4L2_COLORSPACE_RAW and adjust the quantization and transfer
function values. Drop ycbcr_enc as it doesn't apply to RAW sensors.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: i2c: imx219: Complete default format initialization
Jacopo Mondi [Mon, 10 Jul 2023 15:51:59 +0000 (17:51 +0200)]
media: i2c: imx219: Complete default format initialization

Complete the default format initialization in init_cfg() filling in
the fields for the colorspace configuration copied from
imx219_set_default_format().

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: i2c: imx219: Switch from open to init_cfg
Jean-Michel Hautbois [Mon, 10 Jul 2023 15:51:58 +0000 (17:51 +0200)]
media: i2c: imx219: Switch from open to init_cfg

Use the init_cfg pad level operation instead of the internal subdev
open operation to set default formats on the pads.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.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>
10 months agomedia: i2c: imx219: Rename mbus codes array
Jean-Michel Hautbois [Mon, 10 Jul 2023 15:51:57 +0000 (17:51 +0200)]
media: i2c: imx219: Rename mbus codes array

The imx219 is using the name "codes" for the mbus formats array. The
name is too generic and not easy to read and follow in the code. Change
it to imx219_mbus_formats.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Tommaso Merciai <tomm.merciai@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: Remove ov_16bit_addr_reg_helpers.h
Hans de Goede [Tue, 27 Jun 2023 12:51:08 +0000 (14:51 +0200)]
media: Remove ov_16bit_addr_reg_helpers.h

The helpers in this header are not used anywhere anymore,
they have been superseded by the new CCI register access helpers.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-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>
10 months agomedia: atomisp: ov2680: Convert to new CCI register access helpers
Hans de Goede [Tue, 27 Jun 2023 12:51:07 +0000 (14:51 +0200)]
media: atomisp: ov2680: Convert to new CCI register access helpers

Use the new comon CCI register access helpers to replace the private
register access helpers in the ov2680 driver.

While at it also switch to using the same register address defines
as the standard drivers/media/i2c/ov2680.c driver to make merging
the 2 drivers simpler.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-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>
10 months agomedia: imx290: Convert to new CCI register access helpers
Hans de Goede [Tue, 27 Jun 2023 12:51:06 +0000 (14:51 +0200)]
media: imx290: Convert to new CCI register access helpers

Use the new comon CCI register access helpers to replace the private
register access helpers in the imx290 driver.

[Sakari Ailus: Squashed the patch to address a merge issue in Kconfig]

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-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>
10 months agomedia: ov5693: Convert to new CCI register access helpers
Hans de Goede [Tue, 27 Jun 2023 12:51:05 +0000 (14:51 +0200)]
media: ov5693: Convert to new CCI register access helpers

Use the new comon CCI register access helpers to replace the private
register access helpers in the ov5693 driver.

[Sakari Ailus: Squashed the patch to address a merge issue in Kconfig]

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-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>
10 months agomedia: Add MIPI CCI register access helper functions
Hans de Goede [Tue, 27 Jun 2023 12:51:04 +0000 (14:51 +0200)]
media: Add MIPI CCI register access helper functions

The CSI2 specification specifies a standard method to access camera sensor
registers called "Camera Control Interface (CCI)".

This uses either 8 or 16 bit (big-endian wire order) register addresses
and supports 8, 16, 24 or 32 bit (big-endian wire order) register widths.

Currently a lot of Linux camera sensor drivers all have their own custom
helpers for this, often copy and pasted from other drivers.

Add a set of generic helpers for this so that all sensor drivers can
switch to a single common implementation.

These helpers take an extra optional "int *err" function parameter,
this can be used to chain a bunch of register accesses together with
only a single error check at the end, rather than needing to error
check each individual register access. The first failing call will
set the contents of err to a non 0 value and all other calls will
then become no-ops.

Link: https://lore.kernel.org/linux-media/59aefa7f-7bf9-6736-6040-39551329cd0a@redhat.com/
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Tested-by: Tommaso Merciai <tomm.merciai@gmail.com>
Reviewed-by: Tommaso Merciai <tomm.merciai@gmail.com>
Signed-off-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>
10 months agomedia: subdev: Add debug prints to enable/disable_streams
Tomi Valkeinen [Mon, 19 Jun 2023 11:27:07 +0000 (13:27 +0200)]
media: subdev: Add debug prints to enable/disable_streams

It is often useful to see when streaming for a device is being enabled
or disabled. Add debug prints for this to v4l2_subdev_enable_streams()
and v4l2_subdev_disable_streams().

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: subdev: Constify v4l2_subdev_set_routing_with_fmt() param
Tomi Valkeinen [Mon, 19 Jun 2023 11:27:06 +0000 (13:27 +0200)]
media: subdev: Constify v4l2_subdev_set_routing_with_fmt() param

The routing parameter of v4l2_subdev_set_routing_with_fmt() is missing
'const'. Add it.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: subdev: Drop implicit zeroing of stream field
Tomi Valkeinen [Mon, 19 Jun 2023 11:27:05 +0000 (13:27 +0200)]
media: subdev: Drop implicit zeroing of stream field

Now that the kernel drivers have been fixed to initialize the stream
field, and we have the client capability which the userspace uses to say
it has initialized the stream field, we can drop the implicit zeroing of
the stream field in the various check functions.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: MAINTAINERS: Split sensors and lens drivers, add documentation
Sakari Ailus [Fri, 30 Jun 2023 10:59:41 +0000 (12:59 +0200)]
media: MAINTAINERS: Split sensors and lens drivers, add documentation

Split lens drivers from camera sensor into a new section. This makes it
easier to maintain the list.

Also add documentation related files under the camera sensor entry. Add
the word "CAMERA" to the subject as well since there are many other kinds
of sensors.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: MAINTAINERS: Add entry for V4L2 async and fwnode frameworks
Sakari Ailus [Fri, 30 Jun 2023 10:31:21 +0000 (12:31 +0200)]
media: MAINTAINERS: Add entry for V4L2 async and fwnode frameworks

Add an entry for V4L2 async and fwnode frameworks, with myself as the
maintainer.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: i2c: Remove common dependencies from sensor drivers
Sakari Ailus [Fri, 30 Jun 2023 13:58:55 +0000 (15:58 +0200)]
media: i2c: Remove common dependencies from sensor drivers

As selecting V4L2_FWNODE, MEDIA_CONTROLLER and VIDEO_V4L2_SUBDEV_API are
now selected by the top level menu, they can be dropped from the
individual drivers. Also dropped selecting V4L2_ASYNC for a single driver
as this is already implied by V4L2_FWNODE.

Similarly, the I2C dependency is now also in the top level menu, so remove
it, as well as VIDEO_DEV which isn't needed by camera sensor drivers.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: i2c: Add a camera sensor top level menu
Sakari Ailus [Thu, 15 Jun 2023 08:29:07 +0000 (10:29 +0200)]
media: i2c: Add a camera sensor top level menu

Select V4L2_FWNODE and VIDEO_V4L2_SUBDEV_API for all sensor drivers. This
also adds the options to drivers that don't specifically need them, these
are still seldom used drivers using old APIs. The upside is that these
should now all compile --- many drivers have had missing dependencies.

The "menu" is replaced by selectable "menuconfig" to select the needed
V4L2_FWNODE and VIDEO_V4L2_SUBDEV_API options.

Also select MEDIA_CONTROLLER which VIDEO_V4L2_SUBDEV_API effectively
depends on, and add the I2C dependency to the menu.

Reported-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: stable@vger.kernel.org # for >= 6.1
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: imx: imx7-media-csi: Fix frame sizes enumeration
Laurent Pinchart [Tue, 25 Jul 2023 19:14:45 +0000 (22:14 +0300)]
media: imx: imx7-media-csi: Fix frame sizes enumeration

Enumeration of the minimum, maximum and step values for the image width
does not take hardware constraints into account. Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agoMAINTAINERS: correct file entry in MEDIA DRIVERS FOR FREESCALE IMX7/8
Lukas Bulwahn [Mon, 31 Jul 2023 13:14:27 +0000 (15:14 +0200)]
MAINTAINERS: correct file entry in MEDIA DRIVERS FOR FREESCALE IMX7/8

Commit cd063027c304 ("media: imx: Unstage the imx8mq-mipi-csi2 driver")
adds a file entry for the driver code to MEDIA DRIVERS FOR FREESCALE
IMX7/8, but misses the number '2' suffix in that entry. Hence,
./scripts/get_maintainer.pl --self-test=patterns complains about a broken
reference.

Correct the file entry in MEDIA DRIVERS FOR FREESCALE IMX7/8.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.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>
10 months agomedia: nxp: imx8-isi: Add ISI support for i.MX93
Guoniu.zhou [Thu, 29 Jun 2023 01:36:21 +0000 (09:36 +0800)]
media: nxp: imx8-isi: Add ISI support for i.MX93

i.MX93 uses a different gasket which has different register definitions
compared with i.MX8. Hence implement the gasket callbacks in order to
add ISI support for i.MX93.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.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>
10 months agomedia: nxp: imx8-isi: Move i.MX8 gasket configuration to an ops structure
Guoniu.zhou [Thu, 29 Jun 2023 01:36:20 +0000 (09:36 +0800)]
media: nxp: imx8-isi: Move i.MX8 gasket configuration to an ops structure

The i.MX93 includes an ISI instance compatible with the imx8-isi
driver, but with a different gasket. To prepare for this, make the
gasket configuration modular by moving the code to an ops structure.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.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>
10 months agomedia: dt-bindings: nxp,imx8-isi: Add i.MX93 ISI compatible string
Guoniu.zhou [Thu, 29 Jun 2023 01:36:19 +0000 (09:36 +0800)]
media: dt-bindings: nxp,imx8-isi: Add i.MX93 ISI compatible string

Add the compatible string support for i.MX93 ISI.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tommaso Merciai <tomm.merciai@gmail.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: nxp: Fix wrong return pointer check in mxc_isi_crossbar_init()
Yang Yingliang [Tue, 25 Jul 2023 13:00:24 +0000 (21:00 +0800)]
media: nxp: Fix wrong return pointer check in mxc_isi_crossbar_init()

It should check 'xbar->inputs', when allocate memory for it.

Cc: stable@vger.kernel.org
Fixes: cf21f328fcaf ("media: nxp: Add i.MX8 ISI driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Fabio Estevam <festevam@gmail.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>
10 months agoarm64: defconfig: Drop CONFIG_VIDEO_IMX_MEDIA
Laurent Pinchart [Mon, 24 Apr 2023 09:51:24 +0000 (12:51 +0300)]
arm64: defconfig: Drop CONFIG_VIDEO_IMX_MEDIA

CONFIG_VIDEO_IMX_MEDIA isn't needed on arm64 platforms since commit
9f257f502c2e ("media: imx: Unstage the imx7-media-csi driver") which
moved the last arm64 driver depending on that Kconfig symbol out of
staging. Drop it from the arm64 defconfig.

Fixes: 9f257f502c2e ("media: imx: Unstage the imx7-media-csi driver")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agostaging: media: imx: Merge VIDEO_IMX_CSI into VIDEO_IMX_MEDIA
Laurent Pinchart [Mon, 24 Apr 2023 09:48:32 +0000 (12:48 +0300)]
staging: media: imx: Merge VIDEO_IMX_CSI into VIDEO_IMX_MEDIA

The VIDEO_IMX_MEDIA Kconfig symbol used to select helpers shared between
independent drivers for different i.MX SoCs, and VIDEO_IMX_MEDIA then
selects drivers specific to the i.MX5 and i.MX6. Now that i.MX7 and
i.MX8 support has moved to drivers/media/ and doesn't depend on
VIDEO_IMX_CSI, there's no need to have separate Kconfig options. Merge
VIDEO_IMX_CSI into VIDEO_IMX_MEDIA.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: ds90ub960: Rename RXPORT_MODE_CSI2_ASYNC to RXPORT_MODE_CSI2_NONSYNC
Tomi Valkeinen [Mon, 31 Jul 2023 13:24:43 +0000 (16:24 +0300)]
media: i2c: ds90ub960: Rename RXPORT_MODE_CSI2_ASYNC to RXPORT_MODE_CSI2_NONSYNC

FPD-Link has an operating mode that used to be called "asynchronous" in
the hardware documentation, but that has been changed to non-synchronous
already quite a while back. The ub960 driver still had one instance of
the old naming, so let's rename it.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: ds90ub953: Support non-sync mode
Tomi Valkeinen [Mon, 31 Jul 2023 13:24:42 +0000 (16:24 +0300)]
media: i2c: ds90ub953: Support non-sync mode

Add support for FPD-Link non-sync mode with external clock. The only
thing that needs to be added is the calculation for the clkout.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: ds90ub953: Restructure clkout management
Tomi Valkeinen [Mon, 31 Jul 2023 13:24:41 +0000 (16:24 +0300)]
media: i2c: ds90ub953: Restructure clkout management

Separate clkout calculations and register writes into two functions:
ub953_calc_clkout_params and ub953_write_clkout_regs, and add a struct
ub953_clkout_data that is used to store the clkout parameters.

This simplifies the clkout management.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.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: ds90ub960: Allow FPD-Link async mode
Tomi Valkeinen [Mon, 31 Jul 2023 13:24:40 +0000 (16:24 +0300)]
media: i2c: ds90ub960: Allow FPD-Link async mode

Allow using FPD-Link in async mode. The driver handles it correctly, but
the mode was blocked at probe time as there wasn't HW to test this with.
Now the mode has been tested, and it works.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.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: ds90ub953: Handle V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK
Tomi Valkeinen [Mon, 31 Jul 2023 13:24:39 +0000 (16:24 +0300)]
media: i2c: ds90ub953: Handle V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK

Handle V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK flag to configure the CSI-2 RX
continuous/non-continuous clock register.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: ds90ub913: Use v4l2_fwnode_endpoint_parse()
Tomi Valkeinen [Mon, 31 Jul 2023 13:24:38 +0000 (16:24 +0300)]
media: i2c: ds90ub913: Use v4l2_fwnode_endpoint_parse()

Use v4l2_fwnode_endpoint_parse() to parse the sink endpoint parameters.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: ds90ub953: Use v4l2_fwnode_endpoint_parse()
Tomi Valkeinen [Mon, 31 Jul 2023 13:24:37 +0000 (16:24 +0300)]
media: i2c: ds90ub953: Use v4l2_fwnode_endpoint_parse()

Use v4l2_fwnode_endpoint_parse() to parse the sink endpoint parameters.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: ds90ub960: Configure CSI-2 continuous clock
Tomi Valkeinen [Mon, 31 Jul 2023 13:24:36 +0000 (16:24 +0300)]
media: i2c: ds90ub960: Configure CSI-2 continuous clock

Use 'clock-noncontinuous' from DT to configure the
continuous/non-continuous clock setting for the TX ports.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: ds90ub9x3: Fix sub-device matching
Tomi Valkeinen [Mon, 31 Jul 2023 13:24:35 +0000 (16:24 +0300)]
media: i2c: ds90ub9x3: Fix sub-device matching

Commit 1029939b3782 ("media: v4l: async: Simplify async sub-device fwnode
matching") recently changed how async sub-device matching works. This
breaks the UB9x3 drivers, as they set the subdev.fwnode to an endpoint.
Afaiu, the fix is simply to not set subdev.fwnode at all.

Fixes: 1029939b3782 ("media: v4l: async: Simplify async sub-device fwnode matching")
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: firewire: firedtv-avc.c: replace BUG with proper, error return
Hans Verkuil [Fri, 4 Aug 2023 10:59:41 +0000 (12:59 +0200)]
media: firewire: firedtv-avc.c: replace BUG with proper, error return

This resolves this smatch error:

drivers/media/firewire/firedtv-avc.c:602 avc_tuner_dsd() error: uninitialized symbol 'pos'.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: usb: pvrusb2: fix inconsistent indenting
Hans Verkuil [Fri, 4 Aug 2023 10:59:10 +0000 (12:59 +0200)]
media: usb: pvrusb2: fix inconsistent indenting

This resolves a new smatch warning;

drivers/media/usb/pvrusb2/pvrusb2-hdw.c:3293 pvr2_hdw_get_tuner_status() warn: inconsistent indenting

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: tegra_cec: fix the return value handle for platform_get_irq()
Ruan Jinjie [Tue, 1 Aug 2023 13:52:53 +0000 (21:52 +0800)]
media: tegra_cec: fix the return value handle for platform_get_irq()

There is no possible for platform_get_irq() to return 0,
and the return value of platform_get_irq() is more sensible
to show the error reason.

Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: cx23885: debug cosmetics
Mariusz Bialonczyk [Sun, 30 Jul 2023 18:52:37 +0000 (20:52 +0200)]
media: cx23885: debug cosmetics

This commit is fixing the module in a way that trailing spaces
at the end of the line in the debug/dmesg are gone.

Signed-off-by: Mariusz Bialonczyk <manio@skyboo.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: nxp: Remove redundant dev_err()
Ruan Jinjie [Thu, 27 Jul 2023 10:21:54 +0000 (10:21 +0000)]
media: nxp: Remove redundant dev_err()

There is no need to call the dev_err() function directly to print a custom
message when handling an error from platform_get_irq() function as
it is going to display an appropriate error message in case of a failure.

Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: rcar_jpu: Remove redundant dev_err()
Ruan Jinjie [Thu, 27 Jul 2023 10:11:28 +0000 (10:11 +0000)]
media: rcar_jpu: Remove redundant dev_err()

There is no need to call the dev_err() function directly to print a custom
message when handling an error from platform_get_irq() function as
it is going to display an appropriate error message in case of a failure.

Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: jpeg-core: Remove redundant dev_err()
Ruan Jinjie [Thu, 27 Jul 2023 10:06:32 +0000 (10:06 +0000)]
media: jpeg-core: Remove redundant dev_err()

There is no need to call the dev_err() function directly to print a custom
message when handling an error from platform_get_irq() function as
it is going to display an appropriate error message in case of a failure.

Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Acked-by: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agodt-bindings: media: amphion,vpu: correct node name
Peng Fan [Tue, 25 Jul 2023 10:25:45 +0000 (18:25 +0800)]
dt-bindings: media: amphion,vpu: correct node name

The node name should use hyphen(-), not underscore(_).

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: dt-bindings: drop unneeded status from examples
Krzysztof Kozlowski [Tue, 25 Jul 2023 10:16:25 +0000 (12:16 +0200)]
media: dt-bindings: drop unneeded status from examples

Example DTS should not have 'status' property.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Acked-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: dvb: mb86a16: check the return value of mb86a16_read()
Yuanjun Gong [Tue, 25 Jul 2023 03:35:13 +0000 (11:35 +0800)]
media: dvb: mb86a16: check the return value of mb86a16_read()

return an error code if mb86a16_read() gets an unexpected return
value.

Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: add {} around the else statement]

10 months agomedia: doc: dev-encoder: Fixup type for ENUM_FRAMEINTERVALS
Paul Kocialkowski [Fri, 21 Jul 2023 15:50:19 +0000 (17:50 +0200)]
media: doc: dev-encoder: Fixup type for ENUM_FRAMEINTERVALS

The doc mistakently mentions v4l2_frmsizeenum as the struct type passed
to VIDIOC_ENUM_FRAMEINTERVALS, while it's actually v4l2_frmivalenum that
should be used.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: stm32: dcmi: only call s_stream on the source subdev
Alain Volmat [Fri, 21 Jul 2023 12:03:15 +0000 (14:03 +0200)]
media: stm32: dcmi: only call s_stream on the source subdev

Avoid calling s_stream on each subdev until reaching the sensor and
instead call s_stream on the source subdev only (which will in turn
do whatever needed to start the stream).

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Reviewed-by: Hugues FRUCHET <hugues.fruchet@foss.st.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: i2c: st_mipid02: cascade s_stream call to the source subdev
Alain Volmat [Fri, 21 Jul 2023 12:03:14 +0000 (14:03 +0200)]
media: i2c: st_mipid02: cascade s_stream call to the source subdev

Cascade the s_stream call to the source subdev whenever the bridge
streaming is enable / disabled.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: doc: codec: Rename "Return fields" to "Returned fields" for consistency
Paul Kocialkowski [Thu, 20 Jul 2023 10:07:02 +0000 (12:07 +0200)]
media: doc: codec: Rename "Return fields" to "Returned fields" for consistency

The parts about fields that are returned typically comes after
"Required fields" so it feels more consistent to name them
"Returned fields".

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: doc: dev-encoder: Fixup whitespace before bold asterisks
Paul Kocialkowski [Thu, 20 Jul 2023 10:07:01 +0000 (12:07 +0200)]
media: doc: dev-encoder: Fixup whitespace before bold asterisks

An extra whitespace after the asterisks prevents bold syntax parsing
and results in the asterisks shown in the (non-bold) title.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: venus: Fix firmware path for sm8250
Patrick Whewell [Tue, 11 Jul 2023 18:53:30 +0000 (11:53 -0700)]
media: venus: Fix firmware path for sm8250

The firmware path for the sm8250 resources is incorrect. This fixes the
path to address the firmware correctly.

Signed-off-by: Patrick Whewell <patrick.whewell@sightlineapplications.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: venus: firmware: Use of_reserved_mem_lookup()
Stephan Gerhold [Mon, 29 May 2023 18:16:14 +0000 (20:16 +0200)]
media: venus: firmware: Use of_reserved_mem_lookup()

Reserved memory can be either looked up using the generic function
of_address_to_resource() or using the special of_reserved_mem_lookup().
The latter has the advantage that it ensures that the referenced memory
region was really reserved and is not e.g. status = "disabled".

of_reserved_mem also supports allocating reserved memory dynamically at
boot time. This works only when using of_reserved_mem_lookup() since
there won't be a fixed address in the device tree.

Switch the code to use of_reserved_mem_lookup(). There is no functional
difference for static reserved memory allocations.

Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: venus: core: Set up secure memory ranges for SC7180
Konrad Dybcio [Thu, 15 Jun 2023 23:36:58 +0000 (01:36 +0200)]
media: venus: core: Set up secure memory ranges for SC7180

Not all SC7180 devices ship with ChromeOS firmware. WoA devices use
Android-like TZ, which uses PAS for image authentication. That requires
the predefined virtual address ranges to be passed via scm calls.
Define them to enable Venus on non-CrOS SC7180 devices.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: venus: hfi_venus: Restrict writing SCIACMDARG3 to Venus V1/V2
Konrad Dybcio [Tue, 30 May 2023 12:30:51 +0000 (14:30 +0200)]
media: venus: hfi_venus: Restrict writing SCIACMDARG3 to Venus V1/V2

This write was last present on msm-3.10, which means before HFI3XX
platforms were introduced. Guard it with an appropriate if condition.

Does not seem to have any adverse effects on at least SM8250.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: venus: Use newly-introduced hfi_buffer_requirements accessors
Konrad Dybcio [Tue, 30 May 2023 12:30:50 +0000 (14:30 +0200)]
media: venus: Use newly-introduced hfi_buffer_requirements accessors

Now that we have a way which is independent of the HFI version to set
the correct fields in hfi_buffer_requirements, use it!

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: venus: Introduce accessors for remapped hfi_buffer_reqs members
Konrad Dybcio [Tue, 30 May 2023 12:30:49 +0000 (14:30 +0200)]
media: venus: Introduce accessors for remapped hfi_buffer_reqs members

Currently we have macros to access these, but they don't provide a
way to override the remapped fields. Replace the macros with actual
get/set pairs to fix that.

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: venus: vdec: Sanitize vdec_set_work_route() per-VPU-version
Konrad Dybcio [Tue, 30 May 2023 12:30:48 +0000 (14:30 +0200)]
media: venus: vdec: Sanitize vdec_set_work_route() per-VPU-version

Replace the general IS_V6 checks with more specific VPU version checks.

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: venus: hfi_platform: Check vpu_version instead of device compatible
Konrad Dybcio [Tue, 30 May 2023 12:30:47 +0000 (14:30 +0200)]
media: venus: hfi_platform: Check vpu_version instead of device compatible

This is not a matter of the host SoC, but the VPU chip in Venus. Fix it.

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: venus: firmware: Sanitize per-VPU-version
Konrad Dybcio [Tue, 30 May 2023 12:30:46 +0000 (14:30 +0200)]
media: venus: firmware: Sanitize per-VPU-version

Replace the general IS_V6 checks with more specific VPU version checks.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: venus: hfi_venus: Sanitize venus_cpu_idle_and_pc_ready() per-VPU-version
Konrad Dybcio [Tue, 30 May 2023 12:30:45 +0000 (14:30 +0200)]
media: venus: hfi_venus: Sanitize venus_cpu_idle_and_pc_ready() per-VPU-version

Replace the general IS_V6 checks with more specific VPU version checks.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: venus: hfi_venus: Sanitize venus_cpu_and_video_core_idle() per-VPU-version
Konrad Dybcio [Tue, 30 May 2023 12:30:44 +0000 (14:30 +0200)]
media: venus: hfi_venus: Sanitize venus_cpu_and_video_core_idle() per-VPU-version

Replace the general IS_V6 checks with more specific VPU version checks.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: venus: hfi_venus: Sanitize venus_isr() per-VPU-version
Konrad Dybcio [Tue, 30 May 2023 12:30:43 +0000 (14:30 +0200)]
media: venus: hfi_venus: Sanitize venus_isr() per-VPU-version

Replace the general IS_V6 checks with more specific VPU version checks.

Reviewed-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: venus: hfi_venus: Sanitize venus_halt_axi() per-VPU-version
Konrad Dybcio [Tue, 30 May 2023 12:30:42 +0000 (14:30 +0200)]
media: venus: hfi_venus: Sanitize venus_halt_axi() per-VPU-version

Only IRIS2(_1) should enter the until-now-IS_V6() path and IRIS2_1
can be used instead of openly checking the number of VPP pipes.

Use VPU version comparison in both of these cases instead.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: venus: core: Assign registers based on VPU version
Konrad Dybcio [Tue, 30 May 2023 12:30:41 +0000 (14:30 +0200)]
media: venus: core: Assign registers based on VPU version

The current assumption of IS_V6 is overgeneralized. Adjust the logic
to take the VPU hardware version into account.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: venus: hfi_venus: Sanitize venus_boot_core() per-VPU-version
Konrad Dybcio [Tue, 30 May 2023 12:30:40 +0000 (14:30 +0200)]
media: venus: hfi_venus: Sanitize venus_boot_core() per-VPU-version

The current assumption of IS_V6 is overgeneralized. Adjust the logic
to take the VPU hardware version into account.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: venus: firmware: Leave a clue about obtaining CP VARs
Konrad Dybcio [Tue, 30 May 2023 12:30:39 +0000 (14:30 +0200)]
media: venus: firmware: Leave a clue about obtaining CP VARs

The qcom_scm_mem_protect_video_var accepts two sets of <addr size>
pairs as arguments. They describe the virtual address ranges of the
CP (Content Protection) and CP_NONPIXEL regions. It is however not
immediately obvious how to obtain these values.

Leave a comment explaining how one can translate the vendor device
tree properties for use with the mainline driver.

Reviewed-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Reviewed-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: venus: Add vpu_version to most SoCs
Konrad Dybcio [Tue, 30 May 2023 12:30:38 +0000 (14:30 +0200)]
media: venus: Add vpu_version to most SoCs

Add vpu_version where I was able to retrieve the information to
allow for more precise hardware-specific code path matching.

Reviewed-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Reviewed-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: venus: Introduce VPU version distinction
Konrad Dybcio [Tue, 30 May 2023 12:30:37 +0000 (14:30 +0200)]
media: venus: Introduce VPU version distinction

The Video Processing Unit hardware version is the differentiator, based
on which the video driver should decide which code paths to take.

Up until now, we've relied on HFI versions instead, but that was just
a happy accident between recent SoCs. Add a field in the res struct
and add correlated definitions that will be used to account for the
aforementioned differences.

Reviewed-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: venus: hfi_venus: Write to VIDC_CTRL_INIT after unmasking interrupts
Konrad Dybcio [Tue, 30 May 2023 12:30:36 +0000 (14:30 +0200)]
media: venus: hfi_venus: Write to VIDC_CTRL_INIT after unmasking interrupts

The startup procedure shouldn't be started with interrupts masked, as that
may entail silent failures.

Kick off initialization only after the interrupts are unmasked.

Cc: stable@vger.kernel.org # v4.12+
Fixes: d96d3f30c0f2 ("[media] media: venus: hfi: add Venus HFI files")
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>