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

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  chinode.h
/// @brief Defines Chi Node interface
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef CHINODE_H
#define CHINODE_H

#include "camxcdktypes.h"
#include "chi.h"
#include "chicommon.h"
#include "chituningmodeparam.h"

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

// Pack data structures to ensure consistent layout.
#pragma pack(push, 8)

/** @addtogroup chi_node_macros
@{ */

static const UINT32 ChiNodeMaxProperties      = 64;         ///< Maximum number of CHI node properties.

static const UINT32 ChiNodeMaxTagsPublished   = 64;         ///< Maximum number of tags published by a CHI node.
static const UINT32 ChiMaxPipelineInputPorts  = 16;         ///< Maximum number of input ports on a pipeline.


static const UINT32 ChiNodeCapsScale = 0x1;                 ///< CHI node can support a scaling operation (up or down scaling).
static const UINT32 ChiNodeCapsGpuMemcpy         = 1 << 1;  ///< GPU node can support a memory copy operation (copy an input
                                                            ///  image to an output image).
static const UINT32 ChiNodeCapsGPUGrayscale      = 1 << 2;  ///< CHI node can support color-to-grayscale conversion of an
                                                            ///  image.
static const UINT32 ChiNodeCapsGPURotate         = 1 << 3;  ///< CHI node can support GPU image rotation.
static const UINT32 ChiNodeCapsGPUDownscale      = 1 << 4;  ///< CHI node can support GPU downscaling of an image.
static const UINT32 ChiNodeCapsGPUFlip           = 1 << 5;  ///< CHI node can support GPU horizontal or vertical flipping of
                                                            ///  an image.
static const UINT32 ChiNodeCapsParallelReq       = 1 << 6;  ///< CHI node can support parallel processing of multiple requests.
static const UINT32 ChiNodeCapsDewarpEISV3       = 1 << 7;  ///< CHI node can support GPU warping for EIS-3.
static const UINT32 ChiNodeCapsDewarpEISV2       = 1 << 8;  ///< CHI node can support GPU warping for EIS-2.
static const UINT32 ChiNodeCapsGPUSkipProcessing = 1 << 9;  ///< CHI node can support GPU processing skip if no preview buffer
                                                            ///  is present.
static const UINT32 ChiNodeCapsGPUEnableMapping  = 1 << 10; ///< CHI node can support GPU mapping of the buffers.
static const UINT32 ChiNodeCapsDelayedProcessing = 1 << 11; ///< CHI node can support delayed notification.
static const UINT32 ChiNodeCapsCompositeFences   = 1 << 12; ///< CHI node can support composite fences.

static const UINT32 ChiNodeCapsFinalizeBufferByMasterIndex   = 1 << 13; ///< CHI node can support the selection of the input
                                                                        ///  port negotiation data by the master camera index.
static const UINT32 ChiNodeCapsGeneric           = 1 << 14; ///< CHI node can support the copy of an input image directly to
                                                            ///  the output.
static const UINT32 ChiNodeCapsGPUUpscale        = 1 << 15; ///< CHI node can support GPU upscaling of an image.

static const UINT32 ChiNodeCapsFCVDownscale    = ChiNodeCapsGPUDownscale; ///< CHI node can support Fast Computer Vision (FCV)
                                                                          ///  downscaling.
static const UINT32 ChiNodeCapsFCVRotate       = ChiNodeCapsGPURotate;    ///< CHI node can support FCV rotation.
static const UINT32 ChiNodeCapsConvertYUV      = 1 << 16;     ///< Support YUV422 to YUV420 conversion

static const UINT32 ChiNodeMaxCSLCmdBuffer     = 8;         ///< Maximum number of CSL command buffers.
static const UINT32 ChiNodeMaxInputPorts       = 32;         ///< Maximum number of input ports for a CHI node.
static const UINT32 ChiNodeMaxOutputPorts      = 32;        ///< Maximum number of output ports for a CHI node.

static const UINT32 ChiNodeMaxPorts            = ChiNodeMaxInputPorts + ChiNodeMaxOutputPorts; ///< Maximum number of input and
                                                                                               ///  output ports for a CHI
                                                                                               ///  node.
                                                                                               ///  @newpage

static const UINT32 DONT_CARE_ALIGN            = -1; ///< Don't care about alignment - pick best one when set to this

typedef VOID*          CHIHANDLE;              ///< Pointer to the CHI driver handle.
typedef VOID*          CHIMETADATAHANDLE;      ///< Pointer to the CHI metadata handle.
typedef VOID*          CHIDATASOURCECAPS;      ///< Pointer to the CHI data source capabilities.
typedef VOID*          CHIDATAREQUESTHANDLE;   ///< Pointer to the CHI request handle.
typedef VOID*          CHIDATAHANDLE;          ///< Pointer to the CHI data handle.

/** @} */ /* end_addtogroup chi_node_macros */

/** @addtogroup chi_node_datatypes
@{ */

/// @brief Types of Camera Service Layer (CSL) hardware packets.
enum ChiCSLHwPacketContextType
{
    ChiCSLHwPacketInit,
    ChiCSLHwPacketPerRequest
};

/// @brief Valid ICA versions.
typedef enum /** @cond */ ChiICAVersion /** @endcond */
{
    ChiICA10,    ///< ICA version 10.
    ChiICA20,    ///< ICA version 20.
    ChiICA30,    ///< ICA version 30.
    ChiICA33,    ///< ICA version 33.
    ChiICA40,    ///< ICA version 40.
    ChiICA41,    ///< ICA version 41.
    ChiICA43,    ///< ICA version 43.
    ChiICAMax,   ///< Maximum number of ICA versions.
} ChiICAVersion;

/// @brief Valid QLL library versions.
typedef enum /** @cond */ ChiQLLLibVersion /** @endcond */
{
    ChiQLLInvalid,
    ChiQLL10,
    ChiQLL20,
} ChiQLLVersion;

/// @brief Defines the versions of the architecture family.
typedef enum
{
    Titan150 = 0x00010500,    ///< Titan version
    Titan160 = 0x00010600,    ///< Titan version
    Titan165 = 0x00010605,    ///< Titan version
    Titan170 = 0x00010700,    ///< Titan version
    Titan175 = 0x00010705,    ///< Titan version
    Titan480 = 0x00040800,    ///< Spectrum 480
    Titan497 = 0x00040907,    ///< Titan version
    Titan498 = 0x00040908,    ///< Titan version
    Titan520 = 0x00050200,    ///< Spectrum 520
    Titan540 = 0x00050400,    ///< Spectrum 540
    Titan545 = 0x00050405,    ///< Spectrum 545
    Titan570 = 0x00050700,    ///< Spectrum 570
    Titan580 = 0x00050800,    ///< Spectrum 580
    Titan640 = 0x00060400,    ///< Spectrum 640
    Titan680 = 0x00060800,    ///< Spectrum 680
    Titan670 = 0x00070700,    ///< Spectrum 670
    Titan780 = 0x00070800,    ///< Spectrum 780
    Titan860 = 0x00080600,    ///< Spectrum 860
    Titan880 = 0x00080800,    ///< Spectrum 880
} ChiTitanVersion;


/// @ingroup chi_node_macros
/// @brief Master structure for a single image buffer from CamX.
/// In batch mode, the single image buffer can contain multiple actual images (ChiImage).
typedef CHIIMAGELIST* CHINODEBUFFERHANDLE;

#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef struct ChiNodeCallbacks CHINODECALLBACKS;
typedef struct ChiNodeInterface CHINODEINTERFACE;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */


/** @addtogroup chi_node_datatypes
@{ */

/// @brief Port group info for a CHI node.
typedef struct
{
    UINT  numPortsPerGroup;  ///< Number of ports at each camera group.
    UINT  portIndexInGroup;  ///< Port index in the camera group.
}CHINODEPORTGROUPINFO;

/// @brief Node capabilities information.
typedef struct /** @cond */ ChiNodeCapsInfo /** @endcond */
{
    UINT32  size;           ///< Size of this structure.
                            ///
                            ///  Mismatches in size are a warning to the CHI node that the interface header used by the node
                            ///  does not match the interface header used by CHI.

    UINT32  nodeCapsMask;   ///< Mask of the capabilities that the CHI node reports as supported.
} CHINODECAPSINFO;


/// @brief Union of node flags and the value that it represents.
union CHINODEFLAGS
{
    /// @brief Bit mask of node flags.
    struct
    {
        BIT isInplace                    : 1;      ///< Indicates that the CHI node is an in-place node, where the output
                                                   ///  buffer is the same as the input buffer.
        BIT isRealTime                   : 1;      ///< Indicates that the CHI node is part of a real-time pipeline.
        BIT isSecureMode                 : 1;      ///< Indicates that the CHI node is secure.
        BIT isBypassable                 : 1;      ///< Indicates that the CHI node is can be bypassed.

        // This is now deprecated and the new method should be used.
        BIT canDRQPreemptOnStopRecording : 1;      ///< Indicates that the deferred request queue (DRQ) can preempt a CHI node.
                                                   ///  on a recording stop or pause operation.
        BIT canSetInputBufferDependency  : 1;      ///< Indicates that the CHI node can set the input buffer dependency.
        BIT hasFutureDependencies        : 1;      ///< Node has future dependencies, all downstream nodes would set
                                                   ///< hasDelayedNotification automatically
        BIT hasDelayedNotification       : 1;      ///< Indicates the CHI node has delayed notification.
        BIT isPrimaryVM                  : 1;      ///< Flag for Primary VM mode.
        BIT canBatchInitDependency       : 1;      ///< Node requires batch processing for Sequence 0
        BIT needSynxFence                : 1;      ///< Node requires synx fence creation.
        BIT needHWFence                  : 1;      ///< Node requires HW fence creation.
        BIT needSerialDestroy            : 1;      ///< Node requires serial destroy.
        BIT reserved                     : 19;     ///< Must be initialized to NULL.
    };

    UINT value;                                    ///< Value of the mask.
};

/// @brief Union of output port flags and the value that it represents.
typedef union /** @cond */ ChiNodeOutputPortFlags /** @endcond */
{
    /// @brief Bit mask of outport port flags.
    struct
    {
        BIT isSinkBuffer                     : 1;  ///< Indicates a sink port with an output buffer.
        BIT isSinkNoBuffer                   : 1;  ///< Indicates a sink port with no output buffer.
        BIT isEnabled                        : 1;  ///< Indicates that the port is enabled.

        BIT isDisabledBySelf                 : 1;  ///< Indicates whether this node disables this port or if a downstream node
                                                   ///  disables this port.
                                                   ///
                                                   ///  @valuesbul
                                                   ///  - TRUE -- This node disables this port
                                                   ///  - FALSE -- Otherwise @tablebulletend

        BIT isDisabledBySelfDontOverwrite    : 1;  ///< Indicates whether this node disabled this port. Do not overwrite to
                                                   ///  enable this port again.
                                                   ///
                                                   ///  @valuesbul
                                                   ///  - TRUE -- This node disabled this port
                                                   ///  - FALSE -- Otherwise @tablebulletend

        BIT isSinkInplaceBuffer              : 1;  ///< Indicates a sink port with an in-place buffer.
        BIT reserved                         : 26; ///< Must be initialized to NULL.
    };

    UINT value;                                  ///< Value of the mask.
}CHINODEOUTPUTPORTFLAGS;

/// @brief List of metadata tags that the CHI node uses or publishes.
typedef struct /** @cond */ ChiNodeMetadataList /** @endcond */
{
    UINT32      size;                               ///< Size of this structure.
    CHIHANDLE   hNodeSession;                       ///< Handle of the session object in the current CHI node instance.
    UINT32      tagCount;                           ///< Number of tags published by the CHI node.
    UINT32      partialTagCount;                    ///< Number of partial metadata entries in the tag array.
    UINT32      tagArray[ChiNodeMaxTagsPublished];  ///< Array of tags published by the CHI node.
} CHINODEMETADATALIST;

/// @brief Finalize node initialization.
typedef struct /** @cond */ ChiNodeFinalizeInitialize /** @endcond */
{
    UINT32         size;                   ///< Size of this structure.
    CHIHANDLE      hNodeSession;           ///< Handle of the session object in the current CHI node instance.
} CHINODEFINALIZEINITIALIZE;

/// @brief Forward declaration for a CHI node property. Property IDs should start from 1023.
struct ChiNodeProperty;

/// @brief Node creation information.
typedef struct /** @cond */ ChiNodeCreateInfo /** @endcond */
{
    UINT32            size;                   ///< Size of this structure.
                                              ///
                                              ///  Mismatches in size are a warning to the CHI node that the interface header
                                              ///  used by the node does not match the interface header used by CHI.

    CHIHANDLE         hChiSession;            ///< CHI driver handle that the CHI node can use to call back into CHI.
                                              ///
                                              ///  This handle must be provided to CHI when the CHI node makes calls to CHI
                                              ///  using the CHI node interface.
                                              ///
                                              ///  The handle can be unique for each session that CHI creates. CHI expects
                                              ///  the CHI node to return the correct handle associated with a session.

    CHIHANDLE*        phNodeSession;          ///< Pointer to the handle that represents the derived object instance or
                                              ///  context of the CHI node.
                                              ///
                                              ///  CHI can use this CHI node handle to make a call into the context of the
                                              ///  CHI node.

    UINT32            nodeId;                 ///< Unique ID for this CHI node instance in a session.
                                              ///
                                              ///  Multiple CHI node instances might be required to exist at the same time.

    CHINODECAPSINFO   nodeCaps;               ///< Capabilities of the CHI node, which must be enabled for this CHI node
                                              ///  instance.
    CHINODEFLAGS      nodeFlags;              ///< Node flags used to indicate the properties of the CHI node.
    UINT32            nodeInstanceId;         ///< Unique ID of this CHI node instance.
    ChiICAVersion     chiICAVersion;          ///< Tracks the Image Correction and Adjustment version.
    ChiTitanVersion   chiTitanVersion;        ///< Titan architecture version.
    ChiQLLLibVersion  chiQLLLibVersion;       ///< QLL  library version.
    UINT              nodePropertyCount;      ///< Number of properties for the CHI node.
    ChiNodeProperty*  pNodeProperties;        ///< Pointer to the properties associated with the CHI node.
    UINT64            pipelineDelay;          ///< Pipeline delay in frames.
    CHICAMERAINFO*    pCameraInfo;            ///< Pointer to the number of frames the pipeline takes for a setting to take
                                              ///  effect.
    const CHAR*       pNodeIdentifierString;  ///< Pointer to the pipeline name, node name, and instance ID.

    BOOL              isDeferredSetup;          ///< Indicates whether the node deferred setup or not per a request.
                                                ///
                                                ///  @valuesbul
                                                ///  - FALSE -- Did not defer setup
                                                ///  - TRUE  -- Deferred setup @tablebulletend
    BOOL              disableOutputFenceSignal; ///< Indicates whether the base node should disable signaling output fences
                                                ///  To be used when derived node will signal its output fences by itself
                                                ///  @valuesbul
                                                ///  - FALSE -- Node will not signal output fences
                                                ///  - TRUE --  Node will signal all output fence @tablebulletend
} CHINODECREATEINFO;

/// @brief CSL hardware information for a CHI node.
typedef struct /** @cond */ ChiCSLHwResourceInfo /** @endcond */
{
    VOID*        hwInitData;                  ///< Initial hardware data to be sent to the KMD.
    UINT32       sizeInitData;                ///< Size of the initial data.
    UINT32       numResources;                ///< Number of resources to acquire.
} CHICSLHWRESOURCEINFO;

/// @brief CSL device information for a CHI node.
typedef struct /** @cond */ ChiCSLDeviceInfo /** @endcond */
{
    BOOL                 requireCSLAccess;                            ///< Indicates whether this node requires CSL access.
                                                                      ///
                                                                      ///  @valuesbul
                                                                      ///  - 0 -- FALSE
                                                                      ///  - 1 -- TRUE @tablebulletend

    BOOL                 requireOutputBuffers;                        ///< Indicates whether this node requires output buffers.
                                                                      ///
                                                                      ///  @valuesbul
                                                                      ///  - 0 -- FALSE
                                                                      ///  - 1 -- TRUE
                                                                      ///
                                                                      ///  If buffers are not required, there is no need to
                                                                      ///  create a fence. Recycle the command buffers when the
                                                                      ///  submit is complete.

    UINT32               CSLHwResourceID;                             ///< Hardware resource ID for which CSL access is
                                                                      ///  required.
    UINT32               numCmdBuffers;                               ///< Number of command buffers required. The maximum size
                                                                      ///  is 8.
    UINT32               numberOfBuffer;                              ///< Number of buffers for each command buffer.
    UINT32               sizeOfCommandBuffer[ChiNodeMaxCSLCmdBuffer]; ///< Size of each command buffer. The maximum size is 8.

    BOOL                 requireScratchBuffer;                        ///< Indicates whether this node requires a scratch
                                                                      ///  buffer.
                                                                      ///
                                                                      ///  @valuesbul
                                                                      ///  - 0 -- FALSE
                                                                      ///  - 1 -- TRUE @tablebulletend

    UINT32               sizeOfScratchBuffer;                         ///< Size of the scratch buffer, if the buffer is
                                                                      ///  required.
    CHICSLHWRESOURCEINFO CSLHwInfo;                                   ///< Acquire CSL hardware information for a CHI node.
} CHICSLDEVICEINFO;

/// @brief Defines the Destroy information for a CHI node.
typedef struct /** @cond */ ChiNodedestroyInfo /** @endcond */
{
    UINT32      size;            ///< Size of this structure.
                                 ///
                                 ///  Mismatches in size are a warning to the CHI node that the interface header used by the
                                 ///  node does not match the interface header used by CHI.

    CHIHANDLE   hNodeSession;    ///< Handle of the session object in the current CHI node instance.
} CHINODEDESTROYINFO;

/// @brief Stream On information for a CHI node.
typedef struct /** @cond */ ChiNodeOnStreamOnInfo /** @endcond */
{
    UINT32      size;            ///< Size of this structure.
    CHIHANDLE   hNodeSession;    ///< Handle of the session object in the current CHI node instance.
} CHINODEONSTREAMONINFO;

/// @brief Information about a CHI node port.
typedef struct /** @cond */ ChiNodePortInfo /** @endcond */
{
    UINT32                 numInputPorts;                          ///< Number of input ports.
    UINT32                 inputPortId[ChiNodeMaxInputPorts];      ///< Array of input port IDs.
    UINT32                 numOutputPorts;                         ///< Number of output ports.
    UINT32                 outputPortId[ChiNodeMaxOutputPorts];    ///< Array of output port IDs.
    CHINODEOUTPUTPORTFLAGS outputPortFlags[ChiNodeMaxOutputPorts]; ///< Array of output port flags.
} CHINODEPORTINFO;

/// @brief Contains parameters for the node to prepare to acquire hardware information.
typedef struct /** @cond */ ChiNodeAcquireHwResourceInfo /** @endcond */
{
    UINT32                      size;            ///< Size of this structure.
    CHIHANDLE                   hNodeSession;    ///< Handle of the session object in the current CHI node instance.
    CHICSLHWRESOURCEINFO        CSLHwInfo;       ///< Acquire information for the CSL hardware resource.
} CHINODEACQUIREHWRESOURCEINFO;

/// @brief Contains parameters for the node to prepare to release hardware information.
typedef struct /** @cond */ ChiNodeReleaseHwResourceInfo /** @endcond */
{
    UINT32           size;            ///< Size of this structure.
    CHIHANDLE        hNodeSession;    ///< Handle of the session object in the current CHI node instance.
} CHINODERELEASEHWRESOURCEINFO;

/// @brief Contains parameters for the node to prepare stream ON information.
typedef struct /** @cond */ ChiNodePrepareStreamOnInfo /** @endcond */
{
    UINT32                      size;            ///< Size of this structure.
    CHIHANDLE                   hNodeSession;    ///< Handle of the session object in the current CHI node instance.
    CHICSLDEVICEINFO            CSLDeviceInfo;   ///< Information about the CSL device.
    CHINODEPORTINFO             portInfo;        ///< Information about the input and output ports.
} CHINODEPREPARESTREAMONINFO ;

/// @brief Stream Off information for a CHI node.
typedef struct /** @cond */ ChiNodeOnStreamOffInfo /** @endcond */
{
    UINT32      size;            ///< Size of this structure.
    CHIHANDLE   hNodeSession;    ///< Handle of the session object in the current CHI node instance.
} CHINODEONSTREAMOFFINFO;

/// @brief Buffer requirement information.
typedef struct /** @cond */ ChiNodeBufferRequirement /** @endcond */
{
    UINT32           minW;                                     ///< Minimum width the CHI node requires to generate its final
                                                               ///  output buffer.
    UINT32           minH;                                     ///< Minimum height the CHI node requires to generate its final
                                                               ///  output buffer.
    UINT32           maxW;                                     ///< Maximum width the CHI node requires to generate its final
                                                               ///  output buffer.
    UINT32           maxH;                                     ///< Maximum height the CHI node requires to generate its final
                                                               ///  output buffer.
    UINT32           optimalW;                                 ///< Optimal width the CHI node prefers for its input buffer.
    UINT32           optimalH;                                 ///< Optimal height the CHI node prefers for its input buffer.
    ChiFormat        format;                                   ///< Format of the buffer.
    CHIALIGNMENTINFO planeAlignment[ChiNodeFormatsMaxPlanes];  ///< Stride and scanline alignment for each plane.
    BOOL             ignoreOptimal;                            ///< Flag to indicate the optimal requirement can be ignored
} CHINODEBUFFERREQUIREMENT;

/// @brief Image format information.
typedef struct /** @cond */ ChiNodeImageFormat /** @endcond */
{
    UINT32  width;   ///< Width of the image (in pixels).
    UINT32  height;  ///< Height of the image (in pixels).
} CHINODEIMAGEFORMAT;

/// @brief Buffer information for an output port.
typedef struct /** @cond */ ChiOutputPortQueryBufferInfo /** @endcond */
{
    UINT                            outputPortId;               ///< Unique ID of the output port.
    UINT32                          numConnectedInputPorts;     ///< Number of input ports connected to this output port.
    CHINODEBUFFERREQUIREMENT*       pBufferRequirement;         ///< Pointer to the buffer requirement requested by the input
                                                                ///  ports connected to this output port ID.
    CHINODEBUFFERREQUIREMENT        outputBufferOption;         ///< Buffer options returned by the CHI node for this output
                                                                ///  port.
    CHINODEOUTPUTPORTFLAGS          outputPortflags;            ///< Number of output port flags.
    SIZE_T                          numMappedInputs;            ///< Size of pMappedInputs.
    const UINT*                     pMappedSourcePortIds;       ///< Pointer to the mapped input ports for bypass.
} CHIOUTPUTPORTQUERYBUFFERINFO;

/// @brief Buffer information for an input port.
typedef struct /** @cond */ ChiInputPortQueryBufferInfo /** @endcond */
{
    UINT                       inputPortId;                  ///< Unique ID of the input port.
    CHINODEBUFFERREQUIREMENT   inputBufferOption;            ///< Buffer options for this input port.
} CHIINPUTPORTQUERYBUFFERINFO;

/// @brief Check info that can be queried by PFNNODECHECKDIMENSIONFORFORMATS()
typedef struct /** @cond */ ChiNodeCheckDimensionInfo /** @endcond */
{
    ChiImageFormat  outputImageFormat;                        ///< Buffer options sent to the CHI node for checking format
                                                              ///  option
    UINT32          numInputPorts;                            ///< Number of input ports for checking limitation of each port.
                                                              ///  Also represent the number of pInputImageFormat
    ChiImageFormat* pInputImageFormat;                        ///< Array of input buffer options sent to the CHI node for
                                                              ///  checkingformat options
    UINT32          outputPortId;                             ///< Port ID
    UINT32          numOfSupportedFormats;                    ///< Number of the filtered formats.
    ChiFormat       supportedFormats[MaxNumSupportedFormats]; ///< Pointer to the filtered formats of the port
    BOOL            isRenegoNeeded;                           ///< Set True if any primary format of the bypassed output port or
                                                              ///  the primary format calculates the input requirement
                                                              ///  resolution during backward is switched.
} CHINODECHECKDIMENSIONINFO;

/// @brief Exposes the buffer requirement information that can be queried by PFNNODEQUERYBUFFERINFO().
typedef struct /** @cond */ ChiNodeQueryBufferInfo /** @endcond */
{
    UINT32                          size;                       ///< Size of this structure.
                                                                ///
                                                                ///  Mismatches in size are a warning to the CHI node that the
                                                                ///  interface header used by the node does not match the
                                                                ///  interface header used by CHI.

    CHIHANDLE                       hNodeSession;               ///< Handle of the session object in the current CHI node
                                                                ///  instance.
    UINT32                          numOutputPorts;             ///< Number of output ports. The value indicates the size of
                                                                ///  the pOutputPortQueryInfo array.

    CHIOUTPUTPORTQUERYBUFFERINFO*   pOutputPortQueryInfo;       ///< Pointer to the information for an output port buffer query
                                                                ///  (for resolution and type) that CHI expects from the CHI
                                                                ///  node.
                                                                ///
                                                                ///  The format is the input information for the child node
                                                                ///  that is connected to this CHI node in a topology.

    UINT32                          numInputPorts;              ///< Number of input ports. The value indicates the size of the
                                                                ///  pInputOptions array.

    CHIINPUTPORTQUERYBUFFERINFO*    pInputOptions;              ///< Pointer to the format and resolution information that this
                                                                ///  CHI node expects from the parent node in the topology.
                                                                ///
                                                                ///  The CHI node can add the margins, padding, or alignment
                                                                ///  requirements that are required for its processing.

    CHINODEPORTGROUPINFO*           pPortGroupInfo;             ///< Pointer to the port group info.
} CHINODEQUERYBUFFERINFO;

/// @brief Dimension of Negotiation data for the input ports
typedef struct /** @cond */ ChiNodeInputPortNegotiationDimensionData/** @endcond */
{
    UINT       inputPortId; ///< Input portId
    UINT32     width;       ///< Width of the image in pixels.
    UINT32     height;      ///< Height of the image in pixels.
    ChiFormat  format;      ///< Format.
} CHINODEINPUTPORTNEGOTIATIONDIMENSIONDATA;

/// @brief Dimension of Negotiation data for the output ports
typedef struct /** @cond */ ChiNodeOutputPortNegotiationDimensionData/** @endcond */
{
    UINT       outputPortindex; ///< Output port index
    UINT32     width;           ///< Width of the image in pixels.
    UINT32     height;          ///< Height of the image in pixels.
    ChiFormat  format;          ///< Format.
} CHINODEOUTPUTPORTNEGOTIATIONDIMENSIONDATA;

/// @brief Information about specific buffer properties for a port.
typedef struct /** @cond */ ChiNodeSetBufferPropertiesInfo /** @endcond */
{
    UINT32              size;            ///< Size of this structure.
                                         ///
                                         ///  Mismatches in size are a warning to the CHI node that the interface header used
                                         ///  by the node does not match the interface header used by the CHI driver.

    CHIHANDLE           hNodeSession;    ///< Handle of the session object in the current CHI node instance.
    UINT32              portId;          ///< Port index of the current CHI node instance.
    CHINODEIMAGEFORMAT* pFormat;         ///< Pointer to the resolution and type information the CHI driver
                                         ///  sets on this CHI node for the port.

    BOOL                isSinkBuffer;    ///< Indicates a sink port with output buffer.
                                         ///
                                         ///  @valuesbul
                                         ///  - 0 -- FALSE
                                         ///  - 1 -- TRUE @tablebulletend

    UINT                                       numInputPorts;                       //< Number of input ports
    ChiNodeInputPortNegotiationDimensionData*  pInputPortNegotiationDimensionData;  //< Pointer to the Input port resolution
                                                                                    /// and port id
    ChiNodeOutputPortNegotiationDimensionData* pOutputPortNegotiationDimensionData; //< Pointer to the Output port resolution
                                                                                    /// and port index
} CHINODESETBUFFERPROPERTIESINFO;

/// @brief Dependency information for a CHI node.
typedef struct /** @cond */ ChiDependencyInfo /** @endcond */
{
    UINT32         size;                                   ///< Size of this structure.
    CHIHANDLE      hNodeSession;                           ///< Handle of the session object in the current CHI node instance.
    UINT32         count;                                  ///< Number of properties in this unit.
    UINT32         properties[ChiNodeMaxProperties];       ///< Array of property dependencies in this unit.
    UINT64         offsets[ChiNodeMaxProperties];          ///< Offset from the current request for a dependency.

    INT32          processSequenceId;                      ///< Identifier for the CHI node to track its processing order.
                                                           ///
                                                           ///  @values Any 32-bit signed number, like 1, 2, 3 , 0, -1, -2, and
                                                           ///  so on
                                                           ///
                                                           ///  Depending on the CHI node, the value can be one or multiple
                                                           ///  process sequence IDs to enforce a specific execution order in
                                                           ///  the node.

    CHIFENCEHANDLE pChiFences[ChiNodeMaxDependentFences];  ///< Array of CHI fences to depend on.
    UINT32         chiFenceCount;                          ///< Number of CHI fences in the array.

    BOOL           negate[ChiNodeMaxProperties];           ///< Indicates whether the offset is to be negated.
                                                           ///
                                                           ///  @valuesbul
                                                           ///  - 0 -- FALSE
                                                           ///  - 1 -- TRUE @tablebulletend

    VOID*          pInputBufferFence[ChiNodeMaxDependentFences];            ///< Pointer to the array of input buffer fences.
    VOID*          pInputBufferFenceIsSignaled[ChiNodeMaxDependentFences];  ///< Pointer to the array of input buffer fences
                                                                            ///  that are signaled.
    UINT32         inputBufferFenceCount;                                   ///< Number of input buffer fences.

    BOOL           sequentialExecutionNeeded;              ///< Indicates whether sequential execution is required.
                                                           ///
                                                           ///  @valuesbul
                                                           ///  - 0 -- FALSE
                                                           ///  - 1 -- TRUE @tablebulletend

    BOOL           satisfySequentialExecutionDependency;   ///< Indicates whether the wrapper must satisfy a sequential
                                                           ///  execution dependency.
                                                           ///
                                                           ///  @valuesbul
                                                           ///  - 0 -- FALSE
                                                           ///  - 1 -- TRUE @tablebulletend

    BOOL           satisfyPropertyDeferredSetup;           ///< Indicates whether the wrapper has satisfied
                                                           ///  setting up PropertyIDDeferredSetup.
                                                           ///
                                                           ///  @valuesbul
                                                           ///  - 0 -- FALSE
                                                           ///  - 1 -- TRUE @tablebulletend


    BOOL           hasIOBufferAvailabilityDependency;      ///< Indicates whether the CHI node reports input or output buffer
                                                           ///  availability as a dependency.
                                                           ///
                                                           ///  @valuesbul
                                                           ///  - 0 -- FALSE
                                                           ///  - 1 -- TRUE
                                                           ///
                                                           ///  Until this parameter is set, there is no guarantee that the
                                                           ///  input and output buffer handles have valid buffer information.
                                                           ///  CHI nodes must set this flag when buffers are required.
                                                           ///
                                                           ///  @note1 Setting this parameter early (even if buffers are not
                                                           ///  required on this dependency unit) will cause unnecessary memory
                                                           ///  consumption.

    BOOL           isPreemptable;                          ///< Indicates whether the CHI node is preemptable
                                                           ///
                                                           ///  @valuesbul
                                                           ///  - 0 -- FALSE
                                                           ///  - 1 -- TRUE @tablebulletend

    UINT32         inputPortId[ChiNodeMaxProperties];      ///< Input port ID that corresponds to the per-port link
                                                           ///  properties.
    UINT32         typeId[ChiNodeMaxProperties];           ///< Context type ID that corresponds to a given metadata tag.
} CHIDEPENDENCYINFO;

/// @brief Bypass information for a port.
typedef struct /** @cond */ ChiBypassInfo /** @endcond */
{
    UINT32      size;                               ///< Size of this structure.

    BOOL        isBypassNeeded;                     ///< Indicates whether the bypass is required.
                                                    ///
                                                    ///  @valuesbul
                                                    ///  - 0 -- FALSE
                                                    ///  - 1 -- TRUE @tablebulletend

    UINT32      selectedInputPortIndex;             ///< Index of the selected port for bypass.
} CHINODEBYPASSINFO;

/// @brief Information about a process capture request.
typedef struct /** @cond */ ChiNodeProcessRequestInfo /** @endcond */
{
    UINT32                  size;                  ///< Size of this structure.
                                                   ///
                                                   ///  Mismatches in size are a warning to the CHI node that the interface
                                                   ///  header used by the node does not match the interface header used
                                                   ///  by CHI.

    CHIHANDLE               hNodeSession;          ///< Handle of the session object in the current CHI node instance.
    UINT64                  frameNum;              ///< Frame number associated with the current request.

    CHIDEPENDENCYINFO*      pDependency;           ///< Pointer to the dependency structure for this request.
                                                   ///
                                                   ///  The CHI node updates the dependency structure if any metadata or
                                                   ///  buffer dependencies are not available.

    UINT32                  inputNum;              ///< Number of input buffers for this request.
    CHINODEBUFFERHANDLE*    phInputBuffer;         ///< Pointer to an array of input buffer handles. The array is of size
                                                   ///  inputNum.
    UINT32                  outputNum;             ///< Number of output buffers for this request.
    CHINODEBUFFERHANDLE*    phOutputBuffer;        ///< Pointer to an array of output buffer handles. The array is of size
                                                   ///  outputNum.
    CHINODEBYPASSINFO*      pBypassData;           ///< Pointer to the bypass information for the output ports. The array is of
                                                   ///  size outputNum.
    ChiTuningModeParameter* pTuningModeData;       ///< Pointer to the tuning mode data parameters.
    CHIFENCEHANDLE          doneFence;             ///< If valid, sends a signal when the effects of processing are visible.

    BOOL                    isDelayedRequestDone;  ///< Set by a custom CHI node only if it is to delay the Request Done
                                                   ///  notification after a ProcessRequest() call from the wrapper.
                                                   ///
                                                   ///  @valuesbul
                                                   ///  - 0 -- FALSE
                                                   ///  - 1 -- TRUE @tablebulletend

    BOOL                    isEarlyMetadataDone;   ///< Indicates whether a metadata Done status is already called.
                                                   ///
                                                   ///  @valuesbul
                                                   ///  - 0 -- FALSE
                                                   ///  - 1 -- TRUE @tablebulletend

    BOOL                    requireCmdBuffers;     ///< Set by the CHI node after all dependencies are met and the node
                                                   ///  is ready to fill the hardware data in the command buffers.
                                                   ///
                                                   ///  @valuesbul
                                                   ///  - 0 -- FALSE
                                                   ///  - 1 -- TRUE @tablebulletend
} CHINODEPROCESSREQUESTINFO;

/// @brief Defines the hardware input and output configuration for a port.
typedef struct /** @cond */ ChiNodeFillHWIOConfig /** @endcond */
{
    IMAGEBUFFERHANDLE          imageBuffer;        ///< Handle of the image buffer.
    UINT32                     channelID;          ///< Channel ID for each hardware input/output port.
    CHICUSTOMHWBUFFERDIRECTION bufferDirection;    ///< Indicates if the buffer is for input or output.
    VOID*                      pfenceHandle;       ///< Fence ID for each output port.
    UINT32                     frameDropPattern;   ///< Use when setting the skipping pattern for the frame.
    UINT32                     frameDropPeriod;    ///< Use when setting the skipping pattern for the frame.
    UINT32                     subsamplePattern;   ///< Use when setting the skipping pattern for the frame.
    UINT32                     subsamplePeriod;    ///< Use when setting the skipping pattern for the frame.
} CHINODEFILLHWIOCONFIG;

/// @brief Information for a process capture request.
typedef struct /** @cond */ ChiNodeFillHwData /** @endcond */
{
    UINT32                    size;                                   ///< Size of this structure.
    CHIHANDLE                 hNodeSession;                           ///< Handle of the session object in the current CHI node
                                                                      ///  instance.
    UINT64                    frameNum;                               ///< Frame number associated with the current request.
    ChiCSLHwPacketContextType packetContext;                          ///< Indicates the packet context: hardware
                                                                      ///  initialization packet or hardware per-request
                                                                      ///  packet.
    UINT32                    numCmdBufferAddr;                       ///< Number of the command buffer address.
    UINT32*                   pCmdMemoryAdd[ChiNodeMaxCSLCmdBuffer];  ///< Pointer to the array of command buffer addresses.
    UINT32                    opCode;                                 ///< Operation code for the request.
    VOID*                     scratchBufferAddress;                   ///< Pointer to the scratch buffer address.
    UINT32                    numHWIOConfig;                          ///< Number of hardware ports to be configured with
                                                                      ///  buffers.
    CHINODEFILLHWIOCONFIG     hwIOConfig[ChiNodeMaxPorts];            ///< Array of hardware input/output configurations for
                                                                      ///  each input/output port.
} CHINODEFILLHWDATA;

/// @brief Defines the Process Request Done information for a request. Used by PFNCHINODEPROCREQUESTDONE().
typedef struct /** @cond */ ChiNodeProcessRequestDoneInfo /** @endcond */
{
    UINT32      size;                   ///< Size of this structure.
    CHIHANDLE   hChiSession;            ///< CHI driver handle that the CHI node can use to call back into CHI.
    UINT64      frameNum;               ///< Frame number associated with the current request.
    INT32       result;                 ///< Result of the process capture request.

    BOOL        isEarlyMetadataDone;    ///< Indicates to the CHI node wrapper whether early metadata is available (via a
                                        ///  call to PFNCHINODEPROCMETADATADONE()).
                                        ///
                                        ///  @valuesbul
                                        ///  - 0 -- FALSE
                                        ///  - 1 -- TRUE
                                        ///
                                        ///  The CHI node wrapper then decides whether to call ProcessMetadaDone() and
                                        ///  ProcessPartialMetadaDone() on behalf of the CHI node request, or it can skip
                                        ///  this step because it is already done.
} CHINODEPROCESSREQUESTDONEINFO;

/// @brief Defines the Process Metadata Done information for a CHI node request. Used by PFNCHINODEPROCMETADATADONE().
typedef struct /** @cond */ ChiNodeProcessMetadataDoneInfo /** @endcond */
{
    UINT32      size;                   ///< Size of this structure.
    CHIHANDLE   hChiSession;            ///< CHI driver handle that the CHI node can use to call back into CHI.
    UINT64      frameNum;               ///< Frame number associated with the current request.
    INT32       result;                 ///< Result of the process capture request.
} CHINODEPROCESSMETADATADONEINFO;

/// @brief Response information for a process capture request. Used by PFNNODEFLUSHRESPONSEINFO().
typedef struct /** @cond */ ChiNodeResponseInfo /** @endcond */
{
    UINT32      size;                    ///< Size of this structure.
    CHIHANDLE   hChiSession;             ///< CHI driver handle that the CHI node can use to call back into CHI.
    UINT64      responseTimeInMillisec;  ///< Response time (in milliseconds) for the request.
} CHINODERESPONSEINFO;

/// @brief Information for max execution time of a job from node. Used by PFNNODEGETMAXEXECUTIONTIMEINFO().
typedef struct /** @cond */ ChiNodeGetMaxExecutionInfo /** @endcond */
{
    UINT32      size;                        ///< Size of this structure.
    CHIHANDLE   hChiSession;                 ///< CHI driver handle that the CHI node can use to call back into CHI.
    UINT64      maxExecutionTimeInMillisec;  ///< Max Exeuction time (in milliseconds) for the job
} CHINODEGETMAXEXECUTIONINFO;

/// Buffer delta information for a CHI node's input port.
typedef struct /** @cond */ ChiPerInputPortBufferDeltaInfo /** @endcond */
{
    UINT        portIndex;              ///< Index of the input port.
    UINT64      delta;                  ///< Buffer delta.
} CHIPERINPUTPORTBUFFERDELTAINFO;

/// @brief Buffer delta information of all input ports for a CHI node for which a buffer delta is required.
typedef struct /** @cond */ ChiSetInputPortBufferDeltaInfo /** @endcond */
{
    UINT32                          size;                                                   ///< Size of this structure.
    CHIHANDLE                       hChiSession;                                            ///< CHI driver handle that a node
                                                                                            ///  uses to call back into CHI.
    CHIPERINPUTPORTBUFFERDELTAINFO  perInputPortBufferDeltaInfo[ChiMaxPipelineInputPorts];  ///< Array of per-port buffer delta
                                                                                            ///  structures.
    UINT32                          totalInputPortWithBufferDelta;                          ///< Total number of input ports
                                                                                            ///  that have a buffer delta.
} CHISETINPUTPORTBUFFERDELTAINFO;

/// @brief Flush information for a CHI node.
typedef struct /** @cond */ ChiFlushInfo /** @endcond */
{
    UINT32    size;                  ///< Size of this structure.
    CHIHANDLE hChiSession;           ///< CHI driver handle that the CHI node can use to call back into CHI.
    UINT64    lastFlushedRequestId;  ///< ID of the last request that was flushed.

    BOOL      flushInProgress;       ///< Indicates whether a flush is in progress.
                                     ///
                                     ///  @valuesbul
                                     ///  - 0 -- FALSE
                                     ///  - 1 -- TRUE @tablebulletend

    BOOL      hasFlushOccurred;      ///< Indicates whether a flush ever occurred.
                                     ///
                                     ///  @valuesbul
                                     ///  - 0 -- FALSE
                                     ///  - 1 -- TRUE @tablebulletend
} CHIFLUSHINFO;

/// @brief Information required to flush a request.
typedef struct /** @cond */ ChiNodeFlushRequestInfo /** @endcond */
{
    UINT32    size;               ///< Size of this structure.
    CHIHANDLE hNodeSession;       ///< Handle of the session object in the current CHI node instance.
    UINT64    frameNum;           ///< Frame number associated with the current request.
} CHINODEFLUSHREQUESTINFO;

/// @brief Describes the resource cost map for a CHI node.
typedef struct /** @cond */ ChiResourceCostMap /** @endcond */
{
    UINT32 resourceType; ///< Unique identifier of the resource.
    UINT32 deviceId;     ///< Unique identifier of the device.
    UINT32 resourceCost; ///< Cost of using the resurce.
} CHIRESOURCECOSTMAP;

/// @brief Information about the resource cost for a CHI node.
typedef struct /** @cond */ ChiNodeResourceCostInfo /** @endcond */
{
    CHIHANDLE           hNodeSession;                       ///< Handle of the session object in the current CHI node instance.
    ChiResourceCostMap  resourceCostMap[ResourceTypeMax];   ///< !!updated Array of resource cost maps:
                                                            ///  {{resourceId, deviceId} - resourceCost}.
    UINT32              totalNumValidResource;              ///< !!updated Number of valid resources.
} CHINODERESOURCECOSTINFO;

/// @brief Information about a PS Metadata process capture request.
typedef struct /** @cond */ ChiNodePSMetaPortGroup /** @endcond */
{
    UINT32     size;                                                              ///< Size of this structure.
    CHIHANDLE  hNodeSession;                                                      ///< Handle of the session object in the
                                                                                  ///  current CHI node instance.
    UINT32     tagId;                                                             ///< Identifies the metadata tag.
    UINT32     activeOutputPortCount;                                             ///< Number of output ports for the node.
    UINT32     activeOutputPorts[ChiNodeMaxOutputPorts];                          ///< Array of output ports.
    UINT32     outputPortCountPerGroup[ChiNodeMaxOutputPorts];                    ///< Number of output ports per group.
    UINT32     outputPortPerGroup[ChiNodeMaxOutputPorts][ChiNodeMaxOutputPorts];  ///< Array of output ports in each group.
} CHINODEPSMETAPORTGROUP;

/// @brief Describes input parameters used by PFNCHINODEONSETUPREQUESTFORCHINODE() to set up the port.
typedef struct ChiNodeSetupRequestInput
{
    UINT64          requestId;       ///< Unique identifier of the request.
    ChiNodePortInfo portInfo;        ///< Information used for per request port setup.
    UINT32          transitionMode;  ///< Transition mode of the HDR use case.
} /** @cond */ CHINODESETUPREQUESTINPUT /** @endcond */;

/// @brief Describes output parameters used by PFNCHINODEONSETUPREQUESTFORCHINODE() to set up the port.
typedef struct ChiNodeSetupRequestOutput
{
    UINT32     numOutputPortsToDisable;                 ///< Number of output ports that are to be disabled.
    UINT32     outputPortIds[ChiNodeMaxOutputPorts];    ///< Array of output port IDs.
    UINT32     transitionMode;                          ///< Transition mode of the HDR use case.
    UINT32     numInputPortsToDisable;                  ///< Number of input ports that must be disabled.
    UINT32     inputPortIds[ChiNodeMaxInputPorts];      ///< Array of input port IDs.
} /** @cond */ CHINODESETUPREQUESTOUTPUT /** @endcond */;

/// @brief Information about a composite fence group.
typedef struct /** @cond */ ChiNodeCompositeFenceGroup /** @endcond */
{
    UINT32     groupCount;                                                              ///< Number of groups in each arrays.
    UINT32     compositeOutputPorts[ChiNodeMaxOutputPorts][ChiNodeMaxOutputPorts];      ///< Array of composite ports in each
                                                                                        ///  group.
    UINT32     primaryOutputPorts[ChiNodeMaxOutputPorts];                               ///< Array of primary ports in each
                                                                                        ///  group.
} CHINODECOMPOSITEFENCEGROUP;

/// @brief Exposes the port advertised formats that can be queried by PFNNODEGETADVERTISEDOUTPUTFORMATS() and
///        PFNNODEGETADVERTISEDINPUTFORMATS().
typedef struct /** @cond */ ChiNodeAdvertisedPortFormatInfo /** @endcond */
{
    UINT32      size;                                           ///< Size of this structure.
                                                                ///
                                                                ///  Mismatches in size are a warning to the CHI node that the
                                                                ///  interface header used by the node does not match the
                                                                ///  interface header used by CHI.

    CHIHANDLE   hNodeSession;                                   ///< Handle of the session object in the current CHI node
                                                                ///  instance.
    UINT32      portId;                                         ///< Port ID
    UINT32      numOfAdvertisedFormats;                         ///< Number of advertised formats. The value indicates the size
                                                                ///  of the pOutputPortQueryInfo array.

    ChiFormat   advertisedFormats[MaxNumSupportedFormats];      ///< The advertised formats of the port
} CHINODEADVERTISEDPORTFORMATINFO;

/** @} */ /* end_addtogroup chi_node_datatypes */


/** @addtogroup chi_node_functions
@{ */
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODEGETCAPS @endcond
///
/// @brief Gets all the capabilities supported by the CHI node.
///
/// @datatypes
/// #CHINODECAPSINFO
///
/// @param[in,out] pCapsInfo  Pointer to the structure that defines the capabilities supported by the CHI node.
///
/// @detdesc
/// Use this information to verify that the CHI node supports the node properties that are set during CHI node creation.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNNODEGETCAPS)(CHINODECAPSINFO* pCapsInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODECREATE @endcond
///
/// @brief Creates a CHI node instance.
///
/// @datatypes
/// #CHINODECREATEINFO
///
/// @param[in] pCreateInfo  Pointer to the structure that defines the create session information for the CHI node.
///
/// @detdesc
/// CHI calls this function at the start of a camera session during chi_create_pipeline() when a topology is created.
/// At this time, the CHI node can allocate any additional resources for managing per-session states.
/// @par
/// Multiple independent sessions might be active at the same time, so a CHI node can have multiple calls into this function.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNNODECREATE)(CHINODECREATEINFO* pCreateInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODEDESTROY @endcond
///
/// @brief Destroys a CHI node instance.
///
/// @datatypes
/// #CHINODEDESTROYINFO
///
/// @param[in] pDestroyInfo  Pointer to the structure that defines the session information for the CHI node.
///
/// @detdesc
/// CHI calls this function at the end of a camera session during chi_destroy_pipeline()when a topology is destroyed.
/// @par
/// After this function call, the CHI node session handle is invalid and the node is expected to deallocate all per-session
/// state resources associated with this session.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNNODEDESTROY)(CHINODEDESTROYINFO* pDestroyInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODEQUERYMETADATAPUBLISHLIST @endcond
///
/// @brief Queries for the list of metadata tags published by the CHI node. Call this function after CHI node creation and
///        before the first execute capture request.
///
/// @datatypes
/// #CHINODEMETADATALIST
///
/// @param[in] pMetadataPublishlist  Pointer to the structure that contains the published metadata list.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNNODEQUERYMETADATAPUBLISHLIST)(
    CHINODEMETADATALIST* pMetadataPublishlist);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNODEFINALIZENODEINITIALIZE @endcond
///
/// @brief Finalizes node initialization.
///
/// @datatypes
/// #CHINODEFINALIZEINITIALIZE
///
/// @param[in] pNodeFinalize  Pointer to the structure to node finalize
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNODEFINALIZENODEINITIALIZE)(
    CHINODEFINALIZEINITIALIZE* pNodeFinalize);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODEQUERYBUFFERINFO @endcond
///
/// @brief Queries for input buffer resolution and type information.
///
/// @datatypes
/// #CHINODEQUERYBUFFERINFO
///
/// @param[in,out] pQueryBufferInfo  Pointer to the structure that contains the buffer resolution and type query from the CHI
///                                  node.
///
/// @detdesc
/// Call this function after CHI node creation, when the topology walks through all nodes from sink to source for negotiating
/// resolution and type (NV12, YUV422, and so on).
/// @par
/// This function returns the input resolution and type requirements from the CHI node for a specified output format.
/// The CHI node can add any margin or padding requirements that might be required for processing.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNNODEQUERYBUFFERINFO)(CHINODEQUERYBUFFERINFO* pQueryBufferInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODEGETADVERTISEDOUTPUTFORMATS @endcond
///
/// @brief Get the outputport advertised formats.
///
/// @datatypes
/// #CHINODEADVERTISEDPORTFORMATINFO
///
/// @param[in,out] pAdvertisedFormatInfo  Pointer to the structure that contains the advertised format from the CHI
///                                       node port.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNNODEGETADVERTISEDOUTPUTFORMATS)(CHINODEADVERTISEDPORTFORMATINFO* pPortAdvertisedFormatInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODEGETADVERTISEDINPUTFORMATS @endcond
///
/// @brief Give the inputport advertised formats.
///
/// @datatypes
/// #CHINODEADVERTISEDPORTFORMATINFO
///
/// @param[in,out] pAdvertisedFormatInfo  Pointer to the structure that contains the advertised format from the CHI
///                                       node port.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNNODEGETADVERTISEDINPUTFORMATS)(CHINODEADVERTISEDPORTFORMATINFO* pPortAdvertisedFormatInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODEFINALIZEBUFFERDIMENSIONS @endcond
///
/// @brief Sets a specific resolution and type on the CHI node.
///
/// @datatypes
/// #CHINODESETBUFFERPROPERTIESINFO
///
/// @param[in] pSetBufferInfo  Pointer to the structure that defines the buffer resolution and type that CHI sets on the CHI
///                            node.
///
/// @detdesc
/// Call this function after the topology successfully walks through all CHI nodes from sink to source for negotiating
/// resolution and type (NV12, YUV422, and so on).
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNNODEFINALIZEBUFFERDIMENSIONS)(CHINODESETBUFFERPROPERTIESINFO* pSetBufferInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODECHECKDIMENSIONFORFORMATS @endcond
///
/// @brief Sets a specific resolution and type on the CHI node.
///
/// @datatypes
/// #CHINODESETBUFFERPROPERTIESINFO
///
/// @param[in] pCheckInfo      Pointer to the structure that defines the buffer resolution and type that CHI sets on the CHI
///                            node.
///
/// @detdesc
/// Call this function after the forward walk to check the finalized resolution can live with the format options.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNNODECHECKDIMENSIONFORFORMATS)(CHINODECHECKDIMENSIONINFO* pCheckInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODESETBUFFERINFO @endcond
///
/// @brief Sets a specific resolution and type on the CHI node.
///
/// @datatypes
/// #CHINODESETBUFFERPROPERTIESINFO
///
/// @param[in] pSetBufferInfo  Pointer to the structure that defines the buffer resolution and type that CHI sets on the CHI
///                            node.
///
/// @detdesc
/// Call this function after the topology successfully walks through all CHI nodes from sink to source for negotiating
/// resolution and type (NV12, YUV422, and so on).
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNNODESETBUFFERINFO)(CHINODESETBUFFERPROPERTIESINFO* pSetBufferInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODEPROCREQUEST @endcond
///
/// @brief Processes a request.
///
/// @datatypes
/// #CHINODEPROCESSREQUESTINFO
///
/// @param[in] pProcessRequestInfo  Pointer to the structure that defines the information that the CHI node requires for
///                                 processing a request. \n @vertspace{2}
///                                 The information includes input buffer, output buffer, metadata, reference buffers, and
///                                 information about the current request.
///
/// @detdesc
/// The CHI node is expected to check that all the dependencies are available. If buffer or metadata tag
/// dependencies are not available, the CHI node is expected to set the corresponding dependency and return the
/// function with success without request processing.
/// @par
/// The CHI node is invoked with the same function called back when all the dependencies are available. At this
/// point of re-entry, the CHI node can post any new additional dependency.
/// @par
/// If there are no dependencies, the CHI node is expected to continue the processing and complete the request
/// processing with the return status as successful. The function is expected to return a failure only when there
/// is a fatal failure that blocks request processing.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNNODEPROCREQUEST)(CHINODEPROCESSREQUESTINFO* pProcessRequestInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODEFILLPERREQUESTHWDATA @endcond
///
/// @brief For CHI nodes that must be able to program the hardware, provides a pointer to the memory into which the CHI node is
///        expected to write the hardware data.
///
/// @datatypes
/// #CHINODEFILLHWDATA \n
/// #CHINODEPROCESSREQUESTINFO
///
/// @param[in,out] pProcessHWData  Pointer to the structure that defines the information required in the hardware.
/// @param[in,out] pInfo           Pointer to the structure that defines the information required for processing the request.
///
/// @detdesc
/// Call this function after an execute process request and before submitting the packet for processing.
/// @par
/// The hardware data is sent to the kernel through CSL, and the actual data is processed and acted upon by the
/// kernel.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNNODEFILLPERREQUESTHWDATA)(CHINODEFILLHWDATA* pProcessHWData, CHINODEPROCESSREQUESTINFO* pInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHINODEPROCREQUESTDONE @endcond
///
/// @brief Reports the status of a request that is being processed.
///
/// @datatypes
/// #CHINODEPROCESSREQUESTDONEINFO
///
/// @param[in] pInfo  Pointer to the structure that defines the request status.
///
/// @detdesc
/// The CHI node calls this function into the CHI driver to report the status as a success or failure. The fences
/// that are associated with the request are signaled accordingly by the CHI driver.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNCHINODEPROCREQUESTDONE)(CHINODEPROCESSREQUESTDONEINFO* pInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHINODEPROCMETADATADONE @endcond
///
/// @brief Reports the status of the metadata.
///
/// @datatypes
/// #CHINODEPROCESSMETADATADONEINFO
///
/// @param[in] pInfo  Pointer to the structure that contains information about the request.
///
/// @detdesc
/// The CHI node calls this function into the CHI driver to report the status as a success or failure of metadata.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNCHINODEPROCMETADATADONE)(CHINODEPROCESSMETADATADONEINFO* pInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHINODEDISABLEINPUTOUTPUTLINK @endcond
///
/// @brief Disables one input or output port link from the downstream node.
///
/// @datatypes
/// #CHIHANDLE
///
/// @param[in] hChiSession      Handle of the CHI driver session.
/// @param[in] nodeInputPortId  Unique identifier for the input port.
/// @param[in] removeIndices    Indicates whether to remove (1) the indices.
///
/// @detdesc
/// This function should be called after the CHI node is created and
/// before/include post pipeline create to disable indicated port link.
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID(*PFNCHINODEDISABLEINPUTOUTPUTLINK)(
    CHIHANDLE hChiSession,
    UINT      nodeInputPortId,
    BOOL      removeIndices);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNABORTNCSASYNCREQUESTS @endcond
///
/// @brief Terminate the NCS asynchronous request queue for the current sensor and signal all fences with error.
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHIDATASOURCE
///
/// @param[in] hChiSession  Handle to the CHI session.
/// @param[in] pDataSource  Pointer to the data source that has sensor information and a handle.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNABORTNCSASYNCREQUESTS)(CHIHANDLE hChiSession, CHIDATASOURCE* pDataSource);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHICREATEFENCE @endcond
///
/// @brief Creates a CHI fence for synchronization, based on the provided input attributes.
///        Use this function to import native fences as well as to create new fences.
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHIFENCECREATEPARAMS \n
/// #CHIFENCEHANDLE
///
/// @param[in]     hChiSession      Handle of the CHI driver session.
/// @param[in,out] pChiFenceParams  Pointer to the fence parameters.
/// @param[out]    phChiFence       Pointer to the created fence handle.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNCHICREATEFENCE)(CHIHANDLE hChiSession, CHIFENCECREATEPARAMS*, CHIFENCEHANDLE*);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCACHEOPS @endcond
///
/// @brief Cache operations for a CHI buffer handle.
///
/// @datatypes
/// #CHINODEBUFFERHANDLE
///
/// @param[in] hChiBuffer  Handle of the cache buffer.
/// @param[in] invalidate  Set to TRUE to invalidate the cache.
/// @param[in] clean       Set to TRUE to clean the cache.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNCACHEOPS)(
    CHINODEBUFFERHANDLE hChiBuffer,
    BOOL                invalidate,
    BOOL                clean);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCPUACCESS @endcond
///
/// @brief Cache operations for a CHI buffer handle.
///
/// @datatypes
/// #CHINODEBUFFERHANDLE
///
/// @param[in] hChiBuffer  Handle of the cache buffer.
/// @param[in] endAccess   Set to FALSE to Start CPU Access, TRUE for End CPU Access
/// @param[in] readWrite   Bit Mask signifying CPU Access Type, Bit (0) set for read (1) set for write
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNCPUACCESS)(
    CHINODEBUFFERHANDLE hChiBuffer,
    BOOL                endAccess,
    UINT32              readWrite);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNWAITCHIFENCEASYNC @endcond
///
/// @brief Waits for a CHI fence. The CHI driver asynchronously calls the given function when the fence is signaled.
///
/// @datatypes
/// #CHIHANDLE \n
/// #PFNCHIFENCECALLBACK \n
/// #CHIFENCEHANDLE
///
/// @param[in]     hChiSession  Handle of the CHI driver session.
/// @param[in]     pCallbackFn  Pointer to the callback function that the CHI driver asynchronously calls.
/// @param[in]     hChiFence    Handle of the fence to wait for.
/// @param[in,out] pData        Pointer to the data to pass back to the CHI node when calling pCallbackFn.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNWAITCHIFENCEASYNC)(
    CHIHANDLE               hChiSession,
    PFNCHIFENCECALLBACK     pCallbackFn,
    CHIFENCEHANDLE          hChiFence,
    VOID*                   pData);

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

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNGETFENCESTATUS @endcond
///
/// @brief Gets the status of a CHI fence signal.
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHIFENCEHANDLE \n
/// #CDKResult
///
/// @param[in]     hChiSession  Handle of the CHI driver session.
/// @param[in]     hChiFence    Handle of the fence.
/// @param[in,out] result       Pointer to the CDKResult pointer to be filled with the fence status.
///
/// @return
/// - #CDKResultSuccess.
/// - #CDKResultEInvalidState -- Fence is not yet signaled.
/// - #CDKResultEFailed. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNGETFENCESTATUS)(
    CHIHANDLE               hChiSession,
    CHIFENCEHANDLE          hChiFence,
    CDKResult*              result);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNQUERYDATASOURCECAPABILITY @endcond
///
/// @brief Gets a handle to the capabilities of the data source.
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHIDATASOURCETYPE \n
/// #CHIDATASOURCECAPABILITY
///
/// @param[in]  hChiSession     Handle of the CHI driver session.
/// @param[in]  dataSourceType  Type of data source.
/// @param[out] pDataSourceCap  Pointer to the capabilities of the data source.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNQUERYDATASOURCECAPABILITY)(
    CHIHANDLE                hChiSession,
    CHIDATASOURCETYPE        dataSourceType,
    CHIDATASOURCECAPABILITY* pDataSourceCap);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNGETDATASOURCE @endcond
///
/// @brief Gets a handle to a data source.
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHIDATASOURCE \n
/// #CHIDATASOURCECONFIG
///
/// @param[in]     hChiSession        Handle of the CHI driver session.
/// @param[in,out] phDataSource       Pointer to the handle of the created tag information.
/// @param[in]     pDataSourceConfig  Pointer to the configuration parameters of the data source.
///
/// @detdesc
/// This function allows the CHI node to create certain data services through CHI, for example, data services
/// for the gyroscope and accelerometer.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNGETDATASOURCE)(
    CHIHANDLE            hChiSession,
    CHIDATASOURCE*       phDataSource,
    CHIDATASOURCECONFIG* pDataSourceConfig);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNPUTDATASOURCE @endcond
///
/// @brief Puts back or deletes a data source handle. After the function returns, the data source handle becomes invalid.
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHIDATASOURCEHANDLE
///
/// @param[in] hChiSession        Handle of the CHI driver session.
/// @param[in] hDataSourceHandle  Handle of the data source.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNPUTDATASOURCE)(
    CHIHANDLE           hChiSession,
    CHIDATASOURCEHANDLE hDataSourceHandle);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNGETDATA @endcond
///
/// @brief Gets data from a data source
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHIDATASOURCEHANDLE \n
/// #CHIDATAREQUEST
///
/// @param[in]     hChiSession        Handle of the CHI driver session.
/// @param[in]     hDataSourceHandle  Handle of the data source.
/// @param[in]     pDataRequest       Pointer to the structure that defines the data request.
/// @param[in,out] pSize              Pointer to the size of the data.
///
/// @return Pointer to the data.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID* (*PFNGETDATA)(
    CHIHANDLE            hChiSession,
    CHIDATASOURCEHANDLE  hDataSourceHandle,
    CHIDATAREQUEST*      pDataRequest,
    UINT*                pSize);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNPUTDATA @endcond
///
/// @brief Puts data back to the data source.
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHIDATASOURCEHANDLE \n
/// #CHIDATAHANDLE
///
/// @param[in] hChiSession        Handle of the CHI driver session.
/// @param[in] hDataSourceHandle  Handle of the data source.
/// @param[in] hDataHandle        Handle of the data to be put back to the data source.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNPUTDATA)(
    CHIHANDLE            hChiSession,
    CHIDATASOURCEHANDLE  hDataSourceHandle,
    CHIDATAHANDLE        hDataHandle);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHIRELEASEFENCE @endcond
///
/// @brief Releases a created CHI fence.
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHIFENCEHANDLE
///
/// @param[in] hChiSession  Handle of the CHI session.
/// @param[in]              Handle of the fence to be released
///
/// @detdesc
/// If this fence was sent back to the CHI session, only the reference is decremented.
/// The actual destruction occurs when there is no other reference to it.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNCHIRELEASEFENCE)(CHIHANDLE hChiSession, CHIFENCEHANDLE);


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFCHINODEENTRY @endcond
///
/// @brief Entry point called by the CHI driver to initialize a custom node.
///
/// @datatypes
/// #CHINODECALLBACKS
///
/// @param[in,out] pNodeCallbacks  Pointer to the structure that defines the callbacks the CHI driver sends to the CHI node.
///                                The node must fill in these function pointers.
///
/// @detdesc
/// For the CHI driver to initialize the CHI node, every \<library\>.so must export this function.
/// @par
/// This function is called during initialization of the camera server, which occurs during a HAL process
/// start.
/// @par
/// In addition to communicating the necessary function pointers between the CHI driver and external nodes,
/// this function allows a CHI node to do any initialization work that it would typically do during process
/// initialization. The initialization work done here must not be specific to a session. Also, any variables
/// stored in the CHI node must be protected against multiple sessions accessing it at the same time.
///
/// @return None. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFCHINODEENTRY) (CHINODECALLBACKS* pNodeCallbacks);


#ifndef DOXYGEN_SHOULD_SKIP_THIS  /* temporarily hide duplicate function */
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// PFCHINODESETNODEINTERFACE
///
/// @brief Entry point called by the CHI driver to set a CHI node interface. Use this function for a custom node to call into a
///        CHI function.
///
/// @datatypes
/// #CHINODEINTERFACE
///
/// @param[in,out] pNodeInterface  Pointer to the structure that defines the function pointers used by the CHI node.
///
/// @return None. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFCHINODESETNODEINTERFACE) (CHINODEINTERFACE* pNodeInterface);
#endif /* DOXYGEN_SHOULD_SKIP_THIS */


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNPIPELINECREATED @endcond
///
/// @brief Deprecated. Use PFNPOSTPIPELINECREATE().
///
/// Entry point called by the CHI driver to notify a CHI node that a pipeline is created.
///
/// @datatypes
/// #CHIHANDLE
///
/// @param[in] hChiHandle  Handle of the CHI driver.
///
/// @detdesc
/// Currently, both %PFNPIPELINECREATED() and %PFNPOSTPIPELINECREATE() are called in the same functionality,
/// %PFNPOSTPIPELINECREATE(). However, preference is given to a %PFNPOSTPIPELINECREATE() call.
/// @par
/// %PFNPIPELINECREATED() is called only if %PFNPOSTPIPELINECREATE() is NULL.
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID(*PFNPIPELINECREATED) (CHIHANDLE hChiHandle);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNPOSTPIPELINECREATE @endcond
///
/// @brief Entry point called by the CHI driver to notify a CHI node that a pipeline is created.
///        Use this function for a custom node to call into CHI.
///
/// @datatypes
/// #CHIHANDLE
///
/// @param[in] hChiHandle            Handle of the CHI driver.
/// @param[in] maxRequestQueueDepth  Max Request queue depth
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNPOSTPIPELINECREATE) (
    CHIHANDLE hChiHandle,
    UINT32    maxRequestQueueDepth);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFCHINODESETNODEINTERFACE @endcond
///
/// @brief Entry point called by the CHI driver to set a CHI node interface. Use this function for a custom node to
///        call into a CHI function.
///
/// @datatypes
/// #CHINODEINTERFACE
///
/// @param[in,out] pNodeInterface  Pointer to the structure that defines the function pointers used by the CHI node.
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFCHINODESETNODEINTERFACE) (CHINODEINTERFACE* pNodeInterface);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHIACQUIRERESOURCES @endcond
///
/// @brief Acquires hardware resources. CHI nodes can use this hook to do any preparation and configuration.
///
/// @datatypes
/// #CHINODEACQUIREHWRESOURCEINFO
///
/// @param[in] pAcquireHwInfo  Pointer to the structure that defines the hardware information.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNCHIACQUIRERESOURCES)(CHINODEACQUIREHWRESOURCEINFO* pAcquireHwInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHIRELEASERESOURCES @endcond
///
/// @brief Releases hardware resources. CHI nodes can use this hook to do any preparation/configurations.
///
/// @datatypes
/// #CHINODERELEASEHWRESOURCEINFO
///
/// @param[in] pReleaseHwInfo  Pointer to the structure that defines the hardware information.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages})..
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNCHIRELEASERESOURCES)(CHINODERELEASEHWRESOURCEINFO* pReleaseHwInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHIPREPARESTREAMON @endcond
///
/// @brief Indicates that a stream is preparing to be set to the ON mode. CHI nodes can use this hook to perform any
///        preparation or configuration operations.
///
/// @datatypes
/// #CHINODEPREPARESTREAMONINFO
///
/// @param[in] pPrepareStreamOnInfo  Pointer to the structure that defines the preparation information.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNCHIPREPARESTREAMON)(CHINODEPREPARESTREAMONINFO* pPrepareStreamOnInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHIONSTREAMON @endcond
///
/// @brief Indicates that a stream is in the ON mode. A CHI node can use this hook to complete the stream ON operation for
///        the node.
///
/// @datatypes
/// #CHINODEONSTREAMONINFO
///
/// @param[in] pOnStreamOnInfo  Pointer to the structure that defines the stream information.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNCHIONSTREAMON)(CHINODEONSTREAMONINFO* pOnStreamOnInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHIONSTREAMOFF @endcond
///
/// @brief Indicates that a stream is in the OFF mode. A CHI node can use this hook to complete a stream OFF operation for
///        the node.
///
/// @datatypes
/// #CHINODEONSTREAMOFFINFO
///
/// @param[in] pOnStreamOffInfo  Pointer to the structure that defines the stream information.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNCHIONSTREAMOFF)(CHINODEONSTREAMOFFINFO* pOnStreamOffInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODEFLUSH @endcond
///
/// @brief Frees any resources that were allocated per request during a flush operation.
///
/// @datatypes
/// #CHINODEFLUSHREQUESTINFO
///
/// @param[in] pInfo  Pointer to the structure that defines the flush request information.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNNODEFLUSH)(CHINODEFLUSHREQUESTINFO* pInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODEFLUSHRESPONSEINFO @endcond
///
/// @brief Gets the worst-case response time for a flush call on an external node.
///
/// @datatypes
/// #CHINODERESPONSEINFO
///
/// @param[in,out] pInfo  Pointer to the structure that defines the request information.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNNODEFLUSHRESPONSEINFO)(CHINODERESPONSEINFO* pInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODEGETMAXEXECUTIONTIMEINFO @endcond
///
/// @brief Gets the max excution time for a job on an external node.
///
/// @datatypes
/// #CHINODEGETMAXEXECUTIONINFO
///
/// @param[in,out] pInfo  Pointer to the structure that defines the request information.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNNODEGETMAXEXECUTIONTIMEINFO)(CHINODEGETMAXEXECUTIONINFO* pInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODESETINPUTPORTBUFFERDELTA @endcond
///
/// @brief Sets the buffer delta value for an input port. The delta indicates which previous buffer is required for the
///        request.
///
/// @datatypes
/// #CHISETINPUTPORTBUFFERDELTAINFO
///
/// @param[in] pInfo  Pointer to the structure that defines the port information.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID(*PFNNODESETINPUTPORTBUFFERDELTA)(CHISETINPUTPORTBUFFERDELTAINFO* pInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNGETFLUSHINFO @endcond
///
/// @brief Queries for flush information.
///
/// @datatypes
/// #CHIHANDLE \n
/// #CHIFLUSHINFO
///
/// @param[in]     hChiSession  Handle of the CHI driver session.
/// @param[in,out] pFlushInfo   Pointer to the flush information (ID, progress, and so on).
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNGETFLUSHINFO)(
    CHIHANDLE     hChiSession,
    CHIFLUSHINFO* pFlushInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODEBUFFERMANAGERCREATE @endcond
///
/// @brief Creates a buffer manager for a CHI node.
///
/// @datatypes
/// #CHINodeBufferManagerCreateData
///
/// @param[in] pBufferManagerName  Pointer to the name of the buffer manager.
/// @param[in] pCreateData         Pointer to the structure used for creating the buffer manager.
///
/// @return Handle of the buffer manager.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CHIBUFFERMANAGERHANDLE (*PFNNODEBUFFERMANAGERCREATE)(
    const CHAR*                 pBufferManagerName,
    CHINodeBufferManagerCreateData* pCreateData);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODEBUFFERMANAGERDESTROY @endcond
///
/// @brief Destroys the buffer manager of a CHI node.
///
/// @datatypes
/// CHIBUFFERMANAGERHANDLE
///
/// @param[in] hBufferManager  Handle of the buffer manager.
///
/// @return None. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID (*PFNNODEBUFFERMANAGERDESTROY)(
    CHIBUFFERMANAGERHANDLE hBufferManager);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODEBUFFERMANAGERGETIMAGEBUFFER @endcond
///
/// @brief Gets an image buffer reference from a specified buffer manager handle.
///
/// @datatypes
/// CHIBUFFERMANAGERHANDLE
///
/// @param[in] hBufferManager  Handle of the buffer manager.
///
/// @detdesc    The image buffer will have a reference count of 1 after it is obtained.
/// @par
/// To release the reference count assigned by this function, the calling function is responsible for calling
/// PFNNODEBUFFERMANAGERRELEASEREFERENCE().
///
/// @return Handle of the image buffer.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CHINODEBUFFERHANDLE(*PFNNODEBUFFERMANAGERGETIMAGEBUFFER)(
    CHIBUFFERMANAGERHANDLE hBufferManager);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODEBUFFERMANAGERRELEASEREFERENCE @endcond
///
/// @brief Releases an image buffer reference from a specified image buffer.
///
/// @datatypes
/// CHIBUFFERMANAGERHANDLE \n
/// #CHINODEBUFFERHANDLE
///
/// @param[in] hBufferManager  Handle of the buffer manager.
/// @param[in] hImageBuffer    Handle of the image buffer.
///
/// @return Handle of the named module upon success. Otherwise, NULL upon a failure. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNNODEBUFFERMANAGERRELEASEREFERENCE)(
    CHIBUFFERMANAGERHANDLE hBufferManager,
    CHINODEBUFFERHANDLE    hImageBuffer);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNRELEASEINPUTPORT @endcond
///
/// @brief Releases an image buffer reference from a provided image buffer.
///
/// @datatypes
/// #CHIHANDLE
///
/// @param[in] hChiSession     Handle of the CHI driver session.
/// @param[in] inputPortIndex  Index of the input port.
/// @param[in] requestId       Unique ID of the request.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNRELEASEINPUTPORT)(
    CHIHANDLE hChiSession,
    UINT      inputPortIndex,
    UINT64    requestId);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODEGETRESOURCECOST @endcond
///
/// @brief Gets information about the resource cost for a CHI node.
///
/// @datatypes
/// #CHINODERESOURCECOSTINFO
///
/// @param[in] pResourceCostInfo  Pointer to the structure that defines the Resource Cost information.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNNODEGETRESOURCECOST)(
    CHINODERESOURCECOSTINFO* pResourceCostInfo);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNDUMPCORENODECONFIG @endcond
///
/// @brief Dumps the node configuration for a core.
///
/// @datatypes
/// #CHIHANDLE
///
/// @param[in] fd       File descriptor.
/// @param[in] indent   Number of spaces to indent.
/// @param[in] hHandle  Handle of the node session.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNDUMPCORENODECONFIG)(
    INT         fd,
    UINT32      indent,
    CHIHANDLE   hHandle);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHIGETCAMERAID @endcond
///
/// @brief Gets the ID of the current camera.
///
/// @datatypes
/// #CHIHANDLE
///
/// @param[in] hChiSession  Handle of the CHI driver session.
/// @param[in] pCameraId    Pointer to the camera ID.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNCHIGETCAMERAID)(
    CHIHANDLE               hChiSession,
    UINT32*                 pCameraId);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHNODETRIGGERSYSTEMEVENT @endcond
///
/// @brief Triggers a system event from a CHI node. This function notifies the pipeline of the node's information that
///        triggers the system event.
///
/// @datatypes
/// #CHIHANDLE \n
/// #CDKResult
///
/// @param[in] hChiSession    Handle of the CHI driver session.
/// @param[in] errorCode      Node-specific extended error code.
/// @param[in] isDumpOnly     Node to decide on dump only or recovery path.
/// @param[in] forceSigAbort  Flag that indicates whether the node is to force a sigabort during a fatal error.
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID(*PFNCHNODETRIGGERSYSTEMEVENT)(
    CHIHANDLE     hChiSession,
    CDKResult     errorCode,
    BOOL          isDumpOnly,
    BOOL          forceSigAbort);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHINODEFLUSHALL @endcond
///
/// @brief Flushes all pending requests and ensures that all dependencies, including forward-looking dependencies, are
///        cancelled.
///
/// @datatypes
/// #CHIHANDLE
///
/// @param[in] hChiSession  Handle of the CHI driver session.
///
/// @return None. @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef VOID(*PFNCHINODEFLUSHALL)(
    CHIHANDLE hChiSession);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHINODEGETPSMETAPORTGROUP @endcond
///
/// @brief Adds a PS metadata group for output ports.
///
/// @datatypes
/// #CHINODEPSMETAPORTGROUP
///
/// @param[in] pChiNodeGetPSMetaPortGroup  Pointer to the structure that defines the PS metadata information.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNCHINODEGETPSMETAPORTGROUP)(
    CHINODEPSMETAPORTGROUP* pChiNodePSMetaPortGroup);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond CHINODECOMPOSITEFENCEGROUP @endcond
///
/// @brief Gets composite fence group information for output ports.
///
/// @datatypes
/// #CHINODECOMPOSITEFENCEGROUP
///
/// @param[in] pChiNodeCompositeFenceGroup  Pointer to the structure that defines the composite fences information.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNCHINODEGETCOMPOSITEFENCEGROUP)(
    const CHINODECOMPOSITEFENCEGROUP** pChiNodeCompositeFenceGroup);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHIGETSTREAMINTENTMASK @endcond
///
/// @brief Gets the stream intent mask.
///
/// @datatypes
/// #CHIHANDLE
///
/// @param[in]  hChiSession    Handle of the CHI driver session.
/// @param[out] pStreamIntent  Pointer to the stream intent.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult(*PFNCHIGETSTREAMINTENTMASK)(
    CHIHANDLE               hChiSession,
    UINT32*                 pStreamIntent);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHINODEONSETUPREQUESTFORCHINODE @endcond
///
/// @brief Sets up ports for a new request (by default the ports are active).
///
/// @datatypes
/// #CHIHANDLE \n
/// #ChiNodeSetupRequestInput \n
/// #ChiNodeSetupRequestOutput
///
/// @param[in]  hNodeSession         Handle of the node for the current node instance.
/// @param[in]  pSetupRequestInfo    Information from the node wrapper to set up the ports.
/// @param[out] pSetupRequestOutput  Information for ports that are set up for the request.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNCHINODEONSETUPREQUESTFORCHINODE)(
    CHIHANDLE                       hNodeSession,
    const ChiNodeSetupRequestInput* pSetupRequestInfo,
    ChiNodeSetupRequestOutput*      pSetupRequestOutput);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHINODEONSETUPREQUESTINBACKWARDWALK @endcond
///
/// @brief Sets up port APIs called in context of a backward walk of a process request.
///
/// @param[in]  hNodeSession         Handle of the node for the current node instance.
/// @param[in]  pSetupRequestInfo    Information from the node wrapper to set up the ports.
/// @param[out] pSetupRequestOutput  Information for ports that are set up for the request.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*PFNCHINODEONSETUPREQUESTINBACKWARDWALK)(
    CHIHANDLE                       hNodeSession,
    const ChiNodeSetupRequestInput* pSetupRequestInfo,
    ChiNodeSetupRequestOutput*      pSetupRequestOutput);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNGETLOOKAHEADFRAMEDELAY @endcond
///
/// @brief The implementation for node to return lookAhead frameDelay if any
///
/// @param[in]  hNodeSession         Handle of the node for the current node instance.
///
/// @return frameDelay
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef UINT32 (*PFNGETLOOKAHEADFRAMEDELAY)(
    CHIHANDLE     hChiSession);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNNODEREQUESTINORDERREGISTRATION @endcond
///
/// @brief The implementation for node to register for inOrder request submission for final processSequence when the
///         output buffer is being bound to its output port.
///
/// @param[in]  hNodeSession         Handle of the node for the current node instance.
///
/// @return TRUE if register, FALSE otherwise
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef BOOL (*PFNNODEREQUESTINORDERREGISTRATION)(
    CHIHANDLE     hChiSession);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNFINALPROCESSSEQUENCEID @endcond
///
/// @brief The implementation for node to return the final processSequence when the output buffer is actually bound
///
/// @param[in]  hNodeSession         Handle of the node for the current node instance.
///
/// @return #FinalProcessSequenceID
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef INT32 (*PFNFINALPROCESSSEQUENCEID)(
    CHIHANDLE     hChiSession);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond PFNCHINODEBUFFERACCESSTYPE @endcond
///
/// @brief Gets the Node Buffer Access Type
///
/// @return NodeBufferAccessType
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef BufferAccessType (*PFNCHINODEBUFFERACCESSTYPE)();


/** @} */ /* end_addtogroup chi_node_functions */


/** @addtogroup chi_node_datatypes
@{ */

/// @brief Callback interface for CHI to call into custom nodes.
typedef struct /** @cond */ ChiNodeCallbacks /** @endcond */
{
    UINT32                              size;                       ///< Size of this structure, which is initially filled with
                                                                    ///  the size of the NodeCallbacks structure that the CHI
                                                                    ///  driver is using.
                                                                    ///
                                                                    ///  Mismatches in size are a warning to the CHI node that
                                                                    ///  the interface header used by the node does not match
                                                                    ///  the interface header used by CHI. A mismatch is not an
                                                                    ///  error condition because interfaces with the same minor
                                                                    ///  version number are binary-compatible.
                                                                    ///
                                                                    ///  A CHI node must not write data larger than this size
                                                                    ///  into pNodeCallbacks because the larger size corrupts
                                                                    ///  other data structures.
                                                                    ///
                                                                    ///  The CHI node is responsible for returning the size of
                                                                    ///  its NodeCallbacks structure in this field to CHI.

    UINT32                              majorVersion;               ///< Track the major version of the interface that CHI is
                                                                    ///  using.
                                                                    ///
                                                                    ///  If majorVersion does not match the majorVersion in use
                                                                    ///  by the CHI node, the interfaces are not binary
                                                                    ///  compatible and the CHI node entry fails.

    UINT32                              minorVersion;               ///< Track the minor version of the interface that CHI is
                                                                    ///  using.
                                                                    ///
                                                                    ///  If minorVersion does not match the minorVersion in use
                                                                    ///  by the CHI node, the mismatch is not an error
                                                                    ///  condition. Interfaces with the same minorVersion
                                                                    ///  number are binary-compatible.

    PFNNODEGETCAPS                      pGetCapabilities;           ///< Get the capabilities supported by the CHI node; the
                                                                    ///  node must fill this parameter.
                                                                    ///
                                                                    ///  The function returns the capabilities of the CHI node.

    PFNCHIQUERYVENDORTAG                pQueryVendorTag;            ///< Optional function used to get the vendor tags
                                                                    ///  supported by the CHI node. Fill this function pointer
                                                                    ///  if the CHI node is to export a vendor tag.

    PFNNODECREATE                       pCreate;                    ///< Mandatory function used to create an instance of the
                                                                    ///  CHI node. The CHI node must fill this parameter.
                                                                    ///
                                                                    ///  CHI calls this function to create a CHI node instance
                                                                    ///  when a topology is created.

    PFNNODEDESTROY                      pDestroy;                   ///< Mandatory function used to destroy an instance of the
                                                                    ///  CHI node. The CHI node must fill this parameter.
                                                                    ///
                                                                    ///  CHI calls this function to destroy a CHI node instance
                                                                    ///  when a topology is destroyed.

    PFNNODEQUERYBUFFERINFO              pQueryBufferInfo;           ///< Mandatory function called to query for input buffer
                                                                    ///  requirements.
                                                                    ///
                                                                    ///  The CHI node must fill this parameter.
                                                                    ///
                                                                    ///  CHI calls this function to query the input buffer
                                                                    ///  format (resolution and type) requirements from the CHI
                                                                    ///  node for a specific output format.

    PFNNODEFINALIZEBUFFERDIMENSIONS     pFinalizeBufferDimensions;  ///< Mandatory function called to set the buffer resolution.
                                                                    ///
                                                                    ///  The CHI node must fill this parameter.
                                                                    ///
                                                                    ///  CHI calls this function to set the buffer format
                                                                    ///  (resolution and type) for a specific CHI node instance.

    PFNNODECHECKDIMENSIONFORFORMATS     pCheckDimensionForFormats;  ///< Optional function called to check if format option can
                                                                    ///  live with the finalized resolution.
                                                                    ///
                                                                    ///  CHI calls this function to check if format option can
                                                                    ///  live with the finalized resolution and filter out the
                                                                    ///  unqualified format.

    PFNNODESETBUFFERINFO                pSetBufferInfo;             ///< Mandatory function called to set the buffer
                                                                    ///  properties.
                                                                    ///
                                                                    ///  The CHI node must fill this parameter.
                                                                    ///
                                                                    ///  CHI calls this function to set the buffer format
                                                                    ///  (resolution and type) for a specific CHI node instance.

    PFNNODEGETADVERTISEDOUTPUTFORMATS   pGetAdvertisedOutputFormats;///< CHI calls this function to get the output port
                                                                    ///  advertised formats of the specific CHI nodes.

    PFNNODEGETADVERTISEDINPUTFORMATS    pGetAdvertisedInputFormats; ///< CHI calls this function to get the input port
                                                                    ///  advertised formats of the specific CHI nodes.

    PFNNODEPROCREQUEST                  pProcessRequest;            ///< Mandatory function used to process a request by the
                                                                    ///  CHI node. The CHI node must fill this parameter.
                                                                    ///
                                                                    ///  CHI calls this function to enable the CHI node to do
                                                                    ///  the request processing.

    PFCHINODESETNODEINTERFACE           pChiNodeSetNodeInterface;   ///< Mandatory function used to set the CHI node interface
                                                                    ///  functions. The CHI node must fill this parameter.
                                                                    ///
                                                                    ///  CHI calls this function to set predefined CHI
                                                                    ///  interfaces that are required in the CHI node.

    PFNPIPELINECREATED                  pPipelineCreated;           ///< Deprecated.
                                                                    ///
                                                                    ///  The CHI driver uses this interface to notify a CHI
                                                                    ///  node that a specific pipeline is created.

    PFNPOSTPIPELINECREATE               pPostPipelineCreate;        ///< Notification that a pipeline was created.
    PFNCHIPREPARESTREAMON               pPrepareStreamOn;           ///< Notification that the pipeline is preparing for a
                                                                    ///  stream to start.
    PFNCHIONSTREAMON                    pOnStreamOn;                ///< Notification that the pipeline is receiving a stream.
    PFNCHIONSTREAMOFF                   pOnStreamOff;               ///< Notification that the pipeline is not receiving a
                                                                    ///  stream.
    PFNCHIACQUIRERESOURCES              pAcquireResources;          ///< Set up Acquire HW Resources for node.
    PFNCHIRELEASERESOURCES              pReleaseResources;          ///< Release hardware resources in the node.
    PFNNODEQUERYMETADATAPUBLISHLIST     pQueryMetadataPublishList;  ///< Mandatory function called to query the metadata list
                                                                    ///  that the CHI node published.
    PFNNODEFLUSH                        pFlushRequest;              ///< Free CHI node resources that were allocated for a
                                                                    ///  request.
    PFNNODEFLUSHRESPONSEINFO            pGetFlushResponse;          ///< Get the worst-case response time for a flush call.
    PFNNODEGETMAXEXECUTIONTIMEINFO      pGetMaxExecutionTime;       ///< Get the max execution time for a job.
    PFNNODEFILLPERREQUESTHWDATA         pFillHwdata;                ///< Fill memory with hardware data per a request.
    PFNNODESETINPUTPORTBUFFERDELTA      pSetInputPortBufferDelta;   ///< Set the delta value for the input port buffer.
    PFNNODEGETRESOURCECOST              pGetResourceCost;           ///< Get the actual resource cost.
    PFNODEFINALIZENODEINITIALIZE        pFinalizenodeinitialize;    ///< Notify the pipeline to prepare for a stream on command.
    PFNDUMPCORENODECONFIG               pDumpCoreNodeConfig;        ///< Dump the node configuration for a core.
    PFNCHINODEFLUSHALL                  pFlushAll;                  ///< Flush all requests.
    PFNCHINODEGETPSMETAPORTGROUP        pGetPSMetaGroup;            ///< Get the PS metadata group.
    PFNCHINODEONSETUPREQUESTFORCHINODE  pOnSetupRequestForChiNode;  ///< Set up a port for a request.
    PFNCHINODEGETCOMPOSITEFENCEGROUP    pGetCompositeFenceGroup;    ///< Gets composite fence group information for output
                                                                    ///  ports.

    PFNCHINODEONSETUPREQUESTINBACKWARDWALK  pOnSetupRequestInBackwardWalk;    ///< Set up a port in the context
                                                                              ///  of a backward walk of a process request.
    PFNGETLOOKAHEADFRAMEDELAY               pGetLookAheadFrameDelay;          ///< return frame delay
    PFNNODEREQUESTINORDERREGISTRATION       pNodeRequestInOrderRegistration;  ///< node to register for inOrder request
                                                                              ///  submission for final processSequence
                                                                              ///  when the output buffer is being bound
                                                                              ///  to its output port request.
    PFNFINALPROCESSSEQUENCEID               pGetFinalProcessSequenceId;       ///< chinode to return the final processSequence
                                                                              ///  when the output buffer is actually bound
    PFNCHINODEBUFFERACCESSTYPE              pNodeBufferAccessType;            ///< SOC Specific Buffer Access Type
} CHINODECALLBACKS;

/// @brief Interface for custom node to call into CHI.
typedef struct /** @cond */ ChiNodeInterface /** @endcond */
{
    UINT32                               size;                              ///< Size of this structure.
                                                                            ///
                                                                            ///  Mismatches in size are a warning to the CHI
                                                                            ///  node that the interface header used by the
                                                                            ///  node does not match the interface header used
                                                                            ///  by CHI.

    UINT32                               majorVersion;                      ///< Track the major version of the interface that
                                                                            ///  CHI is using.
                                                                            ///
                                                                            ///  If the major version does not match the major
                                                                            ///  version that the CHI node uses, the interfaces
                                                                            ///  are not binary compatible and the CHI node
                                                                            ///  entry fails.

    UINT32                               minorVersion;                      ///< Track the minor version of the interface that
                                                                            ///  CHI is using.
                                                                            ///
                                                                            ///  If the minor version does not match the minor
                                                                            ///  version that the CHI node uses, the mismatch
                                                                            ///  is not an error condition.
                                                                            ///
                                                                            ///  Interfaces with the same minorVersion number
                                                                            ///  are binary compatible. The CHI node is
                                                                            ///  expected to restrict the functionality and
                                                                            ///  data structure accordingly.

    PFNCHIGETLOGICALCAMERAID             pGetLogicalCameraID;               ///< Get the logical camera ID.
    PFNCHIGETMETADATA                    pGetMetadata;                      ///< Get data from a list of metadata information
                                                                            ///  that is already published.
    PFNCHISETMETADATA                    pSetMetadata;                      ///< Set the data for a list of tags (Android or
                                                                            ///  vendor) into the metadata.
    PFNCHIGETVENDORTAGBASE               pGetVendorTagBase;                 ///< Get the base assigned to a vendor tag.
    PFNCHINODEPROCREQUESTDONE            pProcessRequestDone;               ///< Called by the CHI node into CHI to report the
                                                                            ///  status of a process capture request.
    PFNCHINODEPROCMETADATADONE           pProcessMetadataDone;              ///< Report the status for metadata.
    PFNCHICREATEFENCE                    pCreateFence;                      ///< Create a CHI fence.
    PFNCHIRELEASEFENCE                   pReleaseFence;                     ///< Release a CHI fence created by pCreateFence.
    PFNWAITCHIFENCEASYNC                 pWaitFenceAsync;                   ///< Called by the CHI node to asynchronously wait
                                                                            ///  on a CHI fence.
    PFNSIGNALFENCE                       pSignalFence;                      ///< Called by the CHI node to signal a CHI fence.
    PFNGETFENCESTATUS                    pGetFenceStatus;                   ///< Get the status of a CHI fence signal.
    PFNQUERYDATASOURCECAPABILITY         pQueryDataSourceCapability;        ///< Query for the capabilities of a data source.
    PFNGETDATASOURCE                     pGetDataSource;                    ///< Get the supported data source, such as a data
                                                                            ///  service for the gyroscope or accelerometer.
    PFNGETDATA                           pGetData;                          ///< Get data from a data source.
    PFNPUTDATASOURCE                     pPutDataSource;                    ///< Put back (destroys) a data source handle that
                                                                            ///  was obtained from pGetDataSource.
    PFNPUTDATA                           pPutData;                          ///< Put data back to the data source.
    PFNCACHEOPS                          pCacheOps;                         ///< Validates or cleans the cache.
    PFNCPUACCESS                         pCPUAccess;                        ///< CPU Access Type Begin/End, Read/Write.
    PFNGETFLUSHINFO                      pGetFlushInfo;                     ///< Get the session flush information: is flush in
                                                                            ///  state, was the last request ID flushed, and
                                                                            ///  so on.
    PFNNODEBUFFERMANAGERCREATE           pCreateBufferManager;              ///< Create an image buffer manager.
    PFNNODEBUFFERMANAGERDESTROY          pDestroyBufferManager;             ///< Destroy an image buffer manager.
    PFNNODEBUFFERMANAGERGETIMAGEBUFFER   pBufferManagerGetImageBuffer;      ///< Obtains an image buffer from an image buffer
                                                                            ///  manager.
    PFNNODEBUFFERMANAGERRELEASEREFERENCE pBufferManagerReleaseReference;    ///< Release an image buffer reference.
    PFNCHIGETMULTICAMDYNAMICMETABYCAMID  pGetMultiCamDynamicMetaByCamId;    ///< Get the dynamic data from the metadata if the
                                                                            ///  metadata is already published for multicamera.
    PFNCHIGETSTATICMETADATA              pGetStaticMetadata;                ///< Get the static metadata.
    PFNCHIPSGETSUPPORTEDMETADATALIST     pGetSupportedPSMetadataList;       ///< Get the supported port-specific metadata.
    PFNCHIPSGETMETADATA                  pGetPSMetadata;                    ///< Get the port-specific data from the metadata
                                                                            ///  if the metadata is already published.
    PFNCHIPSSETMETADATA                  pSetPSMetadata;                    ///< Set the port-specific metadata.
    PFNCHIPSPUBLISHMETADATA              pPublishPSMetadata;                ///< Publish the port-specific metadata.
    PFNCHIISPSMETADATAPUBLISHED          pIsPSMetadataPublished;            ///< Indicate whether the port-specific metadata
                                                                            ///  was published.
    PFNCHIGETMETADATA                    pGetDataList;                      ///< Get the data from the list of metadata if the
                                                                            ///  metadata is already published.
    PFNCHIREGISTERRESOURCE               pRegisterResource;                 ///< Register a resource that is managed by the
                                                                            ///  resource manager.
    PFNCHIUNREGISTERRESOURCE             pUnregisterResource;               ///< Unregister a resource.
    PFNCHIRESERVERESOURCE                pReserveResource;                  ///< Reserve a resource that is managed by the
                                                                            ///  resource manager.
    PFNCHIUNRESERVERESOURCE              pUnreserveResource;                ///< Unreserve a resource.
    PFNDUMPCORENODECONFIG                pDumpCoreNodeConfig;               ///< Dump the node configuration for a node.
    PFNFORCEDRQTOREMOVEDEPENDENCIES      pForceDRQtoRemoveDependencies;     ///< Force DRQ to remove dependencies of a
                                                                            ///  node.
    PFNRELEASEINPUTPORT                  pReleaseInputPort;                 ///< Release an input port.
    PFNCHIGETCAMERAID                    pGetCameraID;                      ///< Get the camera ID.
    PFNCHNODETRIGGERSYSTEMEVENT          pNodeTriggerSystemEvent;           ///< Trigger a system event.
    PFNCHIGETSTREAMINTENTMASK            pGetStreamIntentMask;              ///< Get the stream intent mask.
    PFNCHINODEDISABLEINPUTOUTPUTLINK     pDisableInputOutputLink;           ///< Disable a CHI node's input or output port
                                                                            ///  link.
    PFNABORTNCSASYNCREQUESTS             pAbortNCSAsyncRequests;            ///< Terminate an NCS asynchronous request
                                                                            ///  queue for the current sensor and signal all
                                                                            ///  fences with error.
    PFNISMETADATAPRESENTINPUBLISHLIST    pIsMetadataPresentInPublishList;   ///< Checks if the tag defined by tagId is present
                                                                            ///  in the Per-Frame publishlist
    UINT32                               reserved[6];                       ///< Padding reserved for future use. Must be
                                                                            ///  initialized to NULL.
                                                                            ///  @newpagetable
} CHINODEINTERFACE;

/** @} */ /* end_addtogroup chi_node_datatypes */

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond ChiNodeEntry @endcond
///
/// @ingroup chi_node_entry_function
///
/// @brief Entry point called by the CHI driver to initialize a custom CHI node.
///
/// @datatypes
/// #CHINODECALLBACKS
///
/// @param[in,out] pNodeCallbacks  Pointer to the structure that defines callbacks for the CHI driver to send to the CHI
///                                node. The node must fill in these function pointers.
///
/// @detdesc
/// For driver to initialize the CHI node, this function must be exported by every \<library\>.so.
/// @par
/// This function is called during camera server initialization, which occurs when the HAL process starts.
/// In addition to communicating the necessary function pointers between CHI and the external nodes, this
/// function allows a CHI node to do any initialization work that it would typically do during process
/// initialization.
/// @par
/// Any work the CHI node does here must not be specific to a session. Any variables stored in the CHI node
/// must be protected from multiple sessions accessing it at the same time.
///
/// @return None.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CDK_VISIBILITY_PUBLIC VOID ChiNodeEntry(
    CHINODECALLBACKS* pNodeCallbacks);


#pragma pack(pop)

#ifdef __cplusplus
}
#endif // __cplusplus

#endif // CHINODE_H
