]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/mgag200: Set scale from DRM format
authorThomas Zimmermann <tzimmermann@suse.de>
Wed, 15 Apr 2026 15:23:36 +0000 (17:23 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Mon, 20 Apr 2026 07:15:57 +0000 (09:15 +0200)
Replace the deprecated cpp value from struct drm_format_info with the
format's 4CC code when setting the scale value in CRTCEXT3. While at it,
remove the scale variable and add a mask constant.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://patch.msgid.link/20260415152625.101710-3-tzimmermann@suse.de
drivers/gpu/drm/mgag200/mgag200_mode.c
drivers/gpu/drm/mgag200/mgag200_reg.h

index 316413d814ae11584b0fd7881f649c961dbf7df2..5b526aebaeb84866acd86890aa1ca25d0db104e6 100644 (file)
@@ -343,24 +343,31 @@ static void mgag200_set_offset(struct mga_device *mdev,
 
 void mgag200_set_format_regs(struct mga_device *mdev, const struct drm_format_info *format)
 {
-       unsigned int bpp, bppshift, scale;
        u8 xmulctrl = 0;
        u8 crtcext3;
 
-       bpp = format->cpp[0] * 8;
+       RREG_ECRT(3, crtcext3);
 
-       bppshift = mgag200_get_bpp_shift(format);
-       switch (bpp) {
-       case 24:
-               scale = ((1 << bppshift) * 3) - 1;
+       switch (format->format) {
+       case DRM_FORMAT_C8:
+               crtcext3 &= ~MGAREG_CRTCEXT3_SCALE_MASK;
+               crtcext3 |= 0x0;
                break;
-       default:
-               scale = (1 << bppshift) - 1;
+       case DRM_FORMAT_XRGB1555:
+       case DRM_FORMAT_RGB565:
+               crtcext3 &= ~MGAREG_CRTCEXT3_SCALE_MASK;
+               crtcext3 |= 0x01;
+               break;
+       case DRM_FORMAT_RGB888:
+               crtcext3 &= ~MGAREG_CRTCEXT3_SCALE_MASK;
+               crtcext3 |= 0x02;
+               break;
+       case DRM_FORMAT_XRGB8888:
+               crtcext3 &= ~MGAREG_CRTCEXT3_SCALE_MASK;
+               crtcext3 |= 0x03;
                break;
        }
 
-       RREG_ECRT(3, crtcext3);
-
        switch (format->format) {
        case DRM_FORMAT_C8:
                xmulctrl = MGA1064_MUL_CTL_8bits;
@@ -379,9 +386,6 @@ void mgag200_set_format_regs(struct mga_device *mdev, const struct drm_format_in
                break;
        }
 
-       crtcext3 &= ~GENMASK(2, 0);
-       crtcext3 |= scale;
-
        WREG_DAC(MGA1064_MUL_CTL, xmulctrl);
 
        WREG_GFX(0, 0x00);
index d4fef8f25871f241611b8cf38bdf54422cd3906e..088b6c16f7f6279fde2c4085626cbc018f33e46c 100644 (file)
 #define MGAREG_CRTCEXT1_HRSTEN         BIT(3)
 
 #define MGAREG_CRTCEXT3_MGAMODE                BIT(7)
+#define MGAREG_CRTCEXT3_SCALE_MASK     GENMASK(2, 0)
 
 /* Cursor X and Y position */
 #define MGA_CURPOSXL 0x3c0c