Skip to content

Commit 39edb28

Browse files
committed
drm/ast: Disable planes while switching display modes
The ast HW cursor requires the primary plane and CRTC to display at a valid mode and format. This is not the case while switching display modes, which can lead to the screen turing permanently dark. As a workaround, the ast driver now disables active planes while the mode or format switch takes place. It also synchronizes with the vertical refresh to give CRTC and planes some time to catch up on each other. The active planes planes (primary or cursor) will be re-enabled by each plane's atomic_update() function. v3: * move the logic into the CRTC's atomic_disable function v2: * move the logic into the commit-tail function Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20200914072236.19398-3-tzimmermann@suse.de
1 parent 5638c82 commit 39edb28

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

‎drivers/gpu/drm/ast/ast_drv.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ struct ast_private *ast_device_create(struct drm_driver *drv,
177177

178178
#define AST_IO_MM_OFFSET (0x380)
179179

180+
#define AST_IO_VGAIR1_VREFRESH BIT(3)
181+
180182
#define __ast_read(x) \
181183
static inline u##x ast_read##x(struct ast_private *ast, u32 reg) { \
182184
u##x val = 0;\

‎drivers/gpu/drm/ast/ast_mode.c‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,16 @@ static void ast_set_start_address_crt1(struct ast_private *ast,
514514

515515
}
516516

517+
static void ast_wait_for_vretrace(struct ast_private *ast)
518+
{
519+
unsigned long timeout = jiffies + HZ;
520+
u8 vgair1;
521+
522+
do {
523+
vgair1 = ast_io_read8(ast, AST_IO_INPUT_STATUS1_READ);
524+
} while (!(vgair1 & AST_IO_VGAIR1_VREFRESH) && time_before(jiffies, timeout));
525+
}
526+
517527
/*
518528
* Primary plane
519529
*/
@@ -809,7 +819,28 @@ static void
809819
ast_crtc_helper_atomic_disable(struct drm_crtc *crtc,
810820
struct drm_crtc_state *old_crtc_state)
811821
{
822+
struct drm_device *dev = crtc->dev;
823+
struct ast_private *ast = to_ast_private(dev);
824+
812825
ast_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
826+
827+
/*
828+
* HW cursors require the underlying primary plane and CRTC to
829+
* display a valid mode and image. This is not the case during
830+
* full modeset operations. So we temporarily disable any active
831+
* plane, including the HW cursor. Each plane's atomic_update()
832+
* helper will re-enable it if necessary.
833+
*
834+
* We only do this during *full* modesets. It does not affect
835+
* simple pageflips on the planes.
836+
*/
837+
drm_atomic_helper_disable_planes_on_crtc(old_crtc_state, false);
838+
839+
/*
840+
* Ensure that no scanout takes place before reprogramming mode
841+
* and format registers.
842+
*/
843+
ast_wait_for_vretrace(ast);
813844
}
814845

815846
static const struct drm_crtc_helper_funcs ast_crtc_helper_funcs = {

0 commit comments

Comments
 (0)