This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[FAQ] AM62A7: How to Set the Minimum/Maximum Exposure Time and Analog Gain for 2A Algorithm?

Part Number: AM62A7

I’ve just brought up a sensor for AM62A. Now I’m going to start image quality tuning. According to the AM6xA ISP Tuning Guide, the first thing is to set the minimum and maximum exposure time and analog gain for the 2A algorithm.

How can I translate the exposure time and analog gain specified by the datasheet to what is expected by TI's 2A algorithm?

  • 2A Algorithm

    The 2A algorithm in the AM62Ax SDK adjusts the exposure based on the H3A statistics provided by the ISP. Both the exposure time and analog gain are adjusted by the 2A algorithm. Every sensor has minimum and maximum exposure time and analog gain it operates within. These specifications can be found in the datasheet and need to be passed to the 2A algorithm. In the AM62Ax SDK, this is done in /opt/edgeai-gst-plugins/ext/tiovx/gsttiovxisp.c in the target file system. Please refer to the AM6xA ISP Tuning Guide for how to modify this file and rebuild the GStreamer plug-in.

    Analog Gain

    For analog gains, the minimum and maximum are usually specified in the datasheet as Nx gain and Mx gain, where N is the minimum gain and M is the maximum gain. The corresponding values in the gain register are usually also given. For example, a sensor’s datasheet could have something like this:

    • Minimum analog gain: 1x, gain_register value is 16
    • Maximum analog gain: 15.5x, gain_register value is 248

    Since the DCC live tuning tool uses 1024 for 1x gain to calculate and display the analog gain in floating point numbers, it is preferred to set the gains in this convention and map it between 2A and the sensor driver. Function get_<sensor-name>_ae_dyn_params() should have the following setting for this example:

      p_ae_dynPrms->analogGainRange[count].min = 1024;      /* 1x gain */
      p_ae_dynPrms->analogGainRange[count].max = 15872;     /* 15.5x gain */

    And the mapping in function gst_tiovx_isp_map_2A_values(...) should be as below:

      *analog_gain_mapped = analog_gain / 64;  /* 64 = 1024 / 16 */

    Alternatively, the minimum and maximum analog gains can be set using the same format as the datasheet and sensor driver. However, with this setting, the analog gain shown by the DCC live tuning tool will not mean actual floating point gain anymore.

      p_ae_dynPrms->analogGainRange[count].min = 16;      /* 1x gain */
      p_ae_dynPrms->analogGainRange[count].max = 248;     /* 15.5x gain */

    And the corresponding mapping in function gst_tiovx_isp_map_2A_values() should be as below:

        *analog_gain_mapped = analog_gain;

    Exposure Time

    For exposure time, the minimum and maximum are usually specified as a number of row periods. For example, the datasheet could have something like below:

    • Minimum exposure time: 5 row periods
    • Maximum exposure time: (frame length – 25) row periods

    Therefore, for resolution 1920x1080, frame length is 1080 plus vertical blanking. Assuming 10% vertical blanking, frame length is 1188 and maximum exposure time is (1188-25) =1163 row periods. It is always a good idea to check the sensor driver and make sure the exposure time is written to the register according to the datasheet.

    Since the DCC live tuning tool displays the exposure time in micro seconds, it is preferred to set the exposure time in micro seconds for 2A and map it between 2A and the sensor driver. The mapping depends on frame size and frame rate. For example, for 1920x1080 and 30fps, the minimum and maximum exposure time can be set as below in function get_<sensor-name>_ae_dyn_params():

    p_ae_dynPrms->exposureTimeRange[count].min = 140;   /* 5*33333/1188 micro sec */
    p_ae_dynPrms->exposureTimeRange[count].max = 32632; /* 1163*33333/1188 micro sec */

    Accordingly, the mapping from micro seconds to number of row periods should be provided in function gst_tiovx_isp_map_2A_values(...):

       *exposure_time_mapped = (int) ((double)exposure_time * 1188 / 33333 + 0.5); 

    Alternatively, the minimum and maximum exposure time can be set using the same format as the datasheet and sensor driver. However, with this setting, the exposure time displayed by the DCC live tuning tool will not be in micro seconds any more.

    p_ae_dynPrms->exposureTimeRange[count].min = 5;    
    p_ae_dynPrms->exposureTimeRange[count].max = 1163;

    And the mapping in function gst_tiovx_isp_map_2A_values(...) should be as below, given that both the sensor and the 2A algorithm use the same unit for exposure time. 

    *exposure_time_mapped = exposure_time;

    Note: the setting and mapping given above is just an example. For different sensor, the setting and mapping will be different. TI's 2A algorithm prefers to use 1024 as 1x analog gain and micro second for exposure time. Users will need to figure out the mapping between TI's 2A algorithm and the sensor driver depending on the sensor's specification on analog gain and exposure time.

    Other Parameters

    Besides exposure time and analog gain, there are other parameters that need to be set. Those parameters can use fixed values as provided in this FAQ.