platform/kernel/linux-starfive.git
2 years agomedia: cedrus: h265: Fix flag name
Jernej Skrabec [Mon, 20 Jun 2022 17:55:11 +0000 (18:55 +0100)]
media: cedrus: h265: Fix flag name

Bit 21 in register 0x24 (slice header info 1) actually represents
negated version of low delay flag. This can be seen in vendor Cedar
library source code. While this flag is not part of the standard, it can
be found in reference HEVC implementation.

Fix macro name and change it to flag.

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>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: hantro: sunxi: Enable 10-bit decoding
Jernej Skrabec [Wed, 6 Jul 2022 18:29:01 +0000 (19:29 +0100)]
media: hantro: sunxi: Enable 10-bit decoding

Now that infrastructure for 10-bit decoding exists, enable it for
Allwinner H6.

Tested-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: hantro: Store VP9 bit depth in context
Jernej Skrabec [Wed, 6 Jul 2022 18:29:00 +0000 (19:29 +0100)]
media: hantro: Store VP9 bit depth in context

Now that we have proper infrastructure for postprocessing 10-bit
formats, store VP9 bit depth in context.

Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Tested-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: hantro: postproc: Properly calculate chroma offset
Jernej Skrabec [Wed, 6 Jul 2022 18:28:59 +0000 (19:28 +0100)]
media: hantro: postproc: Properly calculate chroma offset

Currently chroma offset calculation assumes only 1 byte per luma, with
no consideration for stride.

Take necessary information from destination pixel format which makes
calculation completely universal.

Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Tested-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: hantro: postproc: Fix legacy regs configuration
Jernej Skrabec [Wed, 6 Jul 2022 18:28:58 +0000 (19:28 +0100)]
media: hantro: postproc: Fix legacy regs configuration

Some postproc legacy registers were set in VP9 code. Move them to
postproc and fix their value.

Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Tested-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: hantro: postproc: Fix buffer size calculation
Jernej Skrabec [Wed, 6 Jul 2022 18:28:57 +0000 (19:28 +0100)]
media: hantro: postproc: Fix buffer size calculation

When allocating aux buffers for postprocessing, it's assumed that base
buffer size is the same as that of output. Coincidentally, that's true
most of the time, but not always. 10-bit source also needs aux buffer
size which is appropriate for 10-bit native format, even if the output
format is 8-bit. Similarly, mv sizes and other extra buffer size also
depends on source width/height, not destination.

Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Tested-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: hantro: Support format filtering by depth
Jernej Skrabec [Wed, 6 Jul 2022 18:28:56 +0000 (19:28 +0100)]
media: hantro: Support format filtering by depth

In preparation for supporting 10-bit formats, add mechanism which will
filter formats based on pixel depth.

Hantro G2 supports only one decoding format natively and that is based
on bit depth of current video frame. Additionally, it makes no sense to
upconvert bitness, so filter those out too.

Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Tested-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: Add P010 tiled format
Ezequiel Garcia [Wed, 6 Jul 2022 18:28:55 +0000 (19:28 +0100)]
media: Add P010 tiled format

Add P010 tiled format

[rebased, updated pixel format name and added description]

Tested-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: uvcvideo: Remove unneeded goto
Michael Grzeschik [Thu, 16 Jun 2022 19:54:54 +0000 (20:54 +0100)]
media: uvcvideo: Remove unneeded goto

The goto statement in uvc_v4l2_try_format can simply be replaced by an
direct return. There is no further user of the label, so remove it.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: uvcvideo: Limit power line control for Acer EasyCamera
Ricardo Ribalda [Tue, 7 Jun 2022 13:44:04 +0000 (14:44 +0100)]
media: uvcvideo: Limit power line control for Acer EasyCamera

The device does not implement the power line control correctly. Add a
corresponding control mapping override.

Bus 001 Device 003: ID 5986:1172 Acer, Inc EasyCamera
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x5986 Acer, Inc
  idProduct          0x1172
  bcdDevice           56.04
  iManufacturer           3 Bison
  iProduct                1 EasyCamera
  iSerial                 2
  bNumConfigurations      1

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: Limit power line control for Quanta cameras
Ricardo Ribalda [Tue, 7 Jun 2022 13:44:03 +0000 (14:44 +0100)]
media: uvcvideo: Limit power line control for Quanta cameras

Two more cameras do not implement the power line control correctly. Add
a corresponding control mapping override.

Bus 001 Device 003: ID 0408:4034 Quanta Computer, Inc. ACER HD User Facing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.01
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x0408 Quanta Computer, Inc.
  idProduct          0x4034
  bcdDevice            0.01
  iManufacturer           1 Quanta
  iProduct                2 ACER HD User Facing
  iSerial                 3 01.00.00
  bNumConfigurations      1

Bus 001 Device 003: ID 0408:4030 Quanta Computer, Inc. HD User Facing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.01
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x0408 Quanta Computer, Inc.
  idProduct          0x4030
  bcdDevice            0.02
  iManufacturer           1 Quanta
  iProduct                2 HD User Facing
  iSerial                 3 01.00.00
  bNumConfigurations      1

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: Limit power line control for Chicony Easycamera
Ricardo Ribalda [Tue, 7 Jun 2022 13:44:02 +0000 (14:44 +0100)]
media: uvcvideo: Limit power line control for Chicony Easycamera

Another Chicony camera device does not implement the power line control
correctly. Add a corresponding control mapping override.

Bus 001 Device 003: ID 04f2:b5eb Chicony Electronics Co., Ltd EasyCamera
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x04f2 Chicony Electronics Co., Ltd
  idProduct          0xb5eb
  bcdDevice           90.45
  iManufacturer           3 Chicony Electronics Co.,Ltd.
  iProduct                1 EasyCamera
  iSerial                 2 0001
  bNumConfigurations      1

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: Limit power line control for Chicony Easycamera
Ricardo Ribalda [Tue, 7 Jun 2022 13:44:01 +0000 (14:44 +0100)]
media: uvcvideo: Limit power line control for Chicony Easycamera

Two different Easycamera devices do not implement the power line control
correctly. Add a corresponding control mapping override.

Bus 001 Device 003: ID 04f2:b6ba Chicony Electronics Co., Ltd EasyCamera
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x04f2 Chicony Electronics Co., Ltd
  idProduct          0xb6ba
  bcdDevice           10.70
  iManufacturer           3 Chicony Electronics Co.,Ltd.
  iProduct                1 EasyCamera
  iSerial                 2 0001
  bNumConfigurations      1

Bus 001 Device 003: ID 04f2:b746 Chicony Electronics Co., Ltd EasyCamera
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x04f2 Chicony Electronics Co., Ltd
  idProduct          0xb746
  bcdDevice           97.57
  iManufacturer           3 Chicony Electronics Co.,Ltd.
  iProduct                1 EasyCamera
  iSerial                 2 0001
  bNumConfigurations      1

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: Limit power line control for Quanta UVC Webcam
Ricardo Ribalda [Tue, 7 Jun 2022 13:44:00 +0000 (14:44 +0100)]
media: uvcvideo: Limit power line control for Quanta UVC Webcam

The device does not implement the power line control correctly. Add a
corresponding control mapping override.

Bus 001 Device 003: ID 0408:3090 Quanta Computer, Inc. USB2.0 HD UVC WebCam
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x0408 Quanta Computer, Inc.
  idProduct          0x3090
  bcdDevice            0.04
  iManufacturer           3 Quanta
  iProduct                1 USB2.0 HD UVC WebCam
  iSerial                 2 0x0001
  bNumConfigurations      1

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: Add support for per-device control mapping overrides
Ricardo Ribalda [Tue, 7 Jun 2022 13:43:59 +0000 (14:43 +0100)]
media: uvcvideo: Add support for per-device control mapping overrides

Some devices do not implement all their controls in a way that complies
with the UVC specification. This is for instance the case for several
devices that do not support the disabled mode for the power line
frequency control. Add a mechanism to allow per-device control mapping
overrides to avoid errors when accessing non-compliant controls.

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: Add missing value for power_line_frequency
Ricardo Ribalda [Tue, 7 Jun 2022 13:43:58 +0000 (14:43 +0100)]
media: uvcvideo: Add missing value for power_line_frequency

UVC 1.5 class defines 4 values for this control on:
4.2.2.3.6 Power Line Frequency Control

Add the missing value when the UVC version is 1.5.

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: Replace broken URL
Laurent Pinchart [Wed, 8 Jun 2022 17:38:52 +0000 (18:38 +0100)]
media: uvcvideo: Replace broken URL

The link to the web page that explains continued fractions is broken.
Replace it with a link to the corresponding Wikipedia page.

Reported-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: uvcvideo: Fix comment blocks style
Laurent Pinchart [Wed, 8 Jun 2022 17:38:52 +0000 (18:38 +0100)]
media: uvcvideo: Fix comment blocks style

The uvcvideo driver historically uses the

/* Comment
 * style
 */

for multi-line block comments, which is frowned upon. Patches for the
driver are required to use the more standard

/*
 * Comment
 * style
 */

style. This result in inconsistencies. Fix it by converting all
remaining instances of the old style.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: dt-bindings: media: nxp,imx-mipi-csi2: i.MX8MP support
Laurent Pinchart [Sun, 11 Apr 2021 19:10:22 +0000 (20:10 +0100)]
media: dt-bindings: media: nxp,imx-mipi-csi2: i.MX8MP support

The CSIS CSI-2 receiver in the i.MX8MP seems to be identical to the
version present in the i.MX8MM. Add a device-specific compatible string,
with a fallback to the i.MX8MM compatible.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx: imx-mipi-csis: Implement the .get_frame_desc() operation
Laurent Pinchart [Tue, 22 Feb 2022 09:50:25 +0000 (09:50 +0000)]
media: imx: imx-mipi-csis: Implement the .get_frame_desc() operation

The CSIS is connected to its sink through an SoC-specific gasket that
needs to be configured. Depending on the platform, the gasket
configuration requires knowing the CSI-2 DT. To provide the needed
information, implement the .get_frame_desc() operation.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx: imx-mipi-csis: Add version register
Laurent Pinchart [Wed, 7 Apr 2021 22:54:07 +0000 (23:54 +0100)]
media: imx: imx-mipi-csis: Add version register

Register at offset 0x00 isn't documented, but the NXP BSP
imx8-mipi-csi2-sam driver defines it as a version register. Tests on
i.MX7D and i.MX8MP have confirmed this, with values matching the version
of the IP core specified in the respective reference manuals.

This commit doesn't make use of the version register at runtime as the
compatible strings are enough to identify the IP core version.
Nonetheless, capturing the information in register definitions that
don't affect the code negatively is useful for future development.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx: imx-mipi-csis: Set the subdev fwnode for endpoint matching
Laurent Pinchart [Mon, 21 Mar 2022 07:58:14 +0000 (07:58 +0000)]
media: imx: imx-mipi-csis: Set the subdev fwnode for endpoint matching

Endpoint matching is preferred over device matching with the async
notifier framework. Set the fwnode in the v4l2_subdev for the CSIS to
the endpoint connected to the next device.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: uapi: move HEVC stateless controls out of staging
Benjamin Gaignard [Fri, 8 Jul 2022 16:21:56 +0000 (17:21 +0100)]
media: uapi: move HEVC stateless controls out of staging

HEVC uAPI is used by 2 mainline drivers (Hantro, Cedrus)
and at least 2 out-of-tree drivers (rkvdec, RPi).
The uAPI has been reviewed so it is time to make it 'public' by
un-staging it.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: uapi: Change data_bit_offset definition
Benjamin Gaignard [Fri, 8 Jul 2022 16:21:55 +0000 (17:21 +0100)]
media: uapi: Change data_bit_offset definition

'F.7.3.6.1 General slice segment header syntax' section of HEVC
specification describes that a slice header always end aligned on
byte boundary, therefore we only need to provide the data offset in bytes.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: uapi: HEVC: fix padding in v4l2 control structures
Benjamin Gaignard [Fri, 8 Jul 2022 16:21:54 +0000 (17:21 +0100)]
media: uapi: HEVC: fix padding in v4l2 control structures

Fix padding where needed to remove holes

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Jernej Skrabec <jernej.skrabec@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: Stop using Hantro dedicated control
Benjamin Gaignard [Fri, 8 Jul 2022 16:21:53 +0000 (17:21 +0100)]
media: hantro: Stop using Hantro dedicated control

The number of bits to skip in the slice header can be computed
in the driver by using sps, pps and decode_params information.
This makes it possible to remove Hantro dedicated control.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: controls: Log HEVC stateless control in .std_log
Benjamin Gaignard [Fri, 8 Jul 2022 16:21:52 +0000 (17:21 +0100)]
media: controls: Log HEVC stateless control in .std_log

Simply print the type of the control.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: uapi: Move the HEVC stateless control type out of staging
Benjamin Gaignard [Fri, 8 Jul 2022 16:21:51 +0000 (17:21 +0100)]
media: uapi: Move the HEVC stateless control type out of staging

Move the HEVC stateless controls types out of staging,
and re-number them.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: uapi: Move parsed HEVC pixel format out of staging
Benjamin Gaignard [Fri, 8 Jul 2022 16:21:49 +0000 (17:21 +0100)]
media: uapi: Move parsed HEVC pixel format out of staging

Move HEVC pixel format since we are ready to stabilize the uAPI

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: uapi: Add V4L2_CID_STATELESS_HEVC_ENTRY_POINT_OFFSETS control
Benjamin Gaignard [Fri, 8 Jul 2022 16:21:50 +0000 (18:21 +0200)]
media: uapi: Add V4L2_CID_STATELESS_HEVC_ENTRY_POINT_OFFSETS control

The number of 'entry point offset' can be very variable.
Instead of using a large static array define a v4l2 dynamic array
of U32 (V4L2_CTRL_TYPE_U32).
The number of entry point offsets is reported by the elems field
and in struct v4l2_ctrl_hevc_slice_params.num_entry_point_offsets
field.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Jernej Skrabec <jernej.skrabec@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: uapi: HEVC: Define V4L2_CID_STATELESS_HEVC_SLICE_PARAMS as a dynamic array
Benjamin Gaignard [Fri, 8 Jul 2022 16:21:48 +0000 (17:21 +0100)]
media: uapi: HEVC: Define V4L2_CID_STATELESS_HEVC_SLICE_PARAMS as a dynamic array

Make explicit that V4L2_CID_STATELESS_HEVC_SLICE_PARAMS control is
a dynamic array control type.
Some drivers may be able to receive multiple slices in one control
to improve decoding performance.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@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: uapi: HEVC: Add documentation to uAPI structure
Benjamin Gaignard [Fri, 8 Jul 2022 16:21:47 +0000 (17:21 +0100)]
media: uapi: HEVC: Add documentation to uAPI structure

Add kernel-doc documentation for all the HEVC structures.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: uapi: HEVC: Add SEI pic struct flags
Benjamin Gaignard [Fri, 8 Jul 2022 16:21:46 +0000 (17:21 +0100)]
media: uapi: HEVC: Add SEI pic struct flags

The possible values for the field_pic field in the v4l2_hevc_dpb_entry
structure are defined in the table D.2 in HEVC specification section D.3.3.
Add flags and documentation for each of them.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: uapi: HEVC: Change pic_order_cnt definition in v4l2_hevc_dpb_entry
Benjamin Gaignard [Fri, 8 Jul 2022 16:21:45 +0000 (17:21 +0100)]
media: uapi: HEVC: Change pic_order_cnt definition in v4l2_hevc_dpb_entry

The HEVC specification describes the following:
"PicOrderCntVal is derived as follows:
PicOrderCntVal = PicOrderCntMsb + slice_pic_order_cnt_lsb
The value of PicOrderCntVal shall be in the range of
−2^31 to 2^31 âˆ’ 1, inclusive."

To match with these definitions change __u16 pic_order_cnt[2]
into __s32 pic_order_cnt_val.
Change v4l2_ctrl_hevc_slice_params->slice_pic_order_cnt to __s32 too.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: uapi: HEVC: Rename HEVC stateless controls with STATELESS prefix
Benjamin Gaignard [Fri, 8 Jul 2022 16:21:44 +0000 (17:21 +0100)]
media: uapi: HEVC: Rename HEVC stateless controls with STATELESS prefix

Change HEVC  stateless controls names to V4L2_CID_STATELESS_HEVC instead
of V4L2_CID_MPEG_VIDEO_HEVC be coherent with v4l2 naming convention.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Tested-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: uapi: HEVC: Add missing fields in HEVC controls
Benjamin Gaignard [Fri, 8 Jul 2022 16:21:43 +0000 (17:21 +0100)]
media: uapi: HEVC: Add missing fields in HEVC controls

Complete the HEVC controls with missing fields from H.265 specifications.
Even if these fields aren't used by the current mainlined drivers
they will be required for (at least) the rkvdec driver.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: vivid: add dynamic array test control
Hans Verkuil [Fri, 8 Jul 2022 16:21:42 +0000 (17:21 +0100)]
media: vivid: add dynamic array test control

Add a dynamic array test control to help test support for this
feature.

Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Tested-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Reviewed-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: v4l2-ctrls: add support for dynamically allocated arrays.
Hans Verkuil [Fri, 8 Jul 2022 16:21:41 +0000 (17:21 +0100)]
media: v4l2-ctrls: add support for dynamically allocated arrays.

Implement support for dynamically allocated arrays.

Most of the changes concern keeping track of the number of elements
of the array and the number of elements allocated for the array and
reallocating memory if needed.

Acked-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Tested-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: videodev2.h: add V4L2_CTRL_FLAG_DYNAMIC_ARRAY
Hans Verkuil [Fri, 8 Jul 2022 16:21:40 +0000 (17:21 +0100)]
media: videodev2.h: add V4L2_CTRL_FLAG_DYNAMIC_ARRAY

Add a new flag that indicates that this control is a dynamically sized
array. Also document this flag.

Currently dynamically sized arrays are limited to one dimensional arrays,
but that might change in the future if there is a need for it.

The initial use-case of dynamic arrays are stateless codecs. A frame
can be divided in many slices, so you want to provide an array containing
slice information for each slice. Typically the number of slices is small,
but the standard allow for hundreds or thousands of slices. Dynamic arrays
are a good solution since sizing the array for the worst case would waste
substantial amounts of memory.

Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Tested-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Reviewed-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: venus: set ubwc configuration on specific video hardware
Vikash Garodia [Wed, 13 Jul 2022 11:59:36 +0000 (12:59 +0100)]
media: venus: set ubwc configuration on specific video hardware

UBWC configuration parameters would vary across video hardware
generations. At the same time, driver is expected to configure these
parameters, without relying on video firmware to use the default
configurations.
Setting the configuration parameters for sc7280.

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: venus_helper_get_bufreq(): req is never NULL
Hans Verkuil [Tue, 12 Jul 2022 10:47:15 +0000 (11:47 +0100)]
media: venus: venus_helper_get_bufreq(): req is never NULL

Fix a smatch error:

drivers/media/platform/qcom/venus/helpers.c: drivers/media/platform/qcom/venus/helpers.c:678 venus_helper_get_bufreq() error: we previously assumed 'req' could be null (see line 674)

After checking how venus_helper_get_bufreq() is called it is clear that
req is never NULL, so just drop the checks.

Signed-off-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: ov5693: add ov5693_of_match, dts support
Tommaso Merciai [Wed, 13 Jul 2022 15:05:06 +0000 (16:05 +0100)]
media: ov5693: add ov5693_of_match, dts support

Add ov5693_of_match. Device tree support

Signed-off-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Daniel Scally <djrscally@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: dt-bindings: ov5693: document YAML binding
Tommaso Merciai [Wed, 13 Jul 2022 15:05:05 +0000 (16:05 +0100)]
media: dt-bindings: ov5693: document YAML binding

Add documentation of device tree in YAML schema for the OV5693
CMOS image sensor from Omnivision

Signed-off-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5693: add support for acpi clock-frequency prop
Tommaso Merciai [Wed, 13 Jul 2022 15:05:04 +0000 (16:05 +0100)]
media: ov5693: add support for acpi clock-frequency prop

Add support for ACPI-based platforms that specify the clock frequency by
using the "clock-frequency" property instead of specifying a clock
provider reference

Signed-off-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
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: ov5693: rename clk into xvclk
Tommaso Merciai [Wed, 13 Jul 2022 15:05:03 +0000 (16:05 +0100)]
media: ov5693: rename clk into xvclk

Rename clk pdata pointer into xvclk (system clock input).
Same for clk_rate into xvclk_rate. This is more explicit

Signed-off-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
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: ov5693: add dvdd into ov5693_supply_names array
Tommaso Merciai [Wed, 13 Jul 2022 15:05:02 +0000 (16:05 +0100)]
media: ov5693: add dvdd into ov5693_supply_names array

Add missing "dvdd" (Digital circuit power) entry into ov5693_supply_names
array

Signed-off-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Daniel Scally <djrscally@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5693: count num_supplies using array_size
Tommaso Merciai [Wed, 13 Jul 2022 15:05:01 +0000 (16:05 +0100)]
media: ov5693: count num_supplies using array_size

Instead of hardcode OV5693_NUM_SUPPLIES in a define is better use
ARRAY_SIZE function to count the number of supplies from
ov5693_supply_names array

Signed-off-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Daniel Scally <djrscally@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: entity: Use dedicated data link iterator
Daniel Scally [Thu, 7 Jul 2022 22:47:33 +0000 (23:47 +0100)]
media: entity: Use dedicated data link iterator

Where iteration over links for an entity is clearly assuming that
all of those links are data links, use the new iterator to guarantee
that assumption is met.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Scally <djrscally@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: entity: Add iterator for entity data links
Daniel Scally [Thu, 7 Jul 2022 22:47:32 +0000 (23:47 +0100)]
media: entity: Add iterator for entity data links

Iterating over the links for an entity is a somewhat common need
through the media subsystem, but generally the assumption is that
they will all be data links. To meet that assumption add a new macro
that iterates through an entity's links and skips non-data links.

Signed-off-by: Daniel Scally <djrscally@gmail.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: mt9p031: Implement crop bounds get selection
Marek Vasut [Sun, 19 Jun 2022 00:31:58 +0000 (01:31 +0100)]
media: mt9p031: Implement crop bounds get selection

Implement V4L2_SEL_TGT_CROP_BOUNDS query in get_selection subdev op
for this sensor. This is required e.g. to bind it to STM32MP15x DCMI.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Stefan Riedmueller <s.riedmueller@phytec.de>
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: stm32: dcmi: Fix subdev op call with uninitialized state
Tomi Valkeinen [Fri, 1 Jul 2022 13:15:59 +0000 (14:15 +0100)]
media: stm32: dcmi: Fix subdev op call with uninitialized state

stm32-dcmi calls its source subdev with v4l2_subdev_call() using a
v4l2_subdev_state constructed on stack. This means that init_cfg is
never called for that state, and a source subdev that depends on the
init_cfg call may break.

A new macro has been added for this particular purpose, which properly
initializes the state, so let's use v4l2_subdev_call_state_try() here.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Tested-by: Marek Vasut <marex@denx.de>
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_call_state_try() macro
Tomi Valkeinen [Fri, 1 Jul 2022 13:15:58 +0000 (14:15 +0100)]
media: subdev: Add v4l2_subdev_call_state_try() macro

Add a helper macro for the situations where a non-MC driver needs to
call a state-operation (operation which takes a subdev state as a
parameter) in try-context in another subdev.

The macro allocates a new subdev state for the called subdev and frees
the state afterwards.

An example use case is a media platform driver testing if a
v4l2_subdev_format would be accepted by a source subdev.

This should not be used in MC drivers.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Tested-by: Marek Vasut <marex@denx.de>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ar0521: fix Kconfig: VIDEO_V4L2 -> VIDEO_DEV
Hans Verkuil [Fri, 8 Jul 2022 18:47:04 +0000 (19:47 +0100)]
media: ar0521: fix Kconfig: VIDEO_V4L2 -> VIDEO_DEV

VIDEO_V4L2 no longer exists, instead use VIDEO_DEV. Without this change
this driver cannot be selected.

Signed-off-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: Replace dependency on VIDEO_V4L2_SUBDEV_API with select
Laurent Pinchart [Sat, 18 Jun 2022 18:54:19 +0000 (19:54 +0100)]
media: Replace dependency on VIDEO_V4L2_SUBDEV_API with select

The VIDEO_V4L2_SUBDEV_API Kconfig symbol is mostly selected
automatically, with a a handful of drivers still using it as a
dependency. Fix them to use selection, and drop the symbol title text to
not expose it for manual selection.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov7251: add missing disable functions on error in ov7251_set_power_on()
Yang Yingliang [Wed, 22 Jun 2022 04:42:43 +0000 (05:42 +0100)]
media: ov7251: add missing disable functions on error in ov7251_set_power_on()

Add the missing gpiod_set_value_cansleep() and clk_disable_unprepare()
before return from ov7251_set_power_on() in the error handling case.

Fixes: 9e1d3012cc10 ("media: i2c: Remove .s_power() from ov7251")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: sunxi: Depend on GENERIC_PHY_MIPI_DPHY
Sakari Ailus [Wed, 13 Jul 2022 15:18:08 +0000 (16:18 +0100)]
media: sunxi: Depend on GENERIC_PHY_MIPI_DPHY

The sun6i-mipi-csi2 and sun6i-a83t-mipi-csi2 drivers depend on the generic
MIPI D-PHY support. Select it. This fixes a linking problem when either of
these drivers is enabled and GENERIC_PHY_MIPI_DPHY is disabled.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: v4l2: Sanitize colorspace values in the framework
Laurent Pinchart [Thu, 17 Mar 2022 12:37:12 +0000 (12:37 +0000)]
media: v4l2: Sanitize colorspace values in the framework

Extend the format sanitization code in the framework to handle invalid
values for the colorspace-related fields.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: v4l2: Make colorspace validity checks more future-proof
Laurent Pinchart [Thu, 17 Mar 2022 12:37:12 +0000 (12:37 +0000)]
media: v4l2: Make colorspace validity checks more future-proof

The helper functions that test validity of colorspace-related fields
use the last value of the corresponding enums. This isn't very
future-proof, as there's a high chance someone adding a new value may
forget to update the helpers. Add new "LAST" entries to the enumerations
to improve this, and keep them private to the kernel.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: vivid: Add support for the new YUVA and YUVX formats
Laurent Pinchart [Mon, 7 Mar 2022 17:01:38 +0000 (17:01 +0000)]
media: vivid: Add support for the new YUVA and YUVX formats

Extend vivid to support the newly added YUVA and YUVX pixel formats
through the TPG.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: v4l2-tpg: Add support for the new YUVA and YUVX formats
Laurent Pinchart [Mon, 7 Mar 2022 16:33:44 +0000 (16:33 +0000)]
media: v4l2-tpg: Add support for the new YUVA and YUVX formats

Extend the TPG to support generating the newly added YUVA and YUVX pixel
formats.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: v4l: Add packed YUV 4:4:4 YUVA and YUVX pixel formats
Laurent Pinchart [Mon, 7 Mar 2022 16:32:00 +0000 (16:32 +0000)]
media: v4l: Add packed YUV 4:4:4 YUVA and YUVX pixel formats

The new YUVA and YUVX are permutations of the existing AYUV and XYUV
formats. They are use by the NXP i.MX8 ISI hardware.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek: vcodec: Make encoder capability fields fit requirements
Chen-Yu Tsai [Fri, 8 Jul 2022 10:44:51 +0000 (11:44 +0100)]
media: mediatek: vcodec: Make encoder capability fields fit requirements

This partially reverts commit fd9f8050e355d7fd1e126cd207b06c96cde7f783,
and changes things so that the capability string fields of the encoder
conform to their requirements.

The driver name field should contain the actual driver name, not some
otherwise unused string macro from the driver. To make this clear,
copy the name from the driver's name field.

The card name for the video encoder previously held a static platform
name that was fixed to match MT8173. This obviously doesn't make sense
for newer chips. Since commit fd9f8050e355 ("media: mediatek: vcodec:
Change encoder v4l2 capability value"), this field was changed to hold
the driver's name, or "mtk-vcodec-dec". This doesn't make much sense
either, since this still doesn't reflect what chip this is.

Instead, fill in the card name with "MTxxxx video encoder" with the
proper chip number.

Since commit f2d8b6917f3b ("media: v4l: ioctl: Set bus_info in
v4l_querycap()"), the V4L2 core provides a default value for the
bus_info field for platform and PCI devices. This value will match
the default value for media devices added by commit cef699749f37
("media: mc: Set bus_info in media_device_init()"). These defaults
are stable and device-specific.

Drop the custom capability bus_info from the mtk-vcodec encoder
driver, and use the defaults.

As this patch removes the last usage of MTK_VCODEC_DRV_NAME, remove
the macro as well.

Fixes: fd9f8050e355 ("media: mediatek: vcodec: Change encoder v4l2 capability value")
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek: vcodec: Make decoder capability fields fit requirements
Chen-Yu Tsai [Fri, 8 Jul 2022 10:44:50 +0000 (11:44 +0100)]
media: mediatek: vcodec: Make decoder capability fields fit requirements

This partially reverts commit a8a7a278c56ad3b4ddd4db9a960e0537d032b0b3,
and changes things so that the capability string fields of the decoder
conform to their requirements.

This recent change caused ChromeOS's decoder to no longer function. This
is due to ChromeOS using the driver name field to match the video device
with its accompanying media device. After the change, they no longer
matched.

The driver name field should contain the actual driver name, not some
otherwise unused string macro from the driver. To make this clear,
copy the name from the driver's name field.

The card name for the video decoder previously held a static platform
name that was fixed to match MT8173. This obviously doesn't make sense
for newer chips. Since commit a8a7a278c56a ("media: mediatek: vcodec:
Change decoder v4l2 capability value"), this field was changed to hold
the driver's name, or "mtk-vcodec-dec". This doesn't make much sense
either, since this still doesn't reflect what chip this is.

Instead, fill in the card name with "MTxxxx video decoder" with the
proper chip number.

Since commit f2d8b6917f3b ("media: v4l: ioctl: Set bus_info in
v4l_querycap()"), the V4L2 core provides a default value for the
bus_info field for platform and PCI devices. This value will match
the default value for media devices added by commit cef699749f37
("media: mc: Set bus_info in media_device_init()"). These defaults
are stable and device-specific.

Drop the custom capability bus_info from the mtk-vcodec decoder
driver, and use the defaults. This also fixes the long standing
issue where the media device used for the stateless decoder didn't
have its bus_info set, and would never match its accompanying video
device.

Fixes: a8a7a278c56a ("media: mediatek: vcodec: Change decoder v4l2 capability value")
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: lirc: ensure lirc device receives repeats
Marko Mäkelä [Fri, 8 Jul 2022 08:44:59 +0000 (09:44 +0100)]
media: lirc: ensure lirc device receives repeats

Pressing a button on a remote control unit will typically lead to
messages being sent several times per second until the button is released.

Some remote control units indicate long key presses by sending
special "repeat" messages, for which the protocol driver calls
rc_repeat(). Other units repeat the same message over and over,
which will be handled by calling rc_keydown().

The function rc_keydown() never set the LIRC "repeat" flag to distinguish
repeated messages that were sent due to a long keypress, and messages
sent due to repeated short keypresses. While a user-space program may
implement special logic to distinguish long keypresses, it is much simpler
to be able to rely on the flag.

Commit de142c32410649e64d44928505ffad2176a96a9e ("media: lirc: implement
reading scancode") would never set the LIRC_SCANCODE_FLAG_REPEAT flag.
Commit b66218fddfd29f315a103db811152ab0c95fb054
("media: lirc: ensure lirc device receives nec repeats") fixed it up for
rc_repeat() but not rc_keydown().

Signed-off-by: Marko Mäkelä <marko.makela@iki.fi>
Co-developed-by: Sean Young <sean@mess.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ati-remote: remove private err() macro
Oliver Neukum [Wed, 6 Jul 2022 07:44:59 +0000 (08:44 +0100)]
media: ati-remote: remove private err() macro

Drivers should use dev_err()

Signed-off-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: igorplugusb: use correct size pass to igorplugusb_probe()
Yang Yingliang [Tue, 28 Jun 2022 06:54:53 +0000 (07:54 +0100)]
media: igorplugusb: use correct size pass to igorplugusb_probe()

After 'buf_in' change to pointer, the sizeof() is not correct buffer
size, it should be MAX_PACKET.

Fixes: b3f820b905c9 ("media: igorplugusb: respect DMA coherency")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: vimc: documentation for lens
Yunke Cao [Wed, 29 Jun 2022 02:06:30 +0000 (03:06 +0100)]
media: vimc: documentation for lens

Add documentation for vimc-lens.
Add a lens into the vimc topology graph.

Signed-off-by: Yunke Cao <yunkec@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: vimc: use data link entities enum to index the ent_config array
Daniel Oakley [Thu, 16 Jun 2022 10:07:47 +0000 (11:07 +0100)]
media: vimc: use data link entities enum to index the ent_config array

Future additions to the ent_config[] could break the association between
the index of the struct vimc_ent_config entries in the ent_config[] array,
and the index defined by the enum proposed in the previous patch. Using
designated initializers solves this by linking the 2 together clearly in
code and prevents the array not reflecting the enum. There is no
functional change intended.

Suggested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Daniel Oakley <daniel.oakley@ideasonboard.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: vimc: enumerate data link entities for clarity
Daniel Oakley [Thu, 16 Jun 2022 10:07:46 +0000 (11:07 +0100)]
media: vimc: enumerate data link entities for clarity

The data_links array was hard to read and understand. By implementing
enumerated vimc data link entities, clarity has been improved when
defining data_links. This therefore should help new programmers to
understand the codebase better. There is no functional change intended.

Suggested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Daniel Oakley <daniel.oakley@ideasonboard.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: vimc: expand the names of vimc entity types
Daniel Oakley [Thu, 16 Jun 2022 10:07:45 +0000 (11:07 +0100)]
media: vimc: expand the names of vimc entity types

When introducing the lens controller, it became apparent that the vimc
entity type names were hard to understand, e.g. vimc_len_type refers to the
lens. The names of the vimc entity types have been expanded to make the
code easier to understand. There is no functional change intended.

Suggested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Daniel Oakley <daniel.oakley@ideasonboard.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: vimc: add ancillary lens
Yunke Cao [Tue, 28 Jun 2022 00:53:52 +0000 (01:53 +0100)]
media: vimc: add ancillary lens

Add lens to vimc driver and link them with sensors using ancillary links.
Provides an example of ancillary link usage.The lens supports
FOCUS_ABSOLUTE control.

Test example: With default vimc topology
> media-ctl -p
Media controller API version 5.18.0
...
- entity 28: Lens A (0 pad, 0 link)
             type V4L2 subdev subtype Lens flags 0
             device node name /dev/v4l-subdev6
- entity 29: Lens B (0 pad, 0 link)
             type V4L2 subdev subtype Lens flags 0
             device node name /dev/v4l-subdev7
> v4l2-ctl -d /dev/v4l-subdev7 -C focus_absolute
focus_absolute: 0

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Yunke Cao <yunkec@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: v4l: async: Also match secondary fwnode endpoints
Sakari Ailus [Tue, 5 Jul 2022 17:40:54 +0000 (18:40 +0100)]
media: v4l: async: Also match secondary fwnode endpoints

For camera sensor devices the firmware information of which comes from
non-DT (or some ACPI variants), the kernel makes the information visible
to the drivers in a form similar to DT. This takes place through device's
secondary fwnodes, in which case also the secondary fwnode needs to be
heterogenously (endpoint vs. device) matched.

Fixes: 1f391df44607 ("media: v4l2-async: Use endpoints in __v4l2_async_nf_add_fwnode_remote()")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: amphion: only insert the first sequence startcode for vc1l format
Ming Qian [Fri, 8 Jul 2022 08:56:50 +0000 (09:56 +0100)]
media: amphion: only insert the first sequence startcode for vc1l format

For format V4L2_PIX_FMT_VC1_ANNEX_L,
the amphion vpu requires driver to help insert some custom startcode
before sequence and frame.
but only the first sequence startcode is needed,
the extra startcode will cause decoding error.
So after seek, we don't need to insert the sequence startcode.

In other words, for V4L2_PIX_FMT_VC1_ANNEX_L,
the vpu doesn't support dynamic resolution change.

Fixes: 145e936380edb ("media: amphion: implement malone decoder rpc interface")
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: amphion: sync buffer status with firmware during abort
Ming Qian [Fri, 1 Jul 2022 05:50:04 +0000 (06:50 +0100)]
media: amphion: sync buffer status with firmware during abort

1. prevent to allocate buffer to firmware during abort
2. release buffer when clear the slots

Fixes: 6de8d628df6ef ("media: amphion: add v4l2 m2m vpu decoder stateful driver")
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: hantro: Fix RK3399 H.264 format advertising
Ezequiel Garcia [Wed, 29 Jun 2022 19:56:23 +0000 (20:56 +0100)]
media: hantro: Fix RK3399 H.264 format advertising

Commit 1f82f2df523cb ("media: hantro: Enable H.264 on Rockchip VDPU2")
enabled H.264 on some SoCs with VDPU2 cores. This had the side-effect
of exposing H.264 coded format as supported on RK3399.

Fix this and clarify how the codec is explicitly disabled on RK3399 on
this driver.

Fixes: 1f82f2df523cb ("media: hantro: Enable H.264 on Rockchip VDPU2")
Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Tested-by: Nicolas Dufresne <nicolas.dufresne@collabora.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: docs: Remove extraneous \endgroup from P010 table
Akira Yokosawa [Wed, 29 Jun 2022 13:01:17 +0000 (14:01 +0100)]
media: docs: Remove extraneous \endgroup from P010 table

The \endgroup command at the bottom of a table added in commit
5374d8fb75f3 ("media: Add P010 video format") doesn't have a
corresponding \begingroup command preceding it.

This imbalance causes an build error in "make pdfdocs".

Fix the issue by removing it.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Fixes: 5374d8fb75f3 ("media: Add P010 video format")
Cc: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Cc: 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: dt-bindings: media: samsung,s5pv210-jpeg: convert to dtschema
Krzysztof Kozlowski [Wed, 29 Jun 2022 12:08:03 +0000 (13:08 +0100)]
media: dt-bindings: media: samsung,s5pv210-jpeg: convert to dtschema

Convert the Samsung SoC JPEG codec bindings to DT schema.

The original bindings were quite old and incomplete, so change during
conversion:
1. Add typical (already used) properties like iommus and power domains.
2. Document samsung,exynos4212-jpeg compatible (already used in DTS and
   driver).
3. List clocks per each variant.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@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: amphion: defer setting last_buffer_dequeued until resolution changes are processed
Ming Qian [Tue, 28 Jun 2022 05:21:12 +0000 (06:21 +0100)]
media: amphion: defer setting last_buffer_dequeued until resolution changes are processed

Don't set last_buffer_dequeued during dynamic resolution change,
otherwise it may be cleared in handling resolution change,
as streamoff may be called in dynamic resolution change.

Normally, this does not happen.
But we encounter a special testcase,
User issue V4L2_DEC_CMD_STOP after enqueue one buffer
that only contains codec config header, but not any frame data.
So VPU report the parsed resolution, then report the eos event.

So driver should notify user to handle resolution change first,
after it's handled, set the last_buffer_dequeued.
then the user can exit decoding normally.

Otherwise the user may be stalled.

Fixes: 6de8d628df6ef ("media: amphion: add v4l2 m2m vpu decoder stateful driver")
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: mediatek: vcodec: Initialize decoder parameters for each instance
Chen-Yu Tsai [Mon, 4 Jul 2022 08:49:30 +0000 (09:49 +0100)]
media: mediatek: vcodec: Initialize decoder parameters for each instance

The decoder parameters are stored in each instance's context data. This
needs to be initialized per-instance, but a previous fix incorrectly
changed it to only be initialized for the first opened instance. This
resulted in subsequent instances not correctly signaling the requirement
for the Requests API.

Fix this by calling the initializing function outside of the
v4l2_fh_is_singular() conditional block.

Fixes: faddaa735c20 ("media: mediatek: vcodec: Initialize decoder parameters after getting dec_capability")
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek: vcodec: decoder: Embed framesize inside mtk_video_fmt
Chen-Yu Tsai [Wed, 6 Jul 2022 08:21:38 +0000 (09:21 +0100)]
media: mediatek: vcodec: decoder: Embed framesize inside mtk_video_fmt

Right now the decoder maintains two separate lists for supported pixel
formats and frame sizes. Getting the supported frame sizes for the
current set format is a bit convoluted, requiring a search through
the separate frame size list. The frame sizes are used to clamp and
align requested resolutions.

Instead, the frame size structure could be embedded inside the pixel
format structure. Getting one also gets the other. And since the
the driver already keeps pointers to the current set format, getting
the frame sizes becomes straightforward.

Do just that. Move v4l2_frmsize_stepwise inside mtk_video_fmt, and get
rid of mtk_codec_framesizes.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Tested-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: mediatek: vcodec: decoder: Drop max_{width,height} from mtk_vcodec_ctx
Chen-Yu Tsai [Wed, 6 Jul 2022 08:21:37 +0000 (09:21 +0100)]
media: mediatek: vcodec: decoder: Drop max_{width,height} from mtk_vcodec_ctx

This partially reverts commit b018be06f3c7 ("media: mediatek: vcodec:
Read max resolution from dec_capability").

After the previous patches:

  - media: mediatek: vcodec: decoder: Fix 4K frame size enumeration
  - media: mediatek: vcodec: decoder: Skip alignment for default resolution
  - media: mediatek: vcodec: decoder: Fix resolution clamping in TRY_FMT

the max_{width,height} fields in |struct mtk_vcodec_ctx| no longer have
any real users. Remove them.

Fixes: b018be06f3c7 ("media: mediatek: vcodec: Read max resolution from dec_capability")
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Tested-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: mediatek: vcodec: decoder: Fix resolution clamping in TRY_FMT
Chen-Yu Tsai [Wed, 6 Jul 2022 08:21:36 +0000 (09:21 +0100)]
media: mediatek: vcodec: decoder: Fix resolution clamping in TRY_FMT

In commit b018be06f3c7 ("media: mediatek: vcodec: Read max resolution
from dec_capability"), TRY_FMT clamps the resolution to the maximum
that was previously set either by default 1080p or the limit set by a
previous S_FMT call. This does not make sense when doing TRY_FMT for
the output side, which may have different capabilities.

Instead, for the output side, find the maximum resolution based on the
pixel format requested. For the capture side, find the maximum
resolution based on the currently set output format.

The maximum resolution is found from the list of per-format frame
sizes, so the patch "media: mediatek: vcodec: dec: Fix 4K frame size
enumeration" is needed.

Fixes: b018be06f3c7 ("media: mediatek: vcodec: Read max resolution from dec_capability")
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Tested-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: mediatek: vcodec: decoder: Skip alignment for default resolution
Chen-Yu Tsai [Wed, 6 Jul 2022 08:21:35 +0000 (09:21 +0100)]
media: mediatek: vcodec: decoder: Skip alignment for default resolution

The default resolution of 64x64 is already aligned, according to the
call to v4l_bound_align_image() in mtk_vcodec_dec_set_default_params().

Drop the redundant v4l_bound_align_image() call. This also removes one
usage of ctx->max_{width,height}.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Tested-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: mediatek: vcodec: decoder: Fix 4K frame size enumeration
Chen-Yu Tsai [Wed, 6 Jul 2022 08:21:34 +0000 (09:21 +0100)]
media: mediatek: vcodec: decoder: Fix 4K frame size enumeration

This partially reverts commit b018be06f3c7 ("media: mediatek: vcodec:
Read max resolution from dec_capability"). In this commit, the maximum
resolution ended up being a function of both the firmware capability and
the current set format.

However, frame size enumeration for output (coded) formats should not
depend on the format set, but should return supported resolutions for
the format requested by userspace.

Fix this so that the driver returns the supported resolutions correctly,
even if the instance only has default settings, or if the output format
is currently set to VP8F, which does not support 4K.

This adds an copy of special casing for !VP8 and 4K support. The other
existing copy will be removed when .max_{width,height} are removed from
|struct mtk_vcodec_ctx| in a subsequent patch.

Fixes: b018be06f3c7 ("media: mediatek: vcodec: Read max resolution from dec_capability")
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Tested-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: mediatek: vcodec: decoder: Const-ify stepwise_fhd
Chen-Yu Tsai [Wed, 6 Jul 2022 08:21:33 +0000 (09:21 +0100)]
media: mediatek: vcodec: decoder: Const-ify stepwise_fhd

stepwise_fhd is the reference framesize variable, and should not be
altered. Make it constant.

Fixes: ("76250b48de79 media: mediatek: vcodec: Getting supported decoder format types")
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Tested-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: staging: media: imx: imx7-media-csi: Drop usage of shared helpers
Laurent Pinchart [Tue, 10 May 2022 02:06:45 +0000 (03:06 +0100)]
media: staging: media: imx: imx7-media-csi: Drop usage of shared helpers

None of the shared helpers are used anymore. Make this official by
dropping inclusion of imx-media.h.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Drop V4L2 events support
Laurent Pinchart [Tue, 10 May 2022 02:06:45 +0000 (03:06 +0100)]
media: staging: media: imx: imx7-media-csi: Drop V4L2 events support

The only event that the driver allows subscribing to,
V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR, is never generated. Drop events
support.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Inline imx7_csi_enum_pixel_formats()
Laurent Pinchart [Tue, 10 May 2022 09:47:34 +0000 (10:47 +0100)]
media: staging: media: imx: imx7-media-csi: Inline imx7_csi_enum_pixel_formats()

Inline the imx7_csi_enum_pixel_formats() function in its only caller.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Drop unneeded pixel format validation
Laurent Pinchart [Tue, 10 May 2022 09:47:34 +0000 (10:47 +0100)]
media: staging: media: imx: imx7-media-csi: Drop unneeded pixel format validation

The driver won't accept unsupported pixel formats, there's thus no need
to validate it in imx7_csi_pad_link_validate().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Add V4L2_PIX_FMT_Y14 support
Laurent Pinchart [Tue, 10 May 2022 09:47:34 +0000 (10:47 +0100)]
media: staging: media: imx: imx7-media-csi: Add V4L2_PIX_FMT_Y14 support

The device supports 14-bit greyscale formats the same way it supports
14-bit Bayer formats.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Fix list of supported formats
Laurent Pinchart [Tue, 10 May 2022 09:47:34 +0000 (10:47 +0100)]
media: staging: media: imx: imx7-media-csi: Fix list of supported formats

The list of supported formats comes from helpers shared with the i.MX6
IPUv3 and is incorrect in multiple regards:

- 10-, 12- and 14-bit Bayer formats are stored in memory as SBGGR10,
  SBGGR12 and SBGGR14 respectively (plus components permutations), not
  SBGGR16. Same thing for greyscale formats.
- 16-bit RAW formats are not supported by the hardware.

Fix the supported formats table.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Simplify default format in try_fmt
Laurent Pinchart [Tue, 10 May 2022 09:47:34 +0000 (10:47 +0100)]
media: staging: media: imx: imx7-media-csi: Simplify default format in try_fmt

When trying a format on the video node, if the requested pixel format
isn't supported, fallback to the default with a simpler logic.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Inline imx7_csi_init_mbus_fmt()
Laurent Pinchart [Tue, 10 May 2022 02:06:45 +0000 (03:06 +0100)]
media: staging: media: imx: imx7-media-csi: Inline imx7_csi_init_mbus_fmt()

Inline the imx7_csi_init_mbus_fmt() function in its only caller. This
allows simplifying the code.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Drop unneeded imx7_csi_pixfmt fields
Laurent Pinchart [Tue, 10 May 2022 02:06:45 +0000 (03:06 +0100)]
media: staging: media: imx: imx7-media-csi: Drop unneeded imx7_csi_pixfmt fields

The imx7_csi_pixfmt cycles field is never used nor set, the bayer field
is never used, and the planar field is never set. Drop them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Drop YUV/RGB/BAYER format selectors
Laurent Pinchart [Tue, 10 May 2022 02:06:45 +0000 (03:06 +0100)]
media: staging: media: imx: imx7-media-csi: Drop YUV/RGB/BAYER format selectors

All the format lookup functions are called with a ANY selector, drop
selector support.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Simplify default mbus code in try_fmt
Laurent Pinchart [Tue, 10 May 2022 02:06:45 +0000 (03:06 +0100)]
media: staging: media: imx: imx7-media-csi: Simplify default mbus code in try_fmt

When trying a format on the subdev sink pad, if the requested media bus
code isn't supported, fallback to the default with a simpler logic.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Define macro for default mbus code
Laurent Pinchart [Tue, 10 May 2022 02:06:45 +0000 (03:06 +0100)]
media: staging: media: imx: imx7-media-csi: Define macro for default mbus code

Define a macro for the default media bus code and use it through the
driver to replace a hardcoded value and a dynamic query from the
pixel_formats table.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Make default formats consistent
Laurent Pinchart [Tue, 10 May 2022 02:06:45 +0000 (03:06 +0100)]
media: staging: media: imx: imx7-media-csi: Make default formats consistent

Use the same default image width and height for both the CSI subdev and
the video node to achieve a consistent default through the driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Drop unsupported YUV and RGB formats
Laurent Pinchart [Tue, 10 May 2022 02:06:45 +0000 (03:06 +0100)]
media: staging: media: imx: imx7-media-csi: Drop unsupported YUV and RGB formats

A large number of formats defined in the pixel_formats array are not
supported, as shown by the switch-case check in
imx7_csi_pad_link_validate(). Drop them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Drop IPU-only formats
Laurent Pinchart [Tue, 10 May 2022 02:06:45 +0000 (03:06 +0100)]
media: staging: media: imx: imx7-media-csi: Drop IPU-only formats

The formats specific to the IPUv3 are not supported by the CSI bridge.
Drop them, along with the related code.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>