platform/kernel/linux-rpi.git
2 years agomedia: atomisp: asc.acc.pipeline is always NULL
Hans de Goede [Wed, 15 Jun 2022 20:50:18 +0000 (21:50 +0100)]
media: atomisp: asc.acc.pipeline is always NULL

With the removal of the ACC ioctls and atomisp_acc.c asc.acc.pipeline
never gets set, so it is always NULL.

Remove asc.acc.pipeline and drop checks for it being NULL / !NULL.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-22-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: remove unused atomisp_*css_* functions
Hans de Goede [Wed, 15 Jun 2022 20:50:17 +0000 (21:50 +0100)]
media: atomisp: remove unused atomisp_*css_* functions

With the removal of the ACC ioctls and atomisp_acc.c a whole bunch
of atomisp_*css_* functions is no longer used, remove them.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-21-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: remove atomisp_acc.c
Hans de Goede [Wed, 15 Jun 2022 20:50:16 +0000 (21:50 +0100)]
media: atomisp: remove atomisp_acc.c

With the ACC ioctls removed sd->acc.fw is always empty turning
the atomisp_acc.c code into no-ops, remove it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-20-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: remove private acceleration ioctls
Hans de Goede [Wed, 15 Jun 2022 20:50:15 +0000 (21:50 +0100)]
media: atomisp: remove private acceleration ioctls

These ioctls allow userspace to load custom programs into the ISP, which:

a) Seems dangerous
b) Cannot be used by opensource userspace since there is no FOSS code to
   create such programs
b) These seem to be unused even by the Android closed source camera code
   (they don't show up in a strace of the camera app)

So removing these seems be a good idea. Another reason to remove these is
that atomisp_acc_map() is the only user of the userptr functionality in
hmm_alloc(), so it gets in the way of further cleanups / simplification
of the hmm code.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-19-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: remove bogus comment above hmm_bo_allocated() prototype
Hans de Goede [Wed, 15 Jun 2022 20:50:14 +0000 (21:50 +0100)]
media: atomisp: remove bogus comment above hmm_bo_allocated() prototype

The comment documenting hmm_bo_allocated() was copied (and not modified)
from the comment documenting hmm_bo_alloc(), so there are 2 copies
of the hmm_bo_alloc() documentation.

Remove the copy of the comment above the hmm_bo_allocated() prototype.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-18-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: removed unused hmm_bo_get_page_info() function
Hans de Goede [Wed, 15 Jun 2022 20:50:13 +0000 (21:50 +0100)]
media: atomisp: removed unused hmm_bo_get_page_info() function

hmm_bo_get_page_info() is not used anywhere, remove it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-17-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: drop hmm_page_type
Hans de Goede [Wed, 15 Jun 2022 20:50:12 +0000 (21:50 +0100)]
media: atomisp: drop hmm_page_type

Since the hmm-pool code has been removed this now always gets set
to HMM_PAGE_TYPE_GENERAL, so just remove it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-16-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: remove unused attribute argument from ia_css_frame_map()
Hans de Goede [Wed, 15 Jun 2022 20:50:11 +0000 (21:50 +0100)]
media: atomisp: remove unused attribute argument from ia_css_frame_map()

ia_css_frame_map() has only one caller which passes a hardcoded 0
for the attribute argument, drop it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-15-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: remove pool related kernel cmdline options
Hans de Goede [Wed, 15 Jun 2022 20:50:10 +0000 (21:50 +0100)]
media: atomisp: remove pool related kernel cmdline options

Since we have removed the hmm pools these are completely meaningless now.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-14-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: remove hmm_mem_stats
Hans de Goede [Wed, 15 Jun 2022 20:50:09 +0000 (21:50 +0100)]
media: atomisp: remove hmm_mem_stats

Without pool support the (optional) debug logging done by these is
not really meaningful, drop it all.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-13-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: remove hmm pool code
Hans de Goede [Wed, 15 Jun 2022 20:50:08 +0000 (21:50 +0100)]
media: atomisp: remove hmm pool code

Since we never register any pools, this is all dead code,
remove it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-12-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: remove dynamic and reserved pool code
Hans de Goede [Wed, 15 Jun 2022 20:50:07 +0000 (21:50 +0100)]
media: atomisp: remove dynamic and reserved pool code

There are no callers of this code atm; and looking at the atomisp
memory-management code if anything we want to make it simpler and
not re-introduce use of these pools, so remove the pool code.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-11-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: remove hmm_pool_[un]register()
Hans de Goede [Wed, 15 Jun 2022 20:50:06 +0000 (21:50 +0100)]
media: atomisp: remove hmm_pool_[un]register()

These are no-ops, so lets remove them.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-10-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: drop ATOMISP_MAP_FLAG_CONTIGUOUS
Hans de Goede [Wed, 15 Jun 2022 20:50:05 +0000 (21:50 +0100)]
media: atomisp: drop ATOMISP_MAP_FLAG_CONTIGUOUS

Drop the ATOMISP_MAP_FLAG_CONTIGUOUS hmm_alloc flag. After the contiguous
flag removal done in previous patches in this series it is never set.

And hmm_alloc already did a WARN_ON on the flag and otherwise ignored it,
proving that contiguous support was already never used.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-9-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: drop contiguous flag from struct ia_css_frame
Hans de Goede [Wed, 15 Jun 2022 20:50:04 +0000 (21:50 +0100)]
media: atomisp: drop contiguous flag from struct ia_css_frame

Drop the contiguous flag from struct ia_css_frame, it is always false /
not used.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-8-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: drop IA_CSS_FRAME_FORMAT_MIPI support from ia_css_frame_init_planes()
Hans de Goede [Wed, 15 Jun 2022 20:50:03 +0000 (21:50 +0100)]
media: atomisp: drop IA_CSS_FRAME_FORMAT_MIPI support from ia_css_frame_init_planes()

Nothing ever sets the format to IA_CSS_FRAME_FORMAT_MIPI and
frame_init_mipi_plane() is the only code-path which ever sets
frame->contiguous to true.

Drop A_CSS_FRAME_FORMAT_MIPI support from ia_css_frame_init_planes()
as part of the removal of contiguous alloc support from the frame code.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-7-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: drop contiguous argument from frame_create()
Hans de Goede [Wed, 15 Jun 2022 20:50:02 +0000 (21:50 +0100)]
media: atomisp: drop contiguous argument from frame_create()

Drop the contiguous argument from frame_create()
all callers always passes false.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-6-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: drop contiguous argument from frame_allocate_with_data()
Hans de Goede [Wed, 15 Jun 2022 20:50:01 +0000 (21:50 +0100)]
media: atomisp: drop contiguous argument from frame_allocate_with_data()

Drop the contiguous argument from frame_allocate_with_data()
its only caller always passes false.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-5-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: drop contiguous argument from ia_css_frame_allocate_with_buffer_size()
Hans de Goede [Wed, 15 Jun 2022 20:50:00 +0000 (21:50 +0100)]
media: atomisp: drop contiguous argument from ia_css_frame_allocate_with_buffer_size()

Drop the contiguous argument from ia_css_frame_allocate_with_buffer_size()
its only caller always passes false.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-4-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: remove unused ia_css_frame_allocate_contiguous*() functions
Hans de Goede [Wed, 15 Jun 2022 20:49:59 +0000 (21:49 +0100)]
media: atomisp: remove unused ia_css_frame_allocate_contiguous*() functions

ia_css_frame_allocate_contiguous() and
ia_css_frame_allocate_contiguous_from_info() are not used anywhere,
remove them.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-3-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: remove the unused RAW_BUF_STRIDE macro
Hans de Goede [Wed, 15 Jun 2022 20:49:58 +0000 (21:49 +0100)]
media: atomisp: remove the unused RAW_BUF_STRIDE macro

I noticed that the RAW_BUF_STRIDE macro is using the removed
SH_CSS_BINARY_ID_POST_ISP define, which should be a problem except that
the RAW_BUF_STRIDE macro itself is not used at all, remove it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-2-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: On Semi AR0521 sensor driver
Krzysztof Hałasa [Tue, 1 Mar 2022 08:41:38 +0000 (08:41 +0000)]
media: On Semi AR0521 sensor driver

The driver has been extensively tested in an i.MX6-based system.
AR0521 is a 5.7 mm x 4.3 mm, 5 MPix RGGB MIPI/HiSPi BSI CMOS sensor
from On Semiconductor.

Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: dt-bindings: Add bindings for On Semi AR0521 camera sensor
Krzysztof Hałasa [Tue, 1 Mar 2022 08:38:04 +0000 (08:38 +0000)]
media: dt-bindings: Add bindings for On Semi AR0521 camera sensor

This patch documents DT bindings for the AR0521 camera sensor driver.

[Sakari Ailus: Reworked subject and commit message a little]

Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Move format mux config in format
Jacopo Mondi [Fri, 13 May 2022 14:14:16 +0000 (15:14 +0100)]
media: ov5640: Move format mux config in format

The image format produced by the sensor is controlled by two registers,
whose values computation is open coded in ov5640_set_framefmt().

As we have a list of formats already, move the OV5640_REG_FORMAT_CONTROL00
and OV5640_REG_ISP_FORMAT_MUX_CTRL register values to the static list
of formats instead of open coding it.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Split DVP and CSI-2 formats
Jacopo Mondi [Fri, 13 May 2022 14:14:15 +0000 (15:14 +0100)]
media: ov5640: Split DVP and CSI-2 formats

The format enumeration list is shared between CSI-2 and DVP modes.
This lead to the enumeration of unsupported format variants in both
modes.

Separate the list of DVP and CSI-2 formats and create helpers to access
the correct one.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Adjust format to bpp in s_fmt
Jacopo Mondi [Fri, 13 May 2022 14:14:14 +0000 (15:14 +0100)]
media: ov5640: Adjust format to bpp in s_fmt

The ov5640 driver supports different sizes for different mbus_codes.
In particular:

- 8bpp modes: high resolution sizes (>= 1280x720)
- 16bpp modes: all sizes
- 24bpp modes: low resolutions sizes (< 1280x720)

Adjust the image sizes according to the above constraints.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Restrict sizes to mbus code
Jacopo Mondi [Fri, 13 May 2022 14:14:13 +0000 (15:14 +0100)]
media: ov5640: Restrict sizes to mbus code

The ov5640 driver supports different sizes for different mbus_codes.
In particular:

- 8bpp modes: high resolution sizes (>= 1280x720)
- 16bpp modes: all sizes
- 24bpp modes: low resolutions sizes (< 1280x720)

Restrict the frame sizes enumerations to the above constraints.

While at it, make sure the fse->mbus_code parameter is valid, and return
-EINVAL if it's not.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Add BGR888 format
Jacopo Mondi [Fri, 13 May 2022 14:14:12 +0000 (15:14 +0100)]
media: ov5640: Add BGR888 format

Add support for BGR888 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 when producing images in RGB24 format.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Add RGB565_1X16 format
Jacopo Mondi [Fri, 13 May 2022 14:14:11 +0000 (15:14 +0100)]
media: ov5640: Add RGB565_1X16 format

The driver already supports the 2X8_[LE|BE] variants of RGB565
formats.

As for CSI-2 the 2X8 variants do not apply, add RGB565_1X16 variant
with little-endian ordering of components as required by the CSI-2
specifications.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Register device properties
Jacopo Mondi [Fri, 13 May 2022 14:14:10 +0000 (15:14 +0100)]
media: ov5640: Register device properties

Parse the device properties and register the rotation and orientation
V4L2 controls using v4l2_ctrl_new_fwnode_properties().

Remove the open-coded parsing of the rotation property and assume the
DTS is correct is providing either <0> or <180> as possible rotations.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Implement get_selection
Jacopo Mondi [Fri, 13 May 2022 14:14:09 +0000 (15:14 +0100)]
media: ov5640: Implement get_selection

Implement the get_selection pad operation for the OV5640 sensor driver.

The supported targets report the sensor's native size, the active pixel
array size and the analog crop rectangle from which the image is
produced.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Implement init_cfg
Jacopo Mondi [Fri, 13 May 2022 14:14:08 +0000 (15:14 +0100)]
media: ov5640: Implement init_cfg

Implement the init_cfg pad operation to initialize the subdev state
format to the default one.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Change CSI-2 timings to comply with FPS
Jacopo Mondi [Fri, 13 May 2022 14:14:07 +0000 (15:14 +0100)]
media: ov5640: Change CSI-2 timings to comply with FPS

Now that the frame duration can be controlled by tuning the VBLANK
duration in CSI-2 mode, fix all modes definitions to comply with the
reported FPS.

All modes run at 30 FPS except for full-resolution mode 2592x1944
which runs at 15FPS.

Tested on a 2 data lanes setup in UYVY and RGB565 modes in CSI-2 mode.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Remove frame rate check from find_mode()
Jacopo Mondi [Fri, 13 May 2022 14:14:06 +0000 (15:14 +0100)]
media: ov5640: Remove frame rate check from find_mode()

The current implementation of ov5640_find_mode() fails if the
frame rate programmed with s_frame_interval doesn't match the
maximum frame rate for the current mode.

This causes issues when moving from one mode with higher FPS to another
one which only supports a lower FPS range with tools like media-ctl.

It also forces users that do not use s_frame_interval(), but rather
configure blankings explicitly, to adjust the programmed FPS range to
avoid failures.

For this reason, remove the FPS check from ov5640_find_mode() and only
perform it at s_frame_interval() time.

Signed-off-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: ov5640: Adjust vblank with s_frame_interval
Hugues Fruchet [Fri, 13 May 2022 14:14:05 +0000 (15:14 +0100)]
media: ov5640: Adjust vblank with s_frame_interval

Adjust the vertical blanking when s_frame_interval is used.

s_frame_interval allows to set a fixed frame rate, which gets stored as
the sensor's current one. When a new mode is applied, the current frame
rate is reset to the mode's default one. In order to correctly report
the currently configured vertical blanking for s_frame_interval users,
verify that the desired frame rate has not been changed. If that's the
case, compute the correct blanking value and reflect it through the
corresponding v4l2 control.

Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
Signed-off-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: ov5640: Add VBLANK control
Jacopo Mondi [Fri, 13 May 2022 14:14:04 +0000 (15:14 +0100)]
media: ov5640: Add VBLANK control

Add the VBLANK control which allows to select the duration of the
frame vertical blankings and allows to control the framerate.

The VBLANK control also modifies the exposure time range, which cannot
exceed the maximum frame length.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Add HBLANK control
Jacopo Mondi [Fri, 13 May 2022 14:14:03 +0000 (15:14 +0100)]
media: ov5640: Add HBLANK control

Add the HBLANK control as read-only.

The hblank value is fixed in the mode definition and is updated
everytime a new format is applied.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Remove ov5640_mode_init_data
Jacopo Mondi [Fri, 13 May 2022 14:14:02 +0000 (15:14 +0100)]
media: ov5640: Remove ov5640_mode_init_data

The ov5640_mode_init_data is a fictional sensor more which is used to
program the initial sensor settings.

It is only used to initialize the sensor and can be replaced
it with a throw-away mode which just wraps the register table.

Also rename the register table to drop the format from the name to make
it clear an actual sensor mode has to be applied after the initial
programming.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Remove duplicated mode settings
Jacopo Mondi [Fri, 13 May 2022 14:14:01 +0000 (15:14 +0100)]
media: ov5640: Remove duplicated mode settings

The register tables for all resolutions smaller than 720p are now
identical.

Remove the duplicated ones and create a single ov5640_setting_low_res[]
register table.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Re-sort per-mode register tables
Jacopo Mondi [Fri, 13 May 2022 14:14:00 +0000 (15:14 +0100)]
media: ov5640: Re-sort per-mode register tables

The per-mode register tables are not sorted by size. Fix it.

Cosmetic change only.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Provide timings accessor
Jacopo Mondi [Fri, 13 May 2022 14:13:59 +0000 (15:13 +0100)]
media: ov5640: Provide timings accessor

Provide a function to shortcut access to the correct timings definition
to avoid repeating the same pattern when accessing the sensor timings.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Split DVP and CSI-2 timings
Jacopo Mondi [Fri, 13 May 2022 14:13:58 +0000 (15:13 +0100)]
media: ov5640: Split DVP and CSI-2 timings

Separate the timings for the DVP mode from the timings for the CSI-2
mode in the ov5640 modes definition.

The CSI-2 timings will deviate from the DVP ones as the clock tree is
calculated differently.

In CSI-2 mode change the analog crop rectangles as the OV5640 pixel
array is composed as:
- vertically: 16 dummy columns, 2592 valid ones and 16 dummy columns for
  a total of 2624 columns
- horizontally: 8 optical black lines, 6 dummy ones, 1944 valid and 6
  dummies for a total of 1964 lines

Adjust the analog crop rectangle in CSI-2 mode to:
- Skip the first 16 dummy columns
- Skip the first 14 black/dummy lines
- Pass the whole valid pixel array size to the ISP for all modes except
  1024x768, 720p and 1080p which are obtained by cropping the valid pixel
  array.

Tested in RGB565, UYVY and RGB888 modes in CSI-2 mode.

Signed-off-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: ov5640: Fix 720x480 in RGB888 mode
Jacopo Mondi [Fri, 13 May 2022 14:13:57 +0000 (15:13 +0100)]
media: ov5640: Fix 720x480 in RGB888 mode

Adjust the left crop of 720x480 to enable capture in RGB888 format,
which is otherwise broken.

The 56 pixels alignment has been copied from the 720x576 mode.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Rework timings programming
Jacopo Mondi [Fri, 13 May 2022 14:13:56 +0000 (15:13 +0100)]
media: ov5640: Rework timings programming

The current definition of a sensor mode defines timings as follows:

- hact, vact: Visible width and height
- htot, vtot: Total sizes including blankings

This makes difficult to clearly separate the visible sizes from the
blankings and to make the vertical blanking programmable.

Rework the sensor modes sizes definition to:
- Report the analog crop sizes
- Report the visible crop size
- Report the total pixels per line as HBLANK is fixed
- Report the VBLANK value to make it programmable

Also modify the ov5640_set_timings() function to program all the
windowing registers are remove them from the per-mode register-value
tables.

Do not change the timing values from the ones reported in the register
tables to maintain bisectability.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Rework CSI-2 clock tree
Jacopo Mondi [Fri, 13 May 2022 14:13:55 +0000 (15:13 +0100)]
media: ov5640: Rework CSI-2 clock tree

Re-work the ov5640_set_mipi_pclk() function to calculate the
PLL configuration using the pixel_rate and link_freq values set at
s_fmt time.

Rework the DVP clock mode settings to calculate the pixel clock
internally and remove the assumption on the 16bpp format.

Tested in MIPI CSI-2 mode with 1 and 2 data lanes with:
- all the sensor supported resolutions in UYVY, RGB565 and MJPEG formats.
- resolutions >= 1280x720 in RAW Bayer format.
- resolutions < 1280x720 in RGB888 format.

[Rework pclk_period and link_freq computation]

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Update pixel_rate and link_freq
Jacopo Mondi [Fri, 13 May 2022 14:13:54 +0000 (15:13 +0100)]
media: ov5640: Update pixel_rate and link_freq

After having set a new format re-calculate the pixel_rate and link_freq
control values and update them when in MIPI mode.

Take into account the limitation of the link frequency having to be
strictly smaller than 1GHz when computing the desired link_freq, and
adjust the resulting pixel_rate acounting for the clock tree
configuration.

[Adjust link_freq calculation]

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Add LINK_FREQ control
Jacopo Mondi [Fri, 13 May 2022 14:13:53 +0000 (15:13 +0100)]
media: ov5640: Add LINK_FREQ control

Add the V4L2_CID_LINK_FREQ control to the ov5640 driver.
Make the control read-only for the moment.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Associate bpp with formats
Jacopo Mondi [Fri, 13 May 2022 14:13:52 +0000 (15:13 +0100)]
media: ov5640: Associate bpp with formats

Associate the bit depth to each format supported by the sensor.

The bpp will be used to calculate the line length.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Add ov5640_is_csi2() function
Jacopo Mondi [Fri, 13 May 2022 14:13:51 +0000 (15:13 +0100)]
media: ov5640: Add ov5640_is_csi2() function

Checking if the sensor is used in DVP or MIPI CSI-2 mode is a repeated
pattern which is about to be repeated more often.

Provide an inline function to shortcut that.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5604: Re-arrange modes definition
Jacopo Mondi [Fri, 13 May 2022 14:13:50 +0000 (15:13 +0100)]
media: ov5604: Re-arrange modes definition

The array of supported modes is close to unreadable.
Re-arrange it giving it some room to breath.

Cosmetic change only.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Add pixel rate to modes
Jacopo Mondi [Fri, 13 May 2022 14:13:49 +0000 (15:13 +0100)]
media: ov5640: Add pixel rate to modes

Add to each mode supported by the sensor the ideal pixel rate, as
defined by Table 2.1 in the chip manual.

The ideal pixel rate will be used to compute the MIPI CSI-2 clock tree.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Adam Ford <aford173@gmail.com> #imx8mm-beacon-kit
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: stm32-dcmi: add support of 1X16 serial pixel formats variant
Hugues Fruchet [Mon, 16 May 2022 09:20:48 +0000 (10:20 +0100)]
media: stm32-dcmi: add support of 1X16 serial pixel formats variant

Add support of 1X16 serial pixel formats in order to support
CSI-2 camera sensor exposing 1x16 pixel formats only.

Signed-off-by: Hugues Fruchet <hugues.fruchet@st.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: st-mipid02: expose 1X16 serial pixel format
Hugues Fruchet [Mon, 16 May 2022 09:19:34 +0000 (10:19 +0100)]
media: st-mipid02: expose 1X16 serial pixel format

Expose RGB & YUV 1X16 serial pixel format variants to comply
with CSI-2 camera sensor pixel formats.

Signed-off-by: Hugues Fruchet <hugues.fruchet@foss.st.com>
Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: st-mipid02: add support for YVYU and VYUY formats
Alain Volmat [Mon, 16 May 2022 09:19:33 +0000 (10:19 +0100)]
media: st-mipid02: add support for YVYU and VYUY formats

Those two formats were missing in the list of supported MBUS
formats.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: st-mipid02: add support of pixel clock polarity
Hugues Fruchet [Mon, 16 May 2022 09:19:32 +0000 (10:19 +0100)]
media: st-mipid02: add support of pixel clock polarity

Add support of pixel clock polarity.

Signed-off-by: Hugues Fruchet <hugues.fruchet@foss.st.com>
Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov7251: Fix multiple problems in s_stream callback
Sakari Ailus [Wed, 18 May 2022 15:52:36 +0000 (16:52 +0100)]
media: ov7251: Fix multiple problems in s_stream callback

The s_stream callback had several issues:

- If pm_runtime_get_sync() fails, the usage_count is not put.

- The sensor wasn't suspended if s_stream(subdev, 1) failed.

Fix this.

Fixes: ("media: i2c: Add pm_runtime support to ov7251")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: sunxi: Add support for the A83T MIPI CSI-2 controller
Paul Kocialkowski [Wed, 25 May 2022 19:03:00 +0000 (20:03 +0100)]
media: sunxi: Add support for the A83T MIPI CSI-2 controller

The A83T supports MIPI CSI-2 with a composite controller, covering
both the protocol logic and the D-PHY implementation. This controller
seems to be found on the A83T only and probably was abandoned since.

This implementation splits the protocol and D-PHY registers and
uses the PHY framework internally. The D-PHY is not registered as a
standalone PHY driver since it cannot be used with any other
controller.

There are a few notable points about the controller:
- The initialisation sequence involes writing specific magic init
  values that do not seem to make any particular sense given the
  concerned register fields;
- Interrupts appear to be hitting regardless of the interrupt mask
  registers, which can cause a serious flood when transmission errors
  occur.

Only 8-bit and 10-bit Bayer formats are currently supported.
While up to 4 internal channels to the CSI controller exist, only one
is currently supported by this implementation.

This work is based on the first version of the driver submitted by
Kévin L'hôpital, which was adapted to mainline from the Allwinner BSP.
This version integrates MIPI CSI-2 support as a standalone V4L2 subdev
instead of merging it in the sun6i-csi driver.

It was tested on a Banana Pi M3 board with an OV8865 sensor in a 4-lane
configuration.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Acked-by: Maxime Ripard <mripard@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: Add Allwinner A83T MIPI CSI-2 bindings documentation
Paul Kocialkowski [Wed, 25 May 2022 19:02:59 +0000 (20:02 +0100)]
media: dt-bindings: media: Add Allwinner A83T MIPI CSI-2 bindings documentation

This introduces YAML bindings documentation for the Allwinner A83T
MIPI CSI-2 controller.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
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: MAINTAINERS: Add entry for the Allwinner A31 MIPI CSI-2 bridge driver
Paul Kocialkowski [Wed, 25 May 2022 19:02:58 +0000 (20:02 +0100)]
media: MAINTAINERS: Add entry for the Allwinner A31 MIPI CSI-2 bridge driver

Add myself as maintainer of the Allwinner A31 MIPI CSI-2 bridge media
driver.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: sunxi: Add support for the A31 MIPI CSI-2 controller
Paul Kocialkowski [Wed, 25 May 2022 19:02:57 +0000 (20:02 +0100)]
media: sunxi: Add support for the A31 MIPI CSI-2 controller

The A31 MIPI CSI-2 controller is a dedicated MIPI CSI-2 bridge
found on Allwinner SoCs such as the A31 and V3/V3s.

It is a standalone block, connected to the CSI controller on one side
and to the MIPI D-PHY block on the other. It has a dedicated address
space, interrupt line and clock.

It is represented as a V4L2 subdev to the CSI controller and takes a
MIPI CSI-2 sensor as its own subdev, all using the fwnode graph and
media controller API.

Only 8-bit and 10-bit Bayer formats are currently supported.
While up to 4 internal channels to the CSI controller exist, only one
is currently supported by this implementation.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Acked-by: Maxime Ripard <mripard@kernel.org>
Reported-by: kernel test robot <lkp@intel.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: Add Allwinner A31 MIPI CSI-2 bindings documentation
Paul Kocialkowski [Wed, 25 May 2022 19:02:56 +0000 (20:02 +0100)]
media: dt-bindings: media: Add Allwinner A31 MIPI CSI-2 bindings documentation

This introduces YAML bindings documentation for the Allwinner A31 MIPI
CSI-2 controller.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Maxime Ripard <mripard@kernel.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: sun6i-a31-csi: Add MIPI CSI-2 input port
Paul Kocialkowski [Wed, 25 May 2022 19:02:55 +0000 (20:02 +0100)]
media: dt-bindings: media: sun6i-a31-csi: Add MIPI CSI-2 input port

The A31 CSI controller supports two distinct input interfaces:
parallel and an external MIPI CSI-2 bridge. The parallel interface
is often connected to a set of hardware pins while the MIPI CSI-2
bridge is an internal FIFO-ish link. As a result, these two inputs
are distinguished as two different ports.

Note that only one of the two may be present on a controller instance.
For example, the V3s has one controller dedicated to MIPI-CSI2 and one
dedicated to parallel.

Update the binding with an explicit ports node that holds two distinct
port nodes: one for parallel input and one for MIPI CSI-2.

This is backward-compatible with the single-port approach that was
previously taken for representing the parallel interface port, which
stays enumerated as fwnode port 0.

Note that additional ports may be added in the future, especially to
support feeding the CSI controller's output to the ISP.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Maxime Ripard <mripard@kernel.org>
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 RK356x encoder
Nicolas Frattaroli [Sun, 12 Jun 2022 15:53:45 +0000 (16:53 +0100)]
media: hantro: Add support for RK356x encoder

The RK3566 and RK3568 SoCs come with a small Hantro instance which is
solely dedicated to encoding. This patch adds the necessary structs to
the Hantro driver to allow the JPEG encoder of it to function.

Through some sleuthing through the vendor's MPP source code and after
closer inspection of the TRM, it was determined that the hardware likely
supports VP8 and H.264 as well.

Tested with the following GStreamer command:

gst-launch-1.0 videotestsrc ! v4l2jpegenc ! matroskamux ! \
               filesink location=foo.mkv

Signed-off-by: Nicolas Frattaroli <frattaroli.nicolas@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-binding: media: Add rk3568-vepu binding
Nicolas Frattaroli [Sun, 12 Jun 2022 15:53:44 +0000 (16:53 +0100)]
media: dt-binding: media: Add rk3568-vepu binding

The RK3568 and RK3566 have a Hantro VPU node solely dedicated to
encoding. This patch adds a new binding to describe it, as it
does not really fit the rockchip-vpu binding, since there is no
decoder.

Signed-off-by: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
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: release core lock before reset vpu core
Ming Qian [Tue, 28 Jun 2022 05:19:52 +0000 (06:19 +0100)]
media: amphion: release core lock before reset vpu core

In reset vpu core, driver will wait for a response event,
but if there are still some events unhandled,
they will be handled first, driver may acquire core lock for that.
So if we do reset in core lock, it may led to reset timeout.

Fixes: 9f599f351e86a ("media: amphion: add vpu core 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: Fix incorrect P010 chroma order description
Sebastian Fricke [Mon, 27 Jun 2022 07:12:23 +0000 (08:12 +0100)]
media: Fix incorrect P010 chroma order description

The chroma order of P010 is `CbCr`,
match with the descriptions in `include/uapi/linux/videodev2.h` and the
documentation.

Fixes: 5374d8fb75f3 ("media: Add P010 video format")
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.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: docs: Fix VIVIOC typo
Marek Vasut [Sun, 26 Jun 2022 16:46:08 +0000 (17:46 +0100)]
media: docs: Fix VIVIOC typo

Replace VIVIOC_ with VIDIOC_ , trivial typo fix.

Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: v4l2-ctrls: Fix missing newline in examples
Marek Vasut [Sun, 26 Jun 2022 14:47:01 +0000 (15:47 +0100)]
media: v4l2-ctrls: Fix missing newline in examples

Replace supportedn with supported\n , i.e. add the missing backslash.

Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: platform: mtk-mdp: Fix mdp_ipi_comm structure alignment
AngeloGioacchino Del Regno [Thu, 23 Jun 2022 13:55:46 +0000 (14:55 +0100)]
media: platform: mtk-mdp: Fix mdp_ipi_comm structure alignment

The mdp_ipi_comm structure defines a command that is either
PROCESS (start processing) or DEINIT (destroy instance); we
are using this one to send PROCESS or DEINIT commands from Linux
to an MDP instance through a VPU write but, while the first wants
us to stay 4-bytes aligned, the VPU instead requires an 8-bytes
data alignment.

Keeping in mind that these commands are executed immediately
after sending them (hence not chained with others before the
VPU/MDP "actually" start executing), it is fine to simply add
a padding of 4 bytes to this structure: this keeps the same
performance as before, as we're still stack-allocating it,
while avoiding hackery inside of mtk-vpu to ensure alignment
bringing a definitely bigger performance impact.

Fixes: c8eb2d7e8202 ("[media] media: Add Mediatek MDP Driver")
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Houlong Wei <houlong.wei@mediatek.com>
Reviewed-by: Irui Wang <irui.wang@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: pvrusb2: drop unexpected word 'a' in comments
Jiang Jian [Thu, 23 Jun 2022 07:42:57 +0000 (08:42 +0100)]
media: pvrusb2: drop unexpected word 'a' in comments

there is an unexpected word 'a' in the comments that need to be dropped

file - drivers/media/usb/pvrusb2/pvrusb2-hdw.c
line - 5044

But now it's a a chicken and egg problem...) */

changed to:

But now it's a chicken and egg problem...) */

Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ti: drop unexpected word 'a' in comments
Jiang Jian [Thu, 23 Jun 2022 07:35:04 +0000 (08:35 +0100)]
media: ti: drop unexpected word 'a' in comments

there is an unexpected word 'a' in the comments that need to be dropped

file - drivers/media/platform/ti/cal/cal-camerarx.c
line - 308

 * DRA80xM TRMs have a a slightly simplified sequence.

changed to:

 * DRA80xM TRMs have a slightly simplified sequence.

Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: gspca: drop unexpected word 'is' in the comments
Jiang Jian [Wed, 22 Jun 2022 17:11:37 +0000 (18:11 +0100)]
media: gspca: drop unexpected word 'is' in the comments

there is an unexpected word 'is' in the comments that need to be dropped

file - drivers/media/usb/gspca/spca501.c
line - 491

* This is is for the 3com HomeConnect Lite which is spca501a based.

changed to:

* This is for the 3com HomeConnect Lite which is spca501a based.

Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: cx18: Fix typo in comments
Jiang Jian [Wed, 22 Jun 2022 14:41:51 +0000 (15:41 +0100)]
media: cx18: Fix typo in comments

Remove the repeated word 'and' from comments

Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: c8sectpfe: Remove unneeded NULL check before clk_disable_unprepare
Wan Jiabing [Mon, 16 May 2022 13:12:54 +0000 (14:12 +0100)]
media: c8sectpfe: Remove unneeded NULL check before clk_disable_unprepare

clk_disable_unprepare() already checks NULL by using IS_ERR_OR_NULL.
Remove unneeded NULL check for fei->c8sectpfeclk.

Link: https://lore.kernel.org/linux-media/20220516131254.13816-1-wanjiabing@vivo.com
Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: c8sectpfe: Clean up handling of *_buffer_aligned
Andy Shevchenko [Wed, 9 Feb 2022 18:25:21 +0000 (18:25 +0000)]
media: c8sectpfe: Clean up handling of *_buffer_aligned

There are a few cases where code is harder than needed to read.
Improve those by:
- dropping unnecessary castings (see note below)
- use PTR_ALING() to be more explicit on what's going on there
- use proper definitions instead of hard coded values

Note, dropping castings will allow to perform an additional check
that type is not changed from void * to something else, e.g. u64,
which may very well break the bitmap APIs.

Link: https://lore.kernel.org/linux-media/20220209182521.55632-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Alain Volmat <alain.volmat@foss.st.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: venus: hfi_platform: Correct supported codecs for sc7280
Vikash Garodia [Mon, 23 May 2022 13:43:41 +0000 (14:43 +0100)]
media: venus: hfi_platform: Correct supported codecs for sc7280

VP8 codec is deprecated for sc7280 SOC. Fix in platform layer to
update the supported codecs accordingly.

Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Acked-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Tested-by: Fritz Koenig<frkoenig@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: venus: Add support for SSR trigger using fault injection
Dikshita Agarwal [Thu, 16 Jun 2022 11:02:02 +0000 (12:02 +0100)]
media: venus: Add support for SSR trigger using fault injection

Here we introduce a new fault injection for SSR trigger.

To trigger the SSR:
 echo 100 >  /sys/kernel/debug/venus/fail_ssr/probability
 echo 1 >  /sys/kernel/debug/venus/fail_ssr/times

Co-developed-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: isl7998x: select V4L2_FWNODE to fix build error
Randy Dunlap [Wed, 30 Mar 2022 01:56:52 +0000 (02:56 +0100)]
media: isl7998x: select V4L2_FWNODE to fix build error

Fix build error when VIDEO_ISL7998X=y and V4L2_FWNODE=m
by selecting V4L2_FWNODE.

microblaze-linux-ld: drivers/media/i2c/isl7998x.o: in function `isl7998x_probe':
(.text+0x8f4): undefined reference to `v4l2_fwnode_endpoint_parse'

Cc: stable@vger.kernel.org # 5.18 and above
Fixes: 51ef2be546e2 ("media: i2c: isl7998x: Add driver for Intersil ISL7998x")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Reported-by: kernel test robot <lkp@intel.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Reviewed-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek: vcodec: Report supported bitrate modes
Hirokazu Honda [Wed, 22 Jun 2022 08:36:24 +0000 (09:36 +0100)]
media: mediatek: vcodec: Report supported bitrate modes

The media driver supports constant bitrate mode only.
The supported rate control mode is reported through querymenu() and
s_ctrl() fails if non constant bitrate mode (e.g. VBR) is requested.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Irui Wang <irui.wang@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: av7110: Remove duplicate 'with' in two places.
Jiang Jian [Tue, 21 Jun 2022 16:30:30 +0000 (17:30 +0100)]
media: av7110: Remove duplicate 'with' in two places.

file: ./drivers/staging/media/av7110/av7110.c
line: 2367
         * reset with with MASK_31 to MC1
changed to
         * reset with MASK_31 to MC1

Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: saa7164: Remove duplicate 'on' in two places.
Jiang Jian [Tue, 21 Jun 2022 15:05:28 +0000 (16:05 +0100)]
media: saa7164: Remove duplicate 'on' in two places.

file: drivers/media/pci/saa7164/saa7164-api.c
line: 804
/* Assumption: Hauppauge eeprom is at 0xa0 on on bus 0 */
changed to
/* Assumption: Hauppauge eeprom is at 0xa0 on bus 0 */

Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek: vcodec: Fix non subdev architecture open power fail
Yunfei Dong [Fri, 17 Jun 2022 07:25:21 +0000 (08:25 +0100)]
media: mediatek: vcodec: Fix non subdev architecture open power fail

According to subdev_bitmap bit value to open hardware power, need to
set subdev_bitmap value for non subdev architecture.

Fixes: c05bada35f01 ("media: mtk-vcodec: Add to support multi hardware decode")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Tested-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: usb: gspca: aligned '*' each line
Jiang Jian [Tue, 21 Jun 2022 06:55:02 +0000 (07:55 +0100)]
media: usb: gspca: aligned '*' each line

Consider "*" alignment in comments

Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: tw686x: Fix memory leak in tw686x_video_init
Miaoqian Lin [Tue, 21 Jun 2022 05:30:30 +0000 (06:30 +0100)]
media: tw686x: Fix memory leak in tw686x_video_init

video_device_alloc() allocates memory for vdev,
when video_register_device() fails, it doesn't release the memory and
leads to memory leak, call video_device_release() to fix this.

Fixes: 704a84ccdbf1 ("[media] media: Support Intersil/Techwell TW686x-based video capture cards")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: driver/nxp/imx-jpeg: fix a unexpected return value problem
Jian Zhang [Mon, 20 Jun 2022 08:34:23 +0000 (09:34 +0100)]
media: driver/nxp/imx-jpeg: fix a unexpected return value problem

In function mxc_jpeg_probe(), when devm_clk_get() fail, the return value
will be unexpected, and it should be the devm_clk_get's error code.

Fixes: 4c2e5156d9fa6 ("media: imx-jpeg: Add pm-runtime support for imx-jpeg")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jian Zhang <zhangjian210@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: MAINTAINERS: add Yunfei Dong as mediatek vcodec driver maintainer
Yunfei Dong [Mon, 20 Jun 2022 07:18:17 +0000 (08:18 +0100)]
media: MAINTAINERS: add Yunfei Dong as mediatek vcodec driver maintainer

I have been working on mediatek driver development for a very long time,
and sent many patches to change the driver architecture. Add myself as
co-maintainer for mediatek vcodec driver.

Signed-off-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: Skip SOURCE_CHANGE & EOS events for stateless
Chen-Yu Tsai [Mon, 20 Jun 2022 06:33:49 +0000 (07:33 +0100)]
media: mediatek: vcodec: Skip SOURCE_CHANGE & EOS events for stateless

The stateless decoder API does not specify the usage of SOURCE_CHANGE
and EOF events. These events are used by stateful decoders to signal
changes in the bitstream. They do not make sense for stateless decoders.

Do not handle subscription for these two types of events for stateless
decoder instances. This fixes the last v4l2-compliance error:

Control ioctls:
fail: v4l2-test-controls.cpp(946): have_source_change || have_eos
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAIL

Fixes: 8cdc3794b2e3 ("media: mtk-vcodec: vdec: support stateless API")
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
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: tw686x: Fix an error handling path in tw686x_probe()
Christophe JAILLET [Mon, 20 Jun 2022 05:31:53 +0000 (06:31 +0100)]
media: tw686x: Fix an error handling path in tw686x_probe()

The commit in Fixes: is incomplete. It has moved some code in the probe but
not all error handling paths have been updated.

Now, if request_irq() fails, we must release some resources.

Fixes: c8946454ed96 ("media: tw686x: Register the irq at the end of probe")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: stm32: dcmi: Drop always NULL sd_state from dcmi_pipeline_s_fmt()
Marek Vasut [Sat, 18 Jun 2022 22:23:54 +0000 (23:23 +0100)]
media: stm32: dcmi: Drop always NULL sd_state from dcmi_pipeline_s_fmt()

The second argument is always NULL, stop passing it to the function.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Alain Volmat <alain.volmat@foss.st.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Amelie DELAUNAY <amelie.delaunay@foss.st.com>
Cc: Hugues FRUCHET <hugues.fruchet@foss.st.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Philippe CORNU <philippe.cornu@foss.st.com>
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: stm32: dcmi: Fill in remaining Bayer formats
Marek Vasut [Sat, 18 Jun 2022 22:23:17 +0000 (23:23 +0100)]
media: stm32: dcmi: Fill in remaining Bayer formats

Fill in 10, 12, 14 bit Bayer formats into the DCMI driver.
Those are useful e.g. when MT9P006 sensor is connected.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Alain Volmat <alain.volmat@foss.st.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Amelie DELAUNAY <amelie.delaunay@foss.st.com>
Cc: Hugues FRUCHET <hugues.fruchet@foss.st.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Philippe CORNU <philippe.cornu@foss.st.com>
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-arm-kernel@lists.infradead.org
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 after getting dec_capability
Yunfei Dong [Sat, 18 Jun 2022 07:29:29 +0000 (08:29 +0100)]
media: mediatek: vcodec: Initialize decoder parameters after getting dec_capability

Need to get dec_capability from scp first, then initialize decoder
supported format and other parameters according to dec_capability value.

Fixes: fd00d90330d1 ("media: mtk-vcodec: vdec: move stateful ops into their own file")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Tested-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: rkvdec:Remove redundant memset
Zhang Zekun [Fri, 17 Jun 2022 09:39:25 +0000 (10:39 +0100)]
media: rkvdec:Remove redundant memset

As dma_alloc_coherent() will return a zeroed buffer, we
don't need to memset the returned buffer.
priv_tbl = dma_alloc_coherent() and count_tbl = dma_alloc_coherent()
should be enough.

-see commit 750afb08ca71 ("cross-tree: phase out dma_zalloc_coherent()")

Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atmel: atmel-isc-base: allow wb ctrls to be changed when isc is not configured
Eugen Hristev [Thu, 16 Jun 2022 14:42:59 +0000 (15:42 +0100)]
media: atmel: atmel-isc-base: allow wb ctrls to be changed when isc is not configured

When attempting to change the white balance (WB) ctrls before starting
streaming, e.g.:

 # v4l2-ctl -L

User Controls
..
            blue_component_gain 0x009819c1 (int)    : min=0 max=8191 step=1 default=512 value=512 flags=slider
..
 # v4l2-ctl --set-ctrl=blue_component_gain=500
 # v4l2-ctl -L
..
            blue_component_gain 0x009819c1 (int)    : min=0 max=8191 step=1 default=512 value=500 flags=slider
..

These will not be written to the internal data struct and will not be
written to the WB hardware module.
Thus, after starting streaming, they will be reset to default:

 # v4l2-ctl -L
..
            blue_component_gain 0x009819c1 (int)    : min=0 max=8191 step=1 default=512 value=512 flags=slider
..

It does not make much sense to not be able to configure the WB controls
at all times. Even if the sensor would not be RAW Bayer (and in this case the
WB module is unavailable), the user could configure the ISC itself, as the
ISC should not care about the sensor format.
Thus, when WB module is available (if the sensor changes format e.g.) it will
be already configured as be user's desires.
In consequence, remove the check in isc_s_awb_ctrl that will return if ISC
does not know the sensor format.

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: sta2x11: remove VIRT_TO_BUS dependency
Arnd Bergmann [Thu, 16 Jun 2022 08:52:42 +0000 (09:52 +0100)]
media: sta2x11: remove VIRT_TO_BUS dependency

This driver does not use the virt_to_bus() function, though it
depends on x86 specific fixups in the swiotlb code, which was
last rewritten in commit e380a0394c36 ("x86/PCI: sta2x11: use
default DMA address translation").

It is possible that the driver still fails to build on some
architectures that are missing CONFIG_VIRT_TO_BUS, but it is
always set on x86 machines with the STA2X11 platform enabled.

More likely though is that it was never meant to depend on
CONFIG_VIRT_TO_BUS, and the Kconfig dependency was kept from
an out-of-tree version when the driver was originally merged.

Fixes: efeb98b4e2b2 ("[media] STA2X11 VIP: new V4L2 driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek: vcodec: return EINVAL if plane is too small
Justin Green [Wed, 15 Jun 2022 15:38:27 +0000 (16:38 +0100)]
media: mediatek: vcodec: return EINVAL if plane is too small

Modify vb2ops_vdec_buf_prepare to return EINVAL if the size of the plane
is less than the size of the image. Currently we just log an error and
return 0 anyway, which may cause a buffer overrun bug.

Signed-off-by: Justin Green <greenjustin@chromium.org>
Suggested-by: Andres Calderon Jaramillo <andrescj@chromium.org>
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: v4l2-mem2mem: prevent pollerr when last_buffer_dequeued is set
Ming Qian [Wed, 15 Jun 2022 03:19:20 +0000 (04:19 +0100)]
media: v4l2-mem2mem: prevent pollerr when last_buffer_dequeued is set

If the last buffer was dequeued from the capture queue,
signal userspace. DQBUF(CAPTURE) will return -EPIPE.

But if output queue is empty and capture queue is empty,
v4l2_m2m_poll_for_data will return EPOLLERR,
This is very easy to happen in drain.

When last_buffer_dequeued is set, we shouldn't return EPOLLERR,
but return EPOLLIN | EPOLLRDNORM.

Fixes: 1698a7f151126 ("media: v4l2-mem2mem: simplify poll logic")
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: remove unneeded semicolon
Yang Li [Wed, 15 Jun 2022 00:59:46 +0000 (01:59 +0100)]
media: mediatek: vcodec: remove unneeded semicolon

Eliminate the following coccicheck warning:
./drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c:71:2-3: Unneeded semicolon

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: fix error value returns in hdpvr_read
Niels Dossche [Tue, 14 Jun 2022 17:50:02 +0000 (18:50 +0100)]
media: hdpvr: fix error value returns in hdpvr_read

Error return values are supposed to be negative in hdpvr_read. Most
error returns are currently handled via an unsigned integer "ret". When
setting a negative error value to "ret", the value actually becomes a
large positive value, because "ret" is unsigned. Later on, the "ret"
value is returned. But as ssize_t is a 64-bit signed number, the error
return value stays a large positive integer instead of a negative
integer. This can cause an error value to be interpreted as the read
size, which can cause a buffer overread for applications relying on the
returned size.

Fixes: 9aba42efe85b ("V4L/DVB (11096): V4L2 Driver for the Hauppauge HD PVR usb capture device")
Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek: vcodec: fix minmax.cocci warning
Guo Zhengkui [Tue, 14 Jun 2022 07:25:59 +0000 (08:25 +0100)]
media: mediatek: vcodec: fix minmax.cocci warning

Fix the following coccicheck warning:

drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c:
694:15-16: WARNING opportunity for min().

Signed-off-by: Guo Zhengkui <guozhengkui@vivo.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: MAINTAINERS: add include/dt-bindings/media to MEDIA INPUT INFRASTRUCTURE
Lukas Bulwahn [Mon, 13 Jun 2022 12:10:07 +0000 (13:10 +0100)]
media: MAINTAINERS: add include/dt-bindings/media to MEDIA INPUT INFRASTRUCTURE

Maintainers of the directory Documentation/devicetree/bindings/media
are also the maintainers of the corresponding directory
include/dt-bindings/media.

Add the file entry for include/dt-bindings/media to the appropriate
section in MAINTAINERS.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>