drm/amd/display: Cache backlight_millinits in link structure and setting brightness...
authorNicholas Susanto <nicholas.susanto@amd.com>
Tue, 27 Jun 2023 18:36:49 +0000 (14:36 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 18 Jul 2023 15:14:30 +0000 (11:14 -0400)
[Why]
Need to save the cached backlight level so that display lights up using
appropriate brightness level instead of the default brightness when
waking up from s0i3.

[How]
Adding a backlight level cache in link structure. Also instead on
calling set_default_brightness_aux, check if cached values exists.

Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Reviewed-by: Wenjing Liu <wenjing.liu@amd.com>
Acked-by: Alan Liu <haoping.liu@amd.com>
Signed-off-by: Nicholas Susanto <nicholas.susanto@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dc.h
drivers/gpu/drm/amd/display/dc/dc_types.h
drivers/gpu/drm/amd/display/dc/link/link_detection.c
drivers/gpu/drm/amd/display/dc/link/link_dpms.c
drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c
drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.h

index 194f185..def7a70 100644 (file)
@@ -1515,6 +1515,7 @@ struct dc_link {
        enum edp_revision edp_revision;
        union dpcd_sink_ext_caps dpcd_sink_ext_caps;
 
+       struct backlight_settings backlight_settings;
        struct psr_settings psr_settings;
 
        /* Drive settings read from integrated info table */
index 0564f55..ed4c174 100644 (file)
@@ -994,6 +994,10 @@ struct link_mst_stream_allocation_table {
        struct link_mst_stream_allocation stream_allocations[MAX_CONTROLLER_NUM];
 };
 
+struct backlight_settings {
+       uint32_t backlight_millinits;
+};
+
 /* PSR feature flags */
 struct psr_settings {
        bool psr_feature_enabled;               // PSR is supported by sink
index 8041b83..c9b6676 100644 (file)
@@ -876,8 +876,7 @@ static bool detect_link_and_local_sink(struct dc_link *link,
                        (link->dpcd_sink_ext_caps.bits.oled == 1)) {
                        dpcd_set_source_specific_data(link);
                        msleep(post_oui_delay);
-                       set_default_brightness_aux(link);
-                       //TODO: use cached
+                       set_cached_brightness_aux(link);
                }
 
                return true;
index d8fcff0..834f342 100644 (file)
@@ -2136,7 +2136,8 @@ static enum dc_status enable_link_dp(struct dc_state *state,
        if (link->dpcd_sink_ext_caps.bits.oled == 1 ||
                link->dpcd_sink_ext_caps.bits.sdr_aux_backlight_control == 1 ||
                link->dpcd_sink_ext_caps.bits.hdr_aux_backlight_control == 1) {
-               set_default_brightness_aux(link); // TODO: use cached if known
+               set_cached_brightness_aux(link);
+
                if (link->dpcd_sink_ext_caps.bits.oled == 1)
                        msleep(bl_oled_enable_delay);
                edp_backlight_enable_aux(link, true);
index 2039a34..69fdd6e 100644 (file)
@@ -164,6 +164,7 @@ bool edp_set_backlight_level_nits(struct dc_link *link,
        *(uint32_t *)&dpcd_backlight_set.backlight_level_millinits = backlight_millinits;
        *(uint16_t *)&dpcd_backlight_set.backlight_transition_time_ms = (uint16_t)transition_time_in_ms;
 
+       link->backlight_settings.backlight_millinits = backlight_millinits;
 
        if (!link->dpcd_caps.panel_luminance_control) {
                if (core_link_write_dpcd(link, DP_SOURCE_BACKLIGHT_LEVEL,
@@ -276,6 +277,16 @@ bool set_default_brightness_aux(struct dc_link *link)
        return false;
 }
 
+bool set_cached_brightness_aux(struct dc_link *link)
+{
+       if (link->backlight_settings.backlight_millinits)
+               return edp_set_backlight_level_nits(link, true,
+                                                   link->backlight_settings.backlight_millinits, 0);
+       else
+               return set_default_brightness_aux(link);
+       return false;
+}
+
 bool edp_is_ilr_optimization_required(struct dc_link *link,
                struct dc_crtc_timing *crtc_timing)
 {
index 28f5520..fa89bdb 100644 (file)
@@ -30,6 +30,7 @@
 enum dp_panel_mode dp_get_panel_mode(struct dc_link *link);
 void dp_set_panel_mode(struct dc_link *link, enum dp_panel_mode panel_mode);
 bool set_default_brightness_aux(struct dc_link *link);
+bool set_cached_brightness_aux(struct dc_link *link);
 void edp_panel_backlight_power_on(struct dc_link *link, bool wait_for_hpd);
 int edp_get_backlight_level(const struct dc_link *link);
 bool edp_get_backlight_level_nits(struct dc_link *link,