///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2022-2023 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file   chiifeconfigoverride.h
/// @brief  Defines IFE Node override Configuration
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef CHIIFECONFIGOVERRIDE_H
#define CHIIFECONFIGOVERRIDE_H

#include "chicommonhwconfigoverride.h"

/// @brief  Defines the property of a IFE Node.
struct ChiIFENodeProperty
{
    UINT                profileId;                           ///< Profile Id
};

/// @brief  Define IFE OEM feature type
enum OEMIFEFeatureType
{
    IFEIQControlWBType     = CommonOEMFeatureTypeNumber,     ///< OEM feature type of wb control
    IFEIQControlCCMType,                                     ///< OEM feature type of ccm control
    IFEIQControlLSCType,                                     ///< OEM feature type of LSC control
    IFEIQControlBLSType,                                     ///< OEM feature type of BLS control
    IFEIQControlDemuxBLSType,                                ///< OEM feature type of demux BLS control
    IFEOnlineTuningType,                                     ///< OEM feature type of online tuning
    IFEIQOverrideGTMType,                                    ///< OEM feature type of GTM control
    IFEDisableTintlessControlType,                           ///< OEM feature type of tintless dynamic disable
    IFEOverwriteFaceLevel,                                   ///< OEM feature type of overwriting face level
    IFEOverwritePerPortCropType,                             ///< OEM feature type of per port crop
    IFEOverwriteCalibrationTable,                            ///< OEM feature type of overwriting lsc calibiration table
    IFELSCFastConvergeType,                                  ///< OEM feature type of LSC fast converge
    IFEFunctionCallbackType,                                 ///< OEM feature type of function callback

    IFEFeatureTypeNumber,                                    ///< OEM feature type supported number
    IFEFeatureTypeMax      = OEMFeatureTypeCapability        ///< OEM feature type capability
};

static_assert(IFEFeatureTypeNumber < IFEFeatureTypeMax, "IFE OEM Feature type number overflow!");

static const UINT64 IFEInputBufferTypeMask            = (1ULL << static_cast<UINT>(CommonOEMInputBufferType));
static const UINT64 IFEMetadataTypeMask               = (1ULL << static_cast<UINT>(CommonOEMMetadataType));
static const UINT64 IFETuningModeTypeMask             = (1ULL << static_cast<UINT>(CommonOEMTuningModeType));
static const UINT64 IFETuningSetManagerTypeMask       = (1ULL << static_cast<UINT>(CommonOEMTuningSetManagerType));
static const UINT64 IFEIQTriggerCustomizeMask         = (1ULL << static_cast<UINT>(CommonOEMIQTriggerType));
static const UINT64 IFEIQControlWBTypeMask            = (1ULL << static_cast<UINT>(IFEIQControlWBType));
static const UINT64 IFEIQControlCCMTypeMask           = (1ULL << static_cast<UINT>(IFEIQControlCCMType));
static const UINT64 IFEIQControlLSCTypeMask           = (1ULL << static_cast<UINT>(IFEIQControlLSCType));
static const UINT64 IFEIQControlBLSTypeMask           = (1ULL << static_cast<UINT>(IFEIQControlBLSType));
static const UINT64 IFEIQControlDemuxBLSTypeMask      = (1ULL << static_cast<UINT>(IFEIQControlDemuxBLSType));
static const UINT64 IFEOnlineTuningTypeMask           = (1ULL << static_cast<UINT>(IFEOnlineTuningType));
static const UINT64 IFEIQOverrideGTMTypeMask          = (1ULL << static_cast<UINT>(IFEIQOverrideGTMType));
static const UINT64 IFEDisableTintlessControlTypeMask = (1ULL << static_cast<UINT>(IFEDisableTintlessControlType));
static const UINT64 IFEOverwriteFaceLevelMask         = (1ULL << static_cast<UINT>(IFEOverwriteFaceLevel));
static const UINT64 IFEOverwritePerPortCropTypeMask   = (1ULL << static_cast<UINT>(IFEOverwritePerPortCropType));
static const UINT64 IFEOverwriteCalibrationTableMask  = (1ULL << static_cast<UINT>(IFEOverwriteCalibrationTable));
static const UINT64 IFELSCFastConvergeTypeMask        = (1ULL << static_cast<UINT>(IFELSCFastConvergeType));
static const UINT64 IFEFunctionCallbackTypeMask       = (1ULL << static_cast<UINT>(IFEFunctionCallbackType));

/// @brief Define IFE OEM CCM configuration
struct OEMWBToIFENode
{
    OEMIQControl    IQControl;                               ///< OEM mask to control need overwrite/use last
                                                             /// configuration. Following data would be used
                                                             /// only when OEMIQControlOverwrite

    FLOAT           red;                                     ///< Red pixels gain
    FLOAT           greenEven;                               ///< Green pixels gain on even rows
    FLOAT           greenOdd;                                ///< Green pixels gain on odd rows
    FLOAT           blue;                                    ///< Blue pixels gain
};

/// @brief Define OEM CCM configuration
struct OEMCCMToIFENode
{
    OEMIQControl    IQControl;                                          ///< OEM mask to control need overwrite/use last
                                                                        /// configuration. Following data would be used
                                                                        /// only when OEMIQControlOverwrite
    BOOL            isPublish;                                          ///< Flag to indicate if publish CCM
    CamxRational    CCM[ColorCorrectionRows][ColorCorrectionColumns];   ///< Color correction matrix
};

/// @brief Define IFE OEM BLS configuration
struct OEMBLSToIFENode
{
    OEMIQControl    IQControl;                               ///< OEM mask to control calculate but no apply
};

/// @brief Define IFE node OEM LSC configuration
struct OEMLSCToIFENode
{
    OEMIQControl             IQControl;                                 ///< OEM mask to control need overwrite/use last
                                                                        /// configuration. Following data would be used
                                                                        /// only when OEMIQControlOverwrite

    OEMLSCModeType           LSCMode;                                   ///< Indicate OEM LSC Mode
    union
    {
        LSCMeshTable         meshTable;                                 ///< OEM MeshTable
        LSCSensorData        sensorData;                                ///< OEM Sensor Data
    };
};

/// @brief Define OEM Trigger
struct OEMTriggerToIFENode
{
    OEMIQControl    IQControl;                                          ///< OEM mask to control need overwrite/use last
                                                                        /// configuration. Following data would be used
                                                                        /// only when OEMIQControlOverwrite

    OEMTriggerData  triggerData;                                        /// OEM Trigger Data
};

/// @brief Define IFE node OEM demux BLS configuration
struct OEMDemuxBLSToIFENode
{
    OEMIQControl    IQControl;                                          ///< OEM mask to control need overwrite

    FLOAT           inputDigitalGain;                                   ///< Input digital Gain for overwriting
    FLOAT           outputDigitalGain;                                  ///< Output digital Gain for overwriting
};

/// @brief parameters needed by OEMs for their GTM curve calculation.
struct OEMGTMToIFENode
{
    OEMIQControl        IQControl;                      ///< OEM mask to control need overwrite/use last
                                                        /// configuration. Following data would be used
                                                        /// only when OEMIQControlOverwrite
    BOOL                enableModuleLog;                ///< OEM manual curve GTM module log
    BOOL                IsInitialized;                  ///< OEM initialzaiton at very first request
    GTMManualCurveInfo* pGTMCurveInfo;                  ///< manual curve YratiBase & strength
};

/// @brief Define IFE data structure to OEM, feature type would decide which data should be used
struct IFEFeatureTypeDataToOEM
{
    union
    {
        TuningSetManager*           pTuningSetManager;           ///< Pointer to tuning set manager
        ChiTuningModeParameter      tuningModeData;              ///< Tuning mode to OEM
        LSCSensorDataToOEMParameter LSCSensorInputToOEM;         ///< parameters needed by OEMs for their LSC calculation
        NodeIQTriggerToOEMParameter IQTriggerInputToOEM;         ///< parameters needed by OEMs for their IQTriggerData calculation
        GTMInputToOEM               GTMInput;                    ///< parameters needed by OEMs for their GTM curve info.
        FLOAT                       postSensorGainId;            ///< parameters needed by OEMs for their demux BLS digital gain
    };
};

/// @brief Contains the information for IFE Port Crop Separately
struct OEMPortCropInfo
{
    BOOL            enable;             ///< enable port crop separately or not
    CHIRECTINT      cropWindow;         ///< cropwindow to crop separately, based on effective array size
};

/// @brief Contains several IFE Port Crop Separately information
struct OEMPerPortCropInfo
{
    OEMPortCropInfo cropInfoDisplay;    ///< Crop Info for IFE Display Port
    OEMPortCropInfo cropInfoVideo;      ///< Crop Info for IFE Video Port
    OEMPortCropInfo cropInfoFD;         ///< Crop Info for IFE FD Port
};

/// @brief Define IFE data structure to Hw node, feature type would decide which data should be used
struct OEMFeatureTypeDataToIFENode
{
    union
    {
        HwCfgMetaInfo*            pHwCfgMetaInfo;              ///< Meta Data Info
        ChiTuningModeParameter    tuningModeData;              ///< Tuning mode to HwNode
        OEMWBToIFENode            wbData;                      ///< wb data to HwNode
        OEMCCMToIFENode           ccmData;                     ///< CCM data to HwNode
        OEMTriggerToIFENode       oemTriggerData;              ///< OEM Trigger to HwNode
        OEMBLSToIFENode           blsData;                     ///< bls data to HwNode
        OEMLSCToIFENode           lscData;                     ///< lsc data to HwNode
        OEMDemuxBLSToIFENode      demuxBLSData;                ///< demux bls data to HW Node
        OEMIFEIQSetting*          pOnlineTuningSetting;        ///< OEM IQ cfg settings for OnlineTuning
        OEMGTMToIFENode           gtmData;                     ///< previous OEM GTM curve info to HwNode
        OEMTintlessDisableControl tintlessDisabled;            ///< Tintless dynamic control
        FLOAT                     oemFaceLevel;                ///< OEM face level
        OEMPerPortCropInfo        perPortCropInfo;             ///< OEM per port crop info
        VOID*                     pCallbackFunction;           ///< Function pointer to optimize tuning memory
        OEMLSCCalibrationTable*   pOEMCalibrationTable;        ///< OEM calibration table
        OEMLSCFastConvergeControl lscFastConvergeEnable;       ///< lsc fast converge enable
    };
};
#endif //CHIIFECONFIGOVERRIDE_H
