Commit 49b8d5ae authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/mgag200: Add init and fini functions for cursor handling

Moving the cursor initialization and cleanup into separate functions
makes the overall code slightly more readable.
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-3-tzimmermann@suse.de
parent 52e32da9
......@@ -25,6 +25,34 @@ static void mgag200_hide_cursor(struct mga_device *mdev)
mdev->cursor.pixels_current = NULL;
}
int mgag200_cursor_init(struct mga_device *mdev)
{
struct drm_device *dev = mdev->dev;
/*
* Make small buffers to store a hardware cursor (double
* buffered icon updates)
*/
mdev->cursor.pixels_1 = drm_gem_vram_create(dev, &dev->vram_mm->bdev,
roundup(48*64, PAGE_SIZE),
0, 0);
mdev->cursor.pixels_2 = drm_gem_vram_create(dev, &dev->vram_mm->bdev,
roundup(48*64, PAGE_SIZE),
0, 0);
if (IS_ERR(mdev->cursor.pixels_2) || IS_ERR(mdev->cursor.pixels_1)) {
mdev->cursor.pixels_1 = NULL;
mdev->cursor.pixels_2 = NULL;
dev_warn(&dev->pdev->dev,
"Could not allocate space for cursors. Not doing hardware cursors.\n");
}
mdev->cursor.pixels_current = NULL;
return 0;
}
void mgag200_cursor_fini(struct mga_device *mdev)
{ }
int mgag200_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
uint32_t handle, uint32_t width, uint32_t height)
{
......
......@@ -203,6 +203,8 @@ int mgag200_mm_init(struct mga_device *mdev);
void mgag200_mm_fini(struct mga_device *mdev);
int mgag200_mmap(struct file *filp, struct vm_area_struct *vma);
int mgag200_cursor_init(struct mga_device *mdev);
void mgag200_cursor_fini(struct mga_device *mdev);
int mgag200_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
uint32_t handle, uint32_t width, uint32_t height);
int mgag200_crtc_cursor_move(struct drm_crtc *crtc, int x, int y);
......
......@@ -171,20 +171,10 @@ int mgag200_driver_load(struct drm_device *dev, unsigned long flags)
goto err_modeset;
}
/* Make small buffers to store a hardware cursor (double buffered icon updates) */
mdev->cursor.pixels_1 = drm_gem_vram_create(dev, &dev->vram_mm->bdev,
roundup(48*64, PAGE_SIZE),
0, 0);
mdev->cursor.pixels_2 = drm_gem_vram_create(dev, &dev->vram_mm->bdev,
roundup(48*64, PAGE_SIZE),
0, 0);
if (IS_ERR(mdev->cursor.pixels_2) || IS_ERR(mdev->cursor.pixels_1)) {
mdev->cursor.pixels_1 = NULL;
mdev->cursor.pixels_2 = NULL;
r = mgag200_cursor_init(mdev);
if (r)
dev_warn(&dev->pdev->dev,
"Could not allocate space for cursors. Not doing hardware cursors.\n");
}
mdev->cursor.pixels_current = NULL;
"Could not initialize cursors. Not doing hardware cursors.\n");
r = drm_fbdev_generic_setup(mdev->dev, 0);
if (r)
......@@ -194,6 +184,7 @@ int mgag200_driver_load(struct drm_device *dev, unsigned long flags)
err_modeset:
drm_mode_config_cleanup(dev);
mgag200_cursor_fini(mdev);
mgag200_mm_fini(mdev);
err_mm:
dev->dev_private = NULL;
......@@ -209,6 +200,7 @@ void mgag200_driver_unload(struct drm_device *dev)
return;
mgag200_modeset_fini(mdev);
drm_mode_config_cleanup(dev);
mgag200_cursor_fini(mdev);
mgag200_mm_fini(mdev);
dev->dev_private = NULL;
}
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