linux-block.git
2 months agomedia: qcom: camss: Move format related functions
Radoslav Tsvetkov [Wed, 22 May 2024 15:46:56 +0000 (18:46 +0300)]
media: qcom: camss: Move format related functions

Move out the format related helper functions from vfe and video in a
separate file. The goal here is to create a format API.

Signed-off-by: Radoslav Tsvetkov <quic_rtsvetko@quicinc.com>
Signed-off-by: Gjorgji Rosikopulos <quic_grosikop@quicinc.com>
Acked-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 months agomedia: qcom: camss: Attach formats to CSIPHY resources
Radoslav Tsvetkov [Wed, 22 May 2024 15:46:55 +0000 (18:46 +0300)]
media: qcom: camss: Attach formats to CSIPHY resources

Following the example of VFE and CSID, attach the CSIPHY
formats to the subdevices resources.

Signed-off-by: Radoslav Tsvetkov <quic_rtsvetko@quicinc.com>
Signed-off-by: Gjorgji Rosikopulos <quic_grosikop@quicinc.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp/sm8250/sdm845/apq8016
Acked-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 months agomedia: qcom: camss: Attach formats to CSID resources
Radoslav Tsvetkov [Wed, 22 May 2024 15:46:54 +0000 (18:46 +0300)]
media: qcom: camss: Attach formats to CSID resources

Following the example of VFE, move all formats of the decoder
to camss-csid.c and attach them to the subdevices resources.

Signed-off-by: Radoslav Tsvetkov <quic_rtsvetko@quicinc.com>
Signed-off-by: Gjorgji Rosikopulos <quic_grosikop@quicinc.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp/sm8250/sdm845/apq8016
Acked-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 months agomedia: qcom: camss: Attach formats to VFE resources
Radoslav Tsvetkov [Wed, 22 May 2024 15:46:53 +0000 (18:46 +0300)]
media: qcom: camss: Attach formats to VFE resources

Video node formats have direct dependency by the sub-device pad formats.
Remove dependency for SoC version and move format definitions in device
which creates video node.

This commit attaches a struct to the VFE resources that holds format
description, so it is much easier to assign them to the video node.
No need to use a switch-case.

NOTE: The mbus_bpp is used to calculate the clock rates and is different
from bpp which is the bits per pixel written to memory. We need to keep
both values to not break the calcualtions.

Signed-off-by: Radoslav Tsvetkov <quic_rtsvetko@quicinc.com>
Signed-off-by: Gjorgji Rosikopulos <quic_grosikop@quicinc.com>
Acked-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 months agomedia: qcom: camss: Add per sub-device type resources
Radoslav Tsvetkov [Wed, 22 May 2024 15:46:52 +0000 (18:46 +0300)]
media: qcom: camss: Add per sub-device type resources

Currently resources structure grows with additional parameters required for
each sub-deivce. However each sub-device has some specific resources or
configurations which need to be passed during the initialization.

This change adds per sub-device type structure to simplify the things
and removes the magical void pointer to hw_ops.

Signed-off-by: Radoslav Tsvetkov <quic_rtsvetko@quicinc.com>
Signed-off-by: Gjorgji Rosikopulos <quic_grosikop@quicinc.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp/sm8250/sdm845/apq8016
Acked-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 months agodocumentation: media: vivid: Update documentation on vivid loopback support
Dorcas Anono Litunya [Mon, 24 Jun 2024 09:53:06 +0000 (12:53 +0300)]
documentation: media: vivid: Update documentation on vivid loopback support

Modify section "Video and Sliced VBI Looping" in Documentation to explain
the vivid loopback support for video across multiple vivid instances.
Previous documentation is out-of-date as it was explaining looping in a
single vivid instance only.

Also, in "Some Future Improvements" the item "Add support to loop
from a specific output to a specific input across vivid instances"
can be dropped since that's now implemented.

Signed-off-by: Dorcas Anono Litunya <anonolitunya@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 months agomedia: vivid: loopback based on 'Connected To' controls
Hans Verkuil [Mon, 24 Jun 2024 09:53:04 +0000 (12:53 +0300)]
media: vivid: loopback based on 'Connected To' controls

Instead of using hardwired video loopback limited to a single vivid
instance, use the new 'Connected To' controls to only loopback if an
HDMI or S-Video input is connected to another output, which can be
in another vivid instance. Effectively this emulates connecting and
disconnecting an HDMI/S-Video cable.

The Loop Video control is dropped since it has now been replaced by
the new 'Connected To' controls. The Display Present has also been
dropped since it no longer fits.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Co-developed-by: Dorcas Anono Litunya <anonolitunya@gmail.com>
Signed-off-by: Dorcas Anono Litunya <anonolitunya@gmail.com>
2 months agomedia: vivid: Add 'Is Connected To' menu controls
Dorcas Anono Litunya [Mon, 24 Jun 2024 09:53:02 +0000 (12:53 +0300)]
media: vivid: Add 'Is Connected To' menu controls

The video loopback functionality in vivid is very crude. What we really
want is to be able to emulate connecting an HDMI or S-Video input to
an HDMI or S-Video output, and the input and output can be in different
vivid instances.

Effectively this emulates what happens when you physically connect an
HDMI or S-Video cable between two devices.

In particular, this makes prototyping with vivid much more realistic.

This patch creates a menu control for each HDMI or S-Video input. The
menu control starts with "Test Pattern Generator" and "None" (i.e.
disconnected). After that up to 62 HDMI or S-Video outputs are listed
that you can connect the input to.

If there are more than 62 HDMI or S-Video outputs, then those will not
be included in the menu (currently menucontrols have max 64 entries).

If an input is connected to an output, then all other 'Connected To'
controls are updated to exclude that output to avoid having multiple
inputs connected to the same output.

Signed-off-by: Dorcas Anono Litunya <anonolitunya@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: use u8 in loops in vivid_create_controls() to avoid truncate warning]

2 months agomedia: vivid: add instance number to input/output names
Hans Verkuil [Mon, 24 Jun 2024 09:53:00 +0000 (12:53 +0300)]
media: vivid: add instance number to input/output names

Add the instance number before the input or output number.
So "HDMI 1" becomes "HDMI 000-1".

This is helps identifying which input or output belongs to
which vivid instance.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 months agomedia: vivid: don't set HDMI TX controls if there are no HDMI outputs
Hans Verkuil [Mon, 24 Jun 2024 09:52:59 +0000 (12:52 +0300)]
media: vivid: don't set HDMI TX controls if there are no HDMI outputs

When setting the EDID it would attempt to update two controls
that are only present if there is an HDMI output configured.

If there isn't any (e.g. when the vivid module is loaded with
node_types=1), then calling VIDIOC_S_EDID would crash.

Fix this by first checking if outputs are present.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 months agomedia: vivid: vidioc_g_edid: do not change the original input EDID
Hans Verkuil [Mon, 24 Jun 2024 09:52:58 +0000 (12:52 +0300)]
media: vivid: vidioc_g_edid: do not change the original input EDID

Returning an EDID for a connected output would modify the original
input EDID with the physical address of the output. That causes
problems, and it should just update the physical address of the
output EDID.

Update vivid_hdmi_edid to set the physical address to 0.0.0.0.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 months agomedia: Documentation: vivid.rst: Remove documentation for Capture Overlay
Dorcas Anono Litunya [Mon, 24 Jun 2024 09:52:57 +0000 (12:52 +0300)]
media: Documentation: vivid.rst: Remove documentation for Capture Overlay

Modifying documentation to remove 'Capture Overlay section' as
destructive capture overlay support was removed.

See commit ccaa9d50ca73 ("media: vivid: drop overlay support")

Signed-off-by: Dorcas Anono Litunya <anonolitunya@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 months agomedia: Documentation: vivid.rst: add supports_requests
Hans Verkuil [Mon, 24 Jun 2024 09:52:55 +0000 (12:52 +0300)]
media: Documentation: vivid.rst: add supports_requests

The module option supports_requests was not documented, add it.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 months agomedia: Documentation: vivid.rst: drop "Video, VBI and RDS Looping"
Hans Verkuil [Mon, 24 Jun 2024 09:52:54 +0000 (12:52 +0300)]
media: Documentation: vivid.rst: drop "Video, VBI and RDS Looping"

Drop the "Video, VBI and RDS Looping" section, instead moving the
Video/VBI info to section "Video and Sliced VBI looping" and the
RDS info to section "Radio & RDS Looping".

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 months agomedia: Documentation: vivid.rst: fix confusing section refs
Hans Verkuil [Mon, 24 Jun 2024 09:52:53 +0000 (12:52 +0300)]
media: Documentation: vivid.rst: fix confusing section refs

The documentation contained several instances of "section X"
references, which no longer map to whatever X was.

Replace these by the section titles.

Also fix a single confusing typo in the "Radio & RDS Looping" section:
"are regular frequency intervals" -> "at regular frequency intervals"

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agoRevert "media: stm32: dcmipp: correct error handling in dcmipp_create_subdevs"
Hans Verkuil [Thu, 27 Jun 2024 11:15:31 +0000 (13:15 +0200)]
Revert "media: stm32: dcmipp: correct error handling in dcmipp_create_subdevs"

This reverts commit 77d32b7e2a7b2e5389b67363d25371b4b8cad140.

This patch is obviously wrong (causes array accesses at index -1),
and I caught that just too late.

3 months agomedia: imx-mipi-csis: Use v4l2_subdev_enable_streams()
Laurent Pinchart [Wed, 19 Jun 2024 23:24:31 +0000 (02:24 +0300)]
media: imx-mipi-csis: Use v4l2_subdev_enable_streams()

To support sources that implement the .enable_streams() and
.disable_streams() operations, replace the manual calls to the subdev
.s_stream() operation with the v4l2_subdev_enable_streams() and
v4l2_subdev_disable_streams() helpers. The helpers fall back to
.s_stream() if the source doesn't implement the new operations, so
backward compatibility is preserved.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: i2c: gc2145: use CCI_REG16_LE for little-endian registers
Alain Volmat [Tue, 25 Jun 2024 08:29:55 +0000 (10:29 +0200)]
media: i2c: gc2145: use CCI_REG16_LE for little-endian registers

Use CCI_REG16_LE macro in order to access little-endian
encoded registers of the P3 (CSI) section.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: i2c: gc2145: addition of RAW8 formats support
Alain Volmat [Tue, 25 Jun 2024 08:29:54 +0000 (10:29 +0200)]
media: i2c: gc2145: addition of RAW8 formats support

Adds support for RAW8 formats (BGGR/RGGB/RBRG/BRBG).

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: fix typo: colospace -> colorspace]

3 months agomedia: stm32: dcmipp: correct error handling in dcmipp_create_subdevs
Alain Volmat [Mon, 24 Jun 2024 08:41:22 +0000 (10:41 +0200)]
media: stm32: dcmipp: correct error handling in dcmipp_create_subdevs

Correct error handling within the dcmipp_create_subdevs by properly
decrementing the i counter when releasing the subdeves.

Fixes: 28e0f3772296 ("media: stm32-dcmipp: STM32 DCMIPP camera interface driver")
Cc: stable@vger.kernel.org
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: admin-guide: Document the Raspberry Pi PiSP BE
Jacopo Mondi [Wed, 26 Jun 2024 18:14:38 +0000 (20:14 +0200)]
media: admin-guide: Document the Raspberry Pi PiSP BE

Add documentation for the PiSP Back End memory-to-memory ISP.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: raspberrypi: Add support for PiSP BE
Naushir Patuck [Wed, 26 Jun 2024 18:14:37 +0000 (20:14 +0200)]
media: raspberrypi: Add support for PiSP BE

Add support for the Raspberry Pi PiSP Back End.

The driver has been upported from the Raspberry Pi kernel at revision
f74893f8a0c2 ("drivers: media: pisp_be: Update seqeuence numbers of the
buffers").

The ISP documentation is available at:
https://datasheets.raspberrypi.com/camera/raspberry-pi-image-signal-processor-specification.pdf

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.org>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: drop dev_err after platform_get_irq to fix a coccinelle check]

3 months agomedia: dt-bindings: Add bindings for Raspberry Pi PiSP Back End
Jacopo Mondi [Wed, 26 Jun 2024 18:14:36 +0000 (20:14 +0200)]
media: dt-bindings: Add bindings for Raspberry Pi PiSP Back End

Add bindings for the Raspberry Pi PiSP Back End memory-to-memory image
signal processor.

Datasheet:
https://datasheets.raspberrypi.com/camera/raspberry-pi-image-signal-processor-specification.pdf

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: uapi: Add PiSP Compressed RAW Bayer formats
Jacopo Mondi [Wed, 26 Jun 2024 18:14:35 +0000 (20:14 +0200)]
media: uapi: Add PiSP Compressed RAW Bayer formats

Add Raspberry Pi compressed RAW Bayer formats.

The compression algorithm description is provided by Nick Hollinghurst
<nick.hollinghurst@raspberrypi.com> from Raspberry Pi.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: uapi: Add meta pixel format for PiSP BE config
Jacopo Mondi [Wed, 26 Jun 2024 18:14:34 +0000 (20:14 +0200)]
media: uapi: Add meta pixel format for PiSP BE config

Add format description for the PiSP Back End configuration parameter
buffer.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: uapi: Add Raspberry Pi PiSP Back End uAPI
Jacopo Mondi [Wed, 26 Jun 2024 18:14:33 +0000 (20:14 +0200)]
media: uapi: Add Raspberry Pi PiSP Back End uAPI

Add the Raspberry Pi PiSP Back End uAPI header.

The header defines the data type used to configure the PiSP Back End
ISP.

The detailed description of the types and of the ISP configuration
procedure is available at
https://datasheets.raspberrypi.com/camera/raspberry-pi-image-signal-processor-specification.pdf

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: uapi: Add a pixel format for BGR48 and RGB48
Jacopo Mondi [Wed, 26 Jun 2024 18:14:32 +0000 (20:14 +0200)]
media: uapi: Add a pixel format for BGR48 and RGB48

Add BGR48 and RGB48 16-bit per component image formats.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: uapi: pixfmt-luma: Document MIPI CSI-2 packing
Jacopo Mondi [Wed, 26 Jun 2024 18:14:31 +0000 (20:14 +0200)]
media: uapi: pixfmt-luma: Document MIPI CSI-2 packing

The Y10P, Y12P and Y14P format variants are packed according to
the RAW10, RAW12 and RAW14 formats as defined by the MIPI CSI-2
specification. Document it.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: vivid: fix CREATE_BUFS support in queue_setup()
Hans Verkuil [Wed, 26 Jun 2024 11:00:49 +0000 (13:00 +0200)]
media: vivid: fix CREATE_BUFS support in queue_setup()

While queue_setup was correct for CREATE_BUFS support for
video devices, for VBI, SDR and touch devices it was wrong.

This was found after adding new v4l2-compliance tests.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: vivid: fix wrong sizeimage value for mplane
Hans Verkuil [Wed, 26 Jun 2024 10:59:13 +0000 (12:59 +0200)]
media: vivid: fix wrong sizeimage value for mplane

In several places a division by fmt->vdownsampling[p] was
missing in the sizeimage[p] calculation, causing incorrect
behavior for multiplanar formats were some planes are smaller
than the first plane.

Found by new v4l2-compliance tests.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: vimc: scaler: Use subdev active state
Laurent Pinchart [Wed, 24 Apr 2024 23:57:41 +0000 (02:57 +0300)]
media: vimc: scaler: Use subdev active state

Store the active formats and crop rectangle in the subdevice active
state. This simplifies implementation of the format and selection
accessors, and allows using the v4l2_subdev_get_fmt() helper to
implement the .get_fmt() operation.

The active configuration that is used in the .process_frame() handler is
still stored in the vimc_scaler_device structure. The driver could
instead access the active state in the .process_frame() handler, but the
required locking could interfere with the real time constraints of the
frame processing. This data would be stored in registers in the
.s_stream() handler for real hardware, storing it in dedicated storage
thus mimics a real driver. To differentiate them from the rest of the
device private data, move the corresponding fields to a sub-structure of
vimc_scaler_device named hw.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: vimc: debayer: Use subdev active state
Laurent Pinchart [Wed, 24 Apr 2024 23:57:40 +0000 (02:57 +0300)]
media: vimc: debayer: Use subdev active state

Store the active formats and crop rectangle in the subdevice active
state. This simplifies implementation of the format and selection
accessors, and allows using the v4l2_subdev_get_fmt() helper to
implement the .get_fmt() operation.

The active configuration that is used in the .process_frame() handler is
still stored in the vimc_debayer_device structure. The driver could
instead access the active state in the .process_frame() handler, but the
required locking could interfere with the real time constraints of the
frame processing. This data would be stored in registers in the
.s_stream() handler for real hardware, storing it in dedicated storage
thus mimics a real driver. To differentiate them from the rest of the
device private data, move the corresponding fields to a sub-structure of
vimc_debayer_device named hw.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: vimc: sensor: Use subdev active state
Laurent Pinchart [Wed, 24 Apr 2024 23:57:39 +0000 (02:57 +0300)]
media: vimc: sensor: Use subdev active state

Store the active formats and crop rectangle in the subdevice active
state. This simplifies implementation of the format and selection
accessors, and allows using the v4l2_subdev_get_fmt() helper to
implement the .get_fmt() operation.

The active configuration that is used in the .process_frame() handler is
still stored in the vimc_sensor_device structure. The driver could
instead access the active state in the .process_frame() handler, but the
required locking could interfere with the real time constraints of the
frame processing. This data would be stored in registers in the
.s_stream() handler for real hardware, storing it in dedicated storage
thus mimics a real driver. To differentiate them from the rest of the
device private data, move the corresponding fields to a sub-structure of
vimc_sensor_device named hw.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: vimc: Initialize subdev active state
Laurent Pinchart [Wed, 24 Apr 2024 23:57:38 +0000 (02:57 +0300)]
media: vimc: Initialize subdev active state

Finalize subdev initialization for all subdevs that provide a
.init_state() operation. This creates an active state for all those
subdevs, which subsequent patches will use to simplify the
implementation of individual vimc entities.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: vimc: Centralize subdev internal_ops initialization
Laurent Pinchart [Wed, 24 Apr 2024 23:57:37 +0000 (02:57 +0300)]
media: vimc: Centralize subdev internal_ops initialization

Initialize the subdev internal_ops field in the vimc_ent_sd_register()
function. This handles the internal ops the same way as the subdev ops,
and prepares for moving to the V4L2 subdev active state API.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: vimc: scaler: Rename vic_sca_pad enum to vimc_scaler_pad
Laurent Pinchart [Wed, 24 Apr 2024 23:57:36 +0000 (02:57 +0300)]
media: vimc: scaler: Rename vic_sca_pad enum to vimc_scaler_pad

The vic_sca_pad enum's name has been shortened to the extreme for no
good reason. Rename it to vimc_scaler_pad.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: vimc: Constify the ent_config array
Laurent Pinchart [Wed, 24 Apr 2024 23:57:35 +0000 (02:57 +0300)]
media: vimc: Constify the ent_config array

The ent_config array contains data that is never modified. Make it
const.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: vimc: Constify vimc_ent_type structures
Laurent Pinchart [Wed, 24 Apr 2024 23:57:34 +0000 (02:57 +0300)]
media: vimc: Constify vimc_ent_type structures

The vimc_ent_type structure contains static pointers to functions, and
no other information that need to be modified after initialization. Make
them const to avoid the risk of arbitrary code execution following an
overflow that would overwrite the structure's contents.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: vimc: Don't iterate over single pad
Laurent Pinchart [Wed, 24 Apr 2024 23:57:33 +0000 (02:57 +0300)]
media: vimc: Don't iterate over single pad

The .init_state() operations of the debayer and sensor entities iterate
over the entity's pads. In practice, the iteration covers a single pad
only. Access the pad directly and remove the loops.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agoMerge tag 'tags/next-media-20240626' of git://git.kernel.org/pub/scm/linux/kernel...
Hans Verkuil [Wed, 26 Jun 2024 13:29:04 +0000 (15:29 +0200)]
Merge tag 'tags/next-media-20240626' of git://git./linux/kernel/git/pinchartl/linux.git

- fix typo in v4l2-subdev.h
- imx-pxp bug fix
- media i2c Kconfig: add missing FW_UPLOAD select

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agoMerge tag 'tags/next-media-renesas-20240619' of git://git.kernel.org/pub/scm/linux...
Hans Verkuil [Wed, 26 Jun 2024 12:49:57 +0000 (14:49 +0200)]
Merge tag 'tags/next-media-renesas-20240619' of git://git./linux/kernel/git/pinchartl/linux.git

- Conversion of max9286 and adv748x to V4L2 subdev active state
- Cleanups and fixes for the Renesas R-Car VSP and VIN drivers
- Miscellaneous cleanups to V4L2 core

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: v4l: subdev: Fix typo in documentation
Laurent Pinchart [Wed, 19 Jun 2024 22:53:43 +0000 (01:53 +0300)]
media: v4l: subdev: Fix typo in documentation

Replace the incorrect reference to the v4l2_subdev_enable_stream()
function with the correct v4l2_subdev_enable_streams() spelling.

Fixes: d0749adb3070 ("media: v4l2-subdev: Add subdev .(enable|disable)_streams() operations")
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Link: https://lore.kernel.org/r/20240619225343.15873-1-laurent.pinchart@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
3 months agomedia: i2c: Kconfig: Fix missing firmware upload config select
Kory Maincent [Thu, 20 Jun 2024 10:25:43 +0000 (12:25 +0200)]
media: i2c: Kconfig: Fix missing firmware upload config select

FW_LOADER config only selects the firmware loader API, but we also need
the sysfs_upload symbols for firmware_upload_unregister() and
firmware_upload_register() to function properly.

Fixes: 7a52ab415b43 ("media: i2c: Add driver for THine THP7312")
Cc: stable@vger.kernel.org
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Link: https://lore.kernel.org/r/20240620102544.1918105-1-kory.maincent@bootlin.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
3 months agomedia: imx-pxp: Fix ERR_PTR dereference in pxp_probe()
Harshit Mogalapalli [Tue, 14 May 2024 09:50:38 +0000 (02:50 -0700)]
media: imx-pxp: Fix ERR_PTR dereference in pxp_probe()

devm_regmap_init_mmio() can fail, add a check and bail out in case of
error.

Fixes: 4e5bd3fdbeb3 ("media: imx-pxp: convert to regmap")
Cc: stable@vger.kernel.org
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/r/20240514095038.3464191-1-harshit.m.mogalapalli@oracle.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
3 months agoMAINTAINERS: delete email for Anton Sviridenko
Wolfram Sang [Mon, 3 Jun 2024 10:01:17 +0000 (12:01 +0200)]
MAINTAINERS: delete email for Anton Sviridenko

The email address bounced. I couldn't find a newer one in recent git
history, so update MAINTAINERS accordingly.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: Documentation: ipu6: Fix examples in ipu6-isys admin-guide
Samuel Wein [Mon, 17 Jun 2024 18:53:09 +0000 (18:53 +0000)]
media: Documentation: ipu6: Fix examples in ipu6-isys admin-guide

Fix flags in X1 Yoga example. MEDIA_LNK_FL_DYNAMIC (0x4 in the link flag)
was removed in V4 Intel IPU6 and IPU6 input system drivers. Added -V flag
to media-ctl commands for X1 Yoga, lower-case v only makes it verbose
upper-case V sets the format.

Signed-off-by: Samuel Wein <sam@samwein.com>
[Sakari Ailus: Align subject line, rewrap commit message.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: i2c: Add GC05A2 image sensor driver
Zhi Mao [Tue, 11 Jun 2024 11:32:35 +0000 (19:32 +0800)]
media: i2c: Add GC05A2 image sensor driver

Add a V4L2 sub-device driver for Galaxycore GC05A2 image sensor.

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Zhi Mao <zhi.mao@mediatek.com>
[Sakari Ailus: Fold in MAINTAINERS change.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: dt-bindings: i2c: add GalaxyCore GC05A2 image sensor
Zhi Mao [Tue, 11 Jun 2024 11:32:34 +0000 (19:32 +0800)]
media: dt-bindings: i2c: add GalaxyCore GC05A2 image sensor

Add YAML device tree binding for GC05A2 CMOS image sensor,
and the relevant MAINTAINERS entries.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Zhi Mao <zhi.mao@mediatek.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: i2c: Add GC08A3 image sensor driver
Zhi Mao [Wed, 12 Jun 2024 02:17:59 +0000 (10:17 +0800)]
media: i2c: Add GC08A3 image sensor driver

Add a V4L2 sub-device driver for Galaxycore GC08A3 image sensor.

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Zhi Mao <zhi.mao@mediatek.com>
[Sakari Ailus: Fold in MAINTAINERS change.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: dt-bindings: i2c: add GalaxyCore GC08A3 image sensor
Zhi Mao [Wed, 12 Jun 2024 02:17:58 +0000 (10:17 +0800)]
media: dt-bindings: i2c: add GalaxyCore GC08A3 image sensor

Add YAML device tree binding for GC08A3 CMOS image sensor,
and the relevant MAINTAINERS entries.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Zhi Mao <zhi.mao@mediatek.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: b2c2: flexcop-usb: fix flexcop_usb_memory_req
Hans Verkuil [Thu, 20 Jun 2024 07:52:26 +0000 (09:52 +0200)]
media: b2c2: flexcop-usb: fix flexcop_usb_memory_req

smatch generated this warning:

drivers/media/usb/b2c2/flexcop-usb.c:199 flexcop_usb_memory_req() warn: iterator 'i' not incremented

and indeed the function is not using i or updating buf.

The reason this always worked is that this function is called to write just
6 bytes (a MAC address) to the USB device, and so in practice there is only
a single chunk written. If we ever would need to write more than one chunk,
this function would fail since each chunk would read from or write to the
same buf address.

Rewrite the function to properly handle this.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: verisilicon : Use exported tables from v4l2-jpeg for hantro codec
Devarsh Thakkar [Tue, 18 Jun 2024 19:36:51 +0000 (01:06 +0530)]
media: verisilicon : Use exported tables from v4l2-jpeg for hantro codec

Use v4l2-jpeg core API to import reference quantization and huffman tables
used for JPEG Encoding.

Signed-off-by: Devarsh Thakkar <devarsht@ti.com>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Acked-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>
3 months agomedia: imagination: Use exported tables from v4l2-jpeg core
Devarsh Thakkar [Tue, 18 Jun 2024 19:36:50 +0000 (01:06 +0530)]
media: imagination: Use exported tables from v4l2-jpeg core

Use exported huffman and quantization tables from v4l2-jpeg core library.

Signed-off-by: Devarsh Thakkar <devarsht@ti.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: Documentation: Document v4l2-jpeg helper functions
Devarsh Thakkar [Tue, 18 Jun 2024 19:36:49 +0000 (01:06 +0530)]
media: Documentation: Document v4l2-jpeg helper functions

Enable documentation for v4l2-jpeg header related helper functions which
are useful for parsing jpeg files while decoding or creating jpeg headers
while encoding.

Signed-off-by: Devarsh Thakkar <devarsht@ti.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: v4l2-jpeg: Export reference quantization and huffman tables
Devarsh Thakkar [Tue, 18 Jun 2024 19:36:48 +0000 (01:06 +0530)]
media: v4l2-jpeg: Export reference quantization and huffman tables

Export reference quantization and huffman tables as provided in ITU-T.81 so
that they can be re-used by other JPEG drivers.

These are example tables provided in ITU-T.81 as reference tables and the
JPEG encoders are free to use either these or their own proprietary tables.

Also add necessary prefixes to be used for huffman tables in global header
file.

Signed-off-by: Devarsh Thakkar <devarsht@ti.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: imagination: Add E5010 JPEG Encoder driver
Devarsh Thakkar [Tue, 18 Jun 2024 19:36:47 +0000 (01:06 +0530)]
media: imagination: Add E5010 JPEG Encoder driver

This adds support for stateful V4L2 M2M based driver for Imagination E5010
JPEG Encoder [1] which supports baseline encoding with two different
quantization tables and compression ratio as demanded.

Support for both contiguous and non-contiguous YUV420 and YUV422 semiplanar
formats is added along with alignment restrictions as required by the
hardware.

System and runtime PM hooks are added in the driver along with v4l2 crop
and selection API support.
Minimum resolution supported is 64x64 and
Maximum resolution supported is 8192x8192.

All v4l2-compliance tests are passing [2] :
v4l2-compliance -s -f -a  -d /dev/video0 -e /dev/video1

Total for e5010 device /dev/video0: 79, Succeeded: 79, Failed: 0,
Warnings: 0

NOTE: video1 here is VIVID test pattern generator

Also tests [3] were run manually to verify below driver features:
 - Runtime Power Management
 - Multi-instance JPEG Encoding
 - DMABUF import, export support
 - NV12, NV21, NV16, NV61 video format support
 - Compression quality S_CTRL
 - Cropping support using S_SELECTION

Existing V4L2 M2M based JPEG drivers namely s5p-jpeg, imx-jpeg and rcar_jpu
were referred while making this.

TODO:
Add MMU and memory tiling support

[1]:  AM62A TRM (Section 7.6 is for JPEG Encoder) :
Link: https://www.ti.com/lit/pdf/spruj16
[2]: v4l2-compliance test :
Link: https://gist.github.com/devarsht/1f039c631ca953a57f405cfce1b69e49
[3]: E5010 JPEG Encoder Manual tests :

Performance:
Link: https://gist.github.com/devarsht/c40672944fd71c9a53ab55adbfd9e28b
Functionality:
Link: https://gist.github.com/devarsht/8e88fcaabff016bb2bac83d89c9d23ce
Compression Quality:
Link: https://gist.github.com/devarsht/cbcc7cd97e8c48ba1486caa2b7884655
Multi Instance:
Link: https://gist.github.com/devarsht/22c2fca08cd3441fb40f2c7a4cebc95a
Crop support:
Link: https://gist.github.com/devarsht/de6f5142f678bb1a5338abfd9f814abd
Runtime PM:
Link: https://gist.github.com/devarsht/70cd95d4440ddc678489d93885ddd4dd
Co-developed-by: David Huang <d-huang@ti.com>
Signed-off-by: David Huang <d-huang@ti.com>
Signed-off-by: Devarsh Thakkar <devarsht@ti.com>
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: dt-bindings: Add Imagination E5010 JPEG Encoder
Devarsh Thakkar [Tue, 18 Jun 2024 19:36:46 +0000 (01:06 +0530)]
media: dt-bindings: Add Imagination E5010 JPEG Encoder

Add dt-bindings for Imagination E5010 JPEG Encoder [1] which is implemented
as stateful V4L2 M2M driver.

The device supports baseline encoding with two different quantization
tables and compression ratio as demanded.

Minimum resolution supported is 64x64 and Maximum resolution supported is
8192x8192.

Link: https://www.ti.com/lit/pdf/spruj16
Co-developed-by: David Huang <d-huang@ti.com>
Signed-off-by: David Huang <d-huang@ti.com>
Signed-off-by: Devarsh Thakkar <devarsht@ti.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: chips-media: wave5: support Wave515 decoder
Ivan Bornyakov [Mon, 15 Apr 2024 10:07:23 +0000 (13:07 +0300)]
media: chips-media: wave5: support Wave515 decoder

Add initial support for the Wave515 multi-decoder IP. For now it is only
able to decode HEVC Main/Main10 profile videos into YUV420.

This was tested on FPGA prototype, so wave5_dt_ids[] was not expanded.
Users of the real hardware with Wave515 IP will have to
 * provide firmware specific to their SoC
 * add struct wave5_match_data like this:

static const struct wave5_match_data platform_name_wave515_data = {
.flags = WAVE5_IS_DEC,
.fw_name = "cnm/wave515_platform_name_fw.bin",
.sram_size = (71 * 1024),
};

 * add item to wave5_dt_ids[] like this:

{
.compatible = "vendor,soc-wave515",
.data = &platform_name_wave515_data,
},

 * describe new compatible in
   Documentation/devicetree/bindings/media/cnm,wave521c.yaml

Signed-off-by: Ivan Bornyakov <brnkv.i1@gmail.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: chips-media: wave5: drop "sram-size" DT property
Ivan Bornyakov [Mon, 15 Apr 2024 10:07:22 +0000 (13:07 +0300)]
media: chips-media: wave5: drop "sram-size" DT property

Move the excessive "sram-size" device-tree property to the device match
data. Also change the SRAM memory allocation strategy, instead of
allocating exactly sram_size bytes, allocate all available SRAM memory
up to sram_size. Add the placeholders wave5_vpu_dec_validate_sec_axi()
and wave5_vpu_enc_validate_sec_axi() to validate that the allocated SRAM
memory is sufficient to decode/encode bitstream with a given resolution.

Signed-off-by: Ivan Bornyakov <brnkv.i1@gmail.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: chips-media: wave5: separate irq setup routine
Ivan Bornyakov [Mon, 15 Apr 2024 10:07:21 +0000 (13:07 +0300)]
media: chips-media: wave5: separate irq setup routine

Implement a separate setup routine for interrupts to reduce code
duplication. Also enable interrupts based on vpu_attr->support_encoders
and vpu_attr->support_decoders fields to facilitate support for other
Wave5xx IPs, because not all of them are both encoders and decoders.

Signed-off-by: Ivan Bornyakov <brnkv.i1@gmail.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: chips-media: wave5: support reset lines
Ivan Bornyakov [Mon, 15 Apr 2024 10:07:20 +0000 (13:07 +0300)]
media: chips-media: wave5: support reset lines

Add initial support for optional reset lines. For now, simply deassert
resets while probing the driver and assert them back when removing the
driver.

Signed-off-by: Ivan Bornyakov <brnkv.i1@gmail.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: chips-media: wave5: support decoding HEVC Main10 profile
Ivan Bornyakov [Mon, 15 Apr 2024 10:07:19 +0000 (13:07 +0300)]
media: chips-media: wave5: support decoding HEVC Main10 profile

Add support for decoding HEVC Main10 profile by scaling the FBC
buffer stride and size by a factor of (bitdepth / 8).

Signed-off-by: Ivan Bornyakov <brnkv.i1@gmail.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: imx-jpeg: Drop initial source change event if capture has been setup
Ming Qian [Thu, 19 Oct 2023 08:36:36 +0000 (16:36 +0800)]
media: imx-jpeg: Drop initial source change event if capture has been setup

In section 4.5.1.5. Initialization, the step 4 may be skipped and
continue with the Capture Setup sequence, so if the capture has been
setup, there is no need to trigger the initial source change event, just
start decoding, and follow the dynamic resolution change flow if the
configured values do not match those parsed by the decoder.

And it won't fail the gstreamer pipeline.

Fixes: b833b178498d ("media: imx-jpeg: notify source chagne event when the first picture parsed")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: imx-jpeg: Remove some redundant error logs
Ming Qian [Thu, 19 Oct 2023 08:37:35 +0000 (16:37 +0800)]
media: imx-jpeg: Remove some redundant error logs

If the picture size parsed by decoder is different from those previously
established, it's a normal flow of dynamic resolution change, not an
error case, the log may mislead that some error occurs in decoding, so
remove the error log in this case.

Fixes: 2db16c6ed72c ("media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: Convert from tasklet to BH workqueue
Allen Pais [Tue, 18 Jun 2024 22:52:27 +0000 (15:52 -0700)]
media: Convert from tasklet to BH workqueue

The only generic interface to execute asynchronously in the BH context is
tasklet; however, it's marked deprecated and has some design flaws. To
replace tasklets, BH workqueue support was recently added. A BH workqueue
behaves similarly to regular workqueues except that the queued work items
are executed in the BH context.

This patch converts drivers/media/* from tasklet to BH workqueue.

Based on the work done by Tejun Heo <tj@kernel.org>

Signed-off-by: Allen Pais <allen.lkml@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: cx231xx: Constify struct vb2_ops
Christophe JAILLET [Sun, 16 Jun 2024 06:32:53 +0000 (08:32 +0200)]
media: cx231xx: 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
  36607    1156       0   37763    9383 drivers/media/usb/cx231xx/cx231xx-417.o

After:
=====
   text    data     bss     dec     hex filename
  36735    1016       0   37751    9377 drivers/media/usb/cx231xx/cx231xx-417.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: xc2028: avoid use-after-free in load_firmware_cb()
Chi Zhiling [Fri, 14 Jun 2024 15:22:25 +0000 (08:22 -0700)]
media: xc2028: avoid use-after-free in load_firmware_cb()

syzkaller reported use-after-free in load_firmware_cb() [1].
The reason is because the module allocated a struct tuner in tuner_probe(),
and then the module initialization failed, the struct tuner was released.
A worker which created during module initialization accesses this struct
tuner later, it caused use-after-free.

The process is as follows:

task-6504           worker_thread
tuner_probe                             <= alloc dvb_frontend [2]
...
request_firmware_nowait                 <= create a worker
...
tuner_remove                            <= free dvb_frontend
...
                    request_firmware_work_func  <= the firmware is ready
                    load_firmware_cb    <= but now the dvb_frontend has been freed

To fix the issue, check the dvd_frontend in load_firmware_cb(), if it is
null, report a warning and just return.

[1]:
    ==================================================================
     BUG: KASAN: use-after-free in load_firmware_cb+0x1310/0x17a0
     Read of size 8 at addr ffff8000d7ca2308 by task kworker/2:3/6504

     Call trace:
      load_firmware_cb+0x1310/0x17a0
      request_firmware_work_func+0x128/0x220
      process_one_work+0x770/0x1824
      worker_thread+0x488/0xea0
      kthread+0x300/0x430
      ret_from_fork+0x10/0x20

     Allocated by task 6504:
      kzalloc
      tuner_probe+0xb0/0x1430
      i2c_device_probe+0x92c/0xaf0
      really_probe+0x678/0xcd0
      driver_probe_device+0x280/0x370
      __device_attach_driver+0x220/0x330
      bus_for_each_drv+0x134/0x1c0
      __device_attach+0x1f4/0x410
      device_initial_probe+0x20/0x30
      bus_probe_device+0x184/0x200
      device_add+0x924/0x12c0
      device_register+0x24/0x30
      i2c_new_device+0x4e0/0xc44
      v4l2_i2c_new_subdev_board+0xbc/0x290
      v4l2_i2c_new_subdev+0xc8/0x104
      em28xx_v4l2_init+0x1dd0/0x3770

     Freed by task 6504:
      kfree+0x238/0x4e4
      tuner_remove+0x144/0x1c0
      i2c_device_remove+0xc8/0x290
      __device_release_driver+0x314/0x5fc
      device_release_driver+0x30/0x44
      bus_remove_device+0x244/0x490
      device_del+0x350/0x900
      device_unregister+0x28/0xd0
      i2c_unregister_device+0x174/0x1d0
      v4l2_device_unregister+0x224/0x380
      em28xx_v4l2_init+0x1d90/0x3770

     The buggy address belongs to the object at ffff8000d7ca2000
      which belongs to the cache kmalloc-2k of size 2048
     The buggy address is located 776 bytes inside of
      2048-byte region [ffff8000d7ca2000ffff8000d7ca2800)
     The buggy address belongs to the page:
     page:ffff7fe00035f280 count:1 mapcount:0 mapping:ffff8000c001f000 index:0x0
     flags: 0x7ff800000000100(slab)
     raw: 07ff800000000100 ffff7fe00049d880 0000000300000003 ffff8000c001f000
     raw: 0000000000000000 0000000080100010 00000001ffffffff 0000000000000000
     page dumped because: kasan: bad access detected

     Memory state around the buggy address:
      ffff8000d7ca2200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      ffff8000d7ca2280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
     >ffff8000d7ca2300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                           ^
      ffff8000d7ca2380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      ffff8000d7ca2400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
     ==================================================================

[2]
    Actually, it is allocated for struct tuner, and dvb_frontend is inside.

Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: platform: mtk-mdp3: Add support for MT8188 MDP3 components
AngeloGioacchino Del Regno [Fri, 22 Mar 2024 09:28:45 +0000 (10:28 +0100)]
media: platform: mtk-mdp3: Add support for MT8188 MDP3 components

MT8195 and MT8188 share a similar MDP3 macro-block, with minor
differences - as in, the latter supports a subset of the number
of components supported by the former, but are otherwise handled
in the same way.

Add driver data for MT8188, reusing the already present MT8195
data where possible.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Fei Shao <fshao@chromium.org>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agodt-bindings: media: mediatek: mdp3: Add support for MT8188 RDMA
AngeloGioacchino Del Regno [Fri, 22 Mar 2024 09:28:44 +0000 (10:28 +0100)]
dt-bindings: media: mediatek: mdp3: Add support for MT8188 RDMA

Add a compatible for MediaTek MT8188 RDMA, which supports only a
subset of the MDP3 components of its similar MT8195 counterpart.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agoMerge tag 'tags/media-next-uvc-20240617-2' of git://git.kernel.org/pub/scm/linux...
Hans Verkuil [Thu, 20 Jun 2024 08:40:32 +0000 (10:40 +0200)]
Merge tag 'tags/media-next-uvc-20240617-2' of git://git./linux/kernel/git/pinchartl/linux.git into media_stage

uvcvideo fixes and improvements:

- add/fix quirks
- improve timestamp handling
- improve Power Line Frequency handling

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: rc: add missing MODULE_DESCRIPTION() macro
Jeff Johnson [Wed, 12 Jun 2024 22:58:25 +0000 (15:58 -0700)]
media: rc: add missing MODULE_DESCRIPTION() macro

With ARCH=x86, make allmodconfig && make W=1 C=1 reports:
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/rc-core.o

Add the missing invocation of the MODULE_DESCRIPTION() macro.

Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
3 months agomedia: renesas: vsp1: Initialize control handler after subdev
Laurent Pinchart [Mon, 13 Nov 2023 16:41:44 +0000 (18:41 +0200)]
media: renesas: vsp1: Initialize control handler after subdev

Some VSP modules initialize their control handler after initializing the
subdev, while some initialize it before. This makes the code
inconsistent and more error prone. Standardize on control initialization
after initializing the subdev.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
3 months agomedia: renesas: vsp1: Pass subdev state to entity operations
Laurent Pinchart [Sun, 12 Nov 2023 02:14:05 +0000 (04:14 +0200)]
media: renesas: vsp1: Pass subdev state to entity operations

To prepare for the removal of the vsp1_entity.state field, pass the
state to all entity operations that needs to access it, instead of
accessing the state from the entity inside the operation handlers. This
lowers the number of accesses to the field.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
3 months agomedia: renesas: vsp1: Name parameters to entity operations
Laurent Pinchart [Mon, 13 Nov 2023 22:53:07 +0000 (00:53 +0200)]
media: renesas: vsp1: Name parameters to entity operations

checkpatch.pl complains when function arguments are not named:

WARNING: function definition argument 'struct vsp1_entity *' should also have an identifier name
+       void (*configure_stream)(struct vsp1_entity *,

In preparation for reworking some of the vsp1_entity_operations
functions, fix the warnings for the existing ones.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
3 months agomedia: renesas: vsp1: Get configuration from partition instead of state
Laurent Pinchart [Mon, 13 Nov 2023 22:53:07 +0000 (00:53 +0200)]
media: renesas: vsp1: Get configuration from partition instead of state

Entities access various piece of information from the subdev state when
configuring a partition. The same data is available through the
partition structure passed to the .configure_partition() operation. Use
it to avoid accessing the state, which will simplify moving to the V4L2
subdev active state API.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
3 months agomedia: renesas: vsp1: Compute partitions for DRM pipelines
Laurent Pinchart [Sun, 19 Nov 2023 01:11:51 +0000 (03:11 +0200)]
media: renesas: vsp1: Compute partitions for DRM pipelines

The DRM pipelines don't partition frames, as the hardware operates
synchronously with the display. The entity operations access
configuration data from the entity state in that case, instead of
accessing the partition structure. This requires special cases in
entity-specific code, increasing the driver complexity.

To prepare for simplifying the code, initialize a single partition for
the DRM pipelines, similarly to how video pipelines create one partition
spanning the full image when partitioning isn't needed. The partition is
allocated statically in the vsp1_drm_pipeline structure instead of
dynamically as for video pipelines, as DRM pipelines are guaranteed to
operate on a single partition.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
3 months agomedia: renesas: vsp1: Keep the DRM pipeline entities sorted
Laurent Pinchart [Sun, 19 Nov 2023 01:11:51 +0000 (03:11 +0200)]
media: renesas: vsp1: Keep the DRM pipeline entities sorted

Some of the code that handles pipeline configuration assumes that
entities in a pipeline's entities list are sorted from sink to source.
To prepare for using that code with the DRM pipeline, insert the BRx
just before the WPF, and the RPFs at the head of the list.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
3 months agomedia: renesas: vsp1: Add and use function to dump a pipeline to the log
Laurent Pinchart [Sat, 18 Nov 2023 22:39:34 +0000 (00:39 +0200)]
media: renesas: vsp1: Add and use function to dump a pipeline to the log

It is useful for debugging purpose to dump a vsp1_pipeline to the kernel
log. Add a new function to do so, and use it when initializing the video
and DRM pipelines.

As __vsp1_pipeline_dump() needs to construct the log message
iteratively, it uses pr_cont(...) (exact equivalent to the more verbose
"printk(KERN_CONT ..."). The function thus can't use dev_dbg() to log
the initial part of the message, for two reasons:

- pr_cont() doesn't seem to work with dev_*(). Even if the format string
  passed to dev_*() doesn't end with a '\n', pr_cont() starts a new line
  in the log. This behaviour doesn't seem to be clearly documented, and
  may or may not be on purpose.

- Messages printed by dev_dbg() may be omitted if dynamic debugging is
  enabled. In that case, the continuation messages will still be
  printed, leading to confusing log messages.

To still benefit from the dynamic debug infrastructure, we declare a
vsp1_pipeline_dump() macro that uses _dynamic_func_call() when dynamic
debugging is enabled. The whole vsp1_pipeline_dump() call can be
selected at runtime. The __vsp1_pipeline_dump() function then uses a
plain "printk(KERN_DEBUG ...)" to print the message header using the
debug log level, and pr_cont() to print the rest of the message on the
same line.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
3 months agomedia: renesas: vsp1: Replace vsp1_partition_window with v4l2_rect
Laurent Pinchart [Mon, 13 Nov 2023 22:53:07 +0000 (00:53 +0200)]
media: renesas: vsp1: Replace vsp1_partition_window with v4l2_rect

The vsp1_partition_window structure is used to store the horizontal size
of a partition window. This is all that is currently needed, as all
partitions span the whole image vertically. The horizontal window size
is retrieved in the .configure_partition() handler from the
vsp1_partition_window structure, and the vertical window size from the
subdev state.

Accessing the subdev state in the .configure_partition() handler is
problematic in the context of moving to the V4L2 subdev active state
API, as .configure_partition() is called in non-interruptable context,
and the state lock can't be taken. To avoid this, start by storing the
vertical size in the window, replacing the custom vsp1_partition_window
structure with a v4l2_rect. Retrieving the vertical size from the window
in .configure_partition() will be done in a subsequent change.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
3 months agomedia: renesas: vsp1: Pass partition pointer to .configure_partition()
Laurent Pinchart [Tue, 14 Nov 2023 22:34:56 +0000 (00:34 +0200)]
media: renesas: vsp1: Pass partition pointer to .configure_partition()

The entity .configure_partition() function operates on a partition, and
has to retrieve that partition from the pipeline's current partition
field. Pass the partition pointer to the function to make it clearer
what partition it operates on, and remove the vsp1_pipeline.partition
field.

This change clearly shows that the DRM pipeline doesn't use partitions,
which makes entity implementation more complex and error-prone. This
will be addressed in a further cleanup.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
3 months agomedia: renesas: vsp1: Store RPF partition configuration per RPF instance
Laurent Pinchart [Sun, 19 Nov 2023 01:11:51 +0000 (03:11 +0200)]
media: renesas: vsp1: Store RPF partition configuration per RPF instance

The vsp1_partition structure stores the RPF partition configuration in a
single field for all RPF instances, while each RPF can have its own
configuration. Fix it by storing the configuration separately for each
RPF instance.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Fixes: ab45e8585182 ("media: v4l: vsp1: Allow entities to participate in the partition algorithm")
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
3 months agomedia: renesas: vsp1: Simplify partition calculation
Laurent Pinchart [Thu, 16 Nov 2023 01:00:41 +0000 (03:00 +0200)]
media: renesas: vsp1: Simplify partition calculation

When calculation a partition in vsp1_pipeline_calculate_partition(),
there is no need to handle the case where the whole image is covered by
a single partition locally. In that case, the index and div_size
parameters are 0 and format->width respectively, which makes the general
code behave exactly as the special case. Drop the special case.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
3 months agomedia: renesas: vsp1: Move partition calculation to vsp1_pipe.c
Laurent Pinchart [Thu, 16 Nov 2023 01:00:41 +0000 (03:00 +0200)]
media: renesas: vsp1: Move partition calculation to vsp1_pipe.c

The partition calculation code, located in vsp1_video.c, is not specific
to video pipelines. To prepare for its usage in DRM pipelines, move it
to vsp1_pipe.c.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
3 months agomedia: renesas: vsp1: Drop custom .get_fmt() handler for histogram
Laurent Pinchart [Sun, 12 Nov 2023 02:14:05 +0000 (04:14 +0200)]
media: renesas: vsp1: Drop custom .get_fmt() handler for histogram

The histogram module is the only one that has a custom .get_fmt()
handler, to handle the special case of the output format being fixed.
This can equally well be handled in the .set_fmt() handler instead.
Beside avoiding special cases and using the same .get_fmt() handler in
all modules, it ensures that the correct format is stored in the active
state for the source pad, including when .set_fmt() is called from
vsp1_entity_init_state(). Both are needed to later switch to the V4L2
subdev active state API.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
3 months agomedia: renesas: vsp1: Drop brx_get_compose() wrapper
Laurent Pinchart [Sun, 12 Nov 2023 02:14:05 +0000 (04:14 +0200)]
media: renesas: vsp1: Drop brx_get_compose() wrapper

The brx_get_compose() function is just a wrapper around
v4l2_subdev_state_get_compose() without any added value. Drop it and
call v4l2_subdev_state_get_compose() directly.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
3 months agomedia: renesas: vsp1: Drop vsp1_rwpf_get_crop() wrapper
Laurent Pinchart [Sun, 12 Nov 2023 02:14:05 +0000 (04:14 +0200)]
media: renesas: vsp1: Drop vsp1_rwpf_get_crop() wrapper

The vsp1_rwpf_get_crop() function is just a wrapper around
v4l2_subdev_state_get_crop() without any added value. Drop it and call
v4l2_subdev_state_get_crop() directly.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
3 months agomedia: renesas: vsp1: Drop vsp1_entity_get_pad_selection() wrapper
Laurent Pinchart [Sun, 12 Nov 2023 02:14:05 +0000 (04:14 +0200)]
media: renesas: vsp1: Drop vsp1_entity_get_pad_selection() wrapper

The vsp1_entity_get_pad_selection() function is just a wrapper around
v4l2_subdev_state_get_crop() or v4l2_subdev_state_get_compose() without
any added value. Drop it and call the functions it wraps directly.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
3 months agomedia: renesas: vsp1: Drop vsp1_entity_get_pad_format() wrapper
Laurent Pinchart [Sun, 12 Nov 2023 02:14:05 +0000 (04:14 +0200)]
media: renesas: vsp1: Drop vsp1_entity_get_pad_format() wrapper

The vsp1_entity_get_pad_format() function is just a wrapper around
v4l2_subdev_state_get_format() without any added value. Drop it and call
v4l2_subdev_state_get_format() directly.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
3 months agomedia: renesas: vsp1: Print debug message to diagnose validation failure
Laurent Pinchart [Tue, 18 Jun 2024 18:46:44 +0000 (21:46 +0300)]
media: renesas: vsp1: Print debug message to diagnose validation failure

When formats don't match between a subdev and a connected video device,
starting streaming returns an error without giving the user any
indication as to what went wrong. To help debugging pipeline
misconfigurations, add a debug message that indicates the cause of the
failure.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
3 months agomedia: v4l2-subdev: Drop unreacheable warning
Laurent Pinchart [Mon, 13 Nov 2023 09:35:23 +0000 (11:35 +0200)]
media: v4l2-subdev: Drop unreacheable warning

The v4l2_subdev_link_validate_get_format() function warns if the pad
given as argument belongs to a non-subdev entity. This can't happen, as
the function is called from v4l2_subdev_link_validate() only (indirectly
through v4l2_subdev_link_validate_locked()), and that function ensures
that both ends of the link are subdevs.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
3 months agomedia: videobuf2: core: Drop unneeded forward declaration
Laurent Pinchart [Sun, 5 May 2024 17:19:45 +0000 (20:19 +0300)]
media: videobuf2: core: Drop unneeded forward declaration

The static __enqueue_in_driver() function is forward-declared
needlessly, as it isn't called before its definition. Drop the forward
declaration.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
3 months agomedia: renesas: vsp1: Fix _irqsave and _irq mix
Laurent Pinchart [Sun, 5 May 2024 17:22:27 +0000 (20:22 +0300)]
media: renesas: vsp1: Fix _irqsave and _irq mix

The histogram support mixes _irqsave and _irq, causing the following
smatch warning:

     drivers/media/platform/renesas/vsp1/vsp1_histo.c:153 histo_stop_streaming()
     warn: mixing irqsave and irq

The histo_stop_streaming() calls spin_lock_irqsave() followed by
wait_event_lock_irq(). The former hints that interrupts may be disabled
by the caller, while the latter reenables interrupts unconditionally.
This doesn't cause any real bug, as the function is always called with
interrupts enabled, but the pattern is still incorrect.

Fix the problem by using spin_lock_irq() instead of spin_lock_irqsave()
in histo_stop_streaming(). While at it, switch to spin_lock_irq() and
spin_lock() as appropriate elsewhere.

Fixes: 99362e32332b ("[media] v4l: vsp1: Add histogram support")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-renesas-soc/164d74ff-312c-468f-be64-afa7182cd2f4@moroto.mountain/
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
3 months agomedia: max9286: Use frame interval from subdev state
Jacopo Mondi [Mon, 17 Jun 2024 16:11:34 +0000 (18:11 +0200)]
media: max9286: Use frame interval from subdev state

Use the frame interval stored in the subdev state instead of storing
a copy in the driver private structure.

Initialize the frame interval to the special case 0/0 that in the
max9286 driver represents automatic handling of frame sync.

As the frame sync mode is set at s_stream() time, we can remove it
from max9286_setup().

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/r/20240617161135.130719-12-jacopo.mondi@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
3 months agomedia: max9286: Use the subdev active state
Jacopo Mondi [Mon, 17 Jun 2024 16:11:33 +0000 (18:11 +0200)]
media: max9286: Use the subdev active state

Use the subdev active state in the max9286 driver to store the
image format.

Replace the .open() function call with the .init_state() one and
simplify the set/get_pad_fmt() operations.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20240617161135.130719-11-jacopo.mondi@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
3 months agomedia: max9286: Fix enum_mbus_code
Jacopo Mondi [Mon, 17 Jun 2024 16:11:32 +0000 (18:11 +0200)]
media: max9286: Fix enum_mbus_code

The max9286 driver supports multiple output formats but only a single
one is reported through the .enum_mbus_code operation.

Fix that.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20240617161135.130719-10-jacopo.mondi@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
3 months agomedia: adv748x-csi2: Use the subdev active state
Jacopo Mondi [Mon, 17 Jun 2024 16:11:31 +0000 (18:11 +0200)]
media: adv748x-csi2: Use the subdev active state

Initialize and use the subdev active state to store the subdevice
format.

This simplifies the implementation of the get_fmt and set_fmt pad
operations.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Tested-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://lore.kernel.org/r/20240617161135.130719-9-jacopo.mondi@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
3 months agomedia: adv748x-csi2: Validate the image format
Jacopo Mondi [Mon, 17 Jun 2024 16:11:30 +0000 (18:11 +0200)]
media: adv748x-csi2: Validate the image format

The adv748x-csi2 driver configures the CSI-2 transmitter to
automatically infer the image stream format from the connected
frontend (HDMI or AFE).

Setting a new format on the subdevice hence does not actually control
the CSI-2 output format, but it's only there for the purpose of
pipeline validation.

However, there is currently no validation that the supplied media bus
code is valid and supported by the device.

With the introduction of enum_mbus_codes a list of supported format is
now available, use it to validate that the supplied format is correct
and use the default UYVY8 one if that's not the case.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Tested-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/r/20240617161135.130719-8-jacopo.mondi@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
3 months agomedia: adv748x-afe: Use 1X16 media bus code
Jacopo Mondi [Mon, 17 Jun 2024 16:11:29 +0000 (18:11 +0200)]
media: adv748x-afe: Use 1X16 media bus code

Now that the adv748x CSI-2 transmitter driver validates the supported
formats, it is required for subdevices along the pipeline to produce
and consume the same media bus codes.

The adv748x analog front end driver use the 2X8 variant of the UYVY8
media bus code, while the CSI-2 transmitter use the 1X16 variant, which
is the correct one to use for the serial bus.

Make the adv748x afe use the 1X16 format variant to maintain the
pipeline validation correct.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Tested-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://lore.kernel.org/r/20240617161135.130719-7-jacopo.mondi@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
3 months agomedia: adv748x-csi2: Implement enum_mbus_codes
Jacopo Mondi [Mon, 17 Jun 2024 16:11:28 +0000 (18:11 +0200)]
media: adv748x-csi2: Implement enum_mbus_codes

Define a list of supported mbus codes for the TXA and TXB CSI-2
transmitters and implement the enum_mbus_code operation.

The TXB transmitter only support YUV422 while the TXA one supports
multiple formats as reported by the chip's manual in section 9.7.
but the HDMI and AFE subdevices only provide RGB888 and YUV422, so only
list those ones here.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Tested-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://lore.kernel.org/r/20240617161135.130719-6-jacopo.mondi@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
3 months agomedia: rcar-csi2: Use the subdev active state
Jacopo Mondi [Mon, 17 Jun 2024 16:11:27 +0000 (18:11 +0200)]
media: rcar-csi2: Use the subdev active state

Create the subdevice state with v4l2_subdev_init_finalize() and
implement the init_state() operation to guarantee the state is initialized.

Store the current image format in the subdev active state and remove it
from the driver private structure.

To guarantee the same image format is applied to all source pads,
propagate the format from the sink pad to the sources, disallowing
changing format on a source pad.

To support both gen3 and gen4, which feature a different number of
source pads, introduce an helper function to return the correct number
of pads.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Tested-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://lore.kernel.org/r/20240617161135.130719-5-jacopo.mondi@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>