drm/ast: Add constants for VGACRCB register bits
authorThomas Zimmermann <tzimmermann@suse.de>
Tue, 9 Feb 2021 13:46:23 +0000 (14:46 +0100)
committerThomas Zimmermann <tzimmermann@suse.de>
Wed, 17 Feb 2021 11:39:29 +0000 (12:39 +0100)
Set the bits in VGACRCB with constants. Alo move the rsp code into a
helper function.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210209134632.12157-2-tzimmermann@suse.de
drivers/gpu/drm/ast/ast_cursor.c
drivers/gpu/drm/ast/ast_drv.h

index fac1ee79c372e65af6be7d2d1cc7479f111a27a5..024858371f64c73e9979f1fa220d517ec1cb3dc4 100644 (file)
@@ -236,6 +236,19 @@ static void ast_cursor_set_location(struct ast_private *ast, u16 x, u16 y,
        ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xc7, y1);
 }
 
+static void ast_set_cursor_enabled(struct ast_private *ast, bool enabled)
+{
+       static const u8 mask = (u8)~(AST_IO_VGACRCB_HWC_16BPP |
+                                    AST_IO_VGACRCB_HWC_ENABLED);
+
+       u8 vgacrcb = AST_IO_VGACRCB_HWC_16BPP;
+
+       if (enabled)
+               vgacrcb |= AST_IO_VGACRCB_HWC_ENABLED;
+
+       ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xcb, mask, vgacrcb);
+}
+
 void ast_cursor_show(struct ast_private *ast, int x, int y,
                     unsigned int offset_x, unsigned int offset_y)
 {
@@ -245,7 +258,6 @@ void ast_cursor_show(struct ast_private *ast, int x, int y,
        u8 x_offset, y_offset;
        u8 __iomem *dst;
        u8 __iomem *sig;
-       u8 jreg;
        int ret;
 
        ret = drm_gem_vram_vmap(gbo, &map);
@@ -274,13 +286,10 @@ void ast_cursor_show(struct ast_private *ast, int x, int y,
 
        ast_cursor_set_location(ast, x, y, x_offset, y_offset);
 
-       /* dummy write to fire HWC */
-       jreg = 0x02 |
-              0x01; /* enable ARGB4444 cursor */
-       ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xcb, 0xfc, jreg);
+       ast_set_cursor_enabled(ast, true); /* dummy write to fire HWC */
 }
 
 void ast_cursor_hide(struct ast_private *ast)
 {
-       ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xcb, 0xfc, 0x00);
+       ast_set_cursor_enabled(ast, false);
 }
index f871fc36c2f7aaa320de71b2bc60b516ae2616f5..1575e8e636d7d52ec5a85c1d7988650ac3356baf 100644 (file)
@@ -179,6 +179,9 @@ struct ast_private *ast_device_create(const struct drm_driver *drv,
 
 #define AST_IO_VGAIR1_VREFRESH         BIT(3)
 
+#define AST_IO_VGACRCB_HWC_ENABLED     BIT(1)
+#define AST_IO_VGACRCB_HWC_16BPP       BIT(0) /* set: ARGB4444, cleared: 2bpp palette */
+
 #define __ast_read(x) \
 static inline u##x ast_read##x(struct ast_private *ast, u32 reg) { \
 u##x val = 0;\