diff mbox

[libdrm] omap: fix omap_bo_size for tiled buffers

Message ID 1495608011-6439-1-git-send-email-tomi.valkeinen@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tomi Valkeinen May 24, 2017, 6:40 a.m. UTC
The buffer size is calculated using pixels, not bytes as it should. The
result is often correct, though, as the stride is aligned to page size,
but there are still many cases where the size ends up being wrong.

Fix this by not calculating the size at all, as in that case
DRM_OMAP_GEM_INFO ioctl is used to get the correct size from the kernel.
This is better in any case as then the userspace library doesn't need to
know how the tiled buffers need to be aligned.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 omap/omap_drm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/omap/omap_drm.c b/omap/omap_drm.c
index 08ba64e..a6f8a21 100644
--- a/omap/omap_drm.c
+++ b/omap/omap_drm.c
@@ -215,11 +215,9 @@  static struct omap_bo * omap_bo_new_impl(struct omap_device *dev,
 	bo = bo_from_handle(dev, req.handle);
 	pthread_mutex_unlock(&table_lock);
 
-	if (flags & OMAP_BO_TILED) {
-		bo->size = round_up(size.tiled.width, PAGE_SIZE) * size.tiled.height;
-	} else {
+	/* for tiled buffers we get the size with DRM_OMAP_GEM_INFO later */
+	if (!(flags & OMAP_BO_TILED))
 		bo->size = size.bytes;
-	}
 
 	return bo;