1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /** 3 Support for Intel Camera Imaging ISP subsystem. 4 Copyright (c) 2010 - 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 16 #ifndef _IA_CSS_BINARY_H_ 17 #define _IA_CSS_BINARY_H_ 18 19 #include <type_support.h> 20 #include "ia_css_types.h" 21 #include "ia_css_err.h" 22 #include "ia_css_stream_format.h" 23 #include "ia_css_stream_public.h" 24 #include "ia_css_frame_public.h" 25 #include "sh_css_metrics.h" 26 #include "isp/kernels/fixedbds/fixedbds_1.0/ia_css_fixedbds_types.h" 27 28 /* The binary mode is used in pre-processor expressions so we cannot 29 * use an enum here. */ 30 #define IA_CSS_BINARY_MODE_COPY 0 31 #define IA_CSS_BINARY_MODE_PREVIEW 1 32 #define IA_CSS_BINARY_MODE_PRIMARY 2 33 #define IA_CSS_BINARY_MODE_VIDEO 3 34 #define IA_CSS_BINARY_MODE_PRE_ISP 4 35 #define IA_CSS_BINARY_MODE_GDC 5 36 #define IA_CSS_BINARY_MODE_POST_ISP 6 37 #define IA_CSS_BINARY_MODE_ANR 7 38 #define IA_CSS_BINARY_MODE_CAPTURE_PP 8 39 #define IA_CSS_BINARY_MODE_VF_PP 9 40 #define IA_CSS_BINARY_MODE_PRE_DE 10 41 #define IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE0 11 42 #define IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE1 12 43 #define IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE2 13 44 #define IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE3 14 45 #define IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE4 15 46 #define IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE5 16 47 #define IA_CSS_BINARY_NUM_MODES 17 48 49 #define MAX_NUM_PRIMARY_STAGES 6 50 #define NUM_PRIMARY_HQ_STAGES 6 /* number of primary stages for ISP2.6.1 high quality pipe */ 51 #define NUM_PRIMARY_STAGES 1 /* number of primary satges for ISP1/ISP2.2 pipe */ 52 53 /* Indicate where binaries can read input from */ 54 #define IA_CSS_BINARY_INPUT_SENSOR 0 55 #define IA_CSS_BINARY_INPUT_MEMORY 1 56 #define IA_CSS_BINARY_INPUT_VARIABLE 2 57 58 /* Should be included without the path. 59 However, that requires adding the path to numerous makefiles 60 that have nothing to do with isp parameters. 61 */ 62 #include "runtime/isp_param/interface/ia_css_isp_param_types.h" 63 64 /* now these ports only include output ports but not vf output ports */ 65 enum { 66 IA_CSS_BINARY_OUTPUT_PORT_0 = 0, 67 IA_CSS_BINARY_OUTPUT_PORT_1 = 1, 68 IA_CSS_BINARY_MAX_OUTPUT_PORTS = 2 69 }; 70 71 struct ia_css_cas_binary_descr { 72 unsigned int num_stage; 73 unsigned int num_output_stage; 74 struct ia_css_frame_info *in_info; 75 struct ia_css_frame_info *internal_out_info; 76 struct ia_css_frame_info *out_info; 77 struct ia_css_frame_info *vf_info; 78 bool *is_output_stage; 79 }; 80 81 struct ia_css_binary_descr { 82 int mode; 83 bool online; 84 bool continuous; 85 bool striped; 86 bool two_ppc; 87 bool enable_yuv_ds; 88 bool enable_high_speed; 89 bool enable_dvs_6axis; 90 bool enable_reduced_pipe; 91 bool enable_dz; 92 bool enable_xnr; 93 bool enable_fractional_ds; 94 bool enable_dpc; 95 96 /* ISP2401 */ 97 bool enable_tnr; 98 99 bool enable_capture_pp_bli; 100 struct ia_css_resolution dvs_env; 101 enum atomisp_input_format stream_format; 102 struct ia_css_frame_info *in_info; /* the info of the input-frame with the 103 ISP required resolution. */ 104 struct ia_css_frame_info *bds_out_info; 105 struct ia_css_frame_info *out_info[IA_CSS_BINARY_MAX_OUTPUT_PORTS]; 106 struct ia_css_frame_info *vf_info; 107 unsigned int isp_pipe_version; 108 unsigned int required_bds_factor; 109 int stream_config_left_padding; 110 }; 111 112 struct ia_css_binary { 113 const struct ia_css_binary_xinfo *info; 114 enum atomisp_input_format input_format; 115 struct ia_css_frame_info in_frame_info; 116 struct ia_css_frame_info internal_frame_info; 117 struct ia_css_frame_info out_frame_info[IA_CSS_BINARY_MAX_OUTPUT_PORTS]; 118 struct ia_css_resolution effective_in_frame_res; 119 struct ia_css_frame_info vf_frame_info; 120 int input_buf_vectors; 121 int deci_factor_log2; 122 int vf_downscale_log2; 123 int s3atbl_width; 124 int s3atbl_height; 125 int s3atbl_isp_width; 126 int s3atbl_isp_height; 127 unsigned int morph_tbl_width; 128 unsigned int morph_tbl_aligned_width; 129 unsigned int morph_tbl_height; 130 int sctbl_width_per_color; 131 int sctbl_aligned_width_per_color; 132 int sctbl_height; 133 struct ia_css_sdis_info dis; 134 struct ia_css_resolution dvs_envelope; 135 bool online; 136 unsigned int uds_xc; 137 unsigned int uds_yc; 138 unsigned int left_padding; 139 struct sh_css_binary_metrics metrics; 140 struct ia_css_isp_param_host_segments mem_params; 141 struct ia_css_isp_param_css_segments css_params; 142 }; 143 144 #define IA_CSS_BINARY_DEFAULT_SETTINGS { \ 145 .input_format = ATOMISP_INPUT_FORMAT_YUV420_8_LEGACY, \ 146 .in_frame_info = IA_CSS_BINARY_DEFAULT_FRAME_INFO, \ 147 .internal_frame_info = IA_CSS_BINARY_DEFAULT_FRAME_INFO, \ 148 .out_frame_info = {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \ 149 .vf_frame_info = IA_CSS_BINARY_DEFAULT_FRAME_INFO, \ 150 } 151 152 int 153 ia_css_binary_init_infos(void); 154 155 int 156 ia_css_binary_uninit(void); 157 158 int 159 ia_css_binary_fill_info(const struct ia_css_binary_xinfo *xinfo, 160 bool online, 161 bool two_ppc, 162 enum atomisp_input_format stream_format, 163 const struct ia_css_frame_info *in_info, 164 const struct ia_css_frame_info *bds_out_info, 165 const struct ia_css_frame_info *out_info[], 166 const struct ia_css_frame_info *vf_info, 167 struct ia_css_binary *binary, 168 struct ia_css_resolution *dvs_env, 169 int stream_config_left_padding, 170 bool accelerator); 171 172 int 173 ia_css_binary_find(struct ia_css_binary_descr *descr, 174 struct ia_css_binary *binary); 175 176 /* @brief Get the shading information of the specified shading correction type. 177 * 178 * @param[in] binary: The isp binary which has the shading correction. 179 * @param[in] type: The shading correction type. 180 * @param[in] required_bds_factor: The bayer downscaling factor required in the pipe. 181 * @param[in] stream_config: The stream configuration. 182 * @param[out] shading_info: The shading information. 183 * The shading information necessary as API is stored in the shading_info. 184 * The driver needs to get this information to generate 185 * the shading table directly required from ISP. 186 * @param[out] pipe_config: The pipe configuration. 187 * The shading information related to ISP (but, not necessary as API) is stored in the pipe_config. 188 * @return 0 or error code upon error. 189 * 190 */ 191 int 192 ia_css_binary_get_shading_info(const struct ia_css_binary *binary, 193 enum ia_css_shading_correction_type type, 194 unsigned int required_bds_factor, 195 const struct ia_css_stream_config *stream_config, 196 struct ia_css_shading_info *shading_info, 197 struct ia_css_pipe_config *pipe_config); 198 199 int 200 ia_css_binary_3a_grid_info(const struct ia_css_binary *binary, 201 struct ia_css_grid_info *info, 202 struct ia_css_pipe *pipe); 203 204 void 205 ia_css_binary_dvs_grid_info(const struct ia_css_binary *binary, 206 struct ia_css_grid_info *info, 207 struct ia_css_pipe *pipe); 208 209 void 210 ia_css_binary_dvs_stat_grid_info( 211 const struct ia_css_binary *binary, 212 struct ia_css_grid_info *info, 213 struct ia_css_pipe *pipe); 214 215 unsigned 216 ia_css_binary_max_vf_width(void); 217 218 void 219 ia_css_binary_destroy_isp_parameters(struct ia_css_binary *binary); 220 221 void 222 ia_css_binary_get_isp_binaries(struct ia_css_binary_xinfo **binaries, 223 uint32_t *num_isp_binaries); 224 225 #endif /* _IA_CSS_BINARY_H_ */ 226