bool _s5p_tv_if_init_hd_reg(void)
{
	struct s5p_tv_status *st = &s5ptv_status;
	bool timing_correction_en = st->hdmi_tg_cmd.timing_correction_en;
	bool bt656_sync_en = st->hdmi_tg_cmd.bt656_sync_en;
	bool tg_en;

	TVOUTIFPRINTK("audio type : %d, hdcp : %s)\n\r",
		st->hdmi_audio_type, st->hdcp_en ? "enabled" : "disabled");

/* C110_HDCP:
	if (st->hdcp_en) {
		if (!(st->hpd_status)) {
			TVOUTIFPRINTK("HPD is not detected\n\r");
			return false;
		}
	}
*/

	if (!_s5p_tv_if_init_hd_video_reg())
		return false;

	switch (st->hdmi_audio_type) {

	case HDMI_AUDIO_PCM:
		/* 
		* PCM, Samplingrate 44100, 16bit, 
		* ignore framesize cuz stream is PCM.
		*/
		__s5p_hdmi_audio_init(PCM, 44100, 16, 0); 
		break;

	case HDMI_AUDIO_NO:
		break;

	default:
		TVOUTIFPRINTK("invalid hdmi_audio_type(%d)\n\r",
			st->hdmi_audio_type);
		return false;
		break;
	}

	if (!__s5p_hdmi_start(st->hdmi_audio_type,
			      st->hdcp_en,
			      st->hdcp_i2c_client)) {
		return false;
	}

	st->hdmi_tg_cmd.tg_en = true;
	tg_en = st->hdmi_tg_cmd.tg_en;

	__s5p_hdmi_video_init_tg_cmd(timing_correction_en,
		bt656_sync_en, tg_en);

	return true;
}
/*
 * TV cut off sequence
 * VP stop -> Mixer stop -> HDMI stop -> HDMI TG stop
 * Above sequence should be satisfied.
 */
bool _s5p_tv_if_stop(void)
{
	struct s5p_tv_status *st = &s5ptv_status;

	bool t_corr_en 	 = st->hdmi_tg_cmd.timing_correction_en;
	bool sync_en 	 = st->hdmi_tg_cmd.bt656_sync_en;
	enum s5p_tv_o_mode out_mode = st->tvout_param.out_mode;

	TVOUTIFPRINTK("tvout sub sys. stopped!!\n");

	__s5p_vm_stop();

	switch (out_mode) {

	case TVOUT_OUTPUT_COMPOSITE:

	case TVOUT_OUTPUT_SVIDEO:

	case TVOUT_OUTPUT_COMPONENT_YPBPR_INERLACED:

	case TVOUT_OUTPUT_COMPONENT_YPBPR_PROGRESSIVE:

	case TVOUT_OUTPUT_COMPONENT_RGB_PROGRESSIVE:
		if (st->tvout_output_enable)
			__s5p_sdout_stop();
		break;

	case TVOUT_OUTPUT_HDMI:
	case TVOUT_OUTPUT_HDMI_RGB:
	case TVOUT_OUTPUT_DVI:
		if (st->tvout_output_enable) {
			__s5p_hdmi_stop();
			__s5p_hdmi_video_init_tg_cmd(t_corr_en, sync_en,
				false);
		}
		break;

	default:
		TVOUTIFPRINTK("invalid out_mode parameter(%d)\n\r", out_mode);
		return false;
		break;
	}


#ifdef CONFIG_CPU_S5PC100
	if (__s5p_tv_power_get_power_status()) {
		__s5p_tv_clk_stop();
		__s5p_tv_poweroff();
	}
#endif

	st->tvout_output_enable = false;
	st->tvout_param_available = false;

	return true;
}
bool _s5p_tv_if_init_hd_video_reg(void)
{
	s5p_tv_hdmi_err herr = 0;
	s5p_tv_hdmi_csc_type cscType;
	s5p_tv_status *st = &s5ptv_status;

	bool blue_enable = st->hdmi_video_blue_screen.enable;
	u8 cb_b = st->hdmi_video_blue_screen.cb_b;
	u8 y_g = st->hdmi_video_blue_screen.y_g;
	u8 cr_r = st->hdmi_video_blue_screen.cr_r;
	
	u8 y_min = st->hdmi_color_range.y_min;
	u8 y_max = st->hdmi_color_range.y_max;
	u8 c_min = st->hdmi_color_range.c_min;
	u8 c_max = st->hdmi_color_range.c_max;

	s5p_tv_disp_mode disp_mode = st->tvout_param.disp_mode;
	s5p_tv_o_mode out_mode = st->tvout_param.out_mode;

	s5p_hdmi_transmit a_trans_type = st->hdmi_av_info_frame.trans_type;
	u8 a_check_sum = st->hdmi_av_info_frame.check_sum;
	u8 *a_data = st->hdmi_av_info_frame.data;

	s5p_hdmi_transmit m_trans_type = st->hdmi_mpg_info_frame.trans_type;
	u8 m_check_sum = st->hdmi_mpg_info_frame.check_sum;
	u8 *m_data = st->hdmi_mpg_info_frame.data;

	s5p_hdmi_transmit s_trans_type = st->hdmi_spd_info_frame.trans_type;
	u8 *spd_header = st->hdmi_spd_info_frame.spd_header;
	u8 *spd_data = st->hdmi_spd_info_frame.spd_data;

	bool timing_correction_en = st->hdmi_tg_cmd.timing_correction_en;
	bool bt656_sync_en = st->hdmi_tg_cmd.bt656_sync_en;
	bool tg_en;

	
	herr = __s5p_hdmi_video_init_display_mode(disp_mode,out_mode);

	if (herr != HDMI_NO_ERROR) {
		return false;
	}

	__s5p_hdmi_video_init_bluescreen(blue_enable,cb_b,y_g,cr_r);


	__s5p_hdmi_video_init_color_range(y_min,y_max,c_min,c_max);

	switch (out_mode) {

	case TVOUT_OUTPUT_HDMI_RGB:
	case TVOUT_OUTPUT_HDMI:
		cscType = HDMI_BYPASS;
		break;
		
	case TVOUT_OUTPUT_DVI:
		cscType = HDMI_CSC_YUV601_TO_RGB_LR;
		break;

	default:
		TVOUTIFPRINTK("invalid out_mode parameter(%d)\n\r",
				out_mode);
		return false;
		break;
	}

	herr = __s5p_hdmi_video_init_csc(cscType);

	if (herr != HDMI_NO_ERROR) {
		return false;
	}

	herr =  __s5p_hdmi_video_init_avi_infoframe(a_trans_type,
					a_check_sum,a_data);

	if (herr != HDMI_NO_ERROR) {
		return false;
	}

	herr = __s5p_hdmi_video_init_mpg_infoframe(m_trans_type,
					m_check_sum,m_data);

	if (herr != HDMI_NO_ERROR) {
		return false;
	}

	herr = __s5p_hdmi_init_spd_infoframe(s_trans_type,
					spd_header,spd_data);

	if (herr != HDMI_NO_ERROR) {
		return false;
	}

	st->hdmi_tg_cmd.tg_en = true;
	tg_en = st->hdmi_tg_cmd.tg_en;

	__s5p_hdmi_video_init_tg_cmd(timing_correction_en,bt656_sync_en,tg_en);

	return true;
}