AE Configuration
Development Workflow
Configure the AE in the following order:
- cmos_get_sns_regs_info
This function is used to configure the sensors and ISP registers that have synchronization requirements on the exposure time, gains, total lines, and more. Although these registers can be configured by directly calling sensor_write_register(), the synchronization requirements cannot be guaranteed and flicker may occur. Therefore, these registers must be configured using this function. The configured information includes the communication type (I2C or SPI), communication bus number, register address, and update status of the sensor register.
delay_frame_num indicates the register configuration delay. For example, gains of many sensors take effect in the next frame, but the exposure time takes effect after the next frame. Therefore, the gains need to be configured after a delay of one frame to make sure that the gain and exposure time take effect simultaneously. In this case, the delay function is needed. cfg2_valid_delay_max is used to control the synchronization between the ISP parameters (including ISP Dgain and WDR exposure ratio) and sensor parameters. You can check the parameter correctness by comparing the ISP Dgain and sensor gain. This parameter is used to control the validity time and generally it is one greater than the maximum sensor register delay.
update is used to determine whether to update the register. If no update is required, set it to false.
- cmos_get_ae_default
You need to change the parameter values based on the sensor. accuracy indicates the type of the calculation precision, which is generally set to HI_ISP_AE_ACCURACY_TABLE or HI_ISP_AE_ACCURACY_LINEAR. Due to the CPU calculation precision, HI_ISP_AE_ACCURACY_DB is replaced by TABLE unless the precision is low.
The linear mode indicates that the exposure time or gain increases linearly in fixed steps. For example, the exposure time or gain is increased by a multiple of 0.325 each step, or the exposure time is increased by 1 each step. The step is determined by accuracy.
The table mode applies to gain. That is, the gain each step can reach can be obtained through calculation in cmos_again_calc_table() or cmos_dgain_calc_table() function in a table look-up manner. In this case, accuracy is invalid.
The calculation order of the AE is exposure time, Again, Dgain, and ISP Dgain by default. You can adjust the order by setting AE Route or AE RouteEx.
- cmos_again_calc_table() and cmos_dgain_calc_table
The input and output of the two functions are the same and the two functions correspond to the table mode of the Again and Dgain, respectively. The following takes Again as an example:
again_lin is used as the input and output simultaneously. When it is used as the input, it is the expected gain calculated by the AE and 1024 indicates one multiple. In this function, you need to query the maximum gain that can be implemented by a sensor and is less than the gain. Re-assign this value to pu32AgainLin as the AE output.
again_db is used as the output value. It cannot be calculated in the AE. It is simply used as the input of cmos_gains_update(), to transfer the sensor register value of the current gain.
Assume that the sensor gain is increased by 0.3 dB. If the sensor register value starts from 0 and is increased by 1 each time, the corresponding gains are 0 dB, 0.3 dB, 0.6 dB, 0.9 dB....
Calculate a look-up table which transfers the dB into linear multiple offline, and the corresponding values are 1024, 1060, 1097, 1136….
Compare the input gain with the gain in the look-up table in the function. If the input is 1082, the maximum gain in the table is 1060 and the returned value 1060 is the actual valid gain.
- cmos_get_inttime_max
This function takes effect only in xto1 WDR mode, and is used to calculate the maximum exposure time in different exposure ratios.
The function is needed in line combination mode only. In this mode, the sum of the long exposure time and short exposure time should be less than the length of one frame. As a result, the maximum exposure time varies according to the exposure ratio and needs to be recalculated.
- cmos_gains_update and cmos_inttime_update
The two functions are used to configure the sensor register according to the input Again, Dgain, or exposure time.
When the precision mode is TABLE, the input parameter values are again_db and dgain_db returned by the corresponding cmos_again_calc_table()/cmos_dgain_calc_table() function.
When the linear precision mode is used, the input parameters are the effective gain and exposure time divided by the accuracy. For example, if accuracy is 0.0078125 and the actual valid gain is 1.5x, the input value is 192 (1.5/0.0078125).
In xto1 WDR mode, you need to configure the exposure time of each long frame and each short frame. cmos_inttime_update() will be called for X times and the exposure time of different frames will be input. The exposure time of the short frame will be input first.
- cmos_fps_set and cmos_slow_framerate_set
cmos_fps_set is the manual configuration function for frame rates. You need to configure the sensor register based on the input frame rate, implement the function of changing sensor frame rate, and return the actual frame rate and the maximum number of exposure lines.
cmos_slow_framerate_set() is the automatic configuration function for frame rate reduction. You need to configure the sensor register based on the actual required number of exposure lines, implement sensor frame rate reduction, and return the actual number of exposure lines.