[PATCH RFC v4 11/13] drm/client: splash: turn the BGRT image on panels mounted turned

From: Màxim Pedraza Padilla

Date: Thu Oct 01 2026 - 16:01:06 EST


Since ACPI 6.2, bits 1-2 of the BGRT status tell that the firmware
image is not pre-rotated and how far it has to be turned to show
upright on a panel mounted turned. The client skipped such images
altogether, so tablets and 2-in-1s with a portrait panel got no splash.

Turn the image as the bits say. The values count 90 degree steps
counter clockwise, as Plymouth, the main user of the BGRT, applies
them, and as DRM_MODE_ROTATE_* count, which is what they become.

The offsets need more care. For such an image the firmware gives them
on the upright screen, while the client draws into the buffer as it is
scanned out, which on a panel mounted turned is the upright screen
turned the other way. Check them and apply the efifb sanity check in
the upright frame, then move the image's rectangle into the buffer's
frame. An image without the bits is drawn at its offsets as before:
the buffer is the frame the firmware drew it in, so a pre-rotated image
needs none of the guessing userspace has to do for it.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Màxim Pedraza Padilla <maximpedraza@xxxxxxxxx>
---
drivers/gpu/drm/clients/drm_splash.c | 77 ++++++++++++++++++++++++----
1 file changed, 66 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/clients/drm_splash.c b/drivers/gpu/drm/clients/drm_splash.c
index 30ba6573424e..34f3c3910be1 100644
--- a/drivers/gpu/drm/clients/drm_splash.c
+++ b/drivers/gpu/drm/clients/drm_splash.c
@@ -388,14 +388,14 @@ static bool drm_splash_bgrt_available(struct drm_splash *splash)
return false;
}

- if (bgrt_tab.status & ACPI_BGRT_ORIENTATION_OFFSET) {
- drm_info(client->dev, "splash: BGRT rotation bits set, skipping");
- return false;
- }
-
return true;
}

+static inline u8 drm_splash_bgrt_get_status(void)
+{
+ return bgrt_tab.status;
+}
+
static inline unsigned int drm_splash_bgrt_get_xoffset(void)
{
return bgrt_tab.image_offset_x;
@@ -445,6 +445,11 @@ static inline unsigned int drm_splash_bgrt_get_yoffset(void)
return 0;
}

+static inline u8 drm_splash_bgrt_get_status(void)
+{
+ return 0;
+}
+
static inline int drm_splash_bgrt_load(struct drm_splash *splash,
const u8 **data, size_t *size)
{
@@ -452,6 +457,26 @@ static inline int drm_splash_bgrt_load(struct drm_splash *splash,
}
#endif // CONFIG_DRM_CLIENT_SPLASH_SRC_BGRT

+/*
+ * Since ACPI 6.2, bits 1-2 of the BGRT status say that the image is not
+ * pre-rotated for a panel mounted turned, and by how much it has to be
+ * turned to show upright on it: 0, 90, 180 or 270 degrees, which firmware
+ * and userspace (Plymouth) apply counter clockwise, as DRM counts them.
+ */
+static unsigned int drm_splash_bgrt_rotation(void)
+{
+ switch ((drm_splash_bgrt_get_status() & ACPI_BGRT_ORIENTATION_OFFSET) >> 1) {
+ case 1:
+ return DRM_MODE_ROTATE_90;
+ case 2:
+ return DRM_MODE_ROTATE_180;
+ case 3:
+ return DRM_MODE_ROTATE_270;
+ default:
+ return DRM_MODE_ROTATE_0;
+ }
+}
+
static u32 drm_splash_find_usable_format(struct drm_plane *plane,
u32 preferred_format)
{
@@ -709,11 +734,21 @@ static int drm_splash_bmp_to_scanout(struct drm_splash *splash,
}

if (splash->src == DRM_SPLASH_SRC_BGRT) {
- x_pad = drm_splash_bgrt_get_xoffset();
- y_pad = drm_splash_bgrt_get_yoffset();
-
- if ((x_pad + bmp_width) > scanout->width ||
- (y_pad + bmp_height) > scanout->height) {
+ /*
+ * The BGRT offsets place the upright image on the upright
+ * screen, which for a panel mounted turned is not the frame
+ * the buffer is scanned out in. Work in that frame, then move
+ * the image's rectangle into the buffer's.
+ */
+ bool quarter = splash->rotation &
+ (DRM_MODE_ROTATE_90 | DRM_MODE_ROTATE_270);
+ unsigned int lw = quarter ? scanout->height : scanout->width;
+ unsigned int lh = quarter ? scanout->width : scanout->height;
+ unsigned int xo = drm_splash_bgrt_get_xoffset();
+ unsigned int yo = drm_splash_bgrt_get_yoffset();
+
+ if (xo > lw || bmp_width > lw - xo ||
+ yo > lh || bmp_height > lh - yo) {
drm_err(client->dev, "splash: BGRT image would overflow");
return -EINVAL;
}
@@ -730,11 +765,30 @@ static int drm_splash_bmp_to_scanout(struct drm_splash *splash,
* the display looking quite bad.
*/

- if (x_pad != (scanout->width - bmp_width) / 2) {
+ if (xo != (lw - bmp_width) / 2) {
drm_err(client->dev, "splash: BGRT sanity check failed");
return -EINVAL;
}
#endif
+
+ switch (splash->rotation) {
+ case DRM_MODE_ROTATE_90:
+ x_pad = yo;
+ y_pad = lw - xo - bmp_width;
+ break;
+ case DRM_MODE_ROTATE_180:
+ x_pad = lw - xo - bmp_width;
+ y_pad = lh - yo - bmp_height;
+ break;
+ case DRM_MODE_ROTATE_270:
+ x_pad = lh - yo - bmp_height;
+ y_pad = xo;
+ break;
+ default:
+ x_pad = xo;
+ y_pad = yo;
+ break;
+ }
} else {
x_pad = drm_splash_place_axis(splash->pos_x, splash->off_x,
scanout->width, img_w);
@@ -818,6 +872,7 @@ static enum drm_splash_source drm_splash_pick_source(struct drm_splash *splash)
/* The BGRT carries no colour: firmware splashes sit on black */
if (drm_splash_bgrt_available(splash)) {
splash->bg_color = CONFIG_DRM_CLIENT_SPLASH_BACKGROUND_COLOR;
+ splash->rotation = drm_splash_bgrt_rotation();
return DRM_SPLASH_SRC_BGRT;
}

--
2.39.5