fbdev: vesafb: Detect VGA compatibility from screen info's VESA attributes
Subsystems (2)
PATCH v2 1/1 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, It sets the framebuffer address size and is unrelated to VGA.
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 89ec4c238e7a ("[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 5e8ddcbe8692 ("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.
v2:
- clarify comment on non-VGA modes (Helge)
--- drivers/video/fbdev/vesafb.c | 2 +- include/linux/screen_info.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
drivers/video/fbdev/vesafb.c +1 -1
@@ -271,7 +271,7 @@ static int vesafb_probe(struct platform_device *dev)if (si->orig_video_isVGA !=VIDEO_TYPE_VLFB )return -ENODEV ; - vga_compat = (si->capabilities &2 ) ?0 :1 ; + vga_compat = !__screen_info_vbe_mode_nonvga (si); vesafb_fix.smem_start = si->lfb_base; vesafb_defined.bits_per_pixel = si->lfb_depth;if (15 == vesafb_defined.bits_per_pixel)
include/linux/screen_info.h +10 -0
@@ -49,6 +49,16 @@ static inline u64 __screen_info_lfb_size(const struct screen_info *si, unsignedreturn lfb_size; } +static inline bool __screen_info_vbe_mode_nonvga (const struct screen_info *si) +{ +/* +* VESA modes typically run on VGA hardware. Set bit 5 signal that this +* is not the case. Drivers can then not make use of VGA resources. See +* Sec 4.4 of the VBE 2.0 spec. +*/ +return si->vesa_attributes &BIT (5 ); +} +static inline unsigned int __screen_info_video_type (unsigned int type) {switch (type) {
Signature · 1 line
2.45.2
Am 17.06.24 um 13:06 schrieb Thomas Zimmermann:
Quoted 53 lines
Test the
vesa_attributesfield in structscreen_infofor compatibility with VGA hardware. Vesafb currently tests bit 1 in screen_info's capabilities field, It sets the framebuffer address size and is unrelated to VGA.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
89ec4c238e7a("[PATCH] vesafb: Fix incorrect logo colors inx86_64"). It incorrectly stores the mode attributes in the screen_info's capabilities field and updates vesafb accordingly. Later, commit5e8ddcbe8692("Video mode probing support for the new x86 setup code") fixed thescreen_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.v2:
- clarify comment on non-VGA modes (Helge)Signed-off-by Thomas Zimmermann <[email protected]>Fixes 5e8ddcbe8692 ("Video mode probing support for the new x86 setup code")Reviewed-by Javier Martinez Canillas <[email protected]>Cc <[email protected]> # v2.6.23+--- drivers/video/fbdev/vesafb.c | 2 +- include/linux/screen_info.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)drivers/video/fbdev/vesafb.c +1
-1@@ -271,7 +271,7 @@ static int vesafb_probe(struct platform_device *dev)if (si->orig_video_isVGA !=VIDEO_TYPE_VLFB )return -ENODEV ; - vga_compat = (si->capabilities &2 ) ?0 :1 ; + vga_compat = !__screen_info_vbe_mode_nonvga (si); vesafb_fix.smem_start = si->lfb_base; vesafb_defined.bits_per_pixel = si->lfb_depth;if (15 == vesafb_defined.bits_per_pixel)include/linux/screen_info.h +0
-0
include/linux/screen_info.h static inline u64 __screen_info_lfb_size(const struct screen_info *si, unsigned · line 55
Quoted 7 lines
include/linux/screen_info.h +4
-0@@ -49,6 +49,16 @@ static inline u64 __screen_info_lfb_size(const struct screen_info *si, unsignedreturn lfb_size; } +static inline bool __screen_info_vbe_mode_nonvga (const struct screen_info *si) +{ +/* +* VESA modes typically run on VGA hardware. Set bit 5 signal that this
'signals'
Quoted 9 lines
include/linux/screen_info.h +6
-0+* is not the case. Drivers can then not make use of VGA resources. See +* Sec 4.4 of the VBE 2.0 spec. +*/ +return si->vesa_attributes &BIT (5 ); +} +static inline unsigned int __screen_info_video_type (unsigned int type) {switch (type) {
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)
Helge Deller
maintainerQuoted 55 lines · Thomas Zimmermann
Am 17.06.24 um 13:06 schrieb Thomas Zimmermann:
Quoted 52 lines
Test the
vesa_attributesfield in structscreen_infofor compatibility with VGA hardware. Vesafb currently tests bit 1 in screen_info's capabilities field, It sets the framebuffer address size and is unrelated to VGA.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
89ec4c238e7a("[PATCH] vesafb: Fix incorrect logo colors inx86_64"). It incorrectly stores the mode attributes in the screen_info's capabilities field and updates vesafb accordingly. Later, commit5e8ddcbe8692("Video mode probing support for the new x86 setup code") fixed thescreen_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.v2:
- clarify comment on non-VGA modes (Helge)Signed-off-by Thomas Zimmermann <[email protected]>Fixes 5e8ddcbe8692 ("Video mode probing support for the new x86 setup code")Reviewed-by Javier Martinez Canillas <[email protected]>Cc <[email protected]> # v2.6.23+---
drivers/video/fbdev/vesafb.c| 2 +-
include/linux/screen_info.h | 10 ++++++++++2 files changed, 11 insertions(+), 1 deletion(-)drivers/video/fbdev/vesafb.c +1
-1@@ -271,7 +271,7 @@ static int vesafb_probe(struct platform_device *dev) if (si->orig_video_isVGA != VIDEO_TYPE_VLFB) return -ENODEV; - vga_compat = (si->capabilities & 2) ? 0 : 1; + vga_compat = !__screen_info_vbe_mode_nonvga(si); vesafb_fix.smem_start = si->lfb_base; vesafb_defined.bits_per_pixel = si->lfb_depth; if (15 == vesafb_defined.bits_per_pixel)include/linux/screen_info.h +0
-0@@ -49,6 +49,16 @@ static inline u64 __screen_info_lfb_size(const struct screen_info *si, unsigned
Quoted 8 lines
include/linux/screen_info.h static inline u64 __screen_info_lfb_size(const struct screen_info *si, unsigned · line 55
Quoted 6 lines
include/linux/screen_info.h +4
-0return lfb_size; } +static inline bool __screen_info_vbe_mode_nonvga (const struct screen_info *si) +{ + /* +* VESA modes typically run on VGA hardware. Set bit 5 signal that this 'signals'
I've fixed this up in your patch and applied it to the fbdev git tree. No need to send new patch...
Thanks!
Helge
Hi
Am 17.06.24 um 14:42 schrieb Helge Deller:
Quoted 69 lines · Thomas Zimmermann
Quoted 59 lines
Am 17.06.24 um 13:06 schrieb Thomas Zimmermann:
Quoted 56 lines
Test the
vesa_attributesfield in structscreen_infofor compatibility with VGA hardware. Vesafb currently tests bit 1 in screen_info's capabilities field, It sets the framebuffer address size and is unrelated to VGA.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
89ec4c238e7a("[PATCH] vesafb: Fix incorrect logo colors inx86_64"). It incorrectly stores the mode attributes in the screen_info's capabilities field and updates vesafb accordingly. Later, commit5e8ddcbe8692("Video mode probing support for the new x86 setup code") fixed thescreen_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.v2:
- clarify comment on non-VGA modes (Helge)Signed-off-by Thomas Zimmermann <[email protected]>Fixes 5e8ddcbe8692 ("Video mode probing support for the new x86 setup code")Reviewed-by Javier Martinez Canillas <[email protected]>Cc <[email protected]> # v2.6.23+---
drivers/video/fbdev/vesafb.c| 2 +-
include/linux/screen_info.h | 10 ++++++++++2 files changed, 11 insertions(+), 1 deletion(-)drivers/video/fbdev/vesafb.c +1
-1@@ -271,7 +271,7 @@ static int vesafb_probe(struct platform_device *dev) if (si->orig_video_isVGA != VIDEO_TYPE_VLFB) return -ENODEV; - vga_compat = (si->capabilities & 2) ? 0 : 1; + vga_compat = !__screen_info_vbe_mode_nonvga(si); vesafb_fix.smem_start = si->lfb_base; vesafb_defined.bits_per_pixel = si->lfb_depth; if (15 == vesafb_defined.bits_per_pixel)include/linux/screen_info.h +0
-0@@ -49,6 +49,16 @@ static inline u64 __screen_info_lfb_size(conststruct
screen_info*si, unsigned
returnlfb_size;
}Quoted 8 lines
Quoted 6 lines
+static inline bool
__screen_info_vbe_mode_nonvga(const struct screen_info *si)
+{
+ /*
+ * VESA modes typically run on VGA hardware. Set bit 5 signal that this'signals'
Quoted 2 lines
I've fixed this up in your patch and applied it to the fbdev git tree. No need to send new patch...
Great, thank you so much.
Best regards
Thomas
Quoted 4 lines
Thanks!
Helge
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)