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

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



Call drm_mode_size_dumb() to compute dumb-buffer scanline pitch
and buffer size. No alignment required.

Signed-off-by: Thomas Zimmermann <tzimmermann@xxxxxxx>
Cc: Dave Airlie <airlied@xxxxxxxxxx>
Cc: Gerd Hoffmann <kraxel@xxxxxxxxxx>
---
 drivers/gpu/drm/qxl/qxl_dumb.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_dumb.c b/drivers/gpu/drm/qxl/qxl_dumb.c
index 17df5c7ccf69..1200946767ce 100644
--- a/drivers/gpu/drm/qxl/qxl_dumb.c
+++ b/drivers/gpu/drm/qxl/qxl_dumb.c
@@ -23,6 +23,8 @@
  *          Alon Levy
  */
 
+#include <drm/drm_dumb_buffers.h>
+
 #include "qxl_drv.h"
 #include "qxl_object.h"
 
@@ -35,14 +37,13 @@ int qxl_mode_dumb_create(struct drm_file *file_priv,
        struct qxl_device *qdev = to_qxl(dev);
        struct qxl_bo *qobj;
        struct drm_gem_object *gobj;
-       uint32_t handle;
        int r;
        struct qxl_surface surf;
-       uint32_t pitch, format;
+       u32 format;
 
-       pitch = args->width * ((args->bpp + 1) / 8);
-       args->size = pitch * args->height;
-       args->size = ALIGN(args->size, PAGE_SIZE);
+       r = drm_mode_size_dumb(dev, args, 0, 0);
+       if (r)
+               return r;
 
        switch (args->bpp) {
        case 16:
@@ -57,20 +58,18 @@ int qxl_mode_dumb_create(struct drm_file *file_priv,
 
        surf.width = args->width;
        surf.height = args->height;
-       surf.stride = pitch;
+       surf.stride = args->pitch;
        surf.format = format;
        surf.data = 0;
 
        r = qxl_gem_object_create_with_handle(qdev, file_priv,
                                              QXL_GEM_DOMAIN_CPU,
                                              args->size, &surf, &gobj,
-                                             &handle);
+                                             &args->handle);
        if (r)
                return r;
        qobj = gem_to_qxl_bo(gobj);
        qobj->is_dumb = true;
        drm_gem_object_put(gobj);
-       args->pitch = pitch;
-       args->handle = handle;
        return 0;
 }
-- 
2.47.1




 


Rackspace

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