Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

media: uapi: Add 3a stats buffer for mali-c55

Describe the format of the 3A statistics buffers in the userspace API
header for the mali-c55 ISP.

Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Nayden Kanchev <nayden.kanchev@arm.com>
Co-developed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>

authored by

Daniel Scally and committed by
Hans Verkuil
c7f832f6 4d36f732

+171
+1
MAINTAINERS
··· 2116 2116 F: Documentation/devicetree/bindings/media/arm,mali-c55.yaml 2117 2117 F: Documentation/userspace-api/media/drivers/mali-c55.rst 2118 2118 F: drivers/media/platform/arm/mali-c55/ 2119 + F: include/uapi/linux/media/arm/mali-c55-config.h 2119 2120 2120 2121 ARM MALI PANTHOR DRM DRIVER 2121 2122 M: Boris Brezillon <boris.brezillon@collabora.com>
+170
include/uapi/linux/media/arm/mali-c55-config.h
··· 8 8 #ifndef __UAPI_MALI_C55_CONFIG_H 9 9 #define __UAPI_MALI_C55_CONFIG_H 10 10 11 + #include <linux/types.h> 11 12 #include <linux/v4l2-controls.h> 12 13 13 14 #define V4L2_CID_MALI_C55_CAPABILITIES (V4L2_CID_USER_MALI_C55_BASE + 0x0) ··· 23 22 #define MALI_C55_GPS_CNR (1U << 8) 24 23 #define MALI_C55_GPS_FRSCALER (1U << 9) 25 24 #define MALI_C55_GPS_DS_PIPE (1U << 10) 25 + 26 + /* 27 + * Frames are split into zones of almost equal width and height - a zone is a 28 + * rectangular tile of a frame. The metering blocks within the ISP collect 29 + * aggregated statistics per zone. A maximum of 15x15 zones can be configured, 30 + * and so the statistics buffer within the hardware is sized to accommodate 31 + * that. 32 + * 33 + * The utilised number of zones is runtime configurable. 34 + */ 35 + #define MALI_C55_MAX_ZONES (15 * 15) 36 + 37 + /** 38 + * struct mali_c55_ae_1024bin_hist - Auto Exposure 1024-bin histogram statistics 39 + * 40 + * @bins: 1024 element array of 16-bit pixel counts. 41 + * 42 + * The 1024-bin histogram module collects image-global but zone-weighted 43 + * intensity distributions of pixels in fixed-width bins. The modules can be 44 + * configured into different "plane modes" which affect the contents of the 45 + * collected statistics. In plane mode 0, pixel intensities are taken regardless 46 + * of colour plane into a single 1024-bin histogram with a bin width of 4. In 47 + * plane mode 1, four 256-bin histograms with a bin width of 16 are collected - 48 + * one for each CFA colour plane. In plane modes 4, 5, 6 and 7 two 512-bin 49 + * histograms with a bin width of 8 are collected - in each mode one of the 50 + * colour planes is collected into the first histogram and all the others are 51 + * combined into the second. The histograms are stored consecutively in the bins 52 + * array. 53 + * 54 + * The 16-bit pixel counts are stored as a 4-bit exponent in the most 55 + * significant bits followed by a 12-bit mantissa. Conversion to a usable 56 + * format can be done according to the following pseudo-code:: 57 + * 58 + * if (e == 0) { 59 + * bin = m * 2; 60 + * } else { 61 + * bin = (m + 4096) * 2^e 62 + * } 63 + * 64 + * where 65 + * e is the exponent value in range 0..15 66 + * m is the mantissa value in range 0..4095 67 + * 68 + * The pixels used in calculating the statistics can be masked using three 69 + * methods: 70 + * 71 + * 1. Pixels can be skipped in X and Y directions independently. 72 + * 2. Minimum/Maximum intensities can be configured 73 + * 3. Zones can be differentially weighted, including 0 weighted to mask them 74 + * 75 + * The data for this histogram can be collected from different tap points in the 76 + * ISP depending on configuration - after the white balance or digital gain 77 + * blocks, or immediately after the input crossbar. 78 + */ 79 + struct mali_c55_ae_1024bin_hist { 80 + __u16 bins[1024]; 81 + } __attribute__((packed)); 82 + 83 + /** 84 + * struct mali_c55_ae_5bin_hist - Auto Exposure 5-bin histogram statistics 85 + * 86 + * @hist0: 16-bit normalised pixel count for the 0th intensity bin 87 + * @hist1: 16-bit normalised pixel count for the 1st intensity bin 88 + * @hist3: 16-bit normalised pixel count for the 3rd intensity bin 89 + * @hist4: 16-bit normalised pixel count for the 4th intensity bin 90 + * 91 + * The ISP generates a 5-bin histogram of normalised pixel counts within bins of 92 + * pixel intensity for each of 225 possible zones within a frame. The centre bin 93 + * of the histogram for each zone is not available from the hardware and must be 94 + * calculated by subtracting the values of hist0, hist1, hist3 and hist4 from 95 + * 0xffff as in the following equation: 96 + * 97 + * hist2 = 0xffff - (hist0 + hist1 + hist3 + hist4) 98 + */ 99 + struct mali_c55_ae_5bin_hist { 100 + __u16 hist0; 101 + __u16 hist1; 102 + __u16 hist3; 103 + __u16 hist4; 104 + } __attribute__((packed)); 105 + 106 + /** 107 + * struct mali_c55_awb_average_ratios - Auto White Balance colour ratios 108 + * 109 + * @avg_rg_gr: Average R/G or G/R ratio in Q4.8 format. 110 + * @avg_bg_br: Average B/G or B/R ratio in Q4.8 format. 111 + * @num_pixels: The number of pixels used in the AWB calculation 112 + * 113 + * The ISP calculates and collects average colour ratios for each zone in an 114 + * image and stores them in Q4.8 format (the lowest 8 bits are fractional, with 115 + * bits [11:8] representing the integer). The exact ratios collected (either 116 + * R/G, B/G or G/R, B/R) are configurable through the parameters buffer. The 117 + * value of the 4 high bits is undefined. 118 + */ 119 + struct mali_c55_awb_average_ratios { 120 + __u16 avg_rg_gr; 121 + __u16 avg_bg_br; 122 + __u32 num_pixels; 123 + } __attribute__((packed)); 124 + 125 + /** 126 + * struct mali_c55_af_statistics - Auto Focus edge and intensity statistics 127 + * 128 + * @intensity_stats: Packed mantissa and exponent value for pixel intensity 129 + * @edge_stats: Packed mantissa and exponent values for edge intensity 130 + * 131 + * The ISP collects the squared sum of pixel intensities for each zone within a 132 + * configurable Region of Interest on the frame. Additionally, the same data are 133 + * collected after being passed through a bandpass filter which removes high and 134 + * low frequency components - these are referred to as the edge statistics. 135 + * 136 + * The intensity and edge statistics for a zone can be used to calculate the 137 + * contrast information for a zone 138 + * 139 + * C = E2 / I2 140 + * 141 + * Where I2 is the intensity statistic for a zone and E2 is the edge statistic 142 + * for that zone. Optimum focus is reached when C is at its maximum. 143 + * 144 + * The intensity and edge statistics are stored packed into a non-standard 16 145 + * bit floating point format, where the 7 most significant bits represent the 146 + * exponent and the 9 least significant bits the mantissa. This format can be 147 + * unpacked with the following pseudocode:: 148 + * 149 + * if (e == 0) { 150 + * x = m; 151 + * } else { 152 + * x = 2^e-1 * (m + 2^9) 153 + * } 154 + * 155 + * where 156 + * e is the exponent value in range 0..127 157 + * m is the mantissa value in range 0..511 158 + */ 159 + struct mali_c55_af_statistics { 160 + __u16 intensity_stats; 161 + __u16 edge_stats; 162 + } __attribute__((packed)); 163 + 164 + /** 165 + * struct mali_c55_stats_buffer - 3A statistics for the mali-c55 ISP 166 + * 167 + * @ae_1024bin_hist: 1024-bin frame-global pixel intensity histogram 168 + * @iridix_1024bin_hist: Post-Iridix block 1024-bin histogram 169 + * @ae_5bin_hists: 5-bin pixel intensity histograms for AEC 170 + * @reserved1: Undefined buffer space 171 + * @awb_ratios: Color balance ratios for Auto White Balance 172 + * @reserved2: Undefined buffer space 173 + * @af_statistics: Pixel intensity statistics for Auto Focus 174 + * @reserved3: Undefined buffer space 175 + * 176 + * This struct describes the metering statistics space in the Mali-C55 ISP's 177 + * hardware in its entirety. The space between each defined area is marked as 178 + * "unknown" and may not be 0, but should not be used. The @ae_5bin_hists, 179 + * @awb_ratios and @af_statistics members are arrays of statistics per-zone. 180 + * The zones are arranged in the array in raster order starting from the top 181 + * left corner of the image. 182 + */ 183 + 184 + struct mali_c55_stats_buffer { 185 + struct mali_c55_ae_1024bin_hist ae_1024bin_hist; 186 + struct mali_c55_ae_1024bin_hist iridix_1024bin_hist; 187 + struct mali_c55_ae_5bin_hist ae_5bin_hists[MALI_C55_MAX_ZONES]; 188 + __u32 reserved1[14]; 189 + struct mali_c55_awb_average_ratios awb_ratios[MALI_C55_MAX_ZONES]; 190 + __u32 reserved2[14]; 191 + struct mali_c55_af_statistics af_statistics[MALI_C55_MAX_ZONES]; 192 + __u32 reserved3[15]; 193 + } __attribute__((packed)); 26 194 27 195 #endif /* __UAPI_MALI_C55_CONFIG_H */