////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Copyright (c) 2017, 2019-2020, 2024 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"

static const UINT32 ChiNodeMaxRates     = 10;
static const UINT32 ChiMaxSensorModes   = 4;

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

/// @brief This defines the Chi data request structure for non camera services.
typedef struct ChiNCSDataRequest
{
    size_t        size;              ///< Size of this structure
    struct
    {
        UINT64         tStart;       ///< Start time of the request
        UINT64         tEnd;         ///< End time of the request
    } windowRequest;
    CHIFENCEHANDLE     hChiFence;    ///< Chifence handle
    UINT               numSamples;   ///< Number of samples requested, if more than 0 it is considered a sample request
    CDKResult          result;       ///< Result of this request, read synchronously by the caller
} CHINCSDATAREQUEST;

/// @brief CHI NIS sensor mode
typedef struct ChiNISSensorMode
{
    UINT            width;              ///< Width
    UINT            height;             ///< Height
    UINT            frameRate;          ///< Frame rate
    UINT            outputWidth;        ///< Output width
    UINT            outputHeight;       ///< Output height
    UINT            outputBitsPerPixel; ///< Output format bits per pixel
    CHIBUFFERFORMAT outputFormat;       ///< Output format
    CHIDATASPACE    outputColorSpace;   ///< Output color space
} CHINISSENSORMODE;

/// @brief This defines the Chi accessible data QSEE source capabilities
typedef struct ChiQSEEDataSourceCaps
{
    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;                       ///< is Valid flag indicating validity of ths structure.
} CHIQSEEDATASOURCECAPS;

/// @brief This defines the Chi accessible data NIS source capabilities
typedef struct ChiNISDataSourceCaps
{
    size_t              size;                               ///< Size of this structure
    ChiDataSource       type;                               ///< Chi data souce type
    INT                 sensorId;                           ///< NIS sensor id
    UINT                numOfSensorModes;                   ///< Number of valid sensor modes
    ChiNISSensorMode    sensorModes[ChiMaxSensorModes];     ///< Available sensor modes
    BOOL                isValid;                            ///< is Valid flag indicating validity of ths structure.
} CHINISDATASOURCECAPS;

/// @brief This defines the Chi data non camera service data source qsee config structure
typedef struct ChiQSEEDataSourceConfig
{
    size_t          size;           ///< Size of this structure
    ChiDataSource   sourceType;     ///< CHI Data Source type
    BOOL            operationMode;  ///< batched mode(0) / streaming mode(1)
    FLOAT           samplingRate;   ///< Sampling rate of this sensor
    UINT            reportRate;     ///< Report rate of this sensor
} CHIQSEEDATASOURCECONFIG;

/// @brief This defines the Chi data non camera service data source NIS config structure
typedef struct ChiNISDataSourceConfig
{
    size_t              size;               ///< Size of this structure
    UINT                camIdOfClient;      ///< Camera ID of client
    ChiDataSource       sourceType;         ///< CHI Data Source type
    INT                 sensorId;           ///< CameraId of this sensor
    INT                 clientType;         ///< Client type
    UINT                sensorModeIndex;    ///< Sensor mode index
    INT                 priority;           ///< Config priority
    BOOL                isDefer;            ///< Is defer
    BOOL                isSecureMode;       ///< Is secure mode
} CHINISDATASOURCECONFIG;

/// @brief This defines the Chi data OIS data source config structure
typedef struct ChiOISDataSourceConfig
{
    size_t          size;           ///< Size of this structure
    ChiDataSource   sourceType;     ///< CHI Data Source type
    INT             sensorId;       ///< CameraId of this sensor
    FLOAT           samplingRate;   ///< Sampling rate of this sensor
} CHIOISDATASOURCECONFIG;

/// @brief This enumerates the NIS(Non Image Sensor) sensor types available.
enum NISClientType
{
    ClientAF,         ///< AF as Client for NCS
    ClientAEC,        ///< AEC as Client for NCS
    ClientAWB,        ///< AWB as Client for NCS
    ClientFramework,  ///< Framework as Client for NCS. Should not selected by customers.
                      ///  This is for Android FWK external triggered depth usecase
    ClientChinode,    ///< Chi node as Client for NCS
    ClientMax,        ///< Max Clients
};

/// @brief NIS config priority
enum NCSConfigPriority
{
    NCSConfigBestEffort = 0,        ///< Config best effort, can be reconfigured by any client
    NCSConfigCritical,              ///< Config critical, can only be reconfigured by MustMatch
    NCSConfigMustMatch,             ///< Config must match, can not be reconfigured by any client
    NCSConfigPriorityMax,           ///< Config max
};

/// @brief Chi depth data structure
struct ChiNCSDataDepth
{
    INT     sensorId;       ///< Camera id of this sensor
    UINT64  timestamp;      ///< Timestamp of this sample
    UINT    dataSize;       ///< Data size
    VOID*   pData;          ///< Image data for camx client
    VOID*   pChiBuffer;     ///< Image data for chi node client
};

/// @brief Chi gyro data structure
struct ChiNCSDataGyro
{
    FLOAT  x;           ///< Angular velocity about x axis.
    FLOAT  y;           ///< Angular velocity about y axis.
    FLOAT  z;           ///< Angular velocity about z axis.
    UINT64 timestamp;   ///< Timestamp of this sample
};

/// @brief Chi accelerometer data structure
struct ChiNCSDataAccel
{
    FLOAT  x;           ///< Acceleration about the x-axis.
    FLOAT  y;           ///< Acceleration about the y-axis.
    FLOAT  z;           ///< Acceleration about the z-axis.
    UINT64 timestamp;   ///< Timestamp of this sample
};

/// @brief NCS magnetometer data structure
struct ChiNCSDataMagnetic
{
    FLOAT  x_uncalib;       ///< Magnetic field about the x-axis.
    FLOAT  y_uncalib;       ///< Magnetic field about the y-axis.
    FLOAT  z_uncalib;       ///< Magnetic field about the z-axis.
    FLOAT  x_bias;          ///< Magnetic field about the x-axis.
    FLOAT  y_bias;          ///< Magnetic field about the y-axis.
    FLOAT  z_bias;          ///< Magnetic field about the z-axis.
    UINT64 timestamp;       ///< Timestamp of this sample
};

/// @brief NCS OIS data structure
struct ChiNCSDataOis
{
    FLOAT  x;          ///< Acceleration about the x-axis
    FLOAT  y;          ///< Acceleration about the y-axis
    FLOAT  z;          ///< Acceleration about the z-axis
    FLOAT  w;          ///< Acceleration about the w-axis
    UINT64 timestamp;  ///< Timestamp of this sample
};

/// @brief Defines the NCS gravity data.
struct ChiNCSDataGravity
{
    FLOAT  x;         ///< Gravity value along the x-axis.
    FLOAT  y;         ///< Gravity value along the y-axis.
    FLOAT  z;         ///< Gravity value along the z-axis.
    FLOAT  lx;        ///< Linear acceleration along the x-axis.
    FLOAT  ly;        ///< Linear acceleration along the y-axis.
    FLOAT  lz;        ///< Linear acceleration along the z-axis.
    UINT64 timestamp; ///< Timestamp of this sample.
};

#pragma pack(pop)

#ifdef __cplusplus
}
#endif // __cplusplus

#endif // CHINCSDEFS_H
