[Mesa-dev] [PATCH 14/19] Xephyr: move ephyrdri over to xcb
Eric Anholt
eric at anholt.net
Mon Aug 26 11:16:50 PDT 2013
From: Julien Cristau <jcristau at debian.org>
Require new xcb-xf86dri to get fixed GetDrawableInfo.
Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>
Signed-off-by: Julien Cristau <jcristau at debian.org>
---
configure.ac | 2 +-
hw/kdrive/ephyr/ephyrdri.c | 201 ++++++++++++++++++++++++++++++++-------------
2 files changed, 144 insertions(+), 59 deletions(-)
diff --git a/configure.ac b/configure.ac
index b8d9a25..a6c466e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2121,7 +2121,7 @@ if test "$KDRIVE" = yes; then
XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS xcb-xv"
fi
if test "x$DRI" = xyes && test "x$GLX" = xyes; then
- XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS $LIBGL libdrm xcb-glx xcb-xf86dri"
+ XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS $LIBGL libdrm xcb-glx xcb-xf86dri > 1.6"
fi
if test "x$XEPHYR" = xauto; then
diff --git a/hw/kdrive/ephyr/ephyrdri.c b/hw/kdrive/ephyr/ephyrdri.c
index 3a4a063..16678fc 100644
--- a/hw/kdrive/ephyr/ephyrdri.c
+++ b/hw/kdrive/ephyr/ephyrdri.c
@@ -29,10 +29,8 @@
#include <kdrive-config.h>
#endif
-#include <X11/Xutil.h>
-#include <X11/Xlibint.h>
-#include <GL/glx.h>
-#include "xf86dri.h"
+#include <X11/Xdefs.h>
+#include <xcb/xf86dri.h>
#include "hostx.h"
#include "ephyrdri.h"
#define _HAVE_XALLOC_DECLS
@@ -49,13 +47,21 @@
Bool
ephyrDRIQueryDirectRenderingCapable(int a_screen, Bool *a_is_capable)
{
- Display *dpy = hostx_get_display();
+ xcb_connection_t *conn = hostx_get_xcbconn();
Bool is_ok = FALSE;
+ xcb_xf86dri_query_direct_rendering_capable_cookie_t cookie;
+ xcb_xf86dri_query_direct_rendering_capable_reply_t *reply;
EPHYR_RETURN_VAL_IF_FAIL(a_is_capable, FALSE);
EPHYR_LOG("enter\n");
- is_ok = XF86DRIQueryDirectRenderingCapable(dpy, DefaultScreen(dpy),
- a_is_capable);
+ cookie = xcb_xf86dri_query_direct_rendering_capable(conn,
+ hostx_get_screen());
+ reply = xcb_xf86dri_query_direct_rendering_capable_reply(conn, cookie, NULL);
+ if (reply) {
+ is_ok = TRUE;
+ *a_is_capable = reply->is_capable;
+ free(reply);
+ }
EPHYR_LOG("leave. is_capable:%d, is_ok=%d\n", *a_is_capable, is_ok);
return is_ok;
@@ -65,31 +71,48 @@ Bool
ephyrDRIOpenConnection(int a_screen,
drm_handle_t * a_sarea, char **a_bus_id_string)
{
- Display *dpy = hostx_get_display();
+ xcb_connection_t *conn = hostx_get_xcbconn();
Bool is_ok = FALSE;
+ xcb_xf86dri_open_connection_cookie_t cookie;
+ xcb_xf86dri_open_connection_reply_t *reply;
EPHYR_RETURN_VAL_IF_FAIL(a_bus_id_string, FALSE);
EPHYR_LOG("enter. screen:%d\n", a_screen);
- is_ok = XF86DRIOpenConnection(dpy, DefaultScreen(dpy),
- a_sarea, a_bus_id_string);
- if (*a_bus_id_string) {
- EPHYR_LOG("leave. bus_id_string:%s, is_ok:%d\n",
- *a_bus_id_string, is_ok);
- }
- else {
- EPHYR_LOG("leave. bus_id_string:null, is_ok:%d\n", is_ok);
+ cookie = xcb_xf86dri_open_connection(conn, hostx_get_screen());
+ reply = xcb_xf86dri_open_connection_reply(conn, cookie, NULL);
+ if (!reply)
+ goto out;
+ *a_sarea = reply->sarea_handle_low;
+ if (sizeof(drm_handle_t) == 8) {
+ int shift = 32;
+ *a_sarea |= ((drm_handle_t) reply->sarea_handle_high) << shift;
}
+ *a_bus_id_string = malloc(reply->bus_id_len + 1);
+ if (!*a_bus_id_string)
+ goto out;
+ memcpy(*a_bus_id_string, xcb_xf86dri_open_connection_bus_id(reply), reply->bus_id_len);
+ *a_bus_id_string[reply->bus_id_len] = '\0';
+ is_ok = TRUE;
+out:
+ free(reply);
+ EPHYR_LOG("leave. bus_id_string:%s, is_ok:%d\n", *a_bus_id_string, is_ok);
return is_ok;
}
Bool
ephyrDRIAuthConnection(int a_screen, drm_magic_t a_magic)
{
- Display *dpy = hostx_get_display();
+ xcb_connection_t *conn = hostx_get_xcbconn();
+ int screen = hostx_get_screen();
+ xcb_xf86dri_auth_connection_cookie_t cookie;
+ xcb_xf86dri_auth_connection_reply_t *reply;
Bool is_ok = FALSE;
EPHYR_LOG("enter\n");
- is_ok = XF86DRIAuthConnection(dpy, DefaultScreen(dpy), a_magic);
+ cookie = xcb_xf86dri_auth_connection(conn, screen, a_magic);
+ reply = xcb_xf86dri_auth_connection_reply(conn, cookie, NULL);
+ is_ok = reply->authenticated;
+ free(reply);
EPHYR_LOG("leave. is_ok:%d\n", is_ok);
return is_ok;
}
@@ -97,13 +120,13 @@ ephyrDRIAuthConnection(int a_screen, drm_magic_t a_magic)
Bool
ephyrDRICloseConnection(int a_screen)
{
- Display *dpy = hostx_get_display();
- Bool is_ok = FALSE;
+ xcb_connection_t *conn = hostx_get_xcbconn();
+ int screen = hostx_get_screen();
EPHYR_LOG("enter\n");
- is_ok = XF86DRICloseConnection(dpy, DefaultScreen(dpy));
+ xcb_xf86dri_close_connection(conn, screen);
EPHYR_LOG("leave\n");
- return is_ok;
+ return TRUE;
}
Bool
@@ -113,7 +136,10 @@ ephyrDRIGetClientDriverName(int a_screen,
int *a_ddx_driver_patch_version,
char **a_client_driver_name)
{
- Display *dpy = hostx_get_display();
+ xcb_connection_t *conn = hostx_get_xcbconn();
+ int screen = hostx_get_screen();
+ xcb_xf86dri_get_client_driver_name_cookie_t cookie;
+ xcb_xf86dri_get_client_driver_name_reply_t *reply;
Bool is_ok = FALSE;
EPHYR_RETURN_VAL_IF_FAIL(a_ddx_driver_major_version
@@ -121,15 +147,27 @@ ephyrDRIGetClientDriverName(int a_screen,
&& a_ddx_driver_patch_version
&& a_client_driver_name, FALSE);
EPHYR_LOG("enter\n");
- is_ok = XF86DRIGetClientDriverName(dpy, DefaultScreen(dpy),
- a_ddx_driver_major_version,
- a_ddx_driver_minor_version,
- a_ddx_driver_patch_version,
- a_client_driver_name);
+ cookie = xcb_xf86dri_get_client_driver_name(conn, screen);
+ reply = xcb_xf86dri_get_client_driver_name_reply(conn, cookie, NULL);
+ if (!reply)
+ goto out;
+ *a_ddx_driver_major_version = reply->client_driver_major_version;
+ *a_ddx_driver_minor_version = reply->client_driver_minor_version;
+ *a_ddx_driver_patch_version = reply->client_driver_patch_version;
+ *a_client_driver_name = malloc(reply->client_driver_name_len + 1);
+ if (!*a_client_driver_name)
+ goto out;
+ memcpy(*a_client_driver_name,
+ xcb_xf86dri_get_client_driver_name_client_driver_name(reply),
+ reply->client_driver_name_len);
+ (*a_client_driver_name)[reply->client_driver_name_len] = '\0';
+ is_ok = TRUE;
EPHYR_LOG("major:%d, minor:%d, patch:%d, name:%s\n",
*a_ddx_driver_major_version,
*a_ddx_driver_minor_version,
*a_ddx_driver_patch_version, *a_client_driver_name);
+ out:
+ free(reply);
EPHYR_LOG("leave:%d\n", is_ok);
return is_ok;
}
@@ -139,17 +177,23 @@ ephyrDRICreateContext(int a_screen,
int a_visual_id,
CARD32 ctxt_id, drm_context_t * a_hw_ctxt)
{
- Display *dpy = hostx_get_display();
+ xcb_connection_t *conn = hostx_get_xcbconn();
+ int screen = hostx_get_screen();
Bool is_ok = FALSE;
- Visual v;
- XID returned_ctxt_id = ctxt_id;
+ xcb_xf86dri_create_context_cookie_t cookie;
+ xcb_xf86dri_create_context_reply_t *reply;
+
+ ctxt_id = xcb_generate_id(conn);
EPHYR_LOG("enter. screen:%d, visual:%d\n", a_screen, a_visual_id);
- memset(&v, 0, sizeof(v));
- v.visualid = a_visual_id;
- is_ok = XF86DRICreateContext(dpy,
- DefaultScreen(dpy),
- &v, &returned_ctxt_id, a_hw_ctxt);
+ cookie = xcb_xf86dri_create_context(conn, screen, a_visual_id, ctxt_id);
+ reply = xcb_xf86dri_create_context_reply(conn, cookie, NULL);
+ if (!reply)
+ goto out;
+ *a_hw_ctxt = reply->hw_context;
+ is_ok = TRUE;
+out:
+ free(reply);
EPHYR_LOG("leave:%d\n", is_ok);
return is_ok;
}
@@ -157,13 +201,13 @@ ephyrDRICreateContext(int a_screen,
Bool
ephyrDRIDestroyContext(int a_screen, int a_context_id)
{
- Display *dpy = hostx_get_display();
- Bool is_ok = FALSE;
+ xcb_connection_t *conn = hostx_get_xcbconn ();
+ int screen = hostx_get_screen();
EPHYR_LOG("enter\n");
- is_ok = XF86DRIDestroyContext(dpy, DefaultScreen(dpy), a_context_id);
- EPHYR_LOG("leave:%d\n", is_ok);
- return is_ok;
+ xcb_xf86dri_destroy_context(conn, screen, a_context_id);
+ EPHYR_LOG("leave\n");
+ return TRUE;
}
Bool
@@ -171,11 +215,20 @@ ephyrDRICreateDrawable(int a_screen,
int a_drawable, drm_drawable_t * a_hw_drawable)
{
Bool is_ok = FALSE;
- Display *dpy = hostx_get_display();
+ xcb_connection_t *conn = hostx_get_xcbconn();
+ int screen = hostx_get_screen();
+ xcb_xf86dri_create_drawable_cookie_t cookie;
+ xcb_xf86dri_create_drawable_reply_t *reply;
EPHYR_LOG("enter\n");
- is_ok = XF86DRICreateDrawable(dpy, DefaultScreen(dpy),
- a_drawable, a_hw_drawable);
+ cookie = xcb_xf86dri_create_drawable(conn, screen, a_drawable);
+ reply = xcb_xf86dri_create_drawable_reply(conn, cookie, NULL);
+ if (!reply)
+ goto out;
+ *a_hw_drawable = reply->hw_drawable_handle;
+ is_ok = TRUE;
+out:
+ free(reply);
EPHYR_LOG("leave. is_ok:%d\n", is_ok);
return is_ok;
}
@@ -206,7 +259,10 @@ ephyrDRIGetDrawableInfo(int a_screen,
drm_clip_rect_t ** a_back_clip_rects)
{
Bool is_ok = FALSE;
- Display *dpy = hostx_get_display();
+ xcb_connection_t *conn = hostx_get_xcbconn();
+ int screen = hostx_get_screen();
+ xcb_xf86dri_get_drawable_info_cookie_t cookie;
+ xcb_xf86dri_get_drawable_info_reply_t *reply = NULL;
EphyrHostWindowAttributes attrs;
EPHYR_RETURN_VAL_IF_FAIL(a_x && a_y && a_w && a_h
@@ -218,16 +274,22 @@ ephyrDRIGetDrawableInfo(int a_screen,
EPHYR_LOG_ERROR("failed to query host window attributes\n");
goto out;
}
- if (!XF86DRIGetDrawableInfo(dpy, DefaultScreen(dpy), a_drawable,
- a_index, a_stamp,
- a_x, a_y,
- a_w, a_h,
- a_num_clip_rects, a_clip_rects,
- a_back_x, a_back_y,
- a_num_back_clip_rects, a_back_clip_rects)) {
- EPHYR_LOG_ERROR("XF86DRIGetDrawableInfo ()\n");
+ cookie = xcb_xf86dri_get_drawable_info(conn, screen, a_drawable);
+ reply = xcb_xf86dri_get_drawable_info_reply(conn, cookie, NULL);
+ if (!reply) {
+ EPHYR_LOG_ERROR ("XF86DRIGetDrawableInfo ()\n");
goto out;
}
+ *a_index = reply->drawable_table_index;
+ *a_stamp = reply->drawable_table_stamp;
+ *a_x = reply->drawable_origin_X;
+ *a_y = reply->drawable_origin_Y;
+ *a_w = reply->drawable_size_W;
+ *a_h = reply->drawable_size_H;
+ *a_num_clip_rects = reply->num_clip_rects;
+ *a_clip_rects = calloc(*a_num_clip_rects, sizeof(drm_clip_rect_t));
+ memcpy(*a_clip_rects, xcb_xf86dri_get_drawable_info_clip_rects(reply),
+ *a_num_clip_rects * sizeof(drm_clip_rect_t));
EPHYR_LOG("host x,y,w,h: (%d,%d,%d,%d)\n", *a_x, *a_y, *a_w, *a_h);
if (*a_num_clip_rects) {
free(*a_back_clip_rects);
@@ -247,6 +309,7 @@ ephyrDRIGetDrawableInfo(int a_screen,
out:
EPHYR_LOG("leave. index:%d, stamp:%d, x,y:(%d,%d), w,y:(%d,%d)\n",
*a_index, *a_stamp, *a_x, *a_y, *a_w, *a_h);
+ free(reply);
return is_ok;
}
@@ -259,13 +322,35 @@ ephyrDRIGetDeviceInfo(int a_screen,
int *a_dev_private_size, void **a_dev_private)
{
Bool is_ok = FALSE;
- Display *dpy = hostx_get_display();
+ xcb_connection_t *conn = hostx_get_xcbconn ();
+ int screen = hostx_get_screen();
+ xcb_xf86dri_get_device_info_cookie_t cookie;
+ xcb_xf86dri_get_device_info_reply_t *reply;
- EPHYR_RETURN_VAL_IF_FAIL(dpy, FALSE);
+ EPHYR_RETURN_VAL_IF_FAIL(conn, FALSE);
EPHYR_LOG("enter\n");
- is_ok = XF86DRIGetDeviceInfo(dpy, DefaultScreen(dpy), a_frame_buffer,
- a_fb_origin, a_fb_size, a_fb_stride,
- a_dev_private_size, a_dev_private);
+ cookie = xcb_xf86dri_get_device_info(conn, screen);
+ reply = xcb_xf86dri_get_device_info_reply(conn, cookie, NULL);
+ if (!reply)
+ goto out;
+ *a_frame_buffer = reply->framebuffer_handle_low;
+ if (sizeof(drm_handle_t) == 8) {
+ int shift = 32;
+ *a_frame_buffer |= ((drm_handle_t)reply->framebuffer_handle_high) << shift;
+ }
+ *a_fb_origin = reply->framebuffer_origin_offset;
+ *a_fb_size = reply->framebuffer_size;
+ *a_fb_stride = reply->framebuffer_stride;
+ *a_dev_private_size = reply->device_private_size;
+ *a_dev_private = calloc(reply->device_private_size, 1);
+ if (!*a_dev_private)
+ goto out;
+ memcpy(*a_dev_private,
+ xcb_xf86dri_get_device_info_device_private(reply),
+ reply->device_private_size);
+ is_ok = TRUE;
+out:
+ free(reply);
EPHYR_LOG("leave:%d\n", is_ok);
return is_ok;
}
--
1.8.4.rc3
More information about the mesa-dev
mailing list