[coreboot-gerrit] Change in libgfxinit[master]: [UNTESTED] gma: Allow arbitary framebuffer updates

Nico Huber (Code Review) gerrit at coreboot.org
Fri Dec 15 20:55:54 CET 2017


Nico Huber has uploaded this change for review. ( https://review.coreboot.org/22905


Change subject: [UNTESTED] gma: Allow arbitary framebuffer updates
......................................................................

[UNTESTED] gma: Allow arbitary framebuffer updates

Change-Id: I780bd0a2733222008f5243483656655f1eb2b58e
---
M common/hw-gfx-gma-config_helpers.adb
M common/hw-gfx-gma-config_helpers.ads
M common/hw-gfx-gma-pipe_setup.adb
M common/hw-gfx-gma-pipe_setup.ads
M common/hw-gfx-gma.adb
M gfxtest/hw-gfx-gma-gfx_test.adb
6 files changed, 81 insertions(+), 36 deletions(-)



  git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/05/22905/1

diff --git a/common/hw-gfx-gma-config_helpers.adb b/common/hw-gfx-gma-config_helpers.adb
index f2b4ef6..5e5be5d 100644
--- a/common/hw-gfx-gma-config_helpers.adb
+++ b/common/hw-gfx-gma-config_helpers.adb
@@ -181,9 +181,9 @@
    -- Validates that a given configuration should work with
    -- a given framebuffer.
    function Validate_Config
-     (FB       : Framebuffer_Type;
-      Port_Cfg : Port_Config;
-      Pipe     : Pipe_Index)
+     (FB    : Framebuffer_Type;
+      Mode  : Mode_Type;
+      Pipe  : Pipe_Index)
       return Boolean
    is
    begin
@@ -197,11 +197,11 @@
       -- Plane_Control)
       -- 90 degree rotations are only supported with Y-tiling
       return
-         ((Rotated_Width (FB) = Port_Cfg.Mode.H_Visible and
-           Rotated_Height (FB) = Port_Cfg.Mode.V_Visible) or
+         ((Rotated_Width (FB) = Mode.H_Visible and
+           Rotated_Height (FB) = Mode.V_Visible) or
           (Rotated_Width (FB) <= Config.Maximum_Scalable_Width (Pipe) and
-           Rotated_Width (FB) <= Port_Cfg.Mode.H_Visible and
-           Rotated_Height (FB) <= Port_Cfg.Mode.V_Visible)) and
+           Rotated_Width (FB) <= Mode.H_Visible and
+           Rotated_Height (FB) <= Mode.V_Visible)) and
          (FB.Offset /= VGA_PLANE_FRAMEBUFFER_OFFSET or Pipe = Primary) and
          (FB.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or
           (FB.BPC = 8 and Valid_Stride (FB) and
diff --git a/common/hw-gfx-gma-config_helpers.ads b/common/hw-gfx-gma-config_helpers.ads
index 1dc2390..4853634 100644
--- a/common/hw-gfx-gma-config_helpers.ads
+++ b/common/hw-gfx-gma-config_helpers.ads
@@ -40,15 +40,15 @@
    use type HW.Pos32;
    pragma Warnings (GNAT, On, """Integer_32"" is already use-visible *");
    function Validate_Config
-     (FB       : Framebuffer_Type;
-      Port_Cfg : Port_Config;
-      Pipe     : Pipe_Index)
+     (FB    : Framebuffer_Type;
+      Mode  : Mode_Type;
+      Pipe  : Pipe_Index)
       return Boolean
    with
       Post =>
         (if Validate_Config'Result then
-            Rotated_Width (FB) <= Port_Cfg.Mode.H_Visible and
-            Rotated_Height (FB) <= Port_Cfg.Mode.V_Visible and
+            Rotated_Width (FB) <= Mode.H_Visible and
+            Rotated_Height (FB) <= Mode.V_Visible and
             (FB.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or
              FB.Height + FB.Start_Y <= FB.V_Stride));
 
diff --git a/common/hw-gfx-gma-pipe_setup.adb b/common/hw-gfx-gma-pipe_setup.adb
index e64edc9..7c919c2 100644
--- a/common/hw-gfx-gma-pipe_setup.adb
+++ b/common/hw-gfx-gma-pipe_setup.adb
@@ -206,7 +206,6 @@
 
          Registers.Write
            (Controller.DSPSTRIDE, Word32 (Pixel_To_Bytes (FB.Stride, FB)));
-         Registers.Write (Controller.DSPSURF, FB.Offset and 16#ffff_f000#);
          if Config.Has_DSP_Linoff then
             Registers.Write (Controller.DSPLINOFF, 0);
          end if;
@@ -214,6 +213,7 @@
            (Register => Controller.DSPTILEOFF,
             Value    => Shift_Left (Word32 (FB.Start_Y), 16) or
                         Word32 (FB.Start_X));
+         Registers.Write (Controller.DSPSURF, FB.Offset and 16#ffff_f000#);
       end if;
    end Setup_Hires_Plane;
 
@@ -439,25 +439,34 @@
 
    ----------------------------------------------------------------------------
 
+   procedure Setup_Pipe
+     (Pipe        : Pipe_Index;
+      Mode        : Mode_Type;
+      Framebuffer : Framebuffer_Type)
+   is
+      -- Enable dithering if framebuffer BPC differs from port BPC,
+      -- as smooth gradients look really bad without.
+      Dither : constant Boolean := Framebuffer.BPC /= Mode.BPC;
+   begin
+      pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
+
+      Setup_Display (Controllers (Pipe), Framebuffer, Mode.BPC, Dither);
+      Setup_Scaling (Controllers (Pipe), Mode, Framebuffer);
+   end Setup_Pipe;
+
    procedure On
      (Pipe        : Pipe_Index;
       Port_Cfg    : Port_Config;
       Framebuffer : Framebuffer_Type)
    is
-      -- Enable dithering if framebuffer BPC differs from port BPC,
-      -- as smooth gradients look really bad without.
-      Dither : constant Boolean := Framebuffer.BPC /= Port_Cfg.Mode.BPC;
    begin
       pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
 
       Transcoder.Setup (Pipe, Port_Cfg);
 
-      Setup_Display
-        (Controllers (Pipe), Framebuffer, Port_Cfg.Mode.BPC, Dither);
+      Setup_Pipe (Pipe, Port_Cfg.Mode, Framebuffer);
 
-      Setup_Scaling (Controllers (Pipe), Port_Cfg.Mode, Framebuffer);
-
-      Transcoder.On (Pipe, Port_Cfg, Dither);
+      Transcoder.On (Pipe, Port_Cfg, Framebuffer.BPC /= Port_Cfg.Mode.BPC);
    end On;
 
    ----------------------------------------------------------------------------
@@ -531,16 +540,5 @@
          Transcoder.Clk_Off (Pipe);
       end loop;
    end All_Off;
-
-   ----------------------------------------------------------------------------
-
-   procedure Update_Offset (Pipe : Pipe_Index; Framebuffer : Framebuffer_Type)
-   is
-   begin
-      pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
-
-      Registers.Write
-        (Controllers (Pipe).DSPSURF, Framebuffer.Offset and 16#ffff_f000#);
-   end Update_Offset;
 
 end HW.GFX.GMA.Pipe_Setup;
diff --git a/common/hw-gfx-gma-pipe_setup.ads b/common/hw-gfx-gma-pipe_setup.ads
index 3ef5dcf..11c716a 100644
--- a/common/hw-gfx-gma-pipe_setup.ads
+++ b/common/hw-gfx-gma-pipe_setup.ads
@@ -36,7 +36,16 @@
 
    procedure All_Off;
 
-   procedure Update_Offset (Pipe : Pipe_Index; Framebuffer : Framebuffer_Type);
+   procedure Setup_Pipe
+     (Pipe        : Pipe_Index;
+      Mode        : Mode_Type;
+      Framebuffer : Framebuffer_Type)
+   with
+      Pre =>
+         Rotated_Width (Framebuffer) <= Mode.H_Visible and
+         Rotated_Height (Framebuffer) <= Mode.V_Visible and
+         (Framebuffer.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or
+          Framebuffer.Height + Framebuffer.Start_Y <= Framebuffer.V_Stride);
 
 private
 
diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb
index 420c1a3..798210a 100644
--- a/common/hw-gfx-gma.adb
+++ b/common/hw-gfx-gma.adb
@@ -109,7 +109,7 @@
 
       if Success then
          Success := Config_Helpers.Validate_Config
-           (Pipe_Cfg.Framebuffer, Port_Cfg, Pipe);
+           (Pipe_Cfg.Framebuffer, Port_Cfg.Mode, Pipe);
       end if;
 
       if Success then
@@ -284,9 +284,12 @@
 
             -- update framebuffer offset only
             elsif New_Config.Port /= Disabled and
-                  Cur_Config.Framebuffer /= New_Config.Framebuffer
+                  Cur_Config.Framebuffer /= New_Config.Framebuffer and
+                  Config_Helpers.Validate_Config
+                    (New_Config.Framebuffer, New_Config.Mode, Pipe)
             then
-               Display_Controller.Update_Offset (Pipe, New_Config.Framebuffer);
+               Display_Controller.Setup_Pipe
+                 (Pipe, New_Config.Mode, New_Config.Framebuffer);
                Cur_Config := New_Config;
             end if;
          end;
diff --git a/gfxtest/hw-gfx-gma-gfx_test.adb b/gfxtest/hw-gfx-gma-gfx_test.adb
index 833240f..c3caade 100644
--- a/gfxtest/hw-gfx-gma-gfx_test.adb
+++ b/gfxtest/hw-gfx-gma-gfx_test.adb
@@ -1,3 +1,4 @@
+with Ada.Numerics.Discrete_Random;
 with Ada.Unchecked_Conversion;
 with Ada.Command_Line;
 with Interfaces.C;
@@ -13,6 +14,8 @@
 package body HW.GFX.GMA.GFX_Test
 is
    pragma Disable_Atomic_Synchronization;
+
+   package R is new Ada.Numerics.Discrete_Random (Pos_Type);
 
    Start_X : constant := 0;
    Start_Y : constant := 0;
@@ -369,6 +372,38 @@
             end if;
          end loop;
 
+         if Delay_S > 16 then -- getting bored?
+            declare
+               New_Pipes : GMA.Pipe_Configs := Pipes;
+               Gen : R.Generator;
+            begin
+               Time.M_Delay (12_000);
+               Delay_S := Delay_S - 12;
+               while Delay_S > 4 loop
+                  Time.M_Delay (4_000);
+                  Delay_S := Delay_S - 4;
+                  for Pipe in GMA.Pipe_Index loop
+                     New_Pipes (Pipe).Framebuffer.Start_X :=
+                        R.Random (Gen) mod Pipes (Pipe).Framebuffer.Width / 2;
+                     New_Pipes (Pipe).Framebuffer.Start_Y :=
+                        R.Random (Gen) mod Pipes (Pipe).Framebuffer.Height / 2;
+                     New_Pipes (Pipe).Framebuffer.Width :=
+                        Width_Type'Max (320,
+                           Pipes (Pipe).Framebuffer.Width
+                           - Pipes (Pipe).Framebuffer.Start_X
+                           - R.Random (Gen) mod
+                              Pipes (Pipe).Framebuffer.Width / 2);
+                     New_Pipes (Pipe).Framebuffer.Height :=
+                        Height_Type'Max (200,
+                           Pipes (Pipe).Framebuffer.Height
+                           - Pipes (Pipe).Framebuffer.Start_Y
+                           - R.Random (Gen) mod
+                              Pipes (Pipe).Framebuffer.Height / 2);
+                  end loop;
+                  GMA.Update_Outputs (New_Pipes);
+               end loop;
+            end;
+         end if;
          Time.M_Delay (Delay_S * 1_000);
 
          for Pipe in GMA.Pipe_Index loop

-- 
To view, visit https://review.coreboot.org/22905
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-Project: libgfxinit
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I780bd0a2733222008f5243483656655f1eb2b58e
Gerrit-Change-Number: 22905
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/20171215/4a60fc59/attachment-0001.html>


More information about the coreboot-gerrit mailing list