linux-2.6-block.git
9 months agomedia: ov2740: Add support for 180 MHz link frequency
Hans de Goede [Mon, 4 Dec 2023 12:39:44 +0000 (13:39 +0100)]
media: ov2740: Add support for 180 MHz link frequency

On various Lenovo Thinkpad models with an ov2740 sensor the 360 MHz
link frequency is not supported.

Add support for 180 MHz link frequency, even though this has half the
pixel clock, this supports the same framerate by using half the VTS value
(significantly reducing the amount of empty lines send during vblank).

Normally if there are multiple link-frequencies then the sensor driver
choses the lowest link-frequency still usable for the chosen resolution.

In this case the board supports only 1 link-frequency. Which frequency
is supported is checked in ov2740_check_hwcfg() and then a different
set of supported_modes (using only the supported link-freq) is selected.

The register settings for this were taken from the ov2740 sensor driver
in the out of tree IPU6 driver:

https://github.com/intel/ipu6-drivers/

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: ov2740: Check hwcfg after allocating the ov2740 struct
Hans de Goede [Mon, 4 Dec 2023 12:39:43 +0000 (13:39 +0100)]
media: ov2740: Check hwcfg after allocating the ov2740 struct

Alloc ov2740_data and set up the drvdata pointer before calling
ov2740_check_hwcfg().

This is a preparation patch to allow ov2740_check_hwcfg()
to store some of the parsed data in the ov2740 struct.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: ov2740: Fix hts value
Hans de Goede [Mon, 4 Dec 2023 12:39:42 +0000 (13:39 +0100)]
media: ov2740: Fix hts value

HTS must be more then width, so the 1080 value clearly is wrong,
this is then corrected with some weird math dividing clocks in
to_pixels_per_line() which results in the hts getting multiplied by 2,
resulting in 2160.

Instead just directly set hts to the correct value of 2160 and
drop to_pixels_per_line().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: ov2740: Improve ov2740_check_hwcfg() error reporting
Hans de Goede [Mon, 4 Dec 2023 12:39:41 +0000 (13:39 +0100)]
media: ov2740: Improve ov2740_check_hwcfg() error reporting

Make ov2740_check_hwcfg() report an error on failure in all error paths,
so that it is always clear why the probe() failed.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: ov2740: Move fwnode_graph_get_next_endpoint() call up
Hans de Goede [Mon, 4 Dec 2023 12:39:40 +0000 (13:39 +0100)]
media: ov2740: Move fwnode_graph_get_next_endpoint() call up

If the bridge has not yet setup the fwnode-graph then
the fwnode_property_read_u32("clock-frequency") call will fail.

Move the fwnode_graph_get_next_endpoint() call to above reading
the clock-frequency.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: ov2740: Add support for external clock
Hans de Goede [Mon, 4 Dec 2023 12:39:39 +0000 (13:39 +0100)]
media: ov2740: Add support for external clock

On some ACPI platforms, such as Chromebooks the ACPI methods to
change the power-state (_PS0 and _PS3) fully take care of powering
on/off the sensor.

On other ACPI platforms, such as e.g. various ThinkPad models with
IPU6 + ov2740 sensor, the sensor driver must control the reset GPIO
and the sensor's clock itself.

Add support for having the driver control an optional clock.

Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: ov2740: Add support for reset GPIO
Hans de Goede [Mon, 4 Dec 2023 12:39:38 +0000 (13:39 +0100)]
media: ov2740: Add support for reset GPIO

On some ACPI platforms, such as Chromebooks the ACPI methods to
change the power-state (_PS0 and _PS3) fully take care of powering
on/off the sensor.

On other ACPI platforms, such as e.g. various ThinkPad models with
IPU6 + ov2740 sensor, the sensor driver must control the reset GPIO
and the sensor's clock itself.

Add support for having the driver control an optional reset GPIO.

Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: i2c: Add support for alvium camera
Tommaso Merciai [Mon, 4 Dec 2023 09:47:16 +0000 (10:47 +0100)]
media: i2c: Add support for alvium camera

The Alvium camera is shipped with sensor + isp in the same housing.
The camera can be equipped with one out of various sensor and abstract
the user from this. Camera is connected via MIPI CSI-2.

Most of the camera module features are supported, with the main exception
being fw update.

The driver provides all mandatory, optional and recommended V4L2 controls
for maximum compatibility with libcamera

References:
 - https://www.alliedvision.com/en/products/embedded-vision-solutions

Signed-off-by: Tommaso Merciai <tomm.merciai@gmail.com>
[Sakari Ailus: Assign ret before using it in probe and squash Tommaso's
       other fixes.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: alvium-csi2.h: SPDX must use /* */ instead of //]

9 months agomedia: dt-bindings: alvium: add document YAML binding
Tommaso Merciai [Mon, 4 Dec 2023 09:47:15 +0000 (10:47 +0100)]
media: dt-bindings: alvium: add document YAML binding

Add documentation of device tree in YAML schema for the ALVIUM
Camera from Allied Vision Inc.

References:
 - https://www.alliedvision.com/en/products/embedded-vision-solutions

Signed-off-by: Tommaso Merciai <tomm.merciai@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agodt-bindings: vendor-prefixes: Add prefix alliedvision
Tommaso Merciai [Mon, 4 Dec 2023 09:47:14 +0000 (10:47 +0100)]
dt-bindings: vendor-prefixes: Add prefix alliedvision

Add a vendor prefix entry for Allied Vision Technologies GmbH
(https://www.alliedvision.com)

Signed-off-by: Tommaso Merciai <tomm.merciai@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: i2c: ak7375: Add support for ak7345
Vincent Knecht [Fri, 1 Dec 2023 18:13:50 +0000 (19:13 +0100)]
media: i2c: ak7375: Add support for ak7345

Add support for ak7345 VCM, which has 9 bits position values,
longer power-up delay, and no known standby register setting.
Might be compatible as-is with ak7348.

Tested on msm8916-alcatel-idol347 phone.

Signed-off-by: Vincent Knecht <vincent.knecht@mailoo.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: dt-bindings: ak7375: Add ak7345 support
Vincent Knecht [Fri, 1 Dec 2023 18:13:49 +0000 (19:13 +0100)]
media: dt-bindings: ak7375: Add ak7345 support

Document AK7345 bindings. Compared to AK7375, it has only 9 bits position
values (instead of 12), 20 ms power-up delay (instead of 10), and no known
standby register setting.

Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Vincent Knecht <vincent.knecht@mailoo.org>
[Sakari Ailus: Rewrap commit message.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: i2c: ak7375: Prepare for supporting another chip
Vincent Knecht [Fri, 1 Dec 2023 18:13:48 +0000 (19:13 +0100)]
media: i2c: ak7375: Prepare for supporting another chip

In view of adding support for at least one other chip,
change the driver to move chip-specific properties and
values in a common structure.

No functional changes.

Signed-off-by: Vincent Knecht <vincent.knecht@mailoo.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: i2c: imx290: Properly encode registers as little-endian
Alexander Stein [Thu, 2 Nov 2023 09:50:48 +0000 (10:50 +0100)]
media: i2c: imx290: Properly encode registers as little-endian

The conversion to CCI also converted the multi-byte register access to
big-endian. Correct the register definition by using the correct
little-endian ones.

Fixes: af73323b9770 ("media: imx290: Convert to new CCI register access helpers")
Cc: stable@vger.kernel.org
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[Sakari Ailus: Fixed the Fixes: tag.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: v4l2-cci: Add support for little-endian encoded registers
Alexander Stein [Thu, 2 Nov 2023 09:50:47 +0000 (10:50 +0100)]
media: v4l2-cci: Add support for little-endian encoded registers

Some sensors, e.g. Sony IMX290, are using little-endian registers. Add
support for those by encoding the endianness into Bit 20 of the register
address.

Fixes: af73323b9770 ("media: imx290: Convert to new CCI register access helpers")
Cc: stable@vger.kernel.org
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[Sakari Ailus: Fixed commit message.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: atmel-isi: Fix crash due to missing subdev in state
Laurent Pinchart [Fri, 8 Dec 2023 12:06:37 +0000 (14:06 +0200)]
media: atmel-isi: Fix crash due to missing subdev in state

As a result of converting to the stream-aware state functions, commit
bc0e8d91feec ("media: v4l: subdev: Switch to stream-aware state
functions") caused the sd pointer of the state passed to the
v4l2_subdev_state_get_crop() function to be dereferenced. It however
missed that the atmel-isi driver creates the v4l2_subdev_state instance
on the stack (which it shouldn't do, but that's a separate problem),
without initializing the sd field. This results in a null pointer
dereference.

Fix it by initializing the sd field.

Fixes: bc0e8d91feec ("media: v4l: subdev: Switch to stream-aware state functions")
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-cisco@xs4all.nl>
9 months agomedia: ddbridge: fix an error code problem in ddb_probe
Su Hui [Fri, 20 Oct 2023 09:17:23 +0000 (17:17 +0800)]
media: ddbridge: fix an error code problem in ddb_probe

Error code is assigned to 'stat', return 'stat' rather than '-1'.

Signed-off-by: Su Hui <suhui@nfschina.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: dvb-frontends: m88ds3103: Fix a memory leak in an error handling path of m88ds...
Christophe JAILLET [Mon, 30 Oct 2023 07:20:26 +0000 (08:20 +0100)]
media: dvb-frontends: m88ds3103: Fix a memory leak in an error handling path of m88ds3103_probe()

If an error occurs after a successful i2c_mux_add_adapter(), then
i2c_mux_del_adapters() should be called to free some resources, as
already done in the remove function.

Fixes: e6089feca460 ("media: m88ds3103: Add support for ds3103b demod")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: dvbdev: drop refcount on error path in dvb_device_open()
Dan Carpenter [Tue, 31 Oct 2023 09:53:33 +0000 (12:53 +0300)]
media: dvbdev: drop refcount on error path in dvb_device_open()

If call to file->f_op->open() fails, then call dvb_device_put(dvbdev).

Fixes: 0fc044b2b5e2 ("media: dvbdev: adopts refcnt to avoid UAF")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: platform: exynos4-is: return callee's error code rather than -ENXIO
Su Hui [Wed, 15 Nov 2023 08:57:54 +0000 (16:57 +0800)]
media: platform: exynos4-is: return callee's error code rather than -ENXIO

Clang static analyzer complains that value stored to 'ret' is never read.
Return the callee's error code to fix this.

Signed-off-by: Su Hui <suhui@nfschina.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agoMAINTAINERS: Add missing bindings for max96712
Niklas Söderlund [Wed, 15 Nov 2023 16:41:27 +0000 (17:41 +0100)]
MAINTAINERS: Add missing bindings for max96712

Add the binding documentation to the entry in the MAINTAINERS file.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: i2c: Introduce a driver for the Techwell TW9900 decoder
Mehdi Djait [Thu, 30 Nov 2023 17:46:47 +0000 (18:46 +0100)]
media: i2c: Introduce a driver for the Techwell TW9900 decoder

The Techwell video decoder supports PAL, NTSC standards and
has a parallel BT.656 output interface.

This commit adds support for this device, with basic support
for NTSC and PAL, along with brightness and contrast controls.

The TW9900 is capable of automatic standard detection. This
driver is implemented with support for PAL and NTSC
autodetection.

Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Mehdi Djait <mehdi.djait@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: dt-bindings: media: i2c: Add bindings for TW9900
Mehdi Djait [Thu, 30 Nov 2023 17:46:46 +0000 (18:46 +0100)]
media: dt-bindings: media: i2c: Add bindings for TW9900

The Techwell TW9900 is a video decoder supporting multiple input
standards such as PAL and NTSC and has a parallel BT.656 output
interface.

It's designed to be low-power, posesses some features such as a
programmable comb-filter, and automatic input standard detection

Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Mehdi Djait <mehdi.djait@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agodt-bindings: vendor-prefixes: Add techwell vendor prefix
Mehdi Djait [Thu, 30 Nov 2023 17:46:45 +0000 (18:46 +0100)]
dt-bindings: vendor-prefixes: Add techwell vendor prefix

Add prefix for Techwell, Inc.

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Mehdi Djait <mehdi.djait@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: amphion: remove mutext lock in condition of wait_event
Ming Qian [Fri, 8 Dec 2023 07:33:42 +0000 (15:33 +0800)]
media: amphion: remove mutext lock in condition of wait_event

mutext_lock should not be called in condition of wait_event, otherwise,
when CONFIG_DEBUG_ATOMIC_SLEEP is enabled, we may meet the following
warning:
do not call blocking ops when !TASK_RUNNING; state=2
WARNING: CPU: 5 PID: 741 at kernel/sched/core.c:9859
__might_sleep+0x80/0xa4
Hardware name: Freescale i.MX8QM MEK (DT)
pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)  pc :
__might_sleep+0x80/0xa4  lr : __might_sleep+0x80/0xa4  sp : ffffffc0123738a0
x29: ffffffc0123738a0 x28: ffffffc009194c48 x27: ffffffc00bbc1050
x26: ffffff8814b282f0 x25: ffffff8814b280d0 x24: ffffff8814b28080
x23: 0000000000000001 x22: 0000000000000032 x21: ffffffc00bbc1000
x20: 000000000000011b x19: ffffffc009324670 x18: 00000000fffffffd
x17: 30303c5b20746120 x16: 74657320323d6574 x15: 617473203b474e49
x14: 00058b5b8b9aa1f1 x13: ffffffc00903cda0 x12: 00000000d744fcc9
x11: 000000000000001c x10: 00000000000009a0 x9 : ffffffc0090201f4
x8 : ffffff8828245000 x7 : 0000000000000001 x6 : 0000000000000001
x5 : 00000000410fd080 x4 : 0000000000000002 x3 : ffffff8815aab4c8
x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffffff8828244600
Call trace:
 __might_sleep+0x80/0xa4
 mutex_lock+0x2c/0x80
 sync_session_response+0x110/0x310
 vpu_session_send_cmd+0x18c/0x244
 vpu_session_start+0x38/0x70
 vdec_start_session+0x1b4/0x3e0
 vpu_vb2_start_streaming+0xa0/0x1c4
 vb2_start_streaming+0x74/0x160
 vb2_core_qbuf+0x488/0x650
 vb2_qbuf+0x9c/0x100
 v4l2_m2m_qbuf+0x7c/0x224
 v4l2_m2m_ioctl_qbuf+0x20/0x2c
 v4l_qbuf+0x50/0x6c
 __video_do_ioctl+0x174/0x3f0
 video_usercopy+0x210/0x7cc
 video_ioctl2+0x20/0x30
 v4l2_ioctl+0x48/0x6c

we need to refine check_is_responsed() to remove the mutext_lock, each
cmd has a monotonically increasing id, and cmds are executed
sequentially, so we can check the id of the last reponsed cmd, then
determine whether a command has been responded or not.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
CC: Xiaolei Wang <xiaolei.wang@windriver.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: chips-media: wave5: Requires GENERIC_ALLOCATOR
Randy Dunlap [Wed, 6 Dec 2023 20:48:36 +0000 (12:48 -0800)]
media: chips-media: wave5: Requires GENERIC_ALLOCATOR

This driver uses the API that is provided by GENERIC_ALLOCATOR API, so
select it to prevent build errors:

riscv32-linux-ld: drivers/media/platform/chips-media/wave5/wave5-vpu.o: in function `.L37':
wave5-vpu.c:(.text+0x468): undefined reference to `of_gen_pool_get'
riscv32-linux-ld: drivers/media/platform/chips-media/wave5/wave5-vdi.o: in function `.L116':
wave5-vdi.c:(.text+0xaac): undefined reference to `gen_pool_dma_alloc'
riscv32-linux-ld: drivers/media/platform/chips-media/wave5/wave5-vdi.o: in function `wave5_vdi_free_sram':
wave5-vdi.c:(.text+0xb60): undefined reference to `gen_pool_free_owner'

Fixes: 9707a6254a8a ("media: chips-media: wave5: Add the v4l2 layer")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Nas Chung <nas.chung@chipsnmedia.com>
Cc: Jackson Lee <jackson.lee@chipsnmedia.com>
Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: chips-media: wave5: Fix panic on decoding DECODED_IDX_FLAG_SKIP
Mattijs Korpershoek [Wed, 29 Nov 2023 10:37:40 +0000 (11:37 +0100)]
media: chips-media: wave5: Fix panic on decoding DECODED_IDX_FLAG_SKIP

The display frame region information received from the vpu also
contains the frame display index: info->index_frame_display.

This index, being a s32, can be negative when a skip option is passed.
In that case, its value is DECODED_IDX_FLAG_SKIP (-2).

When disp_idx == -2, the following exception occurs:

[ 1530.782246][ T1900] Hardware name: Texas Instruments AM62P5 SK (DT)
[ 1530.788501][ T1900] pstate: a0400005 (NzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 1530.796144][ T1900] pc : wave5_vpu_dec_get_output_info+0x300/0x308 [wave5]
[ 1530.803060][ T1900] lr : wave5_vpu_dec_get_output_info+0x80/0x308 [wave5]
[ 1530.809873][ T1900] sp : ffffffc00b85bc00
[ 1530.813872][ T1900] x29: ffffffc00b85bc00 x28: 0000000000000000 x27: 0000000000000001
[ 1530.821695][ T1900] x26: 00000000fffffffd x25: 00000000ffffffff x24: ffffff8812820000
[ 1530.829516][ T1900] x23: ffffff88199f7840 x22: ffffff8873f5e000 x21: ffffffc00b85bc58
[ 1530.837336][ T1900] x20: 0000000000000000 x19: ffffff88199f7920 x18: ffffffc00a899030
[ 1530.845156][ T1900] x17: 00000000529c6ef0 x16: 00000000529c6ef0 x15: 0000000000198487
[ 1530.852975][ T1900] x14: ffffffc009f2b650 x13: 0000000000058016 x12: 0000000005000000
[ 1530.860795][ T1900] x11: 0000000000000000 x10: 0000000000000000 x9 : 0000000000000000
[ 1530.868615][ T1900] x8 : 0000000000000000 x7 : 0000000000000000 x6 : 0000000000004086
[ 1530.876434][ T1900] x5 : 0000000000000001 x4 : ffffffc001454b94 x3 : ffffffc001454d94
[ 1530.884256][ T1900] x2 : ffffffc00b8201d0 x1 : 0000000000000020 x0 : 0000000000000000
[ 1530.892087][ T1900] Call trace:
[ 1530.895225][ T1900]  wave5_vpu_dec_get_output_info+0x300/0x308 [wave5]
[ 1530.901788][ T1900]  wave5_vpu_dec_finish_decode+0x6c/0x3dc [wave5]
[ 1530.908081][ T1900]  wave5_vpu_irq_thread+0x140/0x168 [wave5]
[ 1530.913856][ T1900]  irq_thread_fn+0x44/0xa4
[ 1530.918154][ T1900]  irq_thread+0x15c/0x288
[ 1530.922330][ T1900]  kthread+0x104/0x1d4
[ 1530.926247][ T1900]  ret_from_fork+0x10/0x20
[ 1530.930520][ T1900] Code: 2a1f03ea 2a1f03eb 35ffef2c 17ffff74 (d42aa240)
[ 1530.937296][ T1900] ---[ end trace 0000000000000000 ]---
[ 1530.942596][ T1900] Kernel panic - not syncing: BRK handler: Fatal exception
[ 1530.949629][ T1900] SMP: stopping secondary CPUs
[ 1530.954244][ T1900] Kernel Offset: disabled
[ 1530.958415][ T1900] CPU features: 0x00,00000000,00800184,0000421b
[ 1530.964496][ T1900] Memory Limit: none

Move the disp_info assignment after testing that the index is positive
to avoid the exception.

Fixes: 45d1a2b93277 ("media: chips-media: wave5: Add vpuapi layer")
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: chips-media: wave5: Fix spelling mistake "bufferur" -> "buffer"
Colin Ian King [Fri, 24 Nov 2023 16:41:23 +0000 (16:41 +0000)]
media: chips-media: wave5: Fix spelling mistake "bufferur" -> "buffer"

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

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: MAINTAINERS: Correct file entry in WAVE5 VPU CODEC DRIVER
Lukas Bulwahn [Wed, 29 Nov 2023 16:03:13 +0000 (17:03 +0100)]
media: MAINTAINERS: Correct file entry in WAVE5 VPU CODEC DRIVER

Commit 26dde1beb359 ("media: chips-media: wave5: Add wave5 driver to
maintainers file") adds the MAINTAINERS section WAVE5 VPU CODEC DRIVER
referring to the 'cnm,wave5.yaml' media devicetree binding, but the file
actually added in the commit de4b9f7e371a ("dt-bindings: media: wave5: add
yaml devicetree bindings") is named 'cnm,wave521c.yaml'.

Correct the file entry in WAVE5 VPU CODEC DRIVER.

Fixes: 26dde1beb359 ("media: chips-media: wave5: Add wave5 driver to maintainers file")
Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: chips-media: wave5: Remove duplicate check
Dan Carpenter [Tue, 28 Nov 2023 14:39:58 +0000 (17:39 +0300)]
media: chips-media: wave5: Remove duplicate check

We already verified that "ret" is zero a few lines earlier.  Delete this
duplicate check.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: venus: core: Set up secure memory ranges for SC7280
Luca Weiss [Fri, 1 Dec 2023 09:33:18 +0000 (10:33 +0100)]
media: venus: core: Set up secure memory ranges for SC7280

Not all SC7280 devices ship with ChromeOS firmware. Other devices need
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 SC7280 devices.

Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: rkisp1: resizer: Stop manual allocation of v4l2_subdev_state
Laurent Pinchart [Sun, 26 Nov 2023 02:09:48 +0000 (03:09 +0100)]
media: rkisp1: resizer: Stop manual allocation of v4l2_subdev_state

Supported media bus codes on the resizer sink pad are identical to the
ISP source pad. The .enum_mbus_code() handler thus delegates the
enumeration to the ISP's operation. This is problematic for two
reasons:

- Format enumeration on the ISP source pad is dependent on the format
  configured on the ISP sink pad for the same subdev state (TRY or
  ACTIVE), while format enumeration on the resizer sink pad should
  return all formats supported by the resizer subdev, regardless of the
  ISP configuration.

- Delegating the operation involves creating a fake v4l2_subdev_state on
  the stack to pass to the ISP .enum_mbus_code() handler. This gets in
  the way of evolution of both the ISP enumeration handler and, more
  generally, the V4L2 subdev state infrastructure.

Fix those two issues by implementing format enumeration manually for the
resizer.

Link: https://lore.kernel.org/r/20231126020948.2700-1-laurent.pinchart@ideasonboard.com
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: rkisp1: debug: Count completed frame interrupts
Paul Elder [Fri, 1 Dec 2023 14:04:32 +0000 (15:04 +0100)]
media: rkisp1: debug: Count completed frame interrupts

Add a counter to debugfs to count the number of frame-end interrupts.

Link: https://lore.kernel.org/r/20231201140433.2126011-4-paul.elder@ideasonboard.com
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: rkisp1: debug: Add register dump for IS
Paul Elder [Fri, 1 Dec 2023 14:04:31 +0000 (15:04 +0100)]
media: rkisp1: debug: Add register dump for IS

Add register dump for the ISP image stabilizer module to debugfs. This
helps debugging issues related to digital zoom.

Link: https://lore.kernel.org/r/20231201140433.2126011-3-paul.elder@ideasonboard.com
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: rkisp1: regs: Consolidate MI interrupt wrap fields
Paul Elder [Fri, 1 Dec 2023 14:04:30 +0000 (15:04 +0100)]
media: rkisp1: regs: Consolidate MI interrupt wrap fields

Consolidate the wraparound fields in the memory interface interrupt
status registers, so that it can be more succinctly expressed by taking
the stream ID (main or self) as a parameter.

Link: https://lore.kernel.org/r/20231201140433.2126011-2-paul.elder@ideasonboard.com
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: rkisp1: Fix IRQ disable race issue
Tomi Valkeinen [Thu, 7 Dec 2023 07:57:48 +0000 (08:57 +0100)]
media: rkisp1: Fix IRQ disable race issue

In rkisp1_isp_stop() and rkisp1_csi_disable() the driver masks the
interrupts and then apparently assumes that the interrupt handler won't
be running, and proceeds in the stop procedure. This is not the case, as
the interrupt handler can already be running, which would lead to the
ISP being disabled while the interrupt handler handling a captured
frame.

This brings up two issues: 1) the ISP could be powered off while the
interrupt handler is still running and accessing registers, leading to
board lockup, and 2) the interrupt handler code and the code that
disables the streaming might do things that conflict.

It is not clear to me if 2) causes a real issue, but 1) can be seen with
a suitable delay (or printk in my case) in the interrupt handler,
leading to board lockup.

Link: https://lore.kernel.org/r/20231207-rkisp-irq-fix-v3-4-358a2c871a3c@ideasonboard.com
Tested-by: Adam Ford <aford173@gmail.com> #imx8mp-beacon
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: rkisp1: Store IRQ lines
Tomi Valkeinen [Thu, 7 Dec 2023 07:57:47 +0000 (08:57 +0100)]
media: rkisp1: Store IRQ lines

Store the IRQ lines used by the driver for easy access. These are needed
in future patches which fix IRQ race issues.

Link: https://lore.kernel.org/r/20231207-rkisp-irq-fix-v3-3-358a2c871a3c@ideasonboard.com
Tested-by: Adam Ford <aford173@gmail.com> #imx8mp-beacon
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: rkisp1: Fix IRQ handler return values
Tomi Valkeinen [Thu, 7 Dec 2023 07:57:46 +0000 (08:57 +0100)]
media: rkisp1: Fix IRQ handler return values

The IRQ handler rkisp1_isr() calls sub-handlers, all of which returns an
irqreturn_t value, but rkisp1_isr() ignores those values and always
returns IRQ_HANDLED.

Fix this by collecting the return values, and returning IRQ_HANDLED or
IRQ_NONE as appropriate.

Link: https://lore.kernel.org/r/20231207-rkisp-irq-fix-v3-2-358a2c871a3c@ideasonboard.com
Tested-by: Adam Ford <aford173@gmail.com> #imx8mp-beacon
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: rkisp1: Drop IRQF_SHARED
Tomi Valkeinen [Thu, 7 Dec 2023 07:57:45 +0000 (08:57 +0100)]
media: rkisp1: Drop IRQF_SHARED

In all known platforms the ISP has dedicated IRQ lines, but for some
reason the driver uses IRQF_SHARED.

Supporting IRQF_SHARED properly requires handling interrupts even when
our device is disabled, and the driver does not handle this. To avoid
adding such code, and to be sure the driver won't accidentally be used
in a platform with shared interrupts, let's drop the IRQF_SHARED flag.

Link: https://lore.kernel.org/r/20231207-rkisp-irq-fix-v3-1-358a2c871a3c@ideasonboard.com
Tested-by: Adam Ford <aford173@gmail.com> #imx8mp-beacon
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: rkisp1: Fix memory leaks in rkisp1_isp_unregister()
Tomi Valkeinen [Wed, 22 Nov 2023 15:50:08 +0000 (16:50 +0100)]
media: rkisp1: Fix memory leaks in rkisp1_isp_unregister()

Add missing call to v4l2_subdev_cleanup() to fix memory leak.

Link: https://lore.kernel.org/r/20231122-rkisp-fixes-v2-2-78bfb63cdcf8@ideasonboard.com
Fixes: 2cce0a369dbd ("media: rkisp1: isp: Use V4L2 subdev active state")
Reviewed-by: Tommaso Merciai <tomm.merciai@gmail.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: rkisp1: Fix media device memory leak
Tomi Valkeinen [Wed, 22 Nov 2023 15:50:07 +0000 (16:50 +0100)]
media: rkisp1: Fix media device memory leak

Add missing calls to media_device_cleanup() to fix memory leak.

Link: https://lore.kernel.org/r/20231122-rkisp-fixes-v2-1-78bfb63cdcf8@ideasonboard.com
Fixes: d65dd85281fb ("media: staging: rkisp1: add Rockchip ISP1 base driver")
Reviewed-by: Tommaso Merciai <tomm.merciai@gmail.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: dt-bindings: media: rkisp1: Fix the port description for the parallel interface
Mehdi Djait [Wed, 15 Nov 2023 16:44:07 +0000 (17:44 +0100)]
media: dt-bindings: media: rkisp1: Fix the port description for the parallel interface

The bus-type belongs to the endpoint's properties and should therefore
be moved.

Link: https://lore.kernel.org/r/20231115164407.99876-1-mehdi.djait@bootlin.com
Fixes: 6a0eaa25bf36 ("media: dt-bindings: media: rkisp1: Add port for parallel interface")
Signed-off-by: Mehdi Djait <mehdi.djait@bootlin.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: nxp: imx8-isi-debug: Add missing 36-Bit DMA registers to debugfs output
Alexander Stein [Thu, 7 Dec 2023 11:09:18 +0000 (12:09 +0100)]
media: nxp: imx8-isi-debug: Add missing 36-Bit DMA registers to debugfs output

The extended address registers are missing in the debug output register
list. These are only available on 36-Bit DMA platforms. Due to the
prolonged name, the output width has to be adjusted as well.

Link: https://lore.kernel.org/r/20231207110918.1338524-1-alexander.stein@ew.tq-group.com
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: imx-mipi-csis: Drop extra clock enable at probe()
Tomi Valkeinen [Wed, 22 Nov 2023 15:21:35 +0000 (16:21 +0100)]
media: imx-mipi-csis: Drop extra clock enable at probe()

The driver always enables the clocks at probe() and disables them only
at remove(). It is not clear why the driver does this, as it supports
runtime PM, and enables and disables the clocks in the runtime resume
and suspend callbacks. Also, in the case runtime PM is not available,
the driver calls the resume and suspend callbacks manually from probe()
and remove().

Drop the unnecessary clock enable, thus enabling the clocks only when
actually needed.

Link: https://lore.kernel.org/r/20231122-imx-csis-v2-2-e44b8dc4cb66@ideasonboard.com
Fixes: 7807063b862b ("media: staging/imx7: add MIPI CSI-2 receiver subdev for i.MX7")
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: imx-mipi-csis: Fix clock handling in remove()
Tomi Valkeinen [Wed, 22 Nov 2023 15:21:34 +0000 (16:21 +0100)]
media: imx-mipi-csis: Fix clock handling in remove()

The driver always calls mipi_csis_runtime_suspend() and
mipi_csis_clk_disable() in remove(). This causes multiple WARNs from the
kernel, as the clocks get disabled too many times.

Fix the remove() to call mipi_csis_runtime_suspend() and
mipi_csis_clk_disable() in a way that reverses what is done in probe().

Link: https://lore.kernel.org/r/20231122-imx-csis-v2-1-e44b8dc4cb66@ideasonboard.com
Fixes: 7807063b862b ("media: staging/imx7: add MIPI CSI-2 receiver subdev for i.MX7")
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: imx: imx7-media-csi: Include headers explicitly
Laurent Pinchart [Tue, 25 Jul 2023 19:14:45 +0000 (21:14 +0200)]
media: imx: imx7-media-csi: Include headers explicitly

Include all the headers that the driver needs explicitly instead of
relying on indirect inclusion. While at it, drop a few unneeded headers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: uvcvideo: Fix power line control for SunplusIT camera
Ricardo Ribalda [Sat, 28 Oct 2023 07:55:04 +0000 (09:55 +0200)]
media: uvcvideo: Fix power line control for SunplusIT camera

The device does not implement the power line frequency control
correctly. It is a UVC 1.5 device, but implements the control as a UVC
1.1 device.

Add the corresponding control mapping override.

Bus 003 Device 002: ID 2b7e:b752 SunplusIT Inc HD Camera
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.01
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x2b7e
  idProduct          0xb752
  bcdDevice            0.04
  iManufacturer           1 SunplusIT Inc
  iProduct                2 HD Camera
  iSerial                 3 01.00.00
  bNumConfigurations      1

Cc: Yunke Cao <yunkec@chromium.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: uvcvideo: Pick first best alternate setting insteed of last
Laurent Pinchart [Thu, 19 Oct 2023 22:02:46 +0000 (00:02 +0200)]
media: uvcvideo: Pick first best alternate setting insteed of last

When selecting an alternate setting, the driver loops over all available
alternate settings to find the one with the lowest bandwidth high enough
for the selected format and resolution. While all alternate settings
should have different packet sizes, some buggy devices report multiple
alternate settings with the same size. The driver happens to pick the
last one in this case.

In theory this should work fine, but in real life we have device bugs.
The Ali Corp. Newmine Camera (0402:8841) exposes four alternate
settings with the same packet size. The first three seem to work fine,
while selecting the last one results in lots of transmission errors.

Switch to using the first best alternate setting when multiple are
present. This should be safe (last famous words), as sniffing USB
traffic with the faulty device shows that Windows 10 picks the first
alternate setting, and devices are typically tested on Windows.

Closes: https://lore.kernel.org/linux-media/Nh6D0WI--3-9@tutanota.com/

Reported-by: Karel Janda <karel1@tutanota.com>
Suggested-by: Karel Janda <karel1@tutanota.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: uvcvideo: Fix power line control for a Chicony camera
Ricardo Ribalda [Tue, 5 Sep 2023 15:29:52 +0000 (17:29 +0200)]
media: uvcvideo: Fix power line control for a Chicony camera

The device does not implement the control properly.

Fixes v4l2-compliance error:

info: checking control 'Power Line Frequency' (0x00980918)
fail: v4l2-test-controls.cpp(552): could not set valid menu item 3

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: videobuf2: request more buffers for vb2_read
Hans Verkuil [Thu, 30 Nov 2023 12:58:12 +0000 (13:58 +0100)]
media: videobuf2: request more buffers for vb2_read

The vb2 read support requests 1 buffer, leaving it to the driver
to increase this number to something that works.

Unfortunately, drivers do not deal with this reliably, and in fact
this caused problems for the bttv driver and reading from /dev/vbiX,
causing every other VBI frame to be all 0.

Instead, request as the number of buffers whatever is the maximum of
2 and q->min_buffers_needed+1.

In order to start streaming you need at least q->min_buffers_needed
queued buffers, so add 1 buffer for processing. And if that field
is 0, then choose 2 (again, one buffer is being filled while the
other one is being processed).

This certainly makes more sense than requesting just 1 buffer, and
the VBI bttv support is now working again.

It turns out that the old videobuf1 behavior of bttv was to allocate
8 (video) and 4 (vbi) buffers when used with read(). After the vb2
conversion that changed to 2 for both. With this patch it is 3, which
is really all you need.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Fixes: b7ec3212a73a ("media: bttv: convert to vb2")
Tested-by: Dr. David Alan Gilbert <dave@treblig.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: bttv: add back vbi hack
Hans Verkuil [Thu, 30 Nov 2023 12:58:11 +0000 (13:58 +0100)]
media: bttv: add back vbi hack

The old (now removed) videobuf framework had an optional vbi hack where
the sequence number of the frame counter was copied in the last 4 bytes
of the buffer. This hack was active only for the read() interface
(so not for streaming I/O), and it was enabled by bttv. This allowed
applications that used read() for the VBI data to match it with the
corresponding video frame.

When bttv was converted to vb2 this hack was forgotten, but some old
applications rely on this.

So add this back, but this time in the bttv driver rather than in the
vb2 framework.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Fixes: b7ec3212a73a ("media: bttv: convert to vb2")
Tested-by: Dr. David Alan Gilbert <dave@treblig.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: bttv: start_streaming should return a proper error code
Hans Verkuil [Thu, 30 Nov 2023 12:58:10 +0000 (13:58 +0100)]
media: bttv: start_streaming should return a proper error code

The start_streaming callback returned 0 or 1 instead of a
proper error code. Fix that.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Fixes: b7ec3212a73a ("media: bttv: convert to vb2")
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
9 months agomedia: ov9640: Don't set format in sub-device state
Sakari Ailus [Wed, 6 Dec 2023 17:25:07 +0000 (19:25 +0200)]
media: ov9640: Don't set format in sub-device state

For the purpose of setting old non-pad based sub-device try format as a
basis for VIDIOC_TRY_FMT implementation, there is no need to set the
format in the sub-device state. Drop the assignment to the state, which
would result in a NULL pointer dereference.

Fixes: fd17e3a9a788 ("media: i2c: Use accessors for pad config 'try_*' fields")
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-cisco@xs4all.nl>
9 months agomedia: tw9910: Don't set format in sub-device state
Sakari Ailus [Wed, 6 Dec 2023 17:24:11 +0000 (19:24 +0200)]
media: tw9910: Don't set format in sub-device state

For the purpose of setting old non-pad based sub-device try format as a
basis for VIDIOC_TRY_FMT implementation, there is no need to set the
format in the sub-device state. Drop the assignment to the state, which
would result in a NULL pointer dereference.

Fixes: fd17e3a9a788 ("media: i2c: Use accessors for pad config 'try_*' fields")
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-cisco@xs4all.nl>
9 months agomedia: rj54n1cb0c: Don't set format in sub-device state
Sakari Ailus [Wed, 6 Dec 2023 17:22:43 +0000 (19:22 +0200)]
media: rj54n1cb0c: Don't set format in sub-device state

For the purpose of setting old non-pad based sub-device try format as a
basis for VIDIOC_TRY_FMT implementation, there is no need to set the
format in the sub-device state. Drop the assignment to the state, which
would result in a NULL pointer dereference.

Fixes: fd17e3a9a788 ("media: i2c: Use accessors for pad config 'try_*' fields")
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-cisco@xs4all.nl>
9 months agomedia: mt9t112: Don't set format in sub-device state
Sakari Ailus [Wed, 6 Dec 2023 17:22:03 +0000 (19:22 +0200)]
media: mt9t112: Don't set format in sub-device state

For the purpose of setting old non-pad based sub-device try format as a
basis for VIDIOC_TRY_FMT implementation, there is no need to set the
format in the sub-device state. Drop the assignment to the state, which
would result in a NULL pointer dereference.

Fixes: fd17e3a9a788 ("media: i2c: Use accessors for pad config 'try_*' fields")
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-cisco@xs4all.nl>
9 months agomedia: adv7183: Don't set format in sub-device state
Sakari Ailus [Wed, 6 Dec 2023 17:20:19 +0000 (19:20 +0200)]
media: adv7183: Don't set format in sub-device state

For the purpose of setting old non-pad based sub-device try format as a
basis for VIDIOC_TRY_FMT implementation, there is no need to set the
format in the sub-device state. Drop the assignment to the state, which
would result in a NULL pointer dereference.

Fixes: fd17e3a9a788 ("media: i2c: Use accessors for pad config 'try_*' fields")
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-cisco@xs4all.nl>
9 months agomedia: saa6752hs: Don't set format in sub-device state
Sakari Ailus [Wed, 6 Dec 2023 11:35:33 +0000 (13:35 +0200)]
media: saa6752hs: Don't set format in sub-device state

For the purpose of setting old non-pad based sub-device try format as a
basis for VIDIOC_TRY_FMT implementation, there is no need to set the
format in the sub-device state. Drop the assignment to the state, which
would result in a NULL pointer dereference.

Fixes: fd17e3a9a788 ("media: i2c: Use accessors for pad config 'try_*' fields")
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-cisco@xs4all.nl>
9 months agomedia: ccs: Select V4L2_CCI_I2C
Sakari Ailus [Wed, 6 Dec 2023 10:12:13 +0000 (12:12 +0200)]
media: ccs: Select V4L2_CCI_I2C

Select V4L2_CCI_I2C Kconfig option which the CCS driver now depends on.

Fixes: 529322112a3b ("media: ccs: Use V4L2 CCI for accessing sensor registers")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202312060941.CYiHppAp-lkp@intel.com/
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: rockchip: rga: add NV12M support
Michael Tretter [Fri, 13 Oct 2023 11:00:34 +0000 (13:00 +0200)]
media: rockchip: rga: add NV12M support

Add support for the multi-planar variants of NV12. The RGA is now able
to exchange DMABUFs with other devices that only support multi-planar
NV12, for example the Hantro JPEG encoder.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: rockchip: rga: rework buffer handling for multi-planar formats
Michael Tretter [Fri, 13 Oct 2023 11:00:33 +0000 (13:00 +0200)]
media: rockchip: rga: rework buffer handling for multi-planar formats

Multi-planar formats may have multiple planes that must be handled and
correctly mapped into a continuous buffer for the RGA by using the DMA
descriptors.

The plane offsets in the continuous mapping may now start at page
boundaries and the previous calculation based on the frame sizes is only
valid for planar buffers in a single memory. Therefore, the offsets must
be detected and set while creating the mapping.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: rockchip: rga: switch to multi-planar API
Michael Tretter [Fri, 13 Oct 2023 11:00:32 +0000 (13:00 +0200)]
media: rockchip: rga: switch to multi-planar API

Switch to the multi-planar API, which allows to handle buffers with
separate planes.

The RGA driver doesn't expose multi-planar formats, yet. The existing
contiguous planar formats can be used with the multi-planar API as well,
but the multi-planar API is required for multi-planar formats.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: rockchip: rga: use macros for testing buffer type
Michael Tretter [Fri, 13 Oct 2023 11:00:31 +0000 (13:00 +0200)]
media: rockchip: rga: use macros for testing buffer type

Use the provided V4L2_TYPE_IS_{OUTPUT,CAPTURE} macros to check if the
buffer or queue is OUTPUT or CAPTURE. The macros work also work for the
_MPLANE buffer and queue types and make it easier to switch to the
multi-planar API.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: rockchip: rga: add local variable for pix_format
Michael Tretter [Fri, 13 Oct 2023 11:00:30 +0000 (13:00 +0200)]
media: rockchip: rga: add local variable for pix_format

The local variable allows to simplify the accessed to the format and
makes it easier to change the type of the format.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: rockchip: rga: use pixelformat to find format
Michael Tretter [Fri, 13 Oct 2023 11:00:29 +0000 (13:00 +0200)]
media: rockchip: rga: use pixelformat to find format

Use the pixelformat instead of the v4l2_format to find the rga_fmt. This
avoids knowing the structure and type of v4l2_format in rga_fmt_find and
simplifies the function.

Also cleanup the users of the function. In try_fmt always return the
found pixel format to make sure that the pixel format is always set.
Thus, we can be sure that we will find the rga_fmt in s_fmt and can drop
the check if a given format has been found.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: rockchip: rga: use clamp() to clamp size to limits
Michael Tretter [Fri, 13 Oct 2023 11:00:28 +0000 (13:00 +0200)]
media: rockchip: rga: use clamp() to clamp size to limits

The try_fmt should limit the width and height to the know limits of the
RGA. Use the clamp() helper instead of open coding the clamping.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: rockchip: rga: set dma mask to 32 bits
Michael Tretter [Fri, 13 Oct 2023 11:00:27 +0000 (13:00 +0200)]
media: rockchip: rga: set dma mask to 32 bits

The RGA DMA descriptor list contains only 32-bit addresses. Set the
dma_mask to only allocate memory that is addressable by the descriptors.

This prevents errors when preparing vb2 buffers that were allocated by
the RGA.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: rockchip: rga: pre-calculate plane offsets
Michael Tretter [Fri, 13 Oct 2023 11:00:26 +0000 (13:00 +0200)]
media: rockchip: rga: pre-calculate plane offsets

Calculate the plane offsets and store them with the video buffer while
creating the buffer mapping.

This allows the driver to more freely handle the memory of the DMA
mapping as the offsets and the mapping can be kept in sync.

The driver still has to update the offsets to respect the configured
cropping and rotation, but this calculation is now separated from the
calculation of the plane offsets.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: rockchip: rga: split src and dst buffer setup
Michael Tretter [Fri, 13 Oct 2023 11:00:25 +0000 (13:00 +0200)]
media: rockchip: rga: split src and dst buffer setup

Split the register setup for the source and destination video buffers
into separate functions.

This is a cleanup to make the code more readable by separating the
offset calculation for the different buffers and prepares the driver for
using pre-calculated offsets of planes.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: rockchip: rga: allocate DMA descriptors per buffer
Michael Tretter [Fri, 13 Oct 2023 11:00:24 +0000 (13:00 +0200)]
media: rockchip: rga: allocate DMA descriptors per buffer

The RGA driver allocates two buffers for the DMA descriptors of the
input and output buffers. Whenever a new job is processed, the
descriptor list is updated for the current buffers.

By updating the descriptor list during buf_prepare, it is possible to
correctly fail DMABUF imports if the buffers that shall be imported are
not within the 32 bit address range that can be addressed by the RGA.

Managing the DMA descriptor list with the buffer also makes it easier to
track the buffer mapping and the plane offsets into this mapping.

The cost is that the driver now requires DMA coherent memory per buffer
for the descriptor list. However, the size scales with the size of the
video buffers and is not allocated if the RGA is not used.

While at it, use dma_alloc_coherent to allocate the descriptors and get
rid of the virt_to_phys calls to get the physical addresses.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: rockchip: rga: extract helper to fill descriptors
Michael Tretter [Fri, 13 Oct 2023 11:00:23 +0000 (13:00 +0200)]
media: rockchip: rga: extract helper to fill descriptors

The IOMMU of the RGA is programmed with a list of DMA descriptors that
contain an 32 bit address per 4k page in the video buffers. The address
in the descriptor points to the start address of the page.

Introduce 'struct rga_dma_desc' to make the handling of the DMA
descriptors explicit instead of hiding them behind standard types.

While at it, use provided helpers for iterating the sg_table instead of
manually calculating the DMA addresses.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: rockchip: rga: fix swizzling for RGB formats
Michael Tretter [Fri, 13 Oct 2023 11:00:22 +0000 (13:00 +0200)]
media: rockchip: rga: fix swizzling for RGB formats

When using 32 bit RGB formats, the RGA on the rk3568 produces wrong
colors as the wrong color channels are read or written.  The reason is
that the format description for the channel swizzeling is wrong and the
wrong bits are configured. For example, when converting ARGB32 to NV12,
the alpha channel is used as blue channel.. This doesn't happen if the
color format is the same on both sides.

Fix the color_swap settings of the formats to correctly handle 32 bit
RGB formats.

For RGA_COLOR_FMT_XBGR8888, the RGA_COLOR_ALPHA_SWAP bit doesn't have an
effect. Thus, it isn't possible to handle the V4L2_PIX_FMT_XRGB32. Thus,
it is removed from the list of supported formats.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: qcom: camss: Add sm8250 named power-domain support
Bryan O'Donoghue [Thu, 23 Nov 2023 17:03:07 +0000 (17:03 +0000)]
media: qcom: camss: Add sm8250 named power-domain support

Declare power-domain names "top", "ife0" and "ife1" eponymously for the
power-domains TITAN_TOP_GDSC, IFE_0_GDSC and IFE_1_GDSC respectively.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: qcom: camss: Flag CSID-lites to support more CSIDs
Matti Lehtimäki [Thu, 23 Nov 2023 17:03:06 +0000 (17:03 +0000)]
media: qcom: camss: Flag CSID-lites to support more CSIDs

Some platforms such as SC7280 have 3 CSIDs and 2 CSID-lites but current
code has hardcoded 2 as the maximum number of CSIDs. Remove the hardcoded
maximum number of VFEs to handle all possible combinations of CSIDs and
CSID-lites.

Signed-off-by: Matti Lehtimäki <matti.lehtimaki@gmail.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: qcom: camss: Flag VFE-lites to support more VFEs
Matti Lehtimäki [Thu, 23 Nov 2023 17:03:05 +0000 (17:03 +0000)]
media: qcom: camss: Flag VFE-lites to support more VFEs

Some platforms such as SC7280 have three VFEs and two VFE-lites. Current
code has hard-coded two as the maximum number of VFEs. Remove the
hard-coded maximum number of VFEs to handle all possible combinations of
VFEs and VFE-lites.

Signed-off-by: Matti Lehtimäki <matti.lehtimaki@gmail.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202311200405.h6G4L9oe-lkp@intel.com
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: qcom: camss: Add support for named power-domains
Bryan O'Donoghue [Wed, 6 Dec 2023 12:25:00 +0000 (13:25 +0100)]
media: qcom: camss: Add support for named power-domains

Right now we use fixed indexes to assign power-domains, with a
requirement for the TOP GDSC to come last in the list.

Adding support for named power-domains means the declaration in the dtsi
can come in any order.

After this change we continue to support the old indexing - if a SoC
resource declaration or the in-use dtb doesn't declare power-domain names
we fall back to the default legacy indexing.

From this point on though new SoC additions should contain named
power-domains, eventually we will drop support for legacy indexing.

Tested-by: Matti Lehtimäki <matti.lehtimaki@gmail.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: qcom: camss: Move VFE power-domain specifics into vfe.c
Bryan O'Donoghue [Thu, 23 Nov 2023 17:03:03 +0000 (17:03 +0000)]
media: qcom: camss: Move VFE power-domain specifics into vfe.c

Moving the location of the hooks to VFE power domains has several
advantages.

1. Separation of concerns and functional decomposition.
   vfe.c should be responsible for and know best how manage
   power-domains for a VFE, excising from camss.c follows this
   principle.

2. Embedding a pointer to genpd in struct camss_vfe{} meas that we can
   dispense with a bunch of kmalloc array inside of camss.c.

3. Splitting up titan top gdsc from vfe/ife gdsc provides a base for
   breaking up magic indexes in dtsi.

Suggested-by: Matti Lehtimäki <matti.lehtimaki@gmail.com>
Tested-by: Matti Lehtimäki <matti.lehtimaki@gmail.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: qcom: camss: Use common VFE pm_domain_on/pm_domain_off where applicable
Bryan O'Donoghue [Thu, 23 Nov 2023 17:03:02 +0000 (17:03 +0000)]
media: qcom: camss: Use common VFE pm_domain_on/pm_domain_off where applicable

For the various versions of VFE we have a boiler-plate
pm_domain_on/pm_domain_off callback pair of the general form.

- Error check.
  Not always done but applicable to all.

- device_link_add (DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME |
                   DL_FLAG_RPM_ACTIVE);

- Error check returning -EINVAL on error.

- Return 0

Reduce the pattern down to a common callback. VFE 4.1 is a special case
which to me also indicates that it is worthwhile maintaining an indirection
for the vfe_pm_domain_{on|off} for now.

Otherwise lets chuck out a bunch of needlessly replicated code.

Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Suggested-by: Matti Lehtimäki <matti.lehtimaki@gmail.com>
Tested-by: Matti Lehtimäki <matti.lehtimaki@gmail.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: qcom: camss: Convert to per-VFE pointer for power-domain linkages
Bryan O'Donoghue [Thu, 23 Nov 2023 17:03:01 +0000 (17:03 +0000)]
media: qcom: camss: Convert to per-VFE pointer for power-domain linkages

Right now we use the top-level camss structure to provide pointers via
VFE id index back to genpd linkages.

In effect this hard-codes VFE indexes to power-domain indexes in the
dtsi and mandates a very particular ordering of power domains in the
dtsi, which bears no relationship to a real hardware dependency.

As a first step to rationalising the VFE power-domain code and breaking
the magic indexing in dtsi use per-VFE pointers to genpd linkages.

The top-level index in msm_vfe_subdev_init is still used to attain the
initial so no functional or logical change arises from this change.

Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Tested-by: Matti Lehtimäki <matti.lehtimaki@gmail.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: qcom: camss: Flag which VFEs require a power-domain
Bryan O'Donoghue [Thu, 23 Nov 2023 17:03:00 +0000 (17:03 +0000)]
media: qcom: camss: Flag which VFEs require a power-domain

At the moment we have some complex code for determining if a VFE requires a
power-domain attachment. Particularly discordant in this scheme is the
subtle reliance on VFE and VFE Lite declaration ordering in our resources.

VFE id is used to determine if a VFE is lite or not and consequently if a
VFE requires power-domain attachment. VFE Lite though is not a correct
delineation between power-domain and non power-domain state since early
SoCs have neither VFE Lite nor power-domains attached to VFEs.

Introduce has_pd to the VFE resource structure to allow the CAMSS code to
understand if it needs to try to attach a power-domain for a given VFE.

As a side-effect from this we no longer need to care about VFE Lite or
non-Lite or the id number associated with either and which order the
VFE/VFE Lite was declared in.

Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Tested-by: Matti Lehtimäki <matti.lehtimaki@gmail.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: stk1160: Fixed high volume of stk1160_dbg messages
Ghanshyam Agrawal [Sat, 25 Nov 2023 09:02:36 +0000 (14:32 +0530)]
media: stk1160: Fixed high volume of stk1160_dbg messages

The function stk1160_dbg gets called too many times, which causes
the output to get flooded with messages. Since stk1160_dbg uses
printk, it is now replaced with printk_ratelimited.

Suggested-by: Phillip Potter <phil@philpotter.co.uk>
Signed-off-by: Ghanshyam Agrawal <ghanshyam1898@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: cx231xx: fix a memleak in cx231xx_init_isoc
Zhipeng Lu [Fri, 1 Dec 2023 13:22:55 +0000 (21:22 +0800)]
media: cx231xx: fix a memleak in cx231xx_init_isoc

The dma_q->p_left_data alloced by kzalloc should be freed in all the
following error handling paths. However, it hasn't been freed in the
allocation error paths of dev->video_mode.isoc_ctl.urb and
dev->video_mode.isoc_ctl.transfer_buffer.

On the other hand, the dma_q->p_left_data did be freed in the
error-handling paths after that of dev->video_mode.isoc_ctl.urb and
dev->video_mode.isoc_ctl.transfer_buffer, by calling
cx231xx_uninit_isoc(dev). So the same free operation should be done in
error-handling paths of those two allocation.

Fixes: 64fbf4445526 ("[media] cx231xx: Added support for Carraera, Shelby, RDx_253S and VIDEO_GRABBER")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agostaging: media: VIDEO_STARFIVE_CAMSS should depend on ARCH_STARFIVE
Geert Uytterhoeven [Tue, 28 Nov 2023 18:31:53 +0000 (19:31 +0100)]
staging: media: VIDEO_STARFIVE_CAMSS should depend on ARCH_STARFIVE

The StarFive Camera Subsystem is only present on the StarFive JH7110
SoC.  Hence add a dependency on ARCH_STARFIVE, to prevent asking the
user about this driver when configuring a kernel without StarFive SoC
support.

Fixes: bba185d141b1 ("media: staging: media: starfive: camss: Add core driver")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Changhuang Liang <changhuang.liang@starfivetech.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: chips-media: wave5: VIDEO_WAVE_VPU should depend on ARCH_K3
Geert Uytterhoeven [Tue, 28 Nov 2023 18:26:36 +0000 (19:26 +0100)]
media: chips-media: wave5: VIDEO_WAVE_VPU should depend on ARCH_K3

The Chips&Media Wave 5 Series multi-standard codec IP is currently only
supported on Texas Instruments K3 architecture.  Hence add a dependency on
ARCH_K3, to prevent asking the user about this driver when configuring a
kernel without Texas Instruments K3 Multicore SoC support.

Fixes: 9707a6254a8a ("media: chips-media: wave5: Add the v4l2 layer")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: small update in commit log, and reformatted the Fixes tag]

9 months agomedia: staging: starfive: camss: fix off by one in isp_enum_mbus_code()
Dan Carpenter [Tue, 28 Nov 2023 14:40:14 +0000 (17:40 +0300)]
media: staging: starfive: camss: fix off by one in isp_enum_mbus_code()

These > comparisons should be >=.  The formats->fmts[] array is either
a pointer to isp_formats_sink[] or isp_formats_source[] respectively.

Fixes: e57854628f58 ("media: staging: media: starfive: camss: Add ISP driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Changhuang Liang <changhuang.liang@starfivetech.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: videobuf2-dma-sg: fix vmap callback
Michael Grzeschik [Thu, 23 Nov 2023 22:32:05 +0000 (23:32 +0100)]
media: videobuf2-dma-sg: fix vmap callback

For dmabuf import users to be able to use the vaddr from another
videobuf2-dma-sg source, the exporter needs to set a proper vaddr on
vb2_dma_sg_dmabuf_ops_vmap callback. This patch adds vmap on map if
buf->vaddr was not set.

Cc: stable@kernel.org
Fixes: 7938f4218168 ("dma-buf-map: Rename to iosys-map")
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Acked-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agodoc: media: visl: Add AV1 support
Detlev Casanova [Thu, 23 Nov 2023 15:52:26 +0000 (10:52 -0500)]
doc: media: visl: Add AV1 support

Add AV1 information in visl documentation.

Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Detlev Casanova <detlev.casanova@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: visl: Add AV1 support
Detlev Casanova [Thu, 23 Nov 2023 15:52:25 +0000 (10:52 -0500)]
media: visl: Add AV1 support

Let the visl test driver accept the AV1 pixel format.

Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Tested-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Detlev Casanova <detlev.casanova@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: exynos-gsc: remove unused improper CONFIG definition
Lukas Bulwahn [Thu, 23 Nov 2023 10:38:08 +0000 (11:38 +0100)]
media: exynos-gsc: remove unused improper CONFIG definition

Defines prefixed with "CONFIG" should be limited to proper Kconfig options,
that are introduced in a Kconfig file.

In the driver code, there is a define for CONFIG_VB2_GSC_DMA_CONTIG, but
this is not used anywhere in the code.

Just remove this unused definition.

No functional change.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: platform: mtk-mdp3: Use devicetree phandle to retrieve SCP
AngeloGioacchino Del Regno [Thu, 5 Oct 2023 10:49:05 +0000 (12:49 +0200)]
media: platform: mtk-mdp3: Use devicetree phandle to retrieve SCP

Instead of walking the entire parent node for something that has the
right compatible, use the scp_get() function provided by the MediaTek
SCP remoteproc driver to retrieve a handle to mtk_scp through the
devicetree "mediatek,scp" (phandle) property.

In case of multi-core SCP, this also allows to select a specific core.

Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: dt-bindings: mediatek: Add phandle to mediatek,scp on MDP3 RDMA
AngeloGioacchino Del Regno [Thu, 5 Oct 2023 10:49:04 +0000 (12:49 +0200)]
media: dt-bindings: mediatek: Add phandle to mediatek,scp on MDP3 RDMA

The MDP3 RDMA needs to communicate with the SCP remote processor: allow
specifying a phandle to a SCP core.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: v4l: async: Drop useless list move operation
Sebastian Reichel [Mon, 13 Nov 2023 22:57:24 +0000 (23:57 +0100)]
media: v4l: async: Drop useless list move operation

v4l2_async_unbind_subdev_one(), which is called in the line
following the list_move() operation contains list_move_tail()
for the same entry and overrides anything list_move() did.
Thus it can be removed.

Signed-off-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: v4l: async: Fix duplicated list deletion
Sebastian Reichel [Mon, 13 Nov 2023 22:57:23 +0000 (23:57 +0100)]
media: v4l: async: Fix duplicated list deletion

The list deletion call dropped here is already called from the
helper function in the line before. Having a second list_del()
call results in either a warning (with CONFIG_DEBUG_LIST=y):

list_del corruption, c46c8198->next is LIST_POISON1 (00000100)

If CONFIG_DEBUG_LIST is disabled the operation results in a
kernel error due to NULL pointer dereference.

Fixes: 28a1295795d8 ("media: v4l: async: Allow multiple connections between entities")
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: v4l2-subdev: Fix indentation in v4l2-subdev.h
Laurent Pinchart [Mon, 23 Oct 2023 18:19:22 +0000 (21:19 +0300)]
media: v4l2-subdev: Fix indentation in v4l2-subdev.h

Fix a simple indentation issue in the v4l2-subdev.h header.

Fixes: f57fa2959244 ("media: v4l2-subdev: Add new ioctl for client capabilities")
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-cisco@xs4all.nl>
9 months agomedia: ccs: Use V4L2 CCI for accessing sensor registers
Sakari Ailus [Tue, 7 Nov 2023 10:46:42 +0000 (12:46 +0200)]
media: ccs: Use V4L2 CCI for accessing sensor registers

Use V4L2 CCI for accessing device's registers. The 8-bit compatibility
read option is removed but this is supported by regmap through other
means.

Also the CCS register definitions are re-generated with V4L2 CCI
definitions. The older SMIA++ register definitions have been manually
converted.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: ccs: Better separate CCS static data access
Sakari Ailus [Tue, 7 Nov 2023 09:37:21 +0000 (11:37 +0200)]
media: ccs: Better separate CCS static data access

Separate CCS static data read-only register access in ccs-reg-access.c by
naming them differently.

The code in this file generally deals with reading and writing registers
where as static data (when it comes to ccs_static_data_read_ro_reg())
contains the read-only register values but no hardware registers are
accessed in that case.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: ccs: Generate V4L2 CCI compliant register definitions
Sakari Ailus [Tue, 7 Nov 2023 09:32:46 +0000 (11:32 +0200)]
media: ccs: Generate V4L2 CCI compliant register definitions

Generate register definitions that are fit for use with V4L2 CCI.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: v4l: cci: Add macros to obtain register width and address
Sakari Ailus [Tue, 7 Nov 2023 15:42:40 +0000 (17:42 +0200)]
media: v4l: cci: Add macros to obtain register width and address

Add CCI_REG_WIDTH() macro to obtain register width in bits and similarly,
CCI_REG_WIDTH_BYTES() to obtain it in bytes.

Also add CCI_REG_ADDR() macro to obtain the address of a register.

Use both macros in v4l2-cci.c, too.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: v4l: cci: Add driver-private bit definitions
Sakari Ailus [Tue, 7 Nov 2023 09:31:13 +0000 (11:31 +0200)]
media: v4l: cci: Add driver-private bit definitions

Provide a few bits for drivers to store private information on register
definitions.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: v4l: cci: Include linux/bits.h
Sakari Ailus [Tue, 7 Nov 2023 08:45:30 +0000 (10:45 +0200)]
media: v4l: cci: Include linux/bits.h

linux/bits.h is needed for GENMASK(). Include it.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>