📄 tmbslhdmitx_2.c
字号:
for (i = 0; (i < (UInt)pDis->EdidSadCnt) && (i < aFmtLength); i++) { pEdidAFmts[i].ModeChans = pDis->EdidAFmts[i].ModeChans; pEdidAFmts[i].Freqs = pDis->EdidAFmts[i].Freqs; pEdidAFmts[i].Byte3 = pDis->EdidAFmts[i].Byte3; } } else { /* No pEdidAFmts to copy so set a zero format to be safe */ pEdidAFmts[0].ModeChans = 0; pEdidAFmts[0].Freqs = 0; pEdidAFmts[0].Byte3 = 0; } /* Fill Audio Flags parameter */ *pAudioFlags = ((pDis->EdidCeaFlags & 0x40) << 1); /* Basic audio */ if (pDis->EdidSinkAi == True) { *pAudioFlags += 0x40; /* Mask in AI support */ } /* Fill number of SADs available parameter */ *pAFmtsAvail = pDis->EdidSadCnt; return TM_OK;}#endif /* DEMO_BUILD *//*============================================================================*//* tmbslHdmiTxEdidGetBlockCount *//*============================================================================*/tmErrorCode_ttmbslHdmiTxEdidGetBlockCount( tmUnitSelect_t txUnit, UInt8 *puEdidBlockCount){ tmHdmiTxobject_t *pDis; /* Pointer to Device Instance Structure */ tmErrorCode_t err; /* Error code */ UInt8 edidResult; /* Check unit parameter and point to TX unit object */ err = checkUnitSetDis(txUnit, &pDis); RETIF(err != TM_OK, err) /* Check remaining parameter(s) */ RETIF_BADPARAM(puEdidBlockCount == Null) /* IF the EdidStatus value is not valid in the Device Instance Structure * THEN call tmbslHdmiTxEdidGetBlockData. */ if (pDis->EdidStatus == HDMITX_EDID_NOT_READ) { err = tmbslHdmiTxEdidGetBlockData(txUnit, Null, 0, 0, &edidResult); /* IF the result is not TM_OK THEN return it. */ RETIF(err != TM_OK, err) } *puEdidBlockCount = pDis->EdidBlockCnt; return TM_OK;}/*============================================================================*//* tmbslHdmiTxEdidGetBlockData *//*============================================================================*/tmErrorCode_ttmbslHdmiTxEdidGetBlockData( tmUnitSelect_t txUnit, UInt8 *pRawEdid, Int numBlocks, /* Only relevant if pRawEdid valid */ Int lenRawEdid, /* Only relevant if pRawEdid valid */ UInt8 *pEdidStatus){ tmHdmiTxobject_t *pDis; /* Pointer to Device Instance Structure */ tmErrorCode_t err; /* Error code */ Int i; /* Loop index */ UInt8 extBlockCnt; /* Count of extension blocks */ /* Check unit parameter and point to TX unit object */ err = checkUnitSetDis(txUnit, &pDis); RETIF(err != TM_OK, err) /* Check remaining parameter(s) * We do allow a null pRawEdid pointer, in which case buffer length is * irrelevant. If pRawEdid pointer is valid, there is no point in * continuing if insufficient space for at least one block. */ RETIF_BADPARAM((pRawEdid != Null) && (lenRawEdid < EDID_BLOCK_SIZE)) /* Sensible value of numBlocks? */ RETIF((pRawEdid != Null) && ((numBlocks < 1) || (numBlocks > 255)), TMBSL_ERR_HDMI_INCONSISTENT_PARAMS) /* Enough space for the data requested? */ RETIF((pRawEdid != Null) && (lenRawEdid < (numBlocks * EDID_BLOCK_SIZE)), TMBSL_ERR_HDMI_INCONSISTENT_PARAMS) RETIF_BADPARAM(pEdidStatus == Null) /* Reset the EdidStatus in the Device Instance Structure */ pDis->EdidStatus = HDMITX_EDID_NOT_READ; /* Reset stored parameters from EDID in the Device Instance Structure */ pDis->EdidSinkType = HDMITX_SINK_DVI; pDis->EdidSinkAi = False; pDis->EdidCeaFlags = 0; pDis->EdidSvdCnt = 0; pDis->EdidSadCnt = 0; pDis->EdidSourceAddress = 0; /* 0.0.0.0 */ pDis->NbDTDStored = 0; pDis->EdidFirstMonitorDescriptor.bDescRecord = False; pDis->EdidSecondMonitorDescriptor.bDescRecord = False; pDis->EdidOtherMonitorDescriptor.bDescRecord = False; /* Read the HPD pin via the hpd_in flag in the first interrupt status * register and return a TMBSL_ERR_HDMI_NULL_CONNECTION error if it is * not set. * We must use the flag in the Device Instance Structure to avoid * clearing pending interrupt flags. */ RETIF(pDis->hotPlugStatus != HDMITX_HOTPLUG_ACTIVE, TMBSL_ERR_HDMI_NULL_CONNECTION) /* Get the first EDID block into Device Instance workspace */ err = getEdidBlock(pDis, 0); /* PR11 : On i2c error or bad checksum in block 0 */ /* allow driver to go in state CONNECTED */ if (err != TM_OK) { setState(pDis, EV_GETBLOCKDATA);#ifdef TMFL_TDA9981_SUPPORT#ifdef TMFL_RX_SENSE_ON if (pDis->rxSenseStatus == HDMITX_RX_SENSE_ACTIVE) { setState(pDis, EV_SINKON); }#endif /* TMFL_RX_SENSE_ON */#endif /* TMFL_TDA9981_SUPPORT */ return err; } pDis->EdidStatus = HDMITX_EDID_READ; /* Indicate that status OK so far */ /* If pointer present, copy block from workspace. We know from the * paramenter checking on entry that at least one block is required * and we have the space for it. */ if (pRawEdid != Null) { lmemcpy(pRawEdid, pDis->EdidBlock, EDID_BLOCK_SIZE); } /* Could check block 0 header (0x00,6 x 0xFF,0x00) here but not * certain to be future proof [CEA861C A.2.3] */ /* Read block count from penultimate byte of block and store in DIS */ extBlockCnt = pDis->EdidBlock[EDID_BLK0_EXT_CNT]; /* (For N3, used to have to limit extBlockCnt to one block) */ pDis->EdidBlockCnt = extBlockCnt + 1; /* Total = Block 0 + extensions */ /* Parse block 0 */ parseEdidBlock(pDis, 0); /* If extension blocks are present, process them */ if (extBlockCnt > 0) { for (i = 0; i < extBlockCnt; i++) { /* read block */ err = getEdidBlock(pDis, i+1); /* On this occasion, we also accept INVALID_STATE which means * there was a checksum error */ if ((err != TM_OK) && (err != TMBSL_ERR_HDMI_INVALID_STATE)) { /* PR11 : allow driver to go in state CONNECTED */ setState(pDis, EV_GETBLOCKDATA);#ifdef TMFL_TDA9981_SUPPORT#ifdef TMFL_RX_SENSE_ON if (pDis->rxSenseStatus == HDMITX_RX_SENSE_ACTIVE) { setState(pDis, EV_SINKON); }#endif /* TMFL_RX_SENSE_ON */#endif /* TMFL_TDA9981_SUPPORT */ return err; } /* If pointer was supplied, copy block from DIS to buffer */ if (pRawEdid != Null) { /* Check if we've copied as many as requested yet? */ if ((i + 2) <= numBlocks) { lmemcpy(pRawEdid + ((i + 1) * EDID_BLOCK_SIZE), pDis->EdidBlock, EDID_BLOCK_SIZE); if (err == TMBSL_ERR_HDMI_INVALID_STATE) { /* Note checksum error in EdidStatus */ pDis->EdidStatus = HDMITX_EDID_ERROR; } } else /* Fewer blocks requested than EDID contains, warn */ { if (pDis->EdidStatus == HDMITX_EDID_READ) { pDis->EdidStatus = HDMITX_EDID_READ_INCOMPLETE; } else if (pDis->EdidStatus == HDMITX_EDID_ERROR) { pDis->EdidStatus = HDMITX_EDID_ERROR_INCOMPLETE; } } } /* If the checksum was OK, we can parse the block */ if (err == TM_OK) { parseEdidBlock(pDis, i+1); } } } /* Copy return value from EdidStatus */ *pEdidStatus = pDis->EdidStatus; /* Filter out buffer status from the EdidStatus value in the * Device Instance Structure */ if ((pDis->EdidStatus == HDMITX_EDID_READ) || (pDis->EdidStatus == HDMITX_EDID_READ_INCOMPLETE)) { pDis->EdidStatus = HDMITX_EDID_READ; } else if ((pDis->EdidStatus == HDMITX_EDID_ERROR) || (pDis->EdidStatus == HDMITX_EDID_ERROR_INCOMPLETE)) { pDis->EdidStatus = HDMITX_EDID_ERROR; } setState(pDis, EV_GETBLOCKDATA);#ifdef TMFL_TDA9981_SUPPORT#ifdef TMFL_RX_SENSE_ON if (pDis->rxSenseStatus == HDMITX_RX_SENSE_ACTIVE) { setState(pDis, EV_SINKON); }#endif /* TMFL_RX_SENSE_ON */#endif /* TMFL_TDA9981_SUPPORT */ return TM_OK;}/*============================================================================*//* tmbslHdmiTxEdidGetSinkType *//*============================================================================*/tmErrorCode_ttmbslHdmiTxEdidGetSinkType( tmUnitSelect_t txUnit, tmbslHdmiTxSinkType_t *pSinkType ){ tmHdmiTxobject_t *pDis; /* Pointer to Device Instance Structure */ tmErrorCode_t err; /* Error code */ UInt8 edidResult; /* Check unit parameter and point to TX unit object */ err = checkUnitSetDis(txUnit, &pDis); RETIF(err != TM_OK, err) /* Check remaining parameter(s) */ RETIF_BADPARAM(pSinkType == Null) /* IF the EdidStatus value is not valid in the Device Instance Structure * THEN call tmbslHdmiTxEdidGetBlockData. */ if (pDis->EdidStatus == HDMITX_EDID_NOT_READ) { err = tmbslHdmiTxEdidGetBlockData(txUnit, Null, 0, 0, &edidResult); /* IF the result is not TM_OK THEN return it. */ RETIF(err != TM_OK, err) } *pSinkType = pDis->EdidSinkType; return TM_OK;}/*============================================================================*//* tmbslHdmiTxEdidGetSourceAddress *//*============================================================================*/#ifndef DEMO_BUILDtmErrorCode_ttmbslHdmiTxEdidGetSourceAddress( tmUnitSelect_t txUnit, UInt16 *pSourceAddress ){ tmHdmiTxobject_t *pDis; /* Pointer to Device Instance Structure */ tmErrorCode_t err; /* Error code */ UInt8 edidResult; /* Check unit parameter and point to TX unit object */ err = checkUnitSetDis(txUnit, &pDis); RETIF(err != TM_OK, err) /* Check remaining parameter(s) */ RETIF_BADPARAM(pSourceAddress == Null) /* IF the EdidStatus value is not valid in the Device Instance Structure * THEN call tmbslHdmiTxEdidGetBlockData. */ if (pDis->EdidStatus == HDMITX_EDID_NOT_READ) { err = tmbslHdmiTxEdidGetBlockData(txUnit, Null, 0, 0, &edidResult); /* IF the result is not TM_OK THEN return it. */ RETIF(err != TM_OK, err) } *pSourceAddress = pDis->EdidSourceAddress; return TM_OK;}#endif /* DEMO_BUILD *//*============================================================================*//* tmbslHdmiTxEdidGetVideoCapabilities *//*============================================================================*/tmErrorCode_ttmbslHdmiTxEdidGetVideoCapabilities( tmUnitSelect_t txUnit, UInt8 *pEdidVFmts, UInt vFmtLength, UInt *pVFmtsAvail, UInt8 *pVidFlags){ tmHdmiTxobject_t *pDis; /* Pointer to Device Instance Structure */ tmErrorCode_t err; /* Error code */ UInt i; /* Loop index */ UInt8 edidResult; /* Check unit parameter and point to TX unit object */ err = checkUnitSetDis(txUnit, &pDis); RETIF(err != TM_OK, err) /* Check remaining parameter(s) */ RETIF_BADPARAM(pEdidVFmts == Null) RETIF_BADPARAM(vFmtLength < 1) RETIF_BADPARAM(pVFmtsAvail == Null) RETIF_BADPARAM(pVidFlags == Null)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -