platform/kernel/linux-starfive.git
2 years agomedia: gpio-ir-tx: fix transmit with long spaces on Orange Pi PC
Sean Young [Sun, 20 Feb 2022 14:28:24 +0000 (15:28 +0100)]
media: gpio-ir-tx: fix transmit with long spaces on Orange Pi PC

Calling udelay for than 1000us does not always yield the correct
results.

Cc: stable@vger.kernel.org
Reported-by: Михаил <vrserver1@gmail.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: lirc: remove unused feature LIRC_CAN_SET_REC_DUTY_CYCLE
Sean Young [Wed, 9 Feb 2022 16:03:12 +0000 (17:03 +0100)]
media: lirc: remove unused feature LIRC_CAN_SET_REC_DUTY_CYCLE

There is no hardware which can filter input on the duty cycle, so no
driver implements this. On top of that, LIRC_CAN_SET_REC_DUTY_CYCLE
has the same value as LIRC_CAN_MEASURE_CARRIER (0x02000000).

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agoMerge tag 'br-v5.18q' of git://linuxtv.org/hverkuil/media_tree into media_stage
Mauro Carvalho Chehab [Mon, 7 Mar 2022 15:26:54 +0000 (16:26 +0100)]
Merge tag 'br-v5.18q' of git://linuxtv.org/hverkuil/media_tree into media_stage

Tag branch

* tag 'br-v5.18q' of git://linuxtv.org/hverkuil/media_tree:
  media: cec: seco: Drop pointless include
  media: hantro: sunxi: Fix VP9 steps
  media: imx: csis: Store pads format separately
  doc: media: Document VP9 reference_mode miss-placement
  doc: media: Document MM21 tiled format
  media: imx: imx8mq-mipi-csi2: Remove YUV422 2X8
  media: v4l2-core: Initialize h264 scaling matrix
  media: imx: imx-mipi-csis: Add output format
  media: imx: imx-mipi-csis: Add BGR888
  media: imx: imx-mipi-csis: Add RGB565_1X16
  media: imx: imx-mipi-csis: Set PIXEL_MODE for YUV422
  media: imx: imx7-media-csi: Use dual sampling for YUV 1X16
  media: imx: Rename imx7-mipi-csis.c to imx-mipi-csis.c
  media: imx: De-stage imx7-mipi-csis

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agoMerge tag 'br-v5.18l' of git://linuxtv.org/hverkuil/media_tree into media_stage
Mauro Carvalho Chehab [Mon, 7 Mar 2022 15:24:56 +0000 (16:24 +0100)]
Merge tag 'br-v5.18l' of git://linuxtv.org/hverkuil/media_tree into media_stage

Tag branch

* tag 'br-v5.18l' of git://linuxtv.org/hverkuil/media_tree: (39 commits)
  media: imx-jpeg: Set V4L2_BUF_FLAG_LAST at eos
  media: meson-ir-tx: remove incorrect doc comment
  media: vivid: use time_is_after_jiffies() instead of open coding it
  media: wl128x: use time_is_before_jiffies() instead of open coding it
  media: tda8083: use time_is_after_jiffies() instead of open coding it
  media: stv0299: use time_is_before_jiffies() instead of open coding it
  media: si21xx: use time_is_before_jiffies() instead of open coding it
  media: cedrus: h264: Fix neighbour info buffer size
  media: cx88-mpeg: clear interrupt status register before streaming video
  media: cedrus: H265: Fix neighbour info buffer size
  media: fsl-viu: use GFP_KERNEL
  media: cx18: use GFP_KERNEL
  drivers: meson: vdec: add VP9 support to GXM
  stkwebcam: add new Asus laptop to upside_down table
  media: imx-jpeg: fix a bug of accessing array out of bounds
  media: sun6i-csi: fix colorspace in sun6i_video_try_fmt()
  media: usb: go7007: s2250-board: fix leak in probe()
  media: cedrus: Add watchdog for job completion
  pixfmt-yuv-planar.rst: fix typo: 'Cr, Cr' -> 'Cr, Cb'
  media: imx-jpeg: Remove unnecessary print function dev_err()
  ...

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: tegra-vde: De-stage driver
Dmitry Osipenko [Sun, 20 Feb 2022 20:46:21 +0000 (21:46 +0100)]
media: staging: tegra-vde: De-stage driver

The TODO of tegra-vde driver has been completed, driver now supports
V4L2 stateless video decoding API. Relocate driver to drivers/media.

Signed-off-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: staging: tegra-vde: Bump BSEV DMA timeout
Dmitry Osipenko [Sun, 20 Feb 2022 20:46:20 +0000 (21:46 +0100)]
media: staging: tegra-vde: Bump BSEV DMA timeout

BSEV DMA timeouts if VDE is downclocked by x10. Bump the timeout to allow
DMA to complete. We don't support freq scaling yet, this is just a minor
improvement which may become useful sometime later.

Signed-off-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: staging: tegra-vde: Remove legacy UAPI support
Dmitry Osipenko [Sun, 20 Feb 2022 20:46:19 +0000 (21:46 +0100)]
media: staging: tegra-vde: Remove legacy UAPI support

The legacy UAPI became unnecessary with the V4L stateless decoder API
support addition to the Tegra decoder driver. Remove legacy UAPI support.

Signed-off-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: staging: tegra-vde: Support V4L stateless video decoder API
Dmitry Osipenko [Sun, 20 Feb 2022 20:46:18 +0000 (21:46 +0100)]
media: staging: tegra-vde: Support V4L stateless video decoder API

Expose Tegra video decoder as a generic V4L M2M stateless video decoder.

Signed-off-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: staging: tegra-vde: Factor out H.264 code
Dmitry Osipenko [Sun, 20 Feb 2022 20:46:17 +0000 (21:46 +0100)]
media: staging: tegra-vde: Factor out H.264 code

Factor out H.264 hardware programming code into separate source file in a
preparation to support V4L API by the Tegra video decoder driver.

Signed-off-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: v4l2-ctrls: Add new V4L2_H264_DECODE_PARAM_FLAG_P/BFRAME flags
Dmitry Osipenko [Sun, 20 Feb 2022 20:46:16 +0000 (21:46 +0100)]
media: v4l2-ctrls: Add new V4L2_H264_DECODE_PARAM_FLAG_P/BFRAME flags

Add new V4L2_H264_DECODE_PARAM_FLAG_P/BFRAME flags that are needed by
NVIDIA Tegra video decoder. Userspace will have to set these flags in
accordance to the type of a decoded frame.

Reviewed-by: Nicolas Dufresne <nicolas@collabora.com>
Signed-off-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: doc: pixfmt-rgb: Fix V4L2_PIX_FMT_BGR24 format description
Laurent Pinchart [Tue, 15 Feb 2022 11:20:32 +0000 (12:20 +0100)]
media: doc: pixfmt-rgb: Fix V4L2_PIX_FMT_BGR24 format description

The V4L2_PIX_FMT_BGR24 format is incorrectly described, with the B and G
components swapped. Fix it.

Fixes: 2ac9280cb459 ("media: doc: pixfmt-rgb: Make 8 bits per component table more compact")
Signed-off-by: Laurent Pinchart <laurent.pinchart+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: imx8mq-mipi_csi2: Remove unneeded code
Muhammad Usama Anjum [Fri, 28 Jan 2022 17:07:22 +0000 (18:07 +0100)]
media: imx: imx8mq-mipi_csi2: Remove unneeded code

ret is constant in imx8mq_mipi_csi_pm_suspend(). This function cannot
return error. Remove the return variable. Simplify other functions which
are using this function.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: dvb_frontends: make static read-only array fec_tab const
Colin Ian King [Sun, 23 Jan 2022 23:02:42 +0000 (00:02 +0100)]
media: dvb_frontends: make static read-only array fec_tab const

The static array fec_tab is read-only so it make sense to make
it const.

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: dib7000p: make static read-only arrays notch and sine const
Colin Ian King [Sun, 23 Jan 2022 22:56:27 +0000 (23:56 +0100)]
media: dib7000p: make static read-only arrays notch and sine const

The static arrays notch and sine are read-only so it make sense
to make them const.

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: dvb_frontend: make static read-only array DIB3000MC_I2C_ADDRESS const
Colin Ian King [Sun, 23 Jan 2022 22:52:56 +0000 (23:52 +0100)]
media: dvb_frontend: make static read-only array DIB3000MC_I2C_ADDRESS const

The static array DIB3000MC_I2C_ADDRESS is read-only so it make sense
to make it const. Also add spaces to clean up checkpatch warnings.

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: dt-bindings: media: renesas,csi2: Update data-lanes property
Lad Prabhakar [Fri, 21 Jan 2022 00:26:22 +0000 (01:26 +0100)]
media: dt-bindings: media: renesas,csi2: Update data-lanes property

CSI-2 (CSI4LNK0) on R-Car and RZ/G2 supports 4-lane mode which is already
handled by rcar-csi2.c driver. This patch updates the data-lanes property
to describe the same.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-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: Remove usage of the deprecated "pci-dma-compat.h" API
Christophe JAILLET [Thu, 6 Jan 2022 21:50:07 +0000 (22:50 +0100)]
media: Remove usage of the deprecated "pci-dma-compat.h" API

In [1], Christoph Hellwig has proposed to remove the wrappers in
include/linux/pci-dma-compat.h.

Some reasons why this API should be removed have been given by Julia
Lawall in [2].

A coccinelle script has been used to perform the needed transformation.
It can be found in [3].

[1]: https://lore.kernel.org/kernel-janitors/20200421081257.GA131897@infradead.org/
[2]: https://lore.kernel.org/kernel-janitors/alpine.DEB.2.22.394.2007120902170.2424@hadrien/
[3]: https://lore.kernel.org/kernel-janitors/20200716192821.321233-1-christophe.jaillet@wanadoo.fr/

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mtk-vcodec: Remove duplicated include in mtk_vcodec_enc_drv.c
Yang Li [Tue, 25 Jan 2022 00:28:39 +0000 (01:28 +0100)]
media: mtk-vcodec: Remove duplicated include in mtk_vcodec_enc_drv.c

Fix following includecheck warning:
./drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c:
linux/pm_runtime.h is included more than once.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: hdpvr: initialize dev->worker at hdpvr_register_videodev
Dongliang Mu [Fri, 18 Feb 2022 09:41:30 +0000 (10:41 +0100)]
media: hdpvr: initialize dev->worker at hdpvr_register_videodev

hdpvr_register_videodev is responsible to initialize a worker in
hdpvr_device. However, the worker is only initialized at
hdpvr_start_streaming other than hdpvr_register_videodev.
When hdpvr_probe does not initialize its worker, the hdpvr_disconnect
will encounter one WARN in flush_work.The stack trace is as follows:

 hdpvr_disconnect+0xb8/0xf2 drivers/media/usb/hdpvr/hdpvr-core.c:425
 usb_unbind_interface+0xbf/0x3a0 drivers/usb/core/driver.c:458
 __device_release_driver drivers/base/dd.c:1206 [inline]
 device_release_driver_internal+0x22a/0x230 drivers/base/dd.c:1237
 bus_remove_device+0x108/0x160 drivers/base/bus.c:529
 device_del+0x1fe/0x510 drivers/base/core.c:3592
 usb_disable_device+0xd1/0x1d0 drivers/usb/core/message.c:1419
 usb_disconnect+0x109/0x330 drivers/usb/core/hub.c:2228

Fix this by moving the initialization of dev->worker to the starting of
hdpvr_register_videodev

Reported-by: syzkaller <syzkaller@googlegroups.com>
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: camss: Point sm8250 at the correct vdda regulators
Bryan O'Donoghue [Tue, 11 Jan 2022 12:52:12 +0000 (13:52 +0100)]
media: camss: Point sm8250 at the correct vdda regulators

Reviewing the RB5 schematic its clear that we have missed out on defining
both of the power-rails associated with the CSI PHY.

Other PHYs such as the UFS, PCIe and USB connect to these rails and define
each regulator individually.

This means if we were to switch off the other various PHYs which enable
these rails, the CAMSS would not appropriately power-on the CSI PHY.

Reviewed-by: Robert Foss <robert.foss@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: camss: Point sdm845 at the correct vdda regulators
Bryan O'Donoghue [Tue, 11 Jan 2022 12:52:11 +0000 (13:52 +0100)]
media: camss: Point sdm845 at the correct vdda regulators

Reviewing the RB3 schematic its clear that we have missed out on defining
one of the power-rails associated with the CSI PHY.

Other PHYs such as the UFS, PCIe and USB connect to these rails and define
each regulator individually.

This means if we were to switch off the other various PHYs which enable
these rails, the CAMSS would not appropriately power-on the CSI PHY.

Reviewed-by: Robert Foss <robert.foss@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: camss: Set unused regulators to the empty set
Bryan O'Donoghue [Tue, 11 Jan 2022 12:52:10 +0000 (13:52 +0100)]
media: camss: Set unused regulators to the empty set

If a CAMSS block has no regulator set the regulator array to the empty set
as opposed to setting the first element of the array to NULL.

Suggested-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: Robert Foss <robert.foss@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: camss: Add regulator_bulk support
Bryan O'Donoghue [Tue, 11 Jan 2022 12:52:09 +0000 (13:52 +0100)]
media: camss: Add regulator_bulk support

Add the ability to enable or disable multiple regulators in bulk with
camss. This is useful for sm8250, sdm845 and it looks like sdm660 where we
have more than one CSI regulator to do at once.

It should just work for standalone existing vdda regulators and parts which
don't have an explicitly defined CSI regulator.

[hverkuil: fix camss-csid.c:163:13: warning: 'ret' may be used uninitialized in this function]

Reported-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Robert Foss <robert.foss@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: dt-bindings: media: camss: Add vdda supply declarations sm8250
Bryan O'Donoghue [Tue, 11 Jan 2022 12:52:06 +0000 (13:52 +0100)]
media: dt-bindings: media: camss: Add vdda supply declarations sm8250

Add in missing vdda-phy-supply and vdda-pll-supply declarations. The
sm8250 USB, PCIe, UFS, DSI and CSI PHYs use a common set of vdda rails.
Define the CSI vdda regulators in the same way the qmp PHY does.

Reviewed-by: Robert Foss <robert.foss@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-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: dt-bindings: media: camss: Fixup vdda regulator descriptions sdm845
Bryan O'Donoghue [Tue, 11 Jan 2022 12:52:05 +0000 (13:52 +0100)]
media: dt-bindings: media: camss: Fixup vdda regulator descriptions sdm845

If we review the schematic for RB3 Thundercomm document Turbox-845 we see
that the CAMSS CSI PHY has the same basic power-rail layout as UFS, PCIe
and USB PHYs.

We should therefore have two regulator declarations as is the case for UFS,
PCIe and USB.

Reviewed-by: Robert Foss <robert.foss@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-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: davinci: vpif: Use platform_get_irq_optional() to get the interrupt
Lad Prabhakar [Thu, 13 Jan 2022 10:44:15 +0000 (11:44 +0100)]
media: davinci: vpif: Use platform_get_irq_optional() to get the interrupt

platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
allocation of IRQ resources in DT core code, this causes an issue
when using hierarchical interrupt domains using "interrupts" property
in the node as this bypasses the hierarchical setup and messes up the
irq chaining.

In preparation for removal of static setup of IRQ resource from DT core
code use platform_get_irq_optional().

While at it, propagate error code in case devm_request_irq() fails
instead of returning -EINVAL.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: vidtv: Check for null return of vzalloc
Jiasheng Jiang [Fri, 14 Jan 2022 06:28:40 +0000 (07:28 +0100)]
media: vidtv: Check for null return of vzalloc

As the possible failure of the vzalloc(), e->encoder_buf might be NULL.
Therefore, it should be better to check it in order
to guarantee the success of the initialization.
If fails, we need to free not only 'e' but also 'e->name'.
Also, if the allocation for ctx fails, we need to free 'e->encoder_buf'
else.

Fixes: f90cf6079bf6 ("media: vidtv: add a bridge driver")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mtk-mdp: Remove redundant 'flush_workqueue()' calls
Xu Wang [Fri, 14 Jan 2022 08:22:14 +0000 (09:22 +0100)]
media: mtk-mdp: Remove redundant 'flush_workqueue()' calls

'destroy_workqueue()' already drains the queue before destroying it, so
there is no need to flush it explicitly.

Remove the redundant 'flush_workqueue()' calls.

Signed-off-by: Xu Wang <vulab@iscas.ac.cn>
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>
2 years agomedia: videobuf2-dma-contig: Invalidate vmap range before DMA range
Sergey Senozhatsky [Wed, 19 Jan 2022 08:14:17 +0000 (09:14 +0100)]
media: videobuf2-dma-contig: Invalidate vmap range before DMA range

Christoph suggests [1] that invalidating vmap range before
direct mapping range makes more sense.

[1]: https://lore.kernel.org/all/20220111085958.GA22795@lst.de/

Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: stk1160: use dma_alloc_noncontiguous API
Dafna Hirschfeld [Tue, 25 Jan 2022 08:02:13 +0000 (09:02 +0100)]
media: stk1160: use dma_alloc_noncontiguous API

Replace the urb buffers allocation to use the noncontiguous API.

This improves performance on ARM platforms where DMA coherent allocations
produce uncached mappings. Note that the noncontiguous API
requires the driver to handle synchronization.

This commit is similar to this one for the uvc driver:

  https://lkml.org/lkml/2021/3/12/1506

Performance tests on rock-pi4 (Arm64) shows about 15x
improvements:

== DMA NONCONTIGUOUS ==
total durations: 20.63678480 sec
urb processing durations: 0.286864889 sec
uS/qty: 286864/2508 avg: 114.379 min: 0.583 max: 155.461 (uS)
FPS: 24.92
lost: 0 done: 500
raw decode speed: 11.603 Gbits/s
bytes 414831228.000
bytes/urb: 165403

== DMA COHERENT ==
total durations: 20.73551767 sec
urb processing durations: 4.541559160 sec
uS/qty: 4541559/2509 avg: 1810.107 min: 0.583 max: 2113.163 (uS)
FPS: 24.90
lost: 0 done: 500
raw decode speed: 730.738 Mbits/s
bytes 414785444.000
bytes/urb: 165319

Performance tests on x86 laptop show no significant
difference:

== DMA NONCONTIGUOUS ==
total durations: 20.220590102 sec
urb processing durations: 0.63021818 sec
uS/qty: 63021/2512 avg: 25.088 min: 0.138 max: 146.750 (uS)
FPS: 24.72
lost: 0 done: 500
raw decode speed: 52.751 Gbits/s
bytes 415421032.000
bytes/urb: 165374

== DMA COHERENT ==
total durations: 20.220475614 sec
urb processing durations: 0.64751972 sec
uS/qty: 64751/2512 avg: 25.777 min: 0.168 max: 132.250 (uS)
FPS: 24.72
lost: 0 done: 500
raw decode speed: 51.927 Gbits/s
bytes 415422794.000
bytes/urb: 165375

[hverkuil: incorporated Ezequiel's suggestions from his review]

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.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: stk1160: move transfer_buffer and urb to same struct 'stk1160_urb'
Dafna Hirschfeld [Tue, 25 Jan 2022 08:02:12 +0000 (09:02 +0100)]
media: stk1160: move transfer_buffer and urb to same struct 'stk1160_urb'

Instead of having two separated arrays, one for the urbs and
one for their buffers, have one array of a struct containing both.
In addition, the array is just 16 pointers, no need to dynamically
allocate it.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.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: stk1160: If start stream fails, return buffers with VB2_BUF_STATE_QUEUED
Dafna Hirschfeld [Tue, 25 Jan 2022 08:02:11 +0000 (09:02 +0100)]
media: stk1160: If start stream fails, return buffers with VB2_BUF_STATE_QUEUED

If the callback 'start_streaming' fails, then all
queued buffers in the driver should be returned with
state 'VB2_BUF_STATE_QUEUED'. Currently, they are
returned with 'VB2_BUF_STATE_ERROR' which is wrong.
Fix this. This also fixes the warning:

[   65.583633] WARNING: CPU: 5 PID: 593 at drivers/media/common/videobuf2/videobuf2-core.c:1612 vb2_start_streaming+0xd4/0x160 [videobuf2_common]
[   65.585027] Modules linked in: snd_usb_audio snd_hwdep snd_usbmidi_lib snd_rawmidi snd_soc_hdmi_codec dw_hdmi_i2s_audio saa7115 stk1160 videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 videobuf2_common videodev mc crct10dif_ce panfrost snd_soc_simple_card snd_soc_audio_graph_card snd_soc_spdif_tx snd_soc_simple_card_utils gpu_sched phy_rockchip_pcie snd_soc_rockchip_i2s rockchipdrm analogix_dp dw_mipi_dsi dw_hdmi cec drm_kms_helper drm rtc_rk808 rockchip_saradc industrialio_triggered_buffer kfifo_buf rockchip_thermal pcie_rockchip_host ip_tables x_tables ipv6
[   65.589383] CPU: 5 PID: 593 Comm: v4l2src0:src Tainted: G        W         5.16.0-rc4-62408-g32447129cb30-dirty #14
[   65.590293] Hardware name: Radxa ROCK Pi 4B (DT)
[   65.590696] pstate: 80000005 (Nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   65.591304] pc : vb2_start_streaming+0xd4/0x160 [videobuf2_common]
[   65.591850] lr : vb2_start_streaming+0x6c/0x160 [videobuf2_common]
[   65.592395] sp : ffff800012bc3ad0
[   65.592685] x29: ffff800012bc3ad0 x28: 0000000000000000 x27: ffff800012bc3cd8
[   65.593312] x26: 0000000000000000 x25: ffff00000d8a7800 x24: 0000000040045612
[   65.593938] x23: ffff800011323000 x22: ffff800012bc3cd8 x21: ffff00000908a8b0
[   65.594562] x20: ffff00000908a8c8 x19: 00000000fffffff4 x18: ffffffffffffffff
[   65.595188] x17: 000000040044ffff x16: 00400034b5503510 x15: ffff800011323f78
[   65.595813] x14: ffff000013163886 x13: ffff000013163885 x12: 00000000000002ce
[   65.596439] x11: 0000000000000028 x10: 0000000000000001 x9 : 0000000000000228
[   65.597064] x8 : 0101010101010101 x7 : 7f7f7f7f7f7f7f7f x6 : fefefeff726c5e78
[   65.597690] x5 : ffff800012bc3990 x4 : 0000000000000000 x3 : ffff000009a34880
[   65.598315] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff000007cd99f0
[   65.598940] Call trace:
[   65.599155]  vb2_start_streaming+0xd4/0x160 [videobuf2_common]
[   65.599672]  vb2_core_streamon+0x17c/0x1a8 [videobuf2_common]
[   65.600179]  vb2_streamon+0x54/0x88 [videobuf2_v4l2]
[   65.600619]  vb2_ioctl_streamon+0x54/0x60 [videobuf2_v4l2]
[   65.601103]  v4l_streamon+0x3c/0x50 [videodev]
[   65.601521]  __video_do_ioctl+0x1a4/0x428 [videodev]
[   65.601977]  video_usercopy+0x320/0x828 [videodev]
[   65.602419]  video_ioctl2+0x3c/0x58 [videodev]
[   65.602830]  v4l2_ioctl+0x60/0x90 [videodev]
[   65.603227]  __arm64_sys_ioctl+0xa8/0xe0
[   65.603576]  invoke_syscall+0x54/0x118
[   65.603911]  el0_svc_common.constprop.3+0x84/0x100
[   65.604332]  do_el0_svc+0x34/0xa0
[   65.604625]  el0_svc+0x1c/0x50
[   65.604897]  el0t_64_sync_handler+0x88/0xb0
[   65.605264]  el0t_64_sync+0x16c/0x170
[   65.605587] ---[ end trace 578e0ba07742170d ]---

Fixes: 8ac456495a33d ("[media] stk1160: Stop device and unqueue buffers when start_streaming() fails")
Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.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: stk1160: fix number of buffers in case not all buffers are created
Dafna Hirschfeld [Tue, 25 Jan 2022 08:02:10 +0000 (09:02 +0100)]
media: stk1160: fix number of buffers in case not all buffers are created

In case we fail to allocate a transfer_buffer then we
break the buffers creation loop and update the number of
buffers to the number of successfully allocated which should
be 'i' and not 'i - 1' nor 'i + 1'

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.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 i.MX8MM Hantro-G1
Adam Ford [Tue, 25 Jan 2022 17:11:27 +0000 (18:11 +0100)]
media: hantro: Add support for i.MX8MM Hantro-G1

The i.MX8MM has a Hantro G1 video decoder similar to the
imx8mq but lacks the post-processor present in the imx8mq.
Add support in the driver for it with the post-processing
removed.

Signed-off-by: Adam Ford <aford173@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: dt-bindings: media: nxp, imx8mq-vpu: Add support for G1 on imx8mm
Adam Ford [Tue, 25 Jan 2022 17:11:26 +0000 (18:11 +0100)]
media: dt-bindings: media: nxp, imx8mq-vpu: Add support for G1 on imx8mm

The i.MX8M mini appears to have a similar G1 decoder but the
post-processing isn't present, so different compatible flag is required.
Since all the other parameters are the same with imx8mq, just add
the new compatible flag to nxp,imx8mq-vpu.yaml.

Signed-off-by: Adam Ford <aford173@gmail.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
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: hantro: Allow i.MX8MQ G1 and G2 to run independently
Adam Ford [Tue, 25 Jan 2022 17:11:23 +0000 (18:11 +0100)]
media: hantro: Allow i.MX8MQ G1 and G2 to run independently

The VPU in the i.MX8MQ is really the combination of Hantro G1 and
Hantro G2. With the updated vpu-blk-ctrl, the power domains system
can enable and disable them separately as well as pull them out of
reset. This simplifies the code and lets them run independently
while still retaining backwards compatibility with older device
trees for those using G1.

Signed-off-by: Adam Ford <aford173@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: dt-bindings: media: nxp, imx8mq-vpu: Split G1 and G2 nodes
Adam Ford [Tue, 25 Jan 2022 17:11:22 +0000 (18:11 +0100)]
media: dt-bindings: media: nxp, imx8mq-vpu: Split G1 and G2 nodes

The G1 and G2 are independent and separate decoder blocks
that are enabled by the vpu-blk-ctrl power-domain controller,
which now has a proper driver.

Because these blocks only share the power-domain, and can be
independently fused out, update the bindings to support separate
nodes for the G1 and G2 decoders with vpu-blk-ctrl power-domain
support.

The new DT + old kernel isn't a supported configuration.

Signed-off-by: Adam Ford <aford173@gmail.com>
Reviewed-by: Rob Herring <robh@kernel.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: cec: seco: add newlines in debug messages
Ettore Chimenti [Tue, 15 Feb 2022 18:13:13 +0000 (19:13 +0100)]
media: cec: seco: add newlines in debug messages

Newlines were missing in almost all regular and debug printk.

Signed-off-by: Ettore Chimenti <ek5.chimenti@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: Revert "media: em28xx: add missing em28xx_close_extension"
Pavel Skripkin [Thu, 20 Jan 2022 19:37:30 +0000 (20:37 +0100)]
media: Revert "media: em28xx: add missing em28xx_close_extension"

This reverts commit 2c98b8a3458df03abdc6945bbef67ef91d181938.

Reverted patch causes problems with Hauppauge WinTV dualHD as Maximilian
reported [1]. Since quick solution didn't come up let's just revert it
to make this device work with upstream kernels.

Link: https://lore.kernel.org/all/6a72a37b-e972-187d-0322-16336e12bdc5@elbmurf.de/
Reported-by: Maximilian Böhm <maximilian.boehm@elbmurf.de>
Tested-by: Maximilian Böhm <maximilian.boehm@elbmurf.de>
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: venus: hfi_cmds: List HDR10 property as unsupported for v1 and v3
Stanimir Varbanov [Tue, 1 Feb 2022 15:51:29 +0000 (16:51 +0100)]
media: venus: hfi_cmds: List HDR10 property as unsupported for v1 and v3

The HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI HFI property is not supported
on Venus v1 and v3.

cc: stable@vger.kernel.org # 5.13+
Fixes: 9172652d72f8 ("media: venus: venc: Add support for CLL and Mastering display controls")
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: venus: venc: Fix h264 8x8 transform control
Stanimir Varbanov [Tue, 8 Feb 2022 01:18:16 +0000 (02:18 +0100)]
media: venus: venc: Fix h264 8x8 transform control

During encoder driver open controls are initialized via a call
to v4l2_ctrl_handler_setup which returns EINVAL error for
V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM v4l2 control. The control
default value is disabled and because of firmware limitations
8x8 transform cannot be disabled for the supported HIGH and
CONSTRAINED_HIGH profiles.

To fix the issue change the control default value to enabled
(this is fine because the firmware enables 8x8 transform for
high and constrained_high profiles by default). Also, correct
the checking of profile ids in s_ctrl from hfi to v4l2 ids.

cc: stable@vger.kernel.org # 5.15+
Fixes: bfee75f73c37 ("media: venus: venc: add support for V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM control")
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: venus: vdec: fixed possible memory leak issue
Ameer Hamza [Mon, 6 Dec 2021 10:43:15 +0000 (11:43 +0100)]
media: venus: vdec: fixed possible memory leak issue

The venus_helper_alloc_dpb_bufs() implementation allows an early return
on an error path when checking the id from ida_alloc_min() which would
not release the earlier buffer allocation.

Move the direct kfree() from the error checking of dma_alloc_attrs() to
the common fail path to ensure that allocations are released on all
error paths in this function.

Addresses-Coverity: 1494120 ("Resource leak")

cc: stable@vger.kernel.org # 5.16+
Fixes: 40d87aafee29 ("media: venus: vdec: decoded picture buffer handling during reconfig sequence")
Signed-off-by: Ameer Hamza <amhamza.mgc@gmail.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: venus: core: Fix kerneldoc warnings
Stanimir Varbanov [Wed, 24 Nov 2021 22:25:12 +0000 (23:25 +0100)]
media: venus: core: Fix kerneldoc warnings

Describe missing structure members:

core.h: warning: Function parameter or member
'sys_err_done' not described in 'venus_core'
'fw_min_cnt' not described in 'venus_inst'
'flags' not described in 'venus_inst'
'dpb_ids' not described in 'venus_inst'

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: cec: seco: Drop pointless include
Linus Walleij [Tue, 22 Feb 2022 22:23:31 +0000 (23:23 +0100)]
media: cec: seco: Drop pointless include

This driver uses GPIO descriptors not the old legacy GPIO
API so stop including <linux/gpio.h>.

Fix a bug using a completely unrelated legacy API flag
GPIOF_IN by switching to the actually desired flag
GPIOD_IN.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: hantro: sunxi: Fix VP9 steps
Jernej Skrabec [Tue, 22 Feb 2022 18:03:28 +0000 (19:03 +0100)]
media: hantro: sunxi: Fix VP9 steps

It turns out that postproc on Allwinner H6 needs width and height to be
multiple of 32.

Fixes: 86790a4fdf4b ("media: hantro: Add support for Allwinner H6")
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: imx: csis: Store pads format separately
Jacopo Mondi [Tue, 22 Feb 2022 21:46:43 +0000 (22:46 +0100)]
media: imx: csis: Store pads format separately

As the formats on the sink and source pad might be different store
them separately.

The pad format is used to configure the image width and height in
mipi_csis_system_enable(). As the csis cannot downscale, using the sink
or the source one isn't relevant.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agodoc: media: Document VP9 reference_mode miss-placement
Nicolas Dufresne [Mon, 21 Feb 2022 19:37:27 +0000 (14:37 -0500)]
doc: media: Document VP9 reference_mode miss-placement

The reference_mode derived syntax is part of the compressed headers and
should have been moved into the corresponding control structure. Document
this mistake. The value can be set to 0 if the driver does not require
compressed headers information.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: fix small typo in comment]

2 years agodoc: media: Document MM21 tiled format
Nicolas Dufresne [Mon, 21 Feb 2022 19:12:01 +0000 (14:12 -0500)]
doc: media: Document MM21 tiled format

MM21 has been documented through two software implementation [0] in libyuv
and [2] GStreamer. This format is similar to other tiled format, though it
uses uneven tile sizes. The luma tiles are 16x32 while the chroma tile have
a subsampled size of 16x16. This is the uncompressed cousin of
V4L2_PIX_FMT_MT21C and shares its tiling pattern and alignment.

[0] https://chromium.googlesource.com/libyuv/libyuv/+/b4ddbaf549a1bf5572bf703fd2862d1eb7380c6a
[1] https://gitlab.freedesktop.org/gstreamer/gstreamer/-/commit/c9b127dae3af4b3fe78468e697cb491902425254

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: imx: imx8mq-mipi-csi2: Remove YUV422 2X8
Jacopo Mondi [Mon, 21 Feb 2022 18:17:08 +0000 (19:17 +0100)]
media: imx: imx8mq-mipi-csi2: Remove YUV422 2X8

The 2X8 variants of MEDIA_BUS_FMT_YUYV8_2X8 does not apply to serial
busses.

Drop it and while at it also add the canonical UYVY wire format for
packed YUV422 when transmitted on the CSI-2 serial bus.

Also beautify a little the formats declaration list by putting the
opening curly brace after the comment.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: v4l2-core: Initialize h264 scaling matrix
Nicolas Dufresne [Fri, 18 Feb 2022 18:42:07 +0000 (13:42 -0500)]
media: v4l2-core: Initialize h264 scaling matrix

In the final H264 API, it is not required to set scaling matrix if
they are not present in the bitstream. A flag was added in order to let
the driver know. The downside is that it leaves the default control
value to 0, which isn't valid. As per the spec (see formulas 7-8/7-9),
when the scaling matrix are absent from the bitstream, flat values
of 16 should be used. This improves this control semantic in a way
that the control value are always valid. Drivers can then use
the scaling_matrix control values without having to check its presence.
Same method was employed for MPEG2_QUANTISATION.

This fixes issues with MTK VCODEC H264 decoder when using GStreamer.
GStreamer does not set this control if its not present in the bitstream.
As MTK VDCODEC was using the initialized to 0 values, the frames ended
up completely gray.

Fixes: 54889c51b833d236 ("media: uapi: h264: Rename and clarify PPS_FLAG_SCALING_MATRIX_PRESENT")
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: imx: imx-mipi-csis: Add output format
Jacopo Mondi [Mon, 21 Feb 2022 17:47:27 +0000 (18:47 +0100)]
media: imx: imx-mipi-csis: Add output format

Due to how pixel components are transmitted on the CSI-2 serial bus
and how they are deserialized by the CSI-2 receiver, the component
ordering might change and the image formats on the sink and source pads
of the receiver should reflect it.

For RGB24, in example, the component ordering on the wire as described by
the CSI-2 specification matches the BGR888 format, while once
deserialized by the CSIS receiver it matches the RGB888 format.

Add an additional .output field to struct csis_pix_format to allow
propagating the correct format to the source pad after a format
configuration on the sink.

The change is only relevant for RGB24 but paves the way for further
format translations in future.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: imx: imx-mipi-csis: Add BGR888
Jacopo Mondi [Mon, 21 Feb 2022 17:47:26 +0000 (18:47 +0100)]
media: imx: imx-mipi-csis: Add BGR888

Add support for the BGR888_1X24 image format.

No existing media bus codes describe exactly the way data is transferred
on the CSI-2 bus. This is not a new issue, the CSI-2 YUV422 8-bit format
is described by MEDIA_BUS_FMT_UYVY8_1X16 which is an arbitrary
convention and not an exact match. Use the MEDIA_BUS_FMT_BGR888_1X24 to
follow the same convention, based on the order in which bits are
transmitted over the CSI-2 bus.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: imx: imx-mipi-csis: Add RGB565_1X16
Jacopo Mondi [Mon, 21 Feb 2022 17:47:25 +0000 (18:47 +0100)]
media: imx: imx-mipi-csis: Add RGB565_1X16

Add RGB565_1X16 to the enumeration of supported image formats.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: imx: imx-mipi-csis: Set PIXEL_MODE for YUV422
Jacopo Mondi [Mon, 21 Feb 2022 17:47:24 +0000 (18:47 +0100)]
media: imx: imx-mipi-csis: Set PIXEL_MODE for YUV422

Bits 13 and 12 of the ISP_CONFIGn register configure the PIXEL_MODE
which specifies the sampling size, in pixel component units, on the
CSI-2 output data interface when data are transferred to memory.

The register description in the chip manual specifies that DUAL mode
should be used for YUV422 data.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: imx: imx7-media-csi: Use dual sampling for YUV 1X16
Jacopo Mondi [Mon, 21 Feb 2022 17:47:23 +0000 (18:47 +0100)]
media: imx: imx7-media-csi: Use dual sampling for YUV 1X16

The CSI bridge should operate in dual components mode when it is
connected to a pixel transmitter that transfers two components at a time
in YUV 422 formats (16 bits, Y + U/V).

Use the image format variants to determine if single or dual component mode
should be used.

Add a note to the TODO file to record that the list of supported formats
should be restricted to the SoC model the CSI bridge is integrated on
to avoid potential pipeline mis-configurations.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: imx: Rename imx7-mipi-csis.c to imx-mipi-csis.c
Jacopo Mondi [Mon, 21 Feb 2022 17:47:22 +0000 (18:47 +0100)]
media: imx: Rename imx7-mipi-csis.c to imx-mipi-csis.c

Rename the imx7-mipi-csis.c driver to remove the reference to i.MX7.

The driver is for an IP core found on i.MX7 and i.MX8 SoC, so do not
specify a SoC version number in the driver name.

Remove the references to the i.MX7 SoC in the driver symbols and expand
the driver's header with more information about the IP core the driver
controls.

Also rename the associated bindings documentation.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: imx: De-stage imx7-mipi-csis
Jacopo Mondi [Mon, 21 Feb 2022 17:47:21 +0000 (18:47 +0100)]
media: imx: De-stage imx7-mipi-csis

The imx7-mipi-csis driver is in a good state and can be destaged.

Move the imx7-mipi-csis.c driver to the newly created
drivers/media/platform/imx directory and plumb the related
options in Kconfig and in Makefile.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: imx-jpeg: Set V4L2_BUF_FLAG_LAST at eos
Ming Qian [Tue, 22 Feb 2022 08:41:16 +0000 (16:41 +0800)]
media: imx-jpeg: Set V4L2_BUF_FLAG_LAST at eos

The V4L2_EVENT_EOS event is a deprecated behavior,
the V4L2_BUF_FLAG_LAST buffer flag should be used instead.

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>
2 years agomedia: meson-ir-tx: remove incorrect doc comment
Sean Young [Thu, 18 Nov 2021 10:31:31 +0000 (10:31 +0000)]
media: meson-ir-tx: remove incorrect doc comment

Do not use kernel-doc "/**" notation when the comment is not in
kernel-doc format. This fixes a sparse warning.

Suggested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: vivid: use time_is_after_jiffies() instead of open coding it
Wang Qing [Tue, 15 Feb 2022 01:55:50 +0000 (17:55 -0800)]
media: vivid: use time_is_after_jiffies() instead of open coding it

Use the helper function time_is_{before,after}_jiffies() to improve
code readability.

Signed-off-by: Wang Qing <wangqing@vivo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: wl128x: use time_is_before_jiffies() instead of open coding it
Wang Qing [Tue, 15 Feb 2022 01:55:49 +0000 (17:55 -0800)]
media: wl128x: use time_is_before_jiffies() instead of open coding it

Use the helper function time_is_{before,after}_jiffies() to improve
code readability.

Signed-off-by: Wang Qing <wangqing@vivo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: tda8083: use time_is_after_jiffies() instead of open coding it
Wang Qing [Tue, 15 Feb 2022 01:55:48 +0000 (17:55 -0800)]
media: tda8083: use time_is_after_jiffies() instead of open coding it

Use the helper function time_is_{before,after}_jiffies() to improve
code readability.

Signed-off-by: Wang Qing <wangqing@vivo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: stv0299: use time_is_before_jiffies() instead of open coding it
Wang Qing [Tue, 15 Feb 2022 01:55:47 +0000 (17:55 -0800)]
media: stv0299: use time_is_before_jiffies() instead of open coding it

Use the helper function time_is_{before,after}_jiffies() to improve
code readability.

Signed-off-by: Wang Qing <wangqing@vivo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: si21xx: use time_is_before_jiffies() instead of open coding it
Wang Qing [Tue, 15 Feb 2022 01:55:46 +0000 (17:55 -0800)]
media: si21xx: use time_is_before_jiffies() instead of open coding it

Use the helper function time_is_{before,after}_jiffies() to improve
code readability.

Signed-off-by: Wang Qing <wangqing@vivo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: cedrus: h264: Fix neighbour info buffer size
Jernej Skrabec [Mon, 14 Feb 2022 19:08:39 +0000 (20:08 +0100)]
media: cedrus: h264: Fix neighbour info buffer size

According to BSP library source, H264 neighbour info buffer size needs
to be 32 kiB for H6. This is similar to H265 decoding, which also needs
double buffer size in comparison to older Cedrus core generations.

Increase buffer size to cover H6 needs. Since increase is not that big
in absolute numbers, it doesn't make sense to complicate logic for older
generations.

Issue was discovered using iommu and cross checked with BSP library
source.

Fixes: 6eb9b758e307 ("media: cedrus: Add H264 decoding support")
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: cx88-mpeg: clear interrupt status register before streaming video
Daniel González Cabanelas [Sun, 20 Feb 2022 18:19:50 +0000 (19:19 +0100)]
media: cx88-mpeg: clear interrupt status register before streaming video

Some cx88 video cards may have transport stream status interrupts set
to 1 from cold start, causing errors like this:

  cx88xx: cx88_print_irqbits: core:irq mpeg  [0x100000] ts_err?*
  cx8802: cx8802_mpeg_irq: mpeg:general errors: 0x00100000

According to CX2388x datasheet, the interrupt status register should be
cleared before enabling IRQs to stream video.

Fix it by clearing the Transport Stream Interrupt Status register.

Signed-off-by: Daniel González Cabanelas <dgcbueu@gmail.com>
2 years agomedia: cedrus: H265: Fix neighbour info buffer size
Jernej Skrabec [Sat, 12 Feb 2022 07:42:41 +0000 (08:42 +0100)]
media: cedrus: H265: Fix neighbour info buffer size

Neighbour info buffer size needs to be 794 kiB in H6. This is actually
already indirectly mentioned in the comment, but smaller size is used
nevertheless.

Increase buffer size to cover H6 needs. Since increase is not that big
in absolute numbers, it doesn't make sense to complicate logic for older
generations.

Bug was discovered using iommu, which reported access error when trying
to play H265 video.

Fixes: 86caab29da78 ("media: cedrus: Add HEVC/H.265 decoding support")
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: fsl-viu: use GFP_KERNEL
Julia Lawall [Thu, 10 Feb 2022 20:42:20 +0000 (21:42 +0100)]
media: fsl-viu: use GFP_KERNEL

Platform_driver probe functions aren't called with locks held
and thus don't need GFP_ATOMIC. Use GFP_KERNEL instead.

Problem found with Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: cx18: use GFP_KERNEL
Julia Lawall [Thu, 10 Feb 2022 20:42:16 +0000 (21:42 +0100)]
media: cx18: use GFP_KERNEL

Pci_driver probe functions aren't called with locks held
and thus don't need GFP_ATOMIC. Use GFP_KERNEL instead.

Problem found with Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agodrivers: meson: vdec: add VP9 support to GXM
Christian Hewitt [Wed, 9 Feb 2022 15:31:50 +0000 (15:31 +0000)]
drivers: meson: vdec: add VP9 support to GXM

VP9 support for GXM appears to have been missed from the original
codec submission [0] but it works well, so let's add support.

[0] https://github.com/torvalds/linux/commit/00c43088aa680989407b6afbda295f67b3f123f1

Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agostkwebcam: add new Asus laptop to upside_down table
Xose Vazquez Perez [Tue, 8 Feb 2022 16:12:22 +0000 (17:12 +0100)]
stkwebcam: add new Asus laptop to upside_down table

Handle 0x0001, DMI type 1, 27 bytes
System Information
    Manufacturer: ASUSTeK Computer Inc.
    Product Name: A6JC
    Version: 1.0
    Serial Number: XXXXXXXXXXXXXXXXX
    UUID: XXXXXXXXXXXXXXXXX
    Wake-up Type: Power Switch
    SKU Number: To Be Filled By O.E.M.
    Family: To Be Filled By O.E.M.

Handle 0x0002, DMI type 2, 15 bytes
Base Board Information
    Manufacturer: ASUSTeK Computer Inc.
    Product Name: A6JC
    Version: 1.0
    Serial Number: XXXXXXXXXXXXXXXXX
    Asset Tag: To Be Filled By O.E.M.
    Features:
        Board is a hosting board
        Board is replaceable
    Location In Chassis: To Be Filled By O.E.M.
    Chassis Handle: 0x0003
    Type: Motherboard
    Contained Object Handles: 0

Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: MEDIA ML <linux-media@vger.kernel.org>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: imx-jpeg: fix a bug of accessing array out of bounds
Ming Qian [Mon, 7 Feb 2022 06:28:43 +0000 (14:28 +0800)]
media: imx-jpeg: fix a bug of accessing array out of bounds

When error occurs in parsing jpeg, the slot isn't acquired yet, it may
be the default value MXC_MAX_SLOTS.
If the driver access the slot using the incorrect slot number, it will
access array out of bounds.
The result is the driver will change num_domains, which follows
slot_data in struct mxc_jpeg_dev.
Then the driver won't detach the pm domain at rmmod, which will lead to
kernel panic when trying to insmod again.

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>
2 years agomedia: sun6i-csi: fix colorspace in sun6i_video_try_fmt()
Mikhail Rudenko [Sat, 5 Feb 2022 23:33:31 +0000 (02:33 +0300)]
media: sun6i-csi: fix colorspace in sun6i_video_try_fmt()

With gstreamer 1.19.3 all attempts to capture video in YUV formats on
our Allwinner H3-based custom board with an ov5640 sensor result in
pipeline crashes with the following messages:

Device '/dev/video0' does not support 2:0:0:0 colorimetry
Additional debug info:
Device wants 2:0:0:0 colorimetry

Fix this by setting the correct colorspace in sun6i_video_try_fmt().

Signed-off-by: Mikhail Rudenko <mike.rudenko@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: usb: go7007: s2250-board: fix leak in probe()
Dan Carpenter [Wed, 2 Feb 2022 17:52:01 +0000 (20:52 +0300)]
media: usb: go7007: s2250-board: fix leak in probe()

Call i2c_unregister_device(audio) on this error path.

Fixes: d3b2ccd9e307 ("[media] s2250: convert to the control framework")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: cedrus: Add watchdog for job completion
Jernej Skrabec [Tue, 1 Feb 2022 18:33:24 +0000 (19:33 +0100)]
media: cedrus: Add watchdog for job completion

Currently, if job is not completed for whatever reason, userspace
application can hang on ioctl and thus become unkillable.

In order to prevent that, implement watchdog, which will complete job
after 2 seconds with error state.

Concept is borrowed from hantro driver.

Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agopixfmt-yuv-planar.rst: fix typo: 'Cr, Cr' -> 'Cr, Cb'
Hans Verkuil [Tue, 1 Feb 2022 07:23:48 +0000 (08:23 +0100)]
pixfmt-yuv-planar.rst: fix typo: 'Cr, Cr' -> 'Cr, Cb'

Several NV formats incorrectly described the Chroma order as
Cr, Cr when it actually is Cr, Cb.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reported-by: Frank Barchard <fbarchard@google.com>
2 years agomedia: imx-jpeg: Remove unnecessary print function dev_err()
Yang Li [Tue, 1 Feb 2022 06:07:57 +0000 (14:07 +0800)]
media: imx-jpeg: Remove unnecessary print function dev_err()

The print function dev_err() is redundant because platform_get_irq()
already prints an error.

Eliminate the follow coccicheck warning:
./drivers/media/platform/imx-jpeg/mxc-jpeg.c:2025:3-10: line 2025 is
redundant because platform_get_irq() already prints an error

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: aspeed: Remove duplicated include in aspeed-video.c
Yang Li [Tue, 1 Feb 2022 04:04:31 +0000 (12:04 +0800)]
media: aspeed: Remove duplicated include in aspeed-video.c

Fix following includecheck warning:
./drivers/media/platform/aspeed-video.c: linux/videodev2.h is included
more than once.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: saa7164: remove redundant assignment to variable idx
Colin Ian King [Sun, 30 Jan 2022 23:21:40 +0000 (23:21 +0000)]
media: saa7164: remove redundant assignment to variable idx

Variable idx is being assigned a value that is never read, it is being
re-assigned a new value in the following for-loop. 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>
2 years agomedia: saa7134: remove redundant assignment to variable id
Colin Ian King [Sun, 30 Jan 2022 23:15:20 +0000 (23:15 +0000)]
media: saa7134: remove redundant assignment to variable id

Variable id is being assigned a value that is never read. 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>
2 years agomedia: mtk-jpeg: remove redundant initialization of variable plane_fmt
Colin Ian King [Sun, 30 Jan 2022 23:11:11 +0000 (23:11 +0000)]
media: mtk-jpeg: remove redundant initialization of variable plane_fmt

The variable plane_fmt is being initialized with a value that is never
read, it is being re-assigned a new value on each iteration of a for
loop. The initialization is redundant and can be removed.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: gspca: remove redundant assignment of variable n
Colin Ian King [Sun, 30 Jan 2022 22:31:03 +0000 (22:31 +0000)]
media: gspca: remove redundant assignment of variable n

The variable n is being assigned a value that is never read, it is
being reassigned a different value a few statements later. 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>
2 years agomedia: uapi: Init VP9 stateless decode params
Yunfei Dong [Fri, 28 Jan 2022 03:23:30 +0000 (11:23 +0800)]
media: uapi: Init VP9 stateless decode params

Init some of VP9 frame decode params to default value.

Fixes: b88dbe38dca8 ("media: uapi: Add VP9 stateless decoder controls")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: go7007: Constify static struct snd_device_ops
Rikard Falkeborn [Tue, 25 Jan 2022 23:46:02 +0000 (00:46 +0100)]
media: go7007: Constify static struct snd_device_ops

The only usage of go7007_snd_device_ops is to pass its address to
snd_device_new() which takes a pointer to const struct snd_device_ops.
Make it const to allow the compiler to put it in read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: saa7115: make static read-only array lcr2vbi const
Colin Ian King [Sun, 23 Jan 2022 23:07:26 +0000 (23:07 +0000)]
media: saa7115: make static read-only array lcr2vbi const

The static array lcr2vbi is read-only so it make sense to make
it const.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: em28xx: initialize refcount before kref_get
Dongliang Mu [Sat, 22 Jan 2022 07:44:59 +0000 (15:44 +0800)]
media: em28xx: initialize refcount before kref_get

The commit 47677e51e2a4("[media] em28xx: Only deallocate struct
em28xx after finishing all extensions") adds kref_get to many init
functions (e.g., em28xx_audio_init). However, kref_init is called too
late in em28xx_usb_probe, since em28xx_init_dev before will invoke
those init functions and call kref_get function. Then refcount bug
occurs in my local syzkaller instance.

Fix it by moving kref_init before em28xx_init_dev. This issue occurs
not only in dev but also dev->dev_next.

Fixes: 47677e51e2a4 ("[media] em28xx: Only deallocate struct em28xx after finishing all extensions")
Reported-by: syzkaller <syzkaller@googlegroups.com>
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: usb: pwc-uncompress: Use struct_size() helper in pwc_decompress()
Gustavo A. R. Silva [Thu, 20 Jan 2022 21:24:34 +0000 (15:24 -0600)]
media: usb: pwc-uncompress: Use struct_size() helper in pwc_decompress()

Make use of the struct_size() helper instead of an open-coded version,
in order to avoid any potential type mistakes or integer overflows that,
in the worst scenario, could lead to heap overflows.

Also, address the following sparse warnings:
drivers/media/usb/pwc/pwc-uncompress.c:44:44: warning: using sizeof on a flexible structure

Link: https://github.com/KSPP/linux/issues/174
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: platform: mtk-vcodec: Do not force /dev/videoX node number
Benjamin Gaignard [Thu, 20 Jan 2022 08:59:09 +0000 (09:59 +0100)]
media: platform: mtk-vcodec: Do not force /dev/videoX node number

Let's v4l2 framework use a free /dev/videoX node for decode and encoder.
For the decoder call video_register_device() before register the media
controller device so the mapping between ins correctly done.
Since the registering sequence has changed rework exiting errors case too.

Fixes: 590577a4e525 ("[media] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver")
Fixes: 4e855a6efa54 ("[media] vcodec: mediatek: Add Mediatek V4L2 Video Encoder Driver")

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: aspeed: Use of_device_get_match_data() helper
Jammy Huang [Mon, 14 Feb 2022 08:09:09 +0000 (16:09 +0800)]
media: aspeed: Use of_device_get_match_data() helper

Use of_device_get_match_data() to simplify the code.

Signed-off-by: Jammy Huang <jammy_huang@aspeedtech.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: aspeed: Use full swing as JFIF to fix incorrect color
Jammy Huang [Thu, 10 Feb 2022 09:29:45 +0000 (17:29 +0800)]
media: aspeed: Use full swing as JFIF to fix incorrect color

Current settings for video capture rgb-2-yuv is BT.601(studio swing),
but JFIF uses BT.601(full swing) to deocde. This mismatch will lead
to incorrect color. For example, input RGB value, (0, 0, 255), will
become (16, 16, 235) after jpg decoded.

Add an enum, aspeed_video_capture_format, to define VR008[7:6]
capture format and correct default settings for video capture to fix
the problem.

VR008[7:6] decides the data format for video capture as below:
* 00: CCIR601 studio swing compliant YUV format
* 01: CCIR601 full swing compliant YUV format
* 10: RGB format
* 11: Gray color mode

Signed-off-by: Jammy Huang <jammy_huang@aspeedtech.com>
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: aspeed: Fix unstable timing detection
Jammy Huang [Wed, 26 Jan 2022 01:47:25 +0000 (09:47 +0800)]
media: aspeed: Fix unstable timing detection

Using stable-signal in resolution detection, and try detection again
if unstable.

VE_MODE_DETECT_EXTSRC_ADC: 1 if video source is from ADC output.
VE_MODE_DETECT_H_STABLE: 1 if horizontal signal detection is stable.
VE_MODE_DETECT_V_STABLE: 1 if vertical signal detection is stable.

Signed-off-by: Jammy Huang <jammy_huang@aspeedtech.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: aspeed: Add macro for the fields of the mode-detect registers
Jammy Huang [Wed, 26 Jan 2022 01:47:24 +0000 (09:47 +0800)]
media: aspeed: Add macro for the fields of the mode-detect registers

VE_MODE_DT_HOR_TOLER: the tolerance in detecting for stable horizontal
signal.
VE_MODE_DT_VER_TOLER: the tolerance in detecting for stable vertical
signal.
VE_MODE_DT_HOR_STABLE: the minimum required count in detecting stable
HSYNC signal to set mode detection horizontal signal stable.
VE_MODE_DT_VER_STABLE: the minimum required count in detecting stable
VSYNC signal to set mode detection vertical signal stable.

Signed-off-by: Jammy Huang <jammy_huang@aspeedtech.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: aspeed: add comments and macro
Jammy Huang [Tue, 7 Dec 2021 01:54:11 +0000 (09:54 +0800)]
media: aspeed: add comments and macro

Add comments to describe video-stat and 'struct aspeed_video'.
Add macro, ASPEED_VIDEO_V4L2_MIN_BUF_REQ, to describe the buffers
needed.

Signed-off-by: Jammy Huang <jammy_huang@aspeedtech.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: drop docbook tags, not needed]

2 years agomedia: rcar-{csi2,vin}: Move to full Virtual Channel routing per CSI-2 IP
Niklas Söderlund [Mon, 24 Jan 2022 12:48:58 +0000 (13:48 +0100)]
media: rcar-{csi2,vin}: Move to full Virtual Channel routing per CSI-2 IP

When Gen3 support was first added to this R-Car VIN and CSI-2 driver the
routing was centred around the CHSEL register which multiplexes the
different parallel buses that sit between the CSI-2 receivers source
side and the VIN dma engines. This was a bad design as the multiplexing
do allow for only a few combinations and do not play nice with many
video streams in the system.

For example it's only possible for CSI-2 Virtual Channels 0 and 1 of any
given CSI-2 receiver to be used together with the scaler.

Later datasheets have expanded the documentation and it is now possible
to improve on this design by allowing any Virtual Channel to be routed
to any R-Car VIN instance, provided that there exists a parallel bus
between them. This increases the flexibility as all Virtual Channels can
now be used together with the scaler for example.

The redesign is not however perfect. While the new design allows for
many more routes, two constrains limit a small portion of routes that
was possible in the old design but are no more.

- It is no longer possible to route the same CSI-2 and VC to more then
  one VIN at a time. This was theoretically possible before if the
  specific SoC allowed for the same CSI-2 and VC to be routed to two
  different VIN capture groups.

- It is no longer possible to simultaneously mix links from two CSI-2 IP
  blocks to the same VIN capture group.

  For example if VIN2 is capturing from CSI40 then VIN{0,1,3} must also
  capture from CSI40. While VIN{4,5,6,7} is still free to capture from
  any other CSI-2 IP in the system. Once all VIN{0,1,2,3} links to CSI40
  are disabled that VIN capture group is free again to capture from any
  other CSI-2 IP it is connected to.

At the core of the redesign is greater cooperator of the R-Car VIN and
CSI-2 drivers in configuring the routing. The VIN driver is after this
change only responsible to configure the full VIN capture groups
parallel buses to be to a particular CSI-2 IP. While the configuration
of which CSI-2 Virtual Channel is outputted on which of the R-Car CSI-2
IP output ports is handled by the CSI-2 driver.

Before this change the CSI-2 Virtual Channel to output port was static
in the CSI-2 driver and the different links only manipulated the VIN
capture groups CHSEL register. With this change both the CHSEl register
and the CSI-2 routing VCDT registers are modified for greater
flexibility.

This change touches both the R-Car VIN and R-Car CSI-2 drivers in the
same commit as both drivers cooperate closely and one change without the
other would more or less break video capture.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: fix two trivial checkpatch whitespace issues]

2 years agomedia: rcar-vin: Breakout media link creation
Niklas Söderlund [Mon, 24 Jan 2022 12:48:57 +0000 (13:48 +0100)]
media: rcar-vin: Breakout media link creation

In preparation of creating more links to allow for full Virtual Channel
routing within the CSI-2 block break out the link creation logic to a
helper function as the logic will grow in future work.

There is no functional change.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: rcar-vin: Refactor link notify
Niklas Söderlund [Mon, 24 Jan 2022 12:48:56 +0000 (13:48 +0100)]
media: rcar-vin: Refactor link notify

The code has grown organically and a lot of checks are performed for
the CSI-2 use-case even if the link notify is for a subdevice connected
to the parallel interface.

Before reworking the CSI-2 routing logic split the CSI-2 and parallel
link notify code in two separate blocks to make it clearer. There is no
functional change.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2 years agomedia: xilinx: csi2rxss: Use mipi-csi2.h
Laurent Pinchart [Sun, 23 Jan 2022 15:58:17 +0000 (16:58 +0100)]
media: xilinx: csi2rxss: Use mipi-csi2.h

Replace the driver-specific definitions of MIPI CSI-2 data types with
macros from mipi-csi2.h.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rcar-csi2: Use mipi-csi2.h
Laurent Pinchart [Sun, 23 Jan 2022 15:58:17 +0000 (16:58 +0100)]
media: rcar-csi2: Use mipi-csi2.h

Replace the hardcoded MIPI CSI-2 data types with macros from
mipi-csi2.h.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rcar-isp: Use mipi-csi2.h
Laurent Pinchart [Sun, 23 Jan 2022 15:58:17 +0000 (16:58 +0100)]
media: rcar-isp: Use mipi-csi2.h

Replace the hardcoded MIPI CSI-2 data types with macros from
mipi-csi2.h.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: Define MIPI CSI-2 data types in a shared header file
Laurent Pinchart [Sun, 23 Jan 2022 15:36:19 +0000 (16:36 +0100)]
media: Define MIPI CSI-2 data types in a shared header file

There are many CSI-2-related drivers in the media subsystem that come
with their own macros to handle the CSI-2 data types (or just hardcode
the numerical values). Provide a shared header with definitions for
those data types that driver can use.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>