[Mesa-dev] [PATCH 08/13] egl: implement eglQueryDmaBufFormatsEXT
Emil Velikov
emil.l.velikov at gmail.com
Fri Nov 18 14:58:15 UTC 2016
On 15 November 2016 at 14:24, Varad Gautam <varadgautam at gmail.com> wrote:
> 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 | 87 +++++++++++++++++++++++++++++++++++++++++
> src/egl/main/eglapi.c | 19 +++++++++
> src/egl/main/eglapi.h | 4 ++
> 3 files changed, 110 insertions(+)
>
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index 4eb1861..de2d4df 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -78,6 +78,68 @@ const __DRIuseInvalidateExtension use_invalidate = {
> .base = { __DRI_USE_INVALIDATE, 1 }
> };
>
> +static const EGLint dma_buf_formats[] = {
> + DRM_FORMAT_R8,
> + DRM_FORMAT_RG88,
> + DRM_FORMAT_GR88,
> + DRM_FORMAT_RGB332,
> + DRM_FORMAT_BGR233,
> + DRM_FORMAT_XRGB4444,
> + DRM_FORMAT_XBGR4444,
> + DRM_FORMAT_RGBX4444,
> + DRM_FORMAT_BGRX4444,
> + DRM_FORMAT_ARGB4444,
> + DRM_FORMAT_ABGR4444,
> + DRM_FORMAT_RGBA4444,
> + DRM_FORMAT_BGRA4444,
> + DRM_FORMAT_XRGB1555,
> + DRM_FORMAT_XBGR1555,
> + DRM_FORMAT_RGBX5551,
> + DRM_FORMAT_BGRX5551,
> + DRM_FORMAT_ARGB1555,
> + DRM_FORMAT_ABGR1555,
> + DRM_FORMAT_RGBA5551,
> + DRM_FORMAT_BGRA5551,
> + DRM_FORMAT_RGB565,
> + DRM_FORMAT_BGR565,
> + DRM_FORMAT_RGB888,
> + DRM_FORMAT_BGR888,
> + DRM_FORMAT_XRGB8888,
> + DRM_FORMAT_XBGR8888,
> + DRM_FORMAT_RGBX8888,
> + DRM_FORMAT_BGRX8888,
> + DRM_FORMAT_ARGB8888,
> + DRM_FORMAT_ABGR8888,
> + DRM_FORMAT_RGBA8888,
> + DRM_FORMAT_BGRA8888,
> + DRM_FORMAT_XRGB2101010,
> + DRM_FORMAT_XBGR2101010,
> + DRM_FORMAT_RGBX1010102,
> + DRM_FORMAT_BGRX1010102,
> + DRM_FORMAT_ARGB2101010,
> + DRM_FORMAT_ABGR2101010,
> + DRM_FORMAT_RGBA1010102,
> + DRM_FORMAT_BGRA1010102,
> + DRM_FORMAT_YUYV,
> + DRM_FORMAT_YVYU,
> + DRM_FORMAT_UYVY,
> + DRM_FORMAT_VYUY,
> + DRM_FORMAT_NV12,
> + DRM_FORMAT_NV21,
> + DRM_FORMAT_NV16,
> + DRM_FORMAT_NV61,
> + DRM_FORMAT_YUV410,
> + DRM_FORMAT_YVU410,
> + DRM_FORMAT_YUV411,
> + DRM_FORMAT_YVU411,
> + DRM_FORMAT_YUV420,
> + DRM_FORMAT_YVU420,
> + DRM_FORMAT_YUV422,
> + DRM_FORMAT_YVU422,
> + DRM_FORMAT_YUV444,
> + DRM_FORMAT_YVU444
> +};
> +
> EGLint dri2_to_egl_attribute_map[] = {
> 0,
> EGL_BUFFER_SIZE, /* __DRI_ATTRIB_BUFFER_SIZE */
> @@ -2069,6 +2131,30 @@ 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)
> +{
> + EGLint i;
> +
> + if (max < 0 || (max > 0 && formats == NULL)) {
> + _eglError(EGL_BAD_PARAMETER, "invalid value for max count of formats");
> + return EGL_FALSE;
> + }
> +
> + if (max == 0) {
> + *count = ARRAY_SIZE(dma_buf_formats);
> + return EGL_TRUE;
> + }
> +
> + for (i = 0; i < ARRAY_SIZE(dma_buf_formats) && i < max; i++) {
> + formats[i] = dma_buf_formats[i];
> + }
Returning every format imaginable as supported then most drivers
(currently) support up-to half of them is very misleading.
Worth adding another DRIimage callback, reuse existing one(s) and/or
add some other heuristics ?
Emil
More information about the mesa-dev
mailing list