Example #1
0
/**
 * LCD ON.
 *
 * Set LCD On via MIPI interface .
 * Set Backlight on.
*/
static int mipi_novatek_disp_on(struct platform_device *pdev)
{
	struct msm_fb_data_type *mfd;
	struct mipi_panel_info *mipi;

	int disp_bl_cont_gpio;
	disp_bl_cont_gpio = (system_rev>1)?GPIO_LCD_BOOSTER_EN:GPIO_LCD_BOOSTER_EN_EMUL;

	pr_info("****** %s *******\n", __func__);

	mfd = platform_get_drvdata(pdev);
	if (unlikely(!mfd))
		return -ENODEV;
	if (unlikely(mfd->key != MFD_KEY))
		return -EINVAL;

	mipi = &mfd->panel_info.mipi;

	if (mipi->mode == DSI_VIDEO_MODE)
		mipi_novatek_disp_send_cmd(mfd, PANEL_ON, false);

#if defined(CONFIG_FB_MDP4_ENHANCE)
	is_negativeMode_on();
#endif
	mipi_novatek_disp_send_cmd(mfd, PANEL_READY_TO_ON, false);
	pr_debug("%s: DISP_BL_CONT_GPIO High\n", __func__);
	gpio_set_value(disp_bl_cont_gpio , 1);

	is_lcd_on = LCD_STATUS_ON;

#if !defined(CONFIG_HAS_EARLYSUSPEND)
	mipi_novatek_disp_send_cmd(mfd, PANEL_LATE_ON, false);
#endif

#if defined(CONFIG_MIPI_SAMSUNG_ESD_REFRESH)
	set_esd_enable();
#endif

	pr_info("%s:Display on completed\n", __func__);
return 0;
}
static int mipi_samsung_disp_on(struct platform_device *pdev)
{
	struct msm_fb_data_type *mfd;
	struct mipi_panel_info *mipi;
#if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_VIDEO_HD_PT) \
	|| defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_VIDEO_WVGA_PT) \
	|| defined(CONFIG_FB_MSM_MIPI_MAGNA_OLED_VIDEO_WVGA_PT)
	static int boot_on;
#endif

	mfd = platform_get_drvdata(pdev);
	if (unlikely(!mfd))
		return -ENODEV;
	if (unlikely(mfd->key != MFD_KEY))
		return -EINVAL;

	mipi = &mfd->panel_info.mipi;

#if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_CMD_QHD_PT)
	mipi_samsung_disp_send_cmd(mfd, MTP_READ_ENABLE, false);
#endif

#if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_VIDEO_WVGA_PT) \
	|| defined(CONFIG_FB_MSM_MIPI_MAGNA_OLED_VIDEO_WVGA_PT)
	if (boot_on == 0)
		mipi_samsung_disp_send_cmd(mfd, MTP_READ_ENABLE, false);
#endif

#ifdef USE_READ_ID
#if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_VIDEO_WVGA_PT) \
	|| defined(CONFIG_FB_MSM_MIPI_MAGNA_OLED_VIDEO_WVGA_PT)
	if (boot_on == 0)
		msd.mpd->manufacture_id = mipi_samsung_manufacture_id(mfd);
#elif defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_CMD_QHD_PT)
	msd.mpd->manufacture_id = mipi_samsung_manufacture_id(mfd);
#elif defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_VIDEO_HD_PT)
	if (!samsung_has_cmc624())
		msd.mpd->manufacture_id = mipi_samsung_manufacture_id(mfd);
	else
		msd.mpd->manufacture_id = LCD_Get_Value();
#endif
#endif

#if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_CMD_QHD_PT)
	if (!msd.dstat.is_elvss_loaded) {
		read_reg(ELVSS_REGISTER, ELVSS_DATA_SIZE,
			msd.mpd->lcd_elvss_data,
				 FALSE, mfd);  /* read ELVSS data */
		msd.dstat.is_elvss_loaded = true;
	}


	if (!msd.dstat.is_smart_dim_loaded) {
		/* Load MTP Data */
		int i;
		read_reg(MTP_REGISTER, MTP_DATA_SIZE,
				(u8 *)&(msd.mpd->smart_s6e39a0x02.MTP),
						FALSE, mfd);
		for (i = 0; i < MTP_DATA_SIZE; i++) {
			pr_info("%s MTP DATA[%d] : %02x\n", __func__, i,
			((char *)&(msd.mpd->smart_s6e39a0x02.MTP))[i]);
		}

		smart_dimming_init(&(msd.mpd->smart_s6e39a0x02));
#ifdef READ_MTP_ONCE
		msd.dstat.is_smart_dim_loaded = true;
#else
		msd.dstat.is_smart_dim_loaded = false;
#endif
		msd.dstat.gamma_mode = GAMMA_SMART;
	}
#endif
#if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_VIDEO_HD_PT)
	if (!msd.dstat.is_elvss_loaded) {
		if (!samsung_has_cmc624())
			msd.mpd->lcd_elvss_data[0] = elvss_value;
		else
			msd.mpd->lcd_elvss_data[0] = LCD_ID3();

		msd.dstat.is_elvss_loaded = true;
	}

	if (!msd.dstat.is_smart_dim_loaded) {
		/*Load MTP Data*/
		char pBuffer[256] = {0,};
		int i;
		struct SMART_DIM *psmart;
		char *mtp_data;
		int mtp_cnt;

		psmart = &(msd.mpd->smart_s6e8aa0x01);
		mtp_data = (char *)&(msd.mpd->smart_s6e8aa0x01.MTP);

		if (samsung_has_cmc624()) {
			memcpy(mtp_data, mtp_read_data, GAMMA_SET_MAX);
			pr_info("%s This board support CMC", __func__);
		} else {
			mtp_cnt = find_mtp(mfd, mtp_data);
			pr_info("%s MTP is determined : %d", __func__, mtp_cnt);
		}


		for (i = 0; i < MTP_DATA_SIZE; i++)
			snprintf(pBuffer + strnlen(pBuffer, 256), 256, " %02x",
				mtp_data[i]);
		pr_info("MTP: %s", pBuffer);

		psmart->plux_table = msd.mpd->lux_table;
		psmart->lux_table_max = msd.mpd->lux_table_max_cnt;

		if (samsung_has_cmc624())
			psmart->ldi_revision = LCD_Get_Value();
		else
			psmart->ldi_revision = bypass_LCD_Id();

		smart_dimming_init(psmart);

		msd.dstat.is_smart_dim_loaded = true;
		msd.dstat.gamma_mode = GAMMA_SMART;
	}

	if (msd.mpd->gamma_initial && boot_on == 0) {
		msd.mpd->smart_s6e8aa0x01.brightness_level = 180;
		generate_gamma(&msd.mpd->smart_s6e8aa0x01,
			&(msd.mpd->gamma_initial[2]), GAMMA_SET_MAX);

		if (recovery_boot_mode == 0)
			boot_on = 1;
	} else {
		get_min_lux_table(&(msd.mpd->gamma_initial[2]),
					GAMMA_SET_MAX);
		reset_gamma_level();
	}
#endif

#if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_VIDEO_WVGA_PT)
	if (!msd.dstat.is_smart_dim_loaded) {
		/* Load MTP Data */
		int i, mtp_cnt, err_cnt;
		char *mtp_data = (char *)&(msd.mpd->smart_s6e63m0.MTP);

		for (err_cnt = 0; err_cnt < 10; err_cnt++) {
			mtp_cnt = find_mtp(mfd, mtp_data);

			if (mtp_cnt != 0)
				break;
		}

		pr_info("%s MTP is determined:%d err_cnt:%d",
					__func__, mtp_cnt, err_cnt);

		for (i = 0; i < MTP_DATA_SIZE_S6E63M0; i++) {
			pr_info("%s MTP DATA[%d] : %02x\n", __func__, i,
				mtp_data[i]);
		}

		smart_dimming_init(&(msd.mpd->smart_s6e63m0));

		msd.dstat.is_smart_dim_loaded = true;
		msd.dstat.gamma_mode = GAMMA_SMART;
	}

	if (msd.mpd->gamma_initial && boot_on == 0) {
		msd.mpd->smart_s6e63m0.brightness_level = 140;
		generate_gamma(&msd.mpd->smart_s6e63m0,
			&(msd.mpd->gamma_initial[2]), GAMMA_SET_MAX);

		if (recovery_boot_mode == 0)
			boot_on = 1;

	} else {
		msd.mpd->smart_s6e63m0.brightness_level = 30;
		generate_gamma(&msd.mpd->smart_s6e63m0,
			&(msd.mpd->gamma_initial[2]), GAMMA_SET_MAX);
		reset_gamma_level();
	}
#endif

#if defined(CONFIG_FB_MSM_MIPI_MAGNA_OLED_VIDEO_WVGA_PT)
	if (!msd.dstat.is_smart_dim_loaded) {
		/* Load MTP Data */
		int i, mtp_cnt, err_cnt;
		char *mtp_data = (char *)&(msd.mpd->smart_ea8868.MTP);

		if (bypass_lcd_id == 0x4a) {
			for (err_cnt = 0; err_cnt < 10; err_cnt++) {
				mtp_cnt = find_mtp(mfd, mtp_data);

				if (mtp_cnt != 0)
					break;
			}

			pr_info("%s MTP is determined:%d err_cnt:%d",
						__func__, mtp_cnt, err_cnt);

			for (i = 0; i < MTP_DATA_SIZE_EA8868; i++) {
				pr_info("%s MTP DATA[%d] : %02x\n",
						__func__, i, mtp_data[i]);
			}
		} else {
			pr_info("%s MTP is not used LDI_ID: 0x%x",
						__func__, bypass_lcd_id);
			memset(mtp_data, 0x0, MTP_DATA_SIZE_EA8868);
		}

		smart_dimming_init(&(msd.mpd->smart_ea8868));

		msd.dstat.is_smart_dim_loaded = true;
		msd.dstat.gamma_mode = GAMMA_SMART;
	}

	if (msd.mpd->gamma_initial && boot_on == 0) {
		msd.mpd->smart_ea8868.brightness_level = 180;
		generate_gamma(&msd.mpd->smart_ea8868,
			&(msd.mpd->gamma_initial[1]), GAMMA_SET_MAX);

		if (recovery_boot_mode == 0)
			boot_on = 1;
	} else {
		msd.mpd->smart_ea8868.brightness_level = get_gamma_lux();
		generate_gamma(&msd.mpd->smart_ea8868,
			&(msd.mpd->gamma_initial[1]), GAMMA_SET_MAX);
		reset_gamma_level();
	}
#endif

	if (unlikely(first_on)) {
		first_on = false;
		return 0;
	}

	mipi_samsung_disp_send_cmd(mfd, PANEL_READY_TO_ON, false);
	if (mipi->mode == DSI_VIDEO_MODE)
		mipi_samsung_disp_send_cmd(mfd, PANEL_ON, false);

#if !defined(CONFIG_HAS_EARLYSUSPEND)
	mipi_samsung_disp_send_cmd(mfd, PANEL_LATE_ON, false);
#endif
#if defined(CONFIG_MIPI_SAMSUNG_ESD_REFRESH)
#if defined(CONFIG_MACH_JAGUAR)
	if  (system_rev >= 16)
		set_esd_enable();
	if (msd.esd_refresh == true)
		mipi_samsung_disp_send_cmd(mfd, PANEL_LATE_ON, false);
#else
	set_esd_enable();
#endif
#endif

#ifdef READ_REGISTER_ESD
	queue_delayed_work(msd.mpd->esd_workqueue,
				&(msd.mpd->esd_work), ESD_INTERVAL * HZ);
	wake_lock(&(msd.mpd->esd_wake_lock));
#endif

	return 0;
}