cbus_mid.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  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: CbusMidGetDevCapReceiveDone
  195. // Description: see if dev cap receive done
  196. // Parameters: channel to check
  197. // Returns: TRUE - success
  198. // FALSE - failure
  199. //------------------------------------------------------------------------------
  200. BOOL CbusMidGetDevCapReceiveDone(void);
  201. //------------------------------------------------------------------------------
  202. // Function: CbusMidGetDevCapReadyBit
  203. // Description: see if dev cap ready msg has been sent or not
  204. // Parameters: channel to check
  205. // Returns: TRUE - success
  206. // FALSE - failure
  207. //------------------------------------------------------------------------------
  208. BOOL CbusMidGetDevCapReadyBit(void);
  209. //------------------------------------------------------------------------------
  210. // Function: CbusMidSetDevCapReadyBit
  211. // Description: set the devCapReady bit
  212. // Parameters: channel to check, value to set
  213. // Returns: void
  214. //------------------------------------------------------------------------------
  215. void CbusMidSetDevCapReadyBit(BOOL value);
  216. //------------------------------------------------------------------------------
  217. // Function: CbusMidSendDcapRdyMsg
  218. // Description: Send a msg to peer informing the devive capability registers are
  219. // ready to be read.
  220. // Parameters: channel to check
  221. // Returns: TRUE - success
  222. // FALSE - failure
  223. //------------------------------------------------------------------------------
  224. BOOL CbusMidSendDcapRdyMsg(void);
  225. BOOL CbusMidInsertCmdToQueue(cbus_req_t *pReq);
  226. //------------------------------------------------------------------------------
  227. // Function: CbusMidEdidChange
  228. // Description: Check if the channel is an active channel
  229. // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
  230. //------------------------------------------------------------------------------
  231. BOOL CbusMidEdidChange(void);
  232. //------------------------------------------------------------------------------
  233. // Function: CbusMidGrtWrt
  234. // Description:
  235. // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
  236. //------------------------------------------------------------------------------
  237. BOOL CbusMidGrtWrt(void);
  238. //------------------------------------------------------------------------------
  239. // Function: CbusMidReqWrt
  240. // Description:
  241. // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
  242. //------------------------------------------------------------------------------
  243. BOOL CbusMidReqWrt(void);
  244. //------------------------------------------------------------------------------
  245. // Function: CbusMidSendDcapChange
  246. // Description:
  247. // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
  248. //------------------------------------------------------------------------------
  249. BOOL CbusMidSendDcapChange(void);
  250. //------------------------------------------------------------------------------
  251. // Function: CbusMidSendDscrChange
  252. // Description:
  253. // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
  254. //------------------------------------------------------------------------------
  255. BOOL CbusMidSendDscrChange(void);
  256. //------------------------------------------------------------------------------
  257. // Function: CbusMidSendDcapRdy
  258. // Description:
  259. // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
  260. //------------------------------------------------------------------------------
  261. BOOL CbusMidSendDcapRdy(void);
  262. //------------------------------------------------------------------------------
  263. // Function: CbusMidSendPathEn_RcvdAck
  264. // Description: check if PATH_EN msg has been sent and received ACK or not
  265. // Parameters: channel to check
  266. // Returns: TRUE - success
  267. // FALSE - failure
  268. //------------------------------------------------------------------------------
  269. BOOL CbusMidSendPathEn_RcvdAck(void);
  270. //------------------------------------------------------------------------------
  271. // Function: CbusMidGet_HPD_Status
  272. // Description: check if Set HPD Cmd has been sent or not
  273. // Returns: TRUE - success
  274. // FALSE - failure
  275. //------------------------------------------------------------------------------
  276. BOOL CbusMidGet_HPD_Status(void);
  277. //------------------------------------------------------------------------------
  278. // Function: CbusMidSend3DVideoSupportList
  279. // Description: sends 3D Support list by Write Burst
  280. // Parameters:
  281. //------------------------------------------------------------------------------
  282. BOOL CbusMidSend3DVideoSupportList(BOOL fReset);
  283. //------------------------------------------------------------------------------
  284. // Function: CbusMidGetSrcDevCap
  285. // Description: get interest device capabilityies of source
  286. // Parameters: fReset - reset the flow of fetching Device Capability
  287. // Returns: TRUE - success
  288. // FALSE - failure
  289. //------------------------------------------------------------------------------
  290. BOOL CbusMidGetSrcDevCap(BOOL fReset);
  291. //------------------------------------------------------------------------------
  292. // Function: CbusMidGetAdoptID
  293. // Description: get AdoptID
  294. // Returns: AdoptID
  295. //------------------------------------------------------------------------------
  296. UINT16 CbusMidGetAdoptID(void);
  297. //------------------------------------------------------------------------------
  298. // Function: CbusMidGetWhiteListToResetCubs
  299. // Description: get WhitList For reset cbus
  300. // Returns: true : device can reset cbus false: reset cbus is forbidden
  301. //------------------------------------------------------------------------------
  302. //
  303. UINT16 CbusMidGetWhiteListToResetCubs(void);
  304. //------------------------------------------------------------------------------
  305. // Function: CbusMidPathEnable
  306. // Description: Check if the channel is an active channel
  307. // Parameters: port - current active port
  308. //------------------------------------------------------------------------------
  309. BOOL CbusMidPathEnable(void);
  310. //------------------------------------------------------------------------------
  311. // Function: CbusMidSendCommand
  312. // Description: sends general MHL commands
  313. // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
  314. //------------------------------------------------------------------------------
  315. BOOL CbusMidSendCommand(UINT8 cmd);
  316. //------------------------------------------------------------------------------
  317. // Function: CbusMidSendWriteBurst
  318. // Description: sends MHL write burst cmd
  319. // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
  320. //------------------------------------------------------------------------------
  321. BOOL CbusMidSendWriteBurst(UINT8 startOffset, UINT8 length, UINT8* pMsgData);
  322. //------------------------------------------------------------------------------
  323. // Function: MHL_VbusCtrl
  324. // Description: Turn on or off VBUS.
  325. // Parameters: vbusEn - 1-Enable; 0 - Disable
  326. // Returns: TRUE
  327. //------------------------------------------------------------------------------
  328. BOOL MHL_VbusCtrl(BOOL vbusEn);
  329. //------------------------------------------------------------------------------
  330. // Function: MHL_VbusToggle
  331. // Description: MHL_VbusToggle
  332. // Parameters: null
  333. // Returns: nuu
  334. //------------------------------------------------------------------------------
  335. void MHL_VbusToggle(void);
  336. //------------------------------------------------------------------------------
  337. // Function: MHL_CD_SENSE_SEL_Check
  338. // Description: check CD_SENSE_SEL value
  339. // Parameters:
  340. // Returns: CD_SENSE_SEL
  341. //------------------------------------------------------------------------------
  342. BOOL MHL_CD_SENSE_SEL(void);
  343. //------------------------------------------------------------------------------
  344. // Function: MHL_ADOPTER_ID_Check
  345. // Description: check if device have MHL_ADOPTER_ID
  346. // Parameters:
  347. // Returns: TRUE -
  348. // FALSE -
  349. //------------------------------------------------------------------------------
  350. BOOL MHL_ADOPTER_ID_Check(void);
  351. void CbusMidPrintChannelInfo(const UINT8 *bFunc, const UINT32 dLine);
  352. #endif // _mid_cbus_H__