Ejemplo n.º 1
0
void api_PacketsIsrc(u8 initStatus, u8 * codes, u8 length, u8 autoSend)
{
	hdmivsdb_t vsdb;

	LOG_TRACE();
	/* check if sink supports ISRC packets */
	if (api_EdidHdmivsdb(&vsdb))
	{
		if (!hdmivsdb_GetSupportsAi(&vsdb))
		{
			LOG_ERROR("sink does NOT support ISRC");
		}
	}
	else
	{
		printk("sink is NOT HDMI compliant: ISRC may not work");
	}
	packets_IsrcPackets(api_mBaseAddress, initStatus, codes, length, autoSend);
}
Ejemplo n.º 2
0
void api_PacketsAudioContentProtection(u8 type, u8 * fields, u8 length,
		u8 autoSend)
{
	hdmivsdb_t vsdb;

	LOG_TRACE();
	/* check if sink supports ACP packets */
	if (api_EdidHdmivsdb(&vsdb))
	{
		if (!hdmivsdb_GetSupportsAi(&vsdb))
		{
			LOG_ERROR("sink does NOT support ACP");
		}
	}
	else
	{
		printk("sink is NOT HDMI compliant: ACP may not work");
	}
	packets_AudioContentProtection(api_mBaseAddress, type, fields, length,
			autoSend);
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
0
int api_Configure(videoParams_t * video, audioParams_t * audio,
		productParams_t * product, hdcpParams_t * hdcp)
{
	hdmivsdb_t vsdb;
//	int audioOn = 0;  //lltang audio on
	int audioOn = 1;
	int success = TRUE;
	int hdcpOn = (hdcp != 0 && (control_SupportsHdcp(api_mBaseAddress) == TRUE)) ? TRUE : FALSE;
	LOG_TRACE();

	if (video == NULL)
	{
		error_Set(ERR_HPD_LOST);
		LOG_ERROR("video params invalid");
		return FALSE;
	}
	audioOn = (audio != 0 && videoParams_GetHdmi(video));

	if (api_mCurrentState < API_HPD)
	{
		error_Set(ERR_HPD_LOST);
		LOG_ERROR("cable not connected");
		return FALSE;
	}
	else if (api_mCurrentState == API_HPD)
	{
		printk("E-EDID not read. Media may not be supported by sink\n");
	}
	else if (api_mCurrentState == API_EDID_READ)
	{
		api_CheckParamsVideo(video);
		if (api_EdidHdmivsdb(&vsdb))
		{
			if (!hdmivsdb_GetDeepColor30(&vsdb) && !hdmivsdb_GetDeepColor36(&vsdb)
					&& !hdmivsdb_GetDeepColor48(&vsdb))
			{
				videoParams_SetColorResolution(video, 0);
			}
		}
	}
	control_InterruptMute(api_mBaseAddress, ~0); /* disable interrupts */
#ifdef CONFIG_HMDI_JZ4780_DEBUG
	printk("=====>disable TX_INT in %s:%d\n", __func__, __LINE__);
#endif
	system_InterruptDisable(TX_INT);
	do
	{
		if (video_Configure(api_mBaseAddress, video, api_mDataEnablePolarity,
				hdcpOn) != TRUE)
		{
			success = FALSE;
			break;
		}
		if (audioOn)
		{
			if (api_mCurrentState == API_EDID_READ)
			{
				api_CheckParamsAudio(audio);
			}
#if 0  //del by lltang
			if (board_AudioClock(api_mBaseAddress, audioParams_AudioClock(audio))
						!= TRUE)
			{
				success = FALSE;
				break;
			}
#endif
			if (audio_Configure(api_mBaseAddress, audio, videoParams_GetPixelClock(
					video), videoParams_GetRatioClock(video)) != TRUE)
			{
				success = FALSE;
				break;
			}
			packets_AudioInfoFrame(api_mBaseAddress, audio);
		}
		else if (audio != 0 && videoParams_GetHdmi(video) != TRUE)
		{
			printk("DVI mode selected: audio not configured\n");
		}
		else
		{
			printk("No audio parameters provided: not configured\n");
		}
		if (videoParams_GetHdmi(video) == TRUE)
		{
			if (packets_Configure(api_mBaseAddress, video, product) != TRUE)
			{
				success = FALSE;
				break;
			}
			api_mSendGamutOk = (videoParams_GetEncodingOut(video) == YCC444)
					|| (videoParams_GetEncodingOut(video) == YCC422);
			api_mSendGamutOk = api_mSendGamutOk && (videoParams_GetColorimetry(
					video) == EXTENDED_COLORIMETRY);
		}
		else
		{
			printk("DVI mode selected: packets not configured\n");
		}
		if (hdcpOn == TRUE)
		{	/* HDCP is PHY independent */
			if (hdcp_Configure(api_mBaseAddress, hdcp, videoParams_GetHdmi(video),
					dtd_GetHSyncPolarity(videoParams_GetDtd(video)),
					dtd_GetVSyncPolarity(videoParams_GetDtd(video))) == FALSE)
			{
				printk("HDCP not configured\n");
				hdcpOn = FALSE;
				success = FALSE;
				break;
			}
		}
		else if (hdcp != 0 && control_SupportsHdcp(api_mBaseAddress) != TRUE)
		{
			printk("HDCP is not supported by hardware\n");
		}
		else
		{
			printk("No HDCP parameters provided: not configured\n");
		}
		if (board_PixelClock(api_mBaseAddress, videoParams_GetPixelClock(video),
				videoParams_GetColorResolution(video)) != TRUE)
		{
			success = FALSE;
			break;
		}
		if (control_Configure(api_mBaseAddress, videoParams_GetPixelClock(video),
				videoParams_GetPixelRepetitionFactor(video),
				videoParams_GetColorResolution(video),
				videoParams_IsColorSpaceConversion(video), audioOn, FALSE, hdcpOn)
				!= TRUE)
		{
			success = FALSE;
			break;
		}
		if (phy_Configure(api_mBaseAddress, videoParams_GetPixelClock(video),
			videoParams_GetColorResolution(video),
			videoParams_GetPixelRepetitionFactor(video)) != TRUE)
		{
			success = FALSE;
			break;
		}
		/* disable blue screen transmission after turning on all necessary blocks (e.g. HDCP) */
		if (video_ForceOutput(api_mBaseAddress, FALSE) != TRUE)
		{
			success = FALSE;
			break;
		}
		/* reports HPD state to HDCP */
		if (hdcpOn)
		{
			hdcp_RxDetected(api_mBaseAddress, phy_HotPlugDetected(
					api_mBaseAddress));
		}
		/* send AVMUTE CLEAR (optional) */
		api_mCurrentState = API_CONFIGURED;
	}
	while(0);
	control_InterruptMute(api_mBaseAddress, 0); /* enable interrupts */
#ifdef CONFIG_HMDI_JZ4780_DEBUG
	printk("hdmi enable TX_INT in %s:%d\n", __func__, __LINE__);
#endif
	system_InterruptEnable(TX_INT);
	return success;
}
Ejemplo n.º 5
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);
		}
	}