[Mesa-dev] [PATCH 1/2] egl/android: Get gralloc module in dri2_initialize_android()

Emil Velikov emil.l.velikov at gmail.com
Wed Nov 9 19:25:40 UTC 2016


On 9 November 2016 at 08:33, Tomasz Figa <tfiga at chromium.org> wrote:
> Currently droid_open_device() gets a reference to the gralloc module
> only for its own use and does not store it anywhere. To make it possible
> to call gralloc methods from code added in further patches, let's
> refactor current code to get gralloc module in dri2_initialize_android()
> and store it in dri2_dpy.
>
> Signed-off-by: Tomasz Figa <tfiga at chromium.org>
> ---
>  src/egl/drivers/dri2/egl_dri2.h         |  4 ++++
>  src/egl/drivers/dri2/platform_android.c | 28 ++++++++++++++++------------
>  2 files changed, 20 insertions(+), 12 deletions(-)
>
> diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
> index 0020a5b..f6f71aa 100644
> --- a/src/egl/drivers/dri2/egl_dri2.h
> +++ b/src/egl/drivers/dri2/egl_dri2.h
> @@ -219,6 +219,10 @@ struct dri2_egl_display
>     char                     *device_name;
>  #endif
>
> +#ifdef HAVE_ANDROID_PLATFORM
> +   const gralloc_module_t *gralloc;
> +#endif
> +
>     int                       is_render_node;
>     int                       is_different_gpu;
>  };
> diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
> index 86a15f5..0b59724 100644
> --- a/src/egl/drivers/dri2/platform_android.c
> +++ b/src/egl/drivers/dri2/platform_android.c
> @@ -802,19 +802,15 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *dpy)
>  }
>
>  static int
> -droid_open_device(void)
> +droid_open_device(struct dri2_egl_display *dri2_dpy)
>  {
> -   const hw_module_t *mod;
> -   int fd = -1, err;
> +   int fd = -1, err = -EINVAL;
>
> -   err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &mod);
> -   if (!err) {
> -      const gralloc_module_t *gr = (gralloc_module_t *) mod;
> -
> -      err = -EINVAL;
> -      if (gr->perform)
> -         err = gr->perform(gr, GRALLOC_MODULE_PERFORM_GET_DRM_FD, &fd);
> -   }
> +   err = -EINVAL;
I'm seeing double - initialising err twice ?

> +   if (dri2_dpy->gralloc->perform)
> +         err = dri2_dpy->gralloc->perform(dri2_dpy->gralloc,
> +                                          GRALLOC_MODULE_PERFORM_GET_DRM_FD,
> +                                          &fd);
>     if (err || fd < 0) {
>        _eglLog(_EGL_WARNING, "fail to get drm fd");
>        fd = -1;
> @@ -909,6 +905,7 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
>  {
>     struct dri2_egl_display *dri2_dpy;
>     const char *err;
> +   int ret;
>
>     _eglSetLogProc(droid_log);
>
> @@ -918,9 +915,16 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
>     if (!dri2_dpy)
>        return _eglError(EGL_BAD_ALLOC, "eglInitialize");
>
> +   ret = hw_get_module(GRALLOC_HARDWARE_MODULE_ID,
> +                       (const hw_module_t **)&dri2_dpy->gralloc);
One can drop the cast by using &dri2_dpy->gralloc.common.

Regardless, with the err squashed the patch is
Reviewed-by: Emil Velikov <emil.velikov at collabora.com>

Thanks
Emil


More information about the mesa-dev mailing list