diff options
author | Rob Herring <robh@kernel.org> | 2018-04-19 16:09:21 -0500 |
---|---|---|
committer | Sumit Semwal <sumit.semwal@linaro.org> | 2018-04-24 13:09:20 +0530 |
commit | 6620dfaf88231ae1874fc4f72d671124b079285e (patch) | |
tree | 3d879935d45c73e24d1bbff8bdf55852d46002bc | |
parent | e2e1d8ef771f7c4ae6e608ac4900a4aa73134fd7 (diff) |
egl/android: remove flink name support
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>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.h | 1 | ||||
-rw-r--r-- | 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 adabc527f8..f114cbf4d7 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -67,7 +67,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 a19cecfe8a..86e900a33c 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) { @@ -836,50 +829,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) @@ -935,7 +884,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 * @@ -957,82 +906,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) { @@ -1114,6 +987,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) { @@ -1197,15 +1078,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 }, @@ -1214,13 +1086,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, @@ -1277,17 +1142,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)) { |