static int set_acl_on_level(int bl_level) { int cd; cd = get_candela_index(bl_level); if ((LCD_Get_Value() == 0x20) || bypass_LCD_Id() == 0x20 ||\ (LCD_Get_Value() == 0x40)) { if (!lcd_acl_table_4_8[cd].lux) return 1; samsung_panel_acl_update_cmds[0].dlen = lcd_acl_table_4_8[cd].cmd->dlen; samsung_panel_acl_update_cmds[0].payload = lcd_acl_table_4_8[cd].cmd->payload; } else { if (!lcd_acl_table[cd].lux) return 1; samsung_panel_acl_update_cmds[0].dlen = lcd_acl_table[cd].cmd->dlen; samsung_panel_acl_update_cmds[0].payload = lcd_acl_table[cd].cmd->payload; } if (!lcd_acl_table_4_8[cd].lux) return 1; samsung_panel_acl_update_cmds[0].dlen = lcd_acl_table_4_8[cd].cmd->dlen; samsung_panel_acl_update_cmds[0].payload = lcd_acl_table_4_8[cd].cmd->payload; return 0; }
void mipi_samsung_oled_display_fast_init() { struct msm_fb_data_type *mfd; if (samsung_has_cmc624()) msd.mpd->prepare_fast_cmd_array(LCD_Get_Value()); else msd.mpd->prepare_fast_cmd_array(bypass_LCD_Id()); mfd = platform_get_drvdata(msd.msm_pdev); mipi_samsung_disp_send_cmd(mfd, PANEL_READY_TO_ON_FAST, false); mipi_samsung_disp_send_cmd(mfd, PANEL_ON, false); }
static void mipi_samsung_disp_backlight(struct msm_fb_data_type *mfd) { #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_CMD_QHD_PT) mfd->backlight_ctrl_ongoing = TRUE; #else mfd->backlight_ctrl_ongoing = FALSE; #endif #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_VIDEO_HD_PT) \ || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_VIDEO_WVGA_PT) if (msd.mpd->prepare_brightness_control_cmd_array) { int cmds_sent; #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_VIDEO_HD_PT) if (!samsung_has_cmc624()) cmds_sent = msd.mpd->prepare_brightness_control_cmd_array( bypass_LCD_Id(), mfd->bl_level); else cmds_sent = msd.mpd->prepare_brightness_control_cmd_array( LCD_Get_Value(), mfd->bl_level); #else cmds_sent = msd.mpd->prepare_brightness_control_cmd_array( 0, mfd->bl_level); #endif pr_debug("cmds_sent: %x\n", cmds_sent); if (cmds_sent < 0) goto end; mipi_samsung_disp_send_cmd(mfd, PANEL_BRIGHT_CTRL, true); goto end; } #endif #if defined(CONFIG_MIPI_SAMSUNG_ESD_REFRESH) if (msd.esd_refresh == true) goto end; #endif pr_info("mipi_samsung_disp_backlight %d\n", mfd->bl_level); if (!msd.mpd->set_gamma || !mfd->panel_power_on ||\ mfd->resume_state == MIPI_SUSPEND_STATE) goto end; if (msd.mpd->set_gamma(mfd->bl_level, msd.dstat.gamma_mode) < 0) goto end; pr_info("mipi_samsung_disp_backlight %d\n", mfd->bl_level); mipi_samsung_disp_send_cmd(mfd, PANEL_GAMMA_UPDATE, true); #ifdef USE_ELVSS if (msd.mpd->set_elvss) mipi_samsung_disp_send_cmd(mfd, PANEL_ELVSS_UPDATE, true); #endif #ifdef USE_ACL if (msd.mpd->set_acl && msd.dstat.acl_on && msd.mpd->set_acl(mfd->bl_level)) mipi_samsung_disp_send_cmd(mfd, PANEL_ACL_OFF, true); if (msd.mpd->set_acl && msd.dstat.acl_on && !msd.mpd->set_acl(mfd->bl_level)) { #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_CMD_QHD_PT) mipi_samsung_disp_send_cmd(mfd, PANEL_ACL_ON, true); #endif mipi_samsung_disp_send_cmd(mfd, PANEL_ACL_UPDATE, true); } #endif end: #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_CMD_QHD_PT) mfd->backlight_ctrl_ongoing = FALSE; #endif return; }
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; }
static int mipi_samsung_disp_send_cmd(struct msm_fb_data_type *mfd, enum mipi_samsung_cmd_list cmd, unsigned char lock) { struct dsi_cmd_desc *cmd_desc; int cmd_size = 0; wake_lock(&idle_wake_lock); #ifdef CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_VIDEO_WVGA_PT mutex_lock(&mipi_lp_mutex); #endif if (lock) mutex_lock(&mfd->dma->ov_mutex); switch (cmd) { #ifdef CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_VIDEO_HD_PT case PANEL_READY_TO_ON_FAST: if (Is_4_65LCD_cmc() || Is_4_65LCD_bypass()) { /*4.65 LCD_ID*/ pr_info("Select 4.65 = %x\n", LCD_Get_Value()); cmd_desc = msd.mpd->ready_to_on_fast.cmd; cmd_size = msd.mpd->ready_to_on_fast.size; } else { pr_info("Select 4.8 = %x\n", LCD_Get_Value()); cmd_desc = msd.mpd->ready_to_on_4_8_fast.cmd; cmd_size = msd.mpd->ready_to_on_4_8_fast.size; } break; #endif case PANEL_READY_TO_ON: #ifdef CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_VIDEO_HD_PT if (Is_4_65LCD_cmc() || Is_4_65LCD_bypass()) { /*4.65 LCD_ID*/ pr_info("Select 4.65 = %x(%x)\n", LCD_Get_Value(), bypass_LCD_Id()); cmd_desc = msd.mpd->ready_to_on.cmd; cmd_size = msd.mpd->ready_to_on.size; } else { /* 4.8 LCD_ID*/ pr_info("Select 4.8 = %x(%x)\n", LCD_Get_Value(), bypass_LCD_Id()); cmd_desc = msd.mpd->ready_to_on_4_8.cmd; cmd_size = msd.mpd->ready_to_on_4_8.size; } #else cmd_desc = msd.mpd->ready_to_on.cmd; cmd_size = msd.mpd->ready_to_on.size; #endif break; case PANEL_READY_TO_OFF: cmd_desc = msd.mpd->ready_to_off.cmd; cmd_size = msd.mpd->ready_to_off.size; break; case PANEL_ON: cmd_desc = msd.mpd->on.cmd; cmd_size = msd.mpd->on.size; break; case PANEL_OFF: cmd_desc = msd.mpd->off.cmd; cmd_size = msd.mpd->off.size; break; case PANEL_LATE_ON: cmd_desc = msd.mpd->late_on.cmd; cmd_size = msd.mpd->late_on.size; break; case PANEL_EARLY_OFF: cmd_desc = msd.mpd->early_off.cmd; cmd_size = msd.mpd->early_off.size; break; case PANEL_GAMMA_UPDATE: cmd_desc = msd.mpd->gamma_update.cmd; cmd_size = msd.mpd->gamma_update.size; break; case MTP_READ_ENABLE: cmd_desc = msd.mpd->mtp_read_enable.cmd; cmd_size = msd.mpd->mtp_read_enable.size; break; #ifdef USE_ACL case PANEL_ACL_ON: cmd_desc = msd.mpd->acl_on.cmd; cmd_size = msd.mpd->acl_on.size; msd.mpd->ldi_acl_stat = true; break; case PANEL_ACL_OFF: cmd_desc = msd.mpd->acl_off.cmd; cmd_size = msd.mpd->acl_off.size; msd.mpd->ldi_acl_stat = false; break; case PANEL_ACL_UPDATE: cmd_desc = msd.mpd->acl_update.cmd; cmd_size = msd.mpd->acl_update.size; break; #endif #ifdef USE_ELVSS case PANEL_ELVSS_UPDATE: #ifdef CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_VIDEO_HD_PT if (Is_4_65LCD_cmc() || Is_4_65LCD_bypass()) { /*4.65 LCD_ID*/ msd.mpd->set_elvss(mfd->bl_level); cmd_desc = msd.mpd->elvss_update.cmd; cmd_size = msd.mpd->elvss_update.size; } else { /* 4.8 LCD_ID*/ msd.mpd->set_elvss_4_8(mfd->bl_level); cmd_desc = msd.mpd->elvss_update_4_8.cmd; cmd_size = msd.mpd->elvss_update_4_8.size; } #else msd.mpd->set_elvss(mfd->bl_level); cmd_desc = msd.mpd->elvss_update.cmd; cmd_size = msd.mpd->elvss_update.size; #endif break; #endif #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_VIDEO_HD_PT) \ || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_VIDEO_WVGA_PT) case PANEL_BRIGHT_CTRL: cmd_desc = msd.mpd->combined_ctrl.cmd; cmd_size = msd.mpd->combined_ctrl.size; break; #endif default: goto unknown_command; ; } if (!cmd_size) goto unknown_command; if (lock) { mipi_dsi_mdp_busy_wait(); /* Added to resolved cmd loss during dimming factory test */ mdelay(1); mipi_dsi_cmds_tx(&msd.samsung_tx_buf, cmd_desc, cmd_size); mutex_unlock(&mfd->dma->ov_mutex); } else { mipi_dsi_mdp_busy_wait(); /* Added to resolved cmd loss during dimming factory test */ mdelay(1); mipi_dsi_cmds_tx(&msd.samsung_tx_buf, cmd_desc, cmd_size); } #ifdef CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_VIDEO_WVGA_PT mutex_unlock(&mipi_lp_mutex); #endif wake_unlock(&idle_wake_lock); return 0; unknown_command: if (lock) mutex_unlock(&mfd->dma->ov_mutex); #ifdef CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_VIDEO_WVGA_PT mutex_unlock(&mipi_lp_mutex); #endif wake_unlock(&idle_wake_lock); return 0; }
static int aid_operation(int lux) { int index; int ratio; static int aid_status; char panel_cond_aid_ref_1 = panel_cond_aid_ref[1] ; char panel_cond_aid_ref_18 = panel_cond_aid_ref[18]; char etc_cond_set3_aid_ref_9 = etc_cond_set3_aid_ref[9]; int no_change = 0; if ((LCD_Get_Value() == 0x20) || (bypass_LCD_Id() == 0x20) ||\ (LCD_Get_Value() == 0x40)) { /*4.8 LCD_ID*/ if (lux == 0) { panel_cond_aid_ref[1] = 0x19; panel_cond_aid_ref[18] = 0x04; etc_cond_set3_aid_ref[9] = 0x40; aid_status = 0; } else if (lux >= 190) { panel_cond_aid_ref[1] = 0x19; panel_cond_aid_ref[18] = 0x04; etc_cond_set3_aid_ref[9] = 0xC0; aid_status = 0; } else if (lux >= 110) { ratio = aid_below_110_ratio_table[9][1]; panel_cond_aid_ref[1] = 0x59; panel_cond_aid_ref[18] = ratio; etc_cond_set3_aid_ref[9] = 0xC0; aid_status = 1; } else { index = (lux / 10) - 2; ratio = aid_below_110_ratio_table[index][1]; panel_cond_aid_ref[1] = 0x59; panel_cond_aid_ref[18] = ratio; etc_cond_set3_aid_ref[9] = 0xC0; aid_status = 1; } pr_debug("%s brightness_level : %d adi_status:%d", __func__, lux, aid_status); } else { /* 4.65 LCD_ID*/ memcpy(panel_cond_aid_ref, panel_cond_set, sizeof(panel_cond_set)); memcpy(etc_cond_set3_aid_ref, etc_cond_set3, sizeof(etc_cond_set3)); pr_info("%s LCD is 4.65 inch", __func__); } /*4.8 LCD_ID*/ if (lux == 0) { panel_cond_aid_ref[1] = 0x19; panel_cond_aid_ref[18] = 0x04; etc_cond_set3_aid_ref[9] = 0x40; aid_status = 0; } else if (lux >= 190) { panel_cond_aid_ref[1] = 0x19; panel_cond_aid_ref[18] = 0x04; etc_cond_set3_aid_ref[9] = 0xC0; aid_status = 0; } else if (lux >= 110) { ratio = aid_below_110_ratio_table[9][1]; panel_cond_aid_ref[1] = 0x59; panel_cond_aid_ref[18] = ratio; etc_cond_set3_aid_ref[9] = 0xC0; aid_status = 1; } else { index = (lux / 10) - 2; ratio = aid_below_110_ratio_table[index][1]; panel_cond_aid_ref[1] = 0x59; panel_cond_aid_ref[18] = ratio; etc_cond_set3_aid_ref[9] = 0xC0; aid_status = 1; } pr_debug("%s brightness_level : %d adi_status:%d", __func__, lux, aid_status); no_change = (panel_cond_aid_ref_1 == panel_cond_aid_ref[1]) && (panel_cond_aid_ref_18 == panel_cond_aid_ref[18]) && (etc_cond_set3_aid_ref_9 == etc_cond_set3_aid_ref[9]); return !no_change; }