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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  chinisusecaseinterface.h
/// @brief CHI NIS(non-image sensor) nis usecase interface declarations
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef CHINISUSECASEINTERFACE_H
#define CHINISUSECASEINTERFACE_H

#include <assert.h>
#include "camxcdktypes.h"
#include "chxdefs.h"
#include "camera3.h"

class NISUsecaseDevice;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief NIS usecase interface APIs
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/// @brief Callback functions implemented in the NISUsecaseDevice called by the CHI override module
struct ChiNISUsecaseOps
{
    /// @brief Defines the prototype for the callback method to send completed capture results to the NISUsecaseInterface.
    VOID (*process_nis_result)(
        NISUsecaseDevice*,
        const camera3_capture_result_t*);

    /// @brief Defines the prototype for the asynchronous notification callback method from to the NISUsecaseInterface.
    VOID (*process_nis_message)(
        NISUsecaseDevice*,
        const camera3_notify_msg_t*);
};

/// @NISUsecase private data used between CHI override module & NISUsecaseDevice
struct NISUsecaseInfo
{
    VOID*              pUsecase;          ///< Per usecase class asigned by CHI override module
    UsecaseId          usecaseId;         ///< Usecase id asigned by CHI override module
    BOOL               internalTrigger;   ///< If the streamconfig is internally triggered
    ChiNISUsecaseOps   NISUsecaseCb;      ///< Callback functions implemented in the NISUsecaseDevice
    NISUsecaseDevice*  pData;             ///< Pointer to NISUsecaseDevice instance used for NISUsecase callback functions
};

/// @NISUsecaseInterface callback data which contain the result buffer from nisusecase
typedef struct ChiNISUsecaseIntfCbData
{
    VOID*  pUsecase;        ///< Handle of the nisusecase
    UINT   physCameraId;    ///< Physical cameraId of the nisusecase
    UINT   frameNumber;     ///< Frame number of the result buffer
    UINT   format;          ///< Result buffer format
    VOID*  pData;           ///< Result buffer handle
    UINT   dataSize;        ///< Result buffer data length
    UINT64 timestamp;       ///< Result buffer time stamp
} CHINISUSECASEINTFCBDATA;

typedef VOID (*PFNCLIENTDATACB)(VOID* pClient, CHINISUSECASEINTFCBDATA* pCbData);

/// @NISUsecase create data used for create nisusecase
typedef struct ChiNISUsecaseCreateData
{
    UINT sensorId;              ///< Physical cameraId of the nisusecase
    UINT width;                 ///< Result buffer width
    UINT height;                ///< Result buffer height
    UINT bitsPerPixel;          ///< Result buffer bpp
    UINT dataType;              ///< Result buffer data type
    UINT frameRate;             ///< Result buffer frame rate
    UINT outputFormat;          ///< Result buffer format
    UINT outputColorSpace;      ///< Result buffer coloer space
    BOOL isExternalTrigger;     ///< Indicate nisusecase is FWK external-trigger
    INT  logicCamIdOfClient;    ///< Logical cameraId of the client
} CHINISUSECASECREATEDATA;

typedef struct ChiNISUsecaseIntfCreateData
{
    VOID*            pClient;
    PFNCLIENTDATACB  pFnClientDataCb;
} CHINISUECASEINTFCREATEDATA;

typedef VOID* (*PFNCREATENISUSECASEINTERFACE)(CHINISUECASEINTFCREATEDATA* pCreateData);

typedef VOID* (*PFNTRIGGERUSECASECREATION)(CHINISUSECASECREATEDATA* pCreateData, VOID* pIntfInstance);

typedef CDKResult (*PFNTRIGGERUSECASESTREAMON)(VOID* pUsecase, VOID* pIntfInstance);

typedef CDKResult (*PFNTRIGGERUSECASESTREAMOFF)(VOID* pUsecase, VOID* pIntfInstance);

typedef CDKResult (*PFNTRIGGERUSECASERECOVERY)(VOID* pUsecase, VOID* pIntfInstance);

typedef CDKResult (*PFNTRIGGERUSECASEDEACTIVATE)(VOID* pUsecase, VOID* pIntfInstance);

typedef CDKResult (*PFNDESTROYNISUSECASEINTERFACE)(VOID* pIntfInstance);

typedef struct ChiNISUsecaseInterfaceOps
{
    UINT32                          size;                           ///< Size of this structure
    PFNCREATENISUSECASEINTERFACE    pCreateNISUsecaseInterface;     ///< Create nis usecase interface instance
    PFNTRIGGERUSECASECREATION       pTriggerUsecaseCreation;        ///< Trigger usecase creation
    PFNTRIGGERUSECASESTREAMON       pTriggerUsecaseStreamon;        ///< Trigger usecase streamon
    PFNTRIGGERUSECASESTREAMOFF      pTriggerUsecaseStreamoff;       ///< Trigger usecase streamoff
    PFNTRIGGERUSECASERECOVERY       pTriggerUsecaseRecovery;        ///< Trigger usecase recovery
    PFNTRIGGERUSECASEDEACTIVATE     pTriggerUsecaseDeactivate;      ///< Trigger usecase deactivate
    PFNDESTROYNISUSECASEINTERFACE   pDestroyNISUsecaseInterface;    ///< Destroy nis usecase interface instance
} CHINISUSECASEINTERFACEOPS;


typedef VOID (*PCHXNISUSECASEINTERFACEENTRY)(CHINISUSECASEINTERFACEOPS* pNISUsecaseInterfaceOps);

#endif // CHINISUSECASEINTERFACE_H
