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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  chi.h
/// @brief CamX Hardware Interface (CHI) definition
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef CHI_H
#define CHI_H

#include "camxcdktypes.h"
#include "chicommon.h"
#include "chicommondefs.h"
#include <stdio.h>

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

#pragma pack(push, 8)

/** @addtogroup chi_common_defs
@{ */

typedef UINT  VariantGroup;      ///< Identifier for a prunable variant group.
typedef UINT  VariantType;       ///< Name of a prunable variant group.

typedef VOID* IMAGEBUFFERHANDLE; ///< Pointer to the handle for the image buffer.

typedef UINT32 ResourceID;       ///< Identifier for the resource used by the Resource Manager.

/// @brief Tuple-like structure that associates a variant group and variant type used in pruning comparisons.
struct PruneVariant {
    VariantGroup group; ///< Prunable variant group.
    VariantType  type;  ///< Type of prunable variant group.
};

/// @brief Defines a list of prune variants.
struct PruneSettings {
    UINT                numSettings; ///< Length of pVariants.
    const PruneVariant* pVariants;   ///< Pointer to the list of variants.
};

static const UINT32 MaxNumImageSensors              = 32;  ///< Total number of cameras on a device.
static const UINT32 BufferQueueDepth                = 16;  ///< Depth of the buffer queue.
static const UINT32 PrivBufferQueueDepth            = 32;  ///< Depth of the private buffer queue, calculated as follows:
                                                            ///  FD+RDI,(2*MFSR request + 1 B2Y)*(2 active camera)*2.
static const UINT32 MaximumChiPipelineTagsPublished = 300; ///< Maximum number of tags published by the pipeline.
static const UINT32 MaximumContextTagsPublished     = 50;  ///< Maximum number of context-based tags published by the
                                                           ///  pipeline.
static const UINT32 MaxMetadataPerRequest           = 2;   ///< Maximum number of metadata buffers that can be sent per
                                                           ///  request.
static const UINT32 MaxOutputStreamsPerRequest      = 32;  ///< Maximum number of output streams per request.
static const UINT32 MaxPerBufferMetadata            = 10;  ///< Maximum number of per-buffer metadata entries.
static const UINT32 MaxSensorStreamConfigs          = 10;  ///< Maximum number of sensor stream configurations.
static const UINT16 MaximumStringLength             = 256; ///< Maximum value for the string length.
static const UINT16 MaxEEPROMCustomInfoCount        = 50;  ///< Maximum number of custom elements configurable in EEPROM
                                                           ///  custom information.
static const UINT16 MaxAFCalibrationDistances       = 10;  ///< Max AF calibration distance can be configured in EEPROM
static const UINT   MaxSensorModes                  = 50;  ///< Maximum number of sensor modes.
static const UINT   MaxInputStreams                 = 56;  ///< Maximum number of input streams between CamX and CHI.
static const UINT   MaxOutputStreams                = 20;  ///< Maximum number of output streams between CamX and CHI.
static const UINT   MaxNodesInPipelineDesc          = 20;  ///< Maximum number of nodes in a pipeline descriptor.
static const UINT   MaxLinksInPipelineDesc          = 20;  ///< Maximum number of links in a pipeline descriptor.
static const UINT   MaxLinkNodeDescsInPipelineDesc  = 20;  ///< Maximum number of link node descriptors in a pipeline
                                                           ///  descriptor.
static const UINT   MaxOutputBuffersInPipelineDesc  = 16;  ///< Maximum number of output buffer descriptors in a pipeline
                                                           ///  descriptor.
static const UINT32 MaxActiveRealtimePipelines      = 4;   ///< Maximum number of concurrent real-time pipelines in a session.
static const UINT   MaxNumberOfModes                = 4;   ///< Maximum number of transition or pipeline modes.
static const UINT   MaxNumSupportedFormats          = 6;   ///< Maximum number of supported format.
static const UINT32 MaxSensorVirtualChannelID       = 32;  ///< Maximum number of virtual channel IDs.
static const UINT32 MaxSensorVirtualChannelCount    = 2;   ///< Maximum number of virtual channel counts.
static const UINT32 MaximumNumTransitionsSupported  = 10;  ///< Maximum number of supported transitions.
static const UINT32 MaxNumberOfSessions             = 4;   ///< Maximum number of sessions.
static const UINT32 MaxFrequencyModulations         = 2;   ///< Maximum number of frequency modulations supported by the mode
static const UINT   MaxFormatTableSize              = (MaxInputStreams + MaxOutputStreams) * MaxNumSupportedFormats;
                                                           ///< Maximum size of Format table
static const UINT32 MaxNumHMSFailedJobs             = 10;  ///< Maximum number of failed jobs for HMS

// DebugData & TuningMetadata partitions
static const UINT DebugDataPartitionsIFE            = 2; ///< Short and long IFE support (MFHDR use case).
static const UINT DebugDataPartitionsBPS            = 2; ///< For backward compatibility in an MFNR use case.

static const UINT DebugDataPartitionsIPE            = 3; ///< For backward compatibility. This variable does not consider scaler
                                                         ///  data in an MFNR use case.
static const UINT DebugDataPartitionsMimasIPE       = 5; // Short and long context IPE newly added to (MFHDR usecase)

static const UINT DebugDataPartitionsOPE            = 2; ///< Identifies one partition for real time and one partition for the Offline
                                                         ///  Processing Engine (OPE).
static const UINT DebugDataPartitionsTFE            = 2; ///< Short and long TFE support (MFHDR use case).

// There will be 6 (Full/DS4/DS16/VideoFull/VideoDS4/VideoDS16)input for every physical camera
static const UINT32 MaxPhysicalCameraInput = MaxNumImageSensors * 6; ///< Maximum number of input configurations for a
                                                                     ///  physical camera.

// Buffer mem flags
const UINT32 BufferMemFlagHw          = (1 << 0);  ///< Hardware can access the buffer.
const UINT32 BufferMemFlagProtected   = (1 << 1);  ///< Buffer is protected.
const UINT32 BufferMemFlagCache       = (1 << 2);  ///< Buffer is cache enabled.
const UINT32 BufferMemFlagLockable    = (1 << 3);  ///< Buffer can be locked.

// Link flags
const UINT32 LinkFlagDisableLateBinding    = (1 << 0);   ///< Disables late binding on a link for the image buffer manager.
                                                         ///
                                                         ///  When set, the image buffer manager gets buffers from a dedicated
                                                         ///  group. Thus, buffers at this port are not shared with any other
                                                         ///  image buffer manager.

const UINT32 LinkFlagDisableSelfShrinking  = (1 << 1);   ///< Disables self-shrinking of buffers allocated at this output port.
                                                         ///
                                                         ///  When set, the image buffer manager gets buffers from a dedicated
                                                         ///  group. Thus, buffers at this port will not be shared with any
                                                         ///  other image buffer manager.

const UINT32 LinkFlagSinkInplaceBuffer     = (1 << 2);   ///< Indicates that the buffer at this output port of the in-place
                                                         ///  node is a sink buffer.
                                                         ///
                                                         ///  When set, the properties of this sink port are provided to the
                                                         ///  parent node to create a non-sink HAL buffer.

const UINT32 LinkFlagNoBuffersRequired     = (1 << 3);   ///< Indicates whether the link requires output buffers.
const UINT32 LinkFlagFallbackBufferManager = (1 << 4);   ///< Indicates if a shared sink link should provide a fallback buffer
                                                         ///  manager for use when a target sink buffer is not available.
const UINT32 LinkFlagObeyImmediateCount    = (1 << 5);   ///< Indicates if the immediate count mentioned in pipeline must
                                                         ///  be obeyed.
#ifdef CAMERA3_API_HIGH_PERF
const UINT32 LinkFlagDisableCrop           = (1 << 6);   ///< disables crop per port. Only supported in lemans.
#endif // CAMERA3_API_HIGH_PERF

typedef VOID* CHIHANDLE;                   ///< Handle for the CHI driver.
typedef VOID* CHIPIPELINEDESCRIPTOR;       ///< Descriptor for the pipeline.
typedef VOID* CHIPIPELINEHANDLE;           ///< Handle for the pipeline.
typedef VOID* CHIMETAHANDLE;               ///< Handle for the metadata.
typedef VOID* CHIMETADATAITERATOR;         ///< Iterator for the metadata.
typedef VOID* CHIMETAPRIVATEDATA;          ///< Private data associated with the metadata.
typedef VOID* CHITARGETBUFFERINFOHANDLE;   ///< Handle for the buffer information.
typedef VOID* CHISTREAMHANDLE;             ///< Handle for the CHI session.
typedef VOID* CHISESSIONHANDLE;            ///< Handle for the CHI session.

typedef UINT32 NodeProperty;               ///< Identifier for the node property.
static const NodeProperty NodePropertyCustomLib                  = 1;   ///< Indicates that the node is a customer library.
static const NodeProperty NodePropertyProfileId                  = 2;   ///< Instance profile ID for hardware layer nodes.
static const NodeProperty NodePropertyStabilizationType          = 3;   ///< Stabilization type that will be used by the
                                                                        ///  node.
static const NodeProperty NodePropertyProcessingType             = 4;   ///< Processing type that will be used by the node.

static const NodeProperty NodePropertyIPEDownscale               = 5;   ///< Node property that indicates that it is used
                                                                        ///  only for downscaling.

static const NodeProperty NodePropertyStatsSkipPattern           = 6;   ///< Skip pattern to be used for statistics.
static const NodeProperty NodePropertyIFECSIDHeight              = 7;   ///< CSID height to be configured for IFE.
static const NodeProperty NodePropertyIFECSIDWidth               = 8;   ///< CSID width to be configured for IFE.
static const NodeProperty NodePropertyIFECSIDLeft                = 9;   ///< CSID left to be configured for IFE.
static const NodeProperty NodePropertyIFECSIDTop                 = 10;  ///< CSID top to be configured for IFE.

static const NodeProperty NodePropertyNodeClass                  = 11;  ///< Node class: bypassable node, default node, or
                                                                        ///  in-place node.

static const NodeProperty NodePropertyGPUCapsMaskType            = 12;  ///< Capabilities mask type for a GPU instance.
static const NodeProperty NodePropertyIPEDownscaleWidth          = 13;  ///< Downscale width for an IPE instance.
static const NodeProperty NodePropertyIPEDownscaleHeight         = 14;  ///< Downscale height for an IPE instance.
static const NodeProperty NodePropertyEnbaleIPECHICropDependency = 15;  ///< Wait for cropping information in the IPE.

static const NodeProperty NodePropertyEnableFOVC                 = 16;  ///< Indicates that field of view (FOV) compensation
                                                                        ///  is enabled.

static const NodeProperty NodePropertyStitchMaxJpegSize          = 17;  ///< Maximum JPEG size for a dual camera stitched
                                                                        ///  frame.

static const NodeProperty NodePropertyForceSingleIFEOn           = 18;  ///< Force the image front end (IFE) to a single IFE.
static const NodeProperty NodePropertySkipUpdatingBufferProperty = 19;  ///< Deprecated. Skip the creation of a buffer
                                                                        ///  manager.
static const NodeProperty NodePropertyContext                    = 20;  ///< Identify the context for a node.
static const NodeProperty NodePropertyNISInternalTrigger         = 21;  ///< Identifies a node is internal trigger by
static const NodeProperty NodePropertyCustomHwNode               = 22;  ///< External hardware node.
static const NodeProperty NodePropertyActiveStreamIntent         = 23;  ///< Enable a sinkNoBuffer output port for a stream.
static const NodeProperty NodePropertyNoInputBuffer              = 24;  ///< Indicates that a node has no input buffers.
static const NodeProperty NodePropertyDynamicSinkNoBuffer        = 25;  ///< Indicates that the sinkNoBuffer output
                                                                        ///  for a stream is enabled.
static const NodeProperty NodePropertyCustomTuningFeature2Mode   = 26;  ///< Indicates that a node has custom tuning
                                                                        ///  feature v2 mode.
static const NodeProperty NodePropertyNoIOBufferNeeded           = 27;  ///< Enable a node that does not require an
                                                                        ///  in/out buffer.
static const NodeProperty NodePropertySATCapsMaskType            = 28;  ///< Mask for SAT instance capabilities.

// Have an interval in constant values to account for any new properties added on mainline
static const NodeProperty NodePropertyTFECSIDHeight              = 30;
static const NodeProperty NodePropertyTFECSIDWidth               = 31;
static const NodeProperty NodePropertyTFECSIDLeft                = 32;
static const NodeProperty NodePropertyTFECSIDTop                 = 33;
static const NodeProperty NodePropertyForceSingleTFEOn           = 34;    ///< Flag to force TFE to single TFE
static const NodeProperty NodePropertyCameraIndex                = 35;    ///< Identifies the physical camera index of the node
static const NodeProperty NodePropertyMuxerProfile               = 36;    ///< Selects Muxer Profile.
static const NodeProperty NodePropertyMotionVectorDomain         = 37;    ///< Selects Motion Vector Domain.
static const NodeProperty NodePropertySlavePath                  = 38;    ///< Indicates that a node running on Slave path
static const NodeProperty NodePropertyMultipleSensorIO           = 39;    ///< Node can support multi-sensor input-output.

static const NodeProperty NodePropertyStatsProfileId             = 40;
static const NodeProperty NodePropertyIPEDynamicInputFormat      = 41;    ///< Indicates IPE can have variable input format.
static const NodeProperty NodePropertyCascadedMCTFIPE            = 42;    ///< Flag to indicate 1st/2nd cascaded MCTF IPE
static const NodeProperty NodePropertyImgProcID                  = 43;
static const NodeProperty NodePropertyVendorStart       = 1023;  ///< First value in a list of vendors.

static const INT VendorGroupId = 0x70000000;    ///< Unique identifier for a vendor group.

static const UINT MaxAIStrength = 128;          ///< Max value of AI strength

/// @brief Camera State
struct CameraState
{
    UINT32                   cameraId;                   ///< CameraId
    BOOL                     cameraState;                ///< Camera State
};

/// @brief Defines CHI vendor group IDs.
enum ChiGroupId
{
    ChiGroupIdRaw = VendorGroupId + 1,
    ChiGroupIdYUV,
    ChiGroupIdMax
};
/// @brief Available debug data types.
enum class DebugDataType
{
    AEC,        ///< AEC debug data.
    AWB,        ///< AWB debug data.
    AF,         ///< AF debug data.
    AFD,        ///< AFD debug data.
    AFC,        ///< AFC debug data.
    IFETuning,  ///< IFE tuning data dump.
    BPSTuning,  ///< BPS tuning data dump.
    IPETuning,  ///< IPE tuning data dump.
    TFETuning,  ///< TFE tuning data dump.
    OPETuning,  ///< OPE tuning data dump.
    AllTypes,   ///< List all debug data types.
};

/// @brief Available frame rate engines.
enum class ChiFrameRateEngine
{
    NORMAL,         ///< Frames per second achieved by the Sensor mode.
    SENSORSTANDBY,  ///< Frames per second achieved by sensor standby.
    VBISTRETCH      ///< Frames per second achieved by a VBI stretch.
};

/// @brief SOC specific Access
enum BufferAccessType
{
    CPUAccess     = 0,   ///< Buffers will be accessed for Sw Op
    CamHWAccess,         ///< Buffers will be accessed by Cam Hw (Hw Nodes)
    NSPAccess,           ///< Buffers will be accessed NSP Hw Op
    FDHwAccess,          ///< Buffers will be accessed FD Hw Op
    GPUAccess,           ///< Buffers will be accessed GPU Hw Op
    HybridAccess         ///< Buffers can be accessed for Sw/Hw Ops - to add granularity for OEM specific cases
};

/// @brief Describes the debug data.
typedef struct
{
    SIZE_T  size;   ///< Size (in bytes) of the debug data buffer.
    VOID*   pData;  ///< Pointer to the debug data buffer.
} DebugData;

/// @brief Valid stream configuration modes.
typedef enum /** @cond */ StreamConfigMode /** @endcond */
{
    StreamConfigModeNormal                  = 0x0000,   ///< Operation mode for normal stream configuration.
    StreamConfigModeConstrainedHighSpeed    = 0x0001,   ///< Special constrained high-speed operation mode for devices that
                                                        ///  cannot support high-speed output in NORMAL mode.

    StreamConfigModeVendorStart             = 0x8000,   ///< First value for vendor-defined stream configuration modes.
    StreamConfigModeVendorEnd               = 0xEFFF,   ///< Last value for vendor-defined stream configuration modes.
    StreamConfigModeQTIStart                = 0xF000,   ///< First value for QTI-defined stream configuration modes.
    StreamConfigModeQTITorchWidget          = 0xF001,   ///< Operation mode for Torch Widget.
    StreamConfigModeVideoHdr                = 0xF002,   ///< Video HDR is ON.
    StreamConfigModeQTIFOVC                 = 0xF010,   ///< Field-of-view compensation in a recording use case.
    StreamConfigModeQTIFAEC                 = 0xF020,   ///< Fast AEC mode.
    StreamConfigModeFastShutter             = 0xF040,   ///< Fast shutter mode.

    StreamConfigModeSuperSlowMotionFRC      = 0xF080,   ///< Super slow motion with a frame rate up-conversion
                                                        ///  interpolation use case.
    StreamConfigModeQTIEVS                  = 0xF120,   ///< Operation mode for Process sensor output in NCS (EV Sensor)
    StreamConfigModeSensorMode              = 0xF0000,  ///< Sensor mode selection for @ge 60 fps, which requires four bits
                                                        ///  for the Sensor mode index.
} STREAMCONFIGMODE;

/// @brief Valid MFNR support values.
enum MFNRSupportValues
{
   NoMFNRSupport = 0, ///< No MFNR support.
   HWMFNRSupport,     ///< Hardware MFNR is supported.
   SWMFNRSupport,     ///< Software MFNR is supported.
};

/// @brief Device memory capabilities.
typedef enum /** @cond */ DeviceMemoryCapability /** @endcond */
{
    DeviceMemoryCapabilityLow   = 0x00,
    DeviceMemoryCapabilityHigh  = 0x01,
} DEVICEMEMORYCAPABILITY;

/// @brief HDR modes for a stream.
typedef enum /** @cond */ StreamHDRMode /** @endcond */
{
    HDRModeNone = 0,
    HDRModeHLG,               ///< Hybrid Log-Gamma mode.
    HDRModeHDR10,             ///< High Dynamic Range 10-bit mode.
    HDRModeHDR10Plus,         ///< High Dynamic Range 10-bit plus mode.
    HDRModePQ,                ///< Perceptual Quantizer mode.
    HDRModeDolbyVision,       ///< Dolby Vision mode.
    HDRModeMax
} STREAMHDRMODE;

/// @brief In-sensor HDR3 use cases.
typedef enum /** @cond */ SelectInSensorHDR3ExpUsecase /** @endcond */
{
    InSensorHDR3ExpNone = 0,
    InSensorHDR3ExpPreview,                         ///< IHDR3 preview use case.
    InSensorHDR3ExpSeamlessSnapshot,                ///< Seamless IHDR3 snapshot use case.
    InSensorHDR3ExpForceSeamlessSnapshot = 0x10,    ///< Force a seamless IHDR3 snapshot to be enabled for debug use.
} SELECTINSENSORHDRU3EXPSECASE;

/// @brief Options for EIS modes for use cases.
typedef enum /** @cond */ ChiEISMode /** @endcond */
{
    EISModeLookAhead,               ///< a look-ahead EIS recording use case
    EISModeRealTime,                ///< a real-time EIS recording use case.
    EISModeDynamicMargin,           ///< Dynamic margin for EIS.
    EISModeMax
} CHIEISMODE;

/// @brief Options for multi-camera hardware synchronization.
typedef enum /** @cond */ MultiCameraSyncType /** @endcond */
{
    MultiCameraSyncDisabled   = 0,                ///< Disable synchronization for all use cases.
    MultiCameraSyncRTB        = 1,                ///< Enable synchronization for Real-Time Bokeh.
    MultiCameraSyncSAT        = 2,                ///< Enable synchronization for spatial alignment transform.
    MultiCameraSyncVR         = 4,                ///< Enable synchronization for Virtual reality.
    MultiCameraSyncPhyStream  = 8,                ///< Enable synchronization for multiple physical streams.
} MULTICAMERASYNCTYPE;

/// @brief Camera-facing values.
typedef enum /** @cond */ ChiDirection /** @endcond */
{
    FacingBack              = 0,
    FacingFront             = 1,
    External                = 2
} CHIDIRECTION;

/// @brief Types (roles) of the main and auxiliary camera sensors.
typedef enum /** @cond */ ChiSensorPositionType /** @endcond */
{
    NONE                    = 0,                ///< Not part of multi-camera.
    REAR                    = 1,                ///< Rear main camera.
    FRONT                   = 2,                ///< Front main camera.
    REAR_AUX                = 3,                ///< Rear auxiliary camera.
    FRONT_AUX               = 4,                ///< Front auxiliary camera.
} CHISENSORPOSITIONTYPE;

/// @brief Defines the buffer formats.
typedef enum /** @cond */ ChiBufferFormat /** @endcond */
{
    ChiFormatJpeg               = 0,                   // JPEG format.
    ChiFormatY8                 = 1,                   ///< Luma only, 8 bits per pixel.
    ChiFormatY16                = 2,                   ///< Luma only, 16 bits per pixel.
    ChiFormatYUV420NV12         = 3,                   ///< YUV 420 format as described by the NV12 FOURCC.
    ChiFormatYUV420NV21         = 4,                   ///< YUV 420 format as described by the NV21 FOURCC.
    ChiFormatYUV420NV16         = 5,                   ///< YUV 422 format as described by the NV16 FOURCC.
    ChiFormatBlob               = 6,                   ///< Any non-image data.
    ChiFormatRawYUV8BIT         = 7,                   ///< Packed YUV/YVU Raw format of 16 BPP: 8 bits Y and 8 bits UV.
                                                       ///  U and V are interleaved as YUYV or YVYV.

    ChiFormatRawPrivate         = 8,                   ///< Private Raw formats where data is packed into a 64-bit word. \n
                                                       ///  @vertspace{4}
                                                       ///  - 8 BPP -- 64-bit word contains 8 pixels p0-p7, where p0 is stored
                                                       ///    at the LSB. @vertspace{-3}
                                                       ///  - 10 BPP -- 64-bit word contains 6 pixels p0-p5, where the most
                                                       ///    significant 4 bits are set to 0, and P0 is stored at
                                                       ///    the LSB. @vertspace{-3}
                                                       ///  - 12 BPP -- 64-bit word contains 5 pixels p0-p4, where the most
                                                       ///    significant 4 bits are set to 0, and  P0 is stored at
                                                       ///    the LSB. @vertspace{-3}
                                                       ///  - 14 BPP -- 64-bit word contains 4 pixels p0-p3, where the most
                                                       ///    significant 8 bits are set to 0, and P0 is stored at
                                                       ///    the LSB. @vertspace{3}

    ChiFormatRawMIPI            = 9,                   ///< MIPI Raw formats based on the MIPI CSI-2 specification.
                                                       ///  - 8 BPP -- Each pixel occupies one byte, starting at the LSB. The
                                                       ///    output width of image has no restrictions. @vertspace{-3}
                                                       ///  - 10 BPP -- Four pixels are held in every 5 bytes. The output
                                                       ///    width of the image must be a multiple of 4 pixels. @vertspace{3}

    ChiFormatRawMIPI10          = ChiFormatRawMIPI,    ///< Default Raw format is 10-bit MIPI.

    ChiFormatRawPlain16         = 10,                  ///< Plain16 Raw format, where a single pixel is packed into two bytes
                                                       ///  in little endian format. Not all bits can be used because Raw data
                                                       ///  is typically 8 or 10 bits per pixel. Lower order bits are filled
                                                       ///  first.

    ChiFormatRawPlain16LSB10bit = ChiFormatRawPlain16, ///< Default is 10-bit, ChiFormatRawPlain16LSB10bit.
    ChiFormatRawMeta8BIT        = 11,                  ///< Generic 8-bit Raw metadata for internal camera usage.
    ChiFormatUBWCTP10           = 12,                  ///< UBWC TP10 format (per the UBWC2.0 design specification).
    ChiFormatUBWCNV12           = 13,                  ///< UBWC NV12 format (per the UBWC2.0 design specification).
    ChiFormatUBWCNV124R         = 14,                  ///< UBWC NV12-4R format (per the UBWC2.0 design specification).
    ChiFormatYUV420NV12TP10     = 15,                  ///< YUV 420 format: 10 bits per compressed tightly packed format.
    ChiFormatYUV420NV21TP10     = 16,                  ///< YUV 420 format: 10 bits per compressed tightly packed format.
    ChiFormatYUV422NV16TP10     = 17,                  ///< YUV 422 format: 10 bits per compressed tightly packed format.
    ChiFormatPD10               = 18,                  ///< PD10 format.
    ChiFormatRawMIPI8           = 19,                  ///< 8 BPP format, where each pixel occupies one byte starting at the
                                                       ///  LSB. The output width of the image has no restrictions.
    ChiFormatP010               = 22,                  ///< P010 format.
    ChiFormatRawPlain64         = 23,                  ///< Raw Plain 64 format.
    ChiFormatUBWCP010           = 24,                  ///< UBWC P010 format.
    ChiFormatRawDepth           = 25,                  ///< 16-bit depth.
    ChiFormatRawMIPI12          = 26,                  ///< 12 BPP format, where two pixels are held in every three bytes. The
                                                       ///  output width of the image must be a multiple of two pixels.
    ChiFormatRawPlain16LSB12bit = 27,                  ///< Plain16 Raw format where there are 12 bits per pixel.

    ChiFormatRawMIPI14          = 28,                  ///< 14 BPP format, where four pixels are held in every seven bytes.
                                                       ///
                                                       ///  The output width of the image must be a multiple of four pixels.

    ChiFormatRawPlain16LSB14bit = 29,                  ///< Plain16 Raw format where there are 14 bits per pixel.
    ChiFormatLMC                = 32,                  ///< Digital multimeter (DMM) map used for luma motion compensation.
                                                       ///  There are 64 bits per 8x8 block, including two motion vectors
                                                       ///  (MVs).
    ChiFormatBlurMap            = 33,                  ///< Plain8 format for a blur map. The stride requires two more pixels
                                                       ///  than the width requires.
    ChiFormatP010LSB            = 34,                  ///< P010 format; LSB-aligned.
    ChiFormatARGB               = 35,                  ///< ARGB (Addressable RGB) format, where each pixel occupies four or eight bytes.
    ChiFormatUBWCP016LMC        = 36,                  ///< UBWC P016 format for lmc mv
    ChiFormatUBWCP016           = 37,                  ///< UBWC P016 format.
    ChiFormatRGB_888            = 39,                  ///< RGB888 format
} CHIBUFFERFORMAT;

/// @brief Direction of a custom hardware buffer.
typedef enum /** @cond */ ChiCustomHwBufferDirection /** @endcond */
{
    Input,
    Output,
    MaxBufferDirection
} CHICUSTOMHWBUFFERDIRECTION;

/// @brief Stream configuration parameters.
typedef struct /** @cond */ ChiStreamConfigInfo /** @endcond */
{
    UINT32            numStreams;       ///< Number of CHI streams.
    CHISTREAM**       pChiStreams;      ///< Double pointer to the array of CHI stream pointers.
    UINT32            operationMode;    ///< Operation mode of the CHI streams.
    const VOID*       pSessionSettings; ///< Pointer to the session metadata buffer.

#ifndef DOXYGEN_SHOULD_SKIP_THIS
#if defined(CAMX_ANDROID_API) && (CAMX_ANDROID_API >= 31) //Android-S or better
    bool              multiResolutionInputImage; ///< Whether stream needs multiResolution reprocess
#endif
#endif // DOXYGEN_SHOULD_SKIP_THIS
} CHISTREAMCONFIGINFO;


/// @brief Lighter weight stream structure used for checking the stream combination.
typedef struct /** @cond */ ChiStatelessStream /** @endcond */
{
    INT                      streamType;    ///< Type of stream.
    UINT32                   width;         ///< Width in pixels of the buffers in this stream.
    UINT32                   height;        ///< Height in pixels of the buffers in this. stream
    UINT32                   cameraId;      ///< Physical camera index of the stream.
    UINT32                   hintFlags;     ///< Flags used as a hint to the resource manager (see #CHI_RESOURCE_MANAGER_HINT).
} CAMERASTREAMLITE;

 /// @brief Defines all input and output streams for a use case.
typedef struct /** @cond */ ChiStreamCombination /** @endcond */
{
    UINT32                numStreams;       ///< Total number of streams requested by the framework.
    ChiStatelessStream*   pStreams;         ///< Pointer to the array of camera streams.
    UINT32                operationMode;    ///< Operation mode of the streams in this stream combination.
} CHISTREAMCOMBINATION;

/// @brief Parameters used to define a fence.
typedef struct /** @cond */ ChiFenceCreateParams /** @endcond */
{
    UINT32              size;           ///< Size of this structure.
    CHIFENCETYPE        type;           ///< Type of fence.
    CHAR*               pName;          ///< Pointer to the name of the fence.

    /// @brief Parameters used to create data for the fence (based on CHIFENCETYPE).
    union
    {
        UINT64          eglSync;        ///< EGL synchronization object (required to cast to EGLSyncKHR).
        INT             nativeFenceFD;  ///< Native file descriptor for the fence.
    };
} CHIFENCECREATEPARAMS;

/// @brief Valid CHI metadata types.
typedef enum /** @cond */ ChiMetadataTagType : UINT8 /** @endcond */
{
    CMB_TYPE_BYTE       = 0, ///< Unsigned 8-bit character.
    CMB_TYPE_INT32      = 1, ///< Signed 32-bit integer.
    CMB_TYPE_FLOAT      = 2, ///< 32-bit float.
    CMB_TYPE_INT64      = 3, ///< Signed 64-bit integer.
    CMB_TYPE_DOUBLE     = 4, ///< 64-bit double.
    CMB_TYPE_RATIONAL   = 5, ///< Rational metadata (camera_metadata_rational_t).
} CHIMETADATATAGTYPE;

/// @brief Metadata entry information.
typedef struct /** @cond */ ChiMetadataEntry /** @endcond */
{
    UINT32             tagID;    ///< Unique identifier of the tag.
    VOID*              pTagData; ///< Pointer to the tag data.
    UINT32             count;    ///< Number of tags.
    UINT32             size;     ///< Size of the tags.
    CHIMETADATATAGTYPE type;     ///< Type of tag data.
} CHIMETADATAENTRY;

/// @brief Private data used in CHI callbacks.
typedef struct /** @cond */ ChiPrivateData /** @endcond */
{
    UINT32                 streamIndex;                           ///< Private data for saving a pipeline index from the CHI
                                                                  ///  use case.
    UINT32                 featureType;                           ///< Type of feature used for this request.
    UINT32                 numInputBuffers;                       ///< Number of input buffers for this request.
    CHIBUFFERINFO          inputBuffers[PrivBufferQueueDepth];    ///< Array of input buffer handle pointers for this request.
    CHIBUFFERMANAGERHANDLE bufferManagers[PrivBufferQueueDepth];  ///< Array of buffer managers to which the input buffers
                                                                  ///  belong.

    UINT32                 readyMask;                             ///< Ready mask for input buffer release.
                                                                  ///
                                                                  ///  Set the bits when the result is coming, and clear it
                                                                  ///  after the input buffer is released.
} CHIPRIVDATA;

/// @brief Result information for a capture request.
typedef struct /** @cond */ ChiCaptureResult /** @endcond */
{
    UINT32                      frameworkFrameNum;  ///< Unique frame number.
    const VOID*                 pResultMetadata;    ///< Pointer to the result metadata for this capture. This value can be
                                                    ///  NULL.
    UINT32                      numOutputBuffers;   ///< Number of output buffers returned in this result structure.
    const CHISTREAMBUFFER*      pOutputBuffers;     ///< Pointer to the handles for the output stream buffers for this
                                                    ///  capture.
    const CHISTREAMBUFFER*      pInputBuffer;       ///< Pointer to the handle for the input stream buffer for this capture.
                                                    ///  This value can be NULL.
    UINT32                      numPartialMetadata; ///< Number of partial metadata results.

#ifndef DOXYGEN_SHOULD_SKIP_THIS
#if defined(CAMX_ANDROID_API) && (CAMX_ANDROID_API >= 28) //Android-P or better
    UINT32                      numPhysCamMetadata; ///< Number of physical camera metadata
    const CHAR**                physCamIds;         ///< The array of physical camera ids
    const VOID**                physCamMetadata;    ///< The array of physical camera metadata
#endif
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

    VOID*                       pPrivData;          ///< Pointer to the private data that is managed by client.
    CHIMETAHANDLE               pInputMetadata;     ///< Input metadata for this request.
    CHIMETAHANDLE               pOutputMetadata;    ///< Output metadata for this request.
} CHICAPTURERESULT;

/// @brief Result information for a partial capture request.
typedef struct /** @cond */ ChiPartialCaptureResult /** @endcond */
{
    UINT32                  frameworkFrameNum;      ///< Unique frame number.
    CHIMETAHANDLE           pPartialResultMetadata; ///< Partial result metadata for this capture.
    VOID*                   pPrivData;              ///< Pointer to the private data that is managed by the client.
} CHIPARTIALCAPTURERESULT;

/// @brief Valid message types.
typedef enum /** @cond */ ChiMessageType /** @endcond */
{
    ChiMessageTypeError             = 1,
    ChiMessageTypeShutter           = 2,   ///< Exposure of a given request or processing a reprocess request has begun.
    ChiMessageTypeSystemEvent       = 3,
    ChiMessageTypeSof               = 4,
    ChiMessageTypeMetaBufferDone    = 5,
    ChiMessageTypeCustom            = 6,
    ChiMessageTypeFenceCreated      = 7,
} CHIMESSAGETYPE;

/// @brief Header for a system event.
typedef struct /** @cond */ ChiSystemEventHeader /** @endcond */
{
    INT32       errorCode;                               ///< Error code of the system event.
    CHAR        verboseErrorString[MaximumStringLength]; ///< Verbose error string for a smart error code.

    BOOL        isDumpOnly;                              ///< Indicates whether a dump only is to be performed with no
                                                         ///  recovery.
                                                         ///
                                                         ///  @valuesbul
                                                         ///   - 0 -- FALSE
                                                         ///   - 1 -- TRUE (value is negative) @tablebulletend

    BOOL        forceSigAbort;                           ///< Forces a SIGABORT signal during a fatal error.
                                                         ///
                                                         ///  @valuesbul
                                                         ///   - 0 -- FALSE
                                                         ///   - 1 -- TRUE (value is negative) @tablebulletend

    BOOL        isThreadCallStackDumpRequested;          ///< Forces a thread stack dump, even for dumpOnly event.
                                                         ///
                                                         ///  @valuesbul
                                                         ///   - 0 -- FALSE
                                                         ///   - 1 -- TRUE (value is negative) @tablebulletend

    BOOL        isSelectiveRecovery;                     ///< Indicates which recovery type is required.
                                                         ///
                                                         ///  @valuesbul
                                                         ///   - 0 -- FALSE; full recovery required
                                                         ///   - 1 -- TRUE; selective recovery required (value is negative) @tablebulletend
}CHISYSTEMEVENTHEADER;

/// @brief Recovery types.
typedef enum ChiRecoveryType
{
    FullRecovery                  = 1,   ///< Full use case recovery.
    SelectiveChiRecovery          = 2,   ///< Selective recovery from Chi.
    SelectiveSessionRecovery      = 3,   ///< Recovery of selective sessions.
    SelectivePipelineRecovery     = 4,   ///< Recovery of selective pipelines.
    SelectiveSessionFlushRecovery = 5    ///< Recovery of selective pipelines without stream off.
} CHIRECOVERYTYPE;

/// @brief OfflineDependencyProviderType
typedef enum OfflineDependencyProviderType
{
    OfflineDependencyProviderNone            = 0,               ///< None offline dependency provider
    OfflineDependencyProviderAISegCatMap     = 1,               ///< Provider of AISegCatMap
} CHIOFFLINEDEPENDENCYPROVIDERTYPE;

/// @brief Use case-only information for the system event payload.
typedef struct /** @cond */ UsecaseSystemEventPayload /** @endcond */
{
    UINT        usecaseID;          ///< Unique identifier of the use case.
    VOID*       pUsecaseInstance;   ///< Pointer to the use case associated with the system event.
    const CHAR* pUsecaseName;       ///< Pointer to the string that represents the use case name.
}CHIUSECASESYSTEMEVENTPAYLOAD;

/// @brief Graph-only information for the system event payload.
typedef struct /** @cond */ GraphSystemEventPayload /** @endcond */
{
    UINT        graphId;            ///< Unique identifier of the graph.
    VOID*       pGraphInstance;     ///< Pointer to the graph associated with the system event.
    const CHAR* pGraphName;         ///< Pointer to the string that represents the graph name.
}CHIGRAPHSYSTEMEVENTPAYLOAD;


/// @brief Feature-only information for the system event payload.
typedef struct /** @cond */ FeatureSystemEventPayload /** @endcond */
{
    UINT        featureId;          ///< Unique identifier of the feature.
    UINT        featureInstanceId;  ///< Unique identifier of the feature instance.
    VOID*       pfeatureInstance;   ///< Pointer to the feature associated with the system event.
    const CHAR* pfeatureName;       ///< Pointer to the string that represents the feature name.
    const CHAR* pFROState;          ///< Pointer to the Feature Request Object (FRO) state.
}CHIFEATURESYSTEMEVENTPAYLOAD;

/// @brief Node-only information for the system event payload.
typedef struct /** @cond */ NodeSystemEventPayload /** @endcond */
{
    UINT        nodeType;               ///< Type of node.
    UINT        nodeInstanceId;         ///< Unique identifier of the node instance.
    VOID*       pNodeInstance;          ///< Pointer to the node instance associated with the system event.
    const CHAR* pNodeName;              ///< Pointer to the string that represents the node type.
}CHINODESYSTEMEVENTPAYLOAD;

/// @brief Pipeline-only information for the system event payload.
typedef struct /** @cond */ ChiPipelineSystemEventPayload /** @endcond */
{
    UINT        pipelineId;     ///< Unique identifier of the pipeline.
    VOID*       pPipeline;      ///< Pointer to the pipeline associated with the system event.
    const CHAR* pPipelineName;  ///< String that represents the pipeline.
}CHIPIPELINESYSTEMEVENTPAYLOAD;

/// @brief Session-only information for the system event payload.
typedef struct /** @cond */ ChiSessionSystemEventPayload /** @endcond */
{
    VOID*       pSession;       ///< Pointer to the session associated with the system event.
    const CHAR* pPipelineNames; ///< String that represents the pipelines being held in the session.
}CHISESSIONSYSTEMEVENTPAYLOAD;

/// @brief Failed jobs for hms
typedef struct ChiHMSFailedJobsData
{
    UINT32       cameraId;                           ///< Logical cameraId on which failure is detected
    UINT32       errorCode;                          ///< Error code for a failure
    UINT32       pid;                                ///< Process Id for the failed job
    UINT32       tid;                                ///< Thread Id for the failed job
    UINT64       maxExecTime;                        ///< Max execution time alloted for a job
    UINT64       execTime;                           ///< Total execution time  for a job
    CHAR         jobName[MaximumStringLength];       ///< Failed job family/node name
} CHIHMSFAILEDJOBSDATA;

/// @brief HMS information for the system event payload.
typedef struct /** @cond */ ChiHMSSystemEventPayload /** @endcond */
{
    CHIHMSFAILEDJOBSDATA* pFailedJobsData; ///< HMS failed jobs associated with the system event.
    UINT32                numFailedJobs;   ///< HMS failed jobs size.
}CHIHMSSYSTEMEVENTPAYLOAD;

/// @brief Callback information for a system event.
typedef struct /** @cond */ ChiSystemEventMessage /** @endcond */
{
    CHISYSTEMEVENTHEADER             headerData;              ///< System event header for the callback.
    CHINODESYSTEMEVENTPAYLOAD        nodeData;                ///< Node information associated with the system event.
    CHIPIPELINESYSTEMEVENTPAYLOAD    pipelineData;            ///< Pipeline information associated with the system event.
    CHISESSIONSYSTEMEVENTPAYLOAD     sessionData;             ///< Session information associated with the system event.
    CHIFEATURESYSTEMEVENTPAYLOAD     featureData;             ///< Feature information associated with the system event.
    CHIGRAPHSYSTEMEVENTPAYLOAD       graphData;               ///< Graph information associated with the system event.
    CHIUSECASESYSTEMEVENTPAYLOAD     usecaseData;             ///< Use case information associated with the system event.
    BOOL                             threadCallStacksDumped;  ///< Indicates whether a Signal35 Dump is performed as part
                                                              ///  of this system event.
                                                              ///
                                                              ///  @valuesbul
                                                              ///  - 0 -- FALSE
                                                              ///  - 1 -- TRUE @tablebulletend

    CHIHMSSYSTEMEVENTPAYLOAD         hmsData;                 ///< HMS information associated with system event.
} CHISYSTEMEVENTMESSAGE;

/// @brief  Information about selective recovery data.
typedef struct ChiSelectiveRecoveryData
{
    VOID* pSession;           ///< Session that requires selective recovery.
    UINT8 numPipelines;       ///< Number of pipelines.
    VOID* pPipelines;         ///< Pipelines that require selective recovery.
}CHISELECTIVERECOVERYDATA;

/// @brief  Information about selective recovery payload.
typedef struct ChiSelectiveRecoveryPayload
{
    CHIRECOVERYTYPE          recoveryType;                     ///< Recovery type.
    UINT8                    numSessions;                      ///< Number of sessions.
    CHISELECTIVERECOVERYDATA sessionData[MaxNumberOfSessions]; ///< Sessions that need to be selectively recovered.
}CHISELECTIVERECOVERYPAYLOAD;

/// @brief Defines the pipeline output types.
typedef enum /** @cond */ ChiPipelineOutputType /** @endcond */
{
    ChiPipelineOutputDefault,
    ChiPipelineOutputPreview,
    ChiPipelineOutputVideo,
    ChiPipelineOutputSnapshot,
    ChiPipelineOutputDepth,
    ChiPipelineOutputMax,
} CHIPIPELINEOUTPUTTYPE;

/// @brief Contains parameters for an error message.
typedef struct /** @cond */ ChiErrorMessage /** @endcond */
{
    UINT32              frameworkFrameNum;        ///< Frame number of the request to which the error applies.
                                                  ///
                                                  ///  @values 0 if the frame number is not applicable to the error

    CHISTREAM*          pErrorStream;             ///< Pointer to the stream that had a failure.
                                                  ///
                                                  ///  @values NULL if the stream is not applicable to the error

    CHIERRORMESSAGECODE errorMessageCode;         ///< Message code for this error.
    ChiBufferInfo       bufferInfo;               ///< Container for the buffer handle if there is a buffer error.

    BOOL                isRequestCancelled;       ///< Indicates whether a flush is in progress at the use case level.
                                                  ///
                                                  ///  @valuesbul
                                                  ///  - 0 -- FALSE
                                                  ///  - 1 -- TRUE @tablebulletend
} CHIERRORMESSAGE;

/// @brief Contains parameters for a custom message.
typedef struct /** @cond */ ChiCustomMessage /** @endcond */
{
    UINT32 frameworkFrameNum;               ///< Frame number of the request that has started exposure or reprocessing.
    UINT64 timestamp;                       ///< Time when the capture started.
    UINT32 customType;                      ///< Type of custom message.
    UINT64 customData;                      ///< Custom data passed from the algorithm.
}CHICUSTOMMESSAGE;

/// @brief Contains parameters for a start of frame (SOF) message.
typedef struct /** @cond */ ChiSofMessage /** @endcond */
{
    UINT32  frameworkFrameNum;         ///< Frame number of the request that started the exposure or reprocessing.
    UINT64  timestamp;                 ///< Time when the capture started.
    UINT32  sensorExposureTime;        ///< Exposure time (in milliseconds) of the sensor.
    UINT32  sofId;                     ///< Unique identifier of the SOF message.

    BOOL    bIsFrameworkFrameNumValid; ///< Indicates whether the frame number is valid.
                                       ///
                                       ///  @valuesbul
                                       ///  - 0 -- FALSE
                                       ///  - 1 -- TRUE @tablebulletend
} CHISOFMESSAGE;

/// @brief Parameters for a metadata done message.
typedef struct /** @cond */ ChiMetaBufferDoneMessage /** @endcond */
{
    UINT32           frameworkFrameNum;  ///< Frame number of the request associated with the buffers.
    CHIMETAHANDLE    inputMetabuffer;    ///< Handle of the input metadata buffer. This value can be NULL.
    CHIMETAHANDLE    outputMetabuffer;   ///< Handle of the output metadata buffer. This value can be NULL.
    UINT32           numMetaBuffers;     ///< Number of metadata buffers.
} CHIMETABUFFERDONEMESSAGE;

/// @brief Defines a fence-created message.
typedef struct /** @cond */ ChiPortFenceCreatedMessage /** @endcond */
{
    UINT32           frameworkFrameNum;  ///< Frame number of the request associated with the buffers.
    INT32            fenceFD;            ///< Fence file descriptor.
    ChiBufferInfo    outputBufferInfo;   ///< Information about the output buffer.
} ChiPortFenceCreatedMessage;

/// @brief Describes the type of CHI message descriptor and its contents.
typedef struct /** @cond */ ChiMessageDescriptor /** @endcond */
{
    CHIMESSAGETYPE messageType;            ///< Determines which parameter to use from the message union.

    /// @brief Describes the CHI message based on the message type.
    union
    {
        CHIERRORMESSAGE                 errorMessage;           ///< Contents of an error message. This parameter is valid if
                                                                ///  the message type is #ChiMessageTypeError.
        CHISHUTTERMESSAGE               shutterMessage;         ///< Contents of shutter message. This parameter is valid if
                                                                ///  the message type is #ChiMessageTypeShutter.
        CHISOFMESSAGE                   sofMessage;             ///< Contents of an SOF message. This parameter is valid if the
                                                                ///  message type is #ChiMessageTypeSof.
        CHIMETABUFFERDONEMESSAGE        metaBufferDoneMessage;  ///< Contents of a metabuffer done message. This parameter
                                                                ///  is valid if the message type is
                                                                ///  #ChiMessageTypeMetaBufferDone.
        CHISYSTEMEVENTMESSAGE           systemEventMessage;     ///< Contents of a system event message. This parameter is
                                                                ///  valid if the message type is a system event.
        CHICUSTOMMESSAGE                customMessage;          ///< Contents of a custom message.
        UINT8                           generic[32];            ///< Generic message content used to ensure a minimum size for
                                                                ///  custom message types.
        ChiPortFenceCreatedMessage      fenceCreatedMessage;    ///< Fence-created message from CamX.
    } message;

    VOID*                        pPrivData;               ///< Pointer to the private data that is managed by the client.
} CHIMESSAGEDESCRIPTOR;

/** @} */ /* end_addtogroup chi_common_defs */


/// @ingroup chi_common_callbacks
/// @brief Callbacks used by the CHI implementation to call into the CHI application.
typedef struct /** @cond */ ChiCallBacks /** @endcond */
{
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// @cond ChiProcessCaptureResult @endcond
    ///
    /// @brief Callback method used to return the capture results.
    ///
    /// @datatypes
    /// #CHICAPTURERESULT
    ///
    /// @param[in] pCaptureResult        Pointer to the capture result.
    /// @param[in] pPrivateCallbackData  Pointer to the private callback data.
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    void (*ChiProcessCaptureResult)(
        CHICAPTURERESULT*   pCaptureResult,
        VOID*               pPrivateCallbackData);

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// @cond ChiNotify @endcond
    ///
    /// @brief Asynchronous notification callback method.
    ///
    /// @datatypes
    /// #CHIMESSAGEDESCRIPTOR
    ///
    /// @param[in] pMessageDescriptor    Pointer to the message descriptor.
    /// @param[in] pPrivateCallbackData  Pointer to the private callback data.
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    void (*ChiNotify)(
        const CHIMESSAGEDESCRIPTOR* pMessageDescriptor,
        VOID*                       pPrivateCallbackData);

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// @cond ChiProcessPartialCaptureResult @endcond
    ///
    /// @brief Callback method used to return the partial capture results.
    ///
    /// @datatypes
    /// #CHIPARTIALCAPTURERESULT
    ///
    /// @param[in] pCaptureResult        Pointer to the capture result.
    /// @param[in] pPrivateCallbackData  Pointer to the private callback data.
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    void (*ChiProcessPartialCaptureResult)(
         CHIPARTIALCAPTURERESULT*   pCaptureResult,
         VOID*                      pPrivateCallbackData);


} CHICALLBACKS;


/** @addtogroup chi_common_defs
@{ */

/// @brief Contains parameters for the link buffer properties.
typedef struct /** @cond */ ChiLinkBufferProperties /** @endcond */
{
    UINT32  numSupportedFormats;                        ///< Number of buffer formats.
    UINT32  supportedFormats[MaxNumSupportedFormats];   ///< Buffer formats.
    UINT32  bufferSize;                                 ///< Buffer size (in case the buffer is a Raw bytes buffer).
    UINT32  bufferImmediateAllocCount;                  ///< Indicates that initial buffers will  be allocated for the link.
    UINT32  bufferQueueDepth;                           ///< Maximum number of buffers that will exist on the link.
    UINT32  bufferHeap;                                 ///< Type of buffer heap.
    UINT32  bufferFlags;                                ///< Flags to be used for the buffer.
} CHILINKBUFFERPROPERTIES;


#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef UINT VirtualTransitionMode;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */


/// @brief Port information definition for both virtual and hardware ports.
struct PortId
{
    const UINT  id;    ///< Identifier for the port.
    const CHAR* pName; ///< Pointer to the name of the port.
};

/// @brief Contains the virtual port and hardware port mapping.
struct VirtualPortHardwarePortMap
{
    PortId* pVirtualPort;   ///< Pointer to a virtual port.
    PortId* pHardwarePort;  ///< Pointer to a hardware port.
};

/// @brief Contains request mode transition data.
struct VirtualTransitionTable
{
    VirtualTransitionMode       mode;      ///< Mode for the transition table.
    UINT                        nodeType;  ///< Owner of the table, such as an SFE, IFE, or IPE node.
    UINT                        numPort;   ///< Number of ports in the portList.
    VirtualPortHardwarePortMap* pPortList; ///< Pointer to the virtual port and hardware port mapping.
};


#ifndef DOXYGEN_SHOULD_SKIP_THIS
static INT INVALID_TRANSITION_MODE_ID = -1;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */


/// @brief Descriptor for the CHI output port.
typedef struct /** @cond */ ChiOutputPortDescriptor /** @endcond */
{
    UINT32                             portId;                              ///< Unique identifier of the output port.
    UINT32                             isSinkPort;                          ///< Indicates if one of the ports has a sink port.
    UINT32                             isOutputStreamBuffer;                ///< Indicates whether the port outputs a stream
                                                                            ///  buffer.
    UINT32                             portSourceTypeId;                    ///< Unique identifier of the port's source type.
    UINT32                             numSourceIdsMapped;                  ///< Number of sources mapped to this output port
                                                                            ///  for bypass.
    UINT32*                            pMappedSourceIds;                    ///< Pointer to the unique IDs of the sources
                                                                            ///  mapped to this output port for bypass.
    UINT32                             numTransitionModes;                  ///< Number of modes.
    UINT32                             transitionModeIds[MaxNumberOfModes]; ///< Array of transition mode IDs for each mode.
    const VirtualPortHardwarePortMap** ppVirtualPortMappingTable;           ///< Pointer to the Virtual Port mapping table.
} CHIOUTPUTPORTDESCRIPTOR;

/// @brief Descriptor for the CHI input port.
typedef struct /** @cond */ ChiInputPortDescriptor /** @endcond */
{
    UINT32                             portId;                              ///< Unique identifier of the input or output
                                                                            ///  port.
    UINT32                             isInputStreamBuffer;                 ///< Indicates whether the input port takes a
                                                                            ///  source buffer as input.
    UINT32                             portSourceTypeId;                    ///< Unique identifier of the port's source type.
    UINT32                             numTransitionModes;                  ///< Number of transition modes.
    UINT32                             transitionModeIds[MaxNumberOfModes]; ///< Array of Transition mode IDs.
    const VirtualPortHardwarePortMap** ppVirtualPortMappingTable;           ///< Pointer to the virtual port mapping table.
} CHIINPUTPORTDESCRIPTOR;

/// @brief Information about the CHI node ports.
typedef struct /** @cond */ ChiNodePorts /** @endcond */
{
    UINT32                   numInputPorts;                           ///< Number of input ports.
    UINT32                   numInputPortsPerMode[MaxNumberOfModes];  ///< Number of input ports per Transition mode.
    CHIINPUTPORTDESCRIPTOR*  pInputPorts;                             ///< Pointer to the input ports.
    UINT32                   numOutputPorts;                          ///< Number of output ports.
    UINT32                   numOutputPortsPerMode[MaxNumberOfModes]; ///< Number of output ports per Transition mode.
    CHIOUTPUTPORTDESCRIPTOR* pOutputPorts;                            ///< Pointer to the output ports.
} CHINODEPORTS;

/// @brief Property parameters for a CHI node.
typedef struct /** @cond */ ChiNodeProperty /** @endcond */
{
    UINT32       id;                            ///< Unique identifier of the property.
    const VOID*  pValue;                        ///< Pointer to the data. The type depends on the ID.
} CHINODEPROPERTY;

/// @brief Information about a CHI node.
typedef struct /** @cond */ ChiNode /** @endcond */
{
    CHINODEPROPERTY* pNodeProperties;                     ///< Pointer to the properties associated with the node.
    UINT32           nodeId;                              ///< Unique identifier for the node.
    UINT32           nodeInstanceId;                      ///< Unique identifier for the node instance.
    CHINODEPORTS     nodeAllPorts;                        ///< Information about all ports.
    UINT32           numProperties;                       ///< Number of property instances in pNodeProperties.
    PruneSettings    pruneProperties;                     ///< List of prune properties.
    UINT32           preferredMode;                       ///< Preferred mode to be used for sensor initialization.
    UINT32           numTransitionModes;                  ///< Number of Transition modes.
    UINT32           transitionModeIds[MaxNumberOfModes]; ///< Array of Transition mode IDs.
} CHINODE;

/// @brief Information about a node in the link descriptor that defines a connection between two nodes.
typedef struct /** @cond */ ChiLinkNodeDescriptor /** @endcond */
{
    UINT32        nodeId;                        ///< Unique identifier of the node.
    UINT32        nodeInstanceId;                ///< Unique identifier of the node instance.
    UINT32        nodePortId;                    ///< Unique identifier of the node port.
    UINT32        portSourceTypeId;              ///< Unique identifier of the port source type.
    PruneSettings pruneProperties;               ///< List of prune properties.
} CHILINKNODEDESCRIPTOR;

/// @brief Properties for a CHI link.
typedef struct /** @cond */ ChiLinkProperties /** @endcond */
{
    UINT32  isBatchedMode;                    ///< Indicator for a batched mode.
    UINT32  linkFlags;                        ///< Flags for link properties.
} CHILINKPROPERTIES;

/// @brief Represents one link that originates from a node.
typedef struct /** @cond */ ChiNodeLink /** @endcond */
{
    CHILINKNODEDESCRIPTOR           srcNode;                       ///< Source node in a link.
    UINT32                          numDestNodes;                  ///< Number of destination nodes in a link to which the
                                                                   ///  source node can connect.
    CHILINKNODEDESCRIPTOR*          pDestNodes;                    ///< Pointer to all destination nodes connected to the source
                                                                   ///  node.
    CHILINKBUFFERPROPERTIES         bufferProperties;              ///< Buffer properties for the link.
    CHILINKPROPERTIES               linkProperties;                ///< Property information for the link.
    OfflineDependencyProviderType   offlineDependencyProviderType; ///< Offline dependency provider type (for output port)
    UINT                            numOfflineDependencyBuffers;   ///< Number of offline dependency buffer (for output port)
} CHINODELINK;

/// @brief Contains all the information required to create a pipeline.
typedef struct /** @cond */ ChiPipelineCreateDescriptor /** @endcond */
{
    UINT32              size;                                ///< Size of this structure.
    UINT32              numNodes;                            ///< Number of pipeline nodes.
    CHINODE*            pNodes;                              ///< Pointer to the pipeline nodes.
    UINT32              numLinks;                            ///< Number of links.
    CHINODELINK*        pLinks;                              ///< Pointer to each link descriptor.
    UINT32              isRealTime;                          ///< Indicates whether this a real-time pipeline.
    UINT                numPipelineModes;                    ///< Number of pipeline modes (transition modes).
    UINT                pipelineModeIds[MaxNumberOfModes];   ///< Array of Transition mode IDs.
    const CHAR*         pipelineModeNames[MaxNumberOfModes]; ///< Pointer to the array of Transition mode names.
    UINT                numBatchedFrames;                    ///< Number of framework frames that are batched.
    UINT                maxFPSValue;                         ///< Maximum FPS value of the batched frames.
    UINT32              cameraId;                            ///< Camera ID of the pipeline.
    CHIMETAHANDLE       hPipelineMetadata;                   ///< Valid metadata buffer handle that contains tags related to
                                                             ///  initialization.

    BOOL                HALOutputBufferCombined;             ///< Indicates whether the HAL output buffer is combined for
                                                             ///  Batch mode.
                                                             ///
                                                             ///  @valuesbul
                                                             ///  - 0 -- FALSE
                                                             ///  - 1 -- TRUE (buffer is combined) @tablebulletend

    UINT32              logicalCameraId;                     ///< Identifier for the logical camera of the pipeline.
    BOOL                isOfflineMode;                       ///< Indicates whether this is an offline mode pipeline.
} CHIPIPELINECREATEDESCRIPTOR;

/// @brief Contains ranges of the supported buffer sizes.
struct BufferDimension
{
    UINT minWidth;  ///< Minimum width of the buffer.
    UINT minHeight; ///< Minimum height of the buffer.
    UINT maxWidth;  ///< Maximum width of the buffer.
    UINT maxHeight; ///< Maximum height of the buffer.
};

/// @brief Contains information that describes how a buffer is used.
struct ChiTarget
{
    ChiStreamType       direction;      ///< Direction of this target: input, output, or bidirectional.
    BufferDimension     dimension;      ///< Range of supported buffer sizes.
    UINT                numFormats;     ///< Number of supported buffer formats for this target.
    ChiBufferFormat*    pBufferFormats; ///< Array of supported buffer formats of size numFormats.
    ChiStream*          pChiStream;     ///< Temporary pointer to a CHISTREAM used by this target.
                                        ///  This pointer is set to INVALID after a pipeline is created.
};

/// @brief Information about where a port directly interacts with a buffer.
struct ChiTargetPortDescriptor
{
    const CHAR*            pTargetName;  ///< Pointer to the name of the target connected to the nodes within pNodePort.
    ChiTarget*             pTarget;      ///< Pointer to the target.
    UINT                   numNodePorts; ///< Number of ports connected to this target.
    ChiLinkNodeDescriptor* pNodePort;    ///< Array of ports of size numNodePorts.
};

/// @brief List of port-to-buffer information.
struct ChiTargetPortDescriptorInfo
{
    UINT                     numTargets;      ///< Size of pTargetPortDesc.
    ChiTargetPortDescriptor* pTargetPortDesc; ///< Pointer to the array of target port descriptors.
};

/// @brief Combination of pipeline information with buffer information.
struct ChiPipelineTargetCreateDescriptor
{
    const CHAR*                 pPipelineName;      ///< Pointer to the name of this pipeline.
    ChiPipelineCreateDescriptor pipelineCreateDesc; ///< Description of the nodes and links of this pipeline.
    ChiTargetPortDescriptorInfo sinkTarget;         ///< List of this pipeline's sink target descriptors.
    ChiTargetPortDescriptorInfo sourceTarget;       ///< List of this pipeline's source target descriptors.
};

/// @brief Collection of information summarizing a use case.
struct ChiUsecase
{
    const CHAR*                        pUsecaseName;              ///< Pointer to the name of this use case.
    UINT                               streamConfigMode;          ///< Operation mode for this use case.
    UINT                               numTargets;                ///< Number of targets (sink+source) of ppChiTargets.
    ChiTarget**                        ppChiTargets;              ///< Double pointer to the array of all targets within this
                                                                  ///  use case.
    UINT                               numPipelines;              ///< Number of pipelines defined in this use case.
    ChiPipelineTargetCreateDescriptor* pPipelineTargetCreateDesc; ///< Pointer to the list of all pipelines in this use case.
    const PruneSettings*               pTargetPruneSettings;      ///< Pointer to this prune settings for this use case.

    BOOL                               isOriginalDescriptor;      ///< Indicates whether this structure is in g_pipelines.h.
                                                                  ///  When set to TRUE, this structure must <em>never</em> be
                                                                  ///  modified or freed.
                                                                  ///
                                                                  ///  @valuesbul
                                                                  ///  - 0 -- FALSE
                                                                  ///  - 1 -- TRUE @tablebulletend
};

/// @brief Collection of use cases with matching properties (such as target count).
struct ChiTargetUsecases
{
    UINT        numUsecases;  ///< Number of use cases in the array.
    ChiUsecase* pChiUsecases; ///< Pointer to the array of use cases of size numUsecases.
};

/// @brief Contains information about a capture request.
typedef struct /** @cond */ ChiCaptureRequest /** @endcond */
{
    UINT64                 frameNumber;              ///< Frame number for the capture request.
    CHIPIPELINEHANDLE      hPipelineHandle;          ///< Handle of the pipeline output.
    UINT32                 numInputs;                ///< Number of input buffers.
    CHISTREAMBUFFER*       pInputBuffers;            ///< Pointer to the list of input buffers.
    UINT32                 numOutputs;               ///< Number of output buffers.
    CHISTREAMBUFFER*       pOutputBuffers;           ///< Pointer to the list of output buffers.
    const VOID*            pMetadata;                ///< Deprecated. Metadata buffer that contains capture and processing
                                                     ///  parameters.
    CHIMETAHANDLE          pInputMetadata;           ///< Handle for the valid metadata buffer that contains the input tags.
    CHIMETAHANDLE          pOutputMetadata;          ///< Handle for the valid metadata buffer that contains the result tags.
    VOID*                  pPrivData;                ///< Pointer to the private data that is managed by the client.
} CHICAPTUREREQUEST;

/// @brief Represents all requests submitted at once, possibly to different pipelines.
typedef struct /** @cond */ ChiPipelineRequest /** @endcond */
{
    CHIHANDLE                pSessionHandle;     ///< Handle of the CHI session.
    UINT32                   numRequests;        ///< Number of pipeline requests.
    const CHICAPTUREREQUEST* pCaptureRequests;   ///< Pointer to the array of individual request structures.
} CHIPIPELINEREQUEST;

/// @brief Contains width and height integer values.
typedef struct /** @cond */ ChiDimension /** @endcond */
{
    UINT32      width;                          ///< Width of the buffer.
    UINT32      height;                         ///< Height of the buffer.
} CHIDIMENSION;


#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Forward declaration for buffer dimension.
typedef ChiDimension ChiBufferDimension;
typedef ChiDimension CHIBUFFERDIMENSION;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */


/// @brief Information about the histogram.
typedef struct /** @cond */ ChiHDR10PlusHistInfo /** @endcond */
{
    UINT32  maxrbg_hist_stats[1024];    ///< Histogram of the statistics (10 bits).
    UINT32  max_r;                      ///< Maximum number of r values.
    UINT32  max_g;                      ///< Maximum number of g values.
    UINT32  max_b;                      ///< Maximum number of b values.
} CHIHDR10PLUSHISTINFO;

/// @brief Raw format of the sink port.
typedef struct /** @cond */ ChiRawFormatPort /** @endcond */
{
    UINT32 inputPortId;    ///< Unique identifier of the input port.
    UINT32 format;         ///< Indicates Raw format.
    UINT32 sinkPortId;     ///< Unique identifier of the sink port.
} CHIRAWFORMATPORT;

/// @brief Bit field that describes a metadata client ID.
typedef struct /** @cond */ ChiMetadataClientID /** @endcond */
{
    BIT frameNumber : 24;   ///< Frame number.
    BIT clientIndex :  7;   ///< Index of the client.
    BIT reserved    :  1;   ///< Must be initialized to NULL.
} CHIMETADATACLIENTID;

/// @brief Dimension options for a buffer.
typedef struct /** @cond */ ChiBufferOptions /** @endcond */
{
    UINT32              size;                    ///< Size of this structure.
    CHIBUFFERDIMENSION  minDimension;            ///< Minimum value for the dimension.
    CHIBUFFERDIMENSION  maxDimension;            ///< Maximum value for the dimension.
    CHIBUFFERDIMENSION  optimalDimension;        ///< Optimal value for the dimension.
    ChiStreamIntentMask streamIntentMask;        ///< Bit mask for stream intents associated with this port, where the bits are
                                                 ///  defined in ChiStreamIntent.
#if defined(CAMX_ANDROID_API) && (CAMX_ANDROID_API >= 33) //Android-U or better
    ChiStreamColorSpace minColorSpace;           ///< Minimum color space required for this buffer
#endif
    // Buffer formats after filtering by nodes.
    UINT32              numOfFilteredFormats;                    ///< The number of filtered buffer formats.
    ChiBufferFormat     filteredFormats[MaxNumSupportedFormats]; ///< The buffer formats after node filtering.
} CHIBUFFEROPTIONS;

/// @brief Describes the buffer on an input or output port.
typedef struct /** @cond */ ChiPortBufferDescriptor /** @endcond */
{
    UINT32                   size;                          ///< Size of this structure.
    UINT                     numNodePorts;                  ///< Number of node ports for the buffer.
    ChiLinkNodeDescriptor*   pNodePort;                     ///< Pointer to the node port descriptor.
    CHISTREAM*               pStream;                       ///< Pointer to the stream that represents the buffer, which is
                                                            ///  also passed in the pipeline request.

    /// @brief Describes the flag properties and values.
    union
    {
        /// @brief Indicates the flag properties.
        struct
        {
            UINT32 bIsOverrideImplDefinedWithRaw    : 1;  ///< Selects MIPI Raw as the defined format of an application
                                                          ///  implementation.
            UINT32 hasValidBufferNegotiationOptions : 1;  ///< Indicates whether pBufferNegotiationOptions is used during
                                                          ///  buffer negotiations for pStream during the backwards walk.
            UINT32 reserved                         : 30; ///< Must be initialized to NULL.
        };

        UINT32 flagValue;    ///< Flag values for the buffer descriptor.
    };
    const CHIBUFFEROPTIONS* pBufferNegotiationsOptions;                 ///< Pointer to the options for the buffer.
    UINT32                  numOfSupportedFormats;                      ///< Number of supported formats
    ChiStreamFormat         supportedFormats[MaxNumSupportedFormats];   ///< Supported formats
} CHIPORTBUFFERDESCRIPTOR;

/// @brief Metadata tag ID to Maximum number of type and context IDs and bitmask map.
typedef struct MetaToMaxTypeId
{
    UINT32  tagId;              ///< Unique identifier of the metadata tag.
    UINT32  maxTypeId;          ///< Maximum number of type and context IDs.
    UINT32  typeIdBitMask;      ///< Bitmask for storing different type and context IDs.
    UINT32  typeIdIndex[static_cast<UINT32>(ChiContextType::MaxContext)]; ///< Index of types and contexts in the metadata.
                                                                          ///  This index is used for calculating an offset.
} METATOMAXTYPEID;

/// @brief Describes the metadata information from a pipeline.
typedef struct /** @cond */ ChiPipelineMetadataInfo /** @endcond */
{
    UINT32          maxNumMetaBuffers;                                   ///< Maximum number of metadata buffers required by
                                                                         ///  the pipeline.
    UINT32          publishTagCount;                                     ///< Number of tags published by the pipeline.
    UINT32          publishPartialTagCount;                              ///< Number of partial metadata tags published by
                                                                         ///  the pipeline.
    UINT32          publishTagArray[MaximumChiPipelineTagsPublished];    ///< Constant array of tags published by the pipeline.
    UINT32          publishTypeIdMapCount;                               ///< Total number of context tags published by
                                                                         ///  the pipeline.
    METATOMAXTYPEID publishTypeIdMapArray[MaximumContextTagsPublished];  ///< Constant array of context-based tags
                                                                         ///  published by the pipeline.

} CHIPIPELINEMETADATAINFO;

/// @brief Contains recovery data for a PCR timeout.
typedef struct /** @cond */ ChiPCRTimeoutRecoveryData /** @endcond */
{
    CHIHANDLE                 pSessionHandle;    ///< Handle to the session.
    ChiSystemEventHeader      headerData;        ///< Header data for the system event.
} CHIPCRTIMEOUTRECOVERYDATA;

/// @brief Contains a fraction of two integers, a numerator and a denominator.
typedef struct /** @cond */ ChiRational /** @endcond */
{
    UINT32   numerator;                         ///< Supported with no performance impact.
    UINT32   denominator;                       ///< High Quality (HQ) mode is available with a performance impact.
} CHIRATIONAL;

/// @brief Union of available sensor capabilities.
typedef union /** @cond */ ChiSensorModeCaps /** @endcond */
{
    /// @brief Bitfield that describes the sensor capabilities.
    struct
    {
        BIT Normal       : 1;                       ///< Normal mode.
        BIT HFR          : 1;                       ///< High frame rate.
        BIT IHDR         : 1;                       ///< In-sensor High Dynamic Range mode.
        BIT PDAF         : 1;                       ///< Phase Detection Autofocus mode.
        BIT ZZHDR        : 1;                       ///< Zigzag HDR mode.
        BIT DEPTH        : 1;                       ///< Depth mode.
        BIT SHDR         : 1;                       ///< Staggered HDR mode.
        BIT FS           : 1;                       ///< Fast Shutter mode.
        BIT InSensorZoom : 1;                       ///< In-sensor Zoom mode.
        BIT Internal     : 1;                       ///< Internal mode.
        BIT AEB          : 1;                       ///< AEB mode.
        BIT XCFA         : 1;                       ///< XCFA (Universal Color Filter Array) mode.
        BIT XHDR         : 1;                       ///< XHDR (Universal High Dynamic Range) mode.
        BIT IDCG         : 1;                       ///< IDCG mode
        BIT EVS          : 1;                       ///< EVS (Event-based Vision Sensor) mode.
        BIT reserved     : 16;                      ///< Must be initialized to NULL.
        BIT OEMCapsStart : 1;                       ///> Indicate OEM Caps start
    }u;
    /*Internal Caps bit 0-31, OEM Caps bit 32-63*/
    UINT64 value;                                   ///< Value for the sensor capabilities.
} CHISENSORMODECAPS;

/// @brief Sensor resolution
enum class ChiSensorResolution
{
    Low,         ///< Sensor will work on a low resolution mode
    High,        ///< Sensor will work on a high/normal resolution mode
};

/// @brief Valid types of HDR exposures.
typedef enum /** @cond */ ChiHDRExposureType /** @endcond */
{
    OneExposure   = 0,
    TwoExposure   = 1,
    ThreeExposure = 2,
    ExposureMAX   = 3
} CHIHDREXPOSURETYPE;

/// @brief Supported HDR feature modes.
typedef enum /** @cond */ ChiHDRFeatureMode /** @endcond */
{
    HDRFeatureModeNone,
    HDRFeatureModeSHDR,
    HDRFeatureModeMFHDR,
    HDRFeatureModeQHDR,
    HDRFeatureModeMax
}CHIHDRFEATUREMODE;

/// @brief Supported ScreenGrab modes.
typedef enum /** @cond */ ChiScreenGrabMode /** @endcond */
{
    ScreenGrabModeNone,
    ScreenGrabModeSHDR,
    ScreenGrabModeMFHDR,
    ScreenGrabModeQHDR,
    ScreenGrabModeVRT,
    ScreenGrabModeMax
}CHISCREENGRABMODE;

/// @brief Defines the AI camera modes.
enum AICameraModes
{
    AICameraModeOff,
    AICameraModeSnapshotOnly,
    AICameraModeOn,
    AICameraModeMax
};

/// @brief Contains data for the HDR feature mode.
typedef union /** @cond */ ChiHDRFeatureModeData /** @endcond */
{
    /// @brief Bit definitions.
    struct
    {
        BIT AEB         : 1;       ///< AEB.
        BIT Merge       : 1;       ///< Bayer merge.
        BIT reserved    : 30;      ///< Must be initialized to NULL.
    }u;
    UINT32 value;                  ///< Value for the feature mode.
}CHIHDRFEATUREMODEDATA;

/// @brief Contains the HDR feature modes and HDR feature mode data.
typedef struct /** @cond */ ChiHDRModeInfo /** @endcond */
{
    ChiHDRFeatureMode       HDRMode;        ///< Selected HDR mode for the camera.
    ChiHDRFeatureModeData   HDRModeData;    ///< Selected HDR mode data for the camera.
}CHIHDRMODEINFO;

/// @brief Valid types of sensor streams.
typedef enum /** @cond */ ChiSensorStreamType /** @endcond */
{
    StreamBlob          = 0,
    StreamImage         = 1,
    StreamPDAF          = 2,
    StreamHDR           = 3,
    StreamMeta          = 4,
    StreamImageShort    = 5,
    StreamImageMiddle   = 6,
    StreamPDAFVertical  = 7,
    StreamPDAFShort     = 8,
    StreamImage1        = 9,
    StreamImage2        = 10,
    StreamImage3        = 11,
    StreamMAX           = 12
} CHISENSORSTREAMTYPE;

/// @brief Valid remosaic types.
typedef enum /** @cond */ ChiRemosaicType /** @endcond */
{
    UnKnown     = -1, ///< Remosaic type is unknown or invalid.
    SWRemosaic  = 0,  ///< Remosaic by the external software library.
    HWRemosaic  = 1,  ///< Remosaic by the InSensor hardware.
    NoRemosaic  = 2   ///< Raw QCFA output without any remosaic.
} CHIREMOSAICTYPE;

/// @brief Types of PDAF supported for a specific sensor mode.
typedef enum /** @cond */ ChiPDAFType /** @endcond */
{
    PDTypeUnknown = 0, ///< Type is invalid or unknown.
    PDType1       = 1, ///< Calculated PD values are sent by the sensor.
    PDType2       = 2, ///< Raw PD pixels are sent by the sensor to calculate PD.
    PDType3       = 3, ///< PD pixels embedded in Raw image, so need to separate them and calculate PD.
    PDType2PD     = 4, ///< Similar to Type2, but with dual photodiode PD pixels.
    PDTypeQPD     = 5  ///< QPD PDAF. Similar to 2PD but with four photodiode PD pixels.
} CHIPDAFTYPE;

/// @brief Number of Phases supported by the depth sensor mode
enum /** @cond */ DepthPhaseType /** @endcond */
{
    TWOPHASE  = 0,
    FOURPHASE = 1,
};

/// @brief Defines the depth information
typedef struct /** @cond */ ChiSensorDepthInfo /** @endcond */
{
    BOOL                   isAvailable;                ///< Indicates if the sensor driver has depth info
    DepthPhaseType         phaseType;                  ///< Number of phases supported by the mode
    BOOL                   isPhaseShuffle;             ///< Indicates if mode supports Phase shuffle
    BOOL                   isInterleavingMode;         ///< Indicates if the frames will be batched in
                                                       ///< interleaving fashion
    UINT32                 freqModulation[MaxFrequencyModulations];    ///< List of light frequencies generated
    UINT32                 frequencyGCD;               ///< Greatest Common Divisor of the light frequencies
} CHISENSORDEPTHINFO;

/// @brief Generic data structure that contains width and height integer values, and a start offset.
typedef struct /** @cond */ ChiRect /** @endcond */
{
    UINT32      left;                           ///< X coordinate for the top left point.
    UINT32      top;                            ///< Y coordinate for the top left point.
    UINT32      width;                          ///< Width of the rectangle.
    UINT32      height;                         ///< Height of the rectangle.
} CHIRECT;

/// @brief Similar to #CHIRECT, but the coordinates for a point can be negative values.
typedef struct /** @cond */ ChiRectINT /** @endcond */
{
    INT32       left;                           ///< X coordinate for the top left point.
    INT32       top;                            ///< Y coordinate for the top left point.
    UINT32      width;                          ///< Width of the rectangle.
    UINT32      height;                         ///< Height of the rectangle.
} CHIRECTINT;

/// @brief Generic data structure that contains width and height integer values, and a start offset. This structure can be used
/// for positive and negative values.
typedef struct /** @cond */ ChiRectEXT /** @endcond */
{
    INT32      left;                           ///< X coordinate for the top left point.
    INT32      top;                            ///< Y coordinate for the top left point.
    INT32      right;                          ///< X coordinate for the bottom right point.
    INT32      bottom;                         ///< Y coordinate for the bottom right point.
} CHIRECTEXT;

/// @brief Resource policies for communicating the intent of a use case.
///
/// These policies allow the driver to make the correct trade-off when optimizing power and usage of hardware resources.
typedef enum /** @cond */ ChiResourcePolicy /** @endcond */
{
    GreedyPowerOptimal = 0,    ///< Use more hardware resources to optimize for power if the power criteria passes the internal
                               ///  criteria.
                               ///
                               ///  This option might lead to an out-of-resource situation for multi-sensor sessions and use
                               ///  cases.

    HWResourceMinimal          ///< Limit the number of hardware resources used for each stream to maximize the number of
                               ///  simultaneous sensors. This option implies that each stream is limited in resolution.
} CHIRESOURCEPOLICY;

/// @brief Stream configuration parameters for sensors.
typedef struct /** @cond */ ChiSensorStreamConfig /** @endcond */
{
    UINT32               vc[MaxSensorVirtualChannelCount]; ///< Virtual channels defined in the sensor driver.
    UINT32               virtualChannelCount;              ///< Number of virtual channels.
    UINT32               dt;                               ///< Data type.
    CHIRECT              frameDimension;                   ///< Dimensions of the sensor output frame.
    UINT32               bpp;                              ///< Bits per pixel.
    CHISENSORSTREAMTYPE  streamtype;                       ///< Type of sensor stream.
} CHISENSORSTREAMCONFIG;

/// @brief Raw (unformatted) OTP data obtained from the EEPROM.
typedef struct /** @cond */ ChiRawOTPData /** @endcond */
{
    UINT8*  pRawData;       ///< Pointer to the Raw or unformatted OTP data read from the EEPROM.
    UINT32  rawDataSize;    ///< Size of the Raw or unformatted OTP data read from the EEPROM.
} CHIRAWOTPDATA;

/// @brief Custom information for EEPROM data.
typedef struct /** @cond */ ChiEEPROMCustomInfo /** @endcond */
{
    CHAR   name[MaximumStringLength];  ///< Name of the custom element to identify the type of information.
    INT32  value;                      ///< Value of the custom element corresponding to the custom name.
} CHIEEPROMCUSTOMINFO;

/// @brief Contains Raw OTP data and any other custom information.
typedef struct /** @cond */ ChiEEPROMInformation /** @endcond */
{
    ChiRawOTPData        rawOTPData;                             ///< Raw or unformatted OTP data information.
    ChiEEPROMCustomInfo  customInfo[MaxEEPROMCustomInfoCount];   ///< Custom information configured specifically for the EEPROM
                                                                 ///  and sensor.
    UINT32               customInfoCount;                        ///< Number of valid elements in the custom information data.
} CHIEEPROMINFORMATION;

/// @brief Defines a single mode for a camera sensor.
///
/// This structure never shrinks, nor are existing fields reordered or repurposed on interface changes. All fields must have a
/// default value of 0, which means the feature is not available.
typedef struct /** @cond */ ChiSensorModeInfo /** @endcond */
{
    UINT32                 size;                       ///< Size of this structure.
                                                       ///
                                                       ///  Mismatches in size are a warning to the driver that the interface
                                                       ///  header used by the client does not match the interface header used
                                                       ///  by the CHI interface. If there is a mismatch, this structure
                                                       ///  contains only the data that is available in the oldest CHI
                                                       ///  interface.

    UINT32                 modeIndex;                  ///< Sensor mode index for the specified use case.
    UINT32                 arraySizeInMPix;            ///< Number of pixels in the array.
    CHIRECT                frameDimension;             ///< Dimensions of the sensor output frame.
    CHIRECT                cropInfo;                   ///< Information about the requested Camera Serial Interface Decoder
                                                       ///  (CSID) crop.
    CHIRATIONAL            aspectRatio;                ///< Aspect ratio for the sensor in the specified Sensor mode.
    UINT32                 bpp;                        ///< Bits per pixel.
    UINT32                 frameRate;                  ///< Frame rate in frames per second.
    UINT32                 batchedFrames;              ///< Number of frames batched into an SOF (HFR mode).
    CHISENSORMODECAPS      sensorModeCaps;             ///< Sensor mode capabilities (HFR, Quadra, and so on) that are specific
                                                       ///  to this mode.
    CHISENSORSTREAMTYPE    streamtype;                 ///< Type of sensor stream .
    CHIREMOSAICTYPE        remosaictype;               ///< Type of remosaic software or hardware.
    UINT32                 horizontalBinning;          ///< Horizontal binning value.
    UINT32                 verticalBinning;            ///< Vertical binning value.

    BOOL                   HALOutputBufferCombined;    ///< Indicates whether the HAL output buffer is combined for batch mode.
                                                       ///
                                                       ///  @valuesbul
                                                       ///  - 0 -- FALSE
                                                       ///  - 1 -- TRUE (buffer is combined) @tablebulletend

    UINT32                 CSIPHYId;                   ///< Physical ID of the camera serial interface (CSI).
    UINT32                 is3Phase;                   ///< Indicates three-phase.
    UINT32                 laneCount;                  ///< Lane count.
    UINT64                 outPixelClock;              ///< Output pixel clock.
    UINT64                 streamConfigCount;          ///< Number of stream configuration parameters.
    UINT32                 laneCfg;                    ///< Lane configuration.
    CHISENSORSTREAMCONFIG  streamConfig[StreamMAX];    ///< Array of stream configuration parameters.
    CHIRectangle           activeArrayCropWindow;      ///< Crop co-ordinates with respect to the active pixel array.
    CHIPDAFTYPE            PDAFType;                   ///< Indicates the type of PD if it is available in the mode.
    CHIHDREXPOSURETYPE     HDRExposureType;            ///< Sensor HDR exposure type.

    BOOL                   isAEBSupported;             ///< Indicates whether dynamic AEB ON/OFF is supported for this mode.
                                                       ///
                                                       ///  @valuesbul
                                                       ///  - 0 -- FALSE
                                                       ///  - 1 -- TRUE (buffer is combined) @tablebulletend

    CHIRectangle           fullSizeArrayCropWindow;    ///< Crop co-ordinates with respect to the full-size pixel array.
    UINT32                 numberOfPixelsPerColor;     ///< Number of pixels per color
    BOOL                   isOverlappedSHDRSupported;  ///< Indicates this mode supports overlapped SHDR or not
                                                       ///  sensor.
    UINT32                 seamlessTransitionList[MaximumNumTransitionsSupported];  ///< Array of seamless transition mode
                                                                                    ///  lists.
    UINT32                 seamlessTransitionListSize; ///< Size of the Transition mode list.
    UINT32                 frameLengthLines;           ///< Frame Length Lines
    DOUBLE                 lineReadoutTimeNS;          ///< Line Readout Time in nano seconds
    CHISENSORDEPTHINFO     depthInfo;                  ///< Sensor Depth Information
} CHISENSORMODEINFO;

/// @brief Contains parameters for selecting a Sensor mode.
typedef struct /** @cond */ ChiSensorModePickHint /** @endcond */
{
    BOOL              postSensorUpscale;        ///< Indicates whether upscale is allowed for postprocessing.
                                                ///
                                                ///  @valuesbul
                                                ///  - 0 -- FALSE
                                                ///  - 1 -- TRUE (allowed) @tablebulletend

    CHISENSORMODECAPS sensorModeCaps;           ///< Specific capabilities of the sensor.
    CHIDIMENSION      sensorOutputSize;         ///< Override output dimensions of the sensor.
    UINT              frameRateMultiplier;      ///< Frame rate multiplier relative to the use case fps.
    BOOL              isForSnapshot;            ///< To select sensor mdoe for snasphot pipeline/request
} CHISENSORMODEPICKHINT;

/// @brief contains AF lens calibration chart ditsance and DAC values for AF sync.
typedef struct /** @cond */ ChiAFLensData /** @endcond */
{
    UINT32  chartDistanceCM;    ///< Chart distance in centimetres
    INT16   DACValue;           ///< Lens position DAC value at chart distance
    FLOAT   stepPosition;       ///< lens position step value(linearized) corresponding to DAC value
} CHIAFLensData;

/// @brief Auto focus calibration data to generate step table and taking care of hall effect.
typedef struct /** @cond */ ChiAFCalibrationData /** @endcond */
{
    BOOL            isAvailable;                                ///< Indicates whether AF calibration data is available or not
    CHIAFLensData   calibrationInfo[MaxAFCalibrationDistances]; ///< contains chart distance and correpsonding DAC values
    UINT32          numberOfDistances;                          ///< Number of calibrated distances
} CHIAFCALIBRATIONDATA;

/// @brief Defines sensor capabilities related to the imaging characteristics for a device.
///
/// This structure never shrinks, nor are existing fields reordered or repurposed on interface changes. All fields must have a
/// default value of 0, which means the feature is not available.
typedef struct /** @cond */ ChiSensorCaps /** @endcond */
{
    UINT32                  size;                       ///< Size of this structure.
                                                        ///
                                                        ///  Mismatches in size are a warning to the driver that the interface
                                                        ///  header used by the client does not match the interface header used
                                                        ///  by the CHI interface. If there is a mismatch, this structure
                                                        ///  contains only the data that is available in the oldest CHI
                                                        ///  interface.

    UINT32                  sensorId;                   ///< Unique identifier of the camera sensor.
    CHIDIRECTION            facing;                     ///< Direction the camera faces relative to the device screen.
    CHISENSORPOSITIONTYPE   positionType;               ///< Type of camera sensor position: main or auxiliary.
    FLOAT                   pixelSize;                  ///< Physical size of one pixel (in micrometers).
    CHIRECT                 activeArray;                ///< Area of the image sensor that corresponds to the active pixels.
    VOID*                   pRawOTPData;                ///< Pointer to the Raw OTP data.
    UINT32                  rawOTPDataSize;             ///< Size of the Raw OTP data.
    BOOL                    isVirtualSensor;            ///< Sensor module is Virtual or Real/External.
    BOOL                    isAONCamera;                ///< Camera is AON capable
    CHAR*                   pSensorName;                ///< Pointer to the name of the sensor.
    CHIRECT                 sensorFullArray;            ///< Area of the image sensor that represents the actual image
                                                        ///  pixels being exposed after geometric distortion correction is
                                                        ///  applied. The geometric distortion is the actual sensor active
                                                        ///  array.
    CHIRECT                 croppedFromsensorFullArray; ///< Number of pixels in all directions that are cropped from
                                                        ///  the actual sensor active array and used to publish the active
                                                        ///  array.
    CHIAFCALIBRATIONDATA    afCalibration;              ///< Auto Focus calibration data
    BOOL                    isAONCamBusShared;          ///< WIll be true if the bus is shared with AON camera
    BOOL                    isYUVCamera;                ///< Camera is a YUV camera
} CHISENSORCAPS;

/// @brief Defines capabilities related to the lens characteristics of a device.
///
/// This structure never shrinks, nor are existing fields reordered or repurposed on interface changes. All fields must have a
/// default value of 0, which means the feature is not available.
typedef struct /** @cond */ ChiLensCaps /** @endcond */
{
    UINT32      size;            ///< Size of this structure.
                                 ///
                                 ///  Mismatches in size are a warning to the driver that the interface header used by the
                                 ///  client does not match the interface header used by the CHI interface. If there is a
                                 ///  mismatch, this structure contains only the data that is available in the oldest CHI
                                 ///  interface.

    FLOAT       focalLength;     ///< Focal length of the lens.

    BOOL        isFixedFocus;    ///< Indicates whether the focus is fixed.
                                 ///
                                 ///  @valuesbul
                                 ///  - 0 -- FALSE
                                 ///  - 1 -- TRUE (fixed) @tablebulletend

    FLOAT       horViewAngle;    ///< Horizontal view angle (in degrees) of the lens.
} CHILENSCAPS;

/// @brief Test generator capabilities related to the device.
typedef struct
{
    UINT32 maxBayerWidth;                ///< Maximum regular Bayer width.
    UINT32 maxBayerHeight;               ///< Maximum regular Bayer height.
    UINT32 maxQCFAWidth;                 ///< Maximum QCFA width.
    UINT32 maxQCFAHeight;                ///< Maximum QCFA height.
    UINT32 maxQCFAHDRWidth;              ///< Maximum QCFA HDR width.
    UINT32 maxQCFAHDRHeight;             ///< Maximum QCFA HDR height.
    UINT32 maxSHDRWidth;                 ///< Maximum SHDR width.
    UINT32 maxSHDRHeight;                ///< Maximum SHDR height.
    UINT32 maxPDAFWidth;                 ///< Maximum PDAF width.
    UINT32 maxPDAFHeight;                ///< Maximum PDAF height.

    BOOL   bISSHDRSupported;             ///< Indicates whether the test generator supports SHDR mode.
                                         ///
                                         ///  @valuesbul
                                         ///  - 0 -- FALSE
                                         ///  - 1 -- TRUE @tablebulletend

    BOOL   bIsYUVSupported;              ///< Indicates whether the test generator supports YUV output.
                                         ///
                                         ///  @valuesbul
                                         ///  - 0 -- FALSE
                                         ///  - 1 -- TRUE @tablebulletend

    BOOL   bIsQCFASupported;             ///< Indicates whether the test generator supports QCFA mode.
                                         ///
                                         ///  @valuesbul
                                         ///  - 0 -- FALSE
                                         ///  - 1 -- TRUE @tablebulletend

    BOOL   bIsQCFAHDRSupported;          ///< Indicates whether the test generator supports QCFA HDR mode.
                                         ///
                                         ///  @valuesbul
                                         ///  - 0 -- FALSE
                                         ///  - 1 -- TRUE @tablebulletend

    BOOL   bIsFSSupported;               ///< Indicates whether the test generator supports FS mode.
                                         ///
                                         ///  @valuesbul
                                         ///  - 0 -- FALSE
                                         ///  - 1 -- TRUE @tablebulletend

    BOOL   bIsPDAFSupported;             ///< Indicates whether the test generator supports PDAF mode.
                                         ///
                                         ///  @valuesbul
                                         ///  - 0 -- FALSE
                                         ///  - 1 -- TRUE @tablebulletend

    UINT32 maxBitWidth;                  ///< Maximum bit width that can be configured.
    UINT32 maxNumberOfExposuresinSHDR;   ///< Maximum number of exposures that can be supported by the test generator.
                                         ///  @tablebulletend
} CHITESTGENCAPS;

/// @brief Defines all capabilities for a single physical camera sensor.
///
/// This structure enumerates all the limitations in place when this camera sensor is in use for a session.
/// The structure never shrinks, nor are existing fields reordered or repurposed on interface changes. All fields must have a
/// default value of 0, which means the feature is not available.
typedef struct /** @cond */ ChiCameraInfo /** @endcond */
{
    UINT32           size;              ///< Size of this structure.
                                        ///
                                        ///  Mismatches in size are a warning to the driver that the interface header used by
                                        ///  the client does not match the interface header used by the CHI interface. If there
                                        ///  is a mismatch, this structure contains only the data that is available in the
                                        ///  oldest CHI interface.

    UINT32           numSensorModes;    ///< Number of sensor modes.

    VOID*            pLegacy;           ///< Temporary pointer to the framework's metadata structure.
                                        ///
                                        ///  This parameter is used only by the initial override implementation, and it will be
                                        ///  deprecated in the future.

    CHISENSORCAPS    sensorCaps;        ///< Capabilities related to the imaging characteristics of the device.
    CHILENSCAPS      lensCaps;          ///< Capabilities related to the lens characteristics of the device.
    const CHAR*      pTuningBinName;    ///< Pointer to the tuning bin name
} CHICAMERAINFO;

typedef struct ChiPipelineInputOptions CHIPIPELINEINPUTOPTIONS;
typedef ChiPipelineInputOptions        CHIPIPELINEOUTPUTOPTIONS;
typedef ChiPipelineInputOptions        ChiPipelineOptions;

/// @brief Input buffer information to be used when a session is created.
typedef struct /** @cond */ ChiInputBufferInfo /** @endcond */
{
    UINT32                         numInputBuffers;         ///< Number of input buffers.
    const CHIPORTBUFFERDESCRIPTOR* pInputBufferDescriptors; ///< Pointer to the descriptors of the input buffers.
    CHIPIPELINEINPUTOPTIONS*       pPipelineInputOptions;   ///< Pointer to the input buffer options.
} CHIINPUTBUFFERINFO;

/// @brief Information about the sensor used in a pipeline.
typedef struct /** @cond */ ChiSensorInfo /** @endcond */
{
    UINT32                   cameraId;                      ///< Unique identifier of the camera.
    const CHISENSORMODEINFO* pSensorModeInfo;               ///< Pointer to the Sensor mode information.
} CHISENSORINFO;

/// @brief Information about the pipeline inputs.
typedef struct /** @cond */ ChiPipelineInputInfo /** @endcond */
{
    UINT32 isInputSensor;                      ///< Indicates whether the pipeline input is a sensor.

    /// @brief Describes the pipeline input based on isInputSensor.
    union
    {
        CHISENSORINFO      sensorInfo;         ///< If the pipeline input is a sensor, use the CHISENSORINFO structure.
        CHIINPUTBUFFERINFO inputBufferInfo;    ///< If the pipeline input is not a, tse the CHIINPUTBUFFERINFO structure
                                               ///  sensor.
    };

} CHIPIPELINEINPUTINFO;

/// @brief Output dimensions for the pipeline.
typedef struct /** @cond */ ChiPipelineOutputDimension /** @endcond */
{
    CHIBUFFERDIMENSION      outputDimension;    ///< Dimensions of the output buffer.
    CHIPIPELINEOUTPUTTYPE   outputType;         ///< Type of pipeline output.
} CHIPIPELINEOUTPUTDIMENSION;

/// @brief Output buffer information to be used when a session is created.
typedef struct /** @cond */ ChiOutputBufferInfo /** @endcond */
{
    UINT32                         numOutputBuffers;         ///< Number of output buffers.
    const CHIPORTBUFFERDESCRIPTOR* pOutputBufferDescriptors; ///< Pointer to the descriptors of the output buffers.
    CHIPIPELINEOUTPUTOPTIONS*      pPipelineOutputOptions;   ///< Pointer to the output buffer options.
} CHIOUTPUTBUFFERINFO;

/// @brief Output information for the pipeline.
typedef struct /** @cond */ ChiPipelineOutputInfo /** @endcond */
{
    CHIPIPELINEHANDLE         hPipelineHandle;       ///< Handle that represents the created pipeline.
    CHIOUTPUTBUFFERINFO       outputBufferInfo;      ///< Output buffer information.
} CHIPIPELINEOUTPUTINFO;

/// @brief Pipeline information used when a session is created.
typedef struct /** @cond */ ChiPipelineInfo /** @endcond */
{
    CHIPIPELINEDESCRIPTOR hPipelineDescriptor;                 ///< Handle of the pipeline descriptor.
    UINT                  numTransitionModes;                  ///< Number of Transition modes.
    CHIPIPELINEINPUTINFO  pipelineInputInfo;                   ///< Input information for the pipeline.
    UINT32                prefferdTransitionMode;              ///< Indicates the preferred transition mode.
    CHIPIPELINEOUTPUTINFO pipelineOutputInfo;                  ///< Output information the pipeline.

    UINT32                pipelineResourcePolicy;              ///< Resource policy that allows the driver to make the right
                                                               ///  trade-off when optimizing power and usage of hardware
                                                               ///  resources.
                                                               ///
                                                               ///  @values #CHIRESOURCEPOLICY

    BOOL                  isDeferFinalizeNeeded;               ///< Indicates whether pipeline finalization is to be deferred.
                                                               ///
                                                               ///  @valuesbul
                                                               ///  - 0 -- FALSE
                                                               ///  - 1 -- TRUE (deferred) @tablebulletend

    BOOL                  disableDeferFinalizeForOffline;      ///< Flag to indicate if deferred finalization for offline
                                                               ///  pipelines should be disabled, since they are deferred
                                                               ///  by default
    BOOL                  isBufferRenegoNeeded;                ///< Indicates whether buffer renegotiation is needed
                                                               ///
                                                               ///  @valuesbul
                                                               ///  - 0 -- FALSE
                                                               ///  - 1 -- TRUE (Re-neogotiation is needed) @tablebulletend
    BOOL                  isPartialSessionInitNeeded;          ///< Indicates whether partial session initialization is needed
} CHIPIPELINEINFO;

/// @brief Input options for the pipeline.
typedef struct /** @cond */ ChiPipelineInputOptions /** @endcond */
{
    CHILINKNODEDESCRIPTOR nodePort;                                  ///< Information about the input and output buffer node
                                                                     ///  or port.
    CHIBUFFEROPTIONS      bufferOptions;                             ///< Requirement options for the buffer.
    UINT32                numFormatOptions;                          ///< The number of stream formats after filtering.
    ChiStreamFormat       formatOptions[MaxNumSupportedFormats];     ///< Result of node filtered stream formats.
} CHIPIPELINEINPUTOPTIONS;

typedef UINT32 CHIDEACTIVATEPIPELINEMODE;    ///< Bit mask of pipeline deactivation modes.
                                             ///  @newpage
static const CHIDEACTIVATEPIPELINEMODE CHIDeactivateModeDefault         = (1 << 0); ///< Deactivate all nodes in
                                                                                    ///  the pipeline (default mode).
static const CHIDEACTIVATEPIPELINEMODE CHIDeactivateModeSensorStandby   = (1 << 1); ///< Deactivate sensor standby mode.
static const CHIDEACTIVATEPIPELINEMODE CHIDeactivateModeRealTimeDevices = (1 << 2); ///< Deactivate real-time device mode.
static const CHIDEACTIVATEPIPELINEMODE CHIDeactivateModeReleaseBuffer   = (1 << 3); ///< Release allocated buffers of all
                                                                                    ///  nodes in the pipeline.
static const CHIDEACTIVATEPIPELINEMODE CHIDeactivateModeUnlinkPipeline  = (1 << 4); ///< Turn off the stream and unlink the
                                                                                    ///  pipeline.
                                                                                    ///  @newpage

/// @brief Flags used when creating a session.
typedef union /** @cond */ ChiSessionFlags /** @endcond */
{
    /// @brief Bit field that describes the session flags.
    struct
    {
        BIT Deprecated          : 1;    ///< Do not use.
        BIT SupportsPartialMeta : 1;    ///< Session can handle a partial metadata callback (when set to TRUE).
        BIT isNativeChi         : 1;    ///< Session is related to native CHI (when set to TRUE).
        BIT IsFastAecSession    : 1;    ///< Session is a fast AEC session (when set to TRUE).
        BIT IsSSM               : 1;    ///< Session is Super Slow Motion (when set to TRUE).
        BIT reserved            : 27;   ///< Must be initialized to NULL.
    } u;
    UINT32 value;    ///< Value for the session flags.
} CHISESSIONFLAGS;

/// @brief Defines the flush types.
typedef enum /** @cond */ ChiFlushType /** @endcond */
{
    FlushSelective         = 1,  ///< Flush only selective requests.
    FlushAll               = 2   ///< Flush all requests.
} CHIFLUSHTYPE;

/// @brief Contains information about a pipeline flush.
typedef struct /** @cond */ ChiPipelineFlushInfo /** @endcond */
{
    CHIFLUSHTYPE      flushType;              ///< Flush selected requests or all requests.
    CHIPIPELINEHANDLE hPipelineHandle;        ///< Handle of the pipeline.
    UINT64            selectiveStartFrameNum; ///< Starting frame number for selective pipeline flush
    VOID*             pPrivData;              ///< Pointer to the private data that is managed by the client.
} CHIPIPELINEFLUSHINFO;

/// @brief Information about a session flush.
typedef struct /** @cond */ ChiSessionFlushInfo /** @endcond */
{
    CHIHANDLE                   pSessionHandle;      ///< Handle of the session.
    UINT32                      numPipelines;        ///< Number of pipelines in the array.
    const CHIPIPELINEFLUSHINFO* pPipelineFlushInfo;  ///< Pointer to the array of individual requests.

    BOOL                        isDestroyInProgress; ///< Flag that indicates whether the destroy operation is in progress.
                                                     ///
                                                     ///  @valuesbul
                                                     ///  - 0 -- FALSE
                                                     ///  - 1 -- TRUE @tablebulletend
} CHISESSIONFLUSHINFO;

/// Class for secure use cases.
enum class SecureUsecaseType
{
    NotSecure  = 0,     ///< Default use case.
    SecureMode = 1,     ///< Legacy Secure use case.
    TrustedVM  = 2,     ///< Trusted Virtual Machine.
    PrimaryVM  = 3,     ///< Primary Virtual Machine.
};

/// @brief Defines passes of buffer negotiation.
typedef enum /** @cond */ ChiBufferNegotiationPassId /** @endcond */
{
    BackwardBufferNegotiation       = 0,   ///< Backward for resolution range and format option list
    ForwardBufferNegotiation        = 1,   ///< Forward for finalizing the resolution and filtering format option list
    BackwardFinalizeFormatOptions   = 2,   ///< Backward for finalizing the format option list
    ForwardFinalizeBufferFormats    = 3,   ///< Forward for finalizing the format
    BackwardBufferRenegotiation     = 4,   ///< Redo the BackwardBufferNegotiation if the primary format is changed
    ForwardFinalizeBufferDimensions = 5,   ///< Redo the ForwardBufferNegotiation if the primary format is changed
    ForwardFinalizeBufferProperties = 6,   ///< Create target buffer manager
} CHIBUFFERNEGOTIATIONPASSID;

// pass Id string
static const CHAR* BufferNegotiationPassIdStrings[] =
{
    "BackwardBufferNegotiation",         ///< BackwardBufferNegotiation
    "ForwardBufferNegotiation",          ///< ForwardBufferNegotiation
    "BackwardFinalizeFormatOptions",     ///< BackwardFinalizeFormatOptions
    "ForwardFinalizeBufferFormats",      ///< ForwardFinalizeBufferFormats
    "BackwardBufferRenegotiation",       ///< BackwardBufferRenegotiation
    "ForwardFinalizeBufferDimension",    ///< ForwardFinalizeBufferDimension
    "ForwardFinalizeBufferProperties",   ///< ForwardFinalizeBufferProperties
};

/** @} */ /* end_addtogroup chi_common_defs */


/** @addtogroup chi_common_functions
@{ */

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond ChiQueryVendorTagLocation @endcond
///
/// @brief Queries for the vendor tag location assigned by the vendor tag manager.
///
/// @param[in]  pSectionName  Pointer to the section name of the vendor tag.
/// @param[in]  pTagName      Pointer to the name of the vendor tag.
/// @param[out] pTagLocation  Pointer to the location of the vendor tag.
///
/// @return #CDKResultSuccess or #CDKResultENoSuch.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNCHIQUERYVENDORTAGLOCATION)(
    const CHAR* pSectionName,
    const CHAR* pTagName,
    UINT32*     pTagLocation);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond ChiSetMetaData @endcond
///
/// @brief Sets the metadata according to the tag.
///
/// @datatypes
/// #CHIHANDLE
///
/// @param[in] metaHandle  Handle of the metadata.
/// @param[in] tag         Tag to be set.
/// @param[in] pData       Pointer to the data buffer.
/// @param[in] count       Size of the data buffer (in bytes).
///
/// @return Result status (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PSETMETADATA)(
   CHIHANDLE    metaHandle,
   UINT32       tag,
   VOID*        pData,
   SIZE_T       count);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond ChiGetMetaData @endcond
///
/// @brief Gets the metadata according to the tag.
///
/// @datatypes
/// #CHIHANDLE
///
/// @param[in] metaHandle  Handle of the metadata.
/// @param[in] tag         Tag to be set.
/// @param[in] pData       Pointer to the data buffer.
/// @param[in] count       Size of the data buffer (in bytes).
///
/// @return Result status (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PGETMETADATA)(
   CHIHANDLE    metaHandle,
   UINT32       tag,
   VOID*        pData,
   SIZE_T       count);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond ChiGetMetaDataTagId @endcond
///
/// @brief  Gets the metadata tag ID's given tag name.
///
/// @param[in]  pTagName  Pointer to the metadata tag name, including the section name.
/// @param[out] pTagId    Pointer to the tag ID that corresponds to the tag name.
///
/// @return None. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PGETMETADATATAGID)(
    const CHAR* pTagName,
    UINT32*     pTagId);

/** @} */ /* end_addtogroup chi_common_functions */


/// @ingroup chi_common_defs
/// @brief Contains basic functions for Vendor Tag IDs for the camera_metadata structure.
typedef struct /** @cond */ ChiVendorTagsOps /** @endcond */
{
    PFNCHIQUERYVENDORTAGLOCATION    pQueryVendorTagLocation;    ///< Get the Vendor Tag location.
    PSETMETADATA                    pSetMetaData;               ///< Set the metadata according to the tag ID.
    PGETMETADATA                    pGetMetaData;               ///< Get the metadata according to the tag ID.
    PGETMETADATATAGID               pGetMetaDataTagId;          ///< Get the metadata tag ID's given tag name.
    VOID*                           reserved[8];                ///< Pointer to the padding reserved for future use. Must be
                                                                ///  initialized to NULL.
} CHITAGSOPS;

/** @addtogroup chi_common_functions
@{ */

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNGETTAGOPS @endcond
///
/// @brief Gets the tag-related function pointers.
///
/// @datatypes
/// #CHITAGSOPS
///
/// @param[in,out] *  Pointer to the tag-related functions. Memory for CHITagOPS must be allocated by the caller.
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFNGETTAGOPS)(CHITAGSOPS*);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCREATEFENCE @endcond
///
/// @brief Creates a CHI fence.
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHIFENCECREATEPARAMS \n
/// #CHIFENCEHANDLE
///
/// @param[in] hChiContext  Handle of the CHI context.
/// @param[in] pInfo        Pointer to the structure containing information about the fence.
/// @param[in] phChiFence   Pointer to the CHI fence handle.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNCREATEFENCE)(
    CHIHANDLE              hChiContext,
    CHIFENCECREATEPARAMS*  pInfo,
    CHIFENCEHANDLE*        phChiFence);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNRELEASEFENCE @endcond
///
/// @brief Releases a CHI fence.
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHIFENCEHANDLE
///
/// @param[in] hChiContext  Handle of the CHI context.
/// @param[in] hChiFence    Handle of the CHI fence.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNRELEASEFENCE)(
    CHIHANDLE       hChiContext,
    CHIFENCEHANDLE  hChiFence);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNWAITFENCEASYNC @endcond
///
/// @brief Waits asynchronously for the fence callback.
///
/// @datatypes
/// #CHIHANDLE \n
/// #PFNCHIFENCECALLBACK \n
/// #CHIFENCEHANDLE
///
/// @param[in] hChiContext  Handle of the CHI context.
/// @param[in] pCallbackFn  Asynchronous callback function.
/// @param[in] hChiFence    Handle of the CHI fence.
/// @param[in] pData        Pointer of the user data.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNWAITFENCEASYNC)(
    CHIHANDLE            hChiContext,
    PFNCHIFENCECALLBACK  pCallbackFn,
    CHIFENCEHANDLE       hChiFence,
    VOID*                pData);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNSIGNALFENCE @endcond
///
/// @brief Signals a CHI fence.
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHIFENCEHANDLE \n
///
/// @param[in] hChiContext   Handle of the CHI context.
/// @param[in] hChiFence     Handle of the CHI fence.
/// @param[in] statusResult  Status result of the fence signal.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNSIGNALFENCE)(
    CHIHANDLE       hChiContext,
    CHIFENCEHANDLE  hChiFence,
    CDKResult       statusResult);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNGETFENCESTATUS @endcond
///
/// @brief Gets the status of a fence.
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHIFENCEHANDLE
///
/// @param[in] hChiContext  Handle of the CHI context.
/// @param[in] hChiFence    Handle of the CHI fence.
/// @param[in] pResult      Pointer to the CDKResult pointer to be filled with the fence status.
///
/// @return #CDKResultSuccess. Otherwise:
///          - #CDKResultEFailed       -- The fence signaled a Failure status.
///          - #CDKResultEInvalidState -- The fence has not yet signaled its status. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNGETFENCESTATUS)(
    CHIHANDLE       hChiContext,
    CHIFENCEHANDLE  hChiFence,
    CDKResult*      pResult);

/** @} */ /* end_addtogroup chi_common_functions */


/// @ingroup chi_common_defs
/// @brief Contains functions for CHI fences.
typedef struct /** @cond */ ChiFenceOps /** @endcond */
{
    PFNCREATEFENCE      pCreateFence;     ///< Create a fence.
    PFNRELEASEFENCE     pReleaseFence;    ///< Release a fence.
    PFNWAITFENCEASYNC   pWaitFenceAsync;  ///< Wait asynchronously on a fence.
    PFNSIGNALFENCE      pSignalFence;     ///< Signal a fence.
    PFNGETFENCESTATUS   pGetFenceStatus;  ///< Get the signal status of a fence.
    VOID*               reserved[8];      ///< Pointer to the padding reserved for future use. Must be set to initialized to
                                          ///  NULL.
                                          ///  @newpagetable
} CHIFENCEOPS;


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNGETFENCEOPS @endcond
///
/// @ingroup chi_common_functions
///
/// @brief Gets the CHI fence-related function pointers.
///
/// @datatypes
/// #CHIFENCEOPS
///
/// @param[in,out] *  Pointer to the structure that contains the function pointers.
///
/// @detdesc
///  Given a valid pointer, this function associates it with the available fence operations, such as create, release, and
///  signal.
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFNGETFENCEOPS)(
    CHIFENCEOPS*);


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  Chi Metadata Buffer (CMB)
///
/// @addtogroup chi_common_cmb
///
/// The CHI Metadata Buffer (CMB) contains the camera metadata: all the camera control parameters and information specified by
///  the camera2 metadata for vendor tags, and proprietary information that is exchanged between the nodes.
///
/// CMB operations are classified as follows:
/// - Basic metadata operations
/// - Supplementary operations for metadata buffer linkage and management
/// - Iterator operations for tag traversal
/// - Global metadata information query operations that provide all the metadata information (size, count, type, and so on)
///   that is visible to the client
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CMB Basic Operations
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/** @addtogroup chi_common_cmb
@{ */

/// @brief Contains parameters used to create data for CHI metadata.
typedef struct /** @cond */ ChiCMBCreateParams /** @endcond */
{
    BOOL             useExpContextMeta;  ///< Indicates whether to allocate context metadata for an exposure.
                                         ///
                                         ///  @valuesbul
                                         ///  - 0 -- FALSE
                                         ///  - 1 -- TRUE @tablebulletend

    UINT             reserved[6];        ///< Must be initialized to NULL.
    UINT32           maxTypeIdMapCount;  ///< Number of entries in the MaxTypeId map.
    METATOMAXTYPEID* pMaxTypeIdMap;      ///< Metadata tag ID to Maximum number of type and context IDs and bitmask map.
} CHICMBCREATEPARAMS;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_CREATE @endcond
///
/// @brief Creates a new metadata buffer with zero tags.
///
/// @datatypes
/// #CHIMETAHANDLE \n
/// #CHIMETAPRIVATEDATA
///
/// @param[out] pMetaHandle   Pointer to the metadata handle. This value cannot be NULL.
/// @param[in]  pPrivateData  Sets the private data associated with the handle. This value can be NULL.
///
/// @return
/// - #CDKResultSuccess if pMetaHandle is updated with the new handle.
/// - Otherwise, an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_CREATE)(
    CHIMETAHANDLE*      pMetaHandle,
    CHIMETAPRIVATEDATA  pPrivateData,
    CHICMBCREATEPARAMS* pCMBParams);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_CREATE_WITH_TAGARRAY @endcond
///
/// @brief Creates a metadata handle according to the pTagList parameter.
///
/// @datatypes
/// #CHIMETAHANDLE \n
/// #CHIMETAPRIVATEDATA
///
/// @param[in]  pTagList      Pointer to the linear array of tag enumerations. This parameter must contain only valid entries.
/// @param[in]  tagListCount  Maximum number of tags in the array.
/// @param[out] pMetaHandle   Pointer to the metadata handle. This value cannot be NULL.
///                           If successful, *pMetaHandle will be updated with the new handle.
/// @param[in]  pPrivateData  Sets the private data associated with the handle. This value can be NULL.
/// @param[in]  pCMBParams    Parameters used to assist metadata creation. This value can be NULL
///
/// @detdesc
/// If you are using vendor tags, call #PFNCHIQUERYVENDORTAGLOCATION to get the 32-bit tag ID that corresponds to each vendor
/// tag.
/// @par
/// Get all information about visible valid tags by using #PFN_CMB_GET_METADATA_TABLE().
///
/// @return
/// - #CDKResultSuccess if pMetaHandle is updated with the new handle.
/// - Otherwise, an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFN_CMB_CREATE_WITH_TAGARRAY)(
    const UINT32*       pTagList,
    UINT32              tagListCount,
    CHIMETAHANDLE*      pMetaHandle,
    CHIMETAPRIVATEDATA  pPrivateData,
    CHICMBCREATEPARAMS* pCMBParams);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_CREATE_WITH_ANDROIDMETADATA @endcond
///
/// @brief Creates a metadata handle according to the Android metadata (camera_metadata_t) specified by the camera2 functions.
///
/// @datatypes
/// #CHIMETAHANDLE \n
/// #CHIMETAPRIVATEDATA
///
/// @param[in]  pAndroidMeta  Pointer to the metadata.
/// @param[out] pMetaHandle   Pointer to the metadata handle. This value cannot be NULL. If successful, pMetaHandle will be
///                           updated with the new handle.
/// @param[in]  pPrivateData  Sets the private data associated with the handle. This value can be NULL.

/// @return
/// - #CDKResultSuccess if pMetaHandle is updated with the new handle.
/// - Otherwise, an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFN_CMB_CREATE_WITH_ANDROIDMETADATA)(
    const VOID*        pAndroidMeta,
    CHIMETAHANDLE*     pMetaHandle,
    CHIMETAPRIVATEDATA pPrivateData);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_DESTROY @endcond
///
/// @brief Destroys the metadata buffer specified by the handle.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in] hMetaHandle  Handle of the metadata.
/// @param[in] force        Indicates whether the metadata must be force-destroyed.
///
/// @detdesc
/// The metadata buffer can be destroyed only if the reference count is zero. Use #PFN_CMB_REFERENCE_COUNT to query for the
/// reference count.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFN_CMB_DESTROY)(
    CHIMETAHANDLE hMetaHandle,
    BOOL          force);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_CLONE @endcond
///
/// @brief Clones the metadata buffer and creates a new buffer.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in]  hSrcMetaHandle   Handle of the source metadata buffer.
/// @param[out] phDstMetaHandle  Pointer to the handle of the destination metadata buffer.
///
/// @return
/// - #CDKResultSuccess if phDstMetaHandle is updated with the handle to the new metadata.
/// - Otherwise, an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFN_CMB_CLONE)(
    CHIMETAHANDLE  hSrcMetaHandle,
    CHIMETAHANDLE* phDstMetaHandle);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_GET_TAG @endcond
///
/// @brief Gets the tag data specified by the tag identifier.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in]  hMetaHandle  Handle of the metadata.
/// @param[in]  tagID        Unique ID of the tag.
/// @param[in]  typeId       Context type id representing type of a given metadata tag
/// @param[out] ppData       Double pointer to the payload of the tag. This value must not be NULL.
///
/// @detdesc
/// For the ppData parameter, get the size and type of the payload data before using PFN_CMB_GET_METADATA_TABLE() to get
/// information about visible valid tags.
/// @par
/// The memory of the tag (ppData) belongs to the metadata buffer. The client must ensure that the memory is not used after the
/// metadata buffer (hMetaHandle) is destroyed.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFN_CMB_GET_TAG)(
    CHIMETAHANDLE hMetaHandle,
    UINT32        tagID,
    const UINT32  typeId,
    VOID**        ppData);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_GET_TAG_ENTRY @endcond
///
/// @brief Gets a tag entry specified by the tag identifier.
///
/// @datatypes
/// #CHIMETAHANDLE \n
/// #CHIMETADATAENTRY
///
/// @param[in]  hMetaHandle  Handle of the metadata.
/// @param[in]  tagID        Unique ID of the tag.
/// @param[out] pEntry       Pointer to the tag entry.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_GET_TAG_ENTRY)(
    CHIMETAHANDLE       hMetaHandle,
    UINT32              tagID,
    CHIMETADATAENTRY*   pEntry);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_GET_VENDORTAG @endcond
///
/// @brief Gets the tag data specified by the vendor tag section name and tag name.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in]  hMetaHandle      Handle of the metadata.
/// @param[in]  pTagSectionName  Pointer to the section name of the vendor tag.
/// @param[in]  pTagName         Pointer to the vendor tag name.
/// @param[in]  typeId           Context Type ID representing type for a given metadata tag
/// @param[out] ppData           Double pointer to the payload of the tag. This value must not be NULL.
///
/// @detdesc
/// For the ppData parameter, get the size and type of the payload data before using PFN_CMB_GET_METADATA_TABLE() to get
/// information about visible valid tags.
/// @par
/// The memory of the tag (ppData) belongs to the metadata buffer. The client must ensure that the memory is not used after the
/// metadata buffer (hMetaHandle) is destroyed.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_GET_VENDORTAG)(
    CHIMETAHANDLE hMetaHandle,
    const CHAR*   pTagSectionName,
    const CHAR*   pTagName,
    const UINT32  typeId,
    VOID**        ppData);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_GET_TAG_ENTRY @endcond
///
/// @brief Gets a vendor tag entry specified by the section name and tag name.
///
/// @datatypes
/// #CHIMETAHANDLE \n
/// #CHIMETADATAENTRY
///
/// @param[in]  hMetaHandle      Handle of the metadata.
/// @param[in]  pTagSectionName  Pointer to the section name of the vendor tag.
/// @param[in]  pTagName         Pointer to the vendor tag name.
/// @param[out] pEntry           Pointer to the tag entry.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_GET_VENDORTAG_ENTRY)(
    CHIMETAHANDLE       hMetaHandle,
    const CHAR*         pTagSectionName,
    const CHAR*         pTagName,
    CHIMETADATAENTRY*   pEntry);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_GET_TAG_BY_CAMERAID @endcond
///
/// @brief Gets the tag data, specified by the tag ID, from a specific camera ID.
///
/// @param[in]  hMetaHandle  Handle of the metadata.
/// @param[in]  tagID        Unique identifier of the tag.
/// @param[in]  cameraId     Unique identifier of the camera.
/// @param[out] ppData       Double pointer to the payload of the tag. This parameter must not be NULL. On success, it points
///                          to the valid data. The size and type of the data must be known before using
///                          PFN_CMB_GET_METADATA_INFO_TABLE.
///
/// @detdesc
/// This API is only valid for metadata handles that are created using #PFN_CMB_MERGE_MULTICAMERA_METADATA.
/// @par
/// The memory of the tag (ppData) belongs to the metadata buffer. The client must ensure that the memory is not used after
/// the metadata buffer (hMetaHandle) is destroyed.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFN_CMB_GET_TAG_BY_CAMERAID)(
    CHIMETAHANDLE hMetaHandle,
    UINT32        tagID,
    UINT32        cameraId,
    VOID**        ppData);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_IS_MULTICAMERA_METADATA @endcond
///
/// @brief Checks whether the metadata is merged multi-camera metadata.
///
/// @param[in] hMetaHandle  Handle of the metadata.
///
/// @return TRUE if the metadata is multi-camera metadata; otherwise, FALSE.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef BOOL (*PFN_CMB_IS_MULTICAMERA_METADATA)(
    CHIMETAHANDLE hMetaHandle);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_SET_TAG @endcond
///
/// @brief Sets the tag specified by the tag ID into the metadata buffer.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in] hMetaHandle  Handle of the metadata.
/// @param[in] tagID        Unique identifier of the tag.
/// @param[in] pData        Pointer to the data buffer.
/// @param[in] count        Maximum size of the data buffer (in bytes).
/// @param[in] typeId       Pointer to the context type identifier that represents the type of a given metadata tag.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFN_CMB_SET_TAG)(
    CHIMETAHANDLE hMetaHandle,
    UINT32        tagID,
    const VOID*   pData,
    UINT32        count,
    const UINT32  typeId);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_SET_VENDORTAG @endcond
///
/// @brief Sets the vendor tag specified by the section and tag name into the metadata buffer.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in] hMetaHandle      Handle of the metadata.
/// @param[in] pTagSectionName  Pointer to the section name of the vendor tag.
/// @param[in] pTagName         Pointer to the vendor tag name.
/// @param[in] pData            Pointer to the data buffer.
/// @param[in] count            Maximum size of the data buffer (in bytes).
/// @param[in] typeId           Context type id representing type of a given metadata tag
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_SET_VENDORTAG)(
    CHIMETAHANDLE hMetaHandle,
    const CHAR*   pTagSectionName,
    const CHAR*   pTagName,
    const VOID*   pData,
    UINT32        count,
    const UINT32  typeId);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_SET_ANDROIDMETADATA @endcond
///
/// @brief Sets all the tags provided by Android camera metadata into the metadata buffer.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in] hMetaHandle   Handle of the metadata.
/// @param[in] pAndroidMeta  Pointer to the camera metadata (camera_metadata_t).
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_SET_ANDROIDMETADATA)(
    CHIMETAHANDLE hMetaHandle,
    const VOID*   pAndroidMeta);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_DELETE_TAG @endcond
///
/// @brief Deletes the tag specified by the tag identifier.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in] hMetaHandle  Handle of the metadata.
/// @param[in] tagID        Unique identifier of the tag.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFN_CMB_DELETE_TAG)(
    CHIMETAHANDLE hMetaHandle,
    UINT32        tagID);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_INVALIDATE @endcond
///
/// @brief Invalidates all the tags in the metadata buffer.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in] hMetaHandle  Handle of the metadata.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFN_CMB_INVALIDATE)(
    CHIMETAHANDLE hMetaHandle);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_MERGE @endcond
///
/// @brief Merges the source metadata with the destination metadata.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[out] hDstMetaHandle  Handle of the destination metadata buffer.
/// @param[in]  hSrcMetaHandle  Handle of the source metadata buffer.
/// @param[in]  disjoint        Indicates whether the merge is disjointed.
///
/// @detdesc
/// If the disjoint flag is set, only the tags that are not in the destination buffer are merged. Otherwise, for overlapping
/// tags, entries in hDstMetaHandle are overwritten with entries from hSrcMetaHandle.
/// @par
/// Tags from the source buffer are not deep copied to the destination metadata buffer. After a successful merge operation, the
/// destination buffer has tags that refer to the source buffer.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_MERGE)(
    CHIMETAHANDLE hDstMetaHandle,
    CHIMETAHANDLE hSrcMetaHandle,
    BOOL          disjoint);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_COPY @endcond
///
/// @brief Copies the source metadata with the destination metadata.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[out] hDstMetaHandle  Handle of the destination metadata buffer.
/// @param[in]  hSrcMetaHandle  Handle of the source metadata buffer.
/// @param[in]  disjoint        Indicates whether the copy is disjointed.
///
/// @detdesc
/// Tags from the source buffer are allocated and copied to the destination metadata buffer.
/// @par
/// If the disjoint flag is set, only the tags that are not in the destination buffer are copied. Otherwise, for overlapping
/// tags, entries in hDstMetaHandle are overwritten with entries from hSrcMetaHandle.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_COPY)(
    CHIMETAHANDLE hDstMetaHandle,
    CHIMETAHANDLE hSrcMetaHandle,
    BOOL          disjoint);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_MERGE_MULTICAMERA_METADATA @endcond
///
/// @brief Merges multi-camera source metadata to the destination metadata.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[out] hDstMetaHandle      Handle of the destination metadata buffer.
/// @param[in]  srcMetaHandleCount  Maximum number of handles in the phSrcMetaHandles array.
/// @param[in]  phSrcMetaHandles    Pointer to the array of source handles.
/// @param[in]  pCameraIdArray      Array of camera IDs associated with each metahandle.
/// @param[in]  primaryCameraId     Unique ID of the primary camera.
///
/// @detdesc
/// Tags from the source buffers are not deep copied to the destination metadata buffer. After the successful merge operation,
/// the destination buffer has tags that refer to the source buffer.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_MERGE_MULTICAMERA_METADATA)(
    CHIMETAHANDLE  hDstMetaHandle,
    UINT32         srcMetaHandleCount,
    CHIMETAHANDLE* phSrcMetaHandles,
    UINT32*        pCameraIdArray,
    UINT32         primaryCameraId);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_CAPACITY @endcond
///
/// @brief Returns the size (in bytes) of the storage space currently allocated for the metadata buffer.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in]  hMetaHandle  Handle of the metadata.
/// @param[out] pCapacity    Pointer to the size of the metadata handle.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFN_CMB_CAPACITY)(
    CHIMETAHANDLE hMetaHandle,
    UINT32*       pCapacity);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_TAG_COUNT @endcond
///
/// @brief Returns the number of tags inside the metadata buffer.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in]  hMetaHandle  Handle of the metadata.
/// @param[out] pCount       Pointer to the number of tags in the buffer.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_TAG_COUNT)(
    CHIMETAHANDLE hMetaHandle,
    UINT32*       pCount);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_PRINT @endcond
///
/// @brief Prints the metadata information into the logcat or standard output.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in]  hMetaHandle  Handle of the metadata.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_PRINT)(
    CHIMETAHANDLE hMetaHandle);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_PRINT_TAGDATA @endcond
///
/// @brief Prints the data of a specific metadata into the logcat/standard output.
///
/// @param[in] hMetaHandle     Handle to the metadata.
/// @param[in] tagID           Unique identifier for the tag.
/// @param[in] pLogIdentifier  Pointer to the string that contains identifiers like the feature or pipeline name, frame number,
///                            and so on.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_PRINT_TAGDATA)(
    CHIMETAHANDLE hMetaHandle,
    UINT32        tagID,
    const CHAR*   pLogIdentifier);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_DUMP_CLIENT_INFO @endcond
///
/// @brief Function to dump the metadata information and its registered clients information
///
/// @param[in] hMetaHandle  Handle of the metadata.
///
/// @return CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_DUMP_CLIENT_INFO)(
    CHIMETAHANDLE hMetaHandle);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_DUMP @endcond
///
/// @brief Dumps the metadata information into a text file.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in]  hMetaHandle  Handle of the metadata.
/// @param[in]  pFilename    Pointer to the filename.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_DUMP)(
    CHIMETAHANDLE hMetaHandle,
    const CHAR*   pFilename);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_BINARYDUMP @endcond
///
/// @brief Performs a binary dump of the metadata information into a specified file.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in] hMetaHandle  Handle of the metadata.
/// @param[in] pFilename    Pointer to the file name.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_BINARYDUMP)(
    CHIMETAHANDLE hMetaHandle,
    const CHAR*   pFilename);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_MAPCHROMATIXMETADATA @endcond
///
/// @brief Maps the Chromatix metadata buffer.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in] hMetaHandle  Handle to the metadata.
/// @param[in] isReverse    Indicates whether the operation maps from internal to external metadata (FALSE) or from external
///                         to internal metadata (TRUE).
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID(*PFN_CMB_MAPCHROMATIXMETADATA)(
    CHIMETAHANDLE hMetaHandle,
    BOOL          isReverse);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  CMB Buffer Management Operations
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_ADD_REFERENCE @endcond
///
/// @brief Adds a reference to the metabuffer.
///
/// @datatypes
/// #CHIMETAHANDLE \n
/// #CHIMETADATACLIENTID
///
/// @param[in]  hMetaHandle  Handle of the metadata.
/// @param[in]  clientID     Unique ID of the client.
/// @param[out] pRefCount    Pointer to the current reference count after it is incremented.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_ADD_REFERENCE)(
    CHIMETAHANDLE       hMetaHandle,
    CHIMETADATACLIENTID clientID,
    UINT32*             pRefCount);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_RELEASE_REFERENCE @endcond
///
/// @brief Releases a reference from the metabuffer.
///
/// @datatypes
/// #CHIMETAHANDLE \n
/// #CHIMETADATACLIENTID
///
/// @param[in]  hMetaHandle  Handle of the metadata.
/// @param[in]  clientID     Unique ID of the client.
/// @param[out] pRefCount    Pointer to the current reference count after it is decremented.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_RELEASE_REFERENCE)(
    CHIMETAHANDLE       hMetaHandle,
    CHIMETADATACLIENTID clientID,
    UINT32*             pRefCount);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_RELEASE_ALL_REFERENCES @endcond
///
/// @brief Releases all references from the metabuffer.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in] hMetaHandle            Handle of the metadata.
/// @param[in] bCHIAndCAMXReferences  Indicates whether to remove only the CHI references (FALSE) or both CamX and CHI
///                                   references (TRUE). Set this flag to TRUE only for flush or teardown cases.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_RELEASE_ALL_REFERENCES)(
    CHIMETAHANDLE hMetaHandle,
    BOOL          bCHIAndCAMXReferences);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_REFERENCE_COUNT @endcond
///
/// @brief Gets the current reference count of the metabuffer.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in]  hMetaHandle  Handle of the metadata.
/// @param[out] pRefCount    Pointer to the current reference count.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_REFERENCE_COUNT)(
    CHIMETAHANDLE  hMetaHandle,
    UINT32*        pRefCount);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_CAN_BE_RELEASED @endcond
///
/// @brief Returns if the handle can be safely destroyed
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in]  hMetaHandle     Handle of the metadata.
/// @param[out] pCanBeReleased  Reuturns if the handle can be destroyed
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_CAN_BE_RELEASED)(
    CHIMETAHANDLE  hMetaHandle,
    BOOL*          pCanBeReleased);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_HAS_MERGE_REFERENCES @endcond
///
/// @brief Returns if the handle has merge references
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in]  hMetaHandle           Handle of the metadata.
/// @param[out] pHasMergeReferences   Reuturns if the handle has merge references
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_HAS_MERGE_REFERENCES)(
    CHIMETAHANDLE  hMetaHandle,
    BOOL*          pHasMergeReferences);

#ifndef DOXYGEN_SHOULD_SKIP_THIS
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// CMB Iterator Operations
///
/// Example:
///     CHIMETADATAITERATOR    hIterator;
///     CDKResult result = metadataOps.pIteratorCreate(metadataHandle, &hIterator);
///     if (CDKResultSuccess == result)
///     {
///         result = metadataOps.pIteratorBegin(hIterator);
///         while (CDKResultSuccess == result)
///         {
///             CHIMETADATAENTRY entry;
///             metadataOps.pIteratorGetEntry(hIterator, &entry);
///             // entry will be updated with the tag information
///             result = metadataOps.pIteratorNext(hIterator);
///         }
///     }
///     // To reuse the iterator
///     result = metadataOps.pIteratorBegin(hIterator);
///     // After all the iterations
///     result = metadataOps.pIteratorDestroy(hIterator);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_ITERATOR_CREATE @endcond
///
/// @brief Creates an iterator for the current metadata buffer.
///
/// @datatypes
/// #CHIMETAHANDLE \n
/// #CHIMETADATAITERATOR
///
/// @param[in]  hMetaHandle  Handle of the metadata.
/// @param[out] pIterator    Pointer to the iterator handle.
///
/// @detdesc
/// Use #PFN_CMB_ITERATOR_BEGIN and #PFN_CMB_ITERATOR_NEXT to iterate through all the tags.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFN_CMB_ITERATOR_CREATE)(
    CHIMETAHANDLE           hMetaHandle,
    CHIMETADATAITERATOR*    pIterator);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_ITERATOR_DESTROY @endcond
///
/// @brief Destroys the iterator object.
///
/// @datatypes
/// #CHIMETADATAITERATOR
///
/// @param[in] hIterator  Iterator handle.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_ITERATOR_DESTROY)(
    CHIMETADATAITERATOR hIterator);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_ITERATOR_BEGIN @endcond
///
/// @brief Resets the metadata iterator to the first element.
///
/// @datatypes
/// #CHIMETADATAITERATOR
///
/// @param[in] hIterator  Iterator handle.
///
/// @return #CDKResultSuccess. Otherwise:
///          - #CDKResultENoMore -- There are no elements in the metadata.
///          - Another error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_ITERATOR_BEGIN)(
    CHIMETADATAITERATOR hIterator);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_ITERATOR_NEXT @endcond
///
/// @brief Resets the metadata iterator to the next element.
///
/// @datatypes
/// #CHIMETADATAITERATOR
///
/// @param[in] hIterator  Iterator handle.
///
/// @return #CDKResultSuccess. Otherwise:
///          - #CDKResultENoMore -- There are no elements in the metadata.
///          - Another error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_ITERATOR_NEXT)(
    CHIMETADATAITERATOR hIterator);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_ITERATOR_GETENTRY @endcond
///
/// @brief Gets the entry that corresponds to the current position of the iterator.
///
/// @datatypes
/// #CHIMETADATAITERATOR \n
/// #CHIMETADATAENTRY
///
/// @param[in]  hIterator  Iterator handle.
/// @param[out] pEntry     Pointer to the memory the caller is to allocate. When allocation is successful, the the callee fills
///                        the fields in #CHIMETADATAENTRY.
///
/// @return #CDKResultSuccess. Otherwise:
/// - #CDKResultEInvalidArg -- The iterator position is invalid or the iterator is NULL.
/// - Another error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFN_CMB_ITERATOR_GETENTRY)(
    CHIMETADATAITERATOR hIterator,
    CHIMETADATAENTRY*   pEntry);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  CMB Global Metadata Information Query Operations
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_GET_METADATA_ENTRY_COUNT @endcond
///
/// @brief Gets the count of all metadata tags that are visible to the CHI client.
///
/// @param[out] pMetadataCount  Pointer to the number of available metadata tags.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_GET_METADATA_ENTRY_COUNT)(
    UINT32* pMetadataCount);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_GET_METADATA_TABLE @endcond
///
/// @brief Gets the table of metadata entries. The table contains all the necessary information that pertains to the visible
///        metadata tags.
///
/// @datatypes
/// #CHIMETADATAENTRY
///
/// @param[out] pMetadataEntryTable  Pointer to the list of all entries.
///
/// @detdesc
/// The number of entries must be obtained by calling PFN_CMB_GET_METADATA_ENTRY_COUNT() before calling this
/// %PFN_CMB_GET_METADATA_TABLE() function.
/// @par
/// The table of sizeof(CHIMETADATAENTRY) * metadataCount must be allocated.
/// @par
/// If the function is not associated with a specific metadata buffer, the callee sets pTagData in the entry to NULL.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_GET_METADATA_TABLE)(
    CHIMETADATAENTRY* pMetadataEntryTable);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  CMB Default Settings
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_GET_DEFAULT_ANDROIDMETADATA @endcond
///
/// @brief Creates an Android metadata buffer (camera_metadata_t) with the default settings for the specified camera.
///
/// @param[in]  cameraId       Unique ID of the camera.
/// @param[out] ppAndroidMeta  Pointer to the address of the pointer to the Android camera metadata. This value must not be
///                            NULL.
///
/// @return
/// - #CDKResultSuccess if the ppAndroidMeta parameter contains a valid camera_metadata_t packet.
/// - Otherwise, an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_GET_DEFAULT_ANDROIDMETADATA)(
    UINT32          cameraId,
    const VOID**    ppAndroidMeta);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_GET_DEFAULT_METADATA @endcond
///
/// @brief Creates a metadata buffer with the default settings for the specified camera.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in]  cameraId      Unique ID of the camera.
/// @param[out] phMetaBuffer  Pointer to the CHI metadata handle. This parameter must not be NULL.
///
/// @return
/// - #CDKResultSuccess if the phMetaBuffer parameter contains the valid handle.
/// - Otherwise, an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_GET_DEFAULT_METADATA)(
    UINT32          cameraId,
    CHIMETAHANDLE*  phMetaBuffer);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_FILTER @endcond
///
/// @brief Filters the tags in the metadata buffer based on visibility parameters (frameworkTagsOnly, filterProperties,
///        pFilterTagArray, and so on) and generates Android framework metadata.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in]     hMetaHandle        Handle of the metadata.
/// @param[in,out] pAndroidMeta       Pointer to the Android camera metadata.
/// @param[in]     frameworkTagsOnly  Indicates whether only the framework tags must be present in the Android metadata.
/// @param[in]     filterProperties   Indicates whether to remove (filter out) CamX property tags.
/// @param[in]     filterTagCount     Maximum number of tags in the pFilterTagArray array.
/// @param[in]     pFilterTagArray    Pointer to the list of camera metadata tags and vendor tags that must be removed from
///                                   the framework metadata output, pAndroidMeta.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFN_CMB_FILTER)(
    CHIMETAHANDLE hMetaHandle,
    VOID*         pAndroidMeta,
    BOOL          frameworkTagsOnly,
    BOOL          filterProperties,
    UINT32        filterTagCount,
    UINT32*       pFilterTagArray);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_CMB_GET_PRIVATE_DATA @endcond
///
/// @brief Retrieves the private data associated with a metadata handle.
///
/// @datatypes
/// #CHIMETAHANDLE
///
/// @param[in]  hMetaHandle    Handle of the metadata.
/// @param[out] ppPrivateData  Pointer to the private data.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFN_CMB_GET_PRIVATE_DATA)(
    CHIMETAHANDLE       hMetaHandle,
    CHIMETAPRIVATEDATA* ppPrivateData);

/// @brief Contains function pointers for CHI metadata buffer (CMB) operations.
typedef struct /** @cond */ ChiMetadataOps /** @endcond */
{
    // Basic Metadata Operations
    PFN_CMB_CREATE                      pCreate;                    ///< Create a metadata buffer.
    PFN_CMB_CREATE_WITH_TAGARRAY        pCreateWithTagArray;        ///< Create a metadata buffer with a tag array.
    PFN_CMB_CREATE_WITH_ANDROIDMETADATA pCreateWithAndroidMetadata; ///< Create a metadata buffer with Android metadata.
    PFN_CMB_DESTROY                     pDestroy;                   ///< Destroy a metadata buffer.
    PFN_CMB_GET_TAG                     pGetTag;                    ///< Get a tag from a metadata buffer.
    PFN_CMB_GET_TAG_ENTRY               pGetTagEntry;               ///< Get a tag entry from a metadata buffer.
    PFN_CMB_GET_VENDORTAG               pGetVendorTag;              ///< Get a vendor tag from a metadata buffer.
    PFN_CMB_GET_VENDORTAG_ENTRY         pGetVendorTagEntry;         ///< Get a vendor tag entry from a metadata buffer.
    PFN_CMB_SET_TAG                     pSetTag;                    ///< Get a tag on a metadata buffer.
    PFN_CMB_SET_VENDORTAG               pSetVendorTag;              ///< Get a vendor tag on a metadata buffer.
    PFN_CMB_SET_ANDROIDMETADATA         pSetAndroidMetadata;        ///< Get an Android tag on a metadata buffer.
    PFN_CMB_DELETE_TAG                  pDeleteTag;                 ///< Delete a tag from a metadata buffer.
    PFN_CMB_INVALIDATE                  pInvalidate;                ///< Invalidate all tags in a metadata buffer.
    PFN_CMB_MERGE                       pMerge;                     ///< Merge one metadata buffer with another metadata
                                                                    ///  buffer.
    PFN_CMB_COPY                        pCopy;                      ///< Copy metadata from a source to a destination.
    PFN_CMB_CLONE                       pClone;                     ///< Clone the metadata.
    PFN_CMB_CAPACITY                    pCapacity;                  ///< Get the capacity of the metadata.
    PFN_CMB_TAG_COUNT                   pCount;                     ///< Get the number of tags.
    PFN_CMB_PRINT                       pPrint;                     ///< Print metadata information.
    PFN_CMB_PRINT_TAGDATA               pPrintTagData;              ///< Print the metadata of a specific tag into the
                                                                    ///  logcat/standard output.
    PFN_CMB_DUMP                        pDump;                      ///< Dump metadata information to a file.
    PFN_CMB_BINARYDUMP                  pBinaryDump;                ///< Perform a binary dump of the metadata buffer.

    // Supplementary Metadata Buffer Management Operations
    PFN_CMB_ADD_REFERENCE               pAddReference;              ///< Add a reference to a metadata buffer.
    PFN_CMB_RELEASE_REFERENCE           pReleaseReference;          ///< Release a reference from a metadata buffer.
    PFN_CMB_REFERENCE_COUNT             pReferenceCount;            ///< Get a reference count of the metadata buffer.

    // Metadata Information Query Operations
    PFN_CMB_GET_METADATA_TABLE          pGetMetadataTable;          ///< Get the information of the available metadata
                                                                    ///  entries.
    PFN_CMB_GET_METADATA_ENTRY_COUNT    pGetMetadataEntryCount;     ///< Get the number of all available metadata entries.

    // Iterator Operations
    PFN_CMB_ITERATOR_CREATE             pIteratorCreate;            ///< Create an iterator object for tag traversal of a
                                                                    ///  metadata buffer.
    PFN_CMB_ITERATOR_DESTROY            pIteratorDestroy;           ///< Destroy an iterator object.
    PFN_CMB_ITERATOR_BEGIN              pIteratorBegin;             ///< Initialize an iterator object to the first entry.
    PFN_CMB_ITERATOR_NEXT               pIteratorNext;              ///< Move an iterator object to the next entry.
    PFN_CMB_ITERATOR_GETENTRY           pIteratorGetEntry;          ///< Get the metadata entry that corresponds to the
                                                                    ///  current iterator position.

    // Functions for creating metadata filled with default settings
    PFN_CMB_GET_DEFAULT_ANDROIDMETADATA pGetDefaultAndroidMeta;     ///< Get the default settings of camera_metadata_t and
                                                                    ///  create an Android metadata buffer.
    PFN_CMB_GET_DEFAULT_METADATA        pGetDefaultMetadata;        ///< Get the default settings of camera_metadata_t and
                                                                    ///  create a metadata buffer with default settings.
    PFN_CMB_FILTER                      pFilter;                    ///< Function pointer to filter metadata based on tag
                                                                    ///  visibility.
    PFN_CMB_GET_PRIVATE_DATA            pGetPrivateData;            ///< Get the private data associated with the metadata.
    PFN_CMB_RELEASE_ALL_REFERENCES      pReleaseAllReferences;      ///< Release all references of a metadata buffer.
    PFN_CMB_MERGE_MULTICAMERA_METADATA  pMergeMultiCameraMeta;      ///< Merge multi-camera metadata.
    PFN_CMB_GET_TAG_BY_CAMERAID         pGetTagByCameraId;          ///< Get a tag from the metadata buffer that belongs to a
                                                                    ///  specified camera ID.
    PFN_CMB_IS_MULTICAMERA_METADATA     pIsMutiCameraMetadata;      ///< Check whether a handle belongs to multi-camera
                                                                    ///  metadata.
    PFN_CMB_MAPCHROMATIXMETADATA        pMapChromatixMetadata;      ///< Function pointer to map a Chromatix metadata buffer.
    PFN_CMB_DUMP_CLIENT_INFO            pDumpClientInfo;            ///< Function pointer to dump metadata information and its'
                                                                    ///  registered clients information.
    PFN_CMB_CAN_BE_RELEASED             pCanBeReleased;             ///< Function pointer to check if the metadata can be safely
                                                                    ///  destroyed

    PFN_CMB_HAS_MERGE_REFERENCES        pHasMergeReferences;        ///< Function pointer to check if the metadata has merge references

    VOID*                               reserved[4];                ///< Pointer to the padding reserved for future use. Must
                                                                    ///  be initialized to NULL.
                                                                    ///  @newpagetable
} CHIMETADATAOPS;


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNGETMETADATAOPS @endcond
///
/// @brief Gets the tag-related metadata function pointers.
///
/// @datatypes
/// #CHIMETADATAOPS
///
/// @param[in,out] pOps  Pointer to the structure that contains the pointers.
///
/// @detdesc
///  Given a valid pointer, this function associates it with the available metadata operations such as create, destroy, get,
/// set, and so on.
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFNGETMETADATAOPS)(
    CHIMETADATAOPS* pOps);

/** @} */ /* end_addtogroup chi_common_cmb */


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond CHI Resource Manager (CRM) @endcond
///
/// @addtogroup chi_common_crm
///
/// The CHI Resource Manager (CRM) contains the resource management-related operations required for communication between CAMX
/// and CHI.
///
/// CRM operations are classified as follows:
/// - Getting the total resources budget
/// - Reserving and unreserving APIs
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/** @addtogroup chi_common_crm
@{ */

/// @brief Specialized Resource Manager flags.
typedef enum class /** @cond */ ChiResourceManagerHint /** @endcond */
{
    // Camera related flags
    RDICamera         = 1 << 0,   ///< Indicates that the physical camera is RDI only.
    MultiCamera       = 1 << 1,   ///< Indicates that the camera is a logical camera.
    PDLibSensorType3  = 1 << 2,   ///< Sensor mode PDAF type is sparse PD Type 3.

    // Stream related flags
    QCFAStream              = 1 << 3,
    DepthStream             = 1 << 4,
    FDStream                = 1 << 5,
    PreviewStream           = 1 << 6,
    SHDRStream              = 1 << 7,
} CHI_RESOURCE_MANAGER_HINT;

/// @brief Describes the budget information for a specific system resource.
typedef struct /** @cond */ ChiResourceBudgetInfo /** @endcond */
{
    UINT32 resourceId;           ///< Unique identifier given to a resource by the Resource Manager.
    UINT32 deviceId;             ///< Unique identifier given to sub-devices within a certain resource type.
    UINT32 budget;               ///< Budget associated with the combination of device and resource.
    UINT32 singleInstanceBudget; ///< Single instance budget associated with the combination of device and resource.
} CHI_RESOURCE_BUDGET_INFO;

/// @brief Client priorities, where high priority implies exclusive access to resources.
enum ChiClientPriority
{
    PRIORITY_LOW,
    PRIORITY_NORMAL,
    PRIORITY_HIGH,
};

/// @brief Contains remosaic information.
typedef struct /** @cond */ ChiResourceCapabilities /** @endcond */
{
    BOOL         isRemosaicSupported;        ///< Indicates whether remosaic capabilities are supported.
                                             ///
                                             ///  @valuesbul
                                             ///  - 0 -- FALSE
                                             ///  - 1 -- TRUE @tablebulletend

    BOOL         isDynamicSwitchSupported;   ///< Indicates whether the Dynamic mode switch is supported.
                                             ///
                                             ///  @valuesbul
                                             ///  - 0 -- FALSE
                                             ///  - 1 -- TRUE @tablebulletend

    ChiDimension MaxDynamicSwitchResolution; ///< Total resolutions supported by the IFE for dynamic mode switching.
} CHI_RESOURCE_CAPABILITIES;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_GET_SYSTEM_RESOURCES @endcond
///
/// @brief Gets the resources available on this system.
///
/// @datatypes
/// #CHI_RESOURCE_BUDGET_INFO
///
/// @param[out] pOutResourceBudgetInfo  Double pointer to a buffer to be filled with resource information.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFN_GET_SYSTEM_RESOURCES)(
    CHI_RESOURCE_BUDGET_INFO** ppOutResourceBudgetInfo,
    UINT32*                    pOutNumResourceBudgetInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_GET_CAMERA_SYSTEM_RESOURCES @endcond
///
/// @brief Gets the system resources that are used by a specified camera.
///
/// @datatypes
/// #CHI_RESOURCE_BUDGET_INFO
///
/// @param[in]  camId                      Identifier of the camera to be reserved.
/// @param[in]  flags                      CHI Resource Manager flags.
/// @param[out] pOutResourceBudgetInfo     Double pointer to a buffer to be filled with data resources.
/// @param[out] pOutNumResourceBudgetInfo  Pointer to the number of entries in the buffer.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFN_GET_CAMERA_SYSTEM_RESOURCES)(
    UINT32                      camId,
    UINT32                      flags,
    CHI_RESOURCE_BUDGET_INFO**  ppOutResourceBudgetInfo,
    UINT32*                     pOutNumResourceBudgetInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_RELEASE_RESOURCE @endcond
///
/// @brief Asynchronous notification callback function that releases resources.
///
/// @param[in] reservationId     Identifier of the reservation that CamX is to preempt.
/// @param[in] pCallbackContext  Pointer to the context for the callback.
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID(*PFN_RELEASE_RESOURCE) (
    UINT32 reservationId,
    VOID*  pcallbackContext);

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_GET_CAMERA_HW_FUNCTIONALITY @endcond
///
/// @brief Gets the camera hw functional state.
///
/// @return None
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID* (*PFN_GET_CAMERA_HW_FUNCTIONALITY)();

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_RESERVE_RESOURCE @endcond
///
/// @brief Reserves a resource given a reservation ID and priority.
///
/// @datatypes
/// #ChiClientPriority \n
/// #PFN_RELEASE_RESOURCE \n
/// #CHI_RESOURCE_BUDGET_INFO
///
/// @param[in] logicalCamId      Identifier of the logical camera to reserve.
/// @param[in] priority          Priority of the reservation.
/// @param[in] pfnRelease        Callback function.
/// @param[in] pCallbackContext  Context of the callback.
/// @param[in] reservation       System resource and amount to reserve.
///
/// @return None. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFN_RESERVE_RESOURCE)(
    UINT32                      logicalCamId,
    ChiClientPriority           priority,
    PFN_RELEASE_RESOURCE        pfnRelease,
    VOID*                       pCallbackContext,
    CHI_RESOURCE_BUDGET_INFO    reservation);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_ESTIMATE_RESOURCE_INSTANCE_COUNT @endcond
///
/// @brief Calculates the resource cost based on the stream configuration.
///
/// @param[in]  streamCount       Number of streams to be checked.
/// @param[in]  pStreamArr        Pointer to the array of streams to be checked.
/// @param[in]  resourcesCount    Calculate the resource cost based on the stream configuration.
/// @param[in]  pResourcesArr     Pointer to the list of resources.
/// @param[out] pOutInstanceCost  Pointer to the array of resource instances that are required.
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFN_ESTIMATE_RESOURCE_INSTANCE_COUNT)(
    UINT32                  streamCount,
    const CAMERASTREAMLITE* pStreamArr,
    UINT32                  resourcesCount,
    const CHIRESOURCETYPE*  pResourcesArr,
    UINT32*                 pOutInstanceCost);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_UNRESERVE_RESOURCE @endcond
///
/// @brief Undo reservations for all resources given a reservation ID.
///
/// @param[in] logicalCamId  Identifier of the logical camera to unreserve.
///
/// @return None. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFN_UNRESERVE_RESOURCE)(
    UINT32 logicalCamId);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_GET_RESOURCE_CAPABILITIES @endcond
///
/// @brief  Gets resource capabilities.
///
/// @datatypes
/// #ResourceID
///
/// @param[in] resourceId  Identifier of the resource.
///
/// @return Resource capabilities.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CHI_RESOURCE_CAPABILITIES (*PFN_GET_RESOURCE_CAPABILITIES)(
    ResourceID resourceId);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_UNRESERVE_SYSTEM_RESOURCE @endcond
///
/// @brief Undo the reservation of a system resource.
///
/// @param[in] logicalCamId  Identifier for the logical camera.
/// @param[in] reservation   System resource and amount.
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFN_UNRESERVE_SYSTEM_RESOURCE)(
    UINT32                      logicalCamId,
    CHI_RESOURCE_BUDGET_INFO    reservation);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_RELEASE_INACTIVE_CAMERAS @endcond
///
/// @brief Determine the inactive cameras in a current use case and release them.
///
/// @param[in] cameraCount       Total number of all cameras.
/// @param[in] pCameraStateArr   All camera state list.
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFN_RELEASE_INACTIVE_CAMERAS)(
    UINT32                 cameraCount,
    CameraState*           pCameraStateArr);

/// @brief Contains function pointers to CHI Resource Manager Operations.
typedef struct /** @cond */ ChiResourceManagerOps /** @endcond */
{
    PFN_GET_SYSTEM_RESOURCES             pGetSystemResources;             ///< Get system resources.
    PFN_GET_CAMERA_SYSTEM_RESOURCES      pGetCameraSystemResources;       ///< Get system resources for a camera.
    PFN_GET_CAMERA_HW_FUNCTIONALITY      pGetCameraHwFunctionality;       ///< Get camera hw functionality
    PFN_RESERVE_RESOURCE                 pReserveResource;                ///< Reserve a resource for a camera.
    PFN_UNRESERVE_RESOURCE               pUnreserveResource;              ///< Undo a reservation.
    PFN_GET_RESOURCE_CAPABILITIES        pGetResourceCapabilities;        ///< Get resource capabilities.
    PFN_UNRESERVE_SYSTEM_RESOURCE        pUnreserveSystemResource;        ///< Undo the reservation of a system resource.
    PFN_GET_SYSTEM_RESOURCES             pGetAvailableSystemResources;    ///< Get the available system resources.
    PFN_RELEASE_INACTIVE_CAMERAS         pReleaseInactiveCameras;         ///< Release inactive cameras.

    PFN_ESTIMATE_RESOURCE_INSTANCE_COUNT pEstimateResourceInstanceCount;  ///< Calculate the resource cost based on the stream
                                                                          ///< configuration.
} CHIRESOURCEMANAGEROPS;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNGETRESOURCEMANAGEROPS @endcond
///
/// @brief Gets the resource manager related function pointers
///
/// @datatypes
/// #CHIRESOURCEMANAGEROPS
///
/// @param[in,out] pOps  Pointer to the structure that contains the pointers.
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFNGETRESOURCEMANAGEROPS)(
    CHIRESOURCEMANAGEROPS* pOps);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_SUBSCRIBE_CLIENT @endcond
///
/// @brief Called by client to subscribe HMS service.
///
/// @param[in] pClient       Pointer of client object.
/// @param[in] pClientName   Name of the client.
///
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFN_SUBSCRIBE_CLIENT)(
    CHIHEALTHMONITORCLIENTHANDLE  pClient,
    const CHAR*                   pClientName);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_UNSUBSCRIBE_CLIENT @endcond
///
/// @brief Called by client to unsubscribe HMS service.
///
/// @param[in] pClient       Pointer of client object.
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFN_UNSUBSCRIBE_CLIENT)(
    CHIHEALTHMONITORCLIENTHANDLE  pClient);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_SET_HMSEVENTCB @endcond
///
/// @brief Sets the system event callback to HMS
///
/// @param[in] hChiContext    Handle of the CHI context.
/// @param[in] hmsEventCb     Pointer to function for HMS event callback.
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFN_SET_HMSEVENTCB)(
    PFNHMSEVENTCB hmsEventCb);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_PAUSE_MONITOR_JOB @endcond
///
/// @brief Called to pause monitor current job.
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFN_PAUSE_MONITOR_JOB)();

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_RESUME_MONITOR_JOB @endcond
///
/// @brief Called to resume monitor current job.
///
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFN_RESUME_MONITOR_JOB)();

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ChiHealthMonitorOps
///
/// @brief  This structure contains functions for CHI Health Monitor Service
///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct ChiHealthMonitorOps
{
    PFN_SUBSCRIBE_CLIENT          pSubscribeClient;           ///< Function pointer to subscribe for HMS service.
    PFN_UNSUBSCRIBE_CLIENT        pUnSubscribeClient;         ///< Function poiner to unsubscribe for HMS service.
    PFN_SET_HMSEVENTCB            pSetHMSEventCb;             ///< Function pointer to set the HMS event callback.
    PFN_PAUSE_MONITOR_JOB         pPauseMonitorJob;           ///< Function poiner to pause monitor the job by HMS.
    PFN_RESUME_MONITOR_JOB        pResumeMonitorJob;          ///< Function poiner to resume monitor the job by HMS.
} CHIHEALTHMONITOROPS;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNGETHEALTMONITOROPS @endcond
///
/// @brief  Gets the Health manager  related function pointers
///
/// @datatypes
/// #CHIHEALTHMONITOROPS
///
/// @param[in,out] pOps  Pointer to the structure that contains the pointers.
///
/// @return None
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFNGETHEALTMONITOROPS)(
    CHIHEALTHMONITOROPS* pOps);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_ACCEPT_JOB @endcond
///
/// @brief Called by client to add HMS job to monitor by HMS.
///
/// @param[in] pJobName          Job name.
/// @param[in] cameraId          Logical camera Id for which this job is associated
/// @param[in] maxExecTime       Max execution time for thread.
///
/// @return HMS job handle
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CHIHMSJOBHANDLE (*PFN_ACCEPT_JOB)(
    const CHAR* pJobName,
    UINT32      cameraId,
    UINT64      maxExecTime);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFN_REMOVE_JOB @endcond
///
/// @brief Called by client to remove HMS job from monitoring by HMS.
///
/// @param[in] pRuntimeJob       Pointer of HMS run time job of HMSjob client
///
/// @return None.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFN_REMOVE_JOB)(
    CHIHMSJOBHANDLE  pRuntimeJob);

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ChiHMSJobClientOps
///
/// @brief  This structure contains functions for CHI HMSJob Client
///
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct ChiHMSJobClientOps
{
    PFN_ACCEPT_JOB  pAcceptJob; ///< Function ptr to add hms job to monitor by HMS
    PFN_REMOVE_JOB  pRemoveJob; ///< Function ptr to remove hms job from monitoring
} CHIHMSJOBCLIENTOPS;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond CHIHMSJOBCLIENTOPS @endcond
///
/// @brief  Gets the HMSJob Client related function pointers
///
/// @datatypes
/// #CHIHMSJOBCLIENTOPS
///
/// @param[in,out] pOps  Pointer to the structure that contains the pointers.
///
/// @return None
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFNCHIHMSJOBCLIENTOPS)(
    CHIHMSJOBCLIENTOPS* pOps);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNBUFFERMANAGERCREATE @endcond
///
/// @brief Creates a CHI buffer manager.
///
/// @param[in] pBufferManagerName  Pointer to the string of the buffer manager's name.
/// @param[in] pCreateData         Pointer to the data structure that contains parameters for creating a buffer manager.
///
/// @return Buffer manager handle.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CHIBUFFERMANAGERHANDLE (*PFNBUFFERMANAGERCREATE)(
    const CHAR*                 pBufferManagerName,
    CHIBufferManagerCreateData* pCreateData);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNBUFFERMANAGERDESTROY @endcond
///
/// @brief Given a buffer manager handle, destroys a CHI buffer manager that was created with PFNBUFFERMANAGERCREATE().
///
/// @param[in] hBufferManager  Handle of the buffer manager.
///
/// @return None. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFNBUFFERMANAGERDESTROY)(
    CHIBUFFERMANAGERHANDLE hBufferManager);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNBUFFERMANAGERADDREFERENCE @endcond
///
/// @brief Given a buffer manager handle, adds a reference to an image buffer in the buffer manager.
///
/// @param[in] hBufferManager  Handle of the buffer manager.
/// @param[in] hImageBuffer    Handle of the image buffer.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNBUFFERMANAGERADDREFERENCE)(
    CHIBUFFERMANAGERHANDLE hBufferManager,
    CHIBUFFERHANDLE        hImageBuffer);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNBUFFERMANAGERGETIMAGEBUFFER @endcond
///
/// @brief Given a buffer manager handle, returns a handle to an image buffer handle from the buffer manager.
///
/// @param[in] hBufferManager  Handle of the buffer manager.
///
/// @return Image buffer handle.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CHIBUFFERHANDLE(*PFNBUFFERMANAGERGETIMAGEBUFFER)(
    CHIBUFFERMANAGERHANDLE hBufferManager);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNBUFFERMANAGERRELEASEREFERENCE @endcond
///
/// @brief Given a buffer manager handle, releases a reference to an image buffer.
///
/// @param[in] hBufferManager  Handle of the buffer manager.
/// @param[in] hImageBuffer    Handle of the image buffer.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNBUFFERMANAGERRELEASEREFERENCE)(
    CHIBUFFERMANAGERHANDLE hBufferManager,
    CHIBUFFERHANDLE        hImageBuffer);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNBUFFERMANAGERGETREFERENCE @endcond
///
/// @brief Given an image buffer handle, gets the current reference count of this image buffer
///
/// @param[in] hImageBuffer  Handle of the image buffer.
///
/// @return Reference count.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef UINT (*PFNBUFFERMANAGERGETREFERENCE)(
    CHIBUFFERHANDLE hImageBuffer);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNBUFFERMANAGERACTIVATE @endcond
///
/// @brief Activates the buffer manager.
///
/// @param[in] hBufferManager  Handle of the buffer manager.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNBUFFERMANAGERACTIVATE)(
    CHIBUFFERMANAGERHANDLE hBufferManager);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNBUFFERMANAGERDEACTIVATE @endcond
///
/// @brief Deactivates the buffer manager.
///
/// @param[in] hBufferManager  Handle of the buffer manager.
/// @param[in] isPartialFree   Indicates whether buffers are to be partially released.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNBUFFERMANAGERDEACTIVATE)(
    CHIBUFFERMANAGERHANDLE hBufferManager,
    BOOL                   isPartialFree);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNBUFFERMANAGERBINDBUFFER @endcond
///
/// @brief Binds a backing buffer to an image buffer.
///
/// @param[in] hImageBuffer  Handle of the image buffer.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNBUFFERMANAGERBINDBUFFER)(
    CHIBUFFERHANDLE hImageBuffer);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNBUFFERMANAGERGETCPUADDRESS @endcond
///
/// @brief Gets the pointer to the image buffer's CPU address.
///
/// @param[in] hImageBuffer  Handle of the image buffer.
///
/// @return Pointer to the CPU address.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef const VOID* (*PFNBUFFERMANAGERGETCPUADDRESS)(
    CHIBUFFERHANDLE hImageBuffer);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNBUFFERMANAGERGETFILEDESCRIPTOR @endcond
///
/// @brief Gets the file descriptor for the image buffer.
///
/// @param[in] hImageBuffer  Handle of the image buffer.
///
/// @return File descriptor. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef INT (*PFNBUFFERMANAGERGETFILEDESCRIPTOR)(
    CHIBUFFERHANDLE hImageBuffer);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNBUFFERMANAGERGETGRALLOCHANDLE @endcond
///
/// @brief Gets the gralloc handle of the image buffer.
///
/// @param[in] hImageBuffer  Handle of the image buffer.
///
/// @return Pointer to buffer_handle_t typecasted to VOID.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID* (*PFNBUFFERMANAGERGETGRALLOCHANDLE)(
    CHIBUFFERHANDLE hImageBuffer);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNBUFFERMANAGERCACHEOPS @endcond
///
/// @brief Cleans or invalidates the cache for all memory associated with an image buffer.
///
/// @param[in] hImageBuffer  Handle of the image buffer.
/// @param[in] invalidate    Specifies whether to invalidate the cache (TRUE or FALSE).
/// @param[in] clean         Specifies whether to clean the cache (TRUE or FALSE).
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNBUFFERMANAGERCACHEOPS)(
    CHIBUFFERHANDLE hImageBuffer,
    BOOL            invalidate,
    BOOL            clean);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNBUFFERMANAGERCPUACCESS @endcond
///
/// @brief  The implementation for PFNBUFFERMANAGERCPUACCeSS
///
/// @param  [in] hImageBuffer   Image buffer handle
/// @param  [in] endAccess      Begin/End CPU Access
/// @param  [in] readWriteMask  read/Write Mask
///
/// @return CDKResultSuccess if success or appropriate error code.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNBUFFERMANAGERCPUACCESS)(
    CHIBUFFERHANDLE hImageBuffer,
    BOOL            endAccess,
    UINT32          readWriteMask);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNBUFFERMANAGERDUMPIMAGEBUFFER @endcond
///
/// @brief  The implementation for PFNBUFFERMANAGERDUMPIMAGEBUFFER
///
/// @param  [in] hImageBuffer   Image buffer handle
/// @param  [in] pFile          file handle to write/dump the image to
/// @param  [in] bWrite         Write the Image Buffer to File Handle
///
/// @return CDKResultSuccess if success or appropriate error code.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNBUFFERMANAGERDUMPIMAGEBUFFER)(
    CHIBUFFERHANDLE            hImageBuffer,
    FILE*                      pFile,
    BOOL                       bWrite);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNBUFFERMANAGERNOTIFYINACTIVESTREAM @endcond
///
/// @brief Notifies the buffer manager of an inactive stream.
///
/// @param[in] hBufferManager  Handle to the buffer manager.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNBUFFERMANAGERNOTIFYINACTIVESTREAM)(
    CHIBUFFERMANAGERHANDLE hBufferManager);

/// @brief Contains function pointers for the CHI buffer manager.
typedef struct /** @cond */ ChiBufferManagerOps /** @endcond */
{
    PFNBUFFERMANAGERCREATE                  pCreate;               ///< Creates a CHI buffer manager.
    PFNBUFFERMANAGERDESTROY                 pDestroy;              ///< Destroys a CHI buffer manager.
    PFNBUFFERMANAGERGETIMAGEBUFFER          pGetImageBuffer;       ///< Gets an image buffer from a given CHI buffer manager.
    PFNBUFFERMANAGERADDREFERENCE            pAddReference;         ///< Adds a reference to the image buffer specified by the
                                                                   ///  ImageBufferHandle.
    PFNBUFFERMANAGERRELEASEREFERENCE        pReleaseReference;     ///< Releases a reference to the image buffer that was
                                                                   ///  specified by the ImageBufferHandle.
    PFNBUFFERMANAGERGETREFERENCE            pGetReference;         ///< Gets a reference to the image buffer.
    PFNBUFFERMANAGERACTIVATE                pActivate;             ///< Activates a CHI buffer manager.
    PFNBUFFERMANAGERDEACTIVATE              pDeactivate;           ///< Deactivates a CHI buffer manager.
    PFNBUFFERMANAGERBINDBUFFER              pBindBuffer;           ///< Binds a backing buffer to the image buffer.
    PFNBUFFERMANAGERGETCPUADDRESS           pGetCPUAddress;        ///< Retrieves the base virtual address for the image
                                                                   ///  buffer.
    PFNBUFFERMANAGERGETFILEDESCRIPTOR       pGetFileDescriptor;    ///< Gets the file descriptor for the image buffer.
    PFNBUFFERMANAGERGETGRALLOCHANDLE        pGetGrallocHandle;     ///< Gets the gralloc buffer handle for the image buffer.
    PFNBUFFERMANAGERCACHEOPS                pCacheOps;             ///< Cleans or invalidates the cache memory associated with
                                                                   ///  this CHI buffer manager.
    PFNBUFFERMANAGERCPUACCESS               pCPUAccess;            ///< Modify Image Buffer Access Patterns
    PFNBUFFERMANAGERDEACTIVATE              pStartDeactivate;      ///< Starts deactivation of a CHI buffer manager.
    PFNBUFFERMANAGERNOTIFYINACTIVESTREAM    pNotifyInactiveStream; ///< Notify the buffer manager of an inactive stream.
    PFNBUFFERMANAGERDUMPIMAGEBUFFER         pReadWriteImageBuffer; ///< Sets or Resets Buffer attributes on given hdl
    VOID*                                   reserved[3];           ///< Pointer to the padding reserved for future use. Must be
                                                                   ///  initialized to NULL.
                                                                   ///  @newpagetable
} CHIBUFFERMANAGEROPS;

/** @} */ /* end_addtogroup chi_common_crm */


/** @addtogroup chi_common_functions
@{ */

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNGETBUFFERMANAGEROPS @endcond
///
/// @brief Gets the CHI buffer manager-related function pointers.
///
/// @datatypes
/// #CHIBUFFERMANAGEROPS
///
/// @param[in] *  Pointer to the structure that contains the function pointers.
///
/// @detdesc
/// Given a valid pointer, this function associates it with the available buffer manager operations such as create, destroy,
/// add references, release reference, and so on.
///
/// @return None. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFNGETBUFFERMANAGEROPS)(CHIBUFFERMANAGEROPS*);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHIOPENCONTEXT @endcond
///
/// @brief Creates and returns a CHI context.
///
/// @return CHI context pointer.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CHIHANDLE (*PFNCHIOPENCONTEXT)();

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHICLOSECONTEXT @endcond
///
/// @brief Closes a CHI context.
///
/// @datatypes
/// #CHIHANDLE
///
/// @param[in] hChiContext  Handle of the CHI context.
///
/// @detdesc
/// This function kills any outstanding requests and free all resources claimed by this context.
/// @par
/// Clients are expected to destroy all outstanding CHI sessions and CHI pipelines before calling this function. Otherwise,
/// there is a risk of leaking resources.
///
/// @return None. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFNCHICLOSECONTEXT)(CHIHANDLE hChiContext);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHIGETNUMCAMERAS @endcond
///
/// @brief Gets the number of cameras supported by the platform. This function can be called before creating a CHI context.
///
/// @datatypes
/// #CHIHANDLE
///
/// @param[in] hChiContext  Handle of the CHI context.
///
/// @detdesc
/// Typically, this function is called during camera service initialization to determine the number of physical camera sensors
/// available on the platform.
/// @par
/// If the platform has multiple cameras combined into a single physical lane (for example, behind a bridge chip), those
/// cameras will be reported as a single physical sensor.
/// @par
/// CHI identifies all cameras by a packed, zero-based index from 0 to the value returned by this function call. For example,
/// if the platform indicates it has three cameras, they are represented within the CHI driver as follows:
///  - Camera 0 -- Sensor IMX318
///  - Camera 1 -- Sensor IMX258
///  - Camera 2 -- Sensor OV2281
///
/// @return
/// - Integer that represents the number of camera devices on the platform.
/// - 1 if hChiContext is not a valid CHI context handle. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef UINT (*PFNCHIGETNUMCAMERAS)(CHIHANDLE hChiContext);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHIGETCAMERAINFO @endcond
///
/// @brief Gets detailed information about a specified camera sensor. This function can be called before creating a CHI
/// context.
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHICAMERAINFO
///
/// @param[in]  hChiContext  Handle of the CHI context.
/// @param[in]  cameraId     Unique ID of the camera. This value must be an integer between 0 and the value returned by
///                          #PFNCHIGETNUMCAMERAS.
/// @param[out] pCameraInfo  Pointer to the camera information structure. The caller is responsible for allocating the memory
///                          for this field.
///
/// @detdesc
/// Typically, implementations are expected to call #PFNCHIGETNUMCAMERAS to determine the number of physical cameras that are
/// available on a platform. Implementations then call PFNCHIGETCAMERAINFO with every integer from 0 to the number of cameras
/// available to get information about every available sensor.
///
/// @return #CDKResultSuccess. Otherwise, #CDKResultEInvalidArg:
/// - If the handle is not a valid CHI module handle
/// - If pCameraInfo is NULL
/// - If cameraId is not in the range of [0..PFNCHIGETNUMCAMERAS()]
///
/// @dependencies
/// #PFNCHIGETNUMCAMERAS must be called to determine the number of camera sensors. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNCHIGETCAMERAINFO)(
    CHIHANDLE      hChiContext,
    UINT32         cameraId,
    CHICAMERAINFO* pCameraInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHIENUMERATESENSORMODES @endcond
///
/// @brief Gets all mode information about a specific sensor.
///
/// @param[in]  hChiContext      Handle of the CHI context.
/// @param[in]  cameraId         Unique identifier of the camera.
/// @param[in]  numSensorModes   Number of sensor modes.
/// @param[in]  pSensorModeInfo  Array of modes with numModes elements in the array filled in by the driver.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNCHIENUMERATESENSORMODES)(
    CHIHANDLE          hChiContext,
    UINT32             cameraId,
    UINT32             numSensorModes,
    CHISENSORMODEINFO* pSensorModeInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHICREATEPIPELINEDESCRIPTOR @endcond
///
/// @brief Creates a pipeline for use by an image processing session.
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHIPIPELINECREATEDESCRIPTOR \n
/// #CHIPORTBUFFERDESCRIPTOR \n
/// #CHIPIPELINEINPUTOPTIONS
///
/// @param[in]  hChiContext               Handle of the CHI context.
/// @param[in]  pPipelineName             Pointer to the pipeline name.
/// @param[in]  pDescriptor               Pointer to a descriptor that contains all the information used to define a processing
///                                       pipeline.
/// @param[in]  numOutputs                Number of outputs in the pipeline
/// @param[in]  pOutputBufferDescriptors  Pointer to the output descriptors.
/// @param[in]  numInputs                 Number of input requirements for the pipeline.
/// @param[out] pInputBufferOptions       Pointer to the input buffer options.
///                                       - For real-time pipelines, points to lists of valid sensor modes.
///                                       - For offline pipelines, points to buffer requirements for the pipeline inputs.
///                                       @tablebulletend
/// @param[out] pOutputBufferOptions      Pointer to the output buffer options to pass format option list.
/// @param[in]  pInputBufferDescriptors   Pointer to the input descriptors to pass format option list.


///
/// @detdesc
/// This function reads a pipeline descriptor, validates the pipeline contained within the descriptor, and then returns a
/// handle to the internal driver that represents the pipeline descriptor. The session must be created before this descriptor
/// creates the actual pipeline containing all the nodes. Pipelines can be shared between sessions.
/// @par
/// This function can be called at any time after the HAL device has been created. It should not be called during
/// time-sensitive portions of the code.
/// @par
/// The caller is responsible for destroying the pipeline when it has finished using it.
/// @par
/// A pipeline does not contain any binding to buffer formats or sizes. This function applies the requested output buffers, and
/// it determines the sizing requirements for the entry point of every node in the topology.
/// @par
/// A default configuration is returned, which is guaranteed to work for the given set of output buffers. If the difference in
/// size of the input and output for a given node does not exceed the maximum scaling factor for that node, the client can
/// adjust the scaling factors to achieve different results. @newpage
/// @par
/// For pipelines that use a sensor as the input, a list of valid sensor modes is returned to allow for fine tuning by a
/// client. For pipelines that use memory as the input, a list of size requirements is returned.
///
/// @return
/// - Handle to the created pipeline descriptor, or 0 if it fails.
/// - Error upon passing a NULL or invalid pDescriptor (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CHIPIPELINEDESCRIPTOR (*PFNCHICREATEPIPELINEDESCRIPTOR)(
    CHIHANDLE                          hChiContext,
    const CHAR*                        pPipelineName,
    const CHIPIPELINECREATEDESCRIPTOR* pDescriptor,
    UINT32                             numOutputs,
    CHIPORTBUFFERDESCRIPTOR*           pOutputBufferDescriptors,
    UINT32                             numInputs,
    CHIPIPELINEINPUTOPTIONS*           pInputBufferOptions,
    CHIPIPELINEOUTPUTOPTIONS*          pOutputBufferOptions,
    CHIPORTBUFFERDESCRIPTOR*           pInputBufferDescriptors);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHIDESTROYPIPELINEDESCRIPTOR @endcond
///
/// @brief Destroys a pipeline descriptor.
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHIPIPELINEDESCRIPTOR
///
/// @param[in] hChiContext          Handle of the CHI context.
/// @param[in] hPipelineDescriptor  Handle of the pipeline descriptor.
///
/// @detdesc
/// Pipelines do not maintain any state (that is the responsibility of the session). Therefore, they can be destroyed at any
/// time.
///
/// @return None.
///
/// @dependencies
/// The pipeline must have been created using #PFNCHICREATEPIPELINEDESCRIPTOR on the same CHI context that this
/// PFNCHIDESTROYPIPELINEDESCRIPTOR is being called. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFNCHIDESTROYPIPELINEDESCRIPTOR)(
    CHIHANDLE             hChiContext,
    CHIPIPELINEDESCRIPTOR hPipelineDescriptor);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHICREATESESSION @endcond
///
/// @brief Creates a camera session.
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHIPIPELINEINFO \n
/// #CHICALLBACKS \n
/// #CHISESSIONFLAGS
///
/// @param[in] hChiContext           Handle of the CHI context.
/// @param[in] numPipelines          Number of pipelines associated with this session.
/// @param[in] pPipelineInfo         Pointer to the array of structures that describe the pipeline information.
/// @param[in] pCallbacks            Pointer to the callback that the application provides to return session results and
///                                  messages.
/// @param[in] pPrivateCallbackData  Pointer to the private data passed back to the application as part of the callback.
/// @param[in] flags                 Used when creating the camera session.
///
/// @detdesc
/// This function creates a session that comprises independent processing units containing one or multiple pipelines. The
/// pipelines for these processing sessions can get input data from memory (offline) or through streaming (real time).
/// @par
/// Sessions are created in the Deactivated state, and resources are only acquired when attempting to activate a session.
/// @par
/// Sessions are immutable and own all resources for pipelines. Mutually exclusive sessions share resources across pipelines.
/// Non-mutually exclusive sessions have enough resources reserved for all pipelines.
///
/// @return Handle used by the driver to identify the processing session.
///
/// @dependencies
/// All pipelines and pipeline configurations must be created before calling this function. A new session is required if a
/// buffer size must change. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CHIHANDLE (*PFNCHICREATESESSION)(
    CHIHANDLE        hChiContext,
    UINT             numPipelines,
    CHIPIPELINEINFO* pPipelineInfo,
    CHICALLBACKS*    pCallbacks,
    VOID*            pPrivateCallbackData,
    CHISESSIONFLAGS  flags);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHIREQUESTBUFFERNEGOTIATION @endcond
///
/// @brief  Request for performing buffer negotiation related operations. Based on the passId, the feature, pipeline and node
///         will perform the Buffer & Format negotiation, such as BackwardBufferNegotiation, ForwardBufferNegotiation...
///
/// This function performs operation according to the given pass id.
/// Pass id 0 is to create pipeline, populate requirements for dimensions and filter format options based on advertise formats
/// Pass id 1 is to create session and finalize dimensions based on primary format
/// Pass id 2 is to finalize format options for ports
/// Pass id 3 is to determine the final format along with its finalization for ports
/// Pass id 4 is to redo negotiaton for buffer dimensions
/// Pass id 5 is to finalize buffer dimensions for ports
/// Pass id 6 is to create buffer manager and do dimensions / format dependent finalizations
///
/// @param[in] passId                 Pass Id
/// @param[in] hChiContext            CHI Context
/// @param[in] hSession               Session handle
/// @param[in] hPipeline              Pipeline handle, can be NULL
/// @param[in] pPipelineInfo          Pointer to array of structures describing the pipeline info
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNCHIREQUESTBUFFERNEGOTIATION)(
    CHIBUFFERNEGOTIATIONPASSID passId,
    CHIHANDLE                  hChiContext,
    CHIHANDLE                  hSession,
    CHIHANDLE                  hPipeline,
    CHIPIPELINEINFO*           pPipelineInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHIACTIVATEPIPELINE @endcond
///
/// @brief Activates a pipeline in a session, after which a request submission to the pipeline can begin.
///
/// @param[in] hChiContext  Handle of the CHI context.
/// @param[in] hSession     Handle to the session.
/// @param[in] pipeline     Pipeline (handle) to activate.
/// @param[in] pModeInfo    New sensor mode information.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNCHIACTIVATEPIPELINE)(
    CHIHANDLE          hChiContext,
    CHIHANDLE          hSession,
    CHIHANDLE          pipeline,
    CHISENSORMODEINFO* pSensorModeInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHIDEACTIVATEPIPELINE @endcond
///
/// @brief Deactivates a pipeline, after which no request can be submitted to the pipeline.
///
/// @param[in] hChiContext  Handle of the CHI context.
/// @param[in] hSession     Handle to the session.
/// @param[in] pipeline     Pipeline (handle) to deactivate.
/// @param[in] mode         Deactivate mode.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNCHIDEACTIVATEPIPELINE)(
    CHIHANDLE                   hChiContext,
    CHIHANDLE                   hSession,
    CHIHANDLE                   pipeline,
    CHIDEACTIVATEPIPELINEMODE   mode);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHIQUERYPIPELINEMETADATAINFO @endcond
///
/// @brief Queries for metadata information from a specific pipeline.
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHIPIPELINEDESCRIPTOR \n
/// #CHIPIPELINEMETADATAINFO
///
/// @param[in]  hChiContext            Handle of the CHI context.
/// @param[in]  hSession               Handle of the session.
/// @param[in]  hPipelineDescriptor    Handle of the pipeline descriptor.
/// @param[out] pPipelineMetadataInfo  Pointer to the structure that contains the pipeline metadata information.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///
/// @dependencies
/// Session and pipelines must have been initialized. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNCHIQUERYPIPELINEMETADATAINFO)(
    CHIHANDLE                   hChiContext,
    CHIHANDLE                   hSession,
    CHIPIPELINEDESCRIPTOR       hPipelineDescriptor,
    CHIPIPELINEMETADATAINFO*    pPipelineMetadataInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHIDESTROYSESSION @endcond
///
/// @brief Destroys a camera session.
///
/// @datatypes
/// #CHIHANDLE
///
/// @param[in] hChiContext  Handle of the CHI context.
/// @param[in] session      Handle of the session.
/// @param[in] isForced     Indicates that the destroy command is forced.
///
/// @detdesc
/// Tears down a session and releases all resources related to it.
/// @par
/// The client is responsible for ensuring that all pending operations are complete before calling this function. If any work
/// is pending, the driver immediately kills all requests.
///
/// @return None.
///
/// @dependencies
/// The session must have been previously created using #PFNCHICREATESESSION within this context. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFNCHIDESTROYSESSION)(
    CHIHANDLE hChiContext,
    CHIHANDLE session,
    BOOL      isForced);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHIFLUSHSESSION @endcond
///
/// @brief Flushes a camera session.
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHISESSIONFLUSHINFO
///
/// @param[in] hChiContext        Handle of the CHI context.
/// @param[in] hSessionFlushInfo  Handle of the flush information.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNCHIFLUSHSESSION)(
    CHIHANDLE           hChiContext,
    CHISESSIONFLUSHINFO hSessionFlushInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHISUBMITPIPELINEREQUEST @endcond
///
/// @brief Submits a request to an active session (a specific pipeline within the session).
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHIPIPELINEREQUEST
///
/// @param[in] hChiContext  Handle of the CHI context.
/// @param[in] pRequest     Pointer to the request parameters.
///
/// @dependencies
/// The session must have been activated.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNCHISUBMITPIPELINEREQUEST)(
    CHIHANDLE           hChiContext,
    CHIPIPELINEREQUEST* pRequest);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNDUMPEVENT @endcond
///
/// @brief Dumps data when a system event is triggered.
///
/// @param[in] textLogFd    File descriptor for text logging.
/// @param[in] binaryLogFd  File descriptor for binary logging.
/// @param[in] indent       Indentation to be kept.
/// @param[in] pSession     Pointer to the session associated with the system event.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFNDUMPEVENT)(
    INT     textLogFd,
    UINT64  binaryLogFd,
    UINT32  indent,
    VOID*   pSession);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNOTIFYCHIRECOVERY @endcond
///
/// @brief Notifies the CAMX session of a CHI error recovery.
///
/// @param[in] hChiContext    Handle to the CHI context.
/// @param[in] pRecoveryData  Pointer to the recovery data.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNNOTIFYCHIRECOVERY)(
    CHIHANDLE                  hChiContext,
    CHIPCRTIMEOUTRECOVERYDATA* pRecoveryData);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHISTARTAONUSECASE @endcond
///
/// @brief Starts the Always On use case from the CSS.
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFNCHISTARTAONUSECASE)();

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHISTOPAONUSECASE @endcond
///
/// @brief Stops the Always On use case from the CSS.
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFNCHISTOPAONUSECASE)();

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ChiSessionRepeatingRequestEnd
///
/// @brief  Stop always on usecase from CSS
///
/// @param  [in] hChiContext    CHI Context
/// @param  [in] session        Session handle
/// @param  [in] pipeline       Pipeline handle
/// @param  [in] frameNumber    Chi frame number
/// @param  [in] numStreams     Number of streams
/// @param  [in] ppStreams      Array of stream pointers
///
/// @return ChiResultSuccess upon success.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNCHISESSIONREPEATINGREQUESTEND)(
    CHIHANDLE          hChiContext,
    CHIHANDLE          hSession,
    CHIHANDLE          hPipeline,
    UINT               frameNumber,
    UINT               numStreams,
    ChiStream**        ppStreams);

/** @} */ /* end_addtogroup chi_common_functions */

/** @addtogroup chi_common_datatypes
@{ */

/// @brief Contains function pointers to the CHI functions. Clients are expected to call these functions with a valid CHI
/// handle.
///
/// This structure will never shrink, nor will existing fields be reordered or repurposed on interface changes. All fields must
/// have a default value of 0, which means the feature is not available.
typedef struct /** @cond */ ChiContextOps /** @endcond */
{
    UINT32                            size;                         ///< Size of this structure.
                                                                    ///
                                                                    ///  Mismatches in size are a warning to the driver that
                                                                    ///  the interface header used by the client does not match
                                                                    ///  the interface header used by CHI. If there is a
                                                                    ///  mismatch, this structure contains only the data that
                                                                    ///  is availablein the oldest CHI interface.

    UINT32                            majorVersion;                 ///< Major version of the interface.
    UINT32                            minorVersion;                 ///< Minor version of the interface.
    UINT32                            subVersion;                   ///< Sub-version of the interface.
    PFNCHIOPENCONTEXT                 pOpenContext;                 ///< Create and return a CHI context.
    PFNCHICLOSECONTEXT                pCloseContext;                ///< Close a CHI context.
    PFNCHIGETNUMCAMERAS               pGetNumCameras;               ///< Get the number of cameras on a platform.
    PFNCHIGETCAMERAINFO               pGetCameraInfo;               ///< Get camera information for a single camera.
    PFNCHIENUMERATESENSORMODES        pEnumerateSensorModes;        ///< Enumerate the sensor modes.
    PFNCHICREATEPIPELINEDESCRIPTOR    pCreatePipelineDescriptor;    ///< Create a pipeline descriptor.
    PFNCHIDESTROYPIPELINEDESCRIPTOR   pDestroyPipelineDescriptor;   ///< Destroy a pipeline descriptor.
    PFNCHICREATESESSION               pCreateSession;               ///< Create a camera session.
    PFNCHIDESTROYSESSION              pDestroySession;              ///< Destroy a camera session.
    PFNCHIREQUESTBUFFERNEGOTIATION    pRequestBufferNegotiation;    ///< Reqeust to perform buffer negotiation related operation.
    PFNCHIACTIVATEPIPELINE            pActivatePipeline;            ///< Activate a pipeline contained in a session.
    PFNCHIDEACTIVATEPIPELINE          pDeactivatePipeline;          ///< Deactivate a pipeline contained in a session.
    PFNCHISUBMITPIPELINEREQUEST       pSubmitPipelineRequest;       ///< Submit a pipeline request to (multiple) instantiated
                                                                    ///  live or offline pipelines.
    PFNGETTAGOPS                      pTagOps;                      ///< Get the tag-related operations.
    PFNCHIFLUSHSESSION                pFlushSession;                ///< Flush a camera session.
    PFNCHIQUERYPIPELINEMETADATAINFO   pQueryPipelineMetadataInfo;   ///< Query for metadata information that is specific to a
                                                                    ///  pipeline.
    PFNGETFENCEOPS                    pGetFenceOps;                 ///< Get the fence-related operations.
    PFNGETMETADATAOPS                 pMetadataOps;                 ///< Get the tag-related metadata operations.
    PFNGETRESOURCEMANAGEROPS          pResourceManagerOps;          ///< Pointer to the resource manager operations.
    PFNGETBUFFERMANAGEROPS            pGetBufferManagerOps;         ///< Get the CHI buffer manager-related operations.
    PFNDUMPEVENT                      pDumpEvent;                   ///< Dump data.
    PFNNOTIFYCHIRECOVERY              pNotifyChiRecovery;           ///< Notify the CAMX session of a CHI recovery.
    PFNCHISTARTAONUSECASE             pStartCSSAONUsecase;          ///< Pointer to the Start AON use case in the CSS.
    PFNCHISTOPAONUSECASE              pStopCSSAONUsecase;           ///< Pointer to the Stop AON use case in the CSS.
    PFNCHISESSIONREPEATINGREQUESTEND  pRepeatingRequestEnd;         ///< RepeatingRequestEnd API
    PFNGETHEALTMONITOROPS             pGetHealthMonitorOps;         ///< Health monitor operations
    PFNCHIHMSJOBCLIENTOPS             pGetHMSJobClientOps;          ///< HMSJobClient operations
} CHICONTEXTOPS;

/// @brief Contains sensor PDAF pixel coordinates.
typedef struct /** @cond */ ChiPDAFPixelCoordinates /** @endcond */
{
    UINT32  PDXCoordinate;  ///< X coordinate of a pixel.
    UINT32  PDYCoordinate;  ///< Y coordinate of a pixel.
} CHIPDAFPIXELCOORDINATES;

/// @brief Information about the PDAF sensor.
typedef struct /** @cond */ ChiSensorPDAFInfo /** @endcond */
{
    UINT32                  PDAFBlockWidth;       ///< Width of the PDAF block.
    UINT32                  PDAFBlockHeight;      ///< Height of the PDAF block.
    UINT32                  PDAFGlobaloffsetX;    ///< PDAF offset X.
    UINT32                  PDAFGlobaloffsetY;    ///< PDAF offset Y.
    UINT32                  PDAFPixelCount;       ///< Number of pixels in the array.
    ChiPDAFPixelCoordinates PDAFPixelCoords[256]; ///< Array of pixel coordinates.
} CHISENSORPDAFINFO;

/// @brief Contains parameters for the AEC data.
typedef struct /** @cond */ ChiAECData /** @endcond */
{
    UINT64  exposureTime;   ///< Exposure time in nanoseconds.
    INT32   sensitivity;    ///< Sensitivity of the sensor.
} CHIAECDATA;

/// @brief Contains parameters for the timestamp information.
typedef struct /** @cond */ ChiTimestampInfo /** @endcond */
{
     UINT64 timestamp;    ///< Timestamp for the associated request/result.
     UINT64 frameId;      ///< Frame ID for the associated request/result.
} CHITIMESTAMPINFO;

/** @} */ /* end_addtogroup chi_common_datatypes */

#ifndef DOXYGEN_SHOULD_SKIP_THIS
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// PCHIENTRY
///
/// @brief Main entry point of the CHI driver
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PCHIENTRY)(CHICONTEXTOPS* pContextOps);
#endif /* DOXYGEN_SHOULD_SKIP_THIS */


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @ingroup chi_common_entry_fn
///
/// @cond ChiEntry @endcond
///
/// @brief Main entry point of the CHI driver. This method is required for all CHI functionality.
///
/// @datatypes
/// #CHICONTEXTOPS
///
/// @param[in]  pContextOps  Pointer to the CHI context structure. The client is responsible for allocating the memory for this
///                          structure.
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CDK_VISIBILITY_PUBLIC VOID ChiEntry(CHICONTEXTOPS* pContextOps);


#ifndef DOXYGEN_SHOULD_SKIP_THIS
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ChiDumpState
///
/// @brief  Post-mortem dump function.  Used by tools.  Not intended for use in Chi applications.
///
/// @param  textLogFd      file descriptor for textual logging
/// @param  binaryLogFd    file descriptor for binary dump
/// @param  indent         indentation to be kept
///
/// @note  Once Chi and below is in a separate .so, this should be a public entry function (like ChiEntry)
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
VOID ChiDumpState(INT textLogFd, UINT64 binaryLogFd, UINT32 indent);
#endif /* DOXYGEN_SHOULD_SKIP_THIS */


#pragma pack(pop)

#ifdef __cplusplus
}
#endif // __cplusplus

#endif // CHI_H
