AE/AWB/AF Interface
REVISION HISTORY¶
| Revision No. | Description |
Date |
|---|---|---|
| 3.0 (cus3a v1.5) | 01/20/2022 | |
| 3.1 (cus3a v1.5) | 01/26/2022 | |
| 3.2 (cus3a v1.5) | 02/07/2022 | |
| 3.3 (cus3a v1.5) | 07/11/2022 | |
| 3.4 (cus3a v1.5) | 07/22/2022 | |
| 3.5 (cus3a v1.5) | 08/02/2022 | |
| 3.6 (cus3a v1.5) | 10/27/2022 | |
| 3.7 (cus3a v1.5) | 03/14/2023 | |
| 3.8 (cus3a v1.5) | 06/16/2023 | |
| 3.9 (cus3a v1.5) | 08/01/2023 | |
| 3.10 (cus3a v1.5) | 09/01/2023 | |
| 3.11 (cus3a v1.5) | 02/22/2024 | |
| 3.12 (cus3a v1.5) | 04/12/2024 |
SYSTEM STRUCTURE¶
Apart from those provided in the main ISP core, additional 3A algorithm modules can be plugged to the ISP block according to the system structure. Users are allowed to develop their own AWB/AE/AF algorithm libraries and connect them to the ISP by registering the AWB/AE/AF Interfaces.
During the ISP operating process, algorithms registered by users will be called, and these algorithms from the user end will provide calculation results accordingly. Eventually, the CUS3A Host will write the results to the ISP and Sensor.
Based on this architecture, user algorithms are able to focus on the calculation of input and output only, without the need to handle any other issues related to system integration.

AE/AWB WORK FLOW¶
After configuring MI_ISP_CreateChannel, user program must register its algorithm library by calling the callback function through CUS3A_RegInterfaceEx(), and then the algorithm will be switched to the user algorithm library through CUS3A_SetAlgpAdaptor(). Once the front-end sensor starts to capture images, the ISP core will call “run()” at each frame interrupt and input hardware statistics to the algorithm. When ISP is closed, “release()” will be called to notify the algorithm to release all resources.

In this flowchart, functions indicated in red represent the callback functions required on the part of the algorithm.
AE/AWB STATISTIC FORMAT¶
AE/AWB statistics in code is as defined below. Each frame will produce 128 * 90 entries of sampling data. In Pcupid, Macaron, Pudding, Ikayaki, and Tiramisu, each frame produces only 32 * 32 entries of sampled data on AE statistics.
#define isp_3A_ROW (128) /**< number of 3A statistic blocks in a row */
#define isp_3A_COL (90) /**< number of 3A statistic blocks in a column */
/*! @brief Single AE HW statistics data*/
typedef struct
{
U8 r; /**< block pixel R average , 0~255*/
U8 g; /**< block pixel G average , 0~255, g=(Gr+Gb+1)>>1*/
U8 b; /**< block pixel B average , 0~255*/
U8 y; /**< block pixel Y average , 0~255, \
y=(Ravg*9 +Gavg*19 +Bavg*4 + 16)>>5 */
}__attribute__((packed, aligned(1))) ISP_AE_SAMPLE;
/*! @brief Single AWB HW statistics data*/
typedef struct
{
U8 r; /**<center pixel R value , 0~255 */
U8 g; /**<center pixel G value , 0~255 */
U8 b; /**<center pixel B value , 0~255 */
}__attribute__((packed, aligned(1))) ISP_AWB_SAMPLE;
ISP will transmit AE/AWB statistics to the algorithm at each frame end. The data arrangement is shown in the following table. As can be seen from the table, ISP divides images into isp_3A_ROW x isp_3A_COL blocks and calculates the statistics to be filled into each block.
ISP_AWB_INFO::data[isp_3A_ROW*isp_3A_COL]
ISP_AE_INFO::data[isp_3A_ROW*isp_3A_COL]
| 0 | 1 | 2 | 3 | ………… | isp_3A_ROW-1 | ||||
|---|---|---|---|---|---|---|---|---|---|
| isp_3A_ROW | isp_3A_ROW +1 | isp_3A_ROW +2 | isp_3A_ROW +3 | . | . | . | . | . | isp_3A_ROW*2-1 |
| isp_3A_ROW*2 | |||||||||
| . | |||||||||
isp_3A_ROW* (isp_3A_COL-1) |
isp_3A_ROW* (isp_3A_COL-1)+1 |
isp_3A_ROW* isp_3A_COL-1 |
|||||||
If RGB-IR sensor is used, hardware will further extract the histogram of IR information for AE reference.
#define _3A_IR_HIST_BIN (256) /**< histogram type2 resolution*/
typedef struct
{
u16 u2IRHist[_3A_IR_HIST_BIN];
} ____attribute__((packed, aligned(1))) ISP_IR_HISTX;
AF STATISTIC FORMAT¶
When AF statistical window is configured (ISP_AF_RECT), there will be 16*n (n = 1 ~ 16) windows available for configuration (af_stats_win[16]), and each frame will generates statistical results with the output structure ISP_AF_INFO_STATS_PARAM_t. Each window generates the statistical values of 6 types of filters as output.
The following table shows the number of filter bits supported by each chip:
| Filter Bit & Chip Type | Twinkie | Pretzel / Macaron / Pudding / Ikayaki / Pcupid |
Tiramisu / Muffin | Maruko | Souffle | Iford |
|---|---|---|---|---|---|---|
| IIR | 34 | 35 | 37 | 36 | 38 | 36 |
| Sobel | 34 | 35 | 37 | 35 | 37 | 35 |
| Luma | 34 | 32 | 34 | 34 | 36 | 34 |
| YSat | 24 | 22 | 24 | 23 | 25 | 23 |
In the case where AF ROI Mode = AF_ROI_MODE_NORMAL, refer to ISP_AF_INFO_STATS.stParaAPI[0].
In the case where AF ROI Mode = AF_ROI_MODE_MATRIX, refer to ISP_AF_INFO_STATS.stParaAPI[0~15].
typedef struct
{
U32 start_x; /*range : 0~1023*/
U32 start_y; /*range : 0~1023*/
U32 end_x; /*range : 0~1023*/
U32 end_y; /*range : 0~1023*/
} ISP_AF_RECT;
typedef struct _isp_af_init_param
{
U32 Size; /**< struct size*/
ISP_AF_RECT af_stats_win[16];
/*CUS3A v1.3*/
U32 CurPos; //motor current position
U32 MinPos; //motor down position limit
U32 MaxPos; //motor up position limit
U32 MinStep;//motor minimum step
U32 MaxStep;//motor maximum step
} ISP_AF_INIT_PARAM;
AF Filter Description¶
| Parameter Name | Description | Input/Output |
|---|---|---|
| high_iir | AF high-frequency IIR filter statistics in each block division. | Output |
| low_iir | AF low-frequency IIR filter statistics in each block division. | Output |
| luma | AF luminance statistics in each block division. | Output |
| sobel_v | AF vertical FIR filter statistics in each block division. | Output |
| sobel_h | AF horizontal FIR filter statistics in each block division. | Output |
| ysat | Number of AF statistics greater than YThd in each block division. | Output |
Data Example:
General scene, far focus:


General scene, near focus:


Low brightness scene, far focus:


Low brightness scene, far focus, with light source:


High brightness scene with IIR:


Low brightness scene with IIR:


Introduction to AF API¶
The impact order of AF statistics is illustrated in the following figure:

MI_ISP_CUS3A_SetAFSource : Bayer image input. This API enables you to select the source of input image.
MI_ISP_CUS3A_SetAFGMode : Supported by Maruko, Souffle, and Iford only. In this API, Gmode will replace BayerRGB conversion to Y in YParam by using Bayer Gr and Gb as Y.
MI_ISP_CUS3A_SetAFYParam : Parameters for the conversion into brightness (Y) domain.
MI_ISP_CUS3A_SetAFYMap : Processed by YMap (gamma).
MI_ISP_CUS3A_SetAFPreFilter : Performs PreFilter noise reduction against data.
MI_ISP_CUS3A_SetAFBNR : Performs AF Bayer Noise Reduction (BNR).
MI_ISP_CUS3A_SetAFFilter : Sets IIR/FIR Filter statistics.
MI_ISP_CUS3A_SetAFLdg : Adjusts the ratio of statistic output by Level Depend Gain (LDG) based on different brightness intervals.
MI_ISP_CUS3A_SetAFFilterSq : Squares the statistics by FilterSq.
MI_ISP_CUS3A_SetAFPeakMode: Obtains the maximum value is PeakMode.
AE RESULT¶
After the ISP calls run() to run AE algorithm, AE algorithm must provide the corresponding results to the ISP, in the format specified below:
/*! @brief ISP ae algorithm result*/
typedef struct
{
U32 Size; /**< struct size*/
U32 Change; /**< if true, apply this result to hw register*/
U32 Shutter; /**< Shutter in us */
U32 SensorGain; /**< Sensor gain, 1X = 1024 */
U32 IspGain; /**< ISP gain, 1X = 1024 */
U32 ShutterHdrShort; /**< Shutter in us */
U32 SensorGainHdrShort; /**< Sensor gain, 1X = 1024 */
U32 IspGainHdrShort; /**< ISP gain, 1X = 1024 */
U32 u4BVx16384; /**< Bv * 16384 in APEX system, EV = Av + Tv = Sv + Bv */
U32 AvgY; /**< frame brightness */
U32 HdrRatio; /**< hdr ratio, 1X = 1024 */
/*CUS3A v1.1*/
U32 FNx10; /**< F number * 10 */
U32 DebandFPS; /**< Target fps when running auto debanding*/
U32 WeightY; /**< frame brightness with ROI weight*/
/*CUS3A v1.3*/
U16 GMBlendRatio; /**< Adaptive Gamma Blending Ratio from AE**/
} ISP_AE_RESULT;
Size: The size of ISP_AE_RESULT, used to deal with version backward compatibility issue.
Change: If set to 1, ISP will write the value as configured this time to hardware; if 0, ISP will ignore the result.
Shutter: Sets sensor shutter time.
SensorGain: Sets sensor gain. Digital/Analog gain distribution rate will be decided by sensor driver.
IspGain: Sets ISP digital gain.
ShutterHdrShort: Sets short-exposure sensor time.
SensorGainHdrShort: Sets short-exposure sensor gain. Digital/Analog gain distribution rate will be decided by sensor driver.
IspGainHdrShort: Sets short-exposure ISP digital gain.
u4BVx16384: Brightness value of current scene based on APEX calculation formula. This value will be referenced by IQ algorithm.
AvgY: Average grayscale brightness of current frame. This value will be referenced by IQ algorithm.
HdrRatio: HDR long/short exposure ratio of current frame. This value will be referenced by IQ algorithm.
Fnx10: Sets the FN Number.
DebandFPS: Sets the FPS.
WeightY: The average grayscale brightness after the current frame has gone through ROI weighting. This value will be taken into account by the IQ algorithm.
GMBlendRatio: This parameter only works when both AdaptiveGamma and RGBGamma in the IQ Tool are enabled. The IQ Tool will perform AdaptiveGamma and RGBGamma blending according to this ratio, as illustrated in the following figure. The value range is 1 ~ 1025, and 513 indicates the direct use of RGBGamma without blending.

AWB RESULT¶
After the ISP calls run() to run AWB algorithm, AWB algorithm must provide the corresponding results to the ISP, in the format specified below:
/*! @brief AWB algorithm result*/
typedef struct
{
U32 Size; /**< struct size*/
U32 Change; /**< if true, apply this result to hw register*/
U32 R_gain; /**< AWB gain for R channel*/
U32 G_gain; /**< AWB gain for G channel*/
U32 B_gain; /**< AWB gain for B channel*/
U32 ColorTmp; /**< Return color temperature*/
} ISP_AWB_RESULT;
Size: The size of ISP_AWB_RESULT, used to deal with version backward compatibility issue.
Change: If set to 1, ISP will write the value as configured this time to hardware; if 0, ISP will ignore the result.
R_gain: R channel gain.
G_gain: G channel gain.
B_gain: B channel gain.
ColorTmp: Current scene color temperature.
AF RESULT¶
After the ISP calls run() to run AF algorithm, AF algorithm must provide the corresponding results to the ISP in the format specified below:
/*! @brief AF algorithm result*/
typedef struct
{
U32 Size; /**< struct size*/
U32 Change; /**< if true, apply this result to hw*/
U32 NextPos; /**< Next position*/
} ISP_AF_RESULT;
Size: The length of ISP_AF_RESULT, which is used to solve the issue of version compatibility.
Change: If the value is 1, AF will be notified and the focus length (NextPos) calculated by it will become effective.
NextPos: Focal position result as calculated by the AF algorithm.
CUS3A LIBRARY INTERFACE¶
CUS3A_RegInterfaceEX¶
int CUS3A_RegInterfaceEX(CUS3A_ISP_DEV_e eDev, CUS3A_ISP_CH_e eCh, AlgoAdaptor eAdaptor, IspAlgoType eAlgoType, void* pAlgo)
-
Description
AE, AWB and AF library registration interface for users.
-
Parameter
Parameter Name Description Input/Output eDev Specify ISP hardware for the algorithm. Input eCh Specify ISP channel to be switched by the algorithm. Input eAdaptor Specify AlgoAdaptor for the algorithm.
Currently, only E_ALGO_ADAPTOR_1 can be applied from user end.Input eAlgoType Specify the type of algorithm: E_ALGO_TYPE_AE, E_ALGO_TYPE_AWB, E_ALGO_TYPE_AF Input pAlgo Pointer to the library provided by algorithm for its implementation.
If algorithm implementation is not required, fill in NULL.
pAlgo type corresponds to eAlgoType as follows:
E_ALGO_TYPE_AE: pAlgo = ISP_AE_INTERFACE*
E_ALGO_TYPE_AWB: pAlgo = ISP_AWB_INTERFACE*
E_ALGO_TYPE_AF: pAlgo = ISP_AF_INTERFACE*Input -
Return Value
Return Value Description 0 Registration successful. <0 Registration failed.
CUS3A_SetAlgoAdaptor¶
int CUS3A_SetAlgoAdaptor(CUS3A_ISP_DEV_e eDev, CUS3A_ISP_CH_e eCh, AlgoAdaptor eAdaptor, IspAlgoType eAlgoType)
-
Description
Switch between the registered algorithms.
-
Parameter
Parameter Name Description Input/Output eDev Specify ISP hardware for the algorithm. Input eCh Specify ISP channel to be switched by the algorithm. Input eAdaptor Specify AlgoAdaptor for the algorithm.
E_ALGO_ADAPTOR_NATIVE: SStar 3A
E_ALGO_ADAPTOR_1: Customer 3AInput eAlgoType Specify algorithm type: E_ALGO_TYPE_AE, E_ALGO_TYPE_AWB, E_ALGO_TYPE_AF Input -
Return Value
Return Value Description 0 Switch successful. <0 Switch failed. -
Example
/*ISP0 AE -> SStarAE*/ CUS3A_SetAlgoAdaptor(eIspCh0, eAdapNative, eAlgoAE) /*ISP0 AWB -> Customer AWB*/ CUS3A_SetAlgoAdaptor(eIspCh0, eAdap1, eAlgoAWB) /*ISP0 AF -> Customer AF */ CUS3A_SetAlgoAdaptor(eIspCh0, eAdap1, eAlgoAF)

CUS3A_SetRunMode¶
int CUS3A_SetRunMode(CUS3A_ISP_DEV_e eDev, CUS3A_ISP_CH_e eCh, CUS3A_RUN_MODE_e eMode)
-
Description
Switch CUS3A working mode.
-
Parameter
Parameter Name Description Input/Output eDev Specify ISP hardware for the algorithm. Input eCh Specify ISP channel to be switched by the algorithm. Input eMode Specify working mode:
E_CUS3A_MODE_NORMAL – CUS3A task calls 3A algorithms after ISP frame done and update both sensor and IQ parameters.
E_CUS3A_MODE_INJECT – Customer calls CUS3A_RunOnce() to run 3A algorithms once and update both sensor and IQ parameters.
E_CUS3A_MODE_OFF – Stop calling 3A algorithms and updating.Input -
Return Value
Return Value Description 0 Switch successful. <0 Switch failed.
CUS3A_RunOnceEn¶
int CUS3A_RunOnceEn(CUS3A_ISP_DEV_e eDev, CUS3A_ISP_CH_e eCh, u8 bAeEn, u8 bAwbEn, u8 bAfEn)
-
Description
-
Make sure that you call this function when ISP is enabled.
-
The corresponding ISP Ch should be switched to E_CUS3A_MODE_INJECT through CUS3A_SetRunMode.
-
Enable the corresponding ISP Ch 3A by bAeEn/bAwbEn/bAfEn.
-
Set bAeEn/bAwbEn/bAfEn to 0 before you call CUS3A_Release so that algorithm resource can be released.
-
-
Parameter
Parameter Name Description Input/Output eDev Specify ISP hardware for the algorithm. Input eCh Specify ISP channel to be switched by the algorithm. Input bAeEn Enable AE. Input bAwbEn Enable AWB. Input bAfEn Enable AF. Input -
Return Value
Return Value Description 0 Switch successful. <0 Switch failed.
CUS3A_RunOnce¶
int CUS3A_RunOnce(CUS3A_ISP_DEV_e eDev, CUS3A_ISP_CH_e eCh)
-
Description
-
Make sure that you call this function when ISP is enabled.
-
The corresponding ISP Ch should be switched to E_CUS3A_MODE_INJECT through CUS3A_SetRunMode.
-
Please enable 3A by running CUS3A_RunOnceEn.
-
Each call will run 3A algorithms once to calculate and update sensor and IQ settings.
-
The 3A algorithms will be run by the thread that calls this function.
-
-
Parameter
Parameter Name Description Input/Output eDev Specify ISP hardware for the algorithm. Input eCh Specify ISP channel to be switched by the algorithm. Input -
Return Value
Return Value Description 0 Switch successful. <0 Switch failed.
We do not recommend using CUS3A_RegInterface, CUS3A_AERegInterface, CUS3A_AWBRegInterface, and CUS3A_AFRegInterface. Please use CUS3A_RegInterfaceEX instead.
int CUS3A_RegInterface(U32 nCh, ISP_AE_INTERFACE *pAe, ISP_AWB_INTERFACE *pAwb, ISP_AF_INTERFACE *pAf) int CUS3A_AERegInterface(u32 nCh, ISP_AE_INTERFACE *pAE); int CUS3A_AWBRegInterface(u32 nCh, ISP_AWB_INTERFACE *pAWB); int CUS3A_AFRegInterface(u32 nCh, ISP_AF_INTERFACE *pAF);
-
Description
The ISP provides AE, AWB and AF library registration interfaces. You may use CUS3A_RegInterface to register AE, AWB, and AF simultaneously, or use CUS3A_AERegInterface, CUS3A_AWBRegInterface, and CUS3A_AFRegInterface to register AE, AWB, and AF respectively.
-
Parameter
Parameter Name Description Input/Output nCh nCh = 0 Input pAe Pointer to the AE library algorithm implementation side. If you do not need to register AE, fill in NULL. Input pAwb Pointer to the AWB library algorithm implementation side. If you do not need to register AWB, fill in NULL. Input pAf Pointer to the AF library algorithm implementation side. If you do not need to register AF, fill in NULL. Input -
Return Value
Return Value Description 0 Registration successful. <0 Registration failed.
AE CALLBACK INTERFACE¶
int (*init)(void* pdata,ISP_AE_INIT_PARAM *init_state)
-
Description
The ISP notifies AE library to start initialization through this interface.
-
Parameter
Parameter Name Description Input/Output pdata Pointer to the private data of algorithm. Input init_state AE initial value. Input -
Return Value
Return Value Description 0 Successful. -1 Failed.
void (*release)(void* pdata)
-
Description
The ISP notifies AE library to start releasing through this interface.
-
Parameter
Parameter Name Description Input/Output pdata Pointer to the private data of algorithm. Input
void (*run)(void* pdata,const ISP_AE_INFO *info,ISP_AE_RESULT *result)
-
Description
The ISP notifies AE library to start calculation through this interface.
-
Parameter
Parameter Name Description Input/Output pdata Pointer to the private data of algorithm. Input info Pointer to the AE statistical data structure of ISP. Input result Pointer to the AE algorithm result structure of ISP. Output
int (*ctrl)(void* pdata, ISP_AE_CTRL_CMD cmd, void* param)
-
Description
The ISP controls AE parameters through this interface.
-
Parameter
Parameter Name Description Input/Output pdata Pointer to the private data of algorithm. Input cmd AE control command. Input param AE control command parameter. Input
AE DATA STRUCTURE¶
ISP_AE_INTERFACE¶
-
Description
AE library registration structure. The algorithm needs to be implemented and its callback pointers, including initialization, release, run, and control, should be filled in to enable the ISP to call this structure.
-
Declaration
/**@brief ISP AE interface*/ typedef struct { void *pdata; /**< Private data for AE algorithm.*/ int (*init)(void* pdata, ISP_AE_INIT_PARAM *init_state); void (*release)(void* pdata); void (*run)(void* pdata, const ISP_AE_INFO *info, ISP_AE_RESULT *result); int (*ctrl)(void* pdata, ISP_AE_CTRL_CMD cmd, void* param); } ISP_AE_INTERFACE; -
Member
Name Description pdata Pointer to the private data of AE library. init Callback pointer to AE library initialization. release Callback pointer to AE library release. run Callback pointer to AE library calculation. ISP will call AE algorithm to perform calculation when receiving the statistics of a frame. ctrl Callback pointer to AE library control.
ISP_AE_INIT_PARAM¶
-
Description
The ISP notifies AE algorithm of the related hardware initialization status through this structure.
-
Declaration
typedef struct { U32 Size; /**< struct size*/ char sensor_id[32]; /**< sensor module id*/ U32 shutter; /**< shutter Shutter in us*/ U32 shutter_step; /**< shutter Shutter step ns*/ U32 shutter_min; /**< shutter Shutter min us*/ U32 shutter_max; /**< shutter Shutter max us*/ U32 sensor_gain; /**< sensor_gain Sensor gain, 1X = 1024*/ U32 sensor_gain_min; /**< sensor_gain_min Minimum Sensor gain, 1X = 1024*/ U32 sensor_gain_max; /**< sensor_gain_max Maximum Sensor gain, 1X = 1024*/ U32 isp_gain; /**< isp_gain Isp digital gain , 1X = 1024 */ U32 isp_gain_max; /**< isp_gain Maximum Isp digital gain , 1X = 1024 */ U32 FNx10; /**< F number * 10*/ U32 fps; /**< initial frame per second*/ U32 shutterHDRShort_step; /**< shutter Shutter step ns*/ U32 shutterHDRShort_min; /**< shutter Shutter min us*/ U32 shutterHDRShort_max; /**< shutter Shutter max us*/ U32 sensor_gainHDRShort_min; /**< sensor_gain_min Minimum Sensor gain, 1X = 1024*/ U32 sensor_gainHDRShort_max; /**< sensor_gain_max Maximum Sensor gain, 1X = 1024*/ /*CUS3A v1.1*/ U32 AvgBlkX; /**< HW statistics average block number*/ U32 AvgBlkY; /**< HW statistics average block number*/ }ISP_AE_INIT_PARAM; -
Member
Parameter Name Description Input/Output Size Size of ISP_AE_INIT_PARAM structure. Input sensor_id[32] Image sensor name. Input shutter Shutter time initial value in us. Input shutter_step Shutter time step in ns. Input shutter_min Minimum shutter time in us. Input shutter_max Maximum shutter time in us. Input sensor_gain Initial value of sensor gain. Input sensor_gain_min The minimum value of sensor gain. Input sensor_gain_max The maximum value of sensor gain. Input isp_gain Initial value of ISP gain. Input isp_gain_max The maximum value of ISP gain. Input FNx10 Aperture value *10. Input fps Number of frames per second. Input shutterHDRShort_step Shutter time step in ns for HDR short exposure. Input shutterHDRShort_min Minimum shutter time in us for HDR short exposure. Input shutterHDRShort_max Maximum shutter time in us for HDR short exposure. Input sensor_gainHDRShort_min Sensor gain minimum value for HDR short exposure. Input sensor_gainHDRShort_max Sensor gain maximum value for HDR short exposure. Input AvgBlkX Number of AE statistic blocks in x-axis. Input AvgBlkY Number of AE statistic blocks in y-axis. Input
ISP_AE_INFO¶
-
Description
Hardware statistics of ISP AE.
-
Declaration
/*! @brief ISP report to AE, hardware statistic */ typedef struct { U32 Size; /**< struct size*/ ISP_HIST *hist1; /**< HW statistic histogram 1*/ ISP_HIST *hist2; /**< HW statistic histogram 2*/ U32 AvgBlkX; /**< HW statistics average block number*/ U32 AvgBlkY; /**< HW statistics average block number*/ ISP_AE_SAMPLE *avgs; /**< HW statistics average block data*/ U32 Shutter; /**< Current shutter in us*/ U32 SensorGain; /**< Current Sensor gain, 1X = 1024 */ U32 IspGain; /**< Current ISP gain, 1X = 1024*/ U32 ShutterHDRShort; /**< Current shutter in us*/ U32 SensorGainHDRShort; /**< Current Sensor gain, 1X = 1024 */ U32 IspGainHDRShort; /**< Current ISP gain, 1X = 1024*/ /*CUS3A v1.1*/ U32 PreAvgY; /**< Previous frame brightness */ U32 HDRCtlMode; /**< 0 = HDR off;*/ /**< 1 = Separate shutter & Separate sensor gain settings*/ /**< 2 = Separate shutter & Share sensor gain settings*/ /**< 3 = Share shutter & Separate sensor gain settings*/ U32 FNx10; /**< Aperture in FNx10 */ U32 CurFPS; /**< Current sensor FPS */ U32 PreWeightY; /**< Previous frame brightness with ROI weight */ /*CUS3A v1.2*/ ISP_IR_HISTX *histIR; /**< HW statistic histogram IR*/ ISP_HISTX *hist1_short; /**< HW statistic histogram 1 for HDR short frame*/ ISP_HISTX *hist2_short; /**< HW statistic histogram 2 for HDR short frame*/ U32 nTotalStatNum; /**< Total statistic histogram frame number*/ U32 nNextStatsOffset; /**< statistic frame offset, by byte unit*/ } ISP_AE_INFO; -
Member
Parameter Name Description Input/Output Size Size of ISP_AE_INFO structure. Input hist1 Histogram 1. Input hist2 Histogram 2 (Currently not supported). Input AvgBlkX Number of blocks in x-axis. Input AvgBlkY Number of blocks in y-axis. Input avgs Block brightness statistics. Input Shutter Shutter time in us when the statistics are generated. Input SensorGain Sensor Gain 1X=1024 when the statistics are generated. Input IspGain ISP Gain 1X=1024 when the statistics are generated. Input ShutterHDRShort Shutter time in us when the statistics are generated (HDR short). Input SensorGainHDRShort Sensor Gain 1X=1024 when the statistics are generated (HDR short). Input IspGainHDRShort ISP Gain 1X=1024 when the statistics are generated (HDR short). Input PreAvgY Average brightness 8bit*10 of previous AE result. Input HDRCtlMode Supported shutter/gain format as returned by sensor when in HDR mode. Input FNx10 FN value applied when the statistics are generated. Input CurFPS Current FPS. Input PreWeightY Average brightness 8bit*10 of previous AE result after ROI weighting. Input histIR Histogram relating to IR information when RGB-IR sensor is used. Input hist1_short Hardware statistic Histogram 1 for HDR short-exposure frame. Input hist2_short Hardware statistic Histogram 2 for HDR short-exposure frame (Currently not supported). Input nTotalStatsNum The total number of frame of statistical value. Input nNextStatsOffest The value of offset for the statistical value of next frame, in the unit of byte. Input
ISP_AE_RESULT¶
-
Description
Result of ISP AE algorithm.
-
Declaration
/*! @brief ISP ae algorithm result*/ typedef struct { U32 Size; /**< struct size*/ U32 Change; /**< if true, apply this result to hw register*/ U32 Shutter; /**< Shutter in us */ U32 SensorGain; /**< Sensor gain, 1X = 1024 */ U32 IspGain; /**< ISP gain, 1X = 1024 */ U32 ShutterHdrShort; /**< Shutter in us */ U32 SensorGainHdrShort; /**< Sensor gain, 1X = 1024 */ U32 IspGainHdrShort; /**< ISP gain, 1X = 1024 */ U32 u4BVx16384; /**< Bv * 16384 in APEX system, EV = Av + Tv = Sv + Bv */ U32 AvgY; /**< frame brightness */ U32 HdrRatio; /**< hdr ratio, 1X = 1024 */ /*CUS3A v1.1*/ U32 FNx10; /**< F number * 10 */ U32 DebandFPS; /**< Target fps when running auto debanding*/ U32 WeightY; /**< frame brightness with ROI weight*/ /*CUS3A v1.3*/ U16 GMBlendRatio; /**< Adaptive Gamma Blending Ratio from AE**/ }ISP_AE_RESULT; -
Member
Parameter Name Description Input/Output Size Size of ISP_AE_RESULT structure. Input Change Notify ISP whether the current algorithm result is to be applied to hardware. Output Shutter Shutter time in us as reported by AE algorithm. Output SensorGain Sensor gain 1X=1024 as reported by AE algorithm. Output IspGain ISP gain 1X=1024 as reported by AE algorithm. Output ShutterHdrShort Shutter time in us as reported by AE algorithm (HDR Short). Output SensorGainHdrShort Sensor gain 1X=1024 as reported by AE algorithm (HDR Short). Output IspGainHdrShort ISP gain 1X=1024 as reported by AE algorithm (HDR Short). Output u4Bvx16384 Current scene brightness estimate as reported by AE algorithm. Output AvgY Current frame average brightness as reported by AE algorithm. Output HdrRatio Current frame HDR long/short exposure ratio 1x=1024 as reported by AE algorithm. Output FNx10 Current FN number as reported by AE algorithm. Output DebandFPS Current FPS as reported by AE algorithm. Output WeightY Current average brightness after ROI weighting as reported by AE algorithm. Output GMBlendRatio Blending ratio of IQ AdaptiveGamma to RGBGamma, controlled by AE algorithm. Range: 1~1025. Value 513 represents using RGBGamma directly without any blending. Output
ISP_AE_CTRL_CMD¶
-
Description
AE control command. ISP set AE parameters through the callback interface
int (*ctrl)(void* pdata,ISP_AE_CTRL_CMD cmd, void* param). The type of parameter vary with different control commands. -
Declaration
typedef enum { ISP_AE_CMD_MAX }ISP_AE_CTRL_CMD; -
Member
Name Description Parameter Type ISP_AE_CMD_MAX Reserved value, obsolete. N/A.
AWB CALLBACK INTERFACE¶
int (*init)(void* pdata)
-
Description
The ISP notifies the AWB library to start initialization through this interface.
-
Parameter
Parameter Name Description Input/Output pdata Pointer to the private data of algorithm. Input -
Return Value
Return Value Description 0 Initialization successful. -1 Initialization failed.
void (*release)(void* pdata)
-
Description
The ISP notifies the AWB library to start releasing through this interface.
-
Parameter
Parameter Name Description Input/Output pdata Pointer to the private data of algorithm. Input
void (*run)(void* pdata,const ISP_AWB_INFO *awb_info,const ISP_AE_INFO *ae_info,ISP_AWB_RESULT *result)
-
Description
The ISP notifies the AWB library to start calculation through this interface.
-
Parameter
Parameter Name Description Input/Output pdata Pointer to the private data of algorithm. Input awb_info Pointer to the AWB statistical data structure of ISP. Input ae_info Pointer to the AE statistical data structure of ISP. Input result Pointer to the AWB algorithm result structure of ISP. Output
int (*ctrl)(void* pdata,ISP_AWB_CTRL_CMD cmd,void* param)
-
Description
The ISP controls AWB parameters through this interface.
-
Return Value
Return Value Description 0 Control command successful. <0 Control command failed. -
Parameter
Parameter Name Description Input/Output pdata Pointer to the private data of algorithm. Input cmd AWB control command. Input param AWB control command parameter. Input
AWB DATA STRUCTURE¶
ISP_AWB_INTERFACE¶
-
Description
AWB library registration structure. The algorithm needs to be implemented and its callback pointers, including initialization, release, run, and control, should be filled in to enable the ISP to call this structure.
-
Declaration
typedef struct { void *pdata; /**< Private data for AE algorithm.*/ int (*init)(void *pdata); void (*release)(void *pdata); void (*run)(void *pdata, const ISP_AWB_INFO *awb_info, const ISP_AE_INFO *ae_info, ISP_AWB_RESULT *result); int (*ctrl)(void *pdata, ISP_AWB_CTRL_CMD cmd, void* param); } ISP_AWB_INTERFACE -
Member
Name Description pdata Pointer to the private data of AWB library. init Callback pointer to AWB library initialization. release Callback pointer to AWB library release. run Callback pointer to AWB library calculation. ISP will request AWB algorithm to start calculation when receiving the statistics of a frame. ctrl Callback pointer to AWB library control.
ISP_AWB_INFO¶
-
Description
Hardware statistics of ISP AWB.
-
Declaration
/*! @brief AWB HW statistics data*/ typedef struct { U32 Size; /**< struct size*/ U32 AvgBlkX; U32 AvgBlkY; U32 CurRGain; U32 CurGGain; U32 CurBGain; ISP_AWB_SAMPLE *avgs; /*CUS3A v1.1*/ U8 HDRMode; /**< Noramal or HDR mode */ ISP_AWB_SAMPLE* pAwbStatisShort; /**< Short Shutter AWB statistic data*/ U32 u4BVx16384; /**< From AE output, Bv * 16384 in APEX system, EV = Av + Tv = Sv + Bv */ S32 WeightY; /**< frame brightness with ROI weight0 */ U32 nTotalStatNum; /**< Total statistic histogram frame number*/ U32 nNextStatsOffset; /**< statistic frame offset, by byte unit*/ } ISP_AWB_INFO; -
Member
Parameter Name Description Input/Output Size The length of ISP_AWB_INFO. Input AvgBlkX Number of blocks in x-axis. Input AvgBlkY Number of blocks in y-axis. Input CurRGain AWB R Gain of current frame. Input CurGGain AWB G Gain of current frame. Input CurBGain AWB B Gain of current frame. Input avgs ISP AWB block RGB statistics. Input HDRMode Indicates whether the current frame is in HDR mode. Input pAwbStatisShort ISP AWB block RGB statistics (short exposure information under HDR mode). Input U4BVx16384 BV information returned by AE. Input WeightY Average brightness after ROI weighting as returned by AE. Input nTotalStatsNum The total number of frame of statistical value. Input nNextStatsOffest The value of offset for the statistical value of next frame, in the unit of byte. Input
ISP_AWB_RESULT¶
-
Description
Result of ISP AWB algorithm.
-
Declaration
/*! @brief AWB algorithm result*/ typedef struct { U32 Size; /**< struct size*/ U32 Change; /**< if true, apply this result to hw register*/ U32 R_gain; /**< AWB gain for R channel*/ U32 G_gain; /**< AWB gain for G channel*/ U32 B_gain; /**< AWB gain for B channel*/ U32 ColorTmp; /**< Return color temperature*/ } ISP_AWB_RESULT; -
Member
Parameter Name Description Input/Output Size Size of ISP_AWB_RESULT structure. Input Change Notify ISP whether the current algorithm result is to be applied to hardware. Output R_gain AWB R gain 1X = 1024 as reported by AWB algorithm. Output G_gain AWB G gain 1X = 1024 as reported by AWB algorithm. Output B_gain AWB B gain 1X = 1024 as reported by AWB algorithm. Output ColorTmp Current scene color temperature K as reported by AWB algorithm. Output
ISP_AWB_CTRL_CMD¶
-
Description
AWB control command. ISP set AWB parameter through the callback interface
int (*ctrl)(void* pdata, ISP_AWB_CTRL_CMD cmd, void* param). The type of parameter vary with different control commands. -
Declaration
typedef enum { ISP_AWB_CMD_MAX }ISP_AWB_CTRL_CMD; -
Member
Name Description Parameter Type ISP_AWB_CMD_MAX Reserved value, obsolete. N/A.
AF CALLBACK INTERFACE¶
int (*init)(void* pdata, ISP_AF_INIT_PARAM *param)
-
Description
The ISP notifies the AF library to start initialization through this interface.
-
Parameter
Parameter Name Description Input/Output pdata Pointer to the private data of algorithm. Input param AF initialization setting Input/Output -
Return Value
Return Value Description 0 Initialization successful. -1 Initialization failed.
void (*release)(void* pdata)
-
Description
The ISP notifies the AF library to start release through this interface.
-
Parameter
Parameter Name Description Input/Output pdata Pointer to the private data of algorithm. Input
void (*run)(void* pdata, const ISP_AF_INFO *af_info, ISP_AF_RESULT *result)
-
Description
The ISP notifies AF library to start calculation through this interface.
-
Parameter
Parameter Name Description Input/Output pdata Pointer to the private data of algorithm. Input af_info Pointer to the AF statistical data structure of ISP. Input result Pointer to the AF algorithm result structure of ISP. Output
int (*ctrl)(void* pdata,ISP_AF_CTRL_CMD cmd,void* param) (Reserved)
-
Description
The ISP controls AF parameters through this interface.
-
Return Value
Return Value Description 0 Control command successful. <0 Control command failed. -
Parameter
Parameter Name Description Input/Output pdata Pointer to the private data of algorithm (Reserved). Input cmd AF control command (Reserved). Input param AF control command parameter (Reserved). Input
AF DATA STRUCTURE¶
ISP_AF_INTERFACE¶
-
Description
AF library registration structure. The algorithm needs to be implemented, and its callback pointers, including initialization, release, run, and control, should be filled in to enable the ISP to call this structure.
-
Declaration
typedef struct isp_af_interface { void *pdata; /**< Private data for AF algorithm.*/ int (*init)(void *pdata, ISP_AF_INIT_PARAM *param); void (*release)(void *pdata); void (*run)(void *pdata,const ISP_AF_INFO *af_info, ISP_AF_RESULT *result); int (*ctrl)(void *pdata,ISP_AF_CTRL_CMD cmd,void* param); }ISP_AF_INTERFACE; -
Member
Name Description pdata Pointer to the private data of AF library. init Callback pointer to AF library initialization. release Callback pointer to AF library release. run Callback pointer to AF library calculation. ISP will request AF algorithm to start calculation when receiving the statistics of a frame. ctrl Callback pointer to AF library control.
ISP_AF_INIT_PARAM¶
-
Description
ISP uses this structure to indicate the hardware initialization status related to AF algorithm.
-
Declaration
typedef struct _isp_af_init_param { u32 Size; /**< struct size*/ ISP_AF_RECT af_stats_win[16]; /**< CUS3A v1.3*/ u32 CurPos; //motor current position u32 MinPos; //motor down position limit u32 MaxPos; //motor up position limit u32 MinStep;//motor minimum step u32 MaxStep;//motor maximum step } ISP_AF_INIT_PARAM; -
Member
Name Description Input/Output Size Size of ISP_AF_INIT_PARAM structure. Input Af_stats_win[16] The setting value of current AF windows. Input CurPos Current position of AF motor. Input MinPos The bottommost position of AF motor. Input MaxPos The uppermost position of AF motor. Input MinStep The minimum step of AF motor. Input MaxStep The maximum step of AF motor. Input
ISP_AF_INFO¶
-
Description
Hardware statistics of ISP AF.
-
Declaration
/*! @brief AF HW statistics data*/ typedef struct { U32 Size; /**< struct size*/ ISP_AF_STATS pStats; /**< AF statistic*/ u32 CurPos; /**<motor current position*/ u32 MinPos; /**<motor down position limit*/ u32 MaxPos; /**<motor up position limit*/ }ISP_AF_INFO; -
Member
Parameter Name Description Input/Output Size Size of ISP_AF_INFO data structure. Input pStats ISP AF statistics. Output CurPos Current AF motor position. Input MinPos The bottommost position of AF motor. Input MaxPos The uppermost position of AF motor. Input
ISP_AF_INFO_STATS¶
-
Description
Hardware statistics of ISP AF.
-
Declaration
ISP_AF_INFO_STATS (Maruko, Iford)
typedef struct{ U8 high_iir[5*16]; U8 low_iir[5*16]; U8 luma[5*16]; U8 sobel_v[5*16]; U8 sobel_h[5*16]; U8 ysat[3*16]; } ISP_AF_INFO_STATS_PARAM_t; typedef struct{ ISP_AF_INFO_STATS_PARAM_t stParaAPI[16]; } ISP_AF_INFO_STATS;ISP_AF_INFO_STATS (Souffle)
typedef struct{ U8 high_iir[5*16]; U8 low_iir[5*16]; U8 luma[5*16]; U8 sobel_v[5*16]; U8 sobel_h[5*16]; U8 ysat[4*16]; } ISP_AF_INFO_STATS_PARAM_t; typedef struct{ ISP_AF_INFO_STATS_PARAM_t stParaAPI[16]; } ISP_AF_INFO_STATS; -
Member
Parameter Name Description Input/Output high_iir AF high-frequency IIR filter statistics in each block division. Output low_iir AF low-frequency IIR filter statistics in each block division. Output luma AF luminance statistics in each block division. Output sobel_v AF vertical FIR filter statistics in each block division. Output sobel_h AF horizontal FIR filter statistics in each block division. Output ysat Number of AF statistics greater than YThd in each block division. Output Higher IIR FIR values represent greater image clarity. Luma represents brightness.
-
Usage Recommendation
Block weighting weight: “center weight” is suggested.
Statistics: We suggest using “low_iir” in all cases. “high_iir” shows significant changes when the image is clear, but it will hardly change when the image is blurred; for this reason, “high_iir” is ideal for the determination of the clearest position. FIR is biased in nature and is only suitable as the reference of strength change.
ISP_AF_RESULT¶
-
Description
Result of ISP AF algorithm.
-
Declaration
/*! @brief AF algorithm result*/ typedef struct { u32 Size; /**< struct size*/ u32 Change; /**< if true, apply this result to hw*/ u32 NextPos; /**< Next position*/ } ISP_AF_RESULT; -
Member
Parameter Name Description Input/Output Change Notify ISP whether the current algorithm result should be applied to hardware. Output NextPos AF motor target position. Output
ISP_AF_CTRL_CMD¶
-
Description
AF control command. ISP set AF parameters through the callback interface
int (*ctrl)(void* pdata,ISP_AF_CTRL_CMD cmd,void* param). The type of parameter varies with different control commands. -
Declaration
typedef enum { ISP_AF_CMD_MAX }ISP_AF_CTRL_CMD; -
Member
Name Description Parameter Type ISP_AF_CMD_MAX Reserved value, obsolete. N/A.
SAMPLE CODE¶
#include <mi_isp.h>
//// AE INTERFACE TEST ////
int ae_init(void* pdata, ISP_AE_INIT_PARAM *init_state)
{
printf("****** ae_init ,shutter=%d,shutter_step=%d,sensor_gain_min=%d,sensor_gain_max=%d *******\n",
(int)init_state->shutter,
(int)init_state->shutter_step,
(int)init_state->sensor_gain,
(int)init_state->sensor_gain_max
);
return 0;
}
void ae_run(void* pdata, const ISP_AE_INFO *info, ISP_AE_RESULT *result)
{
#define log_info 1
// Only one can be chosen (the following three define)
#define shutter_test 0
#define gain_test 0
#define AE_sample 1
#if (shutter_test) || (gain_test)
static int AE_period = 4;
#endif
static unsigned int fcount = 0;
unsigned int max = info->AvgBlkY * info->AvgBlkX;
unsigned int avg = 0;
unsigned int n;
#if gain_test
static int tmp = 0;
static int tmp1 = 0;
#endif
result->Change = 0;
result->u4BVx16384 = 16384;
result->HdrRatio = 10; //infinity5 //TBD //10 * 1024; //user define hdr exposure ratio
result->IspGain = 1024;
result->SensorGain = 4096;
result->Shutter = 20000;
result->IspGainHdrShort = 1024;
result->SensorGainHdrShort = 1024;
result->ShutterHdrShort = 1000;
//result->Size = sizeof(CusAEResult_t);
for(n = 0; n < max; ++n)
{
avg += info->avgs[n].y;
}
avg /= max;
result->AvgY = avg;
#if shutter_test // shutter test under constant sensor gain
int Shutter_Step = 100; //per frame
int Shutter_Max = 33333;
int Shutter_Min = 150;
int Gain_Constant = 10240;
result->SensorGain = Gain_Constant;
result->Shutter = info->Shutter;
if(++fcount % AE_period == 0)
{
if (tmp == 0)
{
result->Shutter = info->Shutter + Shutter_Step * AE_period;
//printf("[shutter-up] result->Shutter = %d \n", result->SensorGain);
}
else
{
result->Shutter = info->Shutter - Shutter_Step * AE_period;
//printf("[shutter-down] result->Shutter = %d \n", result->SensorGain);
}
if (result->Shutter >= Shutter_Max)
{
result->Shutter = Shutter_Max;
tmp = 1;
}
if (result->Shutter <= Shutter_Min)
{
result->Shutter = Shutter_Min;
tmp = 0;
}
}
#if log_info
printf("fcount = %d, Image avg = 0x%X \n", fcount, avg);
printf("tmp = %d, Shutter: %d -> %d \n", tmp, info->Shutter, result->Shutter);
#endif
#endif
#if gain_test // gain test under constant shutter
int Gain_Step = 1024; //per frame
int Gain_Max = 1024 * 100;
int Gain_Min = 1024 * 2;
int Shutter_Constant = 20000;
result->SensorGain = info->SensorGain;
result->Shutter = Shutter_Constant;
if(++fcount % AE_period == 0)
{
if (tmp1 == 0)
{
result->SensorGain = info->SensorGain + Gain_Step * AE_period;
//printf("[gain-up] result->SensorGain = %d \n", result->SensorGain);
}
else
{
result->SensorGain = info->SensorGain - Gain_Step * AE_period;
//printf("[gain-down] result->SensorGain = %d \n", result->SensorGain);
}
if (result->SensorGain >= Gain_Max)
{
result->SensorGain = Gain_Max;
tmp1 = 1;
}
if (result->SensorGain <= Gain_Min)
{
result->SensorGain = Gain_Min;
tmp1 = 0;
}
}
#if log_info
printf("fcount = %d, Image avg = 0x%X \n", fcount, avg);
printf("tmp = %d, SensorGain: %d -> %d \n", tmp, info->SensorGain, result->SensorGain);
#endif
#endif
#if AE_sample
int y_lower = 0x28;
int y_upper = 0x38;
int change_ratio = 10; // percentage
int Gain_Min = 1024 * 2;
int Gain_Max = 1024 * 1000;
int Shutter_Min = 150;
int Shutter_Max = 33333;
result->SensorGain = info->SensorGain;
result->Shutter = info->Shutter;
if(avg < y_lower)
{
if (info->Shutter < Shutter_Max)
{
result->Shutter = info->Shutter + (info->Shutter * change_ratio / 100);
if (result->Shutter > Shutter_Max) result->Shutter = Shutter_Max;
}
else
{
result->SensorGain = info->SensorGain + (info->SensorGain * change_ratio / 100);
if (result->SensorGain > Gain_Max) result->SensorGain = Gain_Max;
}
result->Change = 1;
}
else if(avg > y_upper)
{
if (info->SensorGain > Gain_Min)
{
result->SensorGain = info->SensorGain - (info->SensorGain * change_ratio / 100);
if (result->SensorGain < Gain_Min) result->SensorGain = Gain_Min;
}
else
{
result->Shutter = info->Shutter - (info->Shutter * change_ratio / 100);
if (result->Shutter < Shutter_Min) result->Shutter = Shutter_Min;
}
result->Change = 1;
}
#if 0 //infinity5 //TBD
//hdr demo code
result->SensorGainHdrShort = result->SensorGain;
result->ShutterHdrShort = result->Shutter * 1024 / result->HdrRatio;
#endif
#if log_info
printf("fcount = %d, Image avg = 0x%X \n", fcount, avg);
printf("SensorGain: %d -> %d \n", (int)info->SensorGain, (int)result->SensorGain);
printf("Shutter: %d -> %d \n", (int)info->Shutter, (int)result->Shutter);
#endif
#endif
}
void ae_release(void* pdata)
{
printf("************* ae_release *************\n");
}
//// AWB INTERFACE TEST ////
int awb_init(void *pdata)
{
printf("************ awb_init **********\n");
return 0;
}
void awb_run(void* pdata, const ISP_AWB_INFO *info, ISP_AWB_RESULT *result)
{
#define log_info 1
static u32 count = 0;
int avg_r = 0;
int avg_g = 0;
int avg_b = 0;
int tar_rgain = 1024;
int tar_bgain = 1024;
int x = 0;
int y = 0;
result->R_gain = info->CurRGain;
result->G_gain = info->CurGGain;
result->B_gain = info->CurBGain;
result->Change = 0;
result->ColorTmp = 6000;
if (++count % 4 == 0)
{
//center area YR/G/B avg
for (y = 30; y < 60; ++y)
{
for (x = 32; x < 96; ++x)
{
avg_r += info->avgs[info->AvgBlkX * y + x].r;
avg_g += info->avgs[info->AvgBlkX * y + x].g;
avg_b += info->avgs[info->AvgBlkX * y + x].b;
}
}
avg_r /= 30 * 64;
avg_g /= 30 * 64;
avg_b /= 30 * 64;
if (avg_r < 1)
avg_r = 1;
if (avg_g < 1)
avg_g = 1;
if (avg_b < 1)
avg_b = 1;
#if log_info
printf("AVG R / G / B = %d, %d, %d \n", avg_r, avg_g, avg_b);
#endif
// calculate Rgain, Bgain
tar_rgain = avg_g * 1024 / avg_r;
tar_bgain = avg_g * 1024 / avg_b;
if (tar_rgain > info->CurRGain)
{
if (tar_rgain - info->CurRGain < 384)
result->R_gain = tar_rgain;
else
result->R_gain = info->CurRGain + (tar_rgain - info->CurRGain) / 10;
}
else
{
if (info->CurRGain - tar_rgain < 384)
result->R_gain = tar_rgain;
else
result->R_gain = info->CurRGain - (info->CurRGain - tar_rgain) / 10;
}
if (tar_bgain > info->CurBGain)
{
if (tar_bgain - info->CurBGain < 384)
result->B_gain = tar_bgain;
else
result->B_gain = info->CurBGain + (tar_bgain - info->CurBGain) / 10;
}
else
{
if (info->CurBGain - tar_bgain < 384)
result->B_gain = tar_bgain;
else
result->B_gain = info->CurBGain - (info->CurBGain - tar_bgain) / 10;
}
result->Change = 1;
result->G_gain = 1024;
#if log_info
printf("[current] r=%d, g=%d, b=%d \n", (int)info->CurRGain, (int)info->CurGGain, (int)info->CurBGain);
printf("[result] r=%d, g=%d, b=%d \n", (int)result->R_gain, (int)result->G_gain, (int)result->B_gain);
#endif
}
}
void awb_release(void *pdata)
{
printf("************ awb_release **********\n");
}
//// AF INTERFACE TEST ////
int af_init(void *pdata, ISP_AF_INIT_PARAM *param)
{
MI_U32 dev = Mdev;
MI_U32 u32ch = Mch;
MIXER_DBG("************ af_init **********\n");
#define USE_NORMAL_MODE 1
#ifdef USE_NORMAL_MODE
//Init Normal mode setting
static CusAFWin_t afwin =
{
AF_ROI_MODE_NORMAL,
1,
{ { 0, 0, 255, 255},
{ 256, 0, 511, 255},
{ 512, 0, 767, 255},
{ 768, 0, 1023, 255},
{ 0, 256, 255, 511},
{ 256, 256, 511, 511},
{ 512, 256, 767, 511},
{ 768, 256, 1023, 511},
{ 0, 512, 255, 767},
{ 256, 512, 511, 767},
{ 512, 512, 767, 767},
{ 768, 512, 1023, 767},
{ 0, 768, 255, 1023},
{ 256, 768, 511, 1023},
{ 512, 768, 767, 1023},
{ 768, 768, 1023, 1023}
}
};
MI_ISP_CUS3A_SetAFWindow(dev, u32ch, &afwin);
#else
//Init Matrix mode setting
static CusAFWin_t afwin =
{
//full image, equal divide to 16x16
//window setting need to multiple of two
AF_ROI_MODE_MATRIX,
16,
{ {0, 0, 62, 62},
{64, 64, 126, 126},
{128, 128, 190, 190},
{192, 192, 254, 254},
{256, 256, 318, 318},
{320, 320, 382, 382},
{384, 384, 446, 446},
{448, 448, 510, 510},
{512, 512, 574, 574},
{576, 576, 638, 638},
{640, 640, 702, 702},
{704, 704, 766, 766},
{768, 768, 830, 830},
{832, 832, 894, 894},
{896, 896, 958, 958},
{960, 960, 1022, 1022}
}
/*
//use two row only => 16x2 win
//and set taf_roimode.u32_vertical_block_number = 2
AF_ROI_MODE_MATRIX,
2,
{ {0, 0, 62, 62},
{64, 64, 126, 126},
{128, 0, 190, 2}, //win2 v_str, v_end doesn't use, set to (0, 2)
{192, 0, 254, 2},
{256, 0, 318, 2},
{320, 0, 382, 2},
{384, 0, 446, 2},
{448, 0, 510, 2},
{512, 0, 574, 2},
{576, 0, 638, 2},
{640, 0, 702, 2},
{704, 0, 766, 2},
{768, 0, 830, 2},
{832, 0, 894, 2},
{896, 0, 958, 2},
{960, 0, 1022, 2}
}
*/
};
MI_ISP_CUS3A_SetAFWindow(dev, u32ch, &afwin);
#endif
//set AF Filter
static CusAFFilter_t affilter =
{
//filter setting with sign value
//{s9, s10, s9, s13, s13}
//[0.3~0.6] : 20, 37, 20, -4352, 3392; 20, -39, 20, 2176, 3264; 26, 0, -26,
-1152, 2432;
//[0.2~0.5] : 20, 35, 20, -6144, 3520; 20, -39, 20, -64, 2304; 26, 0, -26,
-3328, 2432;
//[0.1~0.6] : 37, 0, -37, -6848, 3136; 37, 0, -37, 1600, 1792; 32, 0, -32,
-2624, 0;
//[0.08~0.24]: 13, 11, 13, -5568, 3456; 13, -26, 13, -7680, 3840; 15, 0, -15,
-6592, 3200;
//[0.03~0.25]: 19, 0, -19, -7808, 3776; 19, 0, -19, -4672, 2304; 17, 0, -17,
-5824, 1920;
//[0.07~0.1] : 8, -13, 8, -7680, 3968; 8, -16, 8, -7936, 4032; 3, 0, -3,
-7744, 3904;
//here use [0.3~0.6] & [0.08~0.24]
//convert to hw format (sign bit with msb)
20, 37, 20, 4352+8192, 3392, 0, 1023, 0, 1023,
13, 11, 13, 5568+8192, 3456, 0, 1023, 0, 1023,
1, 20, 39+1024, 20, 2176, 3264,
1, 26, 0, 26+512, 1152+8192, 2432,
1, 13, 26+1024, 13, 7680+8192, 3840,
1, 15, 0, 15+512, 6592+8192, 3200,
};
MI_ISP_CUS3A_SetAFFilter(dev, 0, &affilter);
//set AF Sq
CusAFFilterSq_t sq = {
.bSobelYSatEn = 0,
.u16SobelYThd = 1023,
.bIIRSquareAccEn = 1,
.bSobelSquareAccEn = 0,
.u16IIR1Thd = 0,
.u16IIR2Thd = 0,
.u16SobelHThd = 0,
.u16SobelVThd = 0,
.u8AFTbl1X = {6,7,7,6,6,6,7,6,6,7,6,6,},
.u16AFTbl1Y = {0,32,288,800,1152,1568,2048,3200,3872,4607,6271,7199,8191},
.u8AFTbl2X = {6,7,7,6,6,6,7,6,6,7,6,6,},
.u16AFTbl2Y = {0,32,288,800,1152,1568,2048,3200,3872,4607,6271,7199,8191},
};
MI_ISP_CUS3A_SetAFFilterSq(dev, 0, &sq);
#if MOTOR_TEST
mod1_isp_af_motor_init();
#endif
MIXER_DBG("**** af_init done ****\n");
return 0; }
void af_run(void *pdata, const ISP_AF_INFO *af_info, ISP_AF_RESULT *result)
{
#define af_log_info 1
#if af_log_info
int i=0,x=0;
printf("\n\n");
//print row0 16wins
x=0;
for (i=0; i<16; i++){
printf("[AF]win%d-%d iir0: 0x%02x%02x%02x%02x%02x, iir1:0x%02x%02x%02x%02x%02x, luma:0x%02x%02x%02x%02x%02x, sobelh:0x%02x%02x%02x%02x%02x, sobelv:0x%02x%02x%02x%02x%02x ysat:0x%02x%02x%02x\n",
x, i,
af_info->af_stats.stParaAPI[x].high_iir[4+i*5],af_info->af_stats.stParaAPI[x].high_iir[3+i*5],af_info->af_stats.stParaAPI[x].high_iir[2+i*5],af_info->af_stats.stParaAPI[x].high_iir[1+i*5],af_info->af_stats.stParaAPI[x].high_iir[0+i*5],
af_info->af_stats.stParaAPI[x].low_iir[4+i*5],af_info->af_stats.stParaAPI[x].low_iir[3+i*5],af_info->af_stats.stParaAPI[x].low_iir[2+i*5],af_info->af_stats.stParaAPI[x].low_iir[1+i*5],af_info->af_stats.stParaAPI[x].low_iir[0+i*5],
af_info->af_stats.stParaAPI[x].luma[4+i*5],af_info->af_stats.stParaAPI[x].luma[3+i*45],af_info->af_stats.stParaAPI[x].luma[2+i*45],af_info->af_stats.stParaAPI[x].luma[1+i*45],af_info->af_stats.stParaAPI[x].luma[0+i*45],
af_info->af_stats.stParaAPI[x].sobel_h[4+i*5],af_info->af_stats.stParaAPI[x].sobel_h[3+i*5],af_info->af_stats.stParaAPI[x].sobel_h[2+i*5],af_info->af_stats.stParaAPI[x].sobel_h[1+i*5],af_info->af_stats.stParaAPI[x].sobel_h[0+i*5],
af_info->af_stats.stParaAPI[x].sobel_v[4+i*5],af_info->af_stats.stParaAPI[x].sobel_v[3+i*5],af_info->af_stats.stParaAPI[x].sobel_v[2+i*5],af_info->af_stats.stParaAPI[x].sobel_v[1+i*5],af_info->af_stats.stParaAPI[x].sobel_v[0+i*5],
af_info->af_stats.stParaAPI[x].ysat[2+i*3],af_info->af_stats.stParaAPI[x].ysat[1+i*3],af_info->af_stats.stParaAPI[x].ysat[0+i*3]
);
}
//print row15 16wins
x=15;
for (i=0; i<16; i++){
printf("[AF]win%d-%d iir0: 0x%02x%02x%02x%02x%02x, iir1:0x%02x%02x%02x%02x%02x, luma:0x%02x%02x%02x%02x%02x, sobelh:0x%02x%02x%02x%02x%02x, sobelv:0x%02x%02x%02x%02x%02x ysat:0x%02x%02x%02x\n",
x, i,
af_info->af_stats.stParaAPI[x].high_iir[4+i*5],af_info->af_stats.stParaAPI[x].high_iir[3+i*5],af_info->af_stats.stParaAPI[x].high_iir[2+i*5],af_info->af_stats.stParaAPI[x].high_iir[1+i*5],af_info->af_stats.stParaAPI[x].high_iir[0+i*5],
af_info->af_stats.stParaAPI[x].low_iir[4+i*5],af_info->af_stats.stParaAPI[x].low_iir[3+i*5],af_info->af_stats.stParaAPI[x].low_iir[2+i*5],af_info->af_stats.stParaAPI[x].low_iir[1+i*5],af_info->af_stats.stParaAPI[x].low_iir[0+i*5],
af_info->af_stats.stParaAPI[x].luma[4+i*5],af_info->af_stats.stParaAPI[x].luma[3+i*45],af_info->af_stats.stParaAPI[x].luma[2+i*45],af_info->af_stats.stParaAPI[x].luma[1+i*45],af_info->af_stats.stParaAPI[x].luma[0+i*45],
af_info->af_stats.stParaAPI[x].sobel_h[4+i*5],af_info->af_stats.stParaAPI[x].sobel_h[3+i*5],af_info->af_stats.stParaAPI[x].sobel_h[2+i*5],af_info->af_stats.stParaAPI[x].sobel_h[1+i*5],af_info->af_stats.stParaAPI[x].sobel_h[0+i*5],
af_info->af_stats.stParaAPI[x].sobel_v[4+i*5],af_info->af_stats.stParaAPI[x].sobel_v[3+i*5],af_info->af_stats.stParaAPI[x].sobel_v[2+i*5],af_info->af_stats.stParaAPI[x].sobel_v[1+i*5],af_info->af_stats.stParaAPI[x].sobel_v[0+i*5],
af_info->af_stats.stParaAPI[x].ysat[2+i*3],af_info->af_stats.stParaAPI[x].ysat[1+i*3],af_info->af_stats.stParaAPI[x].ysat[0+i*3]
);
}
#endif}
void af_release(void *pdata)
{
printf("************ af_release **********\n");
}
int main(int argc,char** argv)
{
//TO DO: Register 3rd party AE/AWB library
ISP_AE_INTERFACE tAeIf;
ISP_AWB_INTERFACE tAwbIf;
CUS3A_Init();
/*AE*/
tAeIf.ctrl = NULL;
tAeIf.pdata = NULL;
tAeIf.init = ae_init;
tAeIf.release = ae_release;
tAeIf.run = ae_run;
/*AWB*/
tAwbIf.ctrl = NULL;
tAwbIf.pdata = NULL;
tAwbIf.init = awb_init;
tAwbIf.release = awb_release;
tAwbIf.run = awb_run;
CUS3A_RegInterface(0,&tAeIf,&tAwbIf,NULL);
// or use below reginterface
//CUS3A_AERegInterface(0,&tAeIf);
//CUS3A_AWBRegInterface(0,&tAwbIf);
//TO DO: Open MI
MI_SYS_Init();
while(1)
{
usleep(5000);
}
}
CUS3A_AeAvgDownSample¶
The following function aims to convert AE statistics from 32x32 into 16x16 sample code, as illustrated below.
void ae_run(void* pdata, const ISP_AE_INFO *info, ISP_AE_RESULT *result)
{
ISP_AE_SAMPLE *pInBuf = info->avgs;
ISP_AE_SAMPLE *pOutBuf = info->avgs;
unsigned int u32InBlkNumX = info->AvgBlkX; //value is 32 for MACARON, PUDDING, PCUPID
unsigned int u32InBlkNumY = info->AvgBlkY; //value is 32 for MACARON, PUDDING, PCUPID
unsigned int u32OutBlkNumX = 16;
unsigned int u32OutBlkNumY = 16;
CUS3A_AeAvgDownSample(pInBuf, pOutBuf, u32InBlkNumX, u32InBlkNumY, u32OutBlkNumX, u32OutBlkNumY);
max = u32OutBlkNumX*u32OutBlkNumY;
}
SET AE CROP RANGE IN MI_ISP¶
MI_ISP_CUS3A_SetAECropSize¶
-
Purpose
Set the range of AE statistics.
-
Syntax
MI_RET MI_ISP_CUS3A_SetAECropSize(MI_U32 DevId, MI_U32 Channel, CusAEAWBCropSize_t *data);
-
Description
Call MI_ISP_CUS3A_SetAECropSize to set the range of AE statistics.
Call MI_ISP_CUS3A_SetAEWindowBlockNumber to divide the region within the crop size into MxN blocks.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data Set the range of AE statistics. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAEAWBCropSize_t¶
-
Purpose
Set AE statistical value range.
-
Definition
typedef struct { MI_U16 u2CropX; MI_U16 u2CropY; MI_U16 u2CropW; MI_U16 u2CropH; } CusAEAWBCropSize_t; -
Parameter
Parameter Name Description U2CropX The starting point of X for the range of AE/AWB statistics (0~1023). U2CropY The starting point of Y for the range of AE/AWB statistics (0~1023). U2CropW The cropped width for the range of AE/AWB statistics (0~1023). U2CropH The cropped height for the range of AE/AWB statistics (0~1023). Compared to the actual image size, the minimum width and height supported for the cropped image is 320x256. If the original image size is 1920x1080, the minimum setting of cropped width and height by the API will be (320/1920)*1024, (256/1080)*1024 = 170, 242.
-
CropSize Description

-
Note As the width and height of the image have already reached 1023, the crop information should be based on 1023. FW will automatically take the actual size of current image and perform mapping. Therefore, user can simply set relative position without the need to know the current image size.
Assume CropX = 10, CropY = 10, CropW = 300, and CropH = 250. If the actual image width and height = 1920x1080, the CropX, CropY, CropW and CropH corresponding to 1920x1080 will be as follows:
CropX = 1920*10/1024 = 18
CropY = 1080*10/1024 = 10
CropW = 1920*300/1024 = 563
CropH = 1080*250/1024 = 263
-
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
SET AE BLOCK NUMBER IN MI_ISP¶
MI_ISP_CUS3A_SetAEWindowBlockNumber¶
-
Purpose
Set the number of AE window block.
-
Syntax
MI_RET MI_ISP_CUS3A_SetAEWindowBlockNumber(MI_U32 DevId, MI_U32 Channel, MS_CUST_AE_WIN_BLOCK_NUM_TYPE_e eBlkNum);
-
Description
Call this interface to set the AE block number within the cropped range set by MI_ISP_CUS3A_SetAECropSize. If MI_ISP_CUS3A_SetAECropSize is not set, the default range will be full image.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). eBlkNum Block number, by which an image is divided into X*Y blocks. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
MS_CUST_AE_WIN_BLOCK_NUM_TYPE_e¶
-
Description
AE block.
-
Definition
typedef enum { AE_16x24 = 0, AE_32x24, AE_64x48, AE_64x45, AE_128x80, AE_128x90 } AeWinBlockNum_e; -
Member
Parameter Name Description AE_16x24 Divide image into 16*24 blocks. AE_32x24 Divide image into 32*24 blocks. AE_64x48 Divide image into 64*48 blocks. AE_64x45 Divide image into 64*45 blocks. AE_128x80 Divide image into 128*80 blocks. AE_128x90 Divide image into 128*90 blocks. 
-
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
-
Note
Tiramisu does not support this API, and the image will be divided into 32*32 blocks automatically.
SET AE HISTOGRAM WINDOW IN MI_ISP¶
MI_ISP_CUS3A_SetAEHistogramWindow¶
-
Purpose
Set the position and size of AE brightness distribution statistics window.
-
Syntax
MI_RET MI_ISP_CUS3A_SetAEHistogramWindow(MI_U32 DevId, MI_U32 Channel, CusAEHistWin_t *data);
-
Description
Call this interface to set position and size of AE brightness distribution statistics window.
-
Member
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data Window position and size of AE brightness distribution statistics, for window number (0 or 1). -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
HistWin_t¶
-
Description
Window setting of AE brightness distribution statistics.
-
Definition
typedef struct { MI_U16 u2Stawin_x_offset; MI_U16 u2Stawin_x_size; MI_U16 u2Stawin_y_offset; MI_U16 u2Stawin_y_size; MI_U16 u2WinIdx; } CusAEHistWin_t; -
Member
Parameter Name Description u2Stawin_x_offset Offset of the starting coordinate of window on X-axis. u2Stawin_x_size Window size on the X-axis direction. u2Stawin_y_offset Offset of the starting coordinate of window on Y-axis. u2Stawin_y_size Window size on the Y-axis direction. u2WinIdx Window number (0 or 1). -
Parameter Range
X-axis offset: 0 ~ 127
Y-axis offset: 0 ~ 89
X-axis (offset + size) <= 128
Y-axis (offset + size) <= 90
Please refer to the following figure for illustration.

-
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
-
Note
Currently, only two windows (0/1) can be set at the same time. The window areas can overlap.
SET AWB CROP RANGE IN MI_ISP¶
MI_ISP_CUS3A_SetAWBCropSize¶
-
Purpose
Set the range of AWB statistics.
-
Syntax
MI_RET MI_ISP_CUS3A_SetAWBCropSize(MI_U32 DevId, MI_U32 Channel, CusAEAWBCropSize_t *data);
-
Description
Step 1: Call MI_ISP_CUS3A_SetAWBCropSize interface to set the range of AWB statistics.
Step 2: The hardware will divide the range further into 128x90 blocks according to the statistics.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data Set the range of AWB statistics. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAWBCropSize_t¶
-
Purpose
Set the range of AWB statistics.
-
Definition
typedef struct { MI_U16 u2CropX; MI_U16 u2CropY; MI_U16 u2CropW; MI_U16 u2CropH; } CusAEAWBCropSize_t; -
Parameter
Parameter Name Description U2CropX The starting point of X for the range of AE/AWB statistics (0~1023). U2CropY The starting point of Y for the range of AE/AWB statistics (0~1023). U2CropW The cropped width for the range of AE/AWB statistics (0~1023). U2CropH The cropped height for the range of AE/AWB statistics (0~1023). Compared to the actual image size, the minimum width and height supported for the cropped image is 60x40. If the original image size is 1920x1080, the minimum setting of cropped width and height by the API will be (60/1920)*1024, (40/1080)*1024 = 32, 37.
If the final size of the cropped image is smaller than 1280x720, the number of statistical value will decrease. You may read AvgBlkX and AvgBlkY in awb info to double check.
-
CropSize Description

Note As the image width and height have already reached 1023, the crop information must be based on 1023. FW will automatically take the current actual image size and perform the mapping action. Therefore, user can simply set the relative position without the need to know the current image size.
Assume CropX = 10, CropY = 10, CropW = 300, and CropH = 200. If the actual image width and height = 1920x1080, the CropX, CropY, CropW and CropH corresponding to 1920x1080 will be as follows:
CropX = 1920*10/1023 = 18
CropY = 1080*10/1023 = 10
CropW = 1920*300/1023 = 563
CropH = 1080*200/1023 = 211
-
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
SET AWB SAMPLING IN MI_ISP¶
MI_ISP_CUS3A_SetAwbSampling¶
-
Purpose
Set AWB sampling size.
-
Syntax
MI_RET MI_ISP_CUS3A_SetAwbSampling(MI_U32 DevId, MI_U32 Channel, CusAWBSample_t *data)
-
Description
Call this interface to set AWB sampling size.
-
Member
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data Set AWB sampling size. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAWBSample_t¶
-
Description
AWB sampling size.
-
Definition
typedef struct { MI_U32 SizeX; MI_U32 SizeY; MI_U32 IncRatio; } CusAWBSample_t; -
Member
Parameter Name Description SizeX The number of sampling points on X-axis. SizeY The number of sampling points on Y-axis. IncRatio The ratio to be multiplied by statistics. 
-
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
-
Note
An image is divided into 128*90 blocks, where SizeX * SizeY pixels are taken from each block as the AWB sampling size.
SizeX: SizeX >=4 && SizeX <= Block_size_X
SizeY: SizeY >=2 && SizeY <= Block_size_Y
When AE brightness is very low, you can multiply the statistics by a ratio (IncRatio) to prevent statistics from being 0.
SET AF WINDOW IN MI_ISP¶
MI_ISP_CUS3A_SetAFWindow¶
-
Purpose
Set AF Window.
-
Syntax
MI_RET MI_ISP_CUS3A_SetAFWindow (MI_U32 DevId, MI_U32 Channel, CusAFWin_t *data);
-
Description
Set AF window during the stage of AF_Init by dividing CMOS sensor image into 1024*1024 grids.

The coordinate and actual crop range conversion formula is:
Image width * X / 1024 = actual X coordinate
Image height * Y / 1024 = actual Y coordinate
For example, suppose AF window is set as:
Start_X = 458 End_X = 566 Start_Y = 418 End_Y = 606
Then the AF window coordinates in the case of a 1920x1080 CMOS sensor will be:
Real_Start_X = 1920 *458/1024 = 858 Real_End_X = 1920 *566/1024 = 1061 Real_Start_Y = 1080 *418/1024 = 440 Real_End_Y = 1080 *606/1024 = 639
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data AF Window setting. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAFWin_t¶
typedef enum __attribute__ ((aligned (1)))
{
AF_ROI_MODE_NORMAL,
AF_ROI_MODE_MATRIX
} ISP_AF_ROI_MODE_e;
typedef struct AF_WINDOW_PARAM_s
{
MI_U32 u32StartX; /*range : 0~1023*/
MI_U32 u32StartY; /*range : 0~1023*/
MI_U32 u32EndX; /*range : 0~1023*/
MI_U32 u32EndY; /*range : 0~1023*/
} AF_WINDOW_PARAM_t;
typedef struct
{
ISP_AF_ROI_MODE_e mode;
MI_U32 u32_vertical_block_number;
AF_WINDOW_PARAM_t stParaAPI[16];
} CusAFWin_t;
-
Parameter
Parameter Name Description mode AF_ROI_MODE_NORMAL: the image can be divided into 16 sets of ROI blocks. The window size and position can be set according to user preference. This is the default mode.
AF_ROI_MODE_MATRIX: the image can be divided into 16 * N sets of ROI windows. The window size and position are relatively limited, but more blocks can be used (N= u32_vertical_block_number).u32_vertical_block_number If mode = AF_ROI_MODE_MATRIX, the image can be divided into 16 * N sets of ROI blocks (N= u32_vertical_block_number, 1~16). stParaAPI[16] 16 sets of AF ROI position. -
Description
When AF ROI Mode = AF_ROI_MODE_NORMAL, StrX, StrY, EndX, and EndY represent the position of Window Index.

→ win0 represents stParaAPI[0]
When AF ROI Mode = AF_ROI_MODE_MATRIX, StrX and EndX represent the crop position of the window on horizontal axis, and StrY and EndY the crop position on the vertical axis.

→ win0 represents stParaAPI[0]
→ win1 represents stParaAPI[1]
→ win15 represents stParaAPI[15]
There are 16 fixed ROI blocks on the horizontal direction.
As for the vertical direction, the number of ROI block (16 * N) will be decided by u32_vertical_block_number.
In the above diagram, u32_vertical_block_number=16, meaning that the number of ROI blocks is 16*16.
Limitation:
If AF ROI Mode = AF_ROI_MODE_NORMAL,
-
The width and height of each window can overlap.
-
h/v end > h/v start
If AF ROI Mode = AF_ROI_MODE_MATRIX,
-
The width of the respective window can overlap, but not in the case of window height.
-
h/v end > h/v start
-
win0_v_start < win0_v_end < win1_v_start < win1_v_end < win2…
-
win(0,0), win(1,0), …, win(15,0) share the same h_start and h_end, which are determined by af0_h_start and h_end
-
win(0,1), win(1,1), …, win(15,1) share the same h_start and h_end, which are determined by af1_h_start and h_end, and so on for other windows
-
win(0,0), win(0,1), …, win(0,15) share the same v_start and v_end, which are determined by af0_v_start and v_end
-
win(1,0), win(1,1), …, win(1,15) share the same v_start and v_end, which are determined by af1_v_start and v_end, and so on for other windows
As the statistical value of IIR will be re-calculated in each line of the image, setting window h_start too far on the left end of the horizontal axis (such as setting h_start = 0) is not recommended. Otherwise, the statistical value may contain deviation because IIR has not finished converging.
-
-
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
SET AF SOURCE IN MI_ISP¶
MI_ISP_CUS3A_SetAFSource¶
-
Purpose
Select the source of AF statistics.
-
Syntax
MI_RET MI_ISP_CUS3A_SetAFSource (MI_U32 DevId, MI_U32 Channel, CusAFSource_e *data);
-
Description
Select the source of AF statistics.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data AF Window setting. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAFSource_e¶
typedef enum
{
AF_SOURCE_BF_3DNR_AF_HDR = 0,
AF_SOURCE_FROM_SE_OBC_BF_HDR = 2,
AF_SOURCE_FROM_SE_WBG_BF_HDR = 3,
AF_SOURCE_FROM_ALSC_AF_HDR = 4,
AF_SOURCE_FROM_WBG_AF_HDR = 5,
AF_SOURCE_FROM_LE_OBC_BF_HDR = 6,
AF_SOURCE_FROM_LE_WBG_BF_HDR = 7,
} CusAFSource_e;
-
Parameter
HDR Mode:
Parameter Name Description AF_SOURCE_BF_3DNR_AF_HDR Select post-HDR result (before 3DNR). AF_SOURCE_FROM_SE_OBC_BF_HDR Select pre-HDR short-exposure result (after OB). AF_SOURCE_FROM_SE_WBG_BF_HDR Select pre-HDR short-exposure result (after WBGain). AF_SOURCE_FROM_ALSC_AF_HDR Select post-HDR result (after Shading). AF_SOURCE_FROM_WBG_AF_HDR Select post-HDR result (after WBGain). AF_SOURCE_FROM_LE_OBC_BF_HDR Select pre-HDR long-exposure result (after OB). AF_SOURCE_FROM_LE_WBG_BF_HDR Select pre-HDR long-exposure result (after WBGain). Linear Mode:
Parameter Name Description AF_SOURCE_BF_3DNR_AF_HDR Select pre-3DNR result. AF_SOURCE_FROM_SE_OBC_BF_HDR Select post-OB result. AF_SOURCE_FROM_SE_WBG_BF_HDR Selects post-WBGain result. AF_SOURCE_FROM_ALSC_AF_HDR Select pre-CI result (after Shading). AF_SOURCE_FROM_WBG_AF_HDR Select pre-CI result (after WBGain). AF_SOURCE_FROM_LE_OBC_BF_HDR Not supported. AF_SOURCE_FROM_LE_WBG_BF_HDR Not supported. -
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
SET AF YPARAM IN MI_ISP¶
MI_ISP_CUS3A_SetAFYParam¶
-
Purpose
Set AF Y Param.
-
Syntax
MI_RET MI_ISP_CUS3A_SetAFYParam (MI_U32 DevId, MI_U32 Channel, CusAFYParam_t *data);
-
Description
When AF calculates statistical values, the algorithm will convert Bayer data to Y data. This function provides control over the respective conversion ratio of R/G/B.
Default ratios for the conversion of BayerRGB to Y are (76, 75, 29), respectively. When the value is set to 128, the ratio would be 1x (i.e. remains unchanged). This function will be useful in backlight scenario or under darker environment, where less brightness results in lower AF statistics, which, in turn, impede the determination of peak value. In such cases, you might raise the RGB ratios to — for example — (255, 252, 97), thereby enhancing the Y signal and making the peak value more obvious. The values cannot be set greater than 255.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data AF Window setting. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAFYParam_t¶
typedef struct
{
MI_U8 r; //0~255
MI_U8 g; //0~255
MI_U8 b; //0~255
} CusAFYParam_t;
-
Parameter
Parameter Name Description r Bayer to Y conversion ratio for r channel. Range: 0 ~ 255. g Bayer to Y conversion ratio for g channel. Range: 0 ~ 255. b Bayer to Y conversion ratio for b channel. Range: 0 ~ 255. -
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
SET AF YMAP IN MI_ISP¶
MI_ISP_CUS3A_SetAFYMap¶
-
Purpose
Set AF YMap.
-
Syntax
MI_RET MI_ISP_CUS3A_SetAFYMap (MI_U32 DevId, MI_U32 Channel, CusAFYMap_t *data);
-
Description
Perform tone mapping conversion to brightness (Y) after Bayer data is converted to this format. This function, of which the application timing is the same as MI_ISP_CUS3A_SetAFYParam, helps enhance brightness in low bright scene and makes FV value easier to be detected.
We suggest using SetAFYMap instead of SetAFYParam, because the latter achieves brighter results by multiplying the overall data by a gain, which makes dark area brighter but bright area overexposed. SetAFYMap, by contrast, can be applied to different areas so that brighter areas will not be overexposed.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data AF YMap setting. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAFYMap_t (Muffin)¶
typedef struct
{
MI_U8 u8Src1En;
MI_U8 u8Src1LumaSource; // 0: bef ymap; 1: aft ymap
MI_U8 u8Src1YMapX[AF_YMAP_X_NUM]; // 1~9
MI_U16 u16Src1YMapY[AF_YMAP_Y_NUM]; // 0~1023
MI_U8 u8Src2En;
MI_U8 u8Src2LumaSource; //0: bef ymap; 1: aft ymap
MI_U8 u8Src2YMapX[AF_YMAP_X_NUM]; // 1~9
MI_U16 u16Src2YMapY[AF_YMAP_Y_NUM]; // 0~1023
MI_U8 u8LumaSrc; // 0: src2 bef map; 1: src2 aft ymap;
// 2: src1 bef map; 3: src1 aft ymap;
} CusAFYMap_t;
-
Parameter
Parameter Name Description u8Src1En Enable Src1 YMap. u8Src1LumaSource Select whether FIR/IIR statistics should be processed by Src1 YMap.
0: Calculate the statistics before YMap.
1: Calculate the statistics after YMap.u8Src1YMapX [AF_YMAP_X_NUM] The horizontal axis of Src1 YMap, and the node is accumulated by the power of 2. The last point should be greater than or equal to 1023. AF_YMAP_X_NUM = 8 u16Src1YMapY [AF_YMAP_Y_NUM] The vertical axis of Src1 YMap. Range: 0~1023. AF_YMAP_Y_NUM = 9 u8Src2En Enable Src2 YMap. u8Src2LumaSource Select whether FIR/IIR statistics should be processed by Src2 YMap.
0: Calculate the statistics before YMap.
1: Calculate the statistics after YMap.u8Src2YMapX [AF_YMAP_X_NUM] The horizontal axis of Src2 YMap, and the node is accumulated by the power of 2. The last point should be greater than or equal to 1023. AF_YMAP_X_NUM = 8 u16Src2YMapY [AF_YMAP_Y_NUM] The vertical axis of Src2 YMap. Range: 0~1023. AF_YMAP_Y_NUM = 9 u8LumaSrc Select the position of Luma statistics
0: Calculate Luma before Src2 YMap.
1: Calculate Luma after Src2 YMap
2: Calculate Luma before Src1 YMap
3: Calculate Luma after Src1 YMap
CusAFYMap_t (Maruko, Souffle, Iford)¶
typedef struct
{
MI_U8 u8YMapEn;
MI_U8 u8YMapLumaSource; // 0: bef ymap; 1: aft ymap
MI_U8 u8YMapX[AF_YMAP_X_NUM]; // 1~9
MI_U16 u16YMapY[AF_YMAP_Y_NUM]; // 0~1023
MI_U8 u8LumaSrc; // 0: bef ymap; 1: aft ymap
} CusAFYMap_t;
-
Parameter
Parameter Name Description u8YMapEn Enable YMap. u8YMapLumaSource Whether FIR/IIR statistics should be processed by Y Map
0: before YMap.
1: after YMap.u8YMapX[AF_YMAP_X_NUM] The horizontal axis of YMap, of which the nodes are accumulated by power of 2. The last node should be greater than or equal to 1023 after accumulation. AF_YMAP_X_NUM = 8. u16YMapY[AF_YMAP_Y_NUM] The vertical axis of YMap . Range: 0 ~ 1023. AF_YMAP_Y_NUM = 9. u8LumaSrc Select the source of Luma statistics.
0: Calculate Luma before YMap;
1: Calculate Luma after YMap. -
Note

.ymap_x = {4, 4, 4, 4, 6, 7, 8, 9},
The actual coordinates on the horizontal axis are: 0, 16, 32, 48, 64, 128, 256, 512, 1024
.ymap_y = {0, 72, 135, 183, 222, 340, 501, 722, 1023},
-
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
SET AF PREFILTER IN MI_ISP¶
MI_ISP_CUS3A_SetAFPreFilter¶
-
Purpose
Set AF PreFilter.
-
Syntax
MI_RET MI_ISP_CUS3A_SetAFPreFilter (MI_U32 DevId, MI_U32 Channel, CusAFPreFilter_t *data);
-
Description
Before being processed for statistic calculation, Bayer data will first pass through PreFilter to be denoised. This function can be applied in low brightness scene so as to enhance the denoise capability of FV curve. Only IIR is equipped with this function.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data AF PreFilter setting. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAFPreFilter_t¶
typedef struct
{
MI_U8 u8IIR1En;
MI_U8 u8IIR1Cor; //0, 1, 2, 3: 0x, 1x, 2x, 4x
MI_U8 u8IIR1Hor; //0, 1, 2, 3: 0x, 1x, 2x, 4x
MI_U8 u8IIR1Vert; //0, 1, 2, 3: 0x, 1x, 2x, 4x
MI_U8 u8IIR1Cent; //0, 1, 2, 3: 1x, 2x, 4x, 8x
MI_U8 u8IIR1Div; //0, 1, 2, 3: 1/8x, 1/16x, 1/32x, 1/64x
MI_U8 u8IIR2En;
MI_U8 u8IIR2Cor; //0, 1, 2, 3: 0x, 1x, 2x, 4x
MI_U8 u8IIR2Hor; //0, 1, 2, 3: 0x, 1x, 2x, 4x
MI_U8 u8IIR2Vert; //0, 1, 2, 3: 0x, 1x, 2x, 4x
MI_U8 u8IIR2Cent; //0, 1, 2, 3: 1x, 2x, 4x, 8x
MI_U8 u8IIR2Div; //0, 1, 2, 3: 1/8x, 1/16x, 1/32x, 1/64x
} CusAFPreFilter_t;
-
Parameter
Parameter Name Description u8IIR1En Enable IIR1 to use PreFilter. u8IIR2En Enable IIR2 to use PreFilter. u8IIR1Cor
u8IIR2CorSet proportion of the four neighboring pixels in four diagonal directions.
0: *0
1: *1
2: *2
3: *4u8IIR1Hor
u8IIR2HorSet proportion of the two neighboring pixels in horizontal direction.
0: *0
1: *1
2: *2
3: *4u8IIR1Vert
u8IIR2VertSet proportion of the two neighboring pixels in vertical direction.
0: *0
1: *1
2: *2
3: *4u8IIR1Cent
u8IIR2CentSet proportion of the current pixel.
0: *1
1: *2
2: *4
3: *8u8IIR1Div
u8IIR2DivAccumulate the above pixel results and performs division calculation.
0: /8
1: /16
2: /32
3: /64The pixel positions are illustrated below:
Cor Vert Cor Hor Center Hor Cor Vert Cor Perform the following equation:
Out = (u8Cor * (Cor+Cor+Cor+Cor) + u8Hor * (Hor+Hor) + u8Vert * (Vert+Ver) + u8Cent * (Cent)) / u8Div
-
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
SET AF BNR IN MI_ISP¶
MI_ISP_CUS3A_SetAFBNR¶
-
Purpose
Set AF Bayer noise reduction (BNR).
-
Syntax
MI_RET MI_ISP_CUS3A_SetAFBNR (MI_U32 DevId, MI_U32 Channel, CusAFBNR_t *data);
-
Description
Perform noise reduction on AF source.
AF Bayer noise reduction takes effect only when AF source is set to AF_SOURCE_BF_3DNR_AF_HDR.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data Setting of AF BNR. -
Return Value
Return Value: Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAFBNR_t (Muffin)¶
typedef struct
{
MI_U8 u8IIR1En;
MI_U8 u8IIR2En;
MI_U8 u8FilterStr;
MI_U8 u8SpwSel;
MI_U8 u8PrefltStr;
MI_U8 u8LumaDist[AF_BNR_LUMA_DIST_NUM];
MI_U8 u8LumaGain[AF_BNR_LUMA_GAIN_NUM];
MI_U8 u8WeiX;
MI_U8 u8WeiY[AF_BNR_WEIGHT_Y_NUM];
} CusAFBNR_t;
-
Parameter
Parameter Name Description u8IIR1En Enable IIR1 Bayer noise reduction. Parameter value: 0 ~ 1. u8IIR2En Enable IIR2 Bayer noise reduction. Parameter value: 0 ~ 1. u8FilterStr The strength of Bayer noise reduction. Parameter value: 0 ~ 63. The larger the value, the stronger the noise reduction. u8SpwSel Select filter. Parameter range: 0 ~ 3. The larger the value, the stronger the noise reduction. u8PrefltStr The strength of Pre-Bayer noise reduction. Parameter value: 0 ~ 63. The larger the value, the stronger the noise reduction. u8LumaDist [AF_BNR_LUMA_DIST_NUM] The nodes on the horizontal axis of LumaGain, accumulated by the power of 2. Parameter range: 0 ~ 7. AF_BNR_LUMA_DIST_NUM = 11. u8LumaGain [AF_BNR_LUMA_GAIN_NUM] Control the strength of Bayer noise reduction based on the value of brightness difference. The larger the value, the stronger the noise reduction. Parameter range: 0 ~ 255. 1x = 16. AF_BNR_LUMA_GAIN_NUM = 12. u8WeiX The strength of filter. Parameter range: 0 ~ 7. The larger the value, the stronger the noise reduction. u8WeiY [AF_BNR_WEIGHT_Y_NUM] The mixed weight table of filter. Parameter range: 0 ~ 31. The horizontal axis represents the difference from the center point, while the vertical axis represents the weight. Under normal circumstances, the smaller difference, the greater weight should be set. AF_BNR_WEIGHT_Y_NUM = 32.
CusAFBNR_t (Maruko, Souffle, Iford)¶
typedef struct
{
MI_U8 u8BnrEn;
MI_U8 u8FilterStr;
} CusAFBNR_t;
-
Parameter
Parameter Name Description u8BnrEn Enable Bayer noise reduction. Parameter range: 0 ~ 1. u8FilterStr The strength of Bayer noise reduction. Parameter range: 0 ~ 63. The larger the value, the weaker the noise reduction. -
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
SET AF FILTER IN MI_ISP¶
MI_ISP_CUS3A_SetAFFilter¶
-
Purpose
Set AF Filter parameter.
-
Syntax
MI_RET MI_ISP_CUS3A_SetAFFilter (MI_U32 DevId, MI_U32 Channel, CusAFFilter_t *data);
-
Description
Call this interface to set AF Filter parameter.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data AF Filter parameter. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAFFilter_t¶
typedef struct
{
MI_U16 u16IIR1_a0;
MI_U16 u16IIR1_a1;
MI_U16 u16IIR1_a2;
MI_U16 u16IIR1_b1;
MI_U16 u16IIR1_b2;
MI_U16 u16IIR1_1st_low_clip;
MI_U16 u16IIR1_1st_high_clip;
MI_U16 u16IIR1_2nd_low_clip;
MI_U16 u16IIR1_2nd_high_clip;
MI_U16 u16IIR2_a0;
MI_U16 u16IIR2_a1;
MI_U16 u16IIR2_a2;
MI_U16 u16IIR2_b1;
MI_U16 u16IIR2_b2;
MI_U16 u16IIR2_1st_low_clip;
MI_U16 u16IIR2_1st_high_clip;
MI_U16 u16IIR2_2nd_low_clip;
MI_U16 u16IIR2_2nd_high_clip;
MI_U16 u16IIR1_e1_en;
MI_U16 u16IIR1_e1_a0;
MI_U16 u16IIR1_e1_a1;
MI_U16 u16IIR1_e1_a2;
MI_U16 u16IIR1_e1_b1;
MI_U16 u16IIR1_e1_b2;
MI_U16 u16IIR1_e2_en;
MI_U16 u16IIR1_e2_a0;
MI_U16 u16IIR1_e2_a1;
MI_U16 u16IIR1_e2_a2;
MI_U16 u16IIR1_e2_b1;
MI_U16 u16IIR1_e2_b2;
MI_U16 u16IIR2_e1_en;
MI_U16 u16IIR2_e1_a0;
MI_U16 u16IIR2_e1_a1;
MI_U16 u16IIR2_e1_a2;
MI_U16 u16IIR2_e1_b1;
MI_U16 u16IIR2_e1_b2;
MI_U16 u16IIR2_e2_en;
MI_U16 u16IIR2_e2_a0;
MI_U16 u16IIR2_e2_a1;
MI_U16 u16IIR2_e2_a2;
MI_U16 u16IIR2_e2_b1;
MI_U16 u16IIR2_e2_b2;
} CusAFFilter_t;
-
Member
IIR Parameters are listed as followed.
Parameter Name Bit Representation Description IIR1 default IIR2 default a0 S+9 a0 multiplier 37 19 a1 S+10 a1 multiplier 0 0 a2 S+9 a2 multiplier -37 -19 b1 S+13 b1 multiplier -6848 -7808 b2 S+13 b2 multiplier 3136 3776 1st_low_clip 10 X(n) input low clip 0 0 1st_high_clip 10 X(n) input high clip 1023 1023 2nd_low_clip 10 Y(n) output low clip 0 0 2nd_high_clip 10 Y(n) output high clip 1023 1023 e1_en 1 Extra1 enable 1 1 e1_a0 S+9 a0 multiplier 37 19 e1_a1 S+10 a1 multiplier 0 0 e1_a2 S+9 a2 multiplier -37 -19 e1_b1 S+13 b1 multiplier 1600 -4672 e1_b2 S+13 b2 multiplier 1792 2304 e2_en 1 Extra2 enable 1 1 e2_a0 S+9 a0 multiplier 32 17 e2_a1 S+10 a1 multiplier 0 0 e2_a2 S+9 a2 multiplier -32 -17 e2_b1 S+13 b1 multiplier -2624 -5824 e2_b2 S+13 b2 multiplier 0 1920 By default, IIR1 is IIR High, and IIR2, IIR Low.
The architecture of IIR coefficients is shown in the diagram below:

-
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
SET AF LDG IN MI_ISP¶
MI_ISP_CUS3A_SetAFLDG¶
-
Purpose
Set AF LDG (Level Depend Gain).
-
Syntax
MI_RET MI_ISP_CUS3A_SetAFLdg (MI_U32 DevId, MI_U32 Channel, CusAFLdg_t *data);
-
Description
This function controls the range of statistic output in reference to the pixel brightness, in a bid to curb the influence of point light source upon FV.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data AF LDG setting. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAFLdg_t¶
typedef struct
{
MI_U8 u8IIR1En;
MI_U8 u8IIR2En;
MI_U8 u8FIRHEn;
MI_U8 u8FIRVEn;
MI_U16 u16IIRCurveX[AF_LDG_LUT_NUM]; // 0~1023
MI_U8 u8IIRCurveY[AF_LDG_LUT_NUM]; // 0~255
MI_U16 u16FIRCurveX[AF_LDG_LUT_NUM]; // 0~1023
MI_U8 u8FIRCurveY[AF_LDG_LUT_NUM]; // 0~255
} CusAFLdg_t;
-
Parameter
Parameter Name Description u8IIR1En Enable IIR1 to use LDG function. u8IIR2En Enable IIR2 to use LDG function. u8FIRHEn Enable FIRH to use LDG function. u8FIRVEn Enable FIRV to use LDG function. u16IIRCurveX[AF_LDG_LUT_NUM] The horizontal axis of IIR LDG. The input is brightness. Parameter range: 0 ~ 1023.
AF_LDG_LUT_NUM = 6u8IIRCurveY[AF_LDG_LUT_NUM] The vertical axis of IIR LDG. The output is the proportion of statistics. Parameter range: 0 ~ 255, and 255 represents no attenuation.
AF_LDG_LUT_NUM = 6u16FIRCurveX[AF_LDG_LUT_NUM] The horizontal axis of FIR LDG. The input is brightness. Parameter range: 0 ~ 1023.
AF_LDG_LUT_NUM = 6u8FIRCurveY[AF_LDG_LUT_NUM] The vertical axis of FIR LDG. The output is the proportion of statistics. Parameter range: 0 ~ 255, and 255 represents no attenuation.
AF_LDG_LUT_NUM = 6
.curve_x = {0, 300, 1023, 1023, 1023, 1023},
.curve_y = {255, 255, 40, 40, 40, 40},
Statistics of which the brightness is over 300 will gradually decrease in this setting. When brightness reaches 1023, the value will decrease to 40/255=0.156 approximately.
-
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
SET AF FILTER SQUARE IN MI_ISP¶
MI_ISP_CUS3A_SetAFFilterSq¶
-
Purpose
Set AF Filter Square parameter.
-
Syntax
MI_RET MI_ISP_CUS3A_SetAFFilterSq (MI_U32 DevId, MI_U32 Channel, CusAFFilterSq_t *data);
-
Description
Call this interface to set AF Filter Square parameter.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data AF Filter Square parameter. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAFFilterSq_t (Muffin)¶
typedef struct
{
MI_BOOL bSobelYSatEn;
MI_U8 u8SobelYSatSrc;
MI_U16 u16SobelYThd;
MI_BOOL bIIRSquareAccEn;
MI_BOOL bSobelSquareAccEn;
MI_U16 u16IIR1Thd;
MI_U16 u16IIR2Thd;
MI_U16 u16SobelHThd;
MI_U16 u16SobelVThd;
MI_U8 u8AFTb1lX[AF_FILTER_SQ_TBL_X_NUM];
MI_U16 u16AFTb1lY[AF_FILTER_SQ_TBL_Y_NUM];
MI_U8 u8AFTbl2X[AF_FILTER_SQ_TBL_X_NUM];
MI_U16 u16AFTbl2Y[AF_FILTER_SQ_TBL_Y_NUM];
} CusAFFilterSq_t;
-
Member
Variable Name Description bSobelYSatEn The switch involves two actions: - Control the threshold value of Y for Sobel filter.
- Control the setting of Y_sat statistics.
u8SobelYSatSrc Select the source of Y_sat statistics. 1: The value of brightness after Src1 YMap. 0: The value of brightness after Src2 YMap. u16SobelYThd When bSobelYSatEn = 1 - Control the threshold value of Y for Sobel filter: Pixels of which the brightness is lower than u16SobelYThd will be included in the Sobel filter calculation.
- Control the setting of Y_sat statistics: Pixels larger than u16SobelYThd will be sent back and shown in Y_sat statistics.
Parameter range: 0 ~ 1023.bIIRSquareAccEn Enable enhanced IIR Filter Square. bSobelSquareAccEn Enable enhanced Sobel Filter Square. u16IIR1Thd IIR1 Filter Output = IIR1 Filter Output – IIR1Thd. Parameter range: 0 ~ 1023. u16IIR2Thd IIR2 Filter Output = IIR2 Filter Output – IIR2Thd Parameter range: 0 ~ 1023. u16SobelHThd SobelH Filter Output = SobelH Filter Output – SobelH Thd. Parameter range: 0 ~ 1023. u16SobelVThd SobelV Filter Output = SobelV Filter Output – SobelV Thd Parameter range: 0 ~ 1023. u8AFTbl1X [AF_FILTER_SQ_TBL_X_NUM] Perform non-linear mapping for IIR1 and SobelH Filter.
u8AFTbl1X represents the horizontal axis of Tbl1, for which the nodes are accumulated by the power of 2. The accumulation should be greater than 1024.
Parameter range: 0 ~ 15.
AF_FILTER_SQ_TBL_X_NUM = 12.u16AFTbl1Y [AF_FILTER_SQ_TBL_Y_NUM] Perform non-linear mapping for IIR1 and SobelH Filter.
u16AFTbl1Y represents the vertical axis of Tbl1.
Parameter range: 0 ~ 8191.
AF_FILTER_SQ_TBL_Y_NUM = 13.u8AFTbl2X [AF_FILTER_SQ_TBL_X_NUM] Perform non-linear mapping for IIR2 and SobelV Filter.
u8AFTbl2X represents the horizontal axis of Tbl2, for which the nodes are accumulated by the power of 2. The accumulation should be greater than 1024.
Parameter range: 0 ~ 15.
AF_FILTER_SQ_TBL_X_NUM = 12.u16AFTbl2Y [AF_FILTER_SQ_TBL_Y_NUM] Perform non-linear mapping for IIR2 and SobelV Filter.
u16AFTbl2Y represents the vertical axis of Tbl2.
Parameter range: 0 ~ 8191.
AF_FILTER_SQ_TBL_Y_NUM = 13.SquareACC can be used against coarse edge with middle to high contrast for enhancement. Values lower than Thd will be taken as 0, to deal with noise under low luminance.
CusAFFilterSq_t (Maruko, Souffle, Iford)¶
typedef struct
{
MI_BOOL bSobelYSatEn;
MI_U16 u16SobelYThd;
MI_BOOL bIIRSquareAccEn;
MI_BOOL bSobelSquareAccEn;
MI_U16 u16IIR1Thd;
MI_U16 u16IIR2Thd;
MI_U16 u16SobelHThd;
MI_U16 u16SobelVThd;
MI_U8 u8AFTb1lX[AF_FILTER_SQ_TBL_X_NUM];
MI_U16 u16AFTb1lY[AF_FILTER_SQ_TBL_Y_NUM];
MI_U8 u8AFTbl2X[AF_FILTER_SQ_TBL_X_NUM];
MI_U16 u16AFTbl2Y[AF_FILTER_SQ_TBL_Y_NUM];
} CusAFFilterSq_t;
-
Member
Variable Name Description bSobelYSatEn The switch involves two actions: - Control the threshold value of Y for Sobel filter.
- Control the setting of Y_sat statistics.
u16SobelYThd When bSobelYSatEn = 1 - Control the threshold value of Y for Sobel filter: Pixels of which the brightness is lower than u16SobelYThd will be included in the Sobel filter calculation.
- Control the setting of Y_sat statistics: Pixels larger than u16SobelYThd will be sent back and shown in Y_sat statistics.
Parameter range: 0 ~ 1023.bIIRSquareAccEn Enable enhanced IIR Filter Square. bSobelSquareAccEn Enable enhanced Sobel Filter Square. u16IIR1Thd IIR1 Filter Output = IIR1 Filter Output – IIR1Thd. Parameter range: 0 ~ 1023. u16IIR2Thd IIR2 Filter Output = IIR2 Filter Output – IIR2Thd. Parameter range: 0 ~ 1023. u16SobelHThd SobelH Filter Output = SobelH Filter Output – SobelH Thd. Parameter range: 0 ~ 1023. u16SobelVThd SobelV Filter Output = SobelV Filter Output – SobelV Thd. Parameter range: 0 ~ 1023. u8AFTbl1X [AF_FILTER_SQ_TBL_X_NUM] Perform non-linear mapping for IIR1 and SobelH Filter.
u8AFTbl1X represents the horizontal axis of Tbl1, for which the nodes are accumulated by power of 2. The accumulation should be greater than 1024.
Parameter range: 0 ~ 15.
AF_FILTER_SQ_TBL_X_NUM = 12.u16AFTbl1Y [AF_FILTER_SQ_TBL_Y_NUM] Perform non-linear mapping for IIR1 and SobelH Filter.
u16AFTbl1Y represents the vertical axis of Tbl1.
Parameter range: 0 ~ 8191.
AF_FILTER_SQ_TBL_Y_NUM = 13.u8AFTbl2X [AF_FILTER_SQ_TBL_X_NUM] Perform non-linear mapping for IIR2 and SobelV Filter.
u8AFTbl2X represents the horizontal axis of Tbl2, for which the nodes are accumulated by power of 2. The accumulation should be greater than 1024.
Parameter range: 0 ~ 15.
AF_FILTER_SQ_TBL_X_NUM = 12.u16AFTbl2Y [AF_FILTER_SQ_TBL_Y_NUM] Perform non-linear mapping for IIR2 and SobelV Filter.
u16AFTbl2Y represents the vertical axis of Tbl2. Parameter range: 0 ~ 8191.
AF_FILTER_SQ_TBL_Y_NUM = 13.SquareACC enlarges the contrast of rough edge in medium to high contrast. This parameter also reduces values lower than Thd to 0, working against image noise in low-light scenario.
Reference setting (Square):
u8AFTblX = 6, 7, 7, 6, 6, 6, 7, 6, 6, 7, 6, 6
u16AFTblY = 0, 32, 288, 800, 1152, 1568, 2048, 3200, 3872, 4607, 6271, 7199, 8191
Reference setting (Linear, statistics remain unchanged):
u8AFTblX = 6, 7, 7, 6, 6, 6, 7, 6, 6, 7, 6, 6
u16AFTblY = 0, 64, 192, 320, 384, 448, 512, 640, 704, 768, 896, 960, 1023

-
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
SET AF PEAK MODE IN MI_ISP¶
MI_ISP_CUS3A_SetAFPeakMode¶
-
Purpose
Set AF Peak Mode parameter.
-
Syntax
MI_RET MI_ISP_CUS3A_SetAFPeakMode (MI_U32 DevId, MI_U32 Channel, CusAFPeakMode_t *data);
-
Description
This function performs SubSample and Overlap in reference to the value of pixel brightness, in order to obtain the maximum value. SubSample represents the number of pixels being sampled on the horizontal axis for the determination of a maximum value. Set SubSample to 31, for example, means that a maximum value will be obtained in every 32 pixels. Overlap represents finding the maximum value in 2n+1 pixels on the horizontal axis and taking it as the pixel value, and “n” here represents the result after SubSample. By setting Overlap to 5, for example, five more pixels on both left and right will be taken into consideration, and the largest of the 11 pixels will be taken as the pixel value.
Note: The number of pixels in ROI will decrease due to SubSample sampling on the horizontal axis. Therefore, we suggest using MI_ISP_CUS3A_GetAFWindowPixelCount to get the number of pixels in ROI. Please refer to Chapter 38.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data AF Peak Mode parameter. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAFPeakMode_t¶
typedef struct
{
MI_U8 u8IIR1En;
MI_U8 u8IIR2En;
MI_U8 u8SubSample;
MI_U8 u8Overlap;
} CusAFPeakMode_t;
-
Parameter
Parameter Name Description u8IIR1En Enable peak mode for IIR1. u8IIR2En Enable peak mode for IIR2. u8SubSample The number of pixels being sampled on the horizontal axis for the determination of a maximum value. Value range: 0 ~ 31. u8Overlap Find the maximum value in 2n+1 pixels on the horizontal axis and taking it as the pixel value, and “n” represents the result after SubSample. Value range: 0 ~ 7. -
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
SET AF FIR FILTER IN MI_ISP¶
MI_ISP_CUS3A_SetAFFirFilter¶
-
Purpose
Set AF FIR Filter parameter.
-
Syntax
MI_RET MI_ISP_CUS3A_SetAFFirFilter (MI_U32 DevId, MI_U32 Channel, CusAFFirFilter_t *data);
-
Description
Call this interface to set AF FIR Filter parameter.
This interface is supported by Maruko, Souffle, and Iford only.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data AF FIR Filter parameters. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAFFirFilter_t¶
typedef struct
{
MI_U8 u8FIR_b0;
MI_U8 u8FIR_b1;
MI_U8 u8IIR_b2;
} CusAFFirFilter_t;
-
Member
IIR Parameters are listed as followed.
Parameter Name Bit Representation Description Default Value b0 6 (in 2's complement: 0 ~ 31 represent 0 ~ 31; while 32 ~ 63 represent -32 ~ -1). b0 multiplier 63 b1 6 (in 2's complement: 0 ~ 31 represent 0 ~ 31; while 32 ~ 63 represent -32 ~ -1). b1 multiplier 2 b2 6 (in 2's complement: 0 ~ 31 represent 0 ~ 31; while 32 ~ 63 represent -32 ~ -1). b2 multiplier 63 -
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
SET AF G MODE IN MI_ISP¶
MI_ISP_CUS3A_SetAFGMode¶
-
Purpose
Set AF G Mode.
-
Syntax
MI_RET MI_ISP_CUS3A_SetAFGMode (MI_U32 DevId, MI_U32 Channel, CusAFGMode_t *data);
-
Description
AF G Mode replaces BayerRGB conversion to Y in AF Y Param by using Bayer Gr and Gb as Y. Its effect allows more details to be presented in the picture.
Note:
-
AF G Mode features a different sampling approach, so we recommend that you use MI_ISP_CUS3A_GetAFWindowPixelCount to obtain the number of pixels in ROI.
-
This function does not support AF source when it is set to AF_SOURCE_BF_3DNR_AF_HDR, nor does it support AF BNR or AF Y Param. Besides, this function supports IIR only, while FIR is not supported.
-
This interface is supported by Maruko, Souffle, and Iford only.
-
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data AF G Mode setting. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAFGMode_t¶
typedef struct
{
MI_U8 u8GModeEn;
} CusAFGMode_t;
-
Parameter
Parameter Name Description u8GModeEn Enable G Mode. Parameter range: 0 ~ 1. -
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
GET AE LONG-EXPOSURE STATISTICS IN MI_ISP¶
MI_ISP_AE_GetAeHwAvgStats¶
-
Purpose
Get AE long-exposure statistics, including the AE statistics in linear mode.
-
Syntax
MI_RET MI_ISP_AE_GetAeHwAvgStats (MI_U32 DevId, MI_U32 Channel, MI_ISP_AE_HW_STATISTICS_t *data);
-
Description
Get AE long-exposure statistics, including the AE statistics in linear mode.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data AE long-exposure statistics. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
MI_ISP_AE_HW_STATISTICS_t¶
typedef struct
{
MI_U32 nBlkX;
MI_U32 nBlkY;
MI_ISP_AE_AVGS nAvg[AE_HW_STAT_BLOCK];
} MI_ISP_AE_HW_STATISTICS_t;
-
Parameter
Parameter Name Description nBlkX The number of effective blocks on the horizontal axis of AE statistics. Usually the number is 32. nBlkY The number of effective blocks on the vertical axis of AE statistics. Usually the number is 32. nAvg[AE_HW_STAT_BLOCK] The statistics of each AE block. AE_HW_STAT_BLOCK = 128 * 90
MI_ISP_AE_AVGS¶
typedef struct
{
MI_U8 u8AvgR;
MI_U8 u8AvgG;
MI_U8 u8AvgB;
MI_U8 u8AvgY;
} MI_ISP_AE_AVGS;
-
Parameter
Parameter Name Description u8AvgR Value of R channel. Value range: 0 ~ 255. u8AvgG Value of G channel. Value range: 0 ~ 255. u8AvgB Value of B channel. Value range: 0 ~ 255. u8AvgY Brightness of Y. Value range: 0 ~ 255. -
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
GET AWB LONG-EXPOSURE STATISTICS IN MI_ISP¶
MI_ISP_AWB_GetAwbHwAvgStats¶
-
Purpose
Get AWB long-exposure statistics, including the AWB statistics in linear mode.
-
Syntax
MI_RET MI_ISP_AWB_GetAwbHwAvgStats (MI_U32 DevId, MI_U32 Channel, MI_ISP_AWB_HW_STATISTIC_t *data);
-
Description
Get AWB long-exposure statistics, including the AWB statistics in linear mode.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data AWB long-exposure statistics. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
MI_ISP_AWB_HW_STATISTICS_t¶
typedef struct
{
MI_U32 nBlkX;
MI_U32 nBlkY;
MI_ISP_AWB_AVGS nAvg[AWB_HW_STAT_BLOCK];
} MI_ISP_AWB_HW_STATISTICS_t;
-
Parameter
Parameter Name Description nBlkX The number of effective blocks on the horizontal axis of AWB statistics. Usually the number is 128. nBlkY The number of effective blocks on the vertical axis of AWB statistics. Usually the number is 90. nAvg[AWB_HW_STAT_BLOCK] The statistics of each AWB block. AWB_HW_STAT_BLOCK = 128 * 90
MI_ISP_AWB_AVGS¶
typedef struct
{
MI_U8 u8AvgR;
MI_U8 u8AvgG;
MI_U8 u8AvgB;
} MI_ISP_AWB_AVGS;
-
Parameter
Parameter Name Description u8AvgR Value of R channel. Value range: 0 ~ 255. u8AvgG Value of G channel. Value range: 0 ~ 255. u8AvgB Value of B channel. Value range: 0 ~ 255. -
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
GET AWB SHORT-EXPOSURE STATISTICS IN MI_ISP¶
MI_ISP_AWB_GetAwbHwAvgStatsShort¶
-
Purpose
Get AWB short-exposure statistics.
-
Syntax
MI_RET MI_ISP_AWB_GetAwbHwAvgStatsShort (MI_U32 DevId, MI_U32 Channel, MI_ISP_AWB_HW_STATISTIC_t *data);
-
Description
Get AWB short-exposure statistics.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data AWB short-exposure statistics. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed. -
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
GET AF STATISTICS IN MI_ISP¶
MI_ISP_CUS3A_GetAFStats¶
-
Purpose
Get AF statistics.
-
Syntax
MI_RET MI_ISP_CUS3A_GetAFStats (MI_U32 DevId, MI_U32 Channel, CusAFStats_t *data);
-
Description
Get AF statistics.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data AF statistics. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAFStats_t¶
typedef struct
{
AF_STATS_PARAM_t stParaAPI[AF_STATS_VERTICAL_BLOCK_MAX];
} CusAFStats_t;
-
Parameter
Parameter Name Description stParaAPI[AF_STATS_VERTICAL_BLOCK_MAX] The statistics of each AF block. To divide AF block, please refer to 22. SET AF WINDOW IN MI_ISP.
AF_ROI_MODE_NORMAL: Divide the window into 16 * 1 ROI, and get one set of stParaAPI[0]. This is default setting.
AF_ROI_MODE_MATRIX: Divide the window into 16 * N ROI, and get N sets of statistics, from stParaAPI[0] to stParaAPI[N – 1].
AF_STATS_VERTICAL_BLOCK_MAX = 16
AF_STATS_PARAM_t¶
typedef struct
{
MI_U8 iir_1[AF_STATS_IIR_1_SIZE * AF_HW_WIN_NUM];
MI_U8 iir_2[AF_STATS_IIR_2_SIZE * AF_HW_WIN_NUM];
MI_U8 luma[AF_STATS_LUMA_SIZE * AF_HW_WIN_NUM];
MI_U8 fir_v[AF_STATS_FIR_V_SIZE * AF_HW_WIN_NUM];
MI_U8 fir_h[AF_STATS_FIR_H_SIZE * AF_HW_WIN_NUM];
MI_U8 ysat[AF_STATS_YSAT_SIZE * AF_HW_WIN_NUM];
} AF_STATS_PARAM_t;
-
Parameter
Parameter Name Description iir_1[AF_STATS_IIR_1_SIZE * AF_HW_WIN_NUM] The statistics of AF IIR_1 filter in each block division. The default setting is high-frequency. One set of IIR deploys 5 * u8 to store data of 37 bits.
The total number of block is 16.
AF_STATS_IIR_1_SIZE = 5; AF_HW_WIN_NUM = 16iir_2[AF_STATS_IIR_2_SIZE * AF_HW_WIN_NUM] The statistics of AF IIR_2 filter in each block division. The default setting is low-frequency.
One set of IIR deploys 5 * u8 to store data of 37 bits. The total number of block is 16.
AF_STATS_IIR_2_SIZE = 5; AF_HW_WIN_NUM = 16luma[AF_STATS_LUMA_SIZE * AF_HW_WIN_NUM] The statistics of AF brightness in each block division.
One set of Luma deploys 5 * u8 to store data of 34 bits. The total number of block is 16.
AF_STATS_LUMA_SIZE = 5; AF_HW_WIN_NUM = 16fir_v[AF_STATS_FIR_V_SIZE * AF_HW_WIN_NUM] The statistics of AF vertical FIR filter in each block division.
One set of FIR deploys 5 * u8 to store data of 37 bits. The total number of block is 16.
AF_STATS_FIR_V_SIZE = 5; AF_HW_WIN_NUM = 16fir_h[AF_STATS_FIR_H_SIZE * AF_HW_WIN_NUM] The statistics of AF horizontal FIR filter in each block division.
One set of FIR deploys 5 * u8 to store data of 37 bits. The total number of block is 16.
AF_STATS_FIR_V_SIZE = 5; AF_HW_WIN_NUM = 16ysat[AF_STATS_YSAT_SIZE * AF_HW_WIN_NUM] The number of AF statistics greater than YThd in each block division.
One set of ysat deploys 3 * u8 to store data of 24 bits. The total number of block is 16.
AF_STATS_YSAT_SIZE = 3; AF_HW_WIN_NUM = 16 -
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
GET AF WINDOW PIXEL COUNT IN MI_ISP¶
MI_ISP_CUS3A_GetAFWindowPixelCount¶
-
Purpose
Get the number of pixel of AF window.
-
Syntax
MI_RET MI_ISP_CUS3A_GetAFWindowPixelCount (MI_U32 DevId, MI_U32 Channel, CusAFWinPxCnt_t *data);
-
Description
Get the number of pixel of AF window.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). Data The number of pixel of AF window. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAFWinPxCnt_t¶
typedef struct
{
CusAFWinPxCntOneRow_t win_px_cnt[AF_STATS_VERTICAL_BLOCK_MAX];
} CusAFWinPxCnt_t;
-
Parameter
Parameter Name Description win_px_cnt[AF_STATS_VERTICAL_BLOCK_MAX] The number of pixel in each AF block. To divide AF block, please refer to 22. SET AF WINDOW IN MI_ISP.
AF_ROI_MODE_NORMAL: Divide the window into 16 * 1 ROI, and get one set of win_px_cnt[0]. This is default setting.
AF_ROI_MODE_MATRIX: Divide the window into 16 * N ROI, and get N sets of statistics, from win_px_cnt[0] to win_px_cnt[N – 1].
AF_STATS_VERTICAL_BLOCK_MAX = 16
CusAFWinPxCntOneRow_t¶
typedef struct
{
MI_U32 u32Src1Cnt[AF_HW_WIN_NUM];
MI_U32 u32Src2Cnt[AF_HW_WIN_NUM];
} CusAFWinPxCntOneRow_t;
-
Parameter
Parameter Name Description u32Src1Cnt[AF_HW_WIN_NUM] The number of Src1 pixel in each block division. The default setting is high-frequency. The total number of block division is 16.
AF_HW_WIN_NUM = 16u32Src2Cnt[AF_HW_WIN_NUM] The number of Src2 pixel in each block division. The default setting is low-frequency. The total number of block division is 16.
AF_HW_WIN_NUM = 16 -
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
GET AE LONG-EXPOSURE HISTOGRAM IN MI_ISP¶
MI_ISP_AE_GetHisto0HwStats¶
-
Purpose
Get AE long-exposure histogram, including the AE histogram in linear mode.
-
Syntax
MI_RET MI_ISP_AE_GetHisto0HwStats (MI_U32 DevId, MI_U32 Channel, MI_ISP_HISTO_HW_STATISTICS_t *data);
-
Description
Get AE long-exposure histogram, including the AE histogram in linear mode.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data AE long-exposure histogram. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
MI_ISP_HISTO_HW_STATISTICS_t¶
typedef struct
{
MI_U16 uHisto[HISTO_HW_STAT_BIN];
} MI_ISP_HISTO_HW_STATISTICS_t;
-
Parameter
Parameter Name Description uHisto[HISTO_HW_STAT_BIN] The value of Histogram. HISTO_HW_STAT_BIN = 128. -
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
GET AE SHORT-EXPOSURE HISTOGRAM IN MI_ISP¶
MI_ISP_AE_GetHisto0HwStatsShort¶
-
Purpose
Get AE short-exposure histogram.
-
Syntax
MI_RET MI_ISP_AE_GetHisto0HwStatsShort (MI_U32 DevId, MI_U32 Channel, MI_ISP_HISTO_HW_STATISTICS_t *data);
-
Description
Get AE short-exposure histogram.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data AE short-exposure histogram. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed. -
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
GET YUV HISTOGRAM IN MI_ISP¶
MI_ISP_AE_GetYuvHistoHwStats¶
-
Purpose
Get the histogram of Y (brightness) in YUV domain.
-
Syntax
MI_RET MI_ISP_AE_GetYuvHistoHwStats (MI_U32 DevId, MI_U32 Channel, MI_ISP_YUV_HISTO_HW_STATISTICS_t *data);
-
Description
Get the histogram of Y (brightness) in YUV domain. This brightness will be affected by CCM, HSV, gamma, and WDR, but not by YUV gamma. This function is supported by MUFFIN only.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data Y histogram. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
MI_ISP_YUV_HISTO_HW_STATISTICS_t¶
typedef struct
{
MI_U16 nHisto[YUV_HISTO_HW_STAT_BIN];
} MI_ISP_YUV_HISTO_HW_STATISTICS_t;
-
Parameter
Parameter Name Description nHisto[YUV_HISTO_HW_STAT_BIN] The value of Y histogram. YUV_HISTO_HW_STAT_BIN = 256 -
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
GET RGBIR HISTOGRAM IN MI_ISP¶
MI_ISP_AE_GetRgbIrHistoHwStats¶
-
Purpose
Get IR intensity histogram of RGBIR sensor.
-
Syntax
MI_RET MI_ISP_AE_GetRgbIrHistoHwStats (MI_U32 DevId, MI_U32 Channel, MI_ISP_RGBIR_HISTO_HW_STATISTICS_t *data);
-
Description
Get IR intensity histogram of RGBIR sensor.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data IR intensity histogram. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
MI_ISP_RGBIR_HISTO_HW_STATISTICS_t¶
typedef struct
{
MI_U16 uHisto[RGBIR_HISTO_HW_STAT_BIN];
} MI_ISP_RGBIR_HISTO_HW_STATISTICS_t;
-
Parameter
Parameter Name Description uHisto[RGBIR_HISTO_HW_STAT_BIN] The value of IR intensity histogram. -
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
GET AE STATISTICS IN MI_ISP¶
MI_ISP_CUS3A_GetAESource¶
-
Purpose
Get the position of source to extract AE statistics.
-
Syntax
MI_S32 MI_ISP_CUS3A_GetAESource(MI_U32 DevId, MI_U32 Channel, CusAESource_e *data);
-
Description
Get the position of source to extract AE statistics.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data The position of source to extract AE statistics. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAESource_e¶
typedef enum __attribute__ ((aligned (1)))
{
AE_SOURCE_FROM_SE_OBC_BF_HDR = 2,
AE_SOURCE_FROM_SE_WBG_BF_HDR = 3,
AE_SOURCE_FROM_SE_ALSC_AF_HDR = 4,
AE_SOURCE_FROM_SE_WBG_AF_HDR = 5,
AE_SOURCE_FROM_LE_OBC_BF_HDR = 6,
AE_SOURCE_FROM_LE_WBG_BF_HDR = 7,
AE_SOURCE_RDMA_OUT = 8,
} CusAESource_e;
-
Parameter
HDR Mode:
Parameter Name Description AE_SOURCE_FROM_SE_OBC_BF_HDR Select pre-HDR short-exposure result (after OB). AE_SOURCE_FROM_SE_WBG_BF_HDR Select pre-HDR short-exposure result (after WBGain). AE_SOURCE_FROM_SE_ALSC_AF_HDR Select post-HDR result (after Shading). AE_SOURCE_FROM_SE_WBG_AF_HDR Select post-HDR result (after WBGain). AE_SOURCE_FROM_LE_OBC_BF_HDR Select pre-HDR long-exposure result (after OB). AE_SOURCE_FROM_LE_WBG_BF_HDR Select pre-HDR long-exposure result (after WBGain). AE_SOURCE_RDMA_OUT Not supported. Linear Mode:
Parameter Name Description AE_SOURCE_FROM_SE_OBC_BF_HDR Select the result after OB. AE_SOURCE_FROM_SE_WBG_BF_HDR Select the result after WBGain. AE_SOURCE_FROM_SE_ALSC_AF_HDR Select pre-CI result after Shading. AE_SOURCE_FROM_SE_WBG_AF_HDR Select pre-CI result after WBGain. AE_SOURCE_FROM_LE_OBC_BF_HDR Not supported. AE_SOURCE_FROM_LE_WBG_BF_HDR Not supported. AE_SOURCE_RDMA_OUT Not supported. -
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
SET AE STATISTICS IN MI_ISP¶
MI_ISP_CUS3A_SetAESource¶
-
Purpose
Set the position of source to extract AE statistics.
-
Syntax
MI_S32 MI_ISP_CUS3A_SetAESource(MI_U32 DevId, MI_U32 Channel, CusAESource_e *data);
-
Description
Set the position of source to extract AE statistics.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data The position of source to extract AE statistics. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAESource_e¶
typedef enum __attribute__ ((aligned (1)))
{
AE_SOURCE_FROM_SE_OBC_BF_HDR = 2,
AE_SOURCE_FROM_SE_WBG_BF_HDR = 3,
AE_SOURCE_FROM_SE_ALSC_AF_HDR = 4,
AE_SOURCE_FROM_SE_WBG_AF_HDR = 5,
AE_SOURCE_FROM_LE_OBC_BF_HDR = 6,
AE_SOURCE_FROM_LE_WBG_BF_HDR = 7,
AE_SOURCE_RDMA_OUT = 8,
} CusAESource_e;
-
Parameter
HDR Mode:
Parameter Name Description AE_SOURCE_FROM_SE_OBC_BF_HDR Select pre-HDR short-exposure result (after OB). AE_SOURCE_FROM_SE_WBG_BF_HDR Select pre-HDR short-exposure result (after WBGain). AE_SOURCE_FROM_SE_ALSC_AF_HDR Select post-HDR result (after Shading). AE_SOURCE_FROM_SE_WBG_AF_HDR Select post-HDR result (after WBGain). AE_SOURCE_FROM_LE_OBC_BF_HDR Select pre-HDR long-exposure result (after OB). AE_SOURCE_FROM_LE_WBG_BF_HDR Select pre-HDR long-exposure result (after WBGain). AE_SOURCE_RDMA_OUT Not supported. Linear Mode:
Parameter Name Description AE_SOURCE_FROM_SE_OBC_BF_HDR Select the result after OB. AE_SOURCE_FROM_SE_WBG_BF_HDR Select the result after WBGain. AE_SOURCE_FROM_SE_ALSC_AF_HDR Select pre-CI result after Shading. AE_SOURCE_FROM_SE_WBG_AF_HDR Select pre-CI result after WBGain. AE_SOURCE_FROM_LE_OBC_BF_HDR Not supported. AE_SOURCE_FROM_LE_WBG_BF_HDR Not supported. AE_SOURCE_RDMA_OUT Not supported. -
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
GET AWB STATISTICS IN MI_ISP¶
MI_ISP_CUS3A_GetAWBSource¶
-
Purpose
Get the position of source to extract AWB statistics.
-
Syntax
MI_S32 MI_ISP_CUS3A_GetAWBSource(MI_U32 DevId, MI_U32 Channel, CusAWBSourceSeLe_t *data);
-
Description
Get the position of source to extract AWB statistics.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data The position of source to extract AWB statistics. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAWBSourceSeLe_t¶
typedef struct
{
CusAWBSource_e eAwbSrcSE;
CusAWBSource_e eAwbSrcLE;
} CusAWBSourceSeLe_t;
-
Parameter
Parameter Name Description eAwbSrcSE The position of short-exposure AWB statistics. eAwbSrcLE The position of long-exposure AWB statistics.
CusAWBSource_e¶
typedef enum __attribute__ ((aligned (1)))
{
AWB_SOURCE_SE_OBC_BF_HDR = 2,
AWB_SOURCE_SE_ALSC_AF_HDR = 4,
AWB_SOURCE_LE_OBC_BF_HDR = 6,
AWB_SOURCE_RDMA_OUT = 8,
} CusAWBSource_e;
-
Parameter
HDR Mode:
Parameter Name Description AWB_SOURCE_SE_OBC_BF_HDR Select pre-HDR short-exposure result (after OB). AWB_SOURCE_SE_ALSC_AF_HDR Select post-HDR result (after Shading). AWB_SOURCE_LE_OBC_BF_HDR Select pre-HDR long-exposure result (after OB). AWB_SOURCE_RDMA_OUT Not supported. Linear Mode:
Parameter Name Description AWB_SOURCE_SE_OBC_BF_HDR Select pre-CI result after OB. AWB_SOURCE_SE_ALSC_AF_HDR Select pre-CI result after Shading. AWB_SOURCE_LE_OBC_BF_HDR Not supported. AWB_SOURCE_RDMA_OUT Not supported. -
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
SET AWB STATISTICS IN MI_ISP¶
MI_ISP_CUS3A_SetAWBSource¶
-
Purpose
Set the position of source to extract AWB statistics.
-
Syntax
MI_S32 MI_ISP_CUS3A_SetAWBSource(MI_U32 DevId, MI_U32 Channel, CusAWBSourceSeLe_t *data);
-
Description
Set the position of source to extract AWB statistics.
-
Parameter
Parameter Name Description DevId Video device number (normally 0). Channel Video input channel number (normally 0). data The position of source to extract AWB statistics. -
Return Value
Return Value Description MI_RET_SUCCESS Successful. MI_RET_FAIL Failed.
CusAWBSourceSeLe_t¶
typedef struct
{
CusAWBSource_e eAwbSrcSE;
CusAWBSource_e eAwbSrcLE;
} CusAWBSourceSeLe_t;
-
Parameter
Parameter Name Description eAwbSrcSE The position of short-exposure AWB statistics. eAwbSrcLE The position of long-exposure AWB statistics.
CusAWBSource_e¶
typedef enum __attribute__ ((aligned (1)))
{
AWB_SOURCE_SE_OBC_BF_HDR = 2,
AWB_SOURCE_SE_ALSC_AF_HDR = 4,
AWB_SOURCE_LE_OBC_BF_HDR = 6,
AWB_SOURCE_RDMA_OUT = 8,
} CusAWBSource_e;
-
Parameter
HDR Mode:
Parameter Name Description AWB_SOURCE_SE_OBC_BF_HDR Select pre-HDR short-exposure result (after OB). AWB_SOURCE_SE_ALSC_AF_HDR Select post-HDR result (after Shading). AWB_SOURCE_LE_OBC_BF_HDR Select pre-HDR long-exposure result (after OB). AWB_SOURCE_RDMA_OUT Not supported. Linear Mode
Parameter Name Description AWB_SOURCE_SE_OBC_BF_HDR Select pre-CI result after OB. AWB_SOURCE_SE_ALSC_AF_HDR Select pre-CI result after Shading. AWB_SOURCE_LE_OBC_BF_HDR Not supported. AWB_SOURCE_RDMA_OUT Not supported. -
Requirement
header file: mi_isp_cus3a_api.h
.so: libmi_isp.so
GET CUST3A VERSION¶
Please refer to isp_cus3a_if.h. The version definition is as follows:
#define CUS3A_VER_STR "CUS3A_V1.5" #define CUS3A_VER_MAJOR 1 #define CUS3A_VER_MINOR 1 unsigned int CUS3A_GetVersion(char* pVerStr);
To get the version number, you can:
-
Check the header file
-
Call CUS3A_GetVersion.
SUPPORTING TABLE¶
The following table shows different functions as supported by each chip.
| Parameter Name | Twinkie | Pretzel | Macaron |
|---|---|---|---|
| AE Statistics | 128*90 | 128*90 | 32*32 |
| AE Hist2 | Supported. | Supported. | Not supported. |
| YUV hist | Not supported. | Not supported. | Not supported. |
| AF Statistics | IIR(34), FIR(34), Luma(34), YSat(24) | IIR(35), FIR(35), Luma(32), YSat(22) | IIR(35), FIR(35), Luma(32), YSat(22) |
| MI_ISP_CUS3A_SetAEWindowBlockNumber | Supported. | Supported. | Not supported. |
| MI_ISP_CUS3A_SetAEHistogramWindow | offset + size limit: Max. 128*90 | offset + size limit: Max. 128*90 | offset + size limit: Max. 32*32 |
| MI_ISP_CUS3A_SetAFFilter | Supported. | Supported. | Supported. |
| MI_ISP_CUS3A_SetAFFilterSq | Not supported. | Supported. | Supported. |
| MI_ISP_CUS3A_SetAFRoiMode | Not supported. | Supported. | Supported. |
| MI_ISP_CUS3A_SetAFSource | Supported. | Supported. | Not supported. |
| MI_ISP_CUS3A_SetAFPreFilter | Not supported. | Not supported. | Not supported. |
| MI_ISP_CUS3A_SetAFYMap | Not supported. | Not supported. | Not supported. |
| MI_ISP_CUS3A_SetAFLdg | Not supported. | Not supported. | Not supported. |
| MI_ISP_CUS3A_SetAFPeakMode | Not supported. | Not supported. | Not supported. |
| MI_ISP_CUS3A_SetAFFirFilter | Not supported. | Not supported. | Not supported. |
| MI_ISP_CUS3A_SetAFGMode | Not supported. | Not supported. | Not supported. |
| Parameter Name | Pcupid/Pudding/Ikayaki | Tiramisu | Muffin |
|---|---|---|---|
| AE Statistics | 32*32 | 32*32 | 32*32 |
| AE Hist2 | Not supported. | Not supported. | Not supported. |
| YUV Hist | Not supported. | Not supported. | Y brightness is supported. |
| AF Statistics | IIR(35), FIR(35), Luma(32), YSat(22) | IIR(35), FIR(35), Luma(32), YSat(22) | IIR(35), FIR(35), Luma(32), YSat(22) |
| MI_ISP_CUS3A_SetAEWindowBlockNumber | Not supported. | Not supported. | Not supported. |
| MI_ISP_CUS3A_SetAEHistogramWindow | offset + size limit: Max. 32*32 | offset + size limit: Max. 32*32 | offset + size limit: Max. 32*32 |
| MI_ISP_CUS3A_SetAFFilter | Supported (with extra new parameters). | Supported (with extra new parameters). | Supported (with extra new parameters). |
| MI_ISP_CUS3A_SetAFFilterSq | Supported. | Supported. (iir_h/l, fir_h/v can be controlled separately) | Supported. (iir_h, iir_l, fir_h, fir_v can be controlled separately) |
| MI_ISP_CUS3A_SetAFRoiMode | Supported. | Supported. | Supported, incorporated into MI_ISP_CUS3A_SetAFWindow |
| MI_ISP_CUS3A_SetAFSource | Supported. | Supported. | Supported. |
| MI_ISP_CUS3A_SetAFPreFilter | Not supported. | Supported. | Supported. (iir_h and iir_l can be controlled separately) |
| MI_ISP_CUS3A_SetAFYMap | Not supported. | Supported. | Supported. (src_h and src_l can be controlled separately) |
| MI_ISP_CUS3A_SetAFLdg | Not supported. | Supported. | Supported. |
| MI_ISP_CUS3A_SetAFPeakMode | Not supported. | Not supported. | Supported. |
| MI_ISP_CUS3A_SetAFFirFilter | Not supported. | Not supported. | Not supported. |
| MI_ISP_CUS3A_SetAFGMode | Not supported. | Not supported. | Not supported. |
| Parameter Name | Maruko | Souffle | Iford |
|---|---|---|---|
| AE Statistics | 32 * 32 | 128 * 90 | 32 * 32 |
| AE hist2 | Not supported. | Not supported. | Not supported. |
| YUV hist | Not supported. | Not supported. | Not supported. |
| AF Statistics | IIR(36), FIR(35), Luma(34), YSat(23) | IIR(38), FIR(37), Luma(36), YSat(33) | IIR(36), FIR(35), Luma(34), YSat(23) |
| MI_ISP_CUS3A_SetAEWindowBlockNumber | Not supported. | Supported. | Not supported. |
| MI_ISP_CUS3A_SetAEHistogramWindow | offset + size limit: Max. 32 * 32 | offset + size limit: Max. 128 * 90 | offset + size limit: Max. 32 * 32 |
| MI_ISP_CUS3A_SetAFFilter | Supported (with extra new parameters). | Supported (with extra new parameters). | Supported (with extra new parameters). |
| MI_ISP_CUS3A_SetAFFilterSq | Supported. (iir_h, iir_l, fir_h, fir_v can be controlled separately) | Supported. (iir_h, iir_l, fir_h, fir_v can be controlled separately) | Supported. (iir_h, iir_l, fir_h, fir_v can be controlled separately) |
| MI_ISP_CUS3A_SetAFRoiMode | Supported, incorporated into MI_ISP_CUS3A_SetAFWindow. | Supported, incorporated into MI_ISP_CUS3A_SetAFWindow. | Supported, incorporated into MI_ISP_CUS3A_SetAFWindow. |
| MI_ISP_CUS3A_SetAFSource | Supported. | Supported. | Supported. |
| MI_ISP_CUS3A_SetAFPreFilter | Supported. (iir_h and iir_l can be controlled separately) | Supported. (iir_h and iir_l can be controlled separately) | Supported. (iir_h and iir_l can be controlled separately) |
| MI_ISP_CUS3A_SetAFYMap | Supported. | Supported. | Supported. |
| MI_ISP_CUS3A_SetAFLdg | Supported. | Supported. | Supported. |
| MI_ISP_CUS3A_SetAFBNR | Supported. | Supported. | Supported. |
| MI_ISP_CUS3A_SetAFPeakMode | Supported. | Supported. | Supported. |
| MI_ISP_CUS3A_SetAFFirFilter | Supported. | Supported. | Supported. |
| MI_ISP_CUS3A_SetAFGMode | Supported. | Supported. | Supported. |