Skip to content

Commit c2bc958

Browse files
Thomas Zimmermannhdeller
authored andcommitted
fbdev: vesafb: Detect VGA compatibility from screen info's VESA attributes
Test the vesa_attributes field in struct screen_info for compatibility with VGA hardware. Vesafb currently tests bit 1 in screen_info's capabilities field which indicates a 64-bit lfb address and is unrelated to VGA compatibility. Section 4.4 of the Vesa VBE 2.0 specifications defines that bit 5 in the mode's attributes field signals VGA compatibility. The mode is compatible with VGA hardware if the bit is clear. In that case, the driver can access VGA state of the VBE's underlying hardware. The vesafb driver uses this feature to program the color LUT in palette modes. Without, colors might be incorrect. The problem got introduced in commit 89ec4c2 ("[PATCH] vesafb: Fix incorrect logo colors in x86_64"). It incorrectly stores the mode attributes in the screen_info's capabilities field and updates vesafb accordingly. Later, commit 5e8ddcb ("Video mode probing support for the new x86 setup code") fixed the screen_info, but did not update vesafb. Color output still tends to work, because bit 1 in capabilities is usually 0. Besides fixing the bug in vesafb, this commit introduces a helper that reads the correct bit from screen_info. Signed-off-by: Thomas Zimmermann <[email protected]> Fixes: 5e8ddcb ("Video mode probing support for the new x86 setup code") Reviewed-by: Javier Martinez Canillas <[email protected]> Cc: <[email protected]> # v2.6.23+ Signed-off-by: Helge Deller <[email protected]>
1 parent b03c351 commit c2bc958

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

drivers/video/fbdev/vesafb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ static int vesafb_probe(struct platform_device *dev)
271271
if (si->orig_video_isVGA != VIDEO_TYPE_VLFB)
272272
return -ENODEV;
273273

274-
vga_compat = (si->capabilities & 2) ? 0 : 1;
274+
vga_compat = !__screen_info_vbe_mode_nonvga(si);
275275
vesafb_fix.smem_start = si->lfb_base;
276276
vesafb_defined.bits_per_pixel = si->lfb_depth;
277277
if (15 == vesafb_defined.bits_per_pixel)

include/linux/screen_info.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ static inline u64 __screen_info_lfb_size(const struct screen_info *si, unsigned
4949
return lfb_size;
5050
}
5151

52+
static inline bool __screen_info_vbe_mode_nonvga(const struct screen_info *si)
53+
{
54+
/*
55+
* VESA modes typically run on VGA hardware. Set bit 5 signals that this
56+
* is not the case. Drivers can then not make use of VGA resources. See
57+
* Sec 4.4 of the VBE 2.0 spec.
58+
*/
59+
return si->vesa_attributes & BIT(5);
60+
}
61+
5262
static inline unsigned int __screen_info_video_type(unsigned int type)
5363
{
5464
switch (type) {

0 commit comments

Comments
 (0)