/**
 * @file hv_mw_PanelManager.h
 * @brief Header file of ktx module.
 * 
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 * 
 * @endverbatim
 *
 * @author HiView SoC Software Team
 * @version 0.0.1
 * @date 2023-02-03
 */

#ifndef __SDK_MIDDLEWARE_RUNTIME_SYSTEM_MANAGER_PANEL_MANAGER_INC_PANEL_MANAGER_H__
#define __SDK_MIDDLEWARE_RUNTIME_SYSTEM_MANAGER_PANEL_MANAGER_INC_PANEL_MANAGER_H__


#include "hv_comm_DataType.h"
#include "hv_comm_Define.h"
#include "hv_comm_Event.h"
#include "hv_comm_Timer.h"
#include "hv_comm_LinkedList.h"
#include "hv_mw_StateMachine.h"

#define MAX_PANEL_QUEUE_SIZE             (20)

#if (PANEL_PIXEL_CLOCK_MAX > 750000)
   #error "Panel Pixel Clock exceeds chip limit"
#endif

typedef struct _PanelInnerMsgQueue
{
    USHORT16 usWriteAddr;           /* 写地址 */
    USHORT16 usReadAddr;            /* 读地址 */
    PanelEvent astFifo[MAX_PANEL_QUEUE_SIZE];
}__attribute__((aligned(4)))PanelInnerMsgQueue;
typedef struct _PanelManager
{
    PanelInnerMsgQueue stPanelInnerMsgQueue;/*内部消息队列用于缓存挂在SystemTask其他模块发给Panel模块的消息*/
    PanelState         enCurrentPanelState; /*panel状态机运行的实时状态*/
    //SpiSelf*           pstSpiSelf;
    PanelControl       stPanelControl;
    BOOL               bTimingChangeFlag;
    PanelParam         stPanelParam;
}__attribute__((aligned(4)))PanelManager;

Status Hv_Mw_Panel_SendInnerMsg(const PanelEvent* pstPanelEvent);
Status Hv_Mw_Panel_ProcInnerMsgs(VOID);
Status Hv_Mw_Panel_ProcSystemQueueMsg(const SystemEvent* pstSystemEvent);
BOOL Hv_Mw_Panel_HasInnerMsgs( VOID );


VOID Hv_Mw_Panel_SetTimingChangeFlag(BOOL bFlag);

BOOL Hv_Mw_Panel_GetTimingChangeFlag(VOID);

VOID Hv_Mw_Panel_StartPanelPowerOnTimer(VOID);

const PanelManager* Hv_Mw_Panel_GetManagerPtr(VOID);

const PanelParam Hv_Mw_Panel_GetCurrentPanelParam(VOID);

USHORT16 Hv_Mw_Panel_GetPanelHactive(VOID);

USHORT16 Hv_Mw_Panel_GetPanelVactive(VOID);

UCHAR8 Hv_Mw_Panel_GetPanelFrameRateType(VOID);
/**
 * @brief PanelManager 初始化
 */
Status Hv_Mw_Panel_Init(VOID);

#endif
