Merge remote-tracking branches 'asoc/topic/mc13783', 'asoc/topic/msm8916', 'asoc...
[linux-2.6-block.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / isp / kernels / s3a / s3a_1.0 / ia_css_s3a_types.h
CommitLineData
a49d2536
AC
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
d929fb4e 18/* @file
a49d2536
AC
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
d929fb4e 28/* 3A configuration. This configures the 3A statistics collection
a49d2536
AC
29 * module.
30 */
31
d929fb4e 32/* 3A statistics grid
a49d2536
AC
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 */
39struct ia_css_3a_grid_info {
40
41#if defined(SYSTEM_css_skycam_c0_system)
d929fb4e 42 uint32_t ae_enable; /** ae enabled in binary,
a49d2536 43 0:disabled, 1:enabled */
d929fb4e 44 struct ae_public_config_grid_config ae_grd_info; /** see description in ae_public.h*/
a49d2536 45
d929fb4e 46 uint32_t awb_enable; /** awb enabled in binary,
a49d2536 47 0:disabled, 1:enabled */
d929fb4e 48 struct awb_public_config_grid_config awb_grd_info; /** see description in awb_public.h*/
a49d2536 49
d929fb4e 50 uint32_t af_enable; /** af enabled in binary,
a49d2536 51 0:disabled, 1:enabled */
d929fb4e 52 struct af_public_grid_config af_grd_info; /** see description in af_public.h*/
a49d2536 53
d929fb4e 54 uint32_t awb_fr_enable; /** awb_fr enabled in binary,
a49d2536 55 0:disabled, 1:enabled */
d929fb4e 56 struct awb_fr_public_grid_config awb_fr_grd_info;/** see description in awb_fr_public.h*/
a49d2536 57
d929fb4e 58 uint32_t elem_bit_depth; /** TODO:Taken from BYT - need input from AIQ
a49d2536
AC
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
d929fb4e 66 uint32_t enable; /** 3A statistics enabled.
a49d2536 67 0:disabled, 1:enabled */
d929fb4e 68 uint32_t use_dmem; /** DMEM or VMEM determines layout.
a49d2536
AC
69 0:3A statistics are stored to VMEM,
70 1:3A statistics are stored to DMEM */
d929fb4e 71 uint32_t has_histogram; /** Statistics include histogram.
a49d2536 72 0:no histogram, 1:has histogram */
d929fb4e 73 uint32_t width; /** Width of 3A grid table.
a49d2536
AC
74 (= Horizontal number of grid cells
75 in table, which cells have effective
76 statistics.) */
d929fb4e 77 uint32_t height; /** Height of 3A grid table.
a49d2536
AC
78 (= Vertical number of grid cells
79 in table, which cells have effective
80 statistics.) */
d929fb4e 81 uint32_t aligned_width; /** Horizontal stride (for alloc).
a49d2536
AC
82 (= Horizontal number of grid cells
83 in table, which means
84 the allocated width.) */
d929fb4e 85 uint32_t aligned_height; /** Vertical stride (for alloc).
a49d2536
AC
86 (= Vertical number of grid cells
87 in table, which means
88 the allocated height.) */
d929fb4e 89 uint32_t bqs_per_grid_cell; /** Grid cell size in BQ(Bayer Quad) unit.
a49d2536
AC
90 (1BQ means {Gr,R,B,Gb}(2x2 pixels).)
91 Valid values are 8,16,32,64. */
d929fb4e
MCC
92 uint32_t deci_factor_log2; /** log2 of bqs_per_grid_cell. */
93 uint32_t elem_bit_depth; /** Bit depth of element used
a49d2536
AC
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
d929fb4e 151/* 3A configuration. This configures the 3A statistics collection
a49d2536
AC
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 */
169struct ia_css_3a_config {
d929fb4e 170 ia_css_u0_16 ae_y_coef_r; /** Weight of R for Y.
a49d2536
AC
171 u0.16, [0,65535],
172 default/ineffective 25559 */
d929fb4e 173 ia_css_u0_16 ae_y_coef_g; /** Weight of G for Y.
a49d2536
AC
174 u0.16, [0,65535],
175 default/ineffective 32768 */
d929fb4e 176 ia_css_u0_16 ae_y_coef_b; /** Weight of B for Y.
a49d2536
AC
177 u0.16, [0,65535],
178 default/ineffective 7209 */
d929fb4e 179 ia_css_u0_16 awb_lg_high_raw; /** AWB level gate high for raw.
a49d2536
AC
180 u0.16, [0,65535],
181 default 65472(=1023*64),
182 ineffective 65535 */
d929fb4e 183 ia_css_u0_16 awb_lg_low; /** AWB level gate low.
a49d2536
AC
184 u0.16, [0,65535],
185 default 64(=1*64),
186 ineffective 0 */
d929fb4e 187 ia_css_u0_16 awb_lg_high; /** AWB level gate high.
a49d2536
AC
188 u0.16, [0,65535],
189 default 65535,
190 ineffective 65535 */
d929fb4e 191 ia_css_s0_15 af_fir1_coef[7]; /** AF FIR coefficients of fir1.
a49d2536
AC
192 s0.15, [-32768,32767],
193 default/ineffective
194 -6689,-12207,-32768,32767,12207,6689,0 */
d929fb4e 195 ia_css_s0_15 af_fir2_coef[7]; /** AF FIR coefficients of fir2.
a49d2536
AC
196 s0.15, [-32768,32767],
197 default/ineffective
198 2053,0,-18437,32767,-18437,2053,0 */
199};
200
d929fb4e 201/* 3A statistics. This structure describes the data stored
a49d2536
AC
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 */
211struct ia_css_3a_output {
d929fb4e 212 int32_t ae_y; /** Sum of Y in a statistics window, for AE.
a49d2536 213 (u19.13) */
d929fb4e 214 int32_t awb_cnt; /** Number of effective pixels
a49d2536
AC
215 in a statistics window.
216 Pixels passed by the AWB level gate check are
217 judged as "effective". (u32) */
d929fb4e 218 int32_t awb_gr; /** Sum of Gr in a statistics window, for AWB.
a49d2536
AC
219 All Gr pixels (not only for effective pixels)
220 are summed. (u19.13) */
d929fb4e 221 int32_t awb_r; /** Sum of R in a statistics window, for AWB.
a49d2536
AC
222 All R pixels (not only for effective pixels)
223 are summed. (u19.13) */
d929fb4e 224 int32_t awb_b; /** Sum of B in a statistics window, for AWB.
a49d2536
AC
225 All B pixels (not only for effective pixels)
226 are summed. (u19.13) */
d929fb4e 227 int32_t awb_gb; /** Sum of Gb in a statistics window, for AWB.
a49d2536
AC
228 All Gb pixels (not only for effective pixels)
229 are summed. (u19.13) */
d929fb4e 230 int32_t af_hpf1; /** Sum of |Y| following high pass filter af_fir1
a49d2536 231 within a statistics window, for AF. (u19.13) */
d929fb4e 232 int32_t af_hpf2; /** Sum of |Y| following high pass filter af_fir2
a49d2536
AC
233 within a statistics window, for AF. (u19.13) */
234};
235
236
d929fb4e 237/* 3A Statistics. This structure describes the statistics that are generated
a49d2536
AC
238 * using the provided configuration (ia_css_3a_config).
239 */
240struct ia_css_3a_statistics {
d929fb4e
MCC
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]
a49d2536 243 containing the 3A statistics */
d929fb4e 244 struct ia_css_3a_rgby_output *rgby_data;/** the pointer to 3a_rgby_output[256]
a49d2536
AC
245 containing the histogram */
246};
247
d929fb4e 248/* Histogram (Statistics for AE).
a49d2536
AC
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 */
258struct ia_css_3a_rgby_output {
d929fb4e
MCC
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) */
a49d2536
AC
263};
264
265#endif /* __IA_CSS_S3A_TYPES_H */
266