egl/android: remove flink name support

Submitted by Rob Herring on April 19, 2018, 9:09 p.m.

Details

Message ID 20180419210921.20423-1-robh@kernel.org
State New
Headers show
Series "egl/android: remove flink name support" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Rob Herring April 19, 2018, 9:09 p.m.
Maintaining both flink names and prime fd support which are provided by
2 different gralloc implementations is problematic because we have a
dependency on a specific gralloc implementation header.

This mostly removes the dependency on the gralloc implementation and
headers. The dependency on GRALLOC_MODULE_PERFORM_GET_DRM_FD remains for
now, but the definition is added locally to remove the header
dependency.

Signed-off-by: Rob Herring <robh@kernel.org>
---
With this plus Robert's probing patch, we remove any gralloc 
implementation dependency (other than it has to be a pre 1.0 
implementation...).

 src/egl/drivers/dri2/egl_dri2.h         |   1 -
 src/egl/drivers/dri2/platform_android.c | 172 ++++----------------------------
 2 files changed, 17 insertions(+), 156 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index cc76c73eab2f..d9e1f466fbeb 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -61,7 +61,6 @@  struct zwp_linux_dmabuf_v1;
 
 #include <system/window.h>
 #include <hardware/gralloc.h>
-#include <gralloc_drm_handle.h>
 
 #endif /* HAVE_ANDROID_PLATFORM */
 
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index 4f25cb746915..68c85d7f99fa 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -37,7 +37,6 @@ 
 #include "loader.h"
 #include "egl_dri2.h"
 #include "egl_dri2_fallbacks.h"
-#include "gralloc_drm.h"
 
 #define ALIGN(val, align)	(((val) + (align) - 1) & ~((align) - 1))
 
@@ -164,12 +163,6 @@  get_native_buffer_fd(struct ANativeWindowBuffer *buf)
    return (handle && handle->numFds) ? handle->data[0] : -1;
 }
 
-static int
-get_native_buffer_name(struct ANativeWindowBuffer *buf)
-{
-   return gralloc_drm_get_gem_handle(buf->handle);
-}
-
 static EGLBoolean
 droid_window_dequeue_buffer(struct dri2_egl_surface *dri2_surf)
 {
@@ -822,50 +815,6 @@  droid_create_image_from_prime_fd(_EGLDisplay *disp, _EGLContext *ctx,
    return dri2_create_image_dma_buf(disp, ctx, NULL, attr_list);
 }
 
-static _EGLImage *
-droid_create_image_from_name(_EGLDisplay *disp, _EGLContext *ctx,
-                             struct ANativeWindowBuffer *buf)
-{
-   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
-   struct dri2_egl_image *dri2_img;
-   int name;
-   int format;
-
-   name = get_native_buffer_name(buf);
-   if (!name) {
-      _eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR");
-      return NULL;
-   }
-
-   format = get_format(buf->format);
-   if (format == -1)
-       return NULL;
-
-   dri2_img = calloc(1, sizeof(*dri2_img));
-   if (!dri2_img) {
-      _eglError(EGL_BAD_ALLOC, "droid_create_image_mesa_drm");
-      return NULL;
-   }
-
-   _eglInitImage(&dri2_img->base, disp);
-
-   dri2_img->dri_image =
-      dri2_dpy->image->createImageFromName(dri2_dpy->dri_screen,
-					   buf->width,
-					   buf->height,
-					   format,
-					   name,
-					   buf->stride,
-					   dri2_img);
-   if (!dri2_img->dri_image) {
-      free(dri2_img);
-      _eglError(EGL_BAD_ALLOC, "droid_create_image_mesa_drm");
-      return NULL;
-   }
-
-   return &dri2_img->base;
-}
-
 static EGLBoolean
 droid_query_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
                     EGLint attribute, EGLint *value)
@@ -921,7 +870,7 @@  dri2_create_image_android_native_buffer(_EGLDisplay *disp,
    if (fd >= 0)
       return droid_create_image_from_prime_fd(disp, ctx, buf, fd);
 
-   return droid_create_image_from_name(disp, ctx, buf);
+   return NULL;
 }
 
 static _EGLImage *
@@ -943,82 +892,6 @@  droid_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate)
 {
 }
 
-static int
-droid_get_buffers_parse_attachments(struct dri2_egl_surface *dri2_surf,
-                                    unsigned int *attachments, int count)
-{
-   int num_buffers = 0;
-
-   /* fill dri2_surf->buffers */
-   for (int i = 0; i < count * 2; i += 2) {
-      __DRIbuffer *buf, *local;
-
-      assert(num_buffers < ARRAY_SIZE(dri2_surf->buffers));
-      buf = &dri2_surf->buffers[num_buffers];
-
-      switch (attachments[i]) {
-      case __DRI_BUFFER_BACK_LEFT:
-         if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
-            buf->attachment = attachments[i];
-            buf->name = get_native_buffer_name(dri2_surf->buffer);
-            buf->cpp = get_format_bpp(dri2_surf->buffer->format);
-            buf->pitch = dri2_surf->buffer->stride * buf->cpp;
-            buf->flags = 0;
-
-            if (buf->name)
-               num_buffers++;
-
-            break;
-         }
-         /* fall through for pbuffers */
-      case __DRI_BUFFER_DEPTH:
-      case __DRI_BUFFER_STENCIL:
-      case __DRI_BUFFER_ACCUM:
-      case __DRI_BUFFER_DEPTH_STENCIL:
-      case __DRI_BUFFER_HIZ:
-         local = dri2_egl_surface_alloc_local_buffer(dri2_surf,
-               attachments[i], attachments[i + 1]);
-
-         if (local) {
-            *buf = *local;
-            num_buffers++;
-         }
-         break;
-      case __DRI_BUFFER_FRONT_LEFT:
-      case __DRI_BUFFER_FRONT_RIGHT:
-      case __DRI_BUFFER_FAKE_FRONT_LEFT:
-      case __DRI_BUFFER_FAKE_FRONT_RIGHT:
-      case __DRI_BUFFER_BACK_RIGHT:
-      default:
-         /* no front or right buffers */
-         break;
-      }
-   }
-
-   return num_buffers;
-}
-
-static __DRIbuffer *
-droid_get_buffers_with_format(__DRIdrawable * driDrawable,
-			     int *width, int *height,
-			     unsigned int *attachments, int count,
-			     int *out_count, void *loaderPrivate)
-{
-   struct dri2_egl_surface *dri2_surf = loaderPrivate;
-
-   if (update_buffers(dri2_surf) < 0)
-      return NULL;
-
-   *out_count = droid_get_buffers_parse_attachments(dri2_surf, attachments, count);
-
-   if (width)
-      *width = dri2_surf->base.Width;
-   if (height)
-      *height = dri2_surf->base.Height;
-
-   return dri2_surf->buffers;
-}
-
 static unsigned
 droid_get_capability(void *loaderPrivate, enum dri_loader_cap cap)
 {
@@ -1100,6 +973,14 @@  droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *dpy)
    return (config_count != 0);
 }
 
+enum {
+        /* perform(const struct gralloc_module_t *mod,
+         *         int op,
+         *         int *fd);
+         */
+        GRALLOC_MODULE_PERFORM_GET_DRM_FD                = 0x40000002,
+};
+
 static int
 droid_open_device(struct dri2_egl_display *dri2_dpy)
 {
@@ -1141,15 +1022,6 @@  static const struct dri2_egl_display_vtbl droid_display_vtbl = {
    .get_dri_drawable = dri2_surface_get_dri_drawable,
 };
 
-static const __DRIdri2LoaderExtension droid_dri2_loader_extension = {
-   .base = { __DRI_DRI2_LOADER, 4 },
-
-   .getBuffers           = NULL,
-   .flushFrontBuffer     = droid_flush_front_buffer,
-   .getBuffersWithFormat = droid_get_buffers_with_format,
-   .getCapability        = droid_get_capability,
-};
-
 static const __DRIimageLoaderExtension droid_image_loader_extension = {
    .base = { __DRI_IMAGE_LOADER, 2 },
 
@@ -1158,13 +1030,6 @@  static const __DRIimageLoaderExtension droid_image_loader_extension = {
    .getCapability       = droid_get_capability,
 };
 
-static const __DRIextension *droid_dri2_loader_extensions[] = {
-   &droid_dri2_loader_extension.base,
-   &image_lookup_extension.base,
-   &use_invalidate.base,
-   NULL,
-};
-
 static const __DRIextension *droid_image_loader_extensions[] = {
    &droid_image_loader_extension.base,
    &image_lookup_extension.base,
@@ -1216,17 +1081,14 @@  dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp)
    /* render nodes cannot use Gem names, and thus do not support
     * the __DRI_DRI2_LOADER extension */
    if (!dri2_dpy->is_render_node) {
-      dri2_dpy->loader_extensions = droid_dri2_loader_extensions;
-      if (!dri2_load_driver(disp)) {
-         err = "DRI2: failed to load driver";
-         goto cleanup;
-      }
-   } else {
-      dri2_dpy->loader_extensions = droid_image_loader_extensions;
-      if (!dri2_load_driver_dri3(disp)) {
-         err = "DRI3: failed to load driver";
-         goto cleanup;
-      }
+      err = "DRI2: driver is not a render node";
+      goto cleanup;
+   }
+
+   dri2_dpy->loader_extensions = droid_image_loader_extensions;
+   if (!dri2_load_driver_dri3(disp)) {
+      err = "DRI3: failed to load driver";
+      goto cleanup;
    }
 
    if (!dri2_create_screen(disp)) {

Comments

Hi Rob,

On Fri, Apr 20, 2018 at 6:09 AM Rob Herring <robh@kernel.org> wrote:

> Maintaining both flink names and prime fd support which are provided by
> 2 different gralloc implementations is problematic because we have a
> dependency on a specific gralloc implementation header.

> This mostly removes the dependency on the gralloc implementation and
> headers. The dependency on GRALLOC_MODULE_PERFORM_GET_DRM_FD remains for
> now, but the definition is added locally to remove the header
> dependency.

> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
> With this plus Robert's probing patch, we remove any gralloc
> implementation dependency (other than it has to be a pre 1.0
> implementation...).

Big

Acked-by: Tomasz Figa <tfiga@chromium.org>

from me. +/- 1 nit inline

This relic of the past should have disappeared long ago, together with all
the problems it brings. :)

[snip]
> @@ -1216,17 +1081,14 @@ dri2_initialize_android(_EGLDriver *drv,
_EGLDisplay *disp)
>      /* render nodes cannot use Gem names, and thus do not support
>       * the __DRI_DRI2_LOADER extension */
>      if (!dri2_dpy->is_render_node) {
> -      dri2_dpy->loader_extensions = droid_dri2_loader_extensions;
> -      if (!dri2_load_driver(disp)) {
> -         err = "DRI2: failed to load driver";
> -         goto cleanup;
> -      }
> -   } else {
> -      dri2_dpy->loader_extensions = droid_image_loader_extensions;
> -      if (!dri2_load_driver_dri3(disp)) {
> -         err = "DRI3: failed to load driver";
> -         goto cleanup;
> -      }
> +      err = "DRI2: driver is not a render node";

Perhaps "device" or "handle" rather than "driver"?

Best regards,
Tomasz
Hey Rob,

This looks good to me.
Do you mind if I carry this patch my series to get it all pushed upstream at once?


Rob.

On 04/19/2018 11:09 PM, Rob Herring wrote:
> Maintaining both flink names and prime fd support which are provided by
> 2 different gralloc implementations is problematic because we have a
> dependency on a specific gralloc implementation header.
> 
> This mostly removes the dependency on the gralloc implementation and
> headers. The dependency on GRALLOC_MODULE_PERFORM_GET_DRM_FD remains for
> now, but the definition is added locally to remove the header
> dependency.
> 
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
> With this plus Robert's probing patch, we remove any gralloc
> implementation dependency (other than it has to be a pre 1.0
> implementation...).
> 
>   src/egl/drivers/dri2/egl_dri2.h         |   1 -
>   src/egl/drivers/dri2/platform_android.c | 172 ++++----------------------------
>   2 files changed, 17 insertions(+), 156 deletions(-)
> 
> diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
> index cc76c73eab2f..d9e1f466fbeb 100644
> --- a/src/egl/drivers/dri2/egl_dri2.h
> +++ b/src/egl/drivers/dri2/egl_dri2.h
> @@ -61,7 +61,6 @@ struct zwp_linux_dmabuf_v1;
>   
>   #include <system/window.h>
>   #include <hardware/gralloc.h>
> -#include <gralloc_drm_handle.h>
>   
>   #endif /* HAVE_ANDROID_PLATFORM */
>   
> diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
> index 4f25cb746915..68c85d7f99fa 100644
> --- a/src/egl/drivers/dri2/platform_android.c
> +++ b/src/egl/drivers/dri2/platform_android.c
> @@ -37,7 +37,6 @@
>   #include "loader.h"
>   #include "egl_dri2.h"
>   #include "egl_dri2_fallbacks.h"
> -#include "gralloc_drm.h"
>   
>   #define ALIGN(val, align)	(((val) + (align) - 1) & ~((align) - 1))
>   
> @@ -164,12 +163,6 @@ get_native_buffer_fd(struct ANativeWindowBuffer *buf)
>      return (handle && handle->numFds) ? handle->data[0] : -1;
>   }
>   
> -static int
> -get_native_buffer_name(struct ANativeWindowBuffer *buf)
> -{
> -   return gralloc_drm_get_gem_handle(buf->handle);
> -}
> -
>   static EGLBoolean
>   droid_window_dequeue_buffer(struct dri2_egl_surface *dri2_surf)
>   {
> @@ -822,50 +815,6 @@ droid_create_image_from_prime_fd(_EGLDisplay *disp, _EGLContext *ctx,
>      return dri2_create_image_dma_buf(disp, ctx, NULL, attr_list);
>   }
>   
> -static _EGLImage *
> -droid_create_image_from_name(_EGLDisplay *disp, _EGLContext *ctx,
> -                             struct ANativeWindowBuffer *buf)
> -{
> -   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
> -   struct dri2_egl_image *dri2_img;
> -   int name;
> -   int format;
> -
> -   name = get_native_buffer_name(buf);
> -   if (!name) {
> -      _eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR");
> -      return NULL;
> -   }
> -
> -   format = get_format(buf->format);
> -   if (format == -1)
> -       return NULL;
> -
> -   dri2_img = calloc(1, sizeof(*dri2_img));
> -   if (!dri2_img) {
> -      _eglError(EGL_BAD_ALLOC, "droid_create_image_mesa_drm");
> -      return NULL;
> -   }
> -
> -   _eglInitImage(&dri2_img->base, disp);
> -
> -   dri2_img->dri_image =
> -      dri2_dpy->image->createImageFromName(dri2_dpy->dri_screen,
> -					   buf->width,
> -					   buf->height,
> -					   format,
> -					   name,
> -					   buf->stride,
> -					   dri2_img);
> -   if (!dri2_img->dri_image) {
> -      free(dri2_img);
> -      _eglError(EGL_BAD_ALLOC, "droid_create_image_mesa_drm");
> -      return NULL;
> -   }
> -
> -   return &dri2_img->base;
> -}
> -
>   static EGLBoolean
>   droid_query_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
>                       EGLint attribute, EGLint *value)
> @@ -921,7 +870,7 @@ dri2_create_image_android_native_buffer(_EGLDisplay *disp,
>      if (fd >= 0)
>         return droid_create_image_from_prime_fd(disp, ctx, buf, fd);
>   
> -   return droid_create_image_from_name(disp, ctx, buf);
> +   return NULL;
>   }
>   
>   static _EGLImage *
> @@ -943,82 +892,6 @@ droid_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate)
>   {
>   }
>   
> -static int
> -droid_get_buffers_parse_attachments(struct dri2_egl_surface *dri2_surf,
> -                                    unsigned int *attachments, int count)
> -{
> -   int num_buffers = 0;
> -
> -   /* fill dri2_surf->buffers */
> -   for (int i = 0; i < count * 2; i += 2) {
> -      __DRIbuffer *buf, *local;
> -
> -      assert(num_buffers < ARRAY_SIZE(dri2_surf->buffers));
> -      buf = &dri2_surf->buffers[num_buffers];
> -
> -      switch (attachments[i]) {
> -      case __DRI_BUFFER_BACK_LEFT:
> -         if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
> -            buf->attachment = attachments[i];
> -            buf->name = get_native_buffer_name(dri2_surf->buffer);
> -            buf->cpp = get_format_bpp(dri2_surf->buffer->format);
> -            buf->pitch = dri2_surf->buffer->stride * buf->cpp;
> -            buf->flags = 0;
> -
> -            if (buf->name)
> -               num_buffers++;
> -
> -            break;
> -         }
> -         /* fall through for pbuffers */
> -      case __DRI_BUFFER_DEPTH:
> -      case __DRI_BUFFER_STENCIL:
> -      case __DRI_BUFFER_ACCUM:
> -      case __DRI_BUFFER_DEPTH_STENCIL:
> -      case __DRI_BUFFER_HIZ:
> -         local = dri2_egl_surface_alloc_local_buffer(dri2_surf,
> -               attachments[i], attachments[i + 1]);
> -
> -         if (local) {
> -            *buf = *local;
> -            num_buffers++;
> -         }
> -         break;
> -      case __DRI_BUFFER_FRONT_LEFT:
> -      case __DRI_BUFFER_FRONT_RIGHT:
> -      case __DRI_BUFFER_FAKE_FRONT_LEFT:
> -      case __DRI_BUFFER_FAKE_FRONT_RIGHT:
> -      case __DRI_BUFFER_BACK_RIGHT:
> -      default:
> -         /* no front or right buffers */
> -         break;
> -      }
> -   }
> -
> -   return num_buffers;
> -}
> -
> -static __DRIbuffer *
> -droid_get_buffers_with_format(__DRIdrawable * driDrawable,
> -			     int *width, int *height,
> -			     unsigned int *attachments, int count,
> -			     int *out_count, void *loaderPrivate)
> -{
> -   struct dri2_egl_surface *dri2_surf = loaderPrivate;
> -
> -   if (update_buffers(dri2_surf) < 0)
> -      return NULL;
> -
> -   *out_count = droid_get_buffers_parse_attachments(dri2_surf, attachments, count);
> -
> -   if (width)
> -      *width = dri2_surf->base.Width;
> -   if (height)
> -      *height = dri2_surf->base.Height;
> -
> -   return dri2_surf->buffers;
> -}
> -
>   static unsigned
>   droid_get_capability(void *loaderPrivate, enum dri_loader_cap cap)
>   {
> @@ -1100,6 +973,14 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *dpy)
>      return (config_count != 0);
>   }
>   
> +enum {
> +        /* perform(const struct gralloc_module_t *mod,
> +         *         int op,
> +         *         int *fd);
> +         */
> +        GRALLOC_MODULE_PERFORM_GET_DRM_FD                = 0x40000002,
> +};
> +
>   static int
>   droid_open_device(struct dri2_egl_display *dri2_dpy)
>   {
> @@ -1141,15 +1022,6 @@ static const struct dri2_egl_display_vtbl droid_display_vtbl = {
>      .get_dri_drawable = dri2_surface_get_dri_drawable,
>   };
>   
> -static const __DRIdri2LoaderExtension droid_dri2_loader_extension = {
> -   .base = { __DRI_DRI2_LOADER, 4 },
> -
> -   .getBuffers           = NULL,
> -   .flushFrontBuffer     = droid_flush_front_buffer,
> -   .getBuffersWithFormat = droid_get_buffers_with_format,
> -   .getCapability        = droid_get_capability,
> -};
> -
>   static const __DRIimageLoaderExtension droid_image_loader_extension = {
>      .base = { __DRI_IMAGE_LOADER, 2 },
>   
> @@ -1158,13 +1030,6 @@ static const __DRIimageLoaderExtension droid_image_loader_extension = {
>      .getCapability       = droid_get_capability,
>   };
>   
> -static const __DRIextension *droid_dri2_loader_extensions[] = {
> -   &droid_dri2_loader_extension.base,
> -   &image_lookup_extension.base,
> -   &use_invalidate.base,
> -   NULL,
> -};
> -
>   static const __DRIextension *droid_image_loader_extensions[] = {
>      &droid_image_loader_extension.base,
>      &image_lookup_extension.base,
> @@ -1216,17 +1081,14 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp)
>      /* render nodes cannot use Gem names, and thus do not support
>       * the __DRI_DRI2_LOADER extension */
>      if (!dri2_dpy->is_render_node) {
> -      dri2_dpy->loader_extensions = droid_dri2_loader_extensions;
> -      if (!dri2_load_driver(disp)) {
> -         err = "DRI2: failed to load driver";
> -         goto cleanup;
> -      }
> -   } else {
> -      dri2_dpy->loader_extensions = droid_image_loader_extensions;
> -      if (!dri2_load_driver_dri3(disp)) {
> -         err = "DRI3: failed to load driver";
> -         goto cleanup;
> -      }
> +      err = "DRI2: driver is not a render node";
> +      goto cleanup;
> +   }
> +
> +   dri2_dpy->loader_extensions = droid_image_loader_extensions;
> +   if (!dri2_load_driver_dri3(disp)) {
> +      err = "DRI3: failed to load driver";
> +      goto cleanup;
>      }
>   
>      if (!dri2_create_screen(disp)) {
>
On Fri, Apr 20, 2018 at 6:29 AM, Robert Foss <robert.foss@collabora.com> wrote:
> Hey Rob,
>
> This looks good to me.
> Do you mind if I carry this patch my series to get it all pushed upstream at
> once?

No, not at all.

Rob
What's the impact to drm_gralloc?


2018-04-20 5:09 GMT+08:00 Rob Herring <robh@kernel.org>:
> Maintaining both flink names and prime fd support which are provided by
> 2 different gralloc implementations is problematic because we have a
> dependency on a specific gralloc implementation header.
>
> This mostly removes the dependency on the gralloc implementation and
> headers. The dependency on GRALLOC_MODULE_PERFORM_GET_DRM_FD remains for
> now, but the definition is added locally to remove the header
> dependency.
>
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
> With this plus Robert's probing patch, we remove any gralloc
> implementation dependency (other than it has to be a pre 1.0
> implementation...).
>
>  src/egl/drivers/dri2/egl_dri2.h         |   1 -
>  src/egl/drivers/dri2/platform_android.c | 172 ++++----------------------------
>  2 files changed, 17 insertions(+), 156 deletions(-)
>
> diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
> index cc76c73eab2f..d9e1f466fbeb 100644
> --- a/src/egl/drivers/dri2/egl_dri2.h
> +++ b/src/egl/drivers/dri2/egl_dri2.h
> @@ -61,7 +61,6 @@ struct zwp_linux_dmabuf_v1;
>
>  #include <system/window.h>
>  #include <hardware/gralloc.h>
> -#include <gralloc_drm_handle.h>
>
>  #endif /* HAVE_ANDROID_PLATFORM */
>
> diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
> index 4f25cb746915..68c85d7f99fa 100644
> --- a/src/egl/drivers/dri2/platform_android.c
> +++ b/src/egl/drivers/dri2/platform_android.c
> @@ -37,7 +37,6 @@
>  #include "loader.h"
>  #include "egl_dri2.h"
>  #include "egl_dri2_fallbacks.h"
> -#include "gralloc_drm.h"
>
>  #define ALIGN(val, align)      (((val) + (align) - 1) & ~((align) - 1))
>
> @@ -164,12 +163,6 @@ get_native_buffer_fd(struct ANativeWindowBuffer *buf)
>     return (handle && handle->numFds) ? handle->data[0] : -1;
>  }
>
> -static int
> -get_native_buffer_name(struct ANativeWindowBuffer *buf)
> -{
> -   return gralloc_drm_get_gem_handle(buf->handle);
> -}
> -
>  static EGLBoolean
>  droid_window_dequeue_buffer(struct dri2_egl_surface *dri2_surf)
>  {
> @@ -822,50 +815,6 @@ droid_create_image_from_prime_fd(_EGLDisplay *disp, _EGLContext *ctx,
>     return dri2_create_image_dma_buf(disp, ctx, NULL, attr_list);
>  }
>
> -static _EGLImage *
> -droid_create_image_from_name(_EGLDisplay *disp, _EGLContext *ctx,
> -                             struct ANativeWindowBuffer *buf)
> -{
> -   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
> -   struct dri2_egl_image *dri2_img;
> -   int name;
> -   int format;
> -
> -   name = get_native_buffer_name(buf);
> -   if (!name) {
> -      _eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR");
> -      return NULL;
> -   }
> -
> -   format = get_format(buf->format);
> -   if (format == -1)
> -       return NULL;
> -
> -   dri2_img = calloc(1, sizeof(*dri2_img));
> -   if (!dri2_img) {
> -      _eglError(EGL_BAD_ALLOC, "droid_create_image_mesa_drm");
> -      return NULL;
> -   }
> -
> -   _eglInitImage(&dri2_img->base, disp);
> -
> -   dri2_img->dri_image =
> -      dri2_dpy->image->createImageFromName(dri2_dpy->dri_screen,
> -                                          buf->width,
> -                                          buf->height,
> -                                          format,
> -                                          name,
> -                                          buf->stride,
> -                                          dri2_img);
> -   if (!dri2_img->dri_image) {
> -      free(dri2_img);
> -      _eglError(EGL_BAD_ALLOC, "droid_create_image_mesa_drm");
> -      return NULL;
> -   }
> -
> -   return &dri2_img->base;
> -}
> -
>  static EGLBoolean
>  droid_query_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
>                      EGLint attribute, EGLint *value)
> @@ -921,7 +870,7 @@ dri2_create_image_android_native_buffer(_EGLDisplay *disp,
>     if (fd >= 0)
>        return droid_create_image_from_prime_fd(disp, ctx, buf, fd);
>
> -   return droid_create_image_from_name(disp, ctx, buf);
> +   return NULL;
>  }
>
>  static _EGLImage *
> @@ -943,82 +892,6 @@ droid_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate)
>  {
>  }
>
> -static int
> -droid_get_buffers_parse_attachments(struct dri2_egl_surface *dri2_surf,
> -                                    unsigned int *attachments, int count)
> -{
> -   int num_buffers = 0;
> -
> -   /* fill dri2_surf->buffers */
> -   for (int i = 0; i < count * 2; i += 2) {
> -      __DRIbuffer *buf, *local;
> -
> -      assert(num_buffers < ARRAY_SIZE(dri2_surf->buffers));
> -      buf = &dri2_surf->buffers[num_buffers];
> -
> -      switch (attachments[i]) {
> -      case __DRI_BUFFER_BACK_LEFT:
> -         if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
> -            buf->attachment = attachments[i];
> -            buf->name = get_native_buffer_name(dri2_surf->buffer);
> -            buf->cpp = get_format_bpp(dri2_surf->buffer->format);
> -            buf->pitch = dri2_surf->buffer->stride * buf->cpp;
> -            buf->flags = 0;
> -
> -            if (buf->name)
> -               num_buffers++;
> -
> -            break;
> -         }
> -         /* fall through for pbuffers */
> -      case __DRI_BUFFER_DEPTH:
> -      case __DRI_BUFFER_STENCIL:
> -      case __DRI_BUFFER_ACCUM:
> -      case __DRI_BUFFER_DEPTH_STENCIL:
> -      case __DRI_BUFFER_HIZ:
> -         local = dri2_egl_surface_alloc_local_buffer(dri2_surf,
> -               attachments[i], attachments[i + 1]);
> -
> -         if (local) {
> -            *buf = *local;
> -            num_buffers++;
> -         }
> -         break;
> -      case __DRI_BUFFER_FRONT_LEFT:
> -      case __DRI_BUFFER_FRONT_RIGHT:
> -      case __DRI_BUFFER_FAKE_FRONT_LEFT:
> -      case __DRI_BUFFER_FAKE_FRONT_RIGHT:
> -      case __DRI_BUFFER_BACK_RIGHT:
> -      default:
> -         /* no front or right buffers */
> -         break;
> -      }
> -   }
> -
> -   return num_buffers;
> -}
> -
> -static __DRIbuffer *
> -droid_get_buffers_with_format(__DRIdrawable * driDrawable,
> -                            int *width, int *height,
> -                            unsigned int *attachments, int count,
> -                            int *out_count, void *loaderPrivate)
> -{
> -   struct dri2_egl_surface *dri2_surf = loaderPrivate;
> -
> -   if (update_buffers(dri2_surf) < 0)
> -      return NULL;
> -
> -   *out_count = droid_get_buffers_parse_attachments(dri2_surf, attachments, count);
> -
> -   if (width)
> -      *width = dri2_surf->base.Width;
> -   if (height)
> -      *height = dri2_surf->base.Height;
> -
> -   return dri2_surf->buffers;
> -}
> -
>  static unsigned
>  droid_get_capability(void *loaderPrivate, enum dri_loader_cap cap)
>  {
> @@ -1100,6 +973,14 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *dpy)
>     return (config_count != 0);
>  }
>
> +enum {
> +        /* perform(const struct gralloc_module_t *mod,
> +         *         int op,
> +         *         int *fd);
> +         */
> +        GRALLOC_MODULE_PERFORM_GET_DRM_FD                = 0x40000002,
> +};
> +
>  static int
>  droid_open_device(struct dri2_egl_display *dri2_dpy)
>  {
> @@ -1141,15 +1022,6 @@ static const struct dri2_egl_display_vtbl droid_display_vtbl = {
>     .get_dri_drawable = dri2_surface_get_dri_drawable,
>  };
>
> -static const __DRIdri2LoaderExtension droid_dri2_loader_extension = {
> -   .base = { __DRI_DRI2_LOADER, 4 },
> -
> -   .getBuffers           = NULL,
> -   .flushFrontBuffer     = droid_flush_front_buffer,
> -   .getBuffersWithFormat = droid_get_buffers_with_format,
> -   .getCapability        = droid_get_capability,
> -};
> -
>  static const __DRIimageLoaderExtension droid_image_loader_extension = {
>     .base = { __DRI_IMAGE_LOADER, 2 },
>
> @@ -1158,13 +1030,6 @@ static const __DRIimageLoaderExtension droid_image_loader_extension = {
>     .getCapability       = droid_get_capability,
>  };
>
> -static const __DRIextension *droid_dri2_loader_extensions[] = {
> -   &droid_dri2_loader_extension.base,
> -   &image_lookup_extension.base,
> -   &use_invalidate.base,
> -   NULL,
> -};
> -
>  static const __DRIextension *droid_image_loader_extensions[] = {
>     &droid_image_loader_extension.base,
>     &image_lookup_extension.base,
> @@ -1216,17 +1081,14 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp)
>     /* render nodes cannot use Gem names, and thus do not support
>      * the __DRI_DRI2_LOADER extension */
>     if (!dri2_dpy->is_render_node) {
> -      dri2_dpy->loader_extensions = droid_dri2_loader_extensions;
> -      if (!dri2_load_driver(disp)) {
> -         err = "DRI2: failed to load driver";
> -         goto cleanup;
> -      }
> -   } else {
> -      dri2_dpy->loader_extensions = droid_image_loader_extensions;
> -      if (!dri2_load_driver_dri3(disp)) {
> -         err = "DRI3: failed to load driver";
> -         goto cleanup;
> -      }
> +      err = "DRI2: driver is not a render node";
> +      goto cleanup;
> +   }
> +
> +   dri2_dpy->loader_extensions = droid_image_loader_extensions;
> +   if (!dri2_load_driver_dri3(disp)) {
> +      err = "DRI3: failed to load driver";
> +      goto cleanup;
>     }
>
>     if (!dri2_create_screen(disp)) {
> --
> 2.14.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Hey Chih-Wei,

On 04/23/2018 04:17 AM, Chih-Wei Huang wrote:
> What's the impact to drm_gralloc?

I'm not terribly familiar with drm_gralloc, but as far as I understand it 
depends on flink name support at the moment.

The overarching idea here is to make mesa gralloc independent, but also at the 
same time provide some infrastructure for making the grallocs able to be separate.

I'm not sure what the best way to keep drm_gralloc support alive and at the same 
time make mesa gralloc independent is.


Rob.

> 
> 
> 2018-04-20 5:09 GMT+08:00 Rob Herring <robh@kernel.org>:
>> Maintaining both flink names and prime fd support which are provided by
>> 2 different gralloc implementations is problematic because we have a
>> dependency on a specific gralloc implementation header.
>>
>> This mostly removes the dependency on the gralloc implementation and
>> headers. The dependency on GRALLOC_MODULE_PERFORM_GET_DRM_FD remains for
>> now, but the definition is added locally to remove the header
>> dependency.
>>
>> Signed-off-by: Rob Herring <robh@kernel.org>
>> ---
>> With this plus Robert's probing patch, we remove any gralloc
>> implementation dependency (other than it has to be a pre 1.0
>> implementation...).
>>
>>   src/egl/drivers/dri2/egl_dri2.h         |   1 -
>>   src/egl/drivers/dri2/platform_android.c | 172 ++++----------------------------
>>   2 files changed, 17 insertions(+), 156 deletions(-)
>>
>> diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
>> index cc76c73eab2f..d9e1f466fbeb 100644
>> --- a/src/egl/drivers/dri2/egl_dri2.h
>> +++ b/src/egl/drivers/dri2/egl_dri2.h
>> @@ -61,7 +61,6 @@ struct zwp_linux_dmabuf_v1;
>>
>>   #include <system/window.h>
>>   #include <hardware/gralloc.h>
>> -#include <gralloc_drm_handle.h>
>>
>>   #endif /* HAVE_ANDROID_PLATFORM */
>>
>> diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
>> index 4f25cb746915..68c85d7f99fa 100644
>> --- a/src/egl/drivers/dri2/platform_android.c
>> +++ b/src/egl/drivers/dri2/platform_android.c
>> @@ -37,7 +37,6 @@
>>   #include "loader.h"
>>   #include "egl_dri2.h"
>>   #include "egl_dri2_fallbacks.h"
>> -#include "gralloc_drm.h"
>>
>>   #define ALIGN(val, align)      (((val) + (align) - 1) & ~((align) - 1))
>>
>> @@ -164,12 +163,6 @@ get_native_buffer_fd(struct ANativeWindowBuffer *buf)
>>      return (handle && handle->numFds) ? handle->data[0] : -1;
>>   }
>>
>> -static int
>> -get_native_buffer_name(struct ANativeWindowBuffer *buf)
>> -{
>> -   return gralloc_drm_get_gem_handle(buf->handle);
>> -}
>> -
>>   static EGLBoolean
>>   droid_window_dequeue_buffer(struct dri2_egl_surface *dri2_surf)
>>   {
>> @@ -822,50 +815,6 @@ droid_create_image_from_prime_fd(_EGLDisplay *disp, _EGLContext *ctx,
>>      return dri2_create_image_dma_buf(disp, ctx, NULL, attr_list);
>>   }
>>
>> -static _EGLImage *
>> -droid_create_image_from_name(_EGLDisplay *disp, _EGLContext *ctx,
>> -                             struct ANativeWindowBuffer *buf)
>> -{
>> -   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
>> -   struct dri2_egl_image *dri2_img;
>> -   int name;
>> -   int format;
>> -
>> -   name = get_native_buffer_name(buf);
>> -   if (!name) {
>> -      _eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR");
>> -      return NULL;
>> -   }
>> -
>> -   format = get_format(buf->format);
>> -   if (format == -1)
>> -       return NULL;
>> -
>> -   dri2_img = calloc(1, sizeof(*dri2_img));
>> -   if (!dri2_img) {
>> -      _eglError(EGL_BAD_ALLOC, "droid_create_image_mesa_drm");
>> -      return NULL;
>> -   }
>> -
>> -   _eglInitImage(&dri2_img->base, disp);
>> -
>> -   dri2_img->dri_image =
>> -      dri2_dpy->image->createImageFromName(dri2_dpy->dri_screen,
>> -                                          buf->width,
>> -                                          buf->height,
>> -                                          format,
>> -                                          name,
>> -                                          buf->stride,
>> -                                          dri2_img);
>> -   if (!dri2_img->dri_image) {
>> -      free(dri2_img);
>> -      _eglError(EGL_BAD_ALLOC, "droid_create_image_mesa_drm");
>> -      return NULL;
>> -   }
>> -
>> -   return &dri2_img->base;
>> -}
>> -
>>   static EGLBoolean
>>   droid_query_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
>>                       EGLint attribute, EGLint *value)
>> @@ -921,7 +870,7 @@ dri2_create_image_android_native_buffer(_EGLDisplay *disp,
>>      if (fd >= 0)
>>         return droid_create_image_from_prime_fd(disp, ctx, buf, fd);
>>
>> -   return droid_create_image_from_name(disp, ctx, buf);
>> +   return NULL;
>>   }
>>
>>   static _EGLImage *
>> @@ -943,82 +892,6 @@ droid_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate)
>>   {
>>   }
>>
>> -static int
>> -droid_get_buffers_parse_attachments(struct dri2_egl_surface *dri2_surf,
>> -                                    unsigned int *attachments, int count)
>> -{
>> -   int num_buffers = 0;
>> -
>> -   /* fill dri2_surf->buffers */
>> -   for (int i = 0; i < count * 2; i += 2) {
>> -      __DRIbuffer *buf, *local;
>> -
>> -      assert(num_buffers < ARRAY_SIZE(dri2_surf->buffers));
>> -      buf = &dri2_surf->buffers[num_buffers];
>> -
>> -      switch (attachments[i]) {
>> -      case __DRI_BUFFER_BACK_LEFT:
>> -         if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
>> -            buf->attachment = attachments[i];
>> -            buf->name = get_native_buffer_name(dri2_surf->buffer);
>> -            buf->cpp = get_format_bpp(dri2_surf->buffer->format);
>> -            buf->pitch = dri2_surf->buffer->stride * buf->cpp;
>> -            buf->flags = 0;
>> -
>> -            if (buf->name)
>> -               num_buffers++;
>> -
>> -            break;
>> -         }
>> -         /* fall through for pbuffers */
>> -      case __DRI_BUFFER_DEPTH:
>> -      case __DRI_BUFFER_STENCIL:
>> -      case __DRI_BUFFER_ACCUM:
>> -      case __DRI_BUFFER_DEPTH_STENCIL:
>> -      case __DRI_BUFFER_HIZ:
>> -         local = dri2_egl_surface_alloc_local_buffer(dri2_surf,
>> -               attachments[i], attachments[i + 1]);
>> -
>> -         if (local) {
>> -            *buf = *local;
>> -            num_buffers++;
>> -         }
>> -         break;
>> -      case __DRI_BUFFER_FRONT_LEFT:
>> -      case __DRI_BUFFER_FRONT_RIGHT:
>> -      case __DRI_BUFFER_FAKE_FRONT_LEFT:
>> -      case __DRI_BUFFER_FAKE_FRONT_RIGHT:
>> -      case __DRI_BUFFER_BACK_RIGHT:
>> -      default:
>> -         /* no front or right buffers */
>> -         break;
>> -      }
>> -   }
>> -
>> -   return num_buffers;
>> -}
>> -
>> -static __DRIbuffer *
>> -droid_get_buffers_with_format(__DRIdrawable * driDrawable,
>> -                            int *width, int *height,
>> -                            unsigned int *attachments, int count,
>> -                            int *out_count, void *loaderPrivate)
>> -{
>> -   struct dri2_egl_surface *dri2_surf = loaderPrivate;
>> -
>> -   if (update_buffers(dri2_surf) < 0)
>> -      return NULL;
>> -
>> -   *out_count = droid_get_buffers_parse_attachments(dri2_surf, attachments, count);
>> -
>> -   if (width)
>> -      *width = dri2_surf->base.Width;
>> -   if (height)
>> -      *height = dri2_surf->base.Height;
>> -
>> -   return dri2_surf->buffers;
>> -}
>> -
>>   static unsigned
>>   droid_get_capability(void *loaderPrivate, enum dri_loader_cap cap)
>>   {
>> @@ -1100,6 +973,14 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *dpy)
>>      return (config_count != 0);
>>   }
>>
>> +enum {
>> +        /* perform(const struct gralloc_module_t *mod,
>> +         *         int op,
>> +         *         int *fd);
>> +         */
>> +        GRALLOC_MODULE_PERFORM_GET_DRM_FD                = 0x40000002,
>> +};
>> +
>>   static int
>>   droid_open_device(struct dri2_egl_display *dri2_dpy)
>>   {
>> @@ -1141,15 +1022,6 @@ static const struct dri2_egl_display_vtbl droid_display_vtbl = {
>>      .get_dri_drawable = dri2_surface_get_dri_drawable,
>>   };
>>
>> -static const __DRIdri2LoaderExtension droid_dri2_loader_extension = {
>> -   .base = { __DRI_DRI2_LOADER, 4 },
>> -
>> -   .getBuffers           = NULL,
>> -   .flushFrontBuffer     = droid_flush_front_buffer,
>> -   .getBuffersWithFormat = droid_get_buffers_with_format,
>> -   .getCapability        = droid_get_capability,
>> -};
>> -
>>   static const __DRIimageLoaderExtension droid_image_loader_extension = {
>>      .base = { __DRI_IMAGE_LOADER, 2 },
>>
>> @@ -1158,13 +1030,6 @@ static const __DRIimageLoaderExtension droid_image_loader_extension = {
>>      .getCapability       = droid_get_capability,
>>   };
>>
>> -static const __DRIextension *droid_dri2_loader_extensions[] = {
>> -   &droid_dri2_loader_extension.base,
>> -   &image_lookup_extension.base,
>> -   &use_invalidate.base,
>> -   NULL,
>> -};
>> -
>>   static const __DRIextension *droid_image_loader_extensions[] = {
>>      &droid_image_loader_extension.base,
>>      &image_lookup_extension.base,
>> @@ -1216,17 +1081,14 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp)
>>      /* render nodes cannot use Gem names, and thus do not support
>>       * the __DRI_DRI2_LOADER extension */
>>      if (!dri2_dpy->is_render_node) {
>> -      dri2_dpy->loader_extensions = droid_dri2_loader_extensions;
>> -      if (!dri2_load_driver(disp)) {
>> -         err = "DRI2: failed to load driver";
>> -         goto cleanup;
>> -      }
>> -   } else {
>> -      dri2_dpy->loader_extensions = droid_image_loader_extensions;
>> -      if (!dri2_load_driver_dri3(disp)) {
>> -         err = "DRI3: failed to load driver";
>> -         goto cleanup;
>> -      }
>> +      err = "DRI2: driver is not a render node";
>> +      goto cleanup;
>> +   }
>> +
>> +   dri2_dpy->loader_extensions = droid_image_loader_extensions;
>> +   if (!dri2_load_driver_dri3(disp)) {
>> +      err = "DRI3: failed to load driver";
>> +      goto cleanup;
>>      }
>>
>>      if (!dri2_create_screen(disp)) {
>> --
>> 2.14.1
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 
> 
>
On Tue, Apr 24, 2018 at 4:26 PM Robert Foss <robert.foss@collabora.com>
wrote:

> Hey Chih-Wei,

> On 04/23/2018 04:17 AM, Chih-Wei Huang wrote:
> > What's the impact to drm_gralloc?

> I'm not terribly familiar with drm_gralloc, but as far as I understand it
> depends on flink name support at the moment.

> The overarching idea here is to make mesa gralloc independent, but also
at the
> same time provide some infrastructure for making the grallocs able to be
separate.

> I'm not sure what the best way to keep drm_gralloc support alive and at
the same
> time make mesa gralloc independent is.

Right now we're punishing users of the proper DMA-buf based API by making
them carry local patches to remove the dependencies on drm_gralloc.
Reversing this and putting the burden on users of deprecated (and insecure)
flink API might finally encourage them to fix their systems.

Alternatively, rather than removing, we could just put this behind a macro
that is unset by default and one would need to explicitly set
BOARD_something or pass an argument to ./configure (probably not even
needed, as Chrome OS might be the only user) to enable it.

Best regards,
Tomasz



> Rob.

> >
> >
> > 2018-04-20 5:09 GMT+08:00 Rob Herring <robh@kernel.org>:
> >> Maintaining both flink names and prime fd support which are provided by
> >> 2 different gralloc implementations is problematic because we have a
> >> dependency on a specific gralloc implementation header.
> >>
> >> This mostly removes the dependency on the gralloc implementation and
> >> headers. The dependency on GRALLOC_MODULE_PERFORM_GET_DRM_FD remains
for
> >> now, but the definition is added locally to remove the header
> >> dependency.
> >>
> >> Signed-off-by: Rob Herring <robh@kernel.org>
> >> ---
> >> With this plus Robert's probing patch, we remove any gralloc
> >> implementation dependency (other than it has to be a pre 1.0
> >> implementation...).
> >>
> >>   src/egl/drivers/dri2/egl_dri2.h         |   1 -
> >>   src/egl/drivers/dri2/platform_android.c | 172
++++----------------------------
> >>   2 files changed, 17 insertions(+), 156 deletions(-)
> >>
> >> diff --git a/src/egl/drivers/dri2/egl_dri2.h
b/src/egl/drivers/dri2/egl_dri2.h
> >> index cc76c73eab2f..d9e1f466fbeb 100644
> >> --- a/src/egl/drivers/dri2/egl_dri2.h
> >> +++ b/src/egl/drivers/dri2/egl_dri2.h
> >> @@ -61,7 +61,6 @@ struct zwp_linux_dmabuf_v1;
> >>
> >>   #include <system/window.h>
> >>   #include <hardware/gralloc.h>
> >> -#include <gralloc_drm_handle.h>
> >>
> >>   #endif /* HAVE_ANDROID_PLATFORM */
> >>
> >> diff --git a/src/egl/drivers/dri2/platform_android.c
b/src/egl/drivers/dri2/platform_android.c
> >> index 4f25cb746915..68c85d7f99fa 100644
> >> --- a/src/egl/drivers/dri2/platform_android.c
> >> +++ b/src/egl/drivers/dri2/platform_android.c
> >> @@ -37,7 +37,6 @@
> >>   #include "loader.h"
> >>   #include "egl_dri2.h"
> >>   #include "egl_dri2_fallbacks.h"
> >> -#include "gralloc_drm.h"
> >>
> >>   #define ALIGN(val, align)      (((val) + (align) - 1) & ~((align) -
1))
> >>
> >> @@ -164,12 +163,6 @@ get_native_buffer_fd(struct ANativeWindowBuffer
*buf)
> >>      return (handle && handle->numFds) ? handle->data[0] : -1;
> >>   }
> >>
> >> -static int
> >> -get_native_buffer_name(struct ANativeWindowBuffer *buf)
> >> -{
> >> -   return gralloc_drm_get_gem_handle(buf->handle);
> >> -}
> >> -
> >>   static EGLBoolean
> >>   droid_window_dequeue_buffer(struct dri2_egl_surface *dri2_surf)
> >>   {
> >> @@ -822,50 +815,6 @@ droid_create_image_from_prime_fd(_EGLDisplay
*disp, _EGLContext *ctx,
> >>      return dri2_create_image_dma_buf(disp, ctx, NULL, attr_list);
> >>   }
> >>
> >> -static _EGLImage *
> >> -droid_create_image_from_name(_EGLDisplay *disp, _EGLContext *ctx,
> >> -                             struct ANativeWindowBuffer *buf)
> >> -{
> >> -   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
> >> -   struct dri2_egl_image *dri2_img;
> >> -   int name;
> >> -   int format;
> >> -
> >> -   name = get_native_buffer_name(buf);
> >> -   if (!name) {
> >> -      _eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR");
> >> -      return NULL;
> >> -   }
> >> -
> >> -   format = get_format(buf->format);
> >> -   if (format == -1)
> >> -       return NULL;
> >> -
> >> -   dri2_img = calloc(1, sizeof(*dri2_img));
> >> -   if (!dri2_img) {
> >> -      _eglError(EGL_BAD_ALLOC, "droid_create_image_mesa_drm");
> >> -      return NULL;
> >> -   }
> >> -
> >> -   _eglInitImage(&dri2_img->base, disp);
> >> -
> >> -   dri2_img->dri_image =
> >> -      dri2_dpy->image->createImageFromName(dri2_dpy->dri_screen,
> >> -                                          buf->width,
> >> -                                          buf->height,
> >> -                                          format,
> >> -                                          name,
> >> -                                          buf->stride,
> >> -                                          dri2_img);
> >> -   if (!dri2_img->dri_image) {
> >> -      free(dri2_img);
> >> -      _eglError(EGL_BAD_ALLOC, "droid_create_image_mesa_drm");
> >> -      return NULL;
> >> -   }
> >> -
> >> -   return &dri2_img->base;
> >> -}
> >> -
> >>   static EGLBoolean
> >>   droid_query_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface
*surf,
> >>                       EGLint attribute, EGLint *value)
> >> @@ -921,7 +870,7 @@
dri2_create_image_android_native_buffer(_EGLDisplay *disp,
> >>      if (fd >= 0)
> >>         return droid_create_image_from_prime_fd(disp, ctx, buf, fd);
> >>
> >> -   return droid_create_image_from_name(disp, ctx, buf);
> >> +   return NULL;
> >>   }
> >>
> >>   static _EGLImage *
> >> @@ -943,82 +892,6 @@ droid_flush_front_buffer(__DRIdrawable *
driDrawable, void *loaderPrivate)
> >>   {
> >>   }
> >>
> >> -static int
> >> -droid_get_buffers_parse_attachments(struct dri2_egl_surface
*dri2_surf,
> >> -                                    unsigned int *attachments, int
count)
> >> -{
> >> -   int num_buffers = 0;
> >> -
> >> -   /* fill dri2_surf->buffers */
> >> -   for (int i = 0; i < count * 2; i += 2) {
> >> -      __DRIbuffer *buf, *local;
> >> -
> >> -      assert(num_buffers < ARRAY_SIZE(dri2_surf->buffers));
> >> -      buf = &dri2_surf->buffers[num_buffers];
> >> -
> >> -      switch (attachments[i]) {
> >> -      case __DRI_BUFFER_BACK_LEFT:
> >> -         if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
> >> -            buf->attachment = attachments[i];
> >> -            buf->name = get_native_buffer_name(dri2_surf->buffer);
> >> -            buf->cpp = get_format_bpp(dri2_surf->buffer->format);
> >> -            buf->pitch = dri2_surf->buffer->stride * buf->cpp;
> >> -            buf->flags = 0;
> >> -
> >> -            if (buf->name)
> >> -               num_buffers++;
> >> -
> >> -            break;
> >> -         }
> >> -         /* fall through for pbuffers */
> >> -      case __DRI_BUFFER_DEPTH:
> >> -      case __DRI_BUFFER_STENCIL:
> >> -      case __DRI_BUFFER_ACCUM:
> >> -      case __DRI_BUFFER_DEPTH_STENCIL:
> >> -      case __DRI_BUFFER_HIZ:
> >> -         local = dri2_egl_surface_alloc_local_buffer(dri2_surf,
> >> -               attachments[i], attachments[i + 1]);
> >> -
> >> -         if (local) {
> >> -            *buf = *local;
> >> -            num_buffers++;
> >> -         }
> >> -         break;
> >> -      case __DRI_BUFFER_FRONT_LEFT:
> >> -      case __DRI_BUFFER_FRONT_RIGHT:
> >> -      case __DRI_BUFFER_FAKE_FRONT_LEFT:
> >> -      case __DRI_BUFFER_FAKE_FRONT_RIGHT:
> >> -      case __DRI_BUFFER_BACK_RIGHT:
> >> -      default:
> >> -         /* no front or right buffers */
> >> -         break;
> >> -      }
> >> -   }
> >> -
> >> -   return num_buffers;
> >> -}
> >> -
> >> -static __DRIbuffer *
> >> -droid_get_buffers_with_format(__DRIdrawable * driDrawable,
> >> -                            int *width, int *height,
> >> -                            unsigned int *attachments, int count,
> >> -                            int *out_count, void *loaderPrivate)
> >> -{
> >> -   struct dri2_egl_surface *dri2_surf = loaderPrivate;
> >> -
> >> -   if (update_buffers(dri2_surf) < 0)
> >> -      return NULL;
> >> -
> >> -   *out_count = droid_get_buffers_parse_attachments(dri2_surf,
attachments, count);
> >> -
> >> -   if (width)
> >> -      *width = dri2_surf->base.Width;
> >> -   if (height)
> >> -      *height = dri2_surf->base.Height;
> >> -
> >> -   return dri2_surf->buffers;
> >> -}
> >> -
> >>   static unsigned
> >>   droid_get_capability(void *loaderPrivate, enum dri_loader_cap cap)
> >>   {
> >> @@ -1100,6 +973,14 @@ droid_add_configs_for_visuals(_EGLDriver *drv,
_EGLDisplay *dpy)
> >>      return (config_count != 0);
> >>   }
> >>
> >> +enum {
> >> +        /* perform(const struct gralloc_module_t *mod,
> >> +         *         int op,
> >> +         *         int *fd);
> >> +         */
> >> +        GRALLOC_MODULE_PERFORM_GET_DRM_FD                = 0x40000002,
> >> +};
> >> +
> >>   static int
> >>   droid_open_device(struct dri2_egl_display *dri2_dpy)
> >>   {
> >> @@ -1141,15 +1022,6 @@ static const struct dri2_egl_display_vtbl
droid_display_vtbl = {
> >>      .get_dri_drawable = dri2_surface_get_dri_drawable,
> >>   };
> >>
> >> -static const __DRIdri2LoaderExtension droid_dri2_loader_extension = {
> >> -   .base = { __DRI_DRI2_LOADER, 4 },
> >> -
> >> -   .getBuffers           = NULL,
> >> -   .flushFrontBuffer     = droid_flush_front_buffer,
> >> -   .getBuffersWithFormat = droid_get_buffers_with_format,
> >> -   .getCapability        = droid_get_capability,
> >> -};
> >> -
> >>   static const __DRIimageLoaderExtension droid_image_loader_extension
= {
> >>      .base = { __DRI_IMAGE_LOADER, 2 },
> >>
> >> @@ -1158,13 +1030,6 @@ static const __DRIimageLoaderExtension
droid_image_loader_extension = {
> >>      .getCapability       = droid_get_capability,
> >>   };
> >>
> >> -static const __DRIextension *droid_dri2_loader_extensions[] = {
> >> -   &droid_dri2_loader_extension.base,
> >> -   &image_lookup_extension.base,
> >> -   &use_invalidate.base,
> >> -   NULL,
> >> -};
> >> -
> >>   static const __DRIextension *droid_image_loader_extensions[] = {
> >>      &droid_image_loader_extension.base,
> >>      &image_lookup_extension.base,
> >> @@ -1216,17 +1081,14 @@ dri2_initialize_android(_EGLDriver *drv,
_EGLDisplay *disp)
> >>      /* render nodes cannot use Gem names, and thus do not support
> >>       * the __DRI_DRI2_LOADER extension */
> >>      if (!dri2_dpy->is_render_node) {
> >> -      dri2_dpy->loader_extensions = droid_dri2_loader_extensions;
> >> -      if (!dri2_load_driver(disp)) {
> >> -         err = "DRI2: failed to load driver";
> >> -         goto cleanup;
> >> -      }
> >> -   } else {
> >> -      dri2_dpy->loader_extensions = droid_image_loader_extensions;
> >> -      if (!dri2_load_driver_dri3(disp)) {
> >> -         err = "DRI3: failed to load driver";
> >> -         goto cleanup;
> >> -      }
> >> +      err = "DRI2: driver is not a render node";
> >> +      goto cleanup;
> >> +   }
> >> +
> >> +   dri2_dpy->loader_extensions = droid_image_loader_extensions;
> >> +   if (!dri2_load_driver_dri3(disp)) {
> >> +      err = "DRI3: failed to load driver";
> >> +      goto cleanup;
> >>      }
> >>
> >>      if (!dri2_create_screen(disp)) {
> >> --
> >> 2.14.1
> >>
> >> _______________________________________________
> >> mesa-dev mailing list
> >> mesa-dev@lists.freedesktop.org
> >> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> >
> >
> >
Hi Rob,

Thanks for doing this.

There's a couple of small nits, but the patch looks good IMHO.
On the topic of keeping the old code behind a #define or just removing
it, it'll be great if interested parties can reach a consensus.


On 19 April 2018 at 22:09, Rob Herring <robh@kernel.org> wrote:

> --- a/src/egl/drivers/dri2/egl_dri2.h
> +++ b/src/egl/drivers/dri2/egl_dri2.h
> @@ -61,7 +61,6 @@ struct zwp_linux_dmabuf_v1;
>
>  #include <system/window.h>
>  #include <hardware/gralloc.h>
> -#include <gralloc_drm_handle.h>
>
>  #endif /* HAVE_ANDROID_PLATFORM */
>
Unrelated, future patch:
By adding a couple of fwd declarations, this whole hunk can be moved
to platform_android.c


> +enum {
> +        /* perform(const struct gralloc_module_t *mod,
> +         *         int op,
> +         *         int *fd);
> +         */
> +        GRALLOC_MODULE_PERFORM_GET_DRM_FD                = 0x40000002,
> +};
> +
Might want as well add a comment what/why. Say:
Add a local definition to avoid depending on ...


> @@ -1216,17 +1081,14 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp)
>     /* render nodes cannot use Gem names, and thus do not support
>      * the __DRI_DRI2_LOADER extension */
With the __DRI_DRI2_LOADER hunk removed above, the comment needs an update.

HTH
Emil
On 24 April 2018 at 12:28, Emil Velikov <emil.l.velikov@gmail.com> wrote:

> On the topic of keeping the old code behind a #define or just removing
> it, it'll be great if interested parties can reach a consensus.
>
Actually one can simply drop this code and drm_gralloc users can add a
drm_ioctl_permit() hack.
Namely: loosen the restrictions to consider render nodes identical to
primary/card ones.

Yes, it's a nasty hack, yet no worse than the existing one that
removes the auth :-\

HTH
Emil
Hey Emil & Chih-Wei,


On 04/24/2018 01:59 PM, Emil Velikov wrote:
> On 24 April 2018 at 12:28, Emil Velikov <emil.l.velikov@gmail.com> wrote:
> 
>> On the topic of keeping the old code behind a #define or just removing
>> it, it'll be great if interested parties can reach a consensus.
>>
> Actually one can simply drop this code and drm_gralloc users can add a
> drm_ioctl_permit() hack.
> Namely: loosen the restrictions to consider render nodes identical to
> primary/card ones.
> 
> Yes, it's a nasty hack, yet no worse than the existing one that
> removes the auth :-\

I'm fine with adding a #define.
Chih-Wei: Do you have any objections?


Rob.
2018-04-25 19:55 GMT+08:00 Robert Foss <robert.foss@collabora.com>:
> Hey Emil & Chih-Wei,
>
> On 04/24/2018 01:59 PM, Emil Velikov wrote:
>>
>> On 24 April 2018 at 12:28, Emil Velikov <emil.l.velikov@gmail.com> wrote:
>>
>>> On the topic of keeping the old code behind a #define or just removing
>>> it, it'll be great if interested parties can reach a consensus.
>>>
>> Actually one can simply drop this code and drm_gralloc users can add a
>> drm_ioctl_permit() hack.
>> Namely: loosen the restrictions to consider render nodes identical to
>> primary/card ones.
>>
>> Yes, it's a nasty hack, yet no worse than the existing one that
>> removes the auth :-\
>
> I'm fine with adding a #define.
> Chih-Wei: Do you have any objections?

"keeping the old code behind a #define"?
Sounds good to me. Thank you!
On 26 April 2018 at 03:30, Chih-Wei Huang <cwhuang@linux.org.tw> wrote:
> 2018-04-25 19:55 GMT+08:00 Robert Foss <robert.foss@collabora.com>:
>> Hey Emil & Chih-Wei,
>>
>> On 04/24/2018 01:59 PM, Emil Velikov wrote:
>>>
>>> On 24 April 2018 at 12:28, Emil Velikov <emil.l.velikov@gmail.com> wrote:
>>>
>>>> On the topic of keeping the old code behind a #define or just removing
>>>> it, it'll be great if interested parties can reach a consensus.
>>>>
>>> Actually one can simply drop this code and drm_gralloc users can add a
>>> drm_ioctl_permit() hack.
>>> Namely: loosen the restrictions to consider render nodes identical to
>>> primary/card ones.
>>>
>>> Yes, it's a nasty hack, yet no worse than the existing one that
>>> removes the auth :-\
>>
>> I'm fine with adding a #define.
>> Chih-Wei: Do you have any objections?
>
> "keeping the old code behind a #define"?
> Sounds good to me. Thank you!

Having a look at the Android-x86 kernel:
The current hack in the permission check (see drm_ioctl_permit in [1])
effectively threats render nodes and primary nodes as the same thing.

Thus, on top of the current patch the !dri2_dpy->is_render_node check
should be removed, for Android-x86.
There's no need to keep the flink code around ;-)

-Emil

[1] https://osdn.net/projects/android-x86/scm/git/kernel/blobs/kernel-4.14/drivers/gpu/drm/drm_ioctl.c
On Thu, Apr 26, 2018 at 11:56 AM, Emil Velikov <emil.l.velikov@gmail.com> wrote:
> On 26 April 2018 at 03:30, Chih-Wei Huang <cwhuang@linux.org.tw> wrote:
>> 2018-04-25 19:55 GMT+08:00 Robert Foss <robert.foss@collabora.com>:
>>> Hey Emil & Chih-Wei,
>>>
>>> On 04/24/2018 01:59 PM, Emil Velikov wrote:
>>>>
>>>> On 24 April 2018 at 12:28, Emil Velikov <emil.l.velikov@gmail.com> wrote:
>>>>
>>>>> On the topic of keeping the old code behind a #define or just removing
>>>>> it, it'll be great if interested parties can reach a consensus.
>>>>>
>>>> Actually one can simply drop this code and drm_gralloc users can add a
>>>> drm_ioctl_permit() hack.
>>>> Namely: loosen the restrictions to consider render nodes identical to
>>>> primary/card ones.
>>>>
>>>> Yes, it's a nasty hack, yet no worse than the existing one that
>>>> removes the auth :-\
>>>
>>> I'm fine with adding a #define.
>>> Chih-Wei: Do you have any objections?
>>
>> "keeping the old code behind a #define"?
>> Sounds good to me. Thank you!
>
> Having a look at the Android-x86 kernel:
> The current hack in the permission check (see drm_ioctl_permit in [1])
> effectively threats render nodes and primary nodes as the same thing.
>
> Thus, on top of the current patch the !dri2_dpy->is_render_node check
> should be removed, for Android-x86.
> There's no need to keep the flink code around ;-)

Except I don't think drm_gralloc fills in a dma-buf fd in it's
handle... There was an AOSP version that did IIRC.

Or maybe I'm missing something.

Rob
On 26 April 2018 at 18:34, Rob Herring <robh@kernel.org> wrote:
> On Thu, Apr 26, 2018 at 11:56 AM, Emil Velikov <emil.l.velikov@gmail.com> wrote:
>> On 26 April 2018 at 03:30, Chih-Wei Huang <cwhuang@linux.org.tw> wrote:
>>> 2018-04-25 19:55 GMT+08:00 Robert Foss <robert.foss@collabora.com>:
>>>> Hey Emil & Chih-Wei,
>>>>
>>>> On 04/24/2018 01:59 PM, Emil Velikov wrote:
>>>>>
>>>>> On 24 April 2018 at 12:28, Emil Velikov <emil.l.velikov@gmail.com> wrote:
>>>>>
>>>>>> On the topic of keeping the old code behind a #define or just removing
>>>>>> it, it'll be great if interested parties can reach a consensus.
>>>>>>
>>>>> Actually one can simply drop this code and drm_gralloc users can add a
>>>>> drm_ioctl_permit() hack.
>>>>> Namely: loosen the restrictions to consider render nodes identical to
>>>>> primary/card ones.
>>>>>
>>>>> Yes, it's a nasty hack, yet no worse than the existing one that
>>>>> removes the auth :-\
>>>>
>>>> I'm fine with adding a #define.
>>>> Chih-Wei: Do you have any objections?
>>>
>>> "keeping the old code behind a #define"?
>>> Sounds good to me. Thank you!
>>
>> Having a look at the Android-x86 kernel:
>> The current hack in the permission check (see drm_ioctl_permit in [1])
>> effectively threats render nodes and primary nodes as the same thing.
>>
>> Thus, on top of the current patch the !dri2_dpy->is_render_node check
>> should be removed, for Android-x86.
>> There's no need to keep the flink code around ;-)
>
> Except I don't think drm_gralloc fills in a dma-buf fd in it's
> handle... There was an AOSP version that did IIRC.
>
> Or maybe I'm missing something.
>
You're probably right - I haven't looked closely at drm_gralloc in ages.
Yet again, considering the hacked auth, there should be no blockers to
tweaking drm_gralloc.

Either way, I'm just overly hyped looking for ways to remove the flink code.
Feel free to ignore my suggestions.

-Emil
On 04/26/2018 07:43 PM, Emil Velikov wrote:
> On 26 April 2018 at 18:34, Rob Herring <robh@kernel.org> wrote:
>> On Thu, Apr 26, 2018 at 11:56 AM, Emil Velikov <emil.l.velikov@gmail.com> wrote:
>>> On 26 April 2018 at 03:30, Chih-Wei Huang <cwhuang@linux.org.tw> wrote:
>>>> 2018-04-25 19:55 GMT+08:00 Robert Foss <robert.foss@collabora.com>:
>>>>> Hey Emil & Chih-Wei,
>>>>>
>>>>> On 04/24/2018 01:59 PM, Emil Velikov wrote:
>>>>>>
>>>>>> On 24 April 2018 at 12:28, Emil Velikov <emil.l.velikov@gmail.com> wrote:
>>>>>>
>>>>>>> On the topic of keeping the old code behind a #define or just removing
>>>>>>> it, it'll be great if interested parties can reach a consensus.
>>>>>>>
>>>>>> Actually one can simply drop this code and drm_gralloc users can add a
>>>>>> drm_ioctl_permit() hack.
>>>>>> Namely: loosen the restrictions to consider render nodes identical to
>>>>>> primary/card ones.
>>>>>>
>>>>>> Yes, it's a nasty hack, yet no worse than the existing one that
>>>>>> removes the auth :-\
>>>>>
>>>>> I'm fine with adding a #define.
>>>>> Chih-Wei: Do you have any objections?
>>>>
>>>> "keeping the old code behind a #define"?
>>>> Sounds good to me. Thank you!
>>>
>>> Having a look at the Android-x86 kernel:
>>> The current hack in the permission check (see drm_ioctl_permit in [1])
>>> effectively threats render nodes and primary nodes as the same thing.
>>>
>>> Thus, on top of the current patch the !dri2_dpy->is_render_node check
>>> should be removed, for Android-x86.
>>> There's no need to keep the flink code around ;-)
>>
>> Except I don't think drm_gralloc fills in a dma-buf fd in it's
>> handle... There was an AOSP version that did IIRC.
>>
>> Or maybe I'm missing something.
>>
> You're probably right - I haven't looked closely at drm_gralloc in ages.
> Yet again, considering the hacked auth, there should be no blockers to
> tweaking drm_gralloc.
> 
> Either way, I'm just overly hyped looking for ways to remove the flink code.
> Feel free to ignore my suggestions.

I've spent some time today preparing a #ifdef version of what robher submitted.

It's fine, but there is no way automatically enable the HAVE_DRM_GRALLOC #define 
through the build tools. So a small simple patch adding the shared library 
dependency, and adding the -DHAVE_DRM_GRALLOC cflag is needed.

I'll send it out tomorrow, a bit late in the day for sending out patches now ;)


Rob.
2018-04-27 2:19 GMT+08:00 Robert Foss <robert.foss@collabora.com>:
>
> I've spent some time today preparing a #ifdef version of what robher
> submitted.
>
> It's fine, but there is no way automatically enable the HAVE_DRM_GRALLOC
> #define through the build tools. So a small simple patch adding the shared
> library dependency, and adding the -DHAVE_DRM_GRALLOC cflag is needed.

I can add BOARD_USES_DRM_GRALLOC=true
(like BOARD_USES_DRM_HWCOMPOSER=true)
in our BoardConfig.mk.
Then you can add these in Android.mk of mesa:

ifeq ($(BOARD_USES_DRM_GRALLOC),true)
LOCAL_CFLAGS += -DHAVE_DRM_GRALLOC
endif


> I'll send it out tomorrow, a bit late in the day for sending out patches now
> ;)

Thanks!
2018-04-27 1:34 GMT+08:00 Rob Herring <robh@kernel.org>:
> On Thu, Apr 26, 2018 at 11:56 AM, Emil Velikov <emil.l.velikov@gmail.com> wrote:
>> On 26 April 2018 at 03:30, Chih-Wei Huang <cwhuang@linux.org.tw> wrote:
>>> 2018-04-25 19:55 GMT+08:00 Robert Foss <robert.foss@collabora.com>:
>>>> Hey Emil & Chih-Wei,
>>>>
>>>> On 04/24/2018 01:59 PM, Emil Velikov wrote:
>>>>>
>>>>> On 24 April 2018 at 12:28, Emil Velikov <emil.l.velikov@gmail.com> wrote:
>>>>>
>>>>>> On the topic of keeping the old code behind a #define or just removing
>>>>>> it, it'll be great if interested parties can reach a consensus.
>>>>>>
>>>>> Actually one can simply drop this code and drm_gralloc users can add a
>>>>> drm_ioctl_permit() hack.
>>>>> Namely: loosen the restrictions to consider render nodes identical to
>>>>> primary/card ones.
>>>>>
>>>>> Yes, it's a nasty hack, yet no worse than the existing one that
>>>>> removes the auth :-\
>>>>
>>>> I'm fine with adding a #define.
>>>> Chih-Wei: Do you have any objections?
>>>
>>> "keeping the old code behind a #define"?
>>> Sounds good to me. Thank you!
>>
>> Having a look at the Android-x86 kernel:
>> The current hack in the permission check (see drm_ioctl_permit in [1])
>> effectively threats render nodes and primary nodes as the same thing.
>>
>> Thus, on top of the current patch the !dri2_dpy->is_render_node check
>> should be removed, for Android-x86.
>> There's no need to keep the flink code around ;-)
>
> Except I don't think drm_gralloc fills in a dma-buf fd in it's
> handle... There was an AOSP version that did IIRC.
>
> Or maybe I'm missing something.

IIRC, AOSP's modified drm_gralloc requires drm_hwcomposer.
Then we loop back to the old problem:
drm_hwcomposer doesn't work for most x86 GPUs.
Hi Rob,
On Fri, Apr 27, 2018 at 12:43 PM Chih-Wei Huang <cwhuang@linux.org.tw>
wrote:

> 2018-04-27 2:19 GMT+08:00 Robert Foss <robert.foss@collabora.com>:
> >
> > I've spent some time today preparing a #ifdef version of what robher
> > submitted.
> >
> > It's fine, but there is no way automatically enable the HAVE_DRM_GRALLOC
> > #define through the build tools. So a small simple patch adding the
shared
> > library dependency, and adding the -DHAVE_DRM_GRALLOC cflag is needed.

> I can add BOARD_USES_DRM_GRALLOC=true
> (like BOARD_USES_DRM_HWCOMPOSER=true)
> in our BoardConfig.mk.
> Then you can add these in Android.mk of mesa:

> ifeq ($(BOARD_USES_DRM_GRALLOC),true)
> LOCAL_CFLAGS += -DHAVE_DRM_GRALLOC
> endif

+1 to as Chih-Wei says for Android.mk.

For autotools or meson builds we don't need to define it at all, so no need
for any changes.

Best regards,
Tomasz