From: Johann Klammer <klammerj@a1.net>
To: FlorianSchandinat@gmx.de, linux-kernel@vger.kernel.org,
linux-fbdev@vger.kernel.org
Subject: [PATCH 04/08] viafb: fix broken depth selection
Date: Sat, 5 Dec 2026 23:22:18 +0100 [thread overview]
Message-ID: <ee9fe3dd-623f-44ac-be13-4eebf811bf5a@a1.net> (raw)
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;
reply other threads:[~2026-12-05 22:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ee9fe3dd-623f-44ac-be13-4eebf811bf5a@a1.net \
--to=klammerj@a1.net \
--cc=FlorianSchandinat@gmx.de \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®