hi_isp_ae_sensor_default

Description

Defines the structure of the initialization parameters for the AE algorithm library.

Prototype

typedef struct {   
    hi_u8   hist_thresh[HI_ISP_HIST_THRESH_NUM];     
    hi_u8 ae_compensation;     
    hi_u32  lines_per500ms;     
    hi_u32  flicker_freq;     
    hi_float fps;     
    hi_u32  hmax_times;     
    hi_u32  init_exposure;     
    hi_u32  init_ae_speed;     
    hi_u32  init_ae_tolerance;     
    hi_u32  full_lines_std;     
    hi_u32  full_lines_max;     
    hi_u32  full_lines;     
    hi_u32  binning_full_lines;     
    hi_u32  max_int_time;     
    hi_u32  min_int_time;     
    hi_u32  max_int_time_target;     
    hi_u32  min_int_time_target;
    hi_isp_ae_accuracy int_time_accu;     
    hi_u32  max_again;     
    hi_u32  min_again;     
    hi_u32  max_again_target;     
    hi_u32  min_again_target;     
    hi_isp_ae_accuracy again_accu;     
    hi_u32  max_dgain;     
    hi_u32  min_dgain;     
    hi_u32  max_dgain_target;     
    hi_u32  min_dgain_target;     
    hi_isp_ae_accuracy dgain_accu;
    hi_u32  max_isp_dgain_target;     
    hi_u32  min_isp_dgain_target;     
    hi_u32  isp_dgain_shift;
    hi_u32  max_int_time_step;     
    hi_bool  max_time_step_enable;     
    hi_u32  max_inc_time_step[HI_ISP_WDR_MAX_FRAME_NUM];     
    hi_u32  max_dec_time_step[HI_ISP_WDR_MAX_FRAME_NUM];     
    hi_u32  lf_max_short_time;     
    hi_u32  lf_min_exposure;
    hi_isp_ae_route ae_route_attr;     
    hi_bool ae_route_ex_valid;     
    hi_isp_ae_route_ex ae_route_attr_ex;
    hi_isp_ae_route ae_route_sf_attr;     
    hi_isp_ae_route_ex ae_route_sf_attr_ex;
    hi_u16 man_ratio_enable;     
    hi_u32 arr_ratio[HI_ISP_EXP_RATIO_NUM];
    hi_isp_iris_type  iris_type;     
    hi_isp_piris_attr piris_attr;     
    hi_isp_iris_f_no  max_iris_fno;
    hi_isp_iris_f_no  min_iris_fno;
    hi_isp_ae_strategy ae_exp_mode;
    hi_u16 iso_cal_coef;     
    hi_u8  ae_run_interval;     
    hi_u32 exp_ratio_max;     
    hi_u32 exp_ratio_min;     
    hi_bool diff_gain_support;     
    hi_isp_quick_start_param quick_start;     
    hi_isp_prior_frame prior_frame;     
    hi_bool ae_gain_sep_cfg;     
    hi_bool lhcg_support;     
    hi_u32 sns_lhcg_exp_ratio;
} hi_isp_ae_sensor_default;

Members

Member

Description

hist_thresh

Segmentation threshold array of the 5-segment histogram. The value range of each element in the array is [0, 0xff]. The default values are recommended. In linear mode, the default value is {0xd, 0x28, 0x60, 0x80}. In BUILT_IN WDR mode, the default value is {0x20, 0x40, 0x60, 0x80}. In frame combination WDR mode, the default value is {0xc, 0x18, 0x60, 0x80}.

#define HI_ISP_HIST_THRESH_NUM       4

ae_compensation

Target AE luminance. Value range: [0, 255]. 0x38 to 0x40 is recommended.

lines_per500ms

Total number of lines per 500 ms.

flicker_freq

Anti-flicker frequency. 256 times the current power frequency.

fps

Reference frame rate

hmax_times

Time when the sensor reads a line. Unit: ns.

init_exposure

Default initial exposure, which is equal to the exposure time multiplied by the exposure gain. The unit of the exposure time is μs. The AE algorithm uses this value as the exposure of the first five frames, which can be used to accelerate the startup of the motion DV.

For the product form that concerns fast boot, you are advised to set the initial exposure to an appropriate value based on the common scenario to achieve fast AE convergence. When the linear mode or WDR mode is switched, this value is also used as the exposure of the first frame after switching. Change the exposure time and gain of the sensor initialization sequence accordingly. Compute the exposure by multiplying the exposure time (number of lines) by the gain (6-bit decimal precision), and assign the value to this variable to ensure smooth switching. The default value 0 is used if this parameter is left unconfigured.

init_ae_speed

Default initial AE adjustment speed. The AE algorithm uses the value of this parameter as the auto speed of the initial 100 frames. This parameter can be used to accelerate the startup for motion DV.

You are advised to set this member to 128 for the product form that concerns fast boot. The default value 0 is used if this parameter is left unconfigured. The AE algorithm limits value range of this parameter to [64, 255] internally.

init_ae_tolerance

Default initial AE tolerance. The AE algorithm uses this value as the exposure tolerance of the first 100 frames to obtain the luminance range for the flag indicating that the AE convergence becomes stable for the first time. If the AE statistical luminance falls within the range of [Target luminance – init_ae_tolerance, Target luminance + init_ae_tolerance] for the first time, the flag indicating that the AE convergence is stable for the first time is obtained. The default value 0 is used if this parameter is left unconfigured. If this member is not set or is set to 0 in cmos.c, the AE algorithm internally sets it to ae_compensation /10. The AE algorithm limits value range of this parameter to (0, 255] internally.

full_lines_std

Number of valid lines in a frame at the reference frame rate

full_lines_max

Maximum number of lines in one frame after the frame rate of the sensor is reduced. It is usually set to the maximum number of lines supported by the sensor.

full_lines

Total number of actual lines in one frame for the sensor. When the AE algorithm and the callback functions cmos_fps_set and cmos_slow_framerate_set are used, this member must be assigned to return the total number of actual lines in one frame.

binning_full_lines

Total number of equivalent exposure lines of the sensor in binning mode

max_int_time

Maximum exposure time (in line)

min_int_time

Minimum exposure time (in line)

max_int_time_target

Target maximum exposure time (in line)

min_int_time_target

Target minimum exposure time (in line)

int_time_accu

Exposure time accuracy

max_again

Maximum analog gain (measured by multiple)

min_again

Minimum analog gain (measured by multiple)

max_again_target

Target maximum analog gain (measured by multiple)

min_again_target

Target minimum analog gain (measured by multiple)

again_accu

Analog gain accuracy

max_dgain

Maximum digital gain (measured by multiple)

min_dgain

Minimum digital gain (measured by multiple)

max_dgain_target

Target maximum digital gain (measured by multiple)

min_dgain_target

Target minimum digital gain (measured by multiple)

dgain_accu

Digital gain accuracy

max_isp_dgain_target

Target maximum ISP digital gain (measured by multiple)

min_isp_dgain_target

Target minimum ISP digital gain (measured by multiple)

isp_dgain_shift

ISP digital gain accuracy

max_int_time_step

Maximum adjustment step for decreasing the short-frame exposure time in auto long-frame mode during the switchover between the common mode and long-frame mode. The unit is line. This parameter is valid only in auto long-frame mode.

max_time_step_enable

Maximum step limit enable for the short-frame exposure time. HI_TRUE indicates enabled. This parameter is valid only in 2-frame combination WDR mode.

max_inc_time_step

Currently, only max_inc_time_step [0] is available, which indicates the maximum step for increasing the short-frame exposure. The unit is line. That is, the maximum number of exposure lines of the next frame compared with that of the current frame cannot exceed max_inc_time_step [0]. This member takes effect only after max_time_step_enable is enabled in 2-frame combination WDR mode.

HI_ISP_WDR_MAX_FRAME_NUM defines the maximum number of frames for WDR combination. 4 indicates the maximum number is 4.

max_dec_time_step

Currently, only max_dec_time_step [0] is available, which indicates the maximum step for decreasing the short-frame exposure. The unit is line. That is, the maximum number of decreased exposure lines of the next frame compared with that of the current frame cannot exceed max_dec_time_step [0]. This member takes effect only after max_time_step_enable is enabled in 2-frame combination WDR mode.

HI_ISP_WDR_MAX_FRAME_NUM defines the maximum number of frames for WDR fusion. 4 indicates the maximum number is 4.

lf_max_short_time

Maximum exposure time of short frames in automatic long frame mode

lf_min_exposure

Minimum exposure of the long frames that are forcibly output in automatic long frame mode

ae_route_attr

Default AE allocation route

ae_route_ex_valid

Enabling of the extended AE allocation route. If this parameter is set to HI_TRUE, the extended allocation route is enabled. Otherwise, the common AE allocation route is used.

ae_route_attr_ex

Default extended AE route for short frames. Proper configuration can optimize the image effect in WDR mode.

ae_route_sf_attr

Default AE route for short frames

ae_route_sf_attr_ex

Default extended AE route for short frames. Proper configuration can optimize the image effect in WDR mode.

man_ratio_enable

Manual exposure ratio enabling in multi-frame combination WDR mode. When this parameter is set to HI_TRUE, the exposure ratio is fixed and is not automatically updated based on the scenario.

arr_ratio

Default exposure ratio of two adjacent frames in multi-frame combination WDR mode. When man_ratio_enable is set to HI_TRUE, arr_ratio[0], arr_ratio[1], and arr_ratio[2] are used as the default S/VS exposure ratio, M/S exposure ratio, and L/M exposure ratio respectively. VS, S, M, and L represent the exposure time of the extremely short frame, the short frame, the middle frame, and the long frame, respectively. Only VS and S are valid in 2-frame combination mode. Only VS, S, and M are valid in 3-frame combination mode. VS, S, M, and L are all valid in 4-frame combination mode. 6-bit decimal precision.

Value range of each element in the array: [0x40, 0xFFF].

HI_ISP_EXP_RATIO_NUM defines the number of WDR exposure ratios (indicating 3).

iris_type

Default lens type, DC-Iris or P-Iris. If the default lens type is different from the type of the connected lens, the AI algorithm cannot work properly.

piris_attr

P-Iris parameter, which is related to the lens. This data structure is required only when the default lens type is P-Iris.

max_iris_fno

Maximum f-number that can be used by the P-Iris, which is related to the lens and must be configured when the P-Iris is used. It is used to limit the values of max_iris_fno_target and min_iris_fno_target that actually take effect to avoid AE allocation exceptions caused when the iris target value falls within an inappropriate range.

Value range: [HI_ISP_IRIS_F_NO_32_0, HI_ISP_IRIS_F_NO_1_0]

min_iris_fno

Minimum f-number that can be used by the P-Iris, which is related to the lens and must be configured when the P-Iris is used. It is used to limit the values of max_iris_fno_target and min_iris_fno_target that actually take effect to avoid AE allocation exceptions caused when the iris target value falls within an inappropriate range.

Value range: [HI_ISP_IRIS_F_NO_32_0, HI_ISP_IRIS_F_NO_1_0]

ae_exp_mode

Default exposure policy (highlight first or lowlight first). It is recommended that this member be set to lowlight first in FSWDR mode and be set to highlight first in linear mode and built-in WDR mode. If this member is not configured, the highlight first policy is used by default.

iso_cal_coef

ISO calibration coefficient, which is used to ensure that the ISO displayed in the DCF required for photographing is a standard value (8-bit precision).

Value range: [0x0, 0xFFFF]. Default value: 0x100.

ae_run_interval

Default running interval of the AE algorithm (unit: frame). If this parameter is not configured, the AE algorithm runs for every frame.

Value range: (0x0, 0xFF]

exp_ratio_max

Default maximum exposure ratio, which is valid only in multi-frame combination WDR mode.

  • When man_ratio_enable is set to HI_FALSE,

    exp_ratio_max indicates the maximum ratio of the exposure time of the longest frame to that of the shortest frame. That is, the maximum S/VS exposure time ratio in 2-frame combination mode, the maximum S/VS exposure time ratio in 3-frame combination mode, or the maximum L/VS exposure time ratio in 4-frame combination mode.

  • When man_ratio_enable is set to HI_TRUE, exp_ratio_max is invalid. The precision is 6-bit decimal precision. The value 0x40 indicates 1x exposure time ratio.

Value range: [0x40, 0x4000]

exp_ratio_min

Default minimum exposure ratio, which is valid only in multi-frame combination WDR mode.

  • When man_ratio_enable is set to HI_FALSE, exp_ratio_min indicates the minimum ratio of the long frame exposure time to the short frame exposure time.
  • When man_ratio_enable is set to HI_TRUE, exp_ratio_min is invalid. The precision is 6-bit decimal precision. The value 0x40 indicates 1x exposure time ratio.

    Value range: [0x40, exp_ratio_max]

diff_gain_support

Whether the sensor supports separate gain configurations for long and short frames. When this parameter is set to HI_TRUE, the sensor supports separate analog senor gains and digital sensor gains for long and short frames.

quick_start

No-light-sensor quick start

prior_frame

Priority frame for the exposure route to take effect in WDR mode. In linear mode, this parameter must be set to LONG_FRAME.

ae_gain_sep_cfg

Whether to allocate the gains for long and short frames separately.

lhcg_support

Whether the sensor uses the LCG+HCG mode. If this parameter is set to HI_TRUE, the sensor uses the LCG+HCG mode. If this parameter is set to HI_FALSE, the sensor uses the normal mode.

sns_lhcg_exp_ratio

Basic exposure ratio in LCG+HCG mode

Considerations

  • During the switching between the linear mode and WDR mode, the callback function pfn_cmos_get_ae_default is used to update the related AE default parameters. If the extended AE allocation route is required in WDR mode but not in linear mode, clear the AE route in the cmos_get_ae_default function: ae_route_ex_valid= HI_FALSE, ae_route_attr. total_num= 0, ae_route_attr_ex. total_num= 0 and assign a value to the WDR branch as required.
  • The AE algorithm uses init_exposure as the exposure of the first five frames, which can be used to accelerate the startup of the motion DV. For the product form that concerns fast boot, you are advised to set the initial exposure to an appropriate value based on the common scenario to achieve fast AE convergence. In FSWDR mode, init_exposure indicates the long frame exposure. To guarantee fast boot in FSWDR mode, you are advised to set this member to a fixed exposure ratio in cmos.c to reduce the time for adjusting the exposure ratio, and then set this member to an automatic exposure ratio as required after AE becomes stable. If no value or the value 0 is assigned to init_exposure in cmos.c, the AE algorithm starts calculation by considering the initial exposure as 1024.

    When the WDR mode is switched, the AE algorithm computes the switching exposure to ensure smooth switching. In this case, if you want to make init_exposure effective, you can set init_ae_speed to 0xFFFFFFFF.

  • For specific sensors, for example, the OV2718 sensor in DCG mode, only the fixed exposure ratio is supported internally. In this case, man_ratio_enable needs to be set to HI_TRUE and ratio needs to be configured as the fixed exposure ratio supported by the sensor. If an automatic exposure ratio is used or an unsupported exposure ratio is manually configured, the picture effect will be abnormal.
  • max_int_time_step indicates the maximum adjustment step for decreasing the short-frame exposure time in auto long-frame mode during the switchover between the common mode and long-frame mode. The unit is line. This parameter is valid only in auto long-frame mode. Decreasing the value of max_int_time_step too much will cause bad frames to some sensors.
  • The parameters max_time_step_enable, max_inc_time_step[0], and max_dec_time_step[0] are available for the sensors that have restrictions on the increase or decrease of the adjacent short-frame exposure time in 2-to-1 line combination WDR mode.
  • lf_max_short_time is the maximum value of the short frame exposure time in automatic long frame mode. If the value of lf_max_short_time is too small, the noises in the bright region become more obvious in automatic long frame mode.
  • For sensors that support the LCG+HCG mode, such as OV2775, if this mode is used, the basic exposure ratio sns_lhcg_exp_ratio must be correctly configured, and prior_frame=HI_ISP_LONG_FRAME and ae_gain_sep_cfg= HI_TRUE must be configured. Otherwise, the image effect is abnormal.