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

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file   chibpsconfigoverride.h
/// @brief  Defines BPS Node override Configuration
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef CHIBPSCONFIGOVERRIDE_H
#define CHIBPSCONFIGOVERRIDE_H

#include "chicommonhwconfigoverride.h"

/// @brief  Defines the property of a BPS Node.
struct ChiBPSNodeProperty
{
    UINT                profileId;                           ///< Profile Id
    UINT                processingType;                      ///< Processing type
};

/// @brief  Define BPS OEM feature type
enum OEMBPSFeatureType
{
    BPSIQControlWBType = CommonOEMFeatureTypeNumber,         ///< OEM feature type of wb control
    BPSIQControlCCMType,                                     ///< OEM feature type of ccm control
    BPSIQControlBLSType,                                     ///< OEM feature type of bls control
    BPSIQControlLSCType,                                     ///< OEM feature type of lsc control
    BPSIQControlCGType,                                      ///< OEM feature type of cg control
    BPSOnlineTuningType,                                     ///< OEM feature type of online tuning
    BPSIQOverrideGTMType,                                    ///< OEM feature type of GTM control
    BPSDisableTintlessControlType,                           ///< OEM feature type of tintless dynamic disable
    BPSOverwriteFaceLevel,                                   ///< OEM feature type of overwriting face level
    BPSOverwriteCalibrationTable,                            ///< OEM feature type of overwriting lsc calibiration table
    BPSLSCFastConvergeType,                                  ///< OEM feature type of LSC fast converge
    BPSIQControlGammaType,                                   ///< OEM feature type of gamma control

    BPSFeatureTypeNumber,                                    ///< OEM feature type supported number
    BPSFeatureTypeMax  = OEMFeatureTypeCapability            ///< OEM feature type capability
};

static_assert(BPSFeatureTypeNumber < BPSFeatureTypeMax, "BPS OEM Feature type number overflow!");

static const UINT64 BPSInputBufferTypeMask            = (1ULL << static_cast<UINT>(CommonOEMInputBufferType));
static const UINT64 BPSMetadataTypeMask               = (1ULL << static_cast<UINT>(CommonOEMMetadataType));
static const UINT64 BPSTuningModeTypeMask             = (1ULL << static_cast<UINT>(CommonOEMTuningModeType));
static const UINT64 BPSTuningSetManagerTypeMask       = (1ULL << static_cast<UINT>(CommonOEMTuningSetManagerType));
static const UINT64 BPSIQTriggerCustomizeMask         = (1ULL << static_cast<UINT>(CommonOEMIQTriggerType));
static const UINT64 BPSIQControlWBTypeMask            = (1ULL << static_cast<UINT>(BPSIQControlWBType));
static const UINT64 BPSIQControlCCMTypeMask           = (1ULL << static_cast<UINT>(BPSIQControlCCMType));
static const UINT64 BPSIQControlBLSTypeMask           = (1ULL << static_cast<UINT>(BPSIQControlBLSType));
static const UINT64 BPSIQControlLSCTypeMask           = (1ULL << static_cast<UINT>(BPSIQControlLSCType));
static const UINT64 BPSIQControlCGTypeMask            = (1ULL << static_cast<UINT>(BPSIQControlCGType));
static const UINT64 BPSOnlineTuningTypeMask           = (1ULL << static_cast<UINT>(BPSOnlineTuningType));
static const UINT64 BPSIQOverrideGTMTypeMask          = (1ULL << static_cast<UINT>(BPSIQOverrideGTMType));
static const UINT64 BPSDisableTintlessControlTypeMask = (1ULL << static_cast<UINT>(BPSDisableTintlessControlType));
static const UINT64 BPSOverwriteFaceLevelMask         = (1ULL << static_cast<UINT>(BPSOverwriteFaceLevel));
static const UINT64 BPSOverwriteCalibrationTableMask  = (1ULL << static_cast<UINT>(BPSOverwriteCalibrationTable));
static const UINT64 BPSLSCFastConvergeTypeMask        = (1ULL << static_cast<UINT>(BPSLSCFastConvergeType));
static const UINT64 BPSIQControlGammaTypeMask         = (1ULL << static_cast<UINT>(BPSIQControlGammaType));

/// @brief Define BPS OEM WB configuration
struct OEMWBToBPSNode
{
    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 OEMCCMToBPSNode
{
    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 BPS OEM BLS configuration
struct OEMBLSToBPSNode
{
    OEMIQControl    IQControl;                               ///< OEM mask to control calculate but no apply
};

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

    OEMLSCModeType           LSCMode;                                   ///< Indicates OEM LSC Mode
    union
    {
        LSCMeshTable         meshTable;                                 ///< OEM MeshTable
        LSCSensorData        sensorData;                                ///< OEM Sensor Data
        LSCSensorDataWithSR  sensorDataWithSR;                          ///< OEM Sensor Data with Disable SR
    };
};

/// @brief Define OEM Trigger
struct OEMTriggerToBPSNode
{
    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 BPS OEM CG configuration
struct OEMCGToBPSNode
{
    OEMIQControl    IQControl;                              ///< OEM mask to control overwrite/use last configuration
    struct
    {
        BIT isInputCtrlEnable               :   1;          ///< Flag to indecate IQControl enable for digital gain overwriting
        BIT isOutputCtrlEnable              :   1;          ///< Flag to indecate IQControl enable for output digital gain
        BIT reserved                        :  30;          ///< Reserved
    };
    FLOAT           inputDigitalGain;                       ///< Digital Gain for overwriting
    FLOAT           outputDigitalGain;                      ///< Output Digital Gain
};

/// @brief parameters needed by OEMs for their GTM curve calculation.
struct OEMGTMToBPSNode
{
    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 OEM's configuration for BPS Gamma.
struct OEMGammaToBPSNode
{
    OEMIQControl        IQControl;                      ///< OEM mask to control calculate but not apply
};

/// @brief Define BPS data structure to OEM, feature type would decide which data should be used
struct BPSFeatureTypeDataToOEM
{
    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.
    };
};

/// @brief Define BPS data structure to Hw node, feature type would decide which data should be used
struct OEMFeatureTypeDataToBPSNode
{
    union
    {
        HwCfgMetaInfo*              pHwCfgMetaInfo;              ///< Meta Data Info
        ChiTuningModeParameter      tuningModeData;              ///< Tuning mode to HwNode
        OEMWBToBPSNode              wbData;                      ///< wb data to HwNode
        OEMCCMToBPSNode             ccmData;                     ///< CCM data to HwNode
        OEMTriggerToBPSNode         oemTriggerData;              ///< Customized trigger data to HWNode
        OEMBLSToBPSNode             blsData;                     ///< bls data to HwNode
        OEMLSCToBPSNode             lscData;                     ///< lsc data to HwNode
        OEMCGToBPSNode              cgData;                      ///< CG data to HWNode
        OEMGammaToBPSNode           gammaData;                   ///< Gamma data to HWNode
        OEMBPSIQSetting*            pOnlineTuningSetting;        ///< OEM IQ cfg settings for OnlineTuning
        OEMGTMToBPSNode             gtmData;                     ///< previous OEM GTM curve info to HwNode
        OEMTintlessDisableControl   tintlessDisabled;            ///< Tintless dynamic control
        FLOAT                       oemFaceLevel;                ///< OEM face level
        OEMLSCCalibrationTable*     pOEMCalibrationTable;        ///< OEM calibration table
        OEMLSCFastConvergeControl   lscFastConvergeEnable;       ///< lsc fast converge enable
    };
};
#endif //CHIBPSCONFIGOVERRIDE_H
