[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 08/25] drm/gma500: Compute dumb-buffer sizes with drm_mode_size_dumb()



Call drm_mode_size_dumb() to compute dumb-buffer scanline pitch and
buffer size. Align the pitch to a multiple of 64.

Signed-off-by: Thomas Zimmermann <tzimmermann@xxxxxxx>
Cc: Patrik Jakobsson <patrik.r.jakobsson@xxxxxxxxx>
---
 drivers/gpu/drm/gma500/gem.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/gma500/gem.c b/drivers/gpu/drm/gma500/gem.c
index 4b7627a72637..fc337db0a948 100644
--- a/drivers/gpu/drm/gma500/gem.c
+++ b/drivers/gpu/drm/gma500/gem.c
@@ -16,6 +16,7 @@
 #include <asm/set_memory.h>
 
 #include <drm/drm.h>
+#include <drm/drm_dumb_buffers.h>
 #include <drm/drm_vma_manager.h>
 
 #include "gem.h"
@@ -199,35 +200,25 @@ psb_gem_create(struct drm_device *dev, u64 size, const 
char *name, bool stolen,
 int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
                        struct drm_mode_create_dumb *args)
 {
-       size_t pitch, size;
        struct psb_gem_object *pobj;
        struct drm_gem_object *obj;
-       u32 handle;
        int ret;
 
-       pitch = args->width * DIV_ROUND_UP(args->bpp, 8);
-       pitch = ALIGN(pitch, 64);
-
-       size = pitch * args->height;
-       size = roundup(size, PAGE_SIZE);
-       if (!size)
-               return -EINVAL;
+       ret = drm_mode_size_dumb(dev, args, SZ_64, 0);
+       if (ret)
+               return ret;
 
-       pobj = psb_gem_create(dev, size, "gem", false, PAGE_SIZE);
+       pobj = psb_gem_create(dev, args->size, "gem", false, PAGE_SIZE);
        if (IS_ERR(pobj))
                return PTR_ERR(pobj);
        obj = &pobj->base;
 
-       ret = drm_gem_handle_create(file, obj, &handle);
+       ret = drm_gem_handle_create(file, obj, &args->handle);
        if (ret)
                goto err_drm_gem_object_put;
 
        drm_gem_object_put(obj);
 
-       args->pitch = pitch;
-       args->size = size;
-       args->handle = handle;
-
        return 0;
 
 err_drm_gem_object_put:
-- 
2.47.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.