linux-block.git
7 months agomedia: rtl2832_sdr: drop vb2_ops_wait_prepare/finish
Hans Verkuil [Mon, 14 Oct 2024 15:06:33 +0000 (17:06 +0200)]
media: rtl2832_sdr: drop vb2_ops_wait_prepare/finish

Since commit 88785982a19d ("media: vb2: use lock if wait_prepare/finish
are NULL") it is no longer needed to set the wait_prepare/finish
vb2_ops callbacks as long as the lock field in vb2_queue is set.

Since the vb2_ops_wait_prepare/finish callbacks already rely on that field,
we can safely drop these callbacks.

This simplifies the code and this is a step towards the goal of deleting
these callbacks.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: video-i2c: drop vb2_ops_wait_prepare/finish
Hans Verkuil [Mon, 14 Oct 2024 15:06:32 +0000 (17:06 +0200)]
media: video-i2c: drop vb2_ops_wait_prepare/finish

Since commit 88785982a19d ("media: vb2: use lock if wait_prepare/finish
are NULL") it is no longer needed to set the wait_prepare/finish
vb2_ops callbacks as long as the lock field in vb2_queue is set.

Since the vb2_ops_wait_prepare/finish callbacks already rely on that field,
we can safely drop these callbacks.

This simplifies the code and this is a step towards the goal of deleting
these callbacks.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
7 months agomedia: usb: drop vb2_ops_wait_prepare/finish
Hans Verkuil [Mon, 14 Oct 2024 15:06:31 +0000 (17:06 +0200)]
media: usb: drop vb2_ops_wait_prepare/finish

Since commit 88785982a19d ("media: vb2: use lock if wait_prepare/finish
are NULL") it is no longer needed to set the wait_prepare/finish
vb2_ops callbacks as long as the lock field in vb2_queue is set.

Since the vb2_ops_wait_prepare/finish callbacks already rely on that field,
we can safely drop these callbacks.

This simplifies the code and this is a step towards the goal of deleting
these callbacks.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: pci: drop vb2_ops_wait_prepare/finish
Hans Verkuil [Mon, 14 Oct 2024 15:06:30 +0000 (17:06 +0200)]
media: pci: drop vb2_ops_wait_prepare/finish

Since commit 88785982a19d ("media: vb2: use lock if wait_prepare/finish
are NULL") it is no longer needed to set the wait_prepare/finish
vb2_ops callbacks as long as the lock field in vb2_queue is set.

Since the vb2_ops_wait_prepare/finish callbacks already rely on that field,
we can safely drop these callbacks.

This simplifies the code and this is a step towards the goal of deleting
these callbacks.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
7 months agomedia: test-drivers: drop vb2_ops_wait_prepare/finish
Hans Verkuil [Mon, 14 Oct 2024 15:06:29 +0000 (17:06 +0200)]
media: test-drivers: drop vb2_ops_wait_prepare/finish

Since commit 88785982a19d ("media: vb2: use lock if wait_prepare/finish
are NULL") it is no longer needed to set the wait_prepare/finish
vb2_ops callbacks as long as the lock field in vb2_queue is set.

Since the vb2_ops_wait_prepare/finish callbacks already rely on that field,
we can safely drop these callbacks.

This simplifies the code and this is a step towards the goal of deleting
these callbacks.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
7 months agomedia: videobuf2-core: update vb2_thread if wait_finish/prepare are NULL
Hans Verkuil [Thu, 17 Oct 2024 15:09:23 +0000 (17:09 +0200)]
media: videobuf2-core: update vb2_thread if wait_finish/prepare are NULL

The vb2_thread is used for DVB support. This will queue and dequeue buffers
automatically.

It calls wait_finish/prepare around vb2_core_dqbuf() and vb2_core_qbuf(),
but that assumes all drivers have these ops set. But that will change
due to commit 88785982a19d ("media: vb2: use lock if wait_prepare/finish
are NULL").

So instead just check if the callback is available, and if not, use
q->lock, just as __vb2_wait_for_done_vb() does.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
7 months agomedia: uvcvideo: Stop stream during unregister
Ricardo Ribalda [Thu, 26 Sep 2024 05:59:06 +0000 (05:59 +0000)]
media: uvcvideo: Stop stream during unregister

uvc_unregister_video() can be called asynchronously from
uvc_disconnect(). If the device is still streaming when that happens, a
plethora of race conditions can occur.

Make sure that the device has stopped streaming before exiting this
function.

If the user still holds handles to the driver's file descriptors, any
ioctl will return -ENODEV from the v4l2 core.

This change makes uvc more consistent with the rest of the v4l2 drivers
using the vb2_fop_* and vb2_ioctl_* helpers.

This driver (and many other usb drivers) always had this problem, but it
wasn't possible to easily fix this until the vb2_video_unregister_device()
helper was added. So the Fixes tag points to the creation of that helper.

Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl>
Suggested-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Fixes: f729ef5796d8 ("media: videobuf2-v4l2.c: add vb2_video_unregister_device helper function")
Cc: stable@vger.kernel.org # 5.10.x
[hverkuil: add note regarding Fixes version]
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: renesas: rzg2l-cru: Add 'yuv' flag to IP format structure
Lad Prabhakar [Fri, 18 Oct 2024 13:34:46 +0000 (14:34 +0100)]
media: renesas: rzg2l-cru: Add 'yuv' flag to IP format structure

Add a 'yuv' flag to the `rzg2l_cru_ip_format` structure to indicate
whether a given format is YUV-based and update the `rzg2l_cru_ip_formats`
array with this flag appropriately. This change enables a more efficient
way to check if the input and output formats use the same colorspace.

With this change, we can eliminate the use of `v4l2_format_info()` in
`rzg2l_cru_initialize_image_conv()` as the necessary details for the source
and destination formats are already available through the `yuv` flag.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-24-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: Move register definitions to a separate file
Lad Prabhakar [Fri, 18 Oct 2024 13:34:45 +0000 (14:34 +0100)]
media: rzg2l-cru: Move register definitions to a separate file

Move the RZ/G2L CRU register definitions from `rzg2l-video.c` to a
dedicated header file, `rzg2l-cru-regs.h`. Separating these definitions
into their own file improves the readability of the code.

Suggested-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-23-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: Add support to capture 8bit raw sRGB
Lad Prabhakar [Fri, 18 Oct 2024 13:34:44 +0000 (14:34 +0100)]
media: rzg2l-cru: Add support to capture 8bit raw sRGB

Add support to capture 8bit Bayer formats.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-22-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: Refactor ICnDMR register configuration
Lad Prabhakar [Fri, 18 Oct 2024 13:34:43 +0000 (14:34 +0100)]
media: rzg2l-cru: Refactor ICnDMR register configuration

Refactor the ICnDMR register configuration in
`rzg2l_cru_initialize_image_conv()` by adding a new member `icndmr` in the
`rzg2l_cru_ip_format` structure.

Suggested-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-21-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: csi2: Use rzg2l_csi2_formats array in enum_frame_size
Lad Prabhakar [Fri, 18 Oct 2024 13:34:42 +0000 (14:34 +0100)]
media: rzg2l-cru: csi2: Use rzg2l_csi2_formats array in enum_frame_size

Make use of `rzg2l_csi2_formats` array in rzg2l_csi2_enum_frame_size() to
validate if the `fse->code` is supported.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-20-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: video: Implement .link_validate() callback
Lad Prabhakar [Fri, 18 Oct 2024 13:34:41 +0000 (14:34 +0100)]
media: rzg2l-cru: video: Implement .link_validate() callback

Implement the `.link_validate()` callback for the video node and move the
format checking into this function. This change allows the removal of
`rzg2l_cru_mc_validate_format()`.

Note, the fmt.format.code and fmt.format.field checks have be dropped as
the subdev .set_fmt() handler ensures that those fields always hold valid
values.

Suggested-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-19-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: csi2: Remove unused field from rzg2l_csi2_format
Lad Prabhakar [Fri, 18 Oct 2024 13:34:40 +0000 (14:34 +0100)]
media: rzg2l-cru: csi2: Remove unused field from rzg2l_csi2_format

Remove the unused `datatype` field from the `rzg2l_csi2_format` struct and
update the `rzg2l_csi2_formats[]` array to reflect the updated structure.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-18-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: Use `rzg2l_cru_ip_formats` array in enum_frame_size
Lad Prabhakar [Fri, 18 Oct 2024 13:34:39 +0000 (14:34 +0100)]
media: rzg2l-cru: Use `rzg2l_cru_ip_formats` array in enum_frame_size

Use the `rzg2l_cru_ip_formats` array in `rzg2l_cru_ip_enum_frame_size()`
to validate the format code.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-17-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: Make use of v4l2_format_info() helpers
Lad Prabhakar [Fri, 18 Oct 2024 13:34:38 +0000 (14:34 +0100)]
media: rzg2l-cru: Make use of v4l2_format_info() helpers

Make use of v4l2_format_info() helpers to determine the input and
output formats.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-16-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: Inline calculating bytesperline
Lad Prabhakar [Fri, 18 Oct 2024 13:34:37 +0000 (14:34 +0100)]
media: rzg2l-cru: Inline calculating bytesperline

Remove the `rzg2l_cru_format_bytesperline()` function and inline the
calculation of `bytesperline` directly in `rzg2l_cru_format_align()`.
This simplifies the code by removing an unnecessary function call and
directly multiplying the image width by the `bpp` (bytes per pixel)
from the format structure.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-15-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: Simplify handling of supported formats
Lad Prabhakar [Fri, 18 Oct 2024 13:34:36 +0000 (14:34 +0100)]
media: rzg2l-cru: Simplify handling of supported formats

Refactor the handling of supported formats in the RZ/G2L CRU driver by
adding `pixelformat` and `bpp` members to the `rzg2l_cru_ip_format`
structure.

New helper functions, `rzg2l_cru_ip_format_to_fmt()` and
`rzg2l_cru_ip_index_to_fmt()`, are added to retrieve format information
based on 4CC format and index, respectively. These helpers allow the
removal of the now redundant `rzg2l_cru_format_from_pixel()` function.

The new helpers are used in `rzg2l_cru_format_bytesperline()`,
`rzg2l_cru_format_align()`, and `rzg2l_cru_enum_fmt_vid_cap()`,
streamlining the handling of supported formats and improving code
maintainability.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-14-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: Inline calculating image size
Lad Prabhakar [Fri, 18 Oct 2024 13:34:35 +0000 (14:34 +0100)]
media: rzg2l-cru: Inline calculating image size

Inline the `rzg2l_cru_format_sizeimage()` function into its single
caller as the function is trivial and is not expected to be called
anywhere else.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-13-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: Simplify configuring input format for image processing
Lad Prabhakar [Fri, 18 Oct 2024 13:34:34 +0000 (14:34 +0100)]
media: rzg2l-cru: Simplify configuring input format for image processing

Move the `rzg2l_cru_ip_format` struct to `rzg2l-cru.h` for better
accessibility and add a `datatype` member to it, allowing the
configuration of the ICnMC register based on the MIPI CSI2 data type.

Also, move the `rzg2l_cru_ip_code_to_fmt()` function to `rzg2l-cru.h`
to streamline format lookup and make it more accessible across the
driver.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-12-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: Remove unnecessary WARN_ON check in format func
Lad Prabhakar [Fri, 18 Oct 2024 13:34:33 +0000 (14:34 +0100)]
media: rzg2l-cru: Remove unnecessary WARN_ON check in format func

`WARN_ON(!fmt)` check in `rzg2l_cru_format_bytesperline()` is unnecessary
because the `rzg2l_cru_format_align()` function ensures that a valid
`pixelformat` is set before calling `rzg2l_cru_format_bytesperline()`. As
a result, `rzg2l_cru_format_from_pixel()` is guaranteed to return a
non-NULL value, making the check redundant.

Additionally, the return type of `rzg2l_cru_format_bytesperline()` is
`u32`, but the code returned `-EINVAL`, a negative value. This mismatch is
now resolved by removing the invalid error return path.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-11-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: Remove unused fields from rzg2l_cru_ip_format struct
Lad Prabhakar [Fri, 18 Oct 2024 13:34:32 +0000 (14:34 +0100)]
media: rzg2l-cru: Remove unused fields from rzg2l_cru_ip_format struct

Simplified the `rzg2l_cru_ip_format` struct by removing the unused
`datatype` and `bpp` fields from the structure in `rzg2l-ip.c`.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-10-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: Use MIPI CSI-2 data types for ICnMC_INF definitions
Lad Prabhakar [Fri, 18 Oct 2024 13:34:31 +0000 (14:34 +0100)]
media: rzg2l-cru: Use MIPI CSI-2 data types for ICnMC_INF definitions

The INF field in the ICnMC register accepts data type codes as specified
in the MIPI CSI-2 v2.1 specification. This patch introduces the
`ICnMC_INF()` macro to use the MIPI CSI-2 data types, which are available
in the `media/mipi-csi2.h` header.

Suggested-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-9-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: Remove `channel` member from `struct rzg2l_cru_csi`
Lad Prabhakar [Fri, 18 Oct 2024 13:34:30 +0000 (14:34 +0100)]
media: rzg2l-cru: Remove `channel` member from `struct rzg2l_cru_csi`

Remove the CSI virtual channel number from `struct rzg2l_cru_csi`.
Instead, pass the CSI virtual channel number as an argument to
`rzg2l_cru_csi2_setup()`.

Suggested-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-8-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: Retrieve virtual channel information
Lad Prabhakar [Fri, 18 Oct 2024 13:34:29 +0000 (14:34 +0100)]
media: rzg2l-cru: Retrieve virtual channel information

The RZ/G2L CRU needs to configure the ICnMC.VCSEL bits to specify which
virtual channel should be processed from the four available VCs. To
retrieve this information from the connected subdevice, the
.get_frame_desc() function is called.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-7-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: csi2: Implement .get_frame_desc()
Lad Prabhakar [Fri, 18 Oct 2024 13:34:28 +0000 (14:34 +0100)]
media: rzg2l-cru: csi2: Implement .get_frame_desc()

The RZ/G2L CRU requires information about which VCx to process data from,
among the four available VCs. To obtain this information, the
.get_frame_desc() routine is implemented. This routine, in turn, calls
.get_frame_desc() on the remote sensor connected to the CSI2 bridge.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-6-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: csi2: Use ARRAY_SIZE() in media_entity_pads_init()
Lad Prabhakar [Fri, 18 Oct 2024 13:34:27 +0000 (14:34 +0100)]
media: rzg2l-cru: csi2: Use ARRAY_SIZE() in media_entity_pads_init()

The media_entity_pads_init() function was previously hardcoded to use a
magic number for the number of pads. Replace the magic number with the
ARRAY_SIZE() macro to determine the number of pads dynamically.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-5-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: csi2: Mark sink and source pad with MUST_CONNECT flag
Lad Prabhakar [Fri, 18 Oct 2024 13:34:26 +0000 (14:34 +0100)]
media: rzg2l-cru: csi2: Mark sink and source pad with MUST_CONNECT flag

Mark the sink and source pad with the MEDIA_PAD_FL_MUST_CONNECT flag to
ensure pipeline validation fails if it is not connected.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-4-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: Mark sink and source pad with MUST_CONNECT flag
Lad Prabhakar [Fri, 18 Oct 2024 13:34:25 +0000 (14:34 +0100)]
media: rzg2l-cru: Mark sink and source pad with MUST_CONNECT flag

Mark the sink and source pad with the MEDIA_PAD_FL_MUST_CONNECT flag to
ensure pipeline validation fails if it is not connected.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-3-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: rzg2l-cru: Use RZG2L_CRU_IP_SINK/SOURCE enum entries
Lad Prabhakar [Fri, 18 Oct 2024 13:34:24 +0000 (14:34 +0100)]
media: rzg2l-cru: Use RZG2L_CRU_IP_SINK/SOURCE enum entries

Use enum values (`RZG2L_CRU_IP_SINK` and `RZG2L_CRU_IP_SOURCE`) instead
of hardcoded array indices.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-2-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
7 months agomedia: platform: rzg2l-cru: rzg2l-video: Set AXI burst max length
Biju Das [Thu, 5 Sep 2024 11:18:26 +0000 (12:18 +0100)]
media: platform: rzg2l-cru: rzg2l-video: Set AXI burst max length

As per the hardware manual section 35.2.3.26 'AXI Master Transfer
Setting Register for CRU Image Data', it is mentioned that to improve
the transfer performance of CRU, it is recommended to use AXILEN value
'0xf' for AXI burst max length setting for image data.

Signed-off-by: Hien Huynh <hien.huynh.px@renesas.com>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/r/20240905111828.159670-1-biju.das.jz@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: atomisp: Replace ternary operator with if
Ricardo Ribalda [Sat, 28 Sep 2024 17:24:00 +0000 (17:24 +0000)]
media: atomisp: Replace ternary operator with if

Replace the ternary operator with an if. In this case the code is more
clear and also fixes the following cocci warnings:

drivers/staging/media/atomisp/pci/sh_css_frac.h:40:17-18: WARNING opportunity for max()
drivers/staging/media/atomisp/pci/sh_css_frac.h:50:17-18: WARNING opportunity for max()

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Acked-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: platform: video-mux: Fix mutex locking
Paul Elder [Mon, 9 Sep 2024 15:48:28 +0000 (17:48 +0200)]
media: platform: video-mux: Fix mutex locking

The current order of locking between the driver mutex and the v4l2 subdev
state lock causes a circular locking dependency when trying to set up a
link. Fix this.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[Sakari Ailus: Fix spelling in commit message.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: ipu6: remove redundant dependency in Kconfig
Bingbu Cao [Wed, 9 Oct 2024 05:20:31 +0000 (13:20 +0800)]
media: ipu6: remove redundant dependency in Kconfig

IPU6 driver simply depends on X86, X86 and 64BIT cover the
X86_64, redundant X86_64 dependency in Kconfig could be removed.

Fixes: c70281cc83d6 ("media: intel/ipu6: add Kconfig and Makefile")
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: ipu6: fix the wrong type casting and 64-bit division
Bingbu Cao [Wed, 9 Oct 2024 05:20:30 +0000 (13:20 +0800)]
media: ipu6: fix the wrong type casting and 64-bit division

This patch fixes the build errors with `i386-allmodconfig`, the
errors are caused by wrong type casting and 64-bit division.

Signed-off-by: Bingbu Cao <bingbu.cao@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+huawei@kernel.org>
8 months agov4l2-subdev: Return -EOPNOTSUPP for unsupported pad type in call_get_frame_desc()
Lad Prabhakar [Mon, 7 Oct 2024 12:38:09 +0000 (13:38 +0100)]
v4l2-subdev: Return -EOPNOTSUPP for unsupported pad type in call_get_frame_desc()

The `get_frame_desc()` operation should always be called on a source pad,
which is indicated by the `MEDIA_PAD_FL_SOURCE` flag. This patch adds a
check in `call_get_frame_desc()` to ensure that the `MEDIA_PAD_FL_SOURCE`
flag is set for the pad before invoking `get_frame_desc()`. If the pad is
not a source pad, the function will return an `-EOPNOTSUPP` error,
signaling that the operation is not supported on non-source pads.

Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: i2c: ds90ub960: Fix missing return check on ub960_rxport_read call
Colin Ian King [Wed, 2 Oct 2024 16:53:29 +0000 (17:53 +0100)]
media: i2c: ds90ub960: Fix missing return check on ub960_rxport_read call

The function ub960_rxport_read is being called and afterwards ret is
being checked for any failures, however ret is not being assigned to
the return of the function call. Fix this by assigning ret to the
return of the call which appears to be missing.

Fixes: afe267f2d368 ("media: i2c: add DS90UB960 driver")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: Documentation: Improve v4l2_subdev_{en,dis}able_streams documentation
Sakari Ailus [Tue, 17 Sep 2024 14:58:58 +0000 (17:58 +0300)]
media: Documentation: Improve v4l2_subdev_{en,dis}able_streams documentation

Document that callers of v4l2_subdev_{en,dis}able_streams() need to set
the mask to BIT_ULL(0).

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: Documentation: Update {enable,disable}_streams documentation
Sakari Ailus [Tue, 17 Sep 2024 12:31:47 +0000 (15:31 +0300)]
media: Documentation: Update {enable,disable}_streams documentation

Document the expected {enable,disable}_streams callback behaviour for
drivers that are stream-unaware i.e. don't specify the
V4L2_SUBDEV_CAP_STREAMS sub-device capability flag. In this specific case,
the mask argument can be ignored.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: Documentation: Deprecate s_stream video op, update docs
Sakari Ailus [Tue, 17 Sep 2024 12:14:44 +0000 (15:14 +0300)]
media: Documentation: Deprecate s_stream video op, update docs

The scope of the s_stream video operation is now fully supported by
{enable,disable}_streams. Explicitly document the s_stream() op as
deprecated and update the related documentation.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: platform: rzg2l-cru: rzg2l-video: Move request_irq() to probe()
Biju Das [Mon, 26 Aug 2024 11:07:30 +0000 (12:07 +0100)]
media: platform: rzg2l-cru: rzg2l-video: Move request_irq() to probe()

Move request_irq() to probe(), in order to avoid requesting IRQ during
device start which happens frequently. As this function is in probe(), it
is better to replace it with its devm variant for managing the resource
efficiently.

While at it, drop the IRQF_SHARED flag as currently there is a single user
for this IRQ.

Suggested-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: i2c: vgxy61: Fix an error handling path in vgxy61_detect()
Christophe JAILLET [Thu, 3 Oct 2024 17:53:15 +0000 (19:53 +0200)]
media: i2c: vgxy61: Fix an error handling path in vgxy61_detect()

If cci_read() fails, 'st' is set to 0 in cci_read(), so we return success,
instead of the expected error code.

Fix it and return the expected error.

Fixes: 9a6d7f2ba2b9 ("media: i2c: st-vgxy61: Convert to CCI register access helpers")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: admin-guide: Document the Raspberry Pi CFE (rp1-cfe)
Tomi Valkeinen [Thu, 3 Oct 2024 10:31:13 +0000 (13:31 +0300)]
media: admin-guide: Document the Raspberry Pi CFE (rp1-cfe)

Add documentation for rp1-cfe driver.

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+huawei@kernel.org>
8 months agomedia: raspberrypi: Add support for RP1-CFE
Tomi Valkeinen [Thu, 3 Oct 2024 10:31:12 +0000 (13:31 +0300)]
media: raspberrypi: Add support for RP1-CFE

Add support for Raspberry Pi CFE. The CFE is a hardware block that
contains:

- MIPI D-PHY
- MIPI CSI-2 receiver
- Front End ISP (FE)

The driver has been upported from the Raspberry Pi kernel commit
88a681df9623 ("ARM: dts: bcm2712-rpi: Add i2c<n>_pins labels").

Co-developed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
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+huawei@kernel.org>
8 months agodt-bindings: media: Add bindings for raspberrypi,rp1-cfe
Tomi Valkeinen [Thu, 3 Oct 2024 10:31:11 +0000 (13:31 +0300)]
dt-bindings: media: Add bindings for raspberrypi,rp1-cfe

Add DT bindings for raspberrypi,rp1-cfe.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
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+huawei@kernel.org>
8 months agomedia: uapi: Add meta formats for PiSP FE config and stats
Tomi Valkeinen [Thu, 3 Oct 2024 10:31:10 +0000 (13:31 +0300)]
media: uapi: Add meta formats for PiSP FE config and stats

Add two meta formats for PiSP FE: V4L2_META_FMT_RPI_FE_CFG and
V4L2_META_FMT_RPI_FE_STATS. The former is used to provide configuration
for the FE and the latter is used to read the statistics from the FE.

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+huawei@kernel.org>
8 months agostaging: media: ipu3: fix spelling mistakes
Hridesh MG [Wed, 2 Oct 2024 15:22:30 +0000 (20:52 +0530)]
staging: media: ipu3: fix spelling mistakes

Fix three minor spelling/grammar issues:
chunck -> chunk
procotol -> protocol
follow -> following

Signed-off-by: Hridesh MG <hridesh699@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: rcar-vin: Add support for RAW10
Niklas Söderlund [Wed, 4 Sep 2024 15:06:56 +0000 (17:06 +0200)]
media: rcar-vin: Add support for RAW10

Some R-Car SoCs are capable of capturing RAW10. Extend the format
enumeration, validation and setup to expose and configure for this
format if the particular device supports it.

The VIN is usually capable of converting from most media bus formats to
a range of different pixel formats. However if the input media bus
format is a RAW10 format this is not possible so the corresponding pixel
output format is forced.

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+huawei@kernel.org>
8 months agodt-bindings: media: renesas,isp: Add binding for V4M
Niklas Söderlund [Wed, 2 Oct 2024 10:33:18 +0000 (12:33 +0200)]
dt-bindings: media: renesas,isp: Add binding for V4M

Document support for the ISP module in the Renesas V4M (r8a779h0) SoC.
This device is compatible with the CSISP module on the other Gen4 SoCs.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: rcar-isp: Add family compatible for R-Car Gen4 family
Niklas Söderlund [Wed, 2 Oct 2024 10:33:17 +0000 (12:33 +0200)]
media: rcar-isp: Add family compatible for R-Car Gen4 family

Add the Gen4 family compatible. This will be used instead of a SoC
specific compatible for the new Gen4 SoC V4M. Two Gen4 boards (V3U and
V4H) have already been added prior and their bindings need to be kept
for backward compatibility.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agodt-bindings: media: renesas,isp: Add Gen4 family fallback
Niklas Söderlund [Wed, 2 Oct 2024 10:33:16 +0000 (12:33 +0200)]
dt-bindings: media: renesas,isp: Add Gen4 family fallback

The ISP Channel Selector IP is the same for all current Gen4 devices.
This was not known when adding support for V3U and V4H and a single SoC
specific compatible was used.

Before adding more SoC specific bindings for V4M add a family compatible
fallback for Gen4. That way the driver only needs to be updated once for
Gen4, and we still have the option to fix any problems in the driver if
any testable differences between the SoCs are found.

There are already DTS files using the V3U and V4H compatibles which
needs to be updated to not produce a warning for DTS checks. The driver
also needs to kept the compatible values to be backward compatible , but
for new Gen4 SoCs such as V4M we can avoid this.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: staging: max96712: Add support for MAX96724
Niklas Söderlund [Wed, 2 Oct 2024 09:23:31 +0000 (11:23 +0200)]
media: staging: max96712: Add support for MAX96724

The MAX96724 is almost identical to the MAX96712 and can be supported by
the same driver, add support for it.

For the staging driver which only supports patter generation the big
difference is that the datasheet (rev 4) for MAX96724 do not describe
the DEBUG_EXTRA register, which is at offset 0x0009 on MAX96712. It's
not clear if this register is removed or moved to a different offset.
What is known is writing to register 0x0009 have no effect on MAX96724.

This makes it impossible to increase the test pattern clock frequency
from 25 MHz to 75Mhz on MAX96724. To be able to get a stable test
pattern the DPLL frequency have to be increase instead to compensate for
this. The frequency selected is found by experimentation as the MAX96724
datasheet is much sparser then what's available for MAX96712.

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+huawei@kernel.org>
8 months agomedia: staging: max96712: Document the DEBUG_EXTRA register
Niklas Söderlund [Wed, 2 Oct 2024 09:23:30 +0000 (11:23 +0200)]
media: staging: max96712: Document the DEBUG_EXTRA register

The DEBUG_EXTRA register is not part of soon to be added MAX96724
device. To make it easier to understand the differences when reading the
code prepare for the addition by creating named defines for the
register.

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+huawei@kernel.org>
8 months agomedia: staging: max96712: Move link frequency setting to device struct
Niklas Söderlund [Wed, 2 Oct 2024 09:23:29 +0000 (11:23 +0200)]
media: staging: max96712: Move link frequency setting to device struct

Prepare for supporting MAX96724 by moving the soon device specific link
frequency setting into information structure. This struct will be
extended to carry more differences between the two devices supported.

While at it remove trailing comma in device table, no entries will be
appended after the sentinel.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: staging: max96712: Remove device id check
Niklas Söderlund [Wed, 2 Oct 2024 09:23:28 +0000 (11:23 +0200)]
media: staging: max96712: Remove device id check

This check is incorrect and checks the wrong register. Furthermore there
is no documented shared device id register for MAX96712. There might be
overlap with the soon to be added MAX96724 device which do document such
a register.

However as the check was merely a precaution and to check during
development that the driver could talk to the device there is no harm in
removing it all together. A correct and more sophisticated check can be
added later if there ever is a need to differentiate between different
versions of a device.

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+huawei@kernel.org>
8 months agodt-bindings: i2c: maxim,max96712: Add compatible for MAX96724
Niklas Söderlund [Wed, 2 Oct 2024 09:23:27 +0000 (11:23 +0200)]
dt-bindings: i2c: maxim,max96712: Add compatible for MAX96724

The MAX96712 and MAX96724 are both quad GMSL2 to CSI-2 deserializers and
are in parts similar, but not identical. The most obvious difference is
on the CSI-2 side where the MAX96712 have 4 PHYs and support D-PHY with
1x4, 2x2 and 4x2 lanes where the MAX96724 only have 2 PHYs and supports
D-PHY with 2x4 or 4x2 lanes.

The register layout overlap in part but there are differences and holes.
Most of the differences are related to the different number of CSI-2
PHYs, but there are other capability differences between the two.

Add a specific compatible for MAX96724 to the max96712 bindings. The
bindings do not yet support validating all DT properties to limit it the
each devices capabilities. However to allow for this in future a
specific compatible for the two different devices are needed.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: rcar-csi2: Add support for R-Car V4M
Niklas Söderlund [Fri, 30 Aug 2024 20:31:04 +0000 (22:31 +0200)]
media: rcar-csi2: Add support for R-Car V4M

The V4M is the second Gen4 device that is enabled in the rcar-csi2
driver. There is much overlap with the already supported V4H device. The
registers that where new on Gen4 and where added with the V4H prefix are
retained and only new registers unique to the V4M are added with the new
V4M prefix. This follows the style for when V4H was added which had an
overlap with Gen3 registers.

The V4M CSI-2 receiver supports D-PHY mode only, either in 1-, 2- or
4-lane configuration. The datasheets do not document lane swapping and
is left out for now.

While the V4M only supports D-PHY the configuration for it is added in
such a way that it can be reused for V4H which supports both C-PHY and
D-PHY. No known SoC exists to test the D-PHY configuration on V4H so
it's not wired-up.

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+huawei@kernel.org>
8 months agomedia: rcar-csi2: Add documentation for PHY_EN and PHY_MODE registers
Niklas Söderlund [Fri, 30 Aug 2024 20:31:03 +0000 (22:31 +0200)]
media: rcar-csi2: Add documentation for PHY_EN and PHY_MODE registers

Later datasheets add documentation for two magic value used for V4H
support. The same registers will also be used for V4M support, document
them.

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+huawei@kernel.org>
8 months agomedia: rcar-csi2: Move PHTW write helpers
Niklas Söderlund [Fri, 30 Aug 2024 20:31:02 +0000 (22:31 +0200)]
media: rcar-csi2: Move PHTW write helpers

Prepare for V4M support by moving the PHTW write helpers to the generic
write helpers. This is needed as adding V4M support will involve
interact with the PHTW register from code that are logically grouped
with similar code in such a way that forward declarations of these
helpers would otherwise be needed.

The functions are moved verbatim.

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+huawei@kernel.org>
8 months agomedia: rcar-csi2: Add helper to lookup mbps settings
Niklas Söderlund [Fri, 30 Aug 2024 20:31:01 +0000 (22:31 +0200)]
media: rcar-csi2: Add helper to lookup mbps settings

The structure mapping a configuration information to a particular mpbs
setting needs to be extended with more information to support future
SoCs. Before it is extended reduce code duplication by creating a helper
to lookup information from an array of mbps setting, the lookup code
has already been copied to two speared locations.

While at it rename the structure to make it clear it contains
information related to a mbps setting, not just a single register value.

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+huawei@kernel.org>
8 months agomedia: rcar-csi2: Abstract PHTW and PHYPLL register offsets
Niklas Söderlund [Fri, 30 Aug 2024 20:31:00 +0000 (22:31 +0200)]
media: rcar-csi2: Abstract PHTW and PHYPLL register offsets

Most of the registers used on the R-Car V4M CSI-2 IP are shared with the
devices already supported by the rcar-csi2 driver. Two registers which
function and layout are the same are however found on different offsets.

Prepare for adding support for R-Car V4M by storing the offset to these
two registers offsets in the device information structured. This way the
code, which is shared between the devices, can be reused when V4M
support is added.

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+huawei@kernel.org>
8 months agomedia: rcar-csi2: Allow writing any code and data value to PHTW
Niklas Söderlund [Fri, 30 Aug 2024 20:30:59 +0000 (22:30 +0200)]
media: rcar-csi2: Allow writing any code and data value to PHTW

The helper to write an array of code and data values to the PHY Test
Interface Write Register (PHTW) register uses the case where both code
and data are zero as an exit condition. This prevents writing data = 0
and code = 0 to the register.

Up until now this has been OK as no such combination where needed, and
it was a convenient exit condition. In future writing data = 0 and code
= 0 to the PHTW register will be needed.

Avoid using an exit condition when writing an array of PHTW values and
instead pass the length of the array to the helper. This allows any
combination of code and data to be written.

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+huawei@kernel.org>
8 months agomedia: rcar-csi2: Correct field size for PHTW writes
Niklas Söderlund [Fri, 30 Aug 2024 20:30:58 +0000 (22:30 +0200)]
media: rcar-csi2: Correct field size for PHTW writes

The data and code written thru the Test Interface Write Register (PHTW)
register are 8-bit wide, change the datatype used to reflect this.

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+huawei@kernel.org>
8 months agodt-bindings: media: renesas,csi2: Add binding for V4M
Niklas Söderlund [Fri, 30 Aug 2024 20:30:57 +0000 (22:30 +0200)]
dt-bindings: media: renesas,csi2: Add binding for V4M

Document support for the CSI-2 module in the Renesas V4M (r8a779h0) SoC.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: staging/intel-ipu3: css: Convert comma to semicolon
Shen Lichuan [Fri, 20 Sep 2024 02:17:16 +0000 (10:17 +0800)]
media: staging/intel-ipu3: css: Convert comma to semicolon

The return of function imgu_css_grid_end_calc is void.

To ensure code clarity and prevent potential errors, it's advisable
to employ the ';' as a statement separator, except when ',' are
intentionally used for specific purposes.

Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: ti: j721e-csi2rx: Convert comma to semicolon
Chen Ni [Tue, 3 Sep 2024 07:29:04 +0000 (15:29 +0800)]
media: ti: j721e-csi2rx: Convert comma to semicolon

Replace a comma between expression statements by a semicolon.

Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
Fixes: b4a3d877dc92 ("media: ti: Add CSI2RX support for J721E")
Reviewed-by: Jai Luthra <j-luthra@ti.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: i2c: imx290: Check for availability in probe()
Benjamin Bara [Tue, 3 Sep 2024 14:54:34 +0000 (16:54 +0200)]
media: i2c: imx290: Check for availability in probe()

Currently, the V4L2 subdevice is also created when the device is not
available/connected. From userspace perspective, there is no visible
difference between a working and not-working subdevice (except when
trying it out).

This commit adds a simple preparation step, which includes an
availability check, before the subdev is initialized.

Signed-off-by: Benjamin Bara <benjamin.bara@skidata.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: i2c: imx290: Avoid communication during probe()
Benjamin Bara [Tue, 3 Sep 2024 14:54:33 +0000 (16:54 +0200)]
media: i2c: imx290: Avoid communication during probe()

As we don't know the mode during probe(), it doesn't make sense to
update the sensors' registers with assumptions. As imx290_set_ctrl(),
which is responsible for the happening communication, already ensures that
there is no communication with a suspended sensor, put the sensor to
suspend before calling it.

To clarify the dependency of the PM runtime to the link of the subdev
and the imx290 instance, put the block together.

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Benjamin Bara <benjamin.bara@skidata.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: i2c: imx290: Remove CHIP_ID reg definition
Benjamin Bara [Tue, 3 Sep 2024 14:54:32 +0000 (16:54 +0200)]
media: i2c: imx290: Remove CHIP_ID reg definition

This register is not described in the public available imx290 datasheet.
Additionally, a read returns '0x07d0' for an imx327lqr and also for an
imx462, which means it cannot be used to distinguish between those two
imx290 derivatives.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Benjamin Bara <benjamin.bara@skidata.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: i2c: Fix typos in comments across various files
Yu Jiaoliang [Wed, 25 Sep 2024 06:59:01 +0000 (14:59 +0800)]
media: i2c: Fix typos in comments across various files

This commit corrects spelling errors in comments within
the media/i2c directory found by codespell to enhance clarity
and maintainability of the code.
This change does not affect the functionality.

Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: i2c: max96717: clean up on error in max96717_subdev_init()
Dan Carpenter [Fri, 27 Sep 2024 10:59:10 +0000 (13:59 +0300)]
media: i2c: max96717: clean up on error in max96717_subdev_init()

Call v4l2_ctrl_handler_free() to clean up from v4l2_ctrl_handler_init().

Fixes: 19b5e5511ca4 ("media: i2c: max96717: add test pattern ctrl")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Julien Massot <julien.massot@collabora.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: i2c: max96717: add HAS_EVENTS support
Tommaso Merciai [Thu, 12 Sep 2024 14:06:49 +0000 (16:06 +0200)]
media: i2c: max96717: add HAS_EVENTS support

Controls can be exposed to userspace via a v4l-subdevX device, and
userspace has to be able to subscribe to control events so that it is
notified when the control changes value.
Add missing HAS_EVENTS support: flag and .(un)subscribe_event().

Signed-off-by: Tommaso Merciai <tomm.merciai@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: i2c: max96714: add HAS_EVENTS support
Tommaso Merciai [Thu, 12 Sep 2024 14:06:48 +0000 (16:06 +0200)]
media: i2c: max96714: add HAS_EVENTS support

Controls can be exposed to userspace via a v4l-subdevX device, and
userspace has to be able to subscribe to control events so that it is
notified when the control changes value.
Add missing HAS_EVENTS support: flag and .(un)subscribe_event().

Signed-off-by: Tommaso Merciai <tomm.merciai@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: verisilicon: Use V4L2_FMTDESC_FLAG_ENUM_ALL flag
Benjamin Gaignard [Mon, 26 Aug 2024 17:24:10 +0000 (17:24 +0000)]
media: verisilicon: Use V4L2_FMTDESC_FLAG_ENUM_ALL flag

By adding support for the V4L2_FMTDESC_FLAG_ENUM_ALL flag into the driver
we allow userspace applications to discover all possible
pixel formats of the hardware block. This way userspace can decide
which decoder to use given the supported pixel formats.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: test-drivers: Use V4L2_FMTDESC_FLAG_ENUM_ALL flag
Benjamin Gaignard [Mon, 26 Aug 2024 17:24:10 +0000 (17:24 +0000)]
media: test-drivers: Use V4L2_FMTDESC_FLAG_ENUM_ALL flag

Since the V4L2_FMTDESC_FLAG_ENUM_ALL flag mostly targets stateless
decoder pixel-format enumeration, update visl test driver to use it.
When V4L2_FMTDESC_FLAG_ENUM_ALL flag is set let the driver returns
one more pixel format.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: videodev2: Add flag to unconditionally enumerate pixel formats
Benjamin Gaignard [Mon, 26 Aug 2024 17:24:09 +0000 (17:24 +0000)]
media: videodev2: Add flag to unconditionally enumerate pixel formats

When the index is ORed with V4L2_FMTDESC_FLAG_ENUM_ALL the
driver clears the flag and enumerate all the possible formats,
ignoring any limitations from the current configuration.
Drivers which do not support this flag yet always return an EINVAL.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: improved doc when the new flag is not supported by the driver]

8 months agomedia: qcom: camss: move SM8250 regulators from CSID to CSIPHY subdevice
Vladimir Zapolskiy [Thu, 26 Sep 2024 21:19:57 +0000 (00:19 +0300)]
media: qcom: camss: move SM8250 regulators from CSID to CSIPHY subdevice

On Qualcomm SM8250 SoC there are two sets of regulators, and each of
both sets is specific to six CSIPHY IPs. At the moment there is no
proper split of two "combined" regulators with quite arbitrary selected
names in the driver or platform CAMSS device tree node, however for sake
of clarity and better hardware description it makes sense to move the
currently existing regulator resources from all CSID subdevices to all
CSIPHY subdevices.

Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: qcom: camss: add management of supply regulators to CSIPHY
Vladimir Zapolskiy [Thu, 26 Sep 2024 21:19:56 +0000 (00:19 +0300)]
media: qcom: camss: add management of supply regulators to CSIPHY

This change allows to properly assign and manage supply regulator
resources by CSIPHY subdevices of CAMSS, this is needed to fine tune
description of supply regulators on newer platforms, conversion of
old platforms to the new scheme is also anticipated.

Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Tested-by: Depeng Shao <quic_depengs@quicinc.com> # SM8550
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: qcom: camss: Add hooks to get CSID wrapper resources
Bryan O'Donoghue [Wed, 14 Aug 2024 16:14:34 +0000 (17:14 +0100)]
media: qcom: camss: Add hooks to get CSID wrapper resources

New SoCs have CSID devices inside of a shared "wrapper" i.e. a set of regs
which is responsible for manging the muxes of the CSID to various other
blocks throughout CAMSS.

Not every SoC has this top-level muxing layer so make it optional depending
on whether its declared as a resource or not.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: qcom: camss: fix error path on configuration of power domains
Vladimir Zapolskiy [Tue, 13 Aug 2024 21:03:42 +0000 (00:03 +0300)]
media: qcom: camss: fix error path on configuration of power domains

There is a chance to meet runtime issues during configuration of CAMSS
power domains, because on the error path dev_pm_domain_detach() is
unexpectedly called with NULL or error pointer.

One of the simplest ways to reproduce the problem is to probe CAMSS
driver before registration of CAMSS power domains, for instance if
a platform CAMCC driver is simply not built.

Warning backtrace example:

    Unable to handle kernel NULL pointer dereference at virtual address 00000000000001a2

    <snip>

    pc : dev_pm_domain_detach+0x8/0x48
    lr : camss_probe+0x374/0x9c0

    <snip>

    Call trace:
     dev_pm_domain_detach+0x8/0x48
     platform_probe+0x70/0xf0
     really_probe+0xc4/0x2a8
     __driver_probe_device+0x80/0x140
     driver_probe_device+0x48/0x170
     __device_attach_driver+0xc0/0x148
     bus_for_each_drv+0x88/0xf0
     __device_attach+0xb0/0x1c0
     device_initial_probe+0x1c/0x30
     bus_probe_device+0xb4/0xc0
     deferred_probe_work_func+0x90/0xd0
     process_one_work+0x164/0x3e0
     worker_thread+0x310/0x420
     kthread+0x120/0x130
     ret_from_fork+0x10/0x20

Fixes: 23aa4f0cd327 ("media: qcom: camss: Move VFE power-domain specifics into vfe.c")
Cc: <stable@vger.kernel.org>
Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: ts2020: fix null-ptr-deref in ts2020_probe()
Li Zetao [Thu, 10 Oct 2024 15:41:13 +0000 (23:41 +0800)]
media: ts2020: fix null-ptr-deref in ts2020_probe()

KASAN reported a null-ptr-deref issue when executing the following
command:

  # echo ts2020 0x20 > /sys/bus/i2c/devices/i2c-0/new_device
    KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
    CPU: 53 UID: 0 PID: 970 Comm: systemd-udevd Not tainted 6.12.0-rc2+ #24
    Hardware name: QEMU Standard PC (Q35 + ICH9, 2009)
    RIP: 0010:ts2020_probe+0xad/0xe10 [ts2020]
    RSP: 0018:ffffc9000abbf598 EFLAGS: 00010202
    RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffffc0714809
    RDX: 0000000000000002 RSI: ffff88811550be00 RDI: 0000000000000010
    RBP: ffff888109868800 R08: 0000000000000001 R09: fffff52001577eb6
    R10: 0000000000000000 R11: ffffc9000abbff50 R12: ffffffffc0714790
    R13: 1ffff92001577eb8 R14: ffffffffc07190d0 R15: 0000000000000001
    FS:  00007f95f13b98c0(0000) GS:ffff888149280000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 0000555d2634b000 CR3: 0000000152236000 CR4: 00000000000006f0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
     <TASK>
     ts2020_probe+0xad/0xe10 [ts2020]
     i2c_device_probe+0x421/0xb40
     really_probe+0x266/0x850
    ...

The cause of the problem is that when using sysfs to dynamically register
an i2c device, there is no platform data, but the probe process of ts2020
needs to use platform data, resulting in a null pointer being accessed.

Solve this problem by adding checks to platform data.

Fixes: dc245a5f9b51 ("[media] ts2020: implement I2C client bindings")
Cc: <stable@vger.kernel.org>
Signed-off-by: Li Zetao <lizetao1@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: platform: allegro-dvt: Fix possible memory leak in allocate_buffers_internal()
Gaosheng Cui [Wed, 9 Oct 2024 08:28:02 +0000 (16:28 +0800)]
media: platform: allegro-dvt: Fix possible memory leak in allocate_buffers_internal()

The buffer in the loop should be released under the exception path,
otherwise there may be a memory leak here.

To mitigate this, free the buffer when allegro_alloc_buffer fails.

Fixes: f20387dfd065 ("media: allegro: add Allegro DVT video IP core driver")
Cc: <stable@vger.kernel.org>
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: tc358743: Fix crash in the probe error path when using polling
Alexander Shiyan [Wed, 9 Oct 2024 06:05:44 +0000 (09:05 +0300)]
media: i2c: tc358743: Fix crash in the probe error path when using polling

If an error occurs in the probe() function, we should remove the polling
timer that was alarmed earlier, otherwise the timer is called with
arguments that are already freed, which results in a crash.

------------[ cut here ]------------
WARNING: CPU: 3 PID: 0 at kernel/time/timer.c:1830 __run_timers+0x244/0x268
Modules linked in:
CPU: 3 UID: 0 PID: 0 Comm: swapper/3 Not tainted 6.11.0 #226
Hardware name: Diasom DS-RK3568-SOM-EVB (DT)
pstate: 804000c9 (Nzcv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : __run_timers+0x244/0x268
lr : __run_timers+0x1d4/0x268
sp : ffffff80eff2baf0
x29: ffffff80eff2bb50 x28: 7fffffffffffffff x27: ffffff80eff2bb00
x26: ffffffc080f669c0 x25: ffffff80efef6bf0 x24: ffffff80eff2bb00
x23: 0000000000000000 x22: dead000000000122 x21: 0000000000000000
x20: ffffff80efef6b80 x19: ffffff80041c8bf8 x18: ffffffffffffffff
x17: ffffffc06f146000 x16: ffffff80eff27dc0 x15: 000000000000003e
x14: 0000000000000000 x13: 00000000000054da x12: 0000000000000000
x11: 00000000000639c0 x10: 000000000000000c x9 : 0000000000000009
x8 : ffffff80eff2cb40 x7 : ffffff80eff2cb40 x6 : ffffff8002bee480
x5 : ffffffc080cb2220 x4 : ffffffc080cb2150 x3 : 00000000000f4240
x2 : 0000000000000102 x1 : ffffff80eff2bb00 x0 : ffffff80041c8bf0
Call trace:
 __run_timers+0x244/0x268
 timer_expire_remote+0x50/0x68
 tmigr_handle_remote+0x388/0x39c
 run_timer_softirq+0x38/0x44
 handle_softirqs+0x138/0x298
 __do_softirq+0x14/0x20
 ____do_softirq+0x10/0x1c
 call_on_irq_stack+0x24/0x4c
 do_softirq_own_stack+0x1c/0x2c
 irq_exit_rcu+0x9c/0xcc
 el1_interrupt+0x48/0xc0
 el1h_64_irq_handler+0x18/0x24
 el1h_64_irq+0x7c/0x80
 default_idle_call+0x34/0x68
 do_idle+0x23c/0x294
 cpu_startup_entry+0x38/0x3c
 secondary_start_kernel+0x128/0x160
 __secondary_switched+0xb8/0xbc
---[ end trace 0000000000000000 ]---

Fixes: 4e66a52a2e4c ("[media] tc358743: Add support for platforms without IRQ line")
Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agoMAINTAINERS: mailmap: update Alexey Klimov's email address
Alexey Klimov [Tue, 8 Oct 2024 13:23:53 +0000 (14:23 +0100)]
MAINTAINERS: mailmap: update Alexey Klimov's email address

My new address is alexey.klimov@linaro.org

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: cec: seco: add HAS_IOPORT dependency
Arnd Bergmann [Fri, 4 Oct 2024 10:02:23 +0000 (10:02 +0000)]
media: cec: seco: add HAS_IOPORT dependency

This driver is now enabled for compile-testing on architectures
that may not have I/O port access:

drivers/media/cec/platform/seco/seco-cec.c: In function 'smb_word_op.constprop.isra':
include/asm-generic/io.h:542:14: error: call to '_inb' declared with attribute error: inb()) requires CONFIG_HAS_IOPORT

Add a Kconfig dependency again.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: platform: ti: omap: fix a typo
Andrew Kreimer [Thu, 3 Oct 2024 10:51:58 +0000 (13:51 +0300)]
media: platform: ti: omap: fix a typo

Fix a typo in comments "tobe -> to be".

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: cx231xx: Add support for Dexatek USB Video Grabber 1d19:6108
Rohan Barar [Thu, 3 Oct 2024 09:40:40 +0000 (19:40 +1000)]
media: cx231xx: Add support for Dexatek USB Video Grabber 1d19:6108

Add Dexatek Technology Ltd USB Video Grabber 1d19:6108 to the cx231xx
driver. This device is sold under the name "BAUHN DVD Maker (DK8723)" by
ALDI in Australia.

This device is similar to 1d19:6109, which is already included in cx231xx.

Both video and audio capture function correctly after installing the
patched cx231xx driver.

Patch Changelog
v1:
 - Initial submission.
v2:
 - Fix SoB + Improve subject.
v3:
 - Rephrase message to not exceed 75 characters per line.
 - Removed reference to external GitHub URL.

Signed-off-by: Rohan Barar <rohan.barar@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: cx231xx: Fix the S-Video capture on August VGB100
Fabio Luongo [Fri, 27 Sep 2024 13:38:41 +0000 (15:38 +0200)]
media: cx231xx: Fix the S-Video capture on August VGB100

There are three separate issues preventing color capture with S-Video
on August VGB100 with the cx231xx driver (same vid/pid as OTG102):

1. `cx231xx_set_decoder_video_input` is called with a u32 passed
   as its third argument, yet this functions expects a u8 instead.
   Some information about the configuration of the video mux is lost
   in the conversion, so that ch2 and ch3 do not get set by
   `cx231xx_afe_set_input_mux` (expecting a u32 but being passed a u8).

2. The input pin for the chroma signal is not correctly specified
   in cx231xx-cards.c, which can be verified by looking at the inf file
   coming with the VGB100 and OTG102' drivers for Windows.
   The mistake in the cx231xx driver likely stems from a wrong comment
   in the same file, suggesting VIN1_2 for chroma,
   while VIN3_2 is actually used.

3. Even after fixing the two issues above, the captured stream remains
   essentially B&W (although acquiring some pale green shades, suggesting
   we're moving in the right direction).
   After tests with somewhat random changes, it was found that removing
   `CX25840_SVIDEO_ON` from the vmux configuration in cx231xx-cards.c
   results in a captured stream with the expected colors.

Signed-off-by: Fabio Luongo <f.langufo.l@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: wl128x: Fix atomicity violation in fmc_send_cmd()
Qiu-ji Chen [Fri, 27 Sep 2024 08:39:02 +0000 (16:39 +0800)]
media: wl128x: Fix atomicity violation in fmc_send_cmd()

Atomicity violation occurs when the fmc_send_cmd() function is executed
simultaneously with the modification of the fmdev->resp_skb value.
Consider a scenario where, after passing the validity check within the
function, a non-null fmdev->resp_skb variable is assigned a null value.
This results in an invalid fmdev->resp_skb variable passing the validity
check. As seen in the later part of the function, skb = fmdev->resp_skb;
when the invalid fmdev->resp_skb passes the check, a null pointer
dereference error may occur at line 478, evt_hdr = (void *)skb->data;

To address this issue, it is recommended to include the validity check of
fmdev->resp_skb within the locked section of the function. This
modification ensures that the value of fmdev->resp_skb does not change
during the validation process, thereby maintaining its validity.

This possible bug is found by an experimental static analysis tool
developed by our team. This tool analyzes the locking APIs
to extract function pairs that can be concurrently executed, and then
analyzes the instructions in the paired functions to identify possible
concurrency bugs including data races and atomicity violations.

Fixes: e8454ff7b9a4 ("[media] drivers:media:radio: wl128x: FM Driver Common sources")
Cc: stable@vger.kernel.org
Signed-off-by: Qiu-ji Chen <chenqiuji666@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: Switch back to struct platform_driver::remove()
Uwe Kleine-König [Wed, 25 Sep 2024 11:45:47 +0000 (13:45 +0200)]
media: Switch back to struct platform_driver::remove()

After commit 0edb555a65d1 ("platform: Make platform_driver::remove()
return void") .remove() is (again) the right callback to implement for
platform drivers.

Convert all platform drivers below drivers/media to use .remove(), with
the eventual goal to drop struct platform_driver::remove_new(). As
.remove() and .remove_new() have the same prototypes, conversion is done
by just changing the structure member name in the driver initializer.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: dvb: Fix typos in comments across various files
Yu Jiaoliang [Wed, 25 Sep 2024 08:19:01 +0000 (16:19 +0800)]
media: dvb: Fix typos in comments across various files

This patch corrects spelling errors in comments within
the media/dvb-frontends directory found by codespell to enhance
clarity and maintainability of the code.
This change does not affect the functionality.

Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia:tuners: Fix typos in comments across various files
Yu Jiaoliang [Wed, 25 Sep 2024 07:09:13 +0000 (15:09 +0800)]
media:tuners: Fix typos in comments across various files

This commit corrects spelling errors in comments within
the media/tuners directory found by codespell to enhance
clarity and maintainability of the code.
This change does not affect the functionality.

Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
Acked-by: Akihiro Tsukada <tskd08@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: dw100: Rectify debug log
Umang Jain [Sat, 14 Sep 2024 14:29:28 +0000 (19:59 +0530)]
media: dw100: Rectify debug log

Rectify dev_dbg() log of dw100_hw_set_destination() from
"Set HW source registers" to "Set HW destination registers".

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: imx-jpeg: Ensure power suppliers be suspended before detach them
Ming Qian [Fri, 13 Sep 2024 06:22:54 +0000 (15:22 +0900)]
media: imx-jpeg: Ensure power suppliers be suspended before detach them

The power suppliers are always requested to suspend asynchronously,
dev_pm_domain_detach() requires the caller to ensure proper
synchronization of this function with power management callbacks.
otherwise the detach may led to kernel panic, like below:

[ 1457.107934] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000040
[ 1457.116777] Mem abort info:
[ 1457.119589]   ESR = 0x0000000096000004
[ 1457.123358]   EC = 0x25: DABT (current EL), IL = 32 bits
[ 1457.128692]   SET = 0, FnV = 0
[ 1457.131764]   EA = 0, S1PTW = 0
[ 1457.134920]   FSC = 0x04: level 0 translation fault
[ 1457.139812] Data abort info:
[ 1457.142707]   ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
[ 1457.148196]   CM = 0, WnR = 0, TnD = 0, TagAccess = 0
[ 1457.153256]   GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
[ 1457.158563] user pgtable: 4k pages, 48-bit VAs, pgdp=00000001138b6000
[ 1457.165000] [0000000000000040] pgd=0000000000000000, p4d=0000000000000000
[ 1457.171792] Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
[ 1457.178045] Modules linked in: v4l2_jpeg wave6_vpu_ctrl(-) [last unloaded: mxc_jpeg_encdec]
[ 1457.186383] CPU: 0 PID: 51938 Comm: kworker/0:3 Not tainted 6.6.36-gd23d64eea511 #66
[ 1457.194112] Hardware name: NXP i.MX95 19X19 board (DT)
[ 1457.199236] Workqueue: pm pm_runtime_work
[ 1457.203247] pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 1457.210188] pc : genpd_runtime_suspend+0x20/0x290
[ 1457.214886] lr : __rpm_callback+0x48/0x1d8
[ 1457.218968] sp : ffff80008250bc50
[ 1457.222270] x29: ffff80008250bc50 x28: 0000000000000000 x27: 0000000000000000
[ 1457.229394] x26: 0000000000000000 x25: 0000000000000008 x24: 00000000000f4240
[ 1457.236518] x23: 0000000000000000 x22: ffff00008590f0e4 x21: 0000000000000008
[ 1457.243642] x20: ffff80008099c434 x19: ffff00008590f000 x18: ffffffffffffffff
[ 1457.250766] x17: 5300326563697665 x16: 645f676e696c6f6f x15: 63343a6d726f6674
[ 1457.257890] x14: 0000000000000004 x13: 00000000000003a4 x12: 0000000000000002
[ 1457.265014] x11: 0000000000000000 x10: 0000000000000a60 x9 : ffff80008250bbb0
[ 1457.272138] x8 : ffff000092937200 x7 : ffff0003fdf6af80 x6 : 0000000000000000
[ 1457.279262] x5 : 00000000410fd050 x4 : 0000000000200000 x3 : 0000000000000000
[ 1457.286386] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff00008590f000
[ 1457.293510] Call trace:
[ 1457.295946]  genpd_runtime_suspend+0x20/0x290
[ 1457.300296]  __rpm_callback+0x48/0x1d8
[ 1457.304038]  rpm_callback+0x6c/0x78
[ 1457.307515]  rpm_suspend+0x10c/0x570
[ 1457.311077]  pm_runtime_work+0xc4/0xc8
[ 1457.314813]  process_one_work+0x138/0x248
[ 1457.318816]  worker_thread+0x320/0x438
[ 1457.322552]  kthread+0x110/0x114
[ 1457.325767]  ret_from_fork+0x10/0x20

Fixes: 2db16c6ed72c ("media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder")
Cc: <stable@vger.kernel.org>
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: TaoJiang <tao.jiang_2@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: amphion: Set video drvdata before register video device
Ming Qian [Fri, 13 Sep 2024 06:21:45 +0000 (15:21 +0900)]
media: amphion: Set video drvdata before register video device

The video drvdata should be set before the video device is registered,
otherwise video_drvdata() may return NULL in the open() file ops, and led
to oops.

Fixes: 3cd084519c6f ("media: amphion: add vpu v4l2 m2m support")
Cc: <stable@vger.kernel.org>
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: TaoJiang <tao.jiang_2@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: imx-jpeg: Set video drvdata before register video device
Ming Qian [Fri, 13 Sep 2024 06:21:44 +0000 (15:21 +0900)]
media: imx-jpeg: Set video drvdata before register video device

The video drvdata should be set before the video device is registered,
otherwise video_drvdata() may return NULL in the open() file ops, and led
to oops.

Fixes: 2db16c6ed72c ("media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder")
Cc: <stable@vger.kernel.org>
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: TaoJiang <tao.jiang_2@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agodt-bindings: media: ti,j721e-csi2rx-shim: Update maintainer email
Jai Luthra [Fri, 13 Sep 2024 05:45:01 +0000 (11:15 +0530)]
dt-bindings: media: ti,j721e-csi2rx-shim: Update maintainer email

I will no longer be an employee of TI, so update my email in maintainer
list.

Signed-off-by: Jai Luthra <j-luthra@ti.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agoMAINTAINERS: mailmap: update Jai Luthra's email address
Jai Luthra [Fri, 13 Sep 2024 05:45:00 +0000 (11:15 +0530)]
MAINTAINERS: mailmap: update Jai Luthra's email address

I will no longer be an employee of TI, so update my email in the
MAINTAINERS file and .mailmap.

Signed-off-by: Jai Luthra <j-luthra@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: mtk-jpeg: Fix null-ptr-deref during unload module
Guoqing Jiang [Thu, 12 Sep 2024 02:48:01 +0000 (10:48 +0800)]
media: mtk-jpeg: Fix null-ptr-deref during unload module

The workqueue should be destroyed in mtk_jpeg_core.c since commit
09aea13ecf6f ("media: mtk-jpeg: refactor some variables"), otherwise
the below calltrace can be easily triggered.

[  677.862514] Unable to handle kernel paging request at virtual address dfff800000000023
[  677.863633] KASAN: null-ptr-deref in range [0x0000000000000118-0x000000000000011f]
...
[  677.879654] CPU: 6 PID: 1071 Comm: modprobe Tainted: G           O       6.8.12-mtk+gfa1a78e5d24b+ #17
...
[  677.882838] pc : destroy_workqueue+0x3c/0x770
[  677.883413] lr : mtk_jpegdec_destroy_workqueue+0x70/0x88 [mtk_jpeg_dec_hw]
[  677.884314] sp : ffff80008ad974f0
[  677.884744] x29: ffff80008ad974f0 x28: ffff0000d7115580 x27: ffff0000dd691070
[  677.885669] x26: ffff0000dd691408 x25: ffff8000844af3e0 x24: ffff80008ad97690
[  677.886592] x23: ffff0000e051d400 x22: ffff0000dd691010 x21: dfff800000000000
[  677.887515] x20: 0000000000000000 x19: 0000000000000000 x18: ffff800085397ac0
[  677.888438] x17: 0000000000000000 x16: ffff8000801b87c8 x15: 1ffff000115b2e10
[  677.889361] x14: 00000000f1f1f1f1 x13: 0000000000000000 x12: ffff7000115b2e4d
[  677.890285] x11: 1ffff000115b2e4c x10: ffff7000115b2e4c x9 : ffff80000aa43e90
[  677.891208] x8 : 00008fffeea4d1b4 x7 : ffff80008ad97267 x6 : 0000000000000001
[  677.892131] x5 : ffff80008ad97260 x4 : ffff7000115b2e4d x3 : 0000000000000000
[  677.893054] x2 : 0000000000000023 x1 : dfff800000000000 x0 : 0000000000000118
[  677.893977] Call trace:
[  677.894297]  destroy_workqueue+0x3c/0x770
[  677.894826]  mtk_jpegdec_destroy_workqueue+0x70/0x88 [mtk_jpeg_dec_hw]
[  677.895677]  devm_action_release+0x50/0x90
[  677.896211]  release_nodes+0xe8/0x170
[  677.896688]  devres_release_all+0xf8/0x178
[  677.897219]  device_unbind_cleanup+0x24/0x170
[  677.897785]  device_release_driver_internal+0x35c/0x480
[  677.898461]  device_release_driver+0x20/0x38
...
[  677.912665] ---[ end trace 0000000000000000 ]---

Fixes: 09aea13ecf6f ("media: mtk-jpeg: refactor some variables")
Cc: <stable@vger.kernel.org>
Signed-off-by: Guoqing Jiang <guoqing.jiang@canonical.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: siano: remove redundant null pointer checks in cec_devnode_init()
Li Zetao [Tue, 10 Sep 2024 15:48:03 +0000 (23:48 +0800)]
media: siano: remove redundant null pointer checks in cec_devnode_init()

Since the debugfs_create_dir() never returns a null pointer, checking
the return value for a null pointer is redundant, Remove this check
since debugfs_create_file can handle IS_ERR pointers.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>