* [PATCH 04/08] viafb: fix broken depth selection
@ 2026-12-05 22:22 Johann Klammer
0 siblings, 0 replies; only message in thread
From: Johann Klammer @ 2026-12-05 22:22 UTC (permalink / raw)
To: FlorianSchandinat, linux-kernel, linux-fbdev
Motivation: get X/fbdev working
BUG: x.org's fbdev won't switch modes successfully,
due to a broken depth selection logic using fb_get_color_depth().
This replaces it with a saner one.
Signed-off-by: Johann Klammer <klammerj@a1.net>
---
diff '--color=auto' -uprN -x '*.o' -x '*.ko' -x '*.mod*' -x '*.a' -x '*.cmd' -x modules.order -x Module.symvers -x .tmp_versions linux-7.3.0-gentoo.orig/drivers/video/fbdev/via/viafbdev.c linux-7.3.0-gentoo.work/drivers/video/fbdev/via/viafbdev.c
--- linux-7.3.0-gentoo.orig/drivers/video/fbdev/via/viafbdev.c 2026-12-05 21:06:25.716339069 +0100
+++ linux-7.3.0-gentoo.work/drivers/video/fbdev/via/viafbdev.c 2026-12-05 21:23:05.684366305 +0100
@@ -182,10 +182,17 @@ static inline int get_var_refresh(struct
return PICOS2KHZ(var->pixclock) * 1000 / (htotal * vtotal);
}
+static int viafb_pixbits(struct fb_var_screeninfo *var)
+{
+ return var->red.length +
+ var->green.length +
+ var->blue.length;
+}
+
static int viafb_check_var(struct fb_var_screeninfo *var,
struct fb_info *info)
{
- int depth, refresh;
+ int depth, refresh, pixfmt;
struct viafb_par *ppar = info->par;
u32 line;
@@ -205,25 +212,31 @@ static int viafb_check_var(struct fb_var
return -EINVAL;
}
- depth = fb_get_color_depth(var, &info->fix);
- if (!depth)
- depth = var->bits_per_pixel;
+ depth = var->bits_per_pixel;
if (depth < 0 || depth > 32)
return -EINVAL;
- else if (!depth)
- depth = 24;
- else if (depth == 15 && viafb_dual_fb && ppar->iga_path == IGA1)
- depth = 15;
- else if (depth == 30)
- depth = 30;
- else if (depth <= 8)
+ else if(depth < 15)
depth = 8;
- else if (depth <= 16)
- depth = 16;
- else
+ else if(depth < 24) {
+ pixfmt = viafb_pixbits(var);
+ if(depth <= 15) depth = 15;
+ else
+ if(pixfmt == 15)
+ depth = 15;
+ else
+ depth = 16;
+ if(depth == 15 && !(viafb_dual_fb && ppar->iga_path == IGA1))
+ depth = 16;
+ } else if(depth<30)
depth = 24;
-
+ else {
+ pixfmt = viafb_pixbits(var);
+ if(pixfmt >= 30)
+ depth = 30;
+ else
+ depth = 24;
+ }
viafb_fill_var_color_info(var, depth);
if (var->xres_virtual < var->xres)
var->xres_virtual = var->xres;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-05 22:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-05 22:22 [PATCH 04/08] viafb: fix broken depth selection Johann Klammer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®