gma pipe setup: Fix secondary pipe cursors <= Sandy Bridge

The secondary cursor registers used to have a different offset.

Change-Id: I4d79f59a8cb693d73d6da666525f091021efb4fd
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/libgfxinit/+/27154
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Reto Buerki <reet@codelabs.ch>
diff --git a/common/hw-gfx-gma-pipe_setup.adb b/common/hw-gfx-gma-pipe_setup.adb
index bb7b989..000c536 100644
--- a/common/hw-gfx-gma-pipe_setup.adb
+++ b/common/hw-gfx-gma-pipe_setup.adb
@@ -15,7 +15,6 @@
 with HW.Debug;
 with GNAT.Source_Info;
 
-with HW.GFX.GMA.Config;
 with HW.GFX.GMA.Transcoder;
 
 package body HW.GFX.GMA.Pipe_Setup is
@@ -352,7 +351,7 @@
       -- on some platforms writing CUR_CTL disables self-arming of CUR_POS
       -- so keep it first
       Registers.Write
-        (Register => Controllers (Pipe).CUR_CTL,
+        (Register => Cursors (Pipe).CTL,
          Value    => CUR_CTL_PIPE_SELECT (Pipe) or
                      CUR_CTL_MODE (Cursor.Mode, Cursor.Size));
       Place_Cursor (Pipe, FB, Cursor);
@@ -376,11 +375,11 @@
          Y := -Width;
       end if;
       Registers.Write
-        (Register => Controllers (Pipe).CUR_POS,
+        (Register => Cursors (Pipe).POS,
          Value    => CUR_POS_Y (Y) or CUR_POS_X (X));
       -- write to CUR_BASE always arms other CUR_* registers
       Registers.Write
-        (Register => Controllers (Pipe).CUR_BASE,
+        (Register => Cursors (Pipe).BASE,
          Value    => Shift_Left (Word32 (Cursor.GTT_Offset), 12));
    end Place_Cursor;
 
@@ -699,11 +698,13 @@
 
    ----------------------------------------------------------------------------
 
-   procedure Planes_Off (Controller : Controller_Type) is
+   procedure Planes_Off (Controller : Controller_Type; CUR : Cursor_Regs)
+   is
+      use type Registers.Registers_Invalid_Index;
    begin
-      Registers.Write (Controller.CUR_CTL, 16#0000_0000#);
-      if Config.Has_Cursor_FBC_Control then
-         Registers.Write (Controller.CUR_FBC_CTL, 16#0000_0000#);
+      Registers.Write (CUR.CTL, 16#0000_0000#);
+      if CUR.FBC_CTL /= Registers.Invalid_Register then
+         Registers.Write (CUR.FBC_CTL, 16#0000_0000#);
       end if;
       Registers.Unset_Mask (Controller.SPCNTR, DSPCNTR_ENABLE);
       if Config.Has_Plane_Control then
@@ -720,7 +721,7 @@
    begin
       pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
 
-      Planes_Off (Controllers (Pipe));
+      Planes_Off (Controllers (Pipe), Cursors (Pipe));
       Transcoder.Off (Pipe);
       Panel_Fitter_Off (Controllers (Pipe));
       Transcoder.Clk_Off (Pipe);
@@ -746,7 +747,7 @@
       Legacy_VGA_Off;
 
       for Pipe in Pipe_Index loop
-         Planes_Off (Controllers (Pipe));
+         Planes_Off (Controllers (Pipe), Cursors (Pipe));
          Transcoder.Off (Pipe);
          Panel_Fitter_Off (Controllers (Pipe));
          Transcoder.Clk_Off (Pipe);