static int msm_fb_detect_panel(const char *name)
{
	if (panel_type == PANEL_ID_PYD_SHARP) {
		if (!strcmp(name, "mipi_cmd_novatek_qhd"))
			return 0;
	} else if (panel_type == PANEL_ID_HOY_SONY_OTM) {
		if (!strcmp(name, "mipi_cmd_orise_qhd"))
			return 0;
	} else if (panel_type == PANEL_ID_NONE) {
		if (board_build_flag() != 1) {
			if (!strcmp(name, "mipi_cmd_orise_qhd")) {
				PR_DISP_WARN("%s: bootloader detect NO panel. Use default ID.", __func__);
				panel_type = PANEL_ID_HOY_SONY_OTM;
				return 0;
			}
		}
	}
#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
	else if (!strcmp(name, "hdmi_msm"))
		return 0;
#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */

	PR_DISP_WARN("%s: not supported '%s'", __func__, name);
	return -ENODEV;
}
static int msm_fb_detect_panel(const char *name)
{
	if (panel_type == PANEL_ID_PIO_AUO) {
		if (!strcmp(name, "mipi_cmd_novatek_hvga"))
			return 0;
	} else if ((panel_type == PANEL_ID_PIO_SAMSUNG) | (panel_type == PANEL_ID_PIO_SAMSUNG_C2)) {
		if (!strcmp(name, "mipi_cmd_samsung_hvga"))
			return 0;
	}

	PR_DISP_WARN("%s: not supported '%s'\n", __func__, name);
	return -ENODEV;
}
static int k2_detect_panel(const char *name)
{
#if 0
	if (!strncmp(name, MIPI_VIDEO_NOVATEK_WVGA_PANEL_NAME,
			strnlen(MIPI_VIDEO_NOVATEK_WVGA_PANEL_NAME,
			PANEL_NAME_MAX_LEN))) {
		PR_DISP_INFO("%s: Support (%s)\n",__func__, name);
		return 0;
	}

	PR_DISP_WARN("%s: not supported '%s'\n", __func__, name);
#endif
	return -ENODEV;
}
void mipi_dsi_disable_irq(void)
{
    unsigned long flags;

    spin_lock_irqsave(&dsi_lock, flags);
    if (dsi_irq_enabled == 0) {
        PR_DISP_WARN("%s: IRQ cannot be disabled\n", __func__);
        spin_unlock_irqrestore(&dsi_lock, flags);
        return;
    }

    dsi_irq_enabled = 0;
    disable_irq(DSI_IRQ);
    spin_unlock_irqrestore(&dsi_lock, flags);
}
static int msm_fb_detect_panel(const char *name)
{
	if ((panel_type == PANEL_ID_PIO_SAMSUNG) ||
		(panel_type == PANEL_ID_PIO_SAMSUNG_C2)){

		mipi_dsi_cmd_hvga_panel_device.name = "mipi_samsung";
		if (!strcmp(name, "mipi_cmd_samsung_hvga"))
			return 0;
	} else if(panel_type == PANEL_ID_GOLFU_AUO ||
			panel_type == PANEL_ID_GOLFU_AUO_C2 ||
			panel_type == PANEL_ID_GOLFU_AUO_C3 ||
			panel_type == PANEL_ID_GOLFU_AUO_C4) {
		if (!strcmp(name, "mipi_cmd_orise_hvga"))
			return 0;
	}

	PR_DISP_WARN("%s: not supported '%s'\n", __func__, name);
	return -ENODEV;
}
static void __init msm_fb_add_devices(void)
{
	PR_DISP_INFO("panel ID= 0x%x\n", panel_type);

	if (board_build_flag() != 1 && panel_type == PANEL_ID_NONE) {
		PR_DISP_WARN("%s: bootloader detect NO panel. Use default ID.", __func__);
		panel_type = PANEL_ID_HOY_SONY_OTM;
	}

	msm_fb_register_device("mdp", &mdp_pdata);

	if (panel_type != PANEL_ID_NONE)
		msm_fb_register_device("mipi_dsi", &mipi_pdata);
	else {
		gpio_tlmm_config(lcd_gpio_table[0], GPIO_CFG_ENABLE);
		gpio_tlmm_config(lcd_gpio_table[1], GPIO_CFG_ENABLE);
		gpio_tlmm_config(lcd_gpio_table[2], GPIO_CFG_ENABLE);
	}
#ifdef CONFIG_MSM_BUS_SCALING
	msm_fb_register_device("dtv", &dtv_pdata);
#endif
}
static ssize_t vsync_show_event(struct device *dev,
	struct device_attribute *attr, char *buf)
{
	int cndx;
	struct vsycn_ctrl *vctrl;
	ssize_t ret = 0;
	unsigned long flags;
	int timeout = 0;
	static int cnt = 0;

	cndx = 0;
	vctrl = &vsync_ctrl_db[0];

	if (atomic_read(&vctrl->suspend) > 0)
		return 0;

	spin_lock_irqsave(&vctrl->spin_lock, flags);
	if (vctrl->wait_vsync_cnt == 0)
		INIT_COMPLETION(vctrl->vsync_comp);
	vctrl->wait_vsync_cnt++;
	spin_unlock_irqrestore(&vctrl->spin_lock, flags);

	timeout = wait_for_completion_timeout(&vctrl->vsync_comp, HZ/20);

	if (!timeout) {
		if (cnt > 3)
			PR_DISP_WARN("WARNING %s: vsync timeout\n", __func__);
		cnt++;
	} else
		cnt = 0;


	ret = snprintf(buf, PAGE_SIZE, "VSYNC=%llu",
			ktime_to_ns(vctrl->vsync_time));
	buf[strlen(buf) + 1] = '\0';
	return ret;
}
void mdp4_dsi_cmd_wait4vsync(int cndx, long long *vtime)
{
	struct vsycn_ctrl *vctrl;
	struct mdp4_overlay_pipe *pipe;
	unsigned long flags;
	int timeoutResult = 0;

	if (cndx >= MAX_CONTROLLER) {
		pr_err("%s: out or range: cndx=%d\n", __func__, cndx);
		return;
	}

	vctrl = &vsync_ctrl_db[cndx];
	pipe = vctrl->base_pipe;

	if (atomic_read(&vctrl->suspend) > 0) {
		*vtime = -1;
		return;
	}

	spin_lock_irqsave(&vctrl->spin_lock, flags);
	if (vctrl->wait_vsync_cnt == 0)
		INIT_COMPLETION(vctrl->vsync_comp);
	vctrl->wait_vsync_cnt++;
	spin_unlock_irqrestore(&vctrl->spin_lock, flags);

	timeoutResult = wait_for_completion_timeout(&vctrl->vsync_comp, HZ/10);
	if (!timeoutResult) {
		PR_DISP_WARN("%s: vsync timeout, clk_enabled %d, expire_tick %d, vctrl->wait_vsync_cnt %d\n",
		__func__, vctrl->clk_enabled, vctrl->expire_tick, vctrl->wait_vsync_cnt);
	}

	mdp4_stat.wait4vsync0++;

	*vtime = ktime_to_ns(vctrl->vsync_time);
}