aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/host/ref_vector_func_types.h
blob: 4dd05eba852e1fce5ad4240f515d830ad1e4ae30 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
/*
 * Support for Intel Camera Imaging ISP subsystem.
 * Copyright (c) 2015, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 */

#ifndef __REF_VECTOR_FUNC_TYPES_H_INCLUDED__
#define __REF_VECTOR_FUNC_TYPES_H_INCLUDED__


/*
 * Prerequisites:
 *
 */
#include "mpmath.h"
#include "bbb_config.h"
#include "isp_op1w_types.h"
#include "isp_op2w_types.h"

/* Defines for the Config Unit */
#define MAX_CONFIG_POINTS 5
#define INPUT_OFFSET_FACTOR 10
#define INPUT_SCALE_FACTOR 10
#define OUTPUT_SCALE_FACTOR 10
#define SLOPE_A_RESOLUTION 10
#define CONFIG_UNIT_LUT_SIZE_32 32 /*XCU works for ISP_NWAY = 32 */
#define LXCU_LUT_SIZE      16
#ifdef ISP2401
#define IMAX32_ELEM_SIZE   32
#endif

#define ONE_IN_Q14 (1<<(NUM_BITS-2))
#define Q29_TO_Q15_SHIFT_VAL (NUM_BITS-2)
#define Q28_TO_Q15_SHIFT_VAL (NUM_BITS-3)
#define MAX_ELEM(width_in_bits) ((1<<(width_in_bits))-1)

/* Block matching algorithm related data */
/* NUM_OF_SADS = ((SEARCH_AREA_HEIGHT - REF_BLOCK_HEIGHT)/PIXEL_SHIFT + 1)* \
					((SEARCH_AREA_WIDTH - REF_BLOCK_WIDTH)/PIXEL_SHIFT + 1) */

#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))
#define SADS_16x16_1	SADS(16, 16, 8, 8, 1)
#define SADS_16x16_2	SADS(16, 16, 8, 8, 2)
#define SADS_14x14_1	SADS(14, 14, 8, 8, 1)
#define SADS_14x14_2	SADS(14, 14, 8, 8, 2)

#define BMA_OUTPUT_MATRIX_DIM(sw_h, ref_h, p_sh)	((sw_h - ref_h)/p_sh + 1)
#define BMA_OUT_16x16_2_32		BMA_OUTPUT_MATRIX_DIM(16, 8, 2)
#define BMA_OUT_14x14_2_32		BMA_OUTPUT_MATRIX_DIM(14, 8, 2)
#define BMA_OUT_16x16_1_32 		BMA_OUTPUT_MATRIX_DIM(16, 8, 1)
#define BMA_OUT_14x14_1_32 		BMA_OUTPUT_MATRIX_DIM(14, 8, 1)
#define BMA_SEARCH_BLOCK_SZ_16 	16
#define BMA_REF_BLOCK_SZ_8    	8
#define PIXEL_SHIFT_2         	2
#define PIXEL_SHIFT_1         	1
#define BMA_SEARCH_WIN_SZ_16  	16
#define BMA_SEARCH_WIN_SZ_14  	14


/*
 * Struct type specification
 */

typedef unsigned short tscalar1w_3bit;       /* tscalar1w in interval [0, 2^3)                       */
typedef short tscalar1w_5bit_signed;         /* tscalar1w in interval [-2^(5-1), 2^(5-1))            */
typedef unsigned short tscalar1w_5bit;       /* tscalar1w in interval [0, 2^5)                       */
typedef short tscalar1w_range1wbit;          /* tscalar1w in interval [-NUM_BITS, NUM_BITS]          */
typedef short tscalar1w_unsigned_range1wbit; /* tscalar1w in interval [0, NUM_BITS]                  */
typedef unsigned short tvector_8bit;		/* 8 bit positive number */
typedef unsigned short tvector_5bit;
typedef unsigned short tvector_4bit;
typedef unsigned short tscalar1w_16bit;
typedef unsigned short tscalar1w_4bit_bma_shift;

typedef struct {
  tvector1w     v0  ;
  tvector1w     v1 ;
} s_1w_2x1_matrix;

#define S_1W_2X1_MATRIX_DEFAULT ((s_1w_2x1_matrix)\
	{ 0, 0 })

typedef struct {
	tvector1w v00;
	tvector1w v01;
} s_1w_1x2_matrix;

#define S_1W_1X2_MATRIX_DEFAULT ((s_1w_1x2_matrix)\
	{ 0, 0 })

typedef struct {
  tvector1w     v00  ;
  tvector1w     v01 ;
  tvector1w     v02 ;
} s_1w_1x3_matrix;

#define S_1W_1X3_MATRIX_DEFAULT ((s_1w_1x3_matrix)\
	{ 0, 0, 0, })

typedef struct {
  tvector1w v00; tvector1w v01; tvector1w v02;
  tvector1w v10; tvector1w v11; tvector1w v12;
} s_1w_2x3_matrix;

#define S_1W_2X3_MATRIX_DEFAULT ((s_1w_2x3_matrix)\
	{ 0, 0, 0, \
	  0, 0, 0 })

typedef struct {
  tvector1w     v00  ; tvector1w     v01 ; tvector1w     v02  ;
  tvector1w     v10  ; tvector1w     v11 ; tvector1w     v12  ;
  tvector1w     v20  ; tvector1w     v21 ; tvector1w     v22  ;
} s_1w_3x3_matrix;

#define S_1W_3X3_MATRIX_DEFAULT ((s_1w_3x3_matrix)\
	{ 0, 0, 0, \
	  0, 0, 0, \
	  0, 0, 0 })

typedef struct {
  tvector1w     v00  ; tvector1w     v01 ; tvector1w     v02  ;
  tvector1w     v10  ; tvector1w     v11 ; tvector1w     v12  ;
  tvector1w     v20  ; tvector1w     v21 ; tvector1w     v22  ;
  tvector1w     v30  ; tvector1w     v31 ; tvector1w     v32  ;
} s_1w_4x3_matrix;

#define S_1W_4X3_MATRIX_DEFAULT ((s_1w_4x3_matrix)\
	{ 0, 0, 0, \
	  0, 0, 0, \
	  0, 0, 0, \
	  0, 0, 0 })

typedef struct {
  tvector1w     v00 ;
  tvector1w     v01 ;
  tvector1w     v02 ;
  tvector1w     v03 ;
  tvector1w     v04 ;
} s_1w_1x5_matrix;

#define S_1W_1X5_MATRIX_DEFAULT ((s_1w_1x5_matrix)\
	{ 0, 0, 0, 0, 0 })

typedef struct {
  tvector1w     v00  ; tvector1w     v01 ; tvector1w     v02  ; tvector1w     v03 ; tvector1w     v04  ;
  tvector1w     v10  ; tvector1w     v11 ; tvector1w     v12  ; tvector1w     v13 ; tvector1w     v14  ;
  tvector1w     v20  ; tvector1w     v21 ; tvector1w     v22  ; tvector1w     v23 ; tvector1w     v24  ;
  tvector1w     v30  ; tvector1w     v31 ; tvector1w     v32  ; tvector1w     v33 ; tvector1w     v34  ;
  tvector1w     v40  ; tvector1w     v41 ; tvector1w     v42  ; tvector1w     v43 ; tvector1w     v44  ;
} s_1w_5x5_matrix;

#define S_1W_5X5_MATRIX_DEFAULT ((s_1w_5x5_matrix)\
	{ 0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0 })
#ifndef ISP2401
	
#else

#endif
typedef struct {
	tvector1w v00;
	tvector1w v01;
	tvector1w v02;
	tvector1w v03;
	tvector1w v04;
	tvector1w v05;
	tvector1w v06;
} s_1w_1x7_matrix;

#define S_1W_1X7_MATRIX_DEFAULT ((s_1w_1x7_matrix)\
	{ 0, 0, 0, 0, 0, 0, 0 })

typedef struct {
	tvector1w v00;
	tvector1w v01;
	tvector1w v02;
	tvector1w v03;
	tvector1w v04;
	tvector1w v05;
	tvector1w v06;
	tvector1w v07;
	tvector1w v08;
} s_1w_1x9_matrix;

#define S_1W_1X9_MATRIX_DEFAULT ((s_1w_1x9_matrix)\
	{ 0, 0, 0, 0, 0, 0, 0, 0, 0 })

typedef struct {
	tvector1w v00;
	tvector1w v01;
	tvector1w v02;
	tvector1w v03;
} s_1w_1x4_matrix;

#define S_1W_1X4_MATRIX ((s_1w_1x4_matrix)\
	{ 0, 0, 0, 0 })

typedef struct {
	tvector1w v00; tvector1w v01; tvector1w v02; tvector1w v03;
	tvector1w v10; tvector1w v11; tvector1w v12; tvector1w v13;
	tvector1w v20; tvector1w v21; tvector1w v22; tvector1w v23;
	tvector1w v30; tvector1w v31; tvector1w v32; tvector1w v33;
} s_1w_4x4_matrix;

#define S_1W_4X4_MATRIX_DEFAULT ((s_1w_4x4_matrix)\
	{ 0, 0, 0, 0, \
	  0, 0, 0, 0, \
	  0, 0, 0, 0, \
	  0, 0, 0, 0 })

typedef struct {
	tvector1w v00;
	tvector1w v01;
	tvector1w v02;
	tvector1w v03;
	tvector1w v04;
	tvector1w v05;
} s_1w_1x6_matrix;

#define S_1W_1X6_MATRIX_DEFAULT ((s_1w_1x6_matrix)\
	{ 0, 0, 0, 0, 0, 0 })

typedef struct {
	tvector1w v00; tvector1w v01; tvector1w v02; tvector1w v03; tvector1w v04; tvector1w v05;
	tvector1w v10; tvector1w v11; tvector1w v12; tvector1w v13; tvector1w v14; tvector1w v15;
	tvector1w v20; tvector1w v21; tvector1w v22; tvector1w v23; tvector1w v24; tvector1w v25;
	tvector1w v30; tvector1w v31; tvector1w v32; tvector1w v33; tvector1w v34; tvector1w v35;
	tvector1w v40; tvector1w v41; tvector1w v42; tvector1w v43; tvector1w v44; tvector1w v45;
	tvector1w v50; tvector1w v51; tvector1w v52; tvector1w v53; tvector1w v54; tvector1w v55;
} s_1w_6x6_matrix;

#define S_1W_6X6_MATRIX_DEFAULT ((s_1w_6x6_matrix)\
	{ 0, 0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, 0 })

typedef struct {
	tvector1w v00; tvector1w v01; tvector1w v02; tvector1w v03; tvector1w v04;
	tvector1w v05; tvector1w v06; tvector1w v07; tvector1w v08;
	tvector1w v10; tvector1w v11; tvector1w v12; tvector1w v13; tvector1w v14;
	tvector1w v15; tvector1w v16; tvector1w v17; tvector1w v18;
	tvector1w v20; tvector1w v21; tvector1w v22; tvector1w v23; tvector1w v24;
	tvector1w v25; tvector1w v26; tvector1w v27; tvector1w v28;
	tvector1w v30; tvector1w v31; tvector1w v32; tvector1w v33; tvector1w v34;
	tvector1w v35; tvector1w v36; tvector1w v37; tvector1w v38;
	tvector1w v40; tvector1w v41; tvector1w v42; tvector1w v43; tvector1w v44;
	tvector1w v45; tvector1w v46; tvector1w v47; tvector1w v48;
	tvector1w v50; tvector1w v51; tvector1w v52; tvector1w v53; tvector1w v54;
	tvector1w v55; tvector1w v56; tvector1w v57; tvector1w v58;
	tvector1w v60; tvector1w v61; tvector1w v62; tvector1w v63; tvector1w v64;
	tvector1w v65; tvector1w v66; tvector1w v67; tvector1w v68;
	tvector1w v70; tvector1w v71; tvector1w v72; tvector1w v73; tvector1w v74;
	tvector1w v75; tvector1w v76; tvector1w v77; tvector1w v78;
	tvector1w v80; tvector1w v81; tvector1w v82; tvector1w v83; tvector1w v84;
	tvector1w v85; tvector1w v86; tvector1w v87; tvector1w v88;
} s_1w_9x9_matrix;

#define S_1W_9X9_MATRIX_DEFAULT ((s_1w_9x9_matrix)\
	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, 0, 0, 0, 0 })

typedef struct {
	tvector1w v00; tvector1w v01; tvector1w v02; tvector1w v03; tvector1w v04;
	tvector1w v05; tvector1w v06;
	tvector1w v10; tvector1w v11; tvector1w v12; tvector1w v13; tvector1w v14;
	tvector1w v15; tvector1w v16;
	tvector1w v20; tvector1w v21; tvector1w v22; tvector1w v23; tvector1w v24;
	tvector1w v25; tvector1w v26;
	tvector1w v30; tvector1w v31; tvector1w v32; tvector1w v33; tvector1w v34;
	tvector1w v35; tvector1w v36;
	tvector1w v40; tvector1w v41; tvector1w v42; tvector1w v43; tvector1w v44;
	tvector1w v45; tvector1w v46;
	tvector1w v50; tvector1w v51; tvector1w v52; tvector1w v53; tvector1w v54;
	tvector1w v55; tvector1w v56;
	tvector1w v60; tvector1w v61; tvector1w v62; tvector1w v63; tvector1w v64;
	tvector1w v65; tvector1w v66;
} s_1w_7x7_matrix;

#define S_1W_7X7_MATRIX_DEFAULT ((s_1w_7x7_matrix)\
	{ 0, 0, 0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, 0, 0, \
	  0, 0, 0, 0, 0, 0, 0 })

typedef struct {
	tvector1w v0_0;
	tvector1w v0_1;
	tvector1w v0_2;
	tvector1w v0_3;
	tvector1w v0_4;
	tvector1w v0_5;
	tvector1w v0_6;
	tvector1w v0_7;
	tvector1w v0_8;
	tvector1w v0_9;
	tvector1w v0_10;
} s_1w_1x11_matrix;

#define S_1W_1X11_MATRIX_DEFAULT ((s_1w_1x11_matrix)\
	{ 0, 0, 0, 0, 0, 0, 0, 0, 0 })

typedef struct {
	tvector1w x_cord[MAX_CONFIG_POINTS];
	tvector1w slope[MAX_CONFIG_POINTS-1];
	tvector1w y_offset[MAX_CONFIG_POINTS-1];
} ref_config_points;

typedef struct {
	tscalar1w_range1wbit slope_vec[CONFIG_UNIT_LUT_SIZE_32];
	tscalar1w_range1wbit offset_vec[CONFIG_UNIT_LUT_SIZE_32];
	tscalar1w_16bit x_cord_vec[CONFIG_UNIT_LUT_SIZE_32];
	tscalar1w_16bit x_cord_max;
	tscalar1w_5bit exponent;
	tscalar1w_5bit slope_resolution;
} xcu_ref_init_vectors;

typedef struct {
#ifdef ISP2401
	tvector1w elem[IMAX32_ELEM_SIZE];
} imax32_ref_in_vector;

typedef struct {
#endif
	tscalar1w search[BMA_SEARCH_BLOCK_SZ_16][BMA_SEARCH_BLOCK_SZ_16];
} bma_16x16_search_window;

typedef struct {
	tscalar1w ref[BMA_REF_BLOCK_SZ_8][BMA_REF_BLOCK_SZ_8];
} ref_block_8x8;

typedef struct {
	tscalar1w sads[SADS_16x16_1];
} bma_output_16_1;

typedef struct {
	tscalar1w sads[SADS_16x16_2];
} bma_output_16_2;

typedef struct {
	tscalar1w sads[SADS_14x14_2];
} bma_output_14_2;

typedef struct {
	tscalar1w sads[SADS_14x14_1];
} bma_output_14_1;

typedef struct {
	tvector1w spatial_weight_lut[BFA_MAX_KWAY]; /* spatial weight LUT */
	/* range weight LUT, (BFA_RW_LUT_SIZE + 1) numbers of LUT values are compressed in BFA_RW_LUT_SIZE buffer.
	 * range_weight_lut[k] = packed(drop[k], range_weight[k])
	 * where, drop[k] = range_weight[k+1] - range_weight[k]
	 * pack(msb, lsb): two 8bits numbers packed in one 16bits number */
	tvector1w range_weight_lut[BFA_RW_LUT_SIZE];
} bfa_weights;

/* Return type for BFA BBBs */
typedef struct {
	tvector2w sop; /* weighted sum of pixels */
	tvector1w sow; /* sum of weights */
} bfa_7x7_output;
#endif /* __REF_VECTOR_FUNC_TYPES_H_INCLUDED__ */