From: Dmitry Baryshkov <[email protected]>

commit cbf143b282c64e59559cc8351c0b5b1ab4bbdcbe upstream

This is not a direct cherry-pick of the upstream commit. Only the helper
functions required as dependencies for "drm/i915: Fix HPD polling, reenabling
the output poll work as needed" were extracted from the original commit. The 
rest
of the code was not applied, as the codebase has diverged significantly.

This partial adaptation ensures that the required helpers are available for the
dependent fix, while minimizing changes to the existing code.

Extract drm_kms_helper_enable_hpd() and drm_kms_helper_disable_hpd(),
two helpers that enable and disable HPD handling on all device's
connectors.

Signed-off-by: Dmitry Baryshkov <[email protected]>
Reviewed-by: Neil Armstrong <[email protected]>
Reviewed-by: Jani Nikula <[email protected]>
Signed-off-by: Neil Armstrong <[email protected]>
Link: 
https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Nicusor Huhulea <[email protected]>
---
 drivers/gpu/drm/drm_probe_helper.c | 39 ++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/gpu/drm/drm_probe_helper.c 
b/drivers/gpu/drm/drm_probe_helper.c
index 787f6699971f..938649e3a282 100644
--- a/drivers/gpu/drm/drm_probe_helper.c
+++ b/drivers/gpu/drm/drm_probe_helper.c
@@ -244,6 +244,45 @@ static void reschedule_output_poll_work(struct drm_device 
*dev)
        schedule_delayed_work(&dev->mode_config.output_poll_work, delay);
 }
 
+static void drm_kms_helper_disable_hpd(struct drm_device *dev)
+{
+       struct drm_connector *connector;
+       struct drm_connector_list_iter conn_iter;
+
+       drm_connector_list_iter_begin(dev, &conn_iter);
+       drm_for_each_connector_iter(connector, &conn_iter) {
+               const struct drm_connector_helper_funcs *funcs =
+                       connector->helper_private;
+
+               if (funcs && funcs->disable_hpd)
+                       funcs->disable_hpd(connector);
+       }
+       drm_connector_list_iter_end(&conn_iter);
+}
+
+static bool drm_kms_helper_enable_hpd(struct drm_device *dev)
+{
+       bool poll = false;
+       struct drm_connector *connector;
+       struct drm_connector_list_iter conn_iter;
+
+       drm_connector_list_iter_begin(dev, &conn_iter);
+       drm_for_each_connector_iter(connector, &conn_iter) {
+               const struct drm_connector_helper_funcs *funcs =
+                       connector->helper_private;
+
+               if (funcs && funcs->enable_hpd)
+                       funcs->enable_hpd(connector);
+
+               if (connector->polled & (DRM_CONNECTOR_POLL_CONNECT |
+                                        DRM_CONNECTOR_POLL_DISCONNECT))
+                       poll = true;
+       }
+       drm_connector_list_iter_end(&conn_iter);
+
+       return poll;
+}
+
 /**
  * drm_kms_helper_poll_enable - re-enable output polling.
  * @dev: drm_device
-- 
2.39.2

Reply via email to