1 /* 2 * 3 * SPDX-License-Identifier: GPL-2.0 4 * 5 * Copyright (C) 2011-2018 ARM or its affiliates 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; version 2. 10 * This program is distributed in the hope that it will be useful, but 11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * for more details. 14 * You should have received a copy of the GNU General Public License along 15 * with this program; if not, write to the Free Software Foundation, Inc., 16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 * 18 */ 19 20 #if !defined( __FSM_PARAMETERS_H__ ) 21 #define __FSM_PARAMETERS_H__ 22 23 #include "acamera_types.h" 24 #include "acamera.h" 25 #include "fsm_intf.h" 26 #include "fsm_param_id.h" 27 28 enum { 29 CMOS_CURRENT_EXPOSURE_LOG2, 30 CMOS_MAX_EXPOSURE_LOG2, 31 }; 32 33 enum { 34 AF_MODE_AF = 0, 35 AF_MODE_CAF = 1, 36 AF_MODE_MANUAL = 2, 37 AF_MODE_CALIBRATION = 3, 38 }; 39 40 typedef struct _fsm_param_sensor_info_ { 41 uint16_t total_width; 42 uint16_t total_height; 43 uint16_t active_width; 44 uint16_t active_height; 45 uint16_t pixels_per_line; 46 uint32_t lines_per_second; 47 48 int32_t again_log2_max; 49 int32_t dgain_log2_max; 50 uint32_t integration_time_min; 51 uint32_t integration_time_max; 52 uint32_t integration_time_long_max; 53 uint32_t integration_time_limit; 54 55 uint16_t again; 56 uint16_t dgain; 57 uint8_t integration_time_apply_delay; 58 59 int32_t sensor_exp_number; 60 uint8_t isp_exposure_channel_delay; 61 62 uint8_t resolution_mode; 63 uint16_t isp_output_mode; 64 uint16_t black_level; 65 uint8_t sensor_bits; 66 } fsm_param_sensor_info_t; 67 68 typedef struct _fsm_param_ae_info_ { 69 int32_t exposure_log2; 70 int32_t ae_hist_mean; 71 uint32_t exposure_ratio; 72 int32_t error_log2; 73 } fsm_param_ae_info_t; 74 75 typedef struct _fsm_param_ae_hist_info_ { 76 uint32_t fullhist_sum; 77 const uint32_t *fullhist; 78 uint32_t frame_id; 79 } fsm_param_ae_hist_info_t; 80 81 82 enum fsm_param_ae_mode_bit { 83 AE_MODE_BIT_MANUAL_INT_TIME = ( 1 << 0 ), 84 AE_MODE_BIT_MANUAL_GAIN_MODE = ( 1 << 1 ), 85 }; 86 87 typedef struct _fsm_param_ae_mode_ { 88 uint32_t manual_integration_time; 89 uint8_t manual_gain_mode; 90 uint16_t flag; 91 } fsm_param_ae_mode_t; 92 93 typedef struct _fsm_param_gain_calc_param_ { 94 uint8_t shift_in; 95 uint8_t shift_out; 96 } fsm_param_gain_calc_param_t; 97 98 typedef struct _fsm_param_ccm_info_ { 99 uint8_t light_source; 100 uint8_t light_source_previous; 101 uint8_t light_source_ccm; 102 uint8_t light_source_ccm_previous; 103 uint8_t light_source_change_frames; 104 uint8_t light_source_change_frames_left; 105 } fsm_param_ccm_info_t; 106 107 typedef struct _fsm_param_sensor_int_time_ { 108 uint16_t int_time; 109 uint16_t int_time_M; 110 uint16_t int_time_M2; 111 uint16_t int_time_L; 112 } fsm_param_sensor_int_time_t; 113 114 115 typedef struct _fsm_param_exposure_target_ { 116 int32_t exposure_log2; 117 uint32_t exposure_ratio; 118 uint32_t frame_id_tracking; 119 } fsm_param_exposure_target_t; 120 121 typedef struct _fsm_param_crop_info_ { 122 uint16_t width_fr; 123 uint16_t height_fr; 124 #if ISP_HAS_DS1 125 uint16_t width_ds; 126 uint16_t height_ds; 127 #endif 128 } fsm_param_crop_info_t; 129 130 typedef struct _fsm_param_dma_pipe_setting_buf_ { 131 dma_type pipe_id; 132 tframe_t *buf_array; 133 uint32_t buf_len; 134 buffer_callback_t callback; 135 } fsm_param_dma_pipe_setting_t; 136 137 typedef struct _fsm_param_path_fps_ { 138 dma_type pipe_id; 139 uint32_t c_fps; 140 uint32_t t_fps; 141 }fsm_param_path_fps_t; 142 143 144 typedef struct _fsm_param_dma_frame_ { 145 aframe_t **p_frame; 146 } fsm_param_dma_frame_t; 147 148 enum fsm_param_awb_info_bit { 149 AWB_INFO_TEMPERATURE_DETECTED = ( 1 << 0 ), 150 AWB_INFO_P_HIGH = ( 1 << 1 ), 151 AWB_INFO_LIGHT_SOURCE_CANDIDATE = ( 1 << 2 ), 152 }; 153 154 typedef struct _fsm_param_wb_info_ { 155 int32_t wb_log2[4]; 156 int32_t temperature_detected; 157 uint8_t p_high; 158 uint8_t light_source_candidate; 159 uint32_t avg_GR; 160 uint32_t avg_GB; 161 uint16_t rg_coef; 162 uint16_t bg_coef; 163 int32_t awb_warming[3]; 164 // flag is a combination of fsm_param_awb_info_bit. 165 uint32_t flag; 166 uint32_t result_gain_frame_id; 167 } fsm_param_awb_info_t; 168 169 typedef struct _fsm_param_af_info_ { 170 uint16_t last_position; 171 int32_t last_sharp; 172 uint8_t skip_frame; 173 } fsm_param_af_info_t; 174 175 176 typedef struct _fsm_param_gamma_result_ { 177 uint32_t gamma_gain; 178 uint32_t gamma_offset; 179 } fsm_param_gamma_result_t; 180 181 typedef struct _fsm_param_defect_pixel_info_ { 182 uint8_t hp_started; 183 } fsm_param_defect_pixel_info_t; 184 185 186 typedef struct _fsm_param_roi_ { 187 uint32_t roi; 188 uint32_t roi_api; 189 } fsm_param_roi_t; 190 191 192 enum fsm_param_crop_setting_bit { 193 CROP_SETTING_BIT_RESIZE_TYPE = ( 1 << 0 ), 194 CROP_SETTING_BIT_XSIZE = ( 1 << 1 ), 195 CROP_SETTING_BIT_YSIZE = ( 1 << 2 ), 196 CROP_SETTING_BIT_XOFFSET = ( 1 << 3 ), 197 CROP_SETTING_BIT_YOFFSET = ( 1 << 4 ), 198 CROP_SETTING_BIT_ENABLE = ( 1 << 5 ), 199 CROP_SETTING_BIT_DONE = ( 1 << 6 ), 200 CROP_SETTING_BIT_BANK = ( 1 << 7 ), 201 }; 202 203 typedef struct _fsm_param_crop_setting_ { 204 uint16_t resize_type; 205 uint16_t xsize; 206 uint16_t ysize; 207 uint16_t xoffset; 208 uint16_t yoffset; 209 uint8_t enable; 210 uint8_t done; 211 uint16_t bank; 212 // flag is a combination of fsm_param_crop_info_bit. 213 uint32_t flag; 214 } fsm_param_crop_setting_t; 215 216 217 enum fsm_param_reg_setting_bit { 218 REG_SETTING_BIT_REG_ADDR = ( 1 << 0 ), 219 REG_SETTING_BIT_REG_SIZE = ( 1 << 1 ), 220 REG_SETTING_BIT_REG_SOURCE = ( 1 << 2 ), 221 REG_SETTING_BIT_REG_VALUE = ( 1 << 3 ), 222 }; 223 224 typedef struct _fsm_param_reg_setting_ { 225 uint32_t api_reg_addr; 226 uint16_t api_reg_size; 227 uint16_t api_reg_source; 228 uint32_t api_reg_value; 229 uint32_t flag; 230 } fsm_param_reg_setting_t; 231 232 typedef struct _fsm_param_reg_cfg_ { 233 uint32_t reg_addr; 234 uint32_t reg_value; 235 } fsm_param_reg_cfg_t; 236 237 typedef struct _fsm_param_ccm_manual_ { 238 uint8_t manual_CCM; 239 int16_t manual_color_matrix[9]; 240 } fsm_param_ccm_manual_t; 241 242 typedef struct _fsm_param_set_wdr_param_ { 243 uint32_t wdr_mode; 244 uint32_t exp_number; 245 } fsm_param_set_wdr_param_t; 246 247 // #if !defined(ISP_HAS_CMOS_FSM) || !ISP_HAS_CMOS_FSM 248 // Copied below 3 structs definition from cmos_fsm.h file 249 typedef struct _exposure_data_set_t { 250 uint32_t integration_time; 251 uint32_t again_reg; 252 uint32_t dgain_reg; 253 int32_t isp_dgain_log2; 254 // Below definition is copied from cmos.fsm 255 uint32_t exposure_ratio; 256 uint32_t actual_integration_time; 257 258 uint32_t exposure_ratio_short; 259 uint32_t integration_time_long; 260 261 uint32_t exposure_ratio_medium; 262 uint32_t integration_time_medium; 263 264 uint32_t exposure_ratio_medium2; 265 uint32_t integration_time_medium2; 266 267 uint32_t frame_id_tracking; 268 } exposure_data_set_t; 269 270 typedef struct _exposure_info_set_t { 271 int32_t exposure_log2; 272 int32_t again_log2; 273 int32_t dgain_log2; 274 int32_t isp_dgain_log2; 275 } exposure_info_set_t; 276 277 typedef struct _exposure_set_t { 278 exposure_info_set_t info; 279 exposure_data_set_t data; 280 } exposure_set_t; 281 282 // #endif /* ISP_HAS_CMOS_FSM */ 283 284 285 enum fsm_param_mon_type { 286 // monitor type: Error 287 MON_TYPE_ERR_CALIBRATION_LUT_NULL = 1, 288 289 MON_TYPE_ERR_CMOS_FS_DELAY, 290 MON_TYPE_ERR_CMOS_UPDATE_NOT_IN_VB, 291 MON_TYPE_ERR_CMOS_UPDATE_DGAIN_WRONG_TIMING, 292 293 MON_TYPE_ERR_IRIDIX_UPDATE_NOT_IN_VB, 294 295 // monitor type: Algorithm 296 MON_TYPE_STATUS_ALG_DELAY_IN2OUT_MIN, 297 MON_TYPE_STATUS_ALG_DELAY_IN2OUT_CUR, 298 MON_TYPE_STATUS_ALG_DELAY_IN2OUT_MAX, 299 300 MON_TYPE_STATUS_ALG_DELAY_OUT2APPLY_MIN, 301 MON_TYPE_STATUS_ALG_DELAY_OUT2APPLY_CUR, 302 MON_TYPE_STATUS_ALG_DELAY_OUT2APPLY_MAX, 303 304 MON_TYPE_STATUS_ALG_FPT_MIN, 305 MON_TYPE_STATUS_ALG_FPT_CUR, 306 MON_TYPE_STATUS_ALG_FPT_MAX, 307 MON_TYPE_STATUS_ALG_STATUS_RESET, 308 }; 309 310 typedef struct _fsm_param_mon_err_head_ { 311 uint32_t err_type; 312 uint32_t err_param; 313 } fsm_param_mon_err_head_t; 314 315 316 typedef struct _fsm_param_mon_status_head_ { 317 uint32_t status_type; 318 uint32_t status_param; 319 } fsm_param_mon_status_head_t; 320 321 enum fsm_param_mon_alg_flow_state { 322 MON_ALG_FLOW_STATE_START, 323 MON_ALG_FLOW_STATE_INPUT_READY = MON_ALG_FLOW_STATE_START, 324 MON_ALG_FLOW_STATE_OUTPUT_READY, 325 MON_ALG_FLOW_STATE_APPLIED, 326 MON_ALG_FLOW_AE_STATE_END = MON_ALG_FLOW_STATE_APPLIED, 327 }; 328 329 typedef struct _fsm_param_mon_alg_flow_ { 330 uint32_t frame_id_tracking; 331 uint32_t frame_id_current; 332 uint32_t flow_state; 333 } fsm_param_mon_alg_flow_t; 334 335 typedef struct _fsm_param_sys_status_info_ { 336 int32_t total_gain_log2; 337 int32_t exposure_log2; 338 } sys_status_info_t; 339 340 typedef struct _fsm_param_awb_status_info_ { 341 uint32_t mix_light_contrast; 342 } awb_status_info_t; 343 344 typedef struct _fsm_param_af_status_info_ { 345 uint32_t lens_pos; 346 uint32_t focus_value; 347 } af_status_info_t; 348 349 typedef struct _fsm_param_fw_status_info_ { 350 sys_status_info_t sys_info; 351 awb_status_info_t awb_info; 352 af_status_info_t af_info; 353 } status_info_param_t; 354 355 typedef struct _defog_calibration_control { 356 uint32_t defog_en; 357 uint32_t fog_det_mode; 358 uint32_t acc_fog_val_thd; 359 uint32_t hst_fog_idx_thd; 360 uint32_t hst_fog_pec_thd1; 361 uint32_t hst_fog_pec_thd2; 362 uint32_t ratio_delta; 363 uint32_t max_rng; 364 uint32_t min_rng; 365 uint32_t black_percentage; 366 uint32_t white_percentage; 367 uint32_t avg_coeff; 368 uint32_t reserved_0; 369 uint32_t reserved_1; 370 uint32_t reserved_2; 371 uint32_t reserved_3; 372 } defog_calibration_control_t; 373 374 typedef struct _fsm_ext_param_ctrl { 375 void *ctx; 376 uint32_t id; 377 int32_t total_gain; 378 void *result; 379 } fsm_ext_param_ctrl_t; 380 381 int acamera_fsm_mgr_get_param( acamera_fsm_mgr_t *p_fsm_mgr, uint32_t param_id, void *input, uint32_t input_size, void *output, uint32_t output_size ); 382 int acamera_fsm_mgr_set_param( acamera_fsm_mgr_t *p_fsm_mgr, uint32_t param_id, void *input, uint32_t input_size ); 383 384 void acamera_fsm_mgr_dma_writer_update_address_interrupt( acamera_fsm_mgr_t *p_fsm_mgr, uint8_t irq_event ); 385 386 387 #endif /* __FSM_PARAMETERS_H__ */ 388