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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file camxifeproperty.h
/// @brief Define ife properties per usecase and per frame
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef CAMXIFEPROPERTY_H
#define CAMXIFEPROPERTY_H

#include "camxdefs.h"
#include "camxtypes.h"
#include "camxifestripinginterface.h"
#include "chipdlibcommon.h"
#include "chiafcommon.h"

CAMX_NAMESPACE_BEGIN

/// @todo (CAMX-1777) Need to update the below structures inline with standard HAL structures

// Maximum number of Gamma entries
static const UINT32 MaxGamma16Entries = 65;

// Static const define for Gamma15
static const UINT32 Gamma15TableSize                = 257;   ///< A CDF with first element=0 and last element=1023
static const UINT32 MaxGammaLUTNum                  = 3;     ///< Maximum number of Gamma Channels
static const UINT32 Gamma15LUTNumEntriesPerChannel  = 256;   ///< Maximum number of Gamma15 entries
static const UINT32 MaxGamma15Entries               = Gamma15LUTNumEntriesPerChannel * MaxGammaLUTNum;
static const UINT32 YRatioGTM10Size                 = 64;    // Number of GTM10 Y ratio
static const UINT32 YRatioGTM131Size                = 256;   // Number of GTM131 Y ratio
static const UINT32 YRatioGTMSizeMax                = 256;   // Max Number of GTM Y ratio
static const UINT32 AVGLUTTableSize                 = 1170;  ///< BLTM avg lut table size is 9*130
static const UINT32 WBCHGainSize                    = 3;     ///< WB green/blue/red channel gain

/// @brief This structures encapsulate IFE crop info to IPE for Digital Zoom
struct CropWindow
{
    INT32    left;     ///< starting pixel to crop on IFE output
    INT32    top;      ///< starting line o crop on IFE output
    INT32    width;    ///< width of the crop window
    INT32    height;   ///< height of the crop window
};

/// @brief This structures encapsulate IFE /BPS GMT Info output
struct GTMInfo
{
    UINT64  yRatioGtm[YRatioGTMSizeMax];        ///< Max yRatioGtm array data used by IQ calculation
    UINT32  yRatioBase[YRatioGTMSizeMax];       ///< Max yRatioBase array data used by IQ calculation
    INT32   yRatioSlope[YRatioGTMSizeMax];      ///< Max yRatioSlope array data used by IQ calculation
    UINT8   yRatioSlopeQ[YRatioGTMSizeMax];     ///< Max yRatioSlopeQ array data used by IQ calculation
    BOOL    enabledIFEGTMAdjust;                ///< Enable flag for noise adjustment based on IFE GTM
    BOOL    enabledBPSGTMAdjust;                ///< Enable flag for noise adjustment based on BPS GTM
    BOOL    enabledOPEGTMAdjust;                ///< Enable flag for noise adjustment based on OPE GTM
    UINT32  calculatedYRatioGTMSize;            ///< Actual size of calculated yRatioGtm array
};

/// @brief This structures encapsulate IFE Input
struct IFEInputDimensions
{
    UINT32    width;    ///< width of the Input IFE window
    UINT32    height;   ///< height of the Input IFE window
};

/// @brief This structures encapsulate IFE Input
struct IFEOutputDimensions
{
    UINT32    width;    ///< width of the Output IFE window
    UINT32    height;   ///< height of the Output IFE window
};

/// @brief This structures encapsulate Intermediate Dimension
struct IntermediateDimensions
{
    UINT32 width;   ///< intermediate width
    UINT32 height;  ///< intermediate height
    FLOAT  ratio;   ///< intermediate ratio
};

/// @brief This structures encapsulate IFE Downscale Factor
struct IFEInputResolution
{
    FLOAT               horizontalFactor;    ///< width of the Input IFE window
    FLOAT               verticalFactor;      ///< height of the Input IFE window
    IFEInputDimensions  resolution;          ///< Information about resolution
    CropWindow          CAMIFWindow;         ///< Information about CAMIF window
    CSIDBinningInfo     csidBinningInfo;     ///< CSID binning configuration
};

/// @brief This structures encapsulate IFE MRC Algo Output
struct MRCOutput
{
    FLOAT MACMotionAdjustScale1[2];    ///< width of the Input IFE window
    FLOAT MACMotionAdjustScale2[2];      ///< height of the Input IFE window
};

struct IFEOutputResolution
{
    BOOL                fullPortEnable;       ///< Enable Flag for full port
    BOOL                displayPortEnable;    ///<  Enable Flag for display port
    IFEOutputDimensions fullPortDimension;    ///< Information about full port demension
    IFEOutputDimensions displayPortDimension; ///< Information about Display port demension
};

/// @brief This Strucutres encapsulate IFE striping cuts
struct IFEStripingOutput
{
    UINT32              leftStart;      ///< Max number of ports
    UINT32              leftEnd;        ///< Reserverd
    UINT32              rightStart;     ///< Max number of ports
    UINT32              rightEnd;       ///< Reserverd
    UINT32              ifeMode;        ///< 0 - SingleIFE : 1 - DualIFE
};

/// @ brief Stream dimension
struct StreamDimension
{
    UINT32  width;   ///< Stream width in pixels
    UINT32  height;  ///< Stream Height in pixels
    UINT32  offset;  ///< Start offset in the output buffer
    UINT32  offsetX; ///< Start offset in the output buffer
    UINT32  offsetY; ///< Start offset in the output buffer
};

/// @ brief Structure to share MNDS output details with Crop module
struct IFEScalerOutput
{
    StreamDimension                 dimension;       ///< MNDS out put width and height
    StreamDimension                 input;           ///< MNDS input dimension
    FLOAT                           scalingFactor;   ///< MNDS input to output scaling
    BOOL                            preCropEnable;   ///< MNDS pre crop module Enable/Disable bit
    BOOL                            scalingLimitHit; ///< Scaling restricted to 105;
    IFEStripePreCropParamsInStruct  preCropInfo;     ///< MNDS Pre Crop Informations

    union
    {
        struct
        {
            IFEStripeMNScaleDownInputV16  mnds_config_y;  ///< Y config from striping for MNDS version 1.6
            IFEStripeMNScaleDownInputV16  mnds_config_c;  ///< C config from striping for MNDS version 1.6
        } version16;

        // Precrop is a part of MNDS module from version 2.0 onward.
        struct
        {
            IFEStripeMNScaleDownInputV20  mnds_config_y;  ///< Y config from striping for MNDS version 2.0 or 2.1
            IFEStripeMNScaleDownInputV20  mnds_config_c;  ///< C config from striping for MNDS version 2.0 or 2.1
            IFEStripeCrop                 preMndsCrop_y;  ///< Y precrop for MNDS version 2.0 or 2.1
            IFEStripeCrop                 preMndsCrop_c;  ///< C precrop for MNDS version 2.0 or 2.1
        } version20;
    };
};

typedef AFHWCapability AFHWAvailablity;

/// @brief Represnets IFE Instnace
struct IFEInstanceInfo
{
    CSLDeviceHandle hDeviceHandle;    ///< Device Handle
};

/// @brief Represnets IFE Node Instance Last Submitted Request Info
struct IFEInstanceSubmittedRequestInfo
{
    UINT64 requestId;        ///< Last submitted requested ID from Node
    UINT32 CSIDBank;          ///< CSID DMI Bank
    UINT32 pedestalBank;      ///< Pedestal DMI Bank
    UINT32 linearizaionBank;  ///< Linearization DMI Bank
    UINT32 BPCPDPCBank;       ///< BPC PDPC DMI Bank
    UINT32 ABFBank;           ///< ABF DMI Bank
    UINT32 LSCBank;           ///< LSC DMI Bank
    UINT32 GTMBank;           ///< GTM DMI Bank
    UINT32 gammaBank;         ///< Gamma DMI Bank
    UINT32 BFStatsDMIBank;    ///< BF Stats DMI Bank
    UINT32 DSXYBank;          ///< DSX Y DMI Bank
    UINT32 DSXCBank;          ///< DSX C DMI Bank
    UINT32 HDRBHistBank;      ///< HDR Bhist DMI Bank
    UINT32 BHistBank;         ///< Bhist DMI Bank
    UINT32 IHistBank;         ///< IHist DMI Bank
    UINT32 PDAFBank;          ///< PDAFBank
    UINT32 UVGBank;           ///< UVGaamma DMI Bank
    UINT32 preLSCPDPC1DBank;  ///< Pre LSC 1D Bank
    UINT32 postLSCPDPC1DBank; ///< Post LSC 1D Bank
};

CAMX_NAMESPACE_END

#endif // CAMXIFEPROPERTY_H
