int dsim_panel_set_brightness(struct dsim_device *dsim, int force) { int ret = 0; #ifndef CONFIG_PANEL_AID_DIMMING dsim_info("%s:this panel does not support dimming \n", __func__); #else struct dim_data *dimming; struct panel_private *panel = &dsim->priv; int p_br = panel->bd->props.brightness; int acutal_br = 0; int real_br = 0; int auto_offset = 0; int prev_index = panel->br_index; bool bIsHbm = (LEVEL_IS_HBM(panel->auto_brightness) && (p_br == panel->bd->props.max_brightness)); bool bIsHbmArea = (LEVEL_IS_HBM_AREA(panel->auto_brightness) && (p_br == panel->bd->props.max_brightness)); #ifdef CONFIG_LCD_HMT if(panel->hmt_on == HMT_ON) { pr_info("%s hmt is enabled, plz set hmt brightness \n", __func__); goto set_br_exit; } #endif dimming = (struct dim_data *)panel->dim_data; if ((dimming == NULL) || (panel->br_tbl == NULL)) { dsim_info("%s : this panel does not support dimming\n", __func__); return ret; } panel->acl_enable = ACL_OPR_15P; if(bIsHbmArea) { auto_offset = 13 - panel->auto_brightness; panel->br_index = MAX_BR_INFO - auto_offset; acutal_br = real_br = get_actual_br_value(dsim, panel->br_index); panel->interpolation = 1; panel->acl_enable = ACL_OPR_8P; goto set_brightness; } else { panel->interpolation = 0; } if (panel->weakness_hbm_comp == HBM_COLORBLIND_ON) acutal_br = panel->hbm_inter_br_tbl[p_br]; else acutal_br = panel->br_tbl[p_br]; panel->br_index = get_acutal_br_index(dsim, acutal_br); real_br = get_actual_br_value(dsim, panel->br_index); panel->caps_enable = CAPS_IS_ON(real_br); if(bIsHbm) { panel->br_index = panel->hbm_index; panel->caps_enable = 1; // hbm is caps on panel->acl_enable = ACL_OPR_8P; } if (real_br > MAX_BRIGHTNESS) { panel->interpolation = 1; } else { panel->interpolation = 0; } if((!bIsHbm) && (p_br == 255)) { if (panel->weakness_hbm_comp == HBM_GALLERY_ON) { panel->acl_enable = ACL_OPR_OFF; } else { panel->acl_enable = ACL_OPR_8P; } } if (panel->state != PANEL_STATE_RESUMED) { dsim_info("%s : panel is not active state..\n", __func__); goto set_br_exit; } #ifdef AID_INTERPOLATION if (!force && panel->br_index == prev_index) { if (dynamic_lcd_type == LCD_TYPE_S6E3HA2_WQHD) goto set_br_exit; #ifdef CONFIG_LCD_BURNIN_CORRECTION if((panel->ldu_correction_state == 0) && ((panel->weakness_hbm_comp != HBM_COLORBLIND_ON) || (panel->interpolation != 1))) { #else if((panel->weakness_hbm_comp != HBM_COLORBLIND_ON) || (panel->interpolation != 1)) { #endif mutex_lock(&panel->lock); dsim_panel_aid_interpolation(dsim); ret = dsim_write_hl_data(dsim, SEQ_TEST_KEY_ON_F0, ARRAY_SIZE(SEQ_TEST_KEY_ON_F0)); if (ret < 0) { dsim_err("%s : fail to write CMD : SEQ_TEST_KEY_ON_F0\n", __func__); goto set_br_exit; } dsim_panel_set_acl(dsim, 1); ret = dsim_write_hl_data(dsim, SEQ_TEST_KEY_OFF_F0, ARRAY_SIZE(SEQ_TEST_KEY_OFF_F0)); if (ret < 0) { dsim_err("%s : fail to write CMD : SEQ_TEST_KEY_ON_F0\n", __func__); goto set_br_exit; } mutex_unlock(&panel->lock); } goto set_br_exit; } #else if (!force && panel->br_index == prev_index) goto set_br_exit; #endif if ((acutal_br == 0) || (real_br == 0)) goto set_br_exit; set_brightness: dsim_info("%s : platform : %d, : mapping : %d, real : %d, index : %d, interpolation : %d\n", __func__, p_br, acutal_br, real_br, panel->br_index+1, panel->interpolation); mutex_lock(&panel->lock); ret = low_level_set_brightness(dsim, force); if (ret) { dsim_err("%s failed to set brightness : %d\n", __func__, acutal_br); } mutex_unlock(&panel->lock); set_br_exit: #endif return ret; } #ifdef CONFIG_LCD_HMT #ifdef CONFIG_PANEL_AID_DIMMING static unsigned char *get_gamma_from_index_for_hmt(struct dsim_device *dsim, int index) { struct panel_private *panel = &dsim->priv; struct SmtDimInfo *dimming_info = (struct SmtDimInfo *)panel->hmt_dim_info; if (dimming_info == NULL) { dsim_err("%s : dimming info is NULL\n", __func__); goto get_gamma_err; } if (index > HMT_MAX_BR_INFO - 1) index = HMT_MAX_BR_INFO - 1; return (unsigned char *)dimming_info[index].gamma; get_gamma_err: return NULL; } static unsigned char *get_aid_from_index_for_hmt(struct dsim_device *dsim, int index) { struct panel_private *panel = &dsim->priv; struct SmtDimInfo *dimming_info = (struct SmtDimInfo *)panel->hmt_dim_info; if (dimming_info == NULL) { dsim_err("%s : dimming info is NULL\n", __func__); goto get_aid_err; } if (index > HMT_MAX_BR_INFO - 1) index = HMT_MAX_BR_INFO - 1; return (u8 *)dimming_info[index].aid; get_aid_err: return NULL; } static unsigned char *get_elvss_from_index_for_hmt(struct dsim_device *dsim, int index, int caps) { struct panel_private *panel = &dsim->priv; struct SmtDimInfo *dimming_info = (struct SmtDimInfo *)panel->hmt_dim_info; if (dimming_info == NULL) { dsim_err("%s : dimming info is NULL\n", __func__); goto get_elvess_err; } if(caps) return (unsigned char *)dimming_info[index].elvCaps; else return (unsigned char *)dimming_info[index].elv; get_elvess_err: return NULL; } static void dsim_panel_gamma_ctrl_for_hmt(struct dsim_device *dsim) { u8 *gamma = NULL; gamma = get_gamma_from_index_for_hmt(dsim, dsim->priv.hmt_br_index); if (gamma == NULL) { dsim_err("%s :faied to get gamma\n", __func__); return; } if (dsim_write_hl_data(dsim, gamma, GAMMA_CMD_CNT) < 0) dsim_err("%s : failed to write hmt gamma \n", __func__); }
int dsim_panel_set_brightness(struct dsim_device *dsim, int force) { int ret = 0; #ifndef CONFIG_PANEL_AID_DIMMING dsim_info("%s:this panel does not support dimming \n", __func__); #else struct dim_data *dimming; struct panel_private *panel = &dsim->priv; int p_br = panel->bd->props.brightness; int acutal_br = 0; int real_br = 0; int prev_index = panel->br_index; bool bIsHbm = (LEVEL_IS_HBM(panel->auto_brightness) && (p_br == panel->bd->props.max_brightness)); #ifdef CONFIG_LCD_HMT if(panel->hmt_on == HMT_ON) { pr_info("%s hmt is enabled, plz set hmt brightness \n", __func__); goto set_br_exit; } #endif dimming = (struct dim_data *)panel->dim_data; if ((dimming == NULL) || (panel->br_tbl == NULL)) { dsim_info("%s : this panel does not support dimming\n", __func__); return ret; } if (panel->weakness_hbm_comp == 1) acutal_br = panel->hbm_inter_br_tbl[p_br]; else if(panel->weakness_hbm_comp == 2) acutal_br = panel->gallery_br_tbl[p_br]; else acutal_br = panel->br_tbl[p_br]; panel->br_index = get_acutal_br_index(dsim, acutal_br); real_br = get_actual_br_value(dsim, panel->br_index); panel->caps_enable = CAPS_IS_ON(real_br); panel->acl_enable = ACL_IS_ON(real_br); if(bIsHbm) { panel->br_index = panel->hbm_index; panel->acl_enable = 1; // hbm is acl on panel->caps_enable = 1; // hbm is caps on } if(panel->siop_enable) // check auto acl panel->acl_enable = 1; if (real_br > MAX_BRIGHTNESS) { panel->interpolation = 1; } else { panel->interpolation = 0; } if (panel->weakness_hbm_comp) { panel->acl_enable = 1; if((!bIsHbm) && (p_br == 255)) panel->acl_enable = 0; } if (panel->state != PANEL_STATE_RESUMED) { dsim_info("%s : panel is not active state..\n", __func__); goto set_br_exit; } dsim_info("%s : platform : %d, : mapping : %d, real : %d, index : %d, interpolation : %d\n", __func__, p_br, acutal_br, real_br, panel->br_index, panel->interpolation); if (!force && panel->br_index == prev_index) goto set_br_exit; if ((acutal_br == 0) || (real_br == 0)) goto set_br_exit; mutex_lock(&panel->lock); ret = low_level_set_brightness(dsim, force); if (ret) { dsim_err("%s failed to set brightness : %d\n", __func__, acutal_br); } mutex_unlock(&panel->lock); set_br_exit: #endif return ret; }