Commit 6ae04536 authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/mgag200: Add separate move-cursor function

Adding mgag200_move_cursor() makes the cursor code more consistent and
will become handy when we move to universal cursor planes.
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Acked-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190927091301.10574-4-tzimmermann@suse.de
parent 49b8d5ae
...@@ -25,6 +25,24 @@ static void mgag200_hide_cursor(struct mga_device *mdev) ...@@ -25,6 +25,24 @@ static void mgag200_hide_cursor(struct mga_device *mdev)
mdev->cursor.pixels_current = NULL; mdev->cursor.pixels_current = NULL;
} }
static void mgag200_move_cursor(struct mga_device *mdev, int x, int y)
{
if (WARN_ON(x <= 0))
return;
if (WARN_ON(y <= 0))
return;
if (WARN_ON(x & ~0xffff))
return;
if (WARN_ON(y & ~0xffff))
return;
WREG8(MGA_CURPOSXL, x & 0xff);
WREG8(MGA_CURPOSXH, (x>>8) & 0xff);
WREG8(MGA_CURPOSYL, y & 0xff);
WREG8(MGA_CURPOSYH, (y>>8) & 0xff);
}
int mgag200_cursor_init(struct mga_device *mdev) int mgag200_cursor_init(struct mga_device *mdev)
{ {
struct drm_device *dev = mdev->dev; struct drm_device *dev = mdev->dev;
...@@ -252,19 +270,12 @@ int mgag200_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv, ...@@ -252,19 +270,12 @@ int mgag200_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
int mgag200_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) int mgag200_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
{ {
struct mga_device *mdev = (struct mga_device *)crtc->dev->dev_private; struct mga_device *mdev = (struct mga_device *)crtc->dev->dev_private;
/* Our origin is at (64,64) */ /* Our origin is at (64,64) */
x += 64; x += 64;
y += 64; y += 64;
BUG_ON(x <= 0); mgag200_move_cursor(mdev, x, y);
BUG_ON(y <= 0);
BUG_ON(x & ~0xffff);
BUG_ON(y & ~0xffff);
WREG8(MGA_CURPOSXL, x & 0xff);
WREG8(MGA_CURPOSXH, (x>>8) & 0xff);
WREG8(MGA_CURPOSYL, y & 0xff);
WREG8(MGA_CURPOSYH, (y>>8) & 0xff);
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment