2 * Support for Intel Camera Imaging ISP subsystem.
3 * Copyright (c) 2015, Intel Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 #ifndef __IA_CSS_S3A_TYPES_H
16 #define __IA_CSS_S3A_TYPES_H
19 * CSS-API header file for 3A statistics parameters.
22 #include <ia_css_frac.h>
24 #if (defined(SYSTEM_css_skycam_c0_system)) && (! defined(PIPE_GENERATION) )
25 #include "../../../../components/stats_3a/src/stats_3a_public.h"
28 /** 3A configuration. This configures the 3A statistics collection
32 /** 3A statistics grid
34 * ISP block: S3A1 (3A Support for 3A ver.1 (Histogram is not used for AE))
35 * S3A2 (3A Support for 3A ver.2 (Histogram is used for AE))
39 struct ia_css_3a_grid_info {
41 #if defined(SYSTEM_css_skycam_c0_system)
42 uint32_t ae_enable; /**< ae enabled in binary,
43 0:disabled, 1:enabled */
44 struct ae_public_config_grid_config ae_grd_info; /**< see description in ae_public.h*/
46 uint32_t awb_enable; /**< awb enabled in binary,
47 0:disabled, 1:enabled */
48 struct awb_public_config_grid_config awb_grd_info; /**< see description in awb_public.h*/
50 uint32_t af_enable; /**< af enabled in binary,
51 0:disabled, 1:enabled */
52 struct af_public_grid_config af_grd_info; /**< see description in af_public.h*/
54 uint32_t awb_fr_enable; /**< awb_fr enabled in binary,
55 0:disabled, 1:enabled */
56 struct awb_fr_public_grid_config awb_fr_grd_info;/**< see description in awb_fr_public.h*/
58 uint32_t elem_bit_depth; /**< TODO:Taken from BYT - need input from AIQ
60 Bit depth of element used
61 to calculate 3A statistics.
62 This is 13, which is the normalized
63 bayer bit depth in DSP. */
66 uint32_t enable; /**< 3A statistics enabled.
67 0:disabled, 1:enabled */
68 uint32_t use_dmem; /**< DMEM or VMEM determines layout.
69 0:3A statistics are stored to VMEM,
70 1:3A statistics are stored to DMEM */
71 uint32_t has_histogram; /**< Statistics include histogram.
72 0:no histogram, 1:has histogram */
73 uint32_t width; /**< Width of 3A grid table.
74 (= Horizontal number of grid cells
75 in table, which cells have effective
77 uint32_t height; /**< Height of 3A grid table.
78 (= Vertical number of grid cells
79 in table, which cells have effective
81 uint32_t aligned_width; /**< Horizontal stride (for alloc).
82 (= Horizontal number of grid cells
84 the allocated width.) */
85 uint32_t aligned_height; /**< Vertical stride (for alloc).
86 (= Vertical number of grid cells
88 the allocated height.) */
89 uint32_t bqs_per_grid_cell; /**< Grid cell size in BQ(Bayer Quad) unit.
90 (1BQ means {Gr,R,B,Gb}(2x2 pixels).)
91 Valid values are 8,16,32,64. */
92 uint32_t deci_factor_log2; /**< log2 of bqs_per_grid_cell. */
93 uint32_t elem_bit_depth; /**< Bit depth of element used
94 to calculate 3A statistics.
95 This is 13, which is the normalized
96 bayer bit depth in DSP. */
101 #if defined(SYSTEM_css_skycam_c0_system)
102 #if defined USE_NEW_AE_STRUCT || defined USE_NEW_AWB_STRUCT
103 #define DEFAULT_3A_GRID_INFO \
106 {0,0,0,0,0,0,0}, /* AE: width,height,b_width,b_height,x_start,y_start*/ \
107 0, /* awb_enable */ \
108 {0,0,0,0,0,0}, /* AWB: width,height,b_width,b_height,x_start,y_start*/ \
110 {0,0,0,0,0,0,0}, /* AF: width,height,b_width,b_height,x_start,y_start,ff_en*/ \
111 0, /* awb_fr_enable */ \
112 {0,0,0,0,0,0,0}, /* AWB_FR: width,height,b_width,b_height,x_start,y_start,ff_en*/ \
113 0, /* elem_bit_depth */ \
116 #define DEFAULT_3A_GRID_INFO \
119 {0,0,0,0,0,0,0,0,0}, /* AE: width,height,b_width,b_height,x_start,y_start,x_end,y_end*/ \
120 0, /* awb_enable */ \
121 {0,0,0,0,0,0,0,0}, /* AWB: width,height,b_width,b_height,x_start,y_start,x_end,y_end*/ \
123 {0,0,0,0,0,0,0}, /* AF: width,height,b_width,b_height,x_start,y_start,ff_en*/ \
124 0, /* awb_fr_enable */ \
125 {0,0,0,0,0,0,0}, /* AWB_FR: width,height,b_width,b_height,x_start,y_start,ff_en*/ \
126 0, /* elem_bit_depth */ \
128 #endif /* USE_NEW_AE_STRUCT || defined USE_NEW_AWB_STRUCT */
131 #define DEFAULT_3A_GRID_INFO \
135 0, /* has_histogram */ \
138 0, /* aligned_width */ \
139 0, /* aligned_height */ \
140 0, /* bqs_per_grid_cell */ \
141 0, /* deci_factor_log2 */ \
142 0, /* elem_bit_depth */ \
147 /* This struct should be split into 3, for AE, AWB and AF.
148 * However, that will require driver/ 3A lib modifications.
151 /** 3A configuration. This configures the 3A statistics collection
154 * ae_y_*: Coefficients to calculate luminance from bayer.
155 * awb_lg_*: Thresholds to check the saturated bayer pixels for AWB.
156 * Condition of effective pixel for AWB level gate check:
157 * bayer(sensor) <= awb_lg_high_raw &&
158 * bayer(when AWB statisitcs is calculated) >= awb_lg_low &&
159 * bayer(when AWB statisitcs is calculated) <= awb_lg_high
160 * af_fir*: Coefficients of high pass filter to calculate AF statistics.
162 * ISP block: S3A1(ae_y_* for AE/AF, awb_lg_* for AWB)
163 * S3A2(ae_y_* for AF, awb_lg_* for AWB)
166 * ISP1: S3A1 and SDVS1 are used.
167 * ISP2: S3A2 and SDVS2 are used.
169 struct ia_css_3a_config {
170 ia_css_u0_16 ae_y_coef_r; /**< Weight of R for Y.
172 default/ineffective 25559 */
173 ia_css_u0_16 ae_y_coef_g; /**< Weight of G for Y.
175 default/ineffective 32768 */
176 ia_css_u0_16 ae_y_coef_b; /**< Weight of B for Y.
178 default/ineffective 7209 */
179 ia_css_u0_16 awb_lg_high_raw; /**< AWB level gate high for raw.
181 default 65472(=1023*64),
183 ia_css_u0_16 awb_lg_low; /**< AWB level gate low.
187 ia_css_u0_16 awb_lg_high; /**< AWB level gate high.
191 ia_css_s0_15 af_fir1_coef[7]; /**< AF FIR coefficients of fir1.
192 s0.15, [-32768,32767],
194 -6689,-12207,-32768,32767,12207,6689,0 */
195 ia_css_s0_15 af_fir2_coef[7]; /**< AF FIR coefficients of fir2.
196 s0.15, [-32768,32767],
198 2053,0,-18437,32767,-18437,2053,0 */
201 /** 3A statistics. This structure describes the data stored
202 * in each 3A grid point.
204 * ISP block: S3A1 (3A Support for 3A ver.1) (Histogram is not used for AE)
205 * S3A2 (3A Support for 3A ver.2) (Histogram is used for AE)
206 * - ae_y is used only for S3A1.
207 * - awb_* and af_* are used both for S3A1 and S3A2.
208 * ISP1: S3A1 is used.
209 * ISP2: S3A2 is used.
211 struct ia_css_3a_output {
212 int32_t ae_y; /**< Sum of Y in a statistics window, for AE.
214 int32_t awb_cnt; /**< Number of effective pixels
215 in a statistics window.
216 Pixels passed by the AWB level gate check are
217 judged as "effective". (u32) */
218 int32_t awb_gr; /**< Sum of Gr in a statistics window, for AWB.
219 All Gr pixels (not only for effective pixels)
220 are summed. (u19.13) */
221 int32_t awb_r; /**< Sum of R in a statistics window, for AWB.
222 All R pixels (not only for effective pixels)
223 are summed. (u19.13) */
224 int32_t awb_b; /**< Sum of B in a statistics window, for AWB.
225 All B pixels (not only for effective pixels)
226 are summed. (u19.13) */
227 int32_t awb_gb; /**< Sum of Gb in a statistics window, for AWB.
228 All Gb pixels (not only for effective pixels)
229 are summed. (u19.13) */
230 int32_t af_hpf1; /**< Sum of |Y| following high pass filter af_fir1
231 within a statistics window, for AF. (u19.13) */
232 int32_t af_hpf2; /**< Sum of |Y| following high pass filter af_fir2
233 within a statistics window, for AF. (u19.13) */
237 /** 3A Statistics. This structure describes the statistics that are generated
238 * using the provided configuration (ia_css_3a_config).
240 struct ia_css_3a_statistics {
241 struct ia_css_3a_grid_info grid; /**< grid info contains the dimensions of the 3A grid */
242 struct ia_css_3a_output *data; /**< the pointer to 3a_output[grid.width * grid.height]
243 containing the 3A statistics */
244 struct ia_css_3a_rgby_output *rgby_data;/**< the pointer to 3a_rgby_output[256]
245 containing the histogram */
248 /** Histogram (Statistics for AE).
250 * 4 histograms(r,g,b,y),
251 * 256 bins for each histogram, unsigned 24bit value for each bin.
252 * struct ia_css_3a_rgby_output data[256];
255 * (ISP1: HIST2 is not used.)
256 * ISP2: HIST2 is used.
258 struct ia_css_3a_rgby_output {
259 uint32_t r; /**< Number of R of one bin of the histogram R. (u24) */
260 uint32_t g; /**< Number of G of one bin of the histogram G. (u24) */
261 uint32_t b; /**< Number of B of one bin of the histogram B. (u24) */
262 uint32_t y; /**< Number of Y of one bin of the histogram Y. (u24) */
265 #endif /* __IA_CSS_S3A_TYPES_H */