fbdev: atafb: Add support for further video bit depths on atafb:external
authorMiro Kropacek <miro.kropacek@gmail.com>
Wed, 19 Aug 2026 22:28:36 +0000 (10:28 +1200)
committerHelge Deller <deller@gmx.de>
Thu, 20 Aug 2026 22:02:41 +0000 (00:02 +0200)
Supervidel offers additional video bit depths: 8-bit chunky,
16-bit RGB565 (also on the original Videl) and ARGB888.

Add code to support these bit depths.

Signed-off-by: Miro Kropacek <miro.kropacek@gmail.com>
Reviewed-by: Michael Schmitz <schmitzmic@gmail.com>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
Link: https://lists.debian.org/debian-68k/2026/08/msg00000.html
Signed-off-by: Helge Deller <deller@gmx.de>
drivers/video/fbdev/atafb.c

index 0d415fd..3887521 100644 (file)
@@ -2079,8 +2079,12 @@ static int ext_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par)
                         external_pmode == FB_TYPE_PACKED_PIXELS) ?
                                FB_VISUAL_MONO10 : FB_VISUAL_MONO01;
        } else {
-               /* Use STATIC if we don't know how to access color registers */
-               int visual = external_vgaiobase ?
+               /* Use STATIC if we don't know how to access color registers;
+                * SuperVidel 8bpp chunky (fb in SV RAM) uses the Falcon palette
+                */
+               int visual = (external_vgaiobase ||
+                             (external_depth == 8 &&
+                              external_addr >= 0xa0000000)) ?
                                         FB_VISUAL_PSEUDOCOLOR :
                                         FB_VISUAL_STATIC_PSEUDOCOLOR;
                switch (external_pmode) {
@@ -2158,6 +2162,35 @@ static int ext_encode_var(struct fb_var_screeninfo *var, struct atafb_par *par)
        var->transp.offset = 0;
        var->transp.length = 0;
        var->transp.msb_right = 0;
+       if (external_pmode == -1 && external_depth == 16) {
+               /* RGB565 truecolor (e.g. SuperVidel native mode) */
+               var->red.offset = 11;
+               var->red.length = 5;
+               var->green.offset = 5;
+               var->green.length = 6;
+               var->blue.offset = 0;
+               var->blue.length = 5;
+       } else if (external_pmode == -1 && external_depth == 32) {
+               /* ARGB8888 truecolor (e.g. SuperVidel native mode) */
+               var->red.offset = 16;
+               var->red.length = 8;
+               var->green.offset = 8;
+               var->green.length = 8;
+               var->blue.offset = 0;
+               var->blue.length = 8;
+               var->transp.offset = 24;
+               var->transp.length = 8;
+       } else if (external_pmode == FB_TYPE_PACKED_PIXELS &&
+                  external_depth == 8 && external_addr >= 0xa0000000) {
+               /* SuperVidel 8bpp chunky: palette has 8 bits per channel.
+                * Without this, fb_get_color_depth() sees length 0 and
+                * fbcon falls back to its 2-color palette — the console
+                * text (color 7) stays black on black.
+                */
+               var->red.length = 8;
+               var->green.length = 8;
+               var->blue.length = 8;
+       }
        var->yres_virtual = var->yres;
        var->xoffset = 0;
        var->yoffset = 0;
@@ -2192,6 +2225,38 @@ static int ext_setcolreg(unsigned int regno, unsigned int red,
 {
        unsigned char colmask = (1 << external_bitspercol) - 1;
 
+       if (external_pmode == -1 && external_depth == 16) {
+               /* truecolor: only the pseudo palette for fbcon is needed */
+               if (regno > 15)
+                       return 1;
+               ((u32 *)info->pseudo_palette)[regno] = (red & 0xf800) |
+                                                      ((green & 0xfc00) >> 5) |
+                                                      ((blue & 0xf800) >> 11);
+               return 0;
+       }
+       if (external_pmode == -1 && external_depth == 32) {
+               /* ARGB8888, alpha forced opaque */
+               if (regno > 15)
+                       return 1;
+               ((u32 *)info->pseudo_palette)[regno] = 0xff000000 |
+                                                      ((red & 0xff00) << 8) |
+                                                      (green & 0xff00) |
+                                                      ((blue & 0xff00) >> 8);
+               return 0;
+       }
+       if (external_pmode == FB_TYPE_PACKED_PIXELS && external_depth == 8 &&
+           external_addr >= 0xa0000000) {
+               /* SuperVidel native 8bpp chunky scans out via the Falcon
+                * palette registers, honoring all 8 bits per channel
+                */
+               if (regno > 255)
+                       return 1;
+               f030_col[regno] = ((red & 0xff00) << 16) |
+                                 ((green & 0xff00) << 8) |
+                                 ((blue & 0xff00) >> 8);
+               return 0;
+       }
+
        if (!external_vgaiobase)
                return 1;
 
@@ -2421,7 +2486,9 @@ static void atafb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
                return;
 
 #ifdef ATAFB_FALCON
-       if (info->var.bits_per_pixel == 16) {
+       /* chunky modes (Falcon hicolor, external packed/truecolor) */
+       if (info->fix.type == FB_TYPE_PACKED_PIXELS &&
+           info->var.bits_per_pixel > 1) {
                cfb_fillrect(info, rect);
                return;
        }
@@ -2462,7 +2529,9 @@ static void atafb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
        int rev_copy = 0;
 
 #ifdef ATAFB_FALCON
-       if (info->var.bits_per_pixel == 16) {
+       /* chunky modes (Falcon hicolor, external packed/truecolor) */
+       if (info->fix.type == FB_TYPE_PACKED_PIXELS &&
+           info->var.bits_per_pixel > 1) {
                cfb_copyarea(info, area);
                return;
        }
@@ -2516,7 +2585,9 @@ static void atafb_imageblit(struct fb_info *info, const struct fb_image *image)
        u32 dx, dy, width, height, pitch;
 
 #ifdef ATAFB_FALCON
-       if (info->var.bits_per_pixel == 16) {
+       /* chunky modes (Falcon hicolor, external packed/truecolor) */
+       if (info->fix.type == FB_TYPE_PACKED_PIXELS &&
+           info->var.bits_per_pixel > 1) {
                cfb_imageblit(info, image);
                return;
        }
@@ -2752,7 +2823,7 @@ static void __init atafb_setup_ext(char *spec)
                return;
        depth = simple_strtoul(p, NULL, 10);
        if (depth != 1 && depth != 2 && depth != 4 && depth != 8 &&
-           depth != 16 && depth != 24)
+           depth != 16 && depth != 24 && depth != 32)
                return;
 
        p = strsep(&spec, ";");
@@ -3137,7 +3208,11 @@ static int __init atafb_probe(struct platform_device *pdev)
 
        atafb_set_disp(fb_info);
 
-       fb_alloc_cmap(&(fb_info->cmap), 1 << fb_info->var.bits_per_pixel, 0);
+       /* truecolor visuals only need the 16-entry console palette; this
+        * also avoids 1 << 32 overflowing at 32bpp
+        */
+       fb_alloc_cmap(&(fb_info->cmap), fb_info->var.bits_per_pixel > 8 ?
+                     16 : 1 << fb_info->var.bits_per_pixel, 0);
 
        dev_info(&pdev->dev, "Determined %dx%d, depth %d\n", fb_info->var.xres,
                 fb_info->var.yres, fb_info->var.bits_per_pixel);