<p>Nico Huber has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/23242">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">[WIP] gfx_test: Draw a cursor<br><br>Change-Id: I58cd859f3294f30dfd91b87834699d62b1d0b025<br>Signed-off-by: Nico Huber <nico.huber@secunet.com><br>---<br>M gfxtest/hw-gfx-gma-gfx_test.adb<br>1 file changed, 56 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/42/23242/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/gfxtest/hw-gfx-gma-gfx_test.adb b/gfxtest/hw-gfx-gma-gfx_test.adb</span><br><span>index 145230b..9bbb72a 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>@@ -21,6 +21,7 @@</span><br><span> </span><br><span> Start_X : constant := 0;</span><br><span> Start_Y : constant := 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ Cursor_Width : constant := 64;</span><br><span> </span><br><span> package Dev is new PCI.Dev (PCI.Address'(0, 2, 0));</span><br><span> </span><br><span>@@ -83,7 +84,7 @@</span><br><span> Max_H : constant := 2160;</span><br><span> FB_Align : constant := 16#0004_0000#;</span><br><span> subtype Screen_Index is Natural range</span><br><span style="color: hsl(0, 100%, 40%);">- 0 .. 3 * (Max_W * Max_H + FB_Align / 4) - 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ 0 .. 3 * (Max_W * Max_H + FB_Align / 4 + Cursor_Width * Cursor_Width) - 1;</span><br><span> type Screen_Type is array (Screen_Index) of Word32;</span><br><span> </span><br><span> function Screen_Offset (FB : Framebuffer_Type) return Natural is</span><br><span>@@ -214,6 +215,31 @@</span><br><span> end loop;</span><br><span> end Test_Screen;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ function Donut (X, Y, Max : Cursor_Pos) return Pixel_Type</span><br><span style="color: hsl(120, 100%, 40%);">+ is</span><br><span style="color: hsl(120, 100%, 40%);">+ --Z : constant Int32 := (Max * 14_142_136) / 10_000_000;</span><br><span style="color: hsl(120, 100%, 40%);">+ ZZ : constant Int32 := Max * Max * 2;</span><br><span style="color: hsl(120, 100%, 40%);">+ Dist_Center : constant Int32 := ((X * X + Y * Y) * 510) / ZZ;</span><br><span style="color: hsl(120, 100%, 40%);">+ Dist_Circle : constant Int32 := Dist_Center - 255;</span><br><span style="color: hsl(120, 100%, 40%);">+ begin</span><br><span style="color: hsl(120, 100%, 40%);">+ return (0, 0, 0, Byte (255 - (Dist_Circle * Dist_Circle) / 255));</span><br><span style="color: hsl(120, 100%, 40%);">+ end Donut;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ procedure Draw_Cursor (Cursor : Cursor_Type)</span><br><span style="color: hsl(120, 100%, 40%);">+ is</span><br><span style="color: hsl(120, 100%, 40%);">+ Screen_Offset : Natural := Natural (Cursor.GTT_Offset / 4);</span><br><span style="color: hsl(120, 100%, 40%);">+ begin</span><br><span style="color: hsl(120, 100%, 40%);">+ for X in Cursor_Pos range -Cursor_Width / 2 .. Cursor_Width / 2 - 1 loop</span><br><span style="color: hsl(120, 100%, 40%);">+ for Y in Cursor_Pos range -Cursor_Width / 2 .. Cursor_Width / 2 - 1</span><br><span style="color: hsl(120, 100%, 40%);">+ loop</span><br><span style="color: hsl(120, 100%, 40%);">+ Screen.Write</span><br><span style="color: hsl(120, 100%, 40%);">+ (Index => Screen_Offset,</span><br><span style="color: hsl(120, 100%, 40%);">+ Value => Pixel_To_Word (Donut (X, Y, Cursor_Width / 2)));</span><br><span style="color: hsl(120, 100%, 40%);">+ Screen_Offset := Screen_Offset + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ end loop;</span><br><span style="color: hsl(120, 100%, 40%);">+ end loop;</span><br><span style="color: hsl(120, 100%, 40%);">+ end Draw_Cursor;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> procedure Calc_Framebuffer</span><br><span> (FB : out Framebuffer_Type;</span><br><span> Mode : in Mode_Type;</span><br><span>@@ -252,6 +278,31 @@</span><br><span> Offset := Offset + Word32 (FB_Size (FB));</span><br><span> end Calc_Framebuffer;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ procedure Prepare_Cursor</span><br><span style="color: hsl(120, 100%, 40%);">+ (Cursor : out Cursor_Type;</span><br><span style="color: hsl(120, 100%, 40%);">+ Offset : in out Word32)</span><br><span style="color: hsl(120, 100%, 40%);">+ is</span><br><span style="color: hsl(120, 100%, 40%);">+ begin</span><br><span style="color: hsl(120, 100%, 40%);">+ Offset := (Offset + FB_Align - 1) and not (FB_Align - 1);</span><br><span style="color: hsl(120, 100%, 40%);">+ Cursor :=</span><br><span style="color: hsl(120, 100%, 40%);">+ (Mode => ARGB_Cursor,</span><br><span style="color: hsl(120, 100%, 40%);">+ Size => Cursor_64x64,</span><br><span style="color: hsl(120, 100%, 40%);">+ Center_X => Cursor_Width / 2,</span><br><span style="color: hsl(120, 100%, 40%);">+ Center_Y => Cursor_Width / 2,</span><br><span style="color: hsl(120, 100%, 40%);">+ GTT_Offset => Offset);</span><br><span style="color: hsl(120, 100%, 40%);">+ declare</span><br><span style="color: hsl(120, 100%, 40%);">+ GTT_End : constant Word32 := Offset + Cursor_Width * Cursor_Width * 4;</span><br><span style="color: hsl(120, 100%, 40%);">+ begin</span><br><span style="color: hsl(120, 100%, 40%);">+ while Offset < GTT_End loop</span><br><span style="color: hsl(120, 100%, 40%);">+ GMA.Write_GTT</span><br><span style="color: hsl(120, 100%, 40%);">+ (GTT_Page => GTT_Range (Offset / GTT_Page_Size),</span><br><span style="color: hsl(120, 100%, 40%);">+ Device_Address => GTT_Address_Type (Offset),</span><br><span style="color: hsl(120, 100%, 40%);">+ Valid => True);</span><br><span style="color: hsl(120, 100%, 40%);">+ Offset := Offset + GTT_Page_Size;</span><br><span style="color: hsl(120, 100%, 40%);">+ end loop;</span><br><span style="color: hsl(120, 100%, 40%);">+ end;</span><br><span style="color: hsl(120, 100%, 40%);">+ end Prepare_Cursor;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> Pipes : GMA.Pipe_Configs;</span><br><span> </span><br><span> procedure Prepare_Configs (Rotation : Rotation_Type)</span><br><span>@@ -277,6 +328,9 @@</span><br><span> if not Success then</span><br><span> Pipes (Pipe).Port := GMA.Disabled;</span><br><span> end if;</span><br><span style="color: hsl(120, 100%, 40%);">+ Prepare_Cursor</span><br><span style="color: hsl(120, 100%, 40%);">+ (Cursor => Pipes (Pipe).Cursor,</span><br><span style="color: hsl(120, 100%, 40%);">+ Offset => Offset);</span><br><span> end if;</span><br><span> end loop;</span><br><span> </span><br><span>@@ -371,6 +425,7 @@</span><br><span> Test_Screen</span><br><span> (Framebuffer => Pipes (Pipe).Framebuffer,</span><br><span> Pipe => Pipe);</span><br><span style="color: hsl(120, 100%, 40%);">+ Draw_Cursor (Pipes (Pipe).Cursor);</span><br><span> end if;</span><br><span> end loop;</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/23242">change 23242</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/23242"/><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: I58cd859f3294f30dfd91b87834699d62b1d0b025 </div>
<div style="display:none"> Gerrit-Change-Number: 23242 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Nico Huber <nico.h@gmx.de> </div>