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] Setting up Auto Exposure (AE) for your image sensor with TDA4/AM6xA ISP (VPAC)

How can I set up AE for an camera/sensor with TDA4/AM6xA ISP (VPAC)?

  • static int32_t IMX390_GetExpPrgFxn(uint32_t chId, void *pSensorHdl, IssAeDynamicParams *p_ae_dynPrms)
    {
        int32_t  status = -1;
        uint8_t count = 0;
    
        p_ae_dynPrms->targetBrightness = 45;          // on 0~255 range with 45 for 18% gray
        p_ae_dynPrms->threshold = 5;                  // within this threshold AE is stable
        p_ae_dynPrms->targetBrightnessRange.min = 40; // 40 --> 45 - 5
        p_ae_dynPrms->targetBrightnessRange.max = 50; // 50 --> 45 + 5
        p_ae_dynPrms->enableBlc = 0;                  // not in use and set it to 0
        p_ae_dynPrms->exposureTimeStepSize = 1;       // not useful for most sensors and set it to 1
    
        p_ae_dynPrms->exposureTimeRange[count].min = 11000;  // fixed 11ms exposure time for ADAS
        p_ae_dynPrms->exposureTimeRange[count].max = 11000;  // fixed 11ms exposure time for ADAS
        
        p_ae_dynPrms->analogGainRange[count].min = 1024;     // minimum sensor gain of 1.0x
        p_ae_dynPrms->analogGainRange[count].max = 8192;     // maximum sensor gain of 8.0x
        
        p_ae_dynPrms->digitalGainRange[count].min = 256;     // not used
        p_ae_dynPrms->digitalGainRange[count].max = 256;     // not used
        count++;
    
        p_ae_dynPrms->numAeDynParams = count;
        return (status);
    }

    The code snippet above is for setting up Auto Exposure (AE) of the IMX390 ADAS camera to work with TDA4/AM6xA ISP (VPAC).
    It fixes the sensor exposure time to 11ms and allows the sensor to adjust gain between 1.0x and 8.0x for ADAS applications.

    For some other applications, it may be desirable to avoid the 60Hz AC flickering by limiting exposure time to 8.333ms, 16.666ms, 25ms, and 33.333ms.
    Please refer to the code block below for setting up AE properly in this case.

    static int32_t IMX390_GetExpPrgFxn(uint32_t chId, void *pSensorHdl, IssAeDynamicParams *p_ae_dynPrms)
    {
        int32_t  status = -1;
        uint8_t count = 0;
    
        p_ae_dynPrms->targetBrightness = 45;          // on 0~255 range with 45 for 18% gray
        p_ae_dynPrms->threshold = 5;                  // within this threshold AE is stable
        p_ae_dynPrms->targetBrightnessRange.min = 40; // 40 --> 45 - 5
        p_ae_dynPrms->targetBrightnessRange.max = 50; // 50 --> 45 + 5
        p_ae_dynPrms->enableBlc = 0;                  // not in use and set it to 0
        p_ae_dynPrms->exposureTimeStepSize = 1;       // not useful for most sensors and set it to 1
    
        p_ae_dynPrms->exposureTimeRange[count].min =  100;
        p_ae_dynPrms->exposureTimeRange[count].max = 8333;   // 0.1ms ~ 8.333ms
        p_ae_dynPrms->analogGainRange[count].min = 1024;     // 1.0x sensor gain
        p_ae_dynPrms->analogGainRange[count].max = 1024;     // 1.0x sensor gain
        p_ae_dynPrms->digitalGainRange[count].min = 256;     // not used by IMX390 sensor driver
        p_ae_dynPrms->digitalGainRange[count].max = 256;     // not used by IMX390 sensor driver
        count++;
        
        p_ae_dynPrms->exposureTimeRange[count].min = 8333;
        p_ae_dynPrms->exposureTimeRange[count].max = 8333;   // fix to 8.333ms
        p_ae_dynPrms->analogGainRange[count].min = 1024;
        p_ae_dynPrms->analogGainRange[count].max = 2048;     // 1.0x ~ 2.0x gain
        p_ae_dynPrms->digitalGainRange[count].min = 256;     // not used
        p_ae_dynPrms->digitalGainRange[count].max = 256;     // not used
        count++;
        
        p_ae_dynPrms->exposureTimeRange[count].min = 16666;
        p_ae_dynPrms->exposureTimeRange[count].max = 16666;  // fix to 16.666ms
        p_ae_dynPrms->analogGainRange[count].min = 1024;
        p_ae_dynPrms->analogGainRange[count].max = 1536;     // 1.0x ~ 1.5x gain
        p_ae_dynPrms->digitalGainRange[count].min = 256;     // not used
        p_ae_dynPrms->digitalGainRange[count].max = 256;     // not used
        count++;
        
        p_ae_dynPrms->exposureTimeRange[count].min = 25000;
        p_ae_dynPrms->exposureTimeRange[count].max = 25000;  // fix to 25ms
        p_ae_dynPrms->analogGainRange[count].min = 1024;
        p_ae_dynPrms->analogGainRange[count].max = 1356;     // 1.0x ~ 1.333x gain
        p_ae_dynPrms->digitalGainRange[count].min = 256;     // not used
        p_ae_dynPrms->digitalGainRange[count].max = 256;     // not used
        count++;
        
        p_ae_dynPrms->exposureTimeRange[count].min = 33333;
        p_ae_dynPrms->exposureTimeRange[count].max = 33333;  // fix to 25ms
        p_ae_dynPrms->analogGainRange[count].min = 1024;
        p_ae_dynPrms->analogGainRange[count].max = 8192;     // 1.0x ~ 8.0x gain
        p_ae_dynPrms->digitalGainRange[count].min = 256;     // not used
        p_ae_dynPrms->digitalGainRange[count].max = 256;     // not used
        count++;
    
        p_ae_dynPrms->numAeDynParams = count;
        return (status);
    }

    Further information about setting up AE with Linux sensor driver in edgeai is available in this FAQ below.

    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1303303/faq-am62a7-how-to-set-the-minimum-maximum-exposure-time-and-analog-gain-for-2a-algorithm