[coreboot-gerrit] Change in libgfxinit[master]: gfx, gma: Add helper to decide scaling aspect

Nico Huber (Code Review) gerrit at coreboot.org
Sat Jun 2 18:11:51 CEST 2018


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 at 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 at 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;

-- 
To view, visit https://review.coreboot.org/26766
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: libgfxinit
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I86fb15b03c2f4b55cb00e85b57dc7a64583557d0
Gerrit-Change-Number: 26766
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h at gmx.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180602/2caf6378/attachment-0001.html>


More information about the coreboot-gerrit mailing list