Commit Graph

7007 Commits

Author SHA1 Message Date
Ming Qian
3b53d8b471 LF-15180: media: imx-jpeg: Account for data_offset when getting image address
Applications may set data_offset when it refers to an output queue. So
driver need to account for it when getting the start address of input
image in the plane.

Meanwhile data_offset is included in bytesused. So the data_offset
should be subtracted from the payload of input image.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: Zhou Peng <eagle.zhou@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-04-30 15:51:06 +08:00
Laurentiu Palcu
da02bb4fef LF-13923 media: nxp: imx8-isi: better handle the m2m usage_count
Currently, if streamon/streamoff calls are imbalanced we can either end up
with a negative ISI m2m usage_count (if streamoff() is called more times
than streamon()) in which case we'll not be able to restart the ISI pipe
next time, or the usage_count never gets to 0 and the pipe is never
switched off.

To avoid that, add a 'streaming' flag to mxc_isi_m2m_ctx_queue_data and use it
in the streamon/streamoff to avoid incrementing/decrementing the usage_count
uselessly, if called multiple times from the same context.

Fixes: cf21f328fc ("media: nxp: Add i.MX8 ISI driver")
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Tested-by: Guoniu Zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robert Chiras <robert.chiras@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-11-18 20:24:05 +08:00
Laurentiu Palcu
d0fd392ad3 LF-13267 media: nxp: imx8-isi: fix v4l2-compliance test errors
Running the v4l2-compliance (1.27.0-5208, SHA: af114250d48d) on the m2m
device fails on the MMAP streaming tests, with the following messages:

fail: v4l2-test-buffers.cpp(240): g_field() == V4L2_FIELD_ANY
fail: v4l2-test-buffers.cpp(1508): buf.qbuf(node)

Apparently, the driver does not properly set the field member of
vb2_v4l2_buffer struct, returning the default V4L2_FIELD_ANY value which
is against the guidelines.

Fixes: cf21f328fc ("media: nxp: Add i.MX8 ISI driver")
Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Guoniu Zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robert Chiras <robert.chiras@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-11-18 20:23:21 +08:00
Guoniu Zhou
fbb48d8e2d LF-13493: media: nxp: imx8-isi: Fix ISI write one more line issue
As mentioned in reference manual, ISI actual output line
value will be rounded up to an integer. For example, if
the input line value equal to 800 and the output line
value equal to 720, you must set [Y_SCALE] to a value
such that the theoretical output line value (800/[Y_SCALE])
is equal to or less than 720, which means:

1. If [Y_SCALE] is set to 1C8h, the theoretical output line
value equal to 719.859375 which will be rounded up to 720.
2. If [Y_SCALE] is set to 1C7h, the theoretical output line
value equal to 720.017578 which will be rounded up to 721.

There will be one excessive line in the actual output, So
adjust scale factor to make them equal.

Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2024-10-24 22:56:10 +08:00
Guoniu Zhou
4bb1fd3d06 LF-13720: media: nxp: imx8-isi: Add more RGB formats support
Add more RGB formats which supported by ISI.

Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2024-10-24 22:37:29 +08:00
Alexi Birlinger
da6b71590a LF-13402: media: nxp: neoisp: Use default streamoff/streamon vb2_ioctl
A CMA leak is observed when interrupting the process abnormally. Before
the process stopped, if another interrupt signal is sent, the process
will be forcefully terminated without cleaning properly. This is
preventing any_buf to be released properly and context to be reset
to default as VIDIOC_STREAMOFF could not be sent.

This patch aims to perform cleaning before terminating the process
by using stop_streaming callback to release any_buf and reset context.
This callback is waiting for all buffers to be given back before
terminating, allowing to perform cleaning without being interrupted.
The streamon and streamoff callback will be managed by default video
buffer 2 core framework, while neoisp implementation will be performed
in start_streaming and stop_streaming callback.

Signed-off-by: Alexi Birlinger <alexi.birlinger@nxp.com>
Reviewed-by: Aymen Sghaier <aymen.sghaier@nxp.com>
2024-10-22 16:58:56 +02:00
Alexi Birlinger
2db308515b media: nxp: neoisp: Enable memory dump for LUT via debugfs
Adds dump methods to get isp memory status for Lookup tables.
The Vignetting, Global and Local DRC tonemap tables could be now dumped
using debugfs.

Signed-off-by: Alexi Birlinger <alexi.birlinger@nxp.com>
Reviewed-by: Aymen Sghaier <aymen.sghaier@nxp.com>
2024-10-22 16:50:07 +02:00
Robby Cai
ecd28da1c1 LF-13705-5 media: csi: Fix Coverity issue
Fix issue: CID 5486100: Dereference null return value (NULL_RETURNS)

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Guoniu Zhou <guoniu.zhou@nxp.com>
2024-10-22 15:34:11 +08:00
Robby Cai
edc276f935 LF-13705-2 media: capture: ov5640_mipi_v2: Fix Coverity issue
Fix Coverity issue: CID 20813467 Enum compared against 0 (NO_EFFECT)
Removed it to fix.

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Guoniu Zhou <guoniu.zhou@nxp.com>
2024-10-22 15:34:10 +08:00
Robby Cai
311551b0b7 LF-13705-1 media: mxc: pxp_v4l2: Fix Coverity issue
Fix Coverity issue: CID 5484434 of "dereference null return value".
The function pxp_get_format could return NULL, so add the check before use.

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Guoniu Zhou <guoniu.zhou@nxp.com>
2024-10-22 15:34:09 +08:00
Guoniu.zhou
a232ed03f5 LF-13493: media: nxp: imx8-isi: Add max size for memory ISI can access
ISI may exceed its bounds by accessing memory that does not
belong to it when work with 7 VPU instance at same time. It
maybe a IC bug(TKT0661750), so specifies the maximum size
(in bytes) for the memory location. Tentative write out of
this max size range is not allowed. The feature of ISI is
introduced in iMX95 ISI version.

Reproduce steps:
Setup media pipeline for camera and run commands as bellow:
gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=1280,height=800,format=YUY2 ! queue ! waylandsink window-width=320 window-height=240 &

gst-launch-1.0 videotestsrc ! video/x-raw,width=1280,height=576 ! v4l2h264enc ! h264parse ! v4l2h264dec ! waylandsink window-width=320 window-height=240 &
gst-launch-1.0 videotestsrc ! video/x-raw,width=1280,height=576 ! v4l2h264enc ! h264parse ! v4l2h264dec ! waylandsink window-width=320 window-height=240 &
gst-launch-1.0 videotestsrc ! video/x-raw,width=1280,height=576 ! v4l2h264enc ! h264parse ! v4l2h264dec ! waylandsink window-width=320 window-height=240 &
gst-launch-1.0 videotestsrc ! video/x-raw,width=1280,height=576 ! v4l2h264enc ! h264parse ! v4l2h264dec ! waylandsink window-width=320 window-height=240 &
gst-launch-1.0 videotestsrc ! video/x-raw,width=1280,height=576 ! v4l2h264enc ! h264parse ! v4l2h264dec ! waylandsink window-width=320 window-height=240 &
gst-launch-1.0 videotestsrc ! video/x-raw,width=1280,height=576 ! v4l2h264enc ! h264parse ! v4l2h264dec ! waylandsink window-width=320 window-height=240 &
gst-launch-1.0 videotestsrc ! video/x-raw,width=1280,height=576 ! v4l2h264enc ! h264parse ! v4l2h264dec ! waylandsink window-width=320 window-height=240 &

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2024-10-11 18:20:41 +08:00
Ming Qian
d823f92ed5 LF-13473-8: media: amphion: Set video drvdata before register video device
the video drvdata should be set before the video device is registered,
otherwise video_drvdata() may return NULL in the open() file ops, and led
to oops.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: TaoJiang <tao.jiang_2@nxp.com>
2024-10-10 18:29:24 +09:00
Ming Qian
525fc9e53a LF-13473-7: media: imx-jpeg: Ensure power suppliers be suspended before detach them
The power suppliers are always requested to suspend asynchronously,
dev_pm_domain_detach() requires the caller to ensure proper
synchronization of this function with power management callbacks.
otherwise the detach may led to kernel panic, like below:

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

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: TaoJiang <tao.jiang_2@nxp.com>
2024-10-10 18:29:24 +09:00
Ming Qian
a814c549c5 LF-13473-6: media: imx-jpeg: Set video drvdata before register video device
the video drvdata should be set before the video device is registered,
otherwise video_drvdata() may return NULL in the open() file ops, and led
to oops.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: TaoJiang <tao.jiang_2@nxp.com>
2024-10-10 18:29:24 +09:00
Jason Liu
239f62168d This is the 6.6.51 stable release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmbisF0ACgkQONu9yGCS
 aT5Y8xAAqS/rmrC+/qlFvbtAqK+KXLq9BIGvDHW2QHfCyMpSZ6isehVhh64apHE/
 /XvJ6a+2iPVp5o52iDTUKzbcDr3Jx/QwhS8Xa/HyQQy1rXIPpJNJb8Vuvkn/B2Cq
 cPCfTtfPZUUQTd09uAdBhy5NT8hsT2kSVpmSXDnahn9ih8k0tR40udw5Qf7xpWcf
 HqljbfonLP86mF/SB9m+VhDGF9fekujyb+0iS0OPE+TdvSjKB9ySoeL4PIeTSxrz
 goZdp9ygAYy8Bks825ztbfQszqIwceHU/xZRaUrGfOOk4A5kwTmbdUQu7ooMc+5F
 kbpifbewmY1UGn2KTxgj59xCjQ7HLQe+sqacy0/gALzRSajUNyjLn0n4w3UqaJWb
 pf+gwqHBLgDRfvWctggEdY2ApKgOlM9D7TTpWWB9uv1oR/g3PGfgehZgrMMPgPUw
 EZ8JiwnITfRaRFiH/vSR3aJKRj6qjb4mX3/U8HgGcACtyFfHgtuI7jzhnX36fRNO
 FG38bxSUMrJnlohghfBl6zyaruZBMHVaoQzs6MYZ7qrVvCbt3CHivJdaQ85nw0h7
 YHa2zYFfT0ztyaSMzWq6JatgI7BZfd8PjobhbRZADBBD39KC8aL8XLoDPnpzWMUY
 UDlK8n96gOKo0t8ILDWcIisCVGNogcHJlGppC8Fu7ZyKzYsMhN4=
 =OEL/
 -----END PGP SIGNATURE-----

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

This is the 6.6.51 stable release

* tag 'v6.6.51': (2369 commits)
  Linux 6.6.51
  Bluetooth: hci_sync: Fix UAF on hci_abort_conn_sync
  Bluetooth: hci_sync: Fix UAF on create_le_conn_complete
  ...

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

 Conflicts:
	arch/arm64/boot/dts/freescale/imx8mp.dtsi
	arch/arm64/boot/dts/freescale/imx93.dtsi
	drivers/dma/fsl-edma-common.c
	drivers/dma/fsl-edma-common.h
	drivers/dma/fsl-edma.c
	drivers/irqchip/irq-imx-irqsteer.c
	drivers/perf/fsl_imx9_ddr_perf.c
	drivers/spi/spi-fsl-lpspi.c
	sound/soc/sof/imx/imx8m.c
2024-09-24 11:49:41 +08:00
Chen Ni
b4987d0236 media: qcom: camss: Add check for v4l2_fwnode_endpoint_parse
[ Upstream commit 4caf6d93d9 ]

Add check for the return value of v4l2_fwnode_endpoint_parse() and
return the error if it fails in order to catch the error.

Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-09-12 11:11:31 +02:00
Hans Verkuil
9649d26dc9 media: qcom: venus: fix incorrect return value
[ Upstream commit 51b74c09ac ]

'pd' can be NULL, and in that case it shouldn't be passed to
PTR_ERR. Fixes a smatch warning:

drivers/media/platform/qcom/venus/pm_helpers.c:873 vcodec_domains_get() warn: passing zero to 'PTR_ERR'

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-08-29 17:33:27 +02:00
Chengfeng Ye
e6571cff84 media: s5p-mfc: Fix potential deadlock on condlock
[ Upstream commit 04d19e6513 ]

As &dev->condlock is acquired under irq context along the following
call chain from s5p_mfc_irq(), other acquisition of the same lock
inside process context or softirq context should disable irq avoid double
lock. enc_post_frame_start() seems to be one such function that execute
under process context or softirq context.

<deadlock #1>

enc_post_frame_start()
--> clear_work_bit()
--> spin_loc(&dev->condlock)
<interrupt>
   --> s5p_mfc_irq()
   --> s5p_mfc_handle_frame()
   --> clear_work_bit()
   --> spin_lock(&dev->condlock)

This flaw was found by an experimental static analysis tool I am
developing for irq-related deadlock.

To prevent the potential deadlock, the patch change clear_work_bit()
inside enc_post_frame_start() to clear_work_bit_irqsave().

Signed-off-by: Chengfeng Ye <dg573847474@gmail.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-08-29 17:33:26 +02:00
Ming Qian
a29c1e51ef media: amphion: Remove lock in s_ctrl callback
[ Upstream commit 065927b51e ]

There is no need to add a lock in s_ctrl callback, it has been
synchronized by the ctrl_handler's lock, otherwise it may led to
a deadlock if the driver calls v4l2_ctrl_s_ctrl().

Signed-off-by: Ming Qian <ming.qian@nxp.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-08-14 13:58:45 +02:00
Guoniu.zhou
d257108142 LF-13106: media: imx-csi-formatter: Fix kernel oops issue
Fix kernel oops issue when capture without pipeline setup, log
as bellow:

[   65.185151] Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
[   65.217211] CPU: 2 PID: 730 Comm: v4l2-ctl Not tainted 6.6.36-g7bb0a8c6ab3d #31
[   65.224506] Hardware name: NXP i.MX95 19X19 board (DT)
[   65.229635] pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   65.236579] pc : formatter_subdev_enable_streams+0xb0/0x22c
[   65.242143] lr : formatter_subdev_enable_streams+0x188/0x22c
[   65.247794] sp : ffff80008576b940
[   65.251096] x29: ffff80008576b940 x28: ffff000085b3e180 x27: ffff0000806844b0
[   65.258220] x26: 0000000000000002 x25: ffff000080684480 x24: 0000000000000001
[   65.265344] x23: ffff000080f37010 x22: 0000000000000000 x21: ffff00008442cae0
[   65.272468] x20: ffff0000810e3498 x19: ffff0000810e3480 x18: ffffffffffffffff
[   65.279592] x17: 6d6920646c756f68 x16: 7320312064617020 x15: 6e6f206563697665
[   65.286724] x14: 642d627573206574 x13: ffff800082091528 x12: 000000000000081c
[   65.293848] x11: 00000000000002b4 x10: ffff8000820e9528 x9 : 0000000000000000
[   65.300972] x8 : ffff80008576b7e4 x7 : 0000000000000000 x6 : ffff000080f37190
[   65.308096] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000
[   65.315220] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff8000816e7000
[   65.322345] Call trace:
[   65.324781]  formatter_subdev_enable_streams+0xb0/0x22c
[   65.329997]  v4l2_subdev_enable_streams+0xe8/0x26c
[   65.334781]  mxc_isi_crossbar_enable_streams+0x12c/0x1d0
[   65.340085]  v4l2_subdev_enable_streams+0xe8/0x26c
[   65.344869]  mxc_isi_pipe_enable+0x204/0x2ac
[   65.349124]  mxc_isi_vb2_start_streaming+0xa0/0xe4
[   65.353908]  vb2_start_streaming+0x68/0x15c
[   65.358086]  vb2_core_streamon+0xf8/0x1bc
[   65.362081]  vb2_streamon+0x18/0x64
[   65.365565]  mxc_isi_video_streamon+0x28c/0x314
[   65.370080]  v4l_streamon+0x24/0x30
[   65.373564]  __video_do_ioctl+0x32c/0x3f8
[   65.377568]  video_usercopy+0x2c8/0x658
[   65.381399]  video_ioctl2+0x18/0x24
[   65.384883]  v4l2_ioctl+0x40/0x60
[   65.388194]  __arm64_sys_ioctl+0xac/0xf0
[   65.392111]  invoke_syscall+0x48/0x114
[   65.395855]  el0_svc_common.constprop.0+0xc0/0xe0
[   65.400552]  do_el0_svc+0x1c/0x28
[   65.403863]  el0_svc+0x40/0xe4
[   65.406914]  el0t_64_sync_handler+0x120/0x12c
[   65.411264]  el0t_64_sync+0x190/0x194
[   65.414916] Code: a8c57bfd d50323bf d65f03c0 f0004320 (39401085)
[   65.420998] ---[ end trace 0000000000000000 ]---

Reproduce step:
  Run command as bellow after system boot.
  $ v4l2-ctl -v width=1920,height=1080,pixelformat=YUYV --stream-mmap

The reason is that it will try to get data type index by searching map
between data type and its index when start capture, but the data type
is missing by default if no pipepline setup. So initialize the data type
to default value aligned to subdev format.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2024-08-06 16:38:41 +08:00
Guoniu.zhou
655d2588b4 LF-13077: media: imx8-isi: Correct color map between V4L2 and ISI
Correct color map between V4L2_PIX_FMT_XBGR32 and ISI input
format XRGB8 when it work at memory to memory mode.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2024-08-05 17:59:31 +08:00
Harshit Mogalapalli
358bc85269 media: imx-pxp: Fix ERR_PTR dereference in pxp_probe()
commit 57e9ce68ae upstream.

devm_regmap_init_mmio() can fail, add a check and bail out in case of
error.

Fixes: 4e5bd3fdbe ("media: imx-pxp: convert to regmap")
Cc: stable@vger.kernel.org
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/r/20240514095038.3464191-1-harshit.m.mogalapalli@oracle.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-08-03 08:54:19 +02:00
Dikshita Agarwal
66fa52edd3 media: venus: fix use after free in vdec_close
commit a0157b5aa3 upstream.

There appears to be a possible use after free with vdec_close().
The firmware will add buffer release work to the work queue through
HFI callbacks as a normal part of decoding. Randomly closing the
decoder device from userspace during normal decoding can incur
a read after free for inst.

Fix it by cancelling the work in vdec_close.

Cc: stable@vger.kernel.org
Fixes: af2c3834c8 ("[media] media: venus: adding core part and helper functions")
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Acked-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>
2024-08-03 08:54:14 +02:00
Dikshita Agarwal
645753ce91 media: venus: flush all buffers in output plane streamoff
[ Upstream commit e750a4b122 ]

For scenarios, when source change is followed by VIDIOC_STREAMOFF
on output plane, driver should discard any queued OUTPUT
buffers, which are not decoded or dequeued.
Flush with HFI_FLUSH_INPUT does not have any actual impact.
So, fix it, by invoking HFI_FLUSH_ALL, which will flush all
queued buffers.

Fixes: 85872f861d ("media: venus: Mark last capture buffer")
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Tested-by: Nathan Hebert <nhebert@chromium.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-08-03 08:53:53 +02:00
Ming Qian
be50a293eb media: imx-jpeg: Drop initial source change event if capture has been setup
[ Upstream commit a8fb5fce7a ]

In section 4.5.1.5. Initialization, the step 4 may be skipped and
continue with the Capture Setup sequence, so if the capture has been
setup, there is no need to trigger the initial source change event, just
start decoding, and follow the dynamic resolution change flow if the
configured values do not match those parsed by the decoder.

And it won't fail the gstreamer pipeline.

Fixes: b833b17849 ("media: imx-jpeg: notify source chagne event when the first picture parsed")
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>
2024-08-03 08:53:51 +02:00
Laurent Pinchart
74e622f307 media: renesas: vsp1: Store RPF partition configuration per RPF instance
[ Upstream commit a213bc09b1 ]

The vsp1_partition structure stores the RPF partition configuration in a
single field for all RPF instances, while each RPF can have its own
configuration. Fix it by storing the configuration separately for each
RPF instance.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Fixes: ab45e85851 ("media: v4l: vsp1: Allow entities to participate in the partition algorithm")
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-08-03 08:53:50 +02:00
Laurent Pinchart
fe2025b8f9 media: renesas: vsp1: Fix _irqsave and _irq mix
[ Upstream commit 57edbbcf52 ]

The histogram support mixes _irqsave and _irq, causing the following
smatch warning:

     drivers/media/platform/renesas/vsp1/vsp1_histo.c:153 histo_stop_streaming()
     warn: mixing irqsave and irq

The histo_stop_streaming() calls spin_lock_irqsave() followed by
wait_event_lock_irq(). The former hints that interrupts may be disabled
by the caller, while the latter reenables interrupts unconditionally.
This doesn't cause any real bug, as the function is always called with
interrupts enabled, but the pattern is still incorrect.

Fix the problem by using spin_lock_irq() instead of spin_lock_irqsave()
in histo_stop_streaming(). While at it, switch to spin_lock_irq() and
spin_lock() as appropriate elsewhere.

Fixes: 99362e3233 ("[media] v4l: vsp1: Add histogram support")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-renesas-soc/164d74ff-312c-468f-be64-afa7182cd2f4@moroto.mountain/
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-08-03 08:53:50 +02:00
Jacopo Mondi
c276c2bfd7 media: rcar-csi2: Cleanup subdevice in remove()
[ Upstream commit f6d64d0d28 ]

Cleanup the V4L2 subdevice in the driver's remove function to
ensure its async connection are freed, and guarantee in future that
the subdev active state is cleaned up.

Fixes: 769afd212b ("media: rcar-csi2: add Renesas R-Car MIPI CSI-2 receiver driver")
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Tested-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://lore.kernel.org/r/20240617161135.130719-4-jacopo.mondi@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-08-03 08:53:50 +02:00
Jacopo Mondi
3b6d4821dd media: rcar-csi2: Disable runtime_pm in probe error
[ Upstream commit e306183628 ]

Disable pm_runtime in the probe() function error path.

Fixes: 769afd212b ("media: rcar-csi2: add Renesas R-Car MIPI CSI-2 receiver driver")
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Tested-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://lore.kernel.org/r/20240617161135.130719-3-jacopo.mondi@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-08-03 08:53:49 +02:00
Jacopo Mondi
ea4f6c74d4 media: rcar-vin: Fix YUYV8_1X16 handling for CSI-2
[ Upstream commit 9caf253e8a ]

The YUYV8_1X16 and UYVY8_1X16 formats are treated as 'ITU-R
BT.601/BT.1358 16-bit YCbCr-422 input' (YUV16 - 0x5) in the R-Car VIN
driver and are thus disallowed when capturing frames from the R-Car
CSI-2 interface according to the hardware manual.

As the 1X16 format variants are meant to be used with serial busses they
have to be treated as 'YCbCr-422 8-bit data input' (0x1) when capturing
from CSI-2, which is a valid setting for CSI-2.

Commit 78b3f9d75a ("media: rcar-vin: Add check that input interface
and format are valid") disallowed capturing YUV16 when using the CSI-2
interface. Fix this by using YUV8_BT601 for YCbCr422 when CSI-2 is in
use.

Fixes: 78b3f9d75a ("media: rcar-vin: Add check that input interface and format are valid")
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Tested-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://lore.kernel.org/r/20240617161135.130719-2-jacopo.mondi@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-08-03 08:53:49 +02:00
Irui Wang
1c109f23b2 media: mediatek: vcodec: Handle invalid decoder vsi
[ Upstream commit 59d438f8e0 ]

Handle an invalid decoder vsi in vpu_dec_init to ensure the decoder vsi
is valid for future use.

Fixes: 590577a4e5 ("[media] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver")

Signed-off-by: Irui Wang <irui.wang@mediatek.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-08-03 08:53:48 +02:00
Guoniu.zhou
195814b617 LF-13036: media: imx8-isi: Fix potential build error when ISI m2m is disabled
Fix potential build error when ISI m2m is disabled, log as bellow:

drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c: In function ‘mxc_isi_pm_suspend’:
drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c:359:17: error: implicit declaration of function ‘mxc_isi_m2m_suspend’; did you mean ‘mxc_isi_pm_suspend’? [-Werror=implicit-function-declaration]
              mxc_isi_m2m_suspend(pipe);
              ^~~~~~~~~~~~~~~~~~~
              mxc_isi_pm_suspend
drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c: In function ‘mxc_isi_pm_resume’:
drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c:390:23: error: implicit declaration of function ‘mxc_isi_m2m_resume’; did you mean ‘mxc_isi_pm_resume’? [-Werror=implicit-function-declaration]
              ret = mxc_isi_m2m_resume(pipe);
                    ^~~~~~~~~~~~~~~~~~
                    mxc_isi_pm_resume
cc1: some warnings being treated as errors

Fixes: a84383ad33 ("LF-13013-02: media: imx8-isi: Add suspend/resume support for ISI m2m")

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2024-07-30 13:42:35 +08:00
Alexi Birlinger
5b74faf79b ILIE-114-3: media: nxp: neo: Add vb2 busy check for all s_fmt functions
All s_fmt functions must check that the queue is not busy
before setting format.

Signed-off-by: Alexi Birlinger <alexi.birlinger@nxp.com>
Reviewed-by: Aymen Sghaier <aymen.sghaier@nxp.com>
2024-07-29 18:34:04 +02:00
Alexi Birlinger
fb62439689 ILIE-114-2: media: nxp: neo: Return queued buffers on start_streaming error
The start_streaming function must return all queued buffers
to state VB2_BUF_STATE_QUEUED on error

Signed-off-by: Alexi Birlinger <alexi.birlinger@nxp.com>
Reviewed-by: Aymen Sghaier <aymen.sghaier@nxp.com>
2024-07-29 18:33:57 +02:00
Alexi Birlinger
4755c264ea ILIE-114-1: media: nxp: neo: Perform standard check for VIDIOC_CREATE_BUFS
The check on size has been modified to follow the standard.
The variable size is the minimum size of the plane and
was allocated to sizes[0].
Thus, it was not possible to check sizes[0] < size,
leading to preventing userspace to specify a larger buffer.
This change provides the standard check to perform on size.

Also, the limit of the config node buffer count has been
removed as vb2 core already limits num_buffers to
VB2_MAX_FRAME in vb2_core_queue_init function.

Signed-off-by: Alexi Birlinger <alexi.birlinger@nxp.com>
Reviewed-by: Aymen Sghaier <aymen.sghaier@nxp.com>
2024-07-29 18:33:37 +02:00
Alexi Birlinger
e40f6829c1 ILIE-87: media: nxp: neoisp: Rework job scheduling for node groups
The scheduling is now grouped as a single method either
preparing the job when node group is ready to be queued
or searching for next group index to be ready.
This change also rework spinlock use to be locked and
unlocked into the same function.

hw_lock attribute is now defined as bool instead
of int variable.

Signed-off-by: Alexi Birlinger <alexi.birlinger@nxp.com>
Reviewed-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
2024-07-29 18:33:12 +02:00
Guoniu.zhou
a84383ad33 LF-13013-02: media: imx8-isi: Add suspend/resume support for ISI m2m
Add suspend/resume support for ISI m2m while converting.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Sandor Yu <Sandor.yu@nxp.com>
2024-07-29 17:19:09 +08:00
Ming Qian
d7f597b090 LF-13006: media: amphion: Guard memory allocation to catch failures
The firmware will ask the driver for memory allocation, but it will not
check the completeness of the task. Therefore, the vpu will crash until
reboot. This code will guard this bug and make the driver fail gracefully
when memory allocation cannot be completed.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: Mihai Despotovici <mihai.despotovici@nxp.com>
Reviewed-by: Zhou Peng <eagle.zhou@nxp.com>
2024-07-29 11:16:20 +03:00
Aymen Sghaier
8834db6632 ILIE-108-2: media: nxp: neoisp: Fix v4l2-compliance for ir node
After splitting frame and ir formats enum_fmt ioctl is not reporting
correct formats for ir node
This patch fixes this issue by updating enum_fmt for ir.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Reviewed-by: Alexi Birlinger <alexi.birlinger@nxp.com>
2024-07-17 14:40:24 +02:00
Aymen Sghaier
c1d946b3c7 ILIE-108: media: nxp: neoisp: Split ir and frame nodes formats
Frame and Ir nodes have same formats array, while Ir supports only
two greyscale formats not supported by Frame.

This patch splits this array and cleans some unused code.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Reviewed-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
2024-07-16 11:13:47 +02:00
Aymen Sghaier
db2b70bf9d ILIE-107: media: nxp: neoisp: Fix performance issue added by debugfs
When regmap debugfs structure is filled, a performance decrease is
observed even if debugfs mode is disabled.
This patch restricts debugfs structure to avoid lower performance.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Reviewed-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
2024-07-16 11:13:47 +02:00
Aymen Sghaier
dfeffac490 ILIE-24-3: media: nxp: neoisp: Add head color block to parameters
This patch implements head color block settings to be handled by IPA

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Reviewed-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
2024-07-16 11:13:47 +02:00
Aymen Sghaier
52cdf30639 ILIE-24-1: media: nxp: neoisp: Enable infra-red (ir) sensors support
Neoisp hardware supports infra-red feature.
This patch enables it at driver level.
It also adds Grey 16 bits format support for ir capture node.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Reviewed-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
2024-07-16 11:13:46 +02:00
Fei Shao
5c217253c7 media: mediatek: vcodec: Only free buffer VA that is not NULL
[ Upstream commit eb005c801e ]

In the MediaTek vcodec driver, while mtk_vcodec_mem_free() is mostly
called only when the buffer to free exists, there are some instances
that didn't do the check and triggered warnings in practice.

We believe those checks were forgotten unintentionally. Add the checks
back to fix the warnings.

Signed-off-by: Fei Shao <fshao@chromium.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-07-11 12:49:04 +02:00
Aymen Sghaier
f2e144a22a ILIE-64 media: nxp: neoisp: Add crop support
"s_selection" interface is implemented on "input0" video node (output).
Size of "frame" video node (capture) should match input crop size.
Crop is operated by offsetting input image start address and line
stride.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Reviewed-by: Alexi Birlinger <alexi.birlinger@nxp.com>
2024-07-03 07:56:41 +02:00
Aymen Sghaier
ace0579a14 Revert "ILIE-64 media: nxp: neoisp: Add crop support"
This reverts commit 1b546d1225.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Reviewed-by: Alexi Birlinger <alexi.birlinger@nxp.com>
2024-07-03 07:56:41 +02:00
Aymen Sghaier
449db74ecf ILIE-97: Remove parameters buffer useless copy and use vb2 queue
Current driver allocates a dma mapped buffer for parameters and copy each
queued buffer to it. This was done to mimic the pisp driver and is useless
for neoisp.
This patch removes this extra copy and uses the vb2 queue instead.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Reviewed-by: Alexi Birlinger <alexi.birlinger@nxp.com>
2024-07-03 07:52:40 +02:00
Aymen Sghaier
68662d473c ILIE-103: media: nxp: neoisp: Enable regmap debugfs
Regmap framework includes useful registers dump to debugfs, but this is
not functional for neoisp driver.

This patch adds needed settings to enable debugfs for neoisp.
It also adds a module parameter enable_debugfs that should be set to 1
to prevent clock disabling at probe.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Reviewed-by: Antoine Bouyer <antoine.bouyer@nxp.com>
2024-07-02 15:52:26 +02:00
Aymen Sghaier
15d5fba6ee ILIE-88 media: nxp: neoisp: Fix bit width configuration in isp pipeline
HDR decompression isp block is unable to output 20 bits per pixel if input
bit width is less than 12 bits.
This patch involves obwb block to compensate this limitation and reach
20 bits per pixel in isp internal pipeline 0, also adds the same procedure
to handle 16 bits internal bit width for pipeline 1.

This patch also set the default BNR configuration to the default ISP
registers values.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Signed-off-by: Celine Laurencin <celine.laurencin@nxp.com>
Reviewed-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
2024-07-02 10:26:14 +02:00
Alexi Birlinger
919585d6e5 ILIE-91: media: nxp: neoisp: Fix VYUY format
The YVYU is an unsupported format which is a leftover
that was wrongly swapped with VYUY supported format.

Signed-off-by: Alexi Birlinger <alexi.birlinger@nxp.com>
Reviewed-by: Aymen Sghaier <aymen.sghaier@nxp.com>
2024-07-02 10:26:13 +02:00