📄 tmbslhdmitx_2.c
字号:
/* 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) } /* Copy the Device Instance Structure EdidVFmts descriptors to * pEdidVFmts until we run out or no more space in structure. */ if (pDis->EdidSvdCnt > 0) { for (i = 0; (i < (UInt)pDis->EdidSvdCnt) && (i < vFmtLength); i++) { pEdidVFmts[i] = pDis->EdidVFmts[i]; } } else { /* No pEdidVFmts to copy so set a zero format to be safe */ pEdidVFmts[0] = HDMITX_VFMT_NULL; } /* Fill Video Flags parameter */ *pVidFlags = ((pDis->EdidCeaFlags & 0x80) | /* Underscan */ ((pDis->EdidCeaFlags & 0x30) << 1) ); /* YUV444, YUV422 */ /* Fill number of SVDs available parameter */ *pVFmtsAvail = pDis->EdidSvdCnt; return TM_OK;}/*============================================================================*//* tmbslHdmiTxEdidGetVideoPreferred *//*============================================================================*/#ifndef DEMO_BUILDtmErrorCode_ttmbslHdmiTxEdidGetVideoPreferred( tmUnitSelect_t txUnit, tmbslHdmiTxEdidDtd_t *pEdidDTD){ 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(pEdidDTD == 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) } /* Populate the Detailed Timing Descriptor structure pEdidDTD from * EdidDtd in the Device Instance Structure. */ lmemcpy(pEdidDTD, &pDis->EdidDTD, sizeof(*pEdidDTD)); return TM_OK;}#endif /* DEMO_BUILD */#ifndef DEMO_BUILDtmErrorCode_ttmbslHdmiTxEdidGetDetailedTimingDescriptors( tmUnitSelect_t txUnit, tmbslHdmiTxEdidDtd_t *pEdidDTD, UInt8 nb_size, UInt8 *pDTDAvail){ tmHdmiTxobject_t *pDis; /* Pointer to Device Instance Structure */ tmErrorCode_t err; /* Error code */ /* Check unit parameter and point to TX unit object */ err = checkUnitSetDis(txUnit, &pDis); RETIF(err != TM_OK, err) /* Check remaining parameter(s) */ RETIF_BADPARAM(pEdidDTD == Null) RETIF_BADPARAM(pDTDAvail == Null) RETIF_BADPARAM(nb_size == 0) if ((pDis->EdidStatus == HDMITX_EDID_READ) || (pDis->EdidStatus == HDMITX_EDID_ERROR) || (pDis->EdidStatus == HDMITX_EDID_ERROR_INCOMPLETE) ) { /* allow if edid are read or if there are a chk error on an other block than block 0 */ if (nb_size > pDis->NbDTDStored) { *pDTDAvail = pDis->NbDTDStored; } else { *pDTDAvail = nb_size; } lmemcpy(pEdidDTD, pDis->EdidDTD, sizeof(tmbslHdmiTxEdidDtd_t) * (*pDTDAvail)); } else { /* Not allowed if EdidStatus value is not valid */ err = TMBSL_ERR_HDMI_INVALID_STATE; } return TM_OK;}#endif /* DEMO_BUILD *//*============================================================================*//* tmbslHdmiTxMatrixSetCoeffs *//*============================================================================*/#ifndef DEMO_BUILDtmErrorCode_ttmbslHdmiTxMatrixSetCoeffs( tmUnitSelect_t txUnit, tmbslHdmiTxMatCoeff_t *pMatCoeff){ tmHdmiTxobject_t *pDis; /* Pointer to Device Instance Structure */ tmErrorCode_t err; /* Error code */ Int i; /* Loop index */ UInt8 buf[HDMITX_MAT_COEFF_NUM * 2]; /* Temp buffer */ /* Check unit parameter and point to TX unit object */ err = checkUnitSetDis(txUnit, &pDis); RETIF(err != TM_OK, err) /* Check remaining parameter(s) */ RETIF_BADPARAM(pMatCoeff == (tmbslHdmiTxMatCoeff_t *)0) for (i = 0; i < HDMITX_MAT_COEFF_NUM; i++) { RETIF_BADPARAM((pMatCoeff->Coeff[i] < HDMITX_MAT_OFFSET_MIN) || (pMatCoeff->Coeff[i] > HDMITX_MAT_OFFSET_MAX)) } /* Convert signed 11 bit values from Coeff array to pairs of MSB-LSB * register values, and write to register pairs */ for (i = 0; i < HDMITX_MAT_COEFF_NUM; i++) { /* Mask & copy MSB */ buf[i*2] = (UInt8)(((UInt16)pMatCoeff->Coeff[i] & 0x0700) >> 8); /* Copy LSB */ buf[(i*2)+1] = (UInt8)((UInt16)pMatCoeff->Coeff[i] & 0x00FF); } err = setHwRegisters(pDis, E_REG_P00_MAT_P11_MSB_W, &buf[0], HDMITX_MAT_COEFF_NUM * 2); return err;}#endif /* DEMO_BUILD *//*============================================================================*//* tmbslHdmiTxMatrixSetConversion *//*============================================================================*/tmErrorCode_ttmbslHdmiTxMatrixSetConversion( tmUnitSelect_t txUnit, tmbslHdmiTxVidFmt_t vinFmt, tmbslHdmiTxVinMode_t vinMode, tmbslHdmiTxVidFmt_t voutFmt, tmbslHdmiTxVoutMode_t voutMode){ tmHdmiTxobject_t *pDis; /* Ptr to Device Instance Structure */ tmErrorCode_t err; /* Error code */ tmbslHdmiTxColourspace_t cspace_in; /* Input colourspaces */ tmbslHdmiTxColourspace_t cspace_out; /* Output colourspaces */ Int matrixIndex;/* Index into matrix preset array */ UInt8 buf[MATRIX_PRESET_SIZE]; /* Temp buffer */ UInt8 i; /* Loop index */ /* Check unit parameter and point to TX unit object */ err = checkUnitSetDis(txUnit, &pDis); RETIF(err != TM_OK, err) /* Check remaining parameter(s) */ RETIF_BADPARAM( ((vinFmt < HDMITX_VFMT_TV_MIN) || (vinFmt > HDMITX_VFMT_PC_MAX)) || ((vinFmt > HDMITX_VFMT_TV_MAX) && (vinFmt < HDMITX_VFMT_PC_MIN))) /* NB: NO_CHANGE is not valid for this function, so limit to actual values*/ RETIF_BADPARAM(vinMode >= HDMITX_VINMODE_NO_CHANGE) RETIF_BADPARAM( ((voutFmt < HDMITX_VFMT_TV_MIN) || (voutFmt > HDMITX_VFMT_PC_MAX)) || ((voutFmt > HDMITX_VFMT_TV_MAX) && (voutFmt < HDMITX_VFMT_PC_MIN))) /* NB: NO_CHANGE is not valid for this function, so limit to actual values*/ RETIF_BADPARAM(voutMode >= HDMITX_VOUTMODE_NO_CHANGE) /* Since vinMode and voutMode are different types, we don't use a local function to do this and use inline code twice */ /* Calculate input colour space */ if((vinFmt == HDMITX_VFMT_TV_MIN) || (vinFmt >= HDMITX_VFMT_PC_MIN)) { /* Catch the VGA or PC formats */ cspace_in = HDMITX_CS_RGB_FULL; } else { switch (vinFmt) { /* Catch the HD modes */ case HDMITX_VFMT_04_1280x720p_60Hz: case HDMITX_VFMT_05_1920x1080i_60Hz: case HDMITX_VFMT_16_1920x1080p_60Hz: case HDMITX_VFMT_19_1280x720p_50Hz: case HDMITX_VFMT_20_1920x1080i_50Hz: case HDMITX_VFMT_31_1920x1080p_50Hz: case HDMITX_VFMT_32_1920x1080p_24Hz: case HDMITX_VFMT_33_1920x1080p_25Hz: case HDMITX_VFMT_34_1920x1080p_30Hz: if(vinMode == HDMITX_VINMODE_RGB444) /* RGB */ { cspace_in = HDMITX_CS_RGB_LIMITED; } else /* CCIR656, YUV444, YU422 */ { cspace_in = HDMITX_CS_YUV_ITU_BT709; } break; default: /* Now all the SD modes */ if(vinMode == HDMITX_VINMODE_RGB444) /* we're RGB */ { cspace_in = HDMITX_CS_RGB_LIMITED; } else /* CCIR656, YUV444, YU422 */ { cspace_in = HDMITX_CS_YUV_ITU_BT601; } break; } } /* Calculate output colour space */ if((voutFmt == HDMITX_VFMT_TV_MIN) || (voutFmt >= HDMITX_VFMT_PC_MIN)) { /* Catch the VGA or PC formats */ cspace_out = HDMITX_CS_RGB_FULL; } else { switch (voutFmt) { /* Catch the HD modes */ case HDMITX_VFMT_04_1280x720p_60Hz: case HDMITX_VFMT_05_1920x1080i_60Hz: case HDMITX_VFMT_16_1920x1080p_60Hz: case HDMITX_VFMT_19_1280x720p_50Hz: case HDMITX_VFMT_20_1920x1080i_50Hz: case HDMITX_VFMT_31_1920x1080p_50Hz: case HDMITX_VFMT_32_1920x1080p_24Hz: case HDMITX_VFMT_33_1920x1080p_25Hz: case HDMITX_VFMT_34_1920x1080p_30Hz: if(voutMode == HDMITX_VOUTMODE_RGB444) /* RGB */ { cspace_out = HDMITX_CS_RGB_LIMITED; } else /* YUV444 or YUV422 */ { cspace_out = HDMITX_CS_YUV_ITU_BT709; } break; default: /* Now all the SD modes */ if(voutMode == HDMITX_VOUTMODE_RGB444) /* RGB */ { cspace_out = HDMITX_CS_RGB_LIMITED; } else /* YUV444 or YUV422 */ { cspace_out = HDMITX_CS_YUV_ITU_BT601; } break; } } if (cspace_in == cspace_out) { /* Switch off colour matrix by setting bypass flag */ err = setHwRegisterField(pDis, E_REG_P00_MAT_CONTRL_W, E_MASKREG_P00_MAT_CONTRL_mat_bp, 1); } else { /* Load appropriate values into matrix - we have preset blocks of * 31 register vales in a table, just need to work out which set to use */ matrixIndex = kMatrixIndex[cspace_in][cspace_out]; /* Set the first block byte separately, as it is shadowed and can't * be set by setHwRegisters */ err = setHwRegister(pDis, E_REG_P00_MAT_CONTRL_W, kMatrixPreset[matrixIndex][0]); RETIF_REG_FAIL(err) for (i = 0; i < MATRIX_PRESET_SIZE; i++) { buf[i] = kMatrixPreset[matrixIndex][i]; } /* Set the rest of the block */ err = setHwRegisters(pDis, E_REG_P00_MAT_OI1_MSB_W, &buf[1], MATRIX_PRESET_SIZE - 1); } return err;}/*============================================================================*//* tmbslHdmiTxMatrixSetInputOffset *//*============================================================================*/#ifndef DEMO_BUILDtmErrorCode_ttmbslHdmiTxMatrixSetInputOffset( tmUnitSelect_t txUnit, tmbslHdmiTxMatOffset_t *pMatOffset){ tmHdmiTxobject_t *pDis; /* Pointer to Device Instance Structure */ tmErrorCode_t err; /* Error code */ Int i; /* Loop index */ UInt8 buf[HDMITX_MAT_OFFSET_NUM * 2]; /* Temp buffer */ /* Check unit parameter and point to TX unit object */ err = checkUnitSetDis(txUnit, &pDis); RETIF(err != TM_OK, err) /* Check remaining parameter(s) */ RETIF_BADPARAM(pMatOffset == (tmbslHdmiTxMatOffset_t *)0) for (i = 0; i < HDMITX_MAT_OFFSET_NUM; i++) { RETIF_BADPARAM((pMatOffset->Offset[i] < HDMITX_MAT_OFFSET_MIN) || (pMatOffset->Offset[i] > HDMITX_MAT_OFFSET_MAX)) } /* Convert signed 11 bit values from Offset array to pairs of MSB-LSB
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -