/*
 *******************************************************************************
 *  Copyright (c) 2010-2022 VATICS(KNERON) Inc. All rights reserved.
 *
 *  +-----------------------------------------------------------------+
 *  | THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED |
 *  | AND COPIED IN ACCORDANCE WITH THE TERMS AND CONDITIONS OF SUCH  |
 *  | A LICENSE AND WITH THE INCLUSION OF THE THIS COPY RIGHT NOTICE. |
 *  | THIS SOFTWARE OR ANY OTHER COPIES OF THIS SOFTWARE MAY NOT BE   |
 *  | PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON. THE   |
 *  | OWNERSHIP AND TITLE OF THIS SOFTWARE IS NOT TRANSFERRED.        |
 *  |                                                                 |
 *  | THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT   |
 *  | ANY PRIOR NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY |
 *  | VATICS(KNERON) INC.                                             |
 *  +-----------------------------------------------------------------+
 *
 *******************************************************************************
 */
#ifndef CONFIG_AWB_H
#define CONFIG_AWB_H

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Auto white balance option flag enumeration
 */
typedef enum
{
	//! AWB option: reset
	AWB_OPTION_RESET,

	//! AWB option: converge speed
	AWB_OPTION_CONVERGE_SPEED,

	//! AWB option: control
	AWB_OPTION_CONTROL,

	//! AWB option: auto scene
	AWB_OPTION_AUTOSCENE,

    //! AWB option: color temperature scene definition control
    AWB_OPTION_COLOR_TEMPERATURE_CURVE = 5,

    //! AWB option: initial stat control
    AWB_OPTION_INITIAL = 6,

    //! AWB option: preference stat control
    AWB_OPTION_PREFERENCE = 7,

    //! AWB option: aiawb  set ai control
    AWB_OPTION_AI_CONTROL  = 8,

    //! AWB option: aiawbset ai weighting
    AWB_OPTION_AI_WEIGHTING   = 9,

    //! AWB option: aiawb get info
    AWB_OPTION_CURR_INFO   = 10,

    //! AWB option: aiawb set ai mode
    AWB_OPTION_AI_MODE   = 11
} VMF_AWB_OPTION_FLAG_T;

typedef enum
{
    AWB_CTS_TYPE_NORMAL = 0,    //! Normal, original refCT mode.
    AWB_CTS_TYPE_OUTDOOR = 1,   //! Outdoor, C.T. range will be limited from dwOutdoorCTStartIndex to dwOutdoorCTEndIndex.
    AWB_CTS_TYPE_INDOOR = 2,    //! Indoor, C.T. range will be limited from dwIndoorCTStartIndex to dwIndoorCTEndIndex.
    AWB_CTS_TYPE_EV_SWITCH= 7,  //! EV-Switch, switch scene (Indoor<-->Outdoor) by current EV, dwEVThdLow and dwEVThdHigh.
} VMF_AWB_CTS_TYPE;

typedef enum
{
	AWB_PREFERENCE_TYPE_NORMAL = 0,         //! Keep setting in INI file.
    AWB_PREFERENCE_TYPE_DISABLE = 1,        //! Disable all auto ratio.
	AWB_PREFERENCE_TYPE_ENABLE_PREF = 2,    //! Enable auto PrefRatio (basic).
	AWB_PREFERENCE_TYPE_ENABLE_ADV = 3,     //! Enable auto AdvRatio (advance).
	AWB_PREFERENCE_TYPE_MANUAL_CT = 4,      //! Assign specific CT to look up the ratio setting in INI file.
	AWB_PREFERENCE_TYPE_MANUAL_EV = 5,      //! Assign specific EV to look up the ratio setting in INI file.
	AWB_PREFERENCE_TYPE_MANUAL_RATIO = 10,	//! Assign Preference R/B Ratio manually.
} VMF_AWB_PREFERENCE_TYPE;

/*
 * A data structure for AWB general options
 */
typedef struct
{
	//! A data for awb option flag 
    VMF_AWB_OPTION_FLAG_T eOptionFlags;

    //! A data for AWB handle index (Available in dual lens 360 mode)
	unsigned int dwIndex;

    //! A pointer data for user data
    void *pData; 
} VMF_AWB_OPTION_T;

/*
 * A data structure for AWB ctrl option, AWB_OPTION_CONTROL
 */
typedef struct
{
    //! A data for awb control mode.
    //! Mode: 1: Simple, 2: Manual, 3: Push hold, 9: Sensor(This mode is only used if that the sensor
    //! driver can apply R/B gain on board directly), 10: refCT(This mode is only used if that user does
    //! sensor calibration in light source box)
    unsigned int dwMode;
  
    //! A data for awb control's R gain that only takes effects in manual mode.(1024: 1X)
    //! Default: 1024. (Range: 1 ~ 8191)
    unsigned int dwGainR;

    //! A data for awb control's B gain that only takes effects in manual mode.(1024: 1X)
    //! Default: 1024. (Range: 1 ~ 8191)
    unsigned int dwGainB;

    //! A data for awb control's color temperature that only takes effects in manual mode.
    //! Default: 1024. (Range: 1 ~ 20000)
    unsigned int dwManualColorTemp;

    //! A data for forcing to update window priority. 0: No update, 1: Forcing update.
    unsigned int bUpdateWinPriority;

    //! A buffer pointer for window priority array. Size: 256*(unsigned int).
    //! Value: 0: invalid grid, 1: valid grid.
    unsigned int* pdwWinPriority;
} VMF_AWB_CTRL_OPTION_T;

/*
 * A data structure for AWB converge speed option, AWB_OPTION_CONVERGE_SPEED
 */
typedef struct
{
	//! A data for AWB speed in refCT mode. Default: 8. (Range: 1 ~ 16)
    unsigned int dwSpeed;

    //! A data for enable AWB speed-up mechanism in refCT mode.
    unsigned int bEnableSpeedUp;

    //! A data for AWB speed of outdoor scene in refCT mode.
    //! Default: 1. (Range: 1 ~ 16)
    unsigned int dwOutdoorSpeed;

    //! A data for AWB speed of indoor scene in refCT mode.
    //! Default: 1. (Range: 1 ~ 16)
    unsigned int dwIndoorSpeed;
} VMF_AWB_SPEED_OPTION_T;

/*
 * A data structure for AWB autoscene option, AWB_OPTION_AUTOSCENE
 */
typedef struct
{
	//! A data for AWB mode : DWORD (0: Auto, 1: Full, 2: Customized, 3: Push hold) 
	unsigned int dwMode;

	//! A data for AWB lock : BOOL (1: AWB lock, 0: AWB unlock)
	unsigned int bLock;

	//! A data for customized WB's R gain when dwMode = 2 : DWORD (range 1~8191,  1024 = 1x)
	unsigned int dwCustomGainR;

	//! A data for customized WB's B gain when dwMode = 2 : DWORD (range 1~8191,  1024 = 1x)
	unsigned int dwCustomGainB;
} VMF_AWB_ASC_PARAM_T;

/*
 * A data structure for AWB CT scene option, AWB_OPTION_COLOR_TEMPERATURE_CURVE
 */
typedef struct
{
    //! A data for CT scene type. 0: Normal, original refCT mode.
    //! 1: Outdoor, C.T. range will be limited from dwOutdoorCTStartIndex to dwOutdoorCTEndIndex.
    //! 2: Indoor, C.T. range will be limited from dwIndoorCTStartIndex to dwIndoorCTEndIndex.
    //! 7: EV-Switch, switch scene (Indoor<-->Outdoor) by current EV, dwEVThdLow and dwEVThdHigh.
    //! Default: 0 (Range: 0~7)
    VMF_AWB_CTS_TYPE eSceneType;

    //! A data for EV low thershold. When current EV is smaller than dwEVThdLow, switch to indoor scene setting.
    //! Default: 1000. (Range: 2 ~ 1,600,000,000)
    unsigned int dwEVThdLow;

    //! A data for EV high thershold. When current EV is larger than dwEVThdHigh, switch to outdoor scene setting.
    //! Default: 1000. (Range: 2 ~ 1,600,000,000)
    unsigned int dwEVThdHigh;

    //! A data for starting color temperature index of outdoor scene. The index number must be less than
    //! the calibrated color temperature number. Default: 0. (Range: 0 ~ 14)
    unsigned int dwOutdoorCTStartIndex;

    //! A data for ending color temperature index of outdoor scene. The index number must be less than
    //! the calibrated color temperature number. Default: 0. (Range: 0 ~ 14)
    unsigned int dwOutdoorCTEndIndex;

    //! A data for starting color temperature index of indoor scene. The index number must be less than
    //! the calibrated color temperature number. Default: 0. (Range: 0 ~ 14)
    unsigned int dwIndoorCTStartIndex;

    //! A data for ending color temperature index of indoor scene. The index number must be less than
    //! the calibrated color temperature number. Default: 0. (Range: 0 ~ 14)
    unsigned int dwIndoorCTEndIndex;
} VMF_AWB_CTC_OPTION_T;


/*
 * A data structure for AWB initial stat control option, AWB_OPTION_INITIAL
 */
typedef struct
{
    //! A data for enable this setting. 0: disable, 1: enable.
    unsigned int bEnableInitSetting;

    //! A data for initial R gain. 1024: 1x. Default: 1024. (Range: 1 ~ 8191)
    unsigned int dwInitGainR;

    //! A data for initial B gain. 1024: 1x. Default: 1024. (Range: 1 ~ 8191)
    unsigned int dwInitGainB;

    //! A data for initial color temprature. Default: 1024. (Range: 0 ~ 20000)
    unsigned int dwInitColorTemp;

    //! A data for Initial outdoor R gain, only used for refCT mode. 1024: 1 x.
    //! Default: 1024. (Range: 1 ~ 8191)
    unsigned int dwOutdoorInitGainR;

    //! A data for Initial outdoor B gain, only used for refCT mode. 1024: 1 x.
    //! Default: 1024. (Range: 1 ~ 8191)
    unsigned int dwOutdoorInitGainB;

    //! A data for initial outdoor color temprature, only used for RefCT mode.
    //! Default: 1024, (Range: 0 ~ 20000)
    unsigned int dwOutdoorInitColorTemp;

    //! A data for initial indoor R gain, only used for refCT mode. 1024: 1 x.
    //! Default: 1024. (Range: 1 ~ 8191)
    unsigned int dwIndoorInitGainR;

    //! A data for initial indoor B gain, only used for refCT mode. 1024: 1 x.
    //! Default: 1024. (Range: 1 ~ 8191)
    unsigned int dwIndoorInitGainB;

    //! A data for initial indoor color temprature, only used for RefCT mode.
    //! Default: 1024, (Range: 0 ~ 20000)
    unsigned int dwIndoorInitColorTemp;
} VMF_AWB_INIT_OPTION_T;

/*
 * A data structure for AIAWB control info
 */
typedef struct
{
    unsigned char byAiFilterType;
    unsigned int dwAiConfidenceThd;
} VMF_AWB_AI_CONTROL_OPTION_T;


/*
 * A data structure for AIAWB weighting info
 */
typedef struct
{
    unsigned int dwEnableClassSet01;
    unsigned int dwEnableClassSet02;
    unsigned int dwEnableClassSet03;
    unsigned int adwClassSet01Index[12];		//preserved
    unsigned int adwClassSet01Weight[12];		//preserved
    unsigned int adwClassSet01ConfRatio[12];	//preserved
    unsigned int adwClassSet02Index[12];		//preserved
    unsigned int adwClassSet02Weight[12];		//preserved
    unsigned int adwClassSet02ConfRatio[12];	//preserved
    unsigned int adwClassSet03Index[12];		//preserved
    unsigned int adwClassSet03Weight[12];		//preserved
    unsigned int adwClassSet03ConfRatio[12];	//preserved
    unsigned int adwAIEV[12];					//preserved
    unsigned int adwAIConfRatio[12];			//preserved
} VMF_AWB_AI_WEIGHTING_OPTION_T;

/*
 * A data structure for AIAWB curr info
 */
typedef struct
{
	unsigned int dwAwbStable;   		
	unsigned int dwCurrGainR; 		
	unsigned int dwCurrGainG; 		
	unsigned int dwCurrGainB; 		
	unsigned int dwCurrColorTemp; 	
} VMF_AWB_CURR_INFO_T;

/*
 * A data structure for AIAWB mode info
 */
typedef struct
{
    //! A data for Ai Awb enable
    unsigned int dwAiMode;
} VMF_AWB_AI_MODE_INFO_T;

/*
 * A data structure for AWB preference stat control option, AWB_OPTION_PREFERENCE
 */
typedef struct
{
    //! A data for preference type
    //! Default: 0. (Range: 0 ~ 5, 10)
    VMF_AWB_PREFERENCE_TYPE ePreferenceType;
    //! Be effective on dwPreferenceType(4). It applied a specific RatioR/RatioB according to the current C.T..
    //! Default: 1000. (Range: 2000 ~ 20000)
    unsigned int dwPrefCT;
    //! Be effective on dwPreferenceType(5). It applied a specific RatioR/RatioB according to the current E.V..
    //! Default: 1000. (Range: 2 ~ 1600000000)
    unsigned int dwPrefEV;
    //! Be effective on dwPreferenceType(10). The value would be applied on the output stat R gain directly.
    //! Default: 1024. (Range: 1 ~ 8191)
    unsigned int dwRatioR;
    //! Be effective on dwPreferenceType(10).
    //! Default: 1024. (Range: 1 ~ 8191)
    unsigned int dwRatioB;
} VMF_AWB_PREFERENCE_OPTION_T;


#ifdef __cplusplus
}
#endif

#endif

