<p>Nico Huber has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/22866">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Add Start_X and Start_Y offsets for framebuffer panning<br><br>For tiled modes, the offsets add to the stride. To keep things simple,<br>we always assume that they are accounted for (even in linear mode).<br><br>To make the panning visible, the offsets are added in `gfx_test` and<br>the test image is drawn larger by two times the offsets. Also add the<br>new parameters to Dump_Configs() along with the forgotten tiling and<br>rotation parameters.<br><br>Change-Id: I5d1e1f2ed8b1872a2b82be23a6a622d948f7831f<br>Signed-off-by: Nico Huber <nico.h@gmx.de><br>---<br>M common/hw-gfx-gma-config_helpers.ads<br>M common/hw-gfx-gma-pipe_setup.adb<br>M common/hw-gfx-gma-pipe_setup.ads<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>7 files changed, 86 insertions(+), 33 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/66/22866/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/common/hw-gfx-gma-config_helpers.ads b/common/hw-gfx-gma-config_helpers.ads<br>index e684f22..1dc2390 100644<br>--- a/common/hw-gfx-gma-config_helpers.ads<br>+++ b/common/hw-gfx-gma-config_helpers.ads<br>@@ -50,6 +50,6 @@<br>             Rotated_Width (FB) <= Port_Cfg.Mode.H_Visible and<br>             Rotated_Height (FB) <= Port_Cfg.Mode.V_Visible and<br>             (FB.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or<br>-             FB.Height <= FB.V_Stride));<br>+             FB.Height + FB.Start_Y <= FB.V_Stride));<br> <br> end HW.GFX.GMA.Config_Helpers;<br>diff --git a/common/hw-gfx-gma-pipe_setup.adb b/common/hw-gfx-gma-pipe_setup.adb<br>index 4dc6e2b..e64edc9 100644<br>--- a/common/hw-gfx-gma-pipe_setup.adb<br>+++ b/common/hw-gfx-gma-pipe_setup.adb<br>@@ -157,7 +157,7 @@<br>               (Registers.Register_State,<br>                Controller,<br>                FB)),<br>-      Pre => FB.Height <= FB.V_Stride<br>+      Pre => FB.Height + FB.Start_Y <= FB.V_Stride<br>    is<br>       -- FIXME: setup correct format, based on framebuffer RGB format<br>       Format : constant Word32 := 6 * 2 ** 26;<br>@@ -172,11 +172,13 @@<br>             Height : constant Pos16 := Rotated_Height (FB);<br>          begin<br>             if Rotation_90 (FB) then<br>-               Stride            := Word32 (FB_Pitch (FB.V_Stride, FB));<br>-               Offset            := Word32 (FB.V_Stride - FB.Height);<br>+               Stride   := Word32 (FB_Pitch (FB.V_Stride, FB));<br>+               Offset   := Shift_Left (Word32 (FB.Start_X), 16) or<br>+                           Word32 (FB.V_Stride - FB.Height - FB.Start_Y);<br>             else<br>-               Stride            := Word32 (FB_Pitch (FB.Stride, FB));<br>-               Offset            := 0;<br>+               Stride   := Word32 (FB_Pitch (FB.Stride, FB));<br>+               Offset   := Shift_Left (Word32 (FB.Start_Y), 16) or<br>+                           Word32 (FB.Start_X);<br>             end if;<br>             Registers.Write<br>               (Register    => Controller.PLANE_CTL,<br>@@ -208,7 +210,10 @@<br>          if Config.Has_DSP_Linoff then<br>             Registers.Write (Controller.DSPLINOFF, 0);<br>          end if;<br>-         Registers.Write (Controller.DSPTILEOFF, 0);<br>+         Registers.Write<br>+           (Register => Controller.DSPTILEOFF,<br>+            Value    => Shift_Left (Word32 (FB.Start_Y), 16) or<br>+                        Word32 (FB.Start_X));<br>       end if;<br>    end Setup_Hires_Plane;<br> <br>@@ -232,7 +237,7 @@<br>                (Framebuffer)),<br>       Pre =><br>          Framebuffer.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or<br>-         Framebuffer.Height <= Framebuffer.V_Stride<br>+         Framebuffer.Height + Framebuffer.Start_Y <= Framebuffer.V_Stride<br>    is<br>       use type Word8;<br> <br>diff --git a/common/hw-gfx-gma-pipe_setup.ads b/common/hw-gfx-gma-pipe_setup.ads<br>index 35d9e87..3ef5dcf 100644<br>--- a/common/hw-gfx-gma-pipe_setup.ads<br>+++ b/common/hw-gfx-gma-pipe_setup.ads<br>@@ -28,7 +28,7 @@<br>          Rotated_Width (Framebuffer) <= Port_Cfg.Mode.H_Visible and<br>          Rotated_Height (Framebuffer) <= Port_Cfg.Mode.V_Visible and<br>          (Framebuffer.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or<br>-          Framebuffer.Height <= Framebuffer.V_Stride);<br>+          Framebuffer.Height + Framebuffer.Start_Y <= Framebuffer.V_Stride);<br> <br>    procedure Off (Pipe : Pipe_Index);<br> <br>diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb<br>index b325000..420c1a3 100644<br>--- a/common/hw-gfx-gma.adb<br>+++ b/common/hw-gfx-gma.adb<br>@@ -721,6 +721,21 @@<br>         (Primary     => "Primary  ",<br>          Secondary   => "Secondary",<br>          Tertiary    => "Tertiary ");<br>+<br>+      subtype Tiling_Name is String (1 .. 7);<br>+      type Tiling_Name_Array is array (Tiling_Type) of Tiling_Name;<br>+      Tilings : constant Tiling_Name_Array :=<br>+        (Linear   => "Linear ",<br>+         X_Tiled  => "X_Tiled",<br>+         Y_Tiled  => "Y_Tiled");<br>+<br>+      subtype Rotation_Name is String (1 .. 11);<br>+      type Rotation_Name_Array is array (Rotation_Type) of Rotation_Name;<br>+      Rotations : constant Rotation_Name_Array :=<br>+        (No_Rotation => "No_Rotation",<br>+         Rotated_90  => "Rotated_90 ",<br>+         Rotated_180 => "Rotated_180",<br>+         Rotated_270 => "Rotated_270");<br>    begin<br>       Debug.New_Line;<br>       Debug.Put_Line ("CONFIG =>");<br>@@ -734,15 +749,28 @@<br>          Debug.Put_Line<br>            ("     (Port => " & Port_Names (Configs (Pipe).Port) & ",");<br>          Debug.Put_Line ("      Framebuffer =>");<br>-         Debug.Put ("        (Width  => ");<br>+         Debug.Put ("        (Width     => ");<br>          Debug.Put_Int32 (Configs (Pipe).Framebuffer.Width);<br>          Debug.Put_Line (",");<br>-         Debug.Put ("         Height => ");<br>+         Debug.Put ("         Height    => ");<br>          Debug.Put_Int32 (Configs (Pipe).Framebuffer.Height);<br>          Debug.Put_Line (",");<br>-         Debug.Put ("         Stride => ");<br>+         Debug.Put ("         Start_X   => ");<br>+         Debug.Put_Int32 (Configs (Pipe).Framebuffer.Start_X);<br>+         Debug.Put_Line (",");<br>+         Debug.Put ("         Start_Y   => ");<br>+         Debug.Put_Int32 (Configs (Pipe).Framebuffer.Start_Y);<br>+         Debug.Put_Line (",");<br>+         Debug.Put ("         Stride    => ");<br>          Debug.Put_Int32 (Configs (Pipe).Framebuffer.Stride);<br>          Debug.Put_Line (",");<br>+         Debug.Put ("         V_Stride  => ");<br>+         Debug.Put_Int32 (Configs (Pipe).Framebuffer.V_Stride);<br>+         Debug.Put_Line (",");<br>+         Debug.Put ("         Tiling    => ");<br>+         Debug.Put_Line (Tilings (Configs (Pipe).Framebuffer.Tiling) & ",");<br>+         Debug.Put ("         Rotation  => ");<br>+         Debug.Put_Line (Rotations (Configs (Pipe).Framebuffer.Rotation) & ",");<br>          Debug.Put ("         Offset => ");<br>          Debug.Put_Word32 (Configs (Pipe).Framebuffer.Offset);<br>          Debug.Put_Line (",");<br>diff --git a/common/hw-gfx-gma.ads b/common/hw-gfx-gma.ads<br>index c59b392..77536d4 100644<br>--- a/common/hw-gfx-gma.ads<br>+++ b/common/hw-gfx-gma.ads<br>@@ -180,9 +180,9 @@<br>         (Pixel_To_Bytes (Px, FB), Tile_Width (FB.Tiling) * 4)));<br> <br>    function Valid_Stride (FB : Framebuffer_Type) return Boolean is<br>-     (FB.Width <= FB.Stride and<br>+     (FB.Width + FB.Start_X <= FB.Stride and<br>       Pixel_To_Bytes (FB.Stride, FB) mod (Tile_Width (FB.Tiling) * 4) = 0 and<br>-      FB.Height <= FB.V_Stride and<br>+      FB.Height + FB.Start_Y <= FB.V_Stride and<br>       FB.V_Stride mod Tile_Rows (FB.Tiling) = 0);<br> <br> end HW.GFX.GMA;<br>diff --git a/common/hw-gfx.ads b/common/hw-gfx.ads<br>index 5d8ae59..30e6e56 100644<br>--- a/common/hw-gfx.ads<br>+++ b/common/hw-gfx.ads<br>@@ -26,6 +26,7 @@<br>    -- Allow same range for width and height (for rotated framebuffers)<br>    subtype Width_Type  is Pos32 range 1 .. 8192;<br>    subtype Height_Type is Pos32 range 1 .. 8192;<br>+   subtype Pos_Type    is Int32 range 0 .. 4095;<br> <br>    Auto_BPC : constant := 5;<br>    subtype BPC_Type    is Int64 range Auto_BPC .. 16;<br>@@ -39,6 +40,8 @@<br>    record<br>       Width    : Width_Type;<br>       Height   : Height_Type;<br>+      Start_X  : Pos_Type;<br>+      Start_Y  : Pos_Type;<br>       BPC      : BPC_Type;<br>       Stride   : Width_Type;<br>       V_Stride : Height_Type;<br>@@ -63,6 +66,8 @@<br>    Default_FB : constant Framebuffer_Type := Framebuffer_Type'<br>      (Width    => 1,<br>       Height   => 1,<br>+      Start_X  => 0,<br>+      Start_Y  => 0,<br>       BPC      => 8,<br>       Stride   => 1,<br>       V_Stride => 1,<br>diff --git a/gfxtest/hw-gfx-gma-gfx_test.adb b/gfxtest/hw-gfx-gma-gfx_test.adb<br>index cb09c63..833240f 100644<br>--- a/gfxtest/hw-gfx-gma-gfx_test.adb<br>+++ b/gfxtest/hw-gfx-gma-gfx_test.adb<br>@@ -14,6 +14,9 @@<br> is<br>    pragma Disable_Atomic_Synchronization;<br> <br>+   Start_X : constant := 0;<br>+   Start_Y : constant := 0;<br>+<br>    package Dev is new PCI.Dev (PCI.Address'(0, 2, 0));<br> <br>    type GTT_PTE_Type is mod 2 ** (Config.GTT_PTE_Size * 8);<br>@@ -105,6 +108,12 @@<br>       end loop;<br>    end Restore_Screen;<br> <br>+   function Drawing_Width (FB : Framebuffer_Type) return Natural is<br>+     (Natural (FB.Width + 2 * Start_X));<br>+<br>+   function Drawing_Height (FB : Framebuffer_Type) return Natural is<br>+     (Natural (FB.Height + 2 * Start_Y));<br>+<br>    function Corner_Fill<br>      (X, Y  : Natural;<br>       FB    : Framebuffer_Type;<br>@@ -112,9 +121,9 @@<br>       return Pixel_Type<br>    is<br>       Xrel : constant Integer :=<br>-        (if X < 32 then X else X - (Natural (FB.Width) - 32));<br>+        (if X < 32 then X else X - (Drawing_Width (FB) - 32));<br>       Yrel : constant Integer :=<br>-        (if Y < 32 then Y else Y - (Natural (FB.Height) - 32));<br>+        (if Y < 32 then Y else Y - (Drawing_Height (FB) - 32));<br> <br>       function Color (Idx : Natural) return Pixel_Type is<br>         (case (Idx + Pipe_Index'Pos (Pipe)) mod 4 is<br>@@ -138,8 +147,8 @@<br>    is<br>       use type HW.Byte;<br> <br>-      Xp : constant Natural := X * 256 / Natural (Framebuffer.Width);<br>-      Yp : constant Natural := Y * 256 / Natural (Framebuffer.Height);<br>+      Xp : constant Natural := X * 256 / Drawing_Width (Framebuffer);<br>+      Yp : constant Natural := Y * 256 / Drawing_Height (Framebuffer);<br>       Xn : constant Natural := 255 - Xp;<br>       Yn : constant Natural := 255 - Yp;<br> <br>@@ -166,22 +175,22 @@<br> <br>       function Top_Test (X, Y : Natural) return Boolean<br>       is<br>-         C     : constant Natural := Natural (Framebuffer.Width) / 2;<br>-         S_Y   : constant Natural := 3 * Y / 2;<br>+         C     : constant Natural := Drawing_Width (Framebuffer) / 2;<br>+         S_Y   : constant Natural := 3 * (Y - Start_Y) / 2;<br>          Left  : constant Integer := X - C + S_Y;<br>          Right : constant Integer := X - C - S_Y;<br>       begin<br>          return<br>-            Y < 12 and<br>+            (Y - Start_Y) < 12 and<br>             ((-1 <= Left and Left <= 0) or<br>              (0 <= Right and Right <= 1));<br>       end Top_Test;<br>    begin<br>-      for Y in 0 .. Natural (Framebuffer.Height) - 1 loop<br>+      for Y in 0 .. Drawing_Height (Framebuffer) - 1 loop<br>          Offset := Offset_Y;<br>-         for X in 0 .. Natural (Framebuffer.Width) - 1 loop<br>-            if (X < 32 or X >= Natural (Framebuffer.Width) - 32) and<br>-               (Y < 32 or Y >= Natural (Framebuffer.Height) - 32)<br>+         for X in 0 .. Drawing_Width (Framebuffer) - 1 loop<br>+            if (X < 32 or X >= Drawing_Width (Framebuffer) - 32) and<br>+               (Y < 32 or Y >= Drawing_Height (Framebuffer) - 32)<br>             then<br>                P := Corner_Fill (X, Y, Framebuffer, Pipe);<br>             elsif Framebuffer.Rotation /= No_Rotation and then<br>@@ -206,25 +215,31 @@<br>       Rotation : in     Rotation_Type;<br>       Offset   : in out Word32)<br>    is<br>+      Width : constant Width_Type := Width_Type (Mode.H_Visible);<br>+      Height : constant Height_Type := Height_Type (Mode.V_Visible);<br>    begin<br>       Offset := (Offset + FB_Align - 1) and not (FB_Align - 1);<br>       if Rotation = Rotated_90 or Rotation = Rotated_270 then<br>          FB :=<br>-           (Width    => Width_Type (Mode.V_Visible),<br>-            Height   => Height_Type (Mode.H_Visible),<br>+           (Width    => Width_Type (Height),<br>+            Height   => Height_Type (Width),<br>+            Start_X  => Start_X,<br>+            Start_Y  => Start_Y,<br>             BPC      => 8,<br>-            Stride   => Div_Round_Up (Pos32 (Mode.V_Visible), 32) * 32,<br>-            V_Stride => Div_Round_Up (Pos32 (Mode.H_Visible), 32) * 32,<br>+            Stride   => Div_Round_Up (Pos32 (Height + 2 * Start_X), 32) * 32,<br>+            V_Stride => Div_Round_Up (Pos32 (Width + 2 * Start_Y), 32) * 32,<br>             Tiling   => Y_Tiled,<br>             Rotation => Rotation,<br>             Offset   => Offset + Word32 (GTT_Rotation_Offset) * GTT_Page_Size);<br>       else<br>          FB :=<br>-           (Width    => Width_Type (Mode.H_Visible),<br>-            Height   => Width_Type (Mode.V_Visible),<br>+           (Width    => Width,<br>+            Height   => Height,<br>+            Start_X  => Start_X,<br>+            Start_Y  => Start_Y,<br>             BPC      => 8,<br>-            Stride   => Div_Round_Up (Pos32 (Mode.H_Visible), 16) * 16,<br>-            V_Stride => Height_Type (Mode.V_Visible),<br>+            Stride   => Div_Round_Up (Width + 2 * Start_X, 16) * 16,<br>+            V_Stride => Height + 2 * Start_Y,<br>             Tiling   => Linear,<br>             Rotation => Rotation,<br>             Offset   => Offset);<br></pre><p>To view, visit <a href="https://review.coreboot.org/22866">change 22866</a>. To unsubscribe, 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/22866"/><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: I5d1e1f2ed8b1872a2b82be23a6a622d948f7831f </div>
<div style="display:none"> Gerrit-Change-Number: 22866 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Nico Huber <nico.h@gmx.de> </div>