platform/kernel/linux-rpi.git
10 months agomedia: i2c: ds90ub9x3: Fix sub-device matching
Tomi Valkeinen [Mon, 31 Jul 2023 13:24:35 +0000 (16:24 +0300)]
media: i2c: ds90ub9x3: Fix sub-device matching

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

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

This resolves this smatch error:

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

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

This resolves a new smatch warning;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Example DTS should not have 'status' property.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Use VPU version comparison in both of these cases instead.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Kick off initialization only after the interrupts are unmasked.

Cc: stable@vger.kernel.org # v4.12+
Fixes: d96d3f30c0f2 ("[media] media: venus: hfi: add Venus HFI files")
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: venus: hfi_venus: Only consider sys_idle_indicator on V1
Konrad Dybcio [Tue, 30 May 2023 12:30:35 +0000 (14:30 +0200)]
media: venus: hfi_venus: Only consider sys_idle_indicator on V1

As per information from Qualcomm [1], this property is not really
supported beyond msm8916 (HFI V1) and some newer HFI versions really
dislike receiving it, going as far as crashing the device.

Only consider toggling it (via the module option) on HFIV1.
While at it, get rid of the global static variable (which defaulted
to zero) which was never explicitly assigned to for V1.

Note: [1] is a reply to the actual message in question, as lore did not
properly receive some of the emails..

[1] https://lore.kernel.org/lkml/955cd520-3881-0c22-d818-13fe9a47e124@linaro.org/
Fixes: 7ed9e0b3393c ("media: venus: hfi, vdec: v6 Add IS_V6() to existing IS_V4() if locations")
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: mediatek: vcodec: Fix possible invalid memory access for encoder
Yunfei Dong [Wed, 2 Aug 2023 14:53:02 +0000 (22:53 +0800)]
media: mediatek: vcodec: Fix possible invalid memory access for encoder

The vpu maybe null pointer or unreasonable value when scp crash, need to
validate that the vpu pointer and the vpu instance within this context is
valid in case of leading to kernel reboot.

Fixes: 27a274db6b4c ("[media] vcodec: mediatek: Add Mediatek VP8 Video Encoder Driver")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reported-by: Steve Cho <stevecho@google.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: mediatek: vcodec: Fix possible invalid memory access for decoder
Yunfei Dong [Wed, 2 Aug 2023 14:53:01 +0000 (22:53 +0800)]
media: mediatek: vcodec: Fix possible invalid memory access for decoder

The vpu maybe null pointer or unreasonable value when scp crash, need to
validate that the vpu pointer and the vpu instance within this context is
valid in case of leading to kernel reboot.

Fixes: 590577a4e525 ("[media] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reported-by: Steve Cho <stevecho@google.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: mediatek: vcodec: Add driver to support 10bit
Mingjia Zhang [Sat, 29 Jul 2023 03:41:12 +0000 (11:41 +0800)]
media: mediatek: vcodec: Add driver to support 10bit

Adding to support capture formats V4L2_PIX_FMT_MT2110T and
V4L2_PIX_FMT_MT2110R for 10bit playback. Need to get the size
of each plane again when user space setting syntax to get 10bit
information.

V4L2_PIX_FMT_MT2110T for AV1/VP9/HEVC.
V4L2_PIX_FMT_MT2110R for H264.

Signed-off-by: Mingjia Zhang <mingjia.zhang@mediatek.com>
Co-developed-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: mediatek: vcodec: Add capture format to support 10bit raster mode
Mingjia Zhang [Sat, 29 Jul 2023 03:41:11 +0000 (11:41 +0800)]
media: mediatek: vcodec: Add capture format to support 10bit raster mode

Define one uncompressed capture format V4L2_PIX_FMT_MT2110R in order to
support 10bit for H264 in mt8195.

Signed-off-by: Mingjia Zhang <mingjia.zhang@mediatek.com>
Co-developed-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: mediatek: vcodec: Add capture format to support 10bit tile mode
Mingjia Zhang [Sat, 29 Jul 2023 03:41:10 +0000 (11:41 +0800)]
media: mediatek: vcodec: Add capture format to support 10bit tile mode

Define one uncompressed capture format V4L2_PIX_FMT_MT2110T in order to
support 10bit for AV1/VP9/HEVC in mt8195.

Signed-off-by: Mingjia Zhang <mingjia.zhang@mediatek.com>
Co-developed-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: mediatek: vcodec: separate decoder and encoder
Yunfei Dong [Sat, 29 Jul 2023 02:55:14 +0000 (10:55 +0800)]
media: mediatek: vcodec: separate decoder and encoder

Move all decoder files to folder decoder.
Move all encoder files to folder encoder.
Move common files which shared for encoder and decoder to folder common.

Change include header files and Makefile to fix build error.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: mediatek: vcodec: remove unused include header
Yunfei Dong [Sat, 29 Jul 2023 02:55:13 +0000 (10:55 +0800)]
media: mediatek: vcodec: remove unused include header

remove unused include header for .c files

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: mediatek: vcodec: fix unreasonable parameter definition and style
Yunfei Dong [Sat, 29 Jul 2023 02:55:12 +0000 (10:55 +0800)]
media: mediatek: vcodec: fix unreasonable parameter definition and style

Fix unreasonable coding style.
Fix unreasonable parameter definition.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: mediatek: vcodec: separate struct mtk_vcodec_dev
Yunfei Dong [Sat, 29 Jul 2023 02:55:11 +0000 (10:55 +0800)]
media: mediatek: vcodec: separate struct mtk_vcodec_dev

Adding different dev struct for encoder and decoder, remove
'struct mtk_vcodec_dev'.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: mediatek: vcodec: separate struct 'mtk_vcodec_ctx'
Yunfei Dong [Sat, 29 Jul 2023 02:55:10 +0000 (10:55 +0800)]
media: mediatek: vcodec: separate struct 'mtk_vcodec_ctx'

Adding different context struct for encoder and decoder and removing
struct 'mtk_vcodec_ctx'.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: mediatek: vcodec: replace pr_* with dev_* for v4l2 debug message
Yunfei Dong [Sat, 29 Jul 2023 02:55:09 +0000 (10:55 +0800)]
media: mediatek: vcodec: replace pr_* with dev_* for v4l2 debug message

Adding different macro mtk_v4l2_vdec_dbg and mtk_v4l2_venc_dbg for
encoder and decoder. Then calling the common macro mtk_v4l2_debug to
print debug message.

Replace pr_err with dev_err for 'mtk_v4l2_err' debug message.
Replace pr_debug with dev_dbg for 'mtk_v4l2_debug' debug message.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: mediatek: vcodec: remove the dependency of vcodec debug log
Yunfei Dong [Sat, 29 Jul 2023 02:55:08 +0000 (10:55 +0800)]
media: mediatek: vcodec: remove the dependency of vcodec debug log

'mtk_vcodec_debug' and 'mtk_vcodec_err' depends on 'mtk_vcodec_ctx'
to get the index of each instance. Define two different macro
mtk_vdec_debug and mtk_venc_debug for decoder and encoder, and re-write
macro mtk_vcodec_debug as the common interface which is called
by mtk_vdec_debug and mtk_venc_debug. The vcodec debug log can be
separeated by encoder and decoder.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: mediatek: vcodec: Removing useless debug log
Yunfei Dong [Sat, 29 Jul 2023 02:55:07 +0000 (10:55 +0800)]
media: mediatek: vcodec: Removing useless debug log

Removing unresonable and useless debug log enter and leave
in order to simply the log message.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: mediatek: vcodec: Removing struct 'mtk_vcodec_ctx/dev' for shared interface
Yunfei Dong [Sat, 29 Jul 2023 02:55:06 +0000 (10:55 +0800)]
media: mediatek: vcodec: Removing struct 'mtk_vcodec_ctx/dev' for shared interface

The shared struct 'mtk_vcodec_ctx/dev' will be changed to
'mtk_vcodec_enc_ctx/dev' and 'mtk_vcodec_dec_ctx/dev' in order to separate
encoder and decoder. Removing common struct 'mtk_vcodec_ctx/dev' for shared
interface which encoder and decoder used at the same time. Then encoder and
decoder can call the same interface independently.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: mediatek: vcodec: align fw interface
Yunfei Dong [Sat, 29 Jul 2023 02:55:05 +0000 (10:55 +0800)]
media: mediatek: vcodec: align fw interface

Align scp and vpu firmware interface, remove the depedency for
'struct mtk_vcodec_dev' and 'struct mtk_vcodec_ctx'. It will be
much easier to separate video encoder and decoder.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: mediatek: vcodec: remove unused parameter
Yunfei Dong [Sat, 29 Jul 2023 02:55:04 +0000 (10:55 +0800)]
media: mediatek: vcodec: remove unused parameter

remove unused parameter in struct mtk_vcodec_dev.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: pci: ipu3-cio2: Initialise timing struct to avoid a compiler warning
Sakari Ailus [Tue, 1 Aug 2023 07:14:30 +0000 (10:14 +0300)]
media: pci: ipu3-cio2: Initialise timing struct to avoid a compiler warning

Initialise timing struct in cio2_hw_init() to zero in order to avoid a
compiler warning. The warning was a false positive.

Reported-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: ccs-pll: Initialise best_div to avoid a compiler warning
Sakari Ailus [Tue, 1 Aug 2023 07:14:29 +0000 (10:14 +0300)]
media: ccs-pll: Initialise best_div to avoid a compiler warning

Initialise best_div local variable to avoid a compiler warning. The
warning was harmless though.

Reported-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: atomisp: Fix me->stages error checking in sh_css_sp_init_pipeline()
Hans de Goede [Sun, 30 Jul 2023 15:33:43 +0000 (17:33 +0200)]
media: atomisp: Fix me->stages error checking in sh_css_sp_init_pipeline()

The current error-checking of me->stages in sh_css_sp_init_pipeline()
has some issues / weirdness:

1. It is checked at the top of the function, but only using the atomisp
   custom assert() macro which e.g. smatch does not recognize

2. It is first dereferenced in "first_binary = me->stages->binary", but
   outside of the assert it is checked much later, triggering the following
   smatch warning:

drivers/staging/media/atomisp/pci/sh_css_sp.c:1255 sh_css_sp_init_pipeline()
warn: variable dereferenced before check 'me->stages' (see line 1224)

Drop the custom assert() calls (note 'me' is never NULL) and instead add
a regular check for me->stages not being set.

Reported-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Closes: https://lore.kernel.org/linux-media/7c8fc5b4-280e-844e-cdf5-b6ec2a1616aa@xs4all.nl/
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: atomisp: Fix smatch warnings caused by atomisp custom assert() usage
Hans de Goede [Sun, 30 Jul 2023 15:33:42 +0000 (17:33 +0200)]
media: atomisp: Fix smatch warnings caused by atomisp custom assert() usage

The atomisp code base has a custom assert() macro, a couple of functions
use this in a construction like the following:

   assert(pipe);
   assert(pipe->stream);
   if ((!pipe) || (!pipe->stream)) {
           ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
                               "allocate_mipi_frames(%p) exit: ...\n",
                               pipe);
           return -EINVAL;
   }

The second assert is seen by smatch as dereferencing "pipe" in the above
example (and dereferencing "dvs_6axis_config" in the other case).

Following by the dereferenced variable being checked (a second time)
in the following if () statement.

This triggers the following smatch warnings:
drivers/staging/media/atomisp/pci/sh_css_mipi.c:356 allocate_mipi_frames() warn: variable dereferenced before check 'pipe' (see line 355)
drivers/staging/media/atomisp/pci/sh_css_mipi.c:562 send_mipi_frames() warn: variable dereferenced before check 'pipe' (see line 561)
drivers/staging/media/atomisp/pci/sh_css_param_dvs.c:208 free_dvs_6axis_table() warn: variable dereferenced before check 'dvs_6axis_config' (see line 206)

The custom assert() macro actually expands to a BUG() call and BUG()
calls should not be used in the kernel.

Remove the assert() calls to fix the smatch warnings and in case of
[allocate|send]_mipi_frames() also remove the if () return -EINVAL
block since these functions are never called with a NULL pipe.

Reported-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: atomisp: Remove bogus asd == NULL checks
Hans de Goede [Mon, 19 Jun 2023 10:52:07 +0000 (12:52 +0200)]
media: atomisp: Remove bogus asd == NULL checks

The asd is a sub-structure of the main driver data struct, so it is
never NULL. Drop the unnecessary NULL checks in a couple of places.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-media/533f6930-434a-45f3-afff-127003fa64c9@moroto.mountain/
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
10 months agomedia: go7007: Remove redundant if statement
Colin Ian King [Thu, 27 Jul 2023 17:40:07 +0000 (19:40 +0200)]
media: go7007: Remove redundant if statement

The if statement that compares msgs[i].len != 3 is always false because
it is in a code block where msg[i].len is equal to 3. The check is
redundant and can be removed.

As detected by cppcheck static analysis:
drivers/media/usb/go7007/go7007-i2c.c:168:20: warning: Opposite inner
'if' condition leads to a dead code block. [oppositeInnerCondition]

Link: https://lore.kernel.org/linux-media/20230727174007.635572-1-colin.i.king@gmail.com
Fixes: 866b8695d67e ("Staging: add the go7007 video driver")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: ipu3-cio2: allow ipu_bridge to be a module again
Arnd BergmannArnd Bergmann [Thu, 27 Jul 2023 12:22:58 +0000 (14:22 +0200)]
media: ipu3-cio2: allow ipu_bridge to be a module again

This code was previously part of the VIDEO_IPU3_CIO2 driver, which could
be built-in or a loadable module, but after the move it turned into a
builtin-only driver. This fails to link when the I2C subsystem is a
module:

x86_64-linux-ld: drivers/media/pci/intel/ipu-bridge.o: in function `ipu_bridge_unregister_sensors':
ipu-bridge.c:(.text+0x50): undefined reference to `i2c_unregister_device'
x86_64-linux-ld: drivers/media/pci/intel/ipu-bridge.o: in function `ipu_bridge_init':
ipu-bridge.c:(.text+0x9c9): undefined reference to `i2c_acpi_new_device_by_fwnode'

In general, drivers should not have to be built-in, so change the option
to a tristate with the corresponding dependency. This in turn opens a
new problem with the dependency, as the IPU bridge can be a loadable module
while the ipu3 driver itself is built-in, producing a new link failure:

86_64-linux-ld: drivers/media/pci/intel/ipu3/ipu3-cio2.o: in function `cio2_pci_probe':
ipu3-cio2.c:(.text+0x197e): undefined reference to `ipu_bridge_init'

In order to fix this, restore the old Kconfig option that controlled
the ipu bridge driver before it was split out, but make it select a
hidden symbol that now corresponds to the bridge driver.

When other drivers get added that share ipu-bridge, this should cover
all corner cases, and allow any combination of them to be built-in
or modular.

Link: https://lore.kernel.org/linux-media/20230727122331.2421453-1-arnd@kernel.org
Fixes: 881ca25978c6 ("media: ipu3-cio2: rename cio2 bridge to ipu bridge and move out of ipu3")'
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: cec-pin: only enable interrupts when monitoring the CEC pin
Hans Verkuil [Fri, 7 Jul 2023 11:26:41 +0000 (13:26 +0200)]
media: cec-pin: only enable interrupts when monitoring the CEC pin

The CEC interrupt is only needed if userspace wants to monitor
the CEC pin for an unconfigured CEC device. That gives it the
most precise CEC pin debugging results.

This avoids a corner case where the interrupt is enabled for
a short period when the adapter is about to be configured.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: cec-gpio: drop the cec_gpio_free callback
Hans Verkuil [Fri, 7 Jul 2023 11:26:40 +0000 (13:26 +0200)]
media: cec-gpio: drop the cec_gpio_free callback

Since the CEC pin framework now keeps track of the interrupt
and calls disable_irq when the kthread stops, there is no
longer any need for the cec-gpio driver to do this in the
free callback. So drop this code.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: cec-pin: improve interrupt handling
Hans Verkuil [Fri, 7 Jul 2023 11:26:39 +0000 (13:26 +0200)]
media: cec-pin: improve interrupt handling

The CEC pin framework needs a bit more control over the interrupt
handling: make sure that the disable_irq op is called even if the
device node is unregistered, log the state of the interrupt in
debugfs, and disable the interrupt when the kernel thread is stopped.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: cec-gpio: specify IRQF_NO_AUTOEN when requesting irq
Hans Verkuil [Fri, 7 Jul 2023 11:26:38 +0000 (13:26 +0200)]
media: cec-gpio: specify IRQF_NO_AUTOEN when requesting irq

Use IRQF_NO_AUTOEN rather than manually disabling the requested
interrupt.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: Documentation: media: cec: describe new callbacks
Hans Verkuil [Mon, 12 Jun 2023 13:58:39 +0000 (15:58 +0200)]
media: Documentation: media: cec: describe new callbacks

Describe the new callbacks and clarify when the adap->lock
mutex is held or not.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: cec: core: add adap_unconfigured() callback
Hans Verkuil [Mon, 12 Jun 2023 13:58:38 +0000 (15:58 +0200)]
media: cec: core: add adap_unconfigured() callback

The adap_configured() callback was called with the adap->lock mutex
held if the 'configured' argument was false, and without the adap->lock
mutex held if that argument was true.

That was very confusing, and so split this up in a adap_unconfigured()
callback and a high-level configured() callback.

This also makes it easier to understand when the mutex is held: all
low-level adap_* callbacks are called with the mutex held. All other
callbacks are called without that mutex held.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Fixes: f1b57164305d ("media: cec: add optional adap_configured callback")
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: cec: core: add adap_nb_transmit_canceled() callback
Hans Verkuil [Mon, 12 Jun 2023 13:58:37 +0000 (15:58 +0200)]
media: cec: core: add adap_nb_transmit_canceled() callback

A potential deadlock was found by Zheng Zhang with a local syzkaller
instance.

The problem is that when a non-blocking CEC transmit is canceled by calling
cec_data_cancel, that in turn can call the high-level received() driver
callback, which can call cec_transmit_msg() to transmit a new message.

The cec_data_cancel() function is called with the adap->lock mutex held,
and cec_transmit_msg() tries to take that same lock.

The root cause is that the received() callback can either be used to pass
on a received message (and then adap->lock is not held), or to report a
canceled transmit (and then adap->lock is held).

This is confusing, so create a new low-level adap_nb_transmit_canceled
callback that reports back that a non-blocking transmit was canceled.

And the received() callback is only called when a message is received,
as was the case before commit f9d0ecbf56f4 ("media: cec: correctly pass
on reply results") complicated matters.

Reported-by: Zheng Zhang <zheng.zhang@email.ucr.edu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Fixes: f9d0ecbf56f4 ("media: cec: correctly pass on reply results")
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: Documentation: v4l: Document sub-device notifiers
Sakari Ailus [Wed, 29 Mar 2023 14:02:44 +0000 (16:02 +0200)]
media: Documentation: v4l: Document sub-device notifiers

Document that sub-device notifiers are now registered using
v4l2_async_subdev_nf_init(). No documentation is changed as it seems that
sub-device notifiers were not documented apart from kernel-doc comments.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: v4l: async: Set v4l2_device and subdev in async notifier init
Sakari Ailus [Thu, 23 Feb 2023 15:24:48 +0000 (16:24 +0100)]
media: v4l: async: Set v4l2_device and subdev in async notifier init

Set the v4l2_device already in async notifier init, so struct device
related to it will be available before the notifier is registered. This
requires separating notifier initialisation into two functions, one that
takes v4l2_device as its argument, v4l2_async_nf_init and
v4l2_async_subdev_nf_init, for sub-device notifiers. Registering the
notifier will use a single function, v4l2_async_nf_register.

This is done in order to make struct device available earlier, during
construction of the async connections, for sensible debug prints.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: qcom: Initialise V4L2 async notifier later
Sakari Ailus [Thu, 30 Mar 2023 09:37:02 +0000 (11:37 +0200)]
media: qcom: Initialise V4L2 async notifier later

Initialise V4L2 async notifier and parse DT for async sub-devices later,
just before registering the notifier. This way the device can be made
available to the V4L2 async framework from the notifier init time onwards.
A subsequent patch will add struct v4l2_device as an argument to
v4l2_async_nf_init().

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: davinci: Init async notifier after registering V4L2 device
Sakari Ailus [Thu, 30 Mar 2023 09:31:13 +0000 (11:31 +0200)]
media: davinci: Init async notifier after registering V4L2 device

Initialise the V4L2 async notifier after registering the V4L2 device, just
before parsing DT for async sub-devices. This way the device can be made
available to the V4L2 async framework from the notifier init time onwards.
A subsequent patch will add struct v4l2_device as an argument to
v4l2_async_nf_init().

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: xilinx-vipp: Init async notifier after registering V4L2 device
Sakari Ailus [Wed, 29 Mar 2023 13:46:12 +0000 (15:46 +0200)]
media: xilinx-vipp: Init async notifier after registering V4L2 device

Initialise the V4L2 async notifier after registering the V4L2 device, just
before parsing DT for async sub-devices. This way the device can be made
available to the V4L2 async framework from the notifier init time onwards.
A subsequent patch will add struct v4l2_device as an argument to
v4l2_async_nf_init().

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: omap3isp: Initialise V4L2 async notifier later
Sakari Ailus [Wed, 29 Mar 2023 13:22:16 +0000 (15:22 +0200)]
media: omap3isp: Initialise V4L2 async notifier later

Initialise V4L2 async notifier and parse DT for async sub-devices later,
just before registering the notifier. This way the device can be made
available to the V4L2 async framework from the notifier init time onwards.
A subsequent patch will add struct v4l2_device as an argument to
v4l2_async_nf_init().

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: am437x-vpfe: Register V4L2 device early
Sakari Ailus [Wed, 29 Mar 2023 13:04:04 +0000 (15:04 +0200)]
media: am437x-vpfe: Register V4L2 device early

Register V4L2 device before the async notifier.This way the device can be
made available to the V4L2 async framework from the notifier init time
onwards. A subsequent patch will add struct v4l2_device as an argument to
v4l2_async_nf_init().

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: marvell: cafe: Register V4L2 device earlier
Sakari Ailus [Wed, 29 Mar 2023 13:00:00 +0000 (15:00 +0200)]
media: marvell: cafe: Register V4L2 device earlier

Register V4L2 device before the async notifier. This way the device can be
made available to the V4L2 async framework from the notifier init time
onwards. A subsequent patch will add struct v4l2_device as an argument to
v4l2_async_nf_init().

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: pxa_camera: Register V4L2 device early
Sakari Ailus [Wed, 29 Mar 2023 12:54:05 +0000 (14:54 +0200)]
media: pxa_camera: Register V4L2 device early

Register V4L2 device before initialising the notifier. This way the device
can be made available to the V4L2 async framework from the notifier init
time onwards. A subsequent patch will add struct v4l2_device as an
argument to v4l2_async_nf_init().

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: pxa_camera: Fix probe error handling
Sakari Ailus [Fri, 28 Apr 2023 11:14:46 +0000 (13:14 +0200)]
media: pxa_camera: Fix probe error handling

Fix and simplify error handling in pxa_camera probe, by moving devm_*()
functions early in the probe function and then tearing down what was set
up on error patch.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
10 months agomedia: adv748x: Return to endpoint matching
Sakari Ailus [Fri, 28 Apr 2023 15:09:57 +0000 (17:09 +0200)]
media: adv748x: Return to endpoint matching

Return the two CSI-2 transmitters of adv748x to endpoint matching. This
should make the driver work again as expected.

Fixes: 1029939b3782 ("media: v4l: async: Simplify async sub-device fwnode matching")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: v4l: async: Support fwnode endpoint list matching for subdevs
Sakari Ailus [Fri, 28 Apr 2023 13:58:42 +0000 (15:58 +0200)]
media: v4l: async: Support fwnode endpoint list matching for subdevs

Support matching V4L2 async sub-devices based on particular fwnode
endpoint. This makes it possible to instantiate multiple V4L2 sub-devices
based on given fwnode endpoints from a single device, based on driver
needs.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: v4l: async: Try more connections
Sakari Ailus [Thu, 11 May 2023 12:08:42 +0000 (14:08 +0200)]
media: v4l: async: Try more connections

When an async sub-device is registered, it used to be that the first one
of its connections were matched when found. Continue looking for matches
until a notifier no longer has any.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: v4l: async: Drop unneeded list entry initialisation
Sakari Ailus [Mon, 17 Apr 2023 11:14:56 +0000 (13:14 +0200)]
media: v4l: async: Drop unneeded list entry initialisation

The list entry is initialised as a head in v4l2_async_register_subdev()
just before being added to the list. This isn't needed, drop the
initialisation.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: v4l: async: Allow multiple connections between entities
Sakari Ailus [Fri, 19 May 2023 11:44:03 +0000 (13:44 +0200)]
media: v4l: async: Allow multiple connections between entities

When the v4l2-async framework was introduced, the use case for it was to
connect a camera sensor with a parallel receiver. Both tended to be rather
simple devices with a single connection between them.

The framework has been since improved in multiple ways but there are
limitations that have remained, for instance the assumption an async
sub-device is connected towards a single notifier and via a single link
only.

This patch enables connecting a sub-device to one or more notifiers
simultaneously, with one or more connections per notifier. The notifier
information is moved from the sub-device to the connection and the
connections in sub-device are no longer a pointer but a linked list.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: v4l: async: Obtain async connection based on sub-device
Sakari Ailus [Mon, 15 May 2023 09:06:50 +0000 (11:06 +0200)]
media: v4l: async: Obtain async connection based on sub-device

Add v4l2_async_connection_unique() function for obtaining a struct
v4l2_async_connection, typically allocated by drivers together with their
own information on an external sub-device.

The relation between connections and sub-devices still remains 1:1 but
this code becomes more complex when the relation soon changes.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: v4l: async: Rework internal lists
Sakari Ailus [Tue, 18 Apr 2023 12:00:54 +0000 (14:00 +0200)]
media: v4l: async: Rework internal lists

This patch re-arranges internal V4L2 async lists for preparation of
supporting multiple connections per sub-device as well as cleaning up used
lists.

The list of unbound V4L2 sub-devices shall be maintained for the purpose of
listing those sub-devices only, not for their bindin status. Also, the V4L2
async connections now have, instead of two list entries, a single list
entry in the notifier's list, be that either waiting or done lists, while
the notifier's asc_list is removed.

The one-to-one relation between a sub-device and a connection is still
maintained in this patch.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: v4l: async: Drop duplicate handling when adding connections
Sakari Ailus [Tue, 18 Apr 2023 09:54:32 +0000 (11:54 +0200)]
media: v4l: async: Drop duplicate handling when adding connections

The connections are checked for duplicates already when the notifier is
registered. This is effectively a sanity check for driver (and possibly
obscure firmware) bugs. Don't do this when adding the connection.

Retain the int return type for now. It'll be needed very soon again.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: v4l: async: Clean up error handling in v4l2_async_match_notify
Sakari Ailus [Mon, 17 Apr 2023 14:09:27 +0000 (16:09 +0200)]
media: v4l: async: Clean up error handling in v4l2_async_match_notify

Add labels for error handling instead of doing it all in individual cases.
Prepare for more functionality in this function.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: v4l: async: Rename v4l2_async_subdev as v4l2_async_connection
Sakari Ailus [Thu, 16 Feb 2023 13:54:53 +0000 (14:54 +0100)]
media: v4l: async: Rename v4l2_async_subdev as v4l2_async_connection

Rename v4l2_async_subdev as v4l2_async_connection, in order to
differentiate between the sub-devices and their connections: one
sub-device can have many connections but the V4L2 async framework has so
far allowed just a single one. Connections in this context will later
translate into either MC ancillary or data links.

This patch prepares changing that relation by changing existing users of
v4l2_async_subdev to switch to v4l2_async_connection. Async sub-devices
themselves will not be needed anymore

Additionally, __v4l2_async_nf_add_subdev() has been renamed
__v4l2_async_nf_add_connection().

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: v4l: async: Simplify async sub-device fwnode matching
Sakari Ailus [Sat, 18 Feb 2023 23:21:02 +0000 (00:21 +0100)]
media: v4l: async: Simplify async sub-device fwnode matching

V4L2 async sub-device matching originally used the device nodes only.
Endpoint nodes were taken into use instead as using the device nodes was
problematic for it was in some cases ambiguous which link might have been
in question.

There is however no need to use endpoint nodes on both sides, as the async
sub-device's fwnode can always be trivially obtained using
fwnode_graph_get_remote_endpoint() when needed while what counts is
whether or not the link is between two device nodes, i.e. the device nodes
match.

This will briefly break the adv748x driver but it will be fixed later in
the set, by patch "media: adv748x: Return to endpoint matching".

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: v4l: async: Clean up list heads and entries
Sakari Ailus [Wed, 22 Feb 2023 11:02:39 +0000 (12:02 +0100)]
media: v4l: async: Clean up list heads and entries

The naming of list heads and list entries is confusing as they're named
similarly. Use _list for list head and _entry for list entries.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: v4l: async: Only pass match information for async subdev validation
Sakari Ailus [Sun, 19 Feb 2023 12:24:41 +0000 (13:24 +0100)]
media: v4l: async: Only pass match information for async subdev validation

Pass only information required for sub-device matching to functions
checking whether the async sub-device already exists. Do the same for
debug message printing. This makes further changes to other aspects of
async sub-devices easier.

Accordingly, also perform further renames:

asd_equal as v4l2_async_match_equal,
v4l2_async_nf_has_async_subdev as v4l2_async_nf_has_async_match,
__v4l2_async_nf_has_async_subdev as
v4l2_async_nf_has_async_subdev_entry and
v4l2_async_nf_asd_valid as v4l2_async_nf_match_valid.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: v4l: async: Rename V4L2_ASYNC_MATCH_ macros, add TYPE_
Sakari Ailus [Fri, 5 May 2023 07:09:10 +0000 (09:09 +0200)]
media: v4l: async: Rename V4L2_ASYNC_MATCH_ macros, add TYPE_

The async match type is a struct field now, rename V4L2_ASYNC_MATCH_*
macros as V4L2_ASYNC_MATCH_TYPE_* instead.

This patch has been produced by:

git grep -l V4L2_ASYNC_MATCH_ -- drivers/media/ drivers/staging/media/ \
include/ Documentation/|xargs perl -i -pe \
's/V4L2_ASYNC_MATCH_\K/TYPE_/g'

so it must be correct.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: v4l: async: Make V4L2 async match information a struct
Sakari Ailus [Sun, 19 Feb 2023 12:09:00 +0000 (13:09 +0100)]
media: v4l: async: Make V4L2 async match information a struct

Make V4L2 async match information a struct, making it easier to use it
elsewhere outside the scope of struct v4l2_async_subdev.

Also remove an obsolete comment --- none of these fields are supposed to
be touched by drivers.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: v4l: async: Don't check whether asd is NULL in validity check
Sakari Ailus [Fri, 14 Apr 2023 11:38:24 +0000 (13:38 +0200)]
media: v4l: async: Don't check whether asd is NULL in validity check

The callers do pass a non-NULL asd to v4l2_async_nf_asd_valid() already.
There's no need for the NULL check here.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: v4l: async: Clean up testing for duplicate async subdevs
Sakari Ailus [Mon, 20 Feb 2023 11:14:19 +0000 (12:14 +0100)]
media: v4l: async: Clean up testing for duplicate async subdevs

There's a need to verify that a single async sub-device isn't being added
multiple times, this would be an error. This takes place at the time of
adding the async sub-device to the notifier's list as well as when the
notifier is added to the global notifier's list.

Use the pointer to the sub-device for testing this instead of an index to
an array that is long gone. (There was an array of async sub-devices in
the notifier before it was converted to a linked list by commit
66beb323e4a0 ("media: v4l2: async: Remove notifier subdevs array").)

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: v4l: async: Add some debug prints
Sakari Ailus [Thu, 9 Feb 2023 22:10:04 +0000 (23:10 +0100)]
media: v4l: async: Add some debug prints

Just add some debug prints for V4L2 async sub-device matching process.
These might come useful in figuring out why things don't work as expected.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: Documentation: v4l: Document v4l2_async_nf_cleanup
Sakari Ailus [Tue, 20 Jun 2023 11:26:53 +0000 (13:26 +0200)]
media: Documentation: v4l: Document v4l2_async_nf_cleanup

Document v4l2_async_nf_cleanup() which must be called before releasing an
unregistered notifier's memory. Also remove the sentence regarding
v4l2_async_nf_init() arguments --- those are documented in kerneldoc which
is referred here.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: Documentation: v4l: Document missing async subdev function
Sakari Ailus [Fri, 5 May 2023 11:57:29 +0000 (13:57 +0200)]
media: Documentation: v4l: Document missing async subdev function

Also v4l2_async_nf_add_fwnode() may be used to add an async sub-device
descriptor to a notifier. Document this. Also remove a redundant sentence.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: Documentation: v4l: Fix async sensor subdev helper documentation
Sakari Ailus [Tue, 20 Jun 2023 12:21:58 +0000 (14:21 +0200)]
media: Documentation: v4l: Fix async sensor subdev helper documentation

Document that the notifier of an async sub-device is, besider
unregistered, also cleaned up using v4l2_async_unregister_subdev().

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: Documentation: v4l: Add section titles for async
Sakari Ailus [Tue, 20 Jun 2023 12:03:02 +0000 (14:03 +0200)]
media: Documentation: v4l: Add section titles for async

Add section titles for async documentation. While the documentation is
mostly fine as-is, it has grown from its original state but remains
without internal structure. Add it now.

Also remove an extra newline.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: Documentation: v4l: Fix async notifier registration example
Sakari Ailus [Tue, 13 Jun 2023 16:36:27 +0000 (18:36 +0200)]
media: Documentation: v4l: Fix async notifier registration example

An example adding an async sub-device to a V4L2 async notifier. The name
of the variable in error handling was wrong (asd vs. my_asd).

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: omap3isp: Move link creation to bound callback
Sakari Ailus [Fri, 19 May 2023 11:56:33 +0000 (13:56 +0200)]
media: omap3isp: Move link creation to bound callback

Move the creation of the links between external sub-devices and ISP
sub-devices to the bound callback. This way we can also remove the need to
access the sub-device's notifier field that will soon be removed.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>