Пример #1
0
/**
 * Check Video parameters against allowed values and read EDID structure
 * to ensure compatibility with sink.
 * @param video video parameters
 */
static int api_CheckParamsVideo(videoParams_t * video)
{
	u8 errorCode = TRUE;
	hdmivsdb_t vsdb;
	dtd_t dtd;
	unsigned i = 0;
	shortVideoDesc_t svd;
	videoCapabilityDataBlock_t capability;
	int valid = FALSE;
	colorimetryDataBlock_t colorimetry;

	LOG_TRACE();
	colorimetryDataBlock_Reset(&colorimetry);
	shortVideoDesc_Reset(&svd);
	dtd_Fill(&dtd, 1, 60000);
	videoCapabilityDataBlock_Reset(&capability);

	if (videoParams_GetHdmi(video))
	{ /* HDMI mode */
		if (api_EdidHdmivsdb(&vsdb) == TRUE)
		{
			if (videoParams_GetColorResolution(video) == 10
					&& !hdmivsdb_GetDeepColor30(&vsdb))
			{
				error_Set(ERR_SINK_DOES_NOT_SUPPORT_30BIT_DC);
				printk("Sink does NOT support 30bits/pixel deep colour mode");
				errorCode = FALSE;
			}
			else if (videoParams_GetColorResolution(video) == 12
					&& !hdmivsdb_GetDeepColor36(&vsdb))
			{
				error_Set(ERR_SINK_DOES_NOT_SUPPORT_36BIT_DC);
				printk("Sink does NOT support 36bits/pixel deep colour mode");
				errorCode = FALSE;
			}
			else if (videoParams_GetColorResolution(video) == 16
					&& !hdmivsdb_GetDeepColor48(&vsdb))
			{
				error_Set(ERR_SINK_DOES_NOT_SUPPORT_48BIT_DC);
				printk("Sink does NOT support 48bits/pixel deep colour mode");
				errorCode = FALSE;
			}
			if (videoParams_GetEncodingOut(video) == YCC444
					&& !hdmivsdb_GetDeepColorY444(&vsdb))
			{
				error_Set(ERR_SINK_DOES_NOT_SUPPORT_YCC444_DC);
				printk("Sink does NOT support YCC444 in deep colour mode");
				errorCode = FALSE;
			}
			if (videoParams_GetTmdsClock(video) > 16500)
			{
				/*
				 * Sink must specify MaxTMDSClk when supports frequencies over 165MHz
				 * GetMaxTMDSClk() is TMDS clock / 5MHz and GetTmdsClock() returns [0.01MHz]
				 * so GetMaxTMDSClk() value must be multiplied by 500 in order to be compared
				 */
				if (videoParams_GetTmdsClock(video) > (hdmivsdb_GetMaxTmdsClk(
						&vsdb) * 500))
				{
					error_Set(ERR_SINK_DOES_NOT_SUPPORT_TMDS_CLOCK);
					LOG_WARNING2("Sink does not support TMDS clock", videoParams_GetTmdsClock(video));
					LOG_WARNING2("Maximum TMDS clock supported is", hdmivsdb_GetMaxTmdsClk(&vsdb) * 500);
					errorCode = FALSE;
				}
			}
		}
		else
		{
			error_Set(ERR_SINK_DOES_NOT_SUPPORT_HDMI);
			printk("Sink does not support HDMI");
			errorCode = FALSE;
		}
		/* video out encoding (YCC/RGB) */
		if (videoParams_GetEncodingOut(video) == YCC444
				&& !api_EdidSupportsYcc444())
		{
			error_Set(ERR_SINK_DOES_NOT_SUPPORT_YCC444_ENCODING);
			printk("Sink does NOT support YCC444 encoding");
			errorCode = FALSE;
		}
		else if (videoParams_GetEncodingOut(video) == YCC422
				&& !api_EdidSupportsYcc422())
		{
			error_Set(ERR_SINK_DOES_NOT_SUPPORT_YCC422_ENCODING);
			printk("Sink does NOT support YCC422 encoding");
			errorCode = FALSE;
		}
		/* check extended colorimetry data and if supported by sink */
		if (videoParams_GetColorimetry(video) == EXTENDED_COLORIMETRY)
		{
			if (api_EdidColorimetryDataBlock(&colorimetry) == TRUE)
			{
				if (!colorimetryDataBlock_SupportsXvYcc601(&colorimetry)
						&& videoParams_GetExtColorimetry(video) == 0)
				{
					error_Set(ERR_SINK_DOES_NOT_SUPPORT_XVYCC601_COLORIMETRY);
					printk("Sink does NOT support xvYcc601 extended colorimetry");
					errorCode = FALSE;
				}
				else if (!colorimetryDataBlock_SupportsXvYcc709(&colorimetry)
						&& videoParams_GetExtColorimetry(video) == 1)
				{
					error_Set(ERR_SINK_DOES_NOT_SUPPORT_XVYCC709_COLORIMETRY);
					printk("Sink does NOT support xvYcc709 extended colorimetry");
					errorCode = FALSE;
				}
				else
				{
					error_Set(ERR_EXTENDED_COLORIMETRY_PARAMS_INVALID);
					printk("Invalid extended colorimetry parameters");
					errorCode = FALSE;
				}
			}
			else
			{
				error_Set(ERR_SINK_DOES_NOT_SUPPORT_EXTENDED_COLORIMETRY);
				errorCode = FALSE;
			}
		}
	}
	else
	{ /* DVI mode */
		if (videoParams_GetColorResolution(video) > 8)
		{
			error_Set(ERR_COLOR_DEPTH_NOT_SUPPORTED);
			printk("DVI - deep color not supported");
			errorCode = FALSE;
		}
		if (videoParams_GetEncodingOut(video) != RGB)
		{
			error_Set(ERR_DVI_MODE_WITH_YCC_ENCODING);
			printk("DVI mode does not support video encoding other than RGB");
			errorCode = FALSE;
		}
		if (videoParams_IsPixelRepetition(video))
		{
			error_Set(ERR_DVI_MODE_WITH_PIXEL_REPETITION);
			printk("DVI mode does not support pixel repetition");
			errorCode = FALSE;
		}
		if (videoParams_GetTmdsClock(video) > 16500)
		{
			printk("Sink must support DVI dual-link");
		}
		/* check colorimetry data */
		if ((videoParams_GetColorimetry(video) == EXTENDED_COLORIMETRY))
		{
			error_Set(ERR_DVI_MODE_WITH_EXTENDED_COLORIMETRY);
			printk("DVI does not support extended colorimetry");
			errorCode = FALSE;
		}
	}
	/*
	 * DTD check
	 * always checking VALID to minimise code execution (following probability)
	 * this video code is to be supported by all dtv's
	 */
	valid = (dtd_GetCode(videoParams_GetDtd(video)) == 1) ? TRUE : FALSE;
	if (!valid)
	{
		for (i = 0; i < api_EdidDtdCount(); i++)
		{
			api_EdidDtd(i, &dtd);
			if (dtd_GetCode(videoParams_GetDtd(video)) != (u8) (-1))
			{
				if (dtd_GetCode(videoParams_GetDtd(video)) == dtd_GetCode(&dtd))
				{
					valid = TRUE;
					break;
				}
			}
			else if (dtd_IsEqual(videoParams_GetDtd(video), &dtd))
			{
				valid = TRUE;
				break;
			}
		}
	}
	if (!valid)
	{
		if (dtd_GetCode(videoParams_GetDtd(video)) != (u8) (-1))
		{
			for (i = 0; i < api_EdidSvdCount(); i++)
			{
				api_EdidSvd(i, &svd);
				if ((unsigned) (dtd_GetCode(videoParams_GetDtd(video)))
						== shortVideoDesc_GetCode(&svd))
				{
					valid = TRUE;
					break;
				}
			}
		}
	}
	if (!valid)
	{
		error_Set(ERR_SINK_DOES_NOT_SUPPORT_SELECTED_DTD);
		printk("Sink does NOT indicate support for selected DTD");
		errorCode = FALSE;
	}
	/* check quantization range */
	if (api_EdidVideoCapabilityDataBlock(&capability) == TRUE)
	{
		if (!videoCapabilityDataBlock_GetQuantizationRangeSelectable(
				&capability) && videoParams_GetRgbQuantizationRange(video) > 1)
		{
			printk("Sink does NOT indicate support for selected quantization range");
		}
	}
	return errorCode;
}
Пример #2
0
static int hdmi_config(struct jzhdmi *jzhdmi)
{
	u8 currentMode = 0;
	hdmivsdb_t vsdb;
	shortVideoDesc_t tmp_svd;
	dtd_t tmp_dtd;
	u8 ceaCode = 0;
	u8 errorCode = NO_ERROR;
	u8 svdNo=0;
	/* needed to make sure it doesn't change while in this function*/
	struct device *dev = jzhdmi->dev;

	videoParams_t *pVideo = jzhdmi->hdmi_params.pVideo;
	audioParams_t *pAudio = jzhdmi->hdmi_params.pAudio;
	hdcpParams_t *pHdcp = jzhdmi->hdmi_params.pHdcp;
	productParams_t *pProduct = jzhdmi->hdmi_params.pProduct;

	svdNo = api_EdidSvdCount();

	if ((api_EdidHdmivsdb(&vsdb) == TRUE) && (jzhdmi->edid_faild == 0)) {
		dev_info(dev, "==========>HDMI mode\n");
		videoParams_SetHdmi(pVideo, TRUE);
		/* TODO:
		   if (hdmivsdb_GetDeepColor48(&vsdb)) {
		   videoParams_SetColorResolution(pVideo, 16);
		   } else if (hdmivsdb_GetDeepColor36(&vsdb)) {
		   videoParams_SetColorResolution(pVideo, 12);
		   } else if (hdmivsdb_GetDeepColor30(&vsdb)) {
		   videoParams_SetColorResolution(pVideo, 10);
		   } else {
		   videoParams_SetColorResolution(pVideo, 0);
		   }
		   */
		videoParams_SetColorResolution(pVideo, 0);

		if (currentMode >= svdNo) {
			currentMode = 0;
		}
#ifdef HDMI_JZ4780_DEBUG
		dev_info(jzhdmi->dev, "=====> cur==%d  svno=%d\n",currentMode,svdNo);
#endif
		for (; currentMode < svdNo; currentMode++) {
			if (api_EdidSvd(currentMode, &tmp_svd)) {
				ceaCode = shortVideoDesc_GetCode(&tmp_svd);
				if (ceaCode != jzhdmi->hdmi_info.out_type) continue;
				if (board_SupportedRefreshRate(ceaCode) != -1) {
					dtd_Fill(&tmp_dtd, ceaCode, board_SupportedRefreshRate(ceaCode));
					videoParams_SetDtd(pVideo, &tmp_dtd);
				} else {
					dev_err(dev, "CEA mode not supported\n");
					continue;
				}
			}

			if (api_Configure(pVideo, pAudio, pProduct, pHdcp)) {
				dev_info(dev, "----api_Configure ok\n");
				break;
			}
			dev_err(dev, "error: VM = %d\n", ceaCode);
			errorCode = error_Get();

			if (errorCode == ERR_HDCP_FAIL) {
				system_SleepMs(1000);
				currentMode--;
			}
		}

		if (currentMode >= svdNo) {
			/* spanned all SVDs and non works, sending VGA */
			dev_err(dev, "error spanned all SVDs and non works\n");
			dtd_Fill(&tmp_dtd, 1, board_SupportedRefreshRate(1));
			videoParams_SetDtd(pVideo, &tmp_dtd);
			api_Configure(pVideo, pAudio, pProduct, pHdcp);
		}

		/* lltang add test overflow */
		if(0){
			/* ====>tmds reset  */
			access_CoreWrite(1, 0x4002, 1, 1);
			/* ====>video_Configure again */
			if (video_Configure(0, pVideo, 1, FALSE) != TRUE) {
				return FALSE;
			}
			access_CoreWriteByte(0x0, 0x10DA);
		}

	} else {
		dev_info(dev, "Force into hdmi mode!\n");
#ifndef DVIMODE 
		videoParams_SetHdmi(pVideo, TRUE);
		videoParams_SetColorResolution(pVideo, 0);

		if (currentMode >= svdNo) {
			currentMode = 0;
		}
#ifdef HDMI_JZ4780_DEBUG
		dev_info(jzhdmi->dev, "=====>out_type=%d\n",jzhdmi->hdmi_info.out_type);
#endif
		ceaCode = jzhdmi->hdmi_info.out_type;
		if (board_SupportedRefreshRate(ceaCode) != -1) {
			dtd_Fill(&tmp_dtd, ceaCode, board_SupportedRefreshRate(ceaCode));
			videoParams_SetDtd(pVideo, &tmp_dtd);
		} else {
			dev_err(dev, "CEA mode not supported\n");
		}

		if (api_Configure(pVideo, pAudio, pProduct, pHdcp)) {
			dev_info(dev, "api_Configure ok\n");
		}
	}
#else
		dev_info(dev, "====DVI mode!\n");
		videoParams_SetHdmi(pVideo, FALSE);
		videoParams_SetColorResolution(pVideo, 0);
		if (currentMode >= api_EdidDtdCount()) {
			currentMode = 0;
		}
		for (; currentMode < api_EdidDtdCount(); currentMode++) {
			continue;
			if (api_EdidDtd(currentMode, &tmp_dtd)) {
				ceaCode = cliEdid_GetDtdCode(&tmp_dtd);
				dev_info(dev, "check ceaCode = %d\n", ceaCode);
				if (ceaCode != 3) continue;
				dev_info(dev, "find ceaCode = %d\n", ceaCode);
				dtd_Fill(&tmp_dtd, ceaCode, board_SupportedRefreshRate(ceaCode));
				videoParams_SetDtd(pVideo, &tmp_dtd);
			}
			if (api_Configure(pVideo, pAudio, pProduct, pHdcp)) {
				break;
			}
			errorCode = error_Get();
			dev_err(dev, "API configure fail\n");
			if (errorCode == ERR_HDCP_FAIL) {
				system_SleepMs(1000);
				currentMode--;
			}
		}
		if (currentMode >= api_EdidDtdCount()) {
			dev_err(dev, "spanned all dtds and non works, sending VGA\n");
			dtd_Fill(&tmp_dtd, 1, board_SupportedRefreshRate(1));
			videoParams_SetDtd(pVideo, &tmp_dtd);
			api_Configure(pVideo, pAudio, pProduct, pHdcp);
		}
	}