[0/8] media: rkisp1: Implement support for extensible parameters

Message ID 20240605165434.432230-1-jacopo.mondi@ideasonboard.com (mailing list archive)
Series media: rkisp1: Implement support for extensible parameters |


Jacopo Mondi June 5, 2024, 4:54 p.m. UTC
  The VeriSilicon ISP8000 IP, supported through the rkisp1 driver in the Linux
kernel, is integrated in several SoCs from different vendors. Different
revisions of the IP differ in the number of supported features and in the
register space location assigned to specific ISP blocks.

The current configuration parameters format, defined in
include/uapi/linux/rkisp1-config.h is realized by a C structure (struct
rkisp1_params_cfg) which wraps other structures that allows to configure
specific ISP blocks. The layout of the parameters buffer is part of the Linux
kernel uAPI and can hardly be extended or modified to adapt it to different
revisions of the same IP.

This series proposes the introduction of a new parameters format for the RkISP1
(without dropping support for the existing one) which is designed with the goals
of being:

1) versioned: can be changed without breaking existing applications
2) extensible: new blocks and parameters can be added without breaking the uABI

To do so, a new 'struct rkisp1_ext_params_cfg' type is introduced. It wraps an
header and a data buffer, which userspace fills with configuration blocks
for each ISP block it intends to configure. The parameters buffer is thus of
different effective sizes, depending on the number of blocks userspace intends
to configure.

The kernel driver parses the data block and decides, based on the versioning
number and the platform it operates on, how to handle each block.

The parameters format is very similar to the parameters format implemented
in the in-review Mali C55 ISP driver [1]

I considered sending this out as RFC, but the implementation has been tested
with a libcamera version ported to use the newly introduced format [1] and works
as expected, so I considered it good enough to send a proper patch series

A kernel branch for the interested ones is available at [3] with an associated
CI pipeline [4]

[1] https://lore.kernel.org/linux-media/20240529152858.183799-15-dan.scally@ideasonboard.com/
[2] https://gitlab.freedesktop.org/camera/libcamera/-/commits/imx8mp/extensible-format?ref_type=heads
[3] https://gitlab.freedesktop.org/linux-media/users/jmondi/-/commits/imx8mp/media-state/extensible-format
[4] https://gitlab.freedesktop.org/linux-media/users/jmondi/-/pipelines/1194073

Jacopo Mondi (8):
  uapi: rkisp1-config: Add extensible parameters format
  uapi: videodev2: Add V4L2_META_FMT_RK_ISP1_EXT_PARAMS
  media: rkisp1: Remove cached format info
  media: rkisp1: Add support for ext format
  media: rkisp1: Implement extensible params support
  media: rkisp1: Propagate pre/post-config errors
  media: rkisp1: Add struct rkisp1_params_buffer
  media: rkisp1: Copy and validate parameters buffer

 Documentation/admin-guide/media/rkisp1.rst    |  11 +-
 .../media/v4l/metafmt-rkisp1.rst              |  62 +-
 .../platform/rockchip/rkisp1/rkisp1-common.h  |  29 +-
 .../platform/rockchip/rkisp1/rkisp1-isp.c     |  14 +-
 .../platform/rockchip/rkisp1/rkisp1-params.c  | 795 ++++++++++++++++--
 drivers/media/v4l2-core/v4l2-ioctl.c          |   1 +
 include/uapi/linux/rkisp1-config.h            | 482 +++++++++++
 include/uapi/linux/videodev2.h                |   1 +
 8 files changed, 1314 insertions(+), 81 deletions(-)

base-commit: 1aea3d1d4a21e3e7895663b848ffae79ee82e065