[Mesa-dev] [PATCH] egl/dri2: implement platform_null.
Emil Velikov
emil.l.velikov at gmail.com
Thu Jan 22 13:36:41 PST 2015
Hi Haixia Shi,
On 22/01/15 17:35, Haixia Shi wrote:
> Try the render node first and use it if available. Otherwise fall back to
> normal nodes.
>
What is the use-case for such a platform - I assume it's worth
mentioning in the commit message ?
No other platform picks the device at random as seen below. Why did you
choose such an approach ? It seems like one can easily shoot themselves
by using it.
...
> diff --git a/src/egl/drivers/dri2/platform_null.c b/src/egl/drivers/dri2/platform_null.c
> new file mode 100644
> index 0000000..4f0b18f
> --- /dev/null
> +++ b/src/egl/drivers/dri2/platform_null.c
...
> +static const char* node_path_fmt_card = "/dev/dri/card%d";
You can reuse the DRM_DIR_NAME + DRM_DEV_NAME macros (from xf86drm.h)
for this.
> +static const char* node_path_fmt_render = "/dev/dri/renderD%d";
There is no macro for the renderD%d, although you can still use
DRM_DIR_NAME for the path.
> +
> +EGLBoolean
> +dri2_initialize_null(_EGLDriver *drv, _EGLDisplay *disp)
> +{
> + struct dri2_egl_display *dri2_dpy;
> + const char* err;
> + int i, render_node;
> + int driver_loaded = 0;
> +
> + loader_set_logger(_eglLog);
> +
> + dri2_dpy = calloc(1, sizeof *dri2_dpy);
> + if (!dri2_dpy)
> + return _eglError(EGL_BAD_ALLOC, "eglInitialize");
> +
> + disp->DriverData = (void *) dri2_dpy;
> +
> + for (render_node = 1; render_node >= 0; --render_node) {
> + const char* node_path_fmt =
> + render_node ? node_path_fmt_render : node_path_fmt_card;
> + const int base = render_node ? 128 : 0;
> + for (i = 0; i < 16; ++i) {
What was the reason behind choosing 16 here ?
> + char *card_path;
> + if (asprintf(&card_path, node_path_fmt, base + i) < 0)
> + continue;
> +
> + dri2_dpy->fd = open(card_path, O_RDWR);
If you open a normal node (card%d) I believe that you'll need an
authenticate hook in dri2_egl_display_vtbl. Does things work without it
on your system/platform ?
Cheers
Emil
More information about the mesa-dev
mailing list