]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/s3a/s3a_1.0/ia_css_s3a_types.h
8d674d2c6427515c5e2e926b07846e6f2ac578d7
[mirror_ubuntu-bionic-kernel.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / isp / kernels / s3a / s3a_1.0 / ia_css_s3a_types.h
1 /*
2 * Support for Intel Camera Imaging ISP subsystem.
3 * Copyright (c) 2015, Intel Corporation.
4 *
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.
8 *
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
12 * more details.
13 */
14
15 #ifndef __IA_CSS_S3A_TYPES_H
16 #define __IA_CSS_S3A_TYPES_H
17
18 /* @file
19 * CSS-API header file for 3A statistics parameters.
20 */
21
22 #include <ia_css_frac.h>
23
24 #if (defined(SYSTEM_css_skycam_c0_system)) && (! defined(PIPE_GENERATION) )
25 #include "../../../../components/stats_3a/src/stats_3a_public.h"
26 #endif
27
28 /* 3A configuration. This configures the 3A statistics collection
29 * module.
30 */
31
32 /* 3A statistics grid
33 *
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))
36 * ISP1: S3A1 is used.
37 * ISP2: S3A2 is used.
38 */
39 struct ia_css_3a_grid_info {
40
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*/
45
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*/
49
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*/
53
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*/
57
58 uint32_t elem_bit_depth; /** TODO:Taken from BYT - need input from AIQ
59 if needed for SKC
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. */
64
65 #else
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
76 statistics.) */
77 uint32_t height; /** Height of 3A grid table.
78 (= Vertical number of grid cells
79 in table, which cells have effective
80 statistics.) */
81 uint32_t aligned_width; /** Horizontal stride (for alloc).
82 (= Horizontal number of grid cells
83 in table, which means
84 the allocated width.) */
85 uint32_t aligned_height; /** Vertical stride (for alloc).
86 (= Vertical number of grid cells
87 in table, which means
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. */
97 #endif
98 };
99
100
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 \
104 { \
105 0, /* ae_enable */ \
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*/ \
109 0, /* af_enable */ \
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 */ \
114 }
115 #else
116 #define DEFAULT_3A_GRID_INFO \
117 { \
118 0, /* ae_enable */ \
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*/ \
122 0, /* af_enable */ \
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 */ \
127 }
128 #endif /* USE_NEW_AE_STRUCT || defined USE_NEW_AWB_STRUCT */
129
130 #else
131 #define DEFAULT_3A_GRID_INFO \
132 { \
133 0, /* enable */ \
134 0, /* use_dmem */ \
135 0, /* has_histogram */ \
136 0, /* width */ \
137 0, /* height */ \
138 0, /* aligned_width */ \
139 0, /* aligned_height */ \
140 0, /* bqs_per_grid_cell */ \
141 0, /* deci_factor_log2 */ \
142 0, /* elem_bit_depth */ \
143 }
144
145 #endif
146
147 /* This struct should be split into 3, for AE, AWB and AF.
148 * However, that will require driver/ 3A lib modifications.
149 */
150
151 /* 3A configuration. This configures the 3A statistics collection
152 * module.
153 *
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.
161 *
162 * ISP block: S3A1(ae_y_* for AE/AF, awb_lg_* for AWB)
163 * S3A2(ae_y_* for AF, awb_lg_* for AWB)
164 * SDVS1(ae_y_*)
165 * SDVS2(ae_y_*)
166 * ISP1: S3A1 and SDVS1 are used.
167 * ISP2: S3A2 and SDVS2 are used.
168 */
169 struct ia_css_3a_config {
170 ia_css_u0_16 ae_y_coef_r; /** Weight of R for Y.
171 u0.16, [0,65535],
172 default/ineffective 25559 */
173 ia_css_u0_16 ae_y_coef_g; /** Weight of G for Y.
174 u0.16, [0,65535],
175 default/ineffective 32768 */
176 ia_css_u0_16 ae_y_coef_b; /** Weight of B for Y.
177 u0.16, [0,65535],
178 default/ineffective 7209 */
179 ia_css_u0_16 awb_lg_high_raw; /** AWB level gate high for raw.
180 u0.16, [0,65535],
181 default 65472(=1023*64),
182 ineffective 65535 */
183 ia_css_u0_16 awb_lg_low; /** AWB level gate low.
184 u0.16, [0,65535],
185 default 64(=1*64),
186 ineffective 0 */
187 ia_css_u0_16 awb_lg_high; /** AWB level gate high.
188 u0.16, [0,65535],
189 default 65535,
190 ineffective 65535 */
191 ia_css_s0_15 af_fir1_coef[7]; /** AF FIR coefficients of fir1.
192 s0.15, [-32768,32767],
193 default/ineffective
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],
197 default/ineffective
198 2053,0,-18437,32767,-18437,2053,0 */
199 };
200
201 /* 3A statistics. This structure describes the data stored
202 * in each 3A grid point.
203 *
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.
210 */
211 struct ia_css_3a_output {
212 int32_t ae_y; /** Sum of Y in a statistics window, for AE.
213 (u19.13) */
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) */
234 };
235
236
237 /* 3A Statistics. This structure describes the statistics that are generated
238 * using the provided configuration (ia_css_3a_config).
239 */
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 */
246 };
247
248 /* Histogram (Statistics for AE).
249 *
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];
253
254 * ISP block: HIST2
255 * (ISP1: HIST2 is not used.)
256 * ISP2: HIST2 is used.
257 */
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) */
263 };
264
265 #endif /* __IA_CSS_S3A_TYPES_H */
266