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_luma_only; 98 bool enable_tnr; 99 100 bool enable_capture_pp_bli; 101 struct ia_css_resolution dvs_env; 102 enum atomisp_input_format stream_format; 103 struct ia_css_frame_info *in_info; /* the info of the input-frame with the 104 ISP required resolution. */ 105 struct ia_css_frame_info *bds_out_info; 106 struct ia_css_frame_info *out_info[IA_CSS_BINARY_MAX_OUTPUT_PORTS]; 107 struct ia_css_frame_info *vf_info; 108 unsigned int isp_pipe_version; 109 unsigned int required_bds_factor; 110 int stream_config_left_padding; 111 }; 112 113 struct ia_css_binary { 114 const struct ia_css_binary_xinfo *info; 115 enum atomisp_input_format input_format; 116 struct ia_css_frame_info in_frame_info; 117 struct ia_css_frame_info internal_frame_info; 118 struct ia_css_frame_info out_frame_info[IA_CSS_BINARY_MAX_OUTPUT_PORTS]; 119 struct ia_css_resolution effective_in_frame_res; 120 struct ia_css_frame_info vf_frame_info; 121 int input_buf_vectors; 122 int deci_factor_log2; 123 int vf_downscale_log2; 124 int s3atbl_width; 125 int s3atbl_height; 126 int s3atbl_isp_width; 127 int s3atbl_isp_height; 128 unsigned int morph_tbl_width; 129 unsigned int morph_tbl_aligned_width; 130 unsigned int morph_tbl_height; 131 int sctbl_width_per_color; 132 int sctbl_aligned_width_per_color; 133 int sctbl_height; 134 int sctbl_legacy_width_per_color; 135 int sctbl_legacy_height; 136 struct ia_css_sdis_info dis; 137 struct ia_css_resolution dvs_envelope; 138 bool online; 139 unsigned int uds_xc; 140 unsigned int uds_yc; 141 unsigned int left_padding; 142 struct sh_css_binary_metrics metrics; 143 struct ia_css_isp_param_host_segments mem_params; 144 struct ia_css_isp_param_css_segments css_params; 145 }; 146 147 #define IA_CSS_BINARY_DEFAULT_SETTINGS { \ 148 .input_format = ATOMISP_INPUT_FORMAT_YUV420_8_LEGACY, \ 149 .in_frame_info = IA_CSS_BINARY_DEFAULT_FRAME_INFO, \ 150 .internal_frame_info = IA_CSS_BINARY_DEFAULT_FRAME_INFO, \ 151 .out_frame_info = {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \ 152 .vf_frame_info = IA_CSS_BINARY_DEFAULT_FRAME_INFO, \ 153 } 154 155 int 156 ia_css_binary_init_infos(void); 157 158 int 159 ia_css_binary_uninit(void); 160 161 int 162 ia_css_binary_fill_info(const struct ia_css_binary_xinfo *xinfo, 163 bool online, 164 bool two_ppc, 165 enum atomisp_input_format stream_format, 166 const struct ia_css_frame_info *in_info, 167 const struct ia_css_frame_info *bds_out_info, 168 const struct ia_css_frame_info *out_info[], 169 const struct ia_css_frame_info *vf_info, 170 struct ia_css_binary *binary, 171 struct ia_css_resolution *dvs_env, 172 int stream_config_left_padding, 173 bool accelerator); 174 175 int 176 ia_css_binary_find(struct ia_css_binary_descr *descr, 177 struct ia_css_binary *binary); 178 179 /* @brief Get the shading information of the specified shading correction type. 180 * 181 * @param[in] binary: The isp binary which has the shading correction. 182 * @param[in] type: The shading correction type. 183 * @param[in] required_bds_factor: The bayer downscaling factor required in the pipe. 184 * @param[in] stream_config: The stream configuration. 185 * @param[out] shading_info: The shading information. 186 * The shading information necessary as API is stored in the shading_info. 187 * The driver needs to get this information to generate 188 * the shading table directly required from ISP. 189 * @param[out] pipe_config: The pipe configuration. 190 * The shading information related to ISP (but, not necessary as API) is stored in the pipe_config. 191 * @return 0 or error code upon error. 192 * 193 */ 194 int 195 ia_css_binary_get_shading_info(const struct ia_css_binary *binary, 196 enum ia_css_shading_correction_type type, 197 unsigned int required_bds_factor, 198 const struct ia_css_stream_config *stream_config, 199 struct ia_css_shading_info *shading_info, 200 struct ia_css_pipe_config *pipe_config); 201 202 int 203 ia_css_binary_3a_grid_info(const struct ia_css_binary *binary, 204 struct ia_css_grid_info *info, 205 struct ia_css_pipe *pipe); 206 207 void 208 ia_css_binary_dvs_grid_info(const struct ia_css_binary *binary, 209 struct ia_css_grid_info *info, 210 struct ia_css_pipe *pipe); 211 212 void 213 ia_css_binary_dvs_stat_grid_info( 214 const struct ia_css_binary *binary, 215 struct ia_css_grid_info *info, 216 struct ia_css_pipe *pipe); 217 218 unsigned 219 ia_css_binary_max_vf_width(void); 220 221 void 222 ia_css_binary_destroy_isp_parameters(struct ia_css_binary *binary); 223 224 void 225 ia_css_binary_get_isp_binaries(struct ia_css_binary_xinfo **binaries, 226 uint32_t *num_isp_binaries); 227 228 #endif /* _IA_CSS_BINARY_H_ */ 229