static int mdss_dsi_panel_on(struct mdss_panel_data *pdata)
{
	struct mdss_dsi_ctrl_pdata *ctrl = NULL;
#if defined(CONFIG_ESD_ERR_FG_RECOVERY)
	static int first_boot = 1;
#endif
	msd.mfd = (struct msm_fb_data_type *)registered_fb[0]->par;
	if (pdata == NULL) {
		pr_err("%s: Invalid input data\n", __func__);
		return -EINVAL;
	}
	msd.mpd = pdata;
	ctrl = container_of(pdata, struct mdss_dsi_ctrl_pdata,
				panel_data);

	printk("%s: ctrl=%p ndx=%d\n", __func__, ctrl, ctrl->ndx);

	if (ctrl->on_cmds.cmd_cnt)
		mdss_dsi_panel_cmds_send(ctrl, &ctrl->on_cmds);

	msd.mfd->resume_state = MIPI_RESUME_STATE;

#if defined(CONFIG_MDNIE_LITE_TUNING) || defined(CONFIG_MDNIE_VIDEO_ENHANCED)
	is_negative_on();
#endif
#if defined(CONFIG_BACKLIGHT_IC_KTD2801)
	mdelay(2);
	if (gpio_is_valid(msd.bl_ap_pwm)) {
		gpio_tlmm_config(GPIO_CFG(msd.bl_ap_pwm,3, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
				GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	}
	if((fisrt_boot_bl==1) && (lcd_connected_status ==1)){

#ifdef EXPRESSWIRED
		ktd_backlight_set_brightness(BL_MAX_BRIGHTNESS_LEVEL);
#else
		mdss_dsi_panel_bklt_pwm(BL_MAX_BRIGHTNESS_LEVEL);
#endif
		fisrt_boot_bl=0;
	}
#endif
#if defined(CONFIG_ESD_ERR_FG_RECOVERY)
	if(first_boot) {
		int rc;

		INIT_WORK(&err_fg_work, err_fg_work_func);

		rc = request_threaded_irq(err_fg_gpio, NULL, err_fg_irq_handler,
			IRQF_TRIGGER_LOW | IRQF_ONESHOT, "esd_detect", NULL);
		if (rc) {
			pr_err("%s : Failed to request_irq. :ret=%d", __func__, rc);
		}
		first_boot = 0;
	}

	enable_irq(err_fg_gpio);
#endif
	pr_err("%s:-\n", __func__);
	return 0;
}
static int ktd_backlight_update_status(struct backlight_device *bl)
{
	struct device *dev = bl->dev.parent;
	struct ktd_bl_info *bl_info;
	int brightness = bl->props.brightness;
	if (!dev) {
		printk("%s, dev is null\n");
		return 0;
	}

	bl_info = (struct ktd_bl_info *)dev->platform_data;
	if (!bl_info) {
		printk("%s, bl_info is null\n");
		return 0;
	}

	if (bl->props.power != FB_BLANK_UNBLANK)
		brightness = 0;

	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
		brightness = 0;

	wakeup_brightness = brightness;
	if (!bl_enable && !current_brightness) {
		printk(KERN_INFO "[Backlight] no need to set backlight ---\n");
	} else {
		ktd_backlight_set_brightness(bl_info, brightness);
	}

	return 0;
}
void backlight_set_brightness(int level)
{
	if (!g_bl_info) {
		printk("%s, g_bl_info is null\n", __func__);
		return;
	}
	ktd_backlight_set_brightness(g_bl_info, level);

	return;
}
static int mdss_dsi_panel_off(struct mdss_panel_data *pdata)
{
	struct mdss_dsi_ctrl_pdata *ctrl = NULL;
	msd.mfd = (struct msm_fb_data_type *)registered_fb[0]->par;
	if (pdata == NULL) {
		pr_err("%s: Invalid input data\n", __func__);
		return -EINVAL;
	}

	ctrl = container_of(pdata, struct mdss_dsi_ctrl_pdata,
				panel_data);
#if defined(CONFIG_ESD_ERR_FG_RECOVERY)
	if (!err_fg_working) {
		disable_irq_nosync(err_fg_gpio);
		cancel_work_sync(&err_fg_work);
	}
#endif
	printk("%s: ctrl=%p ndx=%d\n", __func__, ctrl, ctrl->ndx);
#if defined(CONFIG_BACKLIGHT_IC_KTD2801)
	if (gpio_is_valid(msd.bl_ap_pwm)) {
			gpio_tlmm_config(GPIO_CFG(msd.bl_ap_pwm,0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
				GPIO_CFG_2MA), GPIO_CFG_DISABLE);
			gpio_set_value(msd.bl_ap_pwm, 0);
	}
#ifdef EXPRESSWIRED
	ktd_backlight_set_brightness(0);
#endif
#endif

	if (ctrl->off_cmds.cmd_cnt)
		mdss_dsi_panel_cmds_send(ctrl, &ctrl->off_cmds);

	msd.mfd->resume_state = MIPI_SUSPEND_STATE;
	pr_debug("%s:-\n", __func__);

	return 0;
}
static void mdss_dsi_panel_bl_ctrl(struct mdss_panel_data *pdata,
							u32 bl_level)
{
	struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;

#if  defined(CONFIG_BACKLIGHT_IC_KTD253)
	static int bl_level_old;
#endif

#if defined(CONFIG_FB_MSM8x26_MDSS_CHECK_LCD_CONNECTION)
	if (get_samsung_lcd_attached() == 0)
	{
		printk("%s: LCD not connected!\n",__func__);
#if defined(CONFIG_BACKLIGHT_IC_KTD2801)
		gpio_set_value(msd.bl_ap_pwm,0);
#else
		gpio_set_value(12, 0);
#endif
		return;
	}
#endif

	if (pdata == NULL) {
		pr_err("%s: Invalid input data\n", __func__);
		return;
	}

	if( msd.mfd->panel_power_on == false){
		pr_err("%s: panel power off no bl ctrl\n", __func__);
		return;
	}
#if defined(CONFIG_ESD_ERR_FG_RECOVERY)
	if (err_fg_working) {
		pr_info("[LCD] %s : esd is working!! return.. \n", __func__);
		return;
	}
#endif
	ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
				panel_data);
	switch (ctrl_pdata->bklt_ctrl) {
	case BL_WLED:
		led_trigger_event(bl_led_trigger, bl_level);
		break;
	case BL_PWM:
#if defined(CONFIG_BACKLIGHT_IC_KTD2801)
#ifdef EXPRESSWIRED
		ktd_backlight_set_brightness(bl_level);
#else
		pr_err("[MINO] %s --> bl_level[1] : %d\n",__func__, bl_level );
		bl_level=mdss_dsi_panel_pwm_scaling(bl_level);
		mdss_dsi_panel_bklt_pwm(bl_level);
		pr_err("[MINO] %s --> bl_level[2] : %d\n",__func__, bl_level );
#endif
#else
		mdss_dsi_panel_bklt_pwm(ctrl_pdata, bl_level);
#endif
		break;
	case BL_DCS_CMD:
			mdss_dsi_panel_bklt_dcs(ctrl_pdata, bl_level);
		break;
	case BL_GPIO_SWING:
#if defined(CONFIG_BACKLIGHT_IC_KTD253)
	if (bl_level_old == bl_level)
			return;

	pr_err("%s: bl_level = %d\n",__func__,bl_level);

	ktd253_set_brightness(get_candela_index(bl_level),ctrl_pdata);
	bl_level_old = bl_level;
#endif
		break;

	default:
		pr_err("%s: Unknown bl_ctrl configuration\n",
			__func__);
		break;
	}
}