summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2015-12-08 17:41:38 -0500
committerAdam Jackson <ajax@redhat.com>2016-01-28 09:01:12 -0500
commit623ff251dd025929f5bb6174ca86580c5e707261 (patch)
tree747955f3e8b640edd2309f0a8101fc7a1ad54ba6
parent953b71270cf12c59c8a836c9be403d07fb01fa22 (diff)
xephyr: Remove DRI1
This only worked if the backend server supported DRI1, which is stunningly unlikely these days. Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Eric Anholt <eric@anholt.net>
-rw-r--r--hw/kdrive/ephyr/Makefile.am14
-rw-r--r--hw/kdrive/ephyr/ephyr.c76
-rw-r--r--hw/kdrive/ephyr/ephyrdri.c356
-rw-r--r--hw/kdrive/ephyr/ephyrdri.h70
-rw-r--r--hw/kdrive/ephyr/ephyrdriext.c1376
-rw-r--r--hw/kdrive/ephyr/ephyrdriext.h40
-rw-r--r--hw/kdrive/ephyr/ephyrglxext.c854
-rw-r--r--hw/kdrive/ephyr/ephyrglxext.h34
-rw-r--r--hw/kdrive/ephyr/ephyrhostglx.c490
-rw-r--r--hw/kdrive/ephyr/ephyrhostglx.h75
-rw-r--r--hw/kdrive/ephyr/ephyrinit.c13
-rw-r--r--hw/kdrive/ephyr/hostx.c78
-rw-r--r--hw/kdrive/ephyr/hostx.h14
13 files changed, 0 insertions, 3490 deletions
diff --git a/hw/kdrive/ephyr/Makefile.am b/hw/kdrive/ephyr/Makefile.am
index 155e11eb3..6ce0d6fa0 100644
--- a/hw/kdrive/ephyr/Makefile.am
+++ b/hw/kdrive/ephyr/Makefile.am
@@ -46,19 +46,6 @@ GLAMOR_SRCS = \
$()
endif
-if DRI
-DRI_SRCS = \
- ephyrdriext.c \
- ephyrdriext.h \
- ephyrdri.c \
- ephyrdri.h \
- ephyrglxext.c \
- ephyrglxext.h \
- ephyrhostglx.c \
- ephyrhostglx.h \
- $()
-endif
-
bin_PROGRAMS = Xephyr
Xephyr_SOURCES = \
@@ -72,7 +59,6 @@ Xephyr_SOURCES = \
hostx.c \
hostx.h \
$(XV_SRCS) \
- $(DRI_SRCS) \
$(GLAMOR_SRCS) \
$()
diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index 896bac5d6..a272882d4 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -36,13 +36,6 @@
#include "scrnintstr.h"
#include "ephyrlog.h"
-#ifdef XF86DRI
-#include <xcb/xf86dri.h>
-#include "ephyrdri.h"
-#include "ephyrdriext.h"
-#include "ephyrglxext.h"
-#endif /* XF86DRI */
-
#ifdef GLAMOR
#include "glamor.h"
#endif
@@ -658,16 +651,6 @@ ephyrInitScreen(ScreenPtr pScreen)
}
}
#endif /*XV*/
-#ifdef XF86DRI
- if (!ephyrNoDRI && !hostx_has_extension(&xcb_xf86dri_id)) {
- EPHYR_LOG("host x does not support DRI. Disabling DRI forwarding\n");
- ephyrNoDRI = TRUE;
- }
- if (!ephyrNoDRI) {
- ephyrDRIExtensionInit(pScreen);
- ephyrHijackGLXExtension();
- }
-#endif
return TRUE;
}
@@ -849,40 +832,6 @@ miPointerScreenFuncRec ephyrPointerScreenFuncs = {
ephyrWarpCursor,
};
-#ifdef XF86DRI
-/**
- * find if the remote window denoted by a_remote
- * is paired with an internal Window within the Xephyr server.
- * If the remove window is paired with an internal window, send an
- * expose event to the client insterested in the internal window expose event.
- *
- * Pairing happens when a drawable inside Xephyr is associated with
- * a GL surface in a DRI environment.
- * Look at the function ProcXF86DRICreateDrawable in ephyrdriext.c to
- * know a paired window is created.
- *
- * This is useful to make GL drawables (only windows for now) handle
- * expose events and send those events to clients.
- */
-static void
-ephyrExposePairedWindow(int a_remote)
-{
- EphyrWindowPair *pair = NULL;
- RegionRec reg;
- ScreenPtr screen;
-
- if (!findWindowPairFromRemote(a_remote, &pair)) {
- EPHYR_LOG("did not find a pair for this window\n");
- return;
- }
- screen = pair->local->drawable.pScreen;
- RegionNull(&reg);
- RegionCopy(&reg, &pair->local->clipList);
- screen->WindowExposures(pair->local, &reg);
- RegionUninit(&reg);
-}
-#endif /* XF86DRI */
-
static KdScreenInfo *
screen_from_window(Window w)
{
@@ -939,16 +888,6 @@ ephyrProcessExpose(xcb_generic_event_t *xev)
scrpriv->win_height);
} else {
EPHYR_LOG_ERROR("failed to get host screen\n");
-#ifdef XF86DRI
- /*
- * We only receive expose events when the expose event
- * have be generated for a drawable that is a host X
- * window managed by Xephyr. Host X windows managed by
- * Xephyr exists for instance when Xephyr is asked to
- * create a GL drawable in a DRI environment.
- */
- ephyrExposePairedWindow(expose->window);
-#endif /* XF86DRI */
}
}
@@ -974,25 +913,10 @@ ephyrProcessMouseMotion(xcb_generic_event_t *xev)
else {
int x = 0, y = 0;
-#ifdef XF86DRI
- EphyrWindowPair *pair = NULL;
-#endif
EPHYR_LOG("enqueuing mouse motion:%d\n", screen->pScreen->myNum);
x = motion->event_x;
y = motion->event_y;
EPHYR_LOG("initial (x,y):(%d,%d)\n", x, y);
-#ifdef XF86DRI
- EPHYR_LOG("is this window peered by a gl drawable ?\n");
- if (findWindowPairFromRemote(motion->event, &pair)) {
- EPHYR_LOG("yes, it is peered\n");
- x += pair->local->drawable.x;
- y += pair->local->drawable.y;
- }
- else {
- EPHYR_LOG("no, it is not peered\n");
- }
- EPHYR_LOG("final (x,y):(%d,%d)\n", x, y);
-#endif
/* convert coords into desktop-wide coordinates.
* fill_pointer_events will convert that back to
diff --git a/hw/kdrive/ephyr/ephyrdri.c b/hw/kdrive/ephyr/ephyrdri.c
deleted file mode 100644
index 1e34301e1..000000000
--- a/hw/kdrive/ephyr/ephyrdri.c
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- * Xephyr - A kdrive X server thats runs in a host X window.
- * Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2007 OpenedHand Ltd
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of OpenedHand Ltd not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. OpenedHand Ltd makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors:
- * Dodji Seketeli <dodji@openedhand.com>
- */
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-
-#include <X11/Xdefs.h>
-#include <xcb/xf86dri.h>
-#include "hostx.h"
-#include "ephyrdri.h"
-#define _HAVE_XALLOC_DECLS
-#include "ephyrlog.h"
-#include "dixstruct.h"
-#include "pixmapstr.h"
-
-#ifndef TRUE
-#define TRUE 1
-#endif /*TRUE*/
-#ifndef FALSE
-#define FALSE 0
-#endif /*FALSE*/
- Bool
-ephyrDRIQueryDirectRenderingCapable(int a_screen, Bool *a_is_capable)
-{
- 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");
- 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;
-}
-
-Bool
-ephyrDRIOpenConnection(int a_screen,
- drm_handle_t * a_sarea, char **a_bus_id_string)
-{
- 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);
- 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)
-{
- 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");
- 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;
-}
-
-Bool
-ephyrDRICloseConnection(int a_screen)
-{
- xcb_connection_t *conn = hostx_get_xcbconn();
- int screen = hostx_get_screen();
-
- EPHYR_LOG("enter\n");
- xcb_xf86dri_close_connection(conn, screen);
- EPHYR_LOG("leave\n");
- return TRUE;
-}
-
-Bool
-ephyrDRIGetClientDriverName(int a_screen,
- int *a_ddx_driver_major_version,
- int *a_ddx_driver_minor_version,
- int *a_ddx_driver_patch_version,
- char **a_client_driver_name)
-{
- 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
- && a_ddx_driver_minor_version
- && a_ddx_driver_patch_version
- && a_client_driver_name, FALSE);
- EPHYR_LOG("enter\n");
- 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;
-}
-
-Bool
-ephyrDRICreateContext(int a_screen,
- int a_visual_id,
- CARD32 ctxt_id, drm_context_t * a_hw_ctxt)
-{
- xcb_connection_t *conn = hostx_get_xcbconn();
- int screen = hostx_get_screen();
- Bool is_ok = FALSE;
- 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);
- 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;
-}
-
-Bool
-ephyrDRIDestroyContext(int a_screen, int a_context_id)
-{
- xcb_connection_t *conn = hostx_get_xcbconn ();
- int screen = hostx_get_screen();
-
- EPHYR_LOG("enter\n");
- xcb_xf86dri_destroy_context(conn, screen, a_context_id);
- EPHYR_LOG("leave\n");
- return TRUE;
-}
-
-Bool
-ephyrDRICreateDrawable(int a_screen,
- int a_drawable, drm_drawable_t * a_hw_drawable)
-{
- Bool is_ok = FALSE;
- 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");
- 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;
-}
-
-Bool
-ephyrDRIDestroyDrawable(int a_screen, int a_drawable)
-{
- EPHYR_LOG("enter\n");
- EPHYR_LOG_ERROR("not implemented yet\n");
- EPHYR_LOG("leave\n");
- return FALSE;
-}
-
-Bool
-ephyrDRIGetDrawableInfo(int a_screen,
- int a_drawable,
- unsigned int *a_index,
- unsigned int *a_stamp,
- int *a_x,
- int *a_y,
- int *a_w,
- int *a_h,
- int *a_num_clip_rects,
- drm_clip_rect_t ** a_clip_rects,
- int *a_back_x,
- int *a_back_y,
- int *a_num_back_clip_rects,
- drm_clip_rect_t ** a_back_clip_rects)
-{
- Bool is_ok = FALSE;
- 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
- && a_num_clip_rects, FALSE);
-
- EPHYR_LOG("enter\n");
- memset(&attrs, 0, sizeof(attrs));
- if (!hostx_get_window_attributes(a_drawable, &attrs)) {
- EPHYR_LOG_ERROR("failed to query host window attributes\n");
- goto out;
- }
- 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);
- *a_back_clip_rects = calloc(*a_num_clip_rects, sizeof(drm_clip_rect_t));
- memmove(*a_back_clip_rects,
- *a_clip_rects, *a_num_clip_rects * sizeof(drm_clip_rect_t));
- *a_num_back_clip_rects = *a_num_clip_rects;
- }
- EPHYR_LOG("num back clip rects:%d, num clip rects:%d\n",
- *a_num_clip_rects, *a_num_back_clip_rects);
- *a_back_x = *a_x;
- *a_back_y = *a_y;
- *a_w = attrs.width;
- *a_h = attrs.height;
-
- is_ok = TRUE;
- 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;
-}
-
-Bool
-ephyrDRIGetDeviceInfo(int a_screen,
- drm_handle_t * a_frame_buffer,
- int *a_fb_origin,
- int *a_fb_size,
- int *a_fb_stride,
- int *a_dev_private_size, void **a_dev_private)
-{
- Bool is_ok = FALSE;
- 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(conn, FALSE);
- EPHYR_LOG("enter\n");
- 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;
-}
diff --git a/hw/kdrive/ephyr/ephyrdri.h b/hw/kdrive/ephyr/ephyrdri.h
deleted file mode 100644
index b312e62d9..000000000
--- a/hw/kdrive/ephyr/ephyrdri.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Xephyr - A kdrive X server thats runs in a host X window.
- * Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2007 OpenedHand Ltd
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of OpenedHand Ltd not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. OpenedHand Ltd makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors:
- * Dodji Seketeli <dodji@openedhand.com>
- */
-
-#ifndef __EPHYRDRI_H__
-#define __EPHYRDRI_H__
-
-#include <xf86drm.h>
-
-Bool ephyrDRIQueryDirectRenderingCapable(int a_screen, Bool *a_is_capable);
-Bool ephyrDRIOpenConnection(int screen, drm_handle_t * a_sarea,
- char **a_bus_id_string);
-Bool ephyrDRIAuthConnection(int a_screen, drm_magic_t a_magic);
-Bool ephyrDRICloseConnection(int a_screen);
-Bool ephyrDRIGetClientDriverName(int a_screen,
- int *a_ddx_driver_major_version,
- int *a_ddx_driver_minor_version,
- int *a_ddx_driver_patch_version,
- char **a_client_driver_name);
-Bool ephyrDRICreateContext(int a_screen,
- int a_visual_id,
- CARD32 ctx_id, drm_context_t * a_hw_ctx);
-Bool ephyrDRIDestroyContext(int a_screen, int a_context_id);
-Bool ephyrDRICreateDrawable(int a_screen,
- int a_drawable, drm_drawable_t * a_hw_drawable);
-Bool ephyrDRIDestroyDrawable(int a_screen, int a_drawable);
-Bool ephyrDRIGetDrawableInfo(int a_screen, int /*Drawable */ a_drawable,
- unsigned int *a_index,
- unsigned int *a_stamp,
- int *a_x,
- int *a_y,
- int *a_w,
- int *a_h,
- int *a_num_clip_rects,
- drm_clip_rect_t ** a_clip_rects,
- int *a_back_x,
- int *a_back_y,
- int *num_back_clip_rects,
- drm_clip_rect_t ** a_back_clip_rects);
-Bool ephyrDRIGetDeviceInfo(int a_screen,
- drm_handle_t * a_frame_buffer,
- int *a_fb_origin,
- int *a_fb_size,
- int *a_fb_stride,
- int *a_dev_private_size, void **a_dev_private);
-#endif /*__EPHYRDRI_H__*/
diff --git a/hw/kdrive/ephyr/ephyrdriext.c b/hw/kdrive/ephyr/ephyrdriext.c
deleted file mode 100644
index 3703adf8c..000000000
--- a/hw/kdrive/ephyr/ephyrdriext.c
+++ /dev/null
@@ -1,1376 +0,0 @@
-/*
- * Xephyr - A kdrive X server thats runs in a host X window.
- * Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2007 OpenedHand Ltd
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of OpenedHand Ltd not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. OpenedHand Ltd makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * This file is heavily copied from hw/xfree86/dri/xf86dri.c
- *
- * Authors:
- * Dodji Seketeli <dodji@openedhand.com>
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-
-#include <string.h>
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#define _XF86DRI_SERVER_
-#include <X11/dri/xf86dri.h>
-#include <X11/dri/xf86driproto.h>
-#include <xcb/xcb.h>
-#include <xcb/shape.h>
-#include <xcb/xf86dri.h>
-#include "misc.h"
-#include "privates.h"
-#include "dixstruct.h"
-#include "extnsionst.h"
-#include "colormapst.h"
-#include "cursorstr.h"
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "servermd.h"
-#include "swaprep.h"
-#include "ephyrdri.h"
-#include "ephyrdriext.h"
-#include "hostx.h"
-#define _HAVE_XALLOC_DECLS
-#include "ephyrlog.h"
-#include "protocol-versions.h"
-
-typedef struct {
- int foo;
-} EphyrDRIWindowPrivRec;
-typedef EphyrDRIWindowPrivRec *EphyrDRIWindowPrivPtr;
-
-typedef struct {
- CreateWindowProcPtr CreateWindow;
- DestroyWindowProcPtr DestroyWindow;
- MoveWindowProcPtr MoveWindow;
- PositionWindowProcPtr PositionWindow;
- ClipNotifyProcPtr ClipNotify;
-} EphyrDRIScreenPrivRec;
-typedef EphyrDRIScreenPrivRec *EphyrDRIScreenPrivPtr;
-
-static int DRIErrorBase;
-
-static Bool ephyrDRIScreenInit(ScreenPtr a_screen);
-static Bool ephyrDRICreateWindow(WindowPtr a_win);
-static Bool ephyrDRIDestroyWindow(WindowPtr a_win);
-static void ephyrDRIMoveWindow(WindowPtr a_win,
- int a_x, int a_y,
- WindowPtr a_siblings, VTKind a_kind);
-static Bool ephyrDRIPositionWindow(WindowPtr a_win, int x, int y);
-static void ephyrDRIClipNotify(WindowPtr a_win, int a_x, int a_y);
-
-static Bool EphyrMirrorHostVisuals(ScreenPtr a_screen);
-static Bool destroyHostPeerWindow(const WindowPtr a_win);
-static Bool findWindowPairFromLocal(WindowPtr a_local,
- EphyrWindowPair ** a_pair);
-
-static unsigned char DRIReqCode = 0;
-
-static DevPrivateKeyRec ephyrDRIWindowKeyRec;
-
-#define ephyrDRIWindowKey (&ephyrDRIWindowKeyRec)
-static DevPrivateKeyRec ephyrDRIScreenKeyRec;
-
-#define ephyrDRIScreenKey (&ephyrDRIScreenKeyRec)
-
-#define GET_EPHYR_DRI_WINDOW_PRIV(win) ((EphyrDRIWindowPrivPtr) \
- dixLookupPrivate(&(win)->devPrivates, ephyrDRIWindowKey))
-#define GET_EPHYR_DRI_SCREEN_PRIV(screen) ((EphyrDRIScreenPrivPtr) \
- dixLookupPrivate(&(screen)->devPrivates, ephyrDRIScreenKey))
-
-static Bool
-ephyrDRIScreenInit(ScreenPtr a_screen)
-{
- Bool is_ok = FALSE;
- EphyrDRIScreenPrivPtr screen_priv = NULL;
-
- EPHYR_RETURN_VAL_IF_FAIL(a_screen, FALSE);
-
- screen_priv = GET_EPHYR_DRI_SCREEN_PRIV(a_screen);
- EPHYR_RETURN_VAL_IF_FAIL(screen_priv, FALSE);
-
- screen_priv->CreateWindow = a_screen->CreateWindow;
- screen_priv->DestroyWindow = a_screen->DestroyWindow;
- screen_priv->MoveWindow = a_screen->MoveWindow;
- screen_priv->PositionWindow = a_screen->PositionWindow;
- screen_priv->ClipNotify = a_screen->ClipNotify;
-
- a_screen->CreateWindow = ephyrDRICreateWindow;
- a_screen->DestroyWindow = ephyrDRIDestroyWindow;
- a_screen->MoveWindow = ephyrDRIMoveWindow;
- a_screen->PositionWindow = ephyrDRIPositionWindow;
- a_screen->ClipNotify = ephyrDRIClipNotify;
-
- is_ok = TRUE;
-
- return is_ok;
-}
-
-static Bool
-ephyrDRICreateWindow(WindowPtr a_win)
-{
- Bool is_ok = FALSE;
- ScreenPtr screen = NULL;
- EphyrDRIScreenPrivPtr screen_priv = NULL;
-
- EPHYR_RETURN_VAL_IF_FAIL(a_win, FALSE);
- screen = a_win->drawable.pScreen;
- EPHYR_RETURN_VAL_IF_FAIL(screen, FALSE);
- screen_priv = GET_EPHYR_DRI_SCREEN_PRIV(screen);
- EPHYR_RETURN_VAL_IF_FAIL(screen_priv && screen_priv->CreateWindow, FALSE);
-
- EPHYR_LOG("enter. win:%p\n", a_win);
-
- screen->CreateWindow = screen_priv->CreateWindow;
- is_ok = (*screen->CreateWindow) (a_win);
- screen->CreateWindow = ephyrDRICreateWindow;
-
- if (is_ok) {
- dixSetPrivate(&a_win->devPrivates, ephyrDRIWindowKey, NULL);
- }
- return is_ok;
-}
-
-static Bool
-ephyrDRIDestroyWindow(WindowPtr a_win)
-{
- Bool is_ok = FALSE;
- ScreenPtr screen = NULL;
- EphyrDRIScreenPrivPtr screen_priv = NULL;
-
- EPHYR_RETURN_VAL_IF_FAIL(a_win, FALSE);
- screen = a_win->drawable.pScreen;
- EPHYR_RETURN_VAL_IF_FAIL(screen, FALSE);
- screen_priv = GET_EPHYR_DRI_SCREEN_PRIV(screen);
- EPHYR_RETURN_VAL_IF_FAIL(screen_priv && screen_priv->DestroyWindow, FALSE);
-
- screen->DestroyWindow = screen_priv->DestroyWindow;
- if (screen->DestroyWindow) {
- is_ok = (*screen->DestroyWindow) (a_win);
- }
- screen->DestroyWindow = ephyrDRIDestroyWindow;
-
- if (is_ok) {
- EphyrDRIWindowPrivPtr win_priv = GET_EPHYR_DRI_WINDOW_PRIV(a_win);
-
- if (win_priv) {
- destroyHostPeerWindow(a_win);
- free(win_priv);
- dixSetPrivate(&a_win->devPrivates, ephyrDRIWindowKey, NULL);
- EPHYR_LOG("destroyed the remote peer window\n");
- }
- }
- return is_ok;
-}
-
-static void
-ephyrDRIMoveWindow(WindowPtr a_win,
- int a_x, int a_y, WindowPtr a_siblings, VTKind a_kind)
-{
- ScreenPtr screen = NULL;
- EphyrDRIScreenPrivPtr screen_priv = NULL;
- EphyrDRIWindowPrivPtr win_priv = NULL;
- EphyrWindowPair *pair = NULL;
- EphyrBox geo;
- int x = 0, y = 0; /*coords relative to parent window */
-
- EPHYR_RETURN_IF_FAIL(a_win);
-
- EPHYR_LOG("enter\n");
- screen = a_win->drawable.pScreen;
- EPHYR_RETURN_IF_FAIL(screen);
- screen_priv = GET_EPHYR_DRI_SCREEN_PRIV(screen);
- EPHYR_RETURN_IF_FAIL(screen_priv && screen_priv->MoveWindow);
-
- screen->MoveWindow = screen_priv->MoveWindow;
- if (screen->MoveWindow) {
- (*screen->MoveWindow) (a_win, a_x, a_y, a_siblings, a_kind);
- }
- screen->MoveWindow = ephyrDRIMoveWindow;
-
- EPHYR_LOG("window: %p\n", a_win);
- if (!a_win->parent) {
- EPHYR_LOG("cannot move root window\n");
- return;
- }
- win_priv = GET_EPHYR_DRI_WINDOW_PRIV(a_win);
- if (!win_priv) {
- EPHYR_LOG("not a DRI peered window\n");
- return;
- }
- if (!findWindowPairFromLocal(a_win, &pair) || !pair) {
- EPHYR_LOG_ERROR("failed to get window pair\n");
- return;
- }
- /*compute position relative to parent window */
- x = a_win->drawable.x - a_win->parent->drawable.x;
- y = a_win->drawable.y - a_win->parent->drawable.y;
- /*set the geometry to pass to hostx_set_window_geometry */
- memset(&geo, 0, sizeof(geo));
- geo.x = x;
- geo.y = y;
- geo.width = a_win->drawable.width;
- geo.height = a_win->drawable.height;
- hostx_set_window_geometry(pair->remote, &geo);
-}
-
-static Bool
-ephyrDRIPositionWindow(WindowPtr a_win, int a_x, int a_y)
-{
- Bool is_ok = FALSE;
- ScreenPtr screen = NULL;
- EphyrDRIScreenPrivPtr screen_priv = NULL;
- EphyrDRIWindowPrivPtr win_priv = NULL;
- EphyrWindowPair *pair = NULL;
- EphyrBox geo;
-
- EPHYR_RETURN_VAL_IF_FAIL(a_win, FALSE);
-
- EPHYR_LOG("enter\n");
- screen = a_win->drawable.pScreen;
- EPHYR_RETURN_VAL_IF_FAIL(screen, FALSE);
- screen_priv = GET_EPHYR_DRI_SCREEN_PRIV(screen);
- EPHYR_RETURN_VAL_IF_FAIL(screen_priv && screen_priv->PositionWindow, FALSE);
-
- screen->PositionWindow = screen_priv->PositionWindow;
- if (screen->PositionWindow) {
- (*screen->PositionWindow) (a_win, a_x, a_y);
- }
- screen->PositionWindow = ephyrDRIPositionWindow;
-
- EPHYR_LOG("window: %p\n", a_win);
- win_priv = GET_EPHYR_DRI_WINDOW_PRIV(a_win);
- if (!win_priv) {
- EPHYR_LOG("not a DRI peered window\n");
- is_ok = TRUE;
- goto out;
- }
- if (!findWindowPairFromLocal(a_win, &pair) || !pair) {
- EPHYR_LOG_ERROR("failed to get window pair\n");
- goto out;
- }
- /*set the geometry to pass to hostx_set_window_geometry */
- memset(&geo, 0, sizeof(geo));
- geo.x = a_x;
- geo.y = a_y;
- geo.width = a_win->drawable.width;
- geo.height = a_win->drawable.height;
- hostx_set_window_geometry(pair->remote, &geo);
- is_ok = TRUE;
-
- out:
- EPHYR_LOG("leave. is_ok:%d\n", is_ok);
- /*do cleanup here */
- return is_ok;
-}
-
-static void
-ephyrDRIClipNotify(WindowPtr a_win, int a_x, int a_y)
-{
- ScreenPtr screen = NULL;
- EphyrDRIScreenPrivPtr screen_priv = NULL;
- EphyrDRIWindowPrivPtr win_priv = NULL;
- EphyrWindowPair *pair = NULL;
- EphyrRect *rects = NULL;
- int i = 0;
-
- EPHYR_RETURN_IF_FAIL(a_win);
-
- EPHYR_LOG("enter\n");
- screen = a_win->drawable.pScreen;
- EPHYR_RETURN_IF_FAIL(screen);
- screen_priv = GET_EPHYR_DRI_SCREEN_PRIV(screen);
- EPHYR_RETURN_IF_FAIL(screen_priv && screen_priv->ClipNotify);
-
- screen->ClipNotify = screen_priv->ClipNotify;
- if (screen->ClipNotify) {
- (*screen->ClipNotify) (a_win, a_x, a_y);
- }
- screen->ClipNotify = ephyrDRIClipNotify;
-
- EPHYR_LOG("window: %p\n", a_win);
- win_priv = GET_EPHYR_DRI_WINDOW_PRIV(a_win);
- if (!win_priv) {
- EPHYR_LOG("not a DRI peered window\n");
- goto out;
- }
- if (!findWindowPairFromLocal(a_win, &pair) || !pair) {
- EPHYR_LOG_ERROR("failed to get window pair\n");
- goto out;
- }
- rects = calloc(RegionNumRects(&a_win->clipList), sizeof(EphyrRect));
- for (i = 0; i < RegionNumRects(&a_win->clipList); i++) {
- memmove(&rects[i],
- &RegionRects(&a_win->clipList)[i], sizeof(EphyrRect));
- rects[i].x1 -= a_win->drawable.x;
- rects[i].x2 -= a_win->drawable.x;
- rects[i].y1 -= a_win->drawable.y;
- rects[i].y2 -= a_win->drawable.y;
- }
- /*
- * push the clipping region of this window
- * to the peer window in the host
- */
- hostx_set_window_bounding_rectangles
- (pair->remote, rects, RegionNumRects(&a_win->clipList));
-
- out:
- free(rects);
- rects = NULL;
-
- EPHYR_LOG("leave.\n");
- /*do cleanup here */
-}
-
-/**
- * Duplicates a visual of a_screen
- * In screen a_screen, for depth a_depth, find a visual which
- * bitsPerRGBValue and colormap size equal
- * a_bits_per_rgb_values and a_colormap_entries.
- * The ID of that duplicated visual is set to a_new_id.
- * That duplicated visual is then added to the list of visuals
- * of the screen.
- */
-static Bool
-EphyrDuplicateVisual(unsigned int a_screen,
- short a_depth,
- short a_class,
- short a_bits_per_rgb_values,
- short a_colormap_entries,
- unsigned int a_red_mask,
- unsigned int a_green_mask,
- unsigned int a_blue_mask, unsigned int a_new_id)
-{
- Bool is_ok = FALSE, found_visual = FALSE, found_depth = FALSE;
- ScreenPtr screen = NULL;
- VisualRec new_visual, *new_visuals = NULL;
- int i = 0;
-
- EPHYR_LOG("enter\n");
- if (a_screen >= screenInfo.numScreens) {
- EPHYR_LOG_ERROR("bad screen number\n");
- goto out;
- }
- memset(&new_visual, 0, sizeof(VisualRec));
-
- /*get the screen pointed to by a_screen */
- screen = screenInfo.screens[a_screen];
- EPHYR_RETURN_VAL_IF_FAIL(screen, FALSE);
-
- /*
- * In that screen, first look for an existing visual that has the
- * same characteristics as those passed in parameter
- * to this function and copy it.
- */
- for (i = 0; i < screen->numVisuals; i++) {
- if (screen->visuals[i].bitsPerRGBValue == a_bits_per_rgb_values &&
- screen->visuals[i].ColormapEntries == a_colormap_entries) {
- /*copy the visual found */
- memcpy(&new_visual, &screen->visuals[i], sizeof(new_visual));
- new_visual.vid = a_new_id;
- new_visual.class = a_class;
- new_visual.redMask = a_red_mask;
- new_visual.greenMask = a_green_mask;
- new_visual.blueMask = a_blue_mask;
- found_visual = TRUE;
- EPHYR_LOG("found a visual that matches visual id: %d\n", a_new_id);
- break;
- }
- }
- if (!found_visual) {
- EPHYR_LOG("did not find any visual matching %d\n", a_new_id);
- goto out;
- }
- /*
- * be prepare to extend screen->visuals to add new_visual to it
- */
- new_visuals = calloc(screen->numVisuals + 1, sizeof(VisualRec));
- memmove(new_visuals,
- screen->visuals, screen->numVisuals * sizeof(VisualRec));
- memmove(&new_visuals[screen->numVisuals], &new_visual, sizeof(VisualRec));
- /*
- * Now, in that same screen, update the screen->allowedDepths member.
- * In that array, each element represents the visuals applicable to
- * a given depth. So we need to add an entry matching the new visual
- * that we are going to add to screen->visuals
- */
- for (i = 0; i < screen->numDepths; i++) {
- VisualID *vids = NULL;
- DepthPtr cur_depth = NULL;
-
- /*find the entry matching a_depth */
- if (screen->allowedDepths[i].depth != a_depth)
- continue;
- cur_depth = &screen->allowedDepths[i];
- /*
- * extend the list of visual IDs in that entry,
- * so to add a_new_id in there.
- */
- vids = reallocarray(cur_depth->vids,
- cur_depth->numVids + 1, sizeof(VisualID));
- if (!vids) {
- EPHYR_LOG_ERROR("failed to realloc numids\n");
- goto out;
- }
- vids[cur_depth->numVids] = a_new_id;
- /*
- * Okay now commit our change.
- * Do really update screen->allowedDepths[i]
- */
- cur_depth->numVids++;
- cur_depth->vids = vids;
- found_depth = TRUE;
- }
- if (!found_depth) {
- EPHYR_LOG_ERROR("failed to update screen[%d]->allowedDepth\n",
- a_screen);
- goto out;
- }
- /*
- * Commit our change to screen->visuals
- */
- free(screen->visuals);
- screen->visuals = new_visuals;
- screen->numVisuals++;
- new_visuals = NULL;
-
- is_ok = TRUE;
- out:
- free(new_visuals);
- new_visuals = NULL;
-
- EPHYR_LOG("leave\n");
- return is_ok;
-}
-
-/**
- * Duplicates the visuals of the host X server.
- * This is necessary to have visuals that have the same
- * ID as those of the host X. It is important to have that for
- * GLX.
- */
-static Bool
-EphyrMirrorHostVisuals(ScreenPtr a_screen)
-{
- Bool is_ok = FALSE;
- EphyrHostVisualInfo *visuals = NULL;
- int nb_visuals = 0, i = 0;
-
- EPHYR_LOG("enter\n");
- if (!hostx_get_visuals_info(&visuals, &nb_visuals)) {
- EPHYR_LOG_ERROR("failed to get host visuals\n");
- goto out;
- }
- for (i = 0; i < nb_visuals; i++) {
- if (!EphyrDuplicateVisual(a_screen->myNum,
- visuals[i].depth,
- visuals[i].class,
- visuals[i].bits_per_rgb,
- visuals[i].colormap_size,
- visuals[i].red_mask,
- visuals[i].green_mask,
- visuals[i].blue_mask, visuals[i].visualid)) {
- EPHYR_LOG_ERROR("failed to duplicate host visual %d\n",
- (int) visuals[i].visualid);
- }
- }
-
- is_ok = TRUE;
- out:
- EPHYR_LOG("leave\n");
- return is_ok;
-}
-
-static int
-ProcXF86DRIQueryVersion(register ClientPtr client)
-{
- xXF86DRIQueryVersionReply rep = {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = 0,
- .majorVersion = SERVER_XF86DRI_MAJOR_VERSION,
- .minorVersion = SERVER_XF86DRI_MINOR_VERSION,
- .patchVersion = SERVER_XF86DRI_PATCH_VERSION
- };
-
- REQUEST_SIZE_MATCH(xXF86DRIQueryVersionReq);
-
- EPHYR_LOG("enter\n");
-
- if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swaps(&rep.majorVersion);
- swaps(&rep.minorVersion);
- swapl(&rep.patchVersion);
- }
- WriteToClient(client, sizeof(xXF86DRIQueryVersionReply), &rep);
- EPHYR_LOG("leave\n");
- return Success;
-}
-
-static int
-ProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client)
-{
- xXF86DRIQueryDirectRenderingCapableReply rep;
- Bool isCapable;
-
- REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
- REQUEST_SIZE_MATCH(xXF86DRIQueryDirectRenderingCapableReq);
-
- EPHYR_LOG("enter\n");
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- if (!ephyrDRIQueryDirectRenderingCapable(stuff->screen, &isCapable)) {
- return BadValue;
- }
-
- if (!client->local || client->swapped)
- isCapable = 0;
-
- rep = (xXF86DRIQueryDirectRenderingCapableReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = 0,
- .isCapable = isCapable
- };
-
- if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- }
-
- WriteToClient(client, sizeof(xXF86DRIQueryDirectRenderingCapableReply),
- &rep);
- EPHYR_LOG("leave\n");
-
- return Success;
-}
-
-static int
-ProcXF86DRIOpenConnection(register ClientPtr client)
-{
- xXF86DRIOpenConnectionReply rep;
- drm_handle_t hSAREA;
- char *busIdString = NULL;
- CARD32 busIdStringLength = 0;
-
- REQUEST(xXF86DRIOpenConnectionReq);
- REQUEST_SIZE_MATCH(xXF86DRIOpenConnectionReq);
-
- EPHYR_LOG("enter\n");
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- if (!ephyrDRIOpenConnection(stuff->screen, &hSAREA, &busIdString)) {
- return BadValue;
- }
-
- if (busIdString)
- busIdStringLength = strlen(busIdString);
-
- rep = (xXF86DRIOpenConnectionReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = bytes_to_int32(SIZEOF(xXF86DRIOpenConnectionReply) -
- SIZEOF(xGenericReply) +
- pad_to_int32(busIdStringLength)),
- .hSAREALow = (CARD32) (hSAREA & 0xffffffff),
-#if defined(LONG64) && !defined(__linux__)
- .hSAREAHigh = (CARD32) (hSAREA >> 32),
-#else
- .hSAREAHigh = 0,
-#endif
- .busIdStringLength = busIdStringLength
- };
-
- WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), &rep);
- if (busIdStringLength)
- WriteToClient(client, busIdStringLength, busIdString);
- free(busIdString);
- EPHYR_LOG("leave\n");
- return Success;
-}
-
-static int
-ProcXF86DRIAuthConnection(register ClientPtr client)
-{
- xXF86DRIAuthConnectionReply rep;
-
- REQUEST(xXF86DRIAuthConnectionReq);
- REQUEST_SIZE_MATCH(xXF86DRIAuthConnectionReq);
-
- EPHYR_LOG("enter\n");
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- rep = (xXF86DRIAuthConnectionReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = 0,
- .authenticated = 1
- };
-
- if (!ephyrDRIAuthConnection(stuff->screen, stuff->magic)) {
- ErrorF("Failed to authenticate %lu\n", (unsigned long) stuff->magic);
- rep.authenticated = 0;
- }
- WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), &rep);
- EPHYR_LOG("leave\n");
- return Success;
-}
-
-static int
-ProcXF86DRICloseConnection(register ClientPtr client)
-{
- REQUEST(xXF86DRICloseConnectionReq);
- REQUEST_SIZE_MATCH(xXF86DRICloseConnectionReq);
- EPHYR_LOG("enter\n");
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- /*
- DRICloseConnection( screenInfo.screens[stuff->screen]);
- */
-
- EPHYR_LOG("leave\n");
- return Success;
-}
-
-static int
-ProcXF86DRIGetClientDriverName(register ClientPtr client)
-{
- xXF86DRIGetClientDriverNameReply rep = {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .clientDriverNameLength = 0
- };
- char *clientDriverName;
-
- REQUEST(xXF86DRIGetClientDriverNameReq);
- REQUEST_SIZE_MATCH(xXF86DRIGetClientDriverNameReq);
-
- EPHYR_LOG("enter\n");
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- ephyrDRIGetClientDriverName(stuff->screen,
- (int *) &rep.ddxDriverMajorVersion,
- (int *) &rep.ddxDriverMinorVersion,
- (int *) &rep.ddxDriverPatchVersion,
- &clientDriverName);
- if (clientDriverName)
- rep.clientDriverNameLength = strlen(clientDriverName);
- rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetClientDriverNameReply) -
- SIZEOF(xGenericReply) +
- pad_to_int32(rep.clientDriverNameLength));
-
- WriteToClient(client, sizeof(xXF86DRIGetClientDriverNameReply), &rep);
- if (rep.clientDriverNameLength)
- WriteToClient(client, rep.clientDriverNameLength, clientDriverName);
- EPHYR_LOG("leave\n");
- return Success;
-}
-
-static int
-ProcXF86DRICreateContext(register ClientPtr client)
-{
- xXF86DRICreateContextReply rep = {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = 0
- };
- ScreenPtr pScreen;
- VisualPtr visual;
- int i = 0;
-
- REQUEST(xXF86DRICreateContextReq);
- REQUEST_SIZE_MATCH(xXF86DRICreateContextReq);
-
- EPHYR_LOG("enter\n");
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- pScreen = screenInfo.screens[stuff->screen];
- visual = pScreen->visuals;
-
- /* Find the requested X visual */
- for (i = 0; i < pScreen->numVisuals; i++, visual++)
- if (visual->vid == stuff->visual)
- break;
- if (i == pScreen->numVisuals) {
- /* No visual found */
- return BadValue;
- }
-
- if (!ephyrDRICreateContext(stuff->screen,
- stuff->visual,
- stuff->context,
- (drm_context_t *) &rep.hHWContext)) {
- return BadValue;
- }
-
- WriteToClient(client, sizeof(xXF86DRICreateContextReply), &rep);
- EPHYR_LOG("leave\n");
- return Success;
-}
-
-static int
-ProcXF86DRIDestroyContext(register ClientPtr client)
-{
- REQUEST(xXF86DRIDestroyContextReq);
- REQUEST_SIZE_MATCH(xXF86DRIDestroyContextReq);
- EPHYR_LOG("enter\n");
-
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- if (!ephyrDRIDestroyContext(stuff->screen, stuff->context)) {
- return BadValue;
- }
-
- EPHYR_LOG("leave\n");
- return Success;
-}
-
-static Bool
-getWindowVisual(const WindowPtr a_win, VisualPtr * a_visual)
-{
- int i = 0, visual_id = 0;
-
- EPHYR_RETURN_VAL_IF_FAIL(a_win
- && a_win->drawable.pScreen
- && a_win->drawable.pScreen->visuals, FALSE);
-
- visual_id = wVisual(a_win);
- for (i = 0; i < a_win->drawable.pScreen->numVisuals; i++) {
- if (a_win->drawable.pScreen->visuals[i].vid == visual_id) {
- *a_visual = &a_win->drawable.pScreen->visuals[i];
- return TRUE;
- }
- }
- return FALSE;
-}
-
-#define NUM_WINDOW_PAIRS 256
-static EphyrWindowPair window_pairs[NUM_WINDOW_PAIRS];
-
-static Bool
-appendWindowPairToList(WindowPtr a_local, int a_remote)
-{
- int i = 0;
-
- EPHYR_RETURN_VAL_IF_FAIL(a_local, FALSE);
-
- EPHYR_LOG("(local,remote):(%p, %d)\n", a_local, a_remote);
-
- for (i = 0; i < NUM_WINDOW_PAIRS; i++) {
- if (window_pairs[i].local == NULL) {
- window_pairs[i].local = a_local;
- window_pairs[i].remote = a_remote;
- return TRUE;
- }
- }
- return FALSE;
-}
-
-static Bool
-findWindowPairFromLocal(WindowPtr a_local, EphyrWindowPair ** a_pair)
-{
- int i = 0;
-
- EPHYR_RETURN_VAL_IF_FAIL(a_pair && a_local, FALSE);
-
- for (i = 0; i < NUM_WINDOW_PAIRS; i++) {
- if (window_pairs[i].local == a_local) {
- *a_pair = &window_pairs[i];
- EPHYR_LOG("found (%p, %d)\n", (*a_pair)->local, (*a_pair)->remote);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-Bool
-findWindowPairFromRemote(int a_remote, EphyrWindowPair ** a_pair)
-{
- int i = 0;
-
- EPHYR_RETURN_VAL_IF_FAIL(a_pair, FALSE);
-
- for (i = 0; i < NUM_WINDOW_PAIRS; i++) {
- if (window_pairs[i].remote == a_remote) {
- *a_pair = &window_pairs[i];
- EPHYR_LOG("found (%p, %d)\n", (*a_pair)->local, (*a_pair)->remote);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-static Bool
-createHostPeerWindow(const WindowPtr a_win, int *a_peer_win)
-{
- Bool is_ok = FALSE;
- VisualPtr visual = NULL;
- EphyrBox geo;
-
- EPHYR_RETURN_VAL_IF_FAIL(a_win && a_peer_win, FALSE);
- EPHYR_RETURN_VAL_IF_FAIL(a_win->drawable.pScreen, FALSE);
-
- EPHYR_LOG("enter. a_win '%p'\n", a_win);
- if (!getWindowVisual(a_win, &visual)) {
- EPHYR_LOG_ERROR("failed to get window visual\n");
- goto out;
- }
- if (!visual) {
- EPHYR_LOG_ERROR("failed to create visual\n");
- goto out;
- }
- memset(&geo, 0, sizeof(geo));
- geo.x = a_win->drawable.x;
- geo.y = a_win->drawable.y;
- geo.width = a_win->drawable.width;
- geo.height = a_win->drawable.height;
- if (!hostx_create_window(a_win->drawable.pScreen->myNum,
- &geo, visual->vid, a_peer_win)) {
- EPHYR_LOG_ERROR("failed to create host peer window\n");
- goto out;
- }
- if (!appendWindowPairToList(a_win, *a_peer_win)) {
- EPHYR_LOG_ERROR("failed to append window to pair list\n");
- goto out;
- }
- is_ok = TRUE;
- out:
- EPHYR_LOG("leave:remote win%d\n", *a_peer_win);
- return is_ok;
-}
-
-static Bool
-destroyHostPeerWindow(const WindowPtr a_win)
-{
- Bool is_ok = FALSE;
- EphyrWindowPair *pair = NULL;
-
- EPHYR_RETURN_VAL_IF_FAIL(a_win, FALSE);
-
- EPHYR_LOG("enter\n");
-
- if (!findWindowPairFromLocal(a_win, &pair) || !pair) {
- EPHYR_LOG_ERROR("failed to find peer to local window\n");
- goto out;
- }
- hostx_destroy_window(pair->remote);
- is_ok = TRUE;
-
- out:
- EPHYR_LOG("leave\n");
- return is_ok;
-}
-
-static int
-ProcXF86DRICreateDrawable(ClientPtr client)
-{
- xXF86DRICreateDrawableReply rep = {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = 0
- };
- DrawablePtr drawable = NULL;
- WindowPtr window = NULL;
- EphyrWindowPair *pair = NULL;
- EphyrDRIWindowPrivPtr win_priv = NULL;
- int rc = 0, remote_win = 0;
-
- REQUEST(xXF86DRICreateDrawableReq);
- REQUEST_SIZE_MATCH(xXF86DRICreateDrawableReq);
-
- EPHYR_LOG("enter\n");
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- rc = dixLookupDrawable(&drawable, stuff->drawable, client, 0,
- DixReadAccess);
- if (rc != Success)
- return rc;
- if (drawable->type != DRAWABLE_WINDOW) {
- EPHYR_LOG_ERROR("non drawable windows are not yet supported\n");
- return BadImplementation;
- }
- EPHYR_LOG("lookedup drawable %p\n", drawable);
- window = (WindowPtr) drawable;
- if (findWindowPairFromLocal(window, &pair) && pair) {
- remote_win = pair->remote;
- EPHYR_LOG("found window '%p' paire with remote '%d'\n",
- window, remote_win);
- }
- else if (!createHostPeerWindow(window, &remote_win)) {
- EPHYR_LOG_ERROR("failed to create host peer window\n");
- return BadAlloc;
- }
-
- if (!ephyrDRICreateDrawable(stuff->screen,
- remote_win,
- (drm_drawable_t *) &rep.hHWDrawable)) {
- EPHYR_LOG_ERROR("failed to create dri drawable\n");
- return BadValue;
- }
-
- win_priv = GET_EPHYR_DRI_WINDOW_PRIV(window);
- if (!win_priv) {
- win_priv = calloc(1, sizeof(EphyrDRIWindowPrivRec));
- if (!win_priv) {
- EPHYR_LOG_ERROR("failed to allocate window private\n");
- return BadAlloc;
- }
- dixSetPrivate(&window->devPrivates, ephyrDRIWindowKey, win_priv);
- EPHYR_LOG("paired window '%p' with remote '%d'\n", window, remote_win);
- }
-
- WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), &rep);
- EPHYR_LOG("leave\n");
- return Success;
-}
-
-static int
-ProcXF86DRIDestroyDrawable(register ClientPtr client)
-{
- DrawablePtr drawable = NULL;
- WindowPtr window = NULL;
- EphyrWindowPair *pair = NULL;
- int rc = 0;
-
- REQUEST(xXF86DRIDestroyDrawableReq);
- REQUEST_SIZE_MATCH(xXF86DRIDestroyDrawableReq);
-
- EPHYR_LOG("enter\n");
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- rc = dixLookupDrawable(&drawable,
- stuff->drawable, client, 0, DixReadAccess);
- if (rc != Success)
- return rc;
- if (drawable->type != DRAWABLE_WINDOW) {
- EPHYR_LOG_ERROR("non drawable windows are not yet supported\n");
- return BadImplementation;
- }
- window = (WindowPtr) drawable;
- if (!findWindowPairFromLocal(window, &pair) && pair) {
- EPHYR_LOG_ERROR("failed to find pair window\n");
- return BadImplementation;
- }
- if (!ephyrDRIDestroyDrawable(stuff->screen,
- pair->remote /*drawable in host x */ )) {
- EPHYR_LOG_ERROR("failed to destroy dri drawable\n");
- return BadImplementation;
- }
- pair->local = NULL;
- pair->remote = 0;
-
- EPHYR_LOG("leave\n");
- return Success;
-}
-
-static int
-ProcXF86DRIGetDrawableInfo(register ClientPtr client)
-{
- xXF86DRIGetDrawableInfoReply rep = {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = 0
- };
- DrawablePtr drawable;
- WindowPtr window = NULL;
- EphyrWindowPair *pair = NULL;
- int X = 0, Y = 0, W = 0, H = 0, backX = 0, backY = 0, rc = 0, i = 0;
- drm_clip_rect_t *clipRects = NULL;
- drm_clip_rect_t *backClipRects = NULL;
-
- REQUEST(xXF86DRIGetDrawableInfoReq);
- REQUEST_SIZE_MATCH(xXF86DRIGetDrawableInfoReq);
-
- EPHYR_LOG("enter\n");
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- rc = dixLookupDrawable(&drawable, stuff->drawable, client, 0,
- DixReadAccess);
- if (rc != Success || !drawable) {
- EPHYR_LOG_ERROR("could not get drawable\n");
- return rc;
- }
-
- if (drawable->type != DRAWABLE_WINDOW) {
- EPHYR_LOG_ERROR("non windows type drawables are not yes supported\n");
- return BadImplementation;
- }
- window = (WindowPtr) drawable;
- memset(&pair, 0, sizeof(pair));
- if (!findWindowPairFromLocal(window, &pair) || !pair) {
- EPHYR_LOG_ERROR("failed to find remote peer drawable\n");
- return BadMatch;
- }
- EPHYR_LOG("clip list of xephyr gl drawable:\n");
- for (i = 0; i < RegionNumRects(&window->clipList); i++) {
- EPHYR_LOG("x1:%d, y1:%d, x2:%d, y2:%d\n",
- RegionRects(&window->clipList)[i].x1,
- RegionRects(&window->clipList)[i].y1,
- RegionRects(&window->clipList)[i].x2,
- RegionRects(&window->clipList)[i].y2);
- }
-
- if (!ephyrDRIGetDrawableInfo(stuff->screen,
- pair->remote /*the drawable in hostx */ ,
- (unsigned int *) &rep.drawableTableIndex,
- (unsigned int *) &rep.drawableTableStamp,
- (int *) &X,
- (int *) &Y,
- (int *) &W,
- (int *) &H,
- (int *) &rep.numClipRects,
- &clipRects,
- &backX,
- &backY,
- (int *) &rep.numBackClipRects,
- &backClipRects)) {
- return BadValue;
- }
- EPHYR_LOG("num clip rects:%d, num back clip rects:%d\n",
- (int) rep.numClipRects, (int) rep.numBackClipRects);
-
- rep.drawableX = X;
- rep.drawableY = Y;
- rep.drawableWidth = W;
- rep.drawableHeight = H;
- rep.length = (SIZEOF(xXF86DRIGetDrawableInfoReply) - SIZEOF(xGenericReply));
-
- rep.backX = backX;
- rep.backY = backY;
-
- if (rep.numClipRects) {
- if (clipRects) {
- ScreenPtr pScreen = screenInfo.screens[stuff->screen];
-
- EPHYR_LOG("clip list of host gl drawable:\n");
- for (i = 0; i < rep.numClipRects; i++) {
- clipRects[i].x1 = max(clipRects[i].x1, 0);
- clipRects[i].y1 = max(clipRects[i].y1, 0);
- clipRects[i].x2 = min(clipRects[i].x2,
- pScreen->width + clipRects[i].x1);
- clipRects[i].y2 = min(clipRects[i].y2,
- pScreen->width + clipRects[i].y1);
-
- EPHYR_LOG("x1:%d, y1:%d, x2:%d, y2:%d\n",
- clipRects[i].x1, clipRects[i].y1,
- clipRects[i].x2, clipRects[i].y2);
- }
- }
- else {
- rep.numClipRects = 0;
- }
- }
- else {
- EPHYR_LOG("got zero host gl drawable clipping rects\n");
- }
- rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects;
- backClipRects = clipRects;
- rep.numBackClipRects = rep.numClipRects;
- if (rep.numBackClipRects)
- rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects;
- EPHYR_LOG("num host clip rects:%d\n", (int) rep.numClipRects);
- EPHYR_LOG("num host back clip rects:%d\n", (int) rep.numBackClipRects);
-
- rep.length = bytes_to_int32(rep.length);
-
- WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), &rep);
-
- if (rep.numClipRects) {
- WriteToClient(client,
- sizeof(drm_clip_rect_t) * rep.numClipRects,
- clipRects);
- }
-
- if (rep.numBackClipRects) {
- WriteToClient(client,
- sizeof(drm_clip_rect_t) * rep.numBackClipRects,
- backClipRects);
- }
- free(clipRects);
- clipRects = NULL;
-
- EPHYR_LOG("leave\n");
-
- return Success;
-}
-
-static int
-ProcXF86DRIGetDeviceInfo(register ClientPtr client)
-{
- xXF86DRIGetDeviceInfoReply rep = {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = 0
- };
- drm_handle_t hFrameBuffer;
- void *pDevPrivate;
-
- REQUEST(xXF86DRIGetDeviceInfoReq);
- REQUEST_SIZE_MATCH(xXF86DRIGetDeviceInfoReq);
-
- EPHYR_LOG("enter\n");
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- if (!ephyrDRIGetDeviceInfo(stuff->screen,
- &hFrameBuffer,
- (int *) &rep.framebufferOrigin,
- (int *) &rep.framebufferSize,
- (int *) &rep.framebufferStride,
- (int *) &rep.devPrivateSize, &pDevPrivate)) {
- return BadValue;
- }
-
- rep.hFrameBufferLow = (CARD32) (hFrameBuffer & 0xffffffff);
-#if defined(LONG64) && !defined(__linux__)
- rep.hFrameBufferHigh = (CARD32) (hFrameBuffer >> 32);
-#else
- rep.hFrameBufferHigh = 0;
-#endif
-
- if (rep.devPrivateSize) {
- rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetDeviceInfoReply) -
- SIZEOF(xGenericReply) +
- pad_to_int32(rep.devPrivateSize));
- }
-
- WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), &rep);
- if (rep.length) {
- WriteToClient(client, rep.devPrivateSize, pDevPrivate);
- }
- EPHYR_LOG("leave\n");
- return Success;
-}
-
-static int
-ProcXF86DRIDispatch(register ClientPtr client)
-{
- REQUEST(xReq);
- EPHYR_LOG("enter\n");
-
- switch (stuff->data) {
- case X_XF86DRIQueryVersion:{
- EPHYR_LOG("leave\n");
- return ProcXF86DRIQueryVersion(client);
- }
- case X_XF86DRIQueryDirectRenderingCapable:{
- EPHYR_LOG("leave\n");
- return ProcXF86DRIQueryDirectRenderingCapable(client);
- }
- }
-
- if (!client->local)
- return DRIErrorBase + XF86DRIClientNotLocal;
-
- switch (stuff->data) {
- case X_XF86DRIOpenConnection:{
- EPHYR_LOG("leave\n");
- return ProcXF86DRIOpenConnection(client);
- }
- case X_XF86DRICloseConnection:{
- EPHYR_LOG("leave\n");
- return ProcXF86DRICloseConnection(client);
- }
- case X_XF86DRIGetClientDriverName:{
- EPHYR_LOG("leave\n");
- return ProcXF86DRIGetClientDriverName(client);
- }
- case X_XF86DRICreateContext:{
- EPHYR_LOG("leave\n");
- return ProcXF86DRICreateContext(client);
- }
- case X_XF86DRIDestroyContext:{
- EPHYR_LOG("leave\n");
- return ProcXF86DRIDestroyContext(client);
- }
- case X_XF86DRICreateDrawable:{
- EPHYR_LOG("leave\n");
- return ProcXF86DRICreateDrawable(client);
- }
- case X_XF86DRIDestroyDrawable:{
- EPHYR_LOG("leave\n");
- return ProcXF86DRIDestroyDrawable(client);
- }
- case X_XF86DRIGetDrawableInfo:{
- EPHYR_LOG("leave\n");
- return ProcXF86DRIGetDrawableInfo(client);
- }
- case X_XF86DRIGetDeviceInfo:{
- EPHYR_LOG("leave\n");
- return ProcXF86DRIGetDeviceInfo(client);
- }
- case X_XF86DRIAuthConnection:{
- EPHYR_LOG("leave\n");
- return ProcXF86DRIAuthConnection(client);
- }
- /* {Open,Close}FullScreen are deprecated now */
- default:{
- EPHYR_LOG("leave\n");
- return BadRequest;
- }
- }
-}
-
-static int
-SProcXF86DRIQueryVersion(register ClientPtr client)
-{
- REQUEST(xXF86DRIQueryVersionReq);
- swaps(&stuff->length);
- return ProcXF86DRIQueryVersion(client);
-}
-
-static int
-SProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client)
-{
- REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
- swaps(&stuff->length);
- swapl(&stuff->screen);
- return ProcXF86DRIQueryDirectRenderingCapable(client);
-}
-
-static int
-SProcXF86DRIDispatch(register ClientPtr client)
-{
- REQUEST(xReq);
-
- EPHYR_LOG("enter\n");
- /*
- * Only local clients are allowed DRI access, but remote clients still need
- * these requests to find out cleanly.
- */
- switch (stuff->data) {
- case X_XF86DRIQueryVersion:{
- EPHYR_LOG("leave\n");
- return SProcXF86DRIQueryVersion(client);
- }
- case X_XF86DRIQueryDirectRenderingCapable:{
- EPHYR_LOG("leave\n");
- return SProcXF86DRIQueryDirectRenderingCapable(client);
- }
- default:{
- EPHYR_LOG("leave\n");
- return DRIErrorBase + XF86DRIClientNotLocal;
- }
- }
-}
-
-Bool
-ephyrDRIExtensionInit(ScreenPtr a_screen)
-{
- Bool is_ok = FALSE;
- ExtensionEntry *extEntry = NULL;
- EphyrDRIScreenPrivPtr screen_priv = NULL;
-
- EPHYR_LOG("enter\n");
- if (!hostx_has_extension(&xcb_xf86dri_id)) {
- EPHYR_LOG("host does not have DRI extension\n");
- goto out;
- }
- EPHYR_LOG("host X does have DRI extension\n");
- if (!hostx_has_extension(&xcb_shape_id)) {
- EPHYR_LOG("host does not have XShape extension\n");
- goto out;
- }
- EPHYR_LOG("host X does have XShape extension\n");
-
-#ifdef XF86DRI_EVENTS
- EventType = CreateNewResourceType(XF86DRIFreeEvents, "DRIEvents");
- if (!EventType) {
- EPHYR_LOG_ERROR("failed to register DRI event resource type\n");
- goto out;
- }
-#endif
-
- if ((extEntry = AddExtension(XF86DRINAME,
- XF86DRINumberEvents,
- XF86DRINumberErrors,
- ProcXF86DRIDispatch,
- SProcXF86DRIDispatch,
- NULL, StandardMinorOpcode))) {
- DRIReqCode = (unsigned char) extEntry->base;
- DRIErrorBase = extEntry->errorBase;
- }
- else {
- EPHYR_LOG_ERROR("failed to register DRI extension\n");
- goto out;
- }
- if (!dixRegisterPrivateKey(&ephyrDRIScreenKeyRec, PRIVATE_SCREEN, 0))
- goto out;
- if (!dixRegisterPrivateKey(&ephyrDRIWindowKeyRec, PRIVATE_WINDOW, 0))
- goto out;
- screen_priv = calloc(1, sizeof(EphyrDRIScreenPrivRec));
- if (!screen_priv) {
- EPHYR_LOG_ERROR("failed to allocate screen_priv\n");
- goto out;
- }
- dixSetPrivate(&a_screen->devPrivates, ephyrDRIScreenKey, screen_priv);
-
- if (!ephyrDRIScreenInit(a_screen)) {
- EPHYR_LOG_ERROR("ephyrDRIScreenInit() failed\n");
- goto out;
- }
- EphyrMirrorHostVisuals(a_screen);
- is_ok = TRUE;
- out:
- EPHYR_LOG("leave\n");
- return is_ok;
-}
diff --git a/hw/kdrive/ephyr/ephyrdriext.h b/hw/kdrive/ephyr/ephyrdriext.h
deleted file mode 100644
index 975571582..000000000
--- a/hw/kdrive/ephyr/ephyrdriext.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Xephyr - A kdrive X server thats runs in a host X window.
- * Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2007 OpenedHand Ltd
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of OpenedHand Ltd not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. OpenedHand Ltd makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors:
- * Dodji Seketeli <dodji@openedhand.com>
- */
-#ifndef __EPHYRDRIEXT_H__
-#define __EPHYRDRIEXT_H__
-
-typedef struct {
- WindowPtr local;
- int remote;
-} EphyrWindowPair;
-
-Bool ephyrDRIExtensionInit(ScreenPtr a_screen);
-
-Bool findWindowPairFromRemote(int a_remote, EphyrWindowPair ** a_pair);
-
-#endif /*__EPHYRDRIEXT_H__*/
diff --git a/hw/kdrive/ephyr/ephyrglxext.c b/hw/kdrive/ephyr/ephyrglxext.c
deleted file mode 100644
index c6d156900..000000000
--- a/hw/kdrive/ephyr/ephyrglxext.c
+++ /dev/null
@@ -1,854 +0,0 @@
-/*
- * Xephyr - A kdrive X server thats runs in a host X window.
- * Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2007 OpenedHand Ltd
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of OpenedHand Ltd not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. OpenedHand Ltd makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors:
- * Dodji Seketeli <dodji@openedhand.com>
- */
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-
-#include <xcb/glx.h>
-#include "extnsionst.h"
-#include "ephyrglxext.h"
-#include "ephyrhostglx.h"
-#define _HAVE_XALLOC_DECLS
-#include "ephyrlog.h"
-#include <GL/glxproto.h>
-#include "glx/glxserver.h"
-#include "glx/indirect_table.h"
-#include "glx/indirect_util.h"
-#include "glx/unpack.h"
-#include "hostx.h"
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-int ephyrGLXQueryVersion(__GLXclientState * cl, GLbyte * pc);
-int ephyrGLXQueryVersionSwap(__GLXclientState * cl, GLbyte * pc);
-int ephyrGLXGetVisualConfigs(__GLXclientState * cl, GLbyte * pc);
-int ephyrGLXGetVisualConfigsSwap(__GLXclientState * cl, GLbyte * pc);
-int ephyrGLXClientInfo(__GLXclientState * cl, GLbyte * pc);
-int ephyrGLXClientInfoSwap(__GLXclientState * cl, GLbyte * pc);
-int ephyrGLXQueryServerString(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXQueryServerStringSwap(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXGetFBConfigsSGIX(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXGetFBConfigsSGIXSwap(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXCreateContext(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXCreateContextSwap(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXCreateNewContext(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXCreateNewContextSwap(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXDestroyContext(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXDestroyContextSwap(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXMakeCurrent(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXMakeCurrentSwap(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXMakeCurrentReadSGI(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXMakeCurrentReadSGISwap(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXMakeContextCurrent(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXMakeContextCurrentSwap(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXGetString(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXGetStringSwap(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXGetIntegerv(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXGetIntegervSwap(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXIsDirect(__GLXclientState * a_cl, GLbyte * a_pc);
-int ephyrGLXIsDirectSwap(__GLXclientState * a_cl, GLbyte * a_pc);
-
-Bool
-ephyrHijackGLXExtension(void)
-{
- const void *(*dispatch_functions)[2];
-
- if (!hostx_has_extension(&xcb_glx_id)) {
- EPHYR_LOG("host X does not have GLX\n");
- return FALSE;
- }
- EPHYR_LOG("host X does have GLX\n");
-
- if (!Single_dispatch_info.dispatch_functions) {
- EPHYR_LOG_ERROR("could not get dispatch functions table\n");
- return FALSE;
- }
- /*
- * hijack some single entry point dispatch functions
- */
- dispatch_functions = Single_dispatch_info.dispatch_functions;
- EPHYR_RETURN_VAL_IF_FAIL(dispatch_functions, FALSE);
-
- dispatch_functions[X_GLXQueryVersion][0] = ephyrGLXQueryVersion;
- dispatch_functions[X_GLXQueryVersion][1] = ephyrGLXQueryVersionSwap;
-
- dispatch_functions[X_GLXGetVisualConfigs][0] = ephyrGLXGetVisualConfigs;
- dispatch_functions[X_GLXGetVisualConfigs][1] = ephyrGLXGetVisualConfigsSwap;
- dispatch_functions[X_GLXClientInfo][0] = ephyrGLXClientInfo;
- dispatch_functions[X_GLXClientInfo][1] = ephyrGLXClientInfoSwap;
-
- dispatch_functions[X_GLXQueryServerString][0] = ephyrGLXQueryServerString;
- dispatch_functions[X_GLXQueryServerString][1] =
- ephyrGLXQueryServerStringSwap;
-
- dispatch_functions[X_GLXCreateContext][0] = ephyrGLXCreateContext;
- dispatch_functions[X_GLXCreateContext][1] = ephyrGLXCreateContextSwap;
-
- dispatch_functions[X_GLXCreateNewContext][0] = ephyrGLXCreateNewContext;
- dispatch_functions[X_GLXCreateNewContext][1] = ephyrGLXCreateNewContextSwap;
-
- dispatch_functions[X_GLXDestroyContext][0] = ephyrGLXDestroyContext;
- dispatch_functions[X_GLXDestroyContext][1] = ephyrGLXDestroyContextSwap;
-
- dispatch_functions[X_GLXMakeCurrent][0] = ephyrGLXMakeCurrent;
- dispatch_functions[X_GLXMakeCurrent][1] = ephyrGLXMakeCurrentSwap;
-
- dispatch_functions[X_GLXIsDirect][0] = ephyrGLXIsDirect;
- dispatch_functions[X_GLXIsDirect][1] = ephyrGLXIsDirectSwap;
-
- dispatch_functions[73][0] = ephyrGLXGetString;
- dispatch_functions[73][1] = ephyrGLXGetStringSwap;
-
- dispatch_functions[61][0] = ephyrGLXGetIntegerv;
- dispatch_functions[61][1] = ephyrGLXGetIntegervSwap;
-
- dispatch_functions[X_GLXMakeContextCurrent][0] =
- ephyrGLXMakeContextCurrent;
- dispatch_functions[X_GLXMakeContextCurrent][1] =
- ephyrGLXMakeContextCurrentSwap;
-
- /*
- * hijack some vendor priv entry point dispatch functions
- */
- dispatch_functions = VendorPriv_dispatch_info.dispatch_functions;
- dispatch_functions[92][0] = ephyrGLXGetFBConfigsSGIX;
- dispatch_functions[92][1] = ephyrGLXGetFBConfigsSGIXSwap;
-
- dispatch_functions[89][0] = ephyrGLXMakeCurrentReadSGI;
- dispatch_functions[89][1] = ephyrGLXMakeCurrentReadSGISwap;
-
- EPHYR_LOG("hijacked glx entry points to forward requests to host X\n");
-
-
- return TRUE;
-}
-
-/*********************
- * implementation of
- * hijacked GLX entry
- * points
- ********************/
-
-int
-ephyrGLXQueryVersion(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- ClientPtr client = a_cl->client;
- xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) a_pc;
- xGLXQueryVersionReply reply;
- int major, minor;
- int res = BadImplementation;
-
- EPHYR_LOG("enter\n");
-
- major = req->majorVersion;
- minor = req->minorVersion;
-
- if (!ephyrHostGLXQueryVersion(&major, &minor)) {
- EPHYR_LOG_ERROR("ephyrHostGLXQueryVersion() failed\n");
- goto out;
- }
- EPHYR_LOG("major:%d, minor:%d\n", major, minor);
- reply = (xGLXQueryVersionReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = 0,
- .majorVersion = major,
- .minorVersion = minor
- };
-
- if (client->swapped) {
- __glXSwapQueryVersionReply(client, &reply);
- }
- else {
- WriteToClient(client, sz_xGLXQueryVersionReply, &reply);
- }
-
- res = Success;
- out:
- EPHYR_LOG("leave\n");
- return res;
-}
-
-int
-ephyrGLXQueryVersionSwap(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) a_pc;
-
- __GLX_DECLARE_SWAP_VARIABLES;
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->majorVersion);
- __GLX_SWAP_INT(&req->minorVersion);
- return ephyrGLXQueryVersion(a_cl, a_pc);
-}
-
-static int
-ephyrGLXGetVisualConfigsReal(__GLXclientState * a_cl,
- GLbyte * a_pc, Bool a_do_swap)
-{
- xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) a_pc;
- ClientPtr client = a_cl->client;
- xGLXGetVisualConfigsReply reply;
- int32_t *props_buf = NULL, num_visuals = 0,
- num_props = 0, res = BadImplementation, i = 0,
- props_per_visual_size = 0, props_buf_size = 0;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- EPHYR_LOG("enter\n");
-
- if (!ephyrHostGLXGetVisualConfigs(req->screen,
- &num_visuals,
- &num_props,
- &props_buf_size, &props_buf)) {
- EPHYR_LOG_ERROR("ephyrHostGLXGetVisualConfigs() failed\n");
- goto out;
- }
- EPHYR_LOG("num_visuals:%d, num_props:%d\n", num_visuals, num_props);
-
- reply = (xGLXGetVisualConfigsReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = (num_visuals * __GLX_SIZE_CARD32 * num_props) >> 2,
- .numVisuals = num_visuals,
- .numProps = num_props
- };
-
- if (a_do_swap) {
- __GLX_SWAP_SHORT(&reply.sequenceNumber);
- __GLX_SWAP_INT(&reply.length);
- __GLX_SWAP_INT(&reply.numVisuals);
- __GLX_SWAP_INT(&reply.numProps);
- __GLX_SWAP_INT_ARRAY(props_buf, num_props);
- }
- WriteToClient(client, sz_xGLXGetVisualConfigsReply, &reply);
- props_per_visual_size = props_buf_size / num_visuals;
- for (i = 0; i < num_visuals; i++) {
- WriteToClient(client,
- props_per_visual_size,
- (char *) props_buf + i * props_per_visual_size);
- }
- res = Success;
-
- out:
- EPHYR_LOG("leave\n");
- free(props_buf);
- props_buf = NULL;
-
- return res;
-}
-
-static int
-ephyrGLXGetFBConfigsSGIXReal(__GLXclientState * a_cl,
- GLbyte * a_pc, Bool a_do_swap)
-{
- xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) a_pc;
- ClientPtr client = a_cl->client;
- xGLXGetVisualConfigsReply reply;
- int32_t *props_buf = NULL, num_visuals = 0,
- num_props = 0, res = BadImplementation, i = 0,
- props_per_visual_size = 0, props_buf_size = 0;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- EPHYR_LOG("enter\n");
-
- if (!ephyrHostGLXVendorPrivGetFBConfigsSGIX(req->screen,
- &num_visuals,
- &num_props,
- &props_buf_size, &props_buf)) {
- EPHYR_LOG_ERROR("ephyrHostGLXGetVisualConfigs() failed\n");
- goto out;
- }
- EPHYR_LOG("num_visuals:%d, num_props:%d\n", num_visuals, num_props);
-
- reply = (xGLXGetVisualConfigsReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = props_buf_size >> 2,
- .numVisuals = num_visuals,
- .numProps = num_props
- };
-
- if (a_do_swap) {
- __GLX_SWAP_SHORT(&reply.sequenceNumber);
- __GLX_SWAP_INT(&reply.length);
- __GLX_SWAP_INT(&reply.numVisuals);
- __GLX_SWAP_INT(&reply.numProps);
- __GLX_SWAP_INT_ARRAY(props_buf, num_props);
- }
- WriteToClient(client, sz_xGLXGetVisualConfigsReply, &reply);
- props_per_visual_size = props_buf_size / num_visuals;
- for (i = 0; i < num_visuals; i++) {
- WriteToClient(client,
- props_per_visual_size,
- &((char *) props_buf)[i * props_per_visual_size]);
- }
- res = Success;
-
- out:
- EPHYR_LOG("leave\n");
- free(props_buf);
- props_buf = NULL;
-
- return res;
-}
-
-int
-ephyrGLXGetVisualConfigs(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- return ephyrGLXGetVisualConfigsReal(a_cl, a_pc, FALSE);
-}
-
-int
-ephyrGLXGetVisualConfigsSwap(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- return ephyrGLXGetVisualConfigsReal(a_cl, a_pc, TRUE);
-}
-
-int
-ephyrGLXClientInfo(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- int res = BadImplementation;
- xGLXClientInfoReq *req = (xGLXClientInfoReq *) a_pc;
-
- EPHYR_LOG("enter\n");
- if (!ephyrHostGLXSendClientInfo(req->major, req->minor, (char *) req + 1)) {
- EPHYR_LOG_ERROR("failed to send client info to host\n");
- goto out;
- }
- res = Success;
-
- out:
- EPHYR_LOG("leave\n");
- return res;
-}
-
-int
-ephyrGLXClientInfoSwap(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- xGLXClientInfoReq *req = (xGLXClientInfoReq *) a_pc;
-
- __GLX_DECLARE_SWAP_VARIABLES;
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->major);
- __GLX_SWAP_INT(&req->minor);
- __GLX_SWAP_INT(&req->numbytes);
-
- return ephyrGLXClientInfo(a_cl, a_pc);
-}
-
-int
-ephyrGLXQueryServerString(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- int res = BadImplementation;
- ClientPtr client = a_cl->client;
- xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *) a_pc;
- xGLXQueryServerStringReply reply;
- char *server_string = NULL;
- int length = 0;
-
- EPHYR_LOG("enter\n");
- if (!ephyrHostGLXQueryServerString(req->screen,
- req->name,
- &server_string)) {
- EPHYR_LOG_ERROR("failed to query string from host\n");
- goto out;
- }
- EPHYR_LOG("string: %s\n", server_string);
- length = strlen(server_string) + 1;
- reply = (xGLXQueryServerStringReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = __GLX_PAD(length) >> 2,
- .n = length
- };
-
- WriteToClient(client, sz_xGLXQueryServerStringReply, &reply);
- WriteToClient(client, (int) (reply.length << 2), server_string);
-
- res = Success;
-
- out:
- EPHYR_LOG("leave\n");
- free(server_string);
- server_string = NULL;
-
- return res;
-}
-
-int
-ephyrGLXQueryServerStringSwap(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- EPHYR_LOG_ERROR("not yet implemented\n");
- return BadImplementation;
-}
-
-int
-ephyrGLXGetFBConfigsSGIX(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- return ephyrGLXGetFBConfigsSGIXReal(a_cl, a_pc, FALSE);
-}
-
-int
-ephyrGLXGetFBConfigsSGIXSwap(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- return ephyrGLXGetFBConfigsSGIXReal(a_cl, a_pc, TRUE);
-}
-
-static int
-ephyrGLXCreateContextReal(xGLXCreateContextReq * a_req, Bool a_do_swap)
-{
- int res = BadImplementation;
- EphyrHostWindowAttributes host_w_attrs;
-
- __GLX_DECLARE_SWAP_VARIABLES;
-
- EPHYR_RETURN_VAL_IF_FAIL(a_req, BadValue);
- EPHYR_LOG("enter\n");
-
- if (a_do_swap) {
- __GLX_SWAP_SHORT(&a_req->length);
- __GLX_SWAP_INT(&a_req->context);
- __GLX_SWAP_INT(&a_req->visual);
- __GLX_SWAP_INT(&a_req->screen);
- __GLX_SWAP_INT(&a_req->shareList);
- }
-
- EPHYR_LOG("context creation requested. localid:%d, "
- "screen:%d, visual:%d, direct:%d\n",
- (int) a_req->context, (int) a_req->screen,
- (int) a_req->visual, (int) a_req->isDirect);
-
- memset(&host_w_attrs, 0, sizeof(host_w_attrs));
- if (!hostx_get_window_attributes(hostx_get_window(a_req->screen),
- &host_w_attrs)) {
- EPHYR_LOG_ERROR("failed to get host window attrs\n");
- goto out;
- }
-
- EPHYR_LOG("host window visual id: %d\n", host_w_attrs.visualid);
-
- if (!ephyrHostGLXCreateContext(a_req->screen,
- host_w_attrs.visualid,
- a_req->context,
- a_req->shareList, 0,
- a_req->isDirect, X_GLXCreateContext)) {
- EPHYR_LOG_ERROR("ephyrHostGLXCreateContext() failed\n");
- goto out;
- }
- res = Success;
- out:
- EPHYR_LOG("leave\n");
- return res;
-}
-
-static int
-ephyrGLXCreateNewContextReal(xGLXCreateNewContextReq * a_req, Bool a_do_swap)
-{
- int res = BadImplementation;
-
- __GLX_DECLARE_SWAP_VARIABLES;
-
- EPHYR_RETURN_VAL_IF_FAIL(a_req, BadValue);
- EPHYR_LOG("enter\n");
-
- if (a_do_swap) {
- __GLX_SWAP_SHORT(&a_req->length);
- __GLX_SWAP_INT(&a_req->context);
- __GLX_SWAP_INT(&a_req->fbconfig);
- __GLX_SWAP_INT(&a_req->screen);
- __GLX_SWAP_INT(&a_req->renderType);
- __GLX_SWAP_INT(&a_req->shareList);
- }
-
- EPHYR_LOG("context creation requested. localid:%d, "
- "screen:%d, fbconfig:%d, renderType:%d, direct:%d\n",
- (int) a_req->context, (int) a_req->screen,
- (int) a_req->fbconfig, (int) a_req->renderType,
- (int) a_req->isDirect);
-
- if (!ephyrHostGLXCreateContext(a_req->screen,
- a_req->fbconfig,
- a_req->context,
- a_req->shareList, a_req->renderType,
- a_req->isDirect, X_GLXCreateNewContext)) {
- EPHYR_LOG_ERROR("ephyrHostGLXCreateNewContext() failed\n");
- goto out;
- }
- res = Success;
- out:
- EPHYR_LOG("leave\n");
- return res;
-}
-
-int
-ephyrGLXCreateContext(__GLXclientState * cl, GLbyte * pc)
-{
- xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
-
- return ephyrGLXCreateContextReal(req, FALSE);
-}
-
-int
-ephyrGLXCreateContextSwap(__GLXclientState * cl, GLbyte * pc)
-{
- xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
-
- return ephyrGLXCreateContextReal(req, TRUE);
-}
-
-int
-ephyrGLXCreateNewContext(__GLXclientState * cl, GLbyte * pc)
-{
- xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
-
- return ephyrGLXCreateNewContextReal(req, FALSE);
-}
-
-int
-ephyrGLXCreateNewContextSwap(__GLXclientState * cl, GLbyte * pc)
-{
- xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
-
- return ephyrGLXCreateNewContextReal(req, TRUE);
-}
-
-static int
-ephyrGLXDestroyContextReal(__GLXclientState * a_cl,
- GLbyte * a_pc, Bool a_do_swap)
-{
- int res = BadImplementation;
- ClientPtr client = a_cl->client;
- xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) a_pc;
-
- EPHYR_LOG("enter. id:%d\n", (int) req->context);
- if (!ephyrHostDestroyContext(req->context)) {
- EPHYR_LOG_ERROR("ephyrHostDestroyContext() failed\n");
- client->errorValue = req->context;
- goto out;
- }
- res = Success;
-
- out:
- EPHYR_LOG("leave\n");
- return res;
-}
-
-int
-ephyrGLXDestroyContext(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- return ephyrGLXDestroyContextReal(a_cl, a_pc, FALSE);
-}
-
-int
-ephyrGLXDestroyContextSwap(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- return ephyrGLXDestroyContextReal(a_cl, a_pc, TRUE);
-}
-
-static int
-ephyrGLXMakeCurrentReal(__GLXclientState * a_cl, GLXDrawable write,
- GLXDrawable read, GLXContextTag ctx,
- GLXContextTag old_ctx, Bool a_do_swap)
-{
- int res = BadImplementation;
- xGLXMakeCurrentReply reply;
- DrawablePtr drawableR = NULL, drawableW = NULL;
- GLXContextTag new_ctx = 0;
-
- EPHYR_LOG("enter\n");
- res = dixLookupDrawable(&drawableW, write, a_cl->client, 0, DixReadAccess);
- EPHYR_RETURN_VAL_IF_FAIL(drawableW, BadValue);
- EPHYR_RETURN_VAL_IF_FAIL(drawableW->pScreen, BadValue);
- EPHYR_LOG("screen nummber requested:%d\n", drawableW->pScreen->myNum);
-
- if (read != write) {
- res = dixLookupDrawable(&drawableR, read, a_cl->client, 0,
- DixReadAccess);
- EPHYR_RETURN_VAL_IF_FAIL(drawableR, BadValue);
- EPHYR_RETURN_VAL_IF_FAIL(drawableR->pScreen, BadValue);
- }
- else {
- drawableR = drawableW;
- }
-
- if (!ephyrHostGLXMakeCurrent(hostx_get_window(drawableW->pScreen->myNum),
- hostx_get_window(drawableR->pScreen->myNum),
- ctx, old_ctx, (int *) &new_ctx)) {
- EPHYR_LOG_ERROR("ephyrHostGLXMakeCurrent() failed\n");
- goto out;
- }
- reply = (xGLXMakeCurrentReply) {
- .type = X_Reply,
- .sequenceNumber = a_cl->client->sequence,
- .length = 0,
- .contextTag = new_ctx
- };
- if (a_do_swap) {
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_SWAP_SHORT(&reply.sequenceNumber);
- __GLX_SWAP_INT(&reply.length);
- __GLX_SWAP_INT(&reply.contextTag);
- }
- WriteToClient(a_cl->client, sz_xGLXMakeCurrentReply, &reply);
-
- res = Success;
- out:
- EPHYR_LOG("leave\n");
- return res;
-}
-
-int
-ephyrGLXMakeCurrent(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) a_pc;
- return ephyrGLXMakeCurrentReal(a_cl, req->drawable, req->drawable,
- req->context, req->oldContextTag, FALSE);
-}
-
-int
-ephyrGLXMakeCurrentSwap(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) a_pc;
- __GLX_DECLARE_SWAP_VARIABLES;
-
- __GLX_SWAP_INT(&req->drawable);
- __GLX_SWAP_INT(&req->context);
- __GLX_SWAP_INT(&req->oldContextTag);
-
- return ephyrGLXMakeCurrentReal(a_cl, req->drawable, req->drawable,
- req->context, req->oldContextTag, TRUE);
-}
-
-int
-ephyrGLXMakeCurrentReadSGI(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) a_pc;
-
- return ephyrGLXMakeCurrentReal(a_cl, req->drawable, req->readable,
- req->context, req->oldContextTag, FALSE);
-}
-
-int
-ephyrGLXMakeCurrentReadSGISwap(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) a_pc;
- __GLX_DECLARE_SWAP_VARIABLES;
-
- __GLX_SWAP_INT(&req->drawable);
- __GLX_SWAP_INT(&req->readable);
- __GLX_SWAP_INT(&req->context);
- __GLX_SWAP_INT(&req->oldContextTag);
-
- return ephyrGLXMakeCurrentReal(a_cl, req->drawable, req->readable,
- req->context, req->oldContextTag, TRUE);
-}
-
-int
-ephyrGLXMakeContextCurrent(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) a_pc;
-
- return ephyrGLXMakeCurrentReal(a_cl, req->drawable, req->readdrawable,
- req->context, req->oldContextTag, FALSE);
-}
-
-int
-ephyrGLXMakeContextCurrentSwap(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) a_pc;
- __GLX_DECLARE_SWAP_VARIABLES;
-
- __GLX_SWAP_INT(&req->drawable);
- __GLX_SWAP_INT(&req->readdrawable);
- __GLX_SWAP_INT(&req->context);
- __GLX_SWAP_INT(&req->oldContextTag);
-
- return ephyrGLXMakeCurrentReal(a_cl, req->drawable, req->readdrawable,
- req->context, req->oldContextTag, TRUE);
-}
-
-static int
-ephyrGLXGetStringReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap)
-{
- ClientPtr client = NULL;
- int context_tag = 0, name = 0, res = BadImplementation, length = 0;
- char *string = NULL;
-
- __GLX_DECLARE_SWAP_VARIABLES;
-
- EPHYR_RETURN_VAL_IF_FAIL(a_cl && a_pc, BadValue);
-
- EPHYR_LOG("enter\n");
-
- client = a_cl->client;
-
- if (a_do_swap) {
- __GLX_SWAP_INT(a_pc + 4);
- __GLX_SWAP_INT(a_pc + __GLX_SINGLE_HDR_SIZE);
- }
- context_tag = __GLX_GET_SINGLE_CONTEXT_TAG(a_pc);
- a_pc += __GLX_SINGLE_HDR_SIZE;
- name = *(GLenum *) (a_pc + 0);
- EPHYR_LOG("context_tag:%d, name:%d\n", context_tag, name);
- if (!ephyrHostGLXGetString(context_tag, name, &string)) {
- EPHYR_LOG_ERROR("failed to get string from server\n");
- goto out;
- }
- if (string) {
- length = strlen(string) + 1;
- EPHYR_LOG("got string:'%s', size:%d\n", string, length);
- }
- else {
- EPHYR_LOG("got string: string (null)\n");
- }
- __GLX_BEGIN_REPLY(length);
- __GLX_PUT_SIZE(length);
- __GLX_SEND_HEADER();
- if (a_do_swap) {
- __GLX_SWAP_REPLY_SIZE();
- __GLX_SWAP_REPLY_HEADER();
- }
- WriteToClient(client, length, string);
-
- res = Success;
- out:
- EPHYR_LOG("leave\n");
- return res;
-}
-
-int
-ephyrGLXGetString(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- return ephyrGLXGetStringReal(a_cl, a_pc, FALSE);
-}
-
-int
-ephyrGLXGetStringSwap(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- return ephyrGLXGetStringReal(a_cl, a_pc, TRUE);
-}
-
-static int
-ephyrGLXGetIntegervReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap)
-{
- int res = BadImplementation;
- xGLXSingleReq *const req = (xGLXSingleReq *) a_pc;
- GLenum int_name;
- int value = 0;
- GLint answer_buf_room[200];
- GLint *buf = NULL;
-
- EPHYR_LOG("enter\n");
-
- a_pc += __GLX_SINGLE_HDR_SIZE;
-
- int_name = *(GLenum *) (a_pc + 0);
- if (!ephyrHostGetIntegerValue(req->contextTag, int_name, &value)) {
- EPHYR_LOG_ERROR("ephyrHostGetIntegerValue() failed\n");
- goto out;
- }
- buf = __glXGetAnswerBuffer(a_cl, sizeof(value),
- answer_buf_room, sizeof(answer_buf_room), 4);
-
- if (!buf) {
- EPHYR_LOG_ERROR("failed to allocate reply buffer\n");
- res = BadAlloc;
- goto out;
- }
- __glXSendReply(a_cl->client, buf, 1, sizeof(value), GL_FALSE, 0);
- res = Success;
-
- out:
- EPHYR_LOG("leave\n");
- return res;
-}
-
-int
-ephyrGLXGetIntegerv(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- return ephyrGLXGetIntegervReal(a_cl, a_pc, FALSE);
-}
-
-int
-ephyrGLXGetIntegervSwap(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- return ephyrGLXGetIntegervReal(a_cl, a_pc, TRUE);
-}
-
-static int
-ephyrGLXIsDirectReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap)
-{
- int res = BadImplementation;
- ClientPtr client = a_cl->client;
- xGLXIsDirectReq *req = (xGLXIsDirectReq *) a_pc;
- xGLXIsDirectReply reply;
- int is_direct = 0;
-
- EPHYR_RETURN_VAL_IF_FAIL(a_cl && a_pc, FALSE);
-
- EPHYR_LOG("enter\n");
-
- if (!ephyrHostIsContextDirect(req->context, (int *) &is_direct)) {
- EPHYR_LOG_ERROR("ephyrHostIsContextDirect() failed\n");
- goto out;
- }
- reply = (xGLXIsDirectReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = 0,
- .isDirect = is_direct
- };
-
- WriteToClient(client, sz_xGLXIsDirectReply, &reply);
- res = Success;
-
- out:
- EPHYR_LOG("leave\n");
- return res;
-}
-
-int
-ephyrGLXIsDirect(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- return ephyrGLXIsDirectReal(a_cl, a_pc, FALSE);
-}
-
-int
-ephyrGLXIsDirectSwap(__GLXclientState * a_cl, GLbyte * a_pc)
-{
- return ephyrGLXIsDirectReal(a_cl, a_pc, TRUE);
-}
diff --git a/hw/kdrive/ephyr/ephyrglxext.h b/hw/kdrive/ephyr/ephyrglxext.h
deleted file mode 100644
index 8b4b3a248..000000000
--- a/hw/kdrive/ephyr/ephyrglxext.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Xephyr - A kdrive X server thats runs in a host X window.
- * Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2007 OpenedHand Ltd
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of OpenedHand Ltd not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. OpenedHand Ltd makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors:
- * Dodji Seketeli <dodji@openedhand.com>
- */
-#ifndef __EPHYR_GLXEXT_H__
-#define __EPHYR_GLXEXT_H__
-
-#include <X11/Xdefs.h>
-Bool ephyrHijackGLXExtension(void);
-
-#endif /*__EPHYR_GLXEXT_H__*/
diff --git a/hw/kdrive/ephyr/ephyrhostglx.c b/hw/kdrive/ephyr/ephyrhostglx.c
deleted file mode 100644
index 0b98cce71..000000000
--- a/hw/kdrive/ephyr/ephyrhostglx.c
+++ /dev/null
@@ -1,490 +0,0 @@
-/*
- * Xephyr - A kdrive X server thats runs in a host X window.
- * Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2007 OpenedHand Ltd
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of OpenedHand Ltd not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. OpenedHand Ltd makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * a lots of the content of this file has been adapted from the mesa source
- * code.
- * Authors:
- * Dodji Seketeli <dodji@openedhand.com>
- */
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-
-#include <X11/Xdefs.h>
-#include <X11/Xmd.h>
-#include <GL/glxproto.h>
-#include <xcb/glx.h>
-#include "ephyrhostglx.h"
-#define _HAVE_XALLOC_DECLS
-#include "ephyrlog.h"
-#include "hostx.h"
-
-static int glx_major, glx_minor;
-
-enum VisualConfRequestType {
- EPHYR_GET_FB_CONFIG,
- EPHYR_VENDOR_PRIV_GET_FB_CONFIG_SGIX,
- EPHYR_GET_VISUAL_CONFIGS
-};
-
-static Bool ephyrHostGLXGetVisualConfigsInternal
- (enum VisualConfRequestType a_type,
- xcb_glx_get_visual_configs_reply_t *reply,
- int32_t a_screen,
- int32_t *a_num_visuals,
- int32_t *a_num_props,
- int32_t *a_props_buf_size,
- int32_t **a_props_buf);
-
-Bool
-ephyrHostGLXQueryVersion(int *a_major, int *a_minor)
-{
- Bool is_ok = FALSE;
- xcb_connection_t *conn = hostx_get_xcbconn();
- xcb_glx_query_version_cookie_t cookie;
- xcb_glx_query_version_reply_t *reply;
-
- EPHYR_RETURN_VAL_IF_FAIL(a_major && a_minor, FALSE);
- EPHYR_LOG("enter\n");
-
- if (glx_major) {
- *a_major = glx_major;
- *a_minor = glx_minor;
- return TRUE;
- }
-
- /* Send the glXQueryVersion request */
- cookie = xcb_glx_query_version(conn, 2, 1);
- reply = xcb_glx_query_version_reply(conn, cookie, NULL);
- if (!reply)
- goto out;
- *a_major = reply->major_version;
- *a_minor = reply->minor_version;
- free(reply);
-
- EPHYR_LOG("major:%d, minor:%d\n", *a_major, *a_minor);
-
- is_ok = TRUE;
- out:
- EPHYR_LOG("leave\n");
- return is_ok;
-}
-
-Bool
-ephyrHostGLXGetString(int a_context_tag,
- int a_string_name,
- char **a_string)
-{
- Bool is_ok = FALSE;
- xcb_connection_t *conn = hostx_get_xcbconn();
- xcb_glx_get_string_cookie_t cookie;
- xcb_glx_get_string_reply_t *reply;
-
- EPHYR_RETURN_VAL_IF_FAIL(conn && a_string, FALSE);
-
- EPHYR_LOG("enter\n");
- cookie = xcb_glx_get_string(conn, a_context_tag, a_string_name);
- reply = xcb_glx_get_string_reply(conn, cookie, NULL);
- if (!reply)
- goto out;
- *a_string = malloc(reply->n + 1);
- memcpy(*a_string, xcb_glx_get_string_string(reply), reply->n);
- (*a_string)[reply->n] = '\0';
- free(reply);
- is_ok = TRUE;
-out:
- EPHYR_LOG("leave\n");
- return is_ok;
-}
-
-Bool ephyrHostGLXQueryServerString(int a_screen_number,
- int a_string_name,
- char **a_string)
-{
- Bool is_ok = FALSE;
- xcb_connection_t *conn = hostx_get_xcbconn();
- int default_screen = hostx_get_screen();
- xcb_glx_query_server_string_cookie_t cookie;
- xcb_glx_query_server_string_reply_t *reply;
-
- EPHYR_RETURN_VAL_IF_FAIL(conn && a_string, FALSE);
-
- EPHYR_LOG("enter\n");
- cookie = xcb_glx_query_server_string(conn, default_screen, a_string_name);
- reply = xcb_glx_query_server_string_reply(conn, cookie, NULL);
- if (!reply)
- goto out;
- *a_string = malloc(reply->str_len + 1);
- memcpy(*a_string, xcb_glx_query_server_string_string(reply), reply->str_len);
- (*a_string)[reply->str_len] = '\0';
- free(reply);
- is_ok = TRUE;
-out:
- EPHYR_LOG("leave\n");
- return is_ok;
-}
-
-static Bool
-ephyrHostGLXGetVisualConfigsInternal(enum VisualConfRequestType a_type,
- xcb_glx_get_visual_configs_reply_t *reply,
- int32_t a_screen,
- int32_t * a_num_visuals,
- int32_t * a_num_props,
- int32_t * a_props_buf_size,
- int32_t ** a_props_buf)
-{
- Bool is_ok = FALSE;
- int num_props = 0, num_visuals = 0, props_buf_size = 0;
- int props_per_visual_size = 0;
- int32_t *props_buf = NULL;
-
- if (!reply->num_visuals) {
- EPHYR_LOG_ERROR("screen does not support GL rendering\n");
- goto out;
- }
- num_visuals = reply->num_visuals;
-
- num_props = reply->num_properties;
-
- if (a_type != EPHYR_GET_VISUAL_CONFIGS) {
- num_props *= 2;
- }
- props_per_visual_size = num_props * sizeof(uint32_t);
- props_buf_size = props_per_visual_size * reply->num_visuals;
- props_buf = malloc(props_buf_size);
- if (!props_buf)
- goto out;
- memcpy(props_buf, xcb_glx_get_visual_configs_property_list(reply),
- props_buf_size);
-
- *a_num_visuals = num_visuals;
- *a_num_props = reply->num_properties;
- *a_props_buf_size = props_buf_size;
- *a_props_buf = props_buf;
- is_ok = TRUE;
-
-out:
- return is_ok;
-}
-
-Bool
-ephyrHostGLXGetVisualConfigs(int32_t a_screen,
- int32_t * a_num_visuals,
- int32_t * a_num_props,
- int32_t * a_props_buf_size, int32_t ** a_props_buf)
-{
- Bool is_ok = FALSE;
- xcb_glx_get_visual_configs_cookie_t cookie;
- xcb_glx_get_visual_configs_reply_t *reply;
- xcb_connection_t *conn = hostx_get_xcbconn();
- int screen = hostx_get_screen();
-
- EPHYR_LOG("enter\n");
- cookie = xcb_glx_get_visual_configs(conn, screen);
- reply = xcb_glx_get_visual_configs_reply(conn, cookie, NULL);
- if (!reply)
- goto out;
- is_ok = ephyrHostGLXGetVisualConfigsInternal
- (EPHYR_GET_VISUAL_CONFIGS,
- reply,
- a_screen,
- a_num_visuals,
- a_num_props,
- a_props_buf_size,
- a_props_buf);
-
-out:
- free(reply);
- EPHYR_LOG("leave:%d\n", is_ok);
- return is_ok;
-}
-
-Bool
-ephyrHostGLXVendorPrivGetFBConfigsSGIX(int a_screen,
- int32_t * a_num_visuals,
- int32_t * a_num_props,
- int32_t * a_props_buf_size,
- int32_t ** a_props_buf)
-{
- Bool is_ok=FALSE;
- xcb_connection_t *conn = hostx_get_xcbconn();
- int screen = hostx_get_screen();
- xcb_glx_vendor_private_with_reply_cookie_t cookie;
- union {
- xcb_glx_vendor_private_with_reply_reply_t *vprep;
- xcb_glx_get_visual_configs_reply_t *rep;
- } reply;
-
- EPHYR_LOG("enter\n");
- cookie = xcb_glx_vendor_private_with_reply(conn,
- X_GLXvop_GetFBConfigsSGIX,
- 0, 4, (uint8_t *)&screen);
- reply.vprep = xcb_glx_vendor_private_with_reply_reply(conn, cookie, NULL);
- if (!reply.vprep)
- goto out;
- is_ok = ephyrHostGLXGetVisualConfigsInternal
- (EPHYR_VENDOR_PRIV_GET_FB_CONFIG_SGIX,
- reply.rep,
- a_screen,
- a_num_visuals,
- a_num_props,
- a_props_buf_size,
- a_props_buf);
-out:
- free(reply.vprep);
- EPHYR_LOG("leave\n");
- return is_ok;
-}
-
-Bool
-ephyrHostGLXSendClientInfo(int32_t a_major, int32_t a_minor,
- const char *a_extension_list)
-{
- xcb_connection_t *conn = hostx_get_xcbconn();
- int size;
-
- EPHYR_RETURN_VAL_IF_FAIL(conn && a_extension_list, FALSE);
-
- size = strlen (a_extension_list) + 1;
- xcb_glx_client_info(conn, a_major, a_minor, size, a_extension_list);
-
- return TRUE;
-}
-
-Bool
-ephyrHostGLXCreateContext(int a_screen,
- int a_generic_id,
- int a_context_id,
- int a_share_list_ctxt_id,
- int a_render_type,
- Bool a_direct,
- int code)
-{
- xcb_connection_t *conn = hostx_get_xcbconn();
- Bool is_ok = FALSE;
- int remote_context_id = 0;
-
- EPHYR_LOG("enter. screen:%d, generic_id:%d, contextid:%d, rendertype:%d, "
- "direct:%d\n", a_screen, a_generic_id, a_context_id,
- a_render_type, a_direct);
-
- if (!hostx_allocate_resource_id_peer(a_context_id, &remote_context_id)) {
- EPHYR_LOG_ERROR("failed to peer the context id %d host X",
- remote_context_id);
- goto out;
- }
-
- switch (code) {
- case X_GLXCreateContext: {
- xcb_glx_create_context(conn,
- remote_context_id,
- a_generic_id,
- hostx_get_screen(),
- a_share_list_ctxt_id,
- a_direct);
- }
-
- case X_GLXCreateNewContext: {
- xcb_glx_create_new_context(conn,
- remote_context_id,
- a_generic_id,
- hostx_get_screen(),
- a_render_type,
- a_share_list_ctxt_id,
- a_direct);
- }
-
- default:
- /* This should never be reached !*/
- EPHYR_LOG("Internal error! Invalid CreateContext code!\n");
- }
-
- is_ok = TRUE;
-
- out:
- EPHYR_LOG("leave\n");
- return is_ok;
-}
-
-Bool
-ephyrHostDestroyContext(int a_ctxt_id)
-{
- xcb_connection_t *conn = hostx_get_xcbconn();
- Bool is_ok = FALSE;
- int remote_ctxt_id = 0;
-
- EPHYR_LOG("enter:%d\n", a_ctxt_id);
-
- if (!hostx_get_resource_id_peer(a_ctxt_id, &remote_ctxt_id)) {
- EPHYR_LOG_ERROR("failed to get remote glx ctxt id\n");
- goto out;
- }
- EPHYR_LOG("host context id:%d\n", remote_ctxt_id);
-
- xcb_glx_destroy_context(conn, remote_ctxt_id);
-
- is_ok = TRUE;
-
- out:
- EPHYR_LOG("leave\n");
- return is_ok;
-}
-
-Bool
-ephyrHostGLXMakeCurrent(int a_drawable, int a_readable,
- int a_glx_ctxt_id, int a_old_ctxt_tag, int *a_ctxt_tag)
-{
- xcb_connection_t *conn = hostx_get_xcbconn();
- Bool is_ok = FALSE;
- int remote_glx_ctxt_id = 0;
-
- EPHYR_RETURN_VAL_IF_FAIL(a_ctxt_tag, FALSE);
-
- EPHYR_LOG("enter. drawable:%d, read:%d, context:%d, oldtag:%d\n",
- a_drawable, a_readable, a_glx_ctxt_id, a_old_ctxt_tag);
-
- if (!hostx_get_resource_id_peer(a_glx_ctxt_id, &remote_glx_ctxt_id)) {
- EPHYR_LOG_ERROR("failed to get remote glx ctxt id\n");
- goto out;
- }
-
- /* If both drawables are the same, use the old MakeCurrent request.
- * Otherwise, if we have GLX 1.3 or higher, use the MakeContextCurrent
- * request which supports separate read and draw targets. Failing that,
- * try the SGI MakeCurrentRead extension. Logic cribbed from Mesa. */
- if (a_drawable == a_readable) {
- xcb_glx_make_current_cookie_t cookie;
- xcb_glx_make_current_reply_t *reply;
- cookie = xcb_glx_make_current(conn,
- a_drawable,
- remote_glx_ctxt_id,
- a_old_ctxt_tag);
- reply = xcb_glx_make_current_reply(conn, cookie, NULL);
- if (!reply)
- goto out;
- *a_ctxt_tag = reply->context_tag;
- free(reply);
- }
- else if (glx_major > 1 || glx_minor >= 3) {
- xcb_glx_make_context_current_cookie_t cookie;
- xcb_glx_make_context_current_reply_t *reply;
- cookie = xcb_glx_make_context_current(conn,
- a_old_ctxt_tag,
- a_drawable,
- a_readable,
- remote_glx_ctxt_id);
- reply = xcb_glx_make_context_current_reply(conn, cookie, NULL);
- if (!reply)
- goto out;
- *a_ctxt_tag = reply->context_tag;
- free(reply);
- }
- else {
- xcb_glx_vendor_private_with_reply_cookie_t cookie;
- xcb_glx_vendor_private_with_reply_reply_t *reply;
- uint32_t data[3] = {
- a_drawable, a_readable, remote_glx_ctxt_id,
- };
-
- EPHYR_LOG("enter\n");
- cookie = xcb_glx_vendor_private_with_reply(conn,
- X_GLXvop_MakeCurrentReadSGI,
- a_old_ctxt_tag,
- sizeof(data),
- (uint8_t *)data);
- reply = xcb_glx_vendor_private_with_reply_reply(conn, cookie, NULL);
-
- *a_ctxt_tag = reply->retval;
-
- free(reply);
- }
-
- EPHYR_LOG("context tag:%d\n", *a_ctxt_tag);
- is_ok = TRUE;
-
- out:
- EPHYR_LOG("leave\n");
- return is_ok;
-}
-
-Bool
-ephyrHostGetIntegerValue(int a_current_context_tag, int a_int, int *a_val)
-{
- xcb_connection_t *conn = hostx_get_xcbconn();
- Bool is_ok = FALSE;
- int size = 0;
- xcb_glx_get_integerv_cookie_t cookie;
- xcb_glx_get_integerv_reply_t *reply;
-
- EPHYR_RETURN_VAL_IF_FAIL(a_val, FALSE);
-
- EPHYR_LOG("enter\n");
- cookie = xcb_glx_get_integerv(conn, a_current_context_tag, a_int);
- reply = xcb_glx_get_integerv_reply(conn, cookie, NULL);
- if (!reply)
- goto out;
- size = reply->n;
- if (!size) {
- EPHYR_LOG_ERROR("X_GLsop_GetIngerv failed\n");
- goto out;
- }
- *a_val = reply->datum;
- is_ok = TRUE;
-
-out:
- free(reply);
- EPHYR_LOG("leave\n");
- return is_ok;
-}
-
-Bool
-ephyrHostIsContextDirect(int a_ctxt_id, int *a_is_direct)
-{
- Bool is_ok = FALSE;
- xcb_connection_t *conn = hostx_get_xcbconn();
- xcb_glx_is_direct_cookie_t cookie;
- xcb_glx_is_direct_reply_t *reply = NULL;
- int remote_glx_ctxt_id = 0;
-
- EPHYR_LOG("enter\n");
- if (!hostx_get_resource_id_peer (a_ctxt_id, &remote_glx_ctxt_id)) {
- EPHYR_LOG_ERROR ("failed to get remote glx ctxt id\n");
- goto out;
- }
-
- /* Send the glXIsDirect request */
- cookie = xcb_glx_is_direct(conn, remote_glx_ctxt_id);
- reply = xcb_glx_is_direct_reply(conn, cookie, NULL);
- if (!reply) {
- EPHYR_LOG_ERROR("fail in reading reply from host\n");
- goto out;
- }
- *a_is_direct = reply->is_direct;
- is_ok = TRUE;
-
-out:
- free(reply);
- EPHYR_LOG("leave\n");
- return is_ok;
-}
diff --git a/hw/kdrive/ephyr/ephyrhostglx.h b/hw/kdrive/ephyr/ephyrhostglx.h
deleted file mode 100644
index f1eec5f0b..000000000
--- a/hw/kdrive/ephyr/ephyrhostglx.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Xephyr - A kdrive X server thats runs in a host X window.
- * Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2007 OpenedHand Ltd
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of OpenedHand Ltd not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. OpenedHand Ltd makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors:
- * Dodji Seketeli <dodji@openedhand.com>
- */
-#ifndef __EPHYRHOSTGLX_H__
-#define __EPHYRHOSTGLX_H__
-
-enum EphyrHostGLXGetStringOps {
- EPHYR_HOST_GLX_UNDEF,
- EPHYR_HOST_GLX_QueryServerString,
- EPHYR_HOST_GLX_GetString,
-};
-
-Bool ephyrHostGLXQueryVersion(int *a_maj, int *a_min);
-Bool ephyrHostGLXGetString(int a_context_tag,
- int a_string_name,
- char **a_string);
-Bool ephyrHostGLXQueryServerString(int a_screen_number,
- int a_string_name,
- char **a_string);
-Bool ephyrHostGLXGetVisualConfigs(int a_screen,
- int32_t * a_num_visuals,
- int32_t * a_num_props,
- int32_t * a_props_buf_size,
- int32_t ** a_props_buf);
-Bool
-
-ephyrHostGLXVendorPrivGetFBConfigsSGIX(int a_screen,
- int32_t * a_num_visuals,
- int32_t * a_num_props,
- int32_t * a_props_buf_size,
- int32_t ** a_props_buf);
-Bool ephyrHostGLXSendClientInfo(int32_t a_major, int32_t a_minor,
- const char *a_extension_list);
-Bool ephyrHostGLXCreateContext(int a_screen,
- int a_generic_id,
- int a_context_id,
- int a_share_list_ctxt_id,
- int a_render_type,
- Bool a_direct,
- int code);
-
-Bool ephyrHostDestroyContext(int a_ctxt_id);
-
-Bool ephyrHostGLXMakeCurrent(int a_drawable, int a_readable, int a_glx_ctxt_id,
- int a_olg_ctxt_tag, int *a_ctxt_tag);
-
-Bool ephyrHostGetIntegerValue(int a_current_context_tag, int a_int, int *a_val);
-
-Bool ephyrHostIsContextDirect(int a_ctxt_id, int *a_is_direct);
-
-#endif /*__EPHYRHOSTGLX_H__*/
diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c
index d86baf295..6b6c4b1e0 100644
--- a/hw/kdrive/ephyr/ephyrinit.c
+++ b/hw/kdrive/ephyr/ephyrinit.c
@@ -38,9 +38,6 @@ extern Bool kdHasPointer;
extern Bool kdHasKbd;
extern Bool ephyr_glamor, ephyr_glamor_gles2;
-#ifdef GLXEXT
-extern Bool ephyrNoDRI;
-#endif
extern Bool ephyrNoXV;
#ifdef KDRIVE_EVDEV
@@ -154,9 +151,6 @@ ddxUseMsg(void)
ErrorF
("-fakexa Simulate acceleration using software rendering\n");
ErrorF("-verbosity <level> Set log verbosity level\n");
-#ifdef GLXEXT
- ErrorF("-nodri do not use DRI\n");
-#endif
ErrorF("-noxv do not use XV\n");
ErrorF("-name [name] define the name in the WM_CLASS property\n");
ErrorF
@@ -314,13 +308,6 @@ ddxProcessArgument(int argc, char **argv, int i)
exit(1);
}
}
-#ifdef GLXEXT
- else if (!strcmp(argv[i], "-nodri")) {
- ephyrNoDRI = TRUE;
- EPHYR_LOG("no direct rendering enabled\n");
- return 1;
- }
-#endif
else if (!strcmp(argv[i], "-noxv")) {
ephyrNoXV = TRUE;
EPHYR_LOG("no XVideo enabled\n");
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 49516bbd8..ce9facacc 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -52,10 +52,6 @@
#include <xcb/shape.h>
#include <xcb/xcb_keysyms.h>
#include <xcb/randr.h>
-#ifdef XF86DRI
-#include <xcb/xf86dri.h>
-#include <xcb/glx.h>
-#endif /* XF86DRI */
#ifdef GLAMOR
#include <epoxy/gl.h>
#include "glamor.h"
@@ -1345,80 +1341,6 @@ out:
return is_ok;
}
-#ifdef XF86DRI
-typedef struct {
- int is_valid;
- int local_id;
- int remote_id;
-} ResourcePair;
-
-#define RESOURCE_PEERS_SIZE 1024*10
-static ResourcePair resource_peers[RESOURCE_PEERS_SIZE];
-
-int
-hostx_allocate_resource_id_peer(int a_local_resource_id,
- int *a_remote_resource_id)
-{
- int i = 0;
- ResourcePair *peer = NULL;
-
- /*
- * first make sure a resource peer
- * does not exist already for
- * a_local_resource_id
- */
- for (i = 0; i < RESOURCE_PEERS_SIZE; i++) {
- if (resource_peers[i].is_valid
- && resource_peers[i].local_id == a_local_resource_id) {
- peer = &resource_peers[i];
- break;
- }
- }
- /*
- * find one free peer entry, an feed it with
- */
- if (!peer) {
- for (i = 0; i < RESOURCE_PEERS_SIZE; i++) {
- if (!resource_peers[i].is_valid) {
- peer = &resource_peers[i];
- break;
- }
- }
- if (peer) {
- peer->remote_id = xcb_generate_id(HostX.conn);
- peer->local_id = a_local_resource_id;
- peer->is_valid = TRUE;
- }
- }
- if (peer) {
- *a_remote_resource_id = peer->remote_id;
- return TRUE;
- }
- return FALSE;
-}
-
-int
-hostx_get_resource_id_peer(int a_local_resource_id, int *a_remote_resource_id)
-{
- int i = 0;
- ResourcePair *peer = NULL;
-
- for (i = 0; i < RESOURCE_PEERS_SIZE; i++) {
- if (resource_peers[i].is_valid
- && resource_peers[i].local_id == a_local_resource_id) {
- peer = &resource_peers[i];
- break;
- }
- }
- if (peer) {
- *a_remote_resource_id = peer->remote_id;
- return TRUE;
- }
- return FALSE;
-}
-
-#endif /* XF86DRI */
-
#ifdef GLAMOR
Bool
ephyr_glamor_init(ScreenPtr screen)
diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h
index d416dae73..5e642dc70 100644
--- a/hw/kdrive/ephyr/hostx.h
+++ b/hw/kdrive/ephyr/hostx.h
@@ -184,20 +184,6 @@ int hostx_set_window_bounding_rectangles(int a_window,
int hostx_has_extension(xcb_extension_t *extension);
-#ifdef XF86DRI
-int hostx_lookup_peer_window(void *a_local_window,
- int *a_host_peer /*out parameter */ );
-int
-
-hostx_allocate_resource_id_peer(int a_local_resource_id,
- int *a_remote_resource_id);
-int
- hostx_get_resource_id_peer(int a_local_resource_id, int *a_remote_resource_id);
-int hostx_has_dri(void);
-
-int hostx_has_glx(void);
-#endif /* XF86DRI */
-
int hostx_get_fd(void);
#endif /*_XLIBS_STUFF_H_*/