From: Thomas Zimmermann <tzimmermann@suse.de>
To: daniel@ffwll.ch, airlied@gmail.com, javierm@redhat.com,
mripard@kernel.org, maarten.lankhorst@linux.intel.com,
jose.exposito89@gmail.com, mairacanal@riseup.net
Cc: Thomas Zimmermann <tzimmermann@suse.de>, dri-devel@lists.freedesktop.org
Subject: [PATCH 1/9] firmware/sysfb: Fix EFI/VESA format selection
Date: Tue, 13 Dec 2022 21:12:25 +0100 [thread overview]
Message-ID: <20221213201233.9341-2-tzimmermann@suse.de> (raw)
In-Reply-To: <20221213201233.9341-1-tzimmermann@suse.de>
Select color format for EFI/VESA firmware scanout buffer from the
number of bits per pixel and the position of the individual color
components. Fixes the selected format for the buffer in several odd
cases. For example, XRGB1555 has been reported as ARGB1555 because
of the different use of depth and transparency in VESA and Linux.
Bits-per-pixel is always the pixel's raw number of bits; including
alpha and filler bits. It is preferred over color depth, which has a
different meaning among various components and standards.
Also do not compare reserved bits and transparency bits to each other.
These values have different meanings, as reserved bits include filler
bits while transparency does not.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/firmware/sysfb_simplefb.c | 43 ++++++++++++++++++++++++++-----
1 file changed, 37 insertions(+), 6 deletions(-)
diff --git a/drivers/firmware/sysfb_simplefb.c b/drivers/firmware/sysfb_simplefb.c
index a353e27f83f5..ce9c007ed66f 100644
--- a/drivers/firmware/sysfb_simplefb.c
+++ b/drivers/firmware/sysfb_simplefb.c
@@ -27,25 +27,56 @@ static const struct simplefb_format formats[] = SIMPLEFB_FORMATS;
__init bool sysfb_parse_mode(const struct screen_info *si,
struct simplefb_platform_data *mode)
{
- const struct simplefb_format *f;
__u8 type;
+ u32 bits_per_pixel;
unsigned int i;
type = si->orig_video_isVGA;
if (type != VIDEO_TYPE_VLFB && type != VIDEO_TYPE_EFI)
return false;
+ /*
+ * The meaning of depth and bpp for direct-color formats is
+ * inconsistent:
+ *
+ * - DRM format info specifies depth as the number of color
+ * bits; including alpha, but not including filler bits.
+ * - Linux' EFI platform code computes lfb_depth from the
+ * individual color channels, including the reserved bits.
+ * - VBE 1.1 defines lfb_depth for XRGB1555 as 16, but later
+ * versions use 15.
+ * - On the kernel command line, 'bpp' of 32 is usually
+ * XRGB8888 including the filler bits, but 15 is XRGB1555
+ * not including the filler bit.
+ *
+ * It's not easily possible to fix this in struct screen_info,
+ * as this could break UAPI. The best solution is to compute
+ * bits_per_pixel here and ignore lfb_depth. In the loop below,
+ * ignore simplefb formats with alpha bits, as EFI and VESA
+ * don't specify alpha channels.
+ */
+ if (si->lfb_depth > 8) {
+ bits_per_pixel = max(max3(si->red_size + si->red_pos,
+ si->green_size + si->green_pos,
+ si->blue_size + si->blue_pos),
+ si->rsvd_size + si->rsvd_pos);
+ } else {
+ bits_per_pixel = si->lfb_depth;
+ }
+
for (i = 0; i < ARRAY_SIZE(formats); ++i) {
- f = &formats[i];
- if (si->lfb_depth == f->bits_per_pixel &&
+ const struct simplefb_format *f = &formats[i];
+
+ if (f->transp.length)
+ continue; /* transparent formats are unsupported by VESA/EFI */
+
+ if (bits_per_pixel == f->bits_per_pixel &&
si->red_size == f->red.length &&
si->red_pos == f->red.offset &&
si->green_size == f->green.length &&
si->green_pos == f->green.offset &&
si->blue_size == f->blue.length &&
- si->blue_pos == f->blue.offset &&
- si->rsvd_size == f->transp.length &&
- si->rsvd_pos == f->transp.offset) {
+ si->blue_pos == f->blue.offset) {
mode->format = f->name;
mode->width = si->lfb_width;
mode->height = si->lfb_height;
--
2.38.1
next prev parent reply other threads:[~2022-12-13 20:12 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-13 20:12 [PATCH 0/9] drm: Fix color-format selection in fbdev emulation Thomas Zimmermann
2022-12-13 20:12 ` Thomas Zimmermann [this message]
2022-12-20 10:09 ` [PATCH 1/9] firmware/sysfb: Fix EFI/VESA format selection Javier Martinez Canillas
2022-12-13 20:12 ` [PATCH 2/9] drm/format-helper: Flip src/dst-format branches in blit helper Thomas Zimmermann
2022-12-20 10:26 ` Javier Martinez Canillas
2022-12-13 20:12 ` [PATCH 3/9] drm/format-helper: Add conversion from XRGB8888 to ARGB8888 Thomas Zimmermann
2022-12-20 10:31 ` Javier Martinez Canillas
2022-12-13 20:12 ` [PATCH 4/9] drm/format-helper: Add conversion from XRGB8888 to ARGB2101010 Thomas Zimmermann
2022-12-20 10:35 ` Javier Martinez Canillas
2022-12-13 20:12 ` [PATCH 5/9] drm/format-helper: Add conversion from XRGB8888 to 15-bit RGB555 formats Thomas Zimmermann
2022-12-19 9:23 ` José Expósito
2022-12-19 10:58 ` Thomas Zimmermann
2022-12-20 9:37 ` Thomas Zimmermann
2022-12-20 10:38 ` Javier Martinez Canillas
2022-12-13 20:12 ` [PATCH 6/9] drm/fh-helper: Split fbdev single-probe helper Thomas Zimmermann
2022-12-20 10:52 ` Javier Martinez Canillas
2022-12-13 20:12 ` [PATCH 7/9] drm/fb-helper: Fix single-probe color-format selection Thomas Zimmermann
2022-12-20 10:56 ` Javier Martinez Canillas
2022-12-13 20:12 ` [PATCH 8/9] drm/format-helper: Simplify drm_fb_build_fourcc_list() Thomas Zimmermann
2022-12-20 11:03 ` Javier Martinez Canillas
2022-12-13 20:12 ` [PATCH 9/9] drm/format-helper: Remove unnecessary conversion helpers Thomas Zimmermann
2022-12-20 11:06 ` Javier Martinez Canillas
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=20221213201233.9341-2-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=jose.exposito89@gmail.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mairacanal@riseup.net \
--cc=mripard@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.