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 __REF_VECTOR_FUNC_TYPES_H_INCLUDED__
16 #define __REF_VECTOR_FUNC_TYPES_H_INCLUDED__
24 #include "bbb_config.h"
25 #include "isp_op1w_types.h"
26 #include "isp_op2w_types.h"
28 /* Defines for the Config Unit */
29 #define MAX_CONFIG_POINTS 5
30 #define INPUT_OFFSET_FACTOR 10
31 #define INPUT_SCALE_FACTOR 10
32 #define OUTPUT_SCALE_FACTOR 10
33 #define SLOPE_A_RESOLUTION 10
34 #define CONFIG_UNIT_LUT_SIZE_32 32 /*XCU works for ISP_NWAY = 32 */
35 #define LXCU_LUT_SIZE 16
37 #define IMAX32_ELEM_SIZE 32
40 #define ONE_IN_Q14 (1<<(NUM_BITS-2))
41 #define Q29_TO_Q15_SHIFT_VAL (NUM_BITS-2)
42 #define Q28_TO_Q15_SHIFT_VAL (NUM_BITS-3)
43 #define MAX_ELEM(width_in_bits) ((1<<(width_in_bits))-1)
45 /* Block matching algorithm related data */
46 /* NUM_OF_SADS = ((SEARCH_AREA_HEIGHT - REF_BLOCK_HEIGHT)/PIXEL_SHIFT + 1)* \
47 ((SEARCH_AREA_WIDTH - REF_BLOCK_WIDTH)/PIXEL_SHIFT + 1) */
49 #define SADS(sw_h,sw_w, ref_h, ref_w, p_sh) (((sw_h - ref_h)/p_sh + 1)*((sw_w - ref_w)/p_sh + 1))
50 #define SADS_16x16_1 SADS(16, 16, 8, 8, 1)
51 #define SADS_16x16_2 SADS(16, 16, 8, 8, 2)
52 #define SADS_14x14_1 SADS(14, 14, 8, 8, 1)
53 #define SADS_14x14_2 SADS(14, 14, 8, 8, 2)
55 #define BMA_OUTPUT_MATRIX_DIM(sw_h, ref_h, p_sh) ((sw_h - ref_h)/p_sh + 1)
56 #define BMA_OUT_16x16_2_32 BMA_OUTPUT_MATRIX_DIM(16, 8, 2)
57 #define BMA_OUT_14x14_2_32 BMA_OUTPUT_MATRIX_DIM(14, 8, 2)
58 #define BMA_OUT_16x16_1_32 BMA_OUTPUT_MATRIX_DIM(16, 8, 1)
59 #define BMA_OUT_14x14_1_32 BMA_OUTPUT_MATRIX_DIM(14, 8, 1)
60 #define BMA_SEARCH_BLOCK_SZ_16 16
61 #define BMA_REF_BLOCK_SZ_8 8
62 #define PIXEL_SHIFT_2 2
63 #define PIXEL_SHIFT_1 1
64 #define BMA_SEARCH_WIN_SZ_16 16
65 #define BMA_SEARCH_WIN_SZ_14 14
69 * Struct type specification
72 typedef unsigned short tscalar1w_3bit; /* tscalar1w in interval [0, 2^3) */
73 typedef short tscalar1w_5bit_signed; /* tscalar1w in interval [-2^(5-1), 2^(5-1)) */
74 typedef unsigned short tscalar1w_5bit; /* tscalar1w in interval [0, 2^5) */
75 typedef short tscalar1w_range1wbit; /* tscalar1w in interval [-NUM_BITS, NUM_BITS] */
76 typedef short tscalar1w_unsigned_range1wbit; /* tscalar1w in interval [0, NUM_BITS] */
77 typedef unsigned short tvector_8bit; /* 8 bit positive number */
78 typedef unsigned short tvector_5bit;
79 typedef unsigned short tvector_4bit;
80 typedef unsigned short tscalar1w_16bit;
81 typedef unsigned short tscalar1w_4bit_bma_shift;
88 #define S_1W_2X1_MATRIX_DEFAULT ((s_1w_2x1_matrix)\
96 #define S_1W_1X2_MATRIX_DEFAULT ((s_1w_1x2_matrix)\
105 #define S_1W_1X3_MATRIX_DEFAULT ((s_1w_1x3_matrix)\
109 tvector1w v00; tvector1w v01; tvector1w v02;
110 tvector1w v10; tvector1w v11; tvector1w v12;
113 #define S_1W_2X3_MATRIX_DEFAULT ((s_1w_2x3_matrix)\
118 tvector1w v00 ; tvector1w v01 ; tvector1w v02 ;
119 tvector1w v10 ; tvector1w v11 ; tvector1w v12 ;
120 tvector1w v20 ; tvector1w v21 ; tvector1w v22 ;
123 #define S_1W_3X3_MATRIX_DEFAULT ((s_1w_3x3_matrix)\
129 tvector1w v00 ; tvector1w v01 ; tvector1w v02 ;
130 tvector1w v10 ; tvector1w v11 ; tvector1w v12 ;
131 tvector1w v20 ; tvector1w v21 ; tvector1w v22 ;
132 tvector1w v30 ; tvector1w v31 ; tvector1w v32 ;
135 #define S_1W_4X3_MATRIX_DEFAULT ((s_1w_4x3_matrix)\
149 #define S_1W_1X5_MATRIX_DEFAULT ((s_1w_1x5_matrix)\
153 tvector1w v00 ; tvector1w v01 ; tvector1w v02 ; tvector1w v03 ; tvector1w v04 ;
154 tvector1w v10 ; tvector1w v11 ; tvector1w v12 ; tvector1w v13 ; tvector1w v14 ;
155 tvector1w v20 ; tvector1w v21 ; tvector1w v22 ; tvector1w v23 ; tvector1w v24 ;
156 tvector1w v30 ; tvector1w v31 ; tvector1w v32 ; tvector1w v33 ; tvector1w v34 ;
157 tvector1w v40 ; tvector1w v41 ; tvector1w v42 ; tvector1w v43 ; tvector1w v44 ;
160 #define S_1W_5X5_MATRIX_DEFAULT ((s_1w_5x5_matrix)\
181 #define S_1W_1X7_MATRIX_DEFAULT ((s_1w_1x7_matrix)\
182 { 0, 0, 0, 0, 0, 0, 0 })
196 #define S_1W_1X9_MATRIX_DEFAULT ((s_1w_1x9_matrix)\
197 { 0, 0, 0, 0, 0, 0, 0, 0, 0 })
206 #define S_1W_1X4_MATRIX ((s_1w_1x4_matrix)\
210 tvector1w v00; tvector1w v01; tvector1w v02; tvector1w v03;
211 tvector1w v10; tvector1w v11; tvector1w v12; tvector1w v13;
212 tvector1w v20; tvector1w v21; tvector1w v22; tvector1w v23;
213 tvector1w v30; tvector1w v31; tvector1w v32; tvector1w v33;
216 #define S_1W_4X4_MATRIX_DEFAULT ((s_1w_4x4_matrix)\
231 #define S_1W_1X6_MATRIX_DEFAULT ((s_1w_1x6_matrix)\
232 { 0, 0, 0, 0, 0, 0 })
235 tvector1w v00; tvector1w v01; tvector1w v02; tvector1w v03; tvector1w v04; tvector1w v05;
236 tvector1w v10; tvector1w v11; tvector1w v12; tvector1w v13; tvector1w v14; tvector1w v15;
237 tvector1w v20; tvector1w v21; tvector1w v22; tvector1w v23; tvector1w v24; tvector1w v25;
238 tvector1w v30; tvector1w v31; tvector1w v32; tvector1w v33; tvector1w v34; tvector1w v35;
239 tvector1w v40; tvector1w v41; tvector1w v42; tvector1w v43; tvector1w v44; tvector1w v45;
240 tvector1w v50; tvector1w v51; tvector1w v52; tvector1w v53; tvector1w v54; tvector1w v55;
243 #define S_1W_6X6_MATRIX_DEFAULT ((s_1w_6x6_matrix)\
244 { 0, 0, 0, 0, 0, 0, \
252 tvector1w v00; tvector1w v01; tvector1w v02; tvector1w v03; tvector1w v04;
253 tvector1w v05; tvector1w v06; tvector1w v07; tvector1w v08;
254 tvector1w v10; tvector1w v11; tvector1w v12; tvector1w v13; tvector1w v14;
255 tvector1w v15; tvector1w v16; tvector1w v17; tvector1w v18;
256 tvector1w v20; tvector1w v21; tvector1w v22; tvector1w v23; tvector1w v24;
257 tvector1w v25; tvector1w v26; tvector1w v27; tvector1w v28;
258 tvector1w v30; tvector1w v31; tvector1w v32; tvector1w v33; tvector1w v34;
259 tvector1w v35; tvector1w v36; tvector1w v37; tvector1w v38;
260 tvector1w v40; tvector1w v41; tvector1w v42; tvector1w v43; tvector1w v44;
261 tvector1w v45; tvector1w v46; tvector1w v47; tvector1w v48;
262 tvector1w v50; tvector1w v51; tvector1w v52; tvector1w v53; tvector1w v54;
263 tvector1w v55; tvector1w v56; tvector1w v57; tvector1w v58;
264 tvector1w v60; tvector1w v61; tvector1w v62; tvector1w v63; tvector1w v64;
265 tvector1w v65; tvector1w v66; tvector1w v67; tvector1w v68;
266 tvector1w v70; tvector1w v71; tvector1w v72; tvector1w v73; tvector1w v74;
267 tvector1w v75; tvector1w v76; tvector1w v77; tvector1w v78;
268 tvector1w v80; tvector1w v81; tvector1w v82; tvector1w v83; tvector1w v84;
269 tvector1w v85; tvector1w v86; tvector1w v87; tvector1w v88;
272 #define S_1W_9X9_MATRIX_DEFAULT ((s_1w_9x9_matrix)\
273 { 0, 0, 0, 0, 0, 0, 0, 0, 0, \
274 0, 0, 0, 0, 0, 0, 0, 0, 0, \
275 0, 0, 0, 0, 0, 0, 0, 0, 0, \
276 0, 0, 0, 0, 0, 0, 0, 0, 0, \
277 0, 0, 0, 0, 0, 0, 0, 0, 0, \
278 0, 0, 0, 0, 0, 0, 0, 0, 0, \
279 0, 0, 0, 0, 0, 0, 0, 0, 0, \
280 0, 0, 0, 0, 0, 0, 0, 0, 0, \
281 0, 0, 0, 0, 0, 0, 0, 0, 0 })
284 tvector1w v00; tvector1w v01; tvector1w v02; tvector1w v03; tvector1w v04;
285 tvector1w v05; tvector1w v06;
286 tvector1w v10; tvector1w v11; tvector1w v12; tvector1w v13; tvector1w v14;
287 tvector1w v15; tvector1w v16;
288 tvector1w v20; tvector1w v21; tvector1w v22; tvector1w v23; tvector1w v24;
289 tvector1w v25; tvector1w v26;
290 tvector1w v30; tvector1w v31; tvector1w v32; tvector1w v33; tvector1w v34;
291 tvector1w v35; tvector1w v36;
292 tvector1w v40; tvector1w v41; tvector1w v42; tvector1w v43; tvector1w v44;
293 tvector1w v45; tvector1w v46;
294 tvector1w v50; tvector1w v51; tvector1w v52; tvector1w v53; tvector1w v54;
295 tvector1w v55; tvector1w v56;
296 tvector1w v60; tvector1w v61; tvector1w v62; tvector1w v63; tvector1w v64;
297 tvector1w v65; tvector1w v66;
300 #define S_1W_7X7_MATRIX_DEFAULT ((s_1w_7x7_matrix)\
301 { 0, 0, 0, 0, 0, 0, 0, \
302 0, 0, 0, 0, 0, 0, 0, \
303 0, 0, 0, 0, 0, 0, 0, \
304 0, 0, 0, 0, 0, 0, 0, \
305 0, 0, 0, 0, 0, 0, 0, \
306 0, 0, 0, 0, 0, 0, 0, \
307 0, 0, 0, 0, 0, 0, 0 })
323 #define S_1W_1X11_MATRIX_DEFAULT ((s_1w_1x11_matrix)\
324 { 0, 0, 0, 0, 0, 0, 0, 0, 0 })
327 tvector1w x_cord[MAX_CONFIG_POINTS];
328 tvector1w slope[MAX_CONFIG_POINTS-1];
329 tvector1w y_offset[MAX_CONFIG_POINTS-1];
333 tscalar1w_range1wbit slope_vec[CONFIG_UNIT_LUT_SIZE_32];
334 tscalar1w_range1wbit offset_vec[CONFIG_UNIT_LUT_SIZE_32];
335 tscalar1w_16bit x_cord_vec[CONFIG_UNIT_LUT_SIZE_32];
336 tscalar1w_16bit x_cord_max;
337 tscalar1w_5bit exponent;
338 tscalar1w_5bit slope_resolution;
339 } xcu_ref_init_vectors;
343 tvector1w elem[IMAX32_ELEM_SIZE];
344 } imax32_ref_in_vector;
348 tscalar1w search[BMA_SEARCH_BLOCK_SZ_16][BMA_SEARCH_BLOCK_SZ_16];
349 } bma_16x16_search_window;
352 tscalar1w ref[BMA_REF_BLOCK_SZ_8][BMA_REF_BLOCK_SZ_8];
356 tscalar1w sads[SADS_16x16_1];
360 tscalar1w sads[SADS_16x16_2];
364 tscalar1w sads[SADS_14x14_2];
368 tscalar1w sads[SADS_14x14_1];
372 tvector1w spatial_weight_lut[BFA_MAX_KWAY]; /* spatial weight LUT */
373 /* range weight LUT, (BFA_RW_LUT_SIZE + 1) numbers of LUT values are compressed in BFA_RW_LUT_SIZE buffer.
374 * range_weight_lut[k] = packed(drop[k], range_weight[k])
375 * where, drop[k] = range_weight[k+1] - range_weight[k]
376 * pack(msb, lsb): two 8bits numbers packed in one 16bits number */
377 tvector1w range_weight_lut[BFA_RW_LUT_SIZE];
380 /* Return type for BFA BBBs */
382 tvector2w sop; /* weighted sum of pixels */
383 tvector1w sow; /* sum of weights */
385 #endif /* __REF_VECTOR_FUNC_TYPES_H_INCLUDED__ */