Mesa (master): gbm: Explicitly disallow a planar dumb BO

Ben Widawsky bwidawsk at kemper.freedesktop.org
Thu Mar 9 23:36:38 UTC 2017


Module: Mesa
Branch: master
Commit: 770b06588f79abe44d4fa1128759c45d0496362e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=770b06588f79abe44d4fa1128759c45d0496362e

Author: Ben Widawsky <ben at bwidawsk.net>
Date:   Tue Mar  7 15:06:23 2017 -0800

gbm: Explicitly disallow a planar dumb BO

As more GBM functionality support planes is being evaluated, it becomes
clear that a dumb bo can never actually be planar. It's questionable
whether it was ever feasible to do this, and later functionality will
implicitly assume a dumb BO is non-planar.

v2: Include stdbool.h

Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
Acked-by: Daniel Stone <daniels at collabora.com>

---

 src/gbm/backends/dri/gbm_dri.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index ac7ede8..3faa19e 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -29,6 +29,7 @@
 #include <stdlib.h>
 #include <stddef.h>
 #include <stdint.h>
+#include <stdbool.h>
 #include <string.h>
 #include <errno.h>
 #include <limits.h>
@@ -795,6 +796,31 @@ gbm_dri_bo_import(struct gbm_device *gbm,
    return &bo->base.base;
 }
 
+static bool
+is_planar_format(uint32_t format)
+{
+   switch (format) {
+   case GBM_FORMAT_NV12:
+   case GBM_FORMAT_NV21:
+   case GBM_FORMAT_NV16:
+   case GBM_FORMAT_NV61:
+   case GBM_FORMAT_YUV410:
+   case GBM_FORMAT_YVU410:
+   case GBM_FORMAT_YUV411:
+   case GBM_FORMAT_YVU411:
+   case GBM_FORMAT_YUV420:
+   case GBM_FORMAT_YVU420:
+   case GBM_FORMAT_YUV422:
+   case GBM_FORMAT_YVU422:
+   case GBM_FORMAT_YUV444:
+   case GBM_FORMAT_YVU444:
+      return true;
+   default:
+      return false;
+   }
+
+}
+
 static struct gbm_bo *
 create_dumb(struct gbm_device *gbm,
                   uint32_t width, uint32_t height,
@@ -816,6 +842,11 @@ create_dumb(struct gbm_device *gbm,
       return NULL;
    }
 
+   if (is_planar_format(format)) {
+      errno = EINVAL;
+      return NULL;
+   }
+
    bo = calloc(1, sizeof *bo);
    if (bo == NULL)
       return NULL;




More information about the mesa-commit mailing list