Commit Graph

34681 Commits

Author SHA1 Message Date
Aymen Sghaier
eec425eff7 ILIE-70: media: nxp: neoisp: Fix default params restore after stream-off
Current driver keeps latest set parameters in buffer after a stream-off,
and next processed frame will run with non-default parameters.
This patch fixes this issue and ensures using default parameters upon
stream-on event.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Reviewed-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
Acked-by: Robert Chiras <robert.chiras@nxp.com>
2024-04-19 15:15:39 +02:00
Alexi Birlinger
f2ddb547ec ILIE-53-2: media: nxp: neoisp: Expand YUV video capture formats
Add support of the following video capture formats:
- YUVX32, VUYX32 and VYUY (interleaved)
- NV12, NV21, NV16 and NV61 (semi-planar)

Signed-off-by: Alexi Birlinger <alexi.birlinger@nxp.com>
Reviewed-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
Acked-by: Robert Chiras <robert.chiras@nxp.com>
2024-04-19 15:15:08 +02:00
Alexi Birlinger
038ac01355 ILIE-53-1: media: nxp: neoisp: Remove unsupported greyscale formats
Remove greyscale capture formats from formats_vcap struct and update
table size.
Y14 format is not supported
Y10, Y12 are not tested and will be added in the future

Signed-off-by: Alexi Birlinger <alexi.birlinger@nxp.com>
Reviewed-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
Acked-by: Robert Chiras <robert.chiras@nxp.com>
2024-04-19 15:15:08 +02:00
Alexi Birlinger
8b17ad6cdf ILIE-53: media: nxp: neoisp: Expand RGB capture format support
This patch enables BGRX32, RGBX32 and BGR24 video capture formats

Signed-off-by: Alexi Birlinger <alexi.birlinger@nxp.com>
Reviewed-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
Acked-by: Robert Chiras <robert.chiras@nxp.com>
2024-04-19 15:15:08 +02:00
Alexi Birlinger
4855fb395b ILIE-60: media: nxp: neoisp: Change default alignment for input buffers
Image buffers provided to ISP are MSB aligned, while default parameter
is set to LSB alignment.
This patch updates default parameter to be MSB aligned.

Signed-off-by: Alexi Birlinger <alexi.birlinger@nxp.com>
Reviewed-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
Acked-by: Robert Chiras <robert.chiras@nxp.com>
2024-04-19 15:15:08 +02:00
Alexi Birlinger
ea0ad75f00 ILIE-44: media: nxp: neoisp: Fix hdr decompression missing ratio
Add kneepoint_ratio4 as default ratio for pixel values being equal
or greater than declared kneepoints

Signed-off-by: Alexi Birlinger <alexi.birlinger@nxp.com>
Reviewed-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
Acked-by: Robert Chiras <robert.chiras@nxp.com>
2024-04-19 15:15:02 +02:00
Aymen Sghaier
1e57ad8adf ILIE-48: media: nxp: neoisp: Remove V4L2_SUBDEV_FL_STREAMS flag for subdevice
Current v4l2 subdevice node does not support stream/routing file ops,
while V4L2_SUBDEV_FL_STREAMS flag is set and leads to segfault when
using media-ctl with v4l-utils version 1.26.
This patch remove this flag until adding stream/routing support.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Reviewed-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
Acked-by: Robert Chiras <robert.chiras@nxp.com>
2024-04-19 14:58:57 +02:00
Aymen Sghaier
74658ebdce ILIE-25: media: nxp: neoisp: Add multiple contexts support
The driver is updating isp parameters for each processed frame, assuming
only one camera context is used.
This patch adds multiple camera contexts handling.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Reviewed-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
Acked-by: Robert Chiras <robert.chiras@nxp.com>
2024-04-19 14:57:43 +02:00
Nini Song
7611722dc5 media: cec: core: remove length check of Timer Status
commit ce5d241c3a upstream.

The valid_la is used to check the length requirements,
including special cases of Timer Status. If the length is
shorter than 5, that means no Duration Available is returned,
the message will be forced to be invalid.

However, the description of Duration Available in the spec
is that this parameter may be returned when these cases, or
that it can be optionally return when these cases. The key
words in the spec description are flexible choices.

Remove the special length check of Timer Status to fit the
spec which is not compulsory about that.

Signed-off-by: Nini Song <nini.song@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-04-17 11:19:26 +02:00
Mirela Rabulea
cec4700deb LF-11503-5: media: os08a20: Implement .get_frame_desc subdev callback
In order to provide the virtual channel and the CSI data type,
implement the .get_frame_desc() operation.

Signed-off-by: Mirela Rabulea <mirela.rabulea@nxp.com>
Reviewed-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
2024-04-14 19:57:50 +03:00
Mirela Rabulea
3e96822777 MLK-26180: media: nxp: imx8-isi: Fix potential null pointer dereference
Fix mxc_isi_get_frame_desc(), in case the subdevice get_frame_desc
returns success, but the stream is not found in source_fd.

Fixes: 438ca0fc316b ("LF-11234-07: media: nxp: imx8-isi: Implement .get_frame_desc subdev callback")

Signed-off-by: Mirela Rabulea <mirela.rabulea@nxp.com>
Reviewed-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
2024-04-14 19:56:37 +03:00
Mirela Rabulea
3e050005f8 LF-11503-1: media: nxp: dwc-mipi-csi2: Set default VC and DT in CSI when no get_frame_desc
In order to support sensors that do not implement yet the
get_frame_desc(), do not fail, but provide a default virtual
channel and data type for the CSI.

Fixes: a01abbceaf9d ("LF-11234-03: media: nxp: dwc-mipi-csi2: Implement multi frame description")

Signed-off-by: Mirela Rabulea <mirela.rabulea@nxp.com>
Reviewed-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
2024-04-14 19:55:20 +03:00
Yunfei Dong
41671f0c01 media: mediatek: vcodec: adding lock to protect encoder context list
[ Upstream commit afaaf3a0f6 ]

Add a lock for the ctx_list, to avoid accessing a NULL pointer
within the 'vpu_enc_ipi_handler' function when the ctx_list has
been deleted due to an unexpected behavior on the SCP IP block.

Fixes: 1972e32431 ("media: mediatek: vcodec: Fix possible invalid memory access for encoder")
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: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-13 13:07:40 +02:00
Yunfei Dong
0a2dc707aa media: mediatek: vcodec: adding lock to protect decoder context list
[ Upstream commit 6467cda18c ]

Add a lock for the ctx_list, to avoid accessing a NULL pointer
within the 'vpu_dec_ipi_handler' function when the ctx_list has
been deleted due to an unexpected behavior on the SCP IP block.

Hardware name: Google juniper sku16 board (DT)
pstate: 20400005 (nzCv daif +PAN -UAO -TCO BTYPE=--)
pc : vpu_dec_ipi_handler+0x58/0x1f8 [mtk_vcodec_dec]
lr : scp_ipi_handler+0xd0/0x194 [mtk_scp]
sp : ffffffc0131dbbd0
x29: ffffffc0131dbbd0 x28: 0000000000000000
x27: ffffff9bb277f348 x26: ffffff9bb242ad00
x25: ffffffd2d440d3b8 x24: ffffffd2a13ff1d4
x23: ffffff9bb7fe85a0 x22: ffffffc0133fbdb0
x21: 0000000000000010 x20: ffffff9b050ea328
x19: ffffffc0131dbc08 x18: 0000000000001000
x17: 0000000000000000 x16: ffffffd2d461c6e0
x15: 0000000000000242 x14: 000000000000018f
x13: 000000000000004d x12: 0000000000000000
x11: 0000000000000001 x10: fffffffffffffff0
x9 : ffffff9bb6e793a8 x8 : 0000000000000000
x7 : 0000000000000000 x6 : 000000000000003f
x5 : 0000000000000040 x4 : fffffffffffffff0
x3 : 0000000000000020 x2 : ffffff9bb6e79080
x1 : 0000000000000010 x0 : ffffffc0131dbc08
Call trace:
vpu_dec_ipi_handler+0x58/0x1f8 [mtk_vcodec_dec (HASH:6c3f 2)]
scp_ipi_handler+0xd0/0x194 [mtk_scp (HASH:7046 3)]
mt8183_scp_irq_handler+0x44/0x88 [mtk_scp (HASH:7046 3)]
scp_irq_handler+0x48/0x90 [mtk_scp (HASH:7046 3)]
irq_thread_fn+0x38/0x94
irq_thread+0x100/0x1c0
kthread+0x140/0x1fc
ret_from_fork+0x10/0x30
Code: 54000088 f94ca50a eb14015f 54000060 (f9400108)
---[ end trace ace43ce36cbd5c93 ]---
Kernel panic - not syncing: Oops: Fatal exception
SMP: stopping secondary CPUs
Kernel Offset: 0x12c4000000 from 0xffffffc010000000
PHYS_OFFSET: 0xffffffe580000000
CPU features: 0x08240002,2188200c
Memory Limit: none

Fixes: 655b86e52e ("media: mediatek: vcodec: Fix possible invalid memory access for 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: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-13 13:07:40 +02:00
Nicolas Dufresne
ec25fc3c2c media: mediatek: vcodec: Fix oops when HEVC init fails
[ Upstream commit 97c75ee5de ]

The stateless HEVC decoder saves the instance pointer in the context
regardless if the initialization worked or not. This caused a use after
free, when the pointer is freed in case of a failure in the deinit
function.
Only store the instance pointer when the initialization was successful,
to solve this issue.

 Hardware name: Acer Tomato (rev3 - 4) board (DT)
 pstate: 80400009 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
 pc : vcodec_vpu_send_msg+0x4c/0x190 [mtk_vcodec_dec]
 lr : vcodec_send_ap_ipi+0x78/0x170 [mtk_vcodec_dec]
 sp : ffff80008750bc20
 x29: ffff80008750bc20 x28: ffff1299f6d70000 x27: 0000000000000000
 x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000
 x23: ffff80008750bc98 x22: 000000000000a003 x21: ffffd45c4cfae000
 x20: 0000000000000010 x19: ffff1299fd668310 x18: 000000000000001a
 x17: 000000040044ffff x16: ffffd45cb15dc648 x15: 0000000000000000
 x14: ffff1299c08da1c0 x13: ffffd45cb1f87a10 x12: ffffd45cb2f5fe80
 x11: 0000000000000001 x10: 0000000000001b30 x9 : ffffd45c4d12b488
 x8 : 1fffe25339380d81 x7 : 0000000000000001 x6 : ffff1299c9c06c00
 x5 : 0000000000000132 x4 : 0000000000000000 x3 : 0000000000000000
 x2 : 0000000000000010 x1 : ffff80008750bc98 x0 : 0000000000000000
 Call trace:
  vcodec_vpu_send_msg+0x4c/0x190 [mtk_vcodec_dec]
  vcodec_send_ap_ipi+0x78/0x170 [mtk_vcodec_dec]
  vpu_dec_deinit+0x1c/0x30 [mtk_vcodec_dec]
  vdec_hevc_slice_deinit+0x30/0x98 [mtk_vcodec_dec]
  vdec_if_deinit+0x38/0x68 [mtk_vcodec_dec]
  mtk_vcodec_dec_release+0x20/0x40 [mtk_vcodec_dec]
  fops_vcodec_release+0x64/0x118 [mtk_vcodec_dec]
  v4l2_release+0x7c/0x100
  __fput+0x80/0x2d8
  __fput_sync+0x58/0x70
  __arm64_sys_close+0x40/0x90
  invoke_syscall+0x50/0x128
  el0_svc_common.constprop.0+0x48/0xf0
  do_el0_svc+0x24/0x38
  el0_svc+0x38/0xd8
  el0t_64_sync_handler+0xc0/0xc8
  el0t_64_sync+0x1a8/0x1b0
 Code: d503201f f9401660 b900127f b900227f (f9400400)

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Fixes: 2674486aac ("media: mediatek: vcodec: support stateless hevc decoder")
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-13 13:07:40 +02:00
Arnd Bergmann
cb9420142e media: sta2x11: fix irq handler cast
[ Upstream commit 3de49ae81c ]

clang-16 warns about casting incompatible function pointers:

drivers/media/pci/sta2x11/sta2x11_vip.c:1057:6: error: cast from 'irqreturn_t (*)(int, struct sta2x11_vip *)' (aka 'enum irqreturn (*)(int, struct sta2x11_vip *)') to 'irq_handler_t' (aka 'enum irqreturn (*)(int, void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]

Change the prototype of the irq handler to the regular version with a
local variable to adjust the argument type.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: update argument documentation]
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-13 13:07:35 +02:00
Guoniu.zhou
f02a70ea4e LF-11913: media: imx8-isi: fix invalid frame description issue
For iMX95, the stream configurations are moved to csi formatter from
gasket enable/disable callback and only leave ISI QoS setting. When
enable multiple stream support in ISI driver, it will get multiple
frame description entity from remote subdev, but for gasket, only
need be called once, so remove the checking for the number of frame
description entity and use the first stream for single camera platform.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
2024-04-12 17:29:53 +08:00
Laurentiu Palcu
6a03b4c555 LF-11414-8 media/i2c: add support for mx95mbcam camera module
This is a NXP camera module containing a MAX96717F serializer chip and
an OX03C10 Omnivision sensor.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Reviewed-by: Robert Chiras <robert.chiras@nxp.com>
Reviewed-by: Mirela Rabulea <Mirela.rabulea@nxp.com>
2024-04-11 08:37:59 +00:00
Laurentiu Palcu
cb1389d3f3 LF-11414-7 media/i2c: add ox03c10 camera sensor library
The OX03C10 is 1/2.6" optical format, 1920x1280 stacked-chip digital
high dynamic range sensor intended for high-end CMS and SVS application
for the automotive market.

This is the library supporting the chip and will be used by module
drivers that usually contain a serializer and a sensor.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Reviewed-by: Robert Chiras <robert.chiras@nxp.com>
Reviewed-by: Mirela Rabulea <Mirela.rabulea@nxp.com>
2024-04-11 08:37:59 +00:00
Laurentiu Palcu
23ceb31ee0 LF-11414-6 media/i2c: add max96717 chip library
The MAX96717F GMSL serializer receives video on a MIPI CSI-2 interface
and outputs it on a GMSL2 serial link transceiver.

This is just a library that will be used by camera modules drivers that
usually contain a serializer and a camera sensor.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Reviewed-by: Robert Chiras <robert.chiras@nxp.com>
Reviewed-by: Mirela Rabulea <Mirela.rabulea@nxp.com>
2024-04-11 08:37:59 +00:00
Laurentiu Palcu
ad6c1bb4d0 LF-11414-4 media/i2c: add support for MAX96724 deserializer chip
The MAX96724/F/R deserializer converts four GMSL2/1 inputs to 1, 2, or 4
MIPI D-PHY or C-PHY outputs. The device allows simultaneous transmit
bidirectional transmissions over 50ohm coax or 100ohm STP cables that meet
the GMSL channel specification.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Reviewed-by: Robert Chiras <robert.chiras@nxp.com>
Reviewed-by: Mirela Rabulea <Mirela.rabulea@nxp.com>
2024-04-11 08:37:59 +00:00
Laurentiu Palcu
142920ec88 LF-11414-3 media/platform/nxp: imx8-isi: add 16bit raw formats support
We will need RAW16 formats for the OX03C10 cameras.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Reviewed-by: Robert Chiras <robert.chiras@nxp.com>
Reviewed-by: G.N. Zhou <guoniu.zhou@nxp.com>
Reviewed-by: Mirela Rabulea <Mirela.rabulea@nxp.com>
2024-04-11 08:37:59 +00:00
Laurentiu Palcu
f06eedea02 LF-11414-2 media/platform/nxp: imx-csi-formatter: add RAW16 support
The CSI controller and pixel formatter supports RAW16 as well. Add it.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Reviewed-by: Robert Chiras <robert.chiras@nxp.com>
Reviewed-by: G.N. Zhou <guoniu.zhou@nxp.com>
Reviewed-by: Mirela Rabulea <Mirela.rabulea@nxp.com>
2024-04-11 08:37:59 +00:00
Laurentiu Palcu
a115bfbfa4 LF-11414-1 media/platform/nxp: dwc-mipi-csi2: add support for RAW 16bit formats
The 16bit RAW formats will be needed for the OX03C10 camera sensor.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Reviewed-by: Robert Chiras <robert.chiras@nxp.com>
Reviewed-by: G.N. Zhou <guoniu.zhou@nxp.com>
Reviewed-by: Mirela Rabulea <Mirela.rabulea@nxp.com>
2024-04-11 08:37:59 +00:00
Guoniu.zhou
b588873215 LF-11655: media: i2c: ap130x: add scaling support
AP1302 is an external ISP which can support scaling. User can use
this feature to reach 1080P@60 since the maximum size output by
AR0144 sensor is 1280x800.

How to set scaling:
$ media-ctl -V "'ap130x.2-003c':2 [fmt:UYVY8_1X16/1920x1080 field:none]"

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2024-04-08 11:25:51 +08:00
Guoniu.zhou
f5926e028e LF-11653-02: media: i2c: ap130x: remove ADV_IRQ_SYS_INTE register setting
Remove ADV_IRQ_SYS_INTE register setting when enable stream, otherwise
data lanes changing won't take effect. I can't find any description
about the register in AP1302 data sheet. I'm asking Onsemi for help.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2024-04-08 11:25:51 +08:00
Guoniu.zhou
c2d0ac5b4e LF-11233: media: i2c: ap130x: Implement .get_frame_desc subdev callback
Implement .get_frame_desc subdev callback.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2024-04-08 11:25:50 +08:00
Guoniu.zhou
8d1a3591dd LF-11234-07: media: nxp: imx8-isi: Implement .get_frame_desc subdev callback
Implement .get_frame_desc subdev callback for ISI.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Tested-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2024-04-08 11:25:50 +08:00
Guoniu.zhou
84dfe1bc31 LF-11234-06: media: nxp: imx8-isi: add virtual channel support
ISI of iMX95 can handle 8 virtual channel and only process the data
from pixel link which virtual channel ID number matched. It gets the
number from remote connected subdev, so it can handler 8 different
independent camera stream.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Tested-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2024-04-08 11:25:50 +08:00
Guoniu.zhou
10fc626a62 LF-11234-05: media: nxp: imx8-isi: add ISI stream duplicated support
ISI support duplicate input stream into multiple outputs,
but v4l2 subdev stream only can be enabled/disabled one
time, so return zero directly for input stream which has
been enabled or disabled.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Tested-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2024-04-08 11:25:50 +08:00
Guoniu.zhou
081e0820af LF-11234-04: media: nxp: dwc-mipi-csi2: Add multiplexed streams support
Add multiplexed streams support for DesignWare MIPI CSI-2 driver.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Tested-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2024-04-08 11:25:50 +08:00
Guoniu.zhou
34520c46ad LF-11234-03: media: nxp: dwc-mipi-csi2: Implement multi frame description
Implement multi frame description since its input may have
multiple stream, not only single one.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Tested-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2024-04-08 11:25:50 +08:00
Guoniu.zhou
aa2cafeee7 LF-11234-02: media: nxp: dwc-mipi-csi2: Rename sensor_sd to source_sd
Rename sensor_sd to source_sd since the input of MIPI CSI-2
maybe other bridge device, such as deserilizer, so the name
source_sd for the remote connected subdev should be better.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Tested-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2024-04-08 11:25:50 +08:00
Guoniu.zhou
d1eb6606b9 LF-11234-01: media: nxp: dwc-mipi-csi2: fix resources uncleaned issue
Some resources are not cleaned when error happened, fix them.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Tested-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2024-04-08 11:25:50 +08:00
Guoniu.zhou
dd701628d6 LF-10853-04: media: nxp: imx8-isi: remove gasket support for iMX95
The gasket operations are used to control csi pixel formatter, remove
it since a new driver for pixel formatter has been added.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2024-04-08 11:25:50 +08:00
Guoniu.zhou
f261ddc3d1 LF-10853-03: media: nxp: add v4l2 subdev driver for csi pixel formatter
The CSI2 pixel formatter is a module which can uses packet info, pixel
and non-pixel data from the CSI2 host controller and reformat them to
match Pixel Link (PL) definition. In addition, optionally, it can either
route non-pixel data or one of pixel data type to another pixel link
virtual channel.

So add a V4L2 subdev driver for it since it's a standalone module and
need to export more controls to userspace.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2024-04-08 11:25:50 +08:00
Laurent Pinchart
88efc3095b media: nxp: imx8-isi: Mark all crossbar sink pads as MUST_CONNECT
[ Upstream commit 9b71021b2e ]

All the sink pads of the crossbar switch require an active link if
they're part of the pipeline. Mark them with the
MEDIA_PAD_FL_MUST_CONNECT flag to fail pipeline validation if they're
not connected. This allows removing a manual check when translating
streams.

Cc: stable@vger.kernel.org # 6.1
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-03 15:28:18 +02:00
Laurent Pinchart
d0e3440dab media: mc: Expand MUST_CONNECT flag to always require an enabled link
[ Upstream commit b3decc5ce7 ]

The MEDIA_PAD_FL_MUST_CONNECT flag indicates that the pad requires an
enabled link to stream, but only if it has any link at all. This makes
little sense, as if a pad is part of a pipeline, there are very few use
cases for an active link to be mandatory only if links exist at all. A
review of in-tree drivers confirms they all need an enabled link for
pads marked with the MEDIA_PAD_FL_MUST_CONNECT flag.

Expand the scope of the flag by rejecting pads that have no links at
all. This requires modifying the pipeline build code to add those pads
to the pipeline.

Cc: stable@vger.kernel.org # 6.1
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-03 15:28:17 +02:00
Laurent Pinchart
3b6ccc91dc media: mc: Rename pad variable to clarify intent
[ Upstream commit 9ec9109cf9 ]

The pad local variable in the media_pipeline_explore_next_link()
function is used to store the pad through which the entity has been
reached. Rename it to origin to reflect that and make the code easier to
read. This will be even more important in subsequent commits when
expanding the function with additional logic.

Cc: stable@vger.kernel.org # 6.1
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-03 15:28:17 +02:00
Laurent Pinchart
ebb6fb7f62 media: mc: Add num_links flag to media_pad
[ Upstream commit baeddf94aa ]

Maintain a counter of the links connected to a pad in the media_pad
structure. This helps checking if a pad is connected to anything, which
will be used in the pipeline building code.

Cc: stable@vger.kernel.org # 6.1
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-03 15:28:17 +02:00
Marek Vasut
c95318607f media: nxp: imx8-isi: Check whether crossbar pad is non-NULL before access
[ Upstream commit eb2f932100 ]

When translating source to sink streams in the crossbar subdev, the
driver tries to locate the remote subdev connected to the sink pad. The
remote pad may be NULL, if userspace tries to enable a stream that ends
at an unconnected crossbar sink. When that occurs, the driver
dereferences the NULL pad, leading to a crash.

Prevent the crash by checking if the pad is NULL before using it, and
return an error if it is.

Cc: stable@vger.kernel.org # 6.1
Fixes: cf21f328fc ("media: nxp: Add i.MX8 ISI driver")
Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/r/20231201150614.63300-1-marex@denx.de
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-03 15:28:17 +02:00
Laurent Pinchart
0a76902247 media: mc: Fix flags handling when creating pad links
[ Upstream commit 422f7af75d ]

The media_create_pad_link() function doesn't correctly clear reject link
type flags, nor does it set the DATA_LINK flag. It only works because
the MEDIA_LNK_FL_DATA_LINK flag's value is 0.

Fix it by returning an error if any link type flag is set. This doesn't
introduce any regression, as nobody calls the media_create_pad_link()
function with link type flags (easily checked by grepping for the flag
in the source code, there are very few hits).

Set the MEDIA_LNK_FL_DATA_LINK explicitly, which is a no-op that the
compiler will optimize out, but is still useful to make the code more
explicit and easier to understand.

Cc: stable@vger.kernel.org # 6.1
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-03 15:28:17 +02:00
Laurent Pinchart
cc088ebf8b media: mc: Add local pad to pipeline regardless of the link state
[ Upstream commit 78f0daa026 ]

When building pipelines by following links, the
media_pipeline_explore_next_link() function only traverses enabled
links. The remote pad of a disabled link is not added to the pipeline,
and neither is the local pad. While the former is correct as disabled
links should not be followed, not adding the local pad breaks processing
of the MEDIA_PAD_FL_MUST_CONNECT flag.

The MEDIA_PAD_FL_MUST_CONNECT flag is checked in the
__media_pipeline_start() function that iterates over all pads after
populating the pipeline. If the pad is not present, the check gets
skipped, rendering it useless.

Fix this by adding the local pad of all links regardless of their state,
only skipping the remote pad for disabled links.

Cc: stable@vger.kernel.org # 6.1
Fixes: ae21987283 ("media: mc: entity: Rewrite media_pipeline_start()")
Reported-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Closes: https://lore.kernel.org/linux-media/7658a15a-80c5-219f-2477-2a94ba6c6ba1@kontron.de
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-03 15:28:17 +02:00
Gui-Dong Han
dc5e4f2404 media: xc4000: Fix atomicity violation in xc4000_get_frequency
[ Upstream commit 36d503ad54 ]

In xc4000_get_frequency():
	*freq = priv->freq_hz + priv->freq_offset;
The code accesses priv->freq_hz and priv->freq_offset without holding any
lock.

In xc4000_set_params():
	// Code that updates priv->freq_hz and priv->freq_offset
	...

xc4000_get_frequency() and xc4000_set_params() may execute concurrently,
risking inconsistent reads of priv->freq_hz and priv->freq_offset. Since
these related data may update during reading, it can result in incorrect
frequency calculation, leading to atomicity violations.

This possible bug is found by an experimental static analysis tool
developed by our team, BassCheck[1]. This tool analyzes the locking APIs
to extract function pairs that can be concurrently executed, and then
analyzes the instructions in the paired functions to identify possible
concurrency bugs including data races and atomicity violations. The above
possible bug is reported when our tool analyzes the source code of
Linux 6.2.

To address this issue, it is proposed to add a mutex lock pair in
xc4000_get_frequency() to ensure atomicity. With this patch applied, our
tool no longer reports the possible bug, with the kernel configuration
allyesconfig for x86_64. Due to the lack of associated hardware, we cannot
test the patch in runtime testing, and just verify it according to the
code logic.

[1] https://sites.google.com/view/basscheck/

Fixes: 4c07e32884 ("[media] xc4000: Fix get_frequency()")
Cc: stable@vger.kernel.org
Reported-by: BassCheck <bass@buaa.edu.cn>
Signed-off-by: Gui-Dong Han <2045gemini@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-03 15:28:17 +02:00
Ming Qian
168cffba43 media: amphion: Abort vpu parsing directly in seek
Driver abort vpu decoding when both output and capture queues are off,
but if seek in parsing the sequence header, driver may miss aborting the
parsing. so just abort the vpu parsing directly in seek.

Meanwhile if capture is off unexpectedly, we still need to abort the
decoding and return capture buffers.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2024-04-01 15:21:33 +09:00
Ming Qian
69bd9bfd4e media: imx-jpeg: Support for negotiating bytesperline with client
This mxc-jpeg driver doesn't allow the client to set the bytesperline,
but for some android cts case, it need to negotiate the bytesperline
between decoder and display, and fail the case if driver doesn't support
negotiating bytesperline

The jpegdec and jpegenc does support to set bytesperline which is
multiple of 2, and greater than the value calulated by driver.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2024-04-01 15:21:33 +09:00
Peng Fan
b4ebd56fb4 LF-11722 Update copyright for scmi and isi
Add NXP Copyright following patch creation time.

Reviewed-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
2024-04-01 14:04:08 +08:00
Alice Yuan
48a6b3a7dd LF-11619-3: capture: csi : remove unused clocks for mipi csi
As ic ticket TKT0639003 describes, the CSI1_PHY_REF clock (named "phy_clk"
in driver) is unused for imx8mm CSI. However other platforms like iMX7D
still requires "phy_clk", use devm_clk_get_optional() instead.

Test command:
gst-launch-1.0 -v v4l2src device=/dev/video1 num-buffers=20 !
"video/x-raw,format=YUY2,width=1920,height=1080" ! queue ! filesink
location=/home/root/video.yuyv &

Signed-off-by: Alice Yuan <alice.yuan@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2024-04-01 13:57:18 +08:00
Jason Liu
039a4cdb2c Linux 6.6.23
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE4n5dijQDou9mhzu83qZv95d3LNwFAmYDTh8ACgkQ3qZv95d3
 LNzBbhAAwSqAoBZBxApda8QQEVvF012dZG0btn0wJv2H3Bu8wasAhfD2pD5LxFZf
 Ru3EVgrBeupMKhZk/aeN5d2qSxn5mCiU4WnAwqDvjtsIicjmeeRaqcGGFFmZ6TyM
 KrK+NjxHu77L6dlkMZRLRugP/7WGGUI3G0fGj2HvJOlMRFHJSx8o4JeX1Yc10xDz
 MbySZBj4ZctjvP16dxehA44Grw08CTxnoPgrHn52TgncLGuQfcx+w+fXEDJfdRzP
 vS8D+8C4G8iwjyfKLnb/jytZR0jlVii3DkQXcIjUzGRQ4UEhfzvSn9C07zu80cPV
 iskQCo/IS1/2gD5M6OgVOjfR0yfF/NCOm692omEH6oQHjNu6QOxM2PpFpIYzm34r
 /4wnTMg58AMsNGp/D5bipl3X5B93pWDoCLq939ZU9688EaR1n/Xsh5+EXG0lKIux
 Eb4tk2z7zJt54/UQM+J2qhtJrqriflSl1dTBxpuZb2abUrq5ewQgNyqhb0hXBc5f
 F5SU5O+dkntQGcUQ1GBSWk5B5q8oXmqY9reIeuhhRYI0w0Y+Xt+jeQHhQSU0j7ne
 DLv5uG32HTR9p8z1jidJJY8VL3MuCpMzrfFkZsEUEut0haF8FhpGIxZ+YjNYcgRt
 f57z1Sf5Gzr+fpM1q8TesHI8+7MEh7Fel+elyWpvnidJfMNx4t8=
 =mu/j
 -----END PGP SIGNATURE-----

Merge tag 'v6.6.23' into lf-6.6.y

Linux 6.6.23

* tag 'v6.6.23': (630 commits)
  Linux 6.6.23
  x86/efistub: Don't clear BSS twice in mixed mode
  x86/efistub: Clear decompressor BSS in native EFI entrypoint
  ...

Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>

 Conflicts:
	arch/arm64/boot/dts/freescale/imx8mp-evk.dts
	drivers/gpio/Kconfig
	drivers/spi/spi-imx.c
2024-04-01 11:00:10 +08:00
Arnd Bergmann
7334b815d2 media: mediatek: vcodec: avoid -Wcast-function-type-strict warning
[ Upstream commit bfb1b99802 ]

The ipi handler here tries hard to maintain const-ness of its argument,
but by doing that causes a warning about function type casts:

drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c:38:32: error: cast from 'mtk_vcodec_ipi_handler' (aka 'void (*)(void *, unsigned int, void *)') to 'ipi_handler_t' (aka 'void (*)(const void *, unsigned int, void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
   38 |         ipi_handler_t handler_const = (ipi_handler_t)handler;
      |                                       ^~~~~~~~~~~~~~~~~~~~~~

Remove the hack and just use a non-const argument.

Fixes: bf1d556ad4 ("media: mtk-vcodec: abstract firmware interface")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:53 -04:00
Zhipeng Lu
7393c681f9 media: ttpci: fix two memleaks in budget_av_attach
[ Upstream commit d0b07f712b ]

When saa7146_register_device and saa7146_vv_init fails, budget_av_attach
should free the resources it allocates, like the error-handling of
ttpci_budget_init does. Besides, there are two fixme comment refers to
such deallocations.

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:53 -04:00
Zhipeng Lu
f31c1cc374 media: go7007: fix a memleak in go7007_load_encoder
[ Upstream commit b9b683844b ]

In go7007_load_encoder, bounce(i.e. go->boot_fw), is allocated without
a deallocation thereafter. After the following call chain:

saa7134_go7007_init
  |-> go7007_boot_encoder
        |-> go7007_load_encoder
  |-> kfree(go)

go is freed and thus bounce is leaked.

Fixes: 95ef39403f ("[media] go7007: remember boot firmware")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:53 -04:00
Arnd Bergmann
8fad9c5bb0 media: dvb-frontends: avoid stack overflow warnings with clang
[ Upstream commit 7a4cf27d1f ]

A previous patch worked around a KASAN issue in stv0367, now a similar
problem showed up with clang:

drivers/media/dvb-frontends/stv0367.c:1222:12: error: stack frame size (3624) exceeds limit (2048) in 'stv0367ter_set_frontend' [-Werror,-Wframe-larger-than]
 1214 | static int stv0367ter_set_frontend(struct dvb_frontend *fe)

Rework the stv0367_writereg() function to be simpler and mark both
register access functions as noinline_for_stack so the temporary
i2c_msg structures do not get duplicated on the stack when KASAN_STACK
is enabled.

Fixes: 3cd890dbe2 ("media: dvb-frontends: fix i2c access helpers for KASAN")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:53 -04:00
Edward Adam Davis
8e60b99f6b media: pvrusb2: fix uaf in pvr2_context_set_notify
[ Upstream commit 0a0b79ea55 ]

[Syzbot reported]
BUG: KASAN: slab-use-after-free in pvr2_context_set_notify+0x2c4/0x310 drivers/media/usb/pvrusb2/pvrusb2-context.c:35
Read of size 4 at addr ffff888113aeb0d8 by task kworker/1:1/26

CPU: 1 PID: 26 Comm: kworker/1:1 Not tainted 6.8.0-rc1-syzkaller-00046-gf1a27f081c1f #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
Workqueue: usb_hub_wq hub_event
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0xc4/0x620 mm/kasan/report.c:488
 kasan_report+0xda/0x110 mm/kasan/report.c:601
 pvr2_context_set_notify+0x2c4/0x310 drivers/media/usb/pvrusb2/pvrusb2-context.c:35
 pvr2_context_notify drivers/media/usb/pvrusb2/pvrusb2-context.c:95 [inline]
 pvr2_context_disconnect+0x94/0xb0 drivers/media/usb/pvrusb2/pvrusb2-context.c:272

Freed by task 906:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:47
kasan_save_track+0x14/0x30 mm/kasan/common.c:68
kasan_save_free_info+0x3f/0x60 mm/kasan/generic.c:640
poison_slab_object mm/kasan/common.c:241 [inline]
__kasan_slab_free+0x106/0x1b0 mm/kasan/common.c:257
kasan_slab_free include/linux/kasan.h:184 [inline]
slab_free_hook mm/slub.c:2121 [inline]
slab_free mm/slub.c:4299 [inline]
kfree+0x105/0x340 mm/slub.c:4409
pvr2_context_check drivers/media/usb/pvrusb2/pvrusb2-context.c:137 [inline]
pvr2_context_thread_func+0x69d/0x960 drivers/media/usb/pvrusb2/pvrusb2-context.c:158

[Analyze]
Task A set disconnect_flag = !0, which resulted in Task B's condition being met
and releasing mp, leading to this issue.

[Fix]
Place the disconnect_flag assignment operation after all code in pvr2_context_disconnect()
to avoid this issue.

Reported-and-tested-by: syzbot+ce750e124675d4599449@syzkaller.appspotmail.com
Fixes: e5be15c638 ("V4L/DVB (7711): pvrusb2: Fix race on module unload")
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:53 -04:00
Alexander Stein
81d998e183 media: i2c: imx290: Fix IMX920 typo
[ Upstream commit 6fc62efa26 ]

Replace IMX920 by IMX290.

Fixes: b4ab57b07c ("media: i2c: imx290: Add crop selection targets support")
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:51 -04:00
Sakari Ailus
069e1bd0ad media: ivsc: csi: Swap SINK and SOURCE pads
[ Upstream commit 48f5fd8967 ]

This patch swaps SINK and SOURCE pads of the MEI CSI sub-device. While
this does change the UAPI by swapping the pads, the driver has never been
usable in upstream kernel as the Intel IPU6 driver it depends on any
functionality has not yet been merged.

Fixes: 29006e196a ("media: pci: intel: ivsc: Add CSI submodule")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:51 -04:00
Arnd Bergmann
5b8d21f7ed media: pvrusb2: fix pvr2_stream_callback casts
[ Upstream commit 30baa4a96b ]

clang-16 complains about a control flow integrity (KCFI) issue in pvrusb2,
which casts three different prototypes into pvr2_stream_callback:

drivers/media/usb/pvrusb2/pvrusb2-v4l2.c:1070:30: error: cast from 'void (*)(struct pvr2_v4l2_fh *)' to 'pvr2_stream_callback' (aka 'void (*)(void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
 1070 |         pvr2_stream_set_callback(sp,(pvr2_stream_callback)pvr2_v4l2_notify,fh);
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/usb/pvrusb2/pvrusb2-context.c:110:6: error: cast from 'void (*)(struct pvr2_context *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
  110 |                                         (void (*)(void *))pvr2_context_notify,
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/usb/pvrusb2/pvrusb2-dvb.c:152:6: error: cast from 'void (*)(struct pvr2_dvb_adapter *)' to 'pvr2_stream_callback' (aka 'void (*)(void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
  152 |                                  (pvr2_stream_callback) pvr2_dvb_notify, adap);
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Change the functions to actually take a void* argument so the cast is no longer
needed.

Fixes: bb8ce9d914 ("V4L/DVB (7682): pvrusb2-dvb: finish up stream & buffer handling")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:49 -04:00
Daniil Dulov
1ff1f8c388 media: pvrusb2: remove redundant NULL check
[ Upstream commit 95ac1210fb ]

Pointer dip->stream cannot be NULL due to a shift, thus remove redundant
NULL check.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: c74e006268 ("V4L/DVB (5059): Pvrusb2: Be smarter about mode restoration")
Signed-off-by: Daniil Dulov <d.dulov@aladdin.ru>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:49 -04:00
Daniil Dulov
79159e7c48 media: go7007: add check of return value of go7007_read_addr()
[ Upstream commit 0b70530ee7 ]

If go7007_read_addr() returns error channel is not assigned a value.
In this case go to allocfail.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 866b8695d6 ("Staging: add the go7007 video driver")
Signed-off-by: Daniil Dulov <d.dulov@aladdin.ru>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:49 -04:00
Jernej Skrabec
8b50270c4a media: sun8i-di: Fix chroma difference threshold
[ Upstream commit 856525e8db ]

While there is no good explanation what this value does, vendor driver
uses value 31 for it. Align driver with it.

Fixes: a4260ea495 ("media: sun4i: Add H3 deinterlace driver")
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:49 -04:00
Jernej Skrabec
9fd05afd5e media: sun8i-di: Fix power on/off sequences
[ Upstream commit cff104e33b ]

According to user manual, reset line should be deasserted before clocks
are enabled. Also fix power down sequence to be reverse of that.

Fixes: a4260ea495 ("media: sun4i: Add H3 deinterlace driver")
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:49 -04:00
Jernej Skrabec
5e56f933d2 media: sun8i-di: Fix coefficient writes
[ Upstream commit 794b581f8c ]

Currently coefficients are applied only once, since they don't change.
However, this is done before enable bit is set and thus it doesn't get
applied properly.

Fix that by applying coefficients after enable bit is set. While this
means that it will be done evey time, it doesn't bring much time
penalty.

Fixes: a4260ea495 ("media: sun4i: Add H3 deinterlace driver")
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:49 -04:00
Zhipeng Lu
779e8db7ef media: edia: dvbdev: fix a use-after-free
[ Upstream commit 8c64f4cdf4 ]

In dvb_register_device, *pdvbdev is set equal to dvbdev, which is freed
in several error-handling paths. However, *pdvbdev is not set to NULL
after dvbdev's deallocation, causing use-after-frees in many places,
for example, in the following call chain:

budget_register
  |-> dvb_dmxdev_init
        |-> dvb_register_device
  |-> dvb_dmxdev_release
        |-> dvb_unregister_device
              |-> dvb_remove_device
                    |-> dvb_device_put
                          |-> kref_put

When calling dvb_unregister_device, dmxdev->dvbdev (i.e. *pdvbdev in
dvb_register_device) could point to memory that had been freed in
dvb_register_device. Thereafter, this pointer is transferred to
kref_put and triggering a use-after-free.

Link: https://lore.kernel.org/linux-media/20240203134046.3120099-1-alexious@zju.edu.cn
Fixes: b619010247 ("V4L/DVB (5244): Dvbdev: fix illegal re-usage of fileoperations struct")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:45 -04:00
Zhipeng Lu
90029b9c97 media: v4l2-mem2mem: fix a memleak in v4l2_m2m_register_entity
[ Upstream commit 8f94b49a5b ]

The entity->name (i.e. name) is allocated in v4l2_m2m_register_entity
but isn't freed in its following error-handling paths. This patch
adds such deallocation to prevent memleak of entity->name.

Fixes: be2fff6563 ("media: add helpers for memory-to-memory media controller")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:45 -04:00
Zhipeng Lu
4c86c772fe media: v4l2-tpg: fix some memleaks in tpg_alloc
[ Upstream commit 8cf9c50510 ]

In tpg_alloc, resources should be deallocated in each and every
error-handling paths, since they are allocated in for statements.
Otherwise there would be memleaks because tpg_free is called only when
tpg_alloc return 0.

Fixes: 63881df94d ("[media] vivid: add the Test Pattern Generator")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:45 -04:00
Nikita Zhandarovich
b64cc91c6d media: em28xx: annotate unchecked call to media_device_register()
[ Upstream commit fd61d77a3d ]

Static analyzers generate alerts for an unchecked call to
`media_device_register()`. However, in this case, the device will work
reliably without the media controller API.

Add a comment above the call to prevent future unnecessary changes.

Suggested-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Fixes: 37ecc7b127 ("[media] em28xx: add media controller support")
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:45 -04:00
Julien Massot
9a5b6b47a3 media: v4l2: cci: print leading 0 on error
[ Upstream commit 58ab1f9e14 ]

In some error cases leading '0' for register address
were missing.

Fixes: 613cbb91e9 ("media: Add MIPI CCI register access helper functions")
Signed-off-by: Julien Massot <julien.massot@collabora.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:44 -04:00
Julien Massot
ae532eb08a media: cadence: csi2rx: use match fwnode for media link
[ Upstream commit 448699c522 ]

Since commit 1029939b37 ("media: v4l: async: Simplify async sub-device fwnode matching"),
async connections are matched using the async sub-device fwnode, not that
of the endpoint. Fix this by using the fwnode of the connection match to
find the pad.

Fixes: 1029939b37 ("media: v4l: async: Simplify async sub-device fwnode matching")
Signed-off-by: Julien Massot <julien.massot@collabora.com>
Reviewed-by: Jai Luthra <j-luthra@ti.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:43 -04:00
Alexander Stein
edbb3226c9 media: tc358743: register v4l2 async device only after successful setup
[ Upstream commit 87399f1ff9 ]

Ensure the device has been setup correctly before registering the v4l2
async device, thus allowing userspace to access.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Robert Foss <rfoss@kernel.org>
Fixes: 4c5211a100 ("[media] tc358743: register v4l2 asynchronous subdevice")
Signed-off-by: Robert Foss <rfoss@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240110090111.458115-1-alexander.stein@ew.tq-group.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:43 -04:00
Tomi Valkeinen
b39b4d207d media: rkisp1: Fix IRQ handling due to shared interrupts
[ Upstream commit ffb635bb39 ]

The driver requests the interrupts as IRQF_SHARED, so the interrupt
handlers can be called at any time. If such a call happens while the ISP
is powered down, the SoC will hang as the driver tries to access the
ISP registers.

This can be reproduced even without the platform sharing the IRQ line:
Enable CONFIG_DEBUG_SHIRQ and unload the driver, and the board will
hang.

Fix this by adding a new field, 'irqs_enabled', which is used to bail
out from the interrupt handler when the ISP is not operational.

Link: https://lore.kernel.org/r/20231218-rkisp-shirq-fix-v1-2-173007628248@ideasonboard.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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:09 -04:00
Jason Liu
8eb8dd316c This is the 6.6.20 stable release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmXjYIIACgkQONu9yGCS
 aT5mvw/9GnG2BWbZp9BgVzBnT00CXnIpiGlsoSU0I0Uiso3XqpNYBu7jIZ+vmsqz
 3H2bpkToEwJgg40I+w3iRaY84FWJZtl6HWtXydVQghQzXdA7qSuKBmbqQdUGKqZq
 Uqy7SFabkqQmlmF+RX1tYsgj7Vg3tqThERLUKQRhZIRa+Xek6Izi16RKEXcBNoXv
 vN+Q6AJ6vgjzHdw/UndsTH48bA/NofLlGapf7ZRGaSO7vY6bO5N23Xeg8gBIUh3M
 RHYf0ubKOvOw6LfZrE8BAbLd9Om2IHRAwHTqvDUNaIOl6y7exwCCIMK2lDdlzQ3W
 7gug4HzlQjVz93OtL8MjLnfINOO7en65gyqvwit9N7O7nJKvuIMtt5vVam+h4ikB
 xF/QmFj95GNeRLwBmOJxOS89KyC8BrjE3PfYtL1mUO9joH8vZBccon6WIV7C2u5M
 d+0UglxC4lNTJ3s3FcnrzEKCn5YaE8WvFYQX0xvFQL3GWGDkyrNaafqoz19a8yd2
 ndf3xUh5QKYWI2UGhqV6FdfYC9BolEh/niMKrJYCEJ6BroO3nzh1L8keC+MHbJwp
 Yuu9FCT+vNDKfR/HQwUhUGX/3wyBKb8jqzDXUB2s4FLPUSBX+/RAso13FWua1TGd
 E432ZXaobuUx3+kHsqB+0dc99QVblnMFMPEoM4ye3lYHzq8PDJ0=
 =7IL4
 -----END PGP SIGNATURE-----

Merge tag 'v6.6.20' into lf-6.6.y

This is the 6.6.20 stable release

* tag 'v6.6.20': (3154 commits)
  Linux 6.6.20
  fs/ntfs3: fix build without CONFIG_NTFS3_LZX_XPRESS
  Linux 6.6.19
  ...

Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>

 Conflicts:
	arch/arm64/boot/dts/freescale/imx8mm.dtsi
	arch/arm64/boot/dts/freescale/imx8mq.dtsi
	drivers/clk/imx/clk-imx8qxp.c
	drivers/dma/fsl-edma.c
	drivers/firmware/arm_scmi/perf.c
	drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
	drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
	drivers/net/ethernet/freescale/fec_main.c
	drivers/scsi/scsi_error.c
	drivers/spi/spi-imx.c
	sound/soc/fsl/fsl_sai.c
2024-03-11 14:59:44 +08:00
Sean Young
93136132d1 media: rc: bpf attach/detach requires write permission
commit 6a9d552483 upstream.

Note that bpf attach/detach also requires CAP_NET_ADMIN.

Cc: stable@vger.kernel.org
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-02-23 09:25:07 +01:00
Tomi Valkeinen
889a5f329e media: Revert "media: rkisp1: Drop IRQF_SHARED"
commit a107d643b2 upstream.

This reverts commit 85d2a31fe4.

The rkisp1 does share interrupt lines on some platforms, after all. Thus
we need to revert this, and implement a fix for the rkisp1 shared irq
handling in a follow-up patch.

Closes: https://lore.kernel.org/all/87o7eo8vym.fsf@gmail.com/
Link: https://lore.kernel.org/r/20231218-rkisp-shirq-fix-v1-1-173007628248@ideasonboard.com

Reported-by: Mikhail Rudenko <mike.rudenko@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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-02-23 09:25:01 +01:00
Zhipeng Lu
7219a692ff media: ir_toy: fix a memleak in irtoy_tx
[ Upstream commit dc9ceb90c4 ]

When irtoy_command fails, buf should be freed since it is allocated by
irtoy_tx, or there is a memleak.

Fixes: 4114978dcd ("media: ir_toy: prevent device from hanging during transmit")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-02-23 09:24:57 +01:00
Aurelien Jarno
7a62d444a2 media: solo6x10: replace max(a, min(b, c)) by clamp(b, a, c)
commit 31e97d7c9a upstream.

This patch replaces max(a, min(b, c)) by clamp(b, a, c) in the solo6x10
driver.  This improves the readability and more importantly, for the
solo6x10-p2m.c file, this reduces on my system (x86-64, gcc 13):

 - the preprocessed size from 121 MiB to 4.5 MiB;

 - the build CPU time from 46.8 s to 1.6 s;

 - the build memory from 2786 MiB to 98MiB.

In fine, this allows this relatively simple C file to be built on a
32-bit system.

Reported-by: Jiri Slaby <jirislaby@gmail.com>
Closes: https://lore.kernel.org/lkml/18c6df0d-45ed-450c-9eda-95160a2bbb8e@gmail.com/
Cc:  <stable@vger.kernel.org> # v6.7+
Suggested-by: David Laight <David.Laight@ACULAB.COM>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: David Laight <David.Laight@ACULAB.COM>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: <regressions@leemhuis.info>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-02-16 19:10:56 +01:00
Kieran Bingham
777ab143a0 media: i2c: imx335: Fix hblank min/max values
[ Upstream commit d7b95ad7a8 ]

The V4L2_CID_HBLANK control is marked as readonly and can only be a
single value.

Set the minimum and maximum value to match the mode value.

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-02-05 20:14:28 +00:00
Su Hui
7190073513 media: ddbridge: fix an error code problem in ddb_probe
[ Upstream commit 09b4195021 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-02-05 20:14:28 +00:00
Ming Qian
7c180bf296 media: amphion: remove mutext lock in condition of wait_event
[ Upstream commit f9c8ddce2f ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-02-05 20:14:28 +00:00
Laurent Pinchart
8a31520642 media: rkisp1: resizer: Stop manual allocation of v4l2_subdev_state
[ Upstream commit efa28efd9c ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-02-05 20:14:28 +00:00
Tomi Valkeinen
fab4834383 media: rkisp1: Fix IRQ disable race issue
[ Upstream commit 870565f063 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-02-05 20:14:27 +00:00
Tomi Valkeinen
e28e80cda4 media: rkisp1: Store IRQ lines
[ Upstream commit 0753874617 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-02-05 20:14:27 +00:00
Tomi Valkeinen
a32c20cf93 media: rkisp1: Fix IRQ handler return values
[ Upstream commit 3eb7910e1b ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-02-05 20:14:27 +00:00
Tomi Valkeinen
e08195de19 media: rkisp1: Drop IRQF_SHARED
[ Upstream commit 85d2a31fe4 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-02-05 20:14:27 +00:00
Ricardo Ribalda
5193d26a70 media: uvcvideo: Fix power line control for SunplusIT camera
[ Upstream commit 6180056b0e ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-02-05 20:14:27 +00:00
Ricardo Ribalda
051400c305 media: uvcvideo: Fix power line control for a Chicony camera
[ Upstream commit dba3e70191 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-02-05 20:14:27 +00:00
Michael Tretter
6ca8d2c068 media: rockchip: rga: fix swizzling for RGB formats
[ Upstream commit 9e7dc39260 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-02-05 20:14:27 +00:00
Ghanshyam Agrawal
df16808b16 media: stk1160: Fixed high volume of stk1160_dbg messages
[ Upstream commit b3695e86d2 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-02-05 20:14:27 +00:00
Alexander Stein
cca7638637 media: i2c: imx290: Properly encode registers as little-endian
[ Upstream commit 60fc87a695 ]

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: af73323b97 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-31 16:19:10 -08:00
Alexander Stein
8798fdc284 media: v4l2-cci: Add support for little-endian encoded registers
[ Upstream commit d92e7a013f ]

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: af73323b97 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-31 16:19:10 -08:00
Sakari Ailus
8d2cd1724e media: v4l: cci: Add macros to obtain register width and address
[ Upstream commit cd93cc245d ]

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>
Stable-dep-of: d92e7a013f ("media: v4l2-cci: Add support for little-endian encoded registers")
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-31 16:19:09 -08:00
Zheng Wang
8254d54d00 media: mtk-jpeg: Fix use after free bug due to error path handling in mtk_jpeg_dec_device_run
commit 206c857dd1 upstream.

In mtk_jpeg_probe, &jpeg->job_timeout_work is bound with
mtk_jpeg_job_timeout_work.

In mtk_jpeg_dec_device_run, if error happens in
mtk_jpeg_set_dec_dst, it will finally start the worker while
mark the job as finished by invoking v4l2_m2m_job_finish.

There are two methods to trigger the bug. If we remove the
module, it which will call mtk_jpeg_remove to make cleanup.
The possible sequence is as follows, which will cause a
use-after-free bug.

CPU0                  CPU1
mtk_jpeg_dec_...    |
  start worker	    |
                    |mtk_jpeg_job_timeout_work
mtk_jpeg_remove     |
  v4l2_m2m_release  |
    kfree(m2m_dev); |
                    |
                    | v4l2_m2m_get_curr_priv
                    |   m2m_dev->curr_ctx //use

If we close the file descriptor, which will call mtk_jpeg_release,
it will have a similar sequence.

Fix this bug by starting timeout worker only if started jpegdec worker
successfully. Then v4l2_m2m_job_finish will only be called in
either mtk_jpeg_job_timeout_work or mtk_jpeg_dec_device_run.

Fixes: b2f0d2724b ("[media] vcodec: mediatek: Add Mediatek JPEG Decoder Driver")
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Cc: stable@vger.kernel.org
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-01-31 16:18:55 -08:00
Zheng Wang
26f3ae1aa8 media: mtk-jpeg: Fix timeout schedule error in mtk_jpegdec_worker.
commit 38e1857933 upstream.

In mtk_jpegdec_worker, if error occurs in mtk_jpeg_set_dec_dst, it
will start the timeout worker and invoke v4l2_m2m_job_finish at
the same time. This will break the logic of design for there should
be only one function to call v4l2_m2m_job_finish. But now the timeout
handler and mtk_jpegdec_worker will both invoke it.

Fix it by start the worker only if mtk_jpeg_set_dec_dst successfully
finished.

Fixes: da4ede4b7f ("media: mtk-jpeg: move data/code inside CONFIG_OF blocks")
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Cc: stable@vger.kernel.org
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-01-31 16:18:55 -08:00
Alain Volmat
9399d61bf5 media: i2c: st-mipid02: correct format propagation
commit b33cb0cbe2 upstream.

Use a copy of the struct v4l2_subdev_format when propagating
format from the sink to source pad in order to avoid impacting the
sink format returned to the application.

Thanks to Jacopo Mondi for pointing the issue.

Fixes: 6c01e6f3f2 ("media: st-mipid02: Propagate format from sink to source pad")
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Cc: stable@vger.kernel.org
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-01-31 16:18:55 -08:00
Michael Grzeschik
72a28c9283 media: videobuf2-dma-sg: fix vmap callback
commit 608ca5a60e upstream.

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: 7938f42181 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-01-31 16:18:55 -08:00
Bingbu Cao
240fd0215d media: ov01a10: Enable runtime PM before registering async sub-device
commit 47a78052db upstream.

As the sensor device maybe accessible right after its async sub-device is
registered, such as ipu-bridge will try to power up sensor by sensor's
client device's runtime PM from the async notifier callback, if runtime PM
is not enabled, it will fail.

So runtime PM should be ready before its async sub-device is registered
and accessible by others.

It also sets the runtime PM status to active as the sensor was turned
on by i2c-core.

Fixes: 0827b58dab ("media: i2c: add ov01a10 image sensor driver")
Cc: stable@vger.kernel.org
Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-01-31 16:18:51 -08:00
Bingbu Cao
000339cb5d media: ov13b10: Enable runtime PM before registering async sub-device
commit 7b0454cfd8 upstream.

As the sensor device maybe accessible right after its async sub-device is
registered, such as ipu-bridge will try to power up sensor by sensor's
client device's runtime PM from the async notifier callback, if runtime PM
is not enabled, it will fail.

So runtime PM should be ready before its async sub-device is registered
and accessible by others.

Fixes: 7ee8505468 ("media: Add sensor driver support for the ov13b10 camera.")
Cc: stable@vger.kernel.org
Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-01-31 16:18:51 -08:00
Bingbu Cao
92d25e02ee media: ov9734: Enable runtime PM before registering async sub-device
commit e242e9c144 upstream.

As the sensor device maybe accessible right after its async sub-device is
registered, such as ipu-bridge will try to power up sensor by sensor's
client device's runtime PM from the async notifier callback, if runtime PM
is not enabled, it will fail.

So runtime PM should be ready before its async sub-device is registered
and accessible by others.

Fixes: d3f863a63f ("media: i2c: Add ov9734 image sensor driver")
Cc: stable@vger.kernel.org
Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-01-31 16:18:51 -08:00
Bingbu Cao
252ae106ea media: imx355: Enable runtime PM before registering async sub-device
commit efa5fe19c0 upstream.

As the sensor device maybe accessible right after its async sub-device is
registered, such as ipu-bridge will try to power up sensor by sensor's
client device's runtime PM from the async notifier callback, if runtime PM
is not enabled, it will fail.

So runtime PM should be ready before its async sub-device is registered
and accessible by others.

Fixes: df0b5c4a7d ("media: add imx355 camera sensor driver")
Cc: stable@vger.kernel.org
Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-01-31 16:18:50 -08:00
Aymen Sghaier
ba03214175 ILIE-12: media: nxp: neoisp: Update compatible string
Rename compatible string from fsl,neoisp to nxp,neoisp to be aligned
with dt-bindings documentation.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-01-26 17:26:58 +08:00
Aymen Sghaier
1b9567e743 ILIE-33: media: nxp: neoisp: Rename dcg and vs to input0 and input1
DCG and VS names are being renamed in the ISP block guide.
This patch aligns the driver sources with the new block guide version.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-01-26 17:26:26 +08:00
Aymen Sghaier
5ce7a7a889 ILIE-30: media: nxp: neoisp: Fix colorspace selection regarding v4l2 buffer type
Set V4L2_COLORSPACE_RAW for output video buffer type
Set V4L2_COLORSPACE_SRGB for capture v4l2 buffer type

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-01-26 17:26:26 +08:00
Aymen Sghaier
121f43e78b ILIE-19: media: nxp: neoisp: Fix yuv colors
If YUV format is selected for output, the colors shown on the screen are
corrupted, blue appears green and red appears brown and so on.
This patch fixes the GCM block parameters to see correct colors.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-01-26 17:26:26 +08:00
Aymen Sghaier
df04d28256 ILIE-27: media: nxp: neoisp: Add event subscriber ops to subdevice
V4L2_EVENT_FRAME_SYNC event is generated but related ioctl is not
enabled.
This patch adds support for event subscribe ioctl.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-01-26 17:26:26 +08:00
Aymen Sghaier
3571388e96 ILIE-26: media: nxp: neoisp: Add sequence number in video capture v4l2_buffers
Add per neoisp instance a frame sequence number to provide for each
frame done event

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-01-26 17:26:26 +08:00
Aymen Sghaier
9d2b63e515 ILIE-12: media: nxp: neoisp: Queue frame_sync_event before isp start
V4L2_EVENT_FRAME_SYNC is queued only after isp processing done, which is
not expected by pipeline handler.
This patch moves the event before the isp processing to comply with
pipeline handler expectation.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-01-26 17:26:26 +08:00
Aymen Sghaier
ab6f693d93 ILIE-12: media: nxp: neoisp: Remove huge amount of logs at probe
At probe neoisp driver is logging each device node register which is
huge and not needed
This patch moves them to debug level and keeps only probe done log as
notification level.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-01-26 17:26:25 +08:00
Aymen Sghaier
e75025ff9a ILIE-12: media: nxp: neoisp: Add missing neoisp subdevice for pipeline handler
Media entity is created widtout subdevice node which is blocking for
pipeline handler setup.
This patch adds the neoisp subdevice node creation.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-01-26 17:26:25 +08:00
Aymen Sghaier
bf34b6e7ba ILIE-12: media: nxp: neoisp: Fix stats pointer error when disabled
Even when statistics node is disabled for tests and error pointer is
observed while isp is running.
This patch checks if stats are disabled before generating the error.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-01-26 17:26:25 +08:00
Aymen Sghaier
7430cac4d0 ILIE-12: media: nxp: neoisp: Fix rgb settings after playing yuv
Once neoisp processed yuv capture format, rgb capture format is broken
and user will get corrupted frames
This patch fix restoring rgb settings in such scenario.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-01-26 17:26:25 +08:00
Julien Vuillaumier
a7d6512d9c ILIE-17: media: v4l2-core: Add meta neoisp formats description
A warning is emitted when meta neoisp formats description is requested,
this patch adds the missing descriptions for the following formats:
 - V4L2_META_FMT_NEO_ISP_PARAMS
 - V4L2_META_FMT_NEO_ISP_STATS

Signed-off-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-01-26 17:26:25 +08:00
Aymen Sghaier
313aaa2fc5 ILIE-12: media: nxp: neoisp: Fix high resolution frames processing by neoisp
When using frames resolution bigger than 2024x1024 like 1920x1080
neoisp is generating error with unsupported resolution while hardware is
able to process up to 4096 line width frames.
This patch increase the accepted resolutions to 4096x4096.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-01-26 17:26:25 +08:00
Aymen Sghaier
7370ead52d ILIE-18: media: nxp: neoisp: Fix streaming mode using gstreamer
Gstreamer pipeline is generating a bus error because isp is starting
without waiting for frame node buffer to be queued.
This patch adds a condition to not start processing if no frame node
buffer has been queued, to avoid this bus error.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-01-26 17:26:25 +08:00
Christophe JAILLET
ee3e64d1da media: dvb-frontends: m88ds3103: Fix a memory leak in an error handling path of m88ds3103_probe()
[ Upstream commit 5b2f885e2f ]

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: e6089feca4 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:35 -08:00
Dan Carpenter
de28d63ad3 media: dvbdev: drop refcount on error path in dvb_device_open()
[ Upstream commit a2dd235df4 ]

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

Fixes: 0fc044b2b5 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:35 -08:00
Tomi Valkeinen
f2295f1769 media: rkisp1: Fix media device memory leak
[ Upstream commit 452f604a46 ]

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: d65dd85281 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:35 -08:00
Tomi Valkeinen
c9354bffaa media: imx-mipi-csis: Drop extra clock enable at probe()
[ Upstream commit fb387fcb5c ]

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: 7807063b86 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:35 -08:00
Tomi Valkeinen
0e3535ee77 media: imx-mipi-csis: Fix clock handling in remove()
[ Upstream commit 5705b0e0eb ]

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: 7807063b86 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:35 -08:00
Hans Verkuil
54ce93d7e6 media: bttv: add back vbi hack
[ Upstream commit 3f1faa154a ]

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: b7ec3212a7 ("media: bttv: convert to vb2")
Tested-by: Dr. David Alan Gilbert <dave@treblig.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:35 -08:00
Hans Verkuil
e8fa30fa71 media: bttv: start_streaming should return a proper error code
[ Upstream commit 0d75bb6ae1 ]

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: b7ec3212a7 ("media: bttv: convert to vb2")
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:34 -08:00
Zhipeng Lu
1e2c9e7418 media: cx231xx: fix a memleak in cx231xx_init_isoc
[ Upstream commit 5d3c8990e2 ]

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: 64fbf44455 ("[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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:34 -08:00
Sebastian Reichel
b7062628ca media: v4l: async: Fix duplicated list deletion
[ Upstream commit 3de6ee94aa ]

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: 28a1295795 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:33 -08:00
Alexander Stein
c082791b6a media: amphion: Fix VPU core alias name
[ Upstream commit f033c87fda ]

Starting with commit f6038de293 ("arm64: dts: imx8qm: Fix VPU core
alias name") the alias for VPU cores uses dashes instead of underscores.
Adjust the alias stem accordingly. Fixes the errors:
amphion-vpu-core 2d040000.vpu-core: can't get vpu core id
amphion-vpu-core 2d050000.vpu-core: can't get vpu core id

Fixes: f6038de293 ("arm64: dts: imx8qm: Fix VPU core alias name")
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:32 -08:00
Paul Kocialkowski
682588d38a media: verisilicon: Hook the (TRY_)DECODER_CMD stateless ioctls
[ Upstream commit 6c0d9e12b1 ]

The (TRY_)DECODER_CMD ioctls are used to support flushing when holding
capture buffers is supported. This is the case of this driver but the
ioctls were never hooked to the ioctl ops.

Add them to correctly support flushing.

Fixes: 340ce50f75 ("media: hantro: Enable HOLD_CAPTURE_BUF for H.264")
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:32 -08:00
Paul Kocialkowski
f581023e32 media: visl: Hook the (TRY_)DECODER_CMD stateless ioctls
[ Upstream commit 3907f6ef8e ]

The (TRY_)DECODER_CMD ioctls are used to support flushing when holding
capture buffers is supported. This is the case of this driver but the
ioctls were never hooked to the ioctl ops.

Add them to correctly support flushing.

Fixes: 0c078e310b ("media: visl: add virtual stateless decoder driver")
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:32 -08:00
Zheng Wang
2cb808af77 media: mtk-jpeg: Remove cancel worker in mtk_jpeg_remove to avoid the crash of multi-core JPEG devices
[ Upstream commit d8212c5c87 ]

This patch reverts commit c677d7ae83
("media: mtk-jpeg: Fix use after free bug due to uncanceled work").
The job_timeout_work is initialized only for
the single-core JPEG device so it will cause the crash for multi-core
JPEG devices.

Fix it by removing the cancel_delayed_work_sync function.

Fixes: c677d7ae83 ("media: mtk-jpeg: Fix use after free bug due to uncanceled work")
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:32 -08:00
Ricardo B. Marliere
2cf0005d31 media: pvrusb2: fix use after free on context disconnection
[ Upstream commit ded85b0c0e ]

Upon module load, a kthread is created targeting the
pvr2_context_thread_func function, which may call pvr2_context_destroy
and thus call kfree() on the context object. However, that might happen
before the usb hub_event handler is able to notify the driver. This
patch adds a sanity check before the invalid read reported by syzbot,
within the context disconnection call stack.

Reported-and-tested-by: syzbot+621409285c4156a009b3@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/000000000000a02a4205fff8eb92@google.com/

Fixes: e5be15c638 ("V4L/DVB (7711): pvrusb2: Fix race on module unload")
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Acked-by: Mike Isely <isely@pobox.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:32 -08:00
Guoniu.zhou
6cbc4aa1e6 LF-11224: media: nxp: imx8-isi: add QoS setting for iMX95 ISI
Add QoS setting for iMX95 ISI.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
Tested-by: Jared Hu <jared.hu@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-01-16 20:54:12 +08:00
Bryan O'Donoghue
e53b78e3cf media: qcom: camss: Comment CSID dt_id field
commit f910d3ba78 upstream.

Digging into the documentation we find that the DT_ID bitfield is used to
map the six bit DT to a two bit ID code. This value is concatenated to the
VC bitfield to create a CID value. DT_ID is the two least significant bits
of CID and VC the most significant bits.

Originally we set dt_id = vc * 4 in and then subsequently set dt_id = vc.

commit 3c4ed72a16 ("media: camss: sm8250: Virtual channels for CSID")
silently fixed the multiplication by four which would give a better
value for the generated CID without mentioning what was being done or why.

Next up I haplessly changed the value back to "dt_id = vc * 4" since there
didn't appear to be any logic behind it.

Hans asked what the change was for and I honestly couldn't remember the
provenance of it, so I dug in.

Link: https://lore.kernel.org/linux-arm-msm/edd4bf9b-0e1b-883c-1a4d-50f4102c3924@xs4all.nl/

Add a comment so the next hapless programmer doesn't make this same
mistake.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-01-10 17:17:02 +01:00
Bryan O'Donoghue
88a884dec1 media: qcom: camss: Fix genpd cleanup
[ Upstream commit f69791c397 ]

Right now we never release the power-domains properly on the error path.
Add a routine to be reused for this purpose and appropriate jumps in
probe() to run that routine where necessary.

Fixes: 2f6f8af672 ("media: camss: Refactor VFE power domain toggling")
Cc: stable@vger.kernel.org
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-10 17:16:54 +01:00
Bryan O'Donoghue
3c97918a8a media: qcom: camss: Fix V4L2 async notifier error path
[ Upstream commit b278080a89 ]

Previously the jump label err_cleanup was used higher in the probe()
function to release the async notifier however the async notifier
registration was moved later in the code rendering the previous four jumps
redundant.

Rename the label from err_cleanup to err_v4l2_device_unregister to capture
what the jump does.

Fixes: 51397a4ec75d ("media: qcom: Initialise V4L2 async notifier later")
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: fix old name in commit log: err_v4l2_device_register -> err_v4l2_device_unregister]
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-10 17:16:54 +01:00
Guoniu.zhou
d141f1ea04 LF-11117: media: imx8-isi: fix system hang issue when do software reboot
During ISI driver probe, it will do irq register clean up operation,
but doesn't enable clock and power, so meet system hang issue. So
adding the pm runtime during the process to fix this issue.

Signed-off-by: Jacky Bai <ping.bai@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-12-26 16:20:20 +08:00
Mirela Rabulea
82b8ebcacd LF-11113-2: media: os08a20: Rename os08a20 to 0s08a20_mipi
There is another driver named os08a20.ko in vvcam repository,
even if it is in another folder, it is causing build conflicts.
Keep the vvcam driver name, os08a20, so imx8mp customers are not
confused, and rename the kernel driver to os08a20_mipi, including
the compatible.

Signed-off-by: Mirela Rabulea <mirela.rabulea@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Alice Yuan <alice.yuan@nxp.com>
2023-12-25 10:53:29 +02:00
Aymen Sghaier
f862a36a84 ILIE-12: media: platform: Kconfig: Add neoisp build support
Update Kconfig and Makefile in media platfrom nxp folder to build neoisp

Reviewed-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
2023-12-21 21:27:55 +01:00
Aymen Sghaier
f787966697 ILIE-12: media: platform: Add NXP neoisp driver
First NXP neoisp driver version with the following contents:

* Support of raw Bayer images input: (tested V4L2 formats)
 - V4L2_PIX_FMT_SBGGR8
 - V4L2_PIX_FMT_SBGGR12
 - V4L2_PIX_FMT_SGBRG8
 - V4L2_PIX_FMT_SGRBG8
 - V4L2_PIX_FMT_SRGGB8
 - V4L2_PIX_FMT_SRGGB16
* Support of RGB/YUV output formats: (tested V4L2 formats)
 - V4L2_PIX_FMT_RGB24 (RGB-8-8-8)
 - V4L2_PIX_FMT_YUYV (YUV 4:2:2)
 - V4L2_PIX_FMT_YUV24 (YUV3 4:4:4)
* Single camera context support
* Only DCG input is supported - not VS
* Only Frame output is supported - not IR
* Params and stats nodes are supported

This driver is highly inspired from "Raspberry Pi PiSP Backend (BE) ISP driver",
 developed by "David Plowman <david.plowman@raspberrypi.com>" and
"Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>"
It leverages the ability of handling multiple camera streams with only
one ISP hardware.

Reviewed-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
2023-12-21 21:27:55 +01:00
Mirela Rabulea
e8e5d79ee3 LF-10968: media: os08a20: Fix checkpatch errors
Fix multiple errors from cleanfile and checkpatch scripts.

Signed-off-by: Mirela Rabulea <mirela.rabulea@nxp.com>
2023-12-15 15:32:25 +02:00
Mirela Rabulea
51c7fbbb9a LF-10968: media: os08a20: Fix runtime PM usage count underflow
The usage of VVSENSORIOC_S_STREAM from user-space side is
unpaired, there is one enable and two disables, causing:
[ 4663.131145] os08a20 1-0036: Runtime PM usage count underflow!

Fix VVSENSORIOC_S_STREAM.

Signed-off-by: Mirela Rabulea <mirela.rabulea@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-12-15 15:32:16 +02:00
Mirela Rabulea
3c8bb0ad57 LF-10968: media: os08a20: Use os08a20 version from p24 release
Update to the latest available version of the VSI release.

Signed-off-by: Mirela Rabulea <mirela.rabulea@nxp.com>
2023-12-15 15:32:15 +02:00
Mirela Rabulea
f5cc1f00e9 LF-10968: media: os08a20: Add V4L2_CID_LINK_FREQ control
For now, it's just one hardcoded default value for 1080p RAW10.

Signed-off-by: Mirela Rabulea <mirela.rabulea@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-12-15 15:31:33 +02:00
Mirela Rabulea
c92e35ba61 LF-10968: media: os08a20: Use runtime PM
Switch to using runtime PM for power management, the
s_power is obsolete. Follow the changes from:
commit 85644a9b37 ("media: ov5640: Use runtime PM")

Also rename probe_err_free_entiny label.

Signed-off-by: Mirela Rabulea <mirela.rabulea@nxp.com>
2023-12-15 15:06:55 +02:00
Mirela Rabulea
c76e725846 LF-10968: media: os08a20: Add os08a20 driver from VSI p17 release
This is the VSI driver for Omnivision os08a20 raw sensor,
using MIPI-CSI2 interface.

Tested on imx8mp and imx95.
The default mode is 1080p, RAW10.

Signed-off-by: Mirela Rabulea <mirela.rabulea@nxp.com>
2023-12-15 15:06:55 +02:00
Guoniu.zhou
403c112dc3 LF-10821-02: media: nxp: don't print message when error number is -EPROBE_DEFER
Check the return value and don't print error message when return
error is -EPROBE_DEFER to avoid confusion.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-12-13 18:34:12 +08:00
Guoniu.zhou
bf6ec954c6 LF-10822: media: nxp: Create a 1:N mapping between pixel link and ISI channels
Create a 1:N mapping between pixel link inputs and outputs to pipelines
by according to the number of pixel links inputs and ISI channels. The
algorithm will divide the ISI channel equally to each pixel link input
which connect to a remote device.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-12-07 09:55:09 +08:00
Jason Liu
f75d905095 Merge tag 'v6.6.3' into lf-6.6.y
This is the 6.6.3 stable release

* tag 'v6.6.3': (526 commits)
  Linux 6.6.3
  drm/amd/display: Change the DMCUB mailbox memory location from FB to inbox
  drm/amd/display: Clear dpcd_sink_ext_caps if not set
  ...

Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>

 Conflicts:
	arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi
	drivers/usb/dwc3/core.c
2023-11-30 09:41:12 -06:00
Jason Liu
6d09067baf Merge tag 'v6.6.2' into lf-6.6.y
This is the 6.6.2 stable release

* tag 'v6.6.2': (634 commits)
  Linux 6.6.2
  btrfs: make found_logical_ret parameter mandatory for function queue_scrub_stripe()
  btrfs: use u64 for buffer sizes in the tree search ioctls
  ...

Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>

Conflicts:
	drivers/clk/imx/clk-imx8mq.c
	drivers/clk/imx/clk-imx8qxp.c
	drivers/media/i2c/ov5640.c
	drivers/misc/pci_endpoint_test.c
2023-11-30 09:40:58 -06:00
Andrey Konovalov
ed9f1ea918 media: qcom: camss: Fix csid-gen2 for test pattern generator
commit 87889f1b7e upstream.

In the current driver csid Test Pattern Generator (TPG) doesn't work.
This change:
- fixes writing frame width and height values into CSID_TPG_DT_n_CFG_0
- fixes the shift by one between test_pattern control value and the
  actual pattern.
- drops fixed VC of 0x0a which testing showed prohibited some test
  patterns in the CSID to produce output.
So that TPG starts working, but with the below limitations:
- only test_pattern=9 works as it should
- test_pattern=8 and test_pattern=7 produce black frame (all zeroes)
- the rest of test_pattern's don't work (yavta doesn't get the data)
- regardless of the CFA pattern set by 'media-ctl -V' the actual pixel
  order is always the same (RGGB for any RAW8 or RAW10P format in
  4608x2592 resolution).

Tested with:

RAW10P format, VC0:
 media-ctl -V '"msm_csid0":0[fmt:SRGGB10/4608x2592 field:none]'
 media-ctl -V '"msm_vfe0_rdi0":0[fmt:SRGGB10/4608x2592 field:none]'
 media-ctl -l '"msm_csid0":1->"msm_vfe0_rdi0":0[1]'
 v4l2-ctl -d /dev/v4l-subdev6 -c test_pattern=9
 yavta -B capture-mplane --capture=3 -n 3 -f SRGGB10P -s 4608x2592 /dev/video0

RAW10P format, VC1:
 media-ctl -V '"msm_csid0":2[fmt:SRGGB10/4608x2592 field:none]'
 media-ctl -V '"msm_vfe0_rdi1":0[fmt:SRGGB10/4608x2592 field:none]'
 media-ctl -l '"msm_csid0":2->"msm_vfe0_rdi1":0[1]'
 v4l2-ctl -d /dev/v4l-subdev6 -c test_pattern=9
 yavta -B capture-mplane --capture=3 -n 3 -f SRGGB10P -s 4608x2592 /dev/video1

RAW8 format, VC0:
 media-ctl --reset
 media-ctl -V '"msm_csid0":0[fmt:SRGGB8/4608x2592 field:none]'
 media-ctl -V '"msm_vfe0_rdi0":0[fmt:SRGGB8/4608x2592 field:none]'
 media-ctl -l '"msm_csid0":1->"msm_vfe0_rdi0":0[1]'
 yavta -B capture-mplane --capture=3 -n 3 -f SRGGB8 -s 4608x2592 /dev/video0

Fixes: eebe6d00e9 ("media: camss: Add support for CSID hardware version Titan 170")
Cc: stable@vger.kernel.org
Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:20:15 +00:00
Bryan O'Donoghue
e09e1ddc69 media: qcom: camss: Fix invalid clock enable bit disjunction
commit d8f7e1a60d upstream.

define CSIPHY_3PH_CMN_CSI_COMMON_CTRL5_CLK_ENABLE BIT(7)

disjunction for gen2 ? BIT(7) : is a nop we are setting the same bit
either way.

Fixes: 4abb21309f ("media: camss: csiphy: Move to hardcode CSI Clock Lane number")
Cc: stable@vger.kernel.org
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:20:14 +00:00
Bryan O'Donoghue
5fbdccc9f8 media: qcom: camss: Fix set CSI2_RX_CFG1_VC_MODE when VC is greater than 3
commit e655d1ae97 upstream.

VC_MODE = 0 implies a two bit VC address.
VC_MODE = 1 is required for VCs with a larger address than two bits.

Fixes: eebe6d00e9 ("media: camss: Add support for CSID hardware version Titan 170")
Cc: stable@vger.kernel.org
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:20:14 +00:00
Bryan O'Donoghue
f6cc8265eb media: qcom: camss: Fix missing vfe_lite clocks check
commit b6e1bdca46 upstream.

check_clock doesn't account for vfe_lite which means that vfe_lite will
never get validated by this routine. Add the clock name to the expected set
to remediate.

Fixes: 7319cdf189 ("media: camss: Add support for VFE hardware version Titan 170")
Cc: stable@vger.kernel.org
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:20:14 +00:00
Bryan O'Donoghue
4dac469b07 media: qcom: camss: Fix VFE-480 vfe_disable_output()
commit 7f24d29135 upstream.

vfe-480 is copied from vfe-17x and has the same racy idle timeout bug as in
17x.

Fix the vfe_disable_output() logic to no longer be racy and to conform
to the 17x way of quiescing and then resetting the VFE.

Fixes: 4edc8eae71 ("media: camss: Add initial support for VFE hardware version Titan 480")
Cc: stable@vger.kernel.org
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:20:14 +00:00
Bryan O'Donoghue
b1eaec007b media: qcom: camss: Fix VFE-17x vfe_disable_output()
commit 3143ad282f upstream.

There are two problems with the current vfe_disable_output() routine.

Firstly we rightly use a spinlock to protect output->gen2.active_num
everywhere except for in the IDLE timeout path of vfe_disable_output().
Even if that is not racy "in practice" somehow it is by happenstance not
by design.

Secondly we do not get consistent behaviour from this routine. On
sc8280xp 50% of the time I get "VFE idle timeout - resetting". In this
case the subsequent capture will succeed. The other 50% of the time, we
don't hit the idle timeout, never do the VFE reset and subsequent
captures stall indefinitely.

Rewrite the vfe_disable_output() routine to

- Quiesce write masters with vfe_wm_stop()
- Set active_num = 0

remembering to hold the spinlock when we do so followed by

- Reset the VFE

Testing on sc8280xp and sdm845 shows this to be a valid fix.

Fixes: 7319cdf189 ("media: camss: Add support for VFE hardware version Titan 170")
Cc: stable@vger.kernel.org
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:20:14 +00:00
Bryan O'Donoghue
816a4070bc media: qcom: camss: Fix vfe_get() error jump
commit 26bda3da00 upstream.

Right now it is possible to do a vfe_get() with the internal reference
count at 1. If vfe_check_clock_rates() returns non-zero then we will
leave the reference count as-is and

run:
- pm_runtime_put_sync()
- vfe->ops->pm_domain_off()

skip:
- camss_disable_clocks()

Subsequent vfe_put() calls will when the ref-count is non-zero
unconditionally run:

- pm_runtime_put_sync()
- vfe->ops->pm_domain_off()
- camss_disable_clocks()

vfe_get() should not attempt to roll-back on error when the ref-count is
non-zero as the upper layers will still do their own vfe_put() operations.

vfe_put() will drop the reference count and do the necessary power
domain release, the cleanup jumps in vfe_get() should only be run when
the ref-count is zero.

[   50.095796] CPU: 7 PID: 3075 Comm: cam Not tainted 6.3.2+ #80
[   50.095798] Hardware name: LENOVO 21BXCTO1WW/21BXCTO1WW, BIOS N3HET82W (1.54 ) 05/26/2023
[   50.095799] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   50.095802] pc : refcount_warn_saturate+0xf4/0x148
[   50.095804] lr : refcount_warn_saturate+0xf4/0x148
[   50.095805] sp : ffff80000c7cb8b0
[   50.095806] x29: ffff80000c7cb8b0 x28: ffff16ecc0e3fc10 x27: 0000000000000000
[   50.095810] x26: 0000000000000000 x25: 0000000000020802 x24: 0000000000000000
[   50.095813] x23: ffff16ecc7360640 x22: 00000000ffffffff x21: 0000000000000005
[   50.095815] x20: ffff16ed175f4400 x19: ffffb4d9852942a8 x18: ffffffffffffffff
[   50.095818] x17: ffffb4d9852d4a48 x16: ffffb4d983da5db8 x15: ffff80000c7cb320
[   50.095821] x14: 0000000000000001 x13: 2e656572662d7265 x12: 7466612d65737520
[   50.095823] x11: 00000000ffffefff x10: ffffb4d9850cebf0 x9 : ffffb4d9835cf954
[   50.095826] x8 : 0000000000017fe8 x7 : c0000000ffffefff x6 : 0000000000057fa8
[   50.095829] x5 : ffff16f813fe3d08 x4 : 0000000000000000 x3 : ffff621e8f4d2000
[   50.095832] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff16ed32119040
[   50.095835] Call trace:
[   50.095836]  refcount_warn_saturate+0xf4/0x148
[   50.095838]  device_link_put_kref+0x84/0xc8
[   50.095843]  device_link_del+0x38/0x58
[   50.095846]  vfe_pm_domain_off+0x3c/0x50 [qcom_camss]
[   50.095860]  vfe_put+0x114/0x140 [qcom_camss]
[   50.095869]  csid_set_power+0x2c8/0x408 [qcom_camss]
[   50.095878]  pipeline_pm_power_one+0x164/0x170 [videodev]
[   50.095896]  pipeline_pm_power+0xc4/0x110 [videodev]
[   50.095909]  v4l2_pipeline_pm_use+0x5c/0xa0 [videodev]
[   50.095923]  v4l2_pipeline_pm_get+0x1c/0x30 [videodev]
[   50.095937]  video_open+0x7c/0x100 [qcom_camss]
[   50.095945]  v4l2_open+0x84/0x130 [videodev]
[   50.095960]  chrdev_open+0xc8/0x250
[   50.095964]  do_dentry_open+0x1bc/0x498
[   50.095966]  vfs_open+0x34/0x40
[   50.095968]  path_openat+0xb44/0xf20
[   50.095971]  do_filp_open+0xa4/0x160
[   50.095974]  do_sys_openat2+0xc8/0x188
[   50.095975]  __arm64_sys_openat+0x6c/0xb8
[   50.095977]  invoke_syscall+0x50/0x128
[   50.095982]  el0_svc_common.constprop.0+0x4c/0x100
[   50.095985]  do_el0_svc+0x40/0xa8
[   50.095988]  el0_svc+0x2c/0x88
[   50.095991]  el0t_64_sync_handler+0xf4/0x120
[   50.095994]  el0t_64_sync+0x190/0x198
[   50.095996] ---[ end trace 0000000000000000 ]---

Fixes: 779096916d ("media: camss: vfe: Fix runtime PM imbalance on error")
Cc: stable@vger.kernel.org
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:20:14 +00:00
Bryan O'Donoghue
35c9b41dc8 media: qcom: camss: Fix pm_domain_on sequence in probe
commit 7405116519 upstream.

We need to make sure camss_configure_pd() happens before
camss_register_entities() as the vfe_get() path relies on the pointer
provided by camss_configure_pd().

Fix the ordering sequence in probe to ensure the pointers vfe_get() demands
are present by the time camss_register_entities() runs.

In order to facilitate backporting to stable kernels I've moved the
configure_pd() call pretty early on the probe() function so that
irrespective of the existence of the old error handling jump labels this
patch should still apply to -next circa Aug 2023 to v5.13 inclusive.

Fixes: 2f6f8af672 ("media: camss: Refactor VFE power domain toggling")
Cc: stable@vger.kernel.org
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:20:14 +00:00
Sakari Ailus
277fec855b media: ccs: Correctly initialise try compose rectangle
commit 724ff68e96 upstream.

Initialise the try sink compose rectangle size to the sink compose
rectangle for binner and scaler sub-devices. This was missed due to the
faulty condition that lead to the compose rectangles to be initialised for
the pixel array sub-device where it is not relevant.

Fixes: ccfc97bdb5 ("[media] smiapp: Add driver")
Cc: stable@vger.kernel.org
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:20:12 +00:00
Vikash Garodia
648f394548 media: venus: hfi: add checks to handle capabilities from firmware
commit 8d0b89398b upstream.

The hfi parser, parses the capabilities received from venus firmware and
copies them to core capabilities. Consider below api, for example,
fill_caps - In this api, caps in core structure gets updated with the
number of capabilities received in firmware data payload. If the same api
is called multiple times, there is a possibility of copying beyond the max
allocated size in core caps.
Similar possibilities in fill_raw_fmts and fill_profile_level functions.

Cc: stable@vger.kernel.org
Fixes: 1a73374a04 ("media: venus: hfi_parser: add common capability parser")
Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:20:12 +00:00
Vikash Garodia
db6bd47243 media: venus: hfi: fix the check to handle session buffer requirement
commit b18e36dfd6 upstream.

Buffer requirement, for different buffer type, comes from video firmware.
While copying these requirements, there is an OOB possibility when the
payload from firmware is more than expected size. Fix the check to avoid
the OOB possibility.

Cc: stable@vger.kernel.org
Fixes: 09c2845e8f ("[media] media: venus: hfi: add Host Firmware Interface (HFI)")
Reviewed-by: Nathan Hebert <nhebert@chromium.org>
Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:20:12 +00:00
Vikash Garodia
47b12dc269 media: venus: hfi_parser: Add check to keep the number of codecs within range
commit 0768a9dd80 upstream.

Supported codec bitmask is populated from the payload from venus firmware.
There is a possible case when all the bits in the codec bitmask is set. In
such case, core cap for decoder is filled  and MAX_CODEC_NUM is utilized.
Now while filling the caps for encoder, it can lead to access the caps
array beyong 32 index. Hence leading to OOB write.
The fix counts the supported encoder and decoder. If the count is more than
max, then it skips accessing the caps.

Cc: stable@vger.kernel.org
Fixes: 1a73374a04 ("media: venus: hfi_parser: add common capability parser")
Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:20:12 +00:00
Sean Young
e981ecbac5 media: sharp: fix sharp encoding
commit 4f7efc7189 upstream.

The Sharp protocol[1] encoding has incorrect timings for bit space.

[1] https://www.sbprojects.net/knowledge/ir/sharp.php

Fixes: d35afc5fe0 ("[media] rc: ir-sharp-decoder: Add encode capability")
Cc: stable@vger.kernel.org
Reported-by: Joe Ferner <joe.m.ferner@gmail.com>
Closes: https://sourceforge.net/p/lirc/mailman/message/38604507/
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:20:12 +00:00
Sean Young
574bdc51e4 media: lirc: drop trailing space from scancode transmit
commit c8a489f820 upstream.

When transmitting, infrared drivers expect an odd number of samples; iow
without a trailing space. No problems have been observed so far, so
this is just belt and braces.

Fixes: 9b6192589b ("media: lirc: implement scancode sending")
Cc: stable@vger.kernel.org
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:20:11 +00:00
Vikash Garodia
074aed64f3 media: venus: hfi: add checks to perform sanity on queue pointers
commit 5e538fce33 upstream.

Read and write pointers are used to track the packet index in the memory
shared between video driver and firmware. There is a possibility of OOB
access if the read or write pointer goes beyond the queue memory size.
Add checks for the read and write pointer to avoid OOB access.

Cc: stable@vger.kernel.org
Fixes: d96d3f30c0 ("[media] media: venus: hfi: add Venus HFI files")
Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:19:54 +00:00
Takashi Iwai
2a493a34bd media: imon: fix access to invalid resource for the second interface
[ Upstream commit a1766a4fd8 ]

imon driver probes two USB interfaces, and at the probe of the second
interface, the driver assumes blindly that the first interface got
bound with the same imon driver.  It's usually true, but it's still
possible that the first interface is bound with another driver via a
malformed descriptor.  Then it may lead to a memory corruption, as
spotted by syzkaller; imon driver accesses the data from drvdata as
struct imon_context object although it's a completely different one
that was assigned by another driver.

This patch adds a sanity check -- whether the first interface is
really bound with the imon driver or not -- for avoiding the problem
above at the probe time.

Reported-by: syzbot+59875ffef5cb9c9b29e9@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/000000000000a838aa0603cc74d6@google.com/
Tested-by: Ricardo B. Marliere <ricardo@marliere.net>
Link: https://lore.kernel.org/r/20230922005152.163640-1-ricardo@marliere.net
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-28 17:19:47 +00:00
Sakari Ailus
e943d65c32 media: ccs: Fix driver quirk struct documentation
[ Upstream commit 441b5c63d7 ]

Fix documentation for struct ccs_quirk, a device specific struct for
managing deviations from the standard. The flags field was drifted away
from where it should have been.

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-28 17:19:47 +00:00
Ilpo Järvinen
86e281fcdc media: cobalt: Use FIELD_GET() to extract Link Width
[ Upstream commit f301fedbee ]

Use FIELD_GET() to extract PCIe Negotiated and Maximum Link Width fields
instead of custom masking and shifting.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-28 17:19:47 +00:00
Hans Verkuil
92152c4c56 media: vivid: avoid integer overflow
[ Upstream commit 4567ebf8e8 ]

Fixes these compiler warnings:

drivers/media/test-drivers/vivid/vivid-rds-gen.c: In function 'vivid_rds_gen_fill':
drivers/media/test-drivers/vivid/vivid-rds-gen.c:147:56: warning: '.' directive output may be truncated writing 1 byte into a region of size between 0 and 3 [-Wformat-truncation=]
  147 |         snprintf(rds->psname, sizeof(rds->psname), "%6d.%1d",
      |                                                        ^
drivers/media/test-drivers/vivid/vivid-rds-gen.c:147:52: note: directive argument in the range [0, 9]
  147 |         snprintf(rds->psname, sizeof(rds->psname), "%6d.%1d",
      |                                                    ^~~~~~~~~
drivers/media/test-drivers/vivid/vivid-rds-gen.c:147:9: note: 'snprintf' output between 9 and 12 bytes into a destination of size 9
  147 |         snprintf(rds->psname, sizeof(rds->psname), "%6d.%1d",
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  148 |                  freq / 16, ((freq & 0xf) * 10) / 16);
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-28 17:19:46 +00:00
Rajeshwar R Shinde
e2d7149b91 media: gspca: cpia1: shift-out-of-bounds in set_flicker
[ Upstream commit 099be1822d ]

Syzkaller reported the following issue:
UBSAN: shift-out-of-bounds in drivers/media/usb/gspca/cpia1.c:1031:27
shift exponent 245 is too large for 32-bit type 'int'

When the value of the variable "sd->params.exposure.gain" exceeds the
number of bits in an integer, a shift-out-of-bounds error is reported. It
is triggered because the variable "currentexp" cannot be left-shifted by
more than the number of bits in an integer. In order to avoid invalid
range during left-shift, the conditional expression is added.

Reported-by: syzbot+e27f3dbdab04e43b9f73@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/20230818164522.12806-1-coolrrsh@gmail.com
Link: https://syzkaller.appspot.com/bug?extid=e27f3dbdab04e43b9f73
Signed-off-by: Rajeshwar R Shinde <coolrrsh@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-28 17:19:46 +00:00
Guoniu.zhou
8e10e4e7d5 LF-10725: media: imx8-isi: fix kernel dump issue when open/close the same device node
When the video device is streaming and open/close it in other thread,
it will trigger kernel dump. The root cause is that the thread will
close the video device and driver will do clean operation in release
callback, but actually, the ISI channel still be used by the first
thread, so when new frame received, it triggers new interrupt but
the callback is cleaned by the second thread, so kernel dump are
triggered.

Reproduce steps:
1. v4l2-ctl -d "/dev/video2" -v width=1280,height=800,pixelformat=YUYV --stream-mmap
2. v4l2-ctl --list-dev

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reported-by: Jared Hu <jared.hu@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-11-28 09:23:58 +08:00
Guoniu.zhou
78c781d5d2 LF-10724: media: dwc-csi2: fix unused variable warning issue when build with clang
Fix unused variable warning issue when build with clang.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reported-by: Jindong Yue <jindong.yue@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-11-28 09:23:58 +08:00
Dong Aisheng
c4dbfabe86 LF-10676-1 arm64: dts: imx: fix alias_paths build warnings
Fix the following build warnings:

Before:
484  Warning (alias_paths)
After:
0    Warning (alias_paths)

Checked by:
make ARCH=arm64 W=1 dtbs 2>&1 | grep imx | grep alias_paths | wc -l

e.g.
arch/arm64/boot/dts/freescale/imx8qm.dtsi:21.10-63.4: Warning
(alias_paths): /aliases: aliases property name must include only
lowercase and '-'

NOTE vpu and nwl-dsi drivers also need update accordingly.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2023-11-22 17:05:04 +08:00
Dong Aisheng
06fec01db7 Merge branch 'pxp/next' into next
* pxp/next: (51 commits)
  LF-9755 dma: pxp_dma_v3: fix typo causing function break
  LF-9509: dma: pxp_dma_v3: fix dereference after null check issue
  LF-9435: dma: pxp_dma_v3: fix dereference after null check
  LF-8978: dma: pxp: fix fetch/store engine low performance issue
  LF-9276 media: mxc: pxp_v4l2: fix flickering issue found on special stream
  ...
2023-11-22 17:04:57 +08:00
Dong Aisheng
4ee7464398 Merge branch 'mxc/next' into next
* mxc/next: (519 commits)
  MGS-7343 [#nxp] fix the compile warning
  LF-10253: arm64: vpu : h1: solve encode hang
  MGS-7413 [#nxp] reorder the directory
  LF-10543-8: mxc: vpu: wave6: make sequence of decoder capture buffer monotonically increasing
  LF-10543-7: mxc: vpu: wave6: init seq in a separate task
  ...
2023-11-22 17:04:52 +08:00
Dong Aisheng
7f3644fe76 Merge branch 'capture/next' into next
* capture/next: (323 commits)
  LF-10587-08: media: v4l2-subdev: enable stream API
  LF-10587-07: media: i2c: add AP1302 driver from community
  LF-10587-05: media: nxp: add DesignWare MIPI CSI controller driver
  LF-10587-04: media: imx8-isi: add ISI support for iMX95
  LF-10587-03: media: imx8-isi: change ISI compatible string to avoid confliction
  ...
2023-11-22 17:04:45 +08:00
Dong Aisheng
9261a8220a Merge remote-tracking branch 'origin/mxc/vpu' into mxc/next
* origin/mxc/vpu: (159 commits)
  LF-10253: arm64: vpu : h1: solve encode hang
  LF-10543-8: mxc: vpu: wave6: make sequence of decoder capture buffer monotonically increasing
  LF-10543-7: mxc: vpu: wave6: init seq in a separate task
  LF-10543-6: mxc: vpu: wave6: make reserved memory optional
  LF-10543-5: mxc: vpu: wave6: avoid firmware alloc fb fail
  ...
2023-11-22 17:04:26 +08:00
Dong Aisheng
15cb75f619 Merge remote-tracking branch 'origin/capture/mt9m114' into capture/next
* origin/capture/mt9m114:
  LF-9089-02: media: i2c: mt9m114: adjust the output frequency to 72MHz
  LF-7052-04: media: i2c: add MT9M114 driver support for iMX93 platform
2023-11-22 17:03:56 +08:00
Dong Aisheng
f804e1c134 Merge remote-tracking branch 'origin/capture/ap1302' into capture/next
* origin/capture/ap1302:
  LF-10587-07: media: i2c: add AP1302 driver from community
  LF-6257-11: media: i2c: ap1302: add driver support for AP1302
2023-11-22 17:03:55 +08:00
Dong Aisheng
a5b79f65b3 Merge remote-tracking branch 'origin/capture/ov5640' into capture/next
* origin/capture/ov5640: (39 commits)
  LF-10336-2 media: ov5640_v2: Fix Division by zero problem
  LF-10336-1 media: ov5640: Fix Division by zero problem
  LF-8982: media: ov5640: fix abnormal frame issue after kernel upgrade
  LF-9639: media: ov5640: enable auto control mode for PCLK divider
  LF-9609: media: ov5640: fix vblank unchange issue when work at dvp mode
  ...
2023-11-22 17:03:55 +08:00
Dong Aisheng
980c9b12d1 Merge remote-tracking branch 'origin/capture/mxc' into capture/next
* origin/capture/mxc: (15 commits)
  LF-10199-1 media: csi: fix kernel dump when rmmod mx6s_capture module
  LF-9749 media: csi: Fix dump issue against NULL pointer dereference
  MA-20197-3 uapi: mxc_v4l2: use __u32 instead of uint32_t
  LF-7596 media: mxc_v4l2_capture: Fix build warning with gcc v12.2.0
  LF-7107-1: media: capture: csi: Fix intermittent camera failures
  ...
2023-11-22 17:03:55 +08:00
Dong Aisheng
92999cddd3 Merge remote-tracking branch 'origin/capture/media' into capture/next
* origin/capture/media: (6 commits)
  Revert "media: v4l2-ioctl: clear fields in s_parm"
  media: v4l2: export video_usercopy function
  Revert "media: v4l2-subdev.h: remove obsolete g/s_parm"
  MLK-20724: uapi: add RGBA to exend V4L2 standard format for android usage
  MLK-9662 [V4L2 Capture] Revert patch to re-add support for _G_CHIP_IDENT
  ...
2023-11-22 17:03:53 +08:00
Dong Aisheng
abd5b69a1e Merge remote-tracking branch 'origin/capture/jpeg' into capture/next
* origin/capture/jpeg:
  media: imx-jpeg: add support for imx9 jpeg codec
  media: imx-jpeg: notify source chagne event when the first picture parsed
  media: imx-jpeg: initiate a drain of the capture queue in dynamic resolution change
  LF-5926: media: imx-jpeg: Add soft reset after frame done
2023-11-22 17:03:53 +08:00
Dong Aisheng
5a869c343d Merge remote-tracking branch 'origin/capture/isi' into capture/next
* origin/capture/isi: (124 commits)
  LF-10587-08: media: v4l2-subdev: enable stream API
  LF-10587-04: media: imx8-isi: add ISI support for iMX95
  LF-10587-03: media: imx8-isi: change ISI compatible string to avoid confliction
  LF-10587-02: media: isi: change driver name in local ISI driver
  LF-10587-01: media: isi: fix conflict issue when enable config VIDEO_IMX8_ISI
  ...
2023-11-22 17:03:52 +08:00
Dong Aisheng
94673ec3a7 Merge remote-tracking branch 'origin/capture/csi2-dwc' into capture/next
* origin/capture/csi2-dwc:
  LF-10587-05: media: nxp: add DesignWare MIPI CSI controller driver
  LF-6257-09: media: imx: add Synopsys DWC MIPI CSI2 driver support for iMX93
2023-11-22 17:03:51 +08:00
Dong Aisheng
7e48799ffe Merge remote-tracking branch 'origin/capture/csi2-samsung' into capture/next
* origin/capture/csi2-samsung: (44 commits)
  LF-9695: media: csi-sam: fix typo issue
  LF-10199-2 media: mipi csi: fix calling order of v4l2_async_nf_[unregister|cleanup]
  LF-9958-2 media: Samsung CSI2: fix build error due to API change
  LF-9958-1 media: mipi csi: fix build error due to api change
  LF-8993: imx8mp: capture: csi support raw8 format
  ...
2023-11-22 17:03:51 +08:00
Guoniu.zhou
8468e078dc LF-10587-08: media: v4l2-subdev: enable stream API
Enable stream API since it's an experimental feature and need to
enable explicitly.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-11-22 14:10:45 +08:00
Guoniu.zhou
9c5639dcb4 LF-10587-07: media: i2c: add AP1302 driver from community
Add AP1302 driver from community but still not be accepted and the
activity in community has stopped, so I just use the base and make
work with our AP1302 device for iMX95 platform.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-11-22 14:07:33 +08:00
Guoniu.zhou
082dd12f8b LF-10587-05: media: nxp: add DesignWare MIPI CSI controller driver
Add V4L2 subdev driver for DesignWare MIPI CSI controller.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-11-22 11:33:59 +08:00
Guoniu.zhou
95e9eb8687 LF-10587-04: media: imx8-isi: add ISI support for iMX95
Add ISI support for iMX95

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-11-22 11:07:29 +08:00
Guoniu.zhou
47e82cf571 LF-10587-03: media: imx8-isi: change ISI compatible string to avoid confliction
ISI compatible string in upstream ISI driver are the same with local, so
change ISI compatible string in upstream version to avoid confliction
issue.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-11-22 11:07:22 +08:00
Marek Szyprowski
215f8cc508 media: cec: meson: always include meson sub-directory in Makefile
[ Upstream commit 94e27fbeca ]

'meson' directory contains two separate drivers, so it should be added
to Makefile compilation hierarchy unconditionally, because otherwise the
meson-ao-cec-g12a won't be compiled if meson-ao-cec is not selected.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Fixes: 4be5e8648b ("media: move CEC platform drivers to a separate directory")
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:33 +01:00
Moudy Ho
14e1dbe283 media: platform: mtk-mdp3: fix uninitialized variable in mdp_path_config()
[ Upstream commit 2a76e7679b ]

Fix the build warnings that were detected by the linux-media
build scripts tool:

drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c:
	In function 'mdp_path_config.isra':
drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c:
	warning: 'ctx' may be used uninitialized [-Wmaybe-uninitialized]
      |                    out = CFG_COMP(MT8195, ctx->param, outputs[0]);
      |                                           ~~~^~~~~~~
drivers/media/platform/mediatek/mdp3/mtk-img-ipi.h: note:
	in definition of macro 'CFG_COMP'
      |         (IS_ERR_OR_NULL(comp) ? 0 : _CFG_COMP(plat, comp, mem))
      |                         ^~~~
drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c:
	note: 'ctx' was declared here
      |         struct mdp_comp_ctx *ctx;
      |

Fixes: 61890ccaef ("media: platform: mtk-mdp3: add MediaTek MDP3 driver")
Signed-off-by: Moudy Ho <moudy.ho@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:33 +01:00
Yunfei Dong
8bdaa92be1 media: mediatek: vcodec: using encoder device to alloc/free encoder memory
[ Upstream commit 56c0ac05a3 ]

Need to use encoder device to allocate/free encoder memory when calling
mtk_vcodec_mem_alloc/mtk_vcodec_mem_free, or leading to below crash log
when test encoder with decoder device.

pc : dma_alloc_attrs+0x44/0xf4
lr : mtk_vcodec_mem_alloc+0x50/0xa4 [mtk_vcodec_common]
sp : ffffffc0209f3990
x29: ffffffc0209f39a0 x28: ffffff8024102a18 x27: 0000000000000000
x26: 0000000000000000 x25: ffffffc00c06e2d8 x24: 0000000000000001
x23: 0000000000000cc0 x22: 0000000000000010 x21: 0000000000000800
x20: ffffff8024102a18 x19: 0000000000000000 x18: 0000000000000000
x17: 0000000000000009 x16: ffffffe389736a98 x15: 0000000000000078
x14: ffffffe389704434 x13: 0000000000000007 x12: ffffffe38a2b2560
x11: 0000000000000800 x10: 0000000000000004 x9 : ffffffe331f07484
x8 : 5400e9aef2395000 x7 : 0000000000000000 x6 : 000000000000003f
x5 : 0000000000000001 x4 : 0000000000000000 x3 : 0000000000000cc0
x2 : ffffff8024102a18 x1 : 0000000000000800 x0 : 0000000000000010
Call trace:
 dma_alloc_attrs+0x44/0xf4
 mtk_vcodec_mem_alloc+0x50/0xa4 [mtk_vcodec_common 2819d3d601f3cd06c1f2213ac1b9995134441421]
 h264_enc_set_param+0x27c/0x378 [mtk_vcodec_enc 772cc3d26c254e8cf54079451ef8d930d2eb4404]
 venc_if_set_param+0x4c/0x7c [mtk_vcodec_enc 772cc3d26c254e8cf54079451ef8d930d2eb4404]
 vb2ops_venc_start_streaming+0x1bc/0x328 [mtk_vcodec_enc 772cc3d26c254e8cf54079451ef8d930d2eb4404]
 vb2_start_streaming+0x64/0x12c
 vb2_core_streamon+0x114/0x158
 vb2_streamon+0x38/0x60
 v4l2_m2m_streamon+0x48/0x88
 v4l2_m2m_ioctl_streamon+0x20/0x2c
 v4l_streamon+0x2c/0x38
 __video_do_ioctl+0x2c4/0x3dc
 video_usercopy+0x404/0x934
 video_ioctl2+0x20/0x2c
 v4l2_ioctl+0x54/0x64
 v4l2_compat_ioctl32+0x90/0xa34
 __arm64_compat_sys_ioctl+0x128/0x13c
 invoke_syscall+0x4c/0x108
 el0_svc_common+0x98/0x104
 do_el0_svc_compat+0x28/0x34
 el0_svc_compat+0x2c/0x74
 el0t_32_sync_handler+0xa8/0xcc
 el0t_32_sync+0x194/0x198
Code: aa0003f6 aa0203f4 aa0103f5 f900

'Fixes: 01abf5fbb0 ("media: mediatek: vcodec: separate struct 'mtk_vcodec_ctx'")'
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:33 +01:00
Ming Qian
2b2a4fcfb1 media: imx-jpeg: notify source chagne event when the first picture parsed
[ Upstream commit b833b17849 ]

After gstreamer rework the dynamic resolution change handling, gstreamer
stop doing capture buffer allocation based on guesses and wait for the
source change event when available. It requires driver always notify
source change event in the initialization, even if the size parsed is
equal to the size set on capture queue. otherwise, the pipeline will be
stalled.

Currently driver may not notify source change event if the parsed format
and size are equal to those previously established, but it may stall the
gstreamer pipeline.

The link of gstreamer patch is
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4437

Fixes: b4e1fb8643 ("media: imx-jpeg: Support dynamic resolution change")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:33 +01:00
Irui Wang
a4b31459ce media: mediatek: vcodec: Handle invalid encoder vsi
[ Upstream commit 19e2e01f30 ]

Handle invalid encoder vsi in vpu_enc_init to ensure the encoder
vsi is valid for future use.

Fixes: 1972e32431 ("media: mediatek: vcodec: Fix possible invalid memory access for encoder")

Signed-off-by: Irui Wang <irui.wang@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:33 +01:00
Benjamin Gaignard
0747b6f7a3 media: verisilicon: Fixes clock list for rk3588 av1 decoder
[ Upstream commit 39377f84fb ]

Mainlined RK3588 clock driver manage by itself the dependency between
aclk/hclk and their root clocks (aclk_vdpu_root/hclk_vdpu_root).
RK3588 av1 video decoder do not have to take care of it anymore so
remove them from the list and be compliant with yaml bindings description.

Fixes: 003afda97c ("media: verisilicon: Enable AV1 decoder on rk3588")
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:33 +01:00
Hans Verkuil
2b9cecf001 media: dvb-usb-v2: af9035: fix missing unlock
[ Upstream commit f31b2cb85f ]

Instead of returning an error, goto the mutex unlock at
the end of the function.

Fixes smatch warning:

drivers/media/usb/dvb-usb-v2/af9035.c:467 af9035_i2c_master_xfer() warn: inconsistent returns '&d->i2c_mutex'.
  Locked on  : 326,387
  Unlocked on: 465,467

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Fixes: 7bf744f2de ("media: dvb-usb-v2: af9035: Fix null-ptr-deref in af9035_i2c_master_xfer")
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:33 +01:00
Pratyush Yadav
c1c88d6692 media: cadence: csi2rx: Unregister v4l2 async notifier
[ Upstream commit b270171530 ]

The notifier is added to the global notifier list when registered. When
the module is removed, the struct csi2rx_priv in which the notifier is
embedded, is destroyed. As a result the notifier list has a reference to
a notifier that no longer exists. This causes invalid memory accesses
when the list is iterated over. Similar for when the probe fails.
Unregister and clean up the notifier to avoid this.

Fixes: 1fc3b37f34 ("media: v4l: cadence: Add Cadence MIPI-CSI2 RX driver")

Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
Tested-by: Julien Massot <julien.massot@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Jai Luthra <j-luthra@ti.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:32 +01:00
Laurent Pinchart
cf33173063 media: i2c: imx219: Drop IMX219_REG_CSI_LANE_MODE from common regs array
[ Upstream commit ec80c606cc ]

The IMX219_REG_CSI_LANE_MODE is configured twice, once with a hardcoded
value in the imx219_common_regs registers array, and once with the value
appropriate for the system in imx219_configure_lanes(). The latter is
enough, drop the former.

Fixes: ceddfd4493 ("media: i2c: imx219: Support four-lane operation")
Suggested-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:32 +01:00
Laurent Pinchart
ae6f196a8d media: i2c: imx219: Replace register addresses with macros
[ Upstream commit 1c9083565a ]

Define macros for all the known registers used in the register arrays,
and use them to replace the numerical addresses. This improves
readability.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Stable-dep-of: ec80c606cc ("media: i2c: imx219: Drop IMX219_REG_CSI_LANE_MODE from common regs array")
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:32 +01:00
Laurent Pinchart
2e943af4c7 media: i2c: imx219: Convert to CCI register access helpers
[ Upstream commit 852798cc8a ]

Use the new common CCI register access helpers to replace the private
register access helpers in the imx219 driver. This simplifies the driver
by reducing the amount of code.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Stable-dep-of: ec80c606cc ("media: i2c: imx219: Drop IMX219_REG_CSI_LANE_MODE from common regs array")
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:32 +01:00
Jiasheng Jiang
aae7598aff media: vidtv: mux: Add check and kfree for kstrdup
[ Upstream commit 1fd6eb1264 ]

Add check for the return value of kstrdup() and return the error
if it fails in order to avoid NULL pointer dereference.
Moreover, use kfree() in the later error handling in order to avoid
memory leak.

Fixes: c2f78f0cb2 ("media: vidtv: psi: add a Network Information Table (NIT)")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:32 +01:00
Jiasheng Jiang
a51335704a media: vidtv: psi: Add check for kstrdup
[ Upstream commit 76a2c5df6c ]

Add check for the return value of kstrdup() and return the error
if it fails in order to avoid NULL pointer dereference.

Fixes: 7a7899f6f5 ("media: vidtv: psi: Implement an Event Information Table (EIT)")
Fixes: c2f78f0cb2 ("media: vidtv: psi: add a Network Information Table (NIT)")
Fixes: f90cf6079b ("media: vidtv: add a bridge driver")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:32 +01:00
Katya Orlova
f93844d2c8 media: s3c-camif: Avoid inappropriate kfree()
[ Upstream commit 61334819ac ]

s3c_camif_register_video_node() works with video_device structure stored
as a field of camif_vp, so it should not be kfreed.
But there is video_device_release() on error path that do it.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: babde1c243 ("[media] V4L: Add driver for S3C24XX/S3C64XX SoC series camera interface")
Signed-off-by: Katya Orlova <e.orlova@ispras.ru>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:32 +01:00
Fei Shao
495fd08887 media: mtk-jpegenc: Fix bug in JPEG encode quality selection
[ Upstream commit 0aeccc63f3 ]

The driver uses the upper-bound approach to decide the target JPEG
encode quality, but there's a logic bug that if the desired quality is
higher than what the driver can support, the driver falls back to using
the worst quality.

Fix the bug by assuming using the best quality in the beginning, and
with trivial refactor to avoid long lines.

Fixes: 45f13a57d8 ("media: platform: Add jpeg enc feature")
Signed-off-by: Fei Shao <fshao@chromium.org>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:32 +01:00
Ming Qian
746143690e media: amphion: handle firmware debug message
[ Upstream commit 6496617b2b ]

decoder firmware may notify host some debug message,
it can help analyze the state of the firmware in case of error

Fixes: 9f599f351e ("media: amphion: add vpu core driver")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:32 +01:00
Zheng Wang
847599fffa media: bttv: fix use after free error due to btv->timeout timer
[ Upstream commit bd5b50b329 ]

There may be some a race condition between timer function
bttv_irq_timeout and bttv_remove. The timer is setup in
probe and there is no timer_delete operation in remove
function. When it hit kfree btv, the function might still be
invoked, which will cause use after free bug.

This bug is found by static analysis, it may be false positive.

Fix it by adding del_timer_sync invoking to the remove function.

cpu0                cpu1
                  bttv_probe
                    ->timer_setup
                      ->bttv_set_dma
                        ->mod_timer;
bttv_remove
  ->kfree(btv);
                  ->bttv_irq_timeout
                    ->USE btv

Fixes: 162e6376ac ("media: pci: Convert timers to use timer_setup()")
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:32 +01:00
Xiaolei Wang
f9f6e9cb99 media: ov5640: Fix a memory leak when ov5640_probe fails
[ Upstream commit 20290feaae ]

sensor->ctrls.handler is initialized in ov5640_init_controls(),
so when the sensor is not connected and ov5640_sensor_resume()
fails, sensor->ctrls.handler should be released, otherwise a
memory leak will be detected:

unreferenced object 0xc674ca80 (size 64):
   comm "swapper/0", pid 1, jiffies 4294938337 (age 204.880s)
   hex dump (first 32 bytes):
     80 55 75 c6 80 54 75 c6 00 55 75 c6 80 52 75 c6 .Uu..Tu..Uu..Ru.
     00 53 75 c6 00 00 00 00 00 00 00 00 00 00 00 00 .Su..........

Fixes: 85644a9b37 ("media: ov5640: Use runtime PM")
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:32 +01:00
Christophe JAILLET
9bceb07784 media: i2c: max9286: Fix some redundant of_node_put() calls
[ Upstream commit 0822315e46 ]

This is odd to have a of_node_put() just after a for_each_child_of_node()
or a for_each_endpoint_of_node() loop. It should already be called
during the last iteration.

Remove these calls.

Fixes: 66d8c9d242 ("media: i2c: Add MAX9286 driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:31 +01:00
Guoniu.zhou
cd567e637f media: ov5640: fix vblank unchange issue when work at dvp mode
[ Upstream commit 8fc29e3c9f ]

The value of V4L2_CID_VBLANK control is initialized to default vblank
value of 640x480 when driver probe. When OV5640 work at DVP mode, the
control value won't update and lead to sensor can't output data if the
resolution remain the same as last time since incorrect total vertical
size. So update it when there is a new value applied.

Fixes: bce93b827d ("media: ov5640: Add VBLANK control")
Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:31 +01:00
Dan Carpenter
adf4abf768 media: ov13b10: Fix some error checking in probe
[ Upstream commit d66b45e1b0 ]

The "ret = " assignment was missing, so ov13b10_power_on() is not
checked for errors.  Add the assignment.

Fixes: 6e28afd152 ("media: ov13b10: add PM control support based on power resources")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:31 +01:00
Marek Vasut
0fe806fbd7 media: verisilicon: Do not enable G2 postproc downscale if source is narrower than destination
[ Upstream commit 6e481d52d3 ]

In case of encoded input VP9 data width that is not multiple of macroblock
size, which is 16 (e.g. 1080x1920 frames, where 1080 is multiple of 8), the
width is padded to be a multiple of macroblock size (for 1080x1920 frames,
that is 1088x1920).

The hantro_postproc_g2_enable() checks whether the encoded data width is
equal to decoded frame width, and if not, enables down-scale mode. For a
frame where input is 1080x1920 and output is 1088x1920, this is incorrect
as no down-scale happens, the frame is only padded. Enabling the down-scale
mode in this case results in corrupted frames.

Fix this by adjusting the check to test whether encoded data width is
greater than decoded frame width, and only in that case enable the
down-scale mode.

To generate input test data to trigger this bug, use e.g.:
$ gst-launch-1.0 videotestsrc ! video/x-raw,width=272,height=256,format=I420 ! \
                 vp9enc ! matroskamux ! filesink location=/tmp/test.vp9
To trigger the bug upon decoding (note that the NV12 must be forced, as
that assures the output data would pass the G2 postproc):
$ gst-launch-1.0 filesrc location=/tmp/test.vp9 ! matroskademux ! vp9parse ! \
                 v4l2slvp9dec ! video/x-raw,format=NV12 ! videoconvert ! fbdevsink

Fixes: 79c987de8b ("media: hantro: Use post processor scaling capacities")
Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:31 +01:00
Marek Vasut
24c06295f2 media: hantro: Check whether reset op is defined before use
[ Upstream commit 88d4b23a62 ]

The i.MX8MM/N/P does not define the .reset op since reset of the VPU is
done by genpd. Check whether the .reset op is defined before calling it
to avoid NULL pointer dereference.

Note that the Fixes tag is set to the commit which removed the reset op
from i.MX8M Hantro G2 implementation, this is because before this commit
all the implementations did define the .reset op.

Fixes: 6971efb70a ("media: hantro: Allow i.MX8MQ G1 and G2 to run independently")
Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Tested-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: Adam Ford <aford173@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:31 +01:00
Ming Qian
8e629e95d2 media: imx-jpeg: initiate a drain of the capture queue in dynamic resolution change
[ Upstream commit 1c2786632e ]

The last buffer from before the change must be marked,
with the V4L2_BUF_FLAG_LAST flag,
similarly to the Drain sequence above.

Meanwhile if V4L2_DEC_CMD_STOP is sent before
the source change triggered,
we need to restore the is_draing flag after
the draining in dynamic resolution change.

Fixes: b4e1fb8643 ("media: imx-jpeg: Support dynamic resolution change")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:31 +01:00
Robby Cai
fec242e14a LF-10336-2 media: ov5640_v2: Fix Division by zero problem
On some sensor (probably broken), the register SC PLL CONTROLL0 is read out as 0
even it's initialized to 0x1A which cause 'Division by zero' issue.
Default to 8bit setting to fix it.

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Guoniu.zhou <guoniu.zhou@nxp.com>
2023-11-17 18:16:07 +08:00
Robby Cai
f4716672ed LF-10336-1 media: ov5640: Fix Division by zero problem
On some sensor (probably broken), the register SC PLL CONTROLL0 is read out as 0
even it's initialized to 0x1A which cause 'Division by zero' issue as follows.
Default to 8bit setting to fix it.

[ 4050.428618] camera ov5640 is found
[ 4050.532056] ERROR: v4l2 capture: slave not found!
[ 4050.828774] ov5640: unsupported bit mode 0
[ 4050.840158] Division by zero in kernel.
[ 4050.844009] CPU: 1 PID: 4605 Comm: v4l_id Tainted: G O 6.6.0-rc6-04945-gd83c346a4bc5 #1
[ 4050.853416] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[ 4050.859956] unwind_backtrace from show_stack+0x10/0x14
[ 4050.865228] show_stack from dump_stack_lvl+0x40/0x4c
[ 4050.870313] dump_stack_lvl from Ldiv0+0x8/0x10
[ 4050.874875] Ldiv0 from ov5640_set_bandingfilter+0x10c/0x2b0 [ov5640_camera_int]
[ 4050.882332] ov5640_set_bandingfilter [ov5640_camera_int] from ioctl_dev_init+0x148/0x2b4 [ov5640_camera_int]
[ 4050.892344] ioctl_dev_init [ov5640_camera_int] from mxc_v4l_open+0x2b8/0x3a0 [mxc_v4l2_capture]
[ 4050.901257] mxc_v4l_open [mxc_v4l2_capture] from v4l2_open+0x9c/0x108
[ 4050.907865] v4l2_open from chrdev_open+0xc8/0x210
[ 4050.912713] chrdev_open from do_dentry_open+0x1d4/0x528

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Guoniu.zhou <guoniu.zhou@nxp.com>
2023-11-17 18:16:07 +08:00
Ming Qian
1ce894d1ed media: imx-jpeg: add support for imx9 jpeg codec
add match for "fsl,imx9-jpgdec" and "fsl,imx9-jpgenc"

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: TaoJiang <tao.jiang_2@nxp.com>
2023-11-15 15:05:47 +09:00
Robby Cai
c6eceff48a LF-9276 media: mxc: pxp_v4l2: fix flickering issue found on special stream
There is special stream, in which "progressive_sequence" read from buffers is
sometimes 1 and sometimes 0. Libav need to update its caps if "progressive_sequence"
changes from 0 to 1 or vice versa, then imxv4l2sink needs to reset caps. This
means pxp_v4l2 needs to streamoff then streamon each time.

Flickering issue happens because pxp_streamoff( ) always calls pxp_show_buf() to
recover content of the framebuffer. Each time imxv4l2sink reset caps, flickering-like
issue happens.

This patch is to move the pxp_show_buf() to pxp_close() to avoid the issue.

Reported-and-suggested-by: Qi Hou <qi.hou@nxp.com>
Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: G.N. Zhou <guoniu.zhou@nxp.com>
(cherry picked from commit 6acbe7aaae)
2023-10-30 16:08:22 +08:00
Dong Aisheng
5cdaffc102 LF-1162-19 media: mxc: pxp_v4l2: change to use VFL_TYPE_VIDEO
The legacy one VFL_TYPE_GRABBER was removed since:
dc42cf74d9 ("media: v4l2-dev.h: remove VFL_TYPE_GRABBER")

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2023-10-30 16:08:19 +08:00
Robby Cai
dd7e08e00c media: v4l2: add pxp_v4l2 driver
add pxp v4l2 driver

Signed-off-by: Robby Cai <robby.cai@nxp.com>
[ Guoniu: Remove VIDEO_V4L2 because it's duplicated with VIDEO_DEV ]
[ Robby: Change DMA_FROM_DEVICE to DMA_DEV_TO_MEM ]
Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
2023-10-30 16:08:18 +08:00
Ming Qian
c4a25e0064 MMFMWK-9232: media: amphion: vdec always trigger source change for interlaced case
gstreamer will prefer acquired caps over anything downstream,
then interlaced stream may be not trigger an source change event,
but amphion doesn't support interlaced to progressive,
for interlaced case, it need to output interlaced.

so the resolution change event is required.

the above case is included in
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4317

but gstreamer is planed to modify the resolution change flow,
then this patch is no need, so don't upstream this patch.
(https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4437)

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Tested-by: Elliot Chen <elliot.chen@nxp.com>
Reviewed-by: TaoJiang <tao.jiang_2@nxp.com>
2023-10-30 15:58:08 +08:00
Liu Ying
50e1664acc media: platform: mxc: output: Forward IPUv3 V4L2 output driver from imx_4.19.y
This patch forwards IPUv3 V4l2 output driver from imx_4.19.y kernel.

[ Liu Ying: remove unused get_jiffies(), resolve conflicts related to
            vb->ts, some ioctrls(vidioc_cropcap, vidioc_g_crop and
            vidioc_s_crop) and mxc_vout_template->device_caps ]

Signed-off-by: Liu Ying <victor.liu@nxp.com>
[ Aisheng: squash legacy patches ]
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
[ Liu Ying: Defer probe when num_registered_fb == 0 ]
Signed-off-by: Liu Ying <victor.liu@nxp.com>
2023-10-30 15:56:26 +08:00
Liu Ying
430015db3d mxc: IPU3: Forward IPUv3 common driver from imx_4.19.y kernel
This patch forwards IPUv3 common driver from imx_4.19.y kernel.
This includs IPUv3 common, IPUv3 prefetch engine and VDOA support.

Reviewed-by: Sandor Yu <Sandor.yu@nxp.com>
Signed-off-by: Liu Ying <victor.liu@nxp.com>
[ Aisheng: squash legacy patches ]
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
[ Liu Ying: Use platform_get_irq() to get vdoa irq, not platform_get_resource() ]
[ Liu Ying: Check bypass_reset to do internal reset in ipu_probe() ]
Signed-off-by: Liu Ying <victor.liu@nxp.com>
[ Liu Ying: Set ipu->online to false if device_reset() fails ]
Signed-off-by: Liu Ying <victor.liu@nxp.com>
[ Liu Ying: Call dev_err_probe() if device_reset() fails in ipu_probe() ]
Signed-off-by: Liu Ying <victor.liu@nxp.com>
[ Robby Cai: Update class_create() api ]
Signed-off-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:56:26 +08:00
Guoniu.zhou
5cd08b0bc1 LF-9089-02: media: i2c: mt9m114: adjust the output frequency to 72MHz
72MHz is maximum pixel clock frequency value of MT9M114 can output to
iMX93 parallel interface due to the maximum 80MHz input frequency
limitation of iMX93 parallel interface.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:29:39 +08:00
Guoniu.zhou
f5eb071582 LF-7052-04: media: i2c: add MT9M114 driver support for iMX93 platform
Add MT9M114 driver support for iMX93 platform

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:29:39 +08:00
Guoniu.zhou
7a26081aea LF-6257-11: media: i2c: ap1302: add driver support for AP1302
Add Video4Linux2 driver support for ON AP1302 ISP device

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:29:12 +08:00
Guoniu.zhou
9228767336 LF-8982: media: ov5640: fix abnormal frame issue after kernel upgrade
OV5640 will output abnormal frame issue randomly after introduce commit
8064bbb754 ("media: ov5640: Fix soft reset sequence and timings") in
community. It conflict with our local commit 8ae98c8f70 (media: i2c:
ov5640: do software power down during mode change") which used to fix
abnormal frame issue when do mode change, so remove the redundant soft
power down operation. It's a temporary solution to fix this issue since
we need to algin upstream as more as possible.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:28:47 +08:00
Guoniu.zhou
ef63c8538d LF-9639: media: ov5640: enable auto control mode for PCLK divider
Enable auto control mode for PCLK divider by default as recommended
by OmniVision to fix 1024x768@30 and 2592x1944@15 can't work after
boot up.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:28:47 +08:00
Guoniu.zhou
add29182aa LF-9609: media: ov5640: fix vblank unchange issue when work at dvp mode
The value of V4L2_CID_VBLANK control is initialized to default vblank
value of 640x480 when driver probe. When OV5640 work at DVP mode, the
control value won't update and lead to sensor can't output data if the
resolution remain the same as last time since incorrect total vertical
size. So update it when there is a new value applied.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:28:47 +08:00
Guoniu.zhou
4e385388f0 Revert "LF-7244-08: media: i2c: ov5640: fix 1080P and 1024x768 abnormal image issue"
This reverts commit 71f22c24ef.

The required bit rate for 1080P@30 when OV5640 work at DVP mode is
168MHz, but the maximum frequency supported by CI_PI is 160MHz, so
the theoretical frame rate should be about 28fps. The actual frame
rate only can reach to 25fps based on my experimental results. This
is root cause why 1080P@30 can't output normal image. So revert commit
71f22c24ef since it's limitaion of CI_PI module.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:28:47 +08:00
Guoniu.zhou
dd40f93693 LF-8868: media: ov5640: fix incorrect frame frate issue
If run OV5640 with 640x480@30 setting after power up, the real
frame rate for it is 60, not 30. The reason is default frame
interval parameter in probe is 30 but default link frequency is
to generate 60 frame rate, so correct it.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:28:47 +08:00
Guoniu.zhou
dc77fbccd3 LF-7625-01: media: i2c: ov5640: remove 60fps support for 640x480
Remove 640x480@60 support since not verified by iMX platform.
It's a temporary patch and will add 640x480@60 support for iMX
platform in the furture.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:28:47 +08:00
Guoniu.zhou
2cde7298b7 LF-7536: media: i2c: ov5640: fix read register back zero issue
For some ov5640 sensor, the value of all register will return to
zero when do sanity test include R0x300a(CHIPID) which should always
return 0x5640. The reason is that writing PLL system root divider after
loading ov5640 init setting. The solution is do software power down after
loading ov5640 init setting in order to confirm ov5640 in a configured
state and change PLL setting will not cause issue.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:28:46 +08:00
Guoniu.zhou
51cf132302 Revert "media: ov5640: Use runtime PM"
This reverts commit 85644a9b37 since it remove
s_power subdev ops and cause CSI driver fail. The runtime PM for ov5640 is
optional and not stable. So revert it as temporary solution to make ov5640
work normally on iMX platform
2023-10-30 15:28:46 +08:00
Guoniu.zhou
9ec8d9f702 LF-7244-08: media: i2c: ov5640: fix 1080P and 1024x768 abnormal image issue
Fix 1080P and 1024x768 abnormal image issue when ov5640 work at DVP mode.
The most image data of 1080P are zero and 1024x768 image outline can be
seen but the image is not correct. Refer to OV5640 data sheet, restore
OV5640 MIPI mode to 10-bit when OV5640 work at DVP mode since it's default
configuration after OV5640 power up.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:28:46 +08:00
Guoniu.zhou
638988c40d LF-7244-07: media: i2c: ov5640: fix low resolution abnormal image issue
Low resolution, such as 176x144, will have abnormal image issue when
mode switch from 720P to low resolution. Compared all related registers
with normal case, the issue can be fixed when set register 0x3824 to
0x2 in low resolution register configuration table. Can't describe the
reason why it can fix this issue due to missing 0x3824 description in
OV5640 data sheet, so just record the reason and the issue it can fix

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:28:46 +08:00
Guoniu.zhou
8d1ced0d41 iLF-7244-05: media: i2c: ov5640: fix the dark image issue
The first frame will have dark issue since auto exposure is not
stable in the previous frames, so add 100ms delay to skip the
first three frames.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:28:46 +08:00
Guoniu.zhou
c265a120c4 LF-7244-04: media: i2c: ov5640: fix the first frame green background issue
The first frame will have green background issue. The reason is low
output drive capability in sensor side. So setting drive capability
to 4x can fix this issue.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:28:46 +08:00
Guoniu.zhou
cd467c7842 LF-7244-03: media: i2c: ov5640: do software power down during mode change
Some modes will have random abnormal image issue in the previous frames
When do mode switching stress test. If do software power down operation
during mode change setting, the issue gone.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:28:46 +08:00
Alice Yuan
58ba5ec440 LF-7107-2: media: capture: ov5640: Reduce the delay time for sensor to be stable
When do stress test of capture, taking pictures and rebooting.
it will find that about 5% of them are black, the pictures shouldn't be black.

Root cause:
The delay time in the initial of the ov5640 wouldn't prevent dark image from
passing to the buffer. So it need to be optimized.

The few frames of ov5640 AE/AG is not stable,
and at the begin of the few frames, the ov5640 sensor 3A is under adjustment.
And the picture data is dirty, should be skipped.

Signed-off-by: Alice Yuan <alice.yuan@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:28:46 +08:00
Sandor Yu
163af2fc25 LF-6668-1: media: mxc: ov5640: Disable -Wcast-function-type
Disable -Wcast-function-type to avoid build warning.

Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:28:46 +08:00
Robby Cai
dec85f2f15 LF-5735 media: ov5640: Fix Coverity Issue: 21141306 Out-of-bounds read
Fix Coverity Issue: 21141306 Out-of-bounds read

overrun-local: Overrunning array ov5640_mode_info_data[frame_rate] of at element index 255

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Alice Yuan <alice.yuan@nxp.com>
2023-10-30 15:28:46 +08:00
zhipeng.wang
b9e280a493 MA-19173 CONFIG_UBSAN cause kernel panic when connect camera
[    8.048049][  T223] Unexpected kernel BRK exception at E1
[    8.051385][  T223] Internal error: BRK handler: f2000001 [#1]PREEMPT SMP
[    8.287484][  T223] Call trace:
[    8.290630][  T223]  ov5640_probe+0x854/0x858 [ov5640_camera_mipi_v2]
[    8.297077][  T223]  i2c_device_probe+0x200/0x280
[    8.301785][  T223]  really_probe+0x1c0/0x4a8
[    8.306143][  T223]  driver_probe_device+0x68/0xc0
[    8.310935][  T223]  device_driver_attach+0x70/0xb4
[    8.315814][  T223]  __driver_attach+0xc8/0x150
[    8.320346][  T223]  bus_for_each_dev+0x84/0xd4
[    8.324878][  T223]  driver_attach+0x28/0x38
[    8.329149][  T223]  bus_add_driver+0x108/0x1e8
[    8.333681][  T223]  driver_register+0x7c/0x118
[    8.338214][  T223]  i2c_register_driver+0x48/0xa4
[    8.343010][  T223]  init_module+0x24/0xfe8 [ov5640_camera_mipi_v2]
[    8.349280][  T223]  do_one_initcall+0xec/0x318
[    8.353814][  T223]  do_init_module+0x60/0x3a0
[    8.358262][  T223]  load_module+0x2ad0/0x3248
[    8.362708][  T223]  __arm64_sys_finit_module+0xbc/0xfc
[    8.367935][  T223]  el0_svc_common+0xa4/0x180
[    8.372380][  T223]  do_el0_svc+0x28/0x7c
[    8.376392][  T223]  el0_svc+0x14/0x24
[    8.380142][  T223]  el0_sync_handler+0x6c/0xb4
[    8.384673][  T223]  el0_sync+0x19c/0x1c0

UBSAN is a runtime undefined behaviour checker.

Array ov5640_mode_info_data[2][5], and the value of mode and orig_mode
may be 0xff, so there is an undefined access problem.

Change-Id: I9e3487fa2fe2543e37018c494a159345b5ab991e
Signed-off-by: zhipeng.wang <zhipeng.wang_1@nxp.com>
2023-10-30 15:28:46 +08:00
Robby Cai
21feaf9a74 LF-2855-1 media: camera: Fix Coverity Issue: 17397 Unsigned compared against 0
remove the comparison against 0 which is not necessary

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: G.N. Zhou <guoniu.zhou@nxp.com>
2023-10-30 15:28:46 +08:00
Robby Cai
3fb6643e7b LF-4155-9 media: capture: ov5640: fix build error due to api change
Replace struct v4l2_subdev_pad_config with struct v4l2_subdev_state
due to V4L2 API change as follows:

0d346d2a6f ("media: v4l2-subdev: add subdev-wide state struct")

Signed-off-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:28:45 +08:00
Robby Cai
a9a4f12b7f LF-4155-3 media: ov5640: fix build error due to api change
Replace struct v4l2_subdev_pad_config with struct v4l2_subdev_state
due to V4L2 API change as follows:

0d346d2a6f ("media: v4l2-subdev: add subdev-wide state struct")

Signed-off-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:28:45 +08:00
Robby Cai
ac7daa1273 LF-2855 media: camera: Fix Coverity Issue: 17397 Unsigned compared against 0
remove the comparison against 0 which is not necessary

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: G.n. Zhou <guoniu.zhou@nxp.com>
2023-10-30 15:28:45 +08:00
Robby Cai
687439407a LF-2853 media: camera: Fix Coverity Issue: 17391 Unsigned compared against 0
remove the comparison against 0 which is not necessary

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: G.n. Zhou <guoniu.zhou@nxp.com>
2023-10-30 15:28:45 +08:00
Guoniu.zhou
fd0a355246 MLK-23712: media: capture: add get/set_register callback
In ov5640_mipi_v2.c, driver don't implement get_register/set_register
callback but assign ov5640_get_register/ov5640_set_register to
v4l2_subdev_core_ops->get_register/set_register if define
CONFIG_VIDEO_ADV_DEBUG, so implement them in this patch.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:28:45 +08:00
Robby Cai
fdf9ce9681 LF-1564 media: capture: check return value of devm_kzalloc against NULL
check return value agaist NULL for devm_kzalloc()
Fix Coverity Issue ID: 6091815

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: G.n. Zhou <guoniu.zhou@nxp.com>
2023-10-30 15:28:45 +08:00
Dong Aisheng
786d340238 LF-1011-24 media: mxc: ov5640_mipi_v2: fix build due to i2c_new_dummy removed
API changed since:
2c2f00ab16 ("i2c: remove i2c_new_dummy() API")

../drivers/media/platform/mxc/capture/ov5640_mipi_v2.c: In function ‘ov5640_update_slave_id’:
../drivers/media/platform/mxc/capture/ov5640_mipi_v2.c:524:3: error: implicit declaration of function ‘i2c_new_dummy’ [-Werror=implicit-function-declaration]
  524 |   i2c_new_dummy(tmp_client->adapter, DEFAULT_SCCB_ID >> 1);
      |   ^~~~~~~~~~~~~
../drivers/media/platform/mxc/capture/ov5640_mipi_v2.c:523:21: warning: assignment to ‘struct i2c_client *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  523 |  sensor->i2c_client =
      |                     ^

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2023-10-30 15:28:45 +08:00
Dong Aisheng
3801fb12e2 LF-665-21 mxc: ov5640: fix build break due to un-exist pr_warning
pr_warning does not exist anymore.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2023-10-30 15:28:45 +08:00
Robby Cai
f6acfecd91 LF-237 media: ov5640_mipi: fix regulator dump when i2c access for camera fail
in 5451781dad commit, it added the check that
the regulator need to be disabled before calling regulator_put().

when i2c access for camera fails in some case, need disable the regulator to
fix following dump message.

[    3.881140] i2c i2c-2: cannot deal with slave irq,i2c_imx->slave is null
[    3.981772] ov5640_mipi 2-003c: Write reg error: reg=3008, val=2
[    3.987841] ov5640_mipi 2-003c: Camera init failed
[    4.001224] ------------[ cut here ]------------
[    4.005949] WARNING: CPU: 2 PID: 189 at drivers/regulator/core.c:2042 _regulator_put.part.0+0x140/0x148
[    4.015363] Modules linked in:
[    4.018466] CPU: 2 PID: 189 Comm: kworker/2:2 Not tainted 5.4.0-rc7-5.4-zeus-next+g56a9ca3b7f4e #1
[    4.027434] Hardware name: FSL i.MX8MM EVK board (DT)
[    4.032554] Workqueue: events deferred_probe_work_func
[    4.037712] pstate: 80000005 (Nzcv daif -PAN -UAO)
[    4.042511] pc : _regulator_put.part.0+0x140/0x148
[    4.047316] lr : regulator_put+0x34/0x48
[    4.051248] sp : ffff8000129935f0
[    4.054571] x29: ffff8000129935f0 x28: ffff000079d39580
[    4.059891] x27: ffff000079d6cc80 x26: ffff80001206eae0
[    4.065213] x25: ffff8000120ab538 x24: ffff000079d3fc00
[    4.070534] x23: 0000000000000009 x22: ffff8000129936a8
[    4.075856] x21: ffff00007a47c4c0 x20: ffff8000120550c0
[    4.081174] x19: ffff000079d3ff00 x18: 0000000000000000
[    4.086495] x17: 0000000000000000 x16: 0000000000000000
[    4.091817] x15: 0000000000000000 x14: ffff00007b0aa940
[    4.097138] x13: ffff80006c0ef000 x12: 0000000034d4d91d
[    4.102460] x11: 071c71c71c71c71c x10: 0000000000000990
[    4.107780] x9 : 0000000000000000 x8 : ffff8000107ef620
[    4.113102] x7 : ffff000079d5e2b8 x6 : ffff000079d3fc00
[    4.118424] x5 : ffff000079d5e2b8 x4 : 0000000000000000
[    4.123745] x3 : ffff800012055490 x2 : ffff00007a47c4c0
[    4.129066] x1 : 0000000000000000 x0 : 0000000000000001
[    4.134397] Call trace:
[    4.136861]  _regulator_put.part.0+0x140/0x148
[    4.141318]  regulator_put+0x34/0x48
[    4.144917]  devm_regulator_release+0x10/0x18
[    4.149298]  release_nodes+0x1a8/0x220
[    4.153057]  devres_release_all+0x34/0x58
[    4.157078]  really_probe+0x1b8/0x308
[    4.160748]  driver_probe_device+0x54/0xe8
[    4.164851]  __device_attach_driver+0x80/0xb8
[    4.169225]  bus_for_each_drv+0x74/0xc0
[    4.173070]  __device_attach+0xdc/0x138
[    4.176916]  device_initial_probe+0x10/0x18
[    4.181105]  bus_probe_device+0x90/0x98
[    4.184954]  device_add+0x378/0x648
[    4.188450]  device_register+0x1c/0x28
[    4.192230]  i2c_new_client_device+0x134/0x270
[    4.196681]  i2c_new_device+0xc/0x20
[    4.200277]  of_i2c_register_device+0x70/0x98
[    4.204640]  of_i2c_register_devices+0x9c/0x164
[    4.209176]  i2c_register_adapter+0x14c/0x400
[    4.213545]  __i2c_add_numbered_adapter+0x58/0xa0
[    4.218259]  i2c_add_adapter+0x9c/0xc8
[    4.222015]  i2c_add_numbered_adapter+0x24/0x30
[    4.226580]  i2c_imx_probe+0x37c/0x840
[    4.230340]  platform_drv_probe+0x50/0xa0
[    4.234357]  really_probe+0xd4/0x308
[    4.237944]  driver_probe_device+0x54/0xe8
[    4.242050]  __device_attach_driver+0x80/0xb8
[    4.246414]  bus_for_each_drv+0x74/0xc0
[    4.250264]  __device_attach+0xdc/0x138
[    4.254111]  device_initial_probe+0x10/0x18
[    4.258304]  bus_probe_device+0x90/0x98
[    4.262147]  deferred_probe_work_func+0x64/0x98
[    4.266720]  process_one_work+0x198/0x320
[    4.270740]  worker_thread+0x1f0/0x420
[    4.274523]  kthread+0xf0/0x120
[    4.277694]  ret_from_fork+0x10/0x18
[    4.281291] ---[ end trace 429c2bceeb60ea02 ]---

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Guoniu.zhou <guoniu.zhou@nxp.com>
2023-10-30 15:28:45 +08:00
Liu Ying
3e259383f6 media: platform: mxc: capture: ov5640: Disable regulators in ov5640_remove()
The below commit introduced in v5.0 would warn us when putting
a regulator with non-zero enable_count.  So, we should disable
regulators in ov5640_remove() in cases where regulators are
still enabled when the module is removed.  This patch can suppress
the below warnings when the module is removed:

[  456.156524] WARNING: CPU: 3 PID: 11175 at drivers/regulator/core.c:2042 _regulator_put.part.4+0x1a4/0x1c8
[  456.166261] Modules linked in: mxc_v4l2_capture ipu_bg_overlay_sdc ipu_still ipu_prp_enc ipu_csi_enc ipu_fg_overlay_sdc ov5640_camera_mipi_v2 ov5640_camera_int(-) imx_vdoa ov5640_camera_mipi_int v4l2_int_device galcore(O) [last unloaded: ipu_bg_overlay_sdc]
[  456.189199] CPU: 3 PID: 11175 Comm: modprobe Tainted: G        W  O      5.4.0-rc3-5.3-warrior-next+gfb33033 #1
[  456.199312] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[  456.205881] [<c0112e70>] (unwind_backtrace) from [<c010cd80>] (show_stack+0x10/0x14)
[  456.213654] [<c010cd80>] (show_stack) from [<c0c98ba0>] (dump_stack+0xd8/0x110)
[  456.220992] [<c0c98ba0>] (dump_stack) from [<c0136da0>] (__warn+0xc0/0x10c)
[  456.227978] [<c0136da0>] (__warn) from [<c0137168>] (warn_slowpath_fmt+0x58/0xb8)
[  456.235490] [<c0137168>] (warn_slowpath_fmt) from [<c05f143c>] (_regulator_put.part.4+0x1a4/0x1c8)
[  456.244477] [<c05f143c>] (_regulator_put.part.4) from [<c05f148c>] (regulator_put+0x2c/0x3c)
[  456.252942] [<c05f148c>] (regulator_put) from [<c0685f08>] (release_nodes+0x1ac/0x1f8)
[  456.260890] [<c0685f08>] (release_nodes) from [<c0682168>] (device_release_driver_internal+0xf8/0x1b8)
[  456.270222] [<c0682168>] (device_release_driver_internal) from [<c0682284>] (driver_detach+0x44/0x80)
[  456.279464] [<c0682284>] (driver_detach) from [<c0680e40>] (bus_remove_driver+0x4c/0xa4)
[  456.287584] [<c0680e40>] (bus_remove_driver) from [<c01e4c64>] (sys_delete_module+0x164/0x1d8)
[  456.296222] [<c01e4c64>] (sys_delete_module) from [<c0101000>] (ret_fast_syscall+0x0/0x28)
[  456.304505] Exception stack(0xe7657fa8 to 0xe7657ff0)
[  456.309577] 7fa0:                   01d284b8 01d284f4 01d284f4 00000800 00000070 00000000
[  456.317776] 7fc0: 01d284b8 01d284f4 00000000 00000081 00000001 01d27150 01d284b8 be935b40
[  456.325973] 7fe0: b6ef8340 be93479c 0001fd24 b6ef834c
[  456.331155] irq event stamp: 4303
[  456.334505] hardirqs last  enabled at (4311): [<c019d73c>] console_unlock+0x420/0x5dc
[  456.342449] hardirqs last disabled at (4328): [<c019d3c4>] console_unlock+0xa8/0x5dc
[  456.350328] softirqs last  enabled at (4344): [<c01024e4>] __do_softirq+0x2c4/0x518
[  456.358104] softirqs last disabled at (4355): [<c013e9d4>] irq_exit+0x100/0x18c
[  456.365516] ---[ end trace 67f399ebac279467 ]---

commit 5451781dad ("regulator: core: Only count load for enabled consumers")

Signed-off-by: Liu Ying <victor.liu@nxp.com>
2023-10-30 15:28:45 +08:00
Robby Cai
fa51a7c6fd media: ov5640 v2: fix kernel warning when no camera is plugged in
in 5451781dad commit, it added the check that
the regulator need to be disabled before calling regulator_put().
If not do so, the kernel will print warning message as below.
To fix this, need to disable regulator before probe function return if the
camera's not found. regulator_put() will be called when probe fails in this case
as devm_regulator_get() already called in probe function.

[ 1482.424157] camera ov5640 is not found
[ 1482.428022] ------------[ cut here ]------------
[ 1482.433070] WARNING: CPU: 0 PID: 697 at drivers/regulator/core.c:2039 _regulator_put.part.4+0x100/0x120
[ 1482.442566] Modules linked in: ov5640_camera_v2(+) v4l2_int_device mx6s_capture galcore(O) [last unloaded: ov5640_camera_int]
[ 1482.453990] CPU: 0 PID: 697 Comm: modprobe Tainted: G           O      5.3.0-rc3-next-20190809-5.3-warrior-next+g1dc2946 #1
[ 1482.465136] Hardware name: Freescale i.MX6 SoloX (Device Tree)
[ 1482.471007] [<c0112868>] (unwind_backtrace) from [<c010cd9c>] (show_stack+0x10/0x14)
[ 1482.478781] [<c010cd9c>] (show_stack) from [<c0cec834>] (dump_stack+0xd8/0x110)
[ 1482.486116] [<c0cec834>] (dump_stack) from [<c01362c4>] (__warn.part.3+0xa8/0xe8)
[ 1482.493620] [<c01362c4>] (__warn.part.3) from [<c013645c>] (warn_slowpath_null+0x40/0x4c)
[ 1482.501824] [<c013645c>] (warn_slowpath_null) from [<c05e6868>] (_regulator_put.part.4+0x100/0x120)
[ 1482.510894] [<c05e6868>] (_regulator_put.part.4) from [<c05e68b4>] (regulator_put+0x2c/0x3c)
[ 1482.519356] [<c05e68b4>] (regulator_put) from [<c06dd210>] (release_nodes+0x1ac/0x1f8)
[ 1482.527298] [<c06dd210>] (release_nodes) from [<c06d8cb0>] (really_probe+0x104/0x340)
[ 1482.535151] [<c06d8cb0>] (really_probe) from [<c06d9098>] (driver_probe_device+0x84/0x194)
[ 1482.543436] [<c06d9098>] (driver_probe_device) from [<c06d938c>] (device_driver_attach+0x58/0x60)
[ 1482.552329] [<c06d938c>] (device_driver_attach) from [<c06d93ec>] (__driver_attach+0x58/0xd0)
[ 1482.560875] [<c06d93ec>] (__driver_attach) from [<c06d70b8>] (bus_for_each_dev+0x70/0xb4)
[ 1482.569073] [<c06d70b8>] (bus_for_each_dev) from [<c06d80e4>] (bus_add_driver+0x198/0x1d0)
[ 1482.577358] [<c06d80e4>] (bus_add_driver) from [<c06da078>] (driver_register+0x74/0x108)
[ 1482.585474] [<c06da078>] (driver_register) from [<c088b238>] (i2c_register_driver+0x38/0x84)
[ 1482.593937] [<c088b238>] (i2c_register_driver) from [<c0103078>] (do_one_initcall+0x80/0x338)
[ 1482.602486] [<c0103078>] (do_one_initcall) from [<c01e163c>] (do_init_module+0x5c/0x238)
[ 1482.610598] [<c01e163c>] (do_init_module) from [<c01e3b00>] (load_module+0x2260/0x256c)
[ 1482.618623] [<c01e3b00>] (load_module) from [<c01e4060>] (sys_finit_module+0xbc/0xdc)
[ 1482.626473] [<c01e4060>] (sys_finit_module) from [<c0101000>] (ret_fast_syscall+0x0/0x28)
[ 1482.634666] Exception stack(0xec0f5fa8 to 0xec0f5ff0)
[ 1482.639737] 5fa0:                   00000000 00000000 00000003 00028e44 00000000 01602408
[ 1482.647933] 5fc0: 00000000 00000000 00040000 0000017b 00000000 00000000 00000000 01602630
[ 1482.656127] 5fe0: beb158f0 beb158e0 0001fdb4 b6f1f510
[ 1482.661324] irq event stamp: 3497
[ 1482.664677] hardirqs last  enabled at (3505): [<c019be00>] console_unlock+0x418/0x5f4
[ 1482.672612] hardirqs last disabled at (3522): [<c019ba70>] console_unlock+0x88/0x5f4
[ 1482.680451] softirqs last  enabled at (3538): [<c01024e4>] __do_softirq+0x2c4/0x514
[ 1482.688136] softirqs last disabled at (3531): [<c013da4c>] irq_exit+0x100/0x188
[ 1482.695530] ---[ end trace e580778621876135 ]---

Signed-off-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:28:45 +08:00