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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  camxcslresourcedefs.h
/// @brief The definition of CSL device resource structures for packets that will be used both by CSL and HWL
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef CAMXCSLRESOURCEDEFS_H
#define CAMXCSLRESOURCEDEFS_H

// NOWHINE FILE GR016: Converting CSL header to C, we need typedef

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

#include "camxdefs.h"
#include "camxtypes.h"

/// @brief This enumerates VFE device resources.
typedef enum
{
    CSLVFEResourceIDPort = 0,           ///< Indicates a port resource
    CSLVFEResourceIDMaxNumResources     ///< To use as the number of resources
} CSLVFEResourceID;

/// @todo (CAMX-544) Add more resource Ids
/// @brief This enumerates VFE device resources.
typedef enum
{
    CSLVFEPortIdViewer = 0,         ///< Indicates viewer path output resource
    CSLVFEPortIdEncoder,            ///< Indicates encoder path output resource
    CSLVFEPortIdFD,                 ///< Indicates face detect path output resource
    CSLVFEPortIdRDI0,               ///< Indicates RDI 0 path output resource
    CSLVFEPortIdRDI1,               ///< Indicates RDI 1 path output resource
    CSLVFEPortIdRDI2,               ///< Indicates RDI 2 path output resource
    CSLVFEPortIdOffline,            ///< Indicates offline processing path
    CSLVFEPortIdMaxNumPortResources ///< To use as the number of port resources
} CSLVFEPortId;

CAMX_BEGIN_PACKED

/// @todo (CAMX-544) Add stats resource Ids
/// @brief This is the info associated with a VFE port resource.
typedef struct
{
    UINT32  portId; ///< Port Id
    UINT32  format; ///< This indicates the format of the output port resource.
} CAMX_PACKED CSLVFEPortResourceInfo;

typedef enum
{
    CSLIFEInputPortIdTPG    = 2500, ///< Testgen input
    CSLIFEInputPortIdPHY0,          ///< PHY0
    CSLIFEInputPortIdPHY1,          ///< PHY1
    CSLIFEInputPortIdPHY2,          ///< PHY2
    CSLIFEInputPortIdPHY3,          ///< PHY3
    CSLIFEInputPortIdMax            ///< Max resource Id
} CSLIFEInputPortId;

/// @brief This enumerates ICP device types.
typedef enum
{
    CSLICPDeviceTypeA5 = 1, ///< Indicates A5 device
    CSLICPDeviceTypeIPE,    ///< Indicates IPE device
    CSLICPDeviceTypeBPS,    ///< Indicates BPS device
    CSLICPDeviceTypeMax     ///< Max number of devices
} CSLICPDeviceType;


/// @brief Secure/Non-Secure Modes for each stream
typedef enum
{
    CSLStreamNonSecure = 0,         ///< Stream is non secure
    CSLStreamSecure                 ///< Stream is secure
} CSLStreamSecureMode;

/// @brief Domain types for kernel call
typedef enum
{
    CSLDomainTypeNonSecure = 0,   ///< Kernel domain type for non secure
    CSLDomainTypeSecure           ///< Kernel domain type for secure
} CSLInputDomainType;

/// @brief This enumerates ICP device resources.
typedef enum
{
    CSLICPResourceIDBPS = 1,        ///< Indicates BPS Non Realtime resource    = 1
    CSLICPResourceIDIPERealTime,    ///< Indicates IPE realtime resource        = 2
    CSLICPResourceIDIPENonRealTime, ///< Indicates IPE Non Realtime resource    = 3
    CSLICPResourceIDIPESemiRealTime,///< Indicates IPE Pseudo Realtime resource = 4
    CSLICPResourceIDBPSRealTime,    ///< Indicates BPS realTime resource        = 5
    CSLICPResourceIDBPSSemiRealTime,///< Indicates BPS Pseudo RealTime resource = 6
    CSLICPResourceIDMax             ///< Max resource Id
} CSLICPResourceID;

static const UINT32 CSLICPResourceIDMaxNumResources = CSLICPResourceIDMax - CSLICPResourceIDBPS;

/// @brief This enumerates IPE device input port resources.
typedef enum
{
    CSLIPEInputPortIdFull = 0,       ///< Full size input
    CSLIPEInputPortIdDS4,            ///< 1:4 size input
    CSLIPEInputPortIdDS16,           ///< 1:16 size input
    CSLIPEInputPortIdDS64,           ///< 1:64 size input
    CSLIPEInputPortIdFullRef,        ///< IPE Full path reference path input resource
    CSLIPEInputPortIdDS4Ref,         ///< IPE DS4 path input resource
    CSLIPEInputPortIdDS16Ref,        ///< IPE DS16 path input resource
    CSLIPEInputPortIdDS64Ref,        ///< IPE DS64 path input resource
    CSLIPEInput2PortIdFull = 14,     ///< IPE Input 2 Full (aligning to firmware interface)
    CSLIPEInput2PortIdDSX  = 15,     ///< IPE Input 2 DSX (aligning to firmware interface)
    CSLIPEInput2ImageDS16  = 17,     ///< IPE Input 2 Image DS16
    CSLIPEInput2ImageDS64  = 18,     ///< IPE Input 2 Image DS64
    CSLIPEInputFullBlurMapBlur = 19, ///< IPE full input blur map blur
    CSLIPEInputDS4BlurMapBlur  = 20, ///< IPE ds4 input blur map blur
    CSLIPEInputDS16BlurMapBlur = 21, ///< IPE ds16 input blur map blur
    // Index 22 resserved for future for Blur
    CSLIPEInputFullBlurMapVSE  = 23, ///< IPE full input blur map VSE
    CSLIPEInputDS4BlurMapVSE   = 24, ///< IPE ds4 input blur map VSE
    // Index 25 & 26 resserved for future for Blur
    CSLIPEInputFullBokehDC     = 27, ///< IPE full input bokeh DC
    CSLIPEInputDS4BokehDC      = 28, ///< IPE ds4 input bokeh DC
    // Index 29,30 are reservice for future use
    CSLIPEInputImageFullAlgm   = 31, ///< IPE input full image ALGM
    // Index 32,33,34 reserved for future ALGM
    CSLIPEInputImageFullLMC1   = 35, ///< IPE Full image LMC1 input
    CSLIPEInputImageDS4LMC1    = 36, ///< IPE DS4 image LMC1 input
    CSLIPEInputImageDS16LMC1   = 37, ///< IPE DS16 image LMC1 input
    CSLIPEInputImageDS64LMC1   = 38, ///< IPE DS64 image LMC1 input
    CSLIPEInputImageFullLMC2   = 39, ///< IPE Full image LMC2 input
    CSLIPEInputImageDS4LMC2    = 40, ///< IPE DS4 image LMC2 input
    CSLIPEInputImageDS16LMC2   = 41, ///< IPE DS16 image LMC2 input
    CSLIPEInputImageDS64LMC2   = 42, ///< IPE DS64 image LMC2 input
    CSLIPEInputImageFullCATMAPCMUS = 43, ///< IPE Full CATMAP CMUS input
    CSLIPEInputImageDS4CATMAPCMUS  = 44, ///< IPE DS4 CATMAP CMUS input
    CSLIPEInputImageDS16CATMAPCMUS = 45, ///< IPE DS16 CATMAP CMUS input
    CSLIPEInputImageDS64CATMAPCMUS = 46, ///< IPE DS64 CATMAP CMUS input
    CSLIPEInputImageFullCATMAPSTMP = 47, ///< IPE Full CATMAP STMP input
    // Index 48, 49, 50 reserved for future CATMAP STMP
    CSLIPEInputImageBLTMSTATS      = 69, ///< IPE Input BLTM stats
    CSLIPEInputPortIdMaxNumPortResources = CSLIPEInputImageBLTMSTATS + 1 ///< To use as the number of port resources

    } CSLIPEInputPortId;

/// @brief This enumerates IPE device output port resources.
typedef enum
{
    CSLIPEOutputPortIdDisplay = CSLIPEInputPortIdDS64Ref + 1,               ///< IPE display pixel path output resource
    CSLIPEOutputPortIdVideo,                                                ///< IPE video pixel path output resource
    CSLIPEOutputPortIdFullRef,                                              ///< IPE Full path reference output resource
    CSLIPEOutputPortIdDS4Ref,                                               ///< IPE DS4 path reference output resource
    CSLIPEOutputPortIdDS16Ref,                                              ///< IPE DS16 path reference output resource
    CSLIPEOutputPortIdDS64Ref,                                              ///< IPE DS64 path reference output resource
    CSLIPEOutputScratchBufer    = 16,                                       ///< IPE Input Sratch buffer
    CSLIPEOutputImageApp        = 51,                                       ///< IPE Output Image App
    CSLIPEOutputPortDS16BlurDC  = 52,                                       ///< DS 16 Blur output Port
    CSLIPEOutputPortDS4BlurDC   = 53,                                       ///< DS4 Blur output port
    CSLIPEOutputPortBlurMap     = 54,                                       ///< Blur map data
    CSLIPEOutputPortHDR10       = 55,                                       ///< HDR 10 stats output buffer
    CSLIPEOutputImageFullALGM   = 56,                                       ///< IPE Output image Full ALGM
    // Index 57, 58, 59 reserved for future ALGM
    CSLIPEOutputImageLTMStats   = 60,                                       ///< IPE Output Image LTM stats
    CSLIPEOutputImageIHistStats = 61,                                       ///< IPE Output Image IHist stats
    CSLIPEOutputImageGSSTATS    = 62,
    CSLIPEOutputImageDS4GSSTATS = 63,
    CSLIPEOutputPortTFI_FULL    = 64,
    CSLIPEOutputPortTFI_DS4     = 65,
    CSLIPEOutputPortTFI_DS16    = 66,
    CSLIPEOutputPortTFI_DS64    = 67,
    CSLIPEOutputImageBLTMStats  = 68,
    CSLIPEOutputPortIdMaxNumPortResources = CSLIPEOutputImageBLTMStats + 1 ///< To use as the number of port resources
} CSLIPEOutputPortId;

/// @brief This enumerates BPS device input port resources.
typedef enum
{
    CSLBPSInputPortImage = 0,            ///< Full size input
    CSLBPSInputPortImageCADL1 = 9,       ///< CADL1 input
    CSLBPSInputPortImageCADL2 = 10,      ///< CADL2 input
    CSLBPSInputOutputScratchBuffer = 11, ///< Input Output ScratchBuffer
} CSLBPSInputPortId;

/// @brief This enumerates BPS device output port resources.
typedef enum
{
    CSLBPSOutputPortIdPDIImageFull = CSLBPSInputPortImage + 1,  ///< BPS Image full size PDI packed output path resource
    CSLBPSOutputPortIdPDIImageDS4,                              ///< BPS down scale 4 PDI packed output path resource
    CSLBPSOutputPortIdPDIImageDS16,                             ///< BPS down scale 16 PDI packed output path resource
    CSLBPSOutputPortIdPDIImageDS64,                             ///< BPS down scale 64 PDI packed output path resource
    CSLBPSOutputPortIdStatsBG,                                  ///< BPS Bayer Grid stats output path resource
    CSLBPSOutputPortIdStatsHDRBHIST,                            ///< BPS HDR Bayer histogram stats output resource
    CSLBPSOutputPortIdRegistrationImage1,                       ///< BPS Image registration1 image format output resource
    CSLBPSOutputPortIdRegistrationImage2,                       ///< BPS Image registration2 image format output resource
    CSLBPSOutputPortIdMaxNumPortResources =
             CSLBPSInputOutputScratchBuffer +1,                  ///< To use as the number of port resources
}  CSLBPSOutputPortId;

/// @brief This is the info associated with a IFE port resource.
typedef struct
{
    UINT32  portId; ///< Port Id
    UINT32  format; ///< This indicates the format of the output port resource.
} CAMX_PACKED CSLIFEPortResourceInfo;

/// @brief This enumerates JPEG device input port resources.
typedef enum
{
    CSLJPEGInputPortIdImage = 0,    ///< jpeg input port id
    CSLJPEGInputPortIdMax,          ///< jpeg input port id Max
} CSLJPEGInputPortId;

/// @brief This enumerates JPEG device output port resources.
typedef enum
{
    CSLJPEGOutputPortIdImage = CSLJPEGInputPortIdMax,                   ///< jpeg output port id
    CSLJPEGOutputPortIdMax,                                             ///< jpeg input port id max
    CSLJPEGOutputPortIdMaxNumPortResources = CSLJPEGOutputPortIdMax,    ///< jpeg input/output port id
} CSLJPEGOutputPortId;

/// @brief This enumerates JPEG device types.
typedef enum
{
    CSLJPEGDeviceTypeEncoder,   ///< Indicates jpeg Encoder device
    CSLJPEGDeviceTypeDma,       ///< Indicates jpeg DMA device
    CSLJPEGDeviceTypeMax        ///< Max number of devices
} CSLJPEGDeviceType;

/// @brief This enumerates JPEG device resources.
typedef enum
{
    CSLJPEGResourceIDEncoder,           ///< Indicates jpeg Encoder device
    CSLJPEGResourceIDDma,               ///< Indicates jpeg DMA device
    CSLJPEGResourceIDMaxNumResources,   ///< Max number of Resources
} CSLJPEGResourceID;

typedef enum
{
    CSLLRMEOutputPortIdVector = 0,                              ///< LRME output vector Port
    CSLLRMEOutputPortIdDS2,                                     ///< LRME DS2 output port
    CSLLRMEOutputPortIdMax                                      ///< Maximum output ports
} CSLLRMEOutputPortId;

typedef enum
{
    CSLLRMEInputPortTARIFEFull = CSLLRMEOutputPortIdDS2 + 1,    ///< Input port to take input from IFE Full port
    CSLLRMEInputPortREFIFEFull,                                 ///< Input port to take input from IFE Full port
    CSLLRMEInputPortTARIFEDS4,                                  ///< Input port to take input from IFE DS4 port
    CSLLRMEInputPortREFIFEDS4,                                  ///< Input port to take input from IFE DS4 port
    CSLLRMEInputPortTARIFEDS16,                                 ///< Input port to take input from IFE DS16 port
    CSLLRMEInputPortREFIFEDS16,                                 ///< Input port to take input from IFE DS16 port
    CSLLRMEInputPortREFLRMEDS2,                                 ///< Input port to take input LRME Downscaled port
    CSLLRMEInputPortIdMax                                       ///< Maximum Input Ports
} CSLLRMEInputPortId;

/// @brief This enumerates OPE HW types.
typedef enum
{
    CSLOPEHwTypeOPE = 1,   ///< Indicates OPE device
    CSLOPEHwTypeOPECDM,    ///< Indicates OPE CDM device
    CSLOPEHwTypeMax        ///< Max number of devices
} CSLOPEHwType;

/// @brief This enumerates OPE device types.
typedef enum
{
    CSLOPEDeviceTypeRealtime = 1,        ///< Indicates OPE realtime resource
    CSLOPEDeviceTypeNonRealTime,         ///< Indicates OPE Non Realtime resource
    CSLOPEDeviceTypeMax                  ///< Max device type
} CSLOPEDeviceType;

static const UINT32 CSLOPEMaxNumResources = CSLOPEDeviceTypeMax - CSLOPEDeviceTypeRealtime;

/// @brief This enumerates OPE device input port resources.
typedef enum
{
    CSLOPEInputPortIDFull = 1           ///< OPE Full Size Input
} CSLOPEInputPortId;

/// @brief This enumerates OPE device output port resources.
typedef enum
{
    CSLOPEOutputPortIDVideo = 1,   ///< OPE display pixel path output resource
    CSLOPEOutputPortIDDisplay,     ///< OPE video pixel path output resource
    CSLOPEOutputPortIDARGB,        ///< OPE ARGB path output resource
    CSLOPEOutputPortIDStatRS,      ///< OPE stats RS output resource
    CSLOPEOutputPortIDStatIHIST,   ///< OPE stats IHIST output resource
    CSLOPEOutputPortIDStatLTM,     ///< OPE stats LTM output resource
    CSLOPEOutputPortIDMax          ///< To use as the number of port resources
} CSLOPEOutputPortId;

/// @brief This enumerates CRE device types.
typedef enum
{
    CSLCREDeviceTypeNonRealTime = 1, ///< Indicates CRE non real-time resource
    CSLCREDeviceTypeRealTime,        ///< Indicates CRE real-time resource
    CSLCREDeviceTypeMax              ///< Max device type
} CSLCREDeviceType;

/// @brief This enumerates CRE device input port resources.
typedef enum
{
    CSLCREInputPortIdImage = 1,    ///< CRE input port id
    CSLCREInputPortIdMax,          ///< CRE input port id Max
} CSLCREInputPortId;

/// @brief This enumerates CRE device output port resources.
typedef enum
{
    CSLCREOutputPortIdImage = 1,                                     ///< CRE output port id
    CSLCREOutputPortIdMax,                                           ///< CRE output port id max
    CSLCREOutputPortIdMaxNumPortResources = CSLCREOutputPortIdMax,   ///< CRE input/output port id
} CSLCREOutputPortId;

/// @brief This enumerates TFE device output port resources.
typedef enum
{
    CSLTFEPortIdFull           = 1, ///< TFE full pixel path output resource
    CSLTFEPortIdRawDump,            ///< TFE Raw Output path output resource
    CSLTFEPortIdPDAF,               ///< TFE PDAF Output path output resource
    CSLTFEPortIdRDI0,               ///< TFE RDI0 Output path output resource
    CSLTFEPortIdRDI1,               ///< TFE RDI1 Output path output resource
    CSLTFEPortIdRDI2,               ///< TFE RDI2 Output path output resource
    CSLTFEPortIdStatAECBG,          ///< TFE Stats AEC BG output resource
    CSLTFEPortIdStatBHIST,          ///< TFE Stats BHIST output resource
    CSLTFEPortIdStatTLBG,           ///< TFE Stats TL BG output resource
    CSLTFEPortIdStatBF,             ///< TFE Stats BF output resource
    CSLTFEPortIdStatAWBBG,          ///< TFE Stats AWB BG output resource
    CSLTFEPortIdStatRS,             ///< TFE Stats RS output resource
    CSLTFEPortIdDS4,                ///< TFE DS4 output resource
    CSLTFEPortIdDS16,               ///< TFE DS16 output resource
    CSLTFEPortIdAI,                 ///< TFE AI output resource
    CSLTFEPortStatsDualPD,          ///< TFE LCR+LR+LCSAD output resource
    CSLTFEPortIdPDPreProcessed,     ///< TFE PD PreProcessed Port output resource
    CSLTFEPortIdPDparsed,           ///< TFE SparsePD output resource
    CSLTFEPortIdMax                 ///< TFE Max Port Id
} CSLTFEOutputPortId;

static const UINT32 CSLTFEPortIdMaxNumStatsPortResources = CSLTFEPortIdStatRS - CSLTFEPortIdStatAECBG + 1;
static const UINT32 CSLTFEPortIdMaxNumPortResources      = CSLTFEPortIdMax - CSLTFEPortIdFull;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// CSLTFEPortIndex
///
/// @brief  Map CSL TFE port Id to zero-based index
///
/// @param  portId CSL TFE port Id
///
/// @return index
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CAMX_INLINE UINT32 CSLTFEPortIndex(
    CSLTFEOutputPortId portId)
{
    return  portId - CSLTFEPortIdFull;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// CSLTFEStatsPortIndex
///
/// @brief  Map CSL TFE stats port Id to zero-based stats port index
///
/// @param  portId CSL TFE stats port Id
///
/// @return index
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CAMX_INLINE UINT32 CSLTFEStatsPortIndex(
    CSLTFEOutputPortId portId)
{
    return  portId - CSLTFEPortIdStatAECBG;
}

/// @brief This enumerates TFE device input port resources.
typedef enum
{
    CSLTFEInputPortIdTPG    = 1,    ///< Testgen input
    CSLTFEInputPortIdPHY0,          ///< PHY0
    CSLTFEInputPortIdPHY1,          ///< PHY1
    CSLTFEInputPortIdPHY2,          ///< PHY2
    CSLTFEInputPortIdMax            ///< Max resource Id
} CSLTFEInputPortId;

CAMX_END_PACKED

#ifdef __cplusplus
}
#endif // __cplusplus

#endif // CAMXCSLRESOURCEDEFS_H
