<p>Nico Huber has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/22905">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">[UNTESTED] gma: Allow arbitary framebuffer updates<br><br>Change-Id: I780bd0a2733222008f5243483656655f1eb2b58e<br>---<br>M common/hw-gfx-gma-config_helpers.adb<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 gfxtest/hw-gfx-gma-gfx_test.adb<br>6 files changed, 81 insertions(+), 36 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/05/22905/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/common/hw-gfx-gma-config_helpers.adb b/common/hw-gfx-gma-config_helpers.adb<br>index f2b4ef6..5e5be5d 100644<br>--- a/common/hw-gfx-gma-config_helpers.adb<br>+++ b/common/hw-gfx-gma-config_helpers.adb<br>@@ -181,9 +181,9 @@<br>    -- Validates that a given configuration should work with<br>    -- a given framebuffer.<br>    function Validate_Config<br>-     (FB       : Framebuffer_Type;<br>-      Port_Cfg : Port_Config;<br>-      Pipe     : Pipe_Index)<br>+     (FB    : Framebuffer_Type;<br>+      Mode  : Mode_Type;<br>+      Pipe  : Pipe_Index)<br>       return Boolean<br>    is<br>    begin<br>@@ -197,11 +197,11 @@<br>       -- Plane_Control)<br>       -- 90 degree rotations are only supported with Y-tiling<br>       return<br>-         ((Rotated_Width (FB) = Port_Cfg.Mode.H_Visible and<br>-           Rotated_Height (FB) = Port_Cfg.Mode.V_Visible) or<br>+         ((Rotated_Width (FB) = Mode.H_Visible and<br>+           Rotated_Height (FB) = Mode.V_Visible) or<br>           (Rotated_Width (FB) <= Config.Maximum_Scalable_Width (Pipe) and<br>-           Rotated_Width (FB) <= Port_Cfg.Mode.H_Visible and<br>-           Rotated_Height (FB) <= Port_Cfg.Mode.V_Visible)) and<br>+           Rotated_Width (FB) <= Mode.H_Visible and<br>+           Rotated_Height (FB) <= Mode.V_Visible)) and<br>          (FB.Offset /= VGA_PLANE_FRAMEBUFFER_OFFSET or Pipe = Primary) and<br>          (FB.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or<br>           (FB.BPC = 8 and Valid_Stride (FB) and<br>diff --git a/common/hw-gfx-gma-config_helpers.ads b/common/hw-gfx-gma-config_helpers.ads<br>index 1dc2390..4853634 100644<br>--- a/common/hw-gfx-gma-config_helpers.ads<br>+++ b/common/hw-gfx-gma-config_helpers.ads<br>@@ -40,15 +40,15 @@<br>    use type HW.Pos32;<br>    pragma Warnings (GNAT, On, """Integer_32"" is already use-visible *");<br>    function Validate_Config<br>-     (FB       : Framebuffer_Type;<br>-      Port_Cfg : Port_Config;<br>-      Pipe     : Pipe_Index)<br>+     (FB    : Framebuffer_Type;<br>+      Mode  : Mode_Type;<br>+      Pipe  : Pipe_Index)<br>       return Boolean<br>    with<br>       Post =><br>         (if Validate_Config'Result then<br>-            Rotated_Width (FB) <= Port_Cfg.Mode.H_Visible and<br>-            Rotated_Height (FB) <= Port_Cfg.Mode.V_Visible and<br>+            Rotated_Width (FB) <= Mode.H_Visible and<br>+            Rotated_Height (FB) <= Mode.V_Visible and<br>             (FB.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or<br>              FB.Height + FB.Start_Y <= FB.V_Stride));<br> <br>diff --git a/common/hw-gfx-gma-pipe_setup.adb b/common/hw-gfx-gma-pipe_setup.adb<br>index e64edc9..7c919c2 100644<br>--- a/common/hw-gfx-gma-pipe_setup.adb<br>+++ b/common/hw-gfx-gma-pipe_setup.adb<br>@@ -206,7 +206,6 @@<br> <br>          Registers.Write<br>            (Controller.DSPSTRIDE, Word32 (Pixel_To_Bytes (FB.Stride, FB)));<br>-         Registers.Write (Controller.DSPSURF, FB.Offset and 16#ffff_f000#);<br>          if Config.Has_DSP_Linoff then<br>             Registers.Write (Controller.DSPLINOFF, 0);<br>          end if;<br>@@ -214,6 +213,7 @@<br>            (Register => Controller.DSPTILEOFF,<br>             Value    => Shift_Left (Word32 (FB.Start_Y), 16) or<br>                         Word32 (FB.Start_X));<br>+         Registers.Write (Controller.DSPSURF, FB.Offset and 16#ffff_f000#);<br>       end if;<br>    end Setup_Hires_Plane;<br> <br>@@ -439,25 +439,34 @@<br> <br>    ----------------------------------------------------------------------------<br> <br>+   procedure Setup_Pipe<br>+     (Pipe        : Pipe_Index;<br>+      Mode        : Mode_Type;<br>+      Framebuffer : Framebuffer_Type)<br>+   is<br>+      -- Enable dithering if framebuffer BPC differs from port BPC,<br>+      -- as smooth gradients look really bad without.<br>+      Dither : constant Boolean := Framebuffer.BPC /= Mode.BPC;<br>+   begin<br>+      pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));<br>+<br>+      Setup_Display (Controllers (Pipe), Framebuffer, Mode.BPC, Dither);<br>+      Setup_Scaling (Controllers (Pipe), Mode, Framebuffer);<br>+   end Setup_Pipe;<br>+<br>    procedure On<br>      (Pipe        : Pipe_Index;<br>       Port_Cfg    : Port_Config;<br>       Framebuffer : Framebuffer_Type)<br>    is<br>-      -- Enable dithering if framebuffer BPC differs from port BPC,<br>-      -- as smooth gradients look really bad without.<br>-      Dither : constant Boolean := Framebuffer.BPC /= Port_Cfg.Mode.BPC;<br>    begin<br>       pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));<br> <br>       Transcoder.Setup (Pipe, Port_Cfg);<br> <br>-      Setup_Display<br>-        (Controllers (Pipe), Framebuffer, Port_Cfg.Mode.BPC, Dither);<br>+      Setup_Pipe (Pipe, Port_Cfg.Mode, Framebuffer);<br> <br>-      Setup_Scaling (Controllers (Pipe), Port_Cfg.Mode, Framebuffer);<br>-<br>-      Transcoder.On (Pipe, Port_Cfg, Dither);<br>+      Transcoder.On (Pipe, Port_Cfg, Framebuffer.BPC /= Port_Cfg.Mode.BPC);<br>    end On;<br> <br>    ----------------------------------------------------------------------------<br>@@ -531,16 +540,5 @@<br>          Transcoder.Clk_Off (Pipe);<br>       end loop;<br>    end All_Off;<br>-<br>-   ----------------------------------------------------------------------------<br>-<br>-   procedure Update_Offset (Pipe : Pipe_Index; Framebuffer : Framebuffer_Type)<br>-   is<br>-   begin<br>-      pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));<br>-<br>-      Registers.Write<br>-        (Controllers (Pipe).DSPSURF, Framebuffer.Offset and 16#ffff_f000#);<br>-   end Update_Offset;<br> <br> end HW.GFX.GMA.Pipe_Setup;<br>diff --git a/common/hw-gfx-gma-pipe_setup.ads b/common/hw-gfx-gma-pipe_setup.ads<br>index 3ef5dcf..11c716a 100644<br>--- a/common/hw-gfx-gma-pipe_setup.ads<br>+++ b/common/hw-gfx-gma-pipe_setup.ads<br>@@ -36,7 +36,16 @@<br> <br>    procedure All_Off;<br> <br>-   procedure Update_Offset (Pipe : Pipe_Index; Framebuffer : Framebuffer_Type);<br>+   procedure Setup_Pipe<br>+     (Pipe        : Pipe_Index;<br>+      Mode        : Mode_Type;<br>+      Framebuffer : Framebuffer_Type)<br>+   with<br>+      Pre =><br>+         Rotated_Width (Framebuffer) <= Mode.H_Visible and<br>+         Rotated_Height (Framebuffer) <= Mode.V_Visible and<br>+         (Framebuffer.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or<br>+          Framebuffer.Height + Framebuffer.Start_Y <= Framebuffer.V_Stride);<br> <br> private<br> <br>diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb<br>index 420c1a3..798210a 100644<br>--- a/common/hw-gfx-gma.adb<br>+++ b/common/hw-gfx-gma.adb<br>@@ -109,7 +109,7 @@<br> <br>       if Success then<br>          Success := Config_Helpers.Validate_Config<br>-           (Pipe_Cfg.Framebuffer, Port_Cfg, Pipe);<br>+           (Pipe_Cfg.Framebuffer, Port_Cfg.Mode, Pipe);<br>       end if;<br> <br>       if Success then<br>@@ -284,9 +284,12 @@<br> <br>             -- update framebuffer offset only<br>             elsif New_Config.Port /= Disabled and<br>-                  Cur_Config.Framebuffer /= New_Config.Framebuffer<br>+                  Cur_Config.Framebuffer /= New_Config.Framebuffer and<br>+                  Config_Helpers.Validate_Config<br>+                    (New_Config.Framebuffer, New_Config.Mode, Pipe)<br>             then<br>-               Display_Controller.Update_Offset (Pipe, New_Config.Framebuffer);<br>+               Display_Controller.Setup_Pipe<br>+                 (Pipe, New_Config.Mode, New_Config.Framebuffer);<br>                Cur_Config := New_Config;<br>             end if;<br>          end;<br>diff --git a/gfxtest/hw-gfx-gma-gfx_test.adb b/gfxtest/hw-gfx-gma-gfx_test.adb<br>index 833240f..c3caade 100644<br>--- a/gfxtest/hw-gfx-gma-gfx_test.adb<br>+++ b/gfxtest/hw-gfx-gma-gfx_test.adb<br>@@ -1,3 +1,4 @@<br>+with Ada.Numerics.Discrete_Random;<br> with Ada.Unchecked_Conversion;<br> with Ada.Command_Line;<br> with Interfaces.C;<br>@@ -13,6 +14,8 @@<br> package body HW.GFX.GMA.GFX_Test<br> is<br>    pragma Disable_Atomic_Synchronization;<br>+<br>+   package R is new Ada.Numerics.Discrete_Random (Pos_Type);<br> <br>    Start_X : constant := 0;<br>    Start_Y : constant := 0;<br>@@ -369,6 +372,38 @@<br>             end if;<br>          end loop;<br> <br>+         if Delay_S > 16 then -- getting bored?<br>+            declare<br>+               New_Pipes : GMA.Pipe_Configs := Pipes;<br>+               Gen : R.Generator;<br>+            begin<br>+               Time.M_Delay (12_000);<br>+               Delay_S := Delay_S - 12;<br>+               while Delay_S > 4 loop<br>+                  Time.M_Delay (4_000);<br>+                  Delay_S := Delay_S - 4;<br>+                  for Pipe in GMA.Pipe_Index loop<br>+                     New_Pipes (Pipe).Framebuffer.Start_X :=<br>+                        R.Random (Gen) mod Pipes (Pipe).Framebuffer.Width / 2;<br>+                     New_Pipes (Pipe).Framebuffer.Start_Y :=<br>+                        R.Random (Gen) mod Pipes (Pipe).Framebuffer.Height / 2;<br>+                     New_Pipes (Pipe).Framebuffer.Width :=<br>+                        Width_Type'Max (320,<br>+                           Pipes (Pipe).Framebuffer.Width<br>+                           - Pipes (Pipe).Framebuffer.Start_X<br>+                           - R.Random (Gen) mod<br>+                              Pipes (Pipe).Framebuffer.Width / 2);<br>+                     New_Pipes (Pipe).Framebuffer.Height :=<br>+                        Height_Type'Max (200,<br>+                           Pipes (Pipe).Framebuffer.Height<br>+                           - Pipes (Pipe).Framebuffer.Start_Y<br>+                           - R.Random (Gen) mod<br>+                              Pipes (Pipe).Framebuffer.Height / 2);<br>+                  end loop;<br>+                  GMA.Update_Outputs (New_Pipes);<br>+               end loop;<br>+            end;<br>+         end if;<br>          Time.M_Delay (Delay_S * 1_000);<br> <br>          for Pipe in GMA.Pipe_Index loop<br></pre><p>To view, visit <a href="https://review.coreboot.org/22905">change 22905</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/22905"/><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: I780bd0a2733222008f5243483656655f1eb2b58e </div>
<div style="display:none"> Gerrit-Change-Number: 22905 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Nico Huber <nico.h@gmx.de> </div>