static int vo_release(int layer, struct file *filp)
{
	if (s5p_grp_stop(layer) == false)
		return -EINVAL;

	return 0;
}
/* start overlay * */
static int s5p_tv_v4l2_overlay(struct file *file, void *fh, unsigned int i)
{
	struct s5p_tv_vo *layer = (struct s5p_tv_vo *)fh;
	int	start = i;
	V4L2PRINTK("(0x%08x)++\n", i);

	/*
	* tv dirver is on suspend mode
	* Just set the status variable on this function
	* overlay will be enabled or disabled on resume or
	* handle_cable function according to this status variable
	*/
	if (g_s5ptv_status.suspend_status == true || !(g_s5ptv_status.hpd_status)) {
		if (start)
			g_s5ptv_status.grp_layer_enable[layer->index] = true;
		else
			g_s5ptv_status.grp_layer_enable[layer->index] = false;

		V4L2PRINTK("()it's on suspend mode or hdmi cable is not inserted--\n");
	} else {
		if (start)
			s5p_grp_start(layer->index);
		else
			s5p_grp_stop(layer->index);
	}

	V4L2PRINTK("()--\n");
	return 0;
}
void s5p_tv_early_suspend(struct early_suspend *h)
{
	BASEPRINTK("(hpd_status = %d)++\n", g_s5ptv_status.hpd_status);

	mutex_lock(g_mutex_for_fo);
	g_s5ptv_status.suspend_status = true;

	if (g_s5ptv_status.hpd_status == true) {
		/* video layer stop */
		if (g_s5ptv_status.vp_layer_enable) {
			s5p_vlayer_stop();
			g_s5ptv_status.vp_layer_enable = true;
		}

		/* grp0 layer stop */
		if (g_s5ptv_status.grp_layer_enable[VM_GPR0_LAYER]) {
			s5p_grp_stop(VM_GPR0_LAYER);
			g_s5ptv_status.grp_layer_enable[VM_GPR0_LAYER] = true;
		}

		/* grp1 layer stop */
		if (g_s5ptv_status.grp_layer_enable[VM_GPR1_LAYER]) {
			s5p_grp_stop(VM_GPR1_LAYER);
			g_s5ptv_status.grp_layer_enable[VM_GPR1_LAYER] = true;
		}

		/* tv off */
		if (g_s5ptv_status.tvout_output_enable) {
			s5p_tv_if_stop();
			g_s5ptv_status.tvout_output_enable = true;
			g_s5ptv_status.tvout_param_available = true;
		}

		/* clk & power off */
		s5p_tv_base_clk_gate(false);
		if (g_s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI ||
		    g_s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI_RGB)
			s5p_tv_base_phy_power(false);
	}

	mutex_unlock(g_mutex_for_fo);
	BASEPRINTK("()--\n");
	return;
}
static int s5p_tv_v4l2_streamoff(struct file *file, void *fh,
	enum v4l2_buf_type i)
{
	struct s5p_tv_vo *layer = (struct s5p_tv_vo *)fh;

	V4L2PRINTK("(0x%08x)++\n", i);

	/* tv driver is on suspend mode or hdmi cable is not inserted
	* Each layer was disabled on suspend function already.
	* Just set the status variable on this function
	* Each layer will be enabled or disabled on resume or
	* handle_cable function according to this status variable
	*/
	if (g_s5ptv_status.suspend_status == true || !(g_s5ptv_status.hpd_status)) {
		switch (i) {
		/* Vlayer */
		case V4L2_BUF_TYPE_VIDEO_OUTPUT:
			g_s5ptv_status.vp_layer_enable = false;
			break;
		/* GRP0/1 */
		case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
			g_s5ptv_status.grp_layer_enable[layer->index] = false;
			break;
		default:
			break;
		}
		V4L2PRINTK("()it's on suspend mode or hdmi cable is not inserted--\n");
		return 0;

	}

	switch (i) {
	/* Vlayer */
	case V4L2_BUF_TYPE_VIDEO_OUTPUT:
		s5p_vlayer_stop();
		break;
	/* GRP0/1 */
	case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
		s5p_grp_stop(layer->index);
		break;
	default:
		break;
	}

	V4L2PRINTK("()--\n");

	return 0;
}
void s5p_tv_base_handle_cable(void)
{
	char env_buf[120];
	char *envp[2];
	int env_offset = 0;
	bool previous_hpd_status = g_s5ptv_status.hpd_status;

#ifdef CONFIG_HDMI_HPD
#else
	return;
#endif

	switch (g_s5ptv_status.tvout_param.out_mode) {
	case TVOUT_OUTPUT_HDMI:
	case TVOUT_OUTPUT_HDMI_RGB:
	case TVOUT_OUTPUT_DVI:
		break;
	default:
		return;
	}

	g_s5ptv_status.hpd_status = s5p_hpd_get_state();

	if (previous_hpd_status == g_s5ptv_status.hpd_status) {
		pr_err("same hpd_status value: %d\n", previous_hpd_status);
		return;
	}

	memset(env_buf, 0, sizeof(env_buf));

	if (g_s5ptv_status.hpd_status == true) {
		BASEPRINTK("\n hdmi cable is connected\n");
		sprintf(env_buf, "HDMI_STATE=online");
		envp[env_offset++] = env_buf;
		envp[env_offset] = NULL;

		s5p_set_qos();

		if (g_s5ptv_status.suspend_status) {
			kobject_uevent_env(&(s5p_tvout[0].dev.kobj), KOBJ_CHANGE, envp);
			return;
		}

#ifdef CONFIG_PM
		s5p_tv_base_clk_gate(true);
		s5p_tv_base_phy_power(true);
#endif
		/* tv on */
		if (g_s5ptv_status.tvout_output_enable)
			s5p_tv_if_start();

		/* video layer start */
		if (g_s5ptv_status.vp_layer_enable)
			s5p_vlayer_start();

		/* grp0 layer start */
		if (g_s5ptv_status.grp_layer_enable[VM_GPR0_LAYER])
			s5p_grp_start(VM_GPR0_LAYER);

		/* grp1 layer start */
		if (g_s5ptv_status.grp_layer_enable[VM_GPR1_LAYER])
			s5p_grp_start(VM_GPR1_LAYER);

	} else {
		BASEPRINTK("\n hdmi cable is disconnected\n");
		sprintf(env_buf, "HDMI_STATE=offline");
		envp[env_offset++] = env_buf;
		envp[env_offset] = NULL;

		s5p_restore_qos();

		if (g_s5ptv_status.suspend_status) {
			kobject_uevent_env(&(s5p_tvout[0].dev.kobj), KOBJ_CHANGE, envp);
			return;
		}

		if (g_s5ptv_status.vp_layer_enable) {
			s5p_vlayer_stop();
			g_s5ptv_status.vp_layer_enable = true;
		}

		/* grp0 layer stop */
		if (g_s5ptv_status.grp_layer_enable[VM_GPR0_LAYER]) {
			s5p_grp_stop(VM_GPR0_LAYER);
			g_s5ptv_status.grp_layer_enable[VM_GPR0_LAYER] = true;
		}

		/* grp1 layer stop */
		if (g_s5ptv_status.grp_layer_enable[VM_GPR1_LAYER]) {
			s5p_grp_stop(VM_GPR1_LAYER);
			g_s5ptv_status.grp_layer_enable[VM_GPR1_LAYER] = true;
		}

		/* tv off */
		if (g_s5ptv_status.tvout_output_enable) {
			s5p_tv_if_stop();
			g_s5ptv_status.tvout_output_enable = true;
			g_s5ptv_status.tvout_param_available = true;
		}

#ifdef CONFIG_PM
		/* clk & power off */
		s5p_tv_base_clk_gate(false);
		s5p_tv_base_phy_power(false);
#endif
	}
	kobject_uevent_env(&(s5p_tvout[0].dev.kobj), KOBJ_CHANGE, envp);
}