Nico Huber has uploaded this change for review. ( https://review.coreboot.org/c/libgfxinit/+/48815 )
Change subject: gma: Expect cursor coordinates on framebuffer surface ......................................................................
gma: Expect cursor coordinates on framebuffer surface
Cursor coordinates are relative to the framebuffer's surface. In case of a rotated framebuffer, we need to rotate the cursor coordinates too.
Change-Id: I1e796163e6eeee9cb60dbe097e3847bced13f87c Signed-off-by: Nico Huber nico.huber@secunet.com --- M common/hw-gfx-gma-pipe_setup.adb M gfxtest/hw-gfx-gma-gfx_test.adb 2 files changed, 24 insertions(+), 8 deletions(-)
git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/15/48815/1
diff --git a/common/hw-gfx-gma-pipe_setup.adb b/common/hw-gfx-gma-pipe_setup.adb index 82f5222..5ec807d 100644 --- a/common/hw-gfx-gma-pipe_setup.adb +++ b/common/hw-gfx-gma-pipe_setup.adb @@ -363,8 +363,24 @@ Cursor : Cursor_Type) is Width : constant Width_Type := Cursor_Width (Cursor.Size); - X : Int32 := Cursor.Center_X - Width / 2; - Y : Int32 := Cursor.Center_Y - Width / 2; + + -- The cursor's coordinates are on the framebuffer surface + -- but we need to place it on the physical screen: + Center_X : constant Int32 := + (case FB.Rotation is + when No_Rotation => Cursor.Center_X, + when Rotated_90 => FB.Height - 1 - Cursor.Center_Y, + when Rotated_180 => FB.Width - 1 - Cursor.Center_X, + when Rotated_270 => Cursor.Center_Y); + Center_Y : constant Int32 := + (case FB.Rotation is + when No_Rotation => Cursor.Center_Y, + when Rotated_90 => Cursor.Center_X, + when Rotated_180 => FB.Height - 1 - Cursor.Center_Y, + when Rotated_270 => FB.Width - 1 - Cursor.Center_X); + + X : Int32 := Center_X - Width / 2; + Y : Int32 := Center_Y - Width / 2; begin -- off-screen cursor needs special care if X <= -Width or Y <= -Width or diff --git a/gfxtest/hw-gfx-gma-gfx_test.adb b/gfxtest/hw-gfx-gma-gfx_test.adb index e5bc393..606e5a2 100644 --- a/gfxtest/hw-gfx-gma-gfx_test.adb +++ b/gfxtest/hw-gfx-gma-gfx_test.adb @@ -402,8 +402,8 @@ declare C : Cursor_Type renames Pipes (Pipe).Cursor; FB : Framebuffer_Type renames Pipes (Pipe).Framebuffer; - Width : constant Width_Type := Rotated_Width (FB); - Height : constant Height_Type := Rotated_Height (FB); + Width : constant Width_Type := FB.Width; + Height : constant Height_Type := FB.Height; CS : Cursor_Script_Entry renames Cursor_Script (Natural (Cnt) mod (Cursor_Script'Last + 1)); begin @@ -493,8 +493,8 @@ C : Cursor_Type renames Pipes (Pipe).Cursor; CI : Cursor_Info renames Cursor_Infos (Pipe); FB : Framebuffer_Type renames Pipes (Pipe).Framebuffer; - Width : constant Width_Type := Rotated_Width (FB); - Height : constant Height_Type := Rotated_Height (FB); + Width : constant Width_Type := FB.Width; + Height : constant Height_Type := FB.Height;
Update : Boolean := False; begin @@ -611,8 +611,8 @@ New_FB.Height := Height_Type'Max (320, Height - New_FB.Start_Y - Rand_Div (Height));
- Cursor.Center_X := Rotated_Width (New_FB) / 2; - Cursor.Center_Y := Rotated_Height (New_FB) / 2; + Cursor.Center_X := New_FB.Width / 2; + Cursor.Center_Y := New_FB.Height / 2; GMA.Update_Cursor (Pipe, Cursor); end; end loop;