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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
[ 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>
[ 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>
[ 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>
[ 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>
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>
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>
[ 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>
[ 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>
[ 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>
[ 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>
[ 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>
[ 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>
[ 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
[ 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>
"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>
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>
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>
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>
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>