hv_mw_Channel_Manager.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. /**
  2. * @file hv_mw_Channel_Manager.h
  3. * @brief Header file of ChannelManager module.
  4. *
  5. * @verbatim
  6. * ==============================================================================
  7. * ##### How to use #####
  8. * ==============================================================================
  9. * (+) At first.
  10. * (+) Use Hv_Mw_Channel_ManagerInit(...) to initial ChannelManager.
  11. * (+) Use Hv_Mw_Channel_SendInnerMsg(...) send a message to ChannelManager Inner MessageQueue immediately.
  12. * (+) Use Hv_Mw_Channel_ProcSystemQueueMsg(...) will process one Message from SystemQueue.
  13. * (+) Use Hv_Mw_Channel_ProcInnerMsgs(...) will proc all Channel inner MessageQueue messages once time.
  14. * (+) Use Hv_Mw_Channel_HasInnerMsgs(...) judge whether there are messages in the Channel messsage pool.
  15. *
  16. * @endverbatim
  17. *
  18. * @author HiView SoC Software Team
  19. * @version 1.0.0
  20. * @date 2022-08-10
  21. */
  22. #ifndef __SDK_MIDDLEWARE_RUNTIME_SYSTEMMANAGER_CHANNEL_MANAGER_INC_CHANNEL_MANAGER_H__
  23. #define __SDK_MIDDLEWARE_RUNTIME_SYSTEMMANAGER_CHANNEL_MANAGER_INC_CHANNEL_MANAGER_H__
  24. #include "hv_comm_DataType.h"
  25. #include "hv_comm_Define.h"
  26. #include "hv_comm_Event.h"
  27. #include "hv_comm_Timer.h"
  28. #include "hv_mw_StateMachine.h"
  29. /*注意此处宏定义必须加(),否则会有运算符优先级bug,a % MAX_CHANNEL_QUEUE_SIZE运算的结果是
  30. (a % HV_BOARD_CONFIG_MAX_CHANNEL_NUM) * 20!!!! */
  31. #ifdef CONFIG_USER_DOUBLE_CHANNEL_ON
  32. #define MAX_CHANNEL_QUEUE_SIZE (2 * 20)
  33. #else
  34. #define MAX_CHANNEL_QUEUE_SIZE (1 * 20)
  35. #endif
  36. typedef struct _ChannelInnerMsgQueue
  37. {
  38. USHORT16 usWriteAddr; /* 写地址 */
  39. USHORT16 usReadAddr; /* 读地址 */
  40. ChannelEvent astFifo[MAX_CHANNEL_QUEUE_SIZE];
  41. }__attribute__((aligned(4)))ChannelInnerMsgQueue;
  42. typedef struct _SearchStrategy
  43. {
  44. UCHAR8 ucGuiPortIndex; /*搜索的端口号对应的是OSD菜单定义的编号 0, 1, 2, 3 ...*/
  45. UCHAR8 ucSearched; /*记录是否被搜索过*/
  46. USHORT16 usSearchTimes; /*端口已搜索次数*/
  47. }SearchStrategy;
  48. typedef struct _ChannelFlashConfig
  49. {
  50. BOOL bFlashSubFakeVideoSw; /*flash中保存的放大镜开关*/
  51. PxpMode enFlashPxPMode; /*flash中保存的PXP模式开关*/
  52. }ChannelFlashConfig;
  53. typedef struct _ChannelData
  54. {
  55. ChannelState enCurrentCHState; /*当前通道资源配置的即时状态*/
  56. ChannelType enChannelType; /*通道类型,0-Main channel,1-Sub channel,PIB/PBP开启时才需要配置辅通道*/
  57. LinkPortIndex enChannelSrcLinkPortIndex; /*当前通道绑定的具体HDMI/DP链路编号*/
  58. LinkPortIndex enLastChannelSrcLinkPortIndex; /*最后通道绑定的具体HDMI/DP链路编号*/
  59. HV_TIMER_S* pstPeriodSearchTimer; /*进入search态启动的搜索port定时器*/
  60. HV_TIMER_S* pstAVcheckStableTimer; /*config态进入active态前启动的检查audio video mute模块工作正常的定时器*/
  61. HV_TIMER_S* pstNoSignalTimer; /*无信号态启动的定时器*/
  62. HV_TIMER_S* pstVideoMuteTimer; /*video mute模块正常后, 启动的防抖定时器。在timing change场景下mute很快正常,
  63. 此时不能解mute需要等待DPU配置完成才能解mute,非timingchange case直接解mute*/
  64. HV_TIMER_S* pstAudioMuteTimer; /*audio mute模块正常后, 启动的防抖定时器。在timing change场景下mute很快正常,
  65. 此时不能解mute需要等待DPU配置完成才能解mute,非timingchange case直接解mute*/
  66. HV_TIMER_S* pstBurnInPeriodCheckTimer; /*老化模式下的周期性timer 用于检查端口状态及切换老化pattern*/
  67. HV_TIMER_S* pstAvWatchdogTimer; /*video正常显示时,轮询检查系统状态*/
  68. HV_TIMER_S* pstAudioFsCheckTimer; /*FS change时,等待多久去查audio状态*/
  69. BOOL bAVStable; /*audio video mute模块是否正常工作标志位*/
  70. BOOL bOutofRangeFlag; /*framesync模式下DTC动态计算的时钟频率是否超过屏规格*/
  71. BOOL bNoSignalLongTimes; /*true 该通道处于长时间无信号状态,如果2个通道均置位,则进入待机或者老化*/
  72. BOOL bStandByFlag; /*是否发送了standBy消息,0 未发送,1已发送*/
  73. UCHAR8 ucBurnInPattern; /*用于记录当前使用的pattern*/
  74. USHORT16 usAVStableCheckTimes; /*timer检查次数记录,5次以后强制进入active态*/
  75. USHORT16 usNoSignalCheckTimes; /*NoSignal定时器time out次数,用于记录进入无信号状态的时间*/
  76. USHORT16 usTotalSearchTimes; /*用于记录search态已搜索的次数,超过配置的最大次数进入无信号状态*/
  77. UINT32 uiErrorCode; /*用于记录当前Channel的配置的错误,可以用于显示获取timing错误,配置错误等等*/
  78. UINT32 uiMuteStatus; /*记录当前通道mute状态*/
  79. UINT32 uiEnterNoSignalCount; /*记录当前通道无信号时进入NoSignal的次数*/
  80. VideoTimingParam stRxVideoTiming; /*从RX获取到的原始timing, VideoConfigParams存储的是可能被修正的 timing*/
  81. AudioTimingParam stRxAudioTiming; /*从RX获取到的audio相关参数*/
  82. VideoConfigParams stVideoConfigParams; /*Dpu config链路需要使用的所有参数*/
  83. ChanelSignalState enChanelSignalState; /*通道选择的某一端口信号状态,主要用于给OSD显示使用*/
  84. Status (*pfMuteInit)(VOID);
  85. Status (*pfSetMuteTiming)(const VideoTimingParam* pstVideoTiming, UINT32 uiPixelClock, BOOL bOsdVrrEnable);
  86. UINT32 (*pfGetMuteState)(VOID);
  87. UINT32 (*pfGetMuteStatus)(VOID);
  88. Status (*pfMuteForceFreeRun)(BOOL bSwitch);
  89. VOID (*pfMuteClearEn)(VOID);
  90. Status (*pfDpuScalerConfig)(const VideoConfigParams* pstVideoConfigParams);
  91. UCHAR8 (*pfPQCallback)(PQCALLBACKMODE enMode, const VOID *pvVideoConfigParams);
  92. }ChannelData;
  93. typedef struct _ChannelManager
  94. {
  95. #ifdef CONFIG_USER_DOUBLE_CHANNEL_ON
  96. ChannelData astChannelData[2]; /*存储通道数据*/
  97. #else
  98. ChannelData astChannelData[1]; /*存储通道数据*/
  99. #endif
  100. ChannelInnerMsgQueue stChInnerMsgQueue; /*内部消息队列用于缓存挂在SystemTask其他模块发给Channel模块的消息*/
  101. BOOL bOSDActive; /*当前用户是否操作OSD菜单*/
  102. ChannelFlashConfig stChannelFlashConfig; /*flash中保存的变量,给channel使用,与OSD做隔离*/
  103. BOOL bSignalInterruption; /* 睡眠过程中是否有信号打断 */
  104. }__attribute__((aligned(4)))ChannelManager;
  105. typedef struct _ChannelStateMachine
  106. {
  107. USHORT16 usAcceptStates;
  108. ChanelEventId enEventId;
  109. Status (*pfActionHandle)(const ChannelEvent* pstChannelEvent, ChannelData* pstChannelData);
  110. ChannelState enNextSuccessState;
  111. ChannelState enNextFailState;
  112. }ChannelStateMachine;
  113. /**
  114. * @brief proc all of the messages in the channel inner Message pool once time.
  115. * @param[in] pstChannelManager pointer to ChannelManager.
  116. * @return Status, 0-SUCCESS, 1-HV_FAILURE.
  117. */
  118. Status Hv_Mw_Channel_ProcInnerMsgs(VOID);
  119. /**
  120. * @brief proc one SystemEvent messsage form System messageQueue.
  121. * @param[in] pstSystemEvent pointer to message to process.
  122. * @param[in] pstChannelManager pointer to ChannelManager.
  123. * @return Status, 0-SUCCESS, 1-HV_FAILURE.
  124. */
  125. Status Hv_Mw_Channel_ProcSystemQueueMsg(const SystemEvent* pstSystemEvent);
  126. /**
  127. * @brief judge whether there are messages in the channel messsage pool.
  128. * @param[in] None.
  129. * @return BOOL type of result, 0-empty, 1-not empty.
  130. */
  131. BOOL Hv_Mw_Channel_HasInnerMsgs( VOID );
  132. /**
  133. * @brief send a message to the channel messsage pool.
  134. * @param[in] point to ChannelEvent* messages type to send.
  135. * @return Status, 0-SUCCESS, 1-HV_FAILURE.
  136. */
  137. Status Hv_Mw_Channel_SendInnerMsg(const ChannelEvent* pstChannelEvent);
  138. /**
  139. * @brief get ChannelManager object.
  140. * @param[in] None.
  141. * @return pointer to ChannelManager object.
  142. */
  143. const ChannelManager* Hv_Mw_Channel_GetManager();
  144. /**
  145. * @brief get ChannelManager flash data.
  146. * @return value.
  147. */
  148. ChannelFlashConfig* Hv_Mw_Channel_GetManagerData(VOID);
  149. /**
  150. * @brief initial ChannelManager object.
  151. * @param[in] pointer of ChannelManager object to be initial.
  152. * @return Status, 0-SUCCESS, 1-HV_FAILURE.
  153. */
  154. Status Hv_Mw_Channel_Manager_Init(VOID);
  155. /**
  156. * @brief Get channel bind port and state.
  157. * @param[in] ChannelType: main or sub.
  158. * @param[out] LinkPortIndex:bind port idnex. ChanelSignalState:signal state.
  159. * @return Status, 0-SUCCESS, 1-HV_FAILURE.
  160. */
  161. Status Hv_Mw_Channel_GetSignalState(ChannelType enChannelType, LinkPortIndex* penChannelSrcLinkPortIndex, ChanelSignalState* penChanelSignalState);
  162. /**
  163. * @brief Get channel bind port realtime video timing,ps:in vrr case framerate will change.
  164. * @param[in] ChannelType: main or sub.
  165. * @param[out] VdeTimingParam:RX video timing.
  166. * @return Status, 0-SUCCESS, 1-HV_FAILURE.
  167. */
  168. Status Hv_Mw_Channel_GetVideoTiming(ChannelType enChannelType, VideoTimingParam* pstVideoTiming);
  169. LinkPortIndex Hv_Mw_Channel_ConvertGuiToMwPortIndex(UCHAR8 ucGuiPortIndex);
  170. /**
  171. * @brief 设置音源接口.
  172. * @param[in] uiValue:0-主通道/左 1:辅通道/右
  173. * @param[out] NULL
  174. * @return 0-success other-failure
  175. */
  176. Status Hv_Mw_Channel_AudioSourceConfig(ChannelType enChannelType);
  177. /**
  178. * @brief 判断音源输入是否在当前通道接口.
  179. * @param[in] enChannelType:CHANNEL_TYPE_MAIN-主通道/左 CHANNEL_TYPE_SUB:辅通道/右
  180. * @param[out] NULL
  181. * @return HV_TRUE-音源配置在当前通道, False-音源配置未在当前通道
  182. */
  183. BOOL Hv_Mw_Channel_IsAudioOnThisChannel(ChannelType enChannelType);
  184. /**
  185. * @brief 设置当前OSD菜单状态.
  186. * @param[in] uiValue:0-invalid 1:valid
  187. * @param[out] NULL
  188. * @return NULL
  189. */
  190. VOID Hv_Mw_Channel_SetOSDActive(BOOL bStatus);
  191. /**
  192. * @brief 查询当前OSD菜单状态.
  193. * @param[in] NULL
  194. * @param[out] NULL
  195. * @return 0-invalid 1:valid
  196. */
  197. BOOL Hv_Mw_Channel_GetOSDActive(VOID);
  198. /**
  199. * @brief 系统mute函数,包括声音和图像.
  200. * @param[in] ChannelType:主副通道
  201. * @param[out] NULL
  202. * @return NULL
  203. */
  204. VOID Hv_Mw_Channel_MuteOn(ChannelType enChannelType);
  205. /**
  206. * @brief 系统unmute函数,包括声音和图像.
  207. * @param[in] ChannelType:主副通道
  208. * @param[out] NULL
  209. * @return NULL
  210. */
  211. Status Hv_Mw_Channel_MuteOff(ChannelType enChannelType);
  212. /**
  213. * @brief 查询当前是否有信号在显示.
  214. * @param[in] NULL
  215. * @param[out] NULL
  216. * @return 0-invalid 1:valid
  217. */
  218. UCHAR8 Hv_Mw_Channel_GetChannelOnDisplay(VOID);
  219. PxpMode Hv_Mw_Channel_GetPxpMode();
  220. VOID Hv_Mw_Channel_UpdateVideoConfigParam(ChannelType enChannelType, VideoConfigParams stVideoConfigParams);
  221. VOID Hv_Mw_Channel_UpdateMainRxFakeVideoParam(MainRxFakeVideoParam stMainRxFakeVideoParam);
  222. Status Hw_Mw_Channel_SendPowerOffToPowerManager(VOID);
  223. /**
  224. * @brief 发送无信号进待机命令给power manger.
  225. * @param[in] bEnterFlag 1:进待机,2:从待机进入normal.
  226. */
  227. Status Hw_Mw_Channel_SendNoSignalMsgToPowerManager(BOOL bEnterFlag);
  228. /**
  229. * @brief 停止AvWatchdogTimer
  230. * @param[in] NULL
  231. * @param[out] NULL.
  232. * @return NULL
  233. */
  234. VOID Hv_Mw_Channel_StopAvWatchdogTimer(VOID);
  235. LinkPortIndex Hv_Mw_Channel_GetAudioSelInputPortIndex(VOID);
  236. /**
  237. * @brief 判断Main是否有信号识别
  238. */
  239. Status Hv_Mw_Channel_GetChannelNoSignalSearchStatus(VOID);
  240. /**
  241. * @brief channel从no signal跳到search
  242. */
  243. VOID Hv_Mw_Channel_StatusNoSignalToSearch(VOID);
  244. #endif