123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416 |
- //***************************************************************************
- //!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: CbusMidGetDevCapReceiveDone
- // Description: see if dev cap receive done
- // Parameters: channel to check
- // Returns: TRUE - success
- // FALSE - failure
- //------------------------------------------------------------------------------
- BOOL CbusMidGetDevCapReceiveDone(void);
- //------------------------------------------------------------------------------
- // 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: CbusMidGetAdoptID
- // Description: get AdoptID
- // Returns: AdoptID
- //------------------------------------------------------------------------------
- UINT16 CbusMidGetAdoptID(void);
- //------------------------------------------------------------------------------
- // Function: CbusMidGetWhiteListToResetCubs
- // Description: get WhitList For reset cbus
- // Returns: true : device can reset cbus false: reset cbus is forbidden
- //------------------------------------------------------------------------------
- //
- UINT16 CbusMidGetWhiteListToResetCubs(void);
- //------------------------------------------------------------------------------
- // 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_VbusToggle
- // Description: MHL_VbusToggle
- // Parameters: null
- // Returns: nuu
- //------------------------------------------------------------------------------
- void MHL_VbusToggle(void);
- //------------------------------------------------------------------------------
- // Function: MHL_CD_SENSE_SEL_Check
- // Description: check CD_SENSE_SEL value
- // Parameters:
- // Returns: CD_SENSE_SEL
- //------------------------------------------------------------------------------
- BOOL MHL_CD_SENSE_SEL(void);
- //------------------------------------------------------------------------------
- // 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__
|