GNU Linux-libre 4.14.254-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / runtime / binary / interface / ia_css_binary.h
1 #ifndef ISP2401
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2015, Intel Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  */
15 #else
16 /**
17 Support for Intel Camera Imaging ISP subsystem.
18 Copyright (c) 2010 - 2015, Intel Corporation.
19
20 This program is free software; you can redistribute it and/or modify it
21 under the terms and conditions of the GNU General Public License,
22 version 2, as published by the Free Software Foundation.
23
24 This program is distributed in the hope it will be useful, but WITHOUT
25 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
26 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
27 more details.
28 */
29 #endif
30
31 #ifndef _IA_CSS_BINARY_H_
32 #define _IA_CSS_BINARY_H_
33
34 #include <type_support.h>
35 #include "ia_css_types.h"
36 #include "ia_css_err.h"
37 #include "ia_css_stream_format.h"
38 #include "ia_css_stream_public.h"
39 #include "ia_css_frame_public.h"
40 #include "sh_css_metrics.h"
41 #include "isp/kernels/fixedbds/fixedbds_1.0/ia_css_fixedbds_types.h"
42
43 /* The binary mode is used in pre-processor expressions so we cannot
44  * use an enum here. */
45 #define IA_CSS_BINARY_MODE_COPY       0
46 #define IA_CSS_BINARY_MODE_PREVIEW    1
47 #define IA_CSS_BINARY_MODE_PRIMARY    2
48 #define IA_CSS_BINARY_MODE_VIDEO      3
49 #define IA_CSS_BINARY_MODE_PRE_ISP    4
50 #define IA_CSS_BINARY_MODE_GDC        5
51 #define IA_CSS_BINARY_MODE_POST_ISP   6
52 #define IA_CSS_BINARY_MODE_ANR        7
53 #define IA_CSS_BINARY_MODE_CAPTURE_PP 8
54 #define IA_CSS_BINARY_MODE_VF_PP      9
55 #define IA_CSS_BINARY_MODE_PRE_DE     10
56 #define IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE0    11
57 #define IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE1    12
58 #define IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE2    13
59 #define IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE3    14
60 #define IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE4    15
61 #define IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE5    16
62 #define IA_CSS_BINARY_NUM_MODES       17
63
64 #define MAX_NUM_PRIMARY_STAGES 6
65 #define NUM_PRIMARY_HQ_STAGES  6  /* number of primary stages for ISP2.6.1 high quality pipe */
66 #define NUM_PRIMARY_STAGES     1  /* number of primary satges for ISP1/ISP2.2 pipe */
67
68 /* Indicate where binaries can read input from */
69 #define IA_CSS_BINARY_INPUT_SENSOR   0
70 #define IA_CSS_BINARY_INPUT_MEMORY   1
71 #define IA_CSS_BINARY_INPUT_VARIABLE 2
72
73 /* Should be included without the path.
74    However, that requires adding the path to numerous makefiles
75    that have nothing to do with isp parameters.
76  */
77 #include "runtime/isp_param/interface/ia_css_isp_param_types.h"
78
79 /* now these ports only include output ports but not vf output ports */
80 enum {
81         IA_CSS_BINARY_OUTPUT_PORT_0 = 0,
82         IA_CSS_BINARY_OUTPUT_PORT_1 = 1,
83         IA_CSS_BINARY_MAX_OUTPUT_PORTS = 2
84 };
85
86 struct ia_css_cas_binary_descr {
87         unsigned int num_stage;
88         unsigned int num_output_stage;
89         struct ia_css_frame_info *in_info;
90         struct ia_css_frame_info *internal_out_info;
91         struct ia_css_frame_info *out_info;
92         struct ia_css_frame_info *vf_info;
93         bool *is_output_stage;
94 };
95
96 #define IA_CSS_DEFAULT_CAS_BINARY_DESCR \
97 { \
98         0,              \
99         0,              \
100         NULL,           \
101         NULL,           \
102         NULL,           \
103         NULL,           \
104         NULL,           \
105 }
106
107 struct ia_css_binary_descr {
108         int mode;
109         bool online;
110         bool continuous;
111         bool striped;
112         bool two_ppc;
113         bool enable_yuv_ds;
114         bool enable_high_speed;
115         bool enable_dvs_6axis;
116         bool enable_reduced_pipe;
117         bool enable_dz;
118         bool enable_xnr;
119         bool enable_fractional_ds;
120         bool enable_dpc;
121 #ifdef ISP2401
122         bool enable_luma_only;
123         bool enable_tnr;
124 #endif
125         bool enable_capture_pp_bli;
126         struct ia_css_resolution dvs_env;
127         enum ia_css_stream_format stream_format;
128         struct ia_css_frame_info *in_info;              /* the info of the input-frame with the
129                                                            ISP required resolution. */
130         struct ia_css_frame_info *bds_out_info;
131         struct ia_css_frame_info *out_info[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
132         struct ia_css_frame_info *vf_info;
133         unsigned int isp_pipe_version;
134         unsigned int required_bds_factor;
135         int stream_config_left_padding;
136 };
137
138 struct ia_css_binary {
139         const struct ia_css_binary_xinfo *info;
140         enum ia_css_stream_format input_format;
141         struct ia_css_frame_info in_frame_info;
142         struct ia_css_frame_info internal_frame_info;
143         struct ia_css_frame_info out_frame_info[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
144         struct ia_css_resolution effective_in_frame_res;
145         struct ia_css_frame_info vf_frame_info;
146         int                      input_buf_vectors;
147         int                      deci_factor_log2;
148         int                      vf_downscale_log2;
149         int                      s3atbl_width;
150         int                      s3atbl_height;
151         int                      s3atbl_isp_width;
152         int                      s3atbl_isp_height;
153         unsigned int             morph_tbl_width;
154         unsigned int             morph_tbl_aligned_width;
155         unsigned int             morph_tbl_height;
156         int                      sctbl_width_per_color;
157         int                      sctbl_aligned_width_per_color;
158         int                      sctbl_height;
159 #ifdef ISP2401
160         int                      sctbl_legacy_width_per_color;
161         int                      sctbl_legacy_height;
162 #endif
163         struct ia_css_sdis_info  dis;
164         struct ia_css_resolution dvs_envelope;
165         bool                     online;
166         unsigned int             uds_xc;
167         unsigned int             uds_yc;
168         unsigned int             left_padding;
169         struct sh_css_binary_metrics metrics;
170         struct ia_css_isp_param_host_segments mem_params;
171         struct ia_css_isp_param_css_segments  css_params;
172 };
173
174 #ifdef ISP2401
175
176 #define IA_CSS_BINARY_DEFAULT_SETTINGS \
177 { \
178         NULL, \
179         IA_CSS_STREAM_FORMAT_YUV420_8_LEGACY, \
180         IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
181         IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
182         {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
183         { 0, 0},/* effective_in_frame_res */ \
184         IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
185         0,      /* input_buf_vectors */ \
186         0,      /* deci_factor_log2 */ \
187         0,      /* vf_downscale_log2 */ \
188         0,      /* s3atbl_width */ \
189         0,      /* s3atbl_height */ \
190         0,      /* s3atbl_isp_width */ \
191         0,      /* s3atbl_isp_height */ \
192         0,      /* morph_tbl_width */ \
193         0,      /* morph_tbl_aligned_width */ \
194         0,      /* morph_tbl_height */ \
195         0,      /* sctbl_width_per_color */ \
196         0,      /* sctbl_aligned_width_per_color */ \
197         0,      /* sctbl_height */ \
198         0,      /* sctbl_legacy_width_per_color */ \
199         0,      /* sctbl_legacy_height */ \
200         IA_CSS_DEFAULT_SDIS_INFO, /* dis */ \
201         { 0, 0},/* dvs_envelope_info */ \
202         false,  /* online */ \
203         0,      /* uds_xc */ \
204         0,      /* uds_yc */ \
205         0,      /* left_padding */ \
206         DEFAULT_BINARY_METRICS, /* metrics */ \
207         IA_CSS_DEFAULT_ISP_MEM_PARAMS, /* mem_params */ \
208         IA_CSS_DEFAULT_ISP_CSS_PARAMS, /* css_params */ \
209 }
210
211 #else
212
213 #define IA_CSS_BINARY_DEFAULT_SETTINGS \
214 { \
215         NULL, \
216         IA_CSS_STREAM_FORMAT_YUV420_8_LEGACY, \
217         IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
218         IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
219         {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
220         { 0, 0},/* effective_in_frame_res */ \
221         IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
222         0,      /* input_buf_vectors */ \
223         0,      /* deci_factor_log2 */ \
224         0,      /* vf_downscale_log2 */ \
225         0,      /* s3atbl_width */ \
226         0,      /* s3atbl_height */ \
227         0,      /* s3atbl_isp_width */ \
228         0,      /* s3atbl_isp_height */ \
229         0,      /* morph_tbl_width */ \
230         0,      /* morph_tbl_aligned_width */ \
231         0,      /* morph_tbl_height */ \
232         0,      /* sctbl_width_per_color */ \
233         0,      /* sctbl_aligned_width_per_color */ \
234         0,      /* sctbl_height */ \
235         IA_CSS_DEFAULT_SDIS_INFO, /* dis */ \
236         { 0, 0},/* dvs_envelope_info */ \
237         false,  /* online */ \
238         0,      /* uds_xc */ \
239         0,      /* uds_yc */ \
240         0,      /* left_padding */ \
241         DEFAULT_BINARY_METRICS, /* metrics */ \
242         IA_CSS_DEFAULT_ISP_MEM_PARAMS, /* mem_params */ \
243         IA_CSS_DEFAULT_ISP_CSS_PARAMS, /* css_params */ \
244 }
245
246 #endif
247
248 enum ia_css_err
249 ia_css_binary_init_infos(void);
250
251 enum ia_css_err
252 ia_css_binary_uninit(void);
253
254 enum ia_css_err
255 ia_css_binary_fill_info(const struct ia_css_binary_xinfo *xinfo,
256                  bool online,
257                  bool two_ppc,
258                  enum ia_css_stream_format stream_format,
259                  const struct ia_css_frame_info *in_info,
260                  const struct ia_css_frame_info *bds_out_info,
261                  const struct ia_css_frame_info *out_info[],
262                  const struct ia_css_frame_info *vf_info,
263                  struct ia_css_binary *binary,
264                  struct ia_css_resolution *dvs_env,
265                  int stream_config_left_padding,
266                  bool accelerator);
267
268 enum ia_css_err
269 ia_css_binary_find(struct ia_css_binary_descr *descr,
270                    struct ia_css_binary *binary);
271
272 /** @brief Get the shading information of the specified shading correction type.
273  *
274  * @param[in] binary: The isp binary which has the shading correction.
275  * @param[in] type: The shading correction type.
276  * @param[in] required_bds_factor: The bayer downscaling factor required in the pipe.
277  * @param[in] stream_config: The stream configuration.
278 #ifndef ISP2401
279  * @param[out] info: The shading information.
280 #else
281  * @param[out] shading_info: The shading information.
282  *              The shading information necessary as API is stored in the shading_info.
283 #endif
284  *              The driver needs to get this information to generate
285 #ifndef ISP2401
286  *              the shading table directly required in the isp.
287 #else
288  *              the shading table directly required from ISP.
289  * @param[out] pipe_config: The pipe configuration.
290  *              The shading information related to ISP (but, not necessary as API) is stored in the pipe_config.
291 #endif
292  * @return      IA_CSS_SUCCESS or error code upon error.
293  *
294  */
295 enum ia_css_err
296 ia_css_binary_get_shading_info(const struct ia_css_binary *binary,
297                         enum ia_css_shading_correction_type type,
298                         unsigned int required_bds_factor,
299                         const struct ia_css_stream_config *stream_config,
300 #ifndef ISP2401
301                         struct ia_css_shading_info *info);
302 #else
303                         struct ia_css_shading_info *shading_info,
304                         struct ia_css_pipe_config *pipe_config);
305 #endif
306
307 enum ia_css_err
308 ia_css_binary_3a_grid_info(const struct ia_css_binary *binary,
309                            struct ia_css_grid_info *info,
310                            struct ia_css_pipe *pipe);
311
312 void
313 ia_css_binary_dvs_grid_info(const struct ia_css_binary *binary,
314                             struct ia_css_grid_info *info,
315                             struct ia_css_pipe *pipe);
316
317 void
318 ia_css_binary_dvs_stat_grid_info(
319         const struct ia_css_binary *binary,
320         struct ia_css_grid_info *info,
321         struct ia_css_pipe *pipe);
322
323 unsigned
324 ia_css_binary_max_vf_width(void);
325
326 void
327 ia_css_binary_destroy_isp_parameters(struct ia_css_binary *binary);
328
329 void
330 ia_css_binary_get_isp_binaries(struct ia_css_binary_xinfo **binaries,
331         uint32_t *num_isp_binaries);
332
333 #endif /* _IA_CSS_BINARY_H_ */