Set .detect_ctx() in struct drm_connector_helper_funcs to the
common helper drm_connector_helper_detect_from_ddc() and enable
polling for the connector. Mgag200 will now test for the monitor's
presence by probing the DDC in regular intervals.

Signed-off-by: Thomas Zimmermann <tzimmerm...@suse.de>
---
 drivers/gpu/drm/mgag200/mgag200_drv.h     | 3 ++-
 drivers/gpu/drm/mgag200/mgag200_g200.c    | 4 ++++
 drivers/gpu/drm/mgag200/mgag200_g200eh.c  | 4 ++++
 drivers/gpu/drm/mgag200/mgag200_g200eh3.c | 4 ++++
 drivers/gpu/drm/mgag200/mgag200_g200er.c  | 4 ++++
 drivers/gpu/drm/mgag200/mgag200_g200ev.c  | 4 ++++
 drivers/gpu/drm/mgag200/mgag200_g200ew3.c | 4 ++++
 drivers/gpu/drm/mgag200/mgag200_g200se.c  | 4 ++++
 drivers/gpu/drm/mgag200/mgag200_g200wb.c  | 4 ++++
 9 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h 
b/drivers/gpu/drm/mgag200/mgag200_drv.h
index 49237a260ab05..2a3bc9db60870 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.h
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.h
@@ -416,7 +416,8 @@ void mgag200_crtc_atomic_destroy_state(struct drm_crtc 
*crtc, struct drm_crtc_st
        .destroy = drm_encoder_cleanup
 
 #define MGAG200_VGA_CONNECTOR_HELPER_FUNCS \
-       .get_modes = drm_connector_helper_get_modes
+       .get_modes = drm_connector_helper_get_modes, \
+       .detect_ctx = drm_connector_helper_detect_from_ddc
 
 #define MGAG200_VGA_CONNECTOR_FUNCS \
        .reset                  = drm_atomic_helper_connector_reset, \
diff --git a/drivers/gpu/drm/mgag200/mgag200_g200.c 
b/drivers/gpu/drm/mgag200/mgag200_g200.c
index 39a29d8ffca6e..0fe102db5a1a6 100644
--- a/drivers/gpu/drm/mgag200/mgag200_g200.c
+++ b/drivers/gpu/drm/mgag200/mgag200_g200.c
@@ -255,6 +255,9 @@ static int mgag200_g200_pipeline_init(struct mga_device 
*mdev)
        }
        drm_connector_helper_add(connector, 
&mgag200_g200_vga_connector_helper_funcs);
 
+       connector->polled = DRM_CONNECTOR_POLL_CONNECT |
+                           DRM_CONNECTOR_POLL_DISCONNECT;
+
        ret = drm_connector_attach_encoder(connector, encoder);
        if (ret) {
                drm_err(dev, "drm_connector_attach_encoder() failed: %d\n", 
ret);
@@ -443,6 +446,7 @@ struct mga_device *mgag200_g200_device_create(struct 
pci_dev *pdev, const struct
                return ERR_PTR(ret);
 
        drm_mode_config_reset(dev);
+       drm_kms_helper_poll_init(dev);
 
        return mdev;
 }
diff --git a/drivers/gpu/drm/mgag200/mgag200_g200eh.c 
b/drivers/gpu/drm/mgag200/mgag200_g200eh.c
index 619fee7ffdf5e..5a493bbf4a9ae 100644
--- a/drivers/gpu/drm/mgag200/mgag200_g200eh.c
+++ b/drivers/gpu/drm/mgag200/mgag200_g200eh.c
@@ -254,6 +254,9 @@ static int mgag200_g200eh_pipeline_init(struct mga_device 
*mdev)
        }
        drm_connector_helper_add(connector, 
&mgag200_g200eh_vga_connector_helper_funcs);
 
+       connector->polled = DRM_CONNECTOR_POLL_CONNECT |
+                           DRM_CONNECTOR_POLL_DISCONNECT;
+
        ret = drm_connector_attach_encoder(connector, encoder);
        if (ret) {
                drm_err(dev, "drm_connector_attach_encoder() failed: %d\n", 
ret);
@@ -315,6 +318,7 @@ struct mga_device *mgag200_g200eh_device_create(struct 
pci_dev *pdev, const stru
                return ERR_PTR(ret);
 
        drm_mode_config_reset(dev);
+       drm_kms_helper_poll_init(dev);
 
        return mdev;
 }
diff --git a/drivers/gpu/drm/mgag200/mgag200_g200eh3.c 
b/drivers/gpu/drm/mgag200/mgag200_g200eh3.c
index a172b8a4500a0..a439dfc521489 100644
--- a/drivers/gpu/drm/mgag200/mgag200_g200eh3.c
+++ b/drivers/gpu/drm/mgag200/mgag200_g200eh3.c
@@ -158,6 +158,9 @@ static int mgag200_g200eh3_pipeline_init(struct mga_device 
*mdev)
        }
        drm_connector_helper_add(connector, 
&mgag200_g200eh3_vga_connector_helper_funcs);
 
+       connector->polled = DRM_CONNECTOR_POLL_CONNECT |
+                           DRM_CONNECTOR_POLL_DISCONNECT;
+
        ret = drm_connector_attach_encoder(connector, encoder);
        if (ret) {
                drm_err(dev, "drm_connector_attach_encoder() failed: %d\n", 
ret);
@@ -220,6 +223,7 @@ struct mga_device *mgag200_g200eh3_device_create(struct 
pci_dev *pdev,
                return ERR_PTR(ret);
 
        drm_mode_config_reset(dev);
+       drm_kms_helper_poll_init(dev);
 
        return mdev;
 }
diff --git a/drivers/gpu/drm/mgag200/mgag200_g200er.c 
b/drivers/gpu/drm/mgag200/mgag200_g200er.c
index a11c91331e43e..b3e6c2a7281cd 100644
--- a/drivers/gpu/drm/mgag200/mgag200_g200er.c
+++ b/drivers/gpu/drm/mgag200/mgag200_g200er.c
@@ -297,6 +297,9 @@ static int mgag200_g200er_pipeline_init(struct mga_device 
*mdev)
        }
        drm_connector_helper_add(connector, 
&mgag200_g200er_vga_connector_helper_funcs);
 
+       connector->polled = DRM_CONNECTOR_POLL_CONNECT |
+                           DRM_CONNECTOR_POLL_DISCONNECT;
+
        ret = drm_connector_attach_encoder(connector, encoder);
        if (ret) {
                drm_err(dev, "drm_connector_attach_encoder() failed: %d\n", 
ret);
@@ -354,6 +357,7 @@ struct mga_device *mgag200_g200er_device_create(struct 
pci_dev *pdev, const stru
                return ERR_PTR(ret);
 
        drm_mode_config_reset(dev);
+       drm_kms_helper_poll_init(dev);
 
        return mdev;
 }
diff --git a/drivers/gpu/drm/mgag200/mgag200_g200ev.c 
b/drivers/gpu/drm/mgag200/mgag200_g200ev.c
index dfb641b83842a..eefef4ec4abdb 100644
--- a/drivers/gpu/drm/mgag200/mgag200_g200ev.c
+++ b/drivers/gpu/drm/mgag200/mgag200_g200ev.c
@@ -298,6 +298,9 @@ static int mgag200_g200ev_pipeline_init(struct mga_device 
*mdev)
        }
        drm_connector_helper_add(connector, 
&mgag200_g200ev_vga_connector_helper_funcs);
 
+       connector->polled = DRM_CONNECTOR_POLL_CONNECT |
+                           DRM_CONNECTOR_POLL_DISCONNECT;
+
        ret = drm_connector_attach_encoder(connector, encoder);
        if (ret) {
                drm_err(dev, "drm_connector_attach_encoder() failed: %d\n", 
ret);
@@ -359,6 +362,7 @@ struct mga_device *mgag200_g200ev_device_create(struct 
pci_dev *pdev, const stru
                return ERR_PTR(ret);
 
        drm_mode_config_reset(dev);
+       drm_kms_helper_poll_init(dev);
 
        return mdev;
 }
diff --git a/drivers/gpu/drm/mgag200/mgag200_g200ew3.c 
b/drivers/gpu/drm/mgag200/mgag200_g200ew3.c
index 525b7f75e6228..51f8cec5c70c0 100644
--- a/drivers/gpu/drm/mgag200/mgag200_g200ew3.c
+++ b/drivers/gpu/drm/mgag200/mgag200_g200ew3.c
@@ -167,6 +167,9 @@ static int mgag200_g200ew3_pipeline_init(struct mga_device 
*mdev)
        }
        drm_connector_helper_add(connector, 
&mgag200_g200ew3_vga_connector_helper_funcs);
 
+       connector->polled = DRM_CONNECTOR_POLL_CONNECT |
+                           DRM_CONNECTOR_POLL_DISCONNECT;
+
        ret = drm_connector_attach_encoder(connector, encoder);
        if (ret) {
                drm_err(dev, "drm_connector_attach_encoder() failed: %d\n", 
ret);
@@ -240,6 +243,7 @@ struct mga_device *mgag200_g200ew3_device_create(struct 
pci_dev *pdev,
                return ERR_PTR(ret);
 
        drm_mode_config_reset(dev);
+       drm_kms_helper_poll_init(dev);
 
        return mdev;
 }
diff --git a/drivers/gpu/drm/mgag200/mgag200_g200se.c 
b/drivers/gpu/drm/mgag200/mgag200_g200se.c
index ef7606b529ea1..49f433eddf3cc 100644
--- a/drivers/gpu/drm/mgag200/mgag200_g200se.c
+++ b/drivers/gpu/drm/mgag200/mgag200_g200se.c
@@ -429,6 +429,9 @@ static int mgag200_g200se_pipeline_init(struct mga_device 
*mdev)
        }
        drm_connector_helper_add(connector, 
&mgag200_g200se_vga_connector_helper_funcs);
 
+       connector->polled = DRM_CONNECTOR_POLL_CONNECT |
+                           DRM_CONNECTOR_POLL_DISCONNECT;
+
        ret = drm_connector_attach_encoder(connector, encoder);
        if (ret) {
                drm_err(dev, "drm_connector_attach_encoder() failed: %d\n", 
ret);
@@ -559,6 +562,7 @@ struct mga_device *mgag200_g200se_device_create(struct 
pci_dev *pdev, const stru
                return ERR_PTR(ret);
 
        drm_mode_config_reset(dev);
+       drm_kms_helper_poll_init(dev);
 
        return mdev;
 }
diff --git a/drivers/gpu/drm/mgag200/mgag200_g200wb.c 
b/drivers/gpu/drm/mgag200/mgag200_g200wb.c
index e4def62b1e575..689c8959daaa2 100644
--- a/drivers/gpu/drm/mgag200/mgag200_g200wb.c
+++ b/drivers/gpu/drm/mgag200/mgag200_g200wb.c
@@ -301,6 +301,9 @@ static int mgag200_g200wb_pipeline_init(struct mga_device 
*mdev)
        }
        drm_connector_helper_add(connector, 
&mgag200_g200wb_vga_connector_helper_funcs);
 
+       connector->polled = DRM_CONNECTOR_POLL_CONNECT |
+                           DRM_CONNECTOR_POLL_DISCONNECT;
+
        ret = drm_connector_attach_encoder(connector, encoder);
        if (ret) {
                drm_err(dev, "drm_connector_attach_encoder() failed: %d\n", 
ret);
@@ -364,6 +367,7 @@ struct mga_device *mgag200_g200wb_device_create(struct 
pci_dev *pdev, const stru
                return ERR_PTR(ret);
 
        drm_mode_config_reset(dev);
+       drm_kms_helper_poll_init(dev);
 
        return mdev;
 }
-- 
2.44.0

Reply via email to