Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac878e6b authored by guozhiming's avatar guozhiming Committed by qiuchangping
Browse files

Synchronize codes for Oneplus 7 Pro Oxygen OS 9.5.8.GM21AA

Display: Optimize display function

Change-Id: I3f74c518e75894f1574dfc68344f2f5ecb7e5d6b
parent 8010d950
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -973,6 +973,8 @@ static ssize_t panel_mismatch_show(struct device *dev,

int oneplus_panel_alpha =0;
int oneplus_force_screenfp = 0;
int op_dimlayer_bl_enable = 0;
int op_dp_enable = 0;
extern int oneplus_get_panel_brightness_to_alpha(void);

static ssize_t oneplus_display_get_dim_alpha(struct device *dev,
@@ -1024,6 +1026,37 @@ static ssize_t oneplus_display_set_forcescreenfp(struct device *dev,
	return count;
}


static ssize_t op_display_get_dimlayer_enable(struct device *dev,
				struct device_attribute *attr, char *buf)
{
	return sprintf(buf, "%d\n", op_dimlayer_bl_enable);
}

static ssize_t op_display_set_dimlayer_enable(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t count)
{
	sscanf(buf, "%d", &op_dimlayer_bl_enable);

	return count;
}

static ssize_t op_display_get_dp_enable(struct device *dev,
				struct device_attribute *attr, char *buf)
{
	return sprintf(buf, "%d\n", op_dp_enable);
}

static ssize_t op_display_set_dp_enable(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t count)
{
	sscanf(buf, "%d", &op_dp_enable);

	return count;
}

extern  ssize_t oneplus_display_notify_fp_press(struct device *dev,
		struct device_attribute *attr,
		const char *buf, size_t count);
@@ -1065,6 +1098,8 @@ static DEVICE_ATTR(force_screenfp, S_IRUGO|S_IWUSR, oneplus_display_get_forcescr
static DEVICE_ATTR(notify_fppress, S_IRUGO|S_IWUSR, NULL, oneplus_display_notify_fp_press);
static DEVICE_ATTR(notify_dim, S_IRUGO|S_IWUSR, NULL, oneplus_display_notify_dim);
static DEVICE_ATTR(notify_aod, S_IRUGO|S_IWUSR, NULL, oneplus_display_notify_aod_hid);
static DEVICE_ATTR(dimlayer_bl_en, S_IRUGO|S_IWUSR, op_display_get_dimlayer_enable, op_display_set_dimlayer_enable);
static DEVICE_ATTR(dp_en, S_IRUGO|S_IWUSR, op_display_get_dp_enable, op_display_set_dp_enable);

static struct attribute *connector_dev_attrs[] = {
	&dev_attr_status.attr,
@@ -1096,6 +1131,8 @@ static struct attribute *connector_dev_attrs[] = {
	&dev_attr_notify_fppress.attr,
	&dev_attr_notify_dim.attr,
	&dev_attr_notify_aod.attr,
	&dev_attr_dimlayer_bl_en.attr,
	&dev_attr_dp_en.attr,
	NULL
};

+15 −0
Original line number Diff line number Diff line
@@ -781,6 +781,9 @@ int dsi_panel_gamma_read_address_setting(struct dsi_panel *panel, u16 read_numbe
	return rc;
}

extern int op_dimlayer_bl_alpha;
extern int op_dimlayer_bl_enabled;
extern int op_dimlayer_bl_enable_real;
static int dsi_panel_update_backlight(struct dsi_panel *panel,
	u32 bl_lvl)
{
@@ -802,6 +805,18 @@ static int dsi_panel_update_backlight(struct dsi_panel *panel,
		pr_err("HBM is enabled\n");
		return 0;
	}
	if (op_dimlayer_bl_enabled != op_dimlayer_bl_enable_real) {
		op_dimlayer_bl_enable_real = op_dimlayer_bl_enabled;
		if (op_dimlayer_bl_enable_real) {
		bl_lvl = op_dimlayer_bl_alpha;
			pr_err("dc light enable\n");
		} else {
			pr_err("dc light disenable\n");
		}
	}
	if (op_dimlayer_bl_enable_real) {
		bl_lvl = op_dimlayer_bl_alpha;
    }

	if (panel->bl_config.bl_high2bit) {
		if (HBM_flag == true)
+17 −0
Original line number Diff line number Diff line
@@ -623,6 +623,23 @@ extern int oneplus_dim_status;
extern bool aod_real_flag;
extern bool finger_type;

extern int op_dimlayer_bl;
extern int op_dimlayer_bl_enabled;

int sde_connector_update_backlight(struct drm_connector *connector)
{
	if (op_dimlayer_bl != op_dimlayer_bl_enabled) {
		struct sde_connector *c_conn = to_sde_connector(connector);
		if (!c_conn) {
			SDE_ERROR("Invalid params sde_connector null\n");
			return -EINVAL;
			}
		op_dimlayer_bl_enabled = op_dimlayer_bl;
		_sde_connector_update_bl_scale(c_conn);
	}

	return 0;
}
static int _sde_connector_update_hbm(struct sde_connector *c_conn)
{
	struct drm_connector *connector = &c_conn->base;
+101 −10
Original line number Diff line number Diff line
@@ -3099,7 +3099,7 @@ static void _sde_crtc_set_dim_layer_v1(struct sde_crtc_state *cstate,
	}
}

bool sde_crtc_get_fingerprint_mode(struct drm_crtc_state *crtc_state)
bool sde_crtc_get_dimlayer_mode(struct drm_crtc_state *crtc_state)
{
	struct sde_crtc_state *cstate;

@@ -3110,6 +3110,17 @@ bool sde_crtc_get_fingerprint_mode(struct drm_crtc_state *crtc_state)
	return !!cstate->fingerprint_dim_layer;
}

bool sde_crtc_get_fingerprint_mode(struct drm_crtc_state *crtc_state)
{
	struct sde_crtc_state *cstate;

	if (!crtc_state)
		return false;

	cstate = to_sde_crtc_state(crtc_state);
	return !!cstate->fingerprint_mode;
}

bool sde_crtc_get_fingerprint_pressed(struct drm_crtc_state *crtc_state)
{
	struct sde_crtc_state *cstate;
@@ -3154,6 +3165,27 @@ struct ba brightness_alpha_lut[] = {
	{2000, 0x83},
};

struct ba brightness_alpha_lut_dc[] = {

   {0, 0xff},
   {1, 0xE0},
   {2, 0xd5},
   {3, 0xd3},
   {4, 0xd0},
   {5, 0xce},
   {6, 0xcb},
   {8, 0xc8},
   {10, 0xc4},
   {15, 0xba},
   {20, 0xb0},
   {30, 0xa0},
   {45, 0x8b},
   {70, 0x72},
   {100, 0x5a},
   {150, 0x38},
   {227, 0xe},
   {260, 0x00},
};
static int interpolate(int x, int xa, int xb, int ya, int yb)
{
	int bf, factor, plus;
@@ -3190,6 +3222,29 @@ int brightness_to_alpha(int brightness)
			brightness_alpha_lut[i].alpha);
}

int bl_to_alpha_dc(int brightness)
{
	int level = ARRAY_SIZE(brightness_alpha_lut_dc);
	int i = 0;
	int alpha;

	for (i = 0; i < ARRAY_SIZE(brightness_alpha_lut_dc); i++) {
		if (brightness_alpha_lut_dc[i].brightness >= brightness)
			break;
	}

	if (i == 0)
		alpha = brightness_alpha_lut_dc[0].alpha;
	else if (i == level)
		alpha = brightness_alpha_lut_dc[level - 1].alpha;
	else
		alpha = interpolate(brightness,
			brightness_alpha_lut_dc[i-1].brightness,
			brightness_alpha_lut_dc[i].brightness,
			brightness_alpha_lut_dc[i-1].alpha,
			brightness_alpha_lut_dc[i].alpha);
	return alpha;
}
int oneplus_get_panel_brightness_to_alpha(void)
{
	struct dsi_display *display = get_main_display();
@@ -3198,7 +3253,10 @@ int oneplus_get_panel_brightness_to_alpha(void)
		return 0;
	if (oneplus_panel_alpha)
		return oneplus_panel_alpha;
    if (display->panel->dim_status)
		return brightness_to_alpha(display->panel->hbm_backlight);
    else
	return bl_to_alpha_dc(display->panel->hbm_backlight);
}

int oneplus_onscreenaod_hid = 0;
@@ -3287,6 +3345,7 @@ extern int aod_layer_hide;
extern bool HBM_flag;
int oneplus_dim_status = 0;
int oneplus_aod_fod = 0;
int oneplus_aod_dc = 0;
 ssize_t oneplus_display_notify_dim(struct device *dev,
		struct device_attribute *attr,
		const char *buf, size_t count)
@@ -3330,6 +3389,8 @@ int oneplus_aod_fod = 0;
        oneplus_aod_fod = 1;
	}else if(dsi_display->panel->aod_status==1&& dim_status == 0){
		oneplus_onscreenfp_status = 0;
    }else if(dsi_display->panel->aod_status==1&& dim_status == 5){
        oneplus_aod_dc = 1;
    }
    if(dim_status == 0)
        oneplus_onscreenfp_status = 0;
@@ -5458,8 +5519,13 @@ static int _sde_crtc_check_secure_state(struct drm_crtc *crtc,
	return 0;
}

int op_dimlayer_bl_alpha = 260;
int op_dimlayer_bl_enabled = 0;
int op_dimlayer_bl_enable_real = 0;
int op_dimlayer_bl = 0;
extern bool finger_type;
//extern int aod_layer_hide;
extern int op_dimlayer_bl_enable;
extern int op_dp_enable;
extern int sde_plane_check_fingerprint_layer(const struct drm_plane_state *drm_state);
static int sde_crtc_onscreenfinger_atomic_check(struct sde_crtc_state *cstate,
		struct plane_state *pstates, int cnt)
@@ -5475,6 +5541,7 @@ static int sde_crtc_onscreenfinger_atomic_check(struct sde_crtc_state *cstate,
    int aod_mode = -1;
	int i;
    struct dsi_display *display = get_main_display();
    int dim_backlight = 0;

    if(display == NULL || display->panel == NULL){
        SDE_ERROR("display  panel is null\n");
@@ -5509,7 +5576,7 @@ static int sde_crtc_onscreenfinger_atomic_check(struct sde_crtc_state *cstate,
        if (mode ==3)
            aod_index = i;
	}
	if(fp_index >=0)
	if(fp_index >=0 && dim_mode!=0)
		display->panel->dim_status = true;
	else
		display->panel->dim_status = false;
@@ -5519,8 +5586,10 @@ static int sde_crtc_onscreenfinger_atomic_check(struct sde_crtc_state *cstate,
		aod_layer_hide = 0;
	}

	if(fppressed_index_rt < 0)
	if(fppressed_index_rt < 0){
		oneplus_aod_fod = 0;
		oneplus_aod_dc = 0;
    }

    if(finger_type){
        if (aod_index >= 0) {
@@ -5534,7 +5603,23 @@ static int sde_crtc_onscreenfinger_atomic_check(struct sde_crtc_state *cstate,
        return 0;
    }

	if (fp_index >= 0 || fppressed_index >= 0 || oneplus_force_screenfp) {
    if ((fp_index >= 0 && dim_mode!=0)||(display->panel->aod_status==1&& oneplus_aod_dc ==0)) {
	op_dimlayer_bl = 0;
    } else{
	if (op_dimlayer_bl_enable && !op_dp_enable) {
		if (display->panel->bl_config.bl_level != 0 &&
			display->panel->bl_config.bl_level < op_dimlayer_bl_alpha){
			dim_backlight = 1;
			op_dimlayer_bl = 1;
		} else{
			op_dimlayer_bl = 0;
		}
	} else{
		op_dimlayer_bl = 0;
	}
    }

	if (fp_index >= 0 || fppressed_index >= 0 || oneplus_force_screenfp || dim_backlight == 1) {
		if (fp_index >= 0 && fppressed_index >= 0) {
			if (pstates[fp_index].stage >= pstates[fppressed_index].stage) {
				SDE_ERROR("Bug!!@@@@: fp layer top of fppressed layer\n");
@@ -5604,7 +5689,12 @@ static int sde_crtc_onscreenfinger_atomic_check(struct sde_crtc_state *cstate,
			}
		}

		if (fp_index >= 0 && sde_crtc_config_fingerprint_dim_layer(&cstate->base, zpos)) {
		if (fp_index >= 0)
			cstate->fingerprint_mode = true;
		else
			cstate->fingerprint_mode = false;

		if ((fp_index >= 0 || dim_backlight > 0) && sde_crtc_config_fingerprint_dim_layer(&cstate->base, zpos)) {
			SDE_ERROR("Failed to config dim layer\n");
			return -EINVAL;
		}
@@ -5613,12 +5703,13 @@ static int sde_crtc_onscreenfinger_atomic_check(struct sde_crtc_state *cstate,
		else {
			cstate->fingerprint_pressed = false;
		}
	} else{
	cstate->fingerprint_pressed = false;
	cstate->fingerprint_mode = false;
    }
	if (fp_index < 0) {
	if (fp_index < 0 && !dim_backlight) {
		cstate->fingerprint_dim_layer = NULL;
	}
	if (fppressed_index < 0)
		cstate->fingerprint_pressed = false;

	return 0;
}
+1 −0
Original line number Diff line number Diff line
@@ -426,6 +426,7 @@ struct sde_crtc_state {
	u32 sbuf_prefill_line;
	u64 sbuf_clk_rate[2];
	bool sbuf_clk_shifted;
	bool fingerprint_mode;
	bool fingerprint_pressed;
	struct sde_hw_dim_layer *fingerprint_dim_layer;

Loading