////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
// All rights reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  camxcslsensordefs.h
/// @brief The definitions needed for composing sensor packets.
///         Must match definitions in kernel\include\uapi\media\cam_sensor.h
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

#ifndef CAMXCSLSENSORDEFS_H
#define CAMXCSLSENSORDEFS_H

#include "camxdefs.h"

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

#define BIT_PATTERN(a) (1 << a)

static const UINT MaxOISNameSize           = 32;
static const UINT MaxSensorNameSize        = 32;
static const UINT MaxCapabilitySize        = 64;
static const UINT MaxFWCount               = 2;

static const UINT CSLSensorFeatureMask               = BIT_PATTERN(0);
static const UINT CSLSensorNumBatchedFrames          = BIT_PATTERN(1);

static const UINT CSLSensorFeatureNone               = 0;
static const UINT CSLSensorFeatureAEBOn              = BIT_PATTERN(0);
static const UINT CSLSensorFeatureAEBUpdate          = BIT_PATTERN(1);
static const UINT CSLSensorFeatureAEBOff             = BIT_PATTERN(2);
static const UINT CSLSensorFeatureInSensorHDR3ExpOn  = BIT_PATTERN(3);
static const UINT CSLSensorFeatureInSensorHDR3ExpOff = BIT_PATTERN(4);

// Must pack to enforce the expected command layout
CAMX_BEGIN_PACKED

/// @brief  CSIPHY Packet Metadata Types
typedef enum
{
    CSLCSIPHYInitialConfig,     ///< Initial Config Command
    CSLCSIPHYGenericBlob,       ///< Generic Blob Command Buffer
    CSLCSIPHYInitialConfigV2,   ///< Initial Config Command v2
}CSLCSIPHYPacketMetadata;

/// @brief  CSIPHY Blob Types
typedef enum
{
    CSLCSIPHYCDRSweepInfoBlobType,      ///< CDR Sweep Info
    CSLCSIPHYAuxMemoryBufferBlobType    ///< Aux Memory Buffer
}CSLCSIPHYBlobType;

/// @brief  Sensor Packet Metadata Types
typedef enum
{
    CSLSensorGenericBlob = 1,   ///< Generic Blob Command Buffer
}CSLSensorPacketMetadata;

/// @brief  Sensor Blob Types
typedef enum
{
    CSLSensorResInfoBlobType  ///< Resolution mode info
}CSLSensorBlobType;

/// @brief  endianness Types
typedef enum : BYTE
{
    CSLEndiannessTypeBig,      ///< endianness big
    CSLEndiannessTypeLittle    ///< endianness little
}CSLEndiannessType;

/// @brief  Sensor command type
typedef enum
{
    CSLSensorCmdTypeInvalid = 0,            ///< Invalid command
    CSLSensorCmdTypeProbe,                  ///< Sensor probe
    CSLSensorCmdTypePowerUp,                ///< Power up
    CSLSensorCmdTypePowerDown,              ///< Power down
    CSLSensorCmdTypeI2CInfo,                ///< I2C slave information command
    CSLSensorCmdTypeI2CRandomRegWrite,      ///< I2C random write
    CSLSensorCmdTypeI2CRandomRegRead,       ///< I2C random read
    CSLSensorCmdTypeI2CContinuousRegWrite,  ///< I2C continuous write
    CSLSensorCmdTypeI2CContinuousRegRead,   ///< I2C continuous read
    CSLSensorCmdTypeWait,                   ///< Wait
    CSLSensorCmdTypeFlashInit,              ///< Flash init command
    CSLSensorCmdTypeFlashFire,              ///< Flash fire command
    CSLSensorCmdTypeFlashRER,               ///< Flash red eye reduction sequence
    CSLSensorCmdTypeFlashQueryCurrent,      ///< Flash query current
    CSLSensorCmdTypeFlashWidget,            ///< Flash Widget
    CSLSensorCmdTypeReadData,               ///< Read Data
    CSLSensorCmdTypeFlashFireInit,          ///< Initial flash fire command
    CSLSensorCmdTypeOISFWInfo,              ///< OIS FW Information
    CSLSensorCmdTypeResInfo,                ///< For sensor resolution information (index, capability, width, height etc.)
    CSLSensorCmdTypeI2CReadAppendWrite,     ///< Read + Append + Write Command
    CSLSensorCmdTypeSeqXferLock,            ///< Sequential transfer lock
    CSLSensorCmdTypeSeqXferUnlock,          ///< Sequential transfer unlock
    CSLSensorCmdTypeMax,                    ///< Max
} CSLSensorCmdType;

/// @brief  Sensor I2C operation code
typedef enum
{
    CSLSensorI2COpcodeInvalid = 0,                      ///< Invalid opcode
    CSLSensorI2COpcodeRandomWrite,                      ///< Random write
    CSLSensorI2COpcodeRandomWriteVerify,                ///< Random write with verification
    CSLSensorI2COpcodeContinuousWriteBurst,             ///< Continuous burst write
    CSLSensorI2COpcodeContinuousWriteBurstVerify,       ///< Continuous burst write with verification
    CSLSensorI2COpcodeContinuousWriteSequence,          ///< Continuous sequence write
    CSLSensorI2COpcodeContinuousWriteSequenceVerify,    ///< Continuous sequence write with verification
    CSLSensorI2COpcodeRandomRead,                       ///< Random Read
    CSLSensorI2COpcodeContinuousRead,                   ///< Continuous Read
    CSLSensorI2COpcodeReadAppendWrite,                  ///< Read -> Mask with read_value -> write to same offset
    CSLSensorI2COpcodeSeqXferLock,                      ///< Sequential transfer lock
    CSLSensorI2COpcodeqXferUnlock,                      ///< Sequential transfer unlock
    CSLSensorI2COpcodeMax,                              ///< Max
} CSLSensorI2COpcode;

/// @brief  Sensor WAIT operation code
typedef enum
{
    CSLSensorWaitOpcodeInvalid = 0,     ///< Invalid
    CSLSensorWaitOpcodeConditional,     ///< Conditional wait
    CSLSensorWaitOpcodeUnconditionalHw, ///< Unconditional hardware wait
    CSLSensorWaitOpcodeUnconditionalSw, ///< Unconditional software wait
    CSLSensorWaitOpcodeMax,             ///< Max
} CSLSensorWaitOpcode;

/// @brief  Flash opcode
typedef enum
{
    CSLFlashOpcodeInvalid = 0,    ///< Invalid
    CSLFlashOpcodeOff,            ///< Off
    CSLFlashOpcodeFireLow,        ///< Fire with low current
    CSLFlashOpcodeFireHigh,       ///< Fire with high current
    CSLFlashOpcodeFirePrecision,  ///< Fire with precision mode
    CSLFlashOpcodeMax,            ///< Max
} CSLFlashOpcode;

/// @brief  Sensor I2C address type
typedef enum
{
    CSLSensorI2CTypeInvalid = 0,    ///< Invalid type
    CSLSensorI2CTypeByte,           ///< Byte
    CSLSensorI2CTypeWord,           ///< Word
    CSLSensorI2CType3Byte,          ///< 3-byte
    CSLSensorI2CTypeDword,          ///< Dword
    CSLSensorI2CTypeMax,            ///< Max
} CSLSensorI2CType;

/// @brief  Sensor I2C data type
typedef enum
{
    CSLSensorI2CDataTypeInvalid = 0,       ///< Invalid type
    CSLSensorI2CDataTypeByte,              ///< Byte
    CSLSensorI2CDataTypeWord,              ///< Word
    CSLSensorI2CDataTypeDword,             ///< Dword
    CSLSensorI2CDataTypeSetByteMask,       ///< SetByteMask
    CSLSensorI2CDataTypeUnsetByteMask,     ///< UnsetByteMask
    CSLSensorI2CDataTypeSetWordMask,       ///< SetWordMask
    CSLSensorI2CDataTypeUnsetWordMask,     ///< UnsetWordMask
    CSLSensorI2CDataTypeSetByteWriteMask,  ///< SetByteWriteMask
    CSLSensorI2CDataTypeMax,               ///< Max
} CSLSensorI2CDataType;

/// @brief  Camera roll definitions
typedef enum
{
    CSLSensorRoll0          = 0,    ///< 0 mounting angle
    CSLSensorRoll90         = 90,   ///< 90-degree mounting angle
    CSLSensorRoll180        = 180,  ///< 180-degree mounting angle
    CSLSensorRoll270        = 270,  ///< 270-degree mounting angle
    CSLSensorRollInvalid    = 360   ///< Beginning of invalid range of values
} CSLSensorRoll;

/// @brief  Camera yaw definitions
typedef enum
{
    CSLSensorYawFront   = 0,    ///< Yaw of a front-facing camera
    CSLSensorYawRear    = 180,  ///< Yaw of a rear-facing camera
    CSLSensorYawInvalid = 360   ///< Beginning of invalid range of values
} CSLSensorYaw;

/// @brief  Camera pitch definitions
typedef enum
{
    CSLSensorPitchLevel     = 0,    ///< Pitch of front-facing or rear-facing camera
    CSLSensorPitchInvalid   = 360   ///< Beginning of invalid range of values
} CSLSensorPitch;

/// @brief  Sensor Power Sequence type
typedef enum
{
    CSLSensorSequenceMCLK = 0,              ///< Clock
    CSLSensorSequenceVANA,                  ///< Analog voltage
    CSLSensorSequenceVDIG,                  ///< Digital voltage
    CSLSensorSequenceVIO,                   ///< I/O voltage
    CSLSensorSequenceVAF,                   ///< AF voltage
    CSLSensorSequenceVAFPWDN,               ///< AF power down
    CSLSensorSequenceCustomReg1,            ///< Customer Reg1
    CSLSensorSequenceCustomReg2,            ///< Customer Reg2
    CSLSensorSequenceReset,                 ///< Reset
    CSLSensorSequenceStandby,               ///< Standby
    CSLSensorSequenceCustomGPIO1,           ///< GPIO1
    CSLSensorSequenceCustomGPIO2,           ///< GPIO2
    CSLSensorSequenceTypeMax,               ///< MAX
} CSLSensorPowerSequenceType;

/// @brief TPG Packet Opcodes
typedef enum
{
    CSLTPGPacketOpcodeInvalid = 0,   ///< Invalid Packet
    CSLTPGPacketOpcodeInitialConfig, ///< Inital Config
    CSLTPGPacketOpcodeNOP,           ///< NOP packet
    CSLTPGPacketOpcodeUpdate,        ///< Update packet
    CSLTPGPacketOpcodeMax,           ///< Max value
} CSLTPGPacketOpcode;

/// @brief TPG Cmd Type
typedef enum {
    CSLTpgCmdTypeInvalid = 0,         ///< Invalid
    CSLTpgCmdTypeGlobalConfig,        ///< GlobalConfig
    CSLTpgCmdTypeStreamConfig,        ///< StreamConfig
    CSLTpgCmdTypeIlluminationConfig,  ///< IlluminationConfig
    CSLTpgCmdTypeSettingsConfig,      ///< SettingsConfig
    CSLTpgCmdTypeMax                  ///< Max
} CSLTpgCmdType;

/// @brief TPG PhyType
typedef enum {
    CSLTpgPhyTypeInvalid = 0,        ///< Invalid
    CSLTpgPhyTypeDphy,               ///< Dphy
    CSLTpgPhyTypeCphy,               ///< Cphy
    CSLTpgPhyTypeMax                 ///< Max
} CSLTpgPhyType;

/// @brief TPG Data Interleaving Format types
typedef enum {
    CSLTpgInterleavingFormatInvalid = 0,          ///< Invalid
    CSLTpgInterleavingFormatFrameInterleaving,    ///< FrameInterleave
    CSLTpgInterleavingFormatLineInterleaving,     ///< LineInterleave
    CSLTpgInterleavingFormatSHDRInterleaving,     ///< SHDRInterleave
    CSLTpgInterleavingFormatSparsePDInterleaving, ///< Sparse PD
    CSLTpgInterleavingFormatMax                   ///< Max
} CSLTpgInterleavingFormat;

/// @brief TPG Shutter type
typedef enum {
    CSLTpgShutterTypeInvalid = 0,                ///< Invalid
    CSLTpgShutturTypeGlobal,                     ///< Global
    CSLTpgShutturTypeRolling,                    ///< Rolling
    CSLTpgShutturTypeMax                         ///< Max
} CSLTpgShutturType;

/// @brief TPG Pattern Type
typedef enum {
    CSLTpgPatternInvalid = 0,                   ///< Invalid
    CSLTpgPatternRealImage,                     ///< RealImage
    CSLTpgPatternRandomPixl,                    ///< RandomPixel
    CSLTpgPatternRandomIncrementingPixel,       ///< RandomIncrementingPixel
    CSLTpgPatternColorBar,                      ///< ColorBar
    CSLTpgPatternAlternating55AA,               ///< Alternative55AA
    CSLTpgPatternAlternatingUserDefined,        ///< UserDefined
    CSLTpgPatternMax                            ///< Max
} CSLTpgPattern;

/// @brief TPG Colorbar Mode
typedef enum {
    CSLTpgColorBarModeInvalid = 0,             ///< Invalid
    CSLTpgColorBarModeNormal,                  ///< Normal
    CSLTpgColorBarModeSplit,                   ///< Split
    CSLTpgColorBarModeRotating,                ///< Rotating
    CSLTpgColorBarModeMax,                     ///< Max
} CSLTpgColorBarMode;

/// @brief TPG Stream Type
typedef enum {
    CSLTpgStreamTypeInvalid = 0,              ///< Invalid
    CSLTpgStreamTypeImage,                    ///< Image
    CSLTpgStreamTypePdaf,                     ///< Pdaf
    CSLTpgStreamTypeMeta,                     ///< Meta
    CSLTpgStreamTypeMax,                      ///< Max
} CSLTpgStreamType;

/// @brief TPG Color filter arrangement
typedef enum {
    CSLTpgCfaArrangementInvalid = 0,          ///< Invalid
    CSLTpgCfaArrangementBGGR,                 ///< BGGR
    CSLTpgCfaArrangementGBRG,                 ///< GBRG
    CSLTpgCfaArrangementGRBG,                 ///< GRBG
    CSLTpgCfaArrangementRGGB,                 ///< RGGB
    CSLTpgCfaArrangementMax                   ///< Max
} CSLTpgCfaArrangement;

/// @brief TPG Image Format
typedef enum {
    CSLTpgImageFormatInvalid = 0,            ///< Invalid
    CSLTpgImageFormatBayer,                  ///< Bayer
    CSLTpgImageFormatQcfa,                   ///< QCFA
    CSLTpgImageFormatYuv,                    ///< Yuv
    CSLTpgImageFormatJpeg,                   ///< Jpeg
    CSLTpgImageFormatMax                     ///< Max
} CSLTpgImageFormat;

/// @brief CSIPHY CDR Tolerance Type
typedef enum {
    CSLCSIPHYCDRInvalidTolerance,   ///< CDR Invalid Tolerance Type
    CSLCSIPHYCDRAddTolerance,       ///< CDR Add Tolerance
    CSLCSIPHYCDRSubTolerance        ///< CDR Subtract Tolerance
} CSLCSIPHYCDRToleranceType;

/// @brief Used to send sensor mode index to KMD
typedef struct
{
    UINT16 resIndex;                          ///< resolution index
    UINT32 FPS;                               ///< FPS of the resolution mode
    UINT32 imageStreamWidth;                  ///< image stream width of current resolution mode
    UINT32 imageStreamHeight;                 ///< image stream height of current resolution mode
    CHAR   pCapabilities[MaxCapabilitySize];  ///< sensor mode capability, num exposures, and PDAF type
    UINT32 numValidParams;                    ///< Number of valid parameters
    UINT32 validParamMask;                    ///< mask for reserved field
    UINT16 params[5];                         ///< reserved Params
} CAMX_PACKED CSLSensorResolutionInfo;

/// @brief TPG CFAPixelType
typedef enum {
    CSLTpgPixelTypeInvalid = 0,              ///< Invalid
    CSLTpgPixelTypeRed = 0,                  ///< RED
    CSLTpgPixelTypeGreen,                    ///< Green
    CSLTpgPixelTypeBlue,                     ///< Blue
    CSLTpgPixelTypeIR,                       ///< IR
    CSLTpgPixelTypeMONO,                     ///< MONO
} CSLTpgPixelType;

/// @brief TPG CFAExposureType
typedef enum {
    CSLTpgExposureTypeInvalid = 0,           ///< Invalid
    CSLTpgExposureTypeLong,                  ///< Long
    CSLTpgExposureTypeMiddle,                ///< Middle
    CSLTpgExposureTypeShor,                  ///< Short
} CSLTpgExposureType;


/// @brief CSL XCFA Type
typedef enum
{
    Bayer               = 0,  ///< Bayer
    QuadCFA             = 1,  ///< Quad CFA
    ThreeXThreeCFA      = 2,  ///< 3x3 CFA
    FourXFourCFA        = 3,  ///< 4x4 CFA
    RGBIR               = 4,  ///< RGBIR
    RGBWC               = 5,  ///< RGBIR
    RGBWK               = 6,  ///< RGBWK
    UnconventionalBayer = 7   ///< Unconventional Bayer Pattern
} CSLXcfaType;

/// @brief  Capabilities info for sensor
typedef struct
{
    UINT32  slotInfo;       ///< Informs about the slotId or cell Index
    UINT32  secureCamera;   ///< Informs whether the camera is in secure/Non-secure mode
    UINT32  pitch;          ///< Pitch
    UINT32  roll;           ///< Informs about the how sensor is mounted
    UINT32  yaw;            ///< Yaw
    UINT32  actuatorSlotId; ///< Actuator slot id which connected to sensor
    UINT32  EEPROMSlotId;   ///< EEPROM slot id which connected to sensor
    UINT32  OISSlotId;      ///< OIS slot id which connected to sensor
    UINT32  flashSlotId;    ///< Flash slot id which connected to sensor
    UINT32  CSIPHYSlotId;   ///< CSIPHY slot id which connected to sensor
} CAMX_PACKED CSLSensorCapability;

/// @brief  Capabilities info CSIPHY
typedef struct {
    UINT32  slotInfo;   ///< Informs about the slotId or cell Index
    UINT32  version;    ///< CSIPHY version
    UINT32  clockLane;  ///< Of the 5 lanes, informs lane configured as clock lane
    UINT32  reserved;   ///< Reserved and can be used to check if phy is aggregated
}  CAMX_PACKED CSLCSIPHYCapability;

/// @brief  Capabilities info TPG
typedef struct {
    UINT32  slotInfo;       ///< Informs about the slotId or cell Index
    UINT32  version;        ///< TPG version
    UINT32  secureCamera;   ///< Informs whether the camera is in secure/Non-secure mode
    UINT32  CSIPHYSlotId;   ///< CSIPHY slot id which connected to sensor
    UINT32  reserved[2];    ///< Reserved
}  CAMX_PACKED CSLTPGCapability;

/// @brief  Capabilities info EEPROM
typedef struct {
    UINT32  slotInfo;      ///< Informs about the slotId or cell Index
    UINT16  kernelProbe;   ///< Is this Module probed in Kernel
    UINT16  multiModule;   ///< Multimodule support available
}  CAMX_PACKED CSLEEPROMCapability;

/// @brief  Capabilities info Actuator
typedef struct {
    UINT32  slotInfo; ///< Informs about the slotId or cell Index
    UINT32  reserved; ///< Reserved
} CAMX_PACKED CSLActuatorCapability;

/// @brief  Capabilities info OIS
typedef struct {
    UINT32  slotInfo; ///< Informs about the slotId or cell Index
    UINT16  reserved; ///< Reserved
} CAMX_PACKED CSLOISCapability;


/// @brief  Acquire Device info CSIPHY
typedef struct {
    UINT32  comboMode;         ///< Informs about the phy combo mode
    UINT16  cphyDphyComboMode; ///< Info regarding CPHY-DPHY combo_mode being enable / disable
    UINT8   CSIPHY3Phase;      ///< Details on 3Phase / 2Phase operation
    UINT8   sharedMode;        ///< Informs about the phy shared mode
} CAMX_PACKED CSLCSIPHYAcquireDevice;


/// @brief  Acquire Device info TPG
typedef struct {
    UINT32    hSessionHandle;  ///< Session handle
    UINT32    hDeviceHandle;   ///< Device handle
    UINT32    handleType;      ///< Handle Type
    UINT32    reserved;        ///< Reserved
    UINT64    hInfoHandle;     ///< infoHandle
} CAMX_PACKED CSLTPGAcquireDevice;

/// @brief  contains OIS firmware related
typedef struct {
    UINT32  prog;        ///< Informs about fw prog
    UINT32  coeff;       ///< Informs about fw coefficent
    UINT32  pheripheral; ///< Informs about fw pheripheral
    UINT32  memory;      ///< Informs about fw memory
} CAMX_PACKED CSLOISopcode;

/// @brief  contains OIS slave I2C related info
typedef struct
{
    UINT32       slaveAddr;                 ///< Slave address
    UINT8        I2CFrequencyMode;          ///< Lower 4-bits used for I2C freq mode
    UINT8        cmdType;                   ///< Command type
    UINT8        OISFwFlag;                 ///< is true if firmware is supported
    UINT8        isOISCalib;                ///< is ture if calibration data available
    CHAR         OISName[MaxOISNameSize];   ///< OIS Name
    CSLOISopcode opcode;                    ///< opcode
} CAMX_PACKED CSLOISI2CInfo;

/// @brief  contains OIS FW parameter
typedef struct
{
    CHAR        fwName[MaxOISNameSize];     ///< FW file name
    UINT32      fwStartPos;                 ///< FW data's start byte in FW file
    UINT32      fwSize;                     ///< FW size
    UINT32      fwLenPerWrite;              ///< Max FW download size in every write
    UINT8       addrType;                   ///< Slave address type
    UINT8       dataType;                   ///< Slave data type
    UINT8       operation;                  ///< operation
    UINT8       reserved;                   ///< reserved for 32-bit alignment
    UINT32      delayUs;                    ///< delay USecond between every write
    UINT32      regAddr;                    ///< start register address to write
    UINT32      fwInitSize;                 ///< FW init setting size in byte
    UINT32      fwFinalizeSize;             ///< FW finalize setting size in byte
} CAMX_PACKED CSLOISFWParam;

/// @brief  contains OIS FW info
typedef struct
{
    UINT32              version;                ///< version
    UINT8               reserved;               ///< reserved
    UINT8               cmdType;                ///< Command type
    UINT8               fwCount;                ///< FW count
    UINT8               endianness;             ///< endianness combo:
                                                ///< bit[7:4] for endian type of input parameters to ois,
                                                ///< espesially for QTime writing
                                                ///< bit[3:0] for FW data's endianness
    CSLOISFWParam       fwParam[MaxFWCount];    ///< fw parameters
    UINT32              numValidParams;         ///< Number of valid params
    UINT32              paramMask;              ///< Mask to indicate fields in params
    UINT32              params[4];              ///< Additional Params
} CAMX_PACKED CSLOISFWInfo;

/// @brief  contains slave I2C related info
typedef struct
{
    UINT32  slaveAddr;          ///< Slave address
    UINT8   I2CFrequencyMode;   ///< Lower 4-bits used for I2C freq mode
    UINT8   cmdType;            ///< Command type
    UINT16  reserved;           ///< Reserved
} CAMX_PACKED CSLSensorI2CInfo;

/// @brief  Sensor slave info for probing
typedef struct
{
    UINT8   dataType;       ///< Slave data type
    UINT8   addrType;       ///< Slave address type
    UINT8   opcode;         ///< Opcode
    UINT8   cmdType;        ///< Command type
    UINT32  regAddr;        ///< Sensor ID register address
    UINT32  expectedData;   ///< Data expected at slave address
    UINT32  dataMask;       ///< Data mask if only few bits are valid
    UINT16  cameraId;       ///< Informs the slot to which camera needs to be probed
    UINT16  pipelineDelay;  ///< pipeline delay
} CAMX_PACKED CSLSensorProbeCmd;

/// @brief  Sensor slave info for probing - version 2
typedef struct
{
    UINT8   dataType;                      ///< Slave data type
    UINT8   addrType;                      ///< Slave address type
    UINT8   opcode;                        ///< Opcode
    UINT8   cmdType;                       ///< Command type
    UINT32  regAddr;                       ///< Sensor ID register address
    UINT32  expectedData;                  ///< Data expected at slave address
    UINT32  dataMask;                      ///< Data mask if only few bits are valid
    UINT16  cameraId;                      ///< Informs the slot to which camera needs to be probed
    UINT16  pipelineDelay;                 ///< pipeline delay
    UINT32  logicalCameraId;               ///< Logical Camera Id
    CHAR    sensorName[MaxSensorNameSize]; ///< Sensor Name
    UINT32  reserved[4];                   ///< Reserved
} CAMX_PACKED CSLSensorProbeV2Cmd;


/// @brief  Power setting info
typedef struct
{
    UINT16  powerSequenceType;  ///< Type of power sequence
    UINT16  reserved;           ///< Reserved
    UINT32  configValLow;       ///< Lower 32 bit value configuration value
    UINT32  configValHigh;      ///< Higher 32 bit value configuration value
} CAMX_PACKED CSLSensorPowerSetting;

/// @brief  Power settings command
typedef struct
{
    UINT32                  count;              ///< Number of power settings in powerSettings
    UINT8                   reserved;           ///< Reserved
    UINT8                   cmdType;            ///< Command type
    UINT16                  reserved1;          ///< Reserved
    CSLSensorPowerSetting   powerSettings[1];   ///< Extended data area containing power settings
} CAMX_PACKED CSLSensorPowerCmd;

/// @brief  Header of READ/WRITE I2C command
typedef struct
{
    UINT32  count;      ///< Number of registers, data, or reg-data pairs
    UINT8   opcode;     ///< Opcode
    UINT8   cmdType;    ///< Command type
    UINT8   dataType;   ///< I2C address type
    UINT8   addrType;   ///< I2C data type
} CAMX_PACKED CSLSensorI2CHeader;

/// @brief  Payload for I2C random write
typedef struct
{
    UINT32  reg;    ///< Register address
    UINT32  val;    ///< Register data
    UINT32  mask;   ///< Register mask
} CAMX_PACKED CSLSensorI2CRegValPair;

/// @brief  I2C random write command
typedef struct
{
    CSLSensorI2CHeader      header;         ///< I2C header
    CSLSensorI2CRegValPair  regValPairs[1]; ///< Array of address/data pairs
} CAMX_PACKED CSLSensorI2CRandomWriteCmd;

/// @brief  Payload for I2C burst/sequential write
typedef struct
{
    UINT32  val;      ///< Register data
    UINT32  reserved; ///< Reserved field
} CAMX_PACKED CSLSensorI2CVal;

/// @brief  I2C burst/sequential write command
typedef struct
{
    CSLSensorI2CHeader  header;     ///< I2C header
    UINT32              reg;        ///< Register base address
    CSLSensorI2CVal     data[1];    ///< Array of values to be written
} CAMX_PACKED CSLSensorI2CBurstWriteCmd;

/// @brief  I2C random read command
typedef struct
{
    CSLSensorI2CHeader  header;     ///< I2C header
    UINT32              regs[1];    ///< Array of register addresses to be read
} CAMX_PACKED CSLSensorI2CRandomReadCmd;

/// @brief  I2C continuous continuous read command
typedef struct
{
    CSLSensorI2CHeader  header; ///< I2C header
    UINT32              reg;    ///< Register base address to be read
} CAMX_PACKED CSLSensorI2CContinuousReadCmd;


/// @brief  I2C continuous continuous read command
typedef struct
{
    CSLSensorI2CHeader  header;     ///< I2C header
    UINT16              reserved;   ///< Reserved
    UINT8               opcode;     ///< Opcode
    UINT8               cmdType;    ///< Command type
    UINT32              lock;       ///< Lock
} CAMX_PACKED CSLSensorI2CSequentialXferCmd;

/// @brief  Conditional wait command
typedef struct
{
    UINT8   dataType;               ///< Data type
    UINT8   addrType;               ///< Address type
    UINT16  reserved;               ///< Reserved
    UINT8   opcode;                 ///< Opcode
    UINT8   cmdType;                ///< Command type
    UINT16  timeoutMilliseconds;    ///< Timeout in milli-seconds
    UINT32  reg;                    ///< Register address
    UINT32  val;                    ///< Value
    UINT32  mask;                   ///< Mask
} CAMX_PACKED CSLSensorWaitConditionalCmd;

/// @brief  Unconditional wait command
typedef struct
{
    UINT16  delayMicroseconds;  ///< Delay in micro-seconds
    UINT16  reserved;           ///< reserved
    UINT8   opcode;             ///< Opcode
    UINT8   cmdType;            ///< Command type
    UINT16  reserved1;          ///< reserved
} CAMX_PACKED CSLSensorWaitCmd;

/// @brief CSIPHY CDR Sweep Parameters
typedef struct
{
    UINT32                    cdrTolerance;      ///< CDR Tolerance
    CSLCSIPHYCDRToleranceType cdrToleranceType;  ///< CDR Tolerance Type indicating tolarance needs to be added/substracted etc.
    UINT32                    cdrLaneValue;      ///< CDR Lane Value
    UINT32                    numValidParams;    ///< Number of valid parameters
    UINT32                    validParamsMask;   ///< Valid parameters mask
    UINT32                    params[3];         ///< parameters
}CAMX_PACKED CSLCSIPHYCDRSweepParameters;

/// @brief CSIPHY Auxiliary settings parameter
typedef struct
{
    UINT64  datarateAuxMask;          ///< Auxilary datarate mask
    UINT32  numValidParams;           ///< Number of valid parameters
    UINT32  validParamsMask;          ///< Valid parameters mask
    UINT32  params[3];                ///< parameters
}CAMX_PACKED CSLCSIPHYAuxMemSettingsParams;

/// @brief CSIPHY configuration info
typedef struct
{
    UINT16  reserved;               ///< Reserved
    UINT16  laneAssign;             ///< Lane sensor will be using
    UINT16  mipiFlags;              ///< Mipi flags mask
    UINT8   laneCount;              ///< Total number of lanes
    UINT8   secureMode;             ///< secure / non-secure mode
    UINT64  settleTimeMilliseconds; ///< Settling time in ms
    UINT64  dataRate;               ///< Data rate
} CAMX_PACKED CSLSensorCSIPHYInfo;

/// @brief CSIPHY configuration info v2
typedef struct
{
    UINT16  version;                ///< Version
    UINT16  laneAssign;             ///< Lane sensor will be using
    UINT16  mipiFlags;              ///< Mipi flags mask
    UINT8   laneCount;              ///< Total number of lanes
    UINT8   secureMode;             ///< secure / non-secure mode
    UINT64  settleTimeMilliseconds; ///< Settling time in ms
    UINT64  dataRate;               ///< Data rate
    UINT32  channelType;            ///< Channel type
    UINT32  numValidParams;         ///< Number of valid parameters
    UINT32  paramMask;              ///< Parameters mask
    UINT32  params[5];              ///< parameters
} CAMX_PACKED CSLSensorCSIPHYInfoV2;

/// @brief Maximum sensor flash trigger
static const UINT8 CSLFlashMaxLEDTrigger = 2;

/// @brief Flash init command info
typedef struct {
    UINT32 flashType;               ///< Flash type
    UINT8  reserved;                ///< Reserved
    UINT8  cmdType;                 ///< Cmd type
    UINT16 reserved1;               ///< reserved
} CAMX_PACKED CSLFlashInfoCmd;


/// @brief TPG Cmd Header
typedef struct {
    UINT32 cmdType;                  ///< Command Type
    SIZE_T size;                      ///< size
    UINT32 cmdVersion;               ///< version of command payload
} CAMX_PACKED CSLTPGCmdHeader;

/// @brief TPG CFAPixelCoordinate
typedef struct{
    UINT32              xCoordinate;                ///< XCoordinate
    UINT32              yCoordinate;                ///< Ycoordinate
    UINT32              exposureType;               ///< Exposure Type
    UINT32              pixelType;                  ///< Pixel Type
} CAMX_PACKED CSLTpgCfaPixelCoordinate;

/// @brief TPG CFAInformation
typedef struct{
    UINT32                     numberOfPixelsPerColor;   ///< Nuber of Pixel
                                                         ///< per color
    UINT32                     patternWidth;             ///< Pattern Width
    UINT32                     patternHeight;            ///< Pattern Height
    UINT32                     pixelCoordinateCount;     ///< Pixel Coordinate Count
    CSLTpgCfaPixelCoordinate   pixelCoordinate[64];      ///< Pixel Coordinate
} CAMX_PACKED CSLTpgCfaInformation;

/// @brief TPG Global ConfigCmd
typedef struct {
    CSLTPGCmdHeader           header;                  ///< TPG common header
                                                       ///< for all packets
    CSLTpgPhyType             phyType;                 ///< Type of phy used
    UINT8                     laneCount;               ///< Number of lanes active
    CSLTpgInterleavingFormat  interleavingFormat;      ///< TPG data interleaving
                                                       ///< format
    UINT8                     phyMode;                 ///< Phy combo Mode
    CSLTpgShutturType         shutterType;             ///< Shutter type
    UINT32                    mode;                    ///< Tpg Mode Flags
    UINT32                    hbi;                     ///< Horizontal blanking pixels
    UINT32                    vbi;                     ///< Vertical   blanking lines
    UINT32                    skipPattern;             ///< TPG Skip pattern
    UINT64                    tpgClock;                ///< TPG clock required
    UINT32                    reserved[4];             ///< for future use
} CAMX_PACKED CSLTPGGlobalConfigCmd;


/// @brief TPG Stream Dimension
typedef struct {
    UINT32 left;                              ///< Left
    UINT32 top;                               ///< Top
    UINT32 width;                             ///< Width
    UINT32 height;                            ///< Height
} CAMX_PACKED CSLTpgStreamDimesion;


/// @brief Stream Configuration Command
typedef struct {
    CSLTPGCmdHeader      header;            ///< Header
    CSLTpgPattern        patternType;       ///< Tpg pattern Type
    CSLTpgColorBarMode   cbMode;            ///< ColorBar Mode
    UINT32               frameCount;        ///< FrameCount
    CSLTpgStreamType     streamType;        ///< StreamType
    CSLTpgStreamDimesion streamDimension;   ///< Dimension
    UINT8                pixelDepth;        ///< Pixel Depth
    CSLTpgCfaArrangement cfaArrangement;    ///< ColorFilter Arrangement
    CSLTpgImageFormat    outputFormat;      ///< OutputFormat
    UINT32 hbi;                             ///< Horizontal Blanking
    UINT32 vbi;                             ///< Vertical Blanking
    UINT16 vc;                              ///< Virtual Channel
    UINT16 dt;                              ///< Data Type
    UINT32 skipPattern;                     ///< skip pattern
    UINT32 rotatePeriod;                    ///< number of frames before rotating color bar
    UINT32 xcfa_debug;                      ///< for hardcoding xcfa value
    UINT32 shdr_line_offset0;               ///< shdr line offset0
    UINT32 shdr_line_offset1;               ///< shdr line offset1
    UINT32 reserved[4];                     ///< for future use
} CAMX_PACKED CSLTPGStreamConfigCmd;

/// @brief Stream Configuration Command v2
typedef struct {
    CSLTPGCmdHeader      header;            ///< Header
    UINT32               patternType;       ///< Tpg pattern Type
    UINT32               cbMode;            ///< ColorBar Mode
    UINT32               frameCount;        ///< FrameCount
    UINT32               streamType;        ///< StreamType
    CSLTpgStreamDimesion streamDimension;   ///< Dimension
    UINT32               pixelDepth;        ///< Pixel Depth
    UINT32               cfaArrangement;    ///< ColorFilter Arrangement
    UINT32               outputFormat;      ///< OutputFormat
    UINT32               hbi;               ///< Horizontal Blanking
    UINT32               vbi;               ///< Vertical Blanking
    UINT16               vc;                ///< Virtual Channel
    UINT16               dt;                ///< Data Type
    UINT32               skipPattern;       ///< skip pattern
    UINT32               rotatePeriod;      ///< number of frames before rotating color bar
    UINT32               xcfa_debug;        ///< for hardcoding xcfa value
    UINT32               shdr_line_offset0; ///< shdr line offset0
    UINT32               shdr_line_offset1; ///< shdr line offset1
    UINT32               cfaInfoExist;      ///< CFA Info Exist
    CSLTpgCfaInformation cfaInfo;           ///< CFA Information
    UINT32               xcfaType;          ///< xcfa Type
    UINT32               reserved[5];       ///< for future use
} CAMX_PACKED CSLTPGStreamConfigCmdV3;


/// @brief Illumination Control cmd
typedef struct {
    CSLTPGCmdHeader header;                  ///< Header
    UINT16 vc;                               ///< Virtual Channel
    UINT16 dt;                               ///< Data Type
    UINT32 exposureShort;                   ///< Exposure Short
    UINT32 exposureMid;                     ///< Exposure Mid
    UINT32 exposureLong;                    ///< Exposure Long
    UINT16 rGain;                           ///< R channel Gain
    UINT16 gGain;                           ///< G channel Gain
    UINT16 bGain;                           ///< B channel Gain
    UINT32 reserved[4];                      ///< for future use
} CAMX_PACKED CSLTPGIlluminationConfigCmd;

/// @brief TPGSetting
typedef struct {
    UINT32 regOffset;                        ///< register Offset
    UINT32 regValue;                         ///< register Value
    UINT32 operation;                        ///< operation
    UINT32 delayUs;                          ///< Delay in micro seconds
    UINT32 reserved[4];                      ///< for future use
} CAMX_PACKED CSLTPGSetting;

/// @brief TPGSettingsArray cmd
typedef struct {
    CSLTPGCmdHeader header;                  ///< Header
    UINT32 settingsArrayOffset;              ///< offset of settings Array
    UINT32 settingsArraySize;                ///< size of settings array
    UINT32 activeCount;                      ///< size of settings in curent mode
    UINT32 validParamMask;                   ///< valid_param_mask
    UINT32 params[4];                        ///< Reserved Field
} CAMX_PACKED CSLTPGSettingsConfigCmd;

/// @brief Flash fire cmd
typedef struct {
    UINT32 count;                                       ///< Number of flash module
    UINT8  opcode;                                      ///< Opcode
    UINT8  cmdType;                                     ///< Cmd type
    UINT16 reserved;                                    ///< reserved
    UINT32 currentMilliampere[CSLFlashMaxLEDTrigger];   ///< Array of current for each flash module
    UINT64 flashDuration;                               ///< Precision flash duration(in nanosecs)
    UINT64 flashOnWaitTime;                             ///< Precision flash on wait time(in nanosecs)
} CAMX_PACKED CSLFlashFireCmd;

/// @brief Flash RER cmd
typedef struct {
    UINT32 count;                    ///< Number of flash module
    UINT8  opcode;                   ///< Opcode
    UINT8  cmdType;                  ///< Cmd type
    UINT16 numberOfIteration;        ///< Number of iteration
    UINT32 flashOnDelayMillisecond;  ///< Flash on delay
    UINT32 flashOffDelayMillisecond; ///< Flash off delay
    UINT32 currentMilliampere[CSLFlashMaxLEDTrigger];    ///< Array of current for each flash module
}CAMX_PACKED CSLFlashRERCmd;

// @brief Flash query current cmd
typedef struct {
    UINT32 reserved;                 ///< Reserved
    UINT8  opcode;                   ///< Opcode
    UINT8  cmdType;                  ///< Cmd type
    UINT32 currentMilliampere;       ///< Current
    UINT16 reserved1;                ///< reserved
} CAMX_PACKED CSLFlashQueryCurrentCmd;

/// @brief Flash query capability info cmd
typedef struct {
    UINT32 slotInfo;                                ///< Slot info
    UINT32 maxFlashCurrent[CSLFlashMaxLEDTrigger];  ///< Maximum supported current for flash
    UINT32 maxFlashDuration[CSLFlashMaxLEDTrigger]; ///< Maximum flash turn on duration
    UINT32 maxTorchCurrent[CSLFlashMaxLEDTrigger];  ///< Maximum supported current for torch
    UINT32 version;                                 ///< Version
    UINT32 flashType;                               ///< Flash Type (PMIC/I2C/GPIO)
    UINT32 numValidParams;                          ///< Number of Valid Params
    UINT32 paramMask;                               ///< Param Mask
    UINT32 params[3];                               ///< Future Param reference
} CAMX_PACKED CSLFlashQueryCapability;

/// @brief FlashType
enum class FlashType
{
    GPIO,                                           ///< GPIO Flash Type
    I2C,                                            ///< I2C Flash Type
    PMIC,                                           ///< PMIC Flash Type
};

// End of packed definitions
CAMX_END_PACKED

#ifdef __cplusplus
}
#endif // __cplusplus

#endif // CAMXCSLSENSORDEFS_H
