drm: Move the legacy kms disable_all helper to crtc helpers
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 17 Dec 2018 19:43:00 +0000 (20:43 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 11 Jan 2019 21:54:29 +0000 (22:54 +0100)
It's not a core function, and the matching atomic functions are also
not in the core. Plus the suspend/resume helper is also already there.

Needs a tiny bit of open-coding, but less midlayer beats that I think.

v2: Rebase onto ast (which gained a new user).

Cc: Sam Bobroff <sbobroff@linux.ibm.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Sean Paul <sean@poorly.run>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Sean Paul <sean@poorly.run>
Cc: David Airlie <airlied@linux.ie>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: "David (ChunMing) Zhou" <David1.Zhou@amd.com>
Cc: Rex Zhu <Rex.Zhu@amd.com>
Cc: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Cc: Huang Rui <ray.huang@amd.com>
Cc: Shaoyun Liu <Shaoyun.Liu@amd.com>
Cc: Monk Liu <Monk.Liu@amd.com>
Cc: nouveau@lists.freedesktop.org
Cc: amd-gfx@lists.freedesktop.org
Link: https://patchwork.freedesktop.org/patch/msgid/20181217194303.14397-4-daniel.vetter@ffwll.ch
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/ast/ast_fb.c
drivers/gpu/drm/drm_crtc.c
drivers/gpu/drm/drm_crtc_helper.c
drivers/gpu/drm/nouveau/nouveau_display.c
drivers/gpu/drm/radeon/radeon_display.c
include/drm/drm_crtc.h
include/drm/drm_crtc_helper.h

index 8a078f4ae73dd17cc43384e605d28e4c613e7c37..28bccceaa363db9cd8fcef9da4dfadb11e9b0f97 100644 (file)
@@ -2708,7 +2708,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
        amdgpu_irq_disable_all(adev);
        if (adev->mode_info.mode_config_initialized){
                if (!amdgpu_device_has_dc_support(adev))
-                       drm_crtc_force_disable_all(adev->ddev);
+                       drm_helper_force_disable_all(adev->ddev);
                else
                        drm_atomic_helper_shutdown(adev->ddev);
        }
index c2e41369adcf4b8d43cdd4b0ec829318e9b13654..75f867d000315f9953904e9613a87223dc0494ac 100644 (file)
@@ -261,7 +261,7 @@ static void ast_fbdev_destroy(struct drm_device *dev,
 {
        struct ast_framebuffer *afb = &afbdev->afb;
 
-       drm_crtc_force_disable_all(dev);
+       drm_helper_force_disable_all(dev);
        drm_fb_helper_unregister_fbi(&afbdev->helper);
 
        if (afb->obj) {
index f660819d406efb586fe2547a6585a5a9d4c0b02a..7dabbaf033a16055671ccfdb9d164936a8b9a4da 100644 (file)
@@ -104,37 +104,6 @@ int drm_crtc_force_disable(struct drm_crtc *crtc)
        return drm_mode_set_config_internal(&set);
 }
 
-/**
- * drm_crtc_force_disable_all - Forcibly turn off all enabled CRTCs
- * @dev: DRM device whose CRTCs to turn off
- *
- * Drivers may want to call this on unload to ensure that all displays are
- * unlit and the GPU is in a consistent, low power state. Takes modeset locks.
- *
- * Note: This should only be used by non-atomic legacy drivers. For an atomic
- * version look at drm_atomic_helper_shutdown().
- *
- * Returns:
- * Zero on success, error code on failure.
- */
-int drm_crtc_force_disable_all(struct drm_device *dev)
-{
-       struct drm_crtc *crtc;
-       int ret = 0;
-
-       drm_modeset_lock_all(dev);
-       drm_for_each_crtc(crtc, dev)
-               if (crtc->enabled) {
-                       ret = drm_crtc_force_disable(crtc);
-                       if (ret)
-                               goto out;
-               }
-out:
-       drm_modeset_unlock_all(dev);
-       return ret;
-}
-EXPORT_SYMBOL(drm_crtc_force_disable_all);
-
 static unsigned int drm_num_crtcs(struct drm_device *dev)
 {
        unsigned int num = 0;
index 3b5cf93233c1e98ad5a19c3c08ac5e8412b89d63..91dc9b6386e78d440e5f767ae01c35d51c66617f 100644 (file)
@@ -994,3 +994,38 @@ void drm_helper_resume_force_mode(struct drm_device *dev)
        drm_modeset_unlock_all(dev);
 }
 EXPORT_SYMBOL(drm_helper_resume_force_mode);
+
+/**
+ * drm_helper_force_disable_all - Forcibly turn off all enabled CRTCs
+ * @dev: DRM device whose CRTCs to turn off
+ *
+ * Drivers may want to call this on unload to ensure that all displays are
+ * unlit and the GPU is in a consistent, low power state. Takes modeset locks.
+ *
+ * Note: This should only be used by non-atomic legacy drivers. For an atomic
+ * version look at drm_atomic_helper_shutdown().
+ *
+ * Returns:
+ * Zero on success, error code on failure.
+ */
+int drm_helper_force_disable_all(struct drm_device *dev)
+{
+       struct drm_crtc *crtc;
+       int ret = 0;
+
+       drm_modeset_lock_all(dev);
+       drm_for_each_crtc(crtc, dev)
+               if (crtc->enabled) {
+                       struct drm_mode_set set = {
+                               .crtc = crtc,
+                       };
+
+                       ret = drm_mode_set_config_internal(&set);
+                       if (ret)
+                               goto out;
+               }
+out:
+       drm_modeset_unlock_all(dev);
+       return ret;
+}
+EXPORT_SYMBOL(drm_helper_force_disable_all);
index f326ffd867664cd98dfc9dea789f91917c21856a..5d273a65547951afe2a47e96698030ab03b680b7 100644 (file)
@@ -453,7 +453,7 @@ nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime)
                if (drm_drv_uses_atomic_modeset(dev))
                        drm_atomic_helper_shutdown(dev);
                else
-                       drm_crtc_force_disable_all(dev);
+                       drm_helper_force_disable_all(dev);
        }
 
        /* disable flip completion events */
index 9d3ac8b981dab3d324e2864495c5fe739f4d675f..b190478ad087fff6027f29892b8ba036505da873 100644 (file)
@@ -1646,7 +1646,7 @@ void radeon_modeset_fini(struct radeon_device *rdev)
        if (rdev->mode_info.mode_config_initialized) {
                drm_kms_helper_poll_fini(rdev->ddev);
                radeon_hpd_fini(rdev);
-               drm_crtc_force_disable_all(rdev->ddev);
+               drm_helper_force_disable_all(rdev->ddev);
                radeon_fbdev_fini(rdev);
                radeon_afmt_fini(rdev);
                drm_mode_config_cleanup(rdev->ddev);
index b45bec0b7a9c557e139769b08828c02a2736e74f..85abd3fe9e832d4bad14a710e69504821e4bcd3d 100644 (file)
@@ -1149,8 +1149,6 @@ static inline uint32_t drm_crtc_mask(const struct drm_crtc *crtc)
        return 1 << drm_crtc_index(crtc);
 }
 
-int drm_crtc_force_disable_all(struct drm_device *dev);
-
 int drm_mode_set_config_internal(struct drm_mode_set *set);
 struct drm_crtc *drm_crtc_from_index(struct drm_device *dev, int idx);
 
index d65f034843cea620a3d99ff7b28261e8e33122a9..0ee9a96b70dab6a6b9b0c61991bc9d61842b7841 100644 (file)
@@ -56,6 +56,7 @@ bool drm_helper_encoder_in_use(struct drm_encoder *encoder);
 int drm_helper_connector_dpms(struct drm_connector *connector, int mode);
 
 void drm_helper_resume_force_mode(struct drm_device *dev);
+int drm_helper_force_disable_all(struct drm_device *dev);
 
 /* drm_probe_helper.c */
 int drm_helper_probe_single_connector_modes(struct drm_connector