Skip to content

Commit f670b50

Browse files
author
Thomas Zimmermann
committed
sysfb: Fix screen_info type check for VGA
Use the helper screen_info_video_type() to get the framebuffer type from struct screen_info. Handle supported values in sorted switch statement. Reading orig_video_isVGA is unreliable. On most systems it is a VIDEO_TYPE_ constant. On some systems with VGA it is simply set to 1 to signal the presence of a VGA output. See vga_probe() for an example. Retrieving the screen_info type with the helper screen_info_video_type() detects these cases and returns the appropriate VIDEO_TYPE_ constant. For VGA, sysfb creates a device named "vga-framebuffer". The sysfb code has been taken from vga16fb, where it likely didn't work correctly either. With this bugfix applied, vga16fb loads for compatible vga-framebuffer devices. Fixes: 0db5b61 ("fbdev/vga16fb: Create EGA/VGA devices in sysfb code") Cc: Thomas Zimmermann <[email protected]> Cc: Javier Martinez Canillas <[email protected]> Cc: Alex Deucher <[email protected]> Cc: Tzung-Bi Shih <[email protected]> Cc: Helge Deller <[email protected]> Cc: "Uwe Kleine-König" <[email protected]> Cc: Zsolt Kajtar <[email protected]> Cc: <[email protected]> # v6.1+ Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Tzung-Bi Shih <[email protected]> Reviewed-by: Javier Martinez Canillas <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2f29b5c commit f670b50

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

drivers/firmware/sysfb.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ static __init int sysfb_init(void)
143143
{
144144
struct screen_info *si = &screen_info;
145145
struct device *parent;
146+
unsigned int type;
146147
struct simplefb_platform_data mode;
147148
const char *name;
148149
bool compatible;
@@ -170,17 +171,26 @@ static __init int sysfb_init(void)
170171
goto put_device;
171172
}
172173

174+
type = screen_info_video_type(si);
175+
173176
/* if the FB is incompatible, create a legacy framebuffer device */
174-
if (si->orig_video_isVGA == VIDEO_TYPE_EFI)
175-
name = "efi-framebuffer";
176-
else if (si->orig_video_isVGA == VIDEO_TYPE_VLFB)
177-
name = "vesa-framebuffer";
178-
else if (si->orig_video_isVGA == VIDEO_TYPE_VGAC)
179-
name = "vga-framebuffer";
180-
else if (si->orig_video_isVGA == VIDEO_TYPE_EGAC)
177+
switch (type) {
178+
case VIDEO_TYPE_EGAC:
181179
name = "ega-framebuffer";
182-
else
180+
break;
181+
case VIDEO_TYPE_VGAC:
182+
name = "vga-framebuffer";
183+
break;
184+
case VIDEO_TYPE_VLFB:
185+
name = "vesa-framebuffer";
186+
break;
187+
case VIDEO_TYPE_EFI:
188+
name = "efi-framebuffer";
189+
break;
190+
default:
183191
name = "platform-framebuffer";
192+
break;
193+
}
184194

185195
pd = platform_device_alloc(name, 0);
186196
if (!pd) {

0 commit comments

Comments
 (0)