static int dsim_panel_set_acl(struct dsim_device *dsim, int force)
{
	int ret = 0, level = ACL_STATUS_8P;
	struct panel_private *panel = &dsim->priv;

	if (panel == NULL) {
			dsim_err("%s : panel is NULL\n", __func__);
			goto exit;
	}

	if (dsim->priv.siop_enable || LEVEL_IS_HBM(dsim->priv.auto_brightness))  // auto acl or hbm is acl on
		goto acl_update;

	if (!dsim->priv.acl_enable)
		level = ACL_STATUS_0P;

acl_update:
	if(force || dsim->priv.current_acl != panel->acl_cutoff_tbl[level][1]) {
		if((ret = dsim_write_hl_data(dsim,  panel->acl_opr_tbl[level], 2)) < 0) {
			dsim_err("fail to write acl opr command.\n");
			goto exit;
		}
		if((ret = dsim_write_hl_data(dsim, panel->acl_cutoff_tbl[level], 2)) < 0) {
			dsim_err("fail to write acl command.\n");
			goto exit;
		}
		dsim->priv.current_acl = panel->acl_cutoff_tbl[level][1];
		dsim_info("acl: %d, auto_brightness: %d\n", dsim->priv.current_acl, dsim->priv.auto_brightness);
	}
exit:
	if (!ret)
		ret = -EPERM;
	return ret;
}
static int update_brightness(struct lcd_info *lcd, u8 force)
{
	mutex_lock(&lcd->bl_lock);

	lcd->brightness = lcd->bd->props.brightness;

	lcd->bl = get_backlight_level_from_brightness(lcd->brightness);

	if (LEVEL_IS_HBM(lcd->auto_brightness) && (lcd->brightness == lcd->bd->props.max_brightness))
		lcd->bl = IBRIGHTNESS_500NT;

	if (force || lcd->ldi_enable) {
		ana38401_gamma_ctl(lcd, force);
		ana38401_aid_parameter_ctl(lcd, force);
		ana38401_set_elvss(lcd, force);
		ana38401_set_elvss_base(lcd, force);
		ana38401_set_acl(lcd, force);
		ana38401_set_caps(lcd, force);
		ana38401_write(lcd, SEQ_GAMMA_UPDATE_1, ARRAY_SIZE(SEQ_GAMMA_UPDATE_1));
		ana38401_write(lcd, SEQ_GAMMA_UPDATE_2, ARRAY_SIZE(SEQ_GAMMA_UPDATE_2));

		lcd->current_bl = lcd->bl;
		lcd->current_brightness = lcd->brightness;

		dev_info(&lcd->ld->dev, "brightness=%d, bl=%d, candela=%d\n",
			lcd->brightness, lcd->bl, index_brightness_table[lcd->bl]);
	}

	mutex_unlock(&lcd->bl_lock);

	return 0;
}
static void dsim_panel_set_elvss(struct dsim_device *dsim)
{
	u8 *elvss = NULL;
	unsigned char SEQ_ELVSS[ELVSS_LEN_MAX] = {0, };
	struct panel_private *panel = &dsim->priv;
	bool bIsHbm = (LEVEL_IS_HBM(panel->auto_brightness) && (panel->bd->props.brightness == panel->bd->props.max_brightness));

	SEQ_ELVSS[0] = aid_dimming_dynamic.elvss_reg;
	elvss = get_elvss_from_index(dsim, dsim->priv.br_index, dsim->priv.caps_enable);
	if (elvss == NULL) {
		dsim_err("%s : failed to get elvss value\n", __func__);
		return;
	}
	memcpy(&SEQ_ELVSS[1], dsim->priv.elvss_set, aid_dimming_dynamic.elvss_len - 1);
	memcpy(SEQ_ELVSS, elvss, aid_dimming_dynamic.elvss_cmd_cnt);

	SEQ_ELVSS[aid_dimming_dynamic.elvss_len - 1] += dsim_panel_get_elvssoffset(dsim);
	if(bIsHbm)
		SEQ_ELVSS[2] = 0x0A;
	if(dynamic_lcd_type == LCD_TYPE_S6E3HA2_WQHD) {
		dsim_info("%s elvss ha2\n", __func__);
		if (dsim_write_hl_data(dsim, SEQ_ELVSS, aid_dimming_dynamic.elvss_len) < 0)
			dsim_err("%s : failed to write elvss \n", __func__);
	} else {
		dsim_info("%s elvss ha3/hf3\n", __func__);
		memcpy(dsim->priv.tset, &SEQ_ELVSS[1], aid_dimming_dynamic.elvss_len - 1);
		dsim_panel_set_tset(dsim, 1);
	}
}
static int ana38401_set_elvss_base(struct lcd_info *lcd, u8 force)
{
	int ret = 0, level = LEVEL_IS_HBM(lcd->auto_brightness);

	if (force || lcd->current_elvss_base != lcd->elvss_base_table[level][1]) {
		ret += ana38401_write(lcd, SEQ_ELVSS_BASE_SET_1, DEFAULT_PARAM_SIZE);
		ret += ana38401_write(lcd, lcd->elvss_base_table[level], DEFAULT_PARAM_SIZE);
		lcd->current_elvss_base = lcd->elvss_base_table[level][1];
		dev_info(&lcd->ld->dev, "base: %x, auto_brightness: %d\n", lcd->current_elvss_base, lcd->auto_brightness);
	}

	if (!ret)
		ret = -EPERM;

	return ret;
}
Example #5
0
static int update_brightness(struct lcd_info *lcd, u8 force)
{
	u32 brightness;

	mutex_lock(&lcd->bl_lock);

	brightness = lcd->bd->props.brightness;

	if (brightness < DIM_BRIGHTNESS)
		brightness = DIM_BRIGHTNESS;

	lcd->bl = get_backlight_level_from_brightness(brightness);

	if (LEVEL_IS_HBM(lcd->auto_brightness) && (brightness == lcd->bd->props.max_brightness))
		lcd->outdoor = true;
	else
		lcd->outdoor = false;

	if ((force) || ((lcd->ldi_enable) && (lcd->current_bl != lcd->bl))) {

		lcd->current_bl = lcd->bl;
		SEQ_WRDISBV_CTL[1] = lcd->bl;
		s6d6aa1_write(lcd, SEQ_WRDISBV_CTL, ARRAY_SIZE(SEQ_WRDISBV_CTL));

		dev_info(&lcd->ld->dev, "brightness=%d, bl=%d\n", brightness, lcd->bl);
	}

	if ((force) || (lcd->current_outdoor != lcd->outdoor)) {
		lcd->current_outdoor = lcd->outdoor;
		SEQ_WRDISBV_CTL[1] = lcd->outdoor ? 230 : lcd->bl;

		s6d6aa1_write(lcd, SEQ_WRDISBV_CTL,	ARRAY_SIZE(SEQ_WRDISBV_CTL));
		s6d6aa1_write(lcd, (lcd->outdoor ? SEQ_WRCABC_OUTDOOR : SEQ_WRCABC), \
			ARRAY_SIZE(SEQ_WRCABC));

		dev_info(&lcd->ld->dev, "outdoor mode is %s\n", lcd->outdoor ? "ON" : "OFF");
	}

	mutex_unlock(&lcd->bl_lock);

	return 0;
}
static int dsim_panel_set_hbm(struct dsim_device *dsim, int force)
{
	int ret = 0, level = LEVEL_IS_HBM(dsim->priv.auto_brightness);
	struct panel_private *panel = &dsim->priv;

	if (panel == NULL) {
		dsim_err("%s : panel is NULL\n", __func__);
		goto exit;
	}

	if(force || dsim->priv.current_hbm != panel->hbm_tbl[level][1]) {
		dsim->priv.current_hbm = panel->hbm_tbl[level][1];
		if((ret = dsim_write_hl_data(dsim, panel->hbm_tbl[level], ARRAY_SIZE(SEQ_HBM_OFF))) < 0) {
			dsim_err("fail to write hbm command.\n");
			ret = -EPERM;
		}
		dsim_info("hbm: %d, auto_brightness: %d\n", dsim->priv.current_hbm, dsim->priv.auto_brightness);
	}
exit:
	return ret;
}
static int dsim_panel_set_acl(struct dsim_device *dsim, int force )
{
	int ret = 0, level = ACL_OPR_OFF, enabled;
	struct panel_private *panel = &dsim->priv;

	if (panel == NULL) {
			dsim_err("%s : panel is NULL\n", __func__);
			goto exit;
	}

	level = ACL_OPR_OFF;
	enabled = ACL_STATUS_OFF;

	if (dsim->priv.siop_enable || LEVEL_IS_HBM(dsim->priv.auto_brightness))  // auto acl or hbm is acl on
		goto acl_update;

	level = dsim->priv.acl_enable;
	enabled = (dsim->priv.acl_enable != ACL_OPR_OFF);

acl_update:
	if(force || dsim->priv.current_acl != level) {
		if((ret = dsim_write_hl_data(dsim,  panel->acl_opr_tbl[level], ACL_OPR_LEN)) < 0) {
			dsim_err("fail to write acl opr command.\n");
			goto exit;
		}
		if((ret = dsim_write_hl_data(dsim, panel->acl_cutoff_tbl[enabled], ACL_CMD_LEN)) < 0) {
			dsim_err("fail to write acl command.\n");
			goto exit;
		}
		dsim->priv.current_acl = level;
		dsim_info("acl : %x, opr: %x\n",
			panel->acl_cutoff_tbl[enabled][1], panel->acl_opr_tbl[level][ACL_OPR_LEN-1]);
		dsim_info("acl: %d(%x), auto_brightness: %d\n", dsim->priv.current_acl, panel->acl_opr_tbl[level][ACL_CMD_LEN-1],dsim->priv.auto_brightness);
	}
exit:
	if (!ret)
		ret = -EPERM;
	return ret;
}
static void dsim_panel_set_elvss(struct dsim_device *dsim)
{
	u8 *elvss = NULL;
	unsigned char SEQ_ELVSS[ELVSS_LEN_MAX] = {0, };
	struct panel_private *panel = &dsim->priv;
	bool bIsHbm = (LEVEL_IS_HBM(panel->auto_brightness) && (panel->bd->props.brightness == panel->bd->props.max_brightness));

	SEQ_ELVSS[0] = ELVSS_REG;
	elvss = get_elvss_from_index(dsim, dsim->priv.br_index, dsim->priv.caps_enable);
	if (elvss == NULL) {
		dsim_err("%s : failed to get elvss value\n", __func__);
		return;
	}
	memcpy(&SEQ_ELVSS[1], dsim->priv.elvss_set, ELVSS_LEN - 1);
	memcpy(SEQ_ELVSS, elvss, ELVSS_CMD_CNT);

	SEQ_ELVSS[ELVSS_LEN - 1] += dsim_panel_get_elvssoffset(dsim);
	if(bIsHbm ||
		((panel->interpolation) && (panel->weakness_hbm_comp == HBM_COLORBLIND_ON)))
		SEQ_ELVSS[2] = 0x0A;
	if (dsim_write_hl_data(dsim, SEQ_ELVSS, ELVSS_LEN) < 0)
		dsim_err("%s : failed to write elvss \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;
#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)
		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->acl_enable = ACL_IS_ON(real_br);
	panel->caps_enable = CAPS_IS_ON(real_br);

	if (LEVEL_IS_HBM(panel->auto_brightness) && (p_br == panel->bd->props.max_brightness)) {
		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 (acutal_br > MAX_BRIGHTNESS) {
		panel->interpolation = 1;
		panel->acl_enable = 0;
	} else {
		panel->interpolation = 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;
}
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;
	int m_force = force;
	bool bIsHbm = (LEVEL_IS_HBM(panel->auto_brightness) && (p_br == panel->bd->props.max_brightness));
	bool is_weak_mode;
	bool is_gallery;
	bool is_max_br;
	
#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

	if (panel->is_br_override && p_br!=panel->override_br_value) {
		pr_info( "%s : brightness %d canceled by override(%d)\n", 
			__func__, p_br, panel->override_br_value );
		goto set_br_exit;
	}

	is_weak_mode = (panel->weakness_hbm_comp == 1);
	is_gallery = (panel->weakness_hbm_comp == 2);

	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 (is_weak_mode)	// color weak mode
		acutal_br = panel->hbm_inter_br_tbl[p_br];
	else if(is_gallery)	// gallery
		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);
	if(panel->acl_enable != ACL_IS_ON(p_br)) {
		m_force = 1;
	}

	if( ACL_IS_ON(p_br) ) panel->acl_enable = ACL_OPR_15P;
	else panel->acl_enable = ACL_OPR_OFF;

	if(bIsHbm) {
		panel->br_index = panel->hbm_index;
		panel->acl_enable = ACL_OPR_8P;				// hbm is acl on
		panel->caps_enable = 1;				// hbm is caps on
	}
	if(panel->siop_enable)					// check auto acl
		panel->acl_enable = ACL_OPR_15P;

	if (real_br > MAX_BRIGHTNESS) {
		panel->interpolation = 1;
	} else {
		panel->interpolation = 0;
	}

	is_max_br =((!bIsHbm) && (p_br == 255));
	if (is_weak_mode) {
		panel->acl_enable = ACL_OPR_15P;
	} else 	if (is_gallery) {
		panel->acl_enable = ACL_OPR_15P;
		if(is_max_br)
			panel->acl_enable = ACL_OPR_OFF;
	} else if(is_max_br) {
		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;
	}

	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 (!m_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, m_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;
}
static char dsim_panel_get_elvssoffset(struct dsim_device *dsim)
{
	int nit = 0;
	char retVal = 0x00;
	struct panel_private* panel = &(dsim->priv);
	bool bIsHbm = (LEVEL_IS_HBM(panel->auto_brightness) && (panel->bd->props.brightness == panel->bd->props.max_brightness));

	nit = panel->br_tbl[panel->bd->props.brightness];

	if((!bIsHbm) && (panel->interpolation)) {
		if(panel->weakness_hbm_comp == HBM_COLORBLIND_ON)
			retVal = -panel->hbm_elvss_comp;
		else if(panel->weakness_hbm_comp == HBM_GALLERY_ON)
			retVal = -HBM_INTER_22TH_OFFSET[panel->br_index - 65];
		else
			pr_info("%s invaid weakness_hbm_comp:%d\n", __func__, panel->weakness_hbm_comp);
		goto exit_get_elvss;
	}

	if(UNDER_MINUS_20(panel->temperature)) {
		switch(nit)
		{
#if defined(CONFIG_PANEL_S6E3HA2_DYNAMIC)	// flat
		case 2:
			retVal = 0x00;
			break;
		case 3:
			retVal = -0x01;
			break;
		case 4:
			retVal = -0x02;
			break;
		case 5:
			retVal = -0x03;
			break;
		default:
			retVal = -0x04;
			break;
#elif defined(CONFIG_PANEL_S6E3HF2_DYNAMIC)		  // edge
		case 2:
			retVal = -0x01;
			break;
		case 3:
			retVal = -0x02;
			break;
		case 4:
			retVal = -0x03;
			break;
		case 5:
			retVal = -0x04;
			break;
		default:
			retVal = -0x05;
			break;
#endif
		}
	} else if(UNDER_0(panel->temperature)) {
		switch(nit)
		{
		case 2:
			retVal = 0x04;
			break;
		case 3:
			retVal = 0x03;
			break;
		case 4:
			retVal = 0x02;
			break;
		case 5:
			retVal = 0x01;
			break;
		default:
			retVal = 0x00;
			break;
		}
	} else {
		retVal = 0x00;
	}

exit_get_elvss:
	pr_info("%s %d\n", __func__, retVal);
	return retVal;
}
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__);
}