aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/binary/interface/ia_css_binary.h
blob: c65194619a34a832febcbb395a82b82c11980bf2 (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
#ifndef ISP2401
/*
 * 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.
 */
#else
/**
Support for Intel Camera Imaging ISP subsystem.
Copyright (c) 2010 - 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.
*/
#endif

#ifndef _IA_CSS_BINARY_H_
#define _IA_CSS_BINARY_H_

#include <type_support.h>
#include "ia_css_types.h"
#include "ia_css_err.h"
#include "ia_css_stream_format.h"
#include "ia_css_stream_public.h"
#include "ia_css_frame_public.h"
#include "sh_css_metrics.h"
#include "isp/kernels/fixedbds/fixedbds_1.0/ia_css_fixedbds_types.h"

/* The binary mode is used in pre-processor expressions so we cannot
 * use an enum here. */
#define IA_CSS_BINARY_MODE_COPY       0
#define IA_CSS_BINARY_MODE_PREVIEW    1
#define IA_CSS_BINARY_MODE_PRIMARY    2
#define IA_CSS_BINARY_MODE_VIDEO      3
#define IA_CSS_BINARY_MODE_PRE_ISP    4
#define IA_CSS_BINARY_MODE_GDC        5
#define IA_CSS_BINARY_MODE_POST_ISP   6
#define IA_CSS_BINARY_MODE_ANR        7
#define IA_CSS_BINARY_MODE_CAPTURE_PP 8
#define IA_CSS_BINARY_MODE_VF_PP      9
#define IA_CSS_BINARY_MODE_PRE_DE     10
#define IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE0    11
#define IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE1    12
#define IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE2    13
#define IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE3    14
#define IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE4    15
#define IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE5    16
#define IA_CSS_BINARY_NUM_MODES       17

#define MAX_NUM_PRIMARY_STAGES 6
#define NUM_PRIMARY_HQ_STAGES  6  /* number of primary stages for ISP2.6.1 high quality pipe */
#define NUM_PRIMARY_STAGES     1  /* number of primary satges for ISP1/ISP2.2 pipe */

/* Indicate where binaries can read input from */
#define IA_CSS_BINARY_INPUT_SENSOR   0
#define IA_CSS_BINARY_INPUT_MEMORY   1
#define IA_CSS_BINARY_INPUT_VARIABLE 2

/* Should be included without the path.
   However, that requires adding the path to numerous makefiles
   that have nothing to do with isp parameters.
 */
#include "runtime/isp_param/interface/ia_css_isp_param_types.h"

/* now these ports only include output ports but not vf output ports */
enum {
	IA_CSS_BINARY_OUTPUT_PORT_0 = 0,
	IA_CSS_BINARY_OUTPUT_PORT_1 = 1,
	IA_CSS_BINARY_MAX_OUTPUT_PORTS = 2
};

struct ia_css_cas_binary_descr {
	unsigned int num_stage;
	unsigned int num_output_stage;
	struct ia_css_frame_info *in_info;
	struct ia_css_frame_info *internal_out_info;
	struct ia_css_frame_info *out_info;
	struct ia_css_frame_info *vf_info;
	bool *is_output_stage;
};

#define IA_CSS_DEFAULT_CAS_BINARY_DESCR \
{ \
	0,		\
	0,		\
	NULL,		\
	NULL,		\
	NULL,		\
	NULL,		\
	NULL,		\
}

struct ia_css_binary_descr {
	int mode;
	bool online;
	bool continuous;
	bool striped;
	bool two_ppc;
	bool enable_yuv_ds;
	bool enable_high_speed;
	bool enable_dvs_6axis;
	bool enable_reduced_pipe;
	bool enable_dz;
	bool enable_xnr;
	bool enable_fractional_ds;
	bool enable_dpc;
#ifdef ISP2401
	bool enable_luma_only;
	bool enable_tnr;
#endif
	bool enable_capture_pp_bli;
	struct ia_css_resolution dvs_env;
	enum ia_css_stream_format stream_format;
	struct ia_css_frame_info *in_info;		/* the info of the input-frame with the
							   ISP required resolution. */
	struct ia_css_frame_info *bds_out_info;
	struct ia_css_frame_info *out_info[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
	struct ia_css_frame_info *vf_info;
	unsigned int isp_pipe_version;
	unsigned int required_bds_factor;
	int stream_config_left_padding;
};

struct ia_css_binary {
	const struct ia_css_binary_xinfo *info;
	enum ia_css_stream_format input_format;
	struct ia_css_frame_info in_frame_info;
	struct ia_css_frame_info internal_frame_info;
	struct ia_css_frame_info out_frame_info[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
	struct ia_css_resolution effective_in_frame_res;
	struct ia_css_frame_info vf_frame_info;
	int                      input_buf_vectors;
	int                      deci_factor_log2;
	int                      vf_downscale_log2;
	int                      s3atbl_width;
	int                      s3atbl_height;
	int                      s3atbl_isp_width;
	int                      s3atbl_isp_height;
	unsigned int             morph_tbl_width;
	unsigned int             morph_tbl_aligned_width;
	unsigned int             morph_tbl_height;
	int                      sctbl_width_per_color;
	int                      sctbl_aligned_width_per_color;
	int                      sctbl_height;
#ifdef ISP2401
	int                      sctbl_legacy_width_per_color;
	int                      sctbl_legacy_height;
#endif
	struct ia_css_sdis_info	 dis;
	struct ia_css_resolution dvs_envelope;
	bool                     online;
	unsigned int             uds_xc;
	unsigned int             uds_yc;
	unsigned int             left_padding;
	struct sh_css_binary_metrics metrics;
	struct ia_css_isp_param_host_segments mem_params;
	struct ia_css_isp_param_css_segments  css_params;
};

#ifdef ISP2401

#define IA_CSS_BINARY_DEFAULT_SETTINGS \
{ \
	NULL, \
	IA_CSS_STREAM_FORMAT_YUV420_8_LEGACY, \
	IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
	IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
	{IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
	{ 0, 0},/* effective_in_frame_res */ \
	IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
	0,	/* input_buf_vectors */ \
	0,	/* deci_factor_log2 */ \
	0,	/* vf_downscale_log2 */ \
	0,	/* s3atbl_width */ \
	0,	/* s3atbl_height */ \
	0,	/* s3atbl_isp_width */ \
	0,	/* s3atbl_isp_height */ \
	0,	/* morph_tbl_width */ \
	0,	/* morph_tbl_aligned_width */ \
	0,	/* morph_tbl_height */ \
	0,	/* sctbl_width_per_color */ \
	0,	/* sctbl_aligned_width_per_color */ \
	0,	/* sctbl_height */ \
	0,	/* sctbl_legacy_width_per_color */ \
	0,	/* sctbl_legacy_height */ \
	IA_CSS_DEFAULT_SDIS_INFO, /* dis */ \
	{ 0, 0},/* dvs_envelope_info */ \
	false,	/* online */ \
	0,	/* uds_xc */ \
	0,	/* uds_yc */ \
	0,	/* left_padding */ \
	DEFAULT_BINARY_METRICS,	/* metrics */ \
	IA_CSS_DEFAULT_ISP_MEM_PARAMS, /* mem_params */ \
	IA_CSS_DEFAULT_ISP_CSS_PARAMS, /* css_params */ \
}

#else

#define IA_CSS_BINARY_DEFAULT_SETTINGS \
{ \
	NULL, \
	IA_CSS_STREAM_FORMAT_YUV420_8_LEGACY, \
	IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
	IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
	{IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
	{ 0, 0},/* effective_in_frame_res */ \
	IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
	0,	/* input_buf_vectors */ \
	0,	/* deci_factor_log2 */ \
	0,	/* vf_downscale_log2 */ \
	0,	/* s3atbl_width */ \
	0,	/* s3atbl_height */ \
	0,	/* s3atbl_isp_width */ \
	0,	/* s3atbl_isp_height */ \
	0,	/* morph_tbl_width */ \
	0,	/* morph_tbl_aligned_width */ \
	0,	/* morph_tbl_height */ \
	0,	/* sctbl_width_per_color */ \
	0,	/* sctbl_aligned_width_per_color */ \
	0,	/* sctbl_height */ \
	IA_CSS_DEFAULT_SDIS_INFO, /* dis */ \
	{ 0, 0},/* dvs_envelope_info */ \
	false,	/* online */ \
	0,	/* uds_xc */ \
	0,	/* uds_yc */ \
	0,	/* left_padding */ \
	DEFAULT_BINARY_METRICS,	/* metrics */ \
	IA_CSS_DEFAULT_ISP_MEM_PARAMS, /* mem_params */ \
	IA_CSS_DEFAULT_ISP_CSS_PARAMS, /* css_params */ \
}

#endif

enum ia_css_err
ia_css_binary_init_infos(void);

enum ia_css_err
ia_css_binary_uninit(void);

enum ia_css_err
ia_css_binary_fill_info(const struct ia_css_binary_xinfo *xinfo,
		 bool online,
		 bool two_ppc,
		 enum ia_css_stream_format stream_format,
		 const struct ia_css_frame_info *in_info,
		 const struct ia_css_frame_info *bds_out_info,
		 const struct ia_css_frame_info *out_info[],
		 const struct ia_css_frame_info *vf_info,
		 struct ia_css_binary *binary,
		 struct ia_css_resolution *dvs_env,
		 int stream_config_left_padding,
		 bool accelerator);

enum ia_css_err
ia_css_binary_find(struct ia_css_binary_descr *descr,
		   struct ia_css_binary *binary);

/** @brief Get the shading information of the specified shading correction type.
 *
 * @param[in] binary: The isp binary which has the shading correction.
 * @param[in] type: The shading correction type.
 * @param[in] required_bds_factor: The bayer downscaling factor required in the pipe.
 * @param[in] stream_config: The stream configuration.
#ifndef ISP2401
 * @param[out] info: The shading information.
#else
 * @param[out] shading_info: The shading information.
 *		The shading information necessary as API is stored in the shading_info.
#endif
 *		The driver needs to get this information to generate
#ifndef ISP2401
 *		the shading table directly required in the isp.
#else
 *		the shading table directly required from ISP.
 * @param[out] pipe_config: The pipe configuration.
 *		The shading information related to ISP (but, not necessary as API) is stored in the pipe_config.
#endif
 * @return	IA_CSS_SUCCESS or error code upon error.
 *
 */
enum ia_css_err
ia_css_binary_get_shading_info(const struct ia_css_binary *binary,
			enum ia_css_shading_correction_type type,
			unsigned int required_bds_factor,
			const struct ia_css_stream_config *stream_config,
#ifndef ISP2401
			struct ia_css_shading_info *info);
#else
			struct ia_css_shading_info *shading_info,
			struct ia_css_pipe_config *pipe_config);
#endif

enum ia_css_err
ia_css_binary_3a_grid_info(const struct ia_css_binary *binary,
			   struct ia_css_grid_info *info,
			   struct ia_css_pipe *pipe);

void
ia_css_binary_dvs_grid_info(const struct ia_css_binary *binary,
			    struct ia_css_grid_info *info,
			    struct ia_css_pipe *pipe);

void
ia_css_binary_dvs_stat_grid_info(
	const struct ia_css_binary *binary,
	struct ia_css_grid_info *info,
	struct ia_css_pipe *pipe);

unsigned
ia_css_binary_max_vf_width(void);

void
ia_css_binary_destroy_isp_parameters(struct ia_css_binary *binary);

void
ia_css_binary_get_isp_binaries(struct ia_css_binary_xinfo **binaries,
	uint32_t *num_isp_binaries);

#endif /* _IA_CSS_BINARY_H_ */