int mipi_mot_set_ce(void)
{
	int ret = 0;

	ret = check_dsi_error(); /* rst dsi err cnt */
	mipi_mot_tx_cmds(&mot_unlock_mtp[0], ARRAY_SIZE(mot_unlock_mtp));

	mipi_mot_tx_cmds(&set_ce_cmds[0], ARRAY_SIZE(set_ce_cmds));

	ret = check_dsi_error(); /* read dsi error cnt */
	if (ret > 0)
		pr_err("%s: failed to program CE D4 D5, dsi err 05h = %d\n",
			__func__, ret);
	return ret;
}
static int is_bl_supported(struct msm_fb_data_type *mfd)
{
    static int is_bl_supported = -1;
    int ret;
    u8 rdata;

    if (is_bl_supported == -1) {
        if (!is_evt0_sample(mfd))
            is_bl_supported = 1;
        else {
            /* To determine if BL is supported, need to read MTP
               to see if it is programmed.  Per spec, must be done
               in LP mode */
            mipi_set_tx_power_mode(1);
            mipi_mot_tx_cmds(&set_mtp_read_off[0],
                             ARRAY_SIZE(set_mtp_read_off));
            ret = mipi_mot_rx_cmd(&mtp_read_cmd, &rdata, 1);
            mipi_set_tx_power_mode(0);
            if (ret < 0)
                pr_err("%s: failed to determine if MTP is programmed, ret = %d",
                       __func__, ret);
            else {
                pr_info("%s: Panel MTP data = 0x%02x\n",
                        __func__, rdata);
                is_bl_supported = (!rdata) ? 0 : 1;
            }
        }
    }

    return ((is_bl_supported == 1) ? 1 : 0);
}
static void enable_acl(struct msm_fb_data_type *mfd)
{
	/* Write the value only if the display is enable and powerd on */
	if ((mfd->op_enable != 0) && (mfd->panel_power_on != 0)) {
		mipi_set_tx_power_mode(0);
		mipi_mot_tx_cmds(&acl_enable_disable[0],
					ARRAY_SIZE(acl_enable_disable));
	}
}
static int panel_enable(struct msm_fb_data_type *mfd)
{
	static int controller_ver = INVALID_VALUE;

	/* leverage the optimized exit_sleep mechanism */
	mipi_mot_panel_exit_sleep();

	controller_ver = mipi_mot_get_controller_ver(mfd);
	if (controller_ver >= 5)
		led_pwm2[1] = 0x93;	/* enable CE & CABC for ES5+ */
	else if (controller_ver == 4)
		led_pwm2[1] = 0x90;	/* enable CE for ES4 */

	mipi_mot_tx_cmds(&mot_cmd_on_cmds[0],
		ARRAY_SIZE(mot_cmd_on_cmds));
	return 0;
}
static void panel_set_backlight(struct msm_fb_data_type *mfd)
{
	static int bl_level_old;
	int idx = 0;

	pr_debug("%s(bl_level=%d)\n", __func__, (s32)mfd->bl_level);

	if (!mfd->panel_power_on)
		return;

	if (bl_level_old == mfd->bl_level)
		return;

	/* should already be in panel bl range */
	idx = mfd->bl_level;

	if (idx < 0)
		idx = 0;
	if (idx > NUMBER_BRIGHTNESS_LEVELS - 1)
		idx = NUMBER_BRIGHTNESS_LEVELS - 1;

	/* Mapping 1 ~ 30 level to 10 ~ 300 nits table */
	idx = (idx + 1) * PANEL_LEVEL_TO_NITS_LEVEL - 1;

	pr_debug("%s(idx=%d)\n", __func__, (s32)idx);
	set_brightness_cmds[0].payload =
		mipi_mot_get_gamma_setting(mfd, idx);

	mutex_lock(&mfd->dma->ov_mutex);
	mipi_set_tx_power_mode(0);
	mipi_mot_tx_cmds(&set_brightness_cmds[0],
				ARRAY_SIZE(set_brightness_cmds));

	bl_level_old = mfd->bl_level;
	mutex_unlock(&mfd->dma->ov_mutex);

	pr_debug("%s(%d) completed\n", __func__, (s32)mfd->bl_level);

	return;
}
static int panel_disable(struct msm_fb_data_type *mfd)
{
	mipi_mot_tx_cmds(&display_off_cmds[0], ARRAY_SIZE(display_off_cmds));

	return 0;
}
static int panel_enable(struct msm_fb_data_type *mfd)
{
	int i;
	int idx;
	static bool first_boot = true;

	mipi_mot_tx_cmds(smd_qhd_429_cmds_1, ARRAY_SIZE(smd_qhd_429_cmds_1));

	/* Read D4h for elvss and apply gamma */
	mipi_mot_get_mtpset4(mfd);

	if (first_boot) {
		/*
		 * Kernel bootup. Set it to default nit which should
		 * be same with it in bootloader.
		 */
		idx = DEFAULT_BRIGHTNESS_LEVELS;

		/* Calculate gamma setting */
		mipi_mot_get_raw_mtp(mfd);
		mipi_mot_dynamic_gamma_calc(V0, 0xfa, 0x02, input_gamma);
		first_boot = false;
	} else
		idx = mfd->bl_level;

	if (idx < 0)
		idx = 0;
	if (idx > NUMBER_BRIGHTNESS_LEVELS - 1)
		idx = NUMBER_BRIGHTNESS_LEVELS - 1;

	/* Mapping 1 ~ 30 level to 10 ~ 300 nits table */
	idx = (idx + 1) * PANEL_LEVEL_TO_NITS_LEVEL - 1;

	/* gamma */
	smd_qhd_429_cmds_2[0].payload =
		mipi_mot_get_gamma_setting(mfd, idx);
	mipi_mot_tx_cmds(smd_qhd_429_cmds_2, ARRAY_SIZE(smd_qhd_429_cmds_2));

	mipi_mot_tx_cmds(smd_qhd_429_cmds_3, ARRAY_SIZE(smd_qhd_429_cmds_3));
	mipi_mot_tx_cmds(smd_qhd_429_cmds_4, ARRAY_SIZE(smd_qhd_429_cmds_4));

	mipi_mot_tx_cmds(&smd_qhd_429_cmds_2[0],
					ARRAY_SIZE(smd_qhd_429_cmds_2));
	mipi_mot_tx_cmds(&smd_qhd_429_cmds_3[0],
					ARRAY_SIZE(smd_qhd_429_cmds_3));
	mipi_mot_tx_cmds(&smd_qhd_429_cmds_4[0],
					ARRAY_SIZE(smd_qhd_429_cmds_4));
	/* elvss */
	for (i = 1; i < 5; i++)
		elvss_output_set[i] = elvss_value;

	if (mot_panel->elvss_tth_support_present &&
		mot_panel->elvss_tth_status)
		for (i = 1; i < 5; i++)
			elvss_output_set[i] = elvss_value + 0xF;

	mipi_mot_tx_cmds(&elvss_set_cmd[0], ARRAY_SIZE(elvss_set_cmd));
	mipi_mot_panel_exit_sleep();
	mipi_mot_tx_cmds(&smd_qhd_429_cmds_5[0],
					ARRAY_SIZE(smd_qhd_429_cmds_5));
	mipi_mot_tx_cmds(&smd_qhd_429_cmds_6[0],
					ARRAY_SIZE(smd_qhd_429_cmds_6));
	/* acl */
	ACL_enable_disable_settings[1] = mot_panel->acl_enabled;
	mipi_mot_tx_cmds(&smd_qhd_429_cmds_7[0],
					ARRAY_SIZE(smd_qhd_429_cmds_7));

	return 0;
}