//*************************************************************************** //!file mid_cbus.h //!brief // //***************************************************************************/ #ifndef _mid_cbus_H__ #define _mid_cbus_H__ #include "cbus_datatypes.h" #include "cbus_enums.h" #include "cbus_drv_internal.h" #define NUM_CBUS 1 // Number of CBUS instances //------------------------------------------------------------------------------ // Manifest Constants //------------------------------------------------------------------------------ #define MHL_DEVCAP_SIZE 16 #define MHL_INTERRUPT_SIZE 4 #define MHL_STATUS_SIZE 4 #define MHL_SCRATCHPAD_SIZE 16 #define MHL_MAX_BUFFER_SIZE MHL_SCRATCHPAD_SIZE // manually define highest number #define CBUS_MAX_COMMAND_QUEUE 6 #define CBUS_HPD_WAIT_TIME 120 //unit:1ms #define CBUS_ABORT_WAIT_TIME 2000 //unit:1ms #define CBUS_NACK_WAIT_TIME 1000 //unit:1ms typedef enum _CbusHpdStates_t { CbusHPD_INACTIVE_EX, // HPD HI, HDCP, EDID, RX Term disabled CbusHPD_ACTIVE, // HPD HI, HDCP, EDID, RX Term enabled CbusHPD_TOGGLE, // All Toggle Off then On CbusHPD_INACTIVE_EDID, // EDID disabled CbusHPD_ACTIVE_EX, // EDID, RX Term enabled CbusHPD_TOGGLE_EDID, // EDID Toggle Off then On CbusHPD_UNUSED, // Unused to help match CDC values CbusHPD_INACTIVE, // HPD LOW, HDCP, RX Term disabled } CbusHpdStates_t; //------------------------------------------------------------------------------ // CBUS Component typedefs //------------------------------------------------------------------------------ // // structure to hold command details from upper layer to CBUS module // typedef struct { CBUS_REQ_e reqStatus; // CBUS_IDLE, CBUS_PENDING UINT8 command; // VS_CMD or RCP opcode UINT8 offsetData; // Offset of register on CBUS or RCP data UINT8 length; // Only applicable to write burst. ignored otherwise. UINT8 msgData[MHL_MAX_BUFFER_SIZE]; // Pointer to message data area. } cbus_req_t; #pragma pack(push,1) //align to 1 byte typedef struct { BOOL fDevCapReady; union{ UINT8 bDevCap[16]; struct{ //0x00 UINT8 bDevState; // Device State //0x01 union{ UINT8 bMhlVersion; // MHL Version struct{ UINT8 bMhlVerMajor:4; UINT8 bMhlVerMinor:4; }; }; //0x02 union{ UINT8 DevCat; // Device Category struct{ UINT8 bDevType:4; UINT8 bPow:1; UINT8 bPlim:2; }; }; //0x03, 0x04 union{ UINT16 wAdopterId; //Adopter ID struct{ UINT8 bAdopterId_H; UINT8 bAdopterId_L; }; }; UINT8 bDevCap_5_9[5]; //0x0a union{ UINT8 bFeatureFlag; // Feature Support Flag struct{ UINT8 bRcpSupport:1; UINT8 bRapSupport:1; UINT8 bSpSupport:1; UINT8 bUcpSendSupport:1; UINT8 bUcpRecvSupport:1; }; }; //0x0b, 0x0c union{ UINT16 wDeviceId; //Device ID struct{ UINT8 bDeviceId_H; UINT8 bDeviceId_L; }; }; //0x0d UINT8 bScratchpadSize; //Scratchpad Size //0x0e union{ UINT8 IntStatSize; // Interrupt and Status Size struct{ UINT8 bIntSize:4; UINT8 bStatSize:4; }; }; UINT8 bDevCap_f; }; }; } cbusDeviceCabability_t; #pragma pack(pop) typedef struct { BOOL connected; // True if a connected MHL port BOOL setHPD; //does set_HPD done? BOOL dev_cap_regs_ready_bit; // Did dev cap ready bit sent to peer OK? BOOL srcReq3D; //does src send 3D_REQ interrupt bit BOOL srcGrtWrt; //does src send GRT_WRT interrupt bit BOOL sinkPathEn; //did PathEn interrupt bit send to src successful BOOL sinkDscrChgAck; //did DSCR_CHG interrupt bit send to src successful //request queue CBUS_STATE_e state; // State of command execution for this channel cbus_req_t request[CBUS_MAX_COMMAND_QUEUE]; UINT8 activeIndex; // Active queue entry. UINT32 lastSendTime; //the time of sending the last command UINT32 sendNextWaitTime; // wait timer for sending next command, unit:1ms BOOL existRcpInQueue; //for limiting only one RCP command in queue //source's device capability cbusDeviceCabability_t stSrcDevCap; BOOL SrcNotSprtRcpRelease; //some source device does not support RCP release command, ex:Samsung Note3 } cbusChannelState_t; //------------------------------------------------------------------------------ // CBUS Instance Data //------------------------------------------------------------------------------ typedef struct { CBUS_DRV_STATUS_e statusFlags; cbusChannelState_t chState; BOOL isPrevPortMHL; }CbusMidInstanceData_t; //------------------------------------------------------------------------------ // Standard component functions //------------------------------------------------------------------------------ void CbusMidInitialize(void); //------------------------------------------------------------------------------ // Component Specific functions //------------------------------------------------------------------------------ CBUS_SW_ERR_e CbusMidHandler(void); CBUS_REQ_e CbusMidRequestStatus(void); void CbusMidRequestSetStatus(CBUS_REQ_e newState); //------------------------------------------------------------------------------ // Function: CbusMidChannelConnected // Description: Return the CBUS channel connected status for this channel. // Returns: TRUE if connected. // FALSE if disconnected. //------------------------------------------------------------------------------ BOOL CbusMidChannelConnected(void); //------------------------------------------------------------------------------ // Function: CbusMidRequestDataGet // Description: Return a copy of the currently active request structure // Parameters: pbCmdType: return received MSC Command Type // pbData: return received MSC Command data // Returns: none //------------------------------------------------------------------------------ UINT8 CbusMidRequestDataGet(UINT8 *pbCmdType, UINT8 *pbData); //------------------------------------------------------------------------------ // Function: CbusMidMscMsgSubCmdSend // Description: Send MSC_MSG(RCP) message to the specified CBUS channel(port) // // Parameters: channel - CBUS channel // vsCommand - MSC_MSG cmd(RCP, RCPK or RCPE) // cmdData - MSC_MSG data // Returns: TRUE - successful queue/write // FALSE - write and/or queue failed //------------------------------------------------------------------------------ BOOL CbusMidMscMsgSubCmdSend(UINT8 vsCommand, UINT8 cmdData); //------------------------------------------------------------------------------ // Function: CbusMidRapMessageAck // Description: Send RAPK(acknowledge)message to the specified CBUS channel // and set the request status to idle. // // Parameters: channel - CBUS channel // Returns: TRUE - successful queue/write // FALSE - write and/or queue failed //------------------------------------------------------------------------------ BOOL CbusMidRapMessageAck(MHL_RAPE_STATUS_e cmdStatus); //------------------------------------------------------------------------------ // Function: CbusMidGetDevCapReadyBit // Description: see if dev cap ready msg has been sent or not // Parameters: channel to check // Returns: TRUE - success // FALSE - failure //------------------------------------------------------------------------------ BOOL CbusMidGetDevCapReadyBit(void); //------------------------------------------------------------------------------ // Function: CbusMidSetDevCapReadyBit // Description: set the devCapReady bit // Parameters: channel to check, value to set // Returns: void //------------------------------------------------------------------------------ void CbusMidSetDevCapReadyBit(BOOL value); //------------------------------------------------------------------------------ // Function: CbusMidSendDcapRdyMsg // Description: Send a msg to peer informing the devive capability registers are // ready to be read. // Parameters: channel to check // Returns: TRUE - success // FALSE - failure //------------------------------------------------------------------------------ BOOL CbusMidSendDcapRdyMsg(void); BOOL CbusMidInsertCmdToQueue(cbus_req_t *pReq); //------------------------------------------------------------------------------ // Function: CbusMidEdidChange // Description: Check if the channel is an active channel // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF //------------------------------------------------------------------------------ BOOL CbusMidEdidChange(void); //------------------------------------------------------------------------------ // Function: CbusMidGrtWrt // Description: // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF //------------------------------------------------------------------------------ BOOL CbusMidGrtWrt(void); //------------------------------------------------------------------------------ // Function: CbusMidReqWrt // Description: // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF //------------------------------------------------------------------------------ BOOL CbusMidReqWrt(void); //------------------------------------------------------------------------------ // Function: CbusMidSendDcapChange // Description: // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF //------------------------------------------------------------------------------ BOOL CbusMidSendDcapChange(void); //------------------------------------------------------------------------------ // Function: CbusMidSendDscrChange // Description: // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF //------------------------------------------------------------------------------ BOOL CbusMidSendDscrChange(void); //------------------------------------------------------------------------------ // Function: CbusMidSendDcapRdy // Description: // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF //------------------------------------------------------------------------------ BOOL CbusMidSendDcapRdy(void); //------------------------------------------------------------------------------ // Function: CbusMidSendPathEn_RcvdAck // Description: check if PATH_EN msg has been sent and received ACK or not // Parameters: channel to check // Returns: TRUE - success // FALSE - failure //------------------------------------------------------------------------------ BOOL CbusMidSendPathEn_RcvdAck(void); //------------------------------------------------------------------------------ // Function: CbusMidGet_HPD_Status // Description: check if Set HPD Cmd has been sent or not // Returns: TRUE - success // FALSE - failure //------------------------------------------------------------------------------ BOOL CbusMidGet_HPD_Status(void); //------------------------------------------------------------------------------ // Function: CbusMidSend3DVideoSupportList // Description: sends 3D Support list by Write Burst // Parameters: //------------------------------------------------------------------------------ BOOL CbusMidSend3DVideoSupportList(BOOL fReset); //------------------------------------------------------------------------------ // Function: CbusMidGetSrcDevCap // Description: get interest device capabilityies of source // Parameters: fReset - reset the flow of fetching Device Capability // Returns: TRUE - success // FALSE - failure //------------------------------------------------------------------------------ BOOL CbusMidGetSrcDevCap(BOOL fReset); //------------------------------------------------------------------------------ // Function: CbusMidPathEnable // Description: Check if the channel is an active channel // Parameters: port - current active port //------------------------------------------------------------------------------ BOOL CbusMidPathEnable(void); //------------------------------------------------------------------------------ // Function: CbusMidSendCommand // Description: sends general MHL commands // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF //------------------------------------------------------------------------------ BOOL CbusMidSendCommand(UINT8 cmd); //------------------------------------------------------------------------------ // Function: CbusMidSendWriteBurst // Description: sends MHL write burst cmd // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF //------------------------------------------------------------------------------ BOOL CbusMidSendWriteBurst(UINT8 startOffset, UINT8 length, UINT8* pMsgData); //------------------------------------------------------------------------------ // Function: MHL_VbusCtrl // Description: Turn on or off VBUS. // Parameters: vbusEn - 1-Enable; 0 - Disable // Returns: TRUE //------------------------------------------------------------------------------ BOOL MHL_VbusCtrl(BOOL vbusEn); //------------------------------------------------------------------------------ // Function: MHL_ADOPTER_ID_Check // Description: check if device have MHL_ADOPTER_ID // Parameters: // Returns: TRUE - // FALSE - //------------------------------------------------------------------------------ BOOL MHL_ADOPTER_ID_Check(void); void CbusMidPrintChannelInfo(const UINT8 *bFunc, const UINT32 dLine); #endif // _mid_cbus_H__