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

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file chincsdefs.h
/// @brief Define Qualcomm Technologies, Inc. NCS related structure definition
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef CHINCSDEFS_H
#define CHINCSDEFS_H

#ifdef __cplusplus

#include "chicommon.h"
#include "camxncsdefs.h"
static const UINT32 ChiNodeMaxRates     = 10;
static const UINT32 ChiMaxSensorModes   = 8;

extern "C"
{
#endif // __cplusplus
#pragma pack(push, CDK_PACK_SIZE)

/** @addtogroup chi_ncs_datatypes
@{ */

/// @brief Sensor orientation of  non-image sensor (NIS) sensor.
enum NISSensorOrientation
{
    NISSensorRear       = 0,     ///< rear sensor
    NISSensorFront      = 1,     ///< front sensor
    NISSensorRearAux    = 2,     ///< rear aux sensor
    NISSensorFrontAux   = 3,     ///< front aux sensor
    NISSensorExternal   = 4,     ///< external sensor
};

/// @brief Data request structure for non-camera services (NCS).
typedef struct /** @cond */ChiNCSDataRequest/** @endcond */
{
    size_t        size;              ///< Size of this structure.

    /// @brief Timing information for the request.
    struct
    {
        UINT64         tStart;       ///< Starting time of the request.
        UINT64         tEnd;         ///< Starting time of the request.
    } windowRequest;

    CHIFENCEHANDLE     hChiFence;    ///< Fence handle.
    UINT               numSamples;   ///< Number of samples requested. If this field is set to greater than 0, it is considered
                                     ///  to be a sample request.
    CDKResult          result;       ///< Result of this request. The caller reads the result synchronously.
} CHINCSDATAREQUEST;

/// @brief Contains information about the NIS Sensor mode.
typedef struct /** @cond */ ChiNISSensorMode /** @endcond */
{
    UINT            width;               ///< Width of the result buffer.
    UINT            height;              ///< Height of the result buffer.
    UINT            frameRate;           ///< Result buffer frame rate of the result buffer.
    UINT            outputWidth;         ///< Output width.
    UINT            outputHeight;        ///< Output height.
    UINT            outputBitsPerPixel;  ///< Output format bits per pixel.
    CHIBUFFERFORMAT outputFormat;        ///< Output format of buffer.
    CHIDATASPACE    outputColorSpace;    ///< Data space for the use case output stream.
} CHINISSENSORMODE;

/// @brief This defines the Chi accessible data QSEE source capabilities.
typedef struct /** @cond */ChiQSEEDataSourceCaps/** @endcond */
{
    size_t        size;                          ///< Size of this structure.
    ChiDataSource type;                          ///< CHI data souce type.
    FLOAT         resolutions[ChiNodeMaxRates];  ///< Array of supported resolutions.
    UINT          numResolutions;                ///< Number of valid resolutions.
    FLOAT         rates[ChiNodeMaxRates];        ///< Array of supported sampling rates.
    UINT          numRates;                      ///< Number of valid sampling rates.

    BOOL          isValid;                       ///< Indicates whether this structure is valid.
                                                 ///
                                                 ///  @valuesbul
                                                 ///  - 0 -- FALSE
                                                 ///  - 1 -- TRUE @tablebulletend
} CHIQSEEDATASOURCECAPS;

/// @brief Defines the QSEE2 source capabilities for CHI-accessible data.
typedef struct /** @cond */ChiQSEE2DataSourceCaps/** @endcond */
{
    size_t        size;                             ///< Size of this structure.
    ChiDataSource type;                             ///< CHI data souce type.
    FLOAT         resolutions[ChiNodeMaxRates];     ///< Array of supported resolutions.
    UINT          numResolutions;                   ///< Number of valid resolutions.
    FLOAT         rates[ChiNodeMaxRates];           ///< Array of supported sampling rates.
    UINT          numRates;                         ///< Number of valid sampling rates.
    FLOAT         lowLatencyRates[ChiNodeMaxRates]; ///< Array of sensor rates.
    UINT          numLowLatencyRates;               ///< Number of valid low latency rates.

    BOOL          isValid;                          ///< Indicates whether this structure is valid.
                                                    ///
                                                    ///  @valuesbul
                                                    ///  - 0 -- FALSE
                                                    ///  - 1 -- TRUE @tablebulletend
} CHIQSEE2DATASOURCECAPS;

/// @brief Defines the capabilities of the NIS source in the CHI-accessible data .
typedef struct /** @cond */ChiNISDataSourceCaps/** @endcond */
{
    size_t                  size;                               ///< Size of this structure.
    ChiDataSource           type;                               ///< Type of CHI data souce.
    INT                     sensorId;                           ///< Identifier of the NIS sensor.
    NISSensorOrientation    orientation;                        ///< NIS sensor orientation.
    UINT                    numOfSensorModes;                   ///< Number of valid sensor modes.
    ChiNISSensorMode        sensorModes[ChiMaxSensorModes];     ///< Array of available sensor modes.

    BOOL                    isValid;                            ///< Indicates whether this structure is valid.
                                                                ///
                                                                ///  @valuesbul
                                                                ///  - 0 -- FALSE
                                                                ///  - 1 -- TRUE @tablebulletend
} CHINISDATASOURCECAPS;

/// @brief Defines the CHI QSEE source configuration.
typedef struct /** @cond */ChiQSEEDataSourceConfig/** @endcond */
{
    size_t          size;           ///< Size of this structure.
    ChiDataSource   sourceType;     ///< Type of CHI data source.

    BOOL            operationMode;  ///< Indicates the operation mode of the sensor.
                                    ///
                                    ///  @valuesbul
                                    ///  - 0 -- Batched
                                    ///  - 1 -- Streaming @tablebulletend

    FLOAT           samplingRate;   ///< Sampling rate of this sensor.
    UINT            reportRate;     ///< Report rate of this sensor.
} CHIQSEEDATASOURCECONFIG;

/// @brief Defines the CHI NIS data source configuration.
typedef struct /** @cond */ ChiNISDataSourceConfig /** @endcond */
{
    size_t              size;               ///< Size of this structure.
    UINT                camIdOfClient;      ///< Camera ID of the client.
    ChiDataSource       sourceType;         ///< Type of CHI data source.
    INT                 sensorId;           ///< Identifier for the sensor.
    INT                 clientType;         ///< Client type for the non-image sensor (NIS) sensor.
    UINT                sensorModeIndex;    ///< Sensor mode index.
    INT                 priority;           ///< Configuration priority.

    BOOL                isDefer;            ///< Indicates whether configuration is deferred.
                                            ///
                                            ///  @valuesbul
                                            ///  - 0 -- FALSE
                                            ///  - 1 -- TRUE @tablebulletend

    BOOL                isSecureMode;       ///< Indicates whether the data source is in Secure mode.
                                            ///
                                            ///  @valuesbul
                                            ///  - 0 -- FALSE
                                            ///  - 1 -- TRUE @tablebulletend
} CHINISDATASOURCECONFIG;

/// @brief Defines the data source configuration for the CHI data OIS.
typedef struct /** @cond */ ChiOISDataSourceConfig /** @endcond */
{
    size_t          size;           ///< Size of this structure.
    ChiDataSource   sourceType;     ///< CHI Data Source type.
    INT             sensorId;       ///< Identifier for the camera. of this sensor.
    FLOAT           samplingRate;   ///< Sampling rate of this sensor.
} CHIOISDATASOURCECONFIG;

typedef CamX::NISClientType         ChiNISClientType;

/// @brief Priorities for NCS configuration.
enum NCSConfigPriority
{
    NCSConfigBestEffort = 0,        ///< Best effort configuration. Can be reconfigured by any client.
    NCSConfigCritical,              ///< Critical configuration. Can only be reconfigured by NCSConfigMustMatch.
    NCSConfigMustMatch,             ///< Configuration cannot be reconfigured by any client.
    NCSConfigPriorityMax,           ///< Maximum configurations.
};

/// @brief Defines the depth of the CHI data.
struct ChiNCSDataDepth
{
    INT     sensorId;       ///< Identifier for the camera sensor.
    UINT64  timestamp;      ///< Timestamp of this sample.
    UINT    dataSize;       ///< Size of the image data.
    VOID*   pData;          ///< Pointer to the image data for the CAMX client.
    VOID*   pChiBuffer;     ///< Pointer to the image data for CHI node client.
};

/// @brief Defines the data source configuration for the CHI data OFD.
typedef struct /** @cond */ ChiOFDDataSourceConfig /** @endcond */
{
    size_t          size;                   ///< Size of this structure.
    ChiDataSource   sourceType;             ///< CHI Data Source type.
    INT             logicalCameraId;        ///< Logical camera sensor id
    INT             physicalCameraId;       ///< Physical camera sensor id
    BOOL            isLogicalCamProvider;   ///< Is provider for the whole logical camera
} CHIOFDDATASOURCECONFIG;

typedef CamX::NCSDataGyro             ChiNCSDataGyro;
typedef CamX::NCSDataOIS              ChiNCSDataOis;
typedef CamX::NCSDataAccel            ChiNCSDataAccel;
typedef CamX::NCSDataGravity          ChiNCSDataGravity;
typedef CamX::NCSDataMagnetometer     ChiNCSDataMagnetic;
typedef CamX::NCSDataAISegCatMap      ChiNCSDataAISegCatMap;

/** @} */ /* end_addtogroup chi_ncs_types */

#pragma pack(pop)

#ifdef __cplusplus
}
#endif // __cplusplus

#endif // CHINCSDEFS_H
