platform/kernel/linux-starfive.git
21 months agomedia: imx-jpeg: Lock on ioctl encoder/decoder stop cmd
Ming Qian [Fri, 12 Aug 2022 07:22:09 +0000 (15:22 +0800)]
media: imx-jpeg: Lock on ioctl encoder/decoder stop cmd

the ioctl encoder/decoder cmd is under queue lock,
and buf_done is in the irq, it can't be locked with the mutex,
they are not synchronized.
when v4l2_update_last_buf_state is called to
handle the encoder/decoder stop cmd,
the last src buffer may be done at the same time.

so it's possible that last_src_buf is set,
but the output rdy_queue is empty,
then driver won't mark it stopped,
as v4l2_m2m_is_last_draining_src_buf() will always return false and
v4l2_m2m_dst_buf_is_last() return false too.

In this case, the drain will be blocked.

add the hw lock around the ioctl encoder/decoder cmd,
to synchronize with the buf_done.

Fixes: 4911c5acf935 ("media: imx-jpeg: Implement drain using v4l2-mem2mem helpers")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agomedia: imx-jpeg: Support contiguous and non contiguous format
Ming Qian [Tue, 27 Sep 2022 03:12:17 +0000 (11:12 +0800)]
media: imx-jpeg: Support contiguous and non contiguous format

mxc-jpeg supports non contiguous format nv12m,
and in order to compatible with the devices
that only support contiguous format nv12,
jpeg can support nv12 and nv12m in the same time.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: document is_rgb variable]

21 months agomedia: imx-jpeg: Implement g_selection and s_selection
Ming Qian [Tue, 27 Sep 2022 03:12:16 +0000 (11:12 +0800)]
media: imx-jpeg: Implement g_selection and s_selection

The codec can support any image size WxH,
with arbitrary W (image width) and H (image height) dimensions.

But it requires buffer alignment,
so driver can report the aligned resolution through the g_fmt,
and report the actual resolution through the g_selection.

For encoder, it even support to encode a smaller jpeg
than the original picture through s_selection api.

For the decoder, we do not support cropping a portion smaller
than the original picture, due to hardware limitations (wrapper side).

Fixes: 9e7aa76cdb02 ("media: imx-jpeg: Align upwards buffer size")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agomtk-jpegdec: add stop cmd interface for jpgdec
kyrie wu [Thu, 29 Sep 2022 09:08:17 +0000 (17:08 +0800)]
mtk-jpegdec: add stop cmd interface for jpgdec

Add stop cmd interface for jpgdec to stop stream

Signed-off-by: kyrie wu <kyrie.wu@mediatek.com>
Signed-off-by: irui wang <irui.wang@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agomedia: mtk-jpegdec: refactor jpegdec func interface
kyrie wu [Thu, 29 Sep 2022 09:08:16 +0000 (17:08 +0800)]
media: mtk-jpegdec: refactor jpegdec func interface

refactor the func interface of mtk_jpeg_dec_set_config
for decode

Signed-off-by: kyrie wu <kyrie.wu@mediatek.com>
Signed-off-by: irui wang <irui.wang@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agomedia: mtk-jpegdec: add output pic reorder interface
kyrie wu [Thu, 29 Sep 2022 09:08:15 +0000 (17:08 +0800)]
media: mtk-jpegdec: add output pic reorder interface

add output reorder func to reorder the output images
to ensure the output pic is consistent with the input images.

Signed-off-by: kyrie wu <kyrie.wu@mediatek.com>
Signed-off-by: irui wang <irui.wang@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agomedia: mtk-jpegdec: add jpeg decode worker interface
kyrie wu [Thu, 29 Sep 2022 09:08:14 +0000 (17:08 +0800)]
media: mtk-jpegdec: add jpeg decode worker interface

Add jpeg decoding worker to ensure that three HWs
run in parallel in MT8195.

Signed-off-by: kyrie wu <kyrie.wu@mediatek.com>
Signed-off-by: irui wang <irui.wang@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agomedia: mtk-jpegdec: add jpegdec timeout func interface
kyrie wu [Thu, 29 Sep 2022 09:08:13 +0000 (17:08 +0800)]
media: mtk-jpegdec: add jpegdec timeout func interface

Generalizes jpegdec timeout func interfaces to handle HW timeout.

Signed-off-by: kyrie wu <kyrie.wu@mediatek.com>
Signed-off-by: irui wang <irui.wang@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agomedia: mtk-jpegdec: support jpegdec multi-hardware
kyrie wu [Thu, 29 Sep 2022 09:08:12 +0000 (17:08 +0800)]
media: mtk-jpegdec: support jpegdec multi-hardware

support jpegdec multi-hardware includes HW0/HW1/HW2.

Signed-off-by: kyrie wu <kyrie.wu@mediatek.com>
Signed-off-by: irui wang <irui.wang@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agomedia: mtk-jpegdec: export jpeg decoder functions
kyrie wu [Thu, 29 Sep 2022 09:08:11 +0000 (17:08 +0800)]
media: mtk-jpegdec: export jpeg decoder functions

mtk jpeg decoder is built as a module, export some functions to make them
visible by other modules.

Signed-off-by: kyrie wu <kyrie.wu@mediatek.com>
Signed-off-by: irui wang <irui.wang@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agodt-bindings: mediatek: Add mediatek,mt8195-jpgdec compatible
kyrie wu [Thu, 29 Sep 2022 09:08:10 +0000 (17:08 +0800)]
dt-bindings: mediatek: Add mediatek,mt8195-jpgdec compatible

Add mediatek,mt8195-jpgdec compatible to binding document.

Signed-off-by: kyrie wu <kyrie.wu@mediatek.com>
Signed-off-by: irui wang <irui.wang@mediatek.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agomtk-jpegenc: add stop cmd interface for jpgenc
kyrie wu [Thu, 29 Sep 2022 09:08:09 +0000 (17:08 +0800)]
mtk-jpegenc: add stop cmd interface for jpgenc

Add stop cmd interface for jpgenc to stop stream

Signed-off-by: kyrie wu <kyrie.wu@mediatek.com>
Signed-off-by: irui wang <irui.wang@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agomtk-jpegenc: add output pic reorder interface
kyrie wu [Thu, 29 Sep 2022 09:08:08 +0000 (17:08 +0800)]
mtk-jpegenc: add output pic reorder interface

There are two HWs in mt8195. Since the two HWs run
in parallel, it is necessary to reorder the output images
to ensure that the order is consistent with the input images.

Signed-off-by: kyrie wu <kyrie.wu@mediatek.com>
Signed-off-by: irui wang <irui.wang@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agomtk-jpegenc: add jpeg encode worker interface
kyrie wu [Thu, 29 Sep 2022 09:08:07 +0000 (17:08 +0800)]
mtk-jpegenc: add jpeg encode worker interface

Add jpeg encoding worker to ensure that two HWs
run in parallel in MT8195.

Signed-off-by: kyrie wu <kyrie.wu@mediatek.com>
Signed-off-by: irui wang <irui.wang@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agomtk-jpegenc: add jpegenc timeout func interface
kyrie wu [Thu, 29 Sep 2022 09:08:06 +0000 (17:08 +0800)]
mtk-jpegenc: add jpegenc timeout func interface

Generalizes jpegenc timeout func interfaces to handle HW timeout.

Signed-off-by: kyrie wu <kyrie.wu@mediatek.com>
Signed-off-by: irui wang <irui.wang@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agomtk-jpegenc: support jpegenc multi-hardware
kyrie wu [Thu, 29 Sep 2022 09:08:05 +0000 (17:08 +0800)]
mtk-jpegenc: support jpegenc multi-hardware

support jpeg encode multi-hardware includes HW0 and HW1.

Signed-off-by: kyrie wu <kyrie.wu@mediatek.com>
Signed-off-by: irui wang <irui.wang@mediatek.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agomtk-jpegenc: export jpeg encoder functions
kyrie wu [Thu, 29 Sep 2022 09:08:04 +0000 (17:08 +0800)]
mtk-jpegenc: export jpeg encoder functions

mtk jpeg encoder is built as a module, export some functions to make them
visible by other modules.

Signed-off-by: kyrie wu <kyrie.wu@mediatek.com>
Signed-off-by: irui wang <irui.wang@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agodt-bindings: mediatek: Add mediatek, mt8195-jpgenc compatible
kyrie wu [Thu, 29 Sep 2022 09:08:03 +0000 (17:08 +0800)]
dt-bindings: mediatek: Add mediatek, mt8195-jpgenc compatible

Add mediatek,mt8195-jpgenc compatible to binding document.

Signed-off-by: kyrie wu <kyrie.wu@mediatek.com>
Signed-off-by: irui wang <irui.wang@mediatek.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agomedia: imx-jpeg: Disable useless interrupt to avoid kernel panic
Ming Qian [Thu, 4 Aug 2022 09:38:41 +0000 (17:38 +0800)]
media: imx-jpeg: Disable useless interrupt to avoid kernel panic

There is a hardware bug that the interrupt STMBUF_HALF may be triggered
after or when disable interrupt.
It may led to unexpected kernel panic.
And interrupt STMBUF_HALF and STMBUF_RTND have no other effect.
So disable them and the unused interrupts.

meanwhile clear the interrupt status when disable interrupt.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: Mirela Rabulea <mirela.rabulea@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agomedia: imx-jpeg: Don't clear stop state in handling dynamic resolution change
Ming Qian [Tue, 26 Jul 2022 09:04:27 +0000 (17:04 +0800)]
media: imx-jpeg: Don't clear stop state in handling dynamic resolution change

In dynamic resolution change, streamoff and streamon on the capture
queue may be called,
the V4L2_DEC_CMD_STOP cmd may be called before driver parsed the
jpeg header.
don't clear the stop state in streamoff of handling the
dynamic resolution change,
otherwise the drain may not complete.

Fixes: 4911c5acf9351 ("media: imx-jpeg: Implement drain using v4l2-mem2mem helpers")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agodt-bindings: media: mediatek-jpeg-encoder: Add MT8188 compatible string
Jianhua Lin [Tue, 19 Jul 2022 10:02:14 +0000 (18:02 +0800)]
dt-bindings: media: mediatek-jpeg-encoder: Add MT8188 compatible string

Add compatible for MT8188 jpeg encoder.

Signed-off-by: Jianhua Lin <jianhua.lin@mediatek.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agodt-bindings: media: mediatek-jpeg-decoder: Add MT8188 compatible string
Jianhua Lin [Tue, 19 Jul 2022 10:02:13 +0000 (18:02 +0800)]
dt-bindings: media: mediatek-jpeg-decoder: Add MT8188 compatible string

Add compatible for MT8188 jpeg decoder.

Signed-off-by: Jianhua Lin <jianhua.lin@mediatek.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agomedia: imx-jpeg: Add a timeout mechanism for each frame
Ming Qian [Mon, 18 Jul 2022 02:37:37 +0000 (10:37 +0800)]
media: imx-jpeg: Add a timeout mechanism for each frame

Add a timeout mechanism for each frame.
If the frame can't be decoded or encoded,
driver can cancel it to avoid hang.

Fixes: 2db16c6ed72ce ("media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: Mirela Rabulea <mirela.rabulea@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agomedia: imx-jpeg: Remove unnecessary memset() after dma_alloc_coherent()
Jason Wang [Sat, 16 Jul 2022 12:25:43 +0000 (20:25 +0800)]
media: imx-jpeg: Remove unnecessary memset() after dma_alloc_coherent()

The `dma_alloc_coherent()' already zeroes out memory for us, so we don't
need the redundant memset().

Signed-off-by: Jason Wang <wangborong@cdjrlc.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
21 months agoMerge fixes into media_stage
Mauro Carvalho Chehab [Tue, 27 Sep 2022 08:27:48 +0000 (10:27 +0200)]
Merge fixes into media_stage

* fixes:
  media: rkvdec: Disable H.264 error detection
  media: mediatek: vcodec: Drop platform_get_resource(IORESOURCE_IRQ)
  media: dvb_vb2: fix possible out of bound access
  media: v4l2-ioctl.c: fix incorrect error path
  media: v4l2-compat-ioctl32.c: zero buffer passed to v4l2_compat_get_array_args()
  media: uvcvideo: Fix InterfaceProtocol for Quanta camera

21 months agomedia: rkvdec: Disable H.264 error detection
Nicolas Dufresne [Fri, 10 Jun 2022 12:52:11 +0000 (13:52 +0100)]
media: rkvdec: Disable H.264 error detection

Quite often, the HW get stuck in error condition if a stream error
was detected. As documented, the HW should stop immediately and self
reset. There is likely a problem or a miss-understanding of the self
reset mechanism, as unless we make a long pause, the next command
will then report an error even if there is no error in it.

Disabling error detection fixes the issue, and let the decoder continue
after an error. This patch is safe for backport into older kernels.

Fixes: cd33c830448b ("media: rkvdec: Add the rkvdec driver")
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Tested-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: mediatek: vcodec: Drop platform_get_resource(IORESOURCE_IRQ)
Nícolas F. R. A. Prado [Fri, 17 Jun 2022 20:39:06 +0000 (21:39 +0100)]
media: mediatek: vcodec: Drop platform_get_resource(IORESOURCE_IRQ)

Commit a1a2b7125e10 ("of/platform: Drop static setup of IRQ resource
from DT core") removed support for calling platform_get_resource(...,
IORESOURCE_IRQ, ...) on DT-based drivers, but the probe() function of
mtk-vcodec's encoder was still making use of it. This caused the encoder
driver to fail probe.

Since the platform_get_resource() call was only being used to check for
the presence of the interrupt (its returned resource wasn't even used)
and platform_get_irq() was already being used to get the IRQ, simply
drop the use of platform_get_resource(IORESOURCE_IRQ) and handle the
failure of platform_get_irq(), to get the driver probing again.

[hverkuil: drop unused struct resource *res]

Fixes: a1a2b7125e10 ("of/platform: Drop static setup of IRQ resource from DT core")
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: dvb_vb2: fix possible out of bound access
Hangyu Hua [Thu, 19 May 2022 02:17:43 +0000 (03:17 +0100)]
media: dvb_vb2: fix possible out of bound access

vb2_core_qbuf and vb2_core_querybuf don't check the range of b->index
controlled by the user.

Fix this by adding range checking code before using them.

Fixes: 57868acc369a ("media: videobuf2: Add new uAPI for DVB streaming I/O")
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: v4l2-ioctl.c: fix incorrect error path
Hans Verkuil [Wed, 18 May 2022 13:06:31 +0000 (14:06 +0100)]
media: v4l2-ioctl.c: fix incorrect error path

If allocating array_buf fails, or copying data from userspace into that
buffer fails, then just free memory and return the error. Don't attempt
to call video_put_user() since there is no point, and it would copy back
data on error even if INFO_FL_ALWAYS_COPY wasn't set.

So if writing the array back to userspace fails, then don't go to
out_array_args, instead just continue with the regular code that just
returns the error unless 'always_copy' is set.

Update the VIDIOC_G/S/TRY_EXT_CTRLS ioctls to set the ALWAYS_COPY flag
since they now need it. Before this worked due to this buggy code, but
now that that is fixed these ioctls need to set this flag explicitly.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: v4l2-compat-ioctl32.c: zero buffer passed to v4l2_compat_get_array_args()
Hans Verkuil [Mon, 21 Mar 2022 08:33:56 +0000 (08:33 +0000)]
media: v4l2-compat-ioctl32.c: zero buffer passed to v4l2_compat_get_array_args()

The v4l2_compat_get_array_args() function can leave uninitialized memory in the
buffer it is passed. So zero it before copying array elements from userspace
into the buffer.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reported-by: syzbot+ff18193ff05f3f87f226@syzkaller.appspotmail.com
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun6i-csi: Move csi buffer definition to main header file
Paul Kocialkowski [Fri, 26 Aug 2022 18:32:12 +0000 (20:32 +0200)]
media: sun6i-csi: Move csi buffer definition to main header file

The buffer structure is a top-level definition, put it in the main header
to keep things tidy. No functional change intended.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Maxime Ripard <maxime@cerno.tech>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun6i-csi: Introduce and use video helper functions
Paul Kocialkowski [Fri, 26 Aug 2022 18:32:11 +0000 (20:32 +0200)]
media: sun6i-csi: Introduce and use video helper functions

Introduce some helpers for buffer and general video configuration.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun6i-csi: Add media ops with link notify callback
Paul Kocialkowski [Fri, 26 Aug 2022 18:32:10 +0000 (20:32 +0200)]
media: sun6i-csi: Add media ops with link notify callback

In order to keep the power use count fields balanced when link changes
happen between v4l2_pipeline_pm_get/set calls (in open/close),
the link_notify media operation callback needs to be registered.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun6i-csi: Remove controls handler from the driver
Paul Kocialkowski [Fri, 26 Aug 2022 18:32:09 +0000 (20:32 +0200)]
media: sun6i-csi: Remove controls handler from the driver

The driver does not expose controls directly and thus does not need
a controls handler for its own use.

Controls attached to subdevs used to be exposed that way, however this
can easily lead to issue when multiple subdevs attached to the same
v4l2 device expose the same controls. Subdev controls should be set
through each individual subdev node instead.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun6i-csi: Register the media device after creation
Paul Kocialkowski [Fri, 26 Aug 2022 18:32:08 +0000 (20:32 +0200)]
media: sun6i-csi: Register the media device after creation

There is no particular need to register the media device in the
subdev notify complete callback.

Register it in the v4l2 code instead where it's more in-context.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun6i-csi: Pass and store csi device directly in video code
Paul Kocialkowski [Fri, 26 Aug 2022 18:32:07 +0000 (20:32 +0200)]
media: sun6i-csi: Pass and store csi device directly in video code

The video structure is part of the main csi device structure, so pass
pointers to that top-level structure directly. This makes it easier to
navigate and access other elements. No functional change intended.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Maxime Ripard <maxime@cerno.tech>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun6i-csi: Tidy up video code
Paul Kocialkowski [Fri, 26 Aug 2022 18:32:06 +0000 (20:32 +0200)]
media: sun6i-csi: Tidy up video code

Some code cleanups, renames, variable lowerings and moving things around for
better organization. No functional change intended.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Maxime Ripard <maxime@cerno.tech>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun6i-csi: Tidy up v4l2 code
Paul Kocialkowski [Fri, 26 Aug 2022 18:32:05 +0000 (20:32 +0200)]
media: sun6i-csi: Tidy up v4l2 code

Various cosmetic improvements to the v4l2 registration code, with
renames, lowerings, etc. The cleanup function is moved down after
setup. No functional change intended.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Maxime Ripard <maxime@cerno.tech>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun6i-csi: Tidy up Kconfig
Paul Kocialkowski [Fri, 26 Aug 2022 18:32:04 +0000 (20:32 +0200)]
media: sun6i-csi: Tidy up Kconfig

Update the option title and help, group related options together,
add dependency on VIDEO_DEV since the driver uses it and update the
description.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun6i-csi: Use runtime pm for clocks and reset
Paul Kocialkowski [Fri, 26 Aug 2022 18:32:03 +0000 (20:32 +0200)]
media: sun6i-csi: Use runtime pm for clocks and reset

Wrap the clock and reset preparation into runtime pm functions
for better organization of the code. Also fix the clock and
reset enable order to first deassert reset, as recommended in
Allwinner literature.

Make the driver depend on PM while at it since runtime pm is
mandatory for the driver to work.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun6i-csi: Define and use variant to get module clock rate
Paul Kocialkowski [Fri, 26 Aug 2022 18:32:02 +0000 (20:32 +0200)]
media: sun6i-csi: Define and use variant to get module clock rate

Introduce a proper variant structure with the module clock rate
instead of hardcoding it with a manual check on the compatible.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun6i-csi: Always set exclusive module clock rate
Paul Kocialkowski [Fri, 26 Aug 2022 18:32:01 +0000 (20:32 +0200)]
media: sun6i-csi: Always set exclusive module clock rate

In some situations the default rate of the module clock is not the
required one for operation (for example when reconfiguring the clock
tree to use a different parent). As a result, always set the correct
rate for the clock (and take care of cleanup).

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun6i-csi: Tidy up platform code
Paul Kocialkowski [Fri, 26 Aug 2022 18:32:00 +0000 (20:32 +0200)]
media: sun6i-csi: Tidy up platform code

Various renames, variables lowering and other cosmetic changes in the
platform-support code. No functional change intended.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Maxime Ripard <maxime@cerno.tech>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun6i-csi: Refactor main driver data structures
Paul Kocialkowski [Wed, 7 Sep 2022 10:00:38 +0000 (12:00 +0200)]
media: sun6i-csi: Refactor main driver data structures

Merge contents of structs sun6i_csi and sun6i_csi_dev into a main
sun6i_csi_device structure holding a sun6i_csi_v4l2 struct for things
related to v4l2, as well as the already-existing sun6i_csi_video and
sun6i_csi_config which are left unchanged.

This mostly simplifies accessing stuff by having a single main
structure accessible to every part of the code instead of a private
definition.

Also solve some kerneldoc warnings by describing return codes while
at it.

No functional change is intended in this commit, variables are just
moved around (cosmetics).

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Maxime Ripard <maxime@cerno.tech>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun6i-csi: Define and use driver name and (reworked) description
Paul Kocialkowski [Fri, 26 Aug 2022 18:31:58 +0000 (20:31 +0200)]
media: sun6i-csi: Define and use driver name and (reworked) description

Add proper defines for driver name and description instead of
MODULE_NAME and hardcoding (cosmetics).

Also rework the description while at it to mention the hardware
generation that the driver supports and remove the video capture
mentions since it applies to the whole media device.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Maxime Ripard <maxime@cerno.tech>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: cedrus: Add a Kconfig dependency on RESET_CONTROLLER
Paul Kocialkowski [Thu, 25 Aug 2022 10:20:35 +0000 (12:20 +0200)]
media: cedrus: Add a Kconfig dependency on RESET_CONTROLLER

The driver relies on the reset controller API to work, so add
RESET_CONTROLLER as one of its Kconfig dependencies.

Fixes: 50e761516f2b ("media: platform: Add Cedrus VPU decoder driver")
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun8i-rotate: Add a Kconfig dependency on RESET_CONTROLLER
Paul Kocialkowski [Thu, 25 Aug 2022 10:20:34 +0000 (12:20 +0200)]
media: sun8i-rotate: Add a Kconfig dependency on RESET_CONTROLLER

The driver relies on the reset controller API to work, so add
RESET_CONTROLLER as one of its Kconfig dependencies.

Fixes: d77182ada3d4 ("media: sun8i: Add Allwinner A83T Rotate driver")
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun8i-di: Add a Kconfig dependency on RESET_CONTROLLER
Paul Kocialkowski [Thu, 25 Aug 2022 10:20:33 +0000 (12:20 +0200)]
media: sun8i-di: Add a Kconfig dependency on RESET_CONTROLLER

The driver relies on the reset controller API to work, so add
RESET_CONTROLLER as one of its Kconfig dependencies.

Fixes: a4260ea49547 ("media: sun4i: Add H3 deinterlace driver")
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun4i-csi: Add a Kconfig dependency on RESET_CONTROLLER
Paul Kocialkowski [Thu, 25 Aug 2022 10:20:32 +0000 (12:20 +0200)]
media: sun4i-csi: Add a Kconfig dependency on RESET_CONTROLLER

The driver relies on the reset controller API to work, so add
RESET_CONTROLLER as one of its Kconfig dependencies.

Fixes: 577bbf23b758 ("media: sunxi: Add A10 CSI driver")
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun6i-csi: Add a Kconfig dependency on RESET_CONTROLLER
Paul Kocialkowski [Thu, 25 Aug 2022 10:20:31 +0000 (12:20 +0200)]
media: sun6i-csi: Add a Kconfig dependency on RESET_CONTROLLER

The driver relies on the reset controller API to work, so add
RESET_CONTROLLER as one of its Kconfig dependencies.

Fixes: 5cc7522d8965 ("media: sun6i: Add support for Allwinner CSI V3s")
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun8i-a83t-mipi-csi2: Add a Kconfig dependency on RESET_CONTROLLER
Paul Kocialkowski [Thu, 25 Aug 2022 10:20:30 +0000 (12:20 +0200)]
media: sun8i-a83t-mipi-csi2: Add a Kconfig dependency on RESET_CONTROLLER

The driver relies on the reset controller API to work, so add
RESET_CONTROLLER as one of its Kconfig dependencies.

Fixes: 576d196c522b ("media: sunxi: Add support for the A83T MIPI CSI-2 controller")
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sun6i-mipi-csi2: Add a Kconfig dependency on RESET_CONTROLLER
Paul Kocialkowski [Thu, 25 Aug 2022 10:20:29 +0000 (12:20 +0200)]
media: sun6i-mipi-csi2: Add a Kconfig dependency on RESET_CONTROLLER

The driver relies on the reset controller API to work, so add
RESET_CONTROLLER as one of its Kconfig dependencies.

It also selects PHY_SUN6I_MIPI_DPHY, which depends on RESET_CONTROLLER.

Fixes: af54b4f4c17f ("media: sunxi: Add support for the A31 MIPI CSI-2 controller")
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reported-by: kernel test robot <lkp@intel.com>
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: venus: hfi: Remove the unneeded result variable
ye xingchen [Tue, 30 Aug 2022 08:37:53 +0000 (10:37 +0200)]
media: venus: hfi: Remove the unneeded result variable

Return the value venus_hfi_create() directly instead of storing it in
another redundant variable.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: venus: venc: Set HDR10 PQ SEI property only for MAIN10 profile
Stanimir Varbanov [Fri, 2 Sep 2022 10:01:58 +0000 (12:01 +0200)]
media: venus: venc: Set HDR10 PQ SEI property only for MAIN10 profile

The HDR10 PQ SEI should be set only when the codec is HEVC and
the profile is MAIN10, otherwise some artefacts could be produced
on the encoded bitstream.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: venus: venc_ctrls: Add default value for CLL info
Stanimir Varbanov [Fri, 2 Sep 2022 10:00:31 +0000 (12:00 +0200)]
media: venus: venc_ctrls: Add default value for CLL info

Add default value for CLL info when creating compound control.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: venus : Allow MIN/MAX settings for the v4l2 encoder controls defined range.
Vikash Garodia [Mon, 8 Aug 2022 09:28:34 +0000 (11:28 +0200)]
media: venus : Allow MIN/MAX settings for the v4l2 encoder controls defined range.

Control MIN/MAX range defined as 0 to 1, as MIN value setting enabled
for V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM.

error details: fail: v4l2-test-controls.cpp(516):
invalid maximum range check

Signed-off-by: Viswanath Boma <quic_vboma@quicinc.com>
Signed-off-by: Vikash Garodia <vgarodia@qti.qualcomm.com>
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: venus : Remove the capture plane settings for venc_g_parm/venc_s_parm
Viswanath Boma [Mon, 8 Aug 2022 09:28:33 +0000 (11:28 +0200)]
media: venus : Remove the capture plane settings for venc_g_parm/venc_s_parm

v4l2 compliance expecting settings for out buffer only and the same
values will be propagated to capture buffer setting by h/w encoder .
settings on cpature plane are optional , required only if
offline-encoding supports.

error details : fail: v4l2-test-formats.cpp(1350): !ret

Signed-off-by: Viswanath Boma <quic_vboma@quicinc.com>
Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: venus : Addition of support for VIDIOC_TRY_ENCODER_CMD
Dikshita Agarwal [Mon, 8 Aug 2022 09:28:32 +0000 (11:28 +0200)]
media: venus : Addition of support for VIDIOC_TRY_ENCODER_CMD

v4l2 compliance expecting support for vidioc_try_encoder_cmd .

error details : test VIDIOC_(TRY_)ENCODER_CMD: FAIL

Signed-off-by: Viswanath Boma <quic_vboma@quicinc.com>
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: venus : Addition of EOS Event support for Encoder
Viswanath Boma [Mon, 8 Aug 2022 09:28:31 +0000 (11:28 +0200)]
media: venus : Addition of EOS Event support for Encoder

V4l2 encoder compliance expecting End of stream Event registration
support for Encoder.

Signed-off-by: Viswanath Boma <quic_vboma@quicinc.com>
Signed-off-by: Vikash Garodia <vgarodia@qti.qualcomm.com>
Signed-off-by: Dikshita Agarwal <dikshita@codeaurora.org>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: venus : CAPTURE Plane width/height alignment with OUT plane.
Stanimir Varbanov [Mon, 8 Aug 2022 09:28:30 +0000 (11:28 +0200)]
media: venus : CAPTURE Plane width/height alignment with OUT plane.

V4l2 encoder compliance set-format test cases failing as Capture plane
width/height not aligned to OUT plane .

Signed-off-by: Viswanath Boma <quic_vboma@quicinc.com>
Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: venus : Addition of control support - V4L2_CID_MIN_BUFFERS_FOR_OUTPUT
Viswanath Boma [Mon, 8 Aug 2022 09:28:29 +0000 (11:28 +0200)]
media: venus : Addition of control support - V4L2_CID_MIN_BUFFERS_FOR_OUTPUT

V4l2 encoder compliance expecting minimum buffers support for
the application to allocate buffers as per the control support values.

Signed-off-by: Viswanath Boma <quic_vboma@quicinc.com>
Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: venus : Add default values for the control
Stanimir Varbanov [Mon, 8 Aug 2022 09:28:28 +0000 (11:28 +0200)]
media: venus : Add default values for the control

V4l2 encoder compliance expecting default values of colorimetry
for the control.

Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Viswanath Boma <quic_vboma@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: venus: Fix NV12 decoder buffer discovery on HFI_VERSION_1XX
Bryan O'Donoghue [Tue, 26 Jul 2022 02:14:55 +0000 (04:14 +0200)]
media: venus: Fix NV12 decoder buffer discovery on HFI_VERSION_1XX

HFI_VERSION_1XX uses HFI_BUFFER_OUTPUT not HFI_BUFFER_OUTPUT2 for decoder
buffers.

venus_helper_check_format() places a constraint on an output buffer to be
of type HFI_BUFFER_OUTPUT2. HFI_1XX uses HFI_BUFFER_OUTPUT though.

Switching to the logic used in venus_helper_get_out_fmts() first checking
for HFI_BUFFER_OUTPUT and then HFI_BUFFER_OUTPUT2 resolves on HFI_1XX.

db410c before:
root@linaro-alip:~# v4l2-ctl  -d /dev/video0 --list-formats
ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture Multiplanar

        [0]: 'MPG4' (MPEG-4 Part 2 ES, compressed)
        [1]: 'H263' (H.263, compressed)
        [2]: 'H264' (H.264, compressed)
        [3]: 'VP80' (VP8, compressed)

root@linaro-alip:~# v4l2-ctl  -d /dev/video1 --list-formats
ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture Multiplanar

db410c after:
root@linaro-alip:~# v4l2-ctl  -d /dev/video0 --list-formats
ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture Multiplanar

        [0]: 'MPG4' (MPEG-4 Part 2 ES, compressed)
        [1]: 'H263' (H.263, compressed)
        [2]: 'H264' (H.264, compressed)
        [3]: 'VP80' (VP8, compressed)

root@linaro-alip:~# v4l2-ctl  -d /dev/video1 --list-formats
ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture Multiplanar

        [0]: 'NV12' (Y/CbCr 4:2:0)

Validated playback with ffplay on db410c with h264 and vp8 decoding.

Fixes: 9593126dae3e ("media: venus: Add a handling of QC08C compressed format")
Cc: stable@vger.kernel.org # v5.19
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: venus: dec: Handle the case where find_format fails
Bryan O'Donoghue [Tue, 26 Jul 2022 02:14:54 +0000 (04:14 +0200)]
media: venus: dec: Handle the case where find_format fails

Debugging the decoder on msm8916 I noticed the vdec probe was crashing if
the fmt pointer was NULL.

A similar fix from Colin Ian King found by Coverity was implemented for the
encoder. Implement the same fix on the decoder.

Fixes: 7472c1c69138 ("[media] media: venus: vdec: add video decoder files")
Cc: stable@vger.kernel.org # v4.13+
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: cx88: add IR remote support for NotOnlyTV LV3H
Daniel González Cabanelas [Mon, 7 Feb 2022 14:51:41 +0000 (15:51 +0100)]
media: cx88: add IR remote support for NotOnlyTV LV3H

The PCI hybrid card NotOnlyTV LV3H has a built-in IR receiver connected
via I2C bus, currently not supported. This receiver is probably present
in more Geniatech cards. It has no capability for repeating when a key is
held down.

Add support for this built-in IR receiver. Use the existing Total Media
In Hand_02 remote keytable (Geniatech Mygica X8507) which matches exactly
the LV3H remote.

Signed-off-by: Daniel González Cabanelas <dgcbueu@gmail.com>
Signed-off-by: Marek Kidawski <mark_kiddy@wp.pl>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sunxi: Fix some error handling path of sun6i_mipi_csi2_probe()
Christophe JAILLET [Tue, 23 Aug 2022 07:42:11 +0000 (09:42 +0200)]
media: sunxi: Fix some error handling path of sun6i_mipi_csi2_probe()

Release some resources in the error handling path of the probe and of
sun6i_mipi_csi2_resources_setup(), as already done in the remove
function.

Fixes: af54b4f4c17f ("media: sunxi: Add support for the A31 MIPI CSI-2 controller")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: sunxi: Fix some error handling path of sun8i_a83t_mipi_csi2_probe()
Christophe JAILLET [Tue, 23 Aug 2022 07:42:01 +0000 (09:42 +0200)]
media: sunxi: Fix some error handling path of sun8i_a83t_mipi_csi2_probe()

Release some resources in the error handling path of the probe and of
sun8i_a83t_mipi_csi2_resources_setup(), as already done in the remove
function.

Fixes: 576d196c522b ("media: sunxi: Add support for the A83T MIPI CSI-2 controller")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: don't store an unused sink data on a var
Mauro Carvalho Chehab [Sat, 24 Sep 2022 09:10:22 +0000 (11:10 +0200)]
media: atomisp: don't store an unused sink data on a var

Fixes this Werror breakage:

drivers/staging/media/atomisp/pci/atomisp_ioctl.c: In function 'atomisp_streamon':
drivers/staging/media/atomisp/pci/atomisp_ioctl.c:1714:44: error: variable 'sink' set but not used [-Werror=unused-but-set-variable]
 1714 |                 struct v4l2_mbus_framefmt *sink;
      |                                            ^~~~

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp_gmin_platform: Unexport and split camera_sensor_csi()
Andy Shevchenko [Sat, 30 Jul 2022 16:20:27 +0000 (18:20 +0200)]
media: atomisp_gmin_platform: Unexport and split camera_sensor_csi()

The camera_sensor_csi() is not used outside the module, hence make it
static. While at it, split it to _alloc() and _free() to clearly show
the idea behind the last parameter @flag that is passed to
gmin_csi_cfg().

Link: https://lore.kernel.org/r/20220730162027.1011-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Remove atomisp_source_pad_to_stream_id()
Hans de Goede [Fri, 9 Sep 2022 21:46:39 +0000 (23:46 +0200)]
media: atomisp: Remove atomisp_source_pad_to_stream_id()

atomisp_source_pad_to_stream_id() returns ATOMISP_INPUT_STREAM_GENERAL
unconditionally now. Drop it and directly use ATOMISP_INPUT_STREAM_GENERAL
in its callers.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Remove const/fixed camera_caps
Hans de Goede [Sun, 4 Sep 2022 16:54:36 +0000 (18:54 +0200)]
media: atomisp: Remove const/fixed camera_caps

The code checks a camera_caps struct in various places, but this always
points to the same const camera_caps struct.

Remove the checks, keeping the code paths which would be taken with
the fixed camera caps struct still in place and remove the camera_caps
struct itself.

Note this completely removes atomisp_pause_buffer_event() because that
only ever does something if camera_caps.sensors[0].is_slave is true and
that never is true.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Remove unused atomisp_css_get_dis_statistics()
Hans de Goede [Sun, 4 Sep 2022 13:04:36 +0000 (15:04 +0200)]
media: atomisp: Remove unused atomisp_css_get_dis_statistics()

Remove the unused atomisp_css_get_dis_statistics() function. This seems to
be a leftover variant / older version of atomisp_css_get_dis_stats() which
is actually used.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Make atomisp_set_raw_buffer_bitmap() static
Hans de Goede [Sun, 4 Sep 2022 12:59:08 +0000 (14:59 +0200)]
media: atomisp: Make atomisp_set_raw_buffer_bitmap() static

atomisp_set_raw_buffer_bitmap() is only used in atomisp_cmd.c,
make it static. Unfortunately this still requires a forward
declaration (the function cannot be moved easily).

Still this will at least make it obvious to anyone reading the code
that the function is not used elsewhere.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Drop unnecessary first_streamoff check
Hans de Goede [Sun, 4 Sep 2022 08:56:47 +0000 (10:56 +0200)]
media: atomisp: Drop unnecessary first_streamoff check

Drop an unnecessary first_streamoff check from atomisp_streamoff(),
above the check there is a:

if (!first_streamoff)
goto stop_sensor;

Code block which will jump over the code with the test, so the test
is only executed when first_streamoff is true and therefor the test
is not necessary.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Remove a couple of not useful function wrappers
Hans de Goede [Sun, 4 Sep 2022 08:47:23 +0000 (10:47 +0200)]
media: atomisp: Remove a couple of not useful function wrappers

The __atomisp_reqbufs(), __atomisp_streamoff() are 1:1 wrappers for
the non __ prefixed functions now, drop these wrappers.

The atomisp_s_fmt_cap() wrapper is almost a 1:1 wrapper for
atomisp_set_fmt() adjust the latter to have the right function
prototype and drop the wrapper.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Use video_dev.lock for ioctl locking
Hans de Goede [Fri, 2 Sep 2022 21:56:48 +0000 (23:56 +0200)]
media: atomisp: Use video_dev.lock for ioctl locking

Set video_dev.lock to point to isp->mutex so that the core does
the locking surroundig ioctls for us and drop all the now no longer
necessary (and conflicting) locking from the ioctl handling code.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Drop streamoff_mutex
Hans de Goede [Sat, 3 Sep 2022 21:42:53 +0000 (23:42 +0200)]
media: atomisp: Drop streamoff_mutex

Now that __atomisp_streamoff() no longer drops isp->mutex to cancel
the watchdog timer, the streamoff_mutex is no longer necessary to
avoid multiple streamoffs racing with each other.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Rework asd->streaming state update in __atomisp_streamoff()
Hans de Goede [Sat, 3 Sep 2022 21:50:42 +0000 (23:50 +0200)]
media: atomisp: Rework asd->streaming state update in __atomisp_streamoff()

During the first __atomisp_streamoff() call on an asd with only one pipe
streaming asd->streaming would get set twice:

asd->streaming = ATOMISP_DEVICE_STREAMING_STOPPING;
asd->streaming = ATOMISP_DEVICE_STREAMING_DISABLED;

Rework the code a bit so that it gets set to the correct value
right away instead of doing this in 2 steps.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Move atomisp_streaming_count() check into __atomisp_css_recover()
Hans de Goede [Sat, 3 Sep 2022 21:36:01 +0000 (23:36 +0200)]
media: atomisp: Move atomisp_streaming_count() check into __atomisp_css_recover()

Both callers of __atomisp_css_recover() check atomisp_streaming_count()
first, move the check into __atomisp_css_recover().

And __atomisp_css_recover() already calls lockdep_assert_held(&isp->mutex),
so drop that from atomisp_css_flush().

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Remove watchdog timer
Hans de Goede [Sat, 3 Sep 2022 21:26:27 +0000 (23:26 +0200)]
media: atomisp: Remove watchdog timer

The watchdog timer code to recover from the ISP getting stuck has several
major issues:

1. There is no way to do fault injection and normally the ISP does not
get stuck, so is it is impossible to test it.

2. It in essence just stops all streams, resets the ISP and then brings
everything back up. Userspace can easily do this itself by using a
timeout on dqbuf and then closing (which causes a poweroff) +
re-opening the device. Doing this in userspace (if it ever turns out
to be necessary) greatly simplifies the kernel code and in general
will be a more robust solution.

Even just a quick look at the code finds several more issues:

3. The need to sync-cancel the timers + work on streamoff requires
isp->mutex to be dropped halfway during the ioctl opening all sorts of
races.

4. The atomisp code supports setting up 2 pipelines, streaming from
two sensors at the same time. But there is only a single wdt_work
and stopping one of the 2 streams will cancel the timers + work,
stopping the wdt even though the other stream might still be running.

5. In case atomisp_css_flush() the sync cancel is done while keeping
isp->mutex locked, causing a deadlock when racing with wdt_work which
also takes isp->mutex.

6. Even though the watchdog is purely a software/driver thing which
just checkes that new frames keep coming in, there are 2 completely
different implementations for the ISP2400/ISP2401 which is not
necessary at all.

So all in all I believe that it is better to just remove the current
watchdog implementation. Fixing all the issues with the current
implementation will be so much work, that if it turns out that we do
need something like this then doing a clean re-implementation from
scratch will be better anyways.

wdt_work was also (ab)used to reset the ISP after the firmware signalled
an fw-assert error through the irq, add a new assert_recover_work to
replace this.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Add atomisp_pipe_check() helper
Hans de Goede [Sat, 3 Sep 2022 12:49:39 +0000 (14:49 +0200)]
media: atomisp: Add atomisp_pipe_check() helper

Several of the ioctl handlers all do the same checks
(isp->fatal_error and asd->streaming errors) add
an atomisp_pipe_check() helper for this.

Note this changes the vidioc_s_fmt_vid_cap and vidioc_s_input handlers
to now reject calls made while asd->streaming==STOPPING. This fixes
a possible race where one thread can make this ioctls while
vidioc_streamoff is running from another thread and it has
temporarily released isp->mutex to kill the watchdog timers / work.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Remove asd == NULL checks from ioctl handling
Hans de Goede [Sat, 3 Sep 2022 10:41:15 +0000 (12:41 +0200)]
media: atomisp: Remove asd == NULL checks from ioctl handling

At probe time isp_subdev_init_entities() sets pipe->asd to a non NULL
value for all four (preview/vf/capture/capture_video) pipes by calling
atomisp_init_subdev_pipe() for all 4 pipes.

So it can never be NULL. Remove the redundant NULL checks.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Fix locking around asd->streaming read/write
Hans de Goede [Fri, 2 Sep 2022 11:39:51 +0000 (13:39 +0200)]
media: atomisp: Fix locking around asd->streaming read/write

For reading / writing the asd->streaming enum the following rules
should be followed:

1. Writers of streaming must hold both isp->mutex and isp->lock.
2. Readers of streaming need to hold only one of the two locks.

Not all writers where properly taking both locks this fixes this.

In the case of the readers, many readers depend on their caller
to hold isp->mutex, add asserts for this

And in the case of atomisp_css_get_dis_stat() it is called with
isp->mutex held, so there is no need to take the spinlock just
for reading the streaming value.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Remove unused lock member from struct atomisp_sub_device
Hans de Goede [Fri, 2 Sep 2022 11:04:33 +0000 (13:04 +0200)]
media: atomisp: Remove unused lock member from struct atomisp_sub_device

The spin-lock embedded in struct atomisp_sub_device is not used anywhere,
remove it.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Use a normal mutex for the main lock
Hans de Goede [Fri, 2 Sep 2022 10:26:51 +0000 (12:26 +0200)]
media: atomisp: Use a normal mutex for the main lock

There is no reason for atomisp to use a rt_mutex instead of a normal
mutex, so switch over to a normal mutex.

All the changes in this patch are just s/rt_mutex/mutex/.

This is a preparation patch for switching the ioctl locking over
to using the video_dev.lock member so that the v4l2-core takes
care of the locking.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: prevent integer overflow in sh_css_set_black_frame()
Dan Carpenter [Thu, 1 Sep 2022 05:20:09 +0000 (07:20 +0200)]
media: atomisp: prevent integer overflow in sh_css_set_black_frame()

The "height" and "width" values come from the user so the "height * width"
multiplication can overflow.

Link: https://lore.kernel.org/r/YxBBCRnm3mmvaiuR@kili
Fixes: a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Simplify v4l2_fh_open() error handling
Hans de Goede [Mon, 29 Aug 2022 10:37:11 +0000 (12:37 +0200)]
media: atomisp: Simplify v4l2_fh_open() error handling

v4l2_fh_open() can only fail with -ENOMEM and as a generic rule drivers
do not log their own errors for -ENOMEM since the kernel will already
have complained loudly about this before the -ENOMEM return.

Remove the unnecessary error logging from atomisp_open().

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Fix v4l2_fh resource leak on open errors
Hans de Goede [Mon, 29 Aug 2022 10:35:43 +0000 (12:35 +0200)]
media: atomisp: Fix v4l2_fh resource leak on open errors

When atomisp_open() fails then it must call v4l2_fh_release() to undo
the results of v4l2_fh_open().

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Remove loading mutex
Hans de Goede [Mon, 29 Aug 2022 10:30:08 +0000 (12:30 +0200)]
media: atomisp: Remove loading mutex

Now that the registering of the /dev/* video / subdev nodes has been
moved to the end of atomisp_pci_probe() the workaround with the loading
mutex to delay opens until init is done is no longer necessary.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Register /dev/* nodes at the end of atomisp_pci_probe()
Hans de Goede [Sun, 28 Aug 2022 22:12:12 +0000 (00:12 +0200)]
media: atomisp: Register /dev/* nodes at the end of atomisp_pci_probe()

Register /dev/* nodes at the end of atomisp_pci_probe(), this is
a prerequisite for dropping the loading mutex + ready flag kludge
for delaying open() calls on the /dev/* nodes .

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Split subdev and video-node registration into 2 steps
Hans de Goede [Sun, 28 Aug 2022 19:41:50 +0000 (21:41 +0200)]
media: atomisp: Split subdev and video-node registration into 2 steps

Split subdev and video-node registration into 2 steps, this is
a preparation step for moving video-node registration to the
end of probe() so that the loading() mutex can be removed.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Remove empty atomisp_css_set_cont_prev_start_time() function
Hans de Goede [Sun, 28 Aug 2022 19:15:52 +0000 (21:15 +0200)]
media: atomisp: Remove empty atomisp_css_set_cont_prev_start_time() function

atomisp_css_set_cont_prev_start_time() is a no-op, remove it.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Remove some further ATOMISP_ACC_* related dead code
Hans de Goede [Sun, 28 Aug 2022 19:11:51 +0000 (21:11 +0200)]
media: atomisp: Remove some further ATOMISP_ACC_* related dead code

Remove some more code which is no longer referenced after the removal
of the ATOMISP_ACC_* custom ioctls.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Remove the ACC device node
Hans de Goede [Sun, 28 Aug 2022 19:00:20 +0000 (21:00 +0200)]
media: atomisp: Remove the ACC device node

The ACC /dev/video# device node uses a struct video_device embedded in
an atomisp_acc_pipe struct instead of in an atomisp_video_pipe struct.
Yet it uses the same file-ops and ioctl-ops even though it does not have
a videobuf queue, which makes e.g. the mmap fop nonsense.

Worse the only file-ops / ioctls which differentiate between
the 2 types and correctly do container_of on the right type
are the open/release fops and the vidioc_default handler.

The mmap and poll fops and *all* other ioctl handlers unconditionally
do container_of on the passed in struct video_device blindly assuming
they are dealing with the one embedded in the atomisp_video_pipe struct.

This makes it trivial for userspace to cause all sort of undefined behavior
by calling mmap, poll or the other ioctls on the ACC device node!

Presumably the use of the ACC device node was to allow making the special
ioctls to load custom programs while the other /dev/video# nodes were
already open, since the /dev/video# nodes can currently all be opened
only once (which needs to be fixed).

commit 4bbca788b6eb ("media: atomisp: remove private acceleration ioctls")
has removed the custom ATOMISP_ACC_* ioctls, so there no longer is any
reason to keep the ACC device node.

As explained above its presence can easily cause the kernel to crash,
so remove the ACC device node and the code for handling it.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Remove never set file_input flag
Hans de Goede [Sat, 27 Aug 2022 14:49:23 +0000 (16:49 +0200)]
media: atomisp: Remove never set file_input flag

After the file-injection support removal the file_input flag is
always false.

Remove the flag and replace any code checking it with the code-path
for when it is false.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Remove the outq videobuf queue
Hans de Goede [Sat, 27 Aug 2022 14:39:10 +0000 (16:39 +0200)]
media: atomisp: Remove the outq videobuf queue

After the file-injection support removal the outq videobuf queue is
no longer used, remove it.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Remove atomisp_file_fops and atomisp_file_ioctl_ops
Hans de Goede [Sat, 27 Aug 2022 14:28:50 +0000 (16:28 +0200)]
media: atomisp: Remove atomisp_file_fops and atomisp_file_ioctl_ops

After the file-injection support removal, atomisp_video_pipe->type never
is V4L2_BUF_TYPE_VIDEO_OUTPUT anymore, so the V4L2_BUF_TYPE_VIDEO_OUTPUT
support path in atomisp_video_init() is never hit and this path is
the only user of atomisp_file_fops and atomisp_file_ioctl_ops.

Remove atomisp_file_fops and atomisp_file_ioctl_ops and all of
the functions which are only referenced by these ops structs.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Remove file-injection support
Hans de Goede [Sat, 27 Aug 2022 14:17:07 +0000 (16:17 +0200)]
media: atomisp: Remove file-injection support

The file-injection support of the atomisp driver has not been tested
and is not necessary for camera support, remove it.

Note the main reason for removing this is because it depends on
the videobuf (version 1) outq and we want to remove or replace
all videobuf usage in the driver.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Fix device_caps reporting of the registered video-devs
Hans de Goede [Sat, 27 Aug 2022 13:54:27 +0000 (15:54 +0200)]
media: atomisp: Fix device_caps reporting of the registered video-devs

atomisp_subdev_register_entities() had V4L2_CAP_VIDEO_CAPTURE /
V4L2_CAP_VIDEO_OUT swapped. Or-ing in V4L2_CAP_VIDEO_OUT for
the nodes which allow capturing from the camera and or-ing in
V4L2_CAP_VIDEO_CAPTURE for the file-injection node
(mem2mem use of the ISP).

Things happen to still work for the capture device-nodes because
the "shared" caps also included V4L2_CAP_VIDEO_CAPTURE, so those
shared nodes advertised V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUT.

Fix things so that only the correct caps are advertised.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
21 months agomedia: atomisp: Ensure that USERPTR pointers are page aligned
Hans de Goede [Sun, 21 Aug 2022 18:29:06 +0000 (20:29 +0200)]
media: atomisp: Ensure that USERPTR pointers are page aligned

The atomisp code needs USERPTR pointers to be page aligned,
otherwise bad things (scribbling over other parts of the
process' RAM) happen.

Add a check to ensure this and exit VIDIOC_QBUF calls with
unaligned pointers with -EINVAL.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>