From b217ecebcccae1c5c1414b0bfbbb22302e6c7da5 Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Sat, 2 Jun 2018 16:56:35 +0200 Subject: [PATCH] gfx, gma: Add helper to decide scaling aspect Scaling_Type() returns the resulting scaling format, `Letterbox`, `Pillarbox`, or `Evenly` when keeping aspect ratio. Change-Id: I86fb15b03c2f4b55cb00e85b57dc7a64583557d0 Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/26766 Reviewed-by: Arthur Heymans --- common/hw-gfx-gma.ads | 3 +++ common/hw-gfx.ads | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/common/hw-gfx-gma.ads b/common/hw-gfx-gma.ads index e800f7cc03..410f4111b6 100644 --- a/common/hw-gfx-gma.ads +++ b/common/hw-gfx-gma.ads @@ -164,6 +164,9 @@ private function Requires_Scaling (Pipe_Cfg : Pipe_Config) return Boolean is (Requires_Scaling (Pipe_Cfg.Framebuffer, Pipe_Cfg.Mode)); + function Scaling_Type (Pipe_Cfg : Pipe_Config) return Scaling_Aspect is + (Scaling_Type (Pipe_Cfg.Framebuffer, Pipe_Cfg.Mode)); + ---------------------------------------------------------------------------- -- Internal representation of a single pipe's configuration diff --git a/common/hw-gfx.ads b/common/hw-gfx.ads index 71182da640..a6c883ee0f 100644 --- a/common/hw-gfx.ads +++ b/common/hw-gfx.ads @@ -197,4 +197,18 @@ private (Rotated_Width (FB) /= Mode.H_Visible or Rotated_Height (FB) /= Mode.V_Visible); + type Scaling_Aspect is (Uniform, Letterbox, Pillarbox); + function Scaling_Type (FB : Framebuffer_Type; Mode : Mode_Type) + return Scaling_Aspect is + (if Pos32 (Mode.H_Visible) * Pos32 (Rotated_Height (FB)) < + Pos32 (Mode.V_Visible) * Pos32 (Rotated_Width (FB)) + then + Letterbox + elsif Pos32 (Mode.H_Visible) * Pos32 (Rotated_Height (FB)) > + Pos32 (Mode.V_Visible) * Pos32 (Rotated_Width (FB)) + then + Pillarbox + else + Uniform); + end HW.GFX;