OSDN Git Service

tomoyo/tomoyo-test1.git
2 years agomedia: platform: return early if the iface is not handled
Tom Rix [Sat, 19 Mar 2022 14:34:56 +0000 (15:34 +0100)]
media: platform: return early if the iface is not handled

Clang static analysis reports this issue
ispcsiphy.c:63:14: warning: The left operand of '<<'
  is a garbage value
        reg |= mode << shift;
               ~~~~ ^
The iface switch-statement default case falls through
to ISP_INTERFACE_CCP2B_PHY1.  Which is later checked
to set the mode.  Since the default case is left out
of this check mode is never set.  Instead of falling
through and assuming a ISP_INTERFACE_CCP2B_PHY1
iface, return.

Signed-off-by: Tom Rix <trix@redhat.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: exynos4-is: Change clk_disable to clk_disable_unprepare
Miaoqian Lin [Fri, 18 Mar 2022 11:01:01 +0000 (12:01 +0100)]
media: exynos4-is: Change clk_disable to clk_disable_unprepare

The corresponding API for clk_prepare_enable is clk_disable_unprepare,
other than clk_disable.

Fix this by changing clk_disable to clk_disable_unprepare.

Fixes: b4155d7d5b2c ("[media] exynos4-is: Ensure fimc-is clocks are not enabled until properly configured")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: platform: renesas-ceu: Fix unused variable warning
Laurent Pinchart [Thu, 17 Mar 2022 20:49:03 +0000 (21:49 +0100)]
media: platform: renesas-ceu: Fix unused variable warning

The ceu_data_rz variable is unused when CONFIG_OF isn't set. This
generates a compiler warning. Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: davinci: remove unnecessary NULL check
Dan Carpenter [Thu, 17 Mar 2022 07:51:48 +0000 (08:51 +0100)]
media: davinci: remove unnecessary NULL check

We verified that "vpif_obj.sd[i]" is non-NULL on the previous line so
no need to check here.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: bdisp: remove unnecessary IS_ERR() check
Dan Carpenter [Thu, 17 Mar 2022 07:51:16 +0000 (08:51 +0100)]
media: bdisp: remove unnecessary IS_ERR() check

The "bdisp->clock" variable cannot be an error pointer here.  No need to
check.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: platform: Remove unused including <linux/version.h>
Jiapeng Chong [Thu, 17 Mar 2022 01:37:38 +0000 (02:37 +0100)]
media: platform: Remove unused including <linux/version.h>

Eliminate the follow versioncheck warning:

./drivers/media/platform/stm/sti/c8sectpfe/c8sectpfe-common.h: 16
linux/version.h not needed.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: i2c: rdacm20: Fix format definition
Jacopo Mondi [Wed, 16 Mar 2022 21:09:16 +0000 (22:09 +0100)]
media: i2c: rdacm20: Fix format definition

The RDACM20 camera supports a single image format which is currently
listed as MEDIA_BUS_FMT_UYVY8_2X8. As the video stream is transmitted on
the GMSL serial bus, the 2X8 variant does not apply.

Fix the format by using MEDIA_BUS_FMT_UYVY8_1X16.

This fixes a runtime error which is now triggered as the MAX9286
deserializer implements .link_validate().

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rcar-vin: Add check that input interface and format are valid
Niklas Söderlund [Wed, 16 Mar 2022 14:48:39 +0000 (15:48 +0100)]
media: rcar-vin: Add check that input interface and format are valid

Add a check to make sure the input interface (CSI-2 or parallel) allow
for the requested input bus format. If not inform the user and error out
rather then try to continue with incorrect settings.

While at it add the missing define for RGB666 that is not yet supported
in the driver but we can preemptively check for it in this context
already.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: MAINTAINERS: adjust entries to nxp driver movement in media platform
Lukas Bulwahn [Wed, 16 Mar 2022 07:25:17 +0000 (08:25 +0100)]
media: MAINTAINERS: adjust entries to nxp driver movement in media platform

Commit 46fb99951fe2 ("media: platform: place NXP drivers on a separate dir")
moves various files in media/platform into a nxp subdirectory. It adjusts
the section MEDIA DRIVER FOR FREESCALE IMX PXP in MAINTAINERS, but misses
some references in NXP i.MX 8QXP/8QM JPEG V4L2 DRIVER and MEDIA DRIVERS
FOR FREESCALE IMX7.

Hence, ./scripts/get_maintainer.pl --self-test=patterns complains about a
broken reference.

Adjust the file references in the NXP i.MX 8QXP/8QM JPEG V4L2 DRIVER and
MEDIA DRIVERS FOR FREESCALE IMX7 sections.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: v4l2: mem2mem: Fix typos in v4l2_m2m_dev documentation
Laurent Pinchart [Tue, 15 Mar 2022 10:22:45 +0000 (11:22 +0100)]
media: v4l2: mem2mem: Fix typos in v4l2_m2m_dev documentation

The v4l2_m2m_dev structure documentation incorrectly references the
v4l2_m2m_unregister_media_controller() function when it actually means
v4l2_m2m_register_media_controller(). Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: cec: seco: remove byte handling from smb_word_op
Tom Rix [Sat, 12 Mar 2022 15:48:45 +0000 (16:48 +0100)]
media: cec: seco: remove byte handling from smb_word_op

smb_word_op() has a parameter data_format that
determines if the data is either a byte or
word.  From inspection, smb_word_op() is only
used by the macros smb_wr16() and smb_rd16()
both pass in CMD_WORD_DATA. There is no use of
smb_word_op() that passes in CMD_BYTE_DATA.
So remove the byte handling.

Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: i2c: rdacm2x: properly set subdev entity function
Laurentiu Palcu [Wed, 9 Mar 2022 11:55:06 +0000 (12:55 +0100)]
media: i2c: rdacm2x: properly set subdev entity function

The subdevice entity function was left unset, which produces a warning
when probing the device:

mxc-md bus@58000000:camera: Entity type for entity rdacm20 19-0051 was
not initialized!

This patch will set entity function to MEDIA_ENT_F_CAM_SENSOR and leave
flags unset.

Fixes: 34009bffc1c6 ("media: i2c: Add RDACM20 driver")
Fixes: a59f853b3b4b ("media: i2c: Add driver for RDACM21 camera module")
Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx-jpeg: Fix potential array out of bounds in queue_setup
Mirela Rabulea [Tue, 8 Mar 2022 13:16:57 +0000 (14:16 +0100)]
media: imx-jpeg: Fix potential array out of bounds in queue_setup

Fix smatch warning in mxc_jpeg_queue_setup, check *nplanes against
current format:

drivers/media/platform/imx-jpeg/mxc-jpeg.c:1070
mxc_jpeg_queue_setup()
         warn: potential user controlled iterator 'i' (array size 2 vs 7)

Signed-off-by: Mirela Rabulea <mirela.rabulea@oss.nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: MAINTAINERS: drop unreachable contact for MEDIATEK JPEG DRIVER
Lukas Bulwahn [Tue, 8 Mar 2022 11:43:00 +0000 (12:43 +0100)]
media: MAINTAINERS: drop unreachable contact for MEDIATEK JPEG DRIVER

After sending a patch to Rick Chang, the mediatek mail server responded:

  ** Message not delivered **

  Your message couldn't be delivered to rick.chang@mediatek.com because
  the remote server is misconfigured. See technical details below for more
  information.

  The response from the remote server was:
  550 Relaying mail to rick.chang@mediatek.com is not allowed

So, drop Rick Chang from the MEDIATEK JPEG DRIVER section.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Reviewed-by: Miles Chen <miles.chen@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: MAINTAINERS: rectify entry for MEDIATEK MEDIA DRIVER
Lukas Bulwahn [Tue, 8 Mar 2022 11:26:30 +0000 (12:26 +0100)]
media: MAINTAINERS: rectify entry for MEDIATEK MEDIA DRIVER

Commit 9cdd70ceb6fa ("media: dt-bindings: media: mtk-vcodec: Separate video
encoder and decoder dt-bindings") converts and splits mediatek-vcodec.txt
to mediatek,vcodec-{de,en}coder.yaml, but missed to adjust its reference
in MAINTAINERS.

Hence, ./scripts/get_maintainer.pl --self-test=patterns complains about a
broken reference.

Repair this file reference in MEDIATEK MEDIA DRIVER.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: MAINTAINERS: refurbish MEDIATEK JPEG DRIVER section
Lukas Bulwahn [Tue, 8 Mar 2022 11:26:29 +0000 (12:26 +0100)]
media: MAINTAINERS: refurbish MEDIATEK JPEG DRIVER section

Commit a16ce2f33732 ("media: dt-bindings: mediatek: convert mtk jpeg
decoder/encoder to yaml") converts mediatek-jpeg-decoder.txt to yaml, but
missed to adjust its reference in MAINTAINERS.

Hence, ./scripts/get_maintainer.pl --self-test=patterns complains about a
broken reference.

While touching this section, generalize the file entry to also cover the
encoder yaml devicetree, as the driver directory also includes the encoder.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: gspca: make the read-only array table static const
Colin Ian King [Mon, 7 Mar 2022 22:42:47 +0000 (23:42 +0100)]
media: gspca: make the read-only array table static const

Don't populate the read-only array table on the stack but
instead make it static const. Also makes the object code a little
smaller.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: MAINTAINERS: rectify entry for MEDIA DRIVERS FOR NVIDIA TEGRA - VDE
Lukas Bulwahn [Mon, 7 Mar 2022 14:59:35 +0000 (15:59 +0100)]
media: MAINTAINERS: rectify entry for MEDIA DRIVERS FOR NVIDIA TEGRA - VDE

Commit ccc3016261ed ("media: dt: bindings: tegra-vde: Convert to schema")
converts nvidia,tegra-vde.txt to nvidia,tegra-vde.yaml, but missed to
adjust its reference in MAINTAINERS.

Hence, ./scripts/get_maintainer.pl --self-test=patterns complains about a
broken reference.

Repair this file reference in  MEDIA DRIVERS FOR NVIDIA TEGRA - VDE.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Acked-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atmel: atmel-isc: Fix PM disable depth imbalance in atmel_isc_probe
Miaoqian Lin [Mon, 7 Mar 2022 08:16:37 +0000 (09:16 +0100)]
media: atmel: atmel-isc: Fix PM disable depth imbalance in atmel_isc_probe

The pm_runtime_enable will decrease power disable depth.
If the probe fails, we should use pm_runtime_disable() to balance
pm_runtime_enable().

Fixes: 0a0e265515db ("media: atmel: atmel-isc: split driver into driver base and isc")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: st-delta: Fix PM disable depth imbalance in delta_probe
Miaoqian Lin [Mon, 7 Mar 2022 08:08:59 +0000 (09:08 +0100)]
media: st-delta: Fix PM disable depth imbalance in delta_probe

The pm_runtime_enable will decrease power disable depth.
If the probe fails, we should use pm_runtime_disable() to balance
pm_runtime_enable().

Fixes: f386509e4959 ("[media] st-delta: STiH4xx multi-format video decoder v4l2 driver")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Acked-by: Hugues Fruchet <hugues.fruchet@foss.st.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: exynos4-is: Fix PM disable depth imbalance in fimc_is_probe
Miaoqian Lin [Mon, 7 Mar 2022 07:52:06 +0000 (08:52 +0100)]
media: exynos4-is: Fix PM disable depth imbalance in fimc_is_probe

If probe fails then we need to call pm_runtime_disable() to balance
out the previous pm_runtime_enable() call.

Fixes: 9a761e436843 ("[media] exynos4-is: Add Exynos4x12 FIMC-IS driver")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: aspeed: Fix an error handling path in aspeed_video_probe()
Christophe JAILLET [Sun, 6 Mar 2022 18:08:07 +0000 (19:08 +0100)]
media: aspeed: Fix an error handling path in aspeed_video_probe()

A dma_free_coherent() call is missing in the error handling path of the
probe, as already done in the remove function.

In fact, this call is included in aspeed_video_free_buf(). So use the
latter both in the error handling path of the probe and in the remove
function.
It is easier to see the relation with aspeed_video_alloc_buf() this way.

Fixes: d2b4387f3bdf ("media: platform: Add Aspeed Video Engine driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: dt-bindings: mtk-vcodec-encoder: Add power-domains property
Nícolas F. R. A. Prado [Fri, 25 Feb 2022 22:58:54 +0000 (23:58 +0100)]
media: dt-bindings: mtk-vcodec-encoder: Add power-domains property

The encoder node may be dependent on a power-domain. Add a property for
it.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: uvcvideo: Add UVC_GUID_FORMAT_H265
James_Lin [Mon, 18 Apr 2022 09:06:52 +0000 (11:06 +0200)]
media: uvcvideo: Add UVC_GUID_FORMAT_H265

This patch aims to add UVC_GUID_FORMAT_H265
High Efficiency Video Coding (HEVC), also known as H.265 and MPEG-H Part 2.
They describe the same video encoding method.
So for handling their behavior is the same.
However, when external camera device describes this encoding method,
some use hevc, some use h265.
There is no uniform specification to describe this encoding method.
So if an external camera device use h265 to describe this encoding method,
driver will not recognize it.
Therefore, this patch is to enable driver to read HEVC/H265
and convert it to V4L2_PIX_FMT_HEVC.

Signed-off-by: James_Lin <Ping-lei.Lin@mediatek.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: uvcvideo: Undup use uvc_endpoint_max_bpi() code
Ricardo Ribalda [Fri, 1 Apr 2022 17:24:37 +0000 (19:24 +0200)]
media: uvcvideo: Undup use uvc_endpoint_max_bpi() code

Replace manual decoding of psize in uvc_parse_streaming(), with the code
from uvc_endpoint_max_bpi(). It also handles usb3 devices.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: uvcvideo: Simplify uvc_endpoint_max_bpi()
Ricardo Ribalda [Fri, 1 Apr 2022 17:24:36 +0000 (19:24 +0200)]
media: uvcvideo: Simplify uvc_endpoint_max_bpi()

The case USB_SPEED_WIRELESS and the default one were doing the same.

Also, make always use of usb_endpoint_maxp_mult, as it should have a
sane value, even for LOW speed and WIRELESS.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: uvcvideo: Fix memory leak if uvc_ctrl_add_mapping fails
Ricardo Ribalda [Fri, 1 Apr 2022 16:44:58 +0000 (18:44 +0200)]
media: uvcvideo: Fix memory leak if uvc_ctrl_add_mapping fails

Move all the life cycle of the name to add_mapping. This simplifies
the error handling inside uvc_ioctl_ctrl_map and solves a memory leak
when kemmdup fails.

Also make sure that for custom controls, the user provides a valid name.

Fixes: 07adedb5c606 ("media: uvcvideo: Use control names from framework")
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: uvcvideo: Fix bit overflow in uvc_probe_video
Hangyu Hua [Thu, 24 Mar 2022 09:13:08 +0000 (10:13 +0100)]
media: uvcvideo: Fix bit overflow in uvc_probe_video

probe->dwMaxPayloadTransferSize is a 32bit value, but bandwidth is 16bit. This
may lead to a bit overflow.

Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: uvcvideo: Fix missing check to determine if element is found in list
Xiaomeng Tong [Sat, 19 Mar 2022 10:22:22 +0000 (11:22 +0100)]
media: uvcvideo: Fix missing check to determine if element is found in list

The list iterator will point to a bogus position containing HEAD if
the list is empty or the element is not found in list. This case
should be checked before any use of the iterator, otherwise it will
lead to a invalid memory access. The missing check here is before
"pin = iterm->id;", just add check here to fix the security bug.

In addition, the list iterator value will *always* be set and non-NULL
by list_for_each_entry(), so it is incorrect to assume that the iterator
value will be NULL if the element is not found in list, considering
the (mis)use here: "if (iterm == NULL".

Use a new value 'it' as the list iterator, while use the old value
'iterm' as a dedicated pointer to point to the found element, which
1. can fix this bug, due to 'iterm' is NULL only if it's not found.
2. do not need to change all the uses of 'iterm' after the loop.
3. can also limit the scope of the list iterator 'it' *only inside*
   the traversal loop by simply declaring 'it' inside the loop in the
   future, as usage of the iterator outside of the list_for_each_entry
   is considered harmful. https://lkml.org/lkml/2022/2/17/1032

Fixes: d5e90b7a6cd1c ("[media] uvcvideo: Move to video_ioctl2")
Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: docs: media: uvcvideo: Use linux-media mailing list
Jonathan Neuschäfer [Tue, 15 Mar 2022 22:10:06 +0000 (23:10 +0100)]
media: docs: media: uvcvideo: Use linux-media mailing list

As discussed with other developers, the linux-uvc-devel mailing list is
not very useful anymore, and it's better to send people to the general
linux-media mailing list.

Replace/remove the old mailing list address in uvcvideo.rst and
MAINTAINERS.

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: gpio-ir-tx: simplify wait logic
Sean Young [Thu, 7 Apr 2022 08:43:38 +0000 (10:43 +0200)]
media: gpio-ir-tx: simplify wait logic

Do not handroll mdelay().

Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ext-ctrls-codec.rst: fix indentation
Hans Verkuil [Mon, 25 Apr 2022 06:36:14 +0000 (07:36 +0100)]
media: ext-ctrls-codec.rst: fix indentation

The indentation was wrong, causing the documentation build to
fail with:

Sphinx parallel build error:
docutils.utils.SystemMessagePropagation: <system_message level="3" line="1202" source="/home/hans/work/src/v4l/media-git/Documentation/media/userspace-api/v4l/ext-ctrls-codec.rst"
type="ERROR"><paragraph>Error parsing content block for the "flat-table" directive: two-level bullet list expected, but row 1 does not contain a second-level bullet list.</paragraph><literal_block
xml:space="preserve">.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    * - ``V4L2_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE_RANDOM``
      - The whole frame is completely refreshed randomly
      after the specified period.
    * - ``V4L2_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE_CYCLIC``
      - The whole frame MBs are completely refreshed in cyclic order
      after the specified period.

</literal_block></system_message>
make[1]: *** [Documentation/Makefile:96: htmldocs] Error 2
make: *** [Makefile:1678: htmldocs] Error 2

Link: https://lore.kernel.org/linux-media/62b53cbb-f3e2-ed8a-bba2-3f4145d9b8db@xs4all.nl
Fixes: fcbc4acf8b8d ("media: v4l2-ctrls: Add intra-refresh type control")
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: platform: imx-mipi-csis: Remove unneeded 'default n'
Fabio Estevam [Fri, 22 Apr 2022 14:31:29 +0000 (15:31 +0100)]
media: platform: imx-mipi-csis: Remove unneeded 'default n'

There is no need to pass 'default n' in Kconfig, as by default the
CONFIG_VIDEO_IMX_MIPI_CSIS option is not selected.

Signed-off-by: Fabio Estevam <festevam@denx.de>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx: imx-mipi-csis: Fix active format initialization on source pad
Laurent Pinchart [Mon, 21 Mar 2022 15:11:35 +0000 (15:11 +0000)]
media: imx: imx-mipi-csis: Fix active format initialization on source pad

Commit 5c0701a0e791 ("media: imx: csis: Store pads format separately")
broke initialization of the active format on the source pad, as it
forgot to update the .init_cfg() handler. Fix it.

Fixes: 5c0701a0e791 ("media: imx: csis: Store pads format separately")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx: imx-mipi-csis: Protect mipi_csis_dump_regs()
Jacopo Mondi [Mon, 14 Mar 2022 10:39:41 +0000 (10:39 +0000)]
media: imx: imx-mipi-csis: Protect mipi_csis_dump_regs()

The mipi_csis_dump_regs() function accesses the interface registers
in order to printout their values for debug purposes.

As the function access the registers, it requires the interface to be
powered up. Currently this is only enforced in one of the function's
callers (mipi_csis_log_status)() but not when the function is called by
the debugfs attribute handler.

Make sure to access registers only if the interface is powered up and
remove the same check from the caller.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx: imx-mipi-csis: Drop powered flag
Jacopo Mondi [Mon, 14 Mar 2022 10:39:38 +0000 (10:39 +0000)]
media: imx: imx-mipi-csis: Drop powered flag

The mipi_csis_device.powered flag only serves for the purpose of
not accessing registers in mipi_csis_log_status() when the interface
is not powered up.

Instead of manually tracking the power state, rely on
pm_runtime_get_if_in_use() to remove the 'powered' flag. Also remove
the locking in the function as runtime_pm() is refcounted and there's no
risk of the interface being powered down behind our backs.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx: imx-mipi-csis: Simplify mipi_csis_s_stream()
Jacopo Mondi [Mon, 14 Mar 2022 10:39:37 +0000 (10:39 +0000)]
media: imx: imx-mipi-csis: Simplify mipi_csis_s_stream()

Simplify the mipi_csis_s_stream() function.

This actually fixes a bug, as if calling the subdev's s_stream(1) fails,
mipi_csis_stop_stream() was not called.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx: imx-mipi-csis: Simplify runtime PM implementation
Laurent Pinchart [Fri, 11 Mar 2022 13:29:03 +0000 (13:29 +0000)]
media: imx: imx-mipi-csis: Simplify runtime PM implementation

The runtime PM resume handler is guaranteed to be called on a suspended
device, and the suspend handler on a resumed device. The implementation
can thus be simplified.

While at it, rename the mipi_csis_device state field to powered, as the
now state contains a single flag only.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx: imx-mipi-csis: Don't stop streaming at runtime suspend time
Laurent Pinchart [Fri, 11 Mar 2022 13:29:03 +0000 (13:29 +0000)]
media: imx: imx-mipi-csis: Don't stop streaming at runtime suspend time

Streaming is guaranteed to have been stopped by the time the device gets
runtime suspended, as pm_runtime_put() is called from .s_stream(0) only.
Drop the manual stop.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx: imx-mipi-csis: Drop unneeded system PM implementation
Laurent Pinchart [Fri, 11 Mar 2022 13:29:03 +0000 (13:29 +0000)]
media: imx: imx-mipi-csis: Drop unneeded system PM implementation

There's no need to implement system suspend/resume manually, as video
pipelines are supposed to be suspended in a controlled and ordered
manner by the data sink driver at system suspend time (and similarly at
resume time). Drop the system suspend/resume handlers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx: imx-mipi-csis: Don't use .s_power()
Laurent Pinchart [Fri, 11 Mar 2022 13:29:03 +0000 (13:29 +0000)]
media: imx: imx-mipi-csis: Don't use .s_power()

The subdev .s_power() operation is deprecated. Drop it, requiring sensor
drivers to correctly use runtime PM instead of relying on .s_power().

As this driver has just been moved out of staging, and necessary drivers
to implement a full camera pipeline are still in staging, no platform
depends yet on this API being called. There is thus no risk of
regression.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx: imx-mipi-csis: Rename csi_state to mipi_csis_device
Laurent Pinchart [Tue, 22 Feb 2022 09:50:25 +0000 (09:50 +0000)]
media: imx: imx-mipi-csis: Rename csi_state to mipi_csis_device

Usage of "state" for the device-specific data structure is confusing, as
it can also refer to the subdev state. Rename the structure to
mipi_csis_device, and the corresponding state variables to csis.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: hantro: Empty encoder capture buffers by default
Chen-Yu Tsai [Thu, 31 Mar 2022 08:49:06 +0000 (09:49 +0100)]
media: hantro: Empty encoder capture buffers by default

The payload size for encoder capture buffers is set by the driver upon
finishing encoding each frame, based on the encoded length returned from
hardware, and whatever header and padding length used. Setting a
non-zero default serves no real purpose, and also causes issues if the
capture buffer is returned to userspace unused, confusing the
application.

Instead, always set the payload size to 0 for encoder capture buffers
when preparing them.

Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver")
Fixes: 082aaecff35f ("media: hantro: Fix .buf_prepare")
Signed-off-by: Chen-Yu Tsai <wenst@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>
2 years agomedia: hantro: Implement support for encoder commands
Chen-Yu Tsai [Thu, 31 Mar 2022 09:16:28 +0000 (10:16 +0100)]
media: hantro: Implement support for encoder commands

The V4L2 stateful encoder uAPI specification requires that drivers
support the ENCODER_CMD ioctl to allow draining of buffers. This
however was not implemented, and causes issues for some userspace
applications.

Implement support for the ENCODER_CMD ioctl using v4l2-mem2mem helpers.
This is entirely based on existing code found in the vicodec test
driver.

Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver")
Signed-off-by: Chen-Yu Tsai <wenst@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>
2 years agomedia: dt-bindings: media: rockchip-vpu: Add RK3568 compatible
Piotr Oniszczuk [Mon, 14 Feb 2022 21:29:55 +0000 (21:29 +0000)]
media: dt-bindings: media: rockchip-vpu: Add RK3568 compatible

RK356x has Hantro G1 video decoder capable to decode MPEG2/H.264/VP8
video formats.

This patch adds RK3568 compatible in rockchip-vpu dt-bindings.

Tested on [1] with FFmpeg v4l2_request code taken from [2]
with MPEG2, H.642 and VP8 samples with results [3].

[1] https://github.com/warpme/minimyth2
[2] https://github.com/LibreELEC/LibreELEC.tv/blob/master/packages/multimedia/ffmpeg/patches/v4l2-request/ffmpeg-001-v4l2-request.patch
[3] https://github.com/warpme/minimyth2/blob/master/video-test-summary.txt

Signed-off-by: Piotr Oniszczuk <piotr.oniszczuk@gmail.com>
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>
2 years agomedia: hantro: Add support for Hantro G1 on RK356x
Piotr Oniszczuk [Mon, 14 Feb 2022 21:29:53 +0000 (21:29 +0000)]
media: hantro: Add support for Hantro G1 on RK356x

RK356x has Hantro G1 video decoder capable to decode MPEG2/H.264/VP8
video formats.

This patch adds support for RK356x family in existing Hantro
video decoder kernel driver.

Tested on [1] with FFmpeg v4l2_request code taken from [2]
with MPEG2, H.642 and VP8 samples with results [3].

[1] https://github.com/warpme/minimyth2
[2] https://github.com/LibreELEC/LibreELEC.tv/blob/master/packages/multimedia/ffmpeg/patches/v4l2-request/ffmpeg-001-v4l2-request.patch
[3] https://github.com/warpme/minimyth2/blob/master/video-test-summary.txt

Signed-off-by: Piotr Oniszczuk <piotr.oniszczuk@gmail.com>
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>
2 years agomedia: amphion: fix decoder's interlaced field
Ming Qian [Thu, 14 Apr 2022 08:57:22 +0000 (09:57 +0100)]
media: amphion: fix decoder's interlaced field

For interlaced frame, the amphion vpu will store the
two fields sequential into one buffer, top-bottom order
so the field should be set to V4L2_FIELD_SEQ_TB.
fix the previous bug that set it to V4L2_FIELD_SEQ_BT wrongly.

Fixes: 6de8d628df6e ("media: amphion: add v4l2 m2m vpu decoder stateful driver")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: saa7134: simplify if-if to if-else
Wan Jiabing [Mon, 11 Apr 2022 10:56:49 +0000 (11:56 +0100)]
media: saa7134: simplify if-if to if-else

use if and else instead of if(A) and if (!A).

Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx-jpeg: don't change byteused of queued buffer
Ming Qian [Mon, 11 Apr 2022 08:19:53 +0000 (09:19 +0100)]
media: imx-jpeg: don't change byteused of queued buffer

Don't change the output buffer's bytesused set by user.
Drop allow_zero_bytesused, since it's deprecated.
This should also guarantee it's the application's responsibility
to set bytesused for the output buffer.

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>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: cx25821: Fix the warning when removing the module
Zheyu Ma [Sun, 10 Apr 2022 07:44:09 +0000 (08:44 +0100)]
media: cx25821: Fix the warning when removing the module

When removing the module, we will get the following warning:

[   14.746697] remove_proc_entry: removing non-empty directory 'irq/21', leaking at least 'cx25821[1]'
[   14.747449] WARNING: CPU: 4 PID: 368 at fs/proc/generic.c:717 remove_proc_entry+0x389/0x3f0
[   14.751611] RIP: 0010:remove_proc_entry+0x389/0x3f0
[   14.759589] Call Trace:
[   14.759792]  <TASK>
[   14.759975]  unregister_irq_proc+0x14c/0x170
[   14.760340]  irq_free_descs+0x94/0xe0
[   14.760640]  mp_unmap_irq+0xb6/0x100
[   14.760937]  acpi_unregister_gsi_ioapic+0x27/0x40
[   14.761334]  acpi_pci_irq_disable+0x1d3/0x320
[   14.761688]  pci_disable_device+0x1ad/0x380
[   14.762027]  ? _raw_spin_unlock_irqrestore+0x2d/0x60
[   14.762442]  ? cx25821_shutdown+0x20/0x9f0 [cx25821]
[   14.762848]  cx25821_finidev+0x48/0xc0 [cx25821]
[   14.763242]  pci_device_remove+0x92/0x240

Fix this by freeing the irq before call pci_disable_device().

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: pci: cx23885: Fix the error handling in cx23885_initdev()
Zheyu Ma [Sun, 10 Apr 2022 07:34:41 +0000 (08:34 +0100)]
media: pci: cx23885: Fix the error handling in cx23885_initdev()

When the driver fails to call the dma_set_mask(), the driver will get
the following splat:

[   55.853884] BUG: KASAN: use-after-free in __process_removed_driver+0x3c/0x240
[   55.854486] Read of size 8 at addr ffff88810de60408 by task modprobe/590
[   55.856822] Call Trace:
[   55.860327]  __process_removed_driver+0x3c/0x240
[   55.861347]  bus_for_each_dev+0x102/0x160
[   55.861681]  i2c_del_driver+0x2f/0x50

This is because the driver has initialized the i2c related resources
in cx23885_dev_setup() but not released them in error handling, fix this
bug by modifying the error path that jumps after failing to call the
dma_set_mask().

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: v4l2: fix uninitialized value tuner_status(CWE-457)
Yan Lei [Sun, 10 Apr 2022 01:58:54 +0000 (02:58 +0100)]
media: v4l2: fix uninitialized value tuner_status(CWE-457)

Declaring variable "tuner_status" without initializer.
Using uninitialized value "tuner_status" when calling
"*fe_tuner_ops->get_status".
(The function pointer resolves to "cx24113_get_status".)

Signed-off-by: Yan Lei <yan_lei@dahuatech.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: docs: Fix vimc default pipeline graph
Kwang Son [Thu, 7 Apr 2022 06:26:07 +0000 (07:26 +0100)]
media: docs: Fix vimc default pipeline graph

RGB/YUV Input is sensor type and it should be sub-dev node.
To generate this dot graph

sudo modprobe vimc
media-ctl --print-dot

Signed-off-by: Kwang Son <dev.kwang.son@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: coda: Add more H264 levels for CODA960
Nicolas Dufresne [Wed, 6 Apr 2022 20:23:43 +0000 (21:23 +0100)]
media: coda: Add more H264 levels for CODA960

Add H264 level 1.0, 4.1, 4.2 to the list of supported formats.
While the hardware does not fully support these levels, it does support
most of them. The constraints on frame size and pixel formats already
cover the limitation.

This fixes negotiation of level on GStreamer 1.17.1.

Cc: stable@vger.kernel.org
Fixes: 42a68012e67c2 ("media: coda: add read-only h.264 decoder profile/level controls")
Suggested-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: coda: Fix reported H264 profile
Nicolas Dufresne [Wed, 6 Apr 2022 20:23:42 +0000 (21:23 +0100)]
media: coda: Fix reported H264 profile

The CODA960 manual states that ASO/FMO features of baseline are not
supported, so for this reason this driver should only report
constrained baseline support.

This fixes negotiation issue with constrained baseline content
on GStreamer 1.17.1.

ASO/FMO features are unsupported for the encoder and untested for the
decoder because there is currently no userspace support. Neither GStreamer
parsers nor FFMPEG parsers support ASO/FMO.

Cc: stable@vger.kernel.org
Fixes: 42a68012e67c2 ("media: coda: add read-only h.264 decoder profile/level controls")
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Tested-by: Pascal Speck <kernel@iktek.de>
Signed-off-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx-jpeg: Correct the pixel format of rgb
Ming Qian [Wed, 6 Apr 2022 09:47:33 +0000 (10:47 +0100)]
media: imx-jpeg: Correct the pixel format of rgb

The hardware is capable of encoding/decoding RGB and ARGB formats
in whatever order the color components are,
but the resulting jpegs look good
if we start with raw data in BGR/ABGR order,
so we will further only support V4L2_PIX_FMT_BGR24 and V4L2_PIX_FMT_ABGR32.

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>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx-jpeg: Add pm-sleep support for imx-jpeg
Ming Qian [Wed, 6 Apr 2022 09:47:03 +0000 (10:47 +0100)]
media: imx-jpeg: Add pm-sleep support for imx-jpeg

Wait finishing jpeg job before system sleep,
otherwise the encoding/decoding can't be resumed after suspend.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: coda: jpeg: start streaming without valid header
Philipp Zabel [Wed, 6 Apr 2022 08:53:53 +0000 (09:53 +0100)]
media: coda: jpeg: start streaming without valid header

Stop bailing out on JPEG header parsing errors during streamon.
This allows userspace to provide valid output buffers later and
fixes a v4l2-compliance streaming test failure:

fail: v4l2-test-buffers.cpp(1429): node->streamon(q.g_type())
test MMAP (no poll): FAIL

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: coda: jpeg: improve header parse error message
Philipp Zabel [Wed, 6 Apr 2022 08:53:52 +0000 (09:53 +0100)]
media: coda: jpeg: improve header parse error message

If JPEG header parsing fails, output a single message instead of two
messages that say the same thing.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: coda: jpeg: set buffer error flag when header parsing fails
Philipp Zabel [Wed, 6 Apr 2022 08:53:51 +0000 (09:53 +0100)]
media: coda: jpeg: set buffer error flag when header parsing fails

If decoding fails because  the output buffer does not contain a
valid header, set the error flag on the returned capture buffer.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: coda: add JPEG downscale support
Philipp Zabel [Wed, 6 Apr 2022 08:51:45 +0000 (09:51 +0100)]
media: coda: add JPEG downscale support

The JPEG decoder in the CODA960 VPU can downscale images while decoding,
with a factor of 1/2, 1/4, or 1/8.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: platform: samsung: remove redundant assignment to variable m
Colin Ian King [Tue, 5 Apr 2022 17:59:59 +0000 (18:59 +0100)]
media: platform: samsung: remove redundant assignment to variable m

The variable m is being assigned a value that is never read, it
is being re-assigned in both paths of the following if-statement.
The assignment is redundant and can be removed.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: coda: consolidate job_finish calls on decoder prepare_run failure
Philipp Zabel [Tue, 5 Apr 2022 13:55:17 +0000 (14:55 +0100)]
media: coda: consolidate job_finish calls on decoder prepare_run failure

If the decoder prepare_run callback returns an error, the hardware
is never started and v4l2_m2m_job_finish() is called immediately,
currently in every error path.

Remove the duplicated job_finish calls from the error paths and reuse
the v4l2_m2m_job_finish() at the end of coda_pic_run_work instead.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: coda: assert bitstream mutex is locked in coda_fill_bitstream
Philipp Zabel [Tue, 5 Apr 2022 13:50:35 +0000 (14:50 +0100)]
media: coda: assert bitstream mutex is locked in coda_fill_bitstream

coda_fill_bitstream() must be called under the bitstream mutex.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: coda: disable stateful encoder ioctls for jpeg encoder
Philipp Zabel [Mon, 4 Apr 2022 16:35:30 +0000 (17:35 +0100)]
media: coda: disable stateful encoder ioctls for jpeg encoder

Use v4l2_disable_ioctl() to disable the stateful encoder ioctls
VIDIOC_ENUM_FRAMEINTERVALS, VIDIOC_G_PARM, and VIDIOC_S_PARM for
the jpeg encoder device, to fix this v4l2-compliance test failure:

fail: v4l2-test-formats.cpp(68): node->is_m2m && !(node->codec_mask & STATEFUL_ENCODER)
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: FAIL
fail: v4l2-test-formats.cpp(1363): node->is_m2m && !is_stateful_enc
test VIDIOC_G/S_PARM: FAIL

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: coda: disable encoder ioctls for decoder devices
Philipp Zabel [Mon, 4 Apr 2022 16:35:29 +0000 (17:35 +0100)]
media: coda: disable encoder ioctls for decoder devices

Use v4l2_disable_ioctl() to disable the encoder ioctls
VIDIOC_ENUM_FRAMESIZES, VIDIOC_ENUM_FRAMEINTERVALS, VIDIOC_G_PARM, and
VIDIOC_S_PARM, to fix this v4l2-compliance test failure:

fail: v4l2-test-formats.cpp(1363): node->is_m2m && !is_stateful_enc
test VIDIOC_G/S_PARM: FAIL

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: coda: disable encoder cmd ioctl on decoder and vice versa
Philipp Zabel [Mon, 4 Apr 2022 16:35:28 +0000 (17:35 +0100)]
media: coda: disable encoder cmd ioctl on decoder and vice versa

Use v4l2_disable_ioctl() to disable the VIDIOC_TRY_ENCODER_CMD and
VIDIOC_ENCODER_CMD ioctls on decoder video devices and the
VIDIOC_TRY_DECODER_CMD and VIDIOC_DECODER_CMD ioctls on encoder
video devices.

This allows to drop the coda_try_encoder/decoder_cmd() functions
and to use v4l2_m2m_ioctl_try_encoder/decoder_cmd() directly.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: venus: venc: Add support for intra-refresh type
Dikshita Agarwal [Tue, 19 Apr 2022 05:06:43 +0000 (06:06 +0100)]
media: venus: venc: Add support for intra-refresh type

Add support for intra-refresh type v4l2 control.

Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Acked-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: v4l2-ctrls: Add intra-refresh type control
Dikshita Agarwal [Tue, 19 Apr 2022 05:06:42 +0000 (06:06 +0100)]
media: v4l2-ctrls: Add intra-refresh type control

Add a control to set intra-refresh type.

Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Acked-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: venus: vdec: Use output resolution on reconfigure
Stanimir Varbanov [Thu, 3 Mar 2022 15:06:36 +0000 (15:06 +0000)]
media: venus: vdec: Use output resolution on reconfigure

When recalculate output buffer size we have to take into account
the output resolution from the firmware received during event change
notification.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: venus: Add a handling of QC10C compressed format
Stanimir Varbanov [Thu, 3 Mar 2022 15:06:35 +0000 (15:06 +0000)]
media: venus: Add a handling of QC10C compressed format

This adds QC10C compressed pixel format in the Venus driver, and
make it possible to discover from v4l2 clients.

Note: The QC10C format will be enumerable via VIDIOC_ENUM_FMT when
the bitstream is 10-bits and the headers are parsed.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: venus: hfi_platform: Correct supported compressed format
Stanimir Varbanov [Thu, 3 Mar 2022 15:06:34 +0000 (15:06 +0000)]
media: venus: hfi_platform: Correct supported compressed format

In multistream mode HFI supports TP10_UBWC on output2. Correct this
in supported formats capabilities list.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: venus: Add a handling of QC08C compressed format
Stanimir Varbanov [Thu, 3 Mar 2022 15:06:33 +0000 (15:06 +0000)]
media: venus: Add a handling of QC08C compressed format

This adds QC08C compressed pixel format in the Venus driver, and
make it possible to discover from v4l2 clients.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: venus: helpers: Add helper to check supported pixel formats
Stanimir Varbanov [Thu, 3 Mar 2022 15:06:32 +0000 (15:06 +0000)]
media: venus: helpers: Add helper to check supported pixel formats

Add a helper to check supported pixel format per codec and session
type.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: v4l: Add Qualcomm custom compressed pixel formats
Stanimir Varbanov [Thu, 3 Mar 2022 15:06:31 +0000 (15:06 +0000)]
media: v4l: Add Qualcomm custom compressed pixel formats

Add custom Qualcomm raw compressed pixel formats. They are
used in Qualcomm SoCs to optimize the interconnect bandwidth.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Acked-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: venus: vdec: ensure venus is powered on during stream off
Vikash Garodia [Tue, 12 Apr 2022 13:15:11 +0000 (14:15 +0100)]
media: venus: vdec: ensure venus is powered on during stream off

Video decoder driver auto-suspends the hardware if there is no
exchange of command or response for certain amount of time.
In auto suspended state, it becomes mandatory to power on the
hardware before requesting it to process a command. The fix
ensures the hardware is powered on during stop streaming.

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>
2 years agomedia: venus: do not queue internal buffers from previous sequence
Vikash Garodia [Tue, 12 Apr 2022 13:15:10 +0000 (14:15 +0100)]
media: venus: do not queue internal buffers from previous sequence

During reconfig (DRC) event from firmware, it is not guaranteed that
all the DPB(internal) buffers would be released by the firmware. Some
buffers might be released gradually while processing frames from the
new sequence. These buffers now stay idle in the dpblist.
In subsequent call to queue the DPBs to firmware, these idle buffers
should not be queued. The fix identifies those buffers and free them.

Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Tested-by: Fritz Koenig <frkoenig@chromium.org>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: venus: hfi: avoid null dereference in deinit
Luca Weiss [Fri, 14 Jan 2022 11:02:26 +0000 (11:02 +0000)]
media: venus: hfi: avoid null dereference in deinit

If venus_probe fails at pm_runtime_put_sync the error handling first
calls hfi_destroy and afterwards hfi_core_deinit. As hfi_destroy sets
core->ops to NULL, hfi_core_deinit cannot call the core_deinit function
anymore.

Avoid this null pointer derefence by skipping the call when necessary.

Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: venus: hfi: Add error message for timeout error
Luca Weiss [Fri, 14 Jan 2022 11:02:25 +0000 (11:02 +0000)]
media: venus: hfi: Add error message for timeout error

This error can appear with wrong configuration and is difficult to find
as it just returns -ETIMEDOUT with no further message.

Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: video-mux: Use dev_err_probe()
Philipp Zabel [Tue, 12 Apr 2022 07:29:05 +0000 (08:29 +0100)]
media: video-mux: Use dev_err_probe()

Simplify the mux error path a bit by using dev_err_probe().

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: ipu3: Fix AWB x_start position when rightmost stripe is used
Kate Hsuan [Fri, 8 Apr 2022 10:42:22 +0000 (11:42 +0100)]
media: staging: media: ipu3: Fix AWB x_start position when rightmost stripe is used

An not calibrated x_start setting would result in an incorrect AWB grid
configuration on a sensor when only the rightmost stripe is used.

If the AWB grid coordinate is set to the rightmost stripe, for example,
x_start is greater than 640, the AWB grid will be at the rightmost edge of
the sensor. The AWB statistic will be fetched from the wrong place of the
sensor and results in an incorrect AWB estimation result. Therefore,
stripe offset should subtract from x_start to have a correct grid
configuration for the rightmost stripe.

Signed-off-by: Kate Hsuan <hpa@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: media-entity.h: Fix documentation for media_create_intf_link
Ian Jamison [Fri, 8 Apr 2022 17:53:45 +0000 (18:53 +0100)]
media: media-entity.h: Fix documentation for media_create_intf_link

The documentation comment was inserted between the return type
and the function name. Reunite the lines.

Signed-off-by: Ian Jamison <ian.dev@arkver.com>
Fixes: db7ee32aa185 ("[media] media-device.h: Improve documentation and update it")
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: media.h: remove unneeded <stdint.h> inclusion
Masahiro Yamada [Mon, 28 Mar 2022 16:01:53 +0000 (17:01 +0100)]
media: media.h: remove unneeded <stdint.h> inclusion

Commit b3b7a9f138b7 ("[media] media-device: Use u64 ints for pointers")
added this #include <stdint.h>, presumably in order to use uintptr_t.

Now that it is gone, we can compile this for userspace without <stdint.h>.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: i2c: dw9714: Return zero in remove callback
Uwe Kleine-König [Thu, 31 Mar 2022 13:31:32 +0000 (14:31 +0100)]
media: i2c: dw9714: Return zero in remove callback

The only effect of returning an error code in an i2c remove callback is
that the i2c core emits a generic warning and still removes the device.

So even if disabling the regulator fails it's sensible to further cleanup
and then return zero to only emit a single error message.

This patch is a preparation for making i2c remove callbacks return void.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: i2c: dw9714: Disable the regulator when the driver fails to probe
Zheyu Ma [Thu, 14 Apr 2022 02:34:35 +0000 (03:34 +0100)]
media: i2c: dw9714: Disable the regulator when the driver fails to probe

When the driver fails to probe, we will get the following splat:

[   59.305988] ------------[ cut here ]------------
[   59.306417] WARNING: CPU: 2 PID: 395 at drivers/regulator/core.c:2257 _regulator_put+0x3ec/0x4e0
[   59.310345] RIP: 0010:_regulator_put+0x3ec/0x4e0
[   59.318362] Call Trace:
[   59.318582]  <TASK>
[   59.318765]  regulator_put+0x1f/0x30
[   59.319058]  devres_release_group+0x319/0x3d0
[   59.319420]  i2c_device_probe+0x766/0x940

Fix this by disabling the regulator in error handling.

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: i2c: cleanup comments
Tom Rix [Sun, 13 Mar 2022 16:04:57 +0000 (16:04 +0000)]
media: i2c: cleanup comments

For spdx, remove leading space

Replacements
parametrize to parameterize

Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: i2c: ov5695: fix typos in comments
Julia Lawall [Mon, 14 Mar 2022 11:53:33 +0000 (11:53 +0000)]
media: i2c: ov5695: fix typos in comments

Various spelling mistakes in comments.
Detected with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov7640: Use ARRAY_SIZE instead of manual checking
Moses Christopher Bollavarapu [Thu, 17 Mar 2022 14:47:14 +0000 (14:47 +0000)]
media: ov7640: Use ARRAY_SIZE instead of manual checking

Currently, the driver ends the reg-val list with a 0xFF as a check to stop
the loop. Instead an array of reg-vals can be used to avoid this check,
by using the ARRAY_SIZE(arr) macro to obtain the length of the array and
iterate over it.

Signed-off-by: Moses Christopher Bollavarapu <mosescb.dev@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: Revert "media: dw9768: activate runtime PM and turn off device"
Sakari Ailus [Wed, 13 Apr 2022 12:15:58 +0000 (13:15 +0100)]
media: Revert "media: dw9768: activate runtime PM and turn off device"

This reverts commit c09d776eaa060534a1663e3b89d842db3e1d9076.

Revert the commit as it breaks runtime PM support on OF based systems.
More fixes to the driver are needed.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: Documentation: add documentation about subdev state
Tomi Valkeinen [Tue, 12 Apr 2022 09:42:49 +0000 (10:42 +0100)]
media: Documentation: add documentation about subdev state

Add documentation about centrally managed subdev state.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: subdev: add v4l2_subdev_get_fmt() helper function
Tomi Valkeinen [Tue, 12 Apr 2022 09:42:48 +0000 (10:42 +0100)]
media: subdev: add v4l2_subdev_get_fmt() helper function

Add v4l2_subdev_get_fmt() helper function which implements
v4l2_subdev_pad_ops.get_fmt using active state. Subdev drivers that
support active state and do not need to do anything special in their
get_fmt op can use this helper directly for v4l2_subdev_pad_ops.get_fmt.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: subdev: add locking wrappers to subdev op wrappers
Tomi Valkeinen [Tue, 12 Apr 2022 09:42:47 +0000 (10:42 +0100)]
media: subdev: add locking wrappers to subdev op wrappers

It is common that media drivers call subdev ops in source subdevs, and
pass NULL as the state. This was the way to indicate that the callee
should use the callee's private active state.

E.g.:

v4l2_subdev_call(priv->source_sd, pad, get_fmt, NULL, &sd_fmt);

Now that we have a real subdev active state in the v4l2_subdev struct,
we want the caller to pass a proper state (when available). And
furthermore, the state should be locked.

This would mean changing all the callers, which is the long term goal.

To fix this issue in the short term, let's add an extra wrapper layer to
all v4l2_subdev_call_pad_wrappers which deal with states. These wrappers
handle the state == NULL case by using the locked active state instead
(when available).

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: subdev: add subdev state locking
Tomi Valkeinen [Tue, 12 Apr 2022 09:42:46 +0000 (10:42 +0100)]
media: subdev: add subdev state locking

The V4L2 subdevs have managed without centralized locking for the state
(previously pad_config), as the try-state is supposedly safe (although I
believe two TRY ioctls for the same fd would race), and the
active-state, and its locking, is managed by the drivers internally.

We now have active-state in a centralized position, and need locking.
Strictly speaking the locking is only needed for new drivers that use
the new state, as the current drivers continue behaving as they used to.

However, active-state locking is complicated by the fact that currently
the real active-state of a subdev is split into multiple parts: the new
v4l2_subdev_state, subdev control state, and subdev's internal state.

In the future all these three states should be combined into one state
(the v4l2_subdev_state), and then a single lock for the state should be
sufficient.

But to solve the current split-state situation we need to share locks
between the three states. This is accomplished by using the same lock
management as the control handler does: we use a pointer to a mutex,
allowing the driver to override the default mutex. Thus the driver can
do e.g.:

sd->state_lock = sd->ctrl_handler->lock;

before calling v4l2_subdev_init_finalize(), resulting in sharing the
same lock between the states and the controls.

The locking model for active-state is such that any subdev op that gets
the state as a parameter expects the state to be already locked by the
caller, and expects the caller to release the lock.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: subdev: pass also the active state to subdevs from ioctls
Tomi Valkeinen [Tue, 12 Apr 2022 09:42:45 +0000 (10:42 +0100)]
media: subdev: pass also the active state to subdevs from ioctls

At the moment when a subdev op is called, the TRY subdev state
(subdev_fh->state) is passed as a parameter even for the ACTIVE case, or
alternatively a NULL can be passed for ACTIVE case. This used to make
sense, as the ACTIVE state was handled internally by the subdev drivers.

We now have a state for the ACTIVE case in a standard place, and can
pass that also to the drivers. This patch changes the subdev ioctls to
either pass the TRY or ACTIVE state to the subdev.

Unfortunately many drivers call ops from other subdevs, and implicitly
pass NULL as the state, so this is just a partial solution. A coccinelle
spatch could perhaps be created which fixes the drivers' subdev calls.

For all current upstream drivers this doesn't matter, as they do not
expect to get a valid state for ACTIVE case. But future drivers which
support multiplexed streaming and routing will depend on getting a state
for both active and try cases.

For new drivers we can mandate that the pipelines where the drivers are
used need to pass the state properly, or preferably, not call such
subdev ops at all.

However, if an existing subdev driver is changed to support multiplexed
streams, the driver has to consider cases where its ops will be called
with NULL state. The problem can easily be solved by using the
v4l2_subdev_lock_and_get_active_state() helper, introduced in a follow
up patch.

Another follow up patch adds wrappers for pad ops dealing with subdev
state, which automate the use of
v4l2_subdev_lock_and_get_active_state() for cases where the state is
NULL.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: subdev: rename v4l2_subdev_get_pad_* helpers
Tomi Valkeinen [Tue, 12 Apr 2022 09:42:44 +0000 (10:42 +0100)]
media: subdev: rename v4l2_subdev_get_pad_* helpers

The subdev state is now used for both try and active cases. Rename
rename v4l2_subdev_get_try_* helpers to v4l2_subdev_get_pad_*.

Temporary wapper helper macros are added to keep the drivers using
v4l2_subdev_get_try_* compiling. The next step is to change the uses
in th drivers, and then drop the helpers.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: subdev: add active state to struct v4l2_subdev
Tomi Valkeinen [Tue, 12 Apr 2022 09:42:43 +0000 (10:42 +0100)]
media: subdev: add active state to struct v4l2_subdev

Add a new 'active_state' field to struct v4l2_subdev to which we can
store the active state of a subdev. This will place the subdev
configuration into a known place, allowing us to use the state directly
from the v4l2 framework, thus simplifying the drivers.

Also add functions v4l2_subdev_init_finalize() and
v4l2_subdev_cleanup(), which will allocate and free the active state.
The functions are named in a generic way so that they can be also used
for other subdev initialization work.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: subdev: rename subdev-state alloc & free
Tomi Valkeinen [Tue, 12 Apr 2022 09:42:42 +0000 (10:42 +0100)]
media: subdev: rename subdev-state alloc & free

v4l2_subdev_alloc_state() and v4l2_subdev_free_state() are not supposed
to be used by the drivers. However, we do have a few drivers that use
those at the moment, so we need to expose these functions for the time
being.

Prefix the functions with __ to mark the functions as internal.

At the same time, rename them to v4l2_subdev_state_alloc and
v4l2_subdev_state_free to match the style used for other functions like
video_device_alloc() and media_request_alloc().

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: v4l2-subdev: drop extra #ifdef
Tomi Valkeinen [Tue, 12 Apr 2022 09:42:41 +0000 (10:42 +0100)]
media: v4l2-subdev: drop extra #ifdef

subdev_open() is inside #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API, which
depends on CONFIG_MEDIA_CONTROLLER, so there's no need for an extra

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: v4l2-subdev: fix #endif comments
Tomi Valkeinen [Tue, 12 Apr 2022 09:42:40 +0000 (10:42 +0100)]
media: v4l2-subdev: fix #endif comments

Add comments after #endifs to clarify their scope.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: i2c: ov5645: Fix media bus format
Jacopo Mondi [Mon, 28 Mar 2022 16:32:20 +0000 (17:32 +0100)]
media: i2c: ov5645: Fix media bus format

The ov5645 driver reports as its unique supported format
MEDIA_BUS_FMT_UYVY8_2X8, which is not correct as the sensor
uses the MIPI CSI-2 serial bus.

Fix that by using MEDIA_BUS_FMT_UYVY8_1X16 instead.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>