GNU Linux-libre 4.14.265-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / sh_css_params.h
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 _SH_CSS_PARAMS_H_
16 #define _SH_CSS_PARAMS_H_
17
18 /*! \file */
19
20 /* Forward declaration to break mutual dependency */
21 struct ia_css_isp_parameters;
22
23 #include <type_support.h>
24 #include "ia_css_types.h"
25 #include "ia_css_binary.h"
26 #include "sh_css_legacy.h"
27
28 #include "sh_css_defs.h"        /* SH_CSS_MAX_STAGES */
29 #include "ia_css_pipeline.h"
30 #include "ia_css_isp_params.h"
31 #include "uds/uds_1.0/ia_css_uds_param.h"
32 #include "crop/crop_1.0/ia_css_crop_types.h"
33
34
35 #define PIX_SHIFT_FILTER_RUN_IN_X 12
36 #define PIX_SHIFT_FILTER_RUN_IN_Y 12
37
38 #include "ob/ob_1.0/ia_css_ob_param.h"
39 /* Isp configurations per stream */
40 struct sh_css_isp_param_configs {
41         /* OB (Optical Black) */
42         struct sh_css_isp_ob_stream_config ob;
43 };
44
45
46 /* Isp parameters per stream */
47 struct ia_css_isp_parameters {
48         /* UDS */
49         struct sh_css_sp_uds_params uds[SH_CSS_MAX_STAGES];
50         struct sh_css_isp_param_configs stream_configs;
51         struct ia_css_fpn_table     fpn_config;
52         struct ia_css_vector        motion_config;
53         const struct ia_css_morph_table   *morph_table;
54         const struct ia_css_shading_table *sc_table;
55         struct ia_css_shading_table *sc_config;
56         struct ia_css_macc_table    macc_table;
57         struct ia_css_gamma_table   gc_table;
58         struct ia_css_ctc_table     ctc_table;
59         struct ia_css_xnr_table     xnr_table;
60
61         struct ia_css_dz_config     dz_config;
62         struct ia_css_3a_config     s3a_config;
63         struct ia_css_wb_config     wb_config;
64         struct ia_css_cc_config     cc_config;
65         struct ia_css_cc_config     yuv2rgb_cc_config;
66         struct ia_css_cc_config     rgb2yuv_cc_config;
67         struct ia_css_tnr_config    tnr_config;
68         struct ia_css_ob_config     ob_config;
69         /*----- DPC configuration -----*/
70         /* The default DPC configuration is retained and currently set
71          * using the stream configuration. The code generated from genparams
72          * uses this configuration to set the DPC parameters per stage but this
73          * will be overwritten by the per pipe configuration */
74         struct ia_css_dp_config     dp_config;
75         /* ------ pipe specific DPC configuration ------ */
76         /* Please note that this implementation is a temporary solution and
77          * should be replaced by CSS per pipe configuration when the support
78          * is ready (HSD 1303967698)*/
79         struct ia_css_dp_config     pipe_dp_config[IA_CSS_PIPE_ID_NUM];
80         struct ia_css_nr_config     nr_config;
81         struct ia_css_ee_config     ee_config;
82         struct ia_css_de_config     de_config;
83         struct ia_css_gc_config     gc_config;
84         struct ia_css_anr_config    anr_config;
85         struct ia_css_ce_config     ce_config;
86         struct ia_css_formats_config     formats_config;
87 /* ---- deprecated: replaced with pipe_dvs_6axis_config---- */
88         struct ia_css_dvs_6axis_config  *dvs_6axis_config;
89         struct ia_css_ecd_config    ecd_config;
90         struct ia_css_ynr_config    ynr_config;
91         struct ia_css_yee_config    yee_config;
92         struct ia_css_fc_config     fc_config;
93         struct ia_css_cnr_config    cnr_config;
94         struct ia_css_macc_config   macc_config;
95         struct ia_css_ctc_config    ctc_config;
96         struct ia_css_aa_config     aa_config;
97         struct ia_css_aa_config     bds_config;
98         struct ia_css_aa_config     raa_config;
99         struct ia_css_rgb_gamma_table     r_gamma_table;
100         struct ia_css_rgb_gamma_table     g_gamma_table;
101         struct ia_css_rgb_gamma_table     b_gamma_table;
102         struct ia_css_anr_thres     anr_thres;
103         struct ia_css_xnr_config    xnr_config;
104         struct ia_css_xnr3_config   xnr3_config;
105         struct ia_css_uds_config    uds_config;
106         struct ia_css_crop_config   crop_config;
107         struct ia_css_output_config output_config;
108         struct ia_css_dvs_6axis_config  *pipe_dvs_6axis_config[IA_CSS_PIPE_ID_NUM];
109 /* ------ deprecated(bz675) : from ------ */
110         struct ia_css_shading_settings shading_settings;
111 /* ------ deprecated(bz675) : to ------ */
112         struct ia_css_dvs_coefficients  dvs_coefs;
113         struct ia_css_dvs2_coefficients dvs2_coefs;
114
115         bool isp_params_changed;
116         bool isp_mem_params_changed
117                 [IA_CSS_PIPE_ID_NUM][SH_CSS_MAX_STAGES][IA_CSS_NUM_MEMORIES];
118         bool dz_config_changed;
119         bool motion_config_changed;
120         bool dis_coef_table_changed;
121         bool dvs2_coef_table_changed;
122         bool morph_table_changed;
123         bool sc_table_changed;
124         bool sc_table_dirty;
125         unsigned int sc_table_last_pipe_num;
126         bool anr_thres_changed;
127 /* ---- deprecated: replaced with pipe_dvs_6axis_config_changed ---- */
128         bool dvs_6axis_config_changed;
129         /* ------ pipe specific DPC configuration ------ */
130         /* Please note that this implementation is a temporary solution and
131          * should be replaced by CSS per pipe configuration when the support
132          * is ready (HSD 1303967698) */
133         bool pipe_dpc_config_changed[IA_CSS_PIPE_ID_NUM];
134 /* ------ deprecated(bz675) : from ------ */
135         bool shading_settings_changed;
136 /* ------ deprecated(bz675) : to ------ */
137         bool pipe_dvs_6axis_config_changed[IA_CSS_PIPE_ID_NUM];
138
139         bool config_changed[IA_CSS_NUM_PARAMETER_IDS];
140
141         unsigned int sensor_binning;
142         /* local buffers, used to re-order the 3a statistics in vmem-format */
143         struct sh_css_ddr_address_map pipe_ddr_ptrs[IA_CSS_PIPE_ID_NUM];
144         struct sh_css_ddr_address_map_size pipe_ddr_ptrs_size[IA_CSS_PIPE_ID_NUM];
145         struct sh_css_ddr_address_map ddr_ptrs;
146         struct sh_css_ddr_address_map_size ddr_ptrs_size;
147         struct ia_css_frame *output_frame; /**< Output frame the config is to be applied to (optional) */
148         uint32_t isp_parameters_id; /**< Unique ID to track which config was actually applied to a particular frame */
149 };
150
151 void
152 ia_css_params_store_ia_css_host_data(
153         hrt_vaddress ddr_addr,
154         struct ia_css_host_data *data);
155
156 enum ia_css_err
157 ia_css_params_store_sctbl(
158             const struct ia_css_pipeline_stage *stage,
159             hrt_vaddress ddr_addr,
160             const struct ia_css_shading_table *shading_table);
161
162 struct ia_css_host_data *
163 ia_css_params_alloc_convert_sctbl(
164             const struct ia_css_pipeline_stage *stage,
165             const struct ia_css_shading_table *shading_table);
166
167 struct ia_css_isp_config *
168 sh_css_pipe_isp_config_get(struct ia_css_pipe *pipe);
169
170 /* ipu address allocation/free for gdc lut */
171 hrt_vaddress
172 sh_css_params_alloc_gdc_lut(void);
173 void
174 sh_css_params_free_gdc_lut(hrt_vaddress addr);
175
176 enum ia_css_err
177 sh_css_params_map_and_store_default_gdc_lut(void);
178
179 void
180 sh_css_params_free_default_gdc_lut(void);
181
182 hrt_vaddress
183 sh_css_params_get_default_gdc_lut(void);
184
185 hrt_vaddress
186 sh_css_pipe_get_pp_gdc_lut(const struct ia_css_pipe *pipe);
187
188 #endif /* _SH_CSS_PARAMS_H_ */