[Beignet] [PATCH 2/6 newRT] Move X11 files to gen dir.
junyan.he at inbox.com
junyan.he at inbox.com
Tue Mar 28 08:25:33 UTC 2017
From: Junyan He <junyan.he at intel.com>
Signed-off-by: Junyan He <junyan.he at intel.com>
---
src/CMakeLists.txt | 4 +-
src/gen/x11/dricommon.c | 333 ++++++++++++++++++++++++++++++++++++++++++++
src/gen/x11/dricommon.h | 99 +++++++++++++
src/gen/x11/va_dri2.c | 327 +++++++++++++++++++++++++++++++++++++++++++
src/gen/x11/va_dri2.h | 89 ++++++++++++
src/gen/x11/va_dri2str.h | 211 ++++++++++++++++++++++++++++
src/gen/x11/va_dri2tokens.h | 66 +++++++++
src/x11/dricommon.c | 333 --------------------------------------------
src/x11/dricommon.h | 99 -------------
src/x11/va_dri2.c | 327 -------------------------------------------
src/x11/va_dri2.h | 89 ------------
src/x11/va_dri2str.h | 211 ----------------------------
src/x11/va_dri2tokens.h | 66 ---------
13 files changed, 1127 insertions(+), 1127 deletions(-)
create mode 100644 src/gen/x11/dricommon.c
create mode 100644 src/gen/x11/dricommon.h
create mode 100644 src/gen/x11/va_dri2.c
create mode 100644 src/gen/x11/va_dri2.h
create mode 100644 src/gen/x11/va_dri2str.h
create mode 100644 src/gen/x11/va_dri2tokens.h
delete mode 100644 src/x11/dricommon.c
delete mode 100644 src/x11/dricommon.h
delete mode 100644 src/x11/va_dri2.c
delete mode 100644 src/x11/va_dri2.h
delete mode 100644 src/x11/va_dri2str.h
delete mode 100644 src/x11/va_dri2tokens.h
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 709dc10..91a772f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -111,8 +111,8 @@ if (X11_FOUND)
set(CMAKE_C_FLAGS "-DHAS_X11 ${CMAKE_C_FLAGS}")
set(OPENCL_SRC
${OPENCL_SRC}
- x11/dricommon.c
- x11/va_dri2.c)
+ gen/x11/dricommon.c
+ gen/x11/va_dri2.c)
endif (X11_FOUND)
if (CMRT_FOUND)
diff --git a/src/gen/x11/dricommon.c b/src/gen/x11/dricommon.c
new file mode 100644
index 0000000..92623d9
--- /dev/null
+++ b/src/gen/x11/dricommon.c
@@ -0,0 +1,333 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Benjamin Segovia <benjamin.segovia at intel.com>
+ * Note: the code is taken from libva code base
+ */
+
+/*
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <X11/Xlibint.h>
+#include <X11/Xlib.h>
+#include "va_dri2.h"
+#include "va_dri2tokens.h"
+#include "dricommon.h"
+#include "cl_utils.h"
+#include "cl_alloc.h"
+
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <assert.h>
+
+#define LOCAL __attribute__ ((visibility ("internal")))
+
+LOCAL dri_drawable_t*
+dri_state_do_drawable_hash(dri_state_t *state, XID drawable)
+{
+ int index = drawable % DRAWABLE_HASH_SZ;
+ struct dri_drawable *dri_drawable = state->drawable_hash[index];
+
+ while (dri_drawable) {
+ if (dri_drawable->x_drawable == drawable)
+ return dri_drawable;
+ dri_drawable = dri_drawable->next;
+ }
+
+ dri_drawable = dri_state_create_drawable(state, drawable);
+ if(dri_drawable == NULL)
+ return NULL;
+
+ dri_drawable->x_drawable = drawable;
+ dri_drawable->next = state->drawable_hash[index];
+ state->drawable_hash[index] = dri_drawable;
+
+ return dri_drawable;
+}
+
+LOCAL void
+dri_state_free_drawable_hash(dri_state_t *state)
+{
+ int i;
+ struct dri_drawable *dri_drawable, *prev;
+
+ for (i = 0; i < DRAWABLE_HASH_SZ; i++) {
+ dri_drawable = state->drawable_hash[i];
+
+ while (dri_drawable) {
+ prev = dri_drawable;
+ dri_drawable = prev->next;
+ dri_state_destroy_drawable(state, prev);
+ }
+ }
+}
+
+LOCAL dri_drawable_t*
+dri_state_get_drawable(dri_state_t *state, XID drawable)
+{
+ return dri_state_do_drawable_hash(state, drawable);
+}
+
+LOCAL void
+dri_state_init_drawable_hash_table(dri_state_t *state)
+{
+ int i;
+ for(i=0; i < DRAWABLE_HASH_SZ; i++)
+ state->drawable_hash[i] = NULL;
+}
+
+LOCAL void
+dri_state_delete(dri_state_t *state)
+{
+ if (state == NULL)
+ return;
+ dri_state_close(state);
+ CL_FREE(state);
+}
+
+LOCAL dri_state_t*
+dri_state_new(void)
+{
+ dri_state_t *state = NULL;
+ TRY_ALLOC_NO_ERR (state, CL_CALLOC(1, sizeof(dri_state_t)));
+ state->fd = -1;
+ state->driConnectedFlag = NONE;
+ dri_state_init_drawable_hash_table(state);
+
+exit:
+ return state;
+error:
+ dri_state_delete(state);
+ state = NULL;
+ goto exit;
+}
+
+#define __DRI_BUFFER_FRONT_LEFT 0
+#define __DRI_BUFFER_BACK_LEFT 1
+#define __DRI_BUFFER_FRONT_RIGHT 2
+#define __DRI_BUFFER_BACK_RIGHT 3
+#define __DRI_BUFFER_DEPTH 4
+#define __DRI_BUFFER_STENCIL 5
+#define __DRI_BUFFER_ACCUM 6
+#define __DRI_BUFFER_FAKE_FRONT_LEFT 7
+#define __DRI_BUFFER_FAKE_FRONT_RIGHT 8
+
+typedef struct dri2_drawable
+{
+ struct dri_drawable base;
+ union dri_buffer buffers[5];
+ int width;
+ int height;
+ int has_backbuffer;
+ int back_index;
+ int front_index;
+} dri2_drawable_t;
+
+LOCAL dri_drawable_t*
+dri_state_create_drawable(dri_state_t *state, XID x_drawable)
+{
+ dri2_drawable_t *dri2_drwble;
+ dri2_drwble = (dri2_drawable_t*)CL_CALLOC(1, sizeof(*dri2_drwble));
+
+ if (!dri2_drwble)
+ return NULL;
+
+ dri2_drwble->base.x_drawable = x_drawable;
+ dri2_drwble->base.x = 0;
+ dri2_drwble->base.y = 0;
+ VA_DRI2CreateDrawable(state->x11_dpy, x_drawable);
+
+ return &dri2_drwble->base;
+}
+
+LOCAL void
+dri_state_destroy_drawable(dri_state_t *state, dri_drawable_t *dri_drwble)
+{
+ VA_DRI2DestroyDrawable(state->x11_dpy, dri_drwble->x_drawable);
+ free(dri_drwble);
+}
+
+LOCAL void
+dri_state_swap_buffer(dri_state_t *state, dri_drawable_t *dri_drwble)
+{
+ dri2_drawable_t *dri2_drwble = (dri2_drawable_t*)dri_drwble;
+ XRectangle xrect;
+ XserverRegion region;
+
+ if (dri2_drwble->has_backbuffer) {
+ xrect.x = 0;
+ xrect.y = 0;
+ xrect.width = dri2_drwble->width;
+ xrect.height = dri2_drwble->height;
+
+ region = XFixesCreateRegion(state->x11_dpy, &xrect, 1);
+ VA_DRI2CopyRegion(state->x11_dpy, dri_drwble->x_drawable, region,
+ DRI2BufferFrontLeft, DRI2BufferBackLeft);
+ XFixesDestroyRegion(state->x11_dpy, region);
+ }
+}
+
+LOCAL union dri_buffer*
+dri_state_get_rendering_buffer(dri_state_t *state, dri_drawable_t *dri_drwble)
+{
+ dri2_drawable_t *dri2_drwble = (dri2_drawable_t *)dri_drwble;
+ int i;
+ int count;
+ unsigned int attachments[5];
+ VA_DRI2Buffer *buffers;
+
+ i = 0;
+ attachments[i++] = __DRI_BUFFER_BACK_LEFT;
+ attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
+ buffers = VA_DRI2GetBuffers(state->x11_dpy,
+ dri_drwble->x_drawable,
+ &dri2_drwble->width,
+ &dri2_drwble->height,
+ attachments,
+ i,
+ &count);
+ assert(buffers);
+ if (buffers == NULL)
+ return NULL;
+
+ dri2_drwble->has_backbuffer = 0;
+
+ for (i = 0; i < count; i++) {
+ dri2_drwble->buffers[i].dri2.attachment = buffers[i].attachment;
+ dri2_drwble->buffers[i].dri2.name = buffers[i].name;
+ dri2_drwble->buffers[i].dri2.pitch = buffers[i].pitch;
+ dri2_drwble->buffers[i].dri2.cpp = buffers[i].cpp;
+ dri2_drwble->buffers[i].dri2.flags = buffers[i].flags;
+
+ if (buffers[i].attachment == __DRI_BUFFER_BACK_LEFT) {
+ dri2_drwble->has_backbuffer = 1;
+ dri2_drwble->back_index = i;
+ }
+
+ if (buffers[i].attachment == __DRI_BUFFER_FRONT_LEFT)
+ dri2_drwble->front_index = i;
+ }
+
+ dri_drwble->width = dri2_drwble->width;
+ dri_drwble->height = dri2_drwble->height;
+ Xfree(buffers);
+
+ if (dri2_drwble->has_backbuffer)
+ return &dri2_drwble->buffers[dri2_drwble->back_index];
+
+ return &dri2_drwble->buffers[dri2_drwble->front_index];
+}
+
+LOCAL void
+dri_state_close(dri_state_t *state) {
+ dri_state_free_drawable_hash(state);
+ assert(state->fd >= 0);
+ close(state->fd);
+}
+
+LOCAL void
+dri_state_release(dri_state_t *state) {
+ dri_state_delete(state);
+}
+
+LOCAL dri_state_t*
+getDRI2State(Display* dpy, int screen, char **driver_name)
+{
+ int major, minor;
+ int error_base;
+ int event_base;
+ char *device_name = NULL;
+ drm_magic_t magic;
+ char * internal_driver_name = NULL;
+ int fd = -1;
+ dri_state_t* state = NULL;
+
+ if (!VA_DRI2QueryExtension(dpy, &event_base, &error_base))
+ goto err_out;
+
+ if (!VA_DRI2QueryVersion(dpy, &major, &minor))
+ goto err_out;
+
+
+ if (!VA_DRI2Connect(dpy, RootWindow(dpy, screen),
+ &internal_driver_name, &device_name))
+ goto err_out;
+
+ if(device_name != NULL )
+ fd = open(device_name, O_RDWR);
+
+ if (fd < 0)
+ goto err_out;
+
+ if (drmGetMagic(fd, &magic))
+ goto err_out;
+
+ if (!VA_DRI2Authenticate(dpy, RootWindow(dpy, screen),
+ magic))
+ goto err_out;
+
+ if(driver_name)
+ *driver_name = internal_driver_name;
+ else
+ Xfree(internal_driver_name);
+
+ state = dri_state_new();
+ state->fd = fd;
+ state->x11_dpy = dpy;
+ state->x11_screen = screen;
+ state->driConnectedFlag = DRI2;
+ if (device_name)
+ Xfree(device_name);
+ return state;
+
+err_out:
+ if (device_name)
+ Xfree(device_name);
+
+ if (internal_driver_name)
+ Xfree(internal_driver_name);
+
+ if(driver_name) *driver_name = NULL;
+
+ if (fd >= 0)
+ close(fd);
+
+ if (driver_name)
+ *driver_name = NULL;
+
+ return state;
+}
+
diff --git a/src/gen/x11/dricommon.h b/src/gen/x11/dricommon.h
new file mode 100644
index 0000000..aa3a50f
--- /dev/null
+++ b/src/gen/x11/dricommon.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Benjamin Segovia <benjamin.segovia at intel.com>
+ * Note: the code is taken from libva code base
+ */
+
+/*
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _VA_DRICOMMON_H_
+#define _VA_DRICOMMON_H_
+
+#include <X11/Xlib.h>
+#include <xf86drm.h>
+#include <drm.h>
+#include <drm_sarea.h>
+
+union dri_buffer
+{
+ struct {
+ unsigned int attachment;
+ unsigned int name;
+ unsigned int pitch;
+ unsigned int cpp;
+ unsigned int flags;
+ } dri2;
+};
+
+typedef struct dri_drawable
+{
+ XID x_drawable;
+ int x;
+ int y;
+ unsigned int width;
+ unsigned int height;
+ struct dri_drawable *next;
+} dri_drawable_t;
+
+#define DRAWABLE_HASH_SZ 32
+
+enum DRI_VER
+{
+ NONE = 0,
+ // NOT supported VA_DRI1 = 1,
+ DRI2 = 2
+};
+
+typedef struct dri_state
+{
+ Display *x11_dpy;
+ int x11_screen;
+ int fd;
+ enum DRI_VER driConnectedFlag; /* 0: disconnected, 2: DRI2 */
+ dri_drawable_t *drawable_hash[DRAWABLE_HASH_SZ];
+} dri_state_t;
+
+dri_drawable_t *dri_state_create_drawable(dri_state_t*, XID x_drawable);
+void dri_state_destroy_drawable(dri_state_t*, dri_drawable_t*);
+void dri_state_close(dri_state_t*);
+void dri_state_release(dri_state_t*);
+
+// Create a dri2 state from dpy and screen
+dri_state_t *getDRI2State(Display* dpy, int screen, char **driver_name);
+
+#endif /* _VA_DRICOMMON_H_ */
+
diff --git a/src/gen/x11/va_dri2.c b/src/gen/x11/va_dri2.c
new file mode 100644
index 0000000..b660da5
--- /dev/null
+++ b/src/gen/x11/va_dri2.c
@@ -0,0 +1,327 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Benjamin Segovia <benjamin.segovia at intel.com>
+ */
+
+/*
+ * Copyright © 2008 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL 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 PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Authors:
+ * Kristian Høgsberg (krh at redhat.com)
+ */
+
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include "xf86drm.h"
+#include "va_dri2.h"
+#include "va_dri2str.h"
+#include "va_dri2tokens.h"
+
+#ifndef DRI2DriverDRI
+#define DRI2DriverDRI 0
+#endif
+
+#define LOCAL __attribute__ ((visibility ("internal")))
+
+static char va_dri2ExtensionName[] = DRI2_NAME;
+static XExtensionInfo _va_dri2_info_data;
+static XExtensionInfo *va_dri2Info = &_va_dri2_info_data;
+static XEXT_GENERATE_CLOSE_DISPLAY (VA_DRI2CloseDisplay, va_dri2Info)
+static /* const */ XExtensionHooks va_dri2ExtensionHooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ VA_DRI2CloseDisplay, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (DRI2FindDisplay, va_dri2Info,
+ va_dri2ExtensionName,
+ &va_dri2ExtensionHooks,
+ 0, NULL)
+
+LOCAL Bool VA_DRI2QueryExtension(Display *dpy, int *eventBase, int *errorBase)
+{
+ XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+
+ if (XextHasExtension(info)) {
+ *eventBase = info->codes->first_event;
+ *errorBase = info->codes->first_error;
+ return True;
+ }
+
+ return False;
+}
+
+LOCAL Bool VA_DRI2QueryVersion(Display *dpy, int *major, int *minor)
+{
+ XExtDisplayInfo *info = DRI2FindDisplay (dpy);
+ xDRI2QueryVersionReply rep;
+ xDRI2QueryVersionReq *req;
+
+ XextCheckExtension (dpy, info, va_dri2ExtensionName, False);
+
+ LockDisplay(dpy);
+ GetReq(DRI2QueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->dri2Reqtype = X_DRI2QueryVersion;
+ req->majorVersion = DRI2_MAJOR;
+ req->minorVersion = DRI2_MINOR;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *major = rep.majorVersion;
+ *minor = rep.minorVersion;
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return True;
+}
+
+LOCAL Bool VA_DRI2Connect(Display *dpy, XID window,
+ char **driverName, char **deviceName)
+{
+ XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+ xDRI2ConnectReply rep;
+ xDRI2ConnectReq *req;
+
+ XextCheckExtension (dpy, info, va_dri2ExtensionName, False);
+
+ LockDisplay(dpy);
+ GetReq(DRI2Connect, req);
+ req->reqType = info->codes->major_opcode;
+ req->dri2Reqtype = X_DRI2Connect;
+ req->window = window;
+ req->drivertype = DRI2DriverDRI;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+
+ if (rep.driverNameLength == 0 && rep.deviceNameLength == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+
+ *driverName = Xmalloc(rep.driverNameLength + 1);
+ if (*driverName == NULL) {
+ _XEatData(dpy,
+ ((rep.driverNameLength + 3) & ~3) +
+ ((rep.deviceNameLength + 3) & ~3));
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ _XReadPad(dpy, *driverName, rep.driverNameLength);
+ (*driverName)[rep.driverNameLength] = '\0';
+
+ *deviceName = Xmalloc(rep.deviceNameLength + 1);
+ if (*deviceName == NULL) {
+ Xfree(*driverName);
+ _XEatData(dpy, ((rep.deviceNameLength + 3) & ~3));
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ _XReadPad(dpy, *deviceName, rep.deviceNameLength);
+ (*deviceName)[rep.deviceNameLength] = '\0';
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return True;
+}
+
+LOCAL Bool VA_DRI2Authenticate(Display *dpy, XID window, drm_magic_t magic)
+{
+ XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+ xDRI2AuthenticateReq *req;
+ xDRI2AuthenticateReply rep;
+
+ XextCheckExtension (dpy, info, va_dri2ExtensionName, False);
+
+ LockDisplay(dpy);
+ GetReq(DRI2Authenticate, req);
+ req->reqType = info->codes->major_opcode;
+ req->dri2Reqtype = X_DRI2Authenticate;
+ req->window = window;
+ req->magic = magic;
+
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return rep.authenticated;
+}
+
+LOCAL void VA_DRI2CreateDrawable(Display *dpy, XID drawable)
+{
+ XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+ xDRI2CreateDrawableReq *req;
+
+ XextSimpleCheckExtension (dpy, info, va_dri2ExtensionName);
+
+ LockDisplay(dpy);
+ GetReq(DRI2CreateDrawable, req);
+ req->reqType = info->codes->major_opcode;
+ req->dri2Reqtype = X_DRI2CreateDrawable;
+ req->drawable = drawable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+LOCAL void VA_DRI2DestroyDrawable(Display *dpy, XID drawable)
+{
+ XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+ xDRI2DestroyDrawableReq *req;
+
+ XextSimpleCheckExtension (dpy, info, va_dri2ExtensionName);
+
+ XSync(dpy, False);
+
+ LockDisplay(dpy);
+ GetReq(DRI2DestroyDrawable, req);
+ req->reqType = info->codes->major_opcode;
+ req->dri2Reqtype = X_DRI2DestroyDrawable;
+ req->drawable = drawable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+LOCAL VA_DRI2Buffer *VA_DRI2GetBuffers(Display *dpy, XID drawable,
+ int *width, int *height,
+ unsigned int *attachments, int count,
+ int *outcount)
+{
+ XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+ xDRI2GetBuffersReply rep;
+ xDRI2GetBuffersReq *req;
+ VA_DRI2Buffer *buffers;
+ xDRI2Buffer repBuffer;
+ CARD32 *p;
+ int i;
+
+ XextCheckExtension (dpy, info, va_dri2ExtensionName, False);
+
+ LockDisplay(dpy);
+ GetReqExtra(DRI2GetBuffers, count * 4, req);
+ req->reqType = info->codes->major_opcode;
+ req->dri2Reqtype = X_DRI2GetBuffers;
+ req->drawable = drawable;
+ req->count = count;
+ p = (CARD32 *) &req[1];
+ for (i = 0; i < count; i++)
+ p[i] = attachments[i];
+
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+ }
+
+ *width = rep.width;
+ *height = rep.height;
+ *outcount = rep.count;
+
+ buffers = Xmalloc(rep.count * sizeof buffers[0]);
+ if (buffers == NULL) {
+ _XEatData(dpy, rep.count * sizeof repBuffer);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+ }
+
+ for (i = 0; i < (int) rep.count; i++) {
+ _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer);
+ buffers[i].attachment = repBuffer.attachment;
+ buffers[i].name = repBuffer.name;
+ buffers[i].pitch = repBuffer.pitch;
+ buffers[i].cpp = repBuffer.cpp;
+ buffers[i].flags = repBuffer.flags;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return buffers;
+}
+
+LOCAL void VA_DRI2CopyRegion(Display *dpy, XID drawable, XserverRegion region,
+ CARD32 dest, CARD32 src)
+{
+ XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+ xDRI2CopyRegionReq *req;
+ xDRI2CopyRegionReply rep;
+
+ XextSimpleCheckExtension (dpy, info, va_dri2ExtensionName);
+
+ LockDisplay(dpy);
+ GetReq(DRI2CopyRegion, req);
+ req->reqType = info->codes->major_opcode;
+ req->dri2Reqtype = X_DRI2CopyRegion;
+ req->drawable = drawable;
+ req->region = region;
+ req->dest = dest;
+ req->src = src;
+
+ _XReply(dpy, (xReply *)&rep, 0, xFalse);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
diff --git a/src/gen/x11/va_dri2.h b/src/gen/x11/va_dri2.h
new file mode 100644
index 0000000..78e859c
--- /dev/null
+++ b/src/gen/x11/va_dri2.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Benjamin Segovia <benjamin.segovia at intel.com>
+ */
+
+/*
+ * Copyright © 2007,2008 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL 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 PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Authors:
+ * Kristian Høgsberg (krh at redhat.com)
+ */
+#ifndef _VA_DRI2_H_
+#define _VA_DRI2_H_
+
+#include <X11/extensions/Xfixes.h>
+#include <X11/Xfuncproto.h>
+#include <xf86drm.h>
+
+typedef struct {
+ unsigned int attachment;
+ unsigned int name;
+ unsigned int pitch;
+ unsigned int cpp;
+ unsigned int flags;
+} VA_DRI2Buffer;
+
+extern Bool
+VA_DRI2QueryExtension(Display *display, int *eventBase, int *errorBase);
+extern Bool
+VA_DRI2QueryVersion(Display *display, int *major, int *minor);
+extern Bool
+VA_DRI2Connect(Display *display, XID window,
+ char **driverName, char **deviceName);
+extern Bool
+VA_DRI2Authenticate(Display *display, XID window, drm_magic_t magic);
+extern void
+VA_DRI2CreateDrawable(Display *display, XID drawable);
+extern void
+VA_DRI2DestroyDrawable(Display *display, XID handle);
+extern VA_DRI2Buffer *
+VA_DRI2GetBuffers(Display *dpy, XID drawable,
+ int *width, int *height,
+ unsigned int *attachments, int count,
+ int *outcount);
+#if 1
+extern void
+VA_DRI2CopyRegion(Display *dpy, XID drawable, XserverRegion region,
+ CARD32 dest, CARD32 src);
+#endif
+#endif
diff --git a/src/gen/x11/va_dri2str.h b/src/gen/x11/va_dri2str.h
new file mode 100644
index 0000000..d97050f
--- /dev/null
+++ b/src/gen/x11/va_dri2str.h
@@ -0,0 +1,211 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Benjamin Segovia <benjamin.segovia at intel.com>
+ */
+
+/*
+ * Copyright © 2008 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL 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 PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Authors:
+ * Kristian Høgsberg (krh at redhat.com)
+ */
+#ifndef _DRI2_PROTO_H_
+#define _DRI2_PROTO_H_
+
+#define DRI2_NAME "DRI2"
+#define DRI2_MAJOR 1
+#define DRI2_MINOR 0
+
+#define DRI2NumberErrors 0
+#define DRI2NumberEvents 0
+#define DRI2NumberRequests 7
+
+#define X_DRI2QueryVersion 0
+#define X_DRI2Connect 1
+#define X_DRI2Authenticate 2
+#define X_DRI2CreateDrawable 3
+#define X_DRI2DestroyDrawable 4
+#define X_DRI2GetBuffers 5
+#define X_DRI2CopyRegion 6
+
+typedef struct {
+ CARD32 attachment B32;
+ CARD32 name B32;
+ CARD32 pitch B32;
+ CARD32 cpp B32;
+ CARD32 flags B32;
+} xDRI2Buffer;
+
+typedef struct {
+ CARD8 reqType;
+ CARD8 dri2Reqtype;
+ CARD16 length B16;
+ CARD32 majorVersion B32;
+ CARD32 minorVersion B32;
+} xDRI2QueryVersionReq;
+#define sz_xDRI2QueryVersionReq 12
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BYTE pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 majorVersion B32;
+ CARD32 minorVersion B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+} xDRI2QueryVersionReply;
+#define sz_xDRI2QueryVersionReply 32
+
+typedef struct {
+ CARD8 reqType;
+ CARD8 dri2Reqtype;
+ CARD16 length B16;
+ CARD32 window B32;
+ CARD32 drivertype B32;
+} xDRI2ConnectReq;
+#define sz_xDRI2ConnectReq 12
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BYTE pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 driverNameLength B32;
+ CARD32 deviceNameLength B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+} xDRI2ConnectReply;
+#define sz_xDRI2ConnectReply 32
+
+typedef struct {
+ CARD8 reqType;
+ CARD8 dri2Reqtype;
+ CARD16 length B16;
+ CARD32 window B32;
+ CARD32 magic B32;
+} xDRI2AuthenticateReq;
+#define sz_xDRI2AuthenticateReq 12
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BYTE pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 authenticated B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xDRI2AuthenticateReply;
+#define sz_xDRI2AuthenticateReply 32
+
+typedef struct {
+ CARD8 reqType;
+ CARD8 dri2Reqtype;
+ CARD16 length B16;
+ CARD32 drawable B32;
+} xDRI2CreateDrawableReq;
+#define sz_xDRI2CreateDrawableReq 8
+
+typedef struct {
+ CARD8 reqType;
+ CARD8 dri2Reqtype;
+ CARD16 length B16;
+ CARD32 drawable B32;
+} xDRI2DestroyDrawableReq;
+#define sz_xDRI2DestroyDrawableReq 8
+
+typedef struct {
+ CARD8 reqType;
+ CARD8 dri2Reqtype;
+ CARD16 length B16;
+ CARD32 drawable B32;
+ CARD32 count B32;
+} xDRI2GetBuffersReq;
+#define sz_xDRI2GetBuffersReq 12
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BYTE pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 width B32;
+ CARD32 height B32;
+ CARD32 count B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+} xDRI2GetBuffersReply;
+#define sz_xDRI2GetBuffersReply 32
+
+typedef struct {
+ CARD8 reqType;
+ CARD8 dri2Reqtype;
+ CARD16 length B16;
+ CARD32 drawable B32;
+ CARD32 region B32;
+ CARD32 dest B32;
+ CARD32 src B32;
+} xDRI2CopyRegionReq;
+#define sz_xDRI2CopyRegionReq 20
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BYTE pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+ CARD32 pad7 B32;
+} xDRI2CopyRegionReply;
+#define sz_xDRI2CopyRegionReply 32
+
+#endif
diff --git a/src/gen/x11/va_dri2tokens.h b/src/gen/x11/va_dri2tokens.h
new file mode 100644
index 0000000..022609d
--- /dev/null
+++ b/src/gen/x11/va_dri2tokens.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Benjamin Segovia <benjamin.segovia at intel.com>
+ */
+
+/*
+ * Copyright © 2008 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL 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 PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Authors:
+ * Kristian Høgsberg (krh at redhat.com)
+ */
+#ifndef _DRI2_TOKENS_H_
+#define _DRI2_TOKENS_H_
+
+#define DRI2BufferFrontLeft 0
+#define DRI2BufferBackLeft 1
+#define DRI2BufferFrontRight 2
+#define DRI2BufferBackRight 3
+#define DRI2BufferDepth 4
+#define DRI2BufferStencil 5
+#define DRI2BufferAccum 6
+#define DRI2BufferFakeFrontLeft 7
+#define DRI2BufferFakeFrontRight 8
+
+#define DRI2DriverDRI 0
+
+#endif
diff --git a/src/x11/dricommon.c b/src/x11/dricommon.c
deleted file mode 100644
index 345bc47..0000000
--- a/src/x11/dricommon.c
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * Copyright © 2012 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- * Author: Benjamin Segovia <benjamin.segovia at intel.com>
- * Note: the code is taken from libva code base
- */
-
-/*
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <X11/Xlibint.h>
-#include <X11/Xlib.h>
-#include "x11/va_dri2.h"
-#include "x11/va_dri2tokens.h"
-#include "x11/dricommon.h"
-#include "cl_utils.h"
-#include "cl_alloc.h"
-
-#include <stdlib.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <assert.h>
-
-#define LOCAL __attribute__ ((visibility ("internal")))
-
-LOCAL dri_drawable_t*
-dri_state_do_drawable_hash(dri_state_t *state, XID drawable)
-{
- int index = drawable % DRAWABLE_HASH_SZ;
- struct dri_drawable *dri_drawable = state->drawable_hash[index];
-
- while (dri_drawable) {
- if (dri_drawable->x_drawable == drawable)
- return dri_drawable;
- dri_drawable = dri_drawable->next;
- }
-
- dri_drawable = dri_state_create_drawable(state, drawable);
- if(dri_drawable == NULL)
- return NULL;
-
- dri_drawable->x_drawable = drawable;
- dri_drawable->next = state->drawable_hash[index];
- state->drawable_hash[index] = dri_drawable;
-
- return dri_drawable;
-}
-
-LOCAL void
-dri_state_free_drawable_hash(dri_state_t *state)
-{
- int i;
- struct dri_drawable *dri_drawable, *prev;
-
- for (i = 0; i < DRAWABLE_HASH_SZ; i++) {
- dri_drawable = state->drawable_hash[i];
-
- while (dri_drawable) {
- prev = dri_drawable;
- dri_drawable = prev->next;
- dri_state_destroy_drawable(state, prev);
- }
- }
-}
-
-LOCAL dri_drawable_t*
-dri_state_get_drawable(dri_state_t *state, XID drawable)
-{
- return dri_state_do_drawable_hash(state, drawable);
-}
-
-LOCAL void
-dri_state_init_drawable_hash_table(dri_state_t *state)
-{
- int i;
- for(i=0; i < DRAWABLE_HASH_SZ; i++)
- state->drawable_hash[i] = NULL;
-}
-
-LOCAL void
-dri_state_delete(dri_state_t *state)
-{
- if (state == NULL)
- return;
- dri_state_close(state);
- CL_FREE(state);
-}
-
-LOCAL dri_state_t*
-dri_state_new(void)
-{
- dri_state_t *state = NULL;
- TRY_ALLOC_NO_ERR (state, CL_CALLOC(1, sizeof(dri_state_t)));
- state->fd = -1;
- state->driConnectedFlag = NONE;
- dri_state_init_drawable_hash_table(state);
-
-exit:
- return state;
-error:
- dri_state_delete(state);
- state = NULL;
- goto exit;
-}
-
-#define __DRI_BUFFER_FRONT_LEFT 0
-#define __DRI_BUFFER_BACK_LEFT 1
-#define __DRI_BUFFER_FRONT_RIGHT 2
-#define __DRI_BUFFER_BACK_RIGHT 3
-#define __DRI_BUFFER_DEPTH 4
-#define __DRI_BUFFER_STENCIL 5
-#define __DRI_BUFFER_ACCUM 6
-#define __DRI_BUFFER_FAKE_FRONT_LEFT 7
-#define __DRI_BUFFER_FAKE_FRONT_RIGHT 8
-
-typedef struct dri2_drawable
-{
- struct dri_drawable base;
- union dri_buffer buffers[5];
- int width;
- int height;
- int has_backbuffer;
- int back_index;
- int front_index;
-} dri2_drawable_t;
-
-LOCAL dri_drawable_t*
-dri_state_create_drawable(dri_state_t *state, XID x_drawable)
-{
- dri2_drawable_t *dri2_drwble;
- dri2_drwble = (dri2_drawable_t*)CL_CALLOC(1, sizeof(*dri2_drwble));
-
- if (!dri2_drwble)
- return NULL;
-
- dri2_drwble->base.x_drawable = x_drawable;
- dri2_drwble->base.x = 0;
- dri2_drwble->base.y = 0;
- VA_DRI2CreateDrawable(state->x11_dpy, x_drawable);
-
- return &dri2_drwble->base;
-}
-
-LOCAL void
-dri_state_destroy_drawable(dri_state_t *state, dri_drawable_t *dri_drwble)
-{
- VA_DRI2DestroyDrawable(state->x11_dpy, dri_drwble->x_drawable);
- free(dri_drwble);
-}
-
-LOCAL void
-dri_state_swap_buffer(dri_state_t *state, dri_drawable_t *dri_drwble)
-{
- dri2_drawable_t *dri2_drwble = (dri2_drawable_t*)dri_drwble;
- XRectangle xrect;
- XserverRegion region;
-
- if (dri2_drwble->has_backbuffer) {
- xrect.x = 0;
- xrect.y = 0;
- xrect.width = dri2_drwble->width;
- xrect.height = dri2_drwble->height;
-
- region = XFixesCreateRegion(state->x11_dpy, &xrect, 1);
- VA_DRI2CopyRegion(state->x11_dpy, dri_drwble->x_drawable, region,
- DRI2BufferFrontLeft, DRI2BufferBackLeft);
- XFixesDestroyRegion(state->x11_dpy, region);
- }
-}
-
-LOCAL union dri_buffer*
-dri_state_get_rendering_buffer(dri_state_t *state, dri_drawable_t *dri_drwble)
-{
- dri2_drawable_t *dri2_drwble = (dri2_drawable_t *)dri_drwble;
- int i;
- int count;
- unsigned int attachments[5];
- VA_DRI2Buffer *buffers;
-
- i = 0;
- attachments[i++] = __DRI_BUFFER_BACK_LEFT;
- attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
- buffers = VA_DRI2GetBuffers(state->x11_dpy,
- dri_drwble->x_drawable,
- &dri2_drwble->width,
- &dri2_drwble->height,
- attachments,
- i,
- &count);
- assert(buffers);
- if (buffers == NULL)
- return NULL;
-
- dri2_drwble->has_backbuffer = 0;
-
- for (i = 0; i < count; i++) {
- dri2_drwble->buffers[i].dri2.attachment = buffers[i].attachment;
- dri2_drwble->buffers[i].dri2.name = buffers[i].name;
- dri2_drwble->buffers[i].dri2.pitch = buffers[i].pitch;
- dri2_drwble->buffers[i].dri2.cpp = buffers[i].cpp;
- dri2_drwble->buffers[i].dri2.flags = buffers[i].flags;
-
- if (buffers[i].attachment == __DRI_BUFFER_BACK_LEFT) {
- dri2_drwble->has_backbuffer = 1;
- dri2_drwble->back_index = i;
- }
-
- if (buffers[i].attachment == __DRI_BUFFER_FRONT_LEFT)
- dri2_drwble->front_index = i;
- }
-
- dri_drwble->width = dri2_drwble->width;
- dri_drwble->height = dri2_drwble->height;
- Xfree(buffers);
-
- if (dri2_drwble->has_backbuffer)
- return &dri2_drwble->buffers[dri2_drwble->back_index];
-
- return &dri2_drwble->buffers[dri2_drwble->front_index];
-}
-
-LOCAL void
-dri_state_close(dri_state_t *state) {
- dri_state_free_drawable_hash(state);
- assert(state->fd >= 0);
- close(state->fd);
-}
-
-LOCAL void
-dri_state_release(dri_state_t *state) {
- dri_state_delete(state);
-}
-
-LOCAL dri_state_t*
-getDRI2State(Display* dpy, int screen, char **driver_name)
-{
- int major, minor;
- int error_base;
- int event_base;
- char *device_name = NULL;
- drm_magic_t magic;
- char * internal_driver_name = NULL;
- int fd = -1;
- dri_state_t* state = NULL;
-
- if (!VA_DRI2QueryExtension(dpy, &event_base, &error_base))
- goto err_out;
-
- if (!VA_DRI2QueryVersion(dpy, &major, &minor))
- goto err_out;
-
-
- if (!VA_DRI2Connect(dpy, RootWindow(dpy, screen),
- &internal_driver_name, &device_name))
- goto err_out;
-
- if(device_name != NULL )
- fd = open(device_name, O_RDWR);
-
- if (fd < 0)
- goto err_out;
-
- if (drmGetMagic(fd, &magic))
- goto err_out;
-
- if (!VA_DRI2Authenticate(dpy, RootWindow(dpy, screen),
- magic))
- goto err_out;
-
- if(driver_name)
- *driver_name = internal_driver_name;
- else
- Xfree(internal_driver_name);
-
- state = dri_state_new();
- state->fd = fd;
- state->x11_dpy = dpy;
- state->x11_screen = screen;
- state->driConnectedFlag = DRI2;
- if (device_name)
- Xfree(device_name);
- return state;
-
-err_out:
- if (device_name)
- Xfree(device_name);
-
- if (internal_driver_name)
- Xfree(internal_driver_name);
-
- if(driver_name) *driver_name = NULL;
-
- if (fd >= 0)
- close(fd);
-
- if (driver_name)
- *driver_name = NULL;
-
- return state;
-}
-
diff --git a/src/x11/dricommon.h b/src/x11/dricommon.h
deleted file mode 100644
index aa3a50f..0000000
--- a/src/x11/dricommon.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright © 2012 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- * Author: Benjamin Segovia <benjamin.segovia at intel.com>
- * Note: the code is taken from libva code base
- */
-
-/*
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef _VA_DRICOMMON_H_
-#define _VA_DRICOMMON_H_
-
-#include <X11/Xlib.h>
-#include <xf86drm.h>
-#include <drm.h>
-#include <drm_sarea.h>
-
-union dri_buffer
-{
- struct {
- unsigned int attachment;
- unsigned int name;
- unsigned int pitch;
- unsigned int cpp;
- unsigned int flags;
- } dri2;
-};
-
-typedef struct dri_drawable
-{
- XID x_drawable;
- int x;
- int y;
- unsigned int width;
- unsigned int height;
- struct dri_drawable *next;
-} dri_drawable_t;
-
-#define DRAWABLE_HASH_SZ 32
-
-enum DRI_VER
-{
- NONE = 0,
- // NOT supported VA_DRI1 = 1,
- DRI2 = 2
-};
-
-typedef struct dri_state
-{
- Display *x11_dpy;
- int x11_screen;
- int fd;
- enum DRI_VER driConnectedFlag; /* 0: disconnected, 2: DRI2 */
- dri_drawable_t *drawable_hash[DRAWABLE_HASH_SZ];
-} dri_state_t;
-
-dri_drawable_t *dri_state_create_drawable(dri_state_t*, XID x_drawable);
-void dri_state_destroy_drawable(dri_state_t*, dri_drawable_t*);
-void dri_state_close(dri_state_t*);
-void dri_state_release(dri_state_t*);
-
-// Create a dri2 state from dpy and screen
-dri_state_t *getDRI2State(Display* dpy, int screen, char **driver_name);
-
-#endif /* _VA_DRICOMMON_H_ */
-
diff --git a/src/x11/va_dri2.c b/src/x11/va_dri2.c
deleted file mode 100644
index 8779fa5..0000000
--- a/src/x11/va_dri2.c
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * Copyright © 2012 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- * Author: Benjamin Segovia <benjamin.segovia at intel.com>
- */
-
-/*
- * Copyright © 2008 Red Hat, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Soft-
- * ware"), to deal in the Software without restriction, including without
- * limitation the rights to use, copy, modify, merge, publish, distribute,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, provided that the above copyright
- * notice(s) and this permission notice appear in all copies of the Soft-
- * ware and that both the above copyright notice(s) and this permission
- * notice appear in supporting documentation.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
- * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
- * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
- * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
- * QUENTIAL 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 PERFOR-
- * MANCE OF THIS SOFTWARE.
- *
- * Except as contained in this notice, the name of a copyright holder shall
- * not be used in advertising or otherwise to promote the sale, use or
- * other dealings in this Software without prior written authorization of
- * the copyright holder.
- *
- * Authors:
- * Kristian Høgsberg (krh at redhat.com)
- */
-
-#define NEED_REPLIES
-#include <X11/Xlibint.h>
-#include <X11/extensions/Xext.h>
-#include <X11/extensions/extutil.h>
-#include "xf86drm.h"
-#include "x11/va_dri2.h"
-#include "x11/va_dri2str.h"
-#include "x11/va_dri2tokens.h"
-
-#ifndef DRI2DriverDRI
-#define DRI2DriverDRI 0
-#endif
-
-#define LOCAL __attribute__ ((visibility ("internal")))
-
-static char va_dri2ExtensionName[] = DRI2_NAME;
-static XExtensionInfo _va_dri2_info_data;
-static XExtensionInfo *va_dri2Info = &_va_dri2_info_data;
-static XEXT_GENERATE_CLOSE_DISPLAY (VA_DRI2CloseDisplay, va_dri2Info)
-static /* const */ XExtensionHooks va_dri2ExtensionHooks = {
- NULL, /* create_gc */
- NULL, /* copy_gc */
- NULL, /* flush_gc */
- NULL, /* free_gc */
- NULL, /* create_font */
- NULL, /* free_font */
- VA_DRI2CloseDisplay, /* close_display */
- NULL, /* wire_to_event */
- NULL, /* event_to_wire */
- NULL, /* error */
- NULL, /* error_string */
-};
-
-static XEXT_GENERATE_FIND_DISPLAY (DRI2FindDisplay, va_dri2Info,
- va_dri2ExtensionName,
- &va_dri2ExtensionHooks,
- 0, NULL)
-
-LOCAL Bool VA_DRI2QueryExtension(Display *dpy, int *eventBase, int *errorBase)
-{
- XExtDisplayInfo *info = DRI2FindDisplay(dpy);
-
- if (XextHasExtension(info)) {
- *eventBase = info->codes->first_event;
- *errorBase = info->codes->first_error;
- return True;
- }
-
- return False;
-}
-
-LOCAL Bool VA_DRI2QueryVersion(Display *dpy, int *major, int *minor)
-{
- XExtDisplayInfo *info = DRI2FindDisplay (dpy);
- xDRI2QueryVersionReply rep;
- xDRI2QueryVersionReq *req;
-
- XextCheckExtension (dpy, info, va_dri2ExtensionName, False);
-
- LockDisplay(dpy);
- GetReq(DRI2QueryVersion, req);
- req->reqType = info->codes->major_opcode;
- req->dri2Reqtype = X_DRI2QueryVersion;
- req->majorVersion = DRI2_MAJOR;
- req->minorVersion = DRI2_MINOR;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
- *major = rep.majorVersion;
- *minor = rep.minorVersion;
- UnlockDisplay(dpy);
- SyncHandle();
-
- return True;
-}
-
-LOCAL Bool VA_DRI2Connect(Display *dpy, XID window,
- char **driverName, char **deviceName)
-{
- XExtDisplayInfo *info = DRI2FindDisplay(dpy);
- xDRI2ConnectReply rep;
- xDRI2ConnectReq *req;
-
- XextCheckExtension (dpy, info, va_dri2ExtensionName, False);
-
- LockDisplay(dpy);
- GetReq(DRI2Connect, req);
- req->reqType = info->codes->major_opcode;
- req->dri2Reqtype = X_DRI2Connect;
- req->window = window;
- req->drivertype = DRI2DriverDRI;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
-
- if (rep.driverNameLength == 0 && rep.deviceNameLength == 0) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
-
- *driverName = Xmalloc(rep.driverNameLength + 1);
- if (*driverName == NULL) {
- _XEatData(dpy,
- ((rep.driverNameLength + 3) & ~3) +
- ((rep.deviceNameLength + 3) & ~3));
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
- _XReadPad(dpy, *driverName, rep.driverNameLength);
- (*driverName)[rep.driverNameLength] = '\0';
-
- *deviceName = Xmalloc(rep.deviceNameLength + 1);
- if (*deviceName == NULL) {
- Xfree(*driverName);
- _XEatData(dpy, ((rep.deviceNameLength + 3) & ~3));
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
- _XReadPad(dpy, *deviceName, rep.deviceNameLength);
- (*deviceName)[rep.deviceNameLength] = '\0';
-
- UnlockDisplay(dpy);
- SyncHandle();
-
- return True;
-}
-
-LOCAL Bool VA_DRI2Authenticate(Display *dpy, XID window, drm_magic_t magic)
-{
- XExtDisplayInfo *info = DRI2FindDisplay(dpy);
- xDRI2AuthenticateReq *req;
- xDRI2AuthenticateReply rep;
-
- XextCheckExtension (dpy, info, va_dri2ExtensionName, False);
-
- LockDisplay(dpy);
- GetReq(DRI2Authenticate, req);
- req->reqType = info->codes->major_opcode;
- req->dri2Reqtype = X_DRI2Authenticate;
- req->window = window;
- req->magic = magic;
-
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
-
- UnlockDisplay(dpy);
- SyncHandle();
-
- return rep.authenticated;
-}
-
-LOCAL void VA_DRI2CreateDrawable(Display *dpy, XID drawable)
-{
- XExtDisplayInfo *info = DRI2FindDisplay(dpy);
- xDRI2CreateDrawableReq *req;
-
- XextSimpleCheckExtension (dpy, info, va_dri2ExtensionName);
-
- LockDisplay(dpy);
- GetReq(DRI2CreateDrawable, req);
- req->reqType = info->codes->major_opcode;
- req->dri2Reqtype = X_DRI2CreateDrawable;
- req->drawable = drawable;
- UnlockDisplay(dpy);
- SyncHandle();
-}
-
-LOCAL void VA_DRI2DestroyDrawable(Display *dpy, XID drawable)
-{
- XExtDisplayInfo *info = DRI2FindDisplay(dpy);
- xDRI2DestroyDrawableReq *req;
-
- XextSimpleCheckExtension (dpy, info, va_dri2ExtensionName);
-
- XSync(dpy, False);
-
- LockDisplay(dpy);
- GetReq(DRI2DestroyDrawable, req);
- req->reqType = info->codes->major_opcode;
- req->dri2Reqtype = X_DRI2DestroyDrawable;
- req->drawable = drawable;
- UnlockDisplay(dpy);
- SyncHandle();
-}
-
-LOCAL VA_DRI2Buffer *VA_DRI2GetBuffers(Display *dpy, XID drawable,
- int *width, int *height,
- unsigned int *attachments, int count,
- int *outcount)
-{
- XExtDisplayInfo *info = DRI2FindDisplay(dpy);
- xDRI2GetBuffersReply rep;
- xDRI2GetBuffersReq *req;
- VA_DRI2Buffer *buffers;
- xDRI2Buffer repBuffer;
- CARD32 *p;
- int i;
-
- XextCheckExtension (dpy, info, va_dri2ExtensionName, False);
-
- LockDisplay(dpy);
- GetReqExtra(DRI2GetBuffers, count * 4, req);
- req->reqType = info->codes->major_opcode;
- req->dri2Reqtype = X_DRI2GetBuffers;
- req->drawable = drawable;
- req->count = count;
- p = (CARD32 *) &req[1];
- for (i = 0; i < count; i++)
- p[i] = attachments[i];
-
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return NULL;
- }
-
- *width = rep.width;
- *height = rep.height;
- *outcount = rep.count;
-
- buffers = Xmalloc(rep.count * sizeof buffers[0]);
- if (buffers == NULL) {
- _XEatData(dpy, rep.count * sizeof repBuffer);
- UnlockDisplay(dpy);
- SyncHandle();
- return NULL;
- }
-
- for (i = 0; i < (int) rep.count; i++) {
- _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer);
- buffers[i].attachment = repBuffer.attachment;
- buffers[i].name = repBuffer.name;
- buffers[i].pitch = repBuffer.pitch;
- buffers[i].cpp = repBuffer.cpp;
- buffers[i].flags = repBuffer.flags;
- }
-
- UnlockDisplay(dpy);
- SyncHandle();
-
- return buffers;
-}
-
-LOCAL void VA_DRI2CopyRegion(Display *dpy, XID drawable, XserverRegion region,
- CARD32 dest, CARD32 src)
-{
- XExtDisplayInfo *info = DRI2FindDisplay(dpy);
- xDRI2CopyRegionReq *req;
- xDRI2CopyRegionReply rep;
-
- XextSimpleCheckExtension (dpy, info, va_dri2ExtensionName);
-
- LockDisplay(dpy);
- GetReq(DRI2CopyRegion, req);
- req->reqType = info->codes->major_opcode;
- req->dri2Reqtype = X_DRI2CopyRegion;
- req->drawable = drawable;
- req->region = region;
- req->dest = dest;
- req->src = src;
-
- _XReply(dpy, (xReply *)&rep, 0, xFalse);
-
- UnlockDisplay(dpy);
- SyncHandle();
-}
diff --git a/src/x11/va_dri2.h b/src/x11/va_dri2.h
deleted file mode 100644
index 78e859c..0000000
--- a/src/x11/va_dri2.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright © 2012 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- * Author: Benjamin Segovia <benjamin.segovia at intel.com>
- */
-
-/*
- * Copyright © 2007,2008 Red Hat, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Soft-
- * ware"), to deal in the Software without restriction, including without
- * limitation the rights to use, copy, modify, merge, publish, distribute,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, provided that the above copyright
- * notice(s) and this permission notice appear in all copies of the Soft-
- * ware and that both the above copyright notice(s) and this permission
- * notice appear in supporting documentation.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
- * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
- * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
- * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
- * QUENTIAL 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 PERFOR-
- * MANCE OF THIS SOFTWARE.
- *
- * Except as contained in this notice, the name of a copyright holder shall
- * not be used in advertising or otherwise to promote the sale, use or
- * other dealings in this Software without prior written authorization of
- * the copyright holder.
- *
- * Authors:
- * Kristian Høgsberg (krh at redhat.com)
- */
-#ifndef _VA_DRI2_H_
-#define _VA_DRI2_H_
-
-#include <X11/extensions/Xfixes.h>
-#include <X11/Xfuncproto.h>
-#include <xf86drm.h>
-
-typedef struct {
- unsigned int attachment;
- unsigned int name;
- unsigned int pitch;
- unsigned int cpp;
- unsigned int flags;
-} VA_DRI2Buffer;
-
-extern Bool
-VA_DRI2QueryExtension(Display *display, int *eventBase, int *errorBase);
-extern Bool
-VA_DRI2QueryVersion(Display *display, int *major, int *minor);
-extern Bool
-VA_DRI2Connect(Display *display, XID window,
- char **driverName, char **deviceName);
-extern Bool
-VA_DRI2Authenticate(Display *display, XID window, drm_magic_t magic);
-extern void
-VA_DRI2CreateDrawable(Display *display, XID drawable);
-extern void
-VA_DRI2DestroyDrawable(Display *display, XID handle);
-extern VA_DRI2Buffer *
-VA_DRI2GetBuffers(Display *dpy, XID drawable,
- int *width, int *height,
- unsigned int *attachments, int count,
- int *outcount);
-#if 1
-extern void
-VA_DRI2CopyRegion(Display *dpy, XID drawable, XserverRegion region,
- CARD32 dest, CARD32 src);
-#endif
-#endif
diff --git a/src/x11/va_dri2str.h b/src/x11/va_dri2str.h
deleted file mode 100644
index d97050f..0000000
--- a/src/x11/va_dri2str.h
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright © 2012 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- * Author: Benjamin Segovia <benjamin.segovia at intel.com>
- */
-
-/*
- * Copyright © 2008 Red Hat, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Soft-
- * ware"), to deal in the Software without restriction, including without
- * limitation the rights to use, copy, modify, merge, publish, distribute,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, provided that the above copyright
- * notice(s) and this permission notice appear in all copies of the Soft-
- * ware and that both the above copyright notice(s) and this permission
- * notice appear in supporting documentation.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
- * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
- * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
- * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
- * QUENTIAL 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 PERFOR-
- * MANCE OF THIS SOFTWARE.
- *
- * Except as contained in this notice, the name of a copyright holder shall
- * not be used in advertising or otherwise to promote the sale, use or
- * other dealings in this Software without prior written authorization of
- * the copyright holder.
- *
- * Authors:
- * Kristian Høgsberg (krh at redhat.com)
- */
-#ifndef _DRI2_PROTO_H_
-#define _DRI2_PROTO_H_
-
-#define DRI2_NAME "DRI2"
-#define DRI2_MAJOR 1
-#define DRI2_MINOR 0
-
-#define DRI2NumberErrors 0
-#define DRI2NumberEvents 0
-#define DRI2NumberRequests 7
-
-#define X_DRI2QueryVersion 0
-#define X_DRI2Connect 1
-#define X_DRI2Authenticate 2
-#define X_DRI2CreateDrawable 3
-#define X_DRI2DestroyDrawable 4
-#define X_DRI2GetBuffers 5
-#define X_DRI2CopyRegion 6
-
-typedef struct {
- CARD32 attachment B32;
- CARD32 name B32;
- CARD32 pitch B32;
- CARD32 cpp B32;
- CARD32 flags B32;
-} xDRI2Buffer;
-
-typedef struct {
- CARD8 reqType;
- CARD8 dri2Reqtype;
- CARD16 length B16;
- CARD32 majorVersion B32;
- CARD32 minorVersion B32;
-} xDRI2QueryVersionReq;
-#define sz_xDRI2QueryVersionReq 12
-
-typedef struct {
- BYTE type; /* X_Reply */
- BYTE pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 majorVersion B32;
- CARD32 minorVersion B32;
- CARD32 pad2 B32;
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
-} xDRI2QueryVersionReply;
-#define sz_xDRI2QueryVersionReply 32
-
-typedef struct {
- CARD8 reqType;
- CARD8 dri2Reqtype;
- CARD16 length B16;
- CARD32 window B32;
- CARD32 drivertype B32;
-} xDRI2ConnectReq;
-#define sz_xDRI2ConnectReq 12
-
-typedef struct {
- BYTE type; /* X_Reply */
- BYTE pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 driverNameLength B32;
- CARD32 deviceNameLength B32;
- CARD32 pad2 B32;
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
-} xDRI2ConnectReply;
-#define sz_xDRI2ConnectReply 32
-
-typedef struct {
- CARD8 reqType;
- CARD8 dri2Reqtype;
- CARD16 length B16;
- CARD32 window B32;
- CARD32 magic B32;
-} xDRI2AuthenticateReq;
-#define sz_xDRI2AuthenticateReq 12
-
-typedef struct {
- BYTE type; /* X_Reply */
- BYTE pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 authenticated B32;
- CARD32 pad2 B32;
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
-} xDRI2AuthenticateReply;
-#define sz_xDRI2AuthenticateReply 32
-
-typedef struct {
- CARD8 reqType;
- CARD8 dri2Reqtype;
- CARD16 length B16;
- CARD32 drawable B32;
-} xDRI2CreateDrawableReq;
-#define sz_xDRI2CreateDrawableReq 8
-
-typedef struct {
- CARD8 reqType;
- CARD8 dri2Reqtype;
- CARD16 length B16;
- CARD32 drawable B32;
-} xDRI2DestroyDrawableReq;
-#define sz_xDRI2DestroyDrawableReq 8
-
-typedef struct {
- CARD8 reqType;
- CARD8 dri2Reqtype;
- CARD16 length B16;
- CARD32 drawable B32;
- CARD32 count B32;
-} xDRI2GetBuffersReq;
-#define sz_xDRI2GetBuffersReq 12
-
-typedef struct {
- BYTE type; /* X_Reply */
- BYTE pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 width B32;
- CARD32 height B32;
- CARD32 count B32;
- CARD32 pad2 B32;
- CARD32 pad3 B32;
- CARD32 pad4 B32;
-} xDRI2GetBuffersReply;
-#define sz_xDRI2GetBuffersReply 32
-
-typedef struct {
- CARD8 reqType;
- CARD8 dri2Reqtype;
- CARD16 length B16;
- CARD32 drawable B32;
- CARD32 region B32;
- CARD32 dest B32;
- CARD32 src B32;
-} xDRI2CopyRegionReq;
-#define sz_xDRI2CopyRegionReq 20
-
-typedef struct {
- BYTE type; /* X_Reply */
- BYTE pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 pad2 B32;
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
- CARD32 pad7 B32;
-} xDRI2CopyRegionReply;
-#define sz_xDRI2CopyRegionReply 32
-
-#endif
diff --git a/src/x11/va_dri2tokens.h b/src/x11/va_dri2tokens.h
deleted file mode 100644
index 022609d..0000000
--- a/src/x11/va_dri2tokens.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright © 2012 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- * Author: Benjamin Segovia <benjamin.segovia at intel.com>
- */
-
-/*
- * Copyright © 2008 Red Hat, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Soft-
- * ware"), to deal in the Software without restriction, including without
- * limitation the rights to use, copy, modify, merge, publish, distribute,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, provided that the above copyright
- * notice(s) and this permission notice appear in all copies of the Soft-
- * ware and that both the above copyright notice(s) and this permission
- * notice appear in supporting documentation.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
- * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
- * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
- * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
- * QUENTIAL 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 PERFOR-
- * MANCE OF THIS SOFTWARE.
- *
- * Except as contained in this notice, the name of a copyright holder shall
- * not be used in advertising or otherwise to promote the sale, use or
- * other dealings in this Software without prior written authorization of
- * the copyright holder.
- *
- * Authors:
- * Kristian Høgsberg (krh at redhat.com)
- */
-#ifndef _DRI2_TOKENS_H_
-#define _DRI2_TOKENS_H_
-
-#define DRI2BufferFrontLeft 0
-#define DRI2BufferBackLeft 1
-#define DRI2BufferFrontRight 2
-#define DRI2BufferBackRight 3
-#define DRI2BufferDepth 4
-#define DRI2BufferStencil 5
-#define DRI2BufferAccum 6
-#define DRI2BufferFakeFrontLeft 7
-#define DRI2BufferFakeFrontRight 8
-
-#define DRI2DriverDRI 0
-
-#endif
--
2.7.4
More information about the Beignet
mailing list