1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303 |
- //***************************************************************************
- //!file mid_cbus.c
- //!brief
- //
- //***************************************************************************/
- #include <linux/kernel.h> /* printk */
- #include <linux/string.h>
- #include "cbus_mid.h"
- #include "cbus_drv.h"
- #include "cbus_debug.h"
- #include "../hdmi_cfg.h"
- #include "drv_hdmi_external.h"
- #include "../hdmi_hw.h"
- #include <drv2kmf.h>
- #include <drv_event.h>
- #include "../hdmi_notice.h"
- #include "../hdmi_time.h"
- #include "../sysreg.h"
- #include "../../../module_include/drv_hdmi_internal.h"
- //------------------------------------------------------------------------------
- // CBUS Component Instance Data
- //------------------------------------------------------------------------------
- #define CH_ACTIVE_INDEX (pMidCbus->chState.activeIndex)
- #define CH_NEXT_INDEX ((pMidCbus->chState.activeIndex + 1) % CBUS_MAX_COMMAND_QUEUE)
- //------------------------------------------------------------------------------
- // CBUS Instance Data
- //------------------------------------------------------------------------------
- CbusMidInstanceData_t cbusInstance[NUM_CBUS];
- CbusMidInstanceData_t *pMidCbus = &cbusInstance[0];
- //------------------------------------------------------------------------------
- // CBUS Global Data
- //------------------------------------------------------------------------------
- #define DEV_CAP_OFFSET_ARRAY_SIZE 9
- static const UINT8 bGetDevCapOffsetArray[DEV_CAP_OFFSET_ARRAY_SIZE] = {0x01, 0x02, 0x03, 0x04, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e};
- //------------------------------------------------------------------------------
- // Function: CbusMidRequestStatus
- // Description: Return the status of the message currently in process, if any.
- // Parameters:
- // Returns: CBUS_REQ_IDLE, CBUS_REQ_PENDING, CBUS_REQ_SENT, or CBUS_REQ_RECEIVED
- //------------------------------------------------------------------------------
- CBUS_REQ_e CbusMidRequestStatus(void)
- {
- return(pMidCbus->chState.request[ CH_ACTIVE_INDEX ].reqStatus);
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidRequestSetStatus
- // Description: Set the active request to the specified state
- // Parameters:
- //------------------------------------------------------------------------------
- void CbusMidRequestSetStatus(CBUS_REQ_e newState)
- {
- pMidCbus->chState.request[ CH_ACTIVE_INDEX ].reqStatus = newState;
- }
- //------------------------------------------------------------------------------
- // 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)
- {
- if(CbusDrvMSCSubDataGet(pbCmdType, pbData) == FALSE) //if no received sub command
- {
- return ERROR_INVALID;
- }
- //mhldbg("[%s] received MSC SubCmd 0x%x 0x%x\n", __FUNCTION__, *pbCmdType, *pbData);
- return CBUS_SUCCESS;
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidChannelConnected
- // Description: Return the CBUS channel connected status for this channel.
- // Returns: TRUE if connected.
- // FALSE if disconnected.
- //------------------------------------------------------------------------------
- BOOL CbusMidChannelConnected(void)
- {
- return(pMidCbus->chState.connected);
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidSendNextInQueue
- // Description: Starting at the current active index, send the next pending
- // entry, if any
- //------------------------------------------------------------------------------
- static INT32 CbusMidSendNextInQueue(void)
- {
- INT32 result = CBUS_SUCCESS;
- INT32 nextIndex = 0, endIndex = (CH_ACTIVE_INDEX+CBUS_MAX_COMMAND_QUEUE-1)%CBUS_MAX_COMMAND_QUEUE;
- nextIndex =CH_ACTIVE_INDEX;
- while(1)
- {
- if(pMidCbus->chState.request[ nextIndex].reqStatus == CBUS_REQ_PENDING)
- break;
- if(nextIndex == endIndex) // Searched whole queue, no pending messages
- {
- return(CBUS_SUCCESS); // No pending messages, return success
- }
- nextIndex =(nextIndex ==(CBUS_MAX_COMMAND_QUEUE - 1))? 0 :(nextIndex + 1);
- }
- //CbusMidPrintChannelInfo(__FUNCTION__, __LINE__);
- mhldbg("[%s] index:%d cmd:0x%x offset: 0x%x\n", __FUNCTION__, nextIndex, pMidCbus->chState.request[ nextIndex].command, pMidCbus->chState.request[ nextIndex].offsetData);
- // Found a pending message, send it out
- if(CbusDrvWriteCommand(&pMidCbus->chState.request[ nextIndex]))
- {
- pMidCbus->chState.request[nextIndex].reqStatus = CBUS_REQ_SENT;
- pMidCbus->chState.state = CBUS_SENT_WAIT_RESPONSE;
- pMidCbus->chState.lastSendTime = HDMI_GetSysTime();
- pMidCbus->chState.sendNextWaitTime = 0; //reset wait time
- if(pMidCbus->chState.request[CH_ACTIVE_INDEX].command == MHL_CLR_HPD)
- {
- pMidCbus->chState.sendNextWaitTime = CBUS_HPD_WAIT_TIME;
- }
- }
- else
- {
- result = ERROR_WRITE_FAILED;
- }
- //CbusMidPrintChannelInfo(__FUNCTION__, __LINE__);
- return(result);
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidResetToIdle
- // Description: Set the specified channel state to IDLE. Clears any messages that
- // are in progress or queued. Usually used if a channel connection
- // changed or the channel heartbeat has been lost.
- //------------------------------------------------------------------------------
- static void CbusMidResetToIdle(void)
- {
- UINT8 queueIndex;
- mhldbg("[%s]\n", __FUNCTION__);
- pMidCbus->chState.state = CBUS_IDLE;
- for(queueIndex = 0; queueIndex < CBUS_MAX_COMMAND_QUEUE; queueIndex++)
- {
- pMidCbus->chState.request[ queueIndex].reqStatus = CBUS_REQ_IDLE;
- }
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidInsertCmdToQueue
- // Description: Place a command in the CBUS message queue. If queue was empty,
- // send the new command immediately.
- //
- // Parameters:
- // pReq - Pointer to a cbus_req_t structure containing the
- // command to write
- // Returns: TRUE - successful queue/write
- // FALSE - write and/or queue failed
- //------------------------------------------------------------------------------
- BOOL CbusMidInsertCmdToQueue(cbus_req_t *pReq)
- {
- INT32 queueIndex;
- BOOL success = FALSE;
- #ifdef CBUS_DETAIL_DEBUG_MSG
- UINT8 i = 0;
- UINT8 bStr[100] = "";
- char bTemp[10] = "";
- mhldbg("[%s] Channel State: cmd:0x%02x offset:0x%02x len:%d\n", __FUNCTION__, pReq->command, pReq->offsetData, pReq->length);
- memset(bStr, 0, 100);
- for(i = 0; i< MHL_MAX_BUFFER_SIZE;i++)
- {
- sprintf(bTemp, "0x%x ",pReq->msgData[i]);
- strcat(bStr, bTemp);
- }
- mhldbg("\tmsg: %s\n",bStr);
- #endif
- //print request for debug
- //CbusMidPrintChannelInfo(__FUNCTION__, __LINE__);
- if(pMidCbus->chState.connected)
- {
- queueIndex = CH_NEXT_INDEX;
- do{
- if(pMidCbus->chState.request[ queueIndex].reqStatus == CBUS_REQ_IDLE)
- {
- // Found an idle queue entry, copy the request and set to pending.
- memcpy(&pMidCbus->chState.request[ queueIndex], pReq, sizeof(cbus_req_t));
- pMidCbus->chState.request[ queueIndex].reqStatus = CBUS_REQ_PENDING;
- success = TRUE;
- mhldbg("[%s] index:%d cmd:0x%x offset: 0x%x\n", __FUNCTION__, queueIndex, pReq->command, pReq->offsetData);
- break;
- }
- queueIndex=((queueIndex+1)%CBUS_MAX_COMMAND_QUEUE);
- }while(queueIndex != CH_NEXT_INDEX);
- /* If successful at putting the request into the queue */
- if(success == FALSE)
- {
- printk("[MHL]CBUS:: Queue full - skip cmd:0x%x offset:0x%x\n", pReq->command, pReq->offsetData);
- }
- }
- //print queue data for debug
- //CbusMidPrintChannelInfo(__FUNCTION__, __LINE__);
- return(success);
- }
- //------------------------------------------------------------------------------
- // 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)
- {
- cbus_req_t req;
- // Send MSC_MSG command(Vendor Specific command)
- req.command = MHL_MSC_MSG;
- req.msgData[0] = vsCommand;
- req.msgData[1] = cmdData;
- if(!(CbusMidInsertCmdToQueue(&req)))
- {
- printk("[MHL]Couldn't send MHL_MSC_MSG to peer\n");
- return FALSE;
- }
- return TRUE;
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidRapMessageAck
- // Description: Send RAPK(acknowledge)message to the specified CBUS channel
- // and set the request status to idle.
- //
- // Returns: TRUE - successful queue/write
- // FALSE - write and/or queue failed
- //------------------------------------------------------------------------------
- BOOL CbusMidRapMessageAck(MHL_RAPE_STATUS_e cmdStatus)
- {
- return(CbusMidMscMsgSubCmdSend(MHL_MSC_MSG_RAPK, (UINT8)cmdStatus));
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidProcessFailureInterrupts
- // Description: Check for and process any failure interrupts.
- // Returns: SUCCESS or ERROR_CBUS_ABORT
- //------------------------------------------------------------------------------
- static UINT8 CbusMidProcessFailureInterrupts(UINT32 CbusTransIntStatus)
- {
- UINT8 result = CBUS_SUCCESS;
- UINT8 mscAbortReason, ddcAbortReason;
- UINT8 mscFailReason;
- CbusDrvDdcAbortReasonGet(&ddcAbortReason);
- CbusDrvMscAbortReasonGet(&mscAbortReason);
- CbusDrvMscFailReasonGet(&mscFailReason);
- if(CbusTransIntStatus)
- {
- // Check for failure interrupts.
- if(mscFailReason != 0)
- {
- mhldbg("CBUS:: ----mscFailReason:%x----\n",mscFailReason);
- mhldbg("CBUS:: ----mscAbortReason:%x----\n",mscAbortReason);
- if(CbusDrvNackFromPeerGet())
- {
- mhldbg("NACK received from peer!!! \n");
- pMidCbus->chState.sendNextWaitTime = CBUS_NACK_WAIT_TIME;
- //responder nack, retry this command
- pMidCbus->chState.state = CBUS_IDLE;
- pMidCbus->chState.request[CH_ACTIVE_INDEX].reqStatus = CBUS_REQ_PENDING;
- result = ERROR_NACK_FROM_PEER;
- }
- else if(mscFailReason != 0)
- {
- //send fail, skip this command
- pMidCbus->chState.state = CBUS_IDLE;
- pMidCbus->chState.request[CH_ACTIVE_INDEX].reqStatus = CBUS_REQ_IDLE;
- if(CbusDrvAbortFromPeerGet())
- {
- //responder abort
- pMidCbus->chState.sendNextWaitTime = CBUS_ABORT_WAIT_TIME;
- mhldbg("ABORT received from peer!!! \n");
- result = ERROR_ABORT_FROM_PEER;
- }
- else if(CbusDrvIneffectCodeFromPeerGet())
- {
- //responder ineffect code
- mhldbg("INEFFECT CODE received from peer!!! \n");
- result = ERROR_INEFFECT_CODE_FROM_PEER;
- }
- else
- {
- mhldbg("MSC other fail 0x%x received from peer!!! \n", mscFailReason);
- result = ERROR_WRITE_FAILED;
- }
- }
- if(CbusTransIntStatus & wrt_stat_intr)
- {
- mhldbg("CBUS:: ----wrt_stat Fail----\n");
- }
- if(CbusTransIntStatus & red_devc_intr)
- {
- mhldbg("CBUS:: ----red_devc Fail----\n");
- }
- if(CbusTransIntStatus & get_state_intr)
- {
- mhldbg("CBUS:: ----get_state Fail----\n");
- }
- if(CbusTransIntStatus & get_ven_id_intr)
- {
- mhldbg("CBUS:: ----get_ven_id Fail----\n");
- }
- if(CbusTransIntStatus & get_src1_err_intr)
- {
- mhldbg("CBUS:: ----get_src1_err Fail----\n");
- }
- if(CbusTransIntStatus & get_ddc_err_intr)
- {
- mhldbg("CBUS:: ----get_ddc_err Fail----\n");
- }
- if(CbusTransIntStatus & get_msc_err_intr)
- {
- mhldbg("CBUS:: ----get_msc_err Fail----\n");
- }
- if(CbusTransIntStatus & get_src3_err_intr)
- {
- mhldbg("CBUS:: ----get_src3_err Fail----\n");
- }
- if(CbusTransIntStatus & wrt_burst_intr)
- {
- mhldbg("CBUS:: ----wrt_burst Fail----\n");
- }
- if(CbusTransIntStatus & set_hpd_intr)
- {
- mhldbg("CBUS:: ----set_hpd Fail----\n");
- }
- if(CbusTransIntStatus & clr_hpd_intr)
- {
- mhldbg("CBUS:: ----clr_hpd Fail----\n");
- }
- if(CbusTransIntStatus & rap_act_ack_intr)
- {
- mhldbg("CBUS:: ----rap_act_ack Fail----\n");
- }
- //NACK packet of MSC_MSG back from respender, wait T_NACK_RETRY_NEXT = 1000ms
- if(CbusTransIntStatus & rcp_cmd_intr)
- {
- mhldbg("CBUS:: ----rcp_cmd Fail----\n");
- }
- if(CbusTransIntStatus & ucp_cmd_intr)
- {
- mhldbg("CBUS:: ----ucp_cmd Fail----\n");
- }
- if(CbusTransIntStatus & rap_cmd_intr)
- {
- mhldbg("CBUS:: ----rap_cmd Fail----\n");
- }
- }
- else
- {
- pMidCbus->chState.state = CBUS_IDLE;
- pMidCbus->chState.request[CH_ACTIVE_INDEX].reqStatus = CBUS_REQ_IDLE;
- }
- if(pMidCbus->chState.request[CH_ACTIVE_INDEX].reqStatus == CBUS_REQ_IDLE)
- CH_ACTIVE_INDEX = CH_NEXT_INDEX; //next index
- if(ddcAbortReason != 0)
- {
- mhldbg("CBUS:: ----ddcAbortReason:%x----\n",ddcAbortReason);
- }
- }
- return(result);
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidCheckInterruptStatus
- // Description: If any interrupts on the specified channel are set, process them.
- // Parameters:
- // Returns: SUCCESS or CBUS_SW_ERR_e error code.
- //------------------------------------------------------------------------------
- BOOL HAVE_MHL_ADOPTER_ID=FALSE;
- static CBUS_SW_ERR_e CbusMidCheckInterruptStatus(void)
- {
- UINT32 CbusTransIntStatus, CbusLinkIntStatus, result;
- UINT8 bData1, bData2;
- UINT16 wAdopterId;
- /* Read CBUS interrupt status. */
- CbusDrvInterruptStatusGet(&CbusTransIntStatus, &CbusLinkIntStatus);
- /* Check for interrupts. */
- result = CBUS_SUCCESS;
- if(CbusTransIntStatus != 0)
- {
- //CbusDrvWriteCommand's intr
- if((CbusTransIntStatus & wrt_stat_intr)||(CbusTransIntStatus & red_devc_intr)||(CbusTransIntStatus & get_state_intr)||(CbusTransIntStatus & get_ven_id_intr)||
- (CbusTransIntStatus & get_src1_err_intr)||(CbusTransIntStatus & get_ddc_err_intr)||(CbusTransIntStatus & get_msc_err_intr)||(CbusTransIntStatus & get_src3_err_intr)||(CbusTransIntStatus & wrt_burst_intr)||
- (CbusTransIntStatus & rcp_cmd_intr)||(CbusTransIntStatus & rap_cmd_intr)||(CbusTransIntStatus & ucp_cmd_intr)||(CbusTransIntStatus & rap_act_ack_intr)||
- (CbusTransIntStatus & set_hpd_intr)||(CbusTransIntStatus & clr_hpd_intr))
- {
- /* A previous MSC sub-command has been acknowledged by the responder. */
- /* Does not include MSC MSG commands.*/
- mhldbg("CBUS:: Transfer Done \n");
- /* Check for failure interrupts. */
- result = CbusMidProcessFailureInterrupts(CbusTransIntStatus);
- //mhldbg("CBUS:: Transfer Done - Data returned: %02X %02X\n", *pData, *pData1);
- }
- if(CbusDrvWrtStateAckInfoGet(&bData1, &bData2) == TRUE)
- {
- if((bData1 == 0x31) && ((bData2 & 0x08) != 0))
- {
- pMidCbus->chState.sinkPathEn = TRUE;
- }
- else if((bData1 == 0x20) && ((bData2 & 0x02) != 0))
- {
- pMidCbus->chState.sinkDscrChgAck = TRUE;
- }
- }
- if(CbusTransIntStatus & rcp_cmd_intr)
- {
- #ifdef MHL_ONLY_ONE_RCP_IN_QUEUE
- if(pMidCbus->chState.SrcNotSprtRcpRelease == TRUE) //if source does not support RCP release command, there is one RCP command in queue
- {
- if(pMidCbus->chState.request[CH_ACTIVE_INDEX].reqStatus == CBUS_REQ_IDLE) //RCP command done, needn't retry
- {
- pMidCbus->chState.existRcpInQueue = FALSE;
- }
- }
- else //if source supports RCP release command, there is two RCP command in queue
- {
- if((pMidCbus->chState.request[CH_ACTIVE_INDEX].reqStatus == CBUS_REQ_IDLE) && (pMidCbus->chState.request[CH_ACTIVE_INDEX].msgData[1] & 0x80) == 0x80) //RCP command done, needn't retry
- {
- pMidCbus->chState.existRcpInQueue = FALSE;
- }
- }
- #endif
- //source does not support RCP release command
- if((result == ERROR_INEFFECT_CODE_FROM_PEER) &&
- (pMidCbus->chState.request[CH_ACTIVE_INDEX].command == MHL_MSC_MSG) &&
- (pMidCbus->chState.request[CH_ACTIVE_INDEX].msgData[0] == MHL_MSC_MSG_RCP) &&
- ((pMidCbus->chState.request[CH_ACTIVE_INDEX].msgData[1] & 0x80) == 0x80))
- {
- mhldbg("Source does not support RCP release command!!! \n");
- pMidCbus->chState.SrcNotSprtRcpRelease = TRUE;
- }
- }
- if(CbusTransIntStatus & req_3d_intr)
- {
- pMidCbus->chState.srcReq3D = TRUE;
- CbusMidSend3DVideoSupportList(TRUE);
- }
- if(CbusTransIntStatus & req_wrt_intr)
- {
- // request received from peer to write into scratchpad
- if(CbusDrvReqWrtGet())
- {
- mhldbg("\n\ngranting peer's request to write scratchpad!!\n");
- CbusMidGrtWrt();
- }
- }
- if(CbusTransIntStatus & grt_wrt_intr)
- {
- // request to write into peer's scratchpad is granted
- if(CbusDrvGrtWrtGet())
- {
- mhldbg("peer sent grtWrt!!\n");
- pMidCbus->chState.srcGrtWrt = TRUE;
- }
- }
- if(CbusTransIntStatus & clr_hpd_intr)
- {
- CbusMidSendCommand(MHL_SET_HPD);
- }
- if(CbusTransIntStatus & set_hpd_intr)
- {
- pMidCbus->chState.setHPD = TRUE;
- }
- if(CbusTransIntStatus & red_devc_intr)
- {
- CbusDrvDevCapGet(&bData1, &bData2);
- pMidCbus->chState.stSrcDevCap.bDevCap[bData1] = bData2;
- if(bData1 == bGetDevCapOffsetArray[DEV_CAP_OFFSET_ARRAY_SIZE-1]) //fetch read_device_capability done
- {
- pMidCbus->chState.stSrcDevCap.fDevCapReady = TRUE;
- wAdopterId = pMidCbus->chState.stSrcDevCap.wAdopterId;
- noticekmf(KMF2UMF_EVID_HDMI, KMF2UMF_EVTYPE_HDMI_MHL_ADOPTER_ID, (UINT8 *)&wAdopterId, 2);
- //print device capability
- mhldbg("[%s] source dev_cap: MHL_VER: 0x%x Dev_type:0x%x Adopter_ID:0x%x\n \tsupport RCP:%d, RAP:%d SP:%d UCP_Send:%d UCP_RECV:%d\n \tDevice_ID:0x%x SP_Size:%d INT_size:%d STAT_Size:%d\n",
- __FUNCTION__, pMidCbus->chState.stSrcDevCap.bMhlVersion, pMidCbus->chState.stSrcDevCap.bDevType, pMidCbus->chState.stSrcDevCap.wAdopterId,
- pMidCbus->chState.stSrcDevCap.bRcpSupport, pMidCbus->chState.stSrcDevCap.bRapSupport, pMidCbus->chState.stSrcDevCap.bSpSupport, pMidCbus->chState.stSrcDevCap.bUcpSendSupport, pMidCbus->chState.stSrcDevCap.bUcpRecvSupport,
- pMidCbus->chState.stSrcDevCap.wDeviceId, pMidCbus->chState.stSrcDevCap.bScratchpadSize, pMidCbus->chState.stSrcDevCap.bIntSize, pMidCbus->chState.stSrcDevCap.bStatSize);
- /* SAMSUNG S2, Note3, Xiaomi do not support RCP release */
- if((pMidCbus->chState.stSrcDevCap.wAdopterId == ADOPTER_ID_SAMSUNG) || (pMidCbus->chState.stSrcDevCap.wAdopterId == ADOPTER_ID_SIMPLAY))
- {
- pMidCbus->chState.SrcNotSprtRcpRelease = TRUE;
- }
- if((pMidCbus->chState.stSrcDevCap.wAdopterId == ADOPTER_ID_SIMPLAY) && (pMidCbus->chState.stSrcDevCap.wDeviceId == DEVICE_ID_SIMPLAY))
- {
- mhldbg("Set MHL_CTS = TRUE !!\n");
- HDMI_MHL_CTS(TRUE);
- }
- else
- {
- mhldbg("Set MHL_CTS = FALSE !!\n");
- HDMI_MHL_CTS(FALSE);
- }
- if(pMidCbus->chState.stSrcDevCap.wAdopterId == 0x00 )
- {
- mhldbg("MHL ADOPTER_ID == 0x00 !!\n");
- HAVE_MHL_ADOPTER_ID = FALSE;
- }
- else
- {
- HAVE_MHL_ADOPTER_ID = TRUE;
- }
- }
- }
- //Peer's Device Capability ready
- if(CbusTransIntStatus & connected_rdy_intr)
- {
- CbusMidSendCommand(MHL_SET_HPD);
- }
- }
- if(CbusLinkIntStatus != 0)
- {
- if((CbusLinkIntStatus & connt_intr)||(CbusLinkIntStatus & attach_intr)||(CbusLinkIntStatus & discv_intr)||(CbusLinkIntStatus & detach_intr))//[2]HDMIRX_CBUS_connt_int__p Nedd check ??
- {
- BOOL Connected;
- /* The connection change interrupt has been received. */
- mhldbg("CBUS:: ----Connection Change----\n");
- // Update component bus status for this channel.
- CbusDrvConnectedGet(&Connected);
- pMidCbus->chState.connected = Connected;
- //printk("[MD_INT] pMidCbus->chState.connected = %d\n", pMidCbus->chState.connected);
- if((CbusLinkIntStatus & discv_intr))
- {
- pMidCbus->chState.sinkPathEn = FALSE;
- pMidCbus->chState.setHPD =FALSE;
- pMidCbus->chState.SrcNotSprtRcpRelease = FALSE;
- HDMI_RegisterWrite(HDMIRX_CBUS_r_reset_reg, 1);
- HDMI_RegisterWrite(HDMIRX_CBUS_r_reset_reg, 0);
- CbusMidResetToIdle();
- #ifdef CONFIG_HDMI_MHL_PORT
- if(DrvHDMIPortSelectBitsGet()==CONFIG_HDMI_MHL_PORT)
- {
- DRV_HDMI_SW_HDCP_RSTN();//After plug in HTC EVO then plug in XIAOMI display NG
- CbusMidSendCommand(MHL_CLR_HPD);//For Samsung 9100 display NG
- //CbusMidSendCommand(MHL_SET_HPD);
- }
- else
- {
- CbusMidSendCommand(MHL_CLR_HPD);
- }
- #else
- // Send MHL_SET_HPD command(same as heartbeat)
- CbusMidSendCommand(MHL_CLR_HPD);//For Samsung 9100 display NG
- CbusMidSendCommand(MHL_SET_HPD);
- #endif
- }
- // If a disconnect, reset the channel write request state machine
- if(pMidCbus->chState.connected == FALSE)
- {
- //set the cbus to idle
- CbusMidResetToIdle();
- }
- }
- }
- CbusDrvInterruptStatusSet(0, 0);//Clear
- return(result);
- }
- //------------------------------------------------------------------------------
- // 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)
- {
- return(pMidCbus->chState.dev_cap_regs_ready_bit);
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidSetDevCapReadyBit
- // Description: set the devCapReady bit
- // Parameters: channel to check, value to set
- // Returns: void
- //------------------------------------------------------------------------------
- void CbusMidSetDevCapReadyBit(BOOL value)
- {
- pMidCbus->chState.dev_cap_regs_ready_bit = 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 result = TRUE;
- if(CbusMidChannelConnected()&&(pMidCbus->chState.setHPD==TRUE))
- {
- mhldbg("CbusMidSendDcapRdyMsg() Called!!\n");
- //send a msg to peer that the device capability registers are ready to be read.
- //set DCAP_RDY bit
- CbusMidSendDcapRdy();
- //set DCAP_CHG bit
- CbusMidSendDcapChange();
- CbusMidSetDevCapReadyBit(TRUE);
- // set path_en bit too
- result = CbusMidPathEnable();
- }
- return result;
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidSendWriteBurst
- // Description: sends MHL write burst cmd
- // Parameters:
- //------------------------------------------------------------------------------
- BOOL CbusMidSendWriteBurst(UINT8 startOffset, UINT8 length, UINT8* pMsgData)
- {
- cbus_req_t req;
- INT32 i;
- req.command = MHL_WRITE_BURST;
- req.offsetData = startOffset;
- req.length = length;
- // write different values in different registers
- for(i = 0; i < length; i++)
- {
- req.msgData[i] = pMsgData[i];
- }
- if(!(CbusMidInsertCmdToQueue(&req)))
- {
- printk("[MHL]Couldn't send Write Burst to peer\n");
- return FALSE;
- }
- return TRUE;
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidSendCommand
- // Description: sends general MHL commands
- // Parameters:
- //------------------------------------------------------------------------------
- BOOL CbusMidSendCommand(UINT8 cmd)
- {
- cbus_req_t req;
- req.command = cmd;
- if(!(CbusMidInsertCmdToQueue(&req)))
- {
- printk("[MHL]Couldn't send cmd: %02X to peer\n", cmd);
- return FALSE;
- }
- return TRUE;
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidSetInt
- // Description: write peer's status registers
- // regOffset - peer's register offset
- // regBit - bit to be set
- //------------------------------------------------------------------------------
- BOOL CbusMidSetInt(UINT8 regOffset, UINT8 regBit)
- {
- cbus_req_t req;
- req.command = MHL_SET_INT;
- req.offsetData = regOffset;
- req.msgData[0] = regBit;
- if(!(CbusMidInsertCmdToQueue(&req)))
- {
- printk("[MHL]Couldn't send MHL_SET_INT to peer\n");
- return FALSE;
- }
- return TRUE;
- }
- //------------------------------------------------------------------------------
- // Function: EdidChange
- // Description: set edid_chg interrupt
- // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
- //------------------------------------------------------------------------------
- BOOL CbusMidEdidChange(void)
- {
- return(CbusMidSetInt(0x01, BIT1));
- }
- //------------------------------------------------------------------------------
- // Function: DcapChange
- // Description:
- // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
- //------------------------------------------------------------------------------
- BOOL CbusMidSendDcapChange(void)
- {
- return(CbusMidSetInt(0x00, BIT0));
- }
- //------------------------------------------------------------------------------
- // Function: CbusDscrChange
- // Description:
- // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
- //------------------------------------------------------------------------------
- BOOL CbusMidSendDscrChange(void)
- {
- return(CbusMidSetInt(0x00, BIT1));
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidReqWrt
- // Description:
- // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
- //------------------------------------------------------------------------------
- BOOL CbusMidReqWrt(void)
- {
- return(CbusMidSetInt(0x00, BIT2));
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidGrtWrt
- // Description:
- // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
- //------------------------------------------------------------------------------
- BOOL CbusMidGrtWrt(void)
- {
- return(CbusMidSetInt(0x00, BIT3));
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidWriteStatus
- // Description: write peer's status registers
- // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
- // regOffset - peer's register offset
- // value - value to be written
- //------------------------------------------------------------------------------
- BOOL CbusMidWriteStatus(UINT8 regOffset, UINT8 value)
- {
- cbus_req_t req;
- req.command = MHL_WRITE_STAT;
- req.offsetData = regOffset;
- req.msgData[0] = value;
- if(!(CbusMidInsertCmdToQueue(&req)))
- {
- printk("[MHL]Couldn't send MHL_WRITE_STAT to peer\n");
- return FALSE;
- }
- return TRUE;
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidPathEnable
- // Description: Check if the channel is an active channel
- // Parameters: port - current active port
- //------------------------------------------------------------------------------
- BOOL CbusMidPathEnable(void)
- {
- mhldbg("[%s]\n", __FUNCTION__);
- #ifdef CONFIG_HDMI_MHL_PORT
- if(DrvHDMIPortSelectBitsGet()==CONFIG_HDMI_MHL_PORT)
- {
- CbusMidWriteStatus(0x01, 0);//Disable PATH_EN bit on peer's appropriate status register(offset 0x31)
- // enable PATH_EN bit on peer's appropriate status register(offset 0x31)
- mhldbg("PathEnable:: Setting bit 3 to peer's status register.\n");
- pMidCbus->isPrevPortMHL = TRUE;
- #if 0 //Need marked for MHL CTS 4.3.23.2
- if(CONFIG_HDMI_MHL_PORT==0)
- {
- HDMI_RegisterWrite(HDMIRX_HDMIP0_Rx_Sense_external, 1);
- HDMI_RegisterWrite(HDMIRX_HDMIP0_Rx_Sense_mux, 1);
- }
- else if(CONFIG_HDMI_MHL_PORT==1)
- {
- HDMI_RegisterWrite(HDMIRX_HDMIP1_Rx_Sense_external, 1);
- HDMI_RegisterWrite(HDMIRX_HDMIP1_Rx_Sense_mux, 1);
- }
- #endif
- return(CbusMidWriteStatus(0x01, BIT3));
- }
- else
- {
- if(pMidCbus->isPrevPortMHL)
- {
- // disable PATH_EN bit on peer's appropriate status register(offset 0x31)
- mhldbg("PathEnable:: Clearing bit 3 to peer's status register.\n");
- pMidCbus->isPrevPortMHL = FALSE;
- return(CbusMidWriteStatus(0x01, 0));
- }
- }
- #endif
- return(TRUE);
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidReadDevCap
- // Description: read peer's status registers
- // Parameters: regOffset - peer's register offset
- //------------------------------------------------------------------------------
- BOOL CbusMidReadDevCap(UINT8 regOffset)
- {
- cbus_req_t req;
- req.command = MHL_READ_DEVCAP;
- req.offsetData = regOffset;
- if(!(CbusMidInsertCmdToQueue(&req)))
- {
- printk("[MHL]Couldn't send MHL_READ_DEVCAP to peer\n");
- return FALSE;
- }
- return TRUE;
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidSendDcapRdy
- // Description:
- // Parameters: channel - CBUS channel to check, must be in range, NOT 0xFF
- //------------------------------------------------------------------------------
- BOOL CbusMidSendDcapRdy(void)
- {
- return(CbusMidWriteStatus(0x00, BIT0));
- }
- //------------------------------------------------------------------------------
- // 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)
- {
- return(pMidCbus->chState.sinkPathEn);
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidGet_HPD_Status
- // Description: check if Set HPD msg has been sent or not
- // Returns: TRUE - success
- // FALSE - failure
- //------------------------------------------------------------------------------
- BOOL CbusMidGet_HPD_Status(void)
- {
- return(pMidCbus->chState.setHPD );
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidSend3DVideoSupportList
- // Description: sends 3D Support list by Write Burst
- // Parameters:
- //------------------------------------------------------------------------------
- BOOL CbusMidSend3DVideoSupportList(BOOL fReset)
- {
- static CBUS_3D_FSM_STATE_e eSend3dListState = CBUS_3D_FSM_FINISHED;
- #ifdef CONFIG_SUPPORT_3D_EN
- #define CBUS_3DLIST_NUM 4
- static UINT8 pb3DList[CBUS_3DLIST_NUM][MHL_MAX_BUFFER_SIZE] = {{0x00, 0x11, 0xEB, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, //DTD_3D
- {0x00, 0x10, 0xD3, 0x0f, 0x01, 0x05, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00}, //VIC_3D
- {0x00, 0x10, 0xD6, 0x0f, 0x02, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}, //VIC_3D
- {0x00, 0x10, 0xD4, 0x0f, 0x03, 0x05, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; //VIC_3D
- #else
- #define CBUS_3DLIST_NUM 2
- static UINT8 pb3DList[CBUS_3DLIST_NUM][MHL_MAX_BUFFER_SIZE] = {{0x00, 0x11, 0xEE, 0x0, 0x1, 0x0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, //DTD_3D null
- {0x00, 0x10, 0xEF, 0x0, 0x1, 0x0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; //VIC_3D null
- #endif
- static UINT8 b3DListIndex = 0, bTimeout_cnt = 0, bTimeout_target =20;
- if(eSend3dListState != CBUS_3D_FSM_FINISHED)
- {
- mhldbg("%s state:%d\n", __FUNCTION__, eSend3dListState);
- }
- if(pMidCbus->chState.srcReq3D == FALSE)
- return TRUE;
- if(fReset == TRUE) //new 3d_intr happened, reset FSM
- {
- eSend3dListState = CBUS_3D_FSM_IDLE;
- b3DListIndex = 0;
- }
- switch(eSend3dListState)
- {
- case CBUS_3D_FSM_IDLE:
- if(pMidCbus->chState.srcReq3D == TRUE)
- eSend3dListState = CBUS_3D_FSM_SEND_REQ_WRT;
- break;
- case CBUS_3D_FSM_SEND_REQ_WRT:
- if(!CbusMidReqWrt()) //send REQ_WRT to request BURST_WRITE
- {
- mhldbg("Couldn't send REQ_WRT list to peer\n");
- return FALSE;
- }
- eSend3dListState = CBUS_3D_FSM_WAIT_GRT_WRT;
- break;
- //case CBUS_3D_FSM_WAIT_REQ_WRT_ACK:
- case CBUS_3D_FSM_WAIT_GRT_WRT:
- if(pMidCbus->chState.srcGrtWrt == TRUE)
- {
- pMidCbus->chState.srcGrtWrt = FALSE;
- eSend3dListState = CBUS_3D_FSM_SEND_BURST_WRT;
- }
- break;
- case CBUS_3D_FSM_SEND_BURST_WRT:
- if(!CbusMidSendWriteBurst(0, MHL_MAX_BUFFER_SIZE, pb3DList[b3DListIndex]))
- {
- mhldbg("Couldn't send 3D[%d] list to peer\n", b3DListIndex);
- return FALSE;
- }
- eSend3dListState = CBUS_3D_FSM_WAIT_BURST_WRT_ACK;
- bTimeout_cnt =0;
- break;
- case CBUS_3D_FSM_WAIT_BURST_WRT_ACK:
- if(CbusDrvWrtBurstAckGet() == TRUE)
- eSend3dListState = CBUS_3D_FSM_SEND_DSCR_CHG;
- else
- {
- bTimeout_cnt++;
- if(bTimeout_cnt == bTimeout_target)
- eSend3dListState = CBUS_3D_FSM_SEND_BURST_WRT;
- }
- break;
- case CBUS_3D_FSM_SEND_DSCR_CHG:
- if(!CbusMidSendDscrChange())
- {
- mhldbg("Couldn't send DSCR_CHG list to peer\n");
- return FALSE;
- }
- eSend3dListState = CBUS_3D_FSM_WAIT_DSCR_CHG_ACK;
- break;
- case CBUS_3D_FSM_WAIT_DSCR_CHG_ACK:
- if(pMidCbus->chState.sinkDscrChgAck == TRUE)
- {
- b3DListIndex++;
- if(b3DListIndex < CBUS_3DLIST_NUM)
- {
- eSend3dListState = CBUS_3D_FSM_SEND_REQ_WRT;
- }
- else
- {
- pMidCbus->chState.srcReq3D = FALSE;
- eSend3dListState = CBUS_3D_FSM_FINISHED;
- }
- pMidCbus->chState.sinkDscrChgAck = FALSE;
- }
- break;
- case CBUS_3D_FSM_FINISHED:
- default:
- break;
- }
- return TRUE;
- }
- //------------------------------------------------------------------------------
- // 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)
- {
- static UINT8 bGetIndex = 0xff;
- if(fReset == TRUE)
- {
- bGetIndex = 0;
- pMidCbus->chState.stSrcDevCap.fDevCapReady = FALSE;
- }
- if((bGetIndex >= DEV_CAP_OFFSET_ARRAY_SIZE) || (pMidCbus->chState.dev_cap_regs_ready_bit == FALSE))
- return TRUE;
- else
- {
- if(CbusMidReadDevCap(bGetDevCapOffsetArray[bGetIndex]) == TRUE)
- {
- //mhldbg("[%s] Offset 0x%x\n", __FUNCTION__, bGetDevCapOffsetArray[bGetIndex]);
- bGetIndex++;
- }
- else
- {
- mhldbg("[%s] Offset 0x%x fail\n", __FUNCTION__, bGetDevCapOffsetArray[bGetIndex]);
- return FALSE;
- }
- }
- return TRUE;
- }
- // This is to check all the Timers
- BOOL CbusMidIsTimeout(void)
- {
- UINT32 tNow = HDMI_GetSysTime();
- if((tNow - pMidCbus->chState.lastSendTime) >= pMidCbus->chState.sendNextWaitTime)
- {
- //mhldbg("[%s] timeout!\n", __FUNCTION__);
- return TRUE;
- }
- else
- {
- mhldbg("[%s] wait timeout!now:%d lastSend:%d wait:%d\n", __FUNCTION__, tNow, pMidCbus->chState.lastSendTime, pMidCbus->chState.sendNextWaitTime);
- return FALSE;
- }
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidHandler
- // Description: Check the state of any current CBUS message on specified channel.
- // Handle responses or failures and send any pending message if
- // channel is IDLE.
- // Returns: SUCCESS or one of CBUS_SW_ERR_e
- //------------------------------------------------------------------------------
- CBUS_SW_ERR_e CbusMidHandler(void)
- {
- CBUS_SW_ERR_e result;
- /* Check the channel interrupt status to see if anybody is */
- /* talking to us. If they are, talk back. */
- result = CbusMidCheckInterruptStatus();
- if(result != CBUS_SUCCESS)
- {
- return (result);
- }
- CbusMidSend3DVideoSupportList(FALSE);
- // check timer for send next command
- if(CbusMidIsTimeout() == FALSE)
- return (result);
- /* check channel to send next command */
- if(pMidCbus->chState.state == CBUS_IDLE)
- CbusMidSendNextInQueue();
- else
- result = CBUS_SUCCESS;
- return (result);
- }
- //------------------------------------------------------------------------------
- // Function: CbusMidInitialize
- // Description: Initialize the CBUS.
- //------------------------------------------------------------------------------
- void CbusMidInitialize(void)
- {
- mhldbg("[%s]\n", __FUNCTION__);
- memset(pMidCbus, 0, sizeof(CbusMidInstanceData_t));
- }
- //------------------------------------------------------------------------------
- // Function: DRV_MHL_SendRcpCmd
- // Description: Receive RCP Command from APP.
- // Returns: None
- //------------------------------------------------------------------------------
- void DRV_MHL_SendRcpCmd(MHL_RCP_CMD_e eRcpCmd)
- {
- mhldbg("[%s] 0x%x\n", __FUNCTION__, eRcpCmd);
- //if(pMidCbus->chState.stSrcDevCap.bRcpSupport == FALSE)
- //{
- // mhldbg("this device does not support RCP\n");
- // return;
- //}
- #ifdef MHL_ONLY_ONE_RCP_IN_QUEUE
- if(pMidCbus->chState.existRcpInQueue == TRUE)
- {
- mhldbg("there is already one RCP in queue, skip this RCP 0x%x\n", eRcpCmd);
- }
- if(CbusMidMscMsgSubCmdSend(MHL_MSC_MSG_RCP, eRcpCmd) == TRUE) //key press
- pMidCbus->chState.existRcpInQueue = TRUE;
- if(pMidCbus->chState.SrcNotSprtRcpRelease == FALSE)
- {
- CbusMidMscMsgSubCmdSend(MHL_MSC_MSG_RCP, 0x80 | eRcpCmd); //key release
- }
- #else
- CbusMidMscMsgSubCmdSend(MHL_MSC_MSG_RCP, eRcpCmd); //key press
- if(pMidCbus->chState.SrcNotSprtRcpRelease == FALSE)
- {
- CbusMidMscMsgSubCmdSend(MHL_MSC_MSG_RCP, 0x80 | eRcpCmd); //key release
- }
- #endif
- }
- //------------------------------------------------------------------------------
- // Function: DRV_MHL_SendRcpPressAndHoldCmd
- // Description: Receive Press And Hold RCP Command from APP.
- // Returns: None
- //------------------------------------------------------------------------------
- void DRV_MHL_SendRcpPressAndHoldCmd(MHL_RCP_CMD_e eRcpCmd ,BOOL fPress)
- {
- mhldbg("[%s] 0x%x Press:%x\n", __FUNCTION__, eRcpCmd,fPress);
- //if(pMidCbus->chState.stSrcDevCap.bRcpSupport == FALSE)
- //{
- // mhldbg("this device does not support RCP\n");
- // return;
- //}
- #ifdef MHL_ONLY_ONE_RCP_IN_QUEUE
- if(pMidCbus->chState.existRcpInQueue == TRUE)
- {
- mhldbg("there is already one RCP in queue, skip this RCP 0x%x\n", eRcpCmd);
- }
- if(fPress == TRUE)
- {
- if(CbusMidMscMsgSubCmdSend(MHL_MSC_MSG_RCP, eRcpCmd) == TRUE) //key press
- pMidCbus->chState.existRcpInQueue = TRUE;
- }
- else
- {
- CbusMidMscMsgSubCmdSend(MHL_MSC_MSG_RCP, 0x80 | eRcpCmd); //key release
- }
- #else
- if(fPress == TRUE)
- {
- CbusMidMscMsgSubCmdSend(MHL_MSC_MSG_RCP, eRcpCmd); //key press
- }
- else
- {
- if(pMidCbus->chState.SrcNotSprtRcpRelease == FALSE)
- {
- CbusMidMscMsgSubCmdSend(MHL_MSC_MSG_RCP, 0x80 | eRcpCmd); //key release
- }
- }
- #endif
- }
- //------------------------------------------------------------------------------
- // Function: MHL_VbusCtrl
- // Description: Turn on or off VBUS.
- // Parameters: vbusEn - 1-Enable; 0 - Disable
- // Returns: TRUE
- //------------------------------------------------------------------------------
- BOOL MHL_VbusCtrl(BOOL vbusEn)
- {
- BOOL success = TRUE;
- sysset_VbusEnable(vbusEn);
- return(success);
- }
- //------------------------------------------------------------------------------
- // Function: MHL_ADOPTER_ID_Check
- // Description: check if device have MHL_ADOPTER_ID
- // Parameters:
- // Returns: TRUE -
- // FALSE -
- //------------------------------------------------------------------------------
- BOOL MHL_ADOPTER_ID_Check(void)
- {
- return(HAVE_MHL_ADOPTER_ID);
- }
- //for debug
- void CbusMidPrintChannelInfo(const UINT8 *bFunc, const UINT32 dLine)
- {
- UINT8 bStr[100] = "";
- char bTemp[10] = "";
- UINT8 i=0,j=0;
- mhldbg("[%s] caller:%s %d\n", __FUNCTION__,bFunc, dLine);
- mhldbg("statusFlags:%d isPrevPortMHL:%d", pMidCbus->statusFlags, pMidCbus->isPrevPortMHL);
- mhldbg("\tconnected:%d state:%d activeIndex:%d dev_cap_regs_ready_bit:%d\n", pMidCbus->chState.connected, pMidCbus->chState.state, pMidCbus->chState.activeIndex, pMidCbus->chState.dev_cap_regs_ready_bit);
- mhldbg("\ttxReq3D:%d txGrtWrt:%d\n", pMidCbus->chState.srcReq3D, pMidCbus->chState.srcGrtWrt);
- for(i = 0; i< CBUS_MAX_COMMAND_QUEUE;i++)
- {
- mhldbg("req[%d] reqStatus:%d command:0x%x offsetData0x%x length:%d\n", i, pMidCbus->chState.request[i].reqStatus, pMidCbus->chState.request[i].command, pMidCbus->chState.request[i].offsetData, pMidCbus->chState.request[i].length);
- memset(bStr, 0, 100);
- for(j = 0; j< MHL_MAX_BUFFER_SIZE;j++)
- {
- sprintf(bTemp, "0x%x ", pMidCbus->chState.request[i].msgData[j]);
- strcat(bStr, bTemp);
- }
- mhldbg("msg: %s\n",bStr);
- }
- }
|