From a9ad3b7b0e8ae0a63be1e990025ff76c239af338 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Thu, 31 Jan 2013 10:06:41 -0500 Subject: [PATCH] drm/radeon: check initial crtc enabled status at load Check to see which crtcs are enabled when we load init the crtcs. May fix: https://bugs.freedesktop.org/show_bug.cgi?id=59982 Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/atombios_crtc.c | 13 ++++---- drivers/gpu/drm/radeon/radeon_display.c | 47 +++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c index 9175615..81994b0 100644 --- a/drivers/gpu/drm/radeon/atombios_crtc.c +++ b/drivers/gpu/drm/radeon/atombios_crtc.c @@ -265,14 +265,15 @@ void atombios_crtc_dpms(struct drm_crtc *crtc, int mode) case DRM_MODE_DPMS_SUSPEND: case DRM_MODE_DPMS_OFF: drm_vblank_pre_modeset(dev, radeon_crtc->crtc_id); - if (radeon_crtc->enabled) + if (radeon_crtc->enabled) { atombios_blank_crtc(crtc, ATOM_ENABLE); - if (ASIC_IS_DCE3(rdev) && !ASIC_IS_DCE6(rdev)) - atombios_enable_crtc_memreq(crtc, ATOM_DISABLE); - atombios_enable_crtc(crtc, ATOM_DISABLE); + if (ASIC_IS_DCE3(rdev) && !ASIC_IS_DCE6(rdev)) + atombios_enable_crtc_memreq(crtc, ATOM_DISABLE); + atombios_enable_crtc(crtc, ATOM_DISABLE); + if (ASIC_IS_DCE6(rdev) && !radeon_crtc->in_mode_set) + atombios_powergate_crtc(crtc, ATOM_ENABLE); + } radeon_crtc->enabled = false; - if (ASIC_IS_DCE6(rdev) && !radeon_crtc->in_mode_set) - atombios_powergate_crtc(crtc, ATOM_ENABLE); /* adjust pm to dpms changes AFTER disabling crtcs */ radeon_pm_compute_clocks(rdev); break; diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c index 05c96fa..93f47c5 100644 --- a/drivers/gpu/drm/radeon/radeon_display.c +++ b/drivers/gpu/drm/radeon/radeon_display.c @@ -33,6 +33,22 @@ #include #include +static const u32 avivo_crtc_offsets[2] = +{ + 0, + AVIVO_D2CRTC_H_TOTAL - AVIVO_D1CRTC_H_TOTAL +}; + +static const u32 evergreen_crtc_offsets[6] = +{ + EVERGREEN_CRTC0_REGISTER_OFFSET, + EVERGREEN_CRTC1_REGISTER_OFFSET, + EVERGREEN_CRTC2_REGISTER_OFFSET, + EVERGREEN_CRTC3_REGISTER_OFFSET, + EVERGREEN_CRTC4_REGISTER_OFFSET, + EVERGREEN_CRTC5_REGISTER_OFFSET +}; + static void avivo_crtc_load_lut(struct drm_crtc *crtc) { struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); @@ -503,6 +519,35 @@ static const struct drm_crtc_funcs radeon_crtc_funcs = { .page_flip = radeon_crtc_page_flip, }; +/** + * radeon_crtc_enabled - check if a crtc is enabled + * + * @rdev: radeon_device pointer + * @crtc: crtc to check + * + * Check to see if a crtc is enabled (all asics). + * Returns true if enabled, false if not. + */ +static bool radeon_crtc_enabled(struct radeon_device *rdev, int crtc) +{ + if (ASIC_IS_DCE4(rdev)) { + if (RREG32(EVERGREEN_CRTC_CONTROL + evergreen_crtc_offsets[crtc]) & EVERGREEN_CRTC_MASTER_EN) + return true; + } else if (ASIC_IS_AVIVO(rdev)) { + if (RREG32(AVIVO_D1CRTC_CONTROL + avivo_crtc_offsets[crtc]) & AVIVO_CRTC_EN) + return true; + } else { + if (crtc) { + if (RREG32(RADEON_CRTC2_GEN_CNTL) & RADEON_CRTC2_EN) + return true; + } else { + if (RREG32(RADEON_CRTC_GEN_CNTL) & RADEON_CRTC_EN) + return true; + } + } + return false; +} + static void radeon_crtc_init(struct drm_device *dev, int index) { struct radeon_device *rdev = dev->dev_private; @@ -535,6 +580,8 @@ static void radeon_crtc_init(struct drm_device *dev, int index) radeon_atombios_init_crtc(dev, radeon_crtc); else radeon_legacy_init_crtc(dev, radeon_crtc); + + radeon_crtc->enabled = radeon_crtc_enabled(rdev, radeon_crtc->crtc_id); } static const char *encoder_names[37] = { -- 1.7.7.5