<p>Nico Huber has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/26849">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Use (Width|Height)_Type for modeline sizes<br><br>Saves us a lot of conversions and explicit contracts.<br><br>Change-Id: I32c06ca87b18c25e3c519fa608c4b9b36dbc0449<br>Signed-off-by: Nico Huber <nico.h@gmx.de><br>---<br>M common/hw-gfx-edid.adb<br>M common/hw-gfx-gma-config.ads.template<br>M common/hw-gfx-gma-pch-transcoder.adb<br>M common/hw-gfx-gma-pipe_setup.adb<br>M common/hw-gfx-gma-transcoder.adb<br>M common/hw-gfx-gma.adb<br>M common/hw-gfx-gma.ads<br>M common/hw-gfx.ads<br>M gfxtest/hw-gfx-gma-gfx_test.adb<br>9 files changed, 85 insertions(+), 96 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/49/26849/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/common/hw-gfx-edid.adb b/common/hw-gfx-edid.adb</span><br><span>index 83e9cf6..f1fae58 100644</span><br><span>--- a/common/hw-gfx-edid.adb</span><br><span>+++ b/common/hw-gfx-edid.adb</span><br><span>@@ -18,7 +18,6 @@</span><br><span> with GNAT.Source_Info;</span><br><span> </span><br><span> use type HW.Byte;</span><br><span style="color: hsl(0, 100%, 40%);">-use type HW.Pos16;</span><br><span> use type HW.Word16;</span><br><span> </span><br><span> package body HW.GFX.EDID is</span><br><span>@@ -138,14 +137,14 @@</span><br><span>    begin</span><br><span>       Mode := Mode_Type'</span><br><span>         (Dotclock             => Pos64 (Read_LE16 (Raw_EDID, Base)) * 10_000,</span><br><span style="color: hsl(0, 100%, 40%);">-         H_Visible            => Pos16 (Read_12 (Base +  2, Base +  4, 4)),</span><br><span style="color: hsl(0, 100%, 40%);">-         H_Sync_Begin         => Pos16 (Read_10 (Base +  8, Base + 11, 2)),</span><br><span style="color: hsl(0, 100%, 40%);">-         H_Sync_End           => Pos16 (Read_10 (Base +  9, Base + 11, 4)),</span><br><span style="color: hsl(0, 100%, 40%);">-         H_Total              => Pos16 (Read_12 (Base +  3, Base +  4, 8)),</span><br><span style="color: hsl(0, 100%, 40%);">-         V_Visible            => Pos16 (Read_12 (Base +  5, Base +  7, 4)),</span><br><span style="color: hsl(0, 100%, 40%);">-         V_Sync_Begin         => Pos16 (Read_6  (Base + 10, 4, Base + 11, 2)),</span><br><span style="color: hsl(0, 100%, 40%);">-         V_Sync_End           => Pos16 (Read_6  (Base + 10, 0, Base + 11, 4)),</span><br><span style="color: hsl(0, 100%, 40%);">-         V_Total              => Pos16 (Read_12 (Base +  6, Base +  7, 8)),</span><br><span style="color: hsl(120, 100%, 40%);">+         H_Visible            => Width_Type (Read_12 (Base +  2, Base +  4, 4)),</span><br><span style="color: hsl(120, 100%, 40%);">+         H_Sync_Begin         => Width_Type (Read_10 (Base +  8, Base + 11, 2)),</span><br><span style="color: hsl(120, 100%, 40%);">+         H_Sync_End           => Width_Type (Read_10 (Base +  9, Base + 11, 4)),</span><br><span style="color: hsl(120, 100%, 40%);">+         H_Total              => Width_Type (Read_12 (Base +  3, Base +  4, 8)),</span><br><span style="color: hsl(120, 100%, 40%);">+         V_Visible            => Height_Type (Read_12 (Base +  5, Base +  7, 4)),</span><br><span style="color: hsl(120, 100%, 40%);">+         V_Sync_Begin         => Height_Type (Read_6  (Base + 10, 4, Base + 11, 2)),</span><br><span style="color: hsl(120, 100%, 40%);">+         V_Sync_End           => Height_Type (Read_6  (Base + 10, 0, Base + 11, 4)),</span><br><span style="color: hsl(120, 100%, 40%);">+         V_Total              => Height_Type (Read_12 (Base +  6, Base +  7, 8)),</span><br><span>          H_Sync_Active_High   => (Raw_EDID (Base + 17) and 16#02#) /= 0,</span><br><span>          V_Sync_Active_High   => (Raw_EDID (Base + 17) and 16#04#) /= 0,</span><br><span>          BPC                  =></span><br><span>diff --git a/common/hw-gfx-gma-config.ads.template b/common/hw-gfx-gma-config.ads.template</span><br><span>index dba10aa..8a61d81 100644</span><br><span>--- a/common/hw-gfx-gma-config.ads.template</span><br><span>+++ b/common/hw-gfx-gma-config.ads.template</span><br><span>@@ -270,14 +270,14 @@</span><br><span>    -- Maximum source width with enabled scaler. This only accounts</span><br><span>    -- for simple 1:1 pipe:scaler mappings.</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   type Width_Per_Pipe is array (Pipe_Index) of Pos16;</span><br><span style="color: hsl(120, 100%, 40%);">+   type Width_Per_Pipe is array (Pipe_Index) of Width_Type;</span><br><span> </span><br><span>    Maximum_Scalable_Width : constant Width_Per_Pipe :=</span><br><span>      (case CPU is</span><br><span>          when G45 => -- TODO: Is this true?</span><br><span>            (Primary     => 4096,</span><br><span>             Secondary   => 2048,</span><br><span style="color: hsl(0, 100%, 40%);">-            Tertiary    => Pos16'First),</span><br><span style="color: hsl(120, 100%, 40%);">+            Tertiary    => Pos32'First),</span><br><span>          when Ironlake..Haswell =></span><br><span>            (Primary     => 4096,</span><br><span>             Secondary   => 2048,</span><br><span>diff --git a/common/hw-gfx-gma-pch-transcoder.adb b/common/hw-gfx-gma-pch-transcoder.adb</span><br><span>index 29fbaf6..eb1715f 100644</span><br><span>--- a/common/hw-gfx-gma-pch-transcoder.adb</span><br><span>+++ b/common/hw-gfx-gma-pch-transcoder.adb</span><br><span>@@ -153,7 +153,7 @@</span><br><span>    is</span><br><span>       Mode : constant Mode_Type := Port_Cfg.Mode;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-      function Encode (LSW, MSW : Pos16) return Word32 is</span><br><span style="color: hsl(120, 100%, 40%);">+      function Encode (LSW, MSW : Pos32) return Word32 is</span><br><span>       begin</span><br><span>          return (Word32 (LSW) - 1) or ((Word32 (MSW) - 1) * 2 ** 16);</span><br><span>       end Encode;</span><br><span>diff --git a/common/hw-gfx-gma-pipe_setup.adb b/common/hw-gfx-gma-pipe_setup.adb</span><br><span>index e0be5fb..1be2a1a 100644</span><br><span>--- a/common/hw-gfx-gma-pipe_setup.adb</span><br><span>+++ b/common/hw-gfx-gma-pipe_setup.adb</span><br><span>@@ -146,7 +146,7 @@</span><br><span> </span><br><span>    ---------------------------------------------------------------------------</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   function Encode (LSW, MSW : Pos16) return Word32 is</span><br><span style="color: hsl(120, 100%, 40%);">+   function Encode (LSW, MSW : Pos32) return Word32 is</span><br><span>    begin</span><br><span>       return Shift_Left (Word32 (MSW) - 1, 16) or (Word32 (LSW) - 1);</span><br><span>    end Encode;</span><br><span>@@ -220,8 +220,8 @@</span><br><span>       if Config.Has_Plane_Control then</span><br><span>          declare</span><br><span>             Stride, Offset : Word32;</span><br><span style="color: hsl(0, 100%, 40%);">-            Width : constant Pos16 := Rotated_Width (FB);</span><br><span style="color: hsl(0, 100%, 40%);">-            Height : constant Pos16 := Rotated_Height (FB);</span><br><span style="color: hsl(120, 100%, 40%);">+            Width : constant Width_Type := Rotated_Width (FB);</span><br><span style="color: hsl(120, 100%, 40%);">+            Height : constant Width_Type := Rotated_Height (FB);</span><br><span>          begin</span><br><span>             if Rotation_90 (FB) then</span><br><span>                Stride   := Word32 (FB_Pitch (FB.V_Stride, FB));</span><br><span>@@ -376,7 +376,7 @@</span><br><span>    begin</span><br><span>       -- off-screen cursor needs special care</span><br><span>       if X <= -Width or Y <= -Width or</span><br><span style="color: hsl(0, 100%, 40%);">-         X >= Int32 (Rotated_Width (FB)) or Y >= Int32 (Rotated_Height (FB)) or</span><br><span style="color: hsl(120, 100%, 40%);">+         X >= Rotated_Width (FB) or Y >= Rotated_Height (FB) or</span><br><span>          X > Config.Maximum_Cursor_X or Y > Config.Maximum_Cursor_Y</span><br><span>       then</span><br><span>          X := -Width;</span><br><span>@@ -394,29 +394,27 @@</span><br><span>    ----------------------------------------------------------------------------</span><br><span> </span><br><span>    procedure Scale_Keep_Aspect</span><br><span style="color: hsl(0, 100%, 40%);">-     (Width       :    out Pos32;</span><br><span style="color: hsl(0, 100%, 40%);">-      Height      :    out Pos32;</span><br><span style="color: hsl(0, 100%, 40%);">-      Max_Width   : in     Pos32;</span><br><span style="color: hsl(0, 100%, 40%);">-      Max_Height  : in     Pos32;</span><br><span style="color: hsl(120, 100%, 40%);">+     (Width       :    out Width_Type;</span><br><span style="color: hsl(120, 100%, 40%);">+      Height      :    out Height_Type;</span><br><span style="color: hsl(120, 100%, 40%);">+      Max_Width   : in     Width_Type;</span><br><span style="color: hsl(120, 100%, 40%);">+      Max_Height  : in     Height_Type;</span><br><span>       Framebuffer : in     Framebuffer_Type)</span><br><span>    with</span><br><span>       Pre =></span><br><span style="color: hsl(0, 100%, 40%);">-         Max_Width <= Pos32 (Pos16'Last) and</span><br><span style="color: hsl(0, 100%, 40%);">-         Max_Height <= Pos32 (Pos16'Last) and</span><br><span style="color: hsl(0, 100%, 40%);">-         Pos32 (Rotated_Width (Framebuffer)) <= Max_Width and</span><br><span style="color: hsl(0, 100%, 40%);">-         Pos32 (Rotated_Height (Framebuffer)) <= Max_Height,</span><br><span style="color: hsl(120, 100%, 40%);">+         Rotated_Width (Framebuffer) <= Max_Width and</span><br><span style="color: hsl(120, 100%, 40%);">+         Rotated_Height (Framebuffer) <= Max_Height,</span><br><span>       Post =></span><br><span>          Width <= Max_Width and Height <= Max_Height</span><br><span>    is</span><br><span style="color: hsl(0, 100%, 40%);">-      Src_Width : constant Pos32 := Pos32 (Rotated_Width (Framebuffer));</span><br><span style="color: hsl(0, 100%, 40%);">-      Src_Height : constant Pos32 := Pos32 (Rotated_Height (Framebuffer));</span><br><span style="color: hsl(120, 100%, 40%);">+      Src_Width : constant Width_Type := Rotated_Width (Framebuffer);</span><br><span style="color: hsl(120, 100%, 40%);">+      Src_Height : constant Height_Type := Rotated_Height (Framebuffer);</span><br><span>    begin</span><br><span>       case Scaling_Type (Src_Width, Src_Height, Max_Width, Max_Height) is</span><br><span>          when Letterbox =></span><br><span>             Width  := Max_Width;</span><br><span>             Height := (Max_Width * Src_Height) / Src_Width;</span><br><span>          when Pillarbox =></span><br><span style="color: hsl(0, 100%, 40%);">-            pragma Assert ((Max_Height * Src_Width) / Src_Height <= Max_Width);</span><br><span style="color: hsl(120, 100%, 40%);">+            --pragma Assert ((Max_Height * Src_Width) / Src_Height <= Max_Width);</span><br><span>             Width  := (Max_Height * Src_Width) / Src_Height;</span><br><span>             Height := Max_Height;</span><br><span>          when Uniform =></span><br><span>@@ -441,8 +439,8 @@</span><br><span>         (if Controller.PS_CTRL_2 /= Registers.Invalid_Register then</span><br><span>             PS_CTRL_SCALER_MODE_7X5_EXTENDED else 0);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-      Width_In    : constant Pos32 := Pos32 (Rotated_Width (Framebuffer));</span><br><span style="color: hsl(0, 100%, 40%);">-      Height_In   : constant Pos32 := Pos32 (Rotated_Height (Framebuffer));</span><br><span style="color: hsl(120, 100%, 40%);">+      Width_In    : constant Width_Type   := Rotated_Width (Framebuffer);</span><br><span style="color: hsl(120, 100%, 40%);">+      Height_In   : constant Height_Type  := Rotated_Height (Framebuffer);</span><br><span> </span><br><span>       -- We can scale up to 2.99x horizontally:</span><br><span>       Horizontal_Limit : constant Pos32 := (Width_In * 299) / 100;</span><br><span>@@ -457,15 +455,16 @@</span><br><span>             else</span><br><span>                299)) / 100;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-      Width, Height : Pos32;</span><br><span style="color: hsl(120, 100%, 40%);">+      Width : Width_Type;</span><br><span style="color: hsl(120, 100%, 40%);">+      Height : Height_Type;</span><br><span>    begin</span><br><span>       -- Writes to WIN_SZ arm the PS registers.</span><br><span> </span><br><span>       Scale_Keep_Aspect</span><br><span>         (Width       => Width,</span><br><span>          Height      => Height,</span><br><span style="color: hsl(0, 100%, 40%);">-         Max_Width   => Pos32'Min (Horizontal_Limit, Pos32 (Mode.H_Visible)),</span><br><span style="color: hsl(0, 100%, 40%);">-         Max_Height  => Pos32'Min (Vertical_Limit, Pos32 (Mode.V_Visible)),</span><br><span style="color: hsl(120, 100%, 40%);">+         Max_Width   => Pos32'Min (Horizontal_Limit, Mode.H_Visible),</span><br><span style="color: hsl(120, 100%, 40%);">+         Max_Height  => Pos32'Min (Vertical_Limit, Mode.V_Visible),</span><br><span>          Framebuffer => Framebuffer);</span><br><span> </span><br><span>       Registers.Write</span><br><span>@@ -474,8 +473,8 @@</span><br><span>       Registers.Write</span><br><span>         (Register => Controller.PS_WIN_POS_1,</span><br><span>          Value    =></span><br><span style="color: hsl(0, 100%, 40%);">-            Shift_Left (Word32 (Pos32 (Mode.H_Visible) - Width) / 2, 16) or</span><br><span style="color: hsl(0, 100%, 40%);">-            Word32 (Pos32 (Mode.V_Visible) - Height) / 2);</span><br><span style="color: hsl(120, 100%, 40%);">+            Shift_Left (Word32 (Mode.H_Visible - Width) / 2, 16) or</span><br><span style="color: hsl(120, 100%, 40%);">+            Word32 (Mode.V_Visible - Height) / 2);</span><br><span>       Registers.Write</span><br><span>         (Register => Controller.PS_WIN_SZ_1,</span><br><span>          Value    => Shift_Left (Word32 (Width), 16) or Word32 (Height));</span><br><span>@@ -499,7 +498,8 @@</span><br><span>                when Registers.PFC_CTL_1 => 2 * 2 ** 29,</span><br><span>                when others              => 0) else 0);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-      Width, Height : Pos32;</span><br><span style="color: hsl(120, 100%, 40%);">+      Width : Width_Type;</span><br><span style="color: hsl(120, 100%, 40%);">+      Height : Height_Type;</span><br><span>       X, Y : Int32;</span><br><span>    begin</span><br><span>       -- Writes to WIN_SZ arm the PF registers.</span><br><span>@@ -507,21 +507,21 @@</span><br><span>       Scale_Keep_Aspect</span><br><span>         (Width       => Width,</span><br><span>          Height      => Height,</span><br><span style="color: hsl(0, 100%, 40%);">-         Max_Width   => Pos32 (Mode.H_Visible),</span><br><span style="color: hsl(0, 100%, 40%);">-         Max_Height  => Pos32 (Mode.V_Visible),</span><br><span style="color: hsl(120, 100%, 40%);">+         Max_Width   => Mode.H_Visible,</span><br><span style="color: hsl(120, 100%, 40%);">+         Max_Height  => Mode.V_Visible,</span><br><span>          Framebuffer => Framebuffer);</span><br><span> </span><br><span>       -- Do not scale to odd width (at least Haswell has trouble with this).</span><br><span style="color: hsl(0, 100%, 40%);">-      if Width < Pos32 (Mode.H_Visible) and Width mod 2 = 1 then</span><br><span style="color: hsl(120, 100%, 40%);">+      if Width < Mode.H_Visible and Width mod 2 = 1 then</span><br><span>          Width := Width + 1;</span><br><span>       end if;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-      X := (Int32 (Mode.H_Visible) - Width) / 2;</span><br><span style="color: hsl(0, 100%, 40%);">-      Y := (Int32 (Mode.V_Visible) - Height) / 2;</span><br><span style="color: hsl(120, 100%, 40%);">+      X := (Mode.H_Visible - Width) / 2;</span><br><span style="color: hsl(120, 100%, 40%);">+      Y := (Mode.V_Visible - Height) / 2;</span><br><span> </span><br><span>       -- Hardware is picky about minimal horizontal gaps.</span><br><span style="color: hsl(0, 100%, 40%);">-      if Pos32 (Mode.H_Visible) - Width <= 3 then</span><br><span style="color: hsl(0, 100%, 40%);">-         Width := Pos32(Mode.H_Visible);</span><br><span style="color: hsl(120, 100%, 40%);">+      if Mode.H_Visible - Width <= 3 then</span><br><span style="color: hsl(120, 100%, 40%);">+         Width := Mode.H_Visible;</span><br><span>          X := 0;</span><br><span>       end if;</span><br><span> </span><br><span>diff --git a/common/hw-gfx-gma-transcoder.adb b/common/hw-gfx-gma-transcoder.adb</span><br><span>index daa5deb..1e4952d 100644</span><br><span>--- a/common/hw-gfx-gma-transcoder.adb</span><br><span>+++ b/common/hw-gfx-gma-transcoder.adb</span><br><span>@@ -138,12 +138,7 @@</span><br><span> </span><br><span>    ----------------------------------------------------------------------------</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   function Encode (LSW, MSW : Pos16) return Word32</span><br><span style="color: hsl(0, 100%, 40%);">-   is</span><br><span style="color: hsl(0, 100%, 40%);">-      pragma Warnings (GNAT, Off, """Integer_16"" is already use-visible *",</span><br><span style="color: hsl(0, 100%, 40%);">-                       Reason => "Needed for older compiler versions");</span><br><span style="color: hsl(0, 100%, 40%);">-      use type HW.Pos16;</span><br><span style="color: hsl(0, 100%, 40%);">-      pragma Warnings (GNAT, On, """Integer_16"" is already use-visible *");</span><br><span style="color: hsl(120, 100%, 40%);">+   function Encode (LSW, MSW : Pos32) return Word32 is</span><br><span>    begin</span><br><span>       return Shift_Left (Word32 (MSW - 1), 16) or Word32 (LSW - 1);</span><br><span>    end Encode;</span><br><span>diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb</span><br><span>index ab4e1e2..f135a5e 100644</span><br><span>--- a/common/hw-gfx-gma.adb</span><br><span>+++ b/common/hw-gfx-gma.adb</span><br><span>@@ -858,28 +858,28 @@</span><br><span>          Debug.Put_Int64 (Configs (Pipe).Mode.Dotclock);</span><br><span>          Debug.Put_Line (",");</span><br><span>          Debug.Put ("         H_Visible          => ");</span><br><span style="color: hsl(0, 100%, 40%);">-         Debug.Put_Int16 (Configs (Pipe).Mode.H_Visible);</span><br><span style="color: hsl(120, 100%, 40%);">+         Debug.Put_Int32 (Configs (Pipe).Mode.H_Visible);</span><br><span>          Debug.Put_Line (",");</span><br><span>          Debug.Put ("         H_Sync_Begin       => ");</span><br><span style="color: hsl(0, 100%, 40%);">-         Debug.Put_Int16 (Configs (Pipe).Mode.H_Sync_Begin);</span><br><span style="color: hsl(120, 100%, 40%);">+         Debug.Put_Int32 (Configs (Pipe).Mode.H_Sync_Begin);</span><br><span>          Debug.Put_Line (",");</span><br><span>          Debug.Put ("         H_Sync_End         => ");</span><br><span style="color: hsl(0, 100%, 40%);">-         Debug.Put_Int16 (Configs (Pipe).Mode.H_Sync_End);</span><br><span style="color: hsl(120, 100%, 40%);">+         Debug.Put_Int32 (Configs (Pipe).Mode.H_Sync_End);</span><br><span>          Debug.Put_Line (",");</span><br><span>          Debug.Put ("         H_Total            => ");</span><br><span style="color: hsl(0, 100%, 40%);">-         Debug.Put_Int16 (Configs (Pipe).Mode.H_Total);</span><br><span style="color: hsl(120, 100%, 40%);">+         Debug.Put_Int32 (Configs (Pipe).Mode.H_Total);</span><br><span>          Debug.Put_Line (",");</span><br><span>          Debug.Put ("         V_Visible          => ");</span><br><span style="color: hsl(0, 100%, 40%);">-         Debug.Put_Int16 (Configs (Pipe).Mode.V_Visible);</span><br><span style="color: hsl(120, 100%, 40%);">+         Debug.Put_Int32 (Configs (Pipe).Mode.V_Visible);</span><br><span>          Debug.Put_Line (",");</span><br><span>          Debug.Put ("         V_Sync_Begin       => ");</span><br><span style="color: hsl(0, 100%, 40%);">-         Debug.Put_Int16 (Configs (Pipe).Mode.V_Sync_Begin);</span><br><span style="color: hsl(120, 100%, 40%);">+         Debug.Put_Int32 (Configs (Pipe).Mode.V_Sync_Begin);</span><br><span>          Debug.Put_Line (",");</span><br><span>          Debug.Put ("         V_Sync_End         => ");</span><br><span style="color: hsl(0, 100%, 40%);">-         Debug.Put_Int16 (Configs (Pipe).Mode.V_Sync_End);</span><br><span style="color: hsl(120, 100%, 40%);">+         Debug.Put_Int32 (Configs (Pipe).Mode.V_Sync_End);</span><br><span>          Debug.Put_Line (",");</span><br><span>          Debug.Put ("         V_Total            => ");</span><br><span style="color: hsl(0, 100%, 40%);">-         Debug.Put_Int16 (Configs (Pipe).Mode.V_Total);</span><br><span style="color: hsl(120, 100%, 40%);">+         Debug.Put_Int32 (Configs (Pipe).Mode.V_Total);</span><br><span>          Debug.Put_Line (",");</span><br><span>          Debug.Put_Line ("         H_Sync_Active_High => " &</span><br><span>            (if Configs (Pipe).Mode.H_Sync_Active_High</span><br><span>diff --git a/common/hw-gfx-gma.ads b/common/hw-gfx-gma.ads</span><br><span>index 410f411..1f81ece 100644</span><br><span>--- a/common/hw-gfx-gma.ads</span><br><span>+++ b/common/hw-gfx-gma.ads</span><br><span>@@ -210,9 +210,9 @@</span><br><span> </span><br><span>    ----------------------------------------------------------------------------</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   Tile_Width : constant array (Tiling_Type) of Pos32 :=</span><br><span style="color: hsl(120, 100%, 40%);">+   Tile_Width : constant array (Tiling_Type) of Width_Type :=</span><br><span>      (Linear => 16, X_Tiled => 128, Y_Tiled => 32);</span><br><span style="color: hsl(0, 100%, 40%);">-   Tile_Rows : constant array (Tiling_Type) of Pos32 :=</span><br><span style="color: hsl(120, 100%, 40%);">+   Tile_Rows : constant array (Tiling_Type) of Height_Type :=</span><br><span>      (Linear => 1, X_Tiled => 8, Y_Tiled => 32);</span><br><span> </span><br><span>    function FB_Pitch (Px : Pos_Pixel_Type; FB : Framebuffer_Type) return Natural</span><br><span>diff --git a/common/hw-gfx.ads b/common/hw-gfx.ads</span><br><span>index beb111f..cff3e18 100644</span><br><span>--- a/common/hw-gfx.ads</span><br><span>+++ b/common/hw-gfx.ads</span><br><span>@@ -121,14 +121,14 @@</span><br><span>    type Mode_Type is</span><br><span>    record</span><br><span>       Dotclock             : Frequency_Type;</span><br><span style="color: hsl(0, 100%, 40%);">-      H_Visible            : Pos16;</span><br><span style="color: hsl(0, 100%, 40%);">-      H_Sync_Begin         : Pos16;</span><br><span style="color: hsl(0, 100%, 40%);">-      H_Sync_End           : Pos16;</span><br><span style="color: hsl(0, 100%, 40%);">-      H_Total              : Pos16;</span><br><span style="color: hsl(0, 100%, 40%);">-      V_Visible            : Pos16;</span><br><span style="color: hsl(0, 100%, 40%);">-      V_Sync_Begin         : Pos16;</span><br><span style="color: hsl(0, 100%, 40%);">-      V_Sync_End           : Pos16;</span><br><span style="color: hsl(0, 100%, 40%);">-      V_Total              : Pos16;</span><br><span style="color: hsl(120, 100%, 40%);">+      H_Visible            : Width_Type;</span><br><span style="color: hsl(120, 100%, 40%);">+      H_Sync_Begin         : Width_Type;</span><br><span style="color: hsl(120, 100%, 40%);">+      H_Sync_End           : Width_Type;</span><br><span style="color: hsl(120, 100%, 40%);">+      H_Total              : Width_Type;</span><br><span style="color: hsl(120, 100%, 40%);">+      V_Visible            : Height_Type;</span><br><span style="color: hsl(120, 100%, 40%);">+      V_Sync_Begin         : Height_Type;</span><br><span style="color: hsl(120, 100%, 40%);">+      V_Sync_End           : Height_Type;</span><br><span style="color: hsl(120, 100%, 40%);">+      V_Total              : Height_Type;</span><br><span>       H_Sync_Active_High   : Boolean;</span><br><span>       V_Sync_Active_High   : Boolean;</span><br><span>       BPC                  : BPC_Type;</span><br><span>@@ -182,15 +182,15 @@</span><br><span>    function Rotation_90 (FB : Framebuffer_Type) return Boolean is</span><br><span>      (FB.Rotation = Rotated_90 or FB.Rotation = Rotated_270);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   function Rotated_Width (FB : Framebuffer_Type) return Pos16 is</span><br><span style="color: hsl(0, 100%, 40%);">-     (if Rotation_90 (FB) then Pos16 (FB.Height) else Pos16 (FB.Width));</span><br><span style="color: hsl(0, 100%, 40%);">-   function Rotated_Height (FB : Framebuffer_Type) return Pos16 is</span><br><span style="color: hsl(0, 100%, 40%);">-     (if Rotation_90 (FB) then Pos16 (FB.Width) else Pos16 (FB.Height));</span><br><span style="color: hsl(120, 100%, 40%);">+   function Rotated_Width (FB : Framebuffer_Type) return Width_Type is</span><br><span style="color: hsl(120, 100%, 40%);">+     (if Rotation_90 (FB) then FB.Height else FB.Width);</span><br><span style="color: hsl(120, 100%, 40%);">+   function Rotated_Height (FB : Framebuffer_Type) return Height_Type is</span><br><span style="color: hsl(120, 100%, 40%);">+     (if Rotation_90 (FB) then FB.Width else FB.Height);</span><br><span> </span><br><span>    function Pixel_To_Bytes (Pixel : Pixel_Type; FB : Framebuffer_Type)</span><br><span>       return Int32 is (Pixel * Pos32 (FB.BPC) / (8 / 4));</span><br><span style="color: hsl(0, 100%, 40%);">-   function FB_Size (FB : Framebuffer_Type) return Pos32 is</span><br><span style="color: hsl(0, 100%, 40%);">-     (Pixel_To_Bytes (FB.Stride * FB.V_Stride, FB));</span><br><span style="color: hsl(120, 100%, 40%);">+   function FB_Size (FB : Framebuffer_Type)</span><br><span style="color: hsl(120, 100%, 40%);">+      return Pos32 is (Pixel_To_Bytes (FB.Stride * FB.V_Stride, FB));</span><br><span> </span><br><span>    function Requires_Scaling (FB : Framebuffer_Type; Mode : Mode_Type)</span><br><span>       return Boolean is</span><br><span>@@ -198,22 +198,17 @@</span><br><span>       Rotated_Height (FB) /= Mode.V_Visible);</span><br><span> </span><br><span>    type Scaling_Aspect is (Uniform, Letterbox, Pillarbox);</span><br><span style="color: hsl(0, 100%, 40%);">-   function Scaling_Type (Width, Height, Scaled_Width, Scaled_Height : Pos32)</span><br><span style="color: hsl(120, 100%, 40%);">+   function Scaling_Type</span><br><span style="color: hsl(120, 100%, 40%);">+     (Width          : Width_Type;</span><br><span style="color: hsl(120, 100%, 40%);">+      Height         : Height_Type;</span><br><span style="color: hsl(120, 100%, 40%);">+      Scaled_Width   : Width_Type;</span><br><span style="color: hsl(120, 100%, 40%);">+      Scaled_Height  : Height_Type)</span><br><span>       return Scaling_Aspect is</span><br><span>      (if    Scaled_Width * Height < Scaled_Height * Width   then Letterbox</span><br><span>       elsif Scaled_Width * Height > Scaled_Height * Width   then Pillarbox</span><br><span style="color: hsl(0, 100%, 40%);">-      else                                                       Uniform)</span><br><span style="color: hsl(0, 100%, 40%);">-   with</span><br><span style="color: hsl(0, 100%, 40%);">-      Pre =></span><br><span style="color: hsl(0, 100%, 40%);">-         Width <= Pos32 (Pos16'Last) and</span><br><span style="color: hsl(0, 100%, 40%);">-         Height <= Pos32 (Pos16'Last) and</span><br><span style="color: hsl(0, 100%, 40%);">-         Scaled_Width <= Pos32 (Pos16'Last) and</span><br><span style="color: hsl(0, 100%, 40%);">-         Scaled_Height <= Pos32 (Pos16'Last);</span><br><span style="color: hsl(120, 100%, 40%);">+      else                                                       Uniform);</span><br><span>    function Scaling_Type (FB : Framebuffer_Type; Mode : Mode_Type)</span><br><span>       return Scaling_Aspect is (Scaling_Type</span><br><span style="color: hsl(0, 100%, 40%);">-     (Width          => Pos32 (Rotated_Width (FB)),</span><br><span style="color: hsl(0, 100%, 40%);">-      Height         => Pos32 (Rotated_Height (FB)),</span><br><span style="color: hsl(0, 100%, 40%);">-      Scaled_Width   => Pos32 (Mode.H_Visible),</span><br><span style="color: hsl(0, 100%, 40%);">-      Scaled_Height  => Pos32 (Mode.V_Visible)));</span><br><span style="color: hsl(120, 100%, 40%);">+     (Rotated_Width (FB), Rotated_Height (FB), Mode.H_Visible, Mode.V_Visible));</span><br><span> </span><br><span> end HW.GFX;</span><br><span>diff --git a/gfxtest/hw-gfx-gma-gfx_test.adb b/gfxtest/hw-gfx-gma-gfx_test.adb</span><br><span>index d5071c6..6839dc3 100644</span><br><span>--- a/gfxtest/hw-gfx-gma-gfx_test.adb</span><br><span>+++ b/gfxtest/hw-gfx-gma-gfx_test.adb</span><br><span>@@ -267,19 +267,19 @@</span><br><span>       Rotation : in     Rotation_Type;</span><br><span>       Offset   : in out Word32)</span><br><span>    is</span><br><span style="color: hsl(0, 100%, 40%);">-      Width : constant Width_Type := Width_Type (Mode.H_Visible);</span><br><span style="color: hsl(0, 100%, 40%);">-      Height : constant Height_Type := Height_Type (Mode.V_Visible);</span><br><span style="color: hsl(120, 100%, 40%);">+      Width : constant Width_Type := Mode.H_Visible;</span><br><span style="color: hsl(120, 100%, 40%);">+      Height : constant Height_Type := Mode.V_Visible;</span><br><span>    begin</span><br><span>       Offset := (Offset + FB_Align - 1) and not (FB_Align - 1);</span><br><span>       if Rotation = Rotated_90 or Rotation = Rotated_270 then</span><br><span>          FB :=</span><br><span style="color: hsl(0, 100%, 40%);">-           (Width    => Width_Type (Height),</span><br><span style="color: hsl(0, 100%, 40%);">-            Height   => Height_Type (Width),</span><br><span style="color: hsl(120, 100%, 40%);">+           (Width    => Height,</span><br><span style="color: hsl(120, 100%, 40%);">+            Height   => Width,</span><br><span>             Start_X  => Start_X,</span><br><span>             Start_Y  => Start_Y,</span><br><span>             BPC      => 8,</span><br><span style="color: hsl(0, 100%, 40%);">-            Stride   => Div_Round_Up (Pos32 (Height + 2 * Start_X), 32) * 32,</span><br><span style="color: hsl(0, 100%, 40%);">-            V_Stride => Div_Round_Up (Pos32 (Width + 2 * Start_Y), 32) * 32,</span><br><span style="color: hsl(120, 100%, 40%);">+            Stride   => Div_Round_Up (Height + 2 * Start_X, 32) * 32,</span><br><span style="color: hsl(120, 100%, 40%);">+            V_Stride => Div_Round_Up (Width + 2 * Start_Y, 32) * 32,</span><br><span>             Tiling   => Y_Tiled,</span><br><span>             Rotation => Rotation,</span><br><span>             Offset   => Offset + Word32 (GTT_Rotation_Offset) * GTT_Page_Size);</span><br><span>@@ -401,8 +401,8 @@</span><br><span>             declare</span><br><span>                C : Cursor_Type renames Pipes (Pipe).Cursor;</span><br><span>                FB : Framebuffer_Type renames Pipes (Pipe).Framebuffer;</span><br><span style="color: hsl(0, 100%, 40%);">-               Width : constant Int32 := Int32 (Rotated_Width (FB));</span><br><span style="color: hsl(0, 100%, 40%);">-               Height : constant Int32 := Int32 (Rotated_Height (FB));</span><br><span style="color: hsl(120, 100%, 40%);">+               Width : constant Width_Type := Rotated_Width (FB);</span><br><span style="color: hsl(120, 100%, 40%);">+               Height : constant Height_Type := Rotated_Height (FB);</span><br><span>                CS : Cursor_Script_Entry renames Cursor_Script</span><br><span>                  (Natural (Cnt) mod (Cursor_Script'Last + 1));</span><br><span>             begin</span><br><span>@@ -480,8 +480,8 @@</span><br><span>                C : Cursor_Type renames Pipes (Pipe).Cursor;</span><br><span>                CI : Cursor_Info renames Cursor_Infos (Pipe);</span><br><span>                FB : Framebuffer_Type renames Pipes (Pipe).Framebuffer;</span><br><span style="color: hsl(0, 100%, 40%);">-               Width : constant Int32 := Int32 (Rotated_Width (FB));</span><br><span style="color: hsl(0, 100%, 40%);">-               Height : constant Int32 := Int32 (Rotated_Height (FB));</span><br><span style="color: hsl(120, 100%, 40%);">+               Width : constant Width_Type := Rotated_Width (FB);</span><br><span style="color: hsl(120, 100%, 40%);">+               Height : constant Height_Type := Rotated_Height (FB);</span><br><span> </span><br><span>                Update : Boolean := False;</span><br><span>             begin</span><br><span>@@ -649,8 +649,8 @@</span><br><span>                         New_FB.Height := Height_Type'Max</span><br><span>                           (320, Height - New_FB.Start_Y - Rand_Div (Height));</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-                        Cursor.Center_X := Int32 (Rotated_Width (New_FB)) / 2;</span><br><span style="color: hsl(0, 100%, 40%);">-                        Cursor.Center_Y := Int32 (Rotated_Height (New_FB)) / 2;</span><br><span style="color: hsl(120, 100%, 40%);">+                        Cursor.Center_X := Rotated_Width (New_FB) / 2;</span><br><span style="color: hsl(120, 100%, 40%);">+                        Cursor.Center_Y := Rotated_Height (New_FB) / 2;</span><br><span>                         GMA.Update_Cursor (Pipe, Cursor);</span><br><span>                      end;</span><br><span>                   end loop;</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/26849">change 26849</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/26849"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libgfxinit </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I32c06ca87b18c25e3c519fa608c4b9b36dbc0449 </div>
<div style="display:none"> Gerrit-Change-Number: 26849 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Nico Huber <nico.h@gmx.de> </div>