xref: /linux/Documentation/userspace-api/media/v4l/metafmt-rppx1.rst (revision f4cdf7ca9a1fdcca413157df19753f388a5a224e)
1.. SPDX-License-Identifier: GPL-2.0
2
3.. _v4l2-meta-fmt-rppx1-params:
4.. _v4l2-meta-fmt-rppx1-stats:
5
6*************************************************************************
7V4L2_META_FMT_RPPX1_PARAMS ('DR1P'), V4L2_META_FMT_RPPX1_STATS ('DR1S')
8*************************************************************************
9
10Configuration Parameters
11========================
12
13The configuration parameters are passed to the metadata output video node, using
14the :c:type:`v4l2_meta_format` interface. Rather than a single struct containing
15sub-structs for each configurable area of the ISP, parameters for the Dreamchip
16RPPX1 use the v4l2-isp parameters system, through which groups of parameters are
17defined as distinct structs or "blocks" which may be added to the data member of
18:c:type:`v4l2_isp_buffer`. Userspace is responsible for populating the data
19member with the blocks that need to be configured by the driver.  Each
20block-specific struct embeds :c:type:`v4l2_isp_block_header` as its first member
21and userspace must populate the type member with a value from
22:c:type:`rppx1_params_block_type`.
23
24.. code-block:: c
25
26	struct v4l2_isp_params_buffer *params =
27		(struct v4l2_isp_params_buffer *)buffer;
28
29	params->version = V4L2_ISP_PARAMS_VERSION_V1;
30	params->data_size = 0;
31
32	void *data = (void *)params->data;
33
34	struct rppx1_ccor_params *ccor =
35		(struct rppx1_ccor_params *)data;
36
37	ccor->header.type = RPPX1_PARAMS_BLOCK_TYPE_CCOR_POST;
38	ccor->header.flags |= V4L2_ISP_PARAMS_FL_BLOCK_ENABLE;
39	ccor->header.size = sizeof(struct rppx1_ccor_params);
40
41        ccor->coeff[0][0] = 0x1000;
42        ccor->coeff[0][1] = 0x0000;
43        ccor->coeff[0][2] = 0x0000;
44        ccor->coeff[1][0] = 0x0000;
45        ccor->coeff[1][1] = 0x1000;
46        ccor->coeff[1][2] = 0x0000;
47        ccor->coeff[2][0] = 0x0000;
48        ccor->coeff[2][1] = 0x0000;
49        ccor->coeff[2][2] = 0x1000;
50
51        ccor->offset[0] = 0x200000;
52        ccor->offset[1] = 0x200000;
53        ccor->offset[2] = 0x200000;
54
55	data += sizeof(struct rppx1_ccor_params);
56	params->data_size += sizeof(struct rppx1_ccor_params);
57
583A Statistics
59=============
60
61The ISP device collects different statistics over an input bayer frame. Those
62statistics can be obtained by userspace from the metadata capture video node,
63using the :c:type:`v4l2_meta_format` interface. Rather than a single struct
64containing sub-structs for each statistics area of the ISP, statistics for the
65Dreamchip RPPX1 use the v4l2-isp statistics system, through which groups of
66statistics are defined as distinct structs or "blocks" which may be added to the
67data member of :c:type:`v4l2_isp_buffer`. Userspace is responsible for parsing
68the buffer and extracting the blocks of statistics. Each block-specific struct
69embeds :c:type:`v4l2_isp_block_header` as its first member and userspace must
70interpret the type member with a value from :c:type:`rppx1_stats_block_type`.
71
72.. code-block:: C
73
74        const struct v4l2_isp_buffer *stats =
75                (struct v4l2_isp_buffer *)buf;
76        size_t block_offset = 0;
77
78        while (block_offset < stats->data_size) {
79                const struct v4l2_isp_stats_block_header *block =
80                        (void*)(stats->data + block_offset);
81
82                block_offset += block->size;
83
84                switch (block->type) {
85                case RPPX1_STATS_BLOCK_TYPE_HIST_POST:
86                        for (unsigned int i = 0; i < RPPX1_HIST_NUM_BINS; i++)
87                                printf("hist.hist_bins[%u] = 0x%08x\n",
88                                        i, hist.hist_bins[%i]);
89                        break;
90                default:
91                        printf("Unknown block type 0x%04x", block->type);
92                        break;
93                }
94        }
95
96Dreamchip RPPX1 uAPI data types
97===============================
98
99.. kernel-doc:: include/uapi/linux/media/dreamchip/rppx1-config.h
100