Mesa (staging/18.2): egl/dri2: Add a helper for the number of planes for a FOURCC format

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Aug 31 08:52:51 UTC 2018


Module: Mesa
Branch: staging/18.2
Commit: fb3303c4d764908538a9c3b7d3dbcf45147c5331
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=fb3303c4d764908538a9c3b7d3dbcf45147c5331

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Tue Aug 28 16:31:22 2018 -0500

egl/dri2: Add a helper for the number of planes for a FOURCC format

This also serves as a convenient "is this a fourcc format" check as well
which we'll take advantage of in the next commit.

Cc: mesa-stable at lists.freedesktop.org
Tested-By: Eero Tamminen <eero.t.tamminen at intel.com>
Reviewed-by: Eric Engestrom <eric.engestrom at intel.com>
(cherry picked from commit b95896f4923af820f78be6556c4cd5f4ed087f21)

---

 src/egl/drivers/dri2/egl_dri2.c | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index c3024795a1..84018d8642 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -2195,13 +2195,13 @@ dri2_check_dma_buf_attribs(const _EGLImageAttribs *attrs)
    return EGL_TRUE;
 }
 
-/* Returns the total number of file descriptors. Zero indicates an error. */
+/* Returns the total number of planes for the format or zero if it isn't a
+ * valid fourcc format.
+ */
 static unsigned
-dri2_check_dma_buf_format(const _EGLImageAttribs *attrs)
+dri2_num_fourcc_format_planes(EGLint format)
 {
-   unsigned plane_n;
-
-   switch (attrs->DMABufFourCC.Value) {
+   switch (format) {
    case DRM_FORMAT_R8:
    case DRM_FORMAT_RG88:
    case DRM_FORMAT_GR88:
@@ -2249,14 +2249,14 @@ dri2_check_dma_buf_format(const _EGLImageAttribs *attrs)
    case DRM_FORMAT_YVYU:
    case DRM_FORMAT_UYVY:
    case DRM_FORMAT_VYUY:
-      plane_n = 1;
-      break;
+      return 1;
+
    case DRM_FORMAT_NV12:
    case DRM_FORMAT_NV21:
    case DRM_FORMAT_NV16:
    case DRM_FORMAT_NV61:
-      plane_n = 2;
-      break;
+      return 2;
+
    case DRM_FORMAT_YUV410:
    case DRM_FORMAT_YVU410:
    case DRM_FORMAT_YUV411:
@@ -2267,9 +2267,19 @@ dri2_check_dma_buf_format(const _EGLImageAttribs *attrs)
    case DRM_FORMAT_YVU422:
    case DRM_FORMAT_YUV444:
    case DRM_FORMAT_YVU444:
-      plane_n = 3;
-      break;
+      return 3;
+
    default:
+      return 0;
+   }
+}
+
+/* Returns the total number of file descriptors. Zero indicates an error. */
+static unsigned
+dri2_check_dma_buf_format(const _EGLImageAttribs *attrs)
+{
+   unsigned plane_n = dri2_num_fourcc_format_planes(attrs->DMABufFourCC.Value);
+   if (plane_n == 0) {
       _eglError(EGL_BAD_ATTRIBUTE, "invalid format");
       return 0;
    }




More information about the mesa-commit mailing list