Nico Huber has uploaded this change for review. ( https://review.coreboot.org/26766
Change subject: gfx, gma: Add helper to decide scaling aspect ......................................................................
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 nico.h@gmx.de --- M common/Makefile.inc M common/hw-gfx-gma.ads A common/hw-gfx.adb M common/hw-gfx.ads 4 files changed, 42 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/66/26766/1
diff --git a/common/Makefile.inc b/common/Makefile.inc index 8d6634e..eff0be0 100644 --- a/common/Makefile.inc +++ b/common/Makefile.inc @@ -41,6 +41,7 @@ gfxinit-y += hw-gfx-gma.adb gfxinit-y += hw-gfx-gma.ads gfxinit-y += hw-gfx-i2c.ads +gfxinit-y += hw-gfx.adb gfxinit-y += hw-gfx.ads gfxinit-y += hw-gfx-framebuffer_filler.adb gfxinit-y += hw-gfx-framebuffer_filler.ads diff --git a/common/hw-gfx-gma.ads b/common/hw-gfx-gma.ads index 99ae279..8a83ae3 100644 --- a/common/hw-gfx-gma.ads +++ b/common/hw-gfx-gma.ads @@ -164,6 +164,9 @@ 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.adb b/common/hw-gfx.adb new file mode 100644 index 0000000..7124663 --- /dev/null +++ b/common/hw-gfx.adb @@ -0,0 +1,34 @@ +-- +-- Copyright (C) 2015-2016 secunet Security Networks AG +-- Copyright (C) 2017 Nico Huber nico.h@gmx.de +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- + +package body HW.GFX is + + function Scaling_Type + (FB : Framebuffer_Type; + Mode : Mode_Type) + return Scaling_Aspect + is + H_Factor : constant Pos32 := + Pos32 (Mode.H_Visible) * Pos32 (Rotated_Height (FB)); + V_Factor : constant Pos32 := + Pos32 (Mode.V_Visible) * Pos32 (Rotated_Width (FB)); + begin + return + (if H_Factor < V_Factor then Letterbox + elsif H_Factor > V_Factor then Pillarbox + else Evenly); + end Scaling_Type; + +end HW.GFX; diff --git a/common/hw-gfx.ads b/common/hw-gfx.ads index 71182da..66aafca 100644 --- a/common/hw-gfx.ads +++ b/common/hw-gfx.ads @@ -197,4 +197,8 @@ (Rotated_Width (FB) /= Mode.H_Visible or Rotated_Height (FB) /= Mode.V_Visible);
+ type Scaling_Aspect is (Evenly, Letterbox, Pillarbox); + function Scaling_Type (FB : Framebuffer_Type; Mode : Mode_Type) + return Scaling_Aspect; + end HW.GFX;