drm/amd/display: Query DPIA HPD status.
authorJimmy Kizito <Jimmy.Kizito@amd.com>
Fri, 1 Apr 2022 19:24:47 +0000 (15:24 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 26 May 2022 18:56:30 +0000 (14:56 -0400)
[Why]
Driver needs up to date DPIA HPD status.

[How]
Use HPD query command to get DPIA HPD status.

Reviewed-by: Meenakshikumar Somasundaram <Meenakshikumar.Somasundaram@amd.com>
Reviewed-by: Jun Lei <Jun.Lei@amd.com>
Acked-by: Qingqing Zhuo <qingqing.zhuo@amd.com>
Signed-off-by: Jimmy Kizito <Jimmy.Kizito@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/core/dc_link.c
drivers/gpu/drm/amd/display/dc/core/dc_link_dpia.c
drivers/gpu/drm/amd/display/dc/inc/dc_link_dpia.h

index 67ef357..b40abd2 100644 (file)
@@ -33,6 +33,7 @@
 #include "gpio_service_interface.h"
 #include "core_status.h"
 #include "dc_link_dp.h"
+#include "dc_link_dpia.h"
 #include "dc_link_ddc.h"
 #include "link_hwss.h"
 #include "opp.h"
@@ -240,7 +241,7 @@ bool dc_link_detect_sink(struct dc_link *link, enum dc_connection_type *type)
 
        /* Link may not have physical HPD pin. */
        if (link->ep_type != DISPLAY_ENDPOINT_PHY) {
-               if (link->is_hpd_pending || !link->hpd_status)
+               if (link->is_hpd_pending || !dc_link_dpia_query_hpd_status(link))
                        *type = dc_connection_none;
                else
                        *type = dc_connection_single;
index a5765f3..1b7a877 100644 (file)
@@ -34,6 +34,7 @@
 #include "dm_helpers.h"
 #include "dmub/inc/dmub_cmd.h"
 #include "inc/link_dpcd.h"
+#include "dc_dmub_srv.h"
 
 #define DC_LOGGER \
        link->ctx->logger
@@ -69,6 +70,24 @@ enum dc_status dpcd_get_tunneling_device_data(struct dc_link *link)
        return status;
 }
 
+bool dc_link_dpia_query_hpd_status(struct dc_link *link)
+{
+       union dmub_rb_cmd cmd = {0};
+       struct dc_dmub_srv *dmub_srv = link->ctx->dmub_srv;
+       bool is_hpd_high = false;
+
+       /* prepare QUERY_HPD command */
+       cmd.query_hpd.header.type = DMUB_CMD__QUERY_HPD_STATE;
+       cmd.query_hpd.data.instance = link->link_id.enum_id - ENUM_ID_1;
+       cmd.query_hpd.data.ch_type = AUX_CHANNEL_DPIA;
+
+       /* Return HPD status reported by DMUB if query successfully executed. */
+       if (dc_dmub_srv_cmd_with_reply_data(dmub_srv, &cmd) && cmd.query_hpd.data.status == AUX_RET_SUCCESS)
+               is_hpd_high = cmd.query_hpd.data.result;
+
+       return is_hpd_high;
+}
+
 /* Configure link as prescribed in link_setting; set LTTPR mode; and
  * Initialize link training settings.
  * Abort link training if sink unplug detected.
index 74dafd0..39c1d1d 100644 (file)
@@ -87,6 +87,11 @@ union dpia_set_config_data {
  */
 enum dc_status dpcd_get_tunneling_device_data(struct dc_link *link);
 
+/* Query hot plug status of USB4 DP tunnel.
+ * Returns true if HPD high.
+ */
+bool dc_link_dpia_query_hpd_status(struct dc_link *link);
+
 /* Train DP tunneling link for USB4 DPIA display endpoint.
  * DPIA equivalent of dc_link_dp_perfrorm_link_training.
  * Aborts link training upon detection of sink unplug.