Skip to content

Commit 347f21c

Browse files
pwnrazronettboots
authored andcommitted
dsi_display: (doze) interpolated brightness: back to lp2
If set to lp1 screen will dim then go brighter when screen turn on during screen off fod It's still like that on lp2 but a lot less often Signed-off-by: onettboots <blackcocopet@gmail.com>
1 parent 91de164 commit 347f21c

3 files changed

Lines changed: 50 additions & 0 deletions

File tree

drivers/gpu/drm/msm/dsi-staging/dsi_display.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,45 @@ static bool dsi_display_get_cont_splash_status(struct dsi_display *display)
10571057
return true;
10581058
}
10591059

1060+
static u32 interpolate(uint32_t x, uint32_t xa, uint32_t xb, uint32_t ya, uint32_t yb)
1061+
{
1062+
return ya + (yb - ya) * (x - xa) / (xb - xa);
1063+
}
1064+
1065+
struct blbl {
1066+
u32 bl;
1067+
u32 aod_bl;
1068+
};
1069+
1070+
struct blbl aod_bl_lut[] = {
1071+
{0, 1},
1072+
{10, 1},
1073+
{40, 9},
1074+
{90, 30},
1075+
{120, 40},
1076+
};
1077+
1078+
u32 dsi_panel_get_aod_bl(struct dsi_display *display) {
1079+
int i;
1080+
//cached value is better than reading display->panel->bl_config.bl_level
1081+
u32 cur_bl = dsi_panel_backlight_get();
1082+
1083+
for (i = 0; i < 5; i++)
1084+
if (aod_bl_lut[i].bl >= cur_bl)
1085+
break;
1086+
if (i == 0)
1087+
return aod_bl_lut[i].aod_bl;
1088+
1089+
if (i == 4)
1090+
return aod_bl_lut[i - 1].aod_bl;
1091+
1092+
return interpolate(cur_bl,
1093+
aod_bl_lut[i - 1].bl,
1094+
aod_bl_lut[i].bl,
1095+
aod_bl_lut[i - 1].aod_bl,
1096+
aod_bl_lut[i].aod_bl);
1097+
}
1098+
10601099
int dsi_display_set_power(struct drm_connector *connector,
10611100
int power_mode, void *disp)
10621101
{
@@ -1086,6 +1125,8 @@ int dsi_display_set_power(struct drm_connector *connector,
10861125
rc = dsi_panel_set_lp1(display->panel);
10871126
break;
10881127
case SDE_MODE_DPMS_LP2:
1128+
dsi_panel_set_backlight(display->panel, dsi_panel_get_aod_bl(display));
1129+
usleep_range(20000, 30000);
10891130
rc = dsi_panel_set_lp2(display->panel);
10901131
break;
10911132
case SDE_MODE_DPMS_ON:

drivers/gpu/drm/msm/dsi-staging/dsi_panel.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,13 @@ static int dsi_panel_wled_register(struct dsi_panel *panel,
608608
return 0;
609609
}
610610

611+
static int saved_backlight = -1;
612+
613+
int dsi_panel_backlight_get(void)
614+
{
615+
return saved_backlight;
616+
}
617+
611618
static int dsi_panel_update_backlight(struct dsi_panel *panel,
612619
u32 bl_lvl)
613620
{

include/linux/msm_drm_notify.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,6 @@ struct msm_drm_notifier {
4545

4646
int msm_drm_register_client(struct notifier_block *nb);
4747
int msm_drm_unregister_client(struct notifier_block *nb);
48+
49+
int dsi_panel_backlight_get(void);
4850
#endif

0 commit comments

Comments
 (0)