////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2018-2022, 2024 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file chieisdefs.h
/// @brief Define Qualcomm Technologies, Inc. EIS proprietary data for defining internal data structures
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef CHIEISDEFS_H
#define CHIEISDEFS_H
#include "camxcdktypes.h"

#ifdef __cplusplus

extern "C"
{
#endif // __cplusplus


/// @brief Data structures that are exposed to OEM must be packed to have the expected layout.
#pragma pack(push, CDK_PACK_SIZE)

static const CHAR* VendorTagSectionEISLookAheadConfig = "org.quic.camera.eislookahead"; ///< Lookahead EIS config vendor tag section
static const CHAR* VendorTagNameEISLookAheadConfig    = "EISLookAheadConfig";           ///< Lookahead EIS config vendor tag name

static const CHAR* VendorTagSectionEISRealTimeConfig = "org.quic.camera.eisrealtime"; ///< RealTime EIS config vendor tag section
static const CHAR* VendorTagNameEISRealTimeConfig    = "EISRealTimeConfig";           ///< RealTime EIS config vendor tag name

#define MAX_SIZEOF_BUFF_DIS 13568
#define VIDEO4KWIDTH        3840
#define VIDEO4KHEIGHT       2160
#define VIDEO8KWIDTH        7680
#define DISEXTRABUFFERFPS   30
// Vendor Tag size for transform_matrix[(MAX_IS_DG_NUM_VERTICES) * NUM_DG_MATRIX_ELEMENTS]
// (65 x 97 x 2) +2 = 12612
// Extra +2 size is for accomodating number of rows and columns in the VendorTag
#define TMATRIX_SIZE 12612

#define ChiNodeEISDG     1
#define ChiNodeLDCZOOM   2
#define ChiNodeEISDGLDC  3

/// @brief Structure Stabilization Margins to be set to the ICA or GPU
struct StabilizationMargin
{
    UINT32 widthPixels;  ///< Margins on the width in pixels
    UINT32 heightLines;  ///< Margins on the height in pixels
};

/// @brief Structure Request Margins during buffer negotiation
struct MarginRequest
{
    FLOAT widthMargin;   ///<Request margins on the width in percentage (Eg. 0.2 for 20%)
    FLOAT heightMargin;  ///<Request margins on the height in percentage (Eg. 0.1 for 10%)
};

struct DISMVStats
{
    uint32_t  cvp_mv_image_width;
    uint32_t  cvp_mv_image_height;
    float     cvp_alignment_matrix[9];
    uint32_t  cvp_alignment_matrix_confidence;
    uint32_t  cvp_alignment_matrix_model_type;
    uint32_t  buff_size_bytes;
    uint8_t   buff[MAX_SIZEOF_BUFF_DIS];
};

/// @brief Structure MOFAlignment Warp matrices
struct MOFAlignment
{
    bool      eis_mof_enable;                      // Enable perspective matrices
    uint32_t  eis_mof_image_width;                 // Perspective transform defined on width
    uint32_t  eis_mof_image_height;                // Perspective transform defined on height
    uint32_t  eis_alignment_matrix_transform_type; // Type of perspective transform
    uint32_t  eis_alignment_matrix_confidence;     // Perspective transform confidence parameter
    uint32_t  eis_mof_numRows;                     // Number of rows in array
    uint32_t  eis_mof_numColumns;                  // Number of columns in array
    float     eis_mof_alignment_matrix[9];         // 2-dimensional array of perspective transform matrices
};

/** EIS OIS operation mode */
enum EISOISMode
{
    eisOisModeInvalid         = 0,        /**< Output OIS mode is invalid and should be ignored by CamX node,
                                            *   in case previous decision exists in the system use it
                                          */
    eisOisModeCenter          = 1,        /**< OIS mode should be switched to center */
    eisOisModeAutomatic       = 2         /**< OIS mode should be switched to automatic operation mode */
};

struct EISOISModeData
{
    EISOISMode    eisOisMode;
    UINT32        sensorIndex;
};

/**< Scene types enum */
typedef enum SceneTYPE
{
    IsSceneTripod     = 0,    /**< Device is mounted on tripod, without user is touching the device at all */
    IsSceneHandheld   = 1,    /**< Device is hand held, while user is trying to be as steady is possible */
    IsSceneWalking    = 2,    /**< Device is held while the person is walking in normal phase */
    IsSceneRunning    = 3,    /**< Device is held while the person is running (light running) */
    IsScenePanning    = 4,    /**< Panning is done in at least on direction */
    IsStrongPanning   = 5,    /**< Strong panning is done at least on one direction  */

    IsSceneOther      = 6,    /**< All other use-cases */

    IsSceneNumOfSceneTypes,   /**< Invalid value, must be the last member */
    IsSceneInvalid    = IsSceneNumOfSceneTypes,
}SceneTYPE;

/**< Scene types data structure */
struct SceneDetection
{
    SceneTYPE  shortSceneType;
    uint8_t    shortIsPanning[3]; /**< In case panning was detected contains the pan direction
                                    *       0: yaw
                                    *       1: pitch
                                    *       2: roll
                                    */
    SceneTYPE  longSceneType;
    uint8_t    longIsPanning[3]; /**< In case panning was detected contains the pan direction
                                    *       0: yaw
                                    *       1: pitch
                                    *       2: roll
                                    */

};

/// @brief Control for EIS Horizon Leveling
typedef struct EISHorizonLevelControl
{
    BOOL    isEnabled;          // Indicate if Horizon Leveling is enabled
    FLOAT   maxRollLevelingDeg; // Control the max degree of Horizon Leveling
} EISHorizonLevelControl;

/// @brief Motion Vector Domain
enum MotionVectorDomain
{
    UndistortedImageDomain   = 0, ///< Undistorted Image Domain
    DistortedImageDomain     = 1, ///< Distorted Image Domain
    NoMotionVectorDomain     = 2, ///< If DIS is disabled, Domain will be none.
};
  
struct InputSizeOption
{
    UINT32           minW;        ///< Min width that the node would want on its input buffer
    UINT32           minH;        ///< Min height that the node would want on its input buffer
    UINT32           maxW;        ///< Max width that the node would want on its input buffer
    UINT32           maxH;        ///< Max height that the node would want on its input buffer
    UINT32           optimalW;    ///< Optimal width that the node would want on its input buffer
    UINT32           optimalH;    ///< Optimal height that the node would want on its input buffer
};

#pragma pack(pop)

#ifdef __cplusplus
}
#endif // __cplusplus

#endif // CHIIPEDEFS_H
