Commit c2d88e06 authored by Daniel Vetter's avatar Daniel Vetter

drm: Move the legacy kms disable_all helper to crtc helpers

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: default avatarAlex Deucher <alexander.deucher@amd.com>
Reviewed-by: default avatarSean Paul <sean@poorly.run>
Signed-off-by: default avatarDaniel 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
parent 324bb707
...@@ -2708,7 +2708,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev) ...@@ -2708,7 +2708,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
amdgpu_irq_disable_all(adev); amdgpu_irq_disable_all(adev);
if (adev->mode_info.mode_config_initialized){ if (adev->mode_info.mode_config_initialized){
if (!amdgpu_device_has_dc_support(adev)) if (!amdgpu_device_has_dc_support(adev))
drm_crtc_force_disable_all(adev->ddev); drm_helper_force_disable_all(adev->ddev);
else else
drm_atomic_helper_shutdown(adev->ddev); drm_atomic_helper_shutdown(adev->ddev);
} }
......
...@@ -261,7 +261,7 @@ static void ast_fbdev_destroy(struct drm_device *dev, ...@@ -261,7 +261,7 @@ static void ast_fbdev_destroy(struct drm_device *dev,
{ {
struct ast_framebuffer *afb = &afbdev->afb; 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); drm_fb_helper_unregister_fbi(&afbdev->helper);
if (afb->obj) { if (afb->obj) {
......
...@@ -104,37 +104,6 @@ int drm_crtc_force_disable(struct drm_crtc *crtc) ...@@ -104,37 +104,6 @@ int drm_crtc_force_disable(struct drm_crtc *crtc)
return drm_mode_set_config_internal(&set); 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) static unsigned int drm_num_crtcs(struct drm_device *dev)
{ {
unsigned int num = 0; unsigned int num = 0;
......
...@@ -994,3 +994,38 @@ void drm_helper_resume_force_mode(struct drm_device *dev) ...@@ -994,3 +994,38 @@ void drm_helper_resume_force_mode(struct drm_device *dev)
drm_modeset_unlock_all(dev); drm_modeset_unlock_all(dev);
} }
EXPORT_SYMBOL(drm_helper_resume_force_mode); 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);
...@@ -453,7 +453,7 @@ nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime) ...@@ -453,7 +453,7 @@ nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime)
if (drm_drv_uses_atomic_modeset(dev)) if (drm_drv_uses_atomic_modeset(dev))
drm_atomic_helper_shutdown(dev); drm_atomic_helper_shutdown(dev);
else else
drm_crtc_force_disable_all(dev); drm_helper_force_disable_all(dev);
} }
/* disable flip completion events */ /* disable flip completion events */
......
...@@ -1646,7 +1646,7 @@ void radeon_modeset_fini(struct radeon_device *rdev) ...@@ -1646,7 +1646,7 @@ void radeon_modeset_fini(struct radeon_device *rdev)
if (rdev->mode_info.mode_config_initialized) { if (rdev->mode_info.mode_config_initialized) {
drm_kms_helper_poll_fini(rdev->ddev); drm_kms_helper_poll_fini(rdev->ddev);
radeon_hpd_fini(rdev); radeon_hpd_fini(rdev);
drm_crtc_force_disable_all(rdev->ddev); drm_helper_force_disable_all(rdev->ddev);
radeon_fbdev_fini(rdev); radeon_fbdev_fini(rdev);
radeon_afmt_fini(rdev); radeon_afmt_fini(rdev);
drm_mode_config_cleanup(rdev->ddev); drm_mode_config_cleanup(rdev->ddev);
......
...@@ -1149,8 +1149,6 @@ static inline uint32_t drm_crtc_mask(const struct drm_crtc *crtc) ...@@ -1149,8 +1149,6 @@ static inline uint32_t drm_crtc_mask(const struct drm_crtc *crtc)
return 1 << drm_crtc_index(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); int drm_mode_set_config_internal(struct drm_mode_set *set);
struct drm_crtc *drm_crtc_from_index(struct drm_device *dev, int idx); struct drm_crtc *drm_crtc_from_index(struct drm_device *dev, int idx);
......
...@@ -56,6 +56,7 @@ bool drm_helper_encoder_in_use(struct drm_encoder *encoder); ...@@ -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); int drm_helper_connector_dpms(struct drm_connector *connector, int mode);
void drm_helper_resume_force_mode(struct drm_device *dev); void drm_helper_resume_force_mode(struct drm_device *dev);
int drm_helper_force_disable_all(struct drm_device *dev);
/* drm_probe_helper.c */ /* drm_probe_helper.c */
int drm_helper_probe_single_connector_modes(struct drm_connector int drm_helper_probe_single_connector_modes(struct drm_connector
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment