linux/Documentation/userspace-api/media/v4l/metafmt-rppx1.rst
Niklas Söderlund b562e72bdb media: rppx1: Add framework to support Dreamchip RPPX1 ISP
Add a framework driver for Dreamchip RPPX1 ISP. The driver aims to
provide a framework for other V4L2 based drivers to drive the RPPX1
functionality. The reason for this split is that the RPPX1 IP itself do
not provide any DMA engines to drive data to/from the device, instead it
depends on other IP blocks to implement these features.

While the peripherals around the RPPX1 ISP used in different designs and
by different vendors are different the RPPX1 core itself is the same.
For this reason the framework solution to be able to split the Dreamchip
RPPX1 driver from vendors usage of it have been picked in hope to reduce
duplication of the common parts.

The design is to try and keep the surface of this framework as small as
possible. The intention of this change is to be able to fill all needs
of this.

  * Two functions to create and destroy a RPPX1 instance, rppx1_create()
    and rppx1_destory(). These are intended to be called in the users
    probe and remove code paths.

  * Two functions to start and stop the RPPX1 processing, rppx1_start()
    and rppx1_stop(). These are intended to be called in the users
    stream on and stream off code paths.

  * One function to ask the RPPX1 to process parameters buffer prepared
    by user space, rppx1_params(). The intention is to call this
    function when the parameter buffer is queued to the V4L2 driver and
    the result stored by the driver until the time it needs to be
    written to the RPPX1. It's the users responsibility to write it
    either using MMIO or other means.

  * One function to fill in a statistic buffer based on the current
    status of the RPPX1, rppx1_stats_fill_isr(). The intention is that
    the user call's this in its interrupt handler when it knows the
    RPPX1 is done processing a frame.

  * One function to ack and retrieve the interrupts generated by the
    RPPX1, rppx1_interrupt(). The intention is to call this function
    when the users interrupt handler detects the RPPX1 have raised and
    interrupt. There is no need for the user to understand, or act, on
    the actual RPPX1 interrupt, but it can if it wants too.

The initial support in the framework is limited and do not implement any
ISP processing algorithms other then configuring the RPPX1 to process
any Bayer (8-, 10, or 12-bit) image and produce either a RGB or YUYV
output. It do however probe all function blocks of the RPPX1 and provide
an interface to interact with both parameter and statistic bufferers.
The user of the framework will not change as algorithms for the
different function blocks of the ISP are being added.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Co-developed-by: Jai Luthra <jai.luthra+renesas@ideasonboard.com>
Signed-off-by: Jai Luthra <jai.luthra+renesas@ideasonboard.com>
Co-developed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
2026-07-30 20:51:35 +03:00

100 lines
3.8 KiB
ReStructuredText

.. SPDX-License-Identifier: GPL-2.0
.. _v4l2-meta-fmt-rppx1-params:
.. _v4l2-meta-fmt-rppx1-stats:
*************************************************************************
V4L2_META_FMT_RPPX1_PARAMS ('DR1P'), V4L2_META_FMT_RPPX1_STATS ('DR1S')
*************************************************************************
Configuration Parameters
========================
The configuration parameters are passed to the metadata output video node, using
the :c:type:`v4l2_meta_format` interface. Rather than a single struct containing
sub-structs for each configurable area of the ISP, parameters for the Dreamchip
RPPX1 use the v4l2-isp parameters system, through which groups of parameters are
defined as distinct structs or "blocks" which may be added to the data member of
:c:type:`v4l2_isp_buffer`. Userspace is responsible for populating the data
member with the blocks that need to be configured by the driver. Each
block-specific struct embeds :c:type:`v4l2_isp_block_header` as its first member
and userspace must populate the type member with a value from
:c:type:`rppx1_params_block_type`.
.. code-block:: c
struct v4l2_isp_params_buffer *params =
(struct v4l2_isp_params_buffer *)buffer;
params->version = V4L2_ISP_PARAMS_VERSION_V1;
params->data_size = 0;
void *data = (void *)params->data;
struct rppx1_ccor_params *ccor =
(struct rppx1_ccor_params *)data;
ccor->header.type = RPPX1_PARAMS_BLOCK_TYPE_CCOR_POST;
ccor->header.flags |= V4L2_ISP_PARAMS_FL_BLOCK_ENABLE;
ccor->header.size = sizeof(struct rppx1_ccor_params);
ccor->coeff[0][0] = 0x1000;
ccor->coeff[0][1] = 0x0000;
ccor->coeff[0][2] = 0x0000;
ccor->coeff[1][0] = 0x0000;
ccor->coeff[1][1] = 0x1000;
ccor->coeff[1][2] = 0x0000;
ccor->coeff[2][0] = 0x0000;
ccor->coeff[2][1] = 0x0000;
ccor->coeff[2][2] = 0x1000;
ccor->offset[0] = 0x200000;
ccor->offset[1] = 0x200000;
ccor->offset[2] = 0x200000;
data += sizeof(struct rppx1_ccor_params);
params->data_size += sizeof(struct rppx1_ccor_params);
3A Statistics
=============
The ISP device collects different statistics over an input bayer frame. Those
statistics can be obtained by userspace from the metadata capture video node,
using the :c:type:`v4l2_meta_format` interface. Rather than a single struct
containing sub-structs for each statistics area of the ISP, statistics for the
Dreamchip RPPX1 use the v4l2-isp statistics system, through which groups of
statistics are defined as distinct structs or "blocks" which may be added to the
data member of :c:type:`v4l2_isp_buffer`. Userspace is responsible for parsing
the buffer and extracting the blocks of statistics. Each block-specific struct
embeds :c:type:`v4l2_isp_block_header` as its first member and userspace must
interpret the type member with a value from :c:type:`rppx1_stats_block_type`.
.. code-block:: C
const struct v4l2_isp_buffer *stats =
(struct v4l2_isp_buffer *)buf;
size_t block_offset = 0;
while (block_offset < stats->data_size) {
const struct v4l2_isp_stats_block_header *block =
(void*)(stats->data + block_offset);
block_offset += block->size;
switch (block->type) {
case RPPX1_STATS_BLOCK_TYPE_HIST_POST:
for (unsigned int i = 0; i < RPPX1_HIST_NUM_BINS; i++)
printf("hist.hist_bins[%u] = 0x%08x\n",
i, hist.hist_bins[%i]);
break;
default:
printf("Unknown block type 0x%04x", block->type);
break;
}
}
Dreamchip RPPX1 uAPI data types
===============================
.. kernel-doc:: include/uapi/linux/media/dreamchip/rppx1-config.h