1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Support for Intel Camera Imaging ISP subsystem. 4 * Copyright (c) 2015, Intel Corporation. 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms and conditions of the GNU General Public License, 8 * version 2, as published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 * more details. 14 */ 15 16 #ifndef __IA_CSS_S3A_TYPES_H 17 #define __IA_CSS_S3A_TYPES_H 18 19 /* @file 20 * CSS-API header file for 3A statistics parameters. 21 */ 22 23 #include <ia_css_frac.h> 24 25 #if (defined(SYSTEM_css_skycam_c0_system)) && (!defined(PIPE_GENERATION)) 26 #include "../../../../components/stats_3a/src/stats_3a_public.h" 27 #endif 28 29 /* 3A configuration. This configures the 3A statistics collection 30 * module. 31 */ 32 33 /* 3A statistics grid 34 * 35 * ISP block: S3A1 (3A Support for 3A ver.1 (Histogram is not used for AE)) 36 * S3A2 (3A Support for 3A ver.2 (Histogram is used for AE)) 37 * ISP1: S3A1 is used. 38 * ISP2: S3A2 is used. 39 */ 40 struct ia_css_3a_grid_info { 41 #if defined(SYSTEM_css_skycam_c0_system) 42 u32 ae_enable; /** ae enabled in binary, 43 0:disabled, 1:enabled */ 44 struct ae_public_config_grid_config 45 ae_grd_info; /** see description in ae_public.h*/ 46 47 u32 awb_enable; /** awb enabled in binary, 48 0:disabled, 1:enabled */ 49 struct awb_public_config_grid_config 50 awb_grd_info; /** see description in awb_public.h*/ 51 52 u32 af_enable; /** af enabled in binary, 53 0:disabled, 1:enabled */ 54 struct af_public_grid_config af_grd_info; /** see description in af_public.h*/ 55 56 u32 awb_fr_enable; /** awb_fr enabled in binary, 57 0:disabled, 1:enabled */ 58 struct awb_fr_public_grid_config 59 awb_fr_grd_info;/** see description in awb_fr_public.h*/ 60 61 u32 elem_bit_depth; /** TODO:Taken from BYT - need input from AIQ 62 if needed for SKC 63 Bit depth of element used 64 to calculate 3A statistics. 65 This is 13, which is the normalized 66 bayer bit depth in DSP. */ 67 68 #else 69 u32 enable; /** 3A statistics enabled. 70 0:disabled, 1:enabled */ 71 u32 use_dmem; /** DMEM or VMEM determines layout. 72 0:3A statistics are stored to VMEM, 73 1:3A statistics are stored to DMEM */ 74 u32 has_histogram; /** Statistics include histogram. 75 0:no histogram, 1:has histogram */ 76 u32 width; /** Width of 3A grid table. 77 (= Horizontal number of grid cells 78 in table, which cells have effective 79 statistics.) */ 80 u32 height; /** Height of 3A grid table. 81 (= Vertical number of grid cells 82 in table, which cells have effective 83 statistics.) */ 84 u32 aligned_width; /** Horizontal stride (for alloc). 85 (= Horizontal number of grid cells 86 in table, which means 87 the allocated width.) */ 88 u32 aligned_height; /** Vertical stride (for alloc). 89 (= Vertical number of grid cells 90 in table, which means 91 the allocated height.) */ 92 u32 bqs_per_grid_cell; /** Grid cell size in BQ(Bayer Quad) unit. 93 (1BQ means {Gr,R,B,Gb}(2x2 pixels).) 94 Valid values are 8,16,32,64. */ 95 u32 deci_factor_log2; /** log2 of bqs_per_grid_cell. */ 96 u32 elem_bit_depth; /** Bit depth of element used 97 to calculate 3A statistics. 98 This is 13, which is the normalized 99 bayer bit depth in DSP. */ 100 #endif 101 }; 102 103 /* This struct should be split into 3, for AE, AWB and AF. 104 * However, that will require driver/ 3A lib modifications. 105 */ 106 107 /* 3A configuration. This configures the 3A statistics collection 108 * module. 109 * 110 * ae_y_*: Coefficients to calculate luminance from bayer. 111 * awb_lg_*: Thresholds to check the saturated bayer pixels for AWB. 112 * Condition of effective pixel for AWB level gate check: 113 * bayer(sensor) <= awb_lg_high_raw && 114 * bayer(when AWB statisitcs is calculated) >= awb_lg_low && 115 * bayer(when AWB statisitcs is calculated) <= awb_lg_high 116 * af_fir*: Coefficients of high pass filter to calculate AF statistics. 117 * 118 * ISP block: S3A1(ae_y_* for AE/AF, awb_lg_* for AWB) 119 * S3A2(ae_y_* for AF, awb_lg_* for AWB) 120 * SDVS1(ae_y_*) 121 * SDVS2(ae_y_*) 122 * ISP1: S3A1 and SDVS1 are used. 123 * ISP2: S3A2 and SDVS2 are used. 124 */ 125 struct ia_css_3a_config { 126 ia_css_u0_16 ae_y_coef_r; /** Weight of R for Y. 127 u0.16, [0,65535], 128 default/ineffective 25559 */ 129 ia_css_u0_16 ae_y_coef_g; /** Weight of G for Y. 130 u0.16, [0,65535], 131 default/ineffective 32768 */ 132 ia_css_u0_16 ae_y_coef_b; /** Weight of B for Y. 133 u0.16, [0,65535], 134 default/ineffective 7209 */ 135 ia_css_u0_16 awb_lg_high_raw; /** AWB level gate high for raw. 136 u0.16, [0,65535], 137 default 65472(=1023*64), 138 ineffective 65535 */ 139 ia_css_u0_16 awb_lg_low; /** AWB level gate low. 140 u0.16, [0,65535], 141 default 64(=1*64), 142 ineffective 0 */ 143 ia_css_u0_16 awb_lg_high; /** AWB level gate high. 144 u0.16, [0,65535], 145 default 65535, 146 ineffective 65535 */ 147 ia_css_s0_15 af_fir1_coef[7]; /** AF FIR coefficients of fir1. 148 s0.15, [-32768,32767], 149 default/ineffective 150 -6689,-12207,-32768,32767,12207,6689,0 */ 151 ia_css_s0_15 af_fir2_coef[7]; /** AF FIR coefficients of fir2. 152 s0.15, [-32768,32767], 153 default/ineffective 154 2053,0,-18437,32767,-18437,2053,0 */ 155 }; 156 157 /* 3A statistics. This structure describes the data stored 158 * in each 3A grid point. 159 * 160 * ISP block: S3A1 (3A Support for 3A ver.1) (Histogram is not used for AE) 161 * S3A2 (3A Support for 3A ver.2) (Histogram is used for AE) 162 * - ae_y is used only for S3A1. 163 * - awb_* and af_* are used both for S3A1 and S3A2. 164 * ISP1: S3A1 is used. 165 * ISP2: S3A2 is used. 166 */ 167 struct ia_css_3a_output { 168 s32 ae_y; /** Sum of Y in a statistics window, for AE. 169 (u19.13) */ 170 s32 awb_cnt; /** Number of effective pixels 171 in a statistics window. 172 Pixels passed by the AWB level gate check are 173 judged as "effective". (u32) */ 174 s32 awb_gr; /** Sum of Gr in a statistics window, for AWB. 175 All Gr pixels (not only for effective pixels) 176 are summed. (u19.13) */ 177 s32 awb_r; /** Sum of R in a statistics window, for AWB. 178 All R pixels (not only for effective pixels) 179 are summed. (u19.13) */ 180 s32 awb_b; /** Sum of B in a statistics window, for AWB. 181 All B pixels (not only for effective pixels) 182 are summed. (u19.13) */ 183 s32 awb_gb; /** Sum of Gb in a statistics window, for AWB. 184 All Gb pixels (not only for effective pixels) 185 are summed. (u19.13) */ 186 s32 af_hpf1; /** Sum of |Y| following high pass filter af_fir1 187 within a statistics window, for AF. (u19.13) */ 188 s32 af_hpf2; /** Sum of |Y| following high pass filter af_fir2 189 within a statistics window, for AF. (u19.13) */ 190 }; 191 192 /* 3A Statistics. This structure describes the statistics that are generated 193 * using the provided configuration (ia_css_3a_config). 194 */ 195 struct ia_css_3a_statistics { 196 struct ia_css_3a_grid_info 197 grid; /** grid info contains the dimensions of the 3A grid */ 198 struct ia_css_3a_output 199 *data; /** the pointer to 3a_output[grid.width * grid.height] 200 containing the 3A statistics */ 201 struct ia_css_3a_rgby_output *rgby_data;/** the pointer to 3a_rgby_output[256] 202 containing the histogram */ 203 }; 204 205 /* Histogram (Statistics for AE). 206 * 207 * 4 histograms(r,g,b,y), 208 * 256 bins for each histogram, unsigned 24bit value for each bin. 209 * struct ia_css_3a_rgby_output data[256]; 210 211 * ISP block: HIST2 212 * (ISP1: HIST2 is not used.) 213 * ISP2: HIST2 is used. 214 */ 215 struct ia_css_3a_rgby_output { 216 u32 r; /** Number of R of one bin of the histogram R. (u24) */ 217 u32 g; /** Number of G of one bin of the histogram G. (u24) */ 218 u32 b; /** Number of B of one bin of the histogram B. (u24) */ 219 u32 y; /** Number of Y of one bin of the histogram Y. (u24) */ 220 }; 221 222 #endif /* __IA_CSS_S3A_TYPES_H */ 223