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

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  chipdlibcommon.h
/// @brief Phase Detection Library interface definitions
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef CHIPDLIBCOMMON_H
#define CHIPDLIBCOMMON_H

#include "camxcdktypes.h"
#include "chistatsinterfacedefs.h"
#include "chistatspropertydefines.h"
#include "chivendortag.h"

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

// Data structures that are exposed to OEM must be packed to have the expected layout.
#pragma pack(push, CDK_PACK_SIZE)

/** @addtogroup chi_pdlib_macros
@{ */

static const UINT16 PDLibMaxWindowCount            = 200;   ///< Fixed maximum number of PD windows.
static const UINT16 PDLibMaxPixelCount             = 256;   ///< Maximum number of PD pixels in a block.
static const UINT8  PDLibMaxBlockHeight            = 64;    ///< Maximum height of the PD block.
static const UINT16 PDLibAdaptiveDataSize          = 960;   ///< Size of the adaptive K data.
static const UINT16 PDLibGainMapLUTSize            = 221;   ///< Size of the gain map LUT table (17x13).
static const UINT16 PDLibGainMapLUTSizeV31         = 77;   ///< Size of the gain map LUT table (11x7).
static const UINT16 PDLibMaxLeftOrRightPDPixels    = 128;   ///< Maximum number of left/right PD pixels in a sparse PD block.
static const UINT16 PDLibMaxPDPixelRows            = 16;    ///< Maximum number of PD pixel rows in each block.
static const UINT16 PDLibResamplerInstructionSize  = 32;    ///< Number of instructions provided for the resampler.
static const UINT16 PDLibResamplerInputCount       = 4;     ///< Number of input pixels for a resampler instruction.
static const UINT16 PDLibLCRColorComponentCount    = 16;    ///< Number of color component in the Bayer pattern for Left
                                                            ///  Center Right (LCR) PD pixels.
static const UINT16 PDLibLCRMaskCount              = 2;     ///< Number of LCR hardware masks to be used.
static const UINT16 PDLibMaxPixelsInBlock          = 4096;  ///< In the PD Library, the extractor specifies whether a pixel
                                                            ///  in a block is a PD pixel. Maximum: [64][64].

static const UINT8  PDLibBufferArraySize           = 18;    ///< Size of the PDLibStats array.

static const UINT8  PDLibMaxPolyphaseNumPixel   = 8;    ///< Maximum number of PD pixels in a left/right polyphase map.
static const UINT16 PDLibMaxHPSNumPixel         = 64;   ///< Maximum number of PD pixels input to a horizontal separator.
static const UINT16 PDLibMaxVPSNumPixel         = 64;   ///< Maximum number of PD pixels input to a vertical separator.
static const UINT8  PDLibHorizontalROINUM       = 48;   ///< Maximum height of a PD block.
static const UINT8  PDLibVerticalROINUM         = 48;   ///< Maximum height of a PD block.
static const UINT8  PDLibV31HorizontalROINUM    = 32;   ///< Maximum columns in SAD Grid for PDHwV31.
static const UINT8  PDLibV31VerticalROINUM      = 24;   ///< Maximum rows in SAD Grid for PDHwV31.
static const UINT8  PDLibV31MaxSADPhases        = 48;   ///< Maximum SAD search range for PDHwV31.
static const UINT8  PDLibLCRPixelSkipArraySize  = 4;    ///< Maximum pixel skip for a PD channel.
static const UINT8  PDLibMaxILMask              = 16;   ///< Maximum interleave mask for left and right PD channels.

static const UINT8  PDLibMaxLCRLineMask     = 2;    ///< Maximum number of LCR line mask registers.
static const UINT8  PDLibMaxLCRFlushMask    = 2;    ///< Maximum number of LCR flush mask registers.
static const UINT8  PDLibMaxLCRCompMask     = 2;    ///< Maximum number of LCR component mask registers.
static const UINT16 PDLibMaxLCRCompShift    = 64;   ///< Maximum number of LCR component shift mask registers.
static const UINT8  FIRCoefficientACount    = 5;    ///< Number of a coefficients in FRI filter.
static const UINT8  IIRCoefficientACount    = 2;    ///< Number of a coefficients in IIR filter.
static const UINT8  IIRCoefficientBCount    = 3;    ///< Number of b coefficients in IIR filter.

static const UINT8  MAXSEAMLESSMODECOUNT    = 10;    ///< Maximum number of seamless PD hardware configuration caches.

static const UINT8  PDLibMultiRoiMaxROICount    = 5;    ///< Maximum Number of ROI

typedef struct PDHwConfig PDHwConfig;

/** @} */ /* end_addtogroup chi_pdlib_macros */

/** @addtogroup chi_pdlib_datatypes
@{ */

/// @brief Coordinates for a peripheral processing window.
typedef enum
{
    PDLibPeripheralWindowTopLeft = 0,      ///< Top left corner of the window is selected.
    PDLibPeripheralWindowTopCenter,        ///< Top center of the window is selected.
    PDLibPeripheralWindowTopRight,         ///< Top right corner of the window is selected.
    PDLibPeripheralWindowLeft,             ///< Left corner of the window is selected.
    PDLibPeripheralWindowRight,            ///< Right corner of the window is selected.
    PDLibPeripheralWindowBottomLeft,       ///< Bottom left corner of the window is selected.
    PDLibPeripheralWindowBottomCenter,     ///< Bottom center of the window is selected.
    PDLibPeripheralWindowBottomRight,      ///< Bottom right corner of the window is selected.
    PDLibPeripheralWindowMax               ///< Indicates the last item in the definition.
} PDLibPeripheralWindow;

/// @brief Defines the results of PD Library processing.
typedef enum
{
    PDLibResultInital,         ///< Initial value; the buffer not processed.
    PDLibResultCenter,         ///< Center window is selected.
    PDLibResultPeripheral      ///< Peripheral window is selected
} PDLibProcessingResult;

/// @brief Defines the Bayer patterns streamed by the sensor.
typedef enum
{
    PDLibBayerBGGR,
    PDLibBayerGBRG,
    PDLibBayerGRBG,
    PDLibBayerRGGB
} PDLibSensorBayerPattern;

/// @brief Defines the function status return values.
typedef enum
{
    PDLibSuccess,
    PDLibMemoryError,
    PDLibParamError,
    PDLibRunningError,
    PDLibErrorMax = 1023
} PDLibReturnStatus;

/// @brief Defines the shielded pixel pattern for the PD Library.
typedef enum
{
    PDLibLeftDiodePixel        = 1,   ///< Shielded left pixel for dual diode and 2x1 sensors.
    PDLibRightDiodePixel       = 0,   ///< Shielded right pixel for dual diode and 2x1 sensors.

    /// Added change for Vertical / 2x2 sensors
    PDLibUpDiodePixel          = 2,   ///< Shielded up pixel for 2x2 sensors.
    PDLibDownDiodePixel        = 3,   ///< Shielded down pixel for 2x2 sensors.

    PDLibTopLeftDiodePixel     = 4,   ///< Top-left diode for 2x2 sensors.
    PDLibTopRightDiodePixel    = 5,   ///< Top-right diode for 2x2 sensors.
    PDLibBottomLeftDiodePixel  = 6,   ///< Bottom-left diode for 2x2 sensors.
    PDLibBottomRightDiodePixel = 7,   ///< Bottom-right diode for 2x2 sensors.

    PDLibLeftShieldedPixel     = 0,    ///< Metal-shielded left pixel.
    PDLibRightShieldedPixel    = 1,    ///< Metal-shielded right pixel.

    /// Added change for Vertical / 2x2 sensors
    PDLibUpShieldedPixel       = 3,    ///< Metal-shielded up pixel.
    PDLibDownShieldedPixel     = 2     ///< Metal-shielded down pixel.
} PDLibPixelShieldInfo;

/// @brief Window coordinates defined as a percentage of the image size.
///        The range for all parameters is from 0.0 through 1.0 percent.
typedef struct
{
    FLOAT startX;      ///< Percentage of the starting X coordinate in terms of the image width.
    FLOAT startY;      ///< Percentage of the starting Y coordinate in terms of the image height.
    FLOAT endX;        ///< Percentage of the ending X coordinate in terms of the image width.
    FLOAT endY;        ///< Percentage of the ending Y coordinate in terms of the image height.
} PDLibWindowInfo;

/// @brief Defines the main window types.
typedef enum
{
    PDLibRoiTypeCenter = 0x0,  ///< Default type.
    PDLibRoiTypeFace,          ///< Face autofocus.
    PDLibRoiTypeTouch,         ///< Touch autofocus.
    PDLibRoiTypeTopLeft,       ///< Peripheral top left ROI.
    PDLibRoiTypeTopCenter,     ///< Peripheral top center ROI.
    PDLibRoiTypeTopRight,      ///< Peripheral top right ROI.
    PDLibRoiTypeLeft,          ///< Peripheral left ROI.
    PDLibRoiTypeRight,         ///< Peripheral right ROI.
    PDLibRoiTypeBottomLeft,    ///< Peripheral bottom left ROI.
    PDLibRoiTypeBottomCenter,  ///< Peripheral bottom center ROI.
    PDLibRoiTypeBottomRight,   ///< Peripheral bottom right ROI.
    PDLibRoiTypeSalient,       ///< Salient ROI type.
    PDLibRoiTypeEye,           ///< Eye rectangle.
    PDLibRoiTypeTorso,         ///< Human torso rectangle.
} PDLibRoiType;

/// @brief Indicates wether to use sync stats or current stats
typedef enum
{
    PDLibBufSyncTypeAuto = 0,   ///< The PDlib makes a decision about whether to use the current stats or synced stats.
    PDLibBufSyncTypeCurrent,    ///< AF algorithm recommendation to use current stats.
    PDLibBufSyncTypeSync        ///< AF algorithm recommendation to use synced stats corresponding to ROI.
} PDLibBufSyncType;

/// @brief Defines the configuration parameters for the ROI in the PD Library.
typedef struct
{
    PDLibRoiType        type;           ///< Type of ROI coordinates.
    PDLibWindowInfo     rectangle;      ///< Coordinates of the ROI.
    UINT                HGridCount;     ///< Number of grids in the horizontal direction.
    UINT                VGridCount;     ///< Number of grids in the vertical direction.
    PDLibBufSyncType    bufSyncType;    ///< Wether to use sync buffer or current buffer for this ROI
} PDLibROI;

/// @brief Multi ROI information
typedef struct
{
    UINT8       count;                          ///< Number of the Input ROI mapped
    PDLibROI    roi[PDLibMultiRoiMaxROICount];  ///< Multi ROI information
} PDLibMultiROI;

/// @brief Defines the configuration parameters for the window in the PD Library.
typedef struct
{
    PDLibRoiType        roiType;                ///< Type of ROI coordinates.
    PDLibWindowInfo     fixedAFWindow;          ///< Coordinates of the ROI.
    UINT                horizontalWindowCount;  ///< Number of windows in the horizontal direction.
    UINT                verticalWindowCount;    ///< Number of windows in the vertical direction.
    UINT32              targetPosition;         ///< Estimated position of the logical target.
    INT32               targetDistance;         ///< Estimated position of the target distance (cm) for the lens.
    UINT                faceOrientation;        ///< Orientation of the face ROI (up, down, left, right).
    PDLibMultiROI       multiROI;               ///< Multi ROI information.
} PDLibWindowConfig;

/// @brief Defines the PD pixel location in one block.
typedef struct
{
    INT                   x;      ///< X coordinate of the pixel.
    INT                   y;      ///< Y coordinate of the pixel.
    PDLibPixelShieldInfo  type;   ///< Shielded pixel pattern.
} PDLibPDPixelInfo;

/// @brief Defines the sensor orientation types.
typedef enum
{
    PDLibOrientationDefault,        ///< Default orientation.
    PDLibOrientationMirror,         ///< Mirrored orientation.
    PDLibOrientationFlip,           ///< Flipped orientation.
    PDLibOrientationMirrorAndFlip,  ///< Mirrored and flipped orientation.
    PDLibOrientationMax,            ///< Anchor to indicate the last item in the defines.
} PDLibSensorOrientation;

/// @brief Dimensions of the camera interface window.
typedef struct
{
    UINT width;    ///< Width of the window/buffer.
    UINT height;   ///< Height of the window/buffer.
    UINT stride;   ///< Stride of the window/buffer if differs.
} PDLibDimensionInfo;

/// @brief Defines the defocus range.
typedef struct
{
    INT16 rangeNear;     ///< Near end of the range.
    INT16 rangeFar;      ///< Far end of the range.
} PDLibRangeInfo;

/// @brief Contains the output data for a query from the PD Library.
typedef struct
{
    INT   defocus;                ///< Defocus in the DAC range.
    UINT  confidence;             ///< Confidence level.
    FLOAT phaseDiff;              ///< Pixel phase difference estimation for PDAF.
    PDLibRangeInfo defocusRange;  ///< Near end and far end of the defocus estimation range.
} PDLibDefocusInfo;

/// @brief Defines the ROI coordinates.
typedef struct
{
    INT x;              ///< X coordinate of the region.
    INT y;              ///< Y coordinate of the region.
    UINT width;         ///< Width of the region.
    UINT height;        ///< Height of the region.
} PDLibRectangleInfo;

/// @brief Defines the sparse and dual PD data types.
typedef enum
{
    PDLibSensorInvalid,               ///< Sensor is unknown or invalid.
    PDLibSensorType1,                 ///< Sparse PD type 1.
    PDLibSensorType2,                 ///< Sparse PD type 2.
    PDLibSensorType3,                 ///< Sparse PD type 3.
    PDLibSensorDualPD,                ///< Dual PD type 2.
    PDLibSensorQPD,                   ///< QPD sensor type 2.
    PDLibSensorTypeMax,               ///< Indicates the last item in the definition.
} PDLibSensorType;

// @brief Defines the sensor PD statistics format for T1.
typedef enum
{
    PDLibSensorPDStatsCustom                = 0,
    PDLibSensorPDStatsRaw10Conf8BitPd10Bit  = 1,
    PDLibSensorPDStatsRaw10Conf11BitPd11Bit = 2,
    PDLibSensorPDStatsRaw10Conf11BitPd10Bit = 3
} PDLibSensorPDStatsFormat;

// @brief Defines the buffer formats for packing the PD data.
typedef enum
{
    PDLibBufferFormatMipi8,        // Raw 8 unpacked.
    PDLibBufferFormatMipi10,       // Mipi10, [9:2] [9:2] [9:2] [9:2] [1:0][1:0][1:0][1:0].
    PDLibBufferFormatUnpacked16,   // Raw 16 unpacked.
    PDLibBufferFormatPacked10,     // Raw 10 packed, Q10 format.
    PDLibBufferFormatMipi12,       // Raw 12 unpacked.
} PDLibBufferFormat;

/// @brief Defines the PD data ordering types.
typedef enum
{
    PDLibPixelOrderDefault, ///< Default order (PDLibPixelOrderLR).
    PDLibPixelOrderLR,      ///< Left followed by right.
    PDLibPixelOrderRL,      ///< Right followed by left.
} PDLibPixelOrderType;

/// @brief Defines a PD block or native sensor pattern:
///        - The sensor fills it for T2
///        - The ISP fills it for T3
typedef struct
{
    UINT                  pixelCount;                          ///< Number of PD pixels in the window.
    PDLibPDPixelInfo      pixelCoordinate[PDLibMaxPixelCount]; ///< Two-dimensional position of a pixel
                                                               ///  (left_pixel,right_pixel).
    UINT32                horizontalPDOffset;                  ///< Horizontal offsets of the block pattern.
    UINT32                verticalPDOffset;                    ///< Vertical offsets of the block pattern.
    PDLibDimensionInfo    blockDimension;                      ///< Width and height of the pattern window.
} PDLibBlockPattern;

/// @brief Defines the LCR PD block pattern.
typedef struct
{
    UINT                  lineCount;                          ///< Number of PD data lines in a block.
    UINT                  linePosition[PDLibMaxBlockHeight];  ///< Position of the PD data in a block.
    UINT32                horizontalPDOffset;                 ///< Horizontal offset of the block.
    UINT32                verticalPDOffset;                   ///< Vertical offset of the block.
    PDLibDimensionInfo    blockDimension;                     ///< Width and height of the pattern window
} PDLibLcrBlockPattern;

/// @brief Contains information about the PD block pattern.
typedef struct
{
    UINT                  stride;         ///< Stride information.
    PDLibBufferFormat     bufferFormat;   ///< Type of buffer for packing the PD data.
    PDLibSensorType       sensorType;     ///< Type of buffer.
    PDLibBlockPattern     blockPattern;   ///< Block pattern of PD data.
} PDLibBlockPatternInfo;

/// @brief Contains information about the native sensor pattern.
typedef struct
{
    PDLibBlockPattern blockPattern;           ///< Block pattern of sensor data.
    UINT              horizontalBlockCount;   ///< Number of PD blocks in the x coordinate.
    UINT              verticalBlockCount;     ///< Number of PD blocks in the y coordinate.
} PDLibSensorNativePatternInfo;

/// @brief Contains information about the native sensor.
typedef struct
{
    PDLibSensorNativePatternInfo    patternInfo;                ///< Defines the native sensor pattern.
    PDLibRectangleInfo              cropRegion;                 ///< In-sensor region that is cropped.
    UINT                            originalImageWidth;         ///< Width (in pixels) of the original image.
    UINT                            originalImageHeight;        ///< Height (in pixels) of the original image.
    UINT                            currentImageWidth;          ///< Width (in pixels) of the current image.
    UINT                            currentImageHeight;         ///< Height (in pixels) of the current image.
    PDLibSensorOrientation          orientation;                ///< Sensor orientation: mirror, flip, or both.
    PDLibBufferFormat               bufferFormat;               ///< Type of buffer for packing the PD data.
    FLOAT                           horizontalDownscaleFactor;  ///< Horizontal downscale binning factor.
                                                                ///
                                                                ///  @values 2 (for 2PD IMX362)

    FLOAT                           verticalDownscaleFactor;    ///< Vertical downscale binning factor.
                                                                ///
                                                                ///  @values 4 (for 2PD IMX362)

    FLOAT                           PDOffsetCorrection;         ///< Offset correction to add to the estimated PD value.
    FLOAT                           lcrPDOffset;                ///< Offset correction to add to the estimated LCR PD value.
    PDLibLcrBlockPattern            lcrBlockPattern;            ///< Defines the LCR block pattern.
    PDLibSensorBayerPattern         bayerPattern;               ///< Bayer grid pattern that is streamed by the sensor.
} PDLibSensorNativeInfo;

/// @brief Contains information for the LCR buffer data.
typedef struct
{
    PDLibLcrBlockPattern  isp1BlockPattern;       ///< ISP 1: Data pattern for the left VFE camera interface.
    PDLibLcrBlockPattern  isp2BlockPattern;       ///< ISP 2: Data pattern for the right VFE camera interface.
    UINT                  isp1BufferWidth;        ///< ISP 1: Left buffer width of the camera interface.
    UINT                  isp1BufferStride;       ///< ISP 1: Left buffer stride of the camera interface.
    UINT                  isp2BufferWidth;        ///< ISP 2: Right buffer width of the camera interface.
    UINT                  isp2BufferStride;       ///< ISP 2: Right buffer stride of the camera interface.
    UINT                  ispBufferHeight;        ///< Buffer height of the camera interface.
    UINT                  imageOverlap;           ///< Number of pixels when images overlap for dual IFE.
    UINT                  isp2ImageOffset;        ///< ISP 2: Offsets of the right images.
    PDLibBufferFormat     bufferFormat;           ///< Type of buffer for packing the PD data.
} PDLibLcrBufferDataInfo;

/// @brief Defines the PD data buffer information.
///        - For T3 -- Camera interface data pattern
///        - For T2 -- PD statistics pattern
typedef struct
{
    PDLibBlockPattern      isp1BlockPattern;            ///< ISP 1: Camera interface data pattern.
                                                        ///
                                                        ///  @values NULL in a single VFE

    PDLibBlockPattern      isp2BlockPattern;            ///< ISP 2: Camera interface data pattern.
                                                        ///
                                                        ///  @values NULL in a single VFE

    UINT                   isp1BufferWidth;             ///< ISP 1: Subsampled image width (in pixels).
    UINT                   isp1BufferStride;            ///< ISP 1: Subsampled image stride (in bytes).
    UINT                   isp2BufferWidth;             ///< ISP 2: Subsampled image width (in pixels).
    UINT                   isp2BufferStride;            ///< ISP 2: Subsampled image stride (in bytes).
    UINT                   ispBufferHeight;             ///< ISP 1: Subsampled image height.
    UINT                   imageOverlap;                ///< Overlap (in pixels) for dual VFE in the original image priority
                                                        ///  subsample.
    UINT                   isp2ImageOffset;             ///< ISP 2: Offsets of the right images.
    PDLibBufferFormat      bufferFormat;                ///< Type of buffer for packing the PD data.
    PDLibSensorType        sensorType;                  ///< Buffer status descriptor.
    PDLibLcrBufferDataInfo lcrBufferData;               ///< LCR buffer data information.
} PDLibDataBufferInfo;

/// @brief Defines the LCR Raw types.
typedef enum
{
    PDLibMIPIRaw,
    PDLibIdealRaw,
    PDLibCamifRaw
} PDLibLcrRawType;

/// @brief Configuration parameters for the LCR sensor.
typedef struct
{
    INT                   enable;              ///< Indicates whether sensor configuration is enabled.
                                               ///
                                               ///  @valuesbul
                                               ///  - 0 -- FALSE
                                               ///  - 1 -- TRUE @tablebulletend

    PDLibLcrRawType       rawType;             ///< Specifies the LCR Raw type.
    PDLibLcrBlockPattern  lcrNativePattern;    ///< Specifies the LCR native pattern.
} PDLibLcrSensorConfigure;

/// @brief Contains PD Library settings from the camxsettings.xml file.
typedef struct
{
    BOOL                        isPDHWEnabled;              ///< Indicates whether the PD hardware is enabled.
                                                            ///
                                                            ///  @valuesbul
                                                            ///  - 0 -- FALSE
                                                            ///  - 1 -- TRUE @tablebulletend

    BOOL                        enablePDLibProfiling;       ///< Specifies whether to enable profiling for the library.
                                                            ///
                                                            ///  @valuesbul
                                                            ///  - 0 -- FALSE
                                                            ///  - 1 -- TRUE @tablebulletend

    UINT                        enablePDLibTestMode;        ///< Specifies whether to enable Test mode for the library.
                                                            ///
                                                            ///  @valuesbul
                                                            ///  - 0 -- FALSE
                                                            ///  - 1 -- TRUE @tablebulletend

    UINT                        enablePDLibLog;             ///< Specifies whether to enable PDAF_LOGH logging for the library.
                                                            ///
                                                            ///  @valuesbul
                                                            ///  - 0 -- FALSE
                                                            ///  - 1 -- TRUE @tablebulletend

    UINT                        enablePDLibDump;            ///< Specifies whether to enable PDAF_LOGH dumping for the library.
                                                            ///
                                                            ///  @valuesbul
                                                            ///  - 0 -- FALSE
                                                            ///  - 1 -- TRUE @tablebulletend

    UINT                        enhancePDLibDump;           ///< Specifies whether to enable Enhance pdlib dump
                                                            ///
                                                            ///  @valuesbul{for bit 0}
                                                            ///  - 0 -- FALSE
                                                            ///  - 1 -- TRUE
                                                            ///
                                                            ///  @values{for bits 15:1} Specify the camera ID

    BOOL                        disableLCR;                 ///< Specifies whether to disable LCR processing for the library.
                                                            ///
                                                            ///  @valuesbul
                                                            ///  - 0 -- FALSE
                                                            ///  - 1 -- TRUE @tablebulletend

    UINT32                      profile3A;                  ///< API profiling for the library.
} PDLibSettingsInfo;

/// @brief Information used when required conditions are met for the PD hardware.
///        This information is published by the autofocus node and is used by the PD Library.
typedef struct
{
    BOOL    isDualPDEnableConditionsMet;    ///< Indicates whether the conditions are met for the dual PD hardware to
                                            ///  be enabled or disabled.
                                            ///
                                            ///  @valuesbul
                                            ///  - 0 -- FALSE (conditions are not met)
                                            ///  - 1 -- TRUE (conditions are met)
                                            ///
                                            ///  This field does not include the Tuning Enable flag. The library will
                                            ///  consider the tuning flag.

    BOOL    isSparsePDEnableConditionsMet;  ///< Indicates whether the conditions are met for the sparse PD hardware
                                            ///  to be enabled or disabled.
                                            ///
                                            ///  @valuesbul
                                            ///  - 0 -- FALSE (conditions are not met)
                                            ///  - 1 -- TRUE (conditions are met)
                                            ///
                                            ///  This field does not include the Tuning Enable flag. The library will
                                            ///  consider the tuning flag.

    BOOL    isLCREnableConditionsMet;       ///< Indicates whether the conditions are met for the LCR hardware to be
                                            ///  enabled or disabled.
                                            ///
                                            ///  @valuesbul
                                            ///  - 0 -- FALSE (conditions are not met)
                                            ///  - 1 -- TRUE (conditions are met)
                                            ///
                                            ///  This field does not include the Tuning Enable flag. The library will
                                            ///  consider the tuning flag.
} PDHWEnableConditions;

/// @brief Cropping information for a selected sensor mode.
struct StatsSensorModeCropInfo
{
    UINT    firstPixel;     ///< Left side of the crop region.
    UINT    firstLine;      ///< Top side of the crop region.
    UINT    lastPixel;      ///< Output width is right crop -1.
    UINT    lastLine;       ///< Output height is bottom crop -1.
};

/// @brief Valid PD hardware versions.
typedef enum
{
    PDHWVersionInvalid = -1,    ///< Invalid version
    PDHWVersionV10,             ///< PD HW version in SM8150 target
    PDHWVersionV20,             ///< PD HW version in SM8250 & SM8350 target
    PDHWVersionV21,             ///< PD HW version in SM8450 target
    PDHWVersionV30,             ///< PD HW version in SM8550 target
    PDHWVersionV31              ///< PD HW version in PDAF Lite target
} PDHWVersion;

/// @brief Defines the HDR mode type.
typedef enum
{
    PDHwHDRModeInvalid = -1,  ///< Type Invalid.
    PDHwHDRModeAuto,          ///< Auto mode.
    PDHwHDRModeLong,          ///< Use long pixel.
    PDHwHDRModeShort,         ///< Use short Pixel.
} PDHwHDRModeType;

/// @brief Contains any further information required when the PD Library is initialized.
struct PDLibInitInfo
{
    CSIDBinningInfo csidBinningInfo;        ///< CSID binning configuration.
    PDHWVersion     hardwareVersionInfo;    ///< PD hardware version for utilizing statistics parsing.
};

/// @brief This structure provide a point mapping based on FOV.
typedef struct
 {
     FLOAT  x;  ///< The horizontal location based on [0.0-1.0]. 1.0 means the whole FOV.0.0 means none.
     FLOAT  y;  ///< The vertical location based based on [0.0-1.0]. 1.0 means the whole FOV.0.0 means none.
 } PDPoint;

/// @brief Configuration parameters for the FIR filter which will be overridden by client's PDLib.
typedef struct
{
    BOOL    override;                   ///< Indicates if this block has been overridden by client.
    BOOL    enable;                     ///< Disables/enables the setting.
    FLOAT   a[FIRCoefficientACount];    ///< FIR filter a coefficients.
} PDHwFIROverride;

/// @brief Configuration parameters for the IIR filter which will be overridden by client's PDLib.
typedef struct
{
    BOOL    override;                   ///< Indicates if this block has been overridden by client.
    BOOL    enable;                     ///< Disables/enables the setting.
    FLOAT   a[IIRCoefficientACount];    ///< IIR filter a coefficients.
    FLOAT   b[IIRCoefficientBCount];    ///< IIR filter b coefficients.
} PDHwIIROverride;

/// @brief Bin configuration in horizontal & vertical path which will be overridden by client's PDLib.
typedef struct
{
    BOOL    override;   ///< Indicates if this block has been overridden by client.
    BOOL    enable;     ///< Disables/enables the setting.
    UINT8   binx;       ///< Horizontal bin factor. Horizontal bin will be configured in both horizontal and vertical path.
    UINT8   biny;       ///< Vertical bin factor. Vertical bin will be configured only for horizontal path.
} PDHwBinOverride;

/// @brief Configuration parameters for the high dynamic range (HDR) which can be overridden by client's PDLib.
typedef struct
{
    BOOL            override;       ///< Indicates if this block has been overridden by client.
    BOOL            enable;         ///< Disables/enables the setting.
    PDHwHDRModeType mode;           ///< Type of mode selected.
                                    ///  - 0 -- Auto
                                    ///  - 1 -- Long
                                    ///  - 2 -- Short
    FLOAT           threshold;      ///< Threshold used to determine short exposure or long exposure HDR pixels.
    FLOAT           exposureRatio;  ///< HDR exposure ratio in Q8 format.
} PDHwHDROverride;

/// @brief This structure holds the number of phases to be generated per region by H1/H2 LR SAD.
///        Total H1 Phases can be {16, 32, 48, 64}.
///        Total H2 phases can be {0, 16, 32}.
typedef struct
{
    INT16   from;   ///< Starting point of SAD range.
    INT16   to;     ///< End point of SAD range.
} PDHwSADRange;

/// @brief Configuration parameters for for H1/H2 LR SAD which will be overridden by client's PDLib.
typedef struct
{
    BOOL            override;       ///< Indicates if this block has been overridden by client.
    BOOL            enable;         ///< Disables/enables the setting.
    PDHwSADRange    H1Range;        ///< Define Horizontal path1 SAD range.
    PDHwSADRange    H2Range;        ///< Define Horizontal path2 SAD range.
} PDHwSADOverrideConfig;

/// @brief Configuration parameters for LR gain map which will be overridden by client's PDLib.
typedef struct
{
    BOOL    override;                       ///< Indicates if this block has been overridden by client.
    BOOL    enable;                         ///< Disables/enables the setting.
    UINT16  qFactor;                        ///< Gain map QFactor.
    UINT16  left[PDLibGainMapLUTSize];      ///< Look-up table for the left PD pixel gain map.
    UINT16  right[PDLibGainMapLUTSize];     ///< Look-up table for the right PD pixel gain map.
    UINT16  up[PDLibGainMapLUTSize];        ///< Look-up table for the up PD pixel gain map.
    UINT16  down[PDLibGainMapLUTSize];      ///< Look-up table for the down PD pixel gain map.
} PDHwGainMapOverride;

/// @brief Configuration parameters for the FIR & IIR filters which will be overridden by client's PDLib.
typedef struct
{
    BOOL                        override;   ///< Indicates if this block has been overridden by client.
    PDHwFIROverride             H1FIR;      ///< Configuration for H1 FIR filter.
    PDHwFIROverride             H2FIR;      ///< Configuration for H2 FIR filter.
    PDHwIIROverride             H1IIR;      ///< Configuration for H1 IIR filter.
    PDHwIIROverride             H2IIR;      ///< Configuration for H2 IIR filter.
} PDHwFilterCoefficientsOverride;

/// @brief Modes of spotlight detection configuration.
typedef enum
{
    SpotlightDetectionConfigModeInvalid = -1,       ///< Type is unknown or invalid.
    SpotlightDetectionConfigModeBothLRSaturated,    ///< Both L and R pixels should be above the threshold value to be ignored.
    SpotlightDetectionConfigModeLOrRSaturated       ///< Either L or R pixels should be above the threshold value to be
                                                    ///  ignored.
} SpotlightDetectionConfigMode;

/// @brief Configuration parameters for hardwarePD spotlight detection which will be overridden by client's PDLib.
typedef struct
{
    BOOL                            override;                      ///< Indicates if this block has been overridden by client.
    BOOL                            enable;                        ///< Indicates whether spotlight detection is enabled.
                                                                   ///
                                                                   ///  @valuesbul
                                                                   ///  - 0 -- FALSE
                                                                   ///  - 1 -- TRUE @tablebulletend
    SpotlightDetectionConfigMode    configMode;                    ///< Rule for ignoring L and R PD pixels.
    UINT16                          sequenceSaturatedCntThreshold; ///< Threshold for the number of of saturated pixels in a
                                                                   ///  sequence.
    FLOAT                           pixelThreshold;                ///< If a pixel value is larger than this threshold, that
                                                                   ///  PD pixel will be ignored based on the configMode
                                                                   ///  setting.
} PDHwSpotlightDetectionConfigOverride;

/// @brief Contains the pixel exposure type that the PD Library chooses when the sensor supports multiple PD exposure types.
typedef struct
{
    BOOL                    override;               ///< Indicates if this block has been overridden by client
    AlgoInputExposureType   PDPixelExposureType;    ///< Type of PD pixel exposure that is being chosen.
} PDPreferredExposureTypeOverride;

/// @brief SAD grid configuration.
typedef struct
{
    UINT32          HGridNUM;                           ///< Number of horizontal grids.
    UINT32          VGridNUM;                           ///< Number of vertical grids.
    UINT32          colWidth[PDLibHorizontalROINUM];    ///< Width of each region.
    UINT32          rowHeight[PDLibVerticalROINUM];     ///< Height of each region.
    PDPoint         topLeft;                            ///< Crop top left point.
    PDPoint         bottomRight;                        ///< Crop bottom right point.
} PDHwGridInfo;

/// @brief SAD buffer buffer parse info.
typedef struct
{
    PDHwSADRange    H1Range;                            ///< Define horizontal path1 SAD range.
    PDHwSADRange    H2Range;                            ///< Define horizontal path2 SAD range.
    UINT32          LR1Offset;                          ///< Offset of LR1 buffer in byte.
    UINT32          LR1SADSize;                         ///< Size of LR1 SAD for one grid in byte.
    UINT32          LR2Offset;                          ///< Offset of LR2 buffer in byte.
    UINT32          LR2SADSize;                         ///< Size of LR2 SAD for one grid in byte.
    UINT32          channelStatOffset;                  ///< Offset of channel stat buffer in byte.
    UINT32          channelStatSize;                    ///< Size of channel stat SAD for one grid in byte.
    UINT32          stride;                             ///< Size of one horizontal SAD line in byte. If there are 48X32 grids,
                                                        ///< one horizontal line includes LR1, LR2, channelstat for 48 grids
} PDHwSADInfo;

/// @brief SAD parse info.
typedef struct
{
    PDHwGridInfo    gridInfo;                           ///< Grid information.
    PDHwSADInfo     sadInfo;                            ///< SAD information.
} PDHwSADParseInfo;

typedef struct
{
    PDHwSADParseInfo        sadParseInfo;           ///< SAD parse information.
    PDLibDimensionInfo      parsedBufDim;           ///< Size of parsed buffer.
    PDLibDimensionInfo      preprocessedBufDim;     ///< Size of preprocessed buffer.
    AlgoInputExposureType   PDPixelExposureType;    ///< Type of PD pixel exposure that is being chosen.
} PDHwParseInfo;

/// @brief Defines sensor Configuration which is requested by client's PDLib.
typedef struct
{
    BOOL    override;           ///< Indicates if this block has been overridden by client
    BOOL    isVPDDataReal;     ///< Indicates whether sensor streams real or dummy data for vertical stream
} SensorOverridePDConfig;

/// @brief Configuration parameters for PD HW which will be overridden by client's PDLib.
typedef struct
{
    BOOL                                 override;                ///< Indicates if this block has been overridden by client.
    PDHwFilterCoefficientsOverride       filterCoefficients;      ///< FIR & IIR filter coefficients.
    PDHwBinOverride                      H1Bin;                   ///< Horizontal path1 bin config.
    PDHwBinOverride                      H2Bin;                   ///< Horizontal path2 bin config.
    PDHwBinOverride                      VBin;                    ///< Vertical bin config.
    PDHwHDROverride                      H1HDR;                   ///< Horizontal path1 HDR config.
    PDHwHDROverride                      H2HDR;                   ///< Horizontal path2 HDR config.
    PDHwGainMapOverride                  gainMap;                 ///< Gain map config.
    PDHwSADOverrideConfig                sad;                     ///< SAD1 & SAD2 override config.
    PDHwSpotlightDetectionConfigOverride spotlight;               ///< Spotlight Detection override config.
    BOOL                                 enablePostProcessing;    ///< Enable stat processing.
    PDPreferredExposureTypeOverride      pixelExposureType;       ///< Pixel Exposure Type override
} PDHwOverride;

/// @brief The Override setting which is defined as one of the input parameters for PDLibGetParamHWConfig.
typedef struct
{
    PDHwOverride    settings;   ///< Client PD HW override settings.
} PDHwOverrideInput;

/// @brief Defines the input parameters for initialization of the PD Library.
typedef struct
{
    UINT64                      requestId;                  ///< RequestId in which the override Settings is provided by client.
    PDLibSensorNativeInfo       nativePatternInfo;          ///< PD pattern. Location of the PD pixels.
    UINT                        blackLevel;                 ///< Black level of the sensor.
    UINT                        pixelDepth;                 ///< Bit depth for the input pixel value.
    UINT                        isHdrModeEnabled;           ///< Indicates whether HDR mode is enabled (1).
    UINT                        PDPixelOverflowThreshold;   ///< Threshold for determining an overflow or saturated PD pixel
                                                            ///  value.
    INT16                       macroDac;                   ///< DAC value for the macro or close distance focusing position.
    INT16                       infinityDac;                ///< DAC value for the infinity or far distance focusing position.
    FLOAT                       actuatorSensitivity;        ///< Actuator sensitivity of the camera module.
    PDLibPixelOrderType         pixelOrderType;             ///< PD pixel order type to determine whether the first pixel is
                                                            ///  left or right.
    VOID*                       pCalibrationParam;          ///< Pointer to the calibration parameters from the sensor.
    UINT32                      defocusBitShift;            ///< Defocus bit shift required for T1.
    INT32                       defocusConfidenceThreshold; ///< Threshold for the confidence value in T1
    PDLibSensorPDStatsFormat    sensorPDStatsFormat;        ///< Sensor PD statistics format for T1.
    PDLibDataBufferInfo         bufferDataInfo;             ///< Contains buffer dimension, pixel location, and pattern-related
                                                            ///  information for the PD buffer pattern.
    StatsCameraInfo             cameraInfo;                 ///< Camera information: algorithm role (master or slave), camera
                                                            ///  ID, and camera type (see #StatsCameraInfo).
    PDLibSettingsInfo           settingsInfo;               ///< Library settings from the camxsettings.xml file.
    PDHWEnableConditions        pdHWEnableConditions;       ///< Indicates that required conditions are met for enabling the
                                                            ///  PDAF hardware.
                                                            ///  Tuning is not included. The PD library will include the
                                                            ///  tuning enable/disable flag.
    VOID*                       pChromatixPDLib;            ///< (Optional) Pointer to the library tuning parameters.
                                                            ///  The value for this field is not mandatory. This field is
                                                            ///  provided for a client that does not have access to the QTI
                                                            ///  Tuning Manager.
                                                            ///  The value for this field is not mandatory. This field is
                                                            ///  provided for a client that does not have access to the QTI
                                                            ///  Tuning Manager.
    StatsSensorModeCropInfo     sensorCropInfo;             ///< Cropping information for this Sensor mode.
    PDLibInitInfo               pdlibInitInfo;              ///< Contains any further information that is required during
                                                            ///  PD Library initialization.
    UINT32                      currentResolutionIndex;     ///< Current sensor mode.
    UINT32                      PDoffsetmapID;              ///< PD mode of QPD sensor which has multiple PD mode and
                                                            ///  multiple PD offset maps. This value is read from PDoffsetmapID
                                                            ///  in the PDAF configuration.
    PDHwOverrideInput           PDOverrideInput;            ///< Client override settings to consider when providing PDHW config.
} PDLibInitParam;

/// @brief Types of PD buffer pointers.
typedef enum
{
    PDBufferPtrFormatInvalid = -1,
    PDBufferPtrFormatUINT8,        ///< The PD buffer pointer must be cast to UINT8*.
    PDBufferPtrFormatUINT16,       ///< The PD buffer pointer must be cast to UINT16*.
    PDBufferPtrFormatUINT32,       ///< The PD buffer pointer must be cast to UINT32*.
    PDBufferPtrFormatUINT64        ///< The PD buffer pointer must be cast to UINT64*.
} PDBufferPtrFormat;

/// @brief Types of PD statistics.
typedef enum
{
    PDLibStatsTypeInvalid = -1,         ///< Type is invalid or unknown.
    PDLibStatsTypePreProcessedData,     ///< PD buffer pointer is pointing to preprocessed PD pixels.
    PDLibStatsTypeDualPDHWData,         ///< PD buffer pointer is pointing to dual PD hardware statistics.
    PDLibStatsTypeLCRHWData,            ///< PD buffer pointer is pointing to LCR hardware statistics.
    PDLibStatsTypeRDIPDData,            ///< PD buffer pointer is pointing to the RDI buffer.
    PDLibStatsTypeT3RDIPDData,          ///< PD buffer pointer is pointing to the T3 RDI buffer.
    PDLibStatsTypeRDIRawData,           ///< PD buffer pointer is pointing to the RDI Raw buffer.
    PDLibStatsTypeParsedData,           ///< PD buffer pointer is pointing to parsed statistics.
    PDLibStatsTypeRDIPD2Data,           ///< PD buffer pointer is pointing to the RDI2 buffer.
    PDLibStatsTypeRDIPD3Data,           ///< PD buffer pointer is pointing to the RDI3 buffer.
    PDLibStatsTypeMax                   ///< Maximum number of types.
} PDLibStatsType;

/// @brief Contains information about PD statistics for buffers.
typedef struct
{
    PDLibStatsType          pdStatsType;    ///< Type of statistic to which pBuffer is pointing.
    AlgoInputExposureType   pdExposureType; ///< Indicates the PD statistics' exposure type if pdStatsType is set to
                                            ///  PDStatsTypeDualPDHWExposureData.
    PDBufferPtrFormat       pdBufferFormat; ///< Type of the buffer pointer. pBuffer must cast to this type.
    StatsDataPointer        pdBuffer;       ///< Pointer to the statistics' buffer.
    INT                     pdBufferFd;     ///< File descriptor used by the PD Library to map the buffer.
} PDLibStats;

/// @brief Defines newer PD buffer information. New PD statistics buffer information is held in the PDBufferInfo array.
typedef struct
{
    UINT16      statsCount;                     ///< Number of PD statistics in the  array.
    PDLibStats  pdStats[PDLibBufferArraySize];  ///< Array of PD statistics that holds information for different PD statistics.
} PDLibInput;

/// @brief Contains the sensor input information.
typedef struct
{
    FLOAT   imageAnalogGain;    ///< Image sensor gain.
    FLOAT   currentFps;         ///< Real-time frames per second.
    FLOAT   adrcGain;           ///< Gain compensation when ADRC is enabled.
    INT16   lensPosition;       ///< Current logical lens position.
    UINT32  sensorMode;         ///< Specifies the sensor mode.
    UINT32  exposureIndex;      ///< Current exposure index.
} PDLibSensorInfo;

/// @brief Contains information to process stats that match the ROI input
typedef struct
{
    PDLibInput          pdInput;                ///< Information about the PD stats.
    PDHwConfig*         pPDConfig;              ///< The PDHW configuration corresponding to the above stat.
    PDLibSensorInfo     sensorInfo;             ///< Sensor Information.
} PDLibSyncedBufInfo;

/// @brief Contains the input information for defocus processing.
typedef struct
{
    UINT16*             pPDBuffer;                  ///< Pointer to the PD buffer; each buffer element is 16 bits per pixel.
    INT                 PDBufferFd;                 ///< File descriptor used by the PD Library to map the buffer.
    SIZE_T              PDBufferSize;               ///< Size of the PD buffer.
    UINT16*             pRawBuffer;                 ///< Pointer to the Raw pixel buffer.
    PDLibWindowConfig   windowConfig;               ///< Indicates that a fixed window configuration is supported.
    FLOAT               imageAnalogGain;            ///< Image sensor gain.
    FLOAT               currentFps;                 ///< Real-time frames per second.
    FLOAT               integrationTime;            ///< Exposure time in nanoseconds.
    INT16               lensPosition;               ///< Current logical lens position.
    StatsCameraInfo     cameraInfo;                 ///< Camera information: algorithm role (master or slave), camera ID, and
                                                    ///  camera type (see #StatsCameraInfo).
    UINT64*             pPDHWBuffer;                ///< Pointer to the PD hardware buffer; 16 bits per pixel.
    INT                 PDHWBufferFd;               ///< File descriptor used by the PD Library to map the PD hardware buffer.
    SIZE_T              PDHWBufferSize;             ///< Size of the PD hardware buffer.

    BOOL                isPDHWEnable;               ///< Indicates whether the PD hardware is enabled.
                                                    ///
                                                    ///  @valuesbul
                                                    ///  - 0 -- FALSE
                                                    ///  - 1 -- TRUE @tablebulletend

    UINT16*             pLCRHWBuffer;               ///< Pointer to the LCR buffer; 16 bits per pixel.
    INT                 LCRBufferFd;                ///< File descriptor used by the PD Library to map the PD hardware buffer.
    SIZE_T              LCRBufferSize;              ///< Size of the LCR buffer.
    PDLibInput          pdInput;                    ///< Information about the PD buffers.
    PDLibSensorInfo     pdSensorInfo;               ///< Information about the sensor.
    AECExposureOutput   exposureOutput;             ///< Array of AEC exposure outputs for different exposure types.
    PDLibDimensionInfo  IFEInputResolution;         ///< IFE input size that might be different from the sensor output.
    UINT64              requestId;                  ///< Current request ID of an AF node.
    PDHwConfig*         pPDConfig;                  ///< PDHW config corresponding with the current stat.
    PDLibSyncedBufInfo  syncedBufInfo;              ///< PD stats and other required information matched with face ROI
} PDLibParam;

/// @brief Contains version information for the PD Library.
typedef struct
{
    UINT        majorVersion;    ///< Tracks the major version of the library.
    UINT        minorVersion;    ///< Tracks the minor version of the library.
    UINT        tinyVersion;     ///< Tracks the sub-minor version of the library.
} PDLibVersion;

/// @brief Defines the depth map output from the PD Library.
typedef struct
{
    FLOAT   PDMap[PDLibMaxMapGridCount];                ///< Value map for the library.
    UINT    ConfidenceMap[PDLibMaxMapGridCount];        ///< Confidence map for the library.
    INT16   DefocusRangeNearMap[PDLibMaxMapGridCount];  ///< Near end map of the defocus range.
    INT16   DefocusRangeFarMap[PDLibMaxMapGridCount];   ///< Far end map of the defocus range.
    INT     DefocusMap[PDLibMaxMapGridCount];           ///< Defocus map for the library.
    UINT32  horiNumOfRegion;                            ///< Number of horizontal grid cells.
    UINT32  vertNumOfRegion;                            ///< Number of vertical grid cells.
    UINT32  widthOfRegion;                              ///< Width of each grid cell.
    UINT32  heightOfRegion;                             ///< Height of each grid cell.
    UINT32  horiRegionOffset;                           ///< Horizontal offset of the grid.
    UINT32  vertRegionOffset;                           ///< Vertical offset of the grid.
} PDLibFocusMapInfo;

/// @brief PDLib defocus information for an ROI.
typedef struct
{
    PDLibROI            roi;                                ///< ROI information.
    PDLibDefocusInfo    defocusInfo[PDLibMaxWindowCount];   ///< Array to hold defocus result for input roi.
} PDLibROIDefocusInfo;

// @brief PDLib defocus information for each ROI in multi ROI config.
typedef struct
{
    UINT8               count;                          ///< Number of valid multi ROI defocus results.
    PDLibROIDefocusInfo roi[PDLibMultiRoiMaxROICount];  ///< Array to hold multi ROI defocus results.
} PDLibMultiROIDefocusInfo;


/// @brief Contains defocus parameters for the PD Library.
typedef struct
{
    PDLibDefocusInfo       defocus[PDLibMaxWindowCount];                 ///< Defocus output for each ROI.

    UINT16                 isPeripheralValid;                            ///< Indicates whether the peripheral data is valid.
                                                                         ///
                                                                         ///  @valuesbul
                                                                         ///  - 0 -- FALSE
                                                                         ///  - 1 -- TRUE @tablebulletend

    PDLibDefocusInfo       resultPeripheral[PDLibPeripheralWindowMax];   ///< Type of peripheral processing.
    PDLibProcessingResult  processingResult;                             ///< Results of PD processing.
    UINT                   horizontalWindowCount;                        ///< Number of horizontal windows.
    UINT                   verticalWindowCount;                          ///< Number of vertical windows.
    UINT                   windowNumber;                                 ///< Number of grids.
    PDLibFocusMapInfo      focusMapInfo;                                 ///< Information about the depth map output.
    PDLibMultiROIDefocusInfo multiRoiDefocusInfo;                        ///< PDLib multi ROI defocus information.
} PDLibOutputData;

/// @brief Defines the parameters used when creating an instance of the PD Library.
typedef enum
{
    PDLibCreateParamTypeInvalid                 = -1,           ///< Type is unknown or invalid.
    PDLibCreateParamTypeCameraOpenIndicator,                    ///< Actual camera is in the Open state.
    PDLibCreateParamTypeLibName,                                ///< Name of the PD Library.
    PDLibCreateParamTypeCameraInfo,                             ///< Camera information. \n
                                                                ///  Payload: #StatsCameraInfo.
    PDLibCreateParamTypeSessionHandle,                          ///< Handle for the session.
    PDLibCreateParamTypeCount,                                  ///< Total number of parameters.
    PDLibCreateParamTypeMax                     = 0x7FFFFFFF    ///< Indicates the last item in the definition.
} PDLibCreateParamType;

/// @brief Base structure of a Create parameter for a PD Library algorithm instance. This structure is used with
///        #PDLibCreateParamList.
typedef struct
{
    PDLibCreateParamType    createParamType; ///< Type of parameter that is passed to the library.
    VOID*                   pParam;          ///< Pointer to the parameter payload.
    UINT32                  sizeOfParam;     ///< Size of the payload data (in bytes).
} PDLibCreateParam;

/// @brief List of input parameters used when creating a PD Library instance. This list is passed to CREATEPD().
typedef struct
{
    PDLibCreateParam*   pParamList;    ///< Pointer to the array of parameters.
    UINT32              paramCount;    ///< Number of parameters in the array.
} PDLibCreateParamList;

/// @brief Identifies the parameter types used when destroying an instance of the PD Library.
typedef enum
{
    PDLibDestroyParamTypeInvalid                = -1,           ///< Type is unknown or invalid.
    PDLibDestroyParamTypeCameraCloseIndicator,                  ///< Actual camera is in the Closed (1) or Open (0) state.
    PDLibDestroyParamTypeCameraInfo,                            ///< Payload: #StatsCameraInfo.
    PDLibDestroyParamTypeCount,                                 ///< Total number of parameters.
    PDLibDestroyParamTypeMax                    = 0x7FFFFFFF    ///< Indicates the last item in the definition.
} PDLibDestroyParamType;

/// @brief Base structure of a Destroy parameter for a PD Library algorithm instance. This structure is used with
///        #PDLibDestroyParamList.
typedef struct
{
    PDLibDestroyParamType   destroyParamType;       ///< Type of parameter that is passed to the algorithm.
    VOID*                   pParam;                 ///< Pointer to the parameter payload.
    UINT32                  sizeOfParam;            ///< Size of the payload data (in bytes).
} PDLibDestroyParam;

/// @brief List of parameters used when destroying an instance of the PD Library.
///        The list is passed to CHIPDLib::PDLibDestroy().
typedef struct
{
    PDLibDestroyParam*  pParamList;    ///< Pointer to the array of parameters.
    UINT32              paramCount;    ///< Number of parameters in the array.
} PDLibDestroyParamList;

/// @brief Defines the types of dual PD paths.
typedef enum
{
    PDHwPathSelectInvalid = -1, ///< Type is unknown or invalid.
    PDHwPathSelectHW,           ///< PD hardware output.
    PDHwPathSelectCAMIF,        ///< CAMIF extracted image.
} PDHwPathSelect;

/// @brief Identifies the tap point of the preprocessed PD pixel output path.
typedef enum
{
    ProcessedPDOutTapPointInvalid = -1, ///< Type is unknown or invalid.
    ProcessedPDOutTapPointPostIIR,      ///< Data is tapped from post-IIR.
    ProcessedPDOutTapPointPostGM        ///< Data is tapped from the post-gain map.
} PDHwProcessedPDOutTapPoint;

/// @brief Modes for disabling and enabling the horizontal and vertical IIR filters.
typedef enum
{
    PDHwIIRFilterModeInvalid = -1,      ///< Type is unknown or invalid.
    PDHwIIRFilterModeHVDisabled,        ///< Both V_IIR and H_IIR are disabled.
    PDHwIIRFilterModeHEnabled,          ///< H_IIR is enabled.
    PDHwIIRFilterModeBothHVDisabled,    ///< Both V_IIR and H_IIR are disabled. This mode is the same as mode 0.
    PDHwIIRFilterModeVEnabled           ///< V_IIR is enabled.
} PDHwIIRFilterMode;

/// @brief Contains information about dual PD cropping.
typedef struct
{
    BOOL   enablePDCrop;    ///< Indicates whether crop is enabled.
                            ///
                            ///  @valuesbul
                            ///  - 0 -- FALSE
                            ///  - 1 -- TRUE @tablebulletend

    UINT32 firstPixelCrop;  ///< First pixel for a 2PD crop.
    UINT32 lastPixelCrop;   ///< Last pixel for a 2PD crop.
    UINT32 firstLineCrop;   ///< First line for a 2PD crop.
    UINT32 lastLineCrop;    ///< Last line for a 2PD crop.
} PDHwCrop;

/// @brief Contains IIR filter configuration parameters for phase detection.
typedef struct
{
    BOOL                IIREnable;                  ///< Specifies whether the IIR filter is enabled.
                                                    ///
                                                    ///  @valuesbul
                                                    ///  - 0 -- FALSE
                                                    ///  - 1 -- TRUE @tablebulletend

    FLOAT               init0;                      ///< IIR filter coefficient init0 in Q15 format.
    FLOAT               init1;                      ///< IIR filter coefficient init1 in Q15 format.
    FLOAT               a0;                         ///< IIR filter coefficient a0 in Q15 format.
    FLOAT               a1;                         ///< IIR filter coefficient a1 in Q15 format.
    FLOAT               b0;                         ///< IIR filter coefficient b0 in Q15 format.
    FLOAT               b1;                         ///< IIR filter coefficient b1 in Q15 format.
    FLOAT               b2;                         ///< IIR filter coefficient b2 in Q15 format.
    PDHwIIRFilterMode   IIRFilterMode;              ///< Disables or enables the Horizontal and Vertical IIR filters.

    BOOL                IIRAdditionalOffsetEnable;  ///< Indicates whether the IIR additional offset is enabled.
                                                    ///
                                                    ///  @valuesbul
                                                    ///  - 0 -- FALSE
                                                    ///  - 1 -- TRUE
                                                    ///
                                                    ///  When enabled, this flag converts a negative value to a positive value
                                                    ///  by adding an offset of 2^15 to the negative value.
} PDHwIIRConfig;

/// @brief Configuration parameters for the sum of absolute difference (SAD).
typedef struct
{
    BOOL                sadEnable;          ///< Indicates whether SAD is enabled.
                                            ///
                                            ///  @valuesbul
                                            ///  - 0 -- FALSE
                                            ///  - 1 -- TRUE @tablebulletend

    UINT32              horizontalOffset;   ///< Horizontal offset of the ROI grid from the left crop window.
    UINT32              verticalOffset;     ///< Vertical offset of the ROI grid from the left crop window.
    UINT32              regionWidth;        ///< Width (in pixels) of each region in the ROI grid.
    UINT32              regionHeight;       ///< Height (in pixels) of each region in the ROI grid.
    UINT32              horizontalNumber;   ///< Number of columns of regions in the ROI grid.
    UINT32              verticalNumber;     ///< Number of rows of regions in the ROI grid.
    UINT32              sadShift;           ///< Shift configuration of SAD to avoid overflow.

    UINT32              config0Phase;       ///< Indicates whether SAD is to be computed.
                                            ///
                                            ///  @values Phase -1 through phase -32

    UINT32              config1Phase;       ///< Alignment from the MSB to the LSB.
                                            ///
                                            ///  @values +31 through 0
} PDHwSADConfig;

/// @brief Types of HDR pixels.
typedef enum
{
    PDHwHDRPixelInvalid = -1,
    PDHwHDRPixelShort,
    PDHwHDRPixelLong,
} PDHwHDRPixelType;

/// @brief Configuration parameters for the high dynamic range (HDR).
typedef struct
{
    BOOL                hdrEnable;          ///< Indicates whether HDR is enabled.
                                            ///
                                            ///  @valuesbul
                                            ///  - 0 -- FALSE
                                            ///  - 1 -- TRUE @tablebulletend

    PDHwHDRPixelType    hdrFirstPixel;      ///< Type of the first pixel in the HDR.
                                            ///
                                            ///  @valuesbul
                                            ///  - 0 -- T1
                                            ///  - 1 -- T2 @tablebulletend

    PDHwHDRModeType     hdrModeSel;         ///< Type of mode selected.
                                            ///
                                            ///  @valuesbul
                                            ///  - 0 -- Use short pixels
                                            ///  - 1 -- Use long pixels @tablebulletend

    FLOAT               hdrThreshhold;      ///< Threshold used to determine short exposure or long exposure HDR pixels.
    FLOAT               hdrExposureRatio;   ///< HDR exposure ratio in Q8 format.
} PDHwHDRConfig;

/// @brief Configuration parameters for PD black level subtraction (BLS).
typedef struct
{
    UINT32  leftPixelBLSCorrection;     ///< BLS correction for the left pixel offset.
    UINT32  rightPixelBLSCorrection;    ///< BLS correction for the right pixel offset.
} PDHwBLSConfig;

/// @brief Configuration parameters for PD skip or binning.
typedef struct
{
    BOOL    enableSkipBinning;              ///< Indicates whether skip/binning is enabled.
                                            ///
                                            ///  @valuesbul
                                            ///  - 0 -- FALSE
                                            ///  - 1 -- TRUE @tablebulletend

    UINT32  verticalBinningLineCount;       ///< Number of lines for vertical binning.
    UINT32  verticalDecimateCount;          ///< Number of decimate lines.
    UINT32  horizontalBinningPixelCount;    ///< Number of pixels for horizontal binning.
    UINT32  horizontalBinningSkip;          ///< Horizontal bin shift.
    UINT32  verticalBinningSkip;            ///< Vertical bin shift.
} PDHwBinConfig;

/// @brief Interpolation types for the gain map.
typedef enum
{
    GainMapInterpolationInvalid = -1,   ///< Type is unknown or invalid.
    GainMapHInterpolation,              ///< Apply linear interpolation only for horizontal. For vertical, use the nearest
                                        ///  neighbor.
    GainMapHVInterpolation              ///< Apply linear interpolation for both horizontal and vertical.
} PDHwGainMapInterpolationType;

/// @brief Configuration parameters for the gain map.
typedef struct
{
    BOOL                          gainMapEnable;                  ///< Indicates whether the gain map is enabled.
                                                                  ///
                                                                  ///  @valuesbul
                                                                  ///  - 0 -- FALSE
                                                                  ///  - 1 -- TRUE @tablebulletend

    UINT32                        numberHorizontalGrids;          ///< Number of horizontal grids.
    UINT32                        numberVerticalGrids;            ///< Number of vertical grids.
    UINT32                        horizontalPhaseInit;            ///< Horizontal phase offset of the first pixel of the crop
                                                                  ///  window.
    UINT32                        verticalPhaseInit;              ///< Vertical phase offset of the first line of the crop
                                                                  ///  window.
    UINT32                        horizontalPhaseStep;            ///< Phase interval between two pixels.
    UINT32                        verticalPhaseStep;              ///< Phase interval between two lines.
    UINT16                        leftLUT[PDLibGainMapLUTSize];   ///< Look-up table for the left gain map.
    UINT16                        rightLUT[PDLibGainMapLUTSize];  ///< Look-up table for the right gain map.
    UINT16                        gainShift;                      ///< Post-interpolation shift value.
    PDHwGainMapInterpolationType  gainMapInterpolationType;       ///< Direction of gain map interpolation.
} PDHwGainMapConfig;

/// @brief Contains the coordinates of the region to be cropped.
typedef struct
{
    UINT32 firstLine;   ///< Line buffer that contains the top left pixel of the region.
    UINT32 lastLine;    ///< Line buffer that contains the bottom right pixel of the region.
    UINT32 firstPixel;  ///< Location of the top left pixel of the region.
    UINT32 lastPixel;   ///< Location of the bottom right pixel of the region.
} CropCoordinate;

/// @brief Configuration parameters for the LCR hardware.
typedef struct
{
    BOOL            enable;                                         ///< Indicates whether the LCR hardware is enabled.
                                                                    ///
                                                                    ///  @valuesbul
                                                                    ///  - 0 -- FALSE
                                                                    ///  - 1 -- TRUE @tablebulletend

    CropCoordinate  crop;                                           ///< Coordinates of the region to be cropped.
    UINT32          blockHeight;                                    ///< Block height of the repeating pattern. The maximum
                                                                    ///  size is 64 x 64 bits (N = N+1).

    UINT32          componentMask;                                  ///< Bit mask used to include or exclude a color channel
                                                                    ///  for binning.
                                                                    ///
                                                                    ///  @valuesbul
                                                                    ///  - 0 -- Exclude the channel
                                                                    ///  - 1 -- Include the channel
                                                                    ///
                                                                    ///  Each bit indicates a color channel that is on the
                                                                    ///  sensor Bayer pattern.

    UINT16          componentShiftArrayCount;                       ///< Specifies the number of color components inside the
                                                                    ///  componentShift array.
                                                                    ///
                                                                    ///  The array can hold up to PDLibLCRColorComponentCount.
                                                                    ///  However, for a Bayer pattern, the first four elements
                                                                    ///  are valid. In QCFA mode, the first 16 elements are
                                                                    ///  valid.

    INT32           componentShift[PDLibLCRColorComponentCount];    ///< Indicates the number of bits by which each color
                                                                    ///  component is to be shifted.

    UINT32          lineMask[PDLibLCRMaskCount];                    ///< Array where each bit indicates whether to intercept
                                                                    ///  the LCR line for binning.
                                                                    ///  - lineMask[0] -- Bit 0 (LSB) through bit 31 (MSB)
                                                                    ///    represent the mask for line 0 through line 31.
                                                                    ///  - lineMask[1] -- Bit 0 (LSB) through bit 31 (MSB)
                                                                    ///    represent the mask for line 32 through line 63.
                                                                    ///
                                                                    ///  @valuesbul{for each bit}
                                                                    ///  - 0 -- Do not intercept
                                                                    ///  - 1 -- Intercept @tablebulletend

    UINT32          flushMask[PDLibLCRMaskCount];                   ///< Array where each bit indicates whether to flush a
                                                                    ///  line buffer.
                                                                    ///  - flushMask[0] -- Bit 0 (LSB) through Bit 31 (MSB)
                                                                    ///    represent the mask for line 0 through line 31.
                                                                    ///  - flushMask[1] -- Bit 0 (LSB) through Bit 31 (MSB)
                                                                    ///    represent the mask for line 32 through line 63.
                                                                    ///
                                                                    ///  @valuesbul{for each bit}
                                                                    ///  - 0 -- FALSE
                                                                    ///  - 1 -- TRUE @tablebulletend
} PDHwLCRConfig;

/// @brief Valid modes for the SFE LCR hardware.
typedef enum
{
    SFELCRModeInvalid = -1, ///< Type is unknown or invalid.
    SFELCRModeHDR,          ///< HDR sensor input mode.
    SFELCRModeNonHDR        ///< Non-HDR or sHDR sensor input mode.
                            ///  In this mode, the hardware bins the input from lines 0 and 1, and it ignores the input
                            ///  from lines 2 and 3. Default mode = SFELCRModeNonHDR.
} PDHWSFELCRInputModeSelect;

/// @brief Configuration parameters for the SFE LCR hardware.
typedef struct
{
    PDHWSFELCRInputModeSelect   SFELCRInputModeSelect;  ///< Select the SFE LCR hardware input mode.
    PDHwLCRConfig               SFELCRConfig;           ///< Configure the SFE LCR hardware.
} PDHWSFELCRConfig;

/// @brief Valid PD hardware modes.
typedef enum
{
    PDHwModeSelectInvalid = -1,
    PDHwModeSelectDualPD,
    PDHwModeSelectSparsePD,
} PDHwModeSelect;

/// @brief Configuration parameters for the line extractor.
typedef struct
{
    UINT16  globalOffsetLines;                      ///< Number of lines for which NULL pixels are sent before the actual
                                                    ///  transmission of PD pixels in T2 mode.
    UINT16  blockHeight;                            ///< Height of the PD pixels in a block. Maximum = 128.
    UINT16  pdPixelWidth;                           ///< Maximum number of PD pixels in one row of the input image, assuming a
                                                    ///  maximum packing density of 25%.
    UINT16  verticalBlockCount;                     ///< Number of PD pixel blocks in the vertical direction.
    UINT16  blockPDRowCount;                        ///< Number of rows containing PD pixels in a block.
    UINT16  horizontalOffset[PDLibMaxPDPixelRows];  ///< Horizontal offset per line in a block.
    UINT16  verticalOffset[PDLibMaxPDPixelRows];    ///< Vertical offset per line in a block.

    BOOL    halfLine[PDLibMaxPDPixelRows];          ///< Indicates whether to make a half line a full line by duplicating
                                                    ///  each pixel.
                                                    ///
                                                    ///  @valuesbul
                                                    ///  - 0 -- Extract the line as is
                                                    ///  - 1 -- Duplicate each pixel @tablebulletend
} PDHwLineExtractorConfig;

/// @brief Span values that represent the number of PD pixel lines that can be stored in the line buffer between the line
///        extractor and pixel separator.
typedef enum
{
    PixelSeparatorPixelSpanInvalid = -1,    ///< Type is unknown or invalid.
    PixelSeparatorPixelSpan1,               ///< PD pixel line is held in one line buffer. The PD pixel line width is up to
                                            ///  W, where W is the maximum width of the line buffer, which is 1.5 RSL.
    PixelSeparatorPixelSpan2,               ///< Two PD pixel lines are held in 1 line buffer. The PD pixel line width is up
                                            ///  to W/2.
    PixelSeparatorPixelSpan4,               ///< Four PD pixel lines are held in 1 line buffer. The PD pixel line width is up
                                            ///  to W/4.
    PixelSeparatorPixelSpan8                ///< Eight PD pixel lines are held in 1 line buffer. The PD pixel line width is up
                                            ///  to W/8.
} PDHwPixelSeparatorPixelSpan;

/// @brief Configuration parameters for the pixel separator.
typedef struct
{
    UINT16                      rowPerBlock;                            ///< Number of PD pixel rows in each block. A maximum
                                                                        ///  of 16 lines is assumed for each sparse PD block.
    UINT16                      pixelsPerBlock;                         ///< Number of pixels per block for each buffer.
    UINT16                      outputHeight;                           ///< Height of the block output.
    UINT16                      outputWidth;                            ///< Width of the block output.
    UINT16                      pdLMap[PDLibMaxLeftOrRightPDPixels];    ///< Pixel extraction array indices for left pixels:
                                                                        ///  [4][32].
    UINT16                      pdRMap[PDLibMaxLeftOrRightPDPixels];    ///< Pixel extraction array indices for right pixels:
                                                                        ///  [4][32].
    PDHwPixelSeparatorPixelSpan pixelSeparatorPixelSpan;                ///< Number of lines that should be stored in line
                                                                        ///  buffer and the length of each line.
} PDHwPixelSeparatorConfig;

/// @brief Coordinates for the resampler input.
typedef struct
{
    INT16       x;      ///< X coordinate.
    INT16       y;      ///< Y coordinate.
} PDHWResamplerPixel;

/// @brief Coefficients for the 6sQ3 operator.
typedef struct
{
    FLOAT   k0;         ///< K0 coefficient.
    FLOAT   k1;         ///< K1 coefficient.
    FLOAT   k2;         ///< K2 coefficient.
    FLOAT   k3;         ///< K3 coefficient.
} PDHWResamplerCoeff;

/// @brief Instruction parameters for the resampler.
typedef struct
{
    PDHWResamplerPixel  pixelLUT[PDLibResamplerInputCount];    ///< Input pixel coordinates for each instruction.
    PDHWResamplerCoeff  coeffLUT[PDLibResamplerInputCount];    ///< Operator coefficients for each instruction.
} PDHWResamplerInstruction;

/// @brief Modes of resampler power configurations.
typedef enum
{
    ResamplerConfigModeInvalid = -1,    ///< Type is unknown or invalid.
    ResamplerConfigModeRegularPower,    ///< Regular power mode.
    ResamplerConfigModeLowPower         ///< Low power mode in which only one out of four resampler operations are used for
                                        ///  each resampler. In Regular mode, four operations of each resampler can be used.
} PDHwResamplerConfigMode;

/// @brief Configuration parameters for the resampler.
typedef struct
{
    BOOL                        enable;                                     ///< Indicates whether to enable the resampler.
                                                                            ///
                                                                            ///  @valuesbul
                                                                            ///  - 0 -- FALSE
                                                                            ///  - 1 -- TRUE @tablebulletend

    PDHWResamplerInstruction    instruction[PDLibResamplerInstructionSize]; ///< Instructions for the resampler.
    UINT16                      inputHeight;                                ///< Height of the resampler block input after
                                                                            ///  adding padding pixels, if required.
    UINT16                      inputWidth;                                 ///< Width of the resampler block input after
                                                                            ///  adding padding pixels, if required.
    UINT16                      outputHeight;                               ///< Height of the resampler block output.
    UINT16                      outputWidth;                                ///< Number of pixels in each row of the resampler
                                                                            ///  output block.
    PDHwResamplerConfigMode     resamplerConfigMode;                        ///< Power configuration mode for the resampler.
} PDHwResamplerConfig;

/// @brief Configuration parameters for the FIR filter.
typedef struct
{
    BOOL    enable;                     ///< Indicates whether to enable the FIR filter.
                                        ///
                                        ///  @valuesbul
                                        ///  - 0 -- FALSE
                                        ///  - 1 -- TRUE @tablebulletend

    FLOAT   a0;                         ///< Coefficient a0.
    FLOAT   a1;                         ///< Coefficient a1.
    FLOAT   a2;                         ///< Coefficient a2.
    FLOAT   a3;                         ///< Coefficient a3.
    FLOAT   a4;                         ///< Coefficient a4.
    INT16   shift;                      ///< Shifter for the FIR filter.

    BOOL    FIRAdditionalOffsetEnable;  ///< Indicates whether an additional FIR offset is enabled.
                                        ///
                                        ///  @valuesbul
                                        ///  - 0 -- FALSE
                                        ///  - 1 -- TRUE
                                        ///
                                        ///  When the offset is enabled, it converts a negative value to a positive value by
                                        ///  adding an offset of 2^15 to the negative value.
} PDHwFIRConfig;

/// @brief Configuration parameters for the CSID pixel extractor.
typedef struct
{
    BOOL        enable;                             ///< Indicates whether to enable the pixel extractor.
                                                    ///
                                                    ///  @valuesbul
                                                    ///  - 0 -- FALSE
                                                    ///  - 1 -- TRUE @tablebulletend

    PDHwCrop    cropConfig;                         ///< Cropping coordinates of the pixel extractor.
    UINT16      blockHeight;                        ///< Block height of the native sensor repeating pattern. Maximum: 64.
    UINT16      blockWidth;                         ///< Block width of the native sensor repeating pattern. Maximum: 64.

    BOOL        pdPixelMap[PDLibMaxPixelsInBlock];  ///< Indicates whether a pixel in a block is a PD pixel.
                                                    ///
                                                    ///  Maximum: [64][64]
                                                    ///
                                                    ///  @valuesbul
                                                    ///  - 0 -- FALSE
                                                    ///  - 1 -- TRUE @tablebulletend
} PDHwCSIDPixelExtractorConfig;

/// @brief Configuration parameters for sparse PD hardware.
typedef struct
{
    PDHwLineExtractorConfig         LEConfig;                       ///< Configure the line extractor.
    PDHwPixelSeparatorConfig        PSConfig;                       ///< Configure the pixel separator.
    PDHwResamplerConfig             RSConfig;                       ///< Configure the resampler.
    PDHwFIRConfig                   FIRConfig;                      ///< Configure the FIR filter.
    PDHwCSIDPixelExtractorConfig    PEConfig;                       ///< Configure the pixel extractor.
}  SparsePDHwConfig;


/// @brief Configuration parameters for hardware PD spotlight detection.
typedef struct
{
    BOOL                            enable;                         ///< Indicates whether spotlight detection is enabled.
                                                                    ///
                                                                    ///  @valuesbul
                                                                    ///  - 0 -- FALSE
                                                                    ///  - 1 -- TRUE @tablebulletend

    SpotlightDetectionConfigMode    configMode;                     ///< Rule for ignoring L and R PD pixels.
    UINT16                          sequenceSaturatedCntThreshold;  ///< Threshold for the number of of saturated pixels in a
                                                                    ///  sequence.
    UINT32                          pixelThreshold;                 ///< If a pixel value is larger than this threshold, that
                                                                    ///  PD pixel will be ignored based on the configMode
                                                                    ///  setting.
} PDHwSpotlightDetectionConfig;

/// @brief Contains the pixel exposure type that the PD Library chooses when the sensor supports multiple PD exposure types.
typedef struct
{
    AlgoInputExposureType   PDPixelExposureType;    ///< Type of PD pixel exposure that is being chosen.
} PDPreferredExposureType;

/// @brief Contains tuning information about the software PD.
typedef struct
{
    BOOL                            enableLCRfromTuning;    ///< Indicates whether the LCR is enabled from PD Library
                                                            ///  tuning.
                                                            ///
                                                            ///  @valuesbul
                                                            ///  - 0 -- FALSE
                                                            ///  - 1 -- TRUE @tablebulletend
} PDSwInfo;

/// @brief Common configuration parameters for horizontal and vertical grids, and the LCR gain map.
typedef struct
{
    BOOL    gainMapEnable;          ///< Specifies whether the gain map is enabled.
                                    ///
                                    ///  - 0 -- FALSE
                                    ///  - 1 -- TRUE @tablebulletend

    UINT32  numberHorizontalGrids;  ///< Number of horizontal grids.
    UINT32  numberVerticalGrids;    ///< Number of vertical grids.
    UINT32  horizontalPhaseInit;    ///< Horizontal phase offset of the first pixel of the crop window.
    UINT32  verticalPhaseInit;      ///< Vertical phase offset of the first line of the crop window.
    UINT32  horizontalPhaseStep;    ///< Phase interval between two pixels.
    UINT32  verticalPhaseStep;      ///< Phase interval between two lines.
    UINT16  gainShift;              ///< Post-interpolation shift value.
} PDHwCommonGainMapConfigV3;

/// @brief common gaim map configurations parameters for the horizontal a vertical gain map.
typedef PDHwCommonGainMapConfigV3 PDHwCommonGainMapConfigV31;

/// @brief Horizontal & vertical gain map configuration
typedef struct
{
    PDHwCommonGainMapConfigV3       commonGainMap;                      ///< Common configuration for horizontal and vertical
                                                                        ///  grids, and the LCR gain map.
    PDHwGainMapInterpolationType    gainMapInterpolationType;           ///< Interpolation type for the gain map.
    UINT16                          leftUpLUT[PDLibGainMapLUTSize];     ///< Lookup table for an array of left PD pixel gain
                                                                        ///  maps.
    UINT16                          rightDownLUT[PDLibGainMapLUTSize];  ///< Lookup table for an array of right PD pixel gain
                                                                        ///  maps.
} PDHwHVGainMapConfigV3;

/// @brief Horizontal & vertical gain map configuration - V31
typedef struct
{
    PDHwCommonGainMapConfigV31      commonGainMap;                        ///< Common configuration for horizontal and vertical
                                                                          ///  grids, and the LCR gain map
    PDHwGainMapInterpolationType    gainMapInterpolationType;             ///< Gain Map Interpolation type
    UINT16                          leftUpLUT[PDLibGainMapLUTSizeV31];    ///< Look-up table for the left PD pixel gain
                                                                          ///  maps.
    UINT16                          rightDownLUT[PDLibGainMapLUTSizeV31]; ///< Look-up table for the right PD pixel gain
                                                                          ///  maps.
} PDHwHVGainMapConfigV31;

/// @brief Flexible grid configuration
typedef struct
{
    UINT16  regionHOffset;                      ///< Horizontal offset, measured in terms of pixels, from the left of the
                                                ///  input image
    UINT16  regionVOffset;                      ///< Vertical offset, measured in terms of lines, from the top of the input
                                                ///  image
    UINT16  regionWidth[PDLibHorizontalROINUM]; ///< Array of of horizontal grids. Each LR SAD can have its own ROI
                                                ///  configuration.
    UINT16  regionHeight[PDLibVerticalROINUM];  ///< Array of vertical grids. Each LR SAD can have its own ROI
                                                ///  configuration.
} PDHwROIConfig;

/// @brief Defines the horizontal pixel separator that is used to separate L and R pixels into two streams.
typedef struct
{
    BOOL        enable;                             ///< Indicates whether a module is enabled.
                                                    ///
                                                    ///  @valuesbul
                                                    ///  - 0 -- FALSE
                                                    ///  - 1 -- TRUE @tablebulletend

    UINT16      LRPixelMap[PDLibMaxHPSNumPixel];    ///< Separated left and right PD pixels of input block.
    UINT16      inputWidth;                         ///< Width of the block input for the left (or right) map.
    UINT16      inputHeight;                        ///< Height of the block input for the left (or right) map.
    UINT16      outWidth;                           ///< Width of the block output for the left (or right) map.
    UINT16      rightShift;                         ///< Amount of shift to be done in the horizontal separator.
    UINT16      earlyFlush;                         ///< Line number after the first flush in a dual or hybrid flush.
    UINT16      BLSLeftOffset;                      ///< Black level offset applied to the left PD pixels.
    UINT16      BLSRightOffset;                     ///< Black level offset applied to the left PD pixels.
} PDHwHorizontalPixelSeparator;

/// @brief Defines the vertical pixel separator that is used to separate the U and D pixels into two streams.
typedef struct
{
    BOOL    enable;                             ///< Indicates whether the vertical separator is enabled.
                                                ///
                                                ///  @valuesbul
                                                ///  - 0 -- FALSE
                                                ///  - 1 -- TRUE @tablebulletend

    UINT16  UDPixelMap[PDLibMaxVPSNumPixel];    ///< Up and down PD pixels of the input block.
    UINT16  inputWidth;                         ///< Width of the block input for the left (or right) map.
    UINT16  inputHeight;                        ///< Height of the block input for the left (or right) map.
    UINT16  outputWidth;                        ///< Width of the block output for the left (or right) map.
    UINT16  outputHeight;                       ///< Height of the block output for the left (or right) map.
} PDHwVerticalPixelSeparator;

/// @brief Defines the Polyphase filter that is used to map the left and right lines to a uniform sampling space.
typedef struct
{
    BOOL        enable;                                     ///< Indicates whether a module is enabled.
                                                            ///
                                                            ///  @valuesbul
                                                            ///  - 0 -- FALSE
                                                            ///  - 1 -- TRUE @tablebulletend

    UINT32      leftPixelmap[PDLibMaxPolyphaseNumPixel];    ///< Array of left PD pixel mappings in the stream.
    UINT32      rightPixelmap[PDLibMaxPolyphaseNumPixel];   ///< Array of right PD pixel mappings in the stream.
} PDHwPolyphaseFilter;

/// @brief Horizontal binning on the horizontal path.
typedef struct
{
    BOOL    enable;         ///< Indicates whether a module is enabled.
                            ///
                            ///  @valuesbul
                            ///  - 0 -- FALSE
                            ///  - 1 -- TRUE @tablebulletend

    UINT16  binPixelNum;    ///< Number of pixels to be binned horizontally.
    UINT16  postBinShift;   ///< Post-binning shift value.
} PDHwHorizontalHBinConfig;

/// @brief Horizontal binning on the vertical path.
typedef struct
{
    BOOL    enable;             ///< Indicates whether a module is enabled.
                                ///
                                ///  @valuesbul
                                ///  - 0 -- FALSE
                                ///  - 1 -- TRUE @tablebulletend

    UINT16  binPixelNum;        ///< Number of pixels to be binned horizontally.
    UINT16  postBinShift;       ///< Post-binning shift value.
    UINT16  blsUpPDOffset;      ///< Black level offset that applies to the up PD pixels.
    UINT16  blsDownPDOffset;    ///< Black level offset that applies to the down PD pixels.
} PDHwVerticalHBinConfig;

// @brief Horizontal IIR filter configuration parameters for phase detection.
typedef struct
{
    BOOL                enable;                         ///< Indicates whether the IIR filter is enabled.
                                                        ///
                                                        ///  @valuesbul
                                                        ///  - 0 -- FALSE
                                                        ///  - 1 -- TRUE @tablebulletend

    BOOL                IIRAdditionalOffsetEnable;      ///< Indicates whether IIR additional offset is enabled.
                                                        ///
                                                        ///  @valuesbul
                                                        ///  - 0 -- FALSE
                                                        ///  - 1 -- TRUE
                                                        ///
                                                        ///  When the parameter is enabled, it converts a negative value to a
                                                        ///  positive value by adding an offset of 2^15 to the value.

    BOOL                EnableIIRInitAfterSpotlight;    ///< Indicates whether the initialization condition is programmed for
                                                        ///  a spotlight.
                                                        ///
                                                        ///  @valuesbul
                                                        ///< - 0x0 -- IIR is not initialized
                                                        ///< - 0x1 -- IIR is initialized @tablebulletend

    UINT16              ModeInit;                       ///< Indicates whether the initialization value is programmed for the
                                                        ///  first three pixels.
                                                        ///
                                                        ///  @valuesbul
                                                        ///  - 0x0 -- First three pixels are set to 0
                                                        ///  - 0x1 -- First three pixels are from feedback and are LSB-aligned

    FLOAT               a0;                             ///< IIR filter coefficient a0 in Q15 format.
    FLOAT               a1;                             ///< IIR filter coefficient a1 in Q15 format.
    FLOAT               b0;                             ///< IIR filter coefficient b0 in Q15 format.
    FLOAT               b1;                             ///< IIR filter coefficient b1 in Q15 format.
    FLOAT               b2;                             ///< IIR filter coefficient b2 in Q15 format.
} PDHwHorizontalIIRConfig;

/// @brief Configuration parameters for the sum of absolute difference (SAD) on the LR1 and LR2 paths.
typedef struct
{
    BOOL            enable;     ///< Indicates whether a module is enabled.
                                ///
                                ///  @valuesbul
                                ///  - 0 -- FALSE
                                ///  - 1 -- TRUE @tablebulletend

    UINT16          numPhases;  ///< Select the number of phases to be generated per region by H1/H2 LR SAD.
                                ///
                                ///  @valuesbul
                                ///  - H1 phases can be {16, 32, 48, 64}
                                ///  - H2 phases can be {0, 16, 32}

    INT16           initPhases; ///< Select the initial phase for H1 or H2 LR SAD calculation.
} PDHwLRSADConfig;

/// @brief Programs the number of lines to skip after a valid line on the preprocessed or parsed path.
typedef struct
{
    BOOL    enable;             ///< Indicates whether a module is enabled.
                                ///
                                ///  @valuesbul
                                ///  - 0 -- FALSE
                                ///  - 1 -- TRUE @tablebulletend

    UINT16  writeDecimateLines; ///< Vertical skipping on preprocess or parsed output.
} PDHwWrtieSkipConfig;

/// @brief Defines the buffer modes on the LR and LCR paths.
typedef enum
{
    PDLibBufferModeInvalid = -1,
    PDLibBufferModeDual,
    PDLibBufferModeSingle,
    PDLibBufferModeMax
} PDLibBufferMode;

/// @brief Defines the output path for preprocessed output.
typedef enum
{
    PDLibPreprocessedOutMuxInvalid = -1,
    PDLibPreprocessedOutMuxH2IIR,
    PDLibPreprocessedOutMuxH2Polyphase,
    PDLibPreprocessedOutMuxV,
    PDLibPreprocessedOutMuxH1IIR,
    PDLibPreprocessedOutMuxH1Polyphase,
    PDLibPreprocessedOutMuxMax
} PDLibPreprocessedOutMux;

/// @brief Defines the output path for parsed output.
typedef enum
{
    PDLibParsedOutMuxInvalid = -1,
    PDLibParsedOutMuxV,
    PDLibParsedOutMuxLCR,
    PDLibParsedOutMuxMax
} PDLibParsedOutMux;

/// @brief Defines the flush modes.
typedef enum
{
    PDLibFlushModeInvalid = -1,
    PDLibFlushModeSingle,
    PDLibFlushModeDual,
    PDLibFlushModeHybrid,
    PDLibFlushModeMax
} PDLibFlushMode;

/// @brief Parameters used to configure PDAF V3 and LCR statistics ouput-related register.
typedef struct
{
    PDLibBufferMode         LRBufferMode;           ///< Select Single or Dual buffer mode for the LR1/H1 path.
    PDLibBufferMode         LCRBufferMode;          ///< Select Single or Dual buffer mode for the LCR.
    PDLibPreprocessedOutMux preprocessedOutMux;     ///< Select the output path for preprocessed output.
    PDLibParsedOutMux       parsedOutMux;           ///< Select the output path for parsed output.
    PDHwWrtieSkipConfig     preprocessedWriteSkip;  ///< Programs the number of lines to skip after a valid line on the
                                                    ///  preprocessed path.
    PDHwWrtieSkipConfig     parsedWriteSkip;        ///< Programs the number of lines to skip after a valid line on the parsed
                                                    ///  path.
    PDLibFlushMode          FlushMode;              ///< Select the LCR Flush mode: single, dual, hybrid.
} PDHwModuleConfig;

/// @brief Defines the interleave map masks.
///
/// For a hybrid flush, the binary mask pattern denotes which flush line is to be selected for left or right PD pixel output.
typedef enum
{
    PDLibInterleaveMaskInvalid = -1,
    PDLibInterleaveMaskFlush0,
    PDLibInterleaveMaskFlush1,
    PDLibInterleaveMaskMax,
} PDLibInterleaveMask;

/// @brief Interleave map, including the binary mask pattern that denotes which flush line is be selected for left or
///        right PD pixels.
typedef struct
{
    BOOL                enable;                         ///< Indicates whether a module is enabled.
                                                        ///
                                                        ///  @valuesbul
                                                        ///  - 0 -- FALSE
                                                        ///  - 1 -- TRUE @tablebulletend

    PDLibInterleaveMask leftPixelMask[PDLibMaxILMask];  ///< Flush mask for the left PD pixel.
    PDLibInterleaveMask rightPixelMask[PDLibMaxILMask]; ///< Flush mask for the right PD pixel.
} PDHwLCRInterleaveMap;

/// @brief Configuration parameters for the LCR gain map.
typedef struct
{
    PDHwCommonGainMapConfigV3   commonGainMapConfig;            ///< Common configuration for horizontal and vertical and LCR
                                                                ///  gain map
    UINT16                      centerLUT[PDLibGainMapLUTSize]; ///< Look-up table for the center gain map.
                                                                ///< Post-interpolation shift value
} PDHwLCRGainMapConfig;

/// @brief Configuration parameters for LCR gain map - V31
typedef struct
{
    PDHwCommonGainMapConfigV3   commonGainMapConfig;               ///< Common configuration for horizontal & vertical and LCR
                                                                   ///  gain map
    UINT16                      centerLUT[PDLibGainMapLUTSizeV31]; ///< Look-up table for the center gain map.
                                                                   ///< Post-interpolation shift value
} PDHwLCRGainMapConfigV31;

/// @brief The black level offset applied to LCR center pixels
typedef struct
{
    BOOL        enable;     ///< Indicates whether a module is enabled.
                            ///
                            ///  @valuesbul
                            ///  - 0 -- FALSE
                            ///  - 1 -- TRUE @tablebulletend

    UINT16      Offset;     ///< Black level offset applied to center pixels
} PDHwLCRBLSConfig;

/// @brief Extracts non-PD pixel rows to generate a row of Center pixels for LCR SAD processing.
typedef struct
{
    UINT16 blockWidth;                      ///< Block width in C pixels.
                                            ///
                                            ///  This value is a multiplier to the ROI width to compute the C region width: \n
                                            ///  blockWidth = lcrInputBlockWidth/binFactor

    UINT16 blockHeight;                     ///< LCR block height.
    UINT16 CFAWidth;                        ///< CFA pattern width.
    UINT16 CFAHeight;                       ///< CFA pattern height.
    UINT16 binPixels;                       ///< Programs the horizontal binning for C pixels.

    UINT32 lineMask[PDLibMaxLCRLineMask];   ///< Specifies the binary pattern that indicates the lines to be intercepted
                                            ///  for binning.
                                            ///
                                            ///  @valuesbul
                                            ///  - 0x0 -- Line is intercepted
                                            ///  - 0x1 -- Line is skipped; LSB-aligned @tablebulletend

    UINT32 flushMask[PDLibMaxLCRFlushMask]; ///< Specifies the binary pattern with 1 to indicate the input line at which
                                            ///  the LCR generates the output line.

    UINT32 compMask[PDLibMaxLCRCompMask];   ///< Array of LCR component mask registers.
                                            ///
                                            ///  @valuesbul
                                            ///  - 0 - Exclude the color component
                                            ///  - 1 - Include the color component for binning
                                            ///
                                            ///  Depending on the sensor format, the indices can correspond to different color
                                            ///  channels.

    INT16 compShift[PDLibMaxLCRCompShift];  ///< Indicates the number of bits by which each color component is to be shifted.
                                            ///
                                            ///  A value of all zeros indicates no shift. The value will change based on the
                                            ///  Bayer pattern.
} PDHwLCRCExtractorConfig;


/// @brief Defines a Moving Average module, which is a box filter and used only when LCR SAD is enabled.
typedef struct
{
    BOOL    enable;     ///< Indicates whether a module is enabled.
                        ///
                        ///  @valuesbul
                        ///  - 0 -- FALSE
                        ///  - 1 -- TRUE @tablebulletend

    UINT16  outMAMode;  ///< Denotes the power of 2 for the window size of LCR moving average.
} PDHwLCRMovingAverageConfig;

/// @brief Filter coefficients for normal fast IIR.
typedef struct
{
    UINT16  s1C;    ///< Filter coefficient for center pixels.
    UINT16  s2C;    ///< Filter coefficient for center pixels.
    UINT16  s3C;    ///< Filter coefficient for center pixels.
    UINT16  s1LR;   ///< Filter coefficient for LR pixels.
    UINT16  s2LR;   ///< Filter coefficient for LR pixels.
    UINT16  s3LR;   ///< Filter coefficient for LR pixels.
} PDHwLCRNormFastIIRCConfig;

/// @brief Defines different average calculation modes.
typedef enum
{
    PDLibAverageModeInvalid = -1,
    PDLibAverageModeFASTIIR,
    PDLibAverageModeMovingAverage,
    PDLibAverageModeMax
} PDLibAverageMode;

/// @brief Configuration parameters used to remove any residual uniformity issues that can hamper the LCR processing.
///
/// This is achieved by calculating the low pass for each signal and diving the signals by their low pass.
typedef struct
{
    BOOL                        enable;         ///< Indicates whether a module is enabled.
                                                ///
                                                ///  @valuesbul
                                                ///  - 0 -- FALSE
                                                ///  - 1 -- TRUE @tablebulletend

    PDLibAverageMode            averageMode;    ///< Specifies the average calculation mode.
    UINT16                      shiftLCR;       ///< Shift amount after the HDR block.
    UINT16                      delayCenter;    ///< Denotes the shift (power of 2) for a zero-centered window for averaging.
    UINT16                      delayLR;        ///< Denotes the shift (power of 2) for having a left or right window for
                                                ///  averaging.
    PDHwLCRNormFastIIRCConfig   IIRConfig;      ///< IIR filter coefficient.
} PDHwLCRNormFastConfig;

/// @brief Channel statistics configuration.
///
/// Channel statistics provides the summation image pixel value and saturate ratio based on configuring spotlight detection.
typedef struct
{
    BOOL    enable;     ///< Indicates whether a module is enabled.
                        ///
                        ///  @valuesbul
                        ///  - 0 -- FALSE
                        ///  - 1 -- TRUE @tablebulletend

    UINT16  LRShift;    ///< Programs the value by which to shift the input left and right pixels during channel
                        ///  statistics computation.
    UINT16  CShift;     ///< Programs the value by which to shift the input center pixels during channel statistics
                        ///  computation.
} PDHwChannelStatsConfig;

/// @brief Defines an array index for left and right PD pixels.
typedef enum
{
    PDLibPDPixelInvalid = -1,
    PDLibPDPixelLeft,
    PDLibPDPixelRight,
    PDLibPDPixelMax,
} PDLibPDPixel;

/// @brief Defines flush types for LCR.
typedef enum
{
    PDLibLCRFlushInvalid = -1,
    PDLibLCRFlush0,             ///< Flush the left PD pixel.
    PDLibLCRFlush1,             ///< Flush the right PD pixel.
    PDLibLCRFlushMax,
} PDLibLCRFlush;

/// @brief Programs the initial skip and pixel skip in the left and right channels for flush types 0 and 1.
typedef struct
{
    BOOL    enable;                                                 ///< Indicates whether a module is enabled.
                                                                    ///
                                                                    ///  @valuesbul
                                                                    ///  - 0 -- FALSE
                                                                    ///  - 1 -- TRUE @tablebulletend

    UINT8   initSkip[PDLibLCRFlushMax][PDLibPDPixelMax];            ///< Programs an initial skip value for pixels in Single
                                                                    ///  Flush mode, or flush 0 and flush 1 of Dual/Hybrid
                                                                    ///  Flush mode.
    UINT8   pixelSkip[PDLibPDPixelMax][PDLibLCRPixelSkipArraySize]; ///< Programs a pixel skip for the left and right channels
                                                                    ///  in Single Flush mode or flush 0 of Dual/Hybrid Flush
                                                                    ///  mode.
} PDHwPixelSkipConfig;

/// @brief Configuration parameters for the sum of absolute difference (SAD) on the LCR path.
typedef struct
{
    BOOL                enable;         ///< Indicates whether a module is enabled.
                                        ///
                                        ///  @valuesbul
                                        ///  - 0 -- FALSE
                                        ///  - 1 -- TRUE @tablebulletend

    UINT16              numPhases;      ///< Select the number of phases to be generated per region by the LCR, where
                                        ///  numPhases can be {0, 8, 16}.
    PDHwPixelSkipConfig LCRPixelSkip;   ///< Programs the initial skip and pixel skip for the left and right channels for flush
                                        ///  0 and 1.
} PDHwLCRSADConfig;

/// @brief Version 3 of LCR hardware configuration.
typedef struct
{
    BOOL                        enable;         ///< Indicates whether a module is enabled.
                                                ///
                                                ///  @valuesbul
                                                ///  - 0 -- FALSE
                                                ///  - 1 -- TRUE @tablebulletend

    PDHwCrop                    crop;           ///< Ensure that the C extraction block receives an integral number of rows
                                                ///  and columns of the repeating pattern of the Sparse PD sensor.
    PDHwLCRCExtractorConfig     CExtractor;     ///< Extracts non-PD pixel rows to generate a row of center pixels for LCR
                                                ///  SAD processing.
    PDHwLCRBLSConfig            BLS;            ///< Black level offset for center pixels.
    PDHwLCRGainMapConfig        gainMap;        ///< LCR gain map configuration.
    PDHwLCRMovingAverageConfig  movingAverage;  ///< Box filter applied to center pixels.
    PDHwHDRConfig               LRHDR;          ///< LCR HDR configuration.
    PDHwLCRNormFastConfig       normFast;       ///< Remove any residual uniformity issues that can hamper the LCR processing.
    PDHwLCRInterleaveMap        interleaveMap;  ///< Specify which flush line is to be selected for left and right PD pixels.
} PDHwLCRConfigV3;

/// @brief V31 LCR HW configuration
typedef struct
{
    BOOL                        enable;         ///< Disables/enables the module
    PDHwCrop                    crop;           ///< Ensure that the C extraction block receives an integral number of rows
                                                ///  and columns of the repeating pattern of Sparse PD sensor.
    PDHwLCRCExtractorConfig     CExtractor;     ///< Extracts non-PD pixel rows to generate a row of “Center”pixels for LCR
                                                ///  SAD processing
    PDHwLCRBLSConfig            BLS;            ///< Black level offset for center pixels
    PDHwLCRGainMapConfigV31     gainMap;        ///< LCR gain map configuration - V31
    PDHwLCRMovingAverageConfig  movingAverage;  ///< Box filter applied to center pixels
    PDHwHDRConfig               LRHDR;          ///< LCR HDR configuration
    PDHwLCRNormFastConfig       normFast;       ///< Remove any residual uniformity issues which can hamper the LCR
                                                ///  processing
    PDHwLCRInterleaveMap        interleaveMap;  ///< Specify which flush line should be selected for l/R PD pixel
} PDHwLCRConfigV31;

/// @brief Configuration parameters for V3 PD HW vertical path.
typedef struct
{
    PDHwHDRConfig                   HDRConfig;          ///< Configuration for HDR processing.
    PDHwHorizontalHBinConfig        HBinConfig;         ///< Configuration for horizontal binning.
    PDHwPolyphaseFilter             polyphaseFilter;    ///< Configuration for the Polyphase filter.
    PDHwFIRConfig                   FIRConfig;          ///< Configuration for the FIR filter.
    PDHwHorizontalIIRConfig         IIRConfig;          ///< Configuration for the IIR filter.
}  PDHwHorizontalPathConfig;

/// @brief Configuration parameters for version 3 of the PD hardware horizontal path. The path includes LR1/H1 and
/// LR2/H2 configuration.
typedef struct
{
    PDHwHorizontalPixelSeparator    horizontalPixelSeparator;   ///< Separate L and R pixel into two streams.
    PDHwSpotlightDetectionConfig    spotlightDetectionConfig;   ///< Spotlight detection configuration.
    PDHwHVGainMapConfigV3           gainMap;                    ///< Horizontal gain map configuration.
    PDHwHorizontalPathConfig        H1Path;                     ///< Processing block on the LR1 path.
    PDHwHorizontalPathConfig        H2Path;                     ///< Processing block on the LR2 path.
}  PDHwHorizontalConfig;

/// @brief Configuration parameters for V31 PD HW Horizontal path. Horizontal path has LR1/H1 configuration
typedef struct
{
    PDHwHorizontalPixelSeparator    horizontalPixelSeparator;   ///< Separating L and R pixel to 2 streams
    PDHwSpotlightDetectionConfig    spotlightDetectionConfig;   ///< Spotlight detection configuration
    PDHwHVGainMapConfigV31          gainMap;                    ///< Horizontal gain map configuration
    PDHwHorizontalPathConfig        H1Path;                     ///< Processing block in LR1 path
}  PDHwHorizontalConfigV31;

/// @brief Configuration Modules for V3 PD HW Vertical path.
typedef struct
{
    PDHwVerticalPixelSeparator  verticalPixelSeparator; ///< Separate up and down pixels into two streams.
    PDHwVerticalHBinConfig      binConfig;              ///< Horizontal binning on the vertical path.
    PDHwHVGainMapConfigV3       gainMap;                ///< Vertical gain map configuration.
}  PDHwVerticalConfig;

/// @brief Configuration Modules for V31 PD HW Vertical path.
typedef struct
{
    PDHwVerticalPixelSeparator  verticalPixelSeparator; ///< Separating U and D pixel to 2 streams
    PDHwVerticalHBinConfig      binConfig;              ///< Horizontal binning on vertical path
}  PDHwVerticalConfigV31;

/// @brief Configuration parameters of PDAF v3 for vertical path
typedef struct
{
    BOOL                            enable;             ///< Indicates whether a module is enabled.
                                                        ///
                                                        ///  @valuesbul
                                                        ///  - 0 -- FALSE
                                                        ///  - 1 -- TRUE @tablebulletend

    PDHwCSIDPixelExtractorConfig    PEConfig;           ///< Configure the pixel extractor.
    PDHwLineExtractorConfig         LEConfig;           ///< Configure the line extractor.
    PDHwCrop                        cropConfig;         ///< Cropping coordinates of the pixel extractor.
    PDHwHorizontalConfig            horizontalConfig;   ///< Horizontal path for LR1/LR2 configuration.
    PDHwVerticalConfig              verticalConfig;     ///< Vertical path configuration.
}  PDHwPDConfigV3;

/// @brief Configuration parameters of PDAF v31 for vertical path
typedef struct
{
    BOOL                            enable;             ///< Disables/enables the module
    PDHwCSIDPixelExtractorConfig    PEConfig;           ///< Configure the pixel extractor
    PDHwLineExtractorConfig         LEConfig;           ///< Configure the line extractor
    PDHwCrop                        cropConfig;         ///< Cropping coordinates of the pixel extractor
    PDHwHorizontalConfigV31         horizontalConfig;   ///< Horizontal path LR1 config
    PDHwVerticalConfigV31           verticalConfig;     ///< Vertical path config
}  PDHwPDConfigV31;

/// @brief Represents parsed and preprocessed buffer dimension
typedef struct
{
    PDLibDimensionInfo  parsedBuffer;          ///< Dimensions of a parsed buffer.
    PDLibDimensionInfo  preprocessedBuffer;    ///< Dimensions of a preprocessed buffer.
} PDBufferDimension;

/// @brief Configuration parameters for PDAF V3 SAD and channel statistics.
typedef struct
{
    PDHwROIConfig           ROIConfig;          ///< Flexible grid configuration.
    PDHwLRSADConfig         LR1SAD;             ///< SAD configuration for LR1/H1 path.
    PDHwLRSADConfig         LR2SAD;             ///< SAD configuration for LR2/H2 path.
    PDHwLCRSADConfig        LCRSAD;             ///< SAD configuration for LCR path.
    PDHwChannelStatsConfig  ChannelStats;       ///< Sum of the image pixel value and saturate ratio based on spotlight
                                                ///  detection.
    PDHwModuleConfig        ModuleConfig;       ///< PD buffer-related configuration; that is, a preprocessed buffer tap point.
    PDBufferDimension       pdBufferDimension;  ///< Parsed and preprocessed buffer dimensions.
} PDHwOutputConfigV3;

/// @brief Defines sensor config which is requested by PDLib
typedef struct
{
    BOOL isVPDDataReal;     ///< Indicates whether sensor streams real or dummy data for vertical stream
} SensorPDConfig;

/// @brief PDAF V31 SAD and channel stat's configurations
typedef struct
{
    PDHwROIConfig           ROIConfig;         ///< Flexible grid configuration
    PDHwLRSADConfig         LR1SAD;            ///< SAD configuration for LR1/H1 path
    PDHwLCRSADConfig        LCRSAD;            ///< SAD configuration for LCR path
    PDHwChannelStatsConfig  ChannelStats;      ///< summation image pixel value and saturate ratio based on
                                               ///  spotlightDetection
    PDHwModuleConfig        ModuleConfig;      ///< PD buffer related configuration i.e. preprocessed buffer tap point
    PDBufferDimension       pdBufferDimension; ///< Parsed and preprocessed buffer dimension
    UINT32                  statsBufSize;      ///< Memory requirement of this stripe's stats buffer
    UINT32                  parsedBufSize;     ///< Memory requirement of this stripe's parsed PD buffer
    UINT32                  preProcBufSize;    ///< Memory requirement of this stripe's preProcessed PD buffer
    UINT32                  statsOffset;       ///< Offset into stats buffer from where right stripe data is to be written
    UINT32                  parsedBufOffset;   ///< Offset into parsed out buffer from where this stripe data is to be written
    UINT32                  preProcBufOffset;  ///< Offset into pre-processed buffer from where this stripe data is to be written
} PDHwOutputConfigV31;

/// @Configuration parameters for V21 PD hardware.
typedef struct
{
    BOOL                            enablePDHw;                     ///< Indicates whether the PD hardware is enabled.
                                                                    ///
                                                                    ///  @valuesbul
                                                                    ///  - 0 -- FALSE (Disabled)
                                                                    ///  - 1 -- TRUE (Enabled) @tablebulletend

    PDHwPathSelect                  pathSelect;                     ///< Indicates the selected dual PD path.
                                                                    ///
                                                                    ///  @valuesbul
                                                                    ///  - 0 -- PD hardware output
                                                                    ///  - 1 -- Camera interface extracted image
                                                                    ///  @tablebulletend

    BOOL                            enableEarlyInterrupt;           ///< Indicates whether an early interrupt is to be enabled.
                                                                    ///
                                                                    ///  @valuesbul
                                                                    ///  - 0 -- FALSE
                                                                    ///  - 1 -- TRUE @tablebulletend

    UINT32                          earlyInterruptTransactionCount; ///< Number of early interrupt transactions.

    UINT32                          firstPixelSelect;               ///< Specifies which pixel is selected first.
                                                                    ///
                                                                    ///  @valuesbul
                                                                    ///  - 0 -- Right pixel
                                                                    ///  - 1 -- Left pixel @tablebulletend

    PDHwCrop                        cropConfig;                     ///< Cropping coordinates of dual PD.
    PDHwGainMapConfig               gainMapConfig;                  ///< Configure the gain map.
    PDHwBinConfig                   binConfig;                      ///< Configure PD skip and binning.
    PDHwBLSConfig                   BLSConfig;                      ///< Configure the PD BLS.
    PDHwHDRConfig                   HDRConfig;                      ///< Configure the PD HDR.
    PDHwIIRConfig                   IIRConfig;                      ///< Configure the PD IIR filter.
    PDHwSADConfig                   SADConfig;                      ///< Configure the PD SAD.
    PDHwLCRConfig                   LCRConfig;                      ///< Configure the LCR hardware.

    PDHwModeSelect                  modeSelect;                     ///< Specifies the selected PD hardware mode.
                                                                    ///
                                                                    ///  @valuesbul
                                                                    ///  - 0 -- Dual PD
                                                                    ///  - 1 -- Sparse PD @tablebulletend

    SparsePDHwConfig                sparseConfig;                   ///< Configure the sparse PD hardware.
                                                                    ///  Dual PD configuration is shared between the dual
                                                                    ///  and sparse PDs.
    PDHwProcessedPDOutTapPoint      processedPDOutputTapPoint;      ///< Tap point of preprocessed PD output.
    PDHwSpotlightDetectionConfig    spotlightDetectionConfig;       ///< configuration for spotlight detection hardware.
    PDHWSFELCRConfig                SFELCRConfig;                   ///< SFE LCR configuration.
    PDPreferredExposureType         pdPreferredExposureType;        ///< Exposure type for PD pixels.
} PDHWConfigV2;

/// @brief Represents V3.0 PD hardware configuration
typedef struct
{
    BOOL                    enablePDHw;                     ///< Indicates whether the PD hardware is enabled.
                                                            ///
                                                            ///  @valuesbul
                                                            ///  - 0 -- FALSE (Disabled)
                                                            ///  - 1 -- TRUE (Emabled) @tablebulletend

    PDHwPathSelect          pathSelect;                     ///< Indicates the selected dual PD path.
                                                            ///
                                                            ///  @valuesbul
                                                            ///  - 0 -- PD hardware output
                                                            ///  - 1 -- Camera interface extracted image @tablebulletend

    BOOL                    enableEarlyInterrupt;           ///< Indicates whether an early interrupt is to be enabled.
                                                            ///
                                                            ///  @valuesbul
                                                            ///  - 0 -- FALSE
                                                            ///  - 1 -- TRUE @tablebulletend

    UINT32                  earlyInterruptTransactionCount; ///< Number of early interrupt transactions.

    UINT32                  firstPixelSelect;               ///< Specifies which pixel is selected first.
                                                            ///
                                                            ///  @valuesbul
                                                            ///  - 0 -- Right pixel
                                                            ///  - 1 -- Left pixel @tablebulletend

    PDHwModeSelect          modeSelect;                     ///< Specifies the selected PD hardware mode.
                                                            ///
                                                            ///  @valuesbul
                                                            ///  - 0 -- Dual PD
                                                            ///  - 1 -- Sparse PD @tablebulletend

    PDPreferredExposureType pdPreferredExposureType;        ///< Exposure type for PD pixels.
    PDHwPDConfigV3          PDConfig;                       ///< PD hardware configuration for PDAF V3.
    PDHwLCRConfigV3         LCRConfig;                      ///< LCR hardware configuration for PDAF V3.
    PDHwOutputConfigV3      OutputConfig;                   ///< Buffer configuration including SADs and channel statistics.
    PDHwParseInfo           parseInfo;                      ///< PD statistics parse information.
    PDHwOverride            overrideSettings;               ///< Client override request being used for PDHW configuration.
    SensorPDConfig          sensorConfig;                   ///< PDLib's request for sensor configuration.
} PDHWConfigV3;

/// @brief Represents V3.1 PD HW configuration
typedef struct
{
    BOOL                    enablePDHw;                     ///< Indicates whether the PD hardware is enabled.
                                                            ///  - 0 -- FALSE
                                                            ///  - 1 -- TRUE
                                                            ///  If enablePDHw is false, the PD hardware is disabled.
    PDHwPathSelect          pathSelect;                     ///< Indicates the selected dual PD path.
                                                            ///  - 0 -- PD hardware output
                                                            ///  - 1 -- Camera interface extracted image
    BOOL                    enableEarlyInterrupt;           ///< Indicates whether an early interrupt is to be enabled.
                                                            ///  - 0 -- FALSE
                                                            ///  - 1 -- TRUE
    UINT32                  earlyInterruptTransactionCount; ///< Number of early interrupt transactions.
    UINT32                  firstPixelSelect;               ///< Specifies which pixel is selected first.
                                                            ///  - 0 -- Right pixel
                                                            ///  - 1 -- Left pixel
    PDHwModeSelect          modeSelect;                     ///< Specifies the selected PD hardware mode.
                                                            ///  - 0 -- Dual PD
                                                            ///  - 1 -- Sparse PD
    PDPreferredExposureType pdPreferredExposureType;        ///< Exposure type for PD pixels
    PDHwPDConfigV31         PDConfig;                       ///< PD HW config for PDAF V31
    PDHwLCRConfigV31        LCRConfig;                      ///< LCR HW config for PDAF V31
    PDHwOutputConfigV31     OutputConfig;                   ///< Buffer config including SADs and channel stat
} PDHWConfigV31;

// @brief PD hardware configuration for each version.
struct PDHwConfig
{
    union
    {
        PDHWConfigV2    V2;    ///< V2 PD HW configuration
        PDHWConfigV3    V3;    ///< V3 PD HW configuration
        PDHWConfigV31   V31[2];///< V31 PD HW configuration
    };
};

/// @brief Contains information required by the PD Library to calculate the maximum buffer size for preprocess and
///        parsed buffers.
typedef struct
{
    UINT32                  sensorMode;             ///< Specifies the sensor mode.
    PDLibSensorNativeInfo   nativePatternInfo;      ///< PDAF pattern for the sensor.
    PDLibDataBufferInfo     bufferDataInfo;         ///< Information about the buffer data.
} PDSensorInfo;

/// @brief Contains a PDSensorInfo array thatincludes information for each sensor mode in SeamlessTransitionModeList.
typedef struct
{
    UINT32          arrayCount;             ///< Number of valid rows in pSensorInfoArray.
    PDSensorInfo*   pSensorInfoArray;       ///< Pointer to the first element of the PDSensorInfo array.
} PDSensorInfoArray;

/// @brief Contains the maximum possible width and height for preprocess and parsed buffers.
typedef struct
{
    PDLibDimensionInfo  preprocessed;   ///< Maximum width and height for a preprocessed buffer.
    PDLibDimensionInfo  parsed;         ///< Maximum width and height for a parsed buffer.
} PDHwBufferInfo;

/// @brief Contains all PD hardware conditions and configuration for a seamless sensor mode.
// Example: We have 3 seamlessMode mode0 mode2 mode4, then number is 3
//          seamlessSensorModes[] save the mode [0, 2, 4]
//          pdhwConds[] save mode0, mode2, mode4's PDHWEnableConditions
//          pdhwConfigs[] save mode0, mode2, mode4's PDHwConfig
typedef struct
{
    UINT                    numOfSeamlessMode;                         ///< Total number of seamless sensor modes.
    UINT                    seamlessSensorModes[MAXSEAMLESSMODECOUNT]; ///< Array of seamless sensor modes (like sensor
                                                                       ///  mode 0, 2, 4).
    PDHWEnableConditions    pdhwConds[MAXSEAMLESSMODECOUNT];           ///< Array of PD hardware enable conditions.
    PDHwConfig              pdhwConfigs[MAXSEAMLESSMODECOUNT];         ///< Array of PD hardware configurations for a hardware
                                                                       ///  module.
} MultiSetPDHwSetting;

/// @brief Contains tuning information about the PD hardware.
typedef struct
{
    BOOL    enableLCRfromTuning;    ///< Indicates whether the LCR is enabled from PD Library tuning.
                                    ///
                                    ///  @valuesbul
                                    ///  - 0 -- FALSE
                                    ///  - 1 -- TRUE @tablebulletend

    BOOL    enablePDHWfromTuning;   ///< Indicates whether the PD hardware module is enabled.
                                    ///
                                    ///  @valuesbul
                                    ///  - 0 -- FALSE
                                    ///  - 1 -- TRUE @tablebulletend

    BOOL    enableParsedoutput;     ///< Indicates whether the parsed output path is enabled.
                                    ///
                                    ///  @valuesbul
                                    ///  - 0 -- FALSE
                                    ///  - 1 -- TRUE @tablebulletend

    BOOL    enableRDIPDAF;          ///< Indicates whether the RDIPDAF port is to be enabled based on the PD hardware
                                    ///  configuration.
                                    ///
                                    ///  @valuesbul
                                    ///  - 0 -- FALSE
                                    ///  - 1 -- TRUE @tablebulletend
    BOOL    enableRDIPDAF2;         ///< Indicates whether the RDIPDAF2 port is to be enabled or disabled based on PDLib
                                    ///  decision.
                                    ///
                                    ///  @valuesbul
                                    ///  - 0 -- FALSE
                                    ///  - 1 -- TRUE @tablebulletend
} PDHwInfo;

/// @brief Represents the PD offset maps of PDAF calibration data.
typedef struct
{
    BOOL    isAvailableHorizontal;                          ///< Indicates whether horizontal offset map is available.
                                                            ///
                                                            ///  @valuesbul
                                                            ///  - 0 -- FALSE
                                                            ///  - 1 -- TRUE @tablebulletend

    BOOL    isAvailableVertical;                            ///< Indicates whether the vertical offset map is available.
                                                            ///
                                                            ///  @valuesbul
                                                            ///  - 0 -- FALSE
                                                            ///  - 1 -- TRUE @tablebulletend

    BOOL    isAvailableDiagonal;                            ///< Indicates whether the diagonal offset map is available.
                                                            ///
                                                            ///  @valuesbul
                                                            ///  - 0 -- FALSE
                                                            ///  - 1 -- TRUE @tablebulletend

    UINT16  offsetMapCalDistance;                           ///< Distance which is used to calibrate this offset map.
    UINT16  mapWidthPdOffset;                               ///< Width of the PD offset map.
    UINT16  mapHeightPdOffset;                              ///< Height of the PD offset map.
    FLOAT   pdOffsetMapHorizontal[PDLibMaxWindowCount];     ///< Array of PD offset values for the horizontal flow.
    FLOAT   pdOffsetMapVertical[PDLibMaxWindowCount];       ///< Array of PD offset values for the vertical flow.
    FLOAT   pdOffsetMapDiagonal[PDLibMaxWindowCount];       ///< Array of PD offset values for the diagonal flow.
} PDOffsetMap;

/// @brief Represents PDAF calibration data for type2.
typedef struct
{
    BOOL        isAvailable;                                        ///< Indicates whether the current calibration is valid.
                                                                    ///
                                                                    ///  @valuesbul
                                                                    ///  - 0 -- FALSE
                                                                    ///  - 1 -- TRUE @tablebulletend

    UINT16      versionNum;                                         ///< Version number.
    UINT16      mapWidth;                                           ///< Width of the gain map.
    UINT16      mapHeight;                                          ///< Height of the gain map.
    UINT16      leftGainMap[PDLibGainMapLUTSize];                   ///< Lookup table of the left pixel gain map.
    UINT16      rightGainMap[PDLibGainMapLUTSize];                  ///< Lookup table of the right pixel gain map.
    UINT16      centerGainMap[PDLibGainMapLUTSize];                 ///< Lookup table of the center pixel gain map.
    UINT16      upGainMap[PDLibGainMapLUTSize];                     ///< Lookup table of the up pixel gain map.
    UINT16      downGainMap[PDLibGainMapLUTSize];                   ///< Lookup table of the down pixel gain map.
    INT16       PDConversionCoeff[PDLibMaxWindowCount];             ///< Coefficient (DCC) for PD conversion.
    INT16       pdConversionCoeffVertical[PDLibMaxWindowCount];     ///< Coefficient (DCC) for vertical PD conversion.
    UINT16      versionNumDCC;                                      ///< DCC version number.
    UINT16      qFactorDCC;                                         ///< DCC Q factor.
    UINT16      mapWidthDCC;                                        ///< Width of the DCC map.
    UINT16      mapHeightDCC;                                       ///< Height of the DCC map.
    PDOffsetMap pdOffsetMaps;                                       ///< 2-dimensional PD offset maps.
} PDLibCalibration;

/* @} *//* end_addtogroup chi_pdlib_macros */

#pragma pack(pop)

#ifdef __cplusplus
}
#endif // __cplusplus

#endif // CHIPDLIBCOMMON_H