drm/amd/display: Use dig enable to determine fast boot optimization.
authorYongqiang Sun <yongqiang.sun@amd.com>
Mon, 9 Apr 2018 20:15:20 +0000 (16:15 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 15 May 2018 18:43:27 +0000 (13:43 -0500)
Linux doesn't know lid state, better to check dig enable
value from register.

Signed-off-by: Yongqiang Sun <yongqiang.sun@amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dc_stream.h
drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.c
drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.h
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
drivers/gpu/drm/amd/display/dc/inc/hw/link_encoder.h

index 11b3433d6432ce6172b3e5d77e77a3baa28edeaf..d7e6d53bb3834828fd36877fff40fb736b24c2c0 100644 (file)
@@ -92,7 +92,6 @@ struct dc_stream_state {
        int phy_pix_clk;
        enum signal_type signal;
        bool dpms_off;
-       bool lid_state_closed;
 
        struct dc_stream_status status;
 
index 8167cad7bcf742b445012ba1a846f9b3ad966910..dbe3b26b6d9eb6134bf34f184827a19841d28cbd 100644 (file)
@@ -113,6 +113,7 @@ static const struct link_encoder_funcs dce110_lnk_enc_funcs = {
        .connect_dig_be_to_fe = dce110_link_encoder_connect_dig_be_to_fe,
        .enable_hpd = dce110_link_encoder_enable_hpd,
        .disable_hpd = dce110_link_encoder_disable_hpd,
+       .is_dig_enabled = dce110_is_dig_enabled,
        .destroy = dce110_link_encoder_destroy
 };
 
@@ -535,8 +536,9 @@ void dce110_psr_program_secondary_packet(struct link_encoder *enc,
                DP_SEC_GSP0_PRIORITY, 1);
 }
 
-static bool is_dig_enabled(const struct dce110_link_encoder *enc110)
+bool dce110_is_dig_enabled(struct link_encoder *enc)
 {
+       struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
        uint32_t value;
 
        REG_GET(DIG_BE_EN_CNTL, DIG_ENABLE, &value);
@@ -1031,7 +1033,7 @@ void dce110_link_encoder_disable_output(
        struct bp_transmitter_control cntl = { 0 };
        enum bp_result result;
 
-       if (!is_dig_enabled(enc110)) {
+       if (!dce110_is_dig_enabled(enc)) {
                /* OF_SKIP_POWER_DOWN_INACTIVE_ENCODER */
                return;
        }
index 0ec3433d34b622cdc9ebd6251cbf75a0c3261002..347069461a22aec41e54a43b851bfff3b50b86ab 100644 (file)
@@ -263,4 +263,6 @@ void dce110_psr_program_dp_dphy_fast_training(struct link_encoder *enc,
 void dce110_psr_program_secondary_packet(struct link_encoder *enc,
                        unsigned int sdp_transmit_line_num_deadline);
 
+bool dce110_is_dig_enabled(struct link_encoder *enc);
+
 #endif /* __DC_LINK_ENCODER__DCE110_H__ */
index bd34193ad7793fa7bfca6d43f794bfb5fd8889bd..e70ccb9b6afe927f4d10c6bf4a69b8c79078a84d 100644 (file)
@@ -1471,15 +1471,15 @@ static void disable_vga_and_power_gate_all_controllers(
        }
 }
 
-static bool is_eDP_lid_closed(struct dc_state *context)
+static struct dc_link *get_link_for_edp(struct dc *dc)
 {
        int i;
 
-       for (i = 0; i < context->stream_count; i++) {
-               if (context->streams[i]->signal == SIGNAL_TYPE_EDP)
-                       return context->streams[i]->lid_state_closed;
+       for (i = 0; i < dc->link_count; i++) {
+               if (dc->links[i]->connector_signal == SIGNAL_TYPE_EDP)
+                       return dc->links[i];
        }
-       return false;
+       return NULL;
 }
 
 static struct dc_link *get_link_for_edp_not_in_use(
@@ -1516,41 +1516,22 @@ static struct dc_link *get_link_for_edp_not_in_use(
  */
 void dce110_enable_accelerated_mode(struct dc *dc, struct dc_state *context)
 {
-       /* check eDP lid state and BIOS_SCRATCH_3 to determine fast boot optimization
-        * UEFI boot
-        *                              edp_active_status_from_scratch          fast boot optimization
-        * S4/S5 resume:
-        * Lid Open             true                                                            true
-        * Lid Close    false                                                           false
-        *
-        * S3/ resume:
-        * Lid Open             false                                                           false
-        * Lid Close    false                                                           false
-        *
-        * Legacy boot:
-        *                              edp_active_status_from_scratch          fast boot optimization
-        * S4/S resume:
-        * Lid Open             true                                                            true
-        * Lid Close    true                                                            false
-        *
-        * S3/ resume:
-        * Lid Open             false                                                           false
-        * Lid Close    false                                                           false
-        */
-       struct dc_bios *dcb = dc->ctx->dc_bios;
-       bool lid_state_closed = is_eDP_lid_closed(context);
        struct dc_link *edp_link_to_turnoff = NULL;
-       bool edp_active_status_from_scratch =
-                       (dcb->funcs->get_vga_enabled_displays(dc->ctx->dc_bios) == ATOM_DISPLAY_LCD1_ACTIVE);
+       struct dc_link *edp_link = get_link_for_edp(dc);
+       bool can_eDP_fast_boot_optimize = false;
+
+       if (edp_link) {
+               can_eDP_fast_boot_optimize =
+                               edp_link->link_enc->funcs->is_dig_enabled(edp_link->link_enc);
+       }
 
-       /*Lid open*/
-       if (!lid_state_closed) {
+       if (can_eDP_fast_boot_optimize) {
                edp_link_to_turnoff = get_link_for_edp_not_in_use(dc, context);
 
                /* if OS doesn't light up eDP and eDP link is available, we want to disable
                 * If resume from S4/S5, should optimization.
                 */
-               if (!edp_link_to_turnoff && edp_active_status_from_scratch)
+               if (!edp_link_to_turnoff)
                        dc->apply_edp_fast_boot_optimization = true;
        }
 
index 54d8a13861423483dfc01050a78edc1d190424da..cf6df2e7beb2d76c2dc41ea805f6d68317f11b86 100644 (file)
@@ -149,6 +149,7 @@ struct link_encoder_funcs {
                bool connect);
        void (*enable_hpd)(struct link_encoder *enc);
        void (*disable_hpd)(struct link_encoder *enc);
+       bool (*is_dig_enabled)(struct link_encoder *enc);
        void (*destroy)(struct link_encoder **enc);
 };