From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2CA842CAE7 for ; Tue, 13 Oct 2026 09:33:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791884002; cv=none; b=YItsuAh3UtUaoXIks5i8avBUlq1bv58wmEbm1NkBZSxNo+ORY9Bi/FQ9uAPxIjcL61DswYMO6I42r+VL3cUwqna6I+rLzIWZjHSAvO88RB9T5N8l6PWiygcFC+N5Bb51ZofWyUg1Nc53R64XLRA+17IzW9H4B1VhaQ9PQsRpZ5E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791884002; c=relaxed/simple; bh=NPPTuJMFbR++IvlpmQYNkBndrUAcpQgMz91TsS9FU7A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=YsPayx26B3JivSfHICE4mRBPr7dnWd/PqWcpH9E+qtaMmniom9LVLae1WdVZXkHYjhC/PVwZ3tBN72u3mNLRdcVwDOgngg1Gpbe4//A1Gr/itgx6xQBCLUG0VCdVIDAn/lxnLqF3hyZKPRcOxXQpc9gloWhpuQg9zAY4g34SkSI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ITdj5X4L; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ITdj5X4L" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-48b0d19cf7eso3208189f8f.1 for ; Tue, 13 Oct 2026 02:33:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791883994; x=1792488794; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=BdKVfmAGa7RaZVKgQWROr2rYza34vttyTey4iUR61tg=; b=ITdj5X4LJqCUkQoF0IHHdHsIvCaWPw/AGuPz+e9WtALsg7E1bffbbNka0MzR9UBT8P FlMSrIbVDfZvqOFzV6uJ+Osf7fCkqPEF32Stokkb0hu7omCfr4xurzXOV7K3fOcAW+gJ dqlROtEjp2VMQL4DHestT7NXU4yYjBDYvN/LCw++Fqz6UYrhQaIeTrRYZjepCGAOBlsh Myk3Yph1a5ifDEjUuztXvBXqhgkp8QLdMNisFrGVM8+8SzVAfYDZXlizN/5ycaxNMvqK a8/aatVWxnZwRGQcIxRKroQczbyuKOHR7TRCI4XEkpMgl02qLTfBEynMlezizeFFipM5 2Thw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791883994; x=1792488794; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=BdKVfmAGa7RaZVKgQWROr2rYza34vttyTey4iUR61tg=; b=nU6bprbWQiFjIgyhJa4vJLX4DY1uluuOZwNqd43PGkRdMP4RfyvtY5eiuAXqqlclrR CGPofbBT8uNi78cneYsC0R5RVf/zWT7WhtmoF5gnlakEfChgTXM7Oy9aGb4enW+AgHe7 6DT6vnSUq3BnMnREeCrBTLKFiljgTSxptZHpP4tGesEOTEkC/C/iyozhxczHfoP3d2os S7o15dXiNPYnbNNbwYyO2SCiTBItSBtI5mz7DgrkIrzgH57C7uIXbGoIYWxKCT682afj au/yuv6xZgVmpYujlE4BvF44VH+NRLott/NBcKuWsJgvdnJl5zw2I524ZR06b11ajzKZ +48Q== X-Forwarded-Encrypted: i=1; AKwUvBy8zSraPpGiDifz/WHebvLNAvu2ll68gmkbDf/FI0lvTcxmiK1h5sp1ysUpVaUmoFrYH2TCzyAWoRbg@vger.kernel.org X-Gm-Message-State: AFq9FYIO8/AFeGzGRudtqF3k/C94LzcpZt7HS5k8qqxOmXHmzsUVX0A4 G2r3Mcxb8qtRiicnwKBcbb4xhz51bikOSul7kFdyVRA5kSuRh/Sb9exA X-Gm-Gg: AYBFou2aaoHEDHZBmmTSecI2wiUo6Hf8uuIBtHerndAZSe8L8EvTmXstjO106Ei7fm/ UKBLVwv5YASA2Nd+GvGZTZfCwJB3LCGSSAJNkSrZGOXZI1pv7ZpD8HE/3UuqEqVSCWBF+PzIXeO R7QLYcMi6308+on1MtHdM9YupYOTcrCAKVQm/mozRSh87hCC/oDBAeOl0V0iHMN127piNWTVGar 9XZkx+DPfJs6sPv3rhOjKSypj+QX5uOTOza6F1RApyfq8q9HwwakstkkonISn/7l5LdqylJrevl D9JN177NYii4o2G8yhya9+NKhKr+G0pFlcfMcef4KX5Ik9QnbkQ20VkjPRxJVri4pYq3Xj1K4VC RJteJUK8W5/S24NzAKLkrMrFKU81nWL/9J5cq11HKZ68R8VK8MLTMvlPoZQqoTsSW9NuHK0d1ba 9lprtv13yCnewGLUUPp6h5LUp5odhDB3KYqf7M5MBHcVra0U4p0sPL5/FJiSldk8sJHNjn9eNJx 3Rf/xUykbRP/85ZroFSdx2G X-Received: by 2002:a05:600d:864c:10b0:4a1:8bff:9284 with SMTP id 5b1f17b1804b1-4a18dcd532cmr183789385e9.15.1791883994018; Tue, 13 Oct 2026 02:33:14 -0700 (PDT) Received: from ingenieria31.oficinasStQ.local ([79.112.15.218]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48de0bc4ec6sm3986774f8f.48.2026.10.13.02.33.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 02:33:13 -0700 (PDT) From: =?UTF-8?q?M=C3=A0xim=20Pedraza=20Padilla?= To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Ard Biesheuvel , Jonathan Corbet Cc: Francesco Valla , Jani Nikula , Mario Limonciello , Javier Martinez Canillas , Jocelyn Falempe , Sam Ravnborg , Ilias Apalodimas , Shuah Khan , Randy Dunlap , dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-efi@vger.kernel.org, linux-doc@vger.kernel.org, linux-embedded@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 11/13] drm/client: splash: turn the BGRT image on panels mounted turned Date: Tue, 13 Oct 2026 11:32:41 +0200 Message-Id: <20261013093243.505776-12-maximpedraza@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20261013093243.505776-1-maximpedraza@gmail.com> References: <20261013093243.505776-1-maximpedraza@gmail.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- drivers/gpu/drm/clients/drm_splash.c | 67 +++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/clients/drm_splash.c b/drivers/gpu/drm/clients/drm_splash.c index 463aff27c747..4c30de7c5c16 100644 --- a/drivers/gpu/drm/clients/drm_splash.c +++ b/drivers/gpu/drm/clients/drm_splash.c @@ -398,11 +398,6 @@ static bool drm_splash_bgrt_available(struct drm_splash *splash) return false; } - if (efi_bgrt_status() & ACPI_BGRT_ORIENTATION_OFFSET) { - drm_info(client->dev, "splash: BGRT rotation bits set, skipping"); - return false; - } - return true; } @@ -431,6 +426,26 @@ static int drm_splash_bgrt_load(struct drm_splash *splash, const u8 **data, return 0; } +/* + * 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 ((efi_bgrt_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) { @@ -688,11 +703,21 @@ static int drm_splash_bmp_to_scanout(struct drm_splash *splash, } if (splash->src == DRM_SPLASH_SRC_BGRT) { - x_pad = efi_bgrt_image_offset_x(); - y_pad = efi_bgrt_image_offset_y(); - - 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 = efi_bgrt_image_offset_x(); + unsigned int yo = efi_bgrt_image_offset_y(); + + if (xo > lw || bmp_width > lw - xo || + yo > lh || bmp_height > lh - yo) { drm_err(client->dev, "splash: BGRT image would overflow"); return -EINVAL; } @@ -709,11 +734,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); @@ -797,6 +841,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