Commit 9dddcd27 authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/hisilicon/hibmc: Implement hibmc_dumb_create() with generic helpers

The hibmc driver aligns scanlines to 16 bytes. By using the new pitch_align
argument of drm_gem_vram_fill_create_dumb(), convert hibmc over.

v2:
	* move changes to VRAM helpers into separate patch
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: default avatarSam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191203083819.6643-5-tzimmermann@suse.de
parent 98707327
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include <drm/drm_framebuffer.h> #include <drm/drm_framebuffer.h>
struct drm_device; struct drm_device;
struct drm_gem_object;
struct hibmc_drm_private { struct hibmc_drm_private {
/* hw */ /* hw */
...@@ -41,9 +40,6 @@ void hibmc_set_current_gate(struct hibmc_drm_private *priv, ...@@ -41,9 +40,6 @@ void hibmc_set_current_gate(struct hibmc_drm_private *priv,
int hibmc_de_init(struct hibmc_drm_private *priv); int hibmc_de_init(struct hibmc_drm_private *priv);
int hibmc_vdac_init(struct hibmc_drm_private *priv); int hibmc_vdac_init(struct hibmc_drm_private *priv);
int hibmc_gem_create(struct drm_device *dev, u32 size, bool iskernel,
struct drm_gem_object **obj);
int hibmc_mm_init(struct hibmc_drm_private *hibmc); int hibmc_mm_init(struct hibmc_drm_private *hibmc);
void hibmc_mm_fini(struct hibmc_drm_private *hibmc); void hibmc_mm_fini(struct hibmc_drm_private *hibmc);
int hibmc_dumb_create(struct drm_file *file, struct drm_device *dev, int hibmc_dumb_create(struct drm_file *file, struct drm_device *dev,
......
...@@ -47,55 +47,11 @@ void hibmc_mm_fini(struct hibmc_drm_private *hibmc) ...@@ -47,55 +47,11 @@ void hibmc_mm_fini(struct hibmc_drm_private *hibmc)
drm_vram_helper_release_mm(hibmc->dev); drm_vram_helper_release_mm(hibmc->dev);
} }
int hibmc_gem_create(struct drm_device *dev, u32 size, bool iskernel,
struct drm_gem_object **obj)
{
struct drm_gem_vram_object *gbo;
int ret;
*obj = NULL;
size = roundup(size, PAGE_SIZE);
if (size == 0)
return -EINVAL;
gbo = drm_gem_vram_create(dev, &dev->vram_mm->bdev, size, 0, false);
if (IS_ERR(gbo)) {
ret = PTR_ERR(gbo);
if (ret != -ERESTARTSYS)
DRM_ERROR("failed to allocate GEM object: %d\n", ret);
return ret;
}
*obj = &gbo->bo.base;
return 0;
}
int hibmc_dumb_create(struct drm_file *file, struct drm_device *dev, int hibmc_dumb_create(struct drm_file *file, struct drm_device *dev,
struct drm_mode_create_dumb *args) struct drm_mode_create_dumb *args)
{ {
struct drm_gem_object *gobj; return drm_gem_vram_fill_create_dumb(file, dev, &dev->vram_mm->bdev,
u32 handle; 0, 16, false, args);
int ret;
args->pitch = ALIGN(args->width * DIV_ROUND_UP(args->bpp, 8), 16);
args->size = args->pitch * args->height;
ret = hibmc_gem_create(dev, args->size, false,
&gobj);
if (ret) {
DRM_ERROR("failed to create GEM object: %d\n", ret);
return ret;
}
ret = drm_gem_handle_create(file, gobj, &handle);
drm_gem_object_put_unlocked(gobj);
if (ret) {
DRM_ERROR("failed to unreference GEM object: %d\n", ret);
return ret;
}
args->handle = handle;
return 0;
} }
const struct drm_mode_config_funcs hibmc_mode_funcs = { const struct drm_mode_config_funcs hibmc_mode_funcs = {
......
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