/*
 *******************************************************************************
 *  Copyright (c) 2010-2022 VATICS(KNERON) Inc. All rights reserved.
 *
 *  +-----------------------------------------------------------------+
 *  | THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED |
 *  | AND COPIED IN ACCORDANCE WITH THE TERMS AND CONDITIONS OF SUCH  |
 *  | A LICENSE AND WITH THE INCLUSION OF THE THIS COPY RIGHT NOTICE. |
 *  | THIS SOFTWARE OR ANY OTHER COPIES OF THIS SOFTWARE MAY NOT BE   |
 *  | PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON. THE   |
 *  | OWNERSHIP AND TITLE OF THIS SOFTWARE IS NOT TRANSFERRED.        |
 *  |                                                                 |
 *  | THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT   |
 *  | ANY PRIOR NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY |
 *  | VATICS(KNERON) INC.                                             |
 *  +-----------------------------------------------------------------+
 *
 *******************************************************************************
 */
#ifndef VIDEO_SOURCE_CONFIG_H
#define VIDEO_SOURCE_CONFIG_H

#include <config_vi.h>
#include <config_ifp.h>

#define VMF_MOTIONPROCESS_STATUS_OUT_OF_BOUNDARY    0x8024000B

/*
 * A data structure for video source config
 */
typedef struct
{
	//! A data for video option number
	unsigned int dwViOptionNum;

	//! A pointer data for video option
	VMF_VI_OPTION_T* ptViOptions;

	//! A data for ifp option number
	unsigned int dwIfpOptionNum;

	//! A pointer data for ifp option
	VMF_IFP_OPTION_T* ptIfpOptions;
} VMF_VSRC_CONFIG_T;

/**
 * A structure for determine encoding spec of VSRC stream
 */
typedef struct
{
	unsigned int bEncH264; //! Specify if yuv420 buffer connect with H264 encode
	unsigned int bEncH265; //! Specify if yuv420 buffer connect with H265 encode
	unsigned int bEncJPEG; //! Specify if yuv420 buffer connect with MJPG encode
	unsigned int bOthers;  //! Specify if yuv420 buffer will use directly
} VMF_ENC_SPEC_T;

typedef void (*VMF_VSRC_INIT_FUNC) (unsigned int dwWidth, unsigned int dwHeight);
typedef void (*VMF_VSRC_VI_SIGNAL_FUNC) (unsigned int dwNoSignal);
typedef void (*VMF_VSRC_AE_STABLE_FUNC) (unsigned int bAeStable, unsigned int dwDiscardFrames);

/*
 * video source info flag
 */
typedef enum
{
	//! video source info flag: fec offset
	VMF_VSRC_INFO_FEC_OFFSET,

	//! video source info flag: pin prefix
	VMF_VSRC_INFO_PIN_PREFIX,

	//! video source info flag: stream size
	VMF_VSRC_INFO_STREAM_SIZE,

	//! video source info flag: ifp size
	VMF_VSRC_INFO_IFP_SIZE,

	//! video source info flag: video capture
	VMF_VSRC_INFO_VI_CAPTURE,

	//! video source info flag: resize stream
	VMF_VSRC_INFO_RESIZE_STREAM,

	//! video source info flag: is ifp output
	VMF_VSRC_INFO_IS_IFP_OUTPUT,

	//! video source info flag: ifp output pin
	VMF_VSRC_INFO_IFP_OUTPUT_PIN,

	//! video source info flag: sub smaple pin
	VMF_VSRC_INFO_IFP_SUB_SAMPLE_PIN,

	//! video source info flag: ifp sub ir pin
	VMF_VSRC_INFO_IFP_SUB_IR_PIN,

	//! video source info flag: ifp statistic pin
	VMF_VSRC_INFO_IFP_STATIS_PIN,

	//! video source info flag: is ssm shared
	VMF_VSRC_INFO_IS_SSM_SHARED,

	//! video source info flag: resource path
	VMF_VSRC_INFO_RESOURCE_PATH,

	//! video source info flag: check dual 360 resize
	VMF_VSRC_INFO_CHK_DUAL_RESIZE,

	//! video source info flag: isp motion detection totalblock
	VMF_VSRC_INFO_ISP_MD_TOTALBLOCKS,

	//! video source info flag: isp MRF coordinate check.
	VMF_VSRC_INFO_ISP_MD_COORDINATECHECK,

} VMF_VSRC_INFO_FLAG;

/*
 * A data structure for video source query info
 */
typedef struct
{
	//! A data for video source info flag
	VMF_VSRC_INFO_FLAG eInfoFlag;

	//! A data for stream index
	unsigned int dwStreamIdx;

	//! A data array for video source query info data
	unsigned int adwData[8];
} VMF_VSRC_QUERY_INFO_T;

/*
 * A data structure for video source resize stream
 */
typedef struct
{
	//! A data for channel number (range: 0 ~ 4)
	unsigned int dwChannelNum;

	//! A data array for resize stream width
	unsigned int dwWidth[VMF_MAX_RESIZE_NUM];

	//! A data array for resize stream height
	unsigned int dwHeight[VMF_MAX_RESIZE_NUM];

	//! A data array for resize stream stride
	unsigned int dwStride[VMF_MAX_RESIZE_NUM];
} VMF_VSRC_RESIZE_STREAM_INFO_T;

/*
 * A data structure for VI callback function rawdata buffer
 */
typedef struct
{
	//! A data for width of VI buffer
	unsigned int dwWidth;

	//! A data for height of VI buffer
	unsigned int dwHeight;

	//! A data for stride of VI buffer
	unsigned int adwStride[4];

	//! A pointer for VI rawdata buffer
	unsigned char* apbyViBuffer[4];
} VMF_VSRC_VI_BUFFER_RAWDATA_INFO_T;

typedef void (*VMF_VSRC_VI_RAWDATA_FUNC) (VMF_VSRC_VI_BUFFER_RAWDATA_INFO_T* pViBufferStruct);

/*
 * video source option flag
 */
typedef enum
{
	//! video source option: resume control
	VSRC_OPTION_RESUME_CONTROL,

	//! video source option: debug reserved
	VSRC_OPTION_RESUME_DEBUG,

	//! video source option: set AE callback
	VSRC_OPTION_AE_CALLBACK,

	//! video source option: set AES mode
	VSRC_OPTION_AES_MODE,

	//! video source option: set EIS enable/disable (Only availabled when isp option set to EIS mode)
	VSRC_OPTION_EIS_ENABLE,

    //! video source option: set EIS save data enable/disable (Only availabled when isp option set to EIS mode)
    VSRC_OPTION_EIS_SAVE_DATA_ENABLE,

	//! video source option: check AWB stable after resuming (0: Disable, 1: Enable)
	VSRC_OPTION_RESUME_CHECK_AWB,

	//! Ifp option: Set thermal mapping table
	VSRC_OPTION_THERMAL_MAPPING_TABLE,

    //! video source option: set EIS boundary check (0: Disable, 1: Enable)
	VSRC_OPTION_EIS_BOUNDARY_CHECK_SETTING
} VMF_VSRC_OPTION_FLAG_T;

/*
 * A data structure for video source option
 */
typedef struct
{
	//! A data for video source option flag
	VMF_VSRC_OPTION_FLAG_T eOptionFlag;

	//! A pointer data for configuration structure of video source option 
	unsigned int* pdwData;
} VMF_VSRC_OPTION_T;

/*
 * A data structure for EIS save data option
 */
typedef struct
{
    //! A flag for EIS save data. (0: Disable, 1: Enable)
    unsigned int dwOptionFlag;

    //! A pointer data for floder path 
    char* pszData;
} VMF_VSRC_EIS_DATA_OPTION_T;

/*
 * A data structure for resume control
 */
typedef struct
{
	//! A data for frame policy after resuming
	//! 0: Disable, 1~: Discard 1~ frames before AE stable (Maximun: 1~ frames)
	unsigned int dwResumeAeStable;

	//! A data for skip frames after resuming
	//! 0: No skip frame, 1~: Discard 1~ frames than do checking dwResumeAeStable
	unsigned int dwResumeSkipFrames;
} VMF_VSRC_RESUME_CONTROL_T;

/*
 * A data structure for AE stable callback
 */
typedef struct
{
	//! A data for AE stable callback
	VMF_VSRC_AE_STABLE_FUNC fnAeStableCallback;
} VMF_VSRC_AE_CALLBACK_T;

typedef void (*VMF_VSRC_EIS_STATUS_CALLBACK_FUNC) (unsigned int dwEisStatus);
#endif
