/**
* Copyright(c) 2011 Sunmedia Technologies - All Rights Reserved.
*
* @file al_dvb_monitor.c
*
* @brief this file defines dvb monitor function.
*
* The file supports the dvb monitor functions by used for app layer.
* The dvb monitor check tuner signal changed, if signale changed notify application dispose.
* also check program state changed, get stream info from PE, change stream scramble, service locked and data update.
*
*/

/**<header files*/
#include <sys/ioctl.h>
#include "ai_debug_config.h"
#include "mid_playback.h"
#include "mid_dvbmon.h"
#include "mid_siutil_dvb.h"
#include "ai_dvb_monitor.h"
#include "ai_psi_monitor.h"
#include "al_fw.h"
#include "kmf_ioctl.h"
#include "drv_tuner_external.h"
#include "ap_extern.h"
#ifdef CONFIG_DVB_SYSTEM_DVBS_SUPPORT
#include "mid_sat_antenna.h"
#endif

#ifdef __cplusplus
	extern "C"{
#endif

/**<Macro define*/

#if AL_DVB_MONITOR_DEBUG_FLAG
	#define DVB_MONITOR_DEBUG_MSG(fmt, arg...) \
	do { \
		UMFDBG(0,"[Debug]%s: %d Line ", __FUNCTION__, __LINE__); \
		UMFDBG(0,fmt, ##arg); \
	} while(0)
#else
	#define DVB_MONITOR_DEBUG_MSG(fmt, arg...);
#endif

#if AL_DVB_MONITOR_ERROR_FLAG
	#define DVB_MONITOR_ERROR_MSG(fmt, arg...) \
	do { \
		UMFDBG(0,"[Error]%s: %d Line ", __FUNCTION__, __LINE__); \
		UMFDBG(0,fmt, ##arg); \
	} while(0)
#else
	#define DVB_MONITOR_ERROR_MSG(fmt, arg...);
#endif

#define DVBMON_SEND_MSG(CallBk, Msg, Parm)		\
{\
	if(CallBk != al_null) \
	{\
		CallBk(Msg, Parm);\
	}\
}


/* mean 2000ms */
#define AL_DVBMON_STREAM_CHECK_TIMES			(2500/MID_DVBMON_THREAD_PERIOD_IDLE)

/**<Global Variables*/
static al_uint8 g_bSignalStatus = AL_DVB_MONITOR_VALUE_INVAILED; /**<signal status record, al_false: no signale, al_true: good signal*/
static al_bool g_bParentLock = al_false; /**<prarent lock status record, al_false: not lock, al_true: lock*/
static al_bool g_bLastParentLock = al_false; /**<last prarent lock status record, al_false: not lock, al_true: lock*/
static AI_pfDVBMonCallback g_pfDvbMonCallbks = al_null;
static al_bool g_bDvbMonInited = al_false;
#ifdef CONFIG_DVB_SYSTEM_DVBS_SUPPORT
static al_uint8 g_bForceMotor = al_true;
#endif
static al_uint8 g_bCheckStreamTimer = 0;

static al_uint8 g_FE_IsSignal_OK = al_false;
static al_uint8 g_StreamDataStatus = AL_DVB_MONITOR_VALUE_INVAILED;
static al_uint8 g_bStreamStatus = AL_DVB_MONITOR_VALUE_INVAILED;
#ifdef EPG_REPLACE
static al_uint8 g_EPGReplaceTimer = 0;
#endif

/**<Function define*/
static al_void _AI_DVB_Monitor_ResetState(al_void)
{
	g_bParentLock = al_false;
	g_bLastParentLock = al_false;
	g_bSignalStatus = AL_DVB_MONITOR_VALUE_INVAILED;
#ifdef CONFIG_DVB_SYSTEM_DVBS_SUPPORT
	g_bForceMotor = al_true;
#endif
	g_bStreamStatus = AL_DVB_MONITOR_VALUE_TRUE;
	g_bCheckStreamTimer = 0;
#ifdef EPG_REPLACE
	if (AL_PSI_Monitor_CheckState(AL_PSIMONITOR_STATE_EPG_REPLACED, al_null) != al_true)
	{
		g_EPGReplaceTimer = 0;
	}
#endif
}

static al_void _AI_DVB_Monitor_TimerEventCheck(al_uint8 u8Cnt100ms)
{
#if 0
	static al_uint8 u8Counter = 0;
	static al_int iSecond = 0;

	u8Counter += u8Cnt100ms;
	if(u8Counter >= 10)
	{
		u8Counter=0;
		iSecond++;
		if(iSecond >= 0x7fffffff)
		{
			iSecond=0;
		}
		AI_PSI_Monitor_TimerEventCheck(iSecond);
	}
#else
	static al_int iMSecond = 0;

	iMSecond++;
	if(iMSecond >= 0x7fffffff)
	{
		iMSecond=0;
	}
	AI_PSI_Monitor_TimerEventCheck(iMSecond);
#ifdef EPG_REPLACE
	g_EPGReplaceTimer++;
	if (g_EPGReplaceTimer%10 == 0 && g_EPGReplaceTimer > 100)//10s
	{
		AI_PSI_Monitor_EPG_ReplaceCheck();
	}
#endif
#endif
}

#ifdef CONFIG_DVB_SYSTEM_DVBS_SUPPORT
static AL_Return_t _AI_DVB_Monitor_SetCurrServSetting(AL_RecHandle_t hCurProg)
{
	/* current frontend parameters */
	AL_RecHandle_t hTPHandle = AL_DB_INVALIDHDL;
	AL_RecHandle_t hNet = AL_DB_INVALIDHDL;
    SDBNetworkInfo_t stNetInfo;
    AL_MultiplexDetail_t stTPInfo;

	hTPHandle = hCurProg;

	if (AL_SUCCESS != AL_DB_GetRecord(AL_DB_REQ_GETPARENT, AL_DBTYPE_DVB_S, AL_RECTYPE_DVBMULTIPLEX, &hTPHandle))
	{
		DVB_MONITOR_ERROR_MSG("Get current TP handle error.\n");
		return AL_FAILURE;
	}

	if (AL_DB_INVALIDHDL != hTPHandle)
	{
		hNet = hTPHandle;
		if (AL_SUCCESS != AL_DB_GetRecord(AL_DB_REQ_GETPARENT, AL_DBTYPE_DVB_S, AL_RECTYPE_DVBNETWORK, &hNet))
		{
			DVB_MONITOR_ERROR_MSG("Get current Net handle error.\n");
			return AL_FAILURE;
		}
	}

	if (AL_DB_INVALIDHDL != hNet)
	{
		if (AL_SUCCESS != AL_DB_QueryDetail(hNet, &stNetInfo))
		{
			DVB_MONITOR_ERROR_MSG("Get current Net info error.\n");
			return AL_FAILURE;
		}
	}

	/* set Satellite setting according to the current service handle */
	MID_SatCtrl_SetCurrentSatelliteInfo(SATINFO_ALL,0,&stNetInfo);

    MID_Playback_ConnectSatellite(g_bForceMotor);

    AL_DB_QueryDetail(hTPHandle, &stTPInfo);
	MID_SatCtrl_Unicable_Connect(MID_SatCtrl_GetIfFrequency(stTPInfo.stDVBSMultiplex.usFreqM), stTPInfo.stDVBSMultiplex.ucSkew);

	return AL_SUCCESS;
}
#endif

static AL_Return_t _AI_DVB_Monitor_SignalReconnect(al_void)
{
#ifdef CONFIG_DVB_SYSTEM_DVBS_SUPPORT
	AL_RecHandle_t hCurProg = AL_DB_INVALIDHDL;
	AL_DB_EDBType_t eDBType = AL_DBTYPE_MAX;

	if ((MID_SUCCESS != MID_PlaybackGetCurProgHandle(al_null, &hCurProg))
		|| (hCurProg == AL_DB_INVALIDHDL))
	{
		DVB_MONITOR_ERROR_MSG("Get current program handle error.\n");
		return AL_FAILURE;
	}

	if (AL_SUCCESS != AL_DB_GetRecordType(hCurProg, &eDBType, al_null))
	{
		DVB_MONITOR_ERROR_MSG("Get current active db type error.\n");
		return AL_FAILURE;
	}

    if (eDBType == AL_DBTYPE_DVB_S)
	{
		_AI_DVB_Monitor_SetCurrServSetting(hCurProg);
	}
#endif

	return AL_SUCCESS;
}

static al_int _AI_DVB_Monitor_SignalCallback(al_void *pData)
{
	al_uint16 wSignalState = *(al_uint16 *)pData;

	if (wSignalState == SIGNAL_GOOD)
	{
        if (g_FE_IsSignal_OK == 0xff)//signal unstable
        {
            g_bSignalStatus = AL_DVB_MONITOR_VALUE_TRUE;
        }
        else if (g_StreamDataStatus == al_true)
        {
			g_bSignalStatus = AL_DVB_MONITOR_VALUE_TRUE;
		}
        else
		{
            g_bSignalStatus = AL_DVB_MONITOR_VALUE_INVAILED;
        }

        if (
#ifdef DEMUX_CONTROL_TEST
            (MID_PlaybackGetState() == TRUE) && 
#endif
            (MID_PlaybackGetActiveVidHandle() == INVALID_HANDLE) && (MID_PlaybackGetActiveAudHandle(al_false) == INVALID_HANDLE))
        {
            g_bSignalStatus = AL_DVB_MONITOR_VALUE_TRUE;
        }
		g_FE_IsSignal_OK = al_true;
		DVBMON_SEND_MSG(g_pfDvbMonCallbks, AI_DVB_MONITOR_TUNER_LOCKED, 0);
	}
	else if (wSignalState == SIGNAL_BAD)
	{
		g_bSignalStatus = AL_DVB_MONITOR_VALUE_FALSE;
        g_FE_IsSignal_OK = al_false;
		DVBMON_SEND_MSG(g_pfDvbMonCallbks, AI_DVB_MONITOR_TUNER_UNLOCKED, 0);
		AI_PSI_Monitor_TimerEventClear((1<<AI_PSIMONITOR_TIMER_SERVICE_ADD)|(1<<AI_PSIMONITOR_TIMER_SERVICE_REMOVE)|
			(1<<AI_PSIMONITOR_TIMER_SERVICE_UPDATE));
    }
	else if (wSignalState == SIGNAL_RECONNECT)
	{
        g_FE_IsSignal_OK = al_false;
        g_bSignalStatus = AL_DVB_MONITOR_VALUE_FALSE;

		_AI_DVB_Monitor_SignalReconnect();

	}
    else if (wSignalState == SIGNAL_SERVICE_NOT_AVAILABLE)//service not available.
	{
        if (g_FE_IsSignal_OK == al_true)
        {
            g_bSignalStatus = AL_DVB_MONITOR_VALUE_TRUE;
        }
		g_StreamDataStatus = al_false;
        DVB_MONITOR_DEBUG_MSG("\n\n[%s]SIGNAL_SERVICE_NOT_AVAILABLE ======\n\n", __FUNCTION__);
        DVBMON_SEND_MSG(g_pfDvbMonCallbks, AI_DVB_MONITOR_STREAM_NO_DATA, 0);//discuss: we need add a Service not available event??
	}
    else if (wSignalState == SIGNAL_DEMUX_HAS_DATA)
	{
        if (g_FE_IsSignal_OK == al_true)
        {
            g_bSignalStatus = AL_DVB_MONITOR_VALUE_TRUE;
        }
        else
        {
            //demux Msg is ahead of frontend
            DVB_MONITOR_ERROR_MSG("[ERROR]demux Msg is ahead of frontend!!!\n");
            g_bSignalStatus = AL_DVB_MONITOR_VALUE_TRUE;
        }
		g_StreamDataStatus = al_true;
		DVBMON_SEND_MSG(g_pfDvbMonCallbks, AI_DVB_MONITOR_STREAM_HAS_DATA, 0);
	}
    else if (wSignalState == SIGNAL_DEMUX_NO_DATA)
	{
        if (g_FE_IsSignal_OK == al_true)
        {
            g_bSignalStatus = AL_DVB_MONITOR_VALUE_TRUE;
        }
        else
        {
            g_bSignalStatus = AL_DVB_MONITOR_VALUE_FALSE;
        }
		g_StreamDataStatus = al_false;
		DVBMON_SEND_MSG(g_pfDvbMonCallbks, AI_DVB_MONITOR_STREAM_NO_DATA, 0);
	}
    else if (wSignalState == SIGNAL_DEMUX_INVALID_DATA)
	{
        if (g_FE_IsSignal_OK == al_true)
        {
            g_bSignalStatus = AL_DVB_MONITOR_VALUE_TRUE;
        }
        else
        {
            g_bSignalStatus = AL_DVB_MONITOR_VALUE_FALSE;
        }
		g_StreamDataStatus = al_true;
		DVBMON_SEND_MSG(g_pfDvbMonCallbks, AI_DVB_MONITOR_STREAM_INVALID_DATA, 0);
	}
	else if (wSignalState == SIGNAL_DEMUX_UNSUPPORT_DATA)
	{
		if (g_FE_IsSignal_OK == al_true)
        {
            g_bSignalStatus = AL_DVB_MONITOR_VALUE_TRUE;
        }
        else
        {
            g_bSignalStatus = AL_DVB_MONITOR_VALUE_FALSE;
        }
		g_StreamDataStatus = al_true;
		DVBMON_SEND_MSG(g_pfDvbMonCallbks, AI_DVB_MONITOR_STREAM_UNSUPPORT_DATA, 0);
	}
	else if (wSignalState == SIGNAL_MONITOR_RESET)//reset
	{
        g_FE_IsSignal_OK = 0xff;//signal unstable
        g_bSignalStatus = AL_DVB_MONITOR_VALUE_TRUE;
		g_StreamDataStatus = AL_DVB_MONITOR_VALUE_INVAILED;
	}

	 DVB_MONITOR_DEBUG_MSG("\n\n[%s]wSignalState = 0x%x======g_FE_IsSignal_OK: %d, g_StreamDataStatus: %d, g_bSignalStatus: %d\n\n", __FUNCTION__, wSignalState,g_FE_IsSignal_OK,g_StreamDataStatus,g_bSignalStatus);
    return AL_SUCCESS;
}

static al_void _AI_DVB_Monitor_CheckParentalRating(al_void)
{
	al_bool bProgLocked = al_false;
	frmwrk_pfOpConext_t pfDVBMonGetContext = al_null;

	if(g_bSignalStatus == AL_DVB_MONITOR_VALUE_FALSE)
	{
		/*There is no signal*/
		return;
	}

	AL_FW_GetContextCb(&pfDVBMonGetContext);

	if (pfDVBMonGetContext != al_null)
	{
		pfDVBMonGetContext(FW_CONTEXT_TYPE_PARENTAL_LOCK_STATE , FW_CONTEXT_OP_TYPE_READ,
				(al_void *)&bProgLocked ,0);
	}

	if (g_bLastParentLock == al_false && bProgLocked == al_true)
	{
		g_bParentLock = al_true;
		g_bLastParentLock = g_bParentLock;
		DVBMON_SEND_MSG(g_pfDvbMonCallbks, AI_DVB_MONITOR_PARENTAL_LOCKED, 0);
	}
	else if (g_bLastParentLock == al_true && bProgLocked == al_false)
	{
		g_bParentLock = al_false;
		g_bLastParentLock = g_bParentLock;
		DVBMON_SEND_MSG(g_pfDvbMonCallbks, AI_DVB_MONITOR_PARENTAL_UNLOCKED, 0);
	}

    if (g_bParentLock == al_true && g_FE_IsSignal_OK == al_true && g_bSignalStatus != AL_DVB_MONITOR_VALUE_TRUE)
    {
        g_bSignalStatus = AL_DVB_MONITOR_VALUE_TRUE;
    }
}

static al_void _AI_DVB_Monitor_CheckSerNotAvailable(al_void)
{
	AL_RecHandle_t hCurrProgHdl = AL_DB_INVALIDHDL;
	UINT32 u32TvRadioType;
	DBServAttrib_t stProgAttrib;

	memset(&stProgAttrib, 0, sizeof(DBServAttrib_t));

	if ((MID_SUCCESS != MID_PlaybackGetCurProgHandle(&u32TvRadioType, &hCurrProgHdl))
		|| (hCurrProgHdl == AL_DB_INVALIDHDL))
	{
		DVB_MONITOR_DEBUG_MSG("Get current program handle error.\n");
		return;
	}

	if (AL_SUCCESS == AL_DB_QueryDetailFieldByName(hCurrProgHdl, (al_uint8 *)"stProgAttrib", (al_void *)&stProgAttrib))
	{
		/* modify for mantis 22241 */
		if ((stProgAttrib.svrtmp == al_true) && (u32TvRadioType == CDBI_RECTYPE_DVBTV) 
			&& (INVALID_HANDLE != MID_PlaybackGetActiveAudHandle(al_false)) && (INVALID_HANDLE == MID_PlaybackGetActiveVidHandle()))
		{
			g_bCheckStreamTimer = 0;
			g_bStreamStatus = AL_DVB_MONITOR_VALUE_INVAILED;
		}
		else if ((stProgAttrib.svrnotrun == al_true) || (stProgAttrib.svrtmp == al_true))
		{
			if (g_bStreamStatus != AL_DVB_MONITOR_VALUE_FALSE)
			{
				g_bCheckStreamTimer ++;
				if (g_bCheckStreamTimer > AL_DVBMON_STREAM_CHECK_TIMES)
				{
					if (g_bSignalStatus == AL_DVB_MONITOR_VALUE_INVAILED)
					{
						g_bSignalStatus = AL_DVB_MONITOR_VALUE_TRUE;
					}
					DVBMON_SEND_MSG(g_pfDvbMonCallbks, AI_DVB_MONITOR_STREAM_NO_DATA, 0);
					g_bStreamStatus = AL_DVB_MONITOR_VALUE_FALSE;
					g_bCheckStreamTimer = 0;
				}
			}
		}
		else if ((stProgAttrib.svrnotrun == al_false) && (stProgAttrib.svrtmp == al_false))
		{
			if (g_bStreamStatus == AL_DVB_MONITOR_VALUE_FALSE)
			{
				g_bCheckStreamTimer ++;
				if (g_bCheckStreamTimer > AL_DVBMON_STREAM_CHECK_TIMES)
				{
					if (g_bSignalStatus == AL_DVB_MONITOR_VALUE_INVAILED)
					{
						g_bSignalStatus = AL_DVB_MONITOR_VALUE_TRUE;
					}
					DVBMON_SEND_MSG(g_pfDvbMonCallbks, AI_DVB_MONITOR_STREAM_HAS_DATA, 0);
					g_bStreamStatus = AL_DVB_MONITOR_VALUE_TRUE;
					g_bCheckStreamTimer = 0;
				}
			}
		}
		else
		{
			g_bStreamStatus = AL_DVB_MONITOR_VALUE_TRUE;
			g_bCheckStreamTimer = 0;
		}
	}
}

static al_int _AI_DVB_Monitor_ProgStateCallback(al_void *pData)
{
	_AI_DVB_Monitor_CheckParentalRating();
	if(MID_DvbMonReceiveStopCmd()==TRUE)
	{
		return 1;
	}

	_AI_DVB_Monitor_TimerEventCheck(1);
	if(MID_DvbMonReceiveStopCmd() == al_true)
	{
		return AL_FAILURE;
	}

	_AI_DVB_Monitor_CheckSerNotAvailable();
	if(MID_DvbMonReceiveStopCmd() == al_true)
	{
		return AL_FAILURE;
	}

	return AL_SUCCESS;
}

/**
* @brief dvb monitor init function.
*
* @param pfDvbMonCallbks[input] dvb monitor notify framwork callback function.
*
* @return AL_SUCCESS if initialization is successful, AL_FAILURE otherwise.
*/
AL_Return_t AI_DVB_Monitor_Init(AI_pfDVBMonCallback pfDvbMonCallbks)
{
	Mid_DvbMonCallbks_t stDvbMonCallbks;

	if (g_bDvbMonInited == al_true)
	{
		DVB_MONITOR_ERROR_MSG("dvb monitor has inited.\n");
		return AL_SUCCESS;
	}

	g_bDvbMonInited = al_true;
	g_pfDvbMonCallbks = pfDvbMonCallbks;
	memset(&stDvbMonCallbks, 0, sizeof(Mid_DvbMonCallbks_t));
	stDvbMonCallbks.pfMonSignalCallbk = _AI_DVB_Monitor_SignalCallback;
	stDvbMonCallbks.pfMonProgStateCallbk = _AI_DVB_Monitor_ProgStateCallback;
	if (MID_SUCCESS != MID_DvbMonInit(&stDvbMonCallbks))
	{
		DVB_MONITOR_ERROR_MSG("dvb monitor init error.\n");
		return AL_FAILURE;
	}

	return AL_SUCCESS;
}

/**
* @brief dvb monitor init function.
*
* @param al_void.
*
* @return AL_SUCCESS if uninitialization is successful, AL_FAILURE otherwise.
*/
AL_Return_t AI_DVB_Monitor_Uninit(al_void)
{
	if (g_bDvbMonInited != al_true)
	{
		DVB_MONITOR_ERROR_MSG("dvb monitor has not inited.\n");
		return AL_UNINITIALIZED;
	}

	g_bDvbMonInited = al_false;
	g_pfDvbMonCallbks = al_null;
	MID_DvbMonUninit();
	return AL_SUCCESS;
}

/**
* @brief dvb monitor start function.
*
* Active dvb monitor task, start to monitor signal state and program state change.
*
* @param al_void.
*
* @return AL_SUCCESS dvb monitor state is successful, AL_FAILURE otherwise.
*/
AL_Return_t AL_DVB_Monitor_Start(al_void)
{
	_AI_DVB_Monitor_ResetState();

	if (g_bDvbMonInited != al_true)
	{
		DVB_MONITOR_ERROR_MSG("dvb monitor has not inited.\n");
		return AL_UNINITIALIZED;
	}

	if (MID_SUCCESS != MID_DvbMonStart())
	{
		DVB_MONITOR_ERROR_MSG("dvb monitor start failture.\n");
		return AL_FAILURE;
	}

	return AL_SUCCESS;
}

/**
* @brief dvb monitor stop function.
*
*  Stop dvb monitor task, stop to monitor signal state and program state.
*
* @param bExit[input] used to mark hang up dvb monitor task or exit dvb monitor.
*
* @return AL_SUCCESS dvb monitor stop is successful, AL_FAILURE otherwise.
*/
AL_Return_t AL_DVB_Monitor_Stop(al_bool bExit)
{
	if (g_bDvbMonInited != al_true)
	{
		DVB_MONITOR_ERROR_MSG("dvb monitor has not inited.\n");
		return AL_UNINITIALIZED;
	}

	if (MID_SUCCESS != MID_DvbMonStop(bExit))
	{
		DVB_MONITOR_ERROR_MSG("dvb monitor stop failture.\n");
		return AL_FAILURE;
	}

	return AL_SUCCESS;
}

/**
* @brief get dvb monitor running state function.
*
* Get dvb monitor current state.
*
* @param eStateType[input] state type.
*
* @param pbDVBMonState[output] dvb monitor running state value.
*
* @return AL_SUCCESS get dvb monitor state is successful, AL_FAILURE otherwise.
*/
AL_Return_t AL_DVB_Monitor_GetState(AL_DVBMon_State_Type_t eStateType, al_uint8 *pbDVBMonState)
{

	if (pbDVBMonState == al_null)
	{
		DVB_MONITOR_ERROR_MSG("dvb monitor get state error.\n");
		return AL_INVALID_PARAM;
	}

	switch (eStateType)
	{
		case AL_DVB_MONITOR_STATE_MONITOR:
			*pbDVBMonState = MID_DvbMonIsRunning();
			break;
		case AL_DVB_MONITOR_STATE_SIGNAL:
			#ifdef CONFIG_SUPPORT_PATTERNGEN
                        g_bSignalStatus = AL_DVB_MONITOR_VALUE_TRUE;
			#endif
			*pbDVBMonState = g_bSignalStatus;
			break;
		default:
			DVB_MONITOR_ERROR_MSG("dvb monitor get state error.\n");
			break;
	}

	return AL_SUCCESS;
}

/**
* @brief set dvb monitor signal state function.
*
* Set dvb monitor signal state, because driver has received stream has data or vip finish but dvb monitor has not check signal avaible.
*
* @param eStateType[input] state type.
*
* @param pbDVBMonState[output] dvb monitor running state value.
*
* @return AL_SUCCESS get dvb monitor state is successful, AL_FAILURE otherwise.
*/
AL_Return_t AL_DVB_Monitor_SetState(AL_DVBMon_State_Type_t eStateType, al_uint8 *pbDVBMonState)
{

	if (pbDVBMonState == al_null)
	{
		DVB_MONITOR_ERROR_MSG("dvb monitor get state error.\n");
		return AL_INVALID_PARAM;
	}

	switch (eStateType)
	{
		case AL_DVB_MONITOR_STATE_SIGNAL:
			g_bSignalStatus = *pbDVBMonState;
			break;
		default:
			DVB_MONITOR_ERROR_MSG("dvb monitor get state error.\n");
			break;
	}

	return AL_SUCCESS;
}

#ifdef CONFIG_DVB_SYSTEM_DVBS_SUPPORT
al_void AL_DVB_Monitor_SetForceMotor(al_uint8 bForceMotor)
{
	g_bForceMotor = bForceMotor;
}
#endif

#ifdef __cplusplus
}
#endif
