cbus_mid.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. //***************************************************************************
  2. //!file mid_cbus.h
  3. //!brief
  4. //
  5. //***************************************************************************/
  6. #ifndef _mid_cbus_H__
  7. #define _mid_cbus_H__
  8. #include "cbus_datatypes.h"
  9. #include "cbus_enums.h"
  10. #include "cbus_drv_internal.h"
  11. #define NUM_CBUS 1 // Number of CBUS instances
  12. //------------------------------------------------------------------------------
  13. // Manifest Constants
  14. //------------------------------------------------------------------------------
  15. #define MHL_DEVCAP_SIZE 16
  16. #define MHL_INTERRUPT_SIZE 4
  17. #define MHL_STATUS_SIZE 4
  18. #define MHL_SCRATCHPAD_SIZE 16
  19. #define MHL_MAX_BUFFER_SIZE MHL_SCRATCHPAD_SIZE // manually define highest number
  20. #define CBUS_MAX_COMMAND_QUEUE 6
  21. #define CBUS_HPD_WAIT_TIME 120 //unit:1ms
  22. #define CBUS_ABORT_WAIT_TIME 2000 //unit:1ms
  23. #define CBUS_NACK_WAIT_TIME 1000 //unit:1ms
  24. typedef enum _CbusHpdStates_t
  25. {
  26. CbusHPD_INACTIVE_EX, // HPD HI, HDCP, EDID, RX Term disabled
  27. CbusHPD_ACTIVE, // HPD HI, HDCP, EDID, RX Term enabled
  28. CbusHPD_TOGGLE, // All Toggle Off then On
  29. CbusHPD_INACTIVE_EDID, // EDID disabled
  30. CbusHPD_ACTIVE_EX, // EDID, RX Term enabled
  31. CbusHPD_TOGGLE_EDID, // EDID Toggle Off then On
  32. CbusHPD_UNUSED, // Unused to help match CDC values
  33. CbusHPD_INACTIVE, // HPD LOW, HDCP, RX Term disabled
  34. } CbusHpdStates_t;
  35. //------------------------------------------------------------------------------
  36. // CBUS Component typedefs
  37. //------------------------------------------------------------------------------
  38. //
  39. // structure to hold command details from upper layer to CBUS module
  40. //
  41. typedef struct
  42. {
  43. CBUS_REQ_e reqStatus; // CBUS_IDLE, CBUS_PENDING
  44. UINT8 command; // VS_CMD or RCP opcode
  45. UINT8 offsetData; // Offset of register on CBUS or RCP data
  46. UINT8 length; // Only applicable to write burst. ignored otherwise.
  47. UINT8 msgData[MHL_MAX_BUFFER_SIZE]; // Pointer to message data area.
  48. } cbus_req_t;
  49. #pragma pack(push,1) //align to 1 byte
  50. typedef struct
  51. {
  52. BOOL fDevCapReady;
  53. union{
  54. UINT8 bDevCap[16];
  55. struct{
  56. //0x00
  57. UINT8 bDevState; // Device State
  58. //0x01
  59. union{
  60. UINT8 bMhlVersion; // MHL Version
  61. struct{
  62. UINT8 bMhlVerMajor:4;
  63. UINT8 bMhlVerMinor:4;
  64. };
  65. };
  66. //0x02
  67. union{
  68. UINT8 DevCat; // Device Category
  69. struct{
  70. UINT8 bDevType:4;
  71. UINT8 bPow:1;
  72. UINT8 bPlim:2;
  73. };
  74. };
  75. //0x03, 0x04
  76. union{
  77. UINT16 wAdopterId; //Adopter ID
  78. struct{
  79. UINT8 bAdopterId_H;
  80. UINT8 bAdopterId_L;
  81. };
  82. };
  83. UINT8 bDevCap_5_9[5];
  84. //0x0a
  85. union{
  86. UINT8 bFeatureFlag; // Feature Support Flag
  87. struct{
  88. UINT8 bRcpSupport:1;
  89. UINT8 bRapSupport:1;
  90. UINT8 bSpSupport:1;
  91. UINT8 bUcpSendSupport:1;
  92. UINT8 bUcpRecvSupport:1;
  93. };
  94. };
  95. //0x0b, 0x0c
  96. union{
  97. UINT16 wDeviceId; //Device ID
  98. struct{
  99. UINT8 bDeviceId_H;
  100. UINT8 bDeviceId_L;
  101. };
  102. };
  103. //0x0d
  104. UINT8 bScratchpadSize; //Scratchpad Size
  105. //0x0e
  106. union{
  107. UINT8 IntStatSize; // Interrupt and Status Size
  108. struct{
  109. UINT8 bIntSize:4;
  110. UINT8 bStatSize:4;
  111. };
  112. };
  113. UINT8 bDevCap_f;
  114. };
  115. };
  116. } cbusDeviceCabability_t;
  117. #pragma pack(pop)
  118. typedef struct
  119. {
  120. BOOL connected; // True if a connected MHL port
  121. BOOL setHPD; //does set_HPD done?
  122. BOOL dev_cap_regs_ready_bit; // Did dev cap ready bit sent to peer OK?
  123. BOOL srcReq3D; //does src send 3D_REQ interrupt bit
  124. BOOL srcGrtWrt; //does src send GRT_WRT interrupt bit
  125. BOOL sinkPathEn; //did PathEn interrupt bit send to src successful
  126. BOOL sinkDscrChgAck; //did DSCR_CHG interrupt bit send to src successful
  127. //request queue
  128. CBUS_STATE_e state; // State of command execution for this channel
  129. cbus_req_t request[CBUS_MAX_COMMAND_QUEUE];
  130. UINT8 activeIndex; // Active queue entry.
  131. UINT32 lastSendTime; //the time of sending the last command
  132. UINT32 sendNextWaitTime; // wait timer for sending next command, unit:1ms
  133. BOOL existRcpInQueue; //for limiting only one RCP command in queue
  134. //source's device capability
  135. cbusDeviceCabability_t stSrcDevCap;
  136. BOOL SrcNotSprtRcpRelease; //some source device does not support RCP release command, ex:Samsung Note3
  137. } cbusChannelState_t;
  138. //------------------------------------------------------------------------------
  139. // CBUS Instance Data
  140. //------------------------------------------------------------------------------
  141. typedef struct
  142. {
  143. CBUS_DRV_STATUS_e statusFlags;
  144. cbusChannelState_t chState;
  145. BOOL isPrevPortMHL;
  146. }CbusMidInstanceData_t;
  147. //------------------------------------------------------------------------------
  148. // Standard component functions
  149. //------------------------------------------------------------------------------
  150. void CbusMidInitialize(void);
  151. //------------------------------------------------------------------------------
  152. // Component Specific functions
  153. //------------------------------------------------------------------------------
  154. CBUS_SW_ERR_e CbusMidHandler(void);
  155. CBUS_REQ_e CbusMidRequestStatus(void);
  156. void CbusMidRequestSetStatus(CBUS_REQ_e newState);
  157. //------------------------------------------------------------------------------
  158. // Function: CbusMidChannelConnected
  159. // Description: Return the CBUS channel connected status for this channel.
  160. // Returns: TRUE if connected.
  161. // FALSE if disconnected.
  162. //------------------------------------------------------------------------------
  163. BOOL CbusMidChannelConnected(void);
  164. //------------------------------------------------------------------------------
  165. // Function: CbusMidRequestDataGet
  166. // Description: Return a copy of the currently active request structure
  167. // Parameters: pbCmdType: return received MSC Command Type
  168. // pbData: return received MSC Command data
  169. // Returns: none
  170. //------------------------------------------------------------------------------
  171. UINT8 CbusMidRequestDataGet(UINT8 *pbCmdType, UINT8 *pbData);
  172. //------------------------------------------------------------------------------
  173. // Function: CbusMidMscMsgSubCmdSend
  174. // Description: Send MSC_MSG(RCP) message to the specified CBUS channel(port)
  175. //
  176. // Parameters: channel - CBUS channel
  177. // vsCommand - MSC_MSG cmd(RCP, RCPK or RCPE)
  178. // cmdData - MSC_MSG data
  179. // Returns: TRUE - successful queue/write
  180. // FALSE - write and/or queue failed
  181. //------------------------------------------------------------------------------
  182. BOOL CbusMidMscMsgSubCmdSend(UINT8 vsCommand, UINT8 cmdData);
  183. //------------------------------------------------------------------------------
  184. // Function: CbusMidRapMessageAck
  185. // Description: Send RAPK(acknowledge)message to the specified CBUS channel
  186. // and set the request status to idle.
  187. //
  188. // Parameters: channel - CBUS channel
  189. // Returns: TRUE - successful queue/write
  190. // FALSE - write and/or queue failed
  191. //------------------------------------------------------------------------------
  192. BOOL CbusMidRapMessageAck(MHL_RAPE_STATUS_e cmdStatus);
  193. //------------------------------------------------------------------------------
  194. // Function: CbusMidGetDevCapReadyBit
  195. // Description: see if dev cap ready msg has been sent or not
  196. // Parameters: channel to check
  197. // Returns: TRUE - success
  198. // FALSE - failure
  199. //------------------------------------------------------------------------------
  200. BOOL CbusMidGetDevCapReadyBit(void);
  201. //------------------------------------------------------------------------------
  202. // Function: CbusMidSetDevCapReadyBit
  203. // Description: set the devCapReady bit
  204. // Parameters: channel to check, value to set
  205. // Returns: void
  206. //------------------------------------------------------------------------------
  207. void CbusMidSetDevCapReadyBit(BOOL value);
  208. //------------------------------------------------------------------------------
  209. // Function: CbusMidSendDcapRdyMsg
  210. // Description: Send a msg to peer informing the devive capability registers are
  211. // ready to be read.
  212. // Parameters: channel to check
  213. // Returns: TRUE - success
  214. // FALSE - failure
  215. //------------------------------------------------------------------------------
  216. BOOL CbusMidSendDcapRdyMsg(void);
  217. BOOL CbusMidInsertCmdToQueue(cbus_req_t *pReq);
  218. //------------------------------------------------------------------------------
  219. // Function: CbusMidEdidChange
  220. // Description: Check if the channel is an active channel
  221. // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
  222. //------------------------------------------------------------------------------
  223. BOOL CbusMidEdidChange(void);
  224. //------------------------------------------------------------------------------
  225. // Function: CbusMidGrtWrt
  226. // Description:
  227. // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
  228. //------------------------------------------------------------------------------
  229. BOOL CbusMidGrtWrt(void);
  230. //------------------------------------------------------------------------------
  231. // Function: CbusMidReqWrt
  232. // Description:
  233. // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
  234. //------------------------------------------------------------------------------
  235. BOOL CbusMidReqWrt(void);
  236. //------------------------------------------------------------------------------
  237. // Function: CbusMidSendDcapChange
  238. // Description:
  239. // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
  240. //------------------------------------------------------------------------------
  241. BOOL CbusMidSendDcapChange(void);
  242. //------------------------------------------------------------------------------
  243. // Function: CbusMidSendDscrChange
  244. // Description:
  245. // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
  246. //------------------------------------------------------------------------------
  247. BOOL CbusMidSendDscrChange(void);
  248. //------------------------------------------------------------------------------
  249. // Function: CbusMidSendDcapRdy
  250. // Description:
  251. // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
  252. //------------------------------------------------------------------------------
  253. BOOL CbusMidSendDcapRdy(void);
  254. //------------------------------------------------------------------------------
  255. // Function: CbusMidSendPathEn_RcvdAck
  256. // Description: check if PATH_EN msg has been sent and received ACK or not
  257. // Parameters: channel to check
  258. // Returns: TRUE - success
  259. // FALSE - failure
  260. //------------------------------------------------------------------------------
  261. BOOL CbusMidSendPathEn_RcvdAck(void);
  262. //------------------------------------------------------------------------------
  263. // Function: CbusMidGet_HPD_Status
  264. // Description: check if Set HPD Cmd has been sent or not
  265. // Returns: TRUE - success
  266. // FALSE - failure
  267. //------------------------------------------------------------------------------
  268. BOOL CbusMidGet_HPD_Status(void);
  269. //------------------------------------------------------------------------------
  270. // Function: CbusMidSend3DVideoSupportList
  271. // Description: sends 3D Support list by Write Burst
  272. // Parameters:
  273. //------------------------------------------------------------------------------
  274. BOOL CbusMidSend3DVideoSupportList(BOOL fReset);
  275. //------------------------------------------------------------------------------
  276. // Function: CbusMidGetSrcDevCap
  277. // Description: get interest device capabilityies of source
  278. // Parameters: fReset - reset the flow of fetching Device Capability
  279. // Returns: TRUE - success
  280. // FALSE - failure
  281. //------------------------------------------------------------------------------
  282. BOOL CbusMidGetSrcDevCap(BOOL fReset);
  283. //------------------------------------------------------------------------------
  284. // Function: CbusMidPathEnable
  285. // Description: Check if the channel is an active channel
  286. // Parameters: port - current active port
  287. //------------------------------------------------------------------------------
  288. BOOL CbusMidPathEnable(void);
  289. //------------------------------------------------------------------------------
  290. // Function: CbusMidSendCommand
  291. // Description: sends general MHL commands
  292. // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
  293. //------------------------------------------------------------------------------
  294. BOOL CbusMidSendCommand(UINT8 cmd);
  295. //------------------------------------------------------------------------------
  296. // Function: CbusMidSendWriteBurst
  297. // Description: sends MHL write burst cmd
  298. // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
  299. //------------------------------------------------------------------------------
  300. BOOL CbusMidSendWriteBurst(UINT8 startOffset, UINT8 length, UINT8* pMsgData);
  301. //------------------------------------------------------------------------------
  302. // Function: MHL_VbusCtrl
  303. // Description: Turn on or off VBUS.
  304. // Parameters: vbusEn - 1-Enable; 0 - Disable
  305. // Returns: TRUE
  306. //------------------------------------------------------------------------------
  307. BOOL MHL_VbusCtrl(BOOL vbusEn);
  308. //------------------------------------------------------------------------------
  309. // Function: MHL_ADOPTER_ID_Check
  310. // Description: check if device have MHL_ADOPTER_ID
  311. // Parameters:
  312. // Returns: TRUE -
  313. // FALSE -
  314. //------------------------------------------------------------------------------
  315. BOOL MHL_ADOPTER_ID_Check(void);
  316. void CbusMidPrintChannelInfo(const UINT8 *bFunc, const UINT32 dLine);
  317. #endif // _mid_cbus_H__