]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/ast: Store precatch settings in struct ast_device_quirks
authorThomas Zimmermann <tzimmermann@suse.de>
Tue, 7 Oct 2025 14:54:45 +0000 (16:54 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Wed, 15 Oct 2025 07:59:44 +0000 (09:59 +0200)
Add a precatch flag in struct ast_device_info and set it on AST2500
and AST2600. Remove calls to IS_AST_GENn() from ast_set_crtc_reg().

Also fix the coding style in several places.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://lore.kernel.org/r/20251007150343.273718-5-tzimmermann@suse.de
drivers/gpu/drm/ast/ast_2500.c
drivers/gpu/drm/ast/ast_2600.c
drivers/gpu/drm/ast/ast_drv.h
drivers/gpu/drm/ast/ast_mode.c

index 416bce9ea7573deb3a7c27c17b3fb0781bd5377e..2a52af0ded56ce9864fd733717dffd2ff6d08729 100644 (file)
@@ -621,6 +621,7 @@ static void ast_2500_detect_widescreen(struct ast_device *ast)
 static const struct ast_device_quirks ast_2500_device_quirks = {
        .crtc_mem_req_threshold_low = 96,
        .crtc_mem_req_threshold_high = 120,
+       .crtc_hsync_precatch_needed = true,
 };
 
 struct drm_device *ast_2500_device_create(struct pci_dev *pdev,
index bb0a50b2576653b620ada54b89292aa73a038237..7cde5ce9c41f839996dd6df06f5245f2d7278bac 100644 (file)
@@ -62,6 +62,7 @@ static void ast_2600_detect_widescreen(struct ast_device *ast)
 static const struct ast_device_quirks ast_2600_device_quirks = {
        .crtc_mem_req_threshold_low = 160,
        .crtc_mem_req_threshold_high = 224,
+       .crtc_hsync_precatch_needed = true,
 };
 
 struct drm_device *ast_2600_device_create(struct pci_dev *pdev,
index 926e1c7de6f8cd4cae40d9c42ccf3d015c1d7621..76969244d36fda33a00df1a1bf4df23dffd392ef 100644 (file)
@@ -170,6 +170,12 @@ struct ast_device_quirks {
         */
        unsigned char crtc_mem_req_threshold_low;
        unsigned char crtc_mem_req_threshold_high;
+
+       /*
+        * Adjust hsync values to load next scanline early. Signalled
+        * by AST2500PreCatchCRT in VBIOS mode flags.
+        */
+       bool crtc_hsync_precatch_needed;
 };
 
 struct ast_device {
index da374af9596d46b8a5d82a337fad82f17ccb0266..ebb1ec82d9045cccfc5347c993b50dd39a921af8 100644 (file)
@@ -241,16 +241,15 @@ static void ast_set_std_reg(struct ast_device *ast,
                ast_set_index_reg(ast, AST_IO_VGAGRI, i, stdtable->gr[i]);
 }
 
-static void ast_set_crtc_reg(struct ast_device *ast,
-                            struct drm_display_mode *mode,
+static void ast_set_crtc_reg(struct ast_device *ast, struct drm_display_mode *mode,
                             const struct ast_vbios_enhtable *vmode)
 {
        u8 jreg05 = 0, jreg07 = 0, jreg09 = 0, jregAC = 0, jregAD = 0, jregAE = 0;
-       u16 temp, precache = 0;
+       u16 temp;
+       unsigned char crtc_hsync_precatch = 0;
 
-       if ((IS_AST_GEN6(ast) || IS_AST_GEN7(ast)) &&
-           (vmode->flags & AST2500PreCatchCRT))
-               precache = 40;
+       if (ast->quirks->crtc_hsync_precatch_needed && (vmode->flags & AST2500PreCatchCRT))
+               crtc_hsync_precatch = 40;
 
        ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x11, 0x7f, 0x00);
 
@@ -276,12 +275,12 @@ static void ast_set_crtc_reg(struct ast_device *ast,
                jregAD |= 0x01;  /* HBE D[5] */
        ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x03, 0xE0, (temp & 0x1f));
 
-       temp = ((mode->crtc_hsync_start-precache) >> 3) - 1;
+       temp = ((mode->crtc_hsync_start - crtc_hsync_precatch) >> 3) - 1;
        if (temp & 0x100)
                jregAC |= 0x40; /* HRS D[5] */
        ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x04, 0x00, temp);
 
-       temp = (((mode->crtc_hsync_end-precache) >> 3) - 1) & 0x3f;
+       temp = (((mode->crtc_hsync_end - crtc_hsync_precatch) >> 3) - 1) & 0x3f;
        if (temp & 0x20)
                jregAD |= 0x04; /* HRE D[5] */
        ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x05, 0x60, (u8)((temp & 0x1f) | jreg05));
@@ -348,7 +347,7 @@ static void ast_set_crtc_reg(struct ast_device *ast,
        ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x09, 0xdf, jreg09);
        ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xAE, 0x00, (jregAE | 0x80));
 
-       if (precache)
+       if (crtc_hsync_precatch)
                ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0x3f, 0x80);
        else
                ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0x3f, 0x00);