/* SPDX-License-Identifier: LGPL-2.1-only OR BSD-3-Clause */
/******************************************************************************
 *
 * This file is provided under a dual license.  When you use or
 * distribute this software, you may choose to be licensed under
 * version 2.1 of the GNU Lesser General Public License
 * ("LGPLv2.1 License") or BSD License.
 *
 * LGPLv2.1 License
 *
 * Copyright(C) 2019 MediaTek Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html for more
 * details.
 *
 * BSD LICENSE
 *
 * Copyright(C) 2019 MediaTek Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name of the copyright holder nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *****************************************************************************/

/*-----------------------------------------------------------------------------
 *
 * $Author: xiaojun.zhu $
 * $Date: 2015/08/08 $
 * $RCSfile: api_notify.h,v $
 * $Revision: #2 $
 *
 *---------------------------------------------------------------------------*/
#ifndef _API_NOTIFY_H_
#define _API_NOTIFY_H_


/** Function prototype for CC callback. */
typedef void (*NPTV_PFN_CC_NFY) (UINT8 u1Path,
                                 UINT8 u1data1, UPTR u1data2, UPTR u1field);

/** Function prototype for CC2X callback. */
typedef void (*NPTV_PFN_CC2X_NFY) (UINT8 u1Path,
                                  UPTR u4NumPktAvail, UPTR u4VbiReadPtr);

/** Function prototype for TTX callback. */
typedef void (*NPTV_PFN_TTX_NFY) (UINT8 u1Path,
                                  UPTR u4NumPktAvail, UPTR u4VbiReadPtr);

/** Function prototype for WSS callback. */
typedef void (*NPTV_PFN_WSS_NFY) (UINT8 u1Path, UINT32 u4Data);

/** Function prototype for VPS callback. */
typedef void (*NPTV_PFN_VPS_NFY) (UINT8 au1Data[]);

/** Function prototype for TYPE B WSS callback. */
typedef void (*NPTV_PFN_TYPE_B_WSS_NFY) (UINT8 u1Path, UPTR au1Data[]);

/** Function prototype for TTX Info callback. */
typedef void (*NPTV_PFN_VBI_INFO_NFY) (BOOL fgAVFieldIVS);

typedef void (*NPTV_PFN_VGA_AUTO_NFY) (UINT16 ui2_id, BOOL fgSuccess);

typedef void (*NPTV_PFN_VGA_AUTOCOLOR_NFY) (UINT16 ui2_id, BOOL fgSuccess);

typedef void (*NPTV_PFN_TVD_MVCHG_NFY) (UINT8 u1Path, BOOL fgStatus);

typedef void (*NPTV_PFN_SIG_NFY_FCT) (void *pvNfyTag,
                                      UINT32 u4SigStatus, UINT32 u4SigSrc);

typedef void (*NPTV_PFN_SCART_NFY)(UINT8 u1Source, UINT8 u1Status);

/** Resolution change callback function
*/
typedef VOID (*NPTV_PFN_RESOLUTION_CHG_NFY)(
    UINT8 u1Path,
    UINT8 u1SigState
);

/** S-first finish callback function
*/
typedef VOID (*NPTV_PFN_COMP_SIG_CHG_NFY)(
    UINT8 ui1_path,
    UINT8	ui4_drv_status
);

/** color system callback function
*/
typedef VOID (*NPTV_PFN_COLOR_SYSTEM_NFY)(
    UINT8 u1Path,
    UINT8 u1SigState
);

/** Atuo detect source callback function
*/
typedef VOID (*NPTV_PFN_AUTO_DETECT_SRC_NFY)(
    UINT8 u1SrcIndex, 
    UINT8 u1SrcStatus
);

/** Tuner analog tvd notify
*/
typedef VOID (*NPTV_PFN_TUNER_ANA_TVD_NFY)(
    UINT8 u1SrcIndex, 
    UINT8 u1SrcStatus
);

typedef void (*NPTV_PFN_OUT_SYNC)(void);

typedef struct _NPTV_SIG_NFY_INFO_T_
{
    void *pvTag;                /* pull mode only */
    NPTV_PFN_SIG_NFY_FCT pfSigNfy;      /* pull mode only */

} NPTV_SIG_NFY_INFO_T;

#ifdef  DISABLE_NPTV_NOTIFY
#define fgApiSFirstSetup(u1Path,u1Src)	FALSE
#define vApiNotifySigChg( u1Path, u1SigState,u1ReportState)
#define vApiNotifyResolutionChg(u1Path, u1SigState)
#define vApiNotifyColorSystem(u1Path, u1SigState)
#define vApiNotifySFirst( u1Path, u1SigState)
#define vApiNotifyVGAAutoProgress(u1Path, u1Progress)
#define vApiNotifyAutoDone(u1Path,fgSuccess)
#define vApiNotifyAutoColorDone(u1Path, fgSuccess)
#define vApiNotifyMVChg(u1Path, fgSuccess)
#define vApiNotifyScartFastSwith(u1Scartid, u1FSState)
#define vAPiNotifyCCData( u1Path,  d1,  d2,  field)
#define vAPiNotifyCC2XData( u1Path,  u2PktsAvail, readptr)
#define vAPiNotifyTTXData( u1Path,  u2PktsAvail, readptr)
#define vAPiNotifyVPSData(au1Data);
#define vAPiNotifyEUWSSData(u1Path, u4data)
#define vAPiNotifyUSWSSData(u1Path, u4data)
#define vAPiNotifyTypeBWSSData(u1Path, au1Data)
#define vAPiNotifyVbiInfoData(BOOL)

//#elif  defined(CC_DRIVER_PROGRAM)
#else
//extern BOOL fgApiMonitorSetup(UINT8 u1Path, UINT8 u1Src);

/* general */
extern void vApiNotifySigChg(UINT8 u1Path, UINT8 u1SigState,
                             UINT8 u1ReportState);
extern void vApiNotifyResolutionChg(UINT8 u1Path, UINT8 u1SigState);

/* ATV related*/
extern void vApiNotifyColorSystem(UINT8 u1Path, UINT8 u1SigState);

/* input monitor notify*/
extern void vApiNotifySFirst(UINT8 u1Path, UINT8 u1SigState);

#ifdef  SUPPORT_AV_COMP_AUTO
/* input monitor notify*/
extern void vApiNotifyAVCOMPAuto(UINT8 u1Path, UINT8 u1SigState);
#endif

/* VGA/Ypbpr related*/
//#ifdef CC_DRIVER_PROGRAM
extern void vApiNotifyVGAAutoProgress(UINT8 u1Path, UINT8 u1Progress);
//#else
//#define vApiNotifyVGAAutoProgress(u1Path, u1Progress)
//#endif
extern void vApiNotifyAutoDone(UINT8 u1Path, BOOL fgSuccess);
extern void vApiNotifyAutoColorDone(UINT8 u1Path, BOOL fgSuccess);
extern void vApiNotifyMVChg(UINT8 u1Path,BOOL fgStatus);
/*auto source detect*/
#ifdef CC_SOURCE_AUTO_DETECT
extern void vApiNotifyAutoDetectSource(UINT8 u1SrcIndex, UINT8 u1SrcStatus);
#endif

/* non-path related*/
extern void vApiNotifyScartFastSwith(UINT8 u1Scartid, UINT8 u1FSState);

/* EU related*/
extern void vAPiNotifyCCData(UINT8 u1Path, UINT8 d1, UINT8 d2, UINT8 field);
extern void vAPiNotifyCC2XData(UINT8 u1Path, UINT8 u2PktsAvail, UINT32 readptr);
extern void vAPiNotifyTTXData(UINT8 u1Path, UINT8 u2PktsAvail, UINT32 readptr);

extern void vAPiNotifyVPSData(UINT8 au1Data[]);

extern void vAPiNotifyEUWSSData(UINT8 u1Path, UINT32 u4data);

extern void vAPiNotifyUSWSSData(UINT8 u1Path, UINT32 u4data);

extern void vAPiNotifyTypeBWSSData(UINT8 u1Path, UPTR au1Data[]);

extern void vAPiNotifyVbiInfoData(BOOL fgAVFieldIVS);
#endif


//#ifdef CC_DRIVER_PROGRAM
/**
 * @brief Register TTX callback function
 * @param pfnFct: TTX callback function
 * @retval 0 is fail, 1 is success
 */
EXTERN INT32 NPTV_VBI_SetTtxNfy(const NPTV_PFN_TTX_NFY pfnFct);

/**
 * @brief Register CC callback function
 * @param pfnFct: CC callback function
 * @retval 0 is fail, 1 is success
 */
EXTERN INT32 NPTV_VBI_SetCcNfy(const NPTV_PFN_CC_NFY pfnFct);

/**
 * @brief Register VPS callback function
 * @param pfnFct: VPS callback function
 * @retval 0 is fail, 1 is success
 */
EXTERN INT32 NPTV_VBI_SetVpsNfy(const NPTV_PFN_VPS_NFY pfnFct);

/**
 * @brief Register WSS callback function
 * @param pfnFct: WSS callback function
 * @retval 0 is fail, 1 is success
 */
EXTERN INT32 NPTV_VBI_SetWssNfy(const NPTV_PFN_WSS_NFY pfnFct);

/**
 * @brief Register USWSS callback function
 * @param pfnFct: USWSS callback function
 * @retval 0 is fail, 1 is success
 */
EXTERN INT32 NPTV_VBI_SetUsWssNfy(const NPTV_PFN_WSS_NFY pfnFct);

/**
 * @brief Register WSS callback function
* @param pfnFct: WSS callback function
* @retval 0 is fail, 1 is success
*/
EXTERN INT32 NPTV_VBI_SetTypeBWssNfy(const NPTV_PFN_TYPE_B_WSS_NFY pfnFct);

/**
 * @brief Register VBI Info callback function
 * @param pfnFct: VBI Info callback function 
 * @retval 0 is fail, 1 is success
 */
EXTERN INT32 NPTV_VBI_SetVbiInfoNfy(const NPTV_PFN_VBI_INFO_NFY pfnFct);

/**
 * @brief Register input video signal change callback function
 * @param pfnFct: input video signal decteion done callback function
 * @retval 0 is fail, 1 is success
 */
EXTERN INT32 NPTV_SetSigChgNfyFct(const NPTV_PFN_SIG_NFY_FCT pfnFct);

/**
 * @brief Register VgaAuto done callback function
 * @param pfnFct: VgaAuto done callback function
 * @retval 0 is fail, 1 is success
 */
EXTERN INT32 NPTV_SetVgaAutoNfy(const NPTV_PFN_VGA_AUTO_NFY pfnFct);

/**
 * @brief Register VgaAuto progress callback function
 * @param pfnFct: VgaAuto progress callback function
 * @retval 0 is fail, 1 is success
 */
EXTERN INT32 NPTV_SetVgaAutoNfyProgress(const NPTV_PFN_VGA_AUTO_NFY pfnFct);
/**
 * @brief Register AutoColor done callback function
 * @param pfnFct: AutoColor done callback function
 * @retval 0 is fail, 1 is success
 */
EXTERN INT32 NPTV_SetVgaAutocolorNfy(const NPTV_PFN_VGA_AUTOCOLOR_NFY pfnFct);

/**
 * @brief Register TVD/YPbPr Macrovision changed callback function
 * @param pfnFct: Macrovision changed callback function
 * @retval 0 is not MV, 1 is MV
 */
EXTERN INT32 NPTV_SetTvdMVChgNfy(const NPTV_PFN_TVD_MVCHG_NFY pfnFct);

/**
 * @brief Register SCART pin8 changed callback function
 * @param pfnFct: SCART pin8 changed callback function
 * @retval 0 is fail, 1 is success
 */
EXTERN INT32 NPTV_SetScartNfy(const NPTV_PFN_SCART_NFY pfnFct);

//#endif  // CC_DRIVER_PROGRAM

EXTERN INT32 NPTV_SetTunerAnaSigChgNfyFct(const NPTV_PFN_TUNER_ANA_TVD_NFY pfnFct);
EXTERN INT32 NPTV_SetResolutionChgNfy(const NPTV_PFN_RESOLUTION_CHG_NFY pfnFct);
EXTERN INT32 NPTV_SetTvdColorSystemNfy(const NPTV_PFN_COLOR_SYSTEM_NFY pfnFct);
EXTERN INT32 NPTV_SetCompSigChgNfy(const NPTV_PFN_COMP_SIG_CHG_NFY pfnFct);
EXTERN INT32 NPTV_SetTvdMVChgNfy(const NPTV_PFN_TVD_MVCHG_NFY pfnFct);
EXTERN INT32 NPTV_SetAutoDetectSrcNfy(const NPTV_PFN_AUTO_DETECT_SRC_NFY pfnFct);
EXTERN void vApiNotifyTunerAnaTvdSigChg(UINT8 u1SrcIndex, UINT8 u1SrcStatus);

#endif //_API_NOTIFY_H_
