linux-block.git
8 months agomedia: atomisp: hmm_bo: Fix spelling errors in hmm_bo.h
Everest K.C. [Wed, 18 Sep 2024 08:21:11 +0000 (02:21 -0600)]
media: atomisp: hmm_bo: Fix spelling errors in hmm_bo.h

Fixed spelling errors reported by codespell in
drivers/staging/media/atomisp/include/hmm/hmm_bo.h
as follows:
        increse --> increase
decrese --> decrease

Signed-off-by: Everest K.C. <everestkc@everestkc.com.np>
Link: https://lore.kernel.org/r/20240918082203.4941-1-everestkc@everestkc.com.np
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: atomisp: mt9m114: Fix fmt->code not getting set on try_fmt
Hans de Goede [Sun, 13 Oct 2024 15:40:56 +0000 (17:40 +0200)]
media: atomisp: mt9m114: Fix fmt->code not getting set on try_fmt

Fix mt9m114_set_fmt() not setting format.format.code when called with
format.which == V4L2_SUBDEV_FORMAT_TRY.

This fixes atomisp failing to start streaming with the mt9m114 on
an Asus T100TA because of __media_pipeline_start() returning -EPIPE.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://lore.kernel.org/r/20241013154056.12532-5-hdegoede@redhat.com
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: atomisp: mt9m114: Add missing mutex_init() call
Hans de Goede [Sun, 13 Oct 2024 15:40:55 +0000 (17:40 +0200)]
media: atomisp: mt9m114: Add missing mutex_init() call

The input_lock was not being initialized, fix this.

Also switch to devm_kzalloc() for the main driver data struct, so that
devm_mutex_init() can be used for this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://lore.kernel.org/r/20241013154056.12532-4-hdegoede@redhat.com
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: atomisp: mt9m114: Disable V4L2_CID_3A_LOCK control
Hans de Goede [Sun, 13 Oct 2024 15:40:54 +0000 (17:40 +0200)]
media: atomisp: mt9m114: Disable V4L2_CID_3A_LOCK control

The V4L2_CID_3A_LOCK control is causing v4l2_ctrl_new_custom()
to fail with -ERANGE.

It would be better to fix this control but this entire driver is going to
be replaced with the drivers/media/i2c/mt9m114 standard v4l2 driver. This
quick fix gets things going for now until the driver is replaced.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://lore.kernel.org/r/20241013154056.12532-3-hdegoede@redhat.com
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: atomisp: Fix WARN_ON() in vb2_start_streaming() triggering
Hans de Goede [Sun, 13 Oct 2024 15:40:53 +0000 (17:40 +0200)]
media: atomisp: Fix WARN_ON() in vb2_start_streaming() triggering

If atomisp fails to start the stream the buffers must be returned to
the VB2_BUF_STATE_QUEUED state before returning an error from
atomisp_start_streaming().

This fixes the following WARN_ON():
[  250.313554] WARNING: CPU: 3 PID: 2178 at drivers/media/common/videobuf2/videobuf2-core.c:1801 vb2_start_streaming+0xcb/0x150 [videobuf2_common]

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://lore.kernel.org/r/20241013154056.12532-2-hdegoede@redhat.com
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: atomisp: Remove unused libmsrlisthelper
Hans de Goede [Mon, 16 Sep 2024 09:15:11 +0000 (11:15 +0200)]
media: atomisp: Remove unused libmsrlisthelper

Since commit 3a81c7660f80 ("media: staging: atomisp: Remove IMX sensor
support") the libmsrlisthelper code is no longer used, remove it.

Suggested-by: Dr. David Alan Gilbert <linux@treblig.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://lore.kernel.org/r/20240916091512.81859-1-hdegoede@redhat.com
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
8 months agomedia: venus: factor out inst destruction routine
Sergey Senozhatsky [Fri, 25 Oct 2024 16:56:43 +0000 (01:56 +0900)]
media: venus: factor out inst destruction routine

Factor out common instance destruction code into
a common function.

Suggested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: venus: sync with threaded IRQ during inst destruction
Sergey Senozhatsky [Fri, 25 Oct 2024 16:56:42 +0000 (01:56 +0900)]
media: venus: sync with threaded IRQ during inst destruction

When destroying an inst we should make sure that we don't race
against threaded IRQ (or pending IRQ), otherwise we can concurrently
kfree() inst context and inst itself.

BUG: KASAN: slab-use-after-free in vb2_queue_error+0x80/0x90
Call trace:
dump_backtrace+0x1c4/0x1f8
show_stack+0x38/0x60
dump_stack_lvl+0x168/0x1f0
print_report+0x170/0x4c8
kasan_report+0x94/0xd0
__asan_report_load2_noabort+0x20/0x30
vb2_queue_error+0x80/0x90
venus_helper_vb2_queue_error+0x54/0x78
venc_event_notify+0xec/0x158
hfi_event_notify+0x878/0xd20
hfi_process_msg_packet+0x27c/0x4e0
venus_isr_thread+0x258/0x6e8
hfi_isr_thread+0x70/0x90
venus_isr_thread+0x34/0x50
irq_thread_fn+0x88/0x130
irq_thread+0x160/0x2c0
kthread+0x294/0x328
ret_from_fork+0x10/0x20

Allocated by task 20291:
kasan_set_track+0x4c/0x80
kasan_save_alloc_info+0x28/0x38
__kasan_kmalloc+0x84/0xa0
kmalloc_trace+0x7c/0x98
v4l2_m2m_ctx_init+0x74/0x280
venc_open+0x444/0x6d0
v4l2_open+0x19c/0x2a0
chrdev_open+0x374/0x3f0
do_dentry_open+0x710/0x10a8
vfs_open+0x88/0xa8
path_openat+0x1e6c/0x2700
do_filp_open+0x1a4/0x2e0
do_sys_openat2+0xe8/0x508
do_sys_open+0x15c/0x1a0
__arm64_sys_openat+0xa8/0xc8
invoke_syscall+0xdc/0x270
el0_svc_common+0x1ec/0x250
do_el0_svc+0x54/0x70
el0_svc+0x50/0xe8
el0t_64_sync_handler+0x48/0x120
el0t_64_sync+0x1a8/0x1b0

Freed by task 20291:
 kasan_set_track+0x4c/0x80
 kasan_save_free_info+0x3c/0x60
 ____kasan_slab_free+0x124/0x1a0
 __kasan_slab_free+0x18/0x28
 __kmem_cache_free+0x134/0x300
 kfree+0xc8/0x1a8
 v4l2_m2m_ctx_release+0x44/0x60
 venc_close+0x78/0x130 [venus_enc]
 v4l2_release+0x20c/0x2f8
 __fput+0x328/0x7f0
 ____fput+0x2c/0x48
 task_work_run+0x1e0/0x280
 get_signal+0xfb8/0x1190
 do_notify_resume+0x34c/0x16a8
 el0_svc+0x9c/0xe8
 el0t_64_sync_handler+0x48/0x120
 el0t_64_sync+0x1a8/0x1b0

Rearrange inst destruction.  First remove the inst from the
core->instances list, second synchronize IRQ/IRQ-thread to
make sure that nothing else would see the inst while we take
it down.

Fixes: 7472c1c69138 ("[media] media: venus: vdec: add video decoder files")
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: venus: fix enc/dec destruction order
Sergey Senozhatsky [Fri, 25 Oct 2024 16:56:41 +0000 (01:56 +0900)]
media: venus: fix enc/dec destruction order

We destroy mutex-es too early as they are still taken in
v4l2_fh_exit()->v4l2_event_unsubscribe()->v4l2_ctrl_find().

We should destroy mutex-es right before kfree().  Also
do not vdec_ctrl_deinit() before v4l2_fh_exit().

Fixes: 7472c1c69138 ("[media] media: venus: vdec: add video decoder files")
Suggested-by: Tomasz Figa <tfiga@google.com>
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: venus: Enable h.264 hierarchical coding
Fritz Koenig [Tue, 22 Oct 2024 17:40:43 +0000 (10:40 -0700)]
media: venus: Enable h.264 hierarchical coding

HFI supports hierarchical P encoding and the ability to specify the
bitrate for the different layers.

Connect the controls that V4L2 provides and HFI supports.

Signed-off-by: Fritz Koenig <frkoenig@chromium.org>
Reviewed-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: venus: Helper function for dynamically updating bitrate
Fritz Koenig [Tue, 22 Oct 2024 17:40:42 +0000 (10:40 -0700)]
media: venus: Helper function for dynamically updating bitrate

Move the dynamic bitrate updating functionality to a separate function
so that it can be shared.

No functionality changes.

Signed-off-by: Fritz Koenig <frkoenig@chromium.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: i2c: dw9768: Use runtime PM autosuspend
Zhi Mao [Sat, 12 Oct 2024 03:25:53 +0000 (11:25 +0800)]
media: i2c: dw9768: Use runtime PM autosuspend

Use runtime PM autosuspend function to avoid rapid power state bouncing.

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@xs4all.nl>
8 months agomedia: i2c: ov5645: Switch to {enable,disable}_streams
Lad Prabhakar [Fri, 18 Oct 2024 15:32:27 +0000 (16:32 +0100)]
media: i2c: ov5645: Switch to {enable,disable}_streams

Switch from s_stream() to enable_streams() and disable_streams() pad
operations. They are preferred and required for streams support.

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: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: i2c: ov5645: Use subdev active state
Lad Prabhakar [Fri, 18 Oct 2024 15:32:26 +0000 (16:32 +0100)]
media: i2c: ov5645: Use subdev active state

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

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

Signed-off-by: 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: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: i2c: ov5645: Drop `power_lock` mutex
Lad Prabhakar [Fri, 18 Oct 2024 15:32:25 +0000 (16:32 +0100)]
media: i2c: ov5645: Drop `power_lock` mutex

Remove the `power_lock` mutex used during control applications, as it is
only utilized in the .s_ctrl() function. Since the control framework
already serializes calls to this function, the mutex is unnecessary.

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: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: i2c: ov5645: Use v4l2_async_register_subdev_sensor()
Lad Prabhakar [Fri, 18 Oct 2024 15:32:24 +0000 (16:32 +0100)]
media: i2c: ov5645: Use v4l2_async_register_subdev_sensor()

Utilize the v4l2_async_register_subdev_sensor() helper to register the
sub-device, as this facilitates parsing of firmware interfaces for remote
references.

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: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: i2c: ov5645: Replace dev_err with dev_err_probe in probe function
Lad Prabhakar [Fri, 18 Oct 2024 15:32:23 +0000 (16:32 +0100)]
media: i2c: ov5645: Replace dev_err with dev_err_probe in probe function

Refactor error handling in the ov5645_probe() function by replacing
multiple dev_err() calls with dev_err_probe().

- Note that during this process, the error string "external clock
  frequency %u is not supported" was replaced with "unsupported xclk
  frequency %u" to ensure it wraps at 80 columns.
- Additionally, the error string for control initialization failure was
  changed from "%s: control initialization error %d\n" to "failed to add
  controls\n" as there is no need to print the function name and error code
  in the string, since dev_err_probe() already provides this information.

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: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: i2c: ov5645: Use local `dev` pointer for subdev device assignment
Lad Prabhakar [Fri, 18 Oct 2024 15:32:22 +0000 (16:32 +0100)]
media: i2c: ov5645: Use local `dev` pointer for subdev device assignment

While assigning the subdev device pointer, use the local `dev` pointer
which is already extracted from the `i2c_client` pointer.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Tommaso Merciai <tomm.merciai@gmail.com>
Tested-by: Tommaso Merciai <tomm.merciai@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: ipu6: make the ipu6_mmu_unmap() as a void function
Bingbu Cao [Tue, 5 Nov 2024 02:45:08 +0000 (10:45 +0800)]
media: ipu6: make the ipu6_mmu_unmap() as a void function

The DMA unmap API is not supposed to return value. Thus this patch
changes the ipu6_mmu_unmap() as a void function and DMA unmapping
didn't check the return value.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
[Sakari Ailus: Drop unnecessary returns.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: ipu6: optimize the IPU6 MMU unmapping flow
Bingbu Cao [Tue, 5 Nov 2024 02:45:07 +0000 (10:45 +0800)]
media: ipu6: optimize the IPU6 MMU unmapping flow

The MMU mapping flow is optimized for improve the performance, the
unmapping flow could also be optimized to follow same flow.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: ipu6: optimize the IPU6 MMU mapping flow
Bingbu Cao [Tue, 5 Nov 2024 02:45:06 +0000 (10:45 +0800)]
media: ipu6: optimize the IPU6 MMU mapping flow

ipu6_mmu_map() operated on a per-page basis, it leads frequent
spin_lock/unlock() and clflush_cache_range() for each page, it
will cause inefficiencies especially when handling dma-bufs
with large number of pages. However, the pages are likely concentrated
pages by IOMMU DMA driver, IPU MMU driver can map the concentrated
pages into less entries in l1 table.

This change enhances ipu6_mmu_map() with batching process multiple
contiguous pages. It significantly reduces calls for spin_lock/unlock
and clflush_cache_range() and improve the performance.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Jianhui Dai <jianhui.j.dai@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: ipu6: move the l2_unmap() up before l2_map()
Bingbu Cao [Tue, 5 Nov 2024 02:45:05 +0000 (10:45 +0800)]
media: ipu6: move the l2_unmap() up before l2_map()

l2_map() and l2_unmap() are better to be grouped together.
l2_unmap() will soon be called from l2_map() for mapping
optimization.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Jianhui Dai <jianhui.j.dai@intel.com>
[Sakari Ailus: Rebase on debug print fixes on 32-bit.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: mc: Rename pad as origin in __media_pipeline_start()
Sakari Ailus [Sat, 19 Oct 2024 17:23:12 +0000 (20:23 +0300)]
media: mc: Rename pad as origin in __media_pipeline_start()

Rename the pad field in __media_pipeline_start() to both better describe
what it is and avoid masking it during the loop.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: intel/ipu6: remove buttress ish structure
Stanislaw Gruszka [Tue, 5 Nov 2024 07:27:50 +0000 (08:27 +0100)]
media: intel/ipu6: remove buttress ish structure

The buttress ipc ish structure is not effectively used on IPU6 - data
is nullified on init. Remove the ish structure and handing of related
interrupts to cleanup the code.

Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: raspberrypi: cfe: Fix mapping of dmabuf buffers
Tomi Valkeinen [Mon, 4 Nov 2024 07:47:54 +0000 (09:47 +0200)]
media: raspberrypi: cfe: Fix mapping of dmabuf buffers

When using buffers from DRM, DMA-API gives a warning about: "mapping sg
segment longer than device claims to support [len=307200] [max=65536]"

Add a call to vb2_dma_contig_set_max_seg_size() to tell the DMA-API
about the supported segment size (which is UINT_MAX).

Fixes: 6edb685abb2a ("media: raspberrypi: Add support for RP1-CFE")
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: intel/ipu6: do not handle interrupts when device is disabled
Stanislaw Gruszka [Thu, 31 Oct 2024 10:23:21 +0000 (11:23 +0100)]
media: intel/ipu6: do not handle interrupts when device is disabled

Some IPU6 devices have shared interrupts. We need to handle properly
case when interrupt is triggered from other device on shared irq line
and IPU6 itself disabled. In such case we get 0xffffffff from
ISR_STATUS register and handle all irq's cases, for what we are not
not prepared and usually hang the whole system.

To avoid the issue use pm_runtime_get_if_active() to check if
the device is enabled and prevent suspending it when we handle irq
until the end of irq. Additionally use synchronize_irq() in suspend

Fixes: ab29a2478e70 ("media: intel/ipu6: add IPU6 buttress interface driver")
Cc: stable@vger.kernel.org
Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Hans de Goede <hdegoede@redhat.com> # ThinkPad X1 Yoga Gen 8, ov2740
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: i2c: st-mipid02: remove parallel mbus format on sink pad
Alain Volmat [Tue, 8 Oct 2024 11:46:08 +0000 (13:46 +0200)]
media: i2c: st-mipid02: remove parallel mbus format on sink pad

2X.. mbus formats are related to parallel interface and
as such should not be acceptable on the sink pad of the bridge.
Only keep their csi counterpart in 1X..

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@xs4all.nl>
8 months agomedia: i2c: st-mipid02: add pm_runtime handling
Alain Volmat [Tue, 8 Oct 2024 11:46:07 +0000 (13:46 +0200)]
media: i2c: st-mipid02: add pm_runtime handling

Add handling of pm_runtime in order to control the supplies
and clocks of the bridge.

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@xs4all.nl>
8 months agomedia: i2c: st-mipid02: use enable/disable_streams pad ops
Alain Volmat [Tue, 8 Oct 2024 11:46:06 +0000 (13:46 +0200)]
media: i2c: st-mipid02: use enable/disable_streams pad ops

Add pad enable_streams and disable_streams ops in addition to
v4l2_subdev_s_stream_helper. Moreover, use functions
v4l2_subdev_enable_streams and v4l2_subdev_disable_streams to
control the source subdev.

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@xs4all.nl>
8 months agomedia: i2c: st-mipid02: fix mipid02_stream_enable error handling
Alain Volmat [Tue, 8 Oct 2024 11:46:05 +0000 (13:46 +0200)]
media: i2c: st-mipid02: fix mipid02_stream_enable error handling

Following addition of cascaded s_stream call within
mipid02_stream_enable and mipid02_stream_disable,
the mipid02_stream_enable error handling must be fixed to simply
disable the clocks & data lanes without also calling
again the s_stream of the source subdev.

Moreover, main control registers are reset to 0 for all cases
of error within the mipid02_stream_enable even if they haven't yet
been written. Correct this behavior by simply returning an
error when register clear are not necessary.

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@xs4all.nl>
8 months agomedia: i2c: gc2145: introduce enable/disable_streams ops
Alain Volmat [Mon, 30 Sep 2024 06:51:38 +0000 (08:51 +0200)]
media: i2c: gc2145: introduce enable/disable_streams ops

Introduce enable_streams and disable_streams pad ops and
replace s_stream with the v4l2_subdev_s_stream_helper
function.

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@xs4all.nl>
8 months agomedia: mt9p031: Refactor format handling for different sensor models
Tarang Raval [Tue, 29 Oct 2024 06:29:16 +0000 (11:59 +0530)]
media: mt9p031: Refactor format handling for different sensor models

Add new structure 'mt9p031_model_info' to encapsulate format codes for
the mt9p031 camera sensor family. This approach enhances code clarity
and maintainability.

Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: ov08x40: Add OF probe support
Bryan O'Donoghue [Thu, 10 Oct 2024 12:33:20 +0000 (13:33 +0100)]
media: ov08x40: Add OF probe support

The ACPI version of this driver "just works" on dts based systems with a
few extensions to facilitate.

- Add support for DT based probing
- Add support for taking the part out of reset via a GPIO reset pin
- Add in regulator bulk on/off logic for the power rails.

Once done this sensor works nicely on a Qualcomm X1E80100 CRD.

Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # x1e80100-crd
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: ov08x40: Rename ext_clk to xvclk
Bryan O'Donoghue [Thu, 10 Oct 2024 12:33:19 +0000 (13:33 +0100)]
media: ov08x40: Rename ext_clk to xvclk

The data-sheet and documentation for this part uses the name xvclk not
ext_clk for the input reference clock. Rename the variables and defines in
this driver to align with the data-sheet name.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: dt-bindings: Add OmniVision OV08X40
Bryan O'Donoghue [Thu, 10 Oct 2024 12:33:18 +0000 (13:33 +0100)]
media: dt-bindings: Add OmniVision OV08X40

Add bindings for the already upstream OV08X40 to enable usage of this
sensor on DTS based systems.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
[Sakari Ailus: Add the file to MAINTAINERS.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: ov08x40: Fix burst write sequence
Bryan O'Donoghue [Thu, 10 Oct 2024 12:33:17 +0000 (13:33 +0100)]
media: ov08x40: Fix burst write sequence

It is necessary to account for I2C quirks in the burst mode path of this
driver. Not all I2C controllers can accept arbitrarily long writes and this
is represented in the quirks field of the adapter structure.

Prior to this patch the following error message is seen on a Qualcomm
X1E80100 CRD.

[   38.773524] i2c i2c-2: adapter quirk: msg too long (addr 0x0036, size 290, write)
[   38.781454] ov08x40 2-0036: Failed regs transferred: -95
[   38.787076] ov08x40 2-0036: ov08x40_start_streaming failed to set regs

Fix the error by breaking up the write sequence into the advertised maximum
write size of the quirks field if the quirks field is populated.

Fixes: 8f667d202384 ("media: ov08x40: Reduce start streaming time")
Cc: stable@vger.kernel.org # v6.9+
Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # x1e80100-crd
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: gspca: ov534-ov772x: Fix off-by-one error in set_frame_rate()
Jinjie Ruan [Mon, 28 Oct 2024 08:02:56 +0000 (16:02 +0800)]
media: gspca: ov534-ov772x: Fix off-by-one error in set_frame_rate()

In set_frame_rate(), select a rate in rate_0 or rate_1 by checking
sd->frame_rate >= r->fps in a loop, but the loop condition terminates when
the index reaches zero, which fails to check the last elememt in rate_0 or
rate_1.

Check for >= 0 so that the last one in rate_0 or rate_1 is also checked.

Fixes: 189d92af707e ("V4L/DVB (13422): gspca - ov534: ov772x changes from Richard Kaswy.")
Cc: stable@vger.kernel.org
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: venus: Fix pm_runtime_set_suspended() with runtime pm enabled
Jinjie Ruan [Fri, 1 Nov 2024 09:40:50 +0000 (17:40 +0800)]
media: venus: Fix pm_runtime_set_suspended() with runtime pm enabled

It is not valid to call pm_runtime_set_suspended() for devices
with runtime PM enabled because it returns -EAGAIN if it is enabled
already and working. So, call pm_runtime_disable() before to fix it.

Cc: stable@vger.kernel.org
Fixes: af2c3834c8ca ("[media] media: venus: adding core part and helper functions")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Acked-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: amphion: Fix pm_runtime_set_suspended() with runtime pm enabled
Jinjie Ruan [Fri, 1 Nov 2024 09:40:49 +0000 (17:40 +0800)]
media: amphion: Fix pm_runtime_set_suspended() with runtime pm enabled

It is not valid to call pm_runtime_set_suspended() for devices
with runtime PM enabled because it returns -EAGAIN if it is enabled
already and working. So, call pm_runtime_disable() before to fix it.

Cc: stable@vger.kernel.org
Fixes: b50a64fc54af ("media: amphion: add amphion vpu device driver")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: i2c: dw9768: Fix pm_runtime_set_suspended() with runtime pm enabled
Jinjie Ruan [Fri, 1 Nov 2024 09:40:48 +0000 (17:40 +0800)]
media: i2c: dw9768: Fix pm_runtime_set_suspended() with runtime pm enabled

It is not valid to call pm_runtime_set_suspended() and
pm_runtime_set_active() for devices with runtime PM enabled because it
returns -EAGAIN if it is enabled already and working. So, adjust the
order to fix it.

Cc: stable@vger.kernel.org
Fixes: 5f9a089b6de3 ("dw9768: Enable low-power probe on ACPI")
Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: i2c: imx415: Drop HAS_EVENTS flag
Tommaso Merciai [Tue, 29 Oct 2024 22:56:31 +0000 (23:56 +0100)]
media: i2c: imx415: Drop HAS_EVENTS flag

v4l2_subdev_init_finalize() already sets the HAS_EVENTS flag if a
control handler is set. Let's drop the HAS_EVENTS flag.

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Tommaso Merciai <tomm.merciai@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Michael Riesch <michael.riesch@wolfvision.net>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: i2c: Drop HAS_EVENTS and event handlers
Tommaso Merciai [Tue, 29 Oct 2024 22:56:30 +0000 (23:56 +0100)]
media: i2c: Drop HAS_EVENTS and event handlers

v4l2_subdev_init_finalize() already sets the HAS_EVENTS flag if a
control handler is set, and subdev_do_ioctl() uses
v4l2_ctrl_subdev_subscribe_event() and v4l2_event_subdev_unsubscribe()
as defaults if the subdev doesn't have .(un)subscribe.
Let's drop the HAS_EVENTS flag and event handlers.

Signed-off-by: Tommaso Merciai <tomm.merciai@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: dt-bindings: Remove assigned-clock-* from various schema
Bryan O'Donoghue [Tue, 29 Oct 2024 13:44:45 +0000 (13:44 +0000)]
media: dt-bindings: Remove assigned-clock-* from various schema

Remove extraneous assigned-clock* from media/i2c/* schemas.

assigned-clock and assigned-clock-parent assume that there is a clock that
can be assigned and/or a clock parent that similarly can be assigned by
firmware which may not always be the case.

The sensor properties themselves should not mandate assigned-clock* as a
result.

Link: https://lore.kernel.org/linux-media/j7kgz2lyxnler5qwd7yiazdq6fmsv77kyozdrxf33h54ydakjz@uqjhwhoyv6re
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: i2c: mt9p031: Switch from OF to fwnode API
Laurent Pinchart [Mon, 28 Oct 2024 20:44:43 +0000 (22:44 +0200)]
media: i2c: mt9p031: Switch from OF to fwnode API

Remove the direct dependency on OF by using the fwnode API. This makes
the driver usable on non-OF systems, such as ACPI-based platforms.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: i2c: mt9p031: Drop I2C device ID table
Laurent Pinchart [Mon, 28 Oct 2024 20:44:42 +0000 (22:44 +0200)]
media: i2c: mt9p031: Drop I2C device ID table

The mt9p031 driver doesn't support platform data anymore, and requires
the I2C device to be instantiated through a method that supports device
properties. As the driver lacks an ACPI device ID table, the device
matching will always go through the OF device ID table, either for OF
devices, or for ACPI devices using PRP0001. The I2C device ID table is
therefore not needed. Drop it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tarang Raval <tarang.raval@siliconsignals.io>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: i2c: mt9p031: Drop support for legacy platform data
Laurent Pinchart [Mon, 28 Oct 2024 20:44:41 +0000 (22:44 +0200)]
media: i2c: mt9p031: Drop support for legacy platform data

No user of the mt9p031_platform_data legacy platform data for board
files exist in the kernel anymore. Drop support from the driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tarang Raval <tarang.raval@siliconsignals.io>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: raspberrypi: Do some cleanup in probe()
Dan Carpenter [Wed, 23 Oct 2024 08:30:55 +0000 (11:30 +0300)]
media: raspberrypi: Do some cleanup in probe()

If devm_clk_get() fails then we need to free "cfe" before returning.

Fixes: 6edb685abb2a ("media: raspberrypi: Add support for RP1-CFE")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: v4l2-subdev: Refactor events
Tommaso Merciai [Sun, 20 Oct 2024 16:35:32 +0000 (18:35 +0200)]
media: v4l2-subdev: Refactor events

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. If a control handler is set for
the subdev then set the HAS_EVENTS flag automatically into
v4l2_subdev_init_finalize() and use v4l2_ctrl_subdev_subscribe_event() and
v4l2_event_subdev_unsubscribe() as default if subdev don't have
.(un)subscribe control operations. This simplifies subdev drivers by
avoiding the need to set the V4L2_SUBDEV_FL_HAS_EVENTS flag and plug the
event handlers, and ensures consistency of the API exposed to userspace.

Signed-off-by: Tommaso Merciai <tomm.merciai@gmail.com>
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: raspberrypi: Remove redundant "no IRQ" message
Ricardo Ribalda [Fri, 18 Oct 2024 14:24:59 +0000 (14:24 +0000)]
media: raspberrypi: Remove redundant "no IRQ" message

platform_get_irq() already provides a error message.

This fixes the following cocci error:
drivers/media/platform/raspberrypi/rp1-cfe/cfe.c:2326:2-9: line 2326 is redundant because platform_get_irq() already prints an error

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: ipu6: use PFN_UP() and sg_virt() for code simplicity
Bingbu Cao [Wed, 16 Oct 2024 07:53:05 +0000 (15:53 +0800)]
media: ipu6: use PFN_UP() and sg_virt() for code simplicity

Use PFN_UP() and sg_virt() can be used to simplify the code.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: Documentation: ipu6: remove the dma_ops part from the doc
Bingbu Cao [Wed, 16 Oct 2024 07:53:04 +0000 (15:53 +0800)]
media: Documentation: ipu6: remove the dma_ops part from the doc

dma_ops override is not in code anymore, so remove it.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: ipu6: remove architecture DMA ops dependency in Kconfig
Bingbu Cao [Wed, 16 Oct 2024 07:53:03 +0000 (15:53 +0800)]
media: ipu6: remove architecture DMA ops dependency in Kconfig

IPU6 driver doesn't override the dma_ops of device now, it doesn't
depends on the ARCH_HAS_DMA_OPS, so remove the dependency in Kconfig.

Fixes: de6c85bf918e ("dma-mapping: clearly mark DMA ops as an architecture feature")
Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: ipu6: use the IPU6 DMA mapping APIs to do mapping
Bingbu Cao [Wed, 16 Oct 2024 07:53:02 +0000 (15:53 +0800)]
media: ipu6: use the IPU6 DMA mapping APIs to do mapping

dma_ops is removed from the IPU6 auxiliary device, ISYS driver
should use the IPU6 DMA mapping APIs directly instead of depending
on the device callbacks.

ISYS driver switch from the videobuf2 DMA contig memory allocator to
scatter/gather memory allocator.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
[Sakari Ailus: Rebased on recent videobuf2 wait changes.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: ipu6: not override the dma_ops of device in driver
Bingbu Cao [Wed, 16 Oct 2024 07:53:01 +0000 (15:53 +0800)]
media: ipu6: not override the dma_ops of device in driver

DMA ops are a helper for architectures and not for drivers to override the
DMA implementation. Driver should not override the DMA implementation.

This patch removes the dma_ops override from auxiliary device and adds
driver-internal helpers that use the actual DMA mapping APIs.

Fixes: 9163d83573e4 ("media: intel/ipu6: add IPU6 DMA mapping API and MMU table")
Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
[Sakari Ailus: Fix the commit message a little.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: ipu6: Fix DMA and physical address debugging messages for 32-bit
Sakari Ailus [Mon, 4 Nov 2024 11:31:32 +0000 (13:31 +0200)]
media: ipu6: Fix DMA and physical address debugging messages for 32-bit

Fix printing DMA and physical address printing on 32-bit platforms, by
using correct types. Also cast DMA_BIT_MASK() result to dma_addr_t to make
Clang happy.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: ov2740: Don't log ov2740_check_hwcfg() errors twice
Hans de Goede [Sat, 12 Oct 2024 16:08:03 +0000 (18:08 +0200)]
media: ov2740: Don't log ov2740_check_hwcfg() errors twice

All ov2740_check_hwcfg() error-exit paths already log a detailed reason,
logging a second generic "failed to check HW configuration" error is
not useful, drop this.

The one exception is the -EPROBE_DEFER exit on
fwnode_graph_get_next_endpoint() returning NULL.

Call dev_err_probe() there to register the reason for deferring the probe,
this is used if the endpoint is still not there after 30 seconds, e.g. :

 i2c-INT3474:00: deferred probe pending: waiting for fwnode graph endpoint

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: ati_remote: don't push static constants on stack for %*ph
Andy Shevchenko [Thu, 17 Oct 2024 09:36:06 +0000 (12:36 +0300)]
media: ati_remote: don't push static constants on stack for %*ph

There is no need to pass constants via stack. The width may be explicitly
specified in the format.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: mantis: remove orphan mantis_core.h
Bjørn Mork [Thu, 24 Oct 2024 18:43:13 +0000 (20:43 +0200)]
media: mantis: remove orphan mantis_core.h

This file has been an orphan ever since commit b3b961448f70
("V4L/DVB (13795): [Mantis/Hopper] Code overhaul, add Hopper
devices into the PCI ID list"), having no references except
for the orphan removed by commit 519648bed470 ("media: mantis:
remove orphan mantis_core.c")

Fixes: b3b961448f70 ("V4L/DVB (13795): [Mantis/Hopper] Code overhaul, add Hopper devices into the PCI ID list")
Link: https://patchwork.linuxtv.org/project/linux-media/patch/1277054487-14384-1-git-send-email-bjorn@mork.no/
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: vb2: fix confusing log message
Hans Verkuil [Thu, 24 Oct 2024 11:24:35 +0000 (13:24 +0200)]
media: vb2: fix confusing log message

If the number of allocated buffers is less than q->min_queued_buffers,
then a debug message was logged saying that it needs at least that
many queued buffers. But the test is about allocated buffers.

Update the message to say "allocated buffers".

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Acked-by: Tomasz Figa <tfiga@chromium.org>
8 months agomedia: vb2: Fix comment
Ricardo Ribalda [Tue, 22 Oct 2024 07:56:26 +0000 (07:56 +0000)]
media: vb2: Fix comment

If V4L2_TYPE_IS_OUTPUT() the information has been initially provided by
the user, not by the driver.

Fixes: e23ccc0ad925 ("[media] v4l: add videobuf2 Video for Linux 2 driver framework")
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Acked-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: raspberrypi: rp1-cfe: Fix spelling mistake "Orphanded" -> "Orphaned"
Colin Ian King [Mon, 21 Oct 2024 08:22:07 +0000 (09:22 +0100)]
media: raspberrypi: rp1-cfe: Fix spelling mistake "Orphanded" -> "Orphaned"

There is a spelling mistake in a WARN message. Fix it.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: v4l2-core: constify the class struct
Bartosz Golaszewski [Fri, 18 Oct 2024 13:13:51 +0000 (15:13 +0200)]
media: v4l2-core: constify the class struct

All functions that take the class address as argument expect a const
pointer so we can make the video class constant.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: v4l2-core: v4l2-dv-timings: check cvt/gtf result
Hans Verkuil [Mon, 14 Oct 2024 14:52:41 +0000 (16:52 +0200)]
media: v4l2-core: v4l2-dv-timings: check cvt/gtf result

The v4l2_detect_cvt/gtf functions should check the result against the
timing capabilities: these functions calculate the timings, so if they
are out of bounds, they should be rejected.

To do this, add the struct v4l2_dv_timings_cap as argument to those
functions.

This required updates to the adv7604 and adv7842 drivers since the
prototype of these functions has now changed. The timings struct
that is passed to v4l2_detect_cvt/gtf in those two drivers is filled
with the timings detected by the hardware.

The vivid driver was also updated, but an additional check was added:
the width and height specified by VIDIOC_S_DV_TIMINGS has to match the
calculated result, otherwise something went wrong. Note that vivid
*emulates* hardware, so all the values passed to the v4l2_detect_cvt/gtf
functions came from the timings struct that was filled by userspace
and passed on to the driver via VIDIOC_S_DV_TIMINGS. So these fields
can contain random data. Both the constraints check via
struct v4l2_dv_timings_cap and the additional width/height check
ensure that the resulting timings are sane and not messed up by the
v4l2_detect_cvt/gtf calculations.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Fixes: 2576415846bc ("[media] v4l2: move dv-timings related code to v4l2-dv-timings.c")
Cc: stable@vger.kernel.org
Reported-by: syzbot+a828133770f62293563e@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-media/000000000000013050062127830a@google.com/

8 months agomedia: cx231xx: Remove some deadcode
Dr. David Alan Gilbert [Sat, 12 Oct 2024 23:39:48 +0000 (00:39 +0100)]
media: cx231xx: Remove some deadcode

cx231xx_bcount and cx231xx_power_suspend() were added by the original
commit e0d3bafd0258 ("V4L/DVB (10954): Add cx231xx USB driver")
but remained unused.

cx231xx_dump_HH_reg() was added by
commit 64fbf4445526 ("[media] cx231xx: Added support for Carraera, Shelby,
RDx_253S and VIDEO_GRABBER")
but remained unused.

Remove them.

Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
8 months agomedia: samples: v4l2-pci-skeleton.c: drop vb2_ops_wait_prepare/finish
Hans Verkuil [Mon, 14 Oct 2024 15:06:37 +0000 (17:06 +0200)]
media: samples: v4l2-pci-skeleton.c: 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>
8 months agostaging: media: drop vb2_ops_wait_prepare/finish
Hans Verkuil [Mon, 14 Oct 2024 15:06:36 +0000 (17:06 +0200)]
staging: media: 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: Neil Armstrong <neil.armstrong@linaro.org> # for meson/vdec
Tested-by: Luca Ceresoli <luca.ceresoli@bootlin.com> # drivers/staging/media/tegra-video/vi.c
8 months agomedia: common: saa7146: drop vb2_ops_wait_prepare/finish
Hans Verkuil [Mon, 14 Oct 2024 15:06:35 +0000 (17:06 +0200)]
media: common: saa7146: 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>
8 months agomedia: platform: drop vb2_ops_wait_prepare/finish
Hans Verkuil [Mon, 14 Oct 2024 15:06:34 +0000 (17:06 +0200)]
media: platform: 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: Neil Armstrong <neil.armstrong@linaro.org> # for meson-ge2d
Acked-by: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
9 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>