]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/amd/display: Enable type C hotplug
authorEric Yang <Eric.Yang2@amd.com>
Thu, 11 Jul 2019 02:41:51 +0000 (22:41 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 15 Aug 2019 15:55:36 +0000 (10:55 -0500)
[Why and How]
We want to change where timing is done for alt mode.
Some of the commented out #ifs are needed for DCN20
so we enable them for that case.

Signed-off-by: Eric Yang <Eric.Yang2@amd.com>
Reviewed-by: Eric Yang <eric.yang2@amd.com>
Acked-by: Leo Li <sunpeng.li@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc_link.c
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.h
drivers/gpu/drm/amd/display/dc/inc/hw/link_encoder.h

index af42adca6e50babc1a9af3169e3dd5870cb2a88b..7af268c30f2637186179151e9d038fc6ece62e9c 100644 (file)
@@ -684,6 +684,56 @@ static bool is_same_edid(struct dc_edid *old_edid, struct dc_edid *new_edid)
        return (memcmp(old_edid->raw_edid, new_edid->raw_edid, new_edid->length) == 0);
 }
 
+bool wait_for_alt_mode(struct dc_link *link)
+{
+
+       /**
+        * something is terribly wrong if time out is > 200ms. (5Hz)
+        * 500 microseconds * 400 tries us 200 ms
+        **/
+       unsigned int sleep_time_in_microseconds = 500;
+       unsigned int tries_allowed = 400;
+       bool is_in_alt_mode;
+       unsigned long long enter_timestamp;
+       unsigned long long finish_timestamp;
+       unsigned long long time_taken_in_ns;
+       int tries_taken;
+
+       DC_LOGGER_INIT(link->ctx->logger);
+
+       if (link->link_enc->funcs->is_in_alt_mode == NULL)
+               return true;
+
+       is_in_alt_mode = link->link_enc->funcs->is_in_alt_mode(link->link_enc);
+       DC_LOG_WARNING("DP Alt mode state on HPD: %d\n", is_in_alt_mode);
+
+       if (is_in_alt_mode)
+               return true;
+
+       enter_timestamp = dm_get_timestamp(link->ctx);
+
+       for (tries_taken = 0; tries_taken < tries_allowed; tries_taken++) {
+               udelay(sleep_time_in_microseconds);
+               /* ask the link if alt mode is enabled, if so return ok */
+               if (link->link_enc->funcs->is_in_alt_mode(link->link_enc)) {
+
+                       finish_timestamp = dm_get_timestamp(link->ctx);
+                       time_taken_in_ns = dm_get_elapse_time_in_ns(
+                               link->ctx, finish_timestamp, enter_timestamp);
+                       DC_LOG_WARNING("Alt mode entered finished after %llu ms\n",
+                                      time_taken_in_ns / 1000000);
+                       return true;
+               }
+
+       }
+       finish_timestamp = dm_get_timestamp(link->ctx);
+       time_taken_in_ns = dm_get_elapse_time_in_ns(link->ctx, finish_timestamp,
+                                                   enter_timestamp);
+       DC_LOG_WARNING("Alt mode has timed out after %llu ms\n",
+                       time_taken_in_ns / 1000000);
+       return false;
+}
+
 /**
  * dc_link_detect() - Detect if a sink is attached to a given link
  *
@@ -772,6 +822,15 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason)
                }
 
                case SIGNAL_TYPE_DISPLAY_PORT: {
+                       /* wa HPD high coming too early*/
+                       if (link->link_enc->features.flags.bits.DP_IS_USB_C == 1) {
+
+                               /* if alt mode times out, return false */
+                               if (wait_for_alt_mode(link) == false) {
+                                       return false;
+                               }
+                       }
+
                        if (!detect_dp(
                                link,
                                &sink_caps,
index 33b2af1a181ce1f9a66817296710ddab926bdea3..f3e57343417c7917af5a906929d2b3e37658620c 100644 (file)
@@ -337,6 +337,7 @@ struct dcn10_link_enc_registers {
                type RDPCS_TX_FIFO_ERROR_MASK;\
                type RDPCS_DPALT_DISABLE_TOGGLE_MASK;\
                type RDPCS_DPALT_4LANE_TOGGLE_MASK;\
+               type RDPCS_PHY_DPALT_DISABLE;\
                type RDPCS_PHY_DPALT_DISABLE_ACK;\
                type RDPCS_PHY_DP_MPLLB_V2I;\
                type RDPCS_PHY_DP_MPLLB_FREQ_VCO;\
index e5e8640a9ef3ba657dd222b8642108a1650151a6..7001bfbd668187b9251f2469b5b131efa038084e 100644 (file)
@@ -183,6 +183,7 @@ struct link_encoder_funcs {
 
        bool (*fec_is_active)(struct link_encoder *enc);
 #endif
+       bool (*is_in_alt_mode) (struct link_encoder *enc);
 };
 
 #endif /* LINK_ENCODER_H_ */