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