Skip to content

Commit 203873a

Browse files
committed
fbdev: stifb: Provide valid pixelclock and add fb_check_var() checks
Find a valid modeline depending on the machine graphic card configuration and add the fb_check_var() function to validate Xorg provided graphics settings. Signed-off-by: Helge Deller <[email protected]> Cc: [email protected]
1 parent e140980 commit 203873a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

drivers/video/fbdev/stifb.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,28 @@ SETUP_HCRX(struct stifb_info *fb)
921921

922922
/* ------------------- driver specific functions --------------------------- */
923923

924+
static int
925+
stifb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
926+
{
927+
struct stifb_info *fb = container_of(info, struct stifb_info, info);
928+
929+
if (var->xres != fb->info.var.xres ||
930+
var->yres != fb->info.var.yres ||
931+
var->bits_per_pixel != fb->info.var.bits_per_pixel)
932+
return -EINVAL;
933+
934+
var->xres_virtual = var->xres;
935+
var->yres_virtual = var->yres;
936+
var->xoffset = 0;
937+
var->yoffset = 0;
938+
var->grayscale = fb->info.var.grayscale;
939+
var->red.length = fb->info.var.red.length;
940+
var->green.length = fb->info.var.green.length;
941+
var->blue.length = fb->info.var.blue.length;
942+
943+
return 0;
944+
}
945+
924946
static int
925947
stifb_setcolreg(u_int regno, u_int red, u_int green,
926948
u_int blue, u_int transp, struct fb_info *info)
@@ -1145,6 +1167,7 @@ stifb_init_display(struct stifb_info *fb)
11451167

11461168
static const struct fb_ops stifb_ops = {
11471169
.owner = THIS_MODULE,
1170+
.fb_check_var = stifb_check_var,
11481171
.fb_setcolreg = stifb_setcolreg,
11491172
.fb_blank = stifb_blank,
11501173
.fb_fillrect = stifb_fillrect,
@@ -1164,6 +1187,7 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref)
11641187
struct stifb_info *fb;
11651188
struct fb_info *info;
11661189
unsigned long sti_rom_address;
1190+
char modestr[32];
11671191
char *dev_name;
11681192
int bpp, xres, yres;
11691193

@@ -1342,6 +1366,9 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref)
13421366
info->flags = FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT;
13431367
info->pseudo_palette = &fb->pseudo_palette;
13441368

1369+
scnprintf(modestr, sizeof(modestr), "%dx%d-%d", xres, yres, bpp);
1370+
fb_find_mode(&info->var, info, modestr, NULL, 0, NULL, bpp);
1371+
13451372
/* This has to be done !!! */
13461373
if (fb_alloc_cmap(&info->cmap, NR_PALETTE, 0))
13471374
goto out_err1;

0 commit comments

Comments
 (0)