[Mesa-dev] [PATCH v2 11/14] egl: implement eglQueryDmaBufFormatsEXT

Varad Gautam varadgautam at gmail.com
Thu Nov 24 15:20:48 UTC 2016


From: Varad Gautam <varad.gautam at collabora.com>

allow egl clients to query the dmabuf formats supported on this platform.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Signed-off-by: Varad Gautam <varad.gautam at collabora.com>
---
 src/egl/drivers/dri2/egl_dri2.c | 17 +++++++++++++++++
 src/egl/main/eglapi.c           | 19 +++++++++++++++++++
 src/egl/main/eglapi.h           |  4 ++++
 3 files changed, 40 insertions(+)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 4589d9f..bae7da8 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -2081,6 +2081,22 @@ dri2_check_dma_buf_format(const _EGLImageAttribs *attrs)
    return plane_n;
 }
 
+static EGLBoolean
+dri2_query_dma_buf_formats(_EGLDriver *drv, _EGLDisplay *disp,
+                            EGLint max, EGLint *formats, EGLint *count)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+   if (max < 0 || (max > 0 && formats == NULL)) {
+      _eglError(EGL_BAD_PARAMETER, "invalid value for max count of formats");
+      return EGL_FALSE;
+   }
+
+   dri2_dpy->image->queryDmaBufFormats(dri2_dpy->dri_screen, max, formats,
+                                       count);
+
+   return EGL_TRUE;
+}
+
 /**
  * The spec says:
  *
@@ -2964,6 +2980,7 @@ _eglBuiltInDriverDRI2(const char *args)
    dri2_drv->base.API.ExportDRMImageMESA = dri2_export_drm_image_mesa;
    dri2_drv->base.API.ExportDMABUFImageQueryMESA = dri2_export_dma_buf_image_query_mesa;
    dri2_drv->base.API.ExportDMABUFImageMESA = dri2_export_dma_buf_image_mesa;
+   dri2_drv->base.API.QueryDmaBufFormatsEXT = dri2_query_dma_buf_formats;
 #endif
 #ifdef HAVE_WAYLAND_PLATFORM
    dri2_drv->base.API.BindWaylandDisplayWL = dri2_bind_wayland_display_wl;
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 53340bf..53d34d8 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -2257,6 +2257,24 @@ eglQueryDebugKHR(EGLint attribute, EGLAttrib *value)
    return EGL_TRUE;
 }
 
+static EGLBoolean EGLAPIENTRY
+eglQueryDmaBufFormatsEXT(EGLDisplay dpy, EGLint max_formats,
+                         EGLint *formats, EGLint *num_formats)
+{
+   _EGLDisplay *disp = _eglLockDisplay(dpy);
+   _EGLDriver *drv;
+   EGLBoolean ret;
+
+   _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_FALSE);
+
+   _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
+
+   ret = drv->API.QueryDmaBufFormatsEXT(drv, disp, max_formats, formats,
+                                        num_formats);
+
+   RETURN_EGL_EVAL(disp, ret);
+}
+
 __eglMustCastToProperFunctionPointerType EGLAPIENTRY
 eglGetProcAddress(const char *procname)
 {
@@ -2340,6 +2358,7 @@ eglGetProcAddress(const char *procname)
       { "eglLabelObjectKHR", (_EGLProc) eglLabelObjectKHR },
       { "eglDebugMessageControlKHR", (_EGLProc) eglDebugMessageControlKHR },
       { "eglQueryDebugKHR", (_EGLProc) eglQueryDebugKHR },
+      { "eglQueryDmaBufFormatsEXT", (_EGLProc) eglQueryDmaBufFormatsEXT },
       { NULL, NULL }
    };
    EGLint i;
diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h
index b9bcc8e..13388b1 100644
--- a/src/egl/main/eglapi.h
+++ b/src/egl/main/eglapi.h
@@ -196,6 +196,10 @@ struct _egl_api
    int (*GLInteropExportObject)(_EGLDisplay *dpy, _EGLContext *ctx,
                                 struct mesa_glinterop_export_in *in,
                                 struct mesa_glinterop_export_out *out);
+
+   EGLBoolean (*QueryDmaBufFormatsEXT)(_EGLDriver *drv, _EGLDisplay *dpy,
+                                       EGLint max_formats, EGLint *formats,
+                                       EGLint *num_formats);
 };
 
 EGLint _eglConvertIntsToAttribs(const EGLint *int_list,
-- 
2.6.2



More information about the mesa-dev mailing list