g3dvl: Shared drm winsys bits.
authorYounes Manton <younes.m@gmail.com>
Fri, 6 Nov 2009 04:58:29 +0000 (23:58 -0500)
committerYounes Manton <younes.m@gmail.com>
Fri, 6 Nov 2009 04:58:29 +0000 (23:58 -0500)
25 files changed:
src/driclient/include/driclient.h [deleted file]
src/driclient/include/xf86dri.h [deleted file]
src/driclient/src/XF86dri.c [deleted file]
src/driclient/src/driclient.c [deleted file]
src/driclient/src/xf86dristr.h [deleted file]
src/gallium/winsys/Makefile
src/gallium/winsys/g3dvl/Makefile
src/gallium/winsys/g3dvl/dri/Makefile [new file with mode: 0644]
src/gallium/winsys/g3dvl/dri/XF86dri.c [new file with mode: 0644]
src/gallium/winsys/g3dvl/dri/dri_winsys.c [new file with mode: 0644]
src/gallium/winsys/g3dvl/dri/driclient.c [new file with mode: 0644]
src/gallium/winsys/g3dvl/dri/driclient.h [new file with mode: 0644]
src/gallium/winsys/g3dvl/dri/xf86dri.h [new file with mode: 0644]
src/gallium/winsys/g3dvl/dri/xf86dristr.h [new file with mode: 0644]
src/gallium/winsys/g3dvl/drm/Makefile [new file with mode: 0644]
src/gallium/winsys/g3dvl/drm/Makefile.template [new file with mode: 0644]
src/gallium/winsys/g3dvl/drm/nouveau/Makefile [new file with mode: 0644]
src/gallium/winsys/g3dvl/nouveau/Makefile [deleted file]
src/gallium/winsys/g3dvl/nouveau/drm_nouveau_winsys.c [deleted file]
src/gallium/winsys/g3dvl/nouveau/nouveau_context_vl.c [deleted file]
src/gallium/winsys/g3dvl/nouveau/nouveau_context_vl.h [deleted file]
src/gallium/winsys/g3dvl/nouveau/nouveau_screen_vl.c [deleted file]
src/gallium/winsys/g3dvl/nouveau/nouveau_screen_vl.h [deleted file]
src/gallium/winsys/g3dvl/nouveau/nouveau_swapbuffers.c [deleted file]
src/gallium/winsys/g3dvl/nouveau/nouveau_swapbuffers.h [deleted file]

diff --git a/src/driclient/include/driclient.h b/src/driclient/include/driclient.h
deleted file mode 100644 (file)
index d391525..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-#ifndef driclient_h
-#define driclient_h
-
-#include <stdint.h>
-#include <X11/Xlib.h>
-#include <drm_sarea.h>
-#include "xf86dri.h"
-
-/* TODO: Bring in DRI XML options */
-
-typedef struct dri_version
-{
-       int major;
-       int minor;
-       int patch;
-} dri_version_t;
-
-typedef struct dri_screen
-{
-       Display                 *display;
-       unsigned int            num;
-       dri_version_t           ddx, dri, drm;
-       int                     draw_lock_id;
-       int                     fd;
-       drm_sarea_t             *sarea;
-       void                    *drawable_hash;
-       void                    *private;
-} dri_screen_t;
-
-struct dri_context;
-
-typedef struct dri_drawable
-{
-       drm_drawable_t          drm_drawable;
-       Drawable                x_drawable;
-       unsigned int            sarea_index;
-       unsigned int            *sarea_stamp;
-       unsigned int            last_sarea_stamp;
-       int                     x, y, w, h;
-       int                     back_x, back_y;
-       int                     num_cliprects, num_back_cliprects;
-       drm_clip_rect_t         *cliprects, *back_cliprects;
-       dri_screen_t            *dri_screen;
-       unsigned int            refcount;
-       void                    *private;
-} dri_drawable_t;
-
-typedef struct dri_context
-{
-       XID                     id;
-       drm_context_t           drm_context;
-       dri_screen_t            *dri_screen;
-       void                    *private;
-} dri_context_t;
-
-typedef struct dri_framebuffer
-{
-       drm_handle_t            drm_handle;
-       int                     base, size, stride;
-       int                     private_size;
-       void                    *private;
-} dri_framebuffer_t;
-
-int driCreateScreen(Display *display, int screen, dri_screen_t **dri_screen, dri_framebuffer_t *dri_framebuf);
-int driDestroyScreen(dri_screen_t *dri_screen);
-int driCreateDrawable(dri_screen_t *dri_screen, Drawable drawable, dri_drawable_t **dri_drawable);
-int driUpdateDrawableInfo(dri_drawable_t *dri_drawable);
-int driDestroyDrawable(dri_drawable_t *dri_drawable);
-int driCreateContext(dri_screen_t *dri_screen, Visual *visual, dri_context_t **dri_context);
-int driDestroyContext(dri_context_t *dri_context);
-
-#define DRI_VALIDATE_DRAWABLE_INFO_ONCE(dri_drawable)                                  \
-do                                                                                     \
-{                                                                                      \
-       if (*(dri_drawable->sarea_stamp) != dri_drawable->last_sarea_stamp)             \
-               driUpdateDrawableInfo(dri_drawable);                                    \
-} while (0)
-
-#define DRI_VALIDATE_DRAWABLE_INFO(dri_screen, dri_drawable)                                   \
-do                                                                                             \
-{                                                                                              \
-       while (*(dri_drawable->sarea_stamp) != dri_drawable->last_sarea_stamp)                  \
-       {                                                                                       \
-               register unsigned int hwContext = dri_screen->sarea->lock.lock &                \
-               ~(DRM_LOCK_HELD | DRM_LOCK_CONT);                                               \
-               DRM_UNLOCK(dri_screen->fd, &dri_screen->sarea->lock, hwContext);                \
-                                                                                               \
-               DRM_SPINLOCK(&dri_screen->sarea->drawable_lock, dri_screen->draw_lock_id);      \
-               DRI_VALIDATE_DRAWABLE_INFO_ONCE(dri_drawable);                                  \
-               DRM_SPINUNLOCK(&dri_screen->sarea->drawable_lock, dri_screen->draw_lock_id);    \
-                                                                                               \
-               DRM_LIGHT_LOCK(dri_screen->fd, &dri_screen->sarea->lock, hwContext);            \
-       }                                                                                       \
-} while (0)
-
-#endif
-
diff --git a/src/driclient/include/xf86dri.h b/src/driclient/include/xf86dri.h
deleted file mode 100644 (file)
index baf80a7..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-Copyright 2000 VA Linux Systems, Inc.
-All Rights Reserved.
-
-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.
-
-**************************************************************************/
-
-/**
- * \file xf86dri.h
- * Protocol numbers and function prototypes for DRI X protocol.
- *
- * \author Kevin E. Martin <martin@valinux.com>
- * \author Jens Owen <jens@tungstengraphics.com>
- * \author Rickard E. (Rik) Faith <faith@valinux.com>
- */
-
-#ifndef _XF86DRI_H_
-#define _XF86DRI_H_
-
-#include <X11/Xfuncproto.h>
-#include <xf86drm.h>
-
-#define X_XF86DRIQueryVersion                  0
-#define X_XF86DRIQueryDirectRenderingCapable   1
-#define X_XF86DRIOpenConnection                        2
-#define X_XF86DRICloseConnection               3
-#define X_XF86DRIGetClientDriverName           4
-#define X_XF86DRICreateContext                 5
-#define X_XF86DRIDestroyContext                        6
-#define X_XF86DRICreateDrawable                        7
-#define X_XF86DRIDestroyDrawable               8
-#define X_XF86DRIGetDrawableInfo               9
-#define X_XF86DRIGetDeviceInfo                 10
-#define X_XF86DRIAuthConnection                 11
-#define X_XF86DRIOpenFullScreen                 12   /* Deprecated */
-#define X_XF86DRICloseFullScreen                13   /* Deprecated */
-
-#define XF86DRINumberEvents            0
-
-#define XF86DRIClientNotLocal          0
-#define XF86DRIOperationNotSupported   1
-#define XF86DRINumberErrors            (XF86DRIOperationNotSupported + 1)
-
-#ifndef _XF86DRI_SERVER_
-
-_XFUNCPROTOBEGIN
-
-Bool XF86DRIQueryExtension( Display *dpy, int *event_base, int *error_base );
-
-Bool XF86DRIQueryVersion( Display *dpy, int *majorVersion, int *minorVersion,
-    int *patchVersion );
-
-Bool XF86DRIQueryDirectRenderingCapable( Display *dpy, int screen,
-    Bool *isCapable );
-
-Bool XF86DRIOpenConnection( Display *dpy, int screen, drm_handle_t *hSAREA,
-    char **busIDString );
-
-Bool XF86DRIAuthConnection( Display *dpy, int screen, drm_magic_t magic );
-
-Bool XF86DRICloseConnection( Display *dpy, int screen );
-
-Bool XF86DRIGetClientDriverName( Display *dpy, int screen,
-    int *ddxDriverMajorVersion, int *ddxDriverMinorVersion,
-    int *ddxDriverPatchVersion, char **clientDriverName );
-
-Bool XF86DRICreateContext( Display *dpy, int screen, Visual *visual,
-    XID *ptr_to_returned_context_id, drm_context_t *hHWContext );
-
-Bool XF86DRICreateContextWithConfig( Display *dpy, int screen, int configID,
-    XID *ptr_to_returned_context_id, drm_context_t *hHWContext );
-
-Bool XF86DRIDestroyContext( Display *dpy, int screen,
-    XID context_id );
-
-Bool XF86DRICreateDrawable( Display *dpy, int screen,
-    Drawable drawable, drm_drawable_t *hHWDrawable );
-
-Bool XF86DRIDestroyDrawable( Display *dpy, int screen, 
-    Drawable drawable);
-
-Bool XF86DRIGetDrawableInfo( Display *dpy, int screen, Drawable drawable,
-    unsigned int *index, unsigned int *stamp, 
-    int *X, int *Y, int *W, int *H,
-    int *numClipRects, drm_clip_rect_t ** pClipRects,
-    int *backX, int *backY,
-    int *numBackClipRects, drm_clip_rect_t **pBackClipRects );
-
-Bool XF86DRIGetDeviceInfo( Display *dpy, int screen,
-    drm_handle_t *hFrameBuffer, int *fbOrigin, int *fbSize,
-    int *fbStride, int *devPrivateSize, void **pDevPrivate );
-
-_XFUNCPROTOEND
-
-#endif /* _XF86DRI_SERVER_ */
-
-#endif /* _XF86DRI_H_ */
-
diff --git a/src/driclient/src/XF86dri.c b/src/driclient/src/XF86dri.c
deleted file mode 100644 (file)
index 9e359a9..0000000
+++ /dev/null
@@ -1,619 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-Copyright 2000 VA Linux Systems, Inc.
-All Rights Reserved.
-
-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.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <martin@valinux.com>
- *   Jens Owen <jens@tungstengraphics.com>
- *   Rickard E. (Rik) Faith <faith@valinux.com>
- *
- */
-
-/* THIS IS NOT AN X CONSORTIUM STANDARD */
-
-#define NEED_REPLIES
-#include <X11/Xlibint.h>
-#include <X11/extensions/Xext.h>
-#include <X11/extensions/extutil.h>
-#include "xf86dristr.h"
-
-static XExtensionInfo _xf86dri_info_data;
-static XExtensionInfo *xf86dri_info = &_xf86dri_info_data;
-static char xf86dri_extension_name[] = XF86DRINAME;
-
-#define XF86DRICheckExtension(dpy,i,val) \
-  XextCheckExtension (dpy, i, xf86dri_extension_name, val)
-
-/*****************************************************************************
- *                                                                           *
- *                        private utility routines                          *
- *                                                                           *
- *****************************************************************************/
-
-static int close_display(Display *dpy, XExtCodes *extCodes);
-static /* const */ XExtensionHooks xf86dri_extension_hooks = {
-    NULL,                              /* create_gc */
-    NULL,                              /* copy_gc */
-    NULL,                              /* flush_gc */
-    NULL,                              /* free_gc */
-    NULL,                              /* create_font */
-    NULL,                              /* free_font */
-    close_display,                     /* close_display */
-    NULL,                              /* wire_to_event */
-    NULL,                              /* event_to_wire */
-    NULL,                              /* error */
-    NULL,                              /* error_string */
-};
-
-static XEXT_GENERATE_FIND_DISPLAY (find_display, xf86dri_info, 
-                                  xf86dri_extension_name, 
-                                  &xf86dri_extension_hooks, 
-                                  0, NULL)
-
-static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info)
-
-
-/*****************************************************************************
- *                                                                           *
- *                 public XFree86-DRI Extension routines                    *
- *                                                                           *
- *****************************************************************************/
-
-#if 0
-#include <stdio.h>
-#define TRACE(msg)  fprintf(stderr,"XF86DRI%s\n", msg);
-#else
-#define TRACE(msg)
-#endif
-
-#define PUBLIC
-
-PUBLIC Bool XF86DRIQueryExtension (dpy, event_basep, error_basep)
-    Display *dpy;
-    int *event_basep, *error_basep;
-{
-    XExtDisplayInfo *info = find_display (dpy);
-
-    TRACE("QueryExtension...");
-    if (XextHasExtension(info)) {
-       *event_basep = info->codes->first_event;
-       *error_basep = info->codes->first_error;
-        TRACE("QueryExtension... return True");
-       return True;
-    } else {
-        TRACE("QueryExtension... return False");
-       return False;
-    }
-}
-
-PUBLIC Bool XF86DRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion)
-    Display* dpy;
-    int* majorVersion; 
-    int* minorVersion;
-    int* patchVersion;
-{
-    XExtDisplayInfo *info = find_display (dpy);
-    xXF86DRIQueryVersionReply rep;
-    xXF86DRIQueryVersionReq *req;
-
-    TRACE("QueryVersion...");
-    XF86DRICheckExtension (dpy, info, False);
-
-    LockDisplay(dpy);
-    GetReq(XF86DRIQueryVersion, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_XF86DRIQueryVersion;
-    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
-       UnlockDisplay(dpy);
-       SyncHandle();
-        TRACE("QueryVersion... return False");
-       return False;
-    }
-    *majorVersion = rep.majorVersion;
-    *minorVersion = rep.minorVersion;
-    *patchVersion = rep.patchVersion;
-    UnlockDisplay(dpy);
-    SyncHandle();
-    TRACE("QueryVersion... return True");
-    return True;
-}
-
-PUBLIC Bool XF86DRIQueryDirectRenderingCapable(dpy, screen, isCapable)
-    Display* dpy;
-    int screen;
-    Bool* isCapable;
-{
-    XExtDisplayInfo *info = find_display (dpy);
-    xXF86DRIQueryDirectRenderingCapableReply rep;
-    xXF86DRIQueryDirectRenderingCapableReq *req;
-
-    TRACE("QueryDirectRenderingCapable...");
-    XF86DRICheckExtension (dpy, info, False);
-
-    LockDisplay(dpy);
-    GetReq(XF86DRIQueryDirectRenderingCapable, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_XF86DRIQueryDirectRenderingCapable;
-    req->screen = screen;
-    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
-       UnlockDisplay(dpy);
-       SyncHandle();
-        TRACE("QueryDirectRenderingCapable... return False");
-       return False;
-    }
-    *isCapable = rep.isCapable;
-    UnlockDisplay(dpy);
-    SyncHandle();
-    TRACE("QueryDirectRenderingCapable... return True");
-    return True;
-}
-
-PUBLIC Bool XF86DRIOpenConnection(dpy, screen, hSAREA, busIdString)
-    Display* dpy;
-    int screen;
-    drm_handle_t * hSAREA;
-    char **busIdString;
-{
-    XExtDisplayInfo *info = find_display (dpy);
-    xXF86DRIOpenConnectionReply rep;
-    xXF86DRIOpenConnectionReq *req;
-
-    TRACE("OpenConnection...");
-    XF86DRICheckExtension (dpy, info, False);
-
-    LockDisplay(dpy);
-    GetReq(XF86DRIOpenConnection, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_XF86DRIOpenConnection;
-    req->screen = screen;
-    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
-       UnlockDisplay(dpy);
-       SyncHandle();
-        TRACE("OpenConnection... return False");
-       return False;
-    }
-
-    *hSAREA = rep.hSAREALow;
-    if (sizeof(drm_handle_t) == 8) {
-       int shift = 32; /* var to prevent warning on next line */
-       *hSAREA |= ((drm_handle_t) rep.hSAREAHigh) << shift;
-    }
-
-    if (rep.length) {
-        if (!(*busIdString = (char *)Xcalloc(rep.busIdStringLength + 1, 1))) {
-            _XEatData(dpy, ((rep.busIdStringLength+3) & ~3));
-            UnlockDisplay(dpy);
-            SyncHandle();
-            TRACE("OpenConnection... return False");
-            return False;
-        }
-       _XReadPad(dpy, *busIdString, rep.busIdStringLength);
-    } else {
-        *busIdString = NULL;
-    }
-    UnlockDisplay(dpy);
-    SyncHandle();
-    TRACE("OpenConnection... return True");
-    return True;
-}
-
-PUBLIC Bool XF86DRIAuthConnection(dpy, screen, magic)
-    Display* dpy;
-    int screen;
-    drm_magic_t magic;
-{
-    XExtDisplayInfo *info = find_display (dpy);
-    xXF86DRIAuthConnectionReq *req;
-    xXF86DRIAuthConnectionReply rep;
-
-    TRACE("AuthConnection...");
-    XF86DRICheckExtension (dpy, info, False);
-
-    LockDisplay(dpy);
-    GetReq(XF86DRIAuthConnection, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_XF86DRIAuthConnection;
-    req->screen = screen;
-    req->magic = magic;
-    rep.authenticated = 0;
-    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.authenticated) {
-       UnlockDisplay(dpy);
-       SyncHandle();
-        TRACE("AuthConnection... return False");
-       return False;
-    }
-    UnlockDisplay(dpy);
-    SyncHandle();
-    TRACE("AuthConnection... return True");
-    return True;
-}
-
-PUBLIC Bool XF86DRICloseConnection(dpy, screen)
-    Display* dpy;
-    int screen;
-{
-    XExtDisplayInfo *info = find_display (dpy);
-    xXF86DRICloseConnectionReq *req;
-
-    TRACE("CloseConnection...");
-
-    XF86DRICheckExtension (dpy, info, False);
-
-    LockDisplay(dpy);
-    GetReq(XF86DRICloseConnection, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_XF86DRICloseConnection;
-    req->screen = screen;
-    UnlockDisplay(dpy);
-    SyncHandle();
-    TRACE("CloseConnection... return True");
-    return True;
-}
-
-PUBLIC Bool XF86DRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion, 
-       ddxDriverMinorVersion, ddxDriverPatchVersion, clientDriverName)
-    Display* dpy;
-    int screen;
-    int* ddxDriverMajorVersion;
-    int* ddxDriverMinorVersion;
-    int* ddxDriverPatchVersion;
-    char** clientDriverName;
-{
-    XExtDisplayInfo *info = find_display (dpy);
-    xXF86DRIGetClientDriverNameReply rep;
-    xXF86DRIGetClientDriverNameReq *req;
-
-    TRACE("GetClientDriverName...");
-    XF86DRICheckExtension (dpy, info, False);
-
-    LockDisplay(dpy);
-    GetReq(XF86DRIGetClientDriverName, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_XF86DRIGetClientDriverName;
-    req->screen = screen;
-    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
-       UnlockDisplay(dpy);
-       SyncHandle();
-        TRACE("GetClientDriverName... return False");
-       return False;
-    }
-
-    *ddxDriverMajorVersion = rep.ddxDriverMajorVersion;
-    *ddxDriverMinorVersion = rep.ddxDriverMinorVersion;
-    *ddxDriverPatchVersion = rep.ddxDriverPatchVersion;
-
-    if (rep.length) {
-        if (!(*clientDriverName = (char *)Xcalloc(rep.clientDriverNameLength + 1, 1))) {
-            _XEatData(dpy, ((rep.clientDriverNameLength+3) & ~3));
-            UnlockDisplay(dpy);
-            SyncHandle();
-            TRACE("GetClientDriverName... return False");
-            return False;
-        }
-       _XReadPad(dpy, *clientDriverName, rep.clientDriverNameLength);
-    } else {
-        *clientDriverName = NULL;
-    }
-    UnlockDisplay(dpy);
-    SyncHandle();
-    TRACE("GetClientDriverName... return True");
-    return True;
-}
-
-PUBLIC Bool XF86DRICreateContextWithConfig(dpy, screen, configID, context,
-       hHWContext)
-    Display* dpy;
-    int screen;
-    int configID;
-    XID* context;
-    drm_context_t * hHWContext;
-{
-    XExtDisplayInfo *info = find_display (dpy);
-    xXF86DRICreateContextReply rep;
-    xXF86DRICreateContextReq *req;
-
-    TRACE("CreateContext...");
-    XF86DRICheckExtension (dpy, info, False);
-
-    LockDisplay(dpy);
-    GetReq(XF86DRICreateContext, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_XF86DRICreateContext;
-    req->visual = configID;
-    req->screen = screen;
-    *context = XAllocID(dpy);
-    req->context = *context;
-    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
-       UnlockDisplay(dpy);
-       SyncHandle();
-        TRACE("CreateContext... return False");
-       return False;
-    }
-    *hHWContext = rep.hHWContext;
-    UnlockDisplay(dpy);
-    SyncHandle();
-    TRACE("CreateContext... return True");
-    return True;
-}
-
-PUBLIC Bool XF86DRICreateContext(dpy, screen, visual, context, hHWContext)
-    Display* dpy;
-    int screen;
-    Visual* visual;
-    XID* context;
-    drm_context_t * hHWContext;
-{
-    return XF86DRICreateContextWithConfig( dpy, screen, visual->visualid,
-                                          context, hHWContext );
-}
-
-PUBLIC Bool XF86DRIDestroyContext( Display * ndpy, int screen, 
-    XID context )
-{
-    Display * const dpy = (Display *) ndpy;
-    XExtDisplayInfo *info = find_display (dpy);
-    xXF86DRIDestroyContextReq *req;
-
-    TRACE("DestroyContext...");
-    XF86DRICheckExtension (dpy, info, False);
-
-    LockDisplay(dpy);
-    GetReq(XF86DRIDestroyContext, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_XF86DRIDestroyContext;
-    req->screen = screen;
-    req->context = context;
-    UnlockDisplay(dpy);
-    SyncHandle();
-    TRACE("DestroyContext... return True");
-    return True;
-}
-
-PUBLIC Bool XF86DRICreateDrawable( Display * ndpy, int screen, 
-    Drawable drawable, drm_drawable_t * hHWDrawable )
-{
-    Display * const dpy = (Display *) ndpy;
-    XExtDisplayInfo *info = find_display (dpy);
-    xXF86DRICreateDrawableReply rep;
-    xXF86DRICreateDrawableReq *req;
-
-    TRACE("CreateDrawable...");
-    XF86DRICheckExtension (dpy, info, False);
-
-    LockDisplay(dpy);
-    GetReq(XF86DRICreateDrawable, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_XF86DRICreateDrawable;
-    req->screen = screen;
-    req->drawable = drawable;
-    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
-       UnlockDisplay(dpy);
-       SyncHandle();
-        TRACE("CreateDrawable... return False");
-       return False;
-    }
-    *hHWDrawable = rep.hHWDrawable;
-    UnlockDisplay(dpy);
-    SyncHandle();
-    TRACE("CreateDrawable... return True");
-    return True;
-}
-
-PUBLIC Bool XF86DRIDestroyDrawable( Display * ndpy, int screen,
-    Drawable drawable )
-{
-    Display * const dpy = (Display *) ndpy;
-    XExtDisplayInfo *info = find_display (dpy);
-    xXF86DRIDestroyDrawableReq *req;
-
-    TRACE("DestroyDrawable...");
-    XF86DRICheckExtension (dpy, info, False);
-
-    LockDisplay(dpy);
-    GetReq(XF86DRIDestroyDrawable, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_XF86DRIDestroyDrawable;
-    req->screen = screen;
-    req->drawable = drawable;
-    UnlockDisplay(dpy);
-    SyncHandle();
-    TRACE("DestroyDrawable... return True");
-    return True;
-}
-
-PUBLIC Bool XF86DRIGetDrawableInfo(Display* dpy, int screen, Drawable drawable,
-    unsigned int* index, unsigned int* stamp,
-    int* X, int* Y, int* W, int* H,
-    int* numClipRects, drm_clip_rect_t ** pClipRects,
-    int* backX, int* backY,
-    int* numBackClipRects, drm_clip_rect_t ** pBackClipRects )
-{
-    XExtDisplayInfo *info = find_display (dpy);
-    xXF86DRIGetDrawableInfoReply rep;
-    xXF86DRIGetDrawableInfoReq *req;
-    int total_rects;
-
-    TRACE("GetDrawableInfo...");
-    XF86DRICheckExtension (dpy, info, False);
-
-    LockDisplay(dpy);
-    GetReq(XF86DRIGetDrawableInfo, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_XF86DRIGetDrawableInfo;
-    req->screen = screen;
-    req->drawable = drawable;
-
-    if (!_XReply(dpy, (xReply *)&rep, 1, xFalse)) 
-    {
-       UnlockDisplay(dpy);
-       SyncHandle();
-        TRACE("GetDrawableInfo... return False");
-       return False;
-    }
-    *index = rep.drawableTableIndex;
-    *stamp = rep.drawableTableStamp;
-    *X = (int)rep.drawableX;
-    *Y = (int)rep.drawableY;
-    *W = (int)rep.drawableWidth;
-    *H = (int)rep.drawableHeight;
-    *numClipRects = rep.numClipRects;
-    total_rects = *numClipRects;
-
-    *backX = rep.backX;
-    *backY = rep.backY;
-    *numBackClipRects = rep.numBackClipRects;
-    total_rects += *numBackClipRects;
-
-#if 0
-    /* Because of the fix in Xserver/GL/dri/xf86dri.c, this check breaks
-     * backwards compatibility (Because of the >> 2 shift) but the fix
-     * enables multi-threaded apps to work.
-     */
-    if (rep.length !=  ((((SIZEOF(xXF86DRIGetDrawableInfoReply) - 
-                      SIZEOF(xGenericReply) + 
-                      total_rects * sizeof(drm_clip_rect_t)) + 3) & ~3) >> 2)) {
-        _XEatData(dpy, rep.length);
-       UnlockDisplay(dpy);
-       SyncHandle();
-        TRACE("GetDrawableInfo... return False");
-        return False;
-    }
-#endif
-
-    if (*numClipRects) {
-       int len = sizeof(drm_clip_rect_t) * (*numClipRects);
-
-       *pClipRects = (drm_clip_rect_t *)Xcalloc(len, 1);
-       if (*pClipRects) 
-         _XRead(dpy, (char*)*pClipRects, len);
-    } else {
-        *pClipRects = NULL;
-    }
-
-    if (*numBackClipRects) {
-       int len = sizeof(drm_clip_rect_t) * (*numBackClipRects);
-
-       *pBackClipRects = (drm_clip_rect_t *)Xcalloc(len, 1);
-       if (*pBackClipRects) 
-         _XRead(dpy, (char*)*pBackClipRects, len);
-    } else {
-        *pBackClipRects = NULL;
-    }
-
-    UnlockDisplay(dpy);
-    SyncHandle();
-    TRACE("GetDrawableInfo... return True");
-    return True;
-}
-
-PUBLIC Bool XF86DRIGetDeviceInfo(dpy, screen, hFrameBuffer, 
-       fbOrigin, fbSize, fbStride, devPrivateSize, pDevPrivate)
-    Display* dpy;
-    int screen;
-    drm_handle_t * hFrameBuffer;
-    int* fbOrigin;
-    int* fbSize;
-    int* fbStride;
-    int* devPrivateSize;
-    void** pDevPrivate;
-{
-    XExtDisplayInfo *info = find_display (dpy);
-    xXF86DRIGetDeviceInfoReply rep;
-    xXF86DRIGetDeviceInfoReq *req;
-
-    TRACE("GetDeviceInfo...");
-    XF86DRICheckExtension (dpy, info, False);
-
-    LockDisplay(dpy);
-    GetReq(XF86DRIGetDeviceInfo, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_XF86DRIGetDeviceInfo;
-    req->screen = screen;
-    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
-       UnlockDisplay(dpy);
-       SyncHandle();
-        TRACE("GetDeviceInfo... return False");
-       return False;
-    }
-
-    *hFrameBuffer = rep.hFrameBufferLow;
-    if (sizeof(drm_handle_t) == 8) {
-       int shift = 32; /* var to prevent warning on next line */
-       *hFrameBuffer |= ((drm_handle_t) rep.hFrameBufferHigh) << shift;
-    }
-
-    *fbOrigin = rep.framebufferOrigin;
-    *fbSize = rep.framebufferSize;
-    *fbStride = rep.framebufferStride;
-    *devPrivateSize = rep.devPrivateSize;
-
-    if (rep.length) {
-        if (!(*pDevPrivate = (void *)Xcalloc(rep.devPrivateSize, 1))) {
-            _XEatData(dpy, ((rep.devPrivateSize+3) & ~3));
-            UnlockDisplay(dpy);
-            SyncHandle();
-            TRACE("GetDeviceInfo... return False");
-            return False;
-        }
-       _XRead(dpy, (char*)*pDevPrivate, rep.devPrivateSize);
-    } else {
-        *pDevPrivate = NULL;
-    }
-
-    UnlockDisplay(dpy);
-    SyncHandle();
-    TRACE("GetDeviceInfo... return True");
-    return True;
-}
-
-PUBLIC Bool XF86DRIOpenFullScreen(dpy, screen, drawable)
-    Display* dpy;
-    int screen;
-    Drawable drawable;
-{
-    /* This function and the underlying X protocol are deprecated.
-     */
-    (void) dpy;
-    (void) screen;
-    (void) drawable;
-    return False;
-}
-
-PUBLIC Bool XF86DRICloseFullScreen(dpy, screen, drawable)
-    Display* dpy;
-    int screen;
-    Drawable drawable;
-{
-    /* This function and the underlying X protocol are deprecated.
-     */
-    (void) dpy;
-    (void) screen;
-    (void) drawable;
-    return True;
-}
-
diff --git a/src/driclient/src/driclient.c b/src/driclient/src/driclient.c
deleted file mode 100644 (file)
index dc2189a..0000000
+++ /dev/null
@@ -1,310 +0,0 @@
-#include "driclient.h"
-#include <assert.h>
-#include <stdlib.h>
-
-int driCreateScreen(Display *display, int screen, dri_screen_t **dri_screen, dri_framebuffer_t *dri_framebuf)
-{
-       int             evbase, errbase;
-       char            *driver_name;
-       int             newly_opened;
-       drm_magic_t     magic;
-       drmVersionPtr   drm_version;
-       drm_handle_t    sarea_handle;
-       char            *bus_id;
-       dri_screen_t    *dri_scrn;
-
-       assert(display);
-       assert(dri_screen);
-
-       if (!XF86DRIQueryExtension(display, &evbase, &errbase))
-               return 1;
-
-       dri_scrn = calloc(1, sizeof(dri_screen_t));
-
-       if (!dri_scrn)
-               return 1;
-
-       if (!XF86DRIQueryVersion(display, &dri_scrn->dri.major, &dri_scrn->dri.minor, &dri_scrn->dri.patch))
-               goto free_screen;
-
-       dri_scrn->display = display;
-       dri_scrn->num = screen;
-       dri_scrn->draw_lock_id = 1;
-
-       if (!XF86DRIOpenConnection(display, screen, &sarea_handle, &bus_id))
-               goto free_screen;
-
-       dri_scrn->fd = -1;
-       dri_scrn->fd = drmOpenOnce(NULL, bus_id, &newly_opened);
-       XFree(bus_id);
-
-       if (dri_scrn->fd < 0)
-               goto close_connection;
-
-       if (drmGetMagic(dri_scrn->fd, &magic))
-               goto close_drm;
-
-       drm_version = drmGetVersion(dri_scrn->fd);
-
-       if (!drm_version)
-               goto close_drm;
-
-       dri_scrn->drm.major = drm_version->version_major;
-       dri_scrn->drm.minor = drm_version->version_minor;
-       dri_scrn->drm.patch = drm_version->version_patchlevel;
-       drmFreeVersion(drm_version);
-
-       if (!XF86DRIAuthConnection(display, screen, magic))
-               goto close_drm;
-
-       if (!XF86DRIGetClientDriverName
-       (
-               display,
-               screen,
-               &dri_scrn->ddx.major,
-               &dri_scrn->ddx.minor,
-               &dri_scrn->ddx.patch,
-               &driver_name
-       ))
-               goto close_drm;
-
-       if (drmMap(dri_scrn->fd, sarea_handle, SAREA_MAX, (drmAddress)&dri_scrn->sarea))
-               goto close_drm;
-
-       dri_scrn->drawable_hash = drmHashCreate();
-
-       if (!dri_scrn->drawable_hash)
-               goto unmap_sarea;
-
-       if (dri_framebuf)
-       {
-               if (!XF86DRIGetDeviceInfo
-               (
-                       display,
-                       screen, &dri_framebuf->drm_handle,
-                       &dri_framebuf->base,
-                       &dri_framebuf->size,
-                       &dri_framebuf->stride,
-                       &dri_framebuf->private_size,
-                       &dri_framebuf->private
-               ))
-                       goto destroy_hash;
-       }
-
-       *dri_screen = dri_scrn;
-
-       return 0;
-
-destroy_hash:
-       drmHashDestroy(dri_scrn->drawable_hash);
-unmap_sarea:
-       drmUnmap(dri_scrn->sarea, SAREA_MAX);
-close_drm:
-       drmCloseOnce(dri_scrn->fd);
-close_connection:
-       XF86DRICloseConnection(display, screen);
-free_screen:
-       free(dri_scrn);
-
-       return 1;
-}
-
-int driDestroyScreen(dri_screen_t *dri_screen)
-{
-       Drawable        draw;
-       dri_drawable_t  *dri_draw;
-
-       assert(dri_screen);
-
-       if (drmHashFirst(dri_screen->drawable_hash, &draw, (void**)&dri_draw))
-       {
-               dri_draw->refcount = 1;
-               driDestroyDrawable(dri_draw);
-
-               while (drmHashNext(dri_screen->drawable_hash, &draw, (void**)&dri_draw))
-               {
-                       dri_draw->refcount = 1;
-                       driDestroyDrawable(dri_draw);
-               }
-       }
-
-       drmHashDestroy(dri_screen->drawable_hash);
-       drmUnmap(dri_screen->sarea, SAREA_MAX);
-       drmCloseOnce(dri_screen->fd);
-       XF86DRICloseConnection(dri_screen->display, dri_screen->num);
-       free(dri_screen);
-
-       return 0;
-}
-
-int driCreateDrawable(dri_screen_t *dri_screen, Drawable drawable, dri_drawable_t **dri_drawable)
-{
-       int             evbase, errbase;
-       dri_drawable_t  *dri_draw;
-
-       assert(dri_screen);
-       assert(dri_drawable);
-
-       if (!XF86DRIQueryExtension(dri_screen->display, &evbase, &errbase))
-               return 1;
-
-       if (!drmHashLookup(dri_screen->drawable_hash, drawable, (void**)dri_drawable))
-       {
-               /* Found */
-               (*dri_drawable)->refcount++;
-               return 0;
-       }
-
-       dri_draw = calloc(1, sizeof(dri_drawable_t));
-
-       if (!dri_draw)
-               return 1;
-
-       if (!XF86DRICreateDrawable(dri_screen->display, 0, drawable, &dri_draw->drm_drawable))
-       {
-               free(dri_draw);
-               return 1;
-       }
-
-       dri_draw->x_drawable = drawable;
-       dri_draw->sarea_index = 0;
-       dri_draw->sarea_stamp = NULL;
-       dri_draw->last_sarea_stamp = 0;
-       dri_draw->dri_screen = dri_screen;
-       dri_draw->refcount = 1;
-
-       if (drmHashInsert(dri_screen->drawable_hash, drawable, dri_draw))
-       {
-               XF86DRIDestroyDrawable(dri_screen->display, dri_screen->num, drawable);
-               free(dri_draw);
-               return 1;
-       }
-
-       if (!dri_draw->sarea_stamp || *dri_draw->sarea_stamp != dri_draw->last_sarea_stamp)
-       {
-               DRM_SPINLOCK(&dri_screen->sarea->drawable_lock, dri_screen->draw_lock_id);
-
-               if (driUpdateDrawableInfo(dri_draw))
-               {
-                       XF86DRIDestroyDrawable(dri_screen->display, dri_screen->num, drawable);
-                       free(dri_draw);
-                       DRM_SPINUNLOCK(&dri_screen->sarea->drawable_lock, dri_screen->draw_lock_id);
-                       return 1;
-               }
-
-               DRM_SPINUNLOCK(&dri_screen->sarea->drawable_lock, dri_screen->draw_lock_id);
-       }
-
-       *dri_drawable = dri_draw;
-
-       return 0;
-}
-
-int driUpdateDrawableInfo(dri_drawable_t *dri_drawable)
-{
-       assert(dri_drawable);
-
-       if (dri_drawable->cliprects)
-       {
-               XFree(dri_drawable->cliprects);
-               dri_drawable->cliprects = NULL;
-       }
-       if (dri_drawable->back_cliprects)
-       {
-               XFree(dri_drawable->back_cliprects);
-               dri_drawable->back_cliprects = NULL;
-       }
-
-       DRM_SPINUNLOCK(&dri_drawable->dri_screen->sarea->drawable_lock, dri_drawable->dri_screen->draw_lock_id);
-
-       if (!XF86DRIGetDrawableInfo
-       (
-               dri_drawable->dri_screen->display,
-               dri_drawable->dri_screen->num,
-               dri_drawable->x_drawable,
-               &dri_drawable->sarea_index,
-               &dri_drawable->last_sarea_stamp,
-               &dri_drawable->x,
-               &dri_drawable->y,
-               &dri_drawable->w,
-               &dri_drawable->h,
-               &dri_drawable->num_cliprects,
-               &dri_drawable->cliprects,
-               &dri_drawable->back_x,
-               &dri_drawable->back_y,
-               &dri_drawable->num_back_cliprects,
-               &dri_drawable->back_cliprects
-       ))
-       {
-               dri_drawable->sarea_stamp = &dri_drawable->last_sarea_stamp;
-               dri_drawable->num_cliprects = 0;
-               dri_drawable->cliprects = NULL;
-               dri_drawable->num_back_cliprects = 0;
-               dri_drawable->back_cliprects = 0;
-
-               return 1;
-       }
-       else
-               dri_drawable->sarea_stamp = &dri_drawable->dri_screen->sarea->drawableTable[dri_drawable->sarea_index].stamp;
-
-       DRM_SPINLOCK(&dri_drawable->dri_screen->sarea->drawable_lock, dri_drawable->dri_screen->draw_lock_id);
-
-       return 0;
-}
-
-int driDestroyDrawable(dri_drawable_t *dri_drawable)
-{
-       assert(dri_drawable);
-
-       if (--dri_drawable->refcount == 0)
-       {
-               if (dri_drawable->cliprects)
-                       XFree(dri_drawable->cliprects);
-               if (dri_drawable->back_cliprects)
-                       XFree(dri_drawable->back_cliprects);
-               drmHashDelete(dri_drawable->dri_screen->drawable_hash, dri_drawable->x_drawable);
-               XF86DRIDestroyDrawable(dri_drawable->dri_screen->display, dri_drawable->dri_screen->num, dri_drawable->x_drawable);
-               free(dri_drawable);
-       }
-
-       return 0;
-}
-
-int driCreateContext(dri_screen_t *dri_screen, Visual *visual, dri_context_t **dri_context)
-{
-       int             evbase, errbase;
-       dri_context_t   *dri_ctx;
-
-       assert(dri_screen);
-       assert(visual);
-       assert(dri_context);
-
-       if (!XF86DRIQueryExtension(dri_screen->display, &evbase, &errbase))
-               return 1;
-
-       dri_ctx = calloc(1, sizeof(dri_context_t));
-
-       if (!dri_ctx)
-               return 1;
-
-       if (!XF86DRICreateContext(dri_screen->display, dri_screen->num, visual, &dri_ctx->id, &dri_ctx->drm_context))
-       {
-               free(dri_ctx);
-               return 1;
-       }
-
-       dri_ctx->dri_screen = dri_screen;
-       *dri_context = dri_ctx;
-
-       return 0;
-}
-
-int driDestroyContext(dri_context_t *dri_context)
-{
-       assert(dri_context);
-
-       XF86DRIDestroyContext(dri_context->dri_screen->display, dri_context->dri_screen->num, dri_context->id);
-       free(dri_context);
-
-       return 0;
-}
diff --git a/src/driclient/src/xf86dristr.h b/src/driclient/src/xf86dristr.h
deleted file mode 100644 (file)
index b834bd1..0000000
+++ /dev/null
@@ -1,342 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-Copyright 2000 VA Linux Systems, Inc.
-All Rights Reserved.
-
-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.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <martin@valinux.com>
- *   Jens Owen <jens@tungstengraphics.com>
- *   Rickard E. (Rik) Fiath <faith@valinux.com>
- *
- */
-
-#ifndef _XF86DRISTR_H_
-#define _XF86DRISTR_H_
-
-#include "xf86dri.h"
-
-#define XF86DRINAME "XFree86-DRI"
-
-/* The DRI version number.  This was originally set to be the same of the
- * XFree86 version number.  However, this version is really indepedent of
- * the XFree86 version.
- *
- * Version History:
- *    4.0.0: Original
- *    4.0.1: Patch to bump clipstamp when windows are destroyed, 28 May 02
- *    4.1.0: Add transition from single to multi in DRMInfo rec, 24 Jun 02
- */
-#define XF86DRI_MAJOR_VERSION  4
-#define XF86DRI_MINOR_VERSION  1
-#define XF86DRI_PATCH_VERSION  0
-
-typedef struct _XF86DRIQueryVersion {
-    CARD8      reqType;                /* always DRIReqCode */
-    CARD8      driReqType;             /* always X_DRIQueryVersion */
-    CARD16     length B16;
-} xXF86DRIQueryVersionReq;
-#define sz_xXF86DRIQueryVersionReq     4
-
-typedef struct {
-    BYTE       type;                   /* X_Reply */
-    BOOL       pad1;
-    CARD16     sequenceNumber B16;
-    CARD32     length B32;
-    CARD16     majorVersion B16;       /* major version of DRI protocol */
-    CARD16     minorVersion B16;       /* minor version of DRI protocol */
-    CARD32     patchVersion B32;       /* patch version of DRI protocol */
-    CARD32     pad3 B32;
-    CARD32     pad4 B32;
-    CARD32     pad5 B32;
-    CARD32     pad6 B32;
-} xXF86DRIQueryVersionReply;
-#define sz_xXF86DRIQueryVersionReply   32
-
-typedef struct _XF86DRIQueryDirectRenderingCapable {
-    CARD8      reqType;                /* always DRIReqCode */
-    CARD8      driReqType;             /* X_DRIQueryDirectRenderingCapable */
-    CARD16     length B16;
-    CARD32     screen B32;
-} xXF86DRIQueryDirectRenderingCapableReq;
-#define sz_xXF86DRIQueryDirectRenderingCapableReq      8
-
-typedef struct {
-    BYTE       type;                   /* X_Reply */
-    BOOL       pad1;
-    CARD16     sequenceNumber B16;
-    CARD32     length B32;
-    BOOL       isCapable;
-    BOOL       pad2;
-    BOOL       pad3;
-    BOOL       pad4;
-    CARD32     pad5 B32;
-    CARD32     pad6 B32;
-    CARD32     pad7 B32;
-    CARD32     pad8 B32;
-    CARD32     pad9 B32;
-} xXF86DRIQueryDirectRenderingCapableReply;
-#define sz_xXF86DRIQueryDirectRenderingCapableReply    32
-
-typedef struct _XF86DRIOpenConnection {
-    CARD8      reqType;                /* always DRIReqCode */
-    CARD8      driReqType;             /* always X_DRIOpenConnection */
-    CARD16     length B16;
-    CARD32     screen B32;
-} xXF86DRIOpenConnectionReq;
-#define sz_xXF86DRIOpenConnectionReq   8
-
-typedef struct {
-    BYTE       type;                   /* X_Reply */
-    BOOL       pad1;
-    CARD16     sequenceNumber B16;
-    CARD32     length B32;
-    CARD32     hSAREALow B32;
-    CARD32     hSAREAHigh B32;
-    CARD32     busIdStringLength B32;
-    CARD32     pad6 B32;
-    CARD32     pad7 B32;
-    CARD32     pad8 B32;
-} xXF86DRIOpenConnectionReply;
-#define sz_xXF86DRIOpenConnectionReply 32
-
-typedef struct _XF86DRIAuthConnection {
-    CARD8      reqType;                /* always DRIReqCode */
-    CARD8      driReqType;             /* always X_DRICloseConnection */
-    CARD16     length B16;
-    CARD32     screen B32;
-    CARD32      magic B32;
-} xXF86DRIAuthConnectionReq;
-#define sz_xXF86DRIAuthConnectionReq   12
-
-typedef struct {
-    BYTE        type;
-    BOOL        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;
-} xXF86DRIAuthConnectionReply;
-#define zx_xXF86DRIAuthConnectionReply  32
-
-typedef struct _XF86DRICloseConnection {
-    CARD8      reqType;                /* always DRIReqCode */
-    CARD8      driReqType;             /* always X_DRICloseConnection */
-    CARD16     length B16;
-    CARD32     screen B32;
-} xXF86DRICloseConnectionReq;
-#define sz_xXF86DRICloseConnectionReq  8
-
-typedef struct _XF86DRIGetClientDriverName {
-    CARD8      reqType;                /* always DRIReqCode */
-    CARD8      driReqType;             /* always X_DRIGetClientDriverName */
-    CARD16     length B16;
-    CARD32     screen B32;
-} xXF86DRIGetClientDriverNameReq;
-#define sz_xXF86DRIGetClientDriverNameReq      8
-
-typedef struct {
-    BYTE       type;                   /* X_Reply */
-    BOOL       pad1;
-    CARD16     sequenceNumber B16;
-    CARD32     length B32;
-    CARD32     ddxDriverMajorVersion B32;
-    CARD32     ddxDriverMinorVersion B32;
-    CARD32     ddxDriverPatchVersion B32;
-    CARD32     clientDriverNameLength B32;
-    CARD32     pad5 B32;
-    CARD32     pad6 B32;
-} xXF86DRIGetClientDriverNameReply;
-#define sz_xXF86DRIGetClientDriverNameReply    32
-
-typedef struct _XF86DRICreateContext {
-    CARD8      reqType;                /* always DRIReqCode */
-    CARD8      driReqType;             /* always X_DRICreateContext */
-    CARD16     length B16;
-    CARD32     screen B32;
-    CARD32     visual B32;
-    CARD32     context B32;
-} xXF86DRICreateContextReq;
-#define sz_xXF86DRICreateContextReq    16
-
-typedef struct {
-    BYTE       type;                   /* X_Reply */
-    BOOL       pad1;
-    CARD16     sequenceNumber B16;
-    CARD32     length B32;
-    CARD32     hHWContext B32;
-    CARD32     pad2 B32;
-    CARD32     pad3 B32;
-    CARD32     pad4 B32;
-    CARD32     pad5 B32;
-    CARD32     pad6 B32;
-} xXF86DRICreateContextReply;
-#define sz_xXF86DRICreateContextReply  32
-
-typedef struct _XF86DRIDestroyContext {
-    CARD8      reqType;                /* always DRIReqCode */
-    CARD8      driReqType;             /* always X_DRIDestroyContext */
-    CARD16     length B16;
-    CARD32     screen B32;
-    CARD32     context B32;
-} xXF86DRIDestroyContextReq;
-#define sz_xXF86DRIDestroyContextReq   12
-
-typedef struct _XF86DRICreateDrawable {
-    CARD8      reqType;                /* always DRIReqCode */
-    CARD8      driReqType;             /* always X_DRICreateDrawable */
-    CARD16     length B16;
-    CARD32     screen B32;
-    CARD32     drawable B32;
-} xXF86DRICreateDrawableReq;
-#define sz_xXF86DRICreateDrawableReq   12
-
-typedef struct {
-    BYTE       type;                   /* X_Reply */
-    BOOL       pad1;
-    CARD16     sequenceNumber B16;
-    CARD32     length B32;
-    CARD32     hHWDrawable B32;
-    CARD32     pad2 B32;
-    CARD32     pad3 B32;
-    CARD32     pad4 B32;
-    CARD32     pad5 B32;
-    CARD32     pad6 B32;
-} xXF86DRICreateDrawableReply;
-#define sz_xXF86DRICreateDrawableReply 32
-
-typedef struct _XF86DRIDestroyDrawable {
-    CARD8      reqType;                /* always DRIReqCode */
-    CARD8      driReqType;             /* always X_DRIDestroyDrawable */
-    CARD16     length B16;
-    CARD32     screen B32;
-    CARD32     drawable B32;
-} xXF86DRIDestroyDrawableReq;
-#define sz_xXF86DRIDestroyDrawableReq  12
-
-typedef struct _XF86DRIGetDrawableInfo {
-    CARD8      reqType;                /* always DRIReqCode */
-    CARD8      driReqType;             /* always X_DRIGetDrawableInfo */
-    CARD16     length B16;
-    CARD32     screen B32;
-    CARD32     drawable B32;
-} xXF86DRIGetDrawableInfoReq;
-#define sz_xXF86DRIGetDrawableInfoReq  12
-
-typedef struct {
-    BYTE       type;                   /* X_Reply */
-    BOOL       pad1;
-    CARD16     sequenceNumber B16;
-    CARD32     length B32;
-    CARD32     drawableTableIndex B32;
-    CARD32     drawableTableStamp B32;
-    INT16      drawableX B16;
-    INT16      drawableY B16;
-    INT16      drawableWidth B16;
-    INT16      drawableHeight B16;
-    CARD32     numClipRects B32;
-    INT16       backX B16;
-    INT16       backY B16;
-    CARD32      numBackClipRects B32;
-} xXF86DRIGetDrawableInfoReply;
-
-#define sz_xXF86DRIGetDrawableInfoReply        36
-
-
-typedef struct _XF86DRIGetDeviceInfo {
-    CARD8      reqType;                /* always DRIReqCode */
-    CARD8      driReqType;             /* always X_DRIGetDeviceInfo */
-    CARD16     length B16;
-    CARD32     screen B32;
-} xXF86DRIGetDeviceInfoReq;
-#define sz_xXF86DRIGetDeviceInfoReq    8
-
-typedef struct {
-    BYTE       type;                   /* X_Reply */
-    BOOL       pad1;
-    CARD16     sequenceNumber B16;
-    CARD32     length B32;
-    CARD32     hFrameBufferLow B32;
-    CARD32     hFrameBufferHigh B32;
-    CARD32     framebufferOrigin B32;
-    CARD32     framebufferSize B32;
-    CARD32     framebufferStride B32;
-    CARD32     devPrivateSize B32;
-} xXF86DRIGetDeviceInfoReply;
-#define sz_xXF86DRIGetDeviceInfoReply  32
-
-typedef struct _XF86DRIOpenFullScreen {
-    CARD8       reqType;       /* always DRIReqCode */
-    CARD8       driReqType;    /* always X_DRIOpenFullScreen */
-    CARD16      length B16;
-    CARD32      screen B32;
-    CARD32      drawable B32;
-} xXF86DRIOpenFullScreenReq;
-#define sz_xXF86DRIOpenFullScreenReq    12
-
-typedef struct {
-    BYTE        type;
-    BOOL        pad1;
-    CARD16      sequenceNumber B16;
-    CARD32      length B32;
-    CARD32      isFullScreen B32;
-    CARD32      pad2 B32;
-    CARD32      pad3 B32;
-    CARD32      pad4 B32;
-    CARD32      pad5 B32;
-    CARD32      pad6 B32;
-} xXF86DRIOpenFullScreenReply;
-#define sz_xXF86DRIOpenFullScreenReply  32
-
-typedef struct _XF86DRICloseFullScreen {
-    CARD8       reqType;       /* always DRIReqCode */
-    CARD8       driReqType;    /* always X_DRICloseFullScreen */
-    CARD16      length B16;
-    CARD32      screen B32;
-    CARD32      drawable B32;
-} xXF86DRICloseFullScreenReq;
-#define sz_xXF86DRICloseFullScreenReq   12
-
-typedef struct {
-    BYTE        type;
-    BOOL        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;
-} xXF86DRICloseFullScreenReply;
-#define sz_xXF86DRICloseFullScreenReply  32
-
-
-#endif /* _XF86DRISTR_H_ */
index bce5b3f9e0d1a3724aeebec48c6af2f4f4825309..e7cb154b84bf942f4a0dd31e9c6bc3b301de60a8 100644 (file)
@@ -2,7 +2,7 @@
 TOP = ../../..
 include $(TOP)/configs/current
 
-SUBDIRS = $(GALLIUM_WINSYS_DIRS)
+SUBDIRS = $(GALLIUM_WINSYS_DIRS) g3dvl
 
 default install clean:
        @for dir in $(SUBDIRS) ; do \
index 424ddea87ad4b55367874c65921c0f9f1fc76a25..6c793e0f15b2b91fdcab18f01f9c63125fb1d166 100644 (file)
@@ -1,7 +1,8 @@
+# src/gallium/winsys/Makefile
 TOP = ../../../..
 include $(TOP)/configs/current
 
-SUBDIRS = $(GALLIUM_WINSYS_DIRS)
+SUBDIRS = $(GALLIUM_STATE_TRACKERS_DIRS) $(GALLIUM_WINSYS_DIRS)
 
 default install clean:
        @for dir in $(SUBDIRS) ; do \
diff --git a/src/gallium/winsys/g3dvl/dri/Makefile b/src/gallium/winsys/g3dvl/dri/Makefile
new file mode 100644 (file)
index 0000000..dcd58ef
--- /dev/null
@@ -0,0 +1,14 @@
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = vldri
+
+LIBRARY_INCLUDES = -I$(TOP)/src/gallium/winsys/g3dvl \
+                   $(shell pkg-config libdrm --cflags-only-I)
+
+C_SOURCES = \
+       driclient.c \
+       XF86dri.c \
+       dri_winsys.c
+
+include ../../../Makefile.template
diff --git a/src/gallium/winsys/g3dvl/dri/XF86dri.c b/src/gallium/winsys/g3dvl/dri/XF86dri.c
new file mode 100644 (file)
index 0000000..9e359a9
--- /dev/null
@@ -0,0 +1,619 @@
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+All Rights Reserved.
+
+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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Jens Owen <jens@tungstengraphics.com>
+ *   Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include "xf86dristr.h"
+
+static XExtensionInfo _xf86dri_info_data;
+static XExtensionInfo *xf86dri_info = &_xf86dri_info_data;
+static char xf86dri_extension_name[] = XF86DRINAME;
+
+#define XF86DRICheckExtension(dpy,i,val) \
+  XextCheckExtension (dpy, i, xf86dri_extension_name, val)
+
+/*****************************************************************************
+ *                                                                           *
+ *                        private utility routines                          *
+ *                                                                           *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *extCodes);
+static /* const */ XExtensionHooks xf86dri_extension_hooks = {
+    NULL,                              /* create_gc */
+    NULL,                              /* copy_gc */
+    NULL,                              /* flush_gc */
+    NULL,                              /* free_gc */
+    NULL,                              /* create_font */
+    NULL,                              /* free_font */
+    close_display,                     /* close_display */
+    NULL,                              /* wire_to_event */
+    NULL,                              /* event_to_wire */
+    NULL,                              /* error */
+    NULL,                              /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, xf86dri_info, 
+                                  xf86dri_extension_name, 
+                                  &xf86dri_extension_hooks, 
+                                  0, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info)
+
+
+/*****************************************************************************
+ *                                                                           *
+ *                 public XFree86-DRI Extension routines                    *
+ *                                                                           *
+ *****************************************************************************/
+
+#if 0
+#include <stdio.h>
+#define TRACE(msg)  fprintf(stderr,"XF86DRI%s\n", msg);
+#else
+#define TRACE(msg)
+#endif
+
+#define PUBLIC
+
+PUBLIC Bool XF86DRIQueryExtension (dpy, event_basep, error_basep)
+    Display *dpy;
+    int *event_basep, *error_basep;
+{
+    XExtDisplayInfo *info = find_display (dpy);
+
+    TRACE("QueryExtension...");
+    if (XextHasExtension(info)) {
+       *event_basep = info->codes->first_event;
+       *error_basep = info->codes->first_error;
+        TRACE("QueryExtension... return True");
+       return True;
+    } else {
+        TRACE("QueryExtension... return False");
+       return False;
+    }
+}
+
+PUBLIC Bool XF86DRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion)
+    Display* dpy;
+    int* majorVersion; 
+    int* minorVersion;
+    int* patchVersion;
+{
+    XExtDisplayInfo *info = find_display (dpy);
+    xXF86DRIQueryVersionReply rep;
+    xXF86DRIQueryVersionReq *req;
+
+    TRACE("QueryVersion...");
+    XF86DRICheckExtension (dpy, info, False);
+
+    LockDisplay(dpy);
+    GetReq(XF86DRIQueryVersion, req);
+    req->reqType = info->codes->major_opcode;
+    req->driReqType = X_XF86DRIQueryVersion;
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+        TRACE("QueryVersion... return False");
+       return False;
+    }
+    *majorVersion = rep.majorVersion;
+    *minorVersion = rep.minorVersion;
+    *patchVersion = rep.patchVersion;
+    UnlockDisplay(dpy);
+    SyncHandle();
+    TRACE("QueryVersion... return True");
+    return True;
+}
+
+PUBLIC Bool XF86DRIQueryDirectRenderingCapable(dpy, screen, isCapable)
+    Display* dpy;
+    int screen;
+    Bool* isCapable;
+{
+    XExtDisplayInfo *info = find_display (dpy);
+    xXF86DRIQueryDirectRenderingCapableReply rep;
+    xXF86DRIQueryDirectRenderingCapableReq *req;
+
+    TRACE("QueryDirectRenderingCapable...");
+    XF86DRICheckExtension (dpy, info, False);
+
+    LockDisplay(dpy);
+    GetReq(XF86DRIQueryDirectRenderingCapable, req);
+    req->reqType = info->codes->major_opcode;
+    req->driReqType = X_XF86DRIQueryDirectRenderingCapable;
+    req->screen = screen;
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+        TRACE("QueryDirectRenderingCapable... return False");
+       return False;
+    }
+    *isCapable = rep.isCapable;
+    UnlockDisplay(dpy);
+    SyncHandle();
+    TRACE("QueryDirectRenderingCapable... return True");
+    return True;
+}
+
+PUBLIC Bool XF86DRIOpenConnection(dpy, screen, hSAREA, busIdString)
+    Display* dpy;
+    int screen;
+    drm_handle_t * hSAREA;
+    char **busIdString;
+{
+    XExtDisplayInfo *info = find_display (dpy);
+    xXF86DRIOpenConnectionReply rep;
+    xXF86DRIOpenConnectionReq *req;
+
+    TRACE("OpenConnection...");
+    XF86DRICheckExtension (dpy, info, False);
+
+    LockDisplay(dpy);
+    GetReq(XF86DRIOpenConnection, req);
+    req->reqType = info->codes->major_opcode;
+    req->driReqType = X_XF86DRIOpenConnection;
+    req->screen = screen;
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+        TRACE("OpenConnection... return False");
+       return False;
+    }
+
+    *hSAREA = rep.hSAREALow;
+    if (sizeof(drm_handle_t) == 8) {
+       int shift = 32; /* var to prevent warning on next line */
+       *hSAREA |= ((drm_handle_t) rep.hSAREAHigh) << shift;
+    }
+
+    if (rep.length) {
+        if (!(*busIdString = (char *)Xcalloc(rep.busIdStringLength + 1, 1))) {
+            _XEatData(dpy, ((rep.busIdStringLength+3) & ~3));
+            UnlockDisplay(dpy);
+            SyncHandle();
+            TRACE("OpenConnection... return False");
+            return False;
+        }
+       _XReadPad(dpy, *busIdString, rep.busIdStringLength);
+    } else {
+        *busIdString = NULL;
+    }
+    UnlockDisplay(dpy);
+    SyncHandle();
+    TRACE("OpenConnection... return True");
+    return True;
+}
+
+PUBLIC Bool XF86DRIAuthConnection(dpy, screen, magic)
+    Display* dpy;
+    int screen;
+    drm_magic_t magic;
+{
+    XExtDisplayInfo *info = find_display (dpy);
+    xXF86DRIAuthConnectionReq *req;
+    xXF86DRIAuthConnectionReply rep;
+
+    TRACE("AuthConnection...");
+    XF86DRICheckExtension (dpy, info, False);
+
+    LockDisplay(dpy);
+    GetReq(XF86DRIAuthConnection, req);
+    req->reqType = info->codes->major_opcode;
+    req->driReqType = X_XF86DRIAuthConnection;
+    req->screen = screen;
+    req->magic = magic;
+    rep.authenticated = 0;
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.authenticated) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+        TRACE("AuthConnection... return False");
+       return False;
+    }
+    UnlockDisplay(dpy);
+    SyncHandle();
+    TRACE("AuthConnection... return True");
+    return True;
+}
+
+PUBLIC Bool XF86DRICloseConnection(dpy, screen)
+    Display* dpy;
+    int screen;
+{
+    XExtDisplayInfo *info = find_display (dpy);
+    xXF86DRICloseConnectionReq *req;
+
+    TRACE("CloseConnection...");
+
+    XF86DRICheckExtension (dpy, info, False);
+
+    LockDisplay(dpy);
+    GetReq(XF86DRICloseConnection, req);
+    req->reqType = info->codes->major_opcode;
+    req->driReqType = X_XF86DRICloseConnection;
+    req->screen = screen;
+    UnlockDisplay(dpy);
+    SyncHandle();
+    TRACE("CloseConnection... return True");
+    return True;
+}
+
+PUBLIC Bool XF86DRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion, 
+       ddxDriverMinorVersion, ddxDriverPatchVersion, clientDriverName)
+    Display* dpy;
+    int screen;
+    int* ddxDriverMajorVersion;
+    int* ddxDriverMinorVersion;
+    int* ddxDriverPatchVersion;
+    char** clientDriverName;
+{
+    XExtDisplayInfo *info = find_display (dpy);
+    xXF86DRIGetClientDriverNameReply rep;
+    xXF86DRIGetClientDriverNameReq *req;
+
+    TRACE("GetClientDriverName...");
+    XF86DRICheckExtension (dpy, info, False);
+
+    LockDisplay(dpy);
+    GetReq(XF86DRIGetClientDriverName, req);
+    req->reqType = info->codes->major_opcode;
+    req->driReqType = X_XF86DRIGetClientDriverName;
+    req->screen = screen;
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+        TRACE("GetClientDriverName... return False");
+       return False;
+    }
+
+    *ddxDriverMajorVersion = rep.ddxDriverMajorVersion;
+    *ddxDriverMinorVersion = rep.ddxDriverMinorVersion;
+    *ddxDriverPatchVersion = rep.ddxDriverPatchVersion;
+
+    if (rep.length) {
+        if (!(*clientDriverName = (char *)Xcalloc(rep.clientDriverNameLength + 1, 1))) {
+            _XEatData(dpy, ((rep.clientDriverNameLength+3) & ~3));
+            UnlockDisplay(dpy);
+            SyncHandle();
+            TRACE("GetClientDriverName... return False");
+            return False;
+        }
+       _XReadPad(dpy, *clientDriverName, rep.clientDriverNameLength);
+    } else {
+        *clientDriverName = NULL;
+    }
+    UnlockDisplay(dpy);
+    SyncHandle();
+    TRACE("GetClientDriverName... return True");
+    return True;
+}
+
+PUBLIC Bool XF86DRICreateContextWithConfig(dpy, screen, configID, context,
+       hHWContext)
+    Display* dpy;
+    int screen;
+    int configID;
+    XID* context;
+    drm_context_t * hHWContext;
+{
+    XExtDisplayInfo *info = find_display (dpy);
+    xXF86DRICreateContextReply rep;
+    xXF86DRICreateContextReq *req;
+
+    TRACE("CreateContext...");
+    XF86DRICheckExtension (dpy, info, False);
+
+    LockDisplay(dpy);
+    GetReq(XF86DRICreateContext, req);
+    req->reqType = info->codes->major_opcode;
+    req->driReqType = X_XF86DRICreateContext;
+    req->visual = configID;
+    req->screen = screen;
+    *context = XAllocID(dpy);
+    req->context = *context;
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+        TRACE("CreateContext... return False");
+       return False;
+    }
+    *hHWContext = rep.hHWContext;
+    UnlockDisplay(dpy);
+    SyncHandle();
+    TRACE("CreateContext... return True");
+    return True;
+}
+
+PUBLIC Bool XF86DRICreateContext(dpy, screen, visual, context, hHWContext)
+    Display* dpy;
+    int screen;
+    Visual* visual;
+    XID* context;
+    drm_context_t * hHWContext;
+{
+    return XF86DRICreateContextWithConfig( dpy, screen, visual->visualid,
+                                          context, hHWContext );
+}
+
+PUBLIC Bool XF86DRIDestroyContext( Display * ndpy, int screen, 
+    XID context )
+{
+    Display * const dpy = (Display *) ndpy;
+    XExtDisplayInfo *info = find_display (dpy);
+    xXF86DRIDestroyContextReq *req;
+
+    TRACE("DestroyContext...");
+    XF86DRICheckExtension (dpy, info, False);
+
+    LockDisplay(dpy);
+    GetReq(XF86DRIDestroyContext, req);
+    req->reqType = info->codes->major_opcode;
+    req->driReqType = X_XF86DRIDestroyContext;
+    req->screen = screen;
+    req->context = context;
+    UnlockDisplay(dpy);
+    SyncHandle();
+    TRACE("DestroyContext... return True");
+    return True;
+}
+
+PUBLIC Bool XF86DRICreateDrawable( Display * ndpy, int screen, 
+    Drawable drawable, drm_drawable_t * hHWDrawable )
+{
+    Display * const dpy = (Display *) ndpy;
+    XExtDisplayInfo *info = find_display (dpy);
+    xXF86DRICreateDrawableReply rep;
+    xXF86DRICreateDrawableReq *req;
+
+    TRACE("CreateDrawable...");
+    XF86DRICheckExtension (dpy, info, False);
+
+    LockDisplay(dpy);
+    GetReq(XF86DRICreateDrawable, req);
+    req->reqType = info->codes->major_opcode;
+    req->driReqType = X_XF86DRICreateDrawable;
+    req->screen = screen;
+    req->drawable = drawable;
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+        TRACE("CreateDrawable... return False");
+       return False;
+    }
+    *hHWDrawable = rep.hHWDrawable;
+    UnlockDisplay(dpy);
+    SyncHandle();
+    TRACE("CreateDrawable... return True");
+    return True;
+}
+
+PUBLIC Bool XF86DRIDestroyDrawable( Display * ndpy, int screen,
+    Drawable drawable )
+{
+    Display * const dpy = (Display *) ndpy;
+    XExtDisplayInfo *info = find_display (dpy);
+    xXF86DRIDestroyDrawableReq *req;
+
+    TRACE("DestroyDrawable...");
+    XF86DRICheckExtension (dpy, info, False);
+
+    LockDisplay(dpy);
+    GetReq(XF86DRIDestroyDrawable, req);
+    req->reqType = info->codes->major_opcode;
+    req->driReqType = X_XF86DRIDestroyDrawable;
+    req->screen = screen;
+    req->drawable = drawable;
+    UnlockDisplay(dpy);
+    SyncHandle();
+    TRACE("DestroyDrawable... return True");
+    return True;
+}
+
+PUBLIC Bool XF86DRIGetDrawableInfo(Display* dpy, int screen, Drawable drawable,
+    unsigned int* index, unsigned int* stamp,
+    int* X, int* Y, int* W, int* H,
+    int* numClipRects, drm_clip_rect_t ** pClipRects,
+    int* backX, int* backY,
+    int* numBackClipRects, drm_clip_rect_t ** pBackClipRects )
+{
+    XExtDisplayInfo *info = find_display (dpy);
+    xXF86DRIGetDrawableInfoReply rep;
+    xXF86DRIGetDrawableInfoReq *req;
+    int total_rects;
+
+    TRACE("GetDrawableInfo...");
+    XF86DRICheckExtension (dpy, info, False);
+
+    LockDisplay(dpy);
+    GetReq(XF86DRIGetDrawableInfo, req);
+    req->reqType = info->codes->major_opcode;
+    req->driReqType = X_XF86DRIGetDrawableInfo;
+    req->screen = screen;
+    req->drawable = drawable;
+
+    if (!_XReply(dpy, (xReply *)&rep, 1, xFalse)) 
+    {
+       UnlockDisplay(dpy);
+       SyncHandle();
+        TRACE("GetDrawableInfo... return False");
+       return False;
+    }
+    *index = rep.drawableTableIndex;
+    *stamp = rep.drawableTableStamp;
+    *X = (int)rep.drawableX;
+    *Y = (int)rep.drawableY;
+    *W = (int)rep.drawableWidth;
+    *H = (int)rep.drawableHeight;
+    *numClipRects = rep.numClipRects;
+    total_rects = *numClipRects;
+
+    *backX = rep.backX;
+    *backY = rep.backY;
+    *numBackClipRects = rep.numBackClipRects;
+    total_rects += *numBackClipRects;
+
+#if 0
+    /* Because of the fix in Xserver/GL/dri/xf86dri.c, this check breaks
+     * backwards compatibility (Because of the >> 2 shift) but the fix
+     * enables multi-threaded apps to work.
+     */
+    if (rep.length !=  ((((SIZEOF(xXF86DRIGetDrawableInfoReply) - 
+                      SIZEOF(xGenericReply) + 
+                      total_rects * sizeof(drm_clip_rect_t)) + 3) & ~3) >> 2)) {
+        _XEatData(dpy, rep.length);
+       UnlockDisplay(dpy);
+       SyncHandle();
+        TRACE("GetDrawableInfo... return False");
+        return False;
+    }
+#endif
+
+    if (*numClipRects) {
+       int len = sizeof(drm_clip_rect_t) * (*numClipRects);
+
+       *pClipRects = (drm_clip_rect_t *)Xcalloc(len, 1);
+       if (*pClipRects) 
+         _XRead(dpy, (char*)*pClipRects, len);
+    } else {
+        *pClipRects = NULL;
+    }
+
+    if (*numBackClipRects) {
+       int len = sizeof(drm_clip_rect_t) * (*numBackClipRects);
+
+       *pBackClipRects = (drm_clip_rect_t *)Xcalloc(len, 1);
+       if (*pBackClipRects) 
+         _XRead(dpy, (char*)*pBackClipRects, len);
+    } else {
+        *pBackClipRects = NULL;
+    }
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    TRACE("GetDrawableInfo... return True");
+    return True;
+}
+
+PUBLIC Bool XF86DRIGetDeviceInfo(dpy, screen, hFrameBuffer, 
+       fbOrigin, fbSize, fbStride, devPrivateSize, pDevPrivate)
+    Display* dpy;
+    int screen;
+    drm_handle_t * hFrameBuffer;
+    int* fbOrigin;
+    int* fbSize;
+    int* fbStride;
+    int* devPrivateSize;
+    void** pDevPrivate;
+{
+    XExtDisplayInfo *info = find_display (dpy);
+    xXF86DRIGetDeviceInfoReply rep;
+    xXF86DRIGetDeviceInfoReq *req;
+
+    TRACE("GetDeviceInfo...");
+    XF86DRICheckExtension (dpy, info, False);
+
+    LockDisplay(dpy);
+    GetReq(XF86DRIGetDeviceInfo, req);
+    req->reqType = info->codes->major_opcode;
+    req->driReqType = X_XF86DRIGetDeviceInfo;
+    req->screen = screen;
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+        TRACE("GetDeviceInfo... return False");
+       return False;
+    }
+
+    *hFrameBuffer = rep.hFrameBufferLow;
+    if (sizeof(drm_handle_t) == 8) {
+       int shift = 32; /* var to prevent warning on next line */
+       *hFrameBuffer |= ((drm_handle_t) rep.hFrameBufferHigh) << shift;
+    }
+
+    *fbOrigin = rep.framebufferOrigin;
+    *fbSize = rep.framebufferSize;
+    *fbStride = rep.framebufferStride;
+    *devPrivateSize = rep.devPrivateSize;
+
+    if (rep.length) {
+        if (!(*pDevPrivate = (void *)Xcalloc(rep.devPrivateSize, 1))) {
+            _XEatData(dpy, ((rep.devPrivateSize+3) & ~3));
+            UnlockDisplay(dpy);
+            SyncHandle();
+            TRACE("GetDeviceInfo... return False");
+            return False;
+        }
+       _XRead(dpy, (char*)*pDevPrivate, rep.devPrivateSize);
+    } else {
+        *pDevPrivate = NULL;
+    }
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    TRACE("GetDeviceInfo... return True");
+    return True;
+}
+
+PUBLIC Bool XF86DRIOpenFullScreen(dpy, screen, drawable)
+    Display* dpy;
+    int screen;
+    Drawable drawable;
+{
+    /* This function and the underlying X protocol are deprecated.
+     */
+    (void) dpy;
+    (void) screen;
+    (void) drawable;
+    return False;
+}
+
+PUBLIC Bool XF86DRICloseFullScreen(dpy, screen, drawable)
+    Display* dpy;
+    int screen;
+    Drawable drawable;
+{
+    /* This function and the underlying X protocol are deprecated.
+     */
+    (void) dpy;
+    (void) screen;
+    (void) drawable;
+    return True;
+}
+
diff --git a/src/gallium/winsys/g3dvl/dri/dri_winsys.c b/src/gallium/winsys/g3dvl/dri/dri_winsys.c
new file mode 100644 (file)
index 0000000..257aa0a
--- /dev/null
@@ -0,0 +1,393 @@
+/**************************************************************************
+ *
+ * Copyright 2009 Younes Manton.
+ * All Rights Reserved.
+ *
+ * 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 TUNGSTEN GRAPHICS 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 <vl_winsys.h>
+#include <driclient.h>
+#include <state_tracker/dri1_api.h>
+#include <pipe/p_video_context.h>
+#include <pipe/p_state.h>
+#include <util/u_memory.h>
+
+struct vl_dri_screen
+{
+   struct vl_screen base;
+   Visual *visual;
+   struct drm_api *api;
+   dri_screen_t *dri_screen;
+   dri_framebuffer_t dri_framebuf;
+   struct dri1_api *api_hooks;
+};
+
+struct vl_dri_context
+{
+   struct vl_context base;
+   boolean is_locked;
+   boolean lost_lock;
+   drmLock *lock;
+   dri_context_t *dri_context;
+   int fd;
+   struct pipe_video_context *vpipe;
+   dri_drawable_t *drawable;
+};
+
+static void
+vl_dri_lock(void *priv)
+{
+   struct vl_dri_context *vl_dri_ctx = priv;
+   drm_context_t hw_context;
+   char ret = 0;
+
+   assert(priv);
+
+   hw_context = vl_dri_ctx->dri_context->drm_context;
+
+   DRM_CAS(vl_dri_ctx->lock, hw_context, DRM_LOCK_HELD | hw_context, ret);
+   if (ret) {
+      drmGetLock(vl_dri_ctx->fd, hw_context, 0);
+      vl_dri_ctx->lost_lock = TRUE;
+   }
+   vl_dri_ctx->is_locked = TRUE;
+}
+
+static void
+vl_dri_unlock(void *priv)
+{
+   struct vl_dri_context *vl_dri_ctx = priv;
+   drm_context_t hw_context;
+
+   assert(priv);
+
+   hw_context = vl_dri_ctx->dri_context->drm_context;
+
+   vl_dri_ctx->is_locked = FALSE;
+   DRM_UNLOCK(vl_dri_ctx->fd, vl_dri_ctx->lock, hw_context);
+}
+
+static boolean
+vl_dri_is_locked(void *priv)
+{
+   struct vl_dri_context *vl_dri_ctx = priv;
+
+   assert(priv);
+
+   return vl_dri_ctx->is_locked;
+}
+
+static boolean
+vl_dri_lost_lock(void *priv)
+{
+   struct vl_dri_context *vl_dri_ctx = priv;
+
+   assert(priv);
+
+   return vl_dri_ctx->lost_lock;
+}
+
+static void
+vl_dri_clear_lost_lock(void *priv)
+{
+   struct vl_dri_context *vl_dri_ctx = priv;
+
+   assert(priv);
+
+   vl_dri_ctx->lost_lock = FALSE;
+}
+
+struct dri1_api_lock_funcs dri1_lf =
+{
+   .lock = vl_dri_lock,
+   .unlock = vl_dri_unlock,
+   .is_locked = vl_dri_is_locked,
+   .is_lock_lost = vl_dri_lost_lock,
+   .clear_lost_lock = vl_dri_clear_lost_lock
+};
+
+static void
+vl_dri_copy_version(struct dri1_api_version *dst, dri_version_t *src)
+{
+   assert(src);
+   assert(dst);
+   dst->major = src->major;
+   dst->minor = src->minor;
+   dst->patch_level = src->patch;
+}
+
+static boolean
+vl_dri_intersect_src_bbox(struct drm_clip_rect *dst, int dst_x, int dst_y,
+                          const struct drm_clip_rect *src, const struct drm_clip_rect *bbox)
+{
+   int xy1;
+   int xy2;
+
+   assert(dst);
+   assert(src);
+   assert(bbox);
+
+   xy1 = ((int)src->x1 > (int)bbox->x1 + dst_x) ? src->x1 :
+      (int)bbox->x1 + dst_x;
+   xy2 = ((int)src->x2 < (int)bbox->x2 + dst_x) ? src->x2 :
+      (int)bbox->x2 + dst_x;
+   if (xy1 >= xy2 || xy1 < 0)
+      return FALSE;
+
+   dst->x1 = xy1;
+   dst->x2 = xy2;
+
+   xy1 = ((int)src->y1 > (int)bbox->y1 + dst_y) ? src->y1 :
+      (int)bbox->y1 + dst_y;
+   xy2 = ((int)src->y2 < (int)bbox->y2 + dst_y) ? src->y2 :
+      (int)bbox->y2 + dst_y;
+   if (xy1 >= xy2 || xy1 < 0)
+      return FALSE;
+
+   dst->y1 = xy1;
+   dst->y2 = xy2;
+   return TRUE;
+}
+
+static void
+vl_clip_copy(struct vl_dri_context *vl_dri_ctx,
+            struct pipe_surface *dst,
+            struct pipe_surface *src,
+            const struct drm_clip_rect *src_bbox)
+{
+   struct pipe_video_context *vpipe = vl_dri_ctx->base.vpipe;
+   struct drm_clip_rect clip;
+   struct drm_clip_rect *cur;
+   int i;
+
+   assert(vl_dri_ctx);
+   assert(dst);
+   assert(src);
+   assert(src_bbox);
+
+   assert(vl_dri_ctx->drawable->cliprects);
+   assert(vl_dri_ctx->drawable->num_cliprects > 0);
+
+   cur = vl_dri_ctx->drawable->cliprects;
+
+   for (i = 0; i < vl_dri_ctx->drawable->num_cliprects; ++i) {
+      if (vl_dri_intersect_src_bbox(&clip, vl_dri_ctx->drawable->x, vl_dri_ctx->drawable->y, cur++, src_bbox))
+         vpipe->surface_copy
+         (
+            vpipe, dst, clip.x1, clip.y1, src,
+            (int)clip.x1 - vl_dri_ctx->drawable->x,
+            (int)clip.y1 - vl_dri_ctx->drawable->y,
+            clip.x2 - clip.x1, clip.y2 - clip.y1
+         );
+   }
+}
+
+static void
+vl_dri_update_drawables_locked(struct vl_dri_context *vl_dri_ctx)
+{
+   struct vl_dri_screen *vl_dri_scrn;
+
+   assert(vl_dri_ctx);
+
+   vl_dri_scrn = (struct vl_dri_screen*)vl_dri_ctx->base.vscreen;
+
+   if (vl_dri_ctx->lost_lock) {
+      vl_dri_ctx->lost_lock = FALSE;
+      DRI_VALIDATE_DRAWABLE_INFO(vl_dri_scrn->dri_screen, vl_dri_ctx->drawable);
+   }
+}
+
+static void
+vl_dri_flush_frontbuffer(struct pipe_screen *screen,
+                         struct pipe_surface *surf, void *context_private)
+{
+   struct vl_dri_context *vl_dri_ctx = (struct vl_dri_context*)context_private;
+   struct vl_dri_screen *vl_dri_scrn;
+   struct drm_clip_rect src_bbox;
+   boolean save_lost_lock = FALSE;
+
+   assert(screen);
+   assert(surf);
+   assert(context_private);
+
+   vl_dri_scrn = (struct vl_dri_screen*)vl_dri_ctx->base.vscreen;
+
+   vl_dri_lock(vl_dri_ctx);
+
+   save_lost_lock = vl_dri_ctx->lost_lock;
+
+   vl_dri_update_drawables_locked(vl_dri_ctx);
+
+   src_bbox.x1 = 0;
+   src_bbox.x2 = vl_dri_ctx->drawable->w;
+   src_bbox.y1 = 0;
+   src_bbox.y2 = vl_dri_ctx->drawable->h;
+
+#if 0
+   if (vl_dri_scrn->_api_hooks->present_locked)
+      vl_dri_scrn->api_hooks->present_locked(pipe, surf,
+                                             vl_dri_ctx->drawable->cliprects,
+                                             vl_dri_ctx->drawable->num_cliprects,
+                                             vl_dri_ctx->drawable->x, vl_dri_drawable->y,
+                                             &bbox, NULL /*fence*/);
+   else
+#endif
+   if (vl_dri_scrn->api_hooks->front_srf_locked) {
+      struct pipe_surface *front = vl_dri_scrn->api_hooks->front_srf_locked(screen);
+
+      if (front)
+         vl_clip_copy(vl_dri_ctx, front, surf, &src_bbox);
+
+      //st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, fence);
+   }
+
+   vl_dri_ctx->lost_lock = save_lost_lock;
+
+   vl_dri_unlock(vl_dri_ctx);
+}
+
+Drawable
+vl_video_bind_drawable(struct vl_context *vctx, Drawable drawable)
+{
+   struct vl_dri_context *vl_dri_ctx = (struct vl_dri_context*)vctx;
+   struct vl_dri_screen *vl_dri_scrn;
+   dri_drawable_t *dri_drawable;
+   Drawable old_drawable = None;
+
+   assert(vctx);
+
+   if (vl_dri_ctx->drawable)
+      old_drawable = vl_dri_ctx->drawable->x_drawable;
+
+   vl_dri_scrn = (struct vl_dri_screen*)vl_dri_ctx->base.vscreen;
+   driCreateDrawable(vl_dri_scrn->dri_screen, drawable, &dri_drawable);
+   vl_dri_ctx->drawable = dri_drawable;
+
+   return old_drawable;
+}
+
+struct vl_screen*
+vl_screen_create(Display *display, int screen)
+{
+   struct vl_dri_screen *vl_dri_scrn;
+   struct dri1_create_screen_arg arg;
+
+   assert(display);
+
+   vl_dri_scrn = CALLOC_STRUCT(vl_dri_screen);
+   if (!vl_dri_scrn)
+      return NULL;
+
+   driCreateScreen(display, screen, &vl_dri_scrn->dri_screen, &vl_dri_scrn->dri_framebuf);
+   vl_dri_scrn->api = drm_api_create();
+
+   arg.base.mode = DRM_CREATE_DRI1;
+   arg.lf = &dri1_lf;
+   arg.ddx_info = vl_dri_scrn->dri_framebuf.private;
+   arg.ddx_info_size = vl_dri_scrn->dri_framebuf.private_size;
+   arg.sarea = vl_dri_scrn->dri_screen->sarea;
+   vl_dri_copy_version(&arg.ddx_version, &vl_dri_scrn->dri_screen->ddx);
+   vl_dri_copy_version(&arg.dri_version, &vl_dri_scrn->dri_screen->dri);
+   vl_dri_copy_version(&arg.drm_version, &vl_dri_scrn->dri_screen->drm);
+   arg.api = NULL;
+
+   vl_dri_scrn->base.pscreen = vl_dri_scrn->api->create_screen(vl_dri_scrn->api,
+                                                               vl_dri_scrn->dri_screen->fd,
+                                                               &arg.base);
+
+   if (!vl_dri_scrn->base.pscreen) {
+      FREE(vl_dri_scrn);
+      return NULL;
+   }
+
+   vl_dri_scrn->visual = XDefaultVisual(display, screen);
+   vl_dri_scrn->api_hooks = arg.api;
+   vl_dri_scrn->base.pscreen->flush_frontbuffer = vl_dri_flush_frontbuffer;
+   /* XXX: Safe to call this while unlocked? */
+   vl_dri_scrn->base.format = vl_dri_scrn->api_hooks->front_srf_locked(vl_dri_scrn->base.pscreen)->format;
+
+   return &vl_dri_scrn->base;
+}
+
+void vl_screen_destroy(struct vl_screen *vscreen)
+{
+   struct vl_dri_screen *vl_dri_scrn = (struct vl_dri_screen*)vscreen;
+
+   assert(vscreen);
+
+   vl_dri_scrn->base.pscreen->destroy(vl_dri_scrn->base.pscreen);
+   driDestroyScreen(vl_dri_scrn->dri_screen);
+   FREE(vl_dri_scrn);
+}
+
+struct vl_context*
+vl_video_create(struct vl_screen *vscreen,
+                enum pipe_video_profile profile,
+                enum pipe_video_chroma_format chroma_format,
+                unsigned width, unsigned height)
+{
+   struct vl_dri_screen *vl_dri_scrn = (struct vl_dri_screen*)vscreen;
+   struct vl_dri_context *vl_dri_ctx;
+
+   vl_dri_ctx = CALLOC_STRUCT(vl_dri_context);
+   if (!vl_dri_ctx)
+      return NULL;
+
+   /* XXX: Is default visual correct/sufficient here? */
+   driCreateContext(vl_dri_scrn->dri_screen, vl_dri_scrn->visual, &vl_dri_ctx->dri_context);
+
+   if (!vl_dri_scrn->api->create_video_context) {
+      debug_printf("[G3DVL] No video support found on %s/%s.\n",
+                   vl_dri_scrn->base.pscreen->get_vendor(vl_dri_scrn->base.pscreen),
+                   vl_dri_scrn->base.pscreen->get_name(vl_dri_scrn->base.pscreen));
+      FREE(vl_dri_ctx);
+      return NULL;
+   }
+
+   vl_dri_ctx->base.vpipe = vl_dri_scrn->api->create_video_context(vl_dri_scrn->api,
+                                                                   vscreen->pscreen,
+                                                                   profile, chroma_format,
+                                                                   width, height);
+
+   if (!vl_dri_ctx->base.vpipe) {
+      FREE(vl_dri_ctx);
+      return NULL;
+   }
+
+   vl_dri_ctx->base.vpipe->priv = vl_dri_ctx;
+   vl_dri_ctx->base.vscreen = vscreen;
+   vl_dri_ctx->fd = vl_dri_scrn->dri_screen->fd;
+   vl_dri_ctx->lock = (drmLock*)&vl_dri_scrn->dri_screen->sarea->lock;
+
+   return &vl_dri_ctx->base;
+}
+
+void vl_video_destroy(struct vl_context *vctx)
+{
+   struct vl_dri_context *vl_dri_ctx = (struct vl_dri_context*)vctx;
+
+   assert(vctx);
+
+   vl_dri_ctx->base.vpipe->destroy(vl_dri_ctx->base.vpipe);
+   FREE(vl_dri_ctx);
+}
diff --git a/src/gallium/winsys/g3dvl/dri/driclient.c b/src/gallium/winsys/g3dvl/dri/driclient.c
new file mode 100644 (file)
index 0000000..dc2189a
--- /dev/null
@@ -0,0 +1,310 @@
+#include "driclient.h"
+#include <assert.h>
+#include <stdlib.h>
+
+int driCreateScreen(Display *display, int screen, dri_screen_t **dri_screen, dri_framebuffer_t *dri_framebuf)
+{
+       int             evbase, errbase;
+       char            *driver_name;
+       int             newly_opened;
+       drm_magic_t     magic;
+       drmVersionPtr   drm_version;
+       drm_handle_t    sarea_handle;
+       char            *bus_id;
+       dri_screen_t    *dri_scrn;
+
+       assert(display);
+       assert(dri_screen);
+
+       if (!XF86DRIQueryExtension(display, &evbase, &errbase))
+               return 1;
+
+       dri_scrn = calloc(1, sizeof(dri_screen_t));
+
+       if (!dri_scrn)
+               return 1;
+
+       if (!XF86DRIQueryVersion(display, &dri_scrn->dri.major, &dri_scrn->dri.minor, &dri_scrn->dri.patch))
+               goto free_screen;
+
+       dri_scrn->display = display;
+       dri_scrn->num = screen;
+       dri_scrn->draw_lock_id = 1;
+
+       if (!XF86DRIOpenConnection(display, screen, &sarea_handle, &bus_id))
+               goto free_screen;
+
+       dri_scrn->fd = -1;
+       dri_scrn->fd = drmOpenOnce(NULL, bus_id, &newly_opened);
+       XFree(bus_id);
+
+       if (dri_scrn->fd < 0)
+               goto close_connection;
+
+       if (drmGetMagic(dri_scrn->fd, &magic))
+               goto close_drm;
+
+       drm_version = drmGetVersion(dri_scrn->fd);
+
+       if (!drm_version)
+               goto close_drm;
+
+       dri_scrn->drm.major = drm_version->version_major;
+       dri_scrn->drm.minor = drm_version->version_minor;
+       dri_scrn->drm.patch = drm_version->version_patchlevel;
+       drmFreeVersion(drm_version);
+
+       if (!XF86DRIAuthConnection(display, screen, magic))
+               goto close_drm;
+
+       if (!XF86DRIGetClientDriverName
+       (
+               display,
+               screen,
+               &dri_scrn->ddx.major,
+               &dri_scrn->ddx.minor,
+               &dri_scrn->ddx.patch,
+               &driver_name
+       ))
+               goto close_drm;
+
+       if (drmMap(dri_scrn->fd, sarea_handle, SAREA_MAX, (drmAddress)&dri_scrn->sarea))
+               goto close_drm;
+
+       dri_scrn->drawable_hash = drmHashCreate();
+
+       if (!dri_scrn->drawable_hash)
+               goto unmap_sarea;
+
+       if (dri_framebuf)
+       {
+               if (!XF86DRIGetDeviceInfo
+               (
+                       display,
+                       screen, &dri_framebuf->drm_handle,
+                       &dri_framebuf->base,
+                       &dri_framebuf->size,
+                       &dri_framebuf->stride,
+                       &dri_framebuf->private_size,
+                       &dri_framebuf->private
+               ))
+                       goto destroy_hash;
+       }
+
+       *dri_screen = dri_scrn;
+
+       return 0;
+
+destroy_hash:
+       drmHashDestroy(dri_scrn->drawable_hash);
+unmap_sarea:
+       drmUnmap(dri_scrn->sarea, SAREA_MAX);
+close_drm:
+       drmCloseOnce(dri_scrn->fd);
+close_connection:
+       XF86DRICloseConnection(display, screen);
+free_screen:
+       free(dri_scrn);
+
+       return 1;
+}
+
+int driDestroyScreen(dri_screen_t *dri_screen)
+{
+       Drawable        draw;
+       dri_drawable_t  *dri_draw;
+
+       assert(dri_screen);
+
+       if (drmHashFirst(dri_screen->drawable_hash, &draw, (void**)&dri_draw))
+       {
+               dri_draw->refcount = 1;
+               driDestroyDrawable(dri_draw);
+
+               while (drmHashNext(dri_screen->drawable_hash, &draw, (void**)&dri_draw))
+               {
+                       dri_draw->refcount = 1;
+                       driDestroyDrawable(dri_draw);
+               }
+       }
+
+       drmHashDestroy(dri_screen->drawable_hash);
+       drmUnmap(dri_screen->sarea, SAREA_MAX);
+       drmCloseOnce(dri_screen->fd);
+       XF86DRICloseConnection(dri_screen->display, dri_screen->num);
+       free(dri_screen);
+
+       return 0;
+}
+
+int driCreateDrawable(dri_screen_t *dri_screen, Drawable drawable, dri_drawable_t **dri_drawable)
+{
+       int             evbase, errbase;
+       dri_drawable_t  *dri_draw;
+
+       assert(dri_screen);
+       assert(dri_drawable);
+
+       if (!XF86DRIQueryExtension(dri_screen->display, &evbase, &errbase))
+               return 1;
+
+       if (!drmHashLookup(dri_screen->drawable_hash, drawable, (void**)dri_drawable))
+       {
+               /* Found */
+               (*dri_drawable)->refcount++;
+               return 0;
+       }
+
+       dri_draw = calloc(1, sizeof(dri_drawable_t));
+
+       if (!dri_draw)
+               return 1;
+
+       if (!XF86DRICreateDrawable(dri_screen->display, 0, drawable, &dri_draw->drm_drawable))
+       {
+               free(dri_draw);
+               return 1;
+       }
+
+       dri_draw->x_drawable = drawable;
+       dri_draw->sarea_index = 0;
+       dri_draw->sarea_stamp = NULL;
+       dri_draw->last_sarea_stamp = 0;
+       dri_draw->dri_screen = dri_screen;
+       dri_draw->refcount = 1;
+
+       if (drmHashInsert(dri_screen->drawable_hash, drawable, dri_draw))
+       {
+               XF86DRIDestroyDrawable(dri_screen->display, dri_screen->num, drawable);
+               free(dri_draw);
+               return 1;
+       }
+
+       if (!dri_draw->sarea_stamp || *dri_draw->sarea_stamp != dri_draw->last_sarea_stamp)
+       {
+               DRM_SPINLOCK(&dri_screen->sarea->drawable_lock, dri_screen->draw_lock_id);
+
+               if (driUpdateDrawableInfo(dri_draw))
+               {
+                       XF86DRIDestroyDrawable(dri_screen->display, dri_screen->num, drawable);
+                       free(dri_draw);
+                       DRM_SPINUNLOCK(&dri_screen->sarea->drawable_lock, dri_screen->draw_lock_id);
+                       return 1;
+               }
+
+               DRM_SPINUNLOCK(&dri_screen->sarea->drawable_lock, dri_screen->draw_lock_id);
+       }
+
+       *dri_drawable = dri_draw;
+
+       return 0;
+}
+
+int driUpdateDrawableInfo(dri_drawable_t *dri_drawable)
+{
+       assert(dri_drawable);
+
+       if (dri_drawable->cliprects)
+       {
+               XFree(dri_drawable->cliprects);
+               dri_drawable->cliprects = NULL;
+       }
+       if (dri_drawable->back_cliprects)
+       {
+               XFree(dri_drawable->back_cliprects);
+               dri_drawable->back_cliprects = NULL;
+       }
+
+       DRM_SPINUNLOCK(&dri_drawable->dri_screen->sarea->drawable_lock, dri_drawable->dri_screen->draw_lock_id);
+
+       if (!XF86DRIGetDrawableInfo
+       (
+               dri_drawable->dri_screen->display,
+               dri_drawable->dri_screen->num,
+               dri_drawable->x_drawable,
+               &dri_drawable->sarea_index,
+               &dri_drawable->last_sarea_stamp,
+               &dri_drawable->x,
+               &dri_drawable->y,
+               &dri_drawable->w,
+               &dri_drawable->h,
+               &dri_drawable->num_cliprects,
+               &dri_drawable->cliprects,
+               &dri_drawable->back_x,
+               &dri_drawable->back_y,
+               &dri_drawable->num_back_cliprects,
+               &dri_drawable->back_cliprects
+       ))
+       {
+               dri_drawable->sarea_stamp = &dri_drawable->last_sarea_stamp;
+               dri_drawable->num_cliprects = 0;
+               dri_drawable->cliprects = NULL;
+               dri_drawable->num_back_cliprects = 0;
+               dri_drawable->back_cliprects = 0;
+
+               return 1;
+       }
+       else
+               dri_drawable->sarea_stamp = &dri_drawable->dri_screen->sarea->drawableTable[dri_drawable->sarea_index].stamp;
+
+       DRM_SPINLOCK(&dri_drawable->dri_screen->sarea->drawable_lock, dri_drawable->dri_screen->draw_lock_id);
+
+       return 0;
+}
+
+int driDestroyDrawable(dri_drawable_t *dri_drawable)
+{
+       assert(dri_drawable);
+
+       if (--dri_drawable->refcount == 0)
+       {
+               if (dri_drawable->cliprects)
+                       XFree(dri_drawable->cliprects);
+               if (dri_drawable->back_cliprects)
+                       XFree(dri_drawable->back_cliprects);
+               drmHashDelete(dri_drawable->dri_screen->drawable_hash, dri_drawable->x_drawable);
+               XF86DRIDestroyDrawable(dri_drawable->dri_screen->display, dri_drawable->dri_screen->num, dri_drawable->x_drawable);
+               free(dri_drawable);
+       }
+
+       return 0;
+}
+
+int driCreateContext(dri_screen_t *dri_screen, Visual *visual, dri_context_t **dri_context)
+{
+       int             evbase, errbase;
+       dri_context_t   *dri_ctx;
+
+       assert(dri_screen);
+       assert(visual);
+       assert(dri_context);
+
+       if (!XF86DRIQueryExtension(dri_screen->display, &evbase, &errbase))
+               return 1;
+
+       dri_ctx = calloc(1, sizeof(dri_context_t));
+
+       if (!dri_ctx)
+               return 1;
+
+       if (!XF86DRICreateContext(dri_screen->display, dri_screen->num, visual, &dri_ctx->id, &dri_ctx->drm_context))
+       {
+               free(dri_ctx);
+               return 1;
+       }
+
+       dri_ctx->dri_screen = dri_screen;
+       *dri_context = dri_ctx;
+
+       return 0;
+}
+
+int driDestroyContext(dri_context_t *dri_context)
+{
+       assert(dri_context);
+
+       XF86DRIDestroyContext(dri_context->dri_screen->display, dri_context->dri_screen->num, dri_context->id);
+       free(dri_context);
+
+       return 0;
+}
diff --git a/src/gallium/winsys/g3dvl/dri/driclient.h b/src/gallium/winsys/g3dvl/dri/driclient.h
new file mode 100644 (file)
index 0000000..d391525
--- /dev/null
@@ -0,0 +1,97 @@
+#ifndef driclient_h
+#define driclient_h
+
+#include <stdint.h>
+#include <X11/Xlib.h>
+#include <drm_sarea.h>
+#include "xf86dri.h"
+
+/* TODO: Bring in DRI XML options */
+
+typedef struct dri_version
+{
+       int major;
+       int minor;
+       int patch;
+} dri_version_t;
+
+typedef struct dri_screen
+{
+       Display                 *display;
+       unsigned int            num;
+       dri_version_t           ddx, dri, drm;
+       int                     draw_lock_id;
+       int                     fd;
+       drm_sarea_t             *sarea;
+       void                    *drawable_hash;
+       void                    *private;
+} dri_screen_t;
+
+struct dri_context;
+
+typedef struct dri_drawable
+{
+       drm_drawable_t          drm_drawable;
+       Drawable                x_drawable;
+       unsigned int            sarea_index;
+       unsigned int            *sarea_stamp;
+       unsigned int            last_sarea_stamp;
+       int                     x, y, w, h;
+       int                     back_x, back_y;
+       int                     num_cliprects, num_back_cliprects;
+       drm_clip_rect_t         *cliprects, *back_cliprects;
+       dri_screen_t            *dri_screen;
+       unsigned int            refcount;
+       void                    *private;
+} dri_drawable_t;
+
+typedef struct dri_context
+{
+       XID                     id;
+       drm_context_t           drm_context;
+       dri_screen_t            *dri_screen;
+       void                    *private;
+} dri_context_t;
+
+typedef struct dri_framebuffer
+{
+       drm_handle_t            drm_handle;
+       int                     base, size, stride;
+       int                     private_size;
+       void                    *private;
+} dri_framebuffer_t;
+
+int driCreateScreen(Display *display, int screen, dri_screen_t **dri_screen, dri_framebuffer_t *dri_framebuf);
+int driDestroyScreen(dri_screen_t *dri_screen);
+int driCreateDrawable(dri_screen_t *dri_screen, Drawable drawable, dri_drawable_t **dri_drawable);
+int driUpdateDrawableInfo(dri_drawable_t *dri_drawable);
+int driDestroyDrawable(dri_drawable_t *dri_drawable);
+int driCreateContext(dri_screen_t *dri_screen, Visual *visual, dri_context_t **dri_context);
+int driDestroyContext(dri_context_t *dri_context);
+
+#define DRI_VALIDATE_DRAWABLE_INFO_ONCE(dri_drawable)                                  \
+do                                                                                     \
+{                                                                                      \
+       if (*(dri_drawable->sarea_stamp) != dri_drawable->last_sarea_stamp)             \
+               driUpdateDrawableInfo(dri_drawable);                                    \
+} while (0)
+
+#define DRI_VALIDATE_DRAWABLE_INFO(dri_screen, dri_drawable)                                   \
+do                                                                                             \
+{                                                                                              \
+       while (*(dri_drawable->sarea_stamp) != dri_drawable->last_sarea_stamp)                  \
+       {                                                                                       \
+               register unsigned int hwContext = dri_screen->sarea->lock.lock &                \
+               ~(DRM_LOCK_HELD | DRM_LOCK_CONT);                                               \
+               DRM_UNLOCK(dri_screen->fd, &dri_screen->sarea->lock, hwContext);                \
+                                                                                               \
+               DRM_SPINLOCK(&dri_screen->sarea->drawable_lock, dri_screen->draw_lock_id);      \
+               DRI_VALIDATE_DRAWABLE_INFO_ONCE(dri_drawable);                                  \
+               DRM_SPINUNLOCK(&dri_screen->sarea->drawable_lock, dri_screen->draw_lock_id);    \
+                                                                                               \
+               DRM_LIGHT_LOCK(dri_screen->fd, &dri_screen->sarea->lock, hwContext);            \
+       }                                                                                       \
+} while (0)
+
+#endif
+
diff --git a/src/gallium/winsys/g3dvl/dri/xf86dri.h b/src/gallium/winsys/g3dvl/dri/xf86dri.h
new file mode 100644 (file)
index 0000000..baf80a7
--- /dev/null
@@ -0,0 +1,119 @@
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+All Rights Reserved.
+
+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.
+
+**************************************************************************/
+
+/**
+ * \file xf86dri.h
+ * Protocol numbers and function prototypes for DRI X protocol.
+ *
+ * \author Kevin E. Martin <martin@valinux.com>
+ * \author Jens Owen <jens@tungstengraphics.com>
+ * \author Rickard E. (Rik) Faith <faith@valinux.com>
+ */
+
+#ifndef _XF86DRI_H_
+#define _XF86DRI_H_
+
+#include <X11/Xfuncproto.h>
+#include <xf86drm.h>
+
+#define X_XF86DRIQueryVersion                  0
+#define X_XF86DRIQueryDirectRenderingCapable   1
+#define X_XF86DRIOpenConnection                        2
+#define X_XF86DRICloseConnection               3
+#define X_XF86DRIGetClientDriverName           4
+#define X_XF86DRICreateContext                 5
+#define X_XF86DRIDestroyContext                        6
+#define X_XF86DRICreateDrawable                        7
+#define X_XF86DRIDestroyDrawable               8
+#define X_XF86DRIGetDrawableInfo               9
+#define X_XF86DRIGetDeviceInfo                 10
+#define X_XF86DRIAuthConnection                 11
+#define X_XF86DRIOpenFullScreen                 12   /* Deprecated */
+#define X_XF86DRICloseFullScreen                13   /* Deprecated */
+
+#define XF86DRINumberEvents            0
+
+#define XF86DRIClientNotLocal          0
+#define XF86DRIOperationNotSupported   1
+#define XF86DRINumberErrors            (XF86DRIOperationNotSupported + 1)
+
+#ifndef _XF86DRI_SERVER_
+
+_XFUNCPROTOBEGIN
+
+Bool XF86DRIQueryExtension( Display *dpy, int *event_base, int *error_base );
+
+Bool XF86DRIQueryVersion( Display *dpy, int *majorVersion, int *minorVersion,
+    int *patchVersion );
+
+Bool XF86DRIQueryDirectRenderingCapable( Display *dpy, int screen,
+    Bool *isCapable );
+
+Bool XF86DRIOpenConnection( Display *dpy, int screen, drm_handle_t *hSAREA,
+    char **busIDString );
+
+Bool XF86DRIAuthConnection( Display *dpy, int screen, drm_magic_t magic );
+
+Bool XF86DRICloseConnection( Display *dpy, int screen );
+
+Bool XF86DRIGetClientDriverName( Display *dpy, int screen,
+    int *ddxDriverMajorVersion, int *ddxDriverMinorVersion,
+    int *ddxDriverPatchVersion, char **clientDriverName );
+
+Bool XF86DRICreateContext( Display *dpy, int screen, Visual *visual,
+    XID *ptr_to_returned_context_id, drm_context_t *hHWContext );
+
+Bool XF86DRICreateContextWithConfig( Display *dpy, int screen, int configID,
+    XID *ptr_to_returned_context_id, drm_context_t *hHWContext );
+
+Bool XF86DRIDestroyContext( Display *dpy, int screen,
+    XID context_id );
+
+Bool XF86DRICreateDrawable( Display *dpy, int screen,
+    Drawable drawable, drm_drawable_t *hHWDrawable );
+
+Bool XF86DRIDestroyDrawable( Display *dpy, int screen, 
+    Drawable drawable);
+
+Bool XF86DRIGetDrawableInfo( Display *dpy, int screen, Drawable drawable,
+    unsigned int *index, unsigned int *stamp, 
+    int *X, int *Y, int *W, int *H,
+    int *numClipRects, drm_clip_rect_t ** pClipRects,
+    int *backX, int *backY,
+    int *numBackClipRects, drm_clip_rect_t **pBackClipRects );
+
+Bool XF86DRIGetDeviceInfo( Display *dpy, int screen,
+    drm_handle_t *hFrameBuffer, int *fbOrigin, int *fbSize,
+    int *fbStride, int *devPrivateSize, void **pDevPrivate );
+
+_XFUNCPROTOEND
+
+#endif /* _XF86DRI_SERVER_ */
+
+#endif /* _XF86DRI_H_ */
+
diff --git a/src/gallium/winsys/g3dvl/dri/xf86dristr.h b/src/gallium/winsys/g3dvl/dri/xf86dristr.h
new file mode 100644 (file)
index 0000000..b834bd1
--- /dev/null
@@ -0,0 +1,342 @@
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+All Rights Reserved.
+
+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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Jens Owen <jens@tungstengraphics.com>
+ *   Rickard E. (Rik) Fiath <faith@valinux.com>
+ *
+ */
+
+#ifndef _XF86DRISTR_H_
+#define _XF86DRISTR_H_
+
+#include "xf86dri.h"
+
+#define XF86DRINAME "XFree86-DRI"
+
+/* The DRI version number.  This was originally set to be the same of the
+ * XFree86 version number.  However, this version is really indepedent of
+ * the XFree86 version.
+ *
+ * Version History:
+ *    4.0.0: Original
+ *    4.0.1: Patch to bump clipstamp when windows are destroyed, 28 May 02
+ *    4.1.0: Add transition from single to multi in DRMInfo rec, 24 Jun 02
+ */
+#define XF86DRI_MAJOR_VERSION  4
+#define XF86DRI_MINOR_VERSION  1
+#define XF86DRI_PATCH_VERSION  0
+
+typedef struct _XF86DRIQueryVersion {
+    CARD8      reqType;                /* always DRIReqCode */
+    CARD8      driReqType;             /* always X_DRIQueryVersion */
+    CARD16     length B16;
+} xXF86DRIQueryVersionReq;
+#define sz_xXF86DRIQueryVersionReq     4
+
+typedef struct {
+    BYTE       type;                   /* X_Reply */
+    BOOL       pad1;
+    CARD16     sequenceNumber B16;
+    CARD32     length B32;
+    CARD16     majorVersion B16;       /* major version of DRI protocol */
+    CARD16     minorVersion B16;       /* minor version of DRI protocol */
+    CARD32     patchVersion B32;       /* patch version of DRI protocol */
+    CARD32     pad3 B32;
+    CARD32     pad4 B32;
+    CARD32     pad5 B32;
+    CARD32     pad6 B32;
+} xXF86DRIQueryVersionReply;
+#define sz_xXF86DRIQueryVersionReply   32
+
+typedef struct _XF86DRIQueryDirectRenderingCapable {
+    CARD8      reqType;                /* always DRIReqCode */
+    CARD8      driReqType;             /* X_DRIQueryDirectRenderingCapable */
+    CARD16     length B16;
+    CARD32     screen B32;
+} xXF86DRIQueryDirectRenderingCapableReq;
+#define sz_xXF86DRIQueryDirectRenderingCapableReq      8
+
+typedef struct {
+    BYTE       type;                   /* X_Reply */
+    BOOL       pad1;
+    CARD16     sequenceNumber B16;
+    CARD32     length B32;
+    BOOL       isCapable;
+    BOOL       pad2;
+    BOOL       pad3;
+    BOOL       pad4;
+    CARD32     pad5 B32;
+    CARD32     pad6 B32;
+    CARD32     pad7 B32;
+    CARD32     pad8 B32;
+    CARD32     pad9 B32;
+} xXF86DRIQueryDirectRenderingCapableReply;
+#define sz_xXF86DRIQueryDirectRenderingCapableReply    32
+
+typedef struct _XF86DRIOpenConnection {
+    CARD8      reqType;                /* always DRIReqCode */
+    CARD8      driReqType;             /* always X_DRIOpenConnection */
+    CARD16     length B16;
+    CARD32     screen B32;
+} xXF86DRIOpenConnectionReq;
+#define sz_xXF86DRIOpenConnectionReq   8
+
+typedef struct {
+    BYTE       type;                   /* X_Reply */
+    BOOL       pad1;
+    CARD16     sequenceNumber B16;
+    CARD32     length B32;
+    CARD32     hSAREALow B32;
+    CARD32     hSAREAHigh B32;
+    CARD32     busIdStringLength B32;
+    CARD32     pad6 B32;
+    CARD32     pad7 B32;
+    CARD32     pad8 B32;
+} xXF86DRIOpenConnectionReply;
+#define sz_xXF86DRIOpenConnectionReply 32
+
+typedef struct _XF86DRIAuthConnection {
+    CARD8      reqType;                /* always DRIReqCode */
+    CARD8      driReqType;             /* always X_DRICloseConnection */
+    CARD16     length B16;
+    CARD32     screen B32;
+    CARD32      magic B32;
+} xXF86DRIAuthConnectionReq;
+#define sz_xXF86DRIAuthConnectionReq   12
+
+typedef struct {
+    BYTE        type;
+    BOOL        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;
+} xXF86DRIAuthConnectionReply;
+#define zx_xXF86DRIAuthConnectionReply  32
+
+typedef struct _XF86DRICloseConnection {
+    CARD8      reqType;                /* always DRIReqCode */
+    CARD8      driReqType;             /* always X_DRICloseConnection */
+    CARD16     length B16;
+    CARD32     screen B32;
+} xXF86DRICloseConnectionReq;
+#define sz_xXF86DRICloseConnectionReq  8
+
+typedef struct _XF86DRIGetClientDriverName {
+    CARD8      reqType;                /* always DRIReqCode */
+    CARD8      driReqType;             /* always X_DRIGetClientDriverName */
+    CARD16     length B16;
+    CARD32     screen B32;
+} xXF86DRIGetClientDriverNameReq;
+#define sz_xXF86DRIGetClientDriverNameReq      8
+
+typedef struct {
+    BYTE       type;                   /* X_Reply */
+    BOOL       pad1;
+    CARD16     sequenceNumber B16;
+    CARD32     length B32;
+    CARD32     ddxDriverMajorVersion B32;
+    CARD32     ddxDriverMinorVersion B32;
+    CARD32     ddxDriverPatchVersion B32;
+    CARD32     clientDriverNameLength B32;
+    CARD32     pad5 B32;
+    CARD32     pad6 B32;
+} xXF86DRIGetClientDriverNameReply;
+#define sz_xXF86DRIGetClientDriverNameReply    32
+
+typedef struct _XF86DRICreateContext {
+    CARD8      reqType;                /* always DRIReqCode */
+    CARD8      driReqType;             /* always X_DRICreateContext */
+    CARD16     length B16;
+    CARD32     screen B32;
+    CARD32     visual B32;
+    CARD32     context B32;
+} xXF86DRICreateContextReq;
+#define sz_xXF86DRICreateContextReq    16
+
+typedef struct {
+    BYTE       type;                   /* X_Reply */
+    BOOL       pad1;
+    CARD16     sequenceNumber B16;
+    CARD32     length B32;
+    CARD32     hHWContext B32;
+    CARD32     pad2 B32;
+    CARD32     pad3 B32;
+    CARD32     pad4 B32;
+    CARD32     pad5 B32;
+    CARD32     pad6 B32;
+} xXF86DRICreateContextReply;
+#define sz_xXF86DRICreateContextReply  32
+
+typedef struct _XF86DRIDestroyContext {
+    CARD8      reqType;                /* always DRIReqCode */
+    CARD8      driReqType;             /* always X_DRIDestroyContext */
+    CARD16     length B16;
+    CARD32     screen B32;
+    CARD32     context B32;
+} xXF86DRIDestroyContextReq;
+#define sz_xXF86DRIDestroyContextReq   12
+
+typedef struct _XF86DRICreateDrawable {
+    CARD8      reqType;                /* always DRIReqCode */
+    CARD8      driReqType;             /* always X_DRICreateDrawable */
+    CARD16     length B16;
+    CARD32     screen B32;
+    CARD32     drawable B32;
+} xXF86DRICreateDrawableReq;
+#define sz_xXF86DRICreateDrawableReq   12
+
+typedef struct {
+    BYTE       type;                   /* X_Reply */
+    BOOL       pad1;
+    CARD16     sequenceNumber B16;
+    CARD32     length B32;
+    CARD32     hHWDrawable B32;
+    CARD32     pad2 B32;
+    CARD32     pad3 B32;
+    CARD32     pad4 B32;
+    CARD32     pad5 B32;
+    CARD32     pad6 B32;
+} xXF86DRICreateDrawableReply;
+#define sz_xXF86DRICreateDrawableReply 32
+
+typedef struct _XF86DRIDestroyDrawable {
+    CARD8      reqType;                /* always DRIReqCode */
+    CARD8      driReqType;             /* always X_DRIDestroyDrawable */
+    CARD16     length B16;
+    CARD32     screen B32;
+    CARD32     drawable B32;
+} xXF86DRIDestroyDrawableReq;
+#define sz_xXF86DRIDestroyDrawableReq  12
+
+typedef struct _XF86DRIGetDrawableInfo {
+    CARD8      reqType;                /* always DRIReqCode */
+    CARD8      driReqType;             /* always X_DRIGetDrawableInfo */
+    CARD16     length B16;
+    CARD32     screen B32;
+    CARD32     drawable B32;
+} xXF86DRIGetDrawableInfoReq;
+#define sz_xXF86DRIGetDrawableInfoReq  12
+
+typedef struct {
+    BYTE       type;                   /* X_Reply */
+    BOOL       pad1;
+    CARD16     sequenceNumber B16;
+    CARD32     length B32;
+    CARD32     drawableTableIndex B32;
+    CARD32     drawableTableStamp B32;
+    INT16      drawableX B16;
+    INT16      drawableY B16;
+    INT16      drawableWidth B16;
+    INT16      drawableHeight B16;
+    CARD32     numClipRects B32;
+    INT16       backX B16;
+    INT16       backY B16;
+    CARD32      numBackClipRects B32;
+} xXF86DRIGetDrawableInfoReply;
+
+#define sz_xXF86DRIGetDrawableInfoReply        36
+
+
+typedef struct _XF86DRIGetDeviceInfo {
+    CARD8      reqType;                /* always DRIReqCode */
+    CARD8      driReqType;             /* always X_DRIGetDeviceInfo */
+    CARD16     length B16;
+    CARD32     screen B32;
+} xXF86DRIGetDeviceInfoReq;
+#define sz_xXF86DRIGetDeviceInfoReq    8
+
+typedef struct {
+    BYTE       type;                   /* X_Reply */
+    BOOL       pad1;
+    CARD16     sequenceNumber B16;
+    CARD32     length B32;
+    CARD32     hFrameBufferLow B32;
+    CARD32     hFrameBufferHigh B32;
+    CARD32     framebufferOrigin B32;
+    CARD32     framebufferSize B32;
+    CARD32     framebufferStride B32;
+    CARD32     devPrivateSize B32;
+} xXF86DRIGetDeviceInfoReply;
+#define sz_xXF86DRIGetDeviceInfoReply  32
+
+typedef struct _XF86DRIOpenFullScreen {
+    CARD8       reqType;       /* always DRIReqCode */
+    CARD8       driReqType;    /* always X_DRIOpenFullScreen */
+    CARD16      length B16;
+    CARD32      screen B32;
+    CARD32      drawable B32;
+} xXF86DRIOpenFullScreenReq;
+#define sz_xXF86DRIOpenFullScreenReq    12
+
+typedef struct {
+    BYTE        type;
+    BOOL        pad1;
+    CARD16      sequenceNumber B16;
+    CARD32      length B32;
+    CARD32      isFullScreen B32;
+    CARD32      pad2 B32;
+    CARD32      pad3 B32;
+    CARD32      pad4 B32;
+    CARD32      pad5 B32;
+    CARD32      pad6 B32;
+} xXF86DRIOpenFullScreenReply;
+#define sz_xXF86DRIOpenFullScreenReply  32
+
+typedef struct _XF86DRICloseFullScreen {
+    CARD8       reqType;       /* always DRIReqCode */
+    CARD8       driReqType;    /* always X_DRICloseFullScreen */
+    CARD16      length B16;
+    CARD32      screen B32;
+    CARD32      drawable B32;
+} xXF86DRICloseFullScreenReq;
+#define sz_xXF86DRICloseFullScreenReq   12
+
+typedef struct {
+    BYTE        type;
+    BOOL        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;
+} xXF86DRICloseFullScreenReply;
+#define sz_xXF86DRICloseFullScreenReply  32
+
+
+#endif /* _XF86DRISTR_H_ */
diff --git a/src/gallium/winsys/g3dvl/drm/Makefile b/src/gallium/winsys/g3dvl/drm/Makefile
new file mode 100644 (file)
index 0000000..0711f44
--- /dev/null
@@ -0,0 +1,12 @@
+# src/gallium/winsys/Makefile
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+SUBDIRS = $(GALLIUM_WINSYS_DRM_DIRS)
+
+default install clean:
+       @for dir in $(SUBDIRS) ; do \
+               if [ -d $$dir ] ; then \
+                       (cd $$dir && $(MAKE) $@) || exit 1; \
+               fi \
+       done
diff --git a/src/gallium/winsys/g3dvl/drm/Makefile.template b/src/gallium/winsys/g3dvl/drm/Makefile.template
new file mode 100644 (file)
index 0000000..a33d956
--- /dev/null
@@ -0,0 +1,72 @@
+XVMC_MAJOR = 1
+XVMC_MINOR = 0
+XVMC_LIB = XvMCg3dvl
+XVMC_LIB_NAME = lib$(XVMC_LIB).so
+XVMC_LIB_DEPS = $(EXTRA_LIB_PATH) -lXvMC -lXv -lX11 -lm
+
+###############################################################
+
+INCLUDES = $(DRIVER_INCLUDES) \
+           -I$(TOP)/src/gallium/include \
+           -I$(TOP)/src/gallium/auxiliary \
+           -I$(TOP)/src/gallium/drivers \
+           -I$(TOP)/src/gallium/winsys/g3dvl \
+           -I$(TOP)/src/gallium/winsys/g3dvl/dri
+
+DEFINES += $(DRIVER_DEFINES) \
+           -DGALLIUM_SOFTPIPE \
+          -DGALLIUM_TRACE
+
+# XXX: Hack, if we include libxvmctracker.a in LIBS none of the symbols are
+# pulled in by the linker because xsp_winsys.c doesn't refer to them
+OBJECTS = $(C_SOURCES:.c=.o) $(TOP)/src/gallium/state_trackers/xorg/xvmc/*.o
+
+LIBS = $(TOP)/src/gallium/winsys/g3dvl/dri/libvldri.a \
+       $(PIPE_DRIVERS) \
+       $(TOP)/src/gallium/auxiliary/vl/libvl.a \
+       $(TOP)/src/gallium/auxiliary/draw/libdraw.a \
+       $(TOP)/src/gallium/auxiliary/tgsi/libtgsi.a \
+       $(TOP)/src/gallium/auxiliary/translate/libtranslate.a \
+       $(TOP)/src/gallium/auxiliary/cso_cache/libcso_cache.a \
+       $(TOP)/src/gallium/auxiliary/rtasm/librtasm.a \
+       $(TOP)/src/gallium/auxiliary/util/libutil.a
+
+.c.o:
+       $(CC) -c $(INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@
+
+.S.o:
+       $(CC) -c $(INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@
+
+.PHONY: default $(TOP)/$(LIB_DIR)/gallium clean
+
+default: depend $(TOP)/$(LIB_DIR)/gallium $(TOP)/$(LIB_DIR)/gallium/$(XVMC_LIB_NAME)
+
+$(TOP)/$(LIB_DIR)/gallium:
+       @mkdir -p $(TOP)/$(LIB_DIR)/gallium
+
+# Make the libXvMCg3dvl.so library
+$(TOP)/$(LIB_DIR)/gallium/$(XVMC_LIB_NAME): $(OBJECTS) $(LIBS) Makefile
+       $(MKLIB) -o $(XVMC_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+               -major $(XVMC_MAJOR) -minor $(XVMC_MINOR) $(MKLIB_OPTIONS) \
+               -install $(TOP)/$(LIB_DIR)/gallium -id $(INSTALL_LIB_DIR)/lib$(XVMC_LIB).1.dylib \
+               $(XVMC_LIB_DEPS) $(DRIVER_LIB_DEPS) $(OBJECTS) $(LIBS)
+
+depend: $(SOURCES) Makefile
+       $(RM) depend
+       touch depend
+       $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDES) $(SOURCES)
+
+#install: default
+#      $(INSTALL) -d $(INSTALL_DIR)/include/GL
+#      $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
+#      $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(INSTALL_DIR)/include/GL
+#      @if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \
+#              $(INSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \
+#      fi
+
+clean: Makefile
+       $(RM) $(TOP)/$(LIB_DIR)/gallium/$(XVMC_LIB_NAME)
+       $(RM) *.o *~
+       $(RM) depend depend.bak
+
+-include depend
diff --git a/src/gallium/winsys/g3dvl/drm/nouveau/Makefile b/src/gallium/winsys/g3dvl/drm/nouveau/Makefile
new file mode 100644 (file)
index 0000000..7ff4484
--- /dev/null
@@ -0,0 +1,26 @@
+# This makefile produces a libXvMCg3dvl.so which is
+# based on DRM/DRI
+
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+C_SOURCES =
+
+DRIVER_INCLUDES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-I) \
+                   -I$(TOP)/src/gallium/winsys/drm/nouveau \
+DRIVER_DEFINES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-other)
+
+PIPE_DRIVERS = \
+       $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
+       $(TOP)/src/gallium/drivers/nv04/libnv04.a \
+       $(TOP)/src/gallium/drivers/nv10/libnv10.a \
+       $(TOP)/src/gallium/drivers/nv20/libnv20.a \
+       $(TOP)/src/gallium/drivers/nv30/libnv30.a \
+       $(TOP)/src/gallium/drivers/nv40/libnv40.a \
+       $(TOP)/src/gallium/drivers/nv50/libnv50.a \
+       $(TOP)/src/gallium/drivers/nouveau/libnouveau.a \
+        $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a
+
+DRIVER_LIB_DEPS += $(shell pkg-config libdrm_nouveau --libs)
+
+include ../Makefile.template
diff --git a/src/gallium/winsys/g3dvl/nouveau/Makefile b/src/gallium/winsys/g3dvl/nouveau/Makefile
deleted file mode 100644 (file)
index 4eba18a..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-# This makefile produces a libXvMCg3dvl.so which is
-# based on DRM/DRI
-
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-XVMC_MAJOR = 1
-XVMC_MINOR = 0
-XVMC_LIB = XvMCg3dvl
-XVMC_LIB_NAME = lib$(XVMC_LIB).so
-XVMC_LIB_DEPS = $(EXTRA_LIB_PATH) -lXvMC -lXv -lX11 -lm
-
-SOURCES = drm_nouveau_winsys.c
-
-DRIVER_INCLUDES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-I) \
-                   -I$(TOP)/src/gallium/winsys/drm/nouveau \
-                   -I$(TOP)/src/driclient/include
-DRIVER_DEFINES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-other)
-
-PIPE_DRIVERS = \
-       $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
-       $(TOP)/src/gallium/drivers/nv04/libnv04.a \
-       $(TOP)/src/gallium/drivers/nv10/libnv10.a \
-       $(TOP)/src/gallium/drivers/nv20/libnv20.a \
-       $(TOP)/src/gallium/drivers/nv30/libnv30.a \
-       $(TOP)/src/gallium/drivers/nv40/libnv40.a \
-       $(TOP)/src/gallium/drivers/nv50/libnv50.a \
-       $(TOP)/src/gallium/drivers/nouveau/libnouveau.a
-
-DRI_LIB_DEPS += $(shell pkg-config libdrm_nouveau --libs)
-
-###############################################################
-
-INCLUDES = $(DRIVER_INCLUDES) \
-           -I$(TOP)/src/gallium/include \
-           -I$(TOP)/src/gallium/auxiliary \
-           -I$(TOP)/src/gallium/drivers \
-           -I$(TOP)/src/gallium/winsys/g3dvl \
-           -I$(TOP)/src/driclient/include
-
-DEFINES += $(DRIVER_DEFINES) \
-           -DGALLIUM_SOFTPIPE \
-          -DGALLIUM_TRACE
-
-# XXX: Hack, if we include libxvmctracker.a in LIBS none of the symbols are
-# pulled in by the linker because xsp_winsys.c doesn't refer to them
-OBJECTS = $(SOURCES:.c=.o) $(TOP)/src/gallium/state_trackers/xorg/xvmc/*.o
-
-LIBS = $(PIPE_DRIVERS) \
-       $(TOP)/src/driclient/lib/libdriclient.a \
-       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
-       $(TOP)/src/gallium/auxiliary/vl/libvl.a \
-       $(TOP)/src/gallium/auxiliary/draw/libdraw.a \
-       $(TOP)/src/gallium/auxiliary/tgsi/libtgsi.a \
-       $(TOP)/src/gallium/auxiliary/translate/libtranslate.a \
-       $(TOP)/src/gallium/auxiliary/cso_cache/libcso_cache.a \
-       $(TOP)/src/gallium/auxiliary/rtasm/librtasm.a \
-       $(TOP)/src/gallium/auxiliary/util/libutil.a
-
-.c.o:
-       $(CC) -c $(INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@
-
-.S.o:
-       $(CC) -c $(INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@
-
-.PHONY: default $(TOP)/$(LIB_DIR)/gallium clean
-
-default: depend $(TOP)/$(LIB_DIR)/gallium $(TOP)/$(LIB_DIR)/gallium/$(XVMC_LIB_NAME)
-
-$(TOP)/$(LIB_DIR)/gallium:
-       @mkdir -p $(TOP)/$(LIB_DIR)/gallium
-
-# Make the libXvMCg3dvl.so library
-$(TOP)/$(LIB_DIR)/gallium/$(XVMC_LIB_NAME): $(OBJECTS) $(LIBS) Makefile
-       $(MKLIB) -o $(XVMC_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
-               -major $(XVMC_MAJOR) -minor $(XVMC_MINOR) $(MKLIB_OPTIONS) \
-               -install $(TOP)/$(LIB_DIR)/gallium -id $(INSTALL_LIB_DIR)/lib$(XVMC_LIB).1.dylib \
-               $(XVMC_LIB_DEPS) $(DRI_LIB_DEPS) $(OBJECTS) $(LIBS)
-
-depend: $(SOURCES) Makefile
-       $(RM) depend
-       touch depend
-       $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDES) $(SOURCES)
-
-#install: default
-#      $(INSTALL) -d $(INSTALL_DIR)/include/GL
-#      $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
-#      $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(INSTALL_DIR)/include/GL
-#      @if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \
-#              $(INSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \
-#      fi
-
-clean: Makefile
-       $(RM) $(TOP)/$(LIB_DIR)/gallium/$(XVMC_LIB_NAME)
-       $(RM) *.o *~
-       $(RM) depend depend.bak
-
--include depend
diff --git a/src/gallium/winsys/g3dvl/nouveau/drm_nouveau_winsys.c b/src/gallium/winsys/g3dvl/nouveau/drm_nouveau_winsys.c
deleted file mode 100644 (file)
index 257aa0a..0000000
+++ /dev/null
@@ -1,393 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * 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 TUNGSTEN GRAPHICS 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 <vl_winsys.h>
-#include <driclient.h>
-#include <state_tracker/dri1_api.h>
-#include <pipe/p_video_context.h>
-#include <pipe/p_state.h>
-#include <util/u_memory.h>
-
-struct vl_dri_screen
-{
-   struct vl_screen base;
-   Visual *visual;
-   struct drm_api *api;
-   dri_screen_t *dri_screen;
-   dri_framebuffer_t dri_framebuf;
-   struct dri1_api *api_hooks;
-};
-
-struct vl_dri_context
-{
-   struct vl_context base;
-   boolean is_locked;
-   boolean lost_lock;
-   drmLock *lock;
-   dri_context_t *dri_context;
-   int fd;
-   struct pipe_video_context *vpipe;
-   dri_drawable_t *drawable;
-};
-
-static void
-vl_dri_lock(void *priv)
-{
-   struct vl_dri_context *vl_dri_ctx = priv;
-   drm_context_t hw_context;
-   char ret = 0;
-
-   assert(priv);
-
-   hw_context = vl_dri_ctx->dri_context->drm_context;
-
-   DRM_CAS(vl_dri_ctx->lock, hw_context, DRM_LOCK_HELD | hw_context, ret);
-   if (ret) {
-      drmGetLock(vl_dri_ctx->fd, hw_context, 0);
-      vl_dri_ctx->lost_lock = TRUE;
-   }
-   vl_dri_ctx->is_locked = TRUE;
-}
-
-static void
-vl_dri_unlock(void *priv)
-{
-   struct vl_dri_context *vl_dri_ctx = priv;
-   drm_context_t hw_context;
-
-   assert(priv);
-
-   hw_context = vl_dri_ctx->dri_context->drm_context;
-
-   vl_dri_ctx->is_locked = FALSE;
-   DRM_UNLOCK(vl_dri_ctx->fd, vl_dri_ctx->lock, hw_context);
-}
-
-static boolean
-vl_dri_is_locked(void *priv)
-{
-   struct vl_dri_context *vl_dri_ctx = priv;
-
-   assert(priv);
-
-   return vl_dri_ctx->is_locked;
-}
-
-static boolean
-vl_dri_lost_lock(void *priv)
-{
-   struct vl_dri_context *vl_dri_ctx = priv;
-
-   assert(priv);
-
-   return vl_dri_ctx->lost_lock;
-}
-
-static void
-vl_dri_clear_lost_lock(void *priv)
-{
-   struct vl_dri_context *vl_dri_ctx = priv;
-
-   assert(priv);
-
-   vl_dri_ctx->lost_lock = FALSE;
-}
-
-struct dri1_api_lock_funcs dri1_lf =
-{
-   .lock = vl_dri_lock,
-   .unlock = vl_dri_unlock,
-   .is_locked = vl_dri_is_locked,
-   .is_lock_lost = vl_dri_lost_lock,
-   .clear_lost_lock = vl_dri_clear_lost_lock
-};
-
-static void
-vl_dri_copy_version(struct dri1_api_version *dst, dri_version_t *src)
-{
-   assert(src);
-   assert(dst);
-   dst->major = src->major;
-   dst->minor = src->minor;
-   dst->patch_level = src->patch;
-}
-
-static boolean
-vl_dri_intersect_src_bbox(struct drm_clip_rect *dst, int dst_x, int dst_y,
-                          const struct drm_clip_rect *src, const struct drm_clip_rect *bbox)
-{
-   int xy1;
-   int xy2;
-
-   assert(dst);
-   assert(src);
-   assert(bbox);
-
-   xy1 = ((int)src->x1 > (int)bbox->x1 + dst_x) ? src->x1 :
-      (int)bbox->x1 + dst_x;
-   xy2 = ((int)src->x2 < (int)bbox->x2 + dst_x) ? src->x2 :
-      (int)bbox->x2 + dst_x;
-   if (xy1 >= xy2 || xy1 < 0)
-      return FALSE;
-
-   dst->x1 = xy1;
-   dst->x2 = xy2;
-
-   xy1 = ((int)src->y1 > (int)bbox->y1 + dst_y) ? src->y1 :
-      (int)bbox->y1 + dst_y;
-   xy2 = ((int)src->y2 < (int)bbox->y2 + dst_y) ? src->y2 :
-      (int)bbox->y2 + dst_y;
-   if (xy1 >= xy2 || xy1 < 0)
-      return FALSE;
-
-   dst->y1 = xy1;
-   dst->y2 = xy2;
-   return TRUE;
-}
-
-static void
-vl_clip_copy(struct vl_dri_context *vl_dri_ctx,
-            struct pipe_surface *dst,
-            struct pipe_surface *src,
-            const struct drm_clip_rect *src_bbox)
-{
-   struct pipe_video_context *vpipe = vl_dri_ctx->base.vpipe;
-   struct drm_clip_rect clip;
-   struct drm_clip_rect *cur;
-   int i;
-
-   assert(vl_dri_ctx);
-   assert(dst);
-   assert(src);
-   assert(src_bbox);
-
-   assert(vl_dri_ctx->drawable->cliprects);
-   assert(vl_dri_ctx->drawable->num_cliprects > 0);
-
-   cur = vl_dri_ctx->drawable->cliprects;
-
-   for (i = 0; i < vl_dri_ctx->drawable->num_cliprects; ++i) {
-      if (vl_dri_intersect_src_bbox(&clip, vl_dri_ctx->drawable->x, vl_dri_ctx->drawable->y, cur++, src_bbox))
-         vpipe->surface_copy
-         (
-            vpipe, dst, clip.x1, clip.y1, src,
-            (int)clip.x1 - vl_dri_ctx->drawable->x,
-            (int)clip.y1 - vl_dri_ctx->drawable->y,
-            clip.x2 - clip.x1, clip.y2 - clip.y1
-         );
-   }
-}
-
-static void
-vl_dri_update_drawables_locked(struct vl_dri_context *vl_dri_ctx)
-{
-   struct vl_dri_screen *vl_dri_scrn;
-
-   assert(vl_dri_ctx);
-
-   vl_dri_scrn = (struct vl_dri_screen*)vl_dri_ctx->base.vscreen;
-
-   if (vl_dri_ctx->lost_lock) {
-      vl_dri_ctx->lost_lock = FALSE;
-      DRI_VALIDATE_DRAWABLE_INFO(vl_dri_scrn->dri_screen, vl_dri_ctx->drawable);
-   }
-}
-
-static void
-vl_dri_flush_frontbuffer(struct pipe_screen *screen,
-                         struct pipe_surface *surf, void *context_private)
-{
-   struct vl_dri_context *vl_dri_ctx = (struct vl_dri_context*)context_private;
-   struct vl_dri_screen *vl_dri_scrn;
-   struct drm_clip_rect src_bbox;
-   boolean save_lost_lock = FALSE;
-
-   assert(screen);
-   assert(surf);
-   assert(context_private);
-
-   vl_dri_scrn = (struct vl_dri_screen*)vl_dri_ctx->base.vscreen;
-
-   vl_dri_lock(vl_dri_ctx);
-
-   save_lost_lock = vl_dri_ctx->lost_lock;
-
-   vl_dri_update_drawables_locked(vl_dri_ctx);
-
-   src_bbox.x1 = 0;
-   src_bbox.x2 = vl_dri_ctx->drawable->w;
-   src_bbox.y1 = 0;
-   src_bbox.y2 = vl_dri_ctx->drawable->h;
-
-#if 0
-   if (vl_dri_scrn->_api_hooks->present_locked)
-      vl_dri_scrn->api_hooks->present_locked(pipe, surf,
-                                             vl_dri_ctx->drawable->cliprects,
-                                             vl_dri_ctx->drawable->num_cliprects,
-                                             vl_dri_ctx->drawable->x, vl_dri_drawable->y,
-                                             &bbox, NULL /*fence*/);
-   else
-#endif
-   if (vl_dri_scrn->api_hooks->front_srf_locked) {
-      struct pipe_surface *front = vl_dri_scrn->api_hooks->front_srf_locked(screen);
-
-      if (front)
-         vl_clip_copy(vl_dri_ctx, front, surf, &src_bbox);
-
-      //st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, fence);
-   }
-
-   vl_dri_ctx->lost_lock = save_lost_lock;
-
-   vl_dri_unlock(vl_dri_ctx);
-}
-
-Drawable
-vl_video_bind_drawable(struct vl_context *vctx, Drawable drawable)
-{
-   struct vl_dri_context *vl_dri_ctx = (struct vl_dri_context*)vctx;
-   struct vl_dri_screen *vl_dri_scrn;
-   dri_drawable_t *dri_drawable;
-   Drawable old_drawable = None;
-
-   assert(vctx);
-
-   if (vl_dri_ctx->drawable)
-      old_drawable = vl_dri_ctx->drawable->x_drawable;
-
-   vl_dri_scrn = (struct vl_dri_screen*)vl_dri_ctx->base.vscreen;
-   driCreateDrawable(vl_dri_scrn->dri_screen, drawable, &dri_drawable);
-   vl_dri_ctx->drawable = dri_drawable;
-
-   return old_drawable;
-}
-
-struct vl_screen*
-vl_screen_create(Display *display, int screen)
-{
-   struct vl_dri_screen *vl_dri_scrn;
-   struct dri1_create_screen_arg arg;
-
-   assert(display);
-
-   vl_dri_scrn = CALLOC_STRUCT(vl_dri_screen);
-   if (!vl_dri_scrn)
-      return NULL;
-
-   driCreateScreen(display, screen, &vl_dri_scrn->dri_screen, &vl_dri_scrn->dri_framebuf);
-   vl_dri_scrn->api = drm_api_create();
-
-   arg.base.mode = DRM_CREATE_DRI1;
-   arg.lf = &dri1_lf;
-   arg.ddx_info = vl_dri_scrn->dri_framebuf.private;
-   arg.ddx_info_size = vl_dri_scrn->dri_framebuf.private_size;
-   arg.sarea = vl_dri_scrn->dri_screen->sarea;
-   vl_dri_copy_version(&arg.ddx_version, &vl_dri_scrn->dri_screen->ddx);
-   vl_dri_copy_version(&arg.dri_version, &vl_dri_scrn->dri_screen->dri);
-   vl_dri_copy_version(&arg.drm_version, &vl_dri_scrn->dri_screen->drm);
-   arg.api = NULL;
-
-   vl_dri_scrn->base.pscreen = vl_dri_scrn->api->create_screen(vl_dri_scrn->api,
-                                                               vl_dri_scrn->dri_screen->fd,
-                                                               &arg.base);
-
-   if (!vl_dri_scrn->base.pscreen) {
-      FREE(vl_dri_scrn);
-      return NULL;
-   }
-
-   vl_dri_scrn->visual = XDefaultVisual(display, screen);
-   vl_dri_scrn->api_hooks = arg.api;
-   vl_dri_scrn->base.pscreen->flush_frontbuffer = vl_dri_flush_frontbuffer;
-   /* XXX: Safe to call this while unlocked? */
-   vl_dri_scrn->base.format = vl_dri_scrn->api_hooks->front_srf_locked(vl_dri_scrn->base.pscreen)->format;
-
-   return &vl_dri_scrn->base;
-}
-
-void vl_screen_destroy(struct vl_screen *vscreen)
-{
-   struct vl_dri_screen *vl_dri_scrn = (struct vl_dri_screen*)vscreen;
-
-   assert(vscreen);
-
-   vl_dri_scrn->base.pscreen->destroy(vl_dri_scrn->base.pscreen);
-   driDestroyScreen(vl_dri_scrn->dri_screen);
-   FREE(vl_dri_scrn);
-}
-
-struct vl_context*
-vl_video_create(struct vl_screen *vscreen,
-                enum pipe_video_profile profile,
-                enum pipe_video_chroma_format chroma_format,
-                unsigned width, unsigned height)
-{
-   struct vl_dri_screen *vl_dri_scrn = (struct vl_dri_screen*)vscreen;
-   struct vl_dri_context *vl_dri_ctx;
-
-   vl_dri_ctx = CALLOC_STRUCT(vl_dri_context);
-   if (!vl_dri_ctx)
-      return NULL;
-
-   /* XXX: Is default visual correct/sufficient here? */
-   driCreateContext(vl_dri_scrn->dri_screen, vl_dri_scrn->visual, &vl_dri_ctx->dri_context);
-
-   if (!vl_dri_scrn->api->create_video_context) {
-      debug_printf("[G3DVL] No video support found on %s/%s.\n",
-                   vl_dri_scrn->base.pscreen->get_vendor(vl_dri_scrn->base.pscreen),
-                   vl_dri_scrn->base.pscreen->get_name(vl_dri_scrn->base.pscreen));
-      FREE(vl_dri_ctx);
-      return NULL;
-   }
-
-   vl_dri_ctx->base.vpipe = vl_dri_scrn->api->create_video_context(vl_dri_scrn->api,
-                                                                   vscreen->pscreen,
-                                                                   profile, chroma_format,
-                                                                   width, height);
-
-   if (!vl_dri_ctx->base.vpipe) {
-      FREE(vl_dri_ctx);
-      return NULL;
-   }
-
-   vl_dri_ctx->base.vpipe->priv = vl_dri_ctx;
-   vl_dri_ctx->base.vscreen = vscreen;
-   vl_dri_ctx->fd = vl_dri_scrn->dri_screen->fd;
-   vl_dri_ctx->lock = (drmLock*)&vl_dri_scrn->dri_screen->sarea->lock;
-
-   return &vl_dri_ctx->base;
-}
-
-void vl_video_destroy(struct vl_context *vctx)
-{
-   struct vl_dri_context *vl_dri_ctx = (struct vl_dri_context*)vctx;
-
-   assert(vctx);
-
-   vl_dri_ctx->base.vpipe->destroy(vl_dri_ctx->base.vpipe);
-   FREE(vl_dri_ctx);
-}
diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_context_vl.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_context_vl.c
deleted file mode 100644 (file)
index dfc4905..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-#include "nouveau_context_vl.h"
-#include <pipe/p_defines.h>
-#include <pipe/p_context.h>
-#include <pipe/p_screen.h>
-#include <util/u_memory.h>
-#include <common/nouveau_dri.h>
-#include <common/nouveau_local.h>
-#include <common/nouveau_winsys_pipe.h>
-#include "nouveau_screen_vl.h"
-
-/*
-#ifdef DEBUG
-static const struct dri_debug_control debug_control[] = {
-       { "bo", DEBUG_BO },
-       { NULL, 0 }
-};
-int __nouveau_debug = 0;
-#endif
-*/
-
-int
-nouveau_context_create(dri_context_t *dri_context)
-{
-       dri_screen_t                    *dri_screen;
-       struct nouveau_screen_vl        *nv_screen;
-       struct nouveau_context_vl       *nv;
-
-       assert (dri_context);
-
-       dri_screen = dri_context->dri_screen;
-       nv_screen = dri_screen->private;
-       nv = CALLOC_STRUCT(nouveau_context_vl);
-
-       if (!nv)
-               return 1;
-
-       if (nouveau_context_init(&nv_screen->base, dri_context->drm_context,
-                               (drmLock*)&dri_screen->sarea->lock, NULL, &nv->base))
-       {
-               FREE(nv);
-               return 1;
-       }
-
-       dri_context->private = (void*)nv;
-       nv->dri_context = dri_context;
-       nv->nv_screen  = nv_screen;
-
-       /*
-       driParseConfigFiles(&nv->dri_option_cache, &nv_screen->option_cache,
-                           nv->dri_screen->myNum, "nouveau");
-#ifdef DEBUG
-       __nouveau_debug = driParseDebugString(getenv("NOUVEAU_DEBUG"),
-                                             debug_control);
-#endif
-       */
-
-       nv->base.nvc->pctx[nv->base.pctx_id]->priv = nv;
-
-       return 0;
-}
-
-void
-nouveau_context_destroy(dri_context_t *dri_context)
-{
-       struct nouveau_context_vl *nv = dri_context->private;
-
-       assert(dri_context);
-
-       nouveau_context_cleanup(&nv->base);
-
-       FREE(nv);
-}
-
-int
-nouveau_context_bind(struct nouveau_context_vl *nv, dri_drawable_t *dri_drawable)
-{
-       assert(nv);
-       assert(dri_drawable);
-
-       if (nv->dri_drawable != dri_drawable)
-       {
-               nv->dri_drawable = dri_drawable;
-               dri_drawable->private = nv;
-       }
-
-       return 0;
-}
-
-int
-nouveau_context_unbind(struct nouveau_context_vl *nv)
-{
-       assert(nv);
-
-       nv->dri_drawable = NULL;
-
-       return 0;
-}
-
-/* Show starts here */
-
-int bind_pipe_drawable(struct pipe_context *pipe, Drawable drawable)
-{
-       struct nouveau_context_vl       *nv;
-       dri_drawable_t                  *dri_drawable;
-
-       assert(pipe);
-
-       nv = pipe->priv;
-
-       driCreateDrawable(nv->nv_screen->dri_screen, drawable, &dri_drawable);
-
-       nouveau_context_bind(nv, dri_drawable);
-
-       return 0;
-}
-
-int unbind_pipe_drawable(struct pipe_context *pipe)
-{
-       assert (pipe);
-
-       nouveau_context_unbind(pipe->priv);
-
-       return 0;
-}
-
-struct pipe_context* create_pipe_context(Display *display, int screen)
-{
-       dri_screen_t                    *dri_screen;
-       dri_framebuffer_t               dri_framebuf;
-       dri_context_t                   *dri_context;
-       struct nouveau_context_vl       *nv;
-
-       assert(display);
-
-       driCreateScreen(display, screen, &dri_screen, &dri_framebuf);
-       driCreateContext(dri_screen, XDefaultVisual(display, screen), &dri_context);
-
-       nouveau_screen_create(dri_screen, &dri_framebuf);
-       nouveau_context_create(dri_context);
-
-       nv = dri_context->private;
-
-       return nv->base.nvc->pctx[nv->base.pctx_id];
-}
-
-int destroy_pipe_context(struct pipe_context *pipe)
-{
-       struct pipe_screen              *screen;
-       struct pipe_winsys              *winsys;
-       struct nouveau_context_vl       *nv;
-       dri_screen_t                    *dri_screen;
-       dri_context_t                   *dri_context;
-
-       assert(pipe);
-
-       screen = pipe->screen;
-       winsys = pipe->winsys;
-       nv = pipe->priv;
-       dri_context = nv->dri_context;
-       dri_screen = dri_context->dri_screen;
-
-       pipe->destroy(pipe);
-       screen->destroy(screen);
-       FREE(winsys);
-
-       nouveau_context_destroy(dri_context);
-       nouveau_screen_destroy(dri_screen);
-       driDestroyContext(dri_context);
-       driDestroyScreen(dri_screen);
-
-       return 0;
-}
diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_context_vl.h b/src/gallium/winsys/g3dvl/nouveau/nouveau_context_vl.h
deleted file mode 100644 (file)
index 1115c31..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef __NOUVEAU_CONTEXT_VL_H__
-#define __NOUVEAU_CONTEXT_VL_H__
-
-#include <driclient.h>
-#include <nouveau/nouveau_winsys.h>
-#include <common/nouveau_context.h>
-
-/*#include "xmlconfig.h"*/
-
-struct nouveau_context_vl {
-       struct nouveau_context          base;
-       struct nouveau_screen_vl        *nv_screen;
-       dri_context_t                   *dri_context;
-       dri_drawable_t                  *dri_drawable;
-       unsigned int                    last_stamp;
-       /*driOptionCache                dri_option_cache;*/
-       drm_context_t                   drm_context;
-       drmLock                         drm_lock;
-};
-
-extern int nouveau_context_create(dri_context_t *);
-extern void nouveau_context_destroy(dri_context_t *);
-extern int nouveau_context_bind(struct nouveau_context_vl *, dri_drawable_t *);
-extern int nouveau_context_unbind(struct nouveau_context_vl *);
-
-#ifdef DEBUG
-extern int __nouveau_debug;
-
-#define DEBUG_BO (1 << 0)
-
-#define DBG(flag, ...) do {                   \
-       if (__nouveau_debug & (DEBUG_##flag)) \
-               NOUVEAU_ERR(__VA_ARGS__);     \
-} while(0)
-#else
-#define DBG(flag, ...)
-#endif
-
-#endif
diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_screen_vl.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_screen_vl.c
deleted file mode 100644 (file)
index b7c74f8..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-#include "nouveau_screen_vl.h"
-#include <util/u_memory.h>
-#include <nouveau_drm.h>
-#include <common/nouveau_dri.h>
-#include <common/nouveau_local.h>
-
-#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 12
-#error nouveau_drm.h version does not match expected version
-#endif
-
-/*
-PUBLIC const char __driConfigOptions[] =
-DRI_CONF_BEGIN
-DRI_CONF_END;
-static const GLuint __driNConfigOptions = 0;
-*/
-
-int nouveau_check_dri_drm_ddx(dri_version_t *dri, dri_version_t *drm, dri_version_t *ddx)
-{
-       static const dri_version_t ddx_expected = {0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL};
-       static const dri_version_t dri_expected = {4, 0, 0};
-       static const dri_version_t drm_expected = {0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL};
-
-       assert(dri);
-       assert(drm);
-       assert(ddx);
-
-       if (dri->major != dri_expected.major || dri->minor < dri_expected.minor)
-       {
-               NOUVEAU_ERR("Unexpected DRI version.\n");
-               return 1;
-       }
-       if (drm->major != drm_expected.major || drm->minor < drm_expected.minor)
-       {
-               NOUVEAU_ERR("Unexpected DRM version.\n");
-               return 1;
-       }
-       if (ddx->major != ddx_expected.major || ddx->minor < ddx_expected.minor)
-       {
-               NOUVEAU_ERR("Unexpected DDX version.\n");
-               return 1;
-       }
-
-       return 0;
-}
-
-int
-nouveau_screen_create(dri_screen_t *dri_screen, dri_framebuffer_t *dri_framebuf)
-{
-       struct nouveau_dri              *nv_dri = dri_framebuf->private;
-       struct nouveau_screen_vl        *nv_screen;
-
-       assert(dri_screen);
-       assert(dri_framebuf);
-
-       if (nouveau_check_dri_drm_ddx(&dri_screen->dri, &dri_screen->drm, &dri_screen->ddx))
-               return 1;
-
-       nv_screen = CALLOC_STRUCT(nouveau_screen_vl);
-
-       if (!nv_screen)
-               return 1;
-
-       if (nouveau_screen_init(nv_dri, dri_screen->fd, &nv_screen->base))
-       {
-               FREE(nv_screen);
-               return 1;
-       }
-
-       /*
-       driParseOptionInfo(&nv_screen->option_cache,
-                          __driConfigOptions, __driNConfigOptions);
-       */
-
-       nv_screen->dri_screen = dri_screen;
-       dri_screen->private = (void*)nv_screen;
-
-       return 0;
-}
-
-void
-nouveau_screen_destroy(dri_screen_t *dri_screen)
-{
-       struct nouveau_screen_vl *nv_screen = dri_screen->private;
-
-       nouveau_screen_cleanup(&nv_screen->base);
-       FREE(nv_screen);
-}
diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_screen_vl.h b/src/gallium/winsys/g3dvl/nouveau/nouveau_screen_vl.h
deleted file mode 100644 (file)
index 0c1ceca..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __NOUVEAU_SCREEN_VL_H__
-#define __NOUVEAU_SCREEN_VL_H__
-
-#include <driclient.h>
-#include <common/nouveau_screen.h>
-
-/* TODO: Investigate using DRI options for interesting things */
-/*#include "xmlconfig.h"*/
-
-struct nouveau_screen_vl
-{
-       struct nouveau_screen           base;
-       dri_screen_t                    *dri_screen;
-       /*driOptionCache                option_cache;*/
-};
-
-int nouveau_screen_create(dri_screen_t *dri_screen, dri_framebuffer_t *dri_framebuf);
-void nouveau_screen_destroy(dri_screen_t *dri_screen);
-
-#endif
diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_swapbuffers.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_swapbuffers.c
deleted file mode 100644 (file)
index 77e46a2..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-#include <driclient.h>
-#include <common/nouveau_local.h>
-#include <common/nouveau_screen.h>
-#include "nouveau_context_vl.h"
-#include "nouveau_swapbuffers.h"
-
-void
-nouveau_copy_buffer(dri_drawable_t *dri_drawable, struct pipe_surface *surf,
-                   const drm_clip_rect_t *rect)
-{
-       struct nouveau_context_vl       *nv = dri_drawable->private;
-       struct pipe_context             *pipe = nv->base.nvc->pctx[nv->base.pctx_id];
-       drm_clip_rect_t                 *pbox;
-       int                             nbox, i;
-
-       LOCK_HARDWARE(&nv->base);
-       if (!dri_drawable->num_cliprects) {
-               UNLOCK_HARDWARE(&nv->base);
-               return;
-       }
-       pbox = dri_drawable->cliprects;
-       nbox = dri_drawable->num_cliprects;
-
-       for (i = 0; i < nbox; i++, pbox++) {
-               int sx, sy, dx, dy, w, h;
-
-               sx = pbox->x1 - dri_drawable->x;
-               sy = pbox->y1 - dri_drawable->y;
-               dx = pbox->x1;
-               dy = pbox->y1;
-               w  = pbox->x2 - pbox->x1;
-               h  = pbox->y2 - pbox->y1;
-
-               pipe->surface_copy(pipe, nv->base.frontbuffer,
-                                  dx, dy, surf, sx, sy, w, h);
-       }
-
-       FIRE_RING(nv->base.nvc->channel);
-       UNLOCK_HARDWARE(&nv->base);
-}
-
-void
-nouveau_copy_sub_buffer(dri_drawable_t *dri_drawable, struct pipe_surface *surf, int x, int y, int w, int h)
-{
-       if (surf) {
-               drm_clip_rect_t rect;
-               rect.x1 = x;
-               rect.y1 = y;
-               rect.x2 = x + w;
-               rect.y2 = y + h;
-
-               nouveau_copy_buffer(dri_drawable, surf, &rect);
-       }
-}
-
-void
-nouveau_swap_buffers(dri_drawable_t *dri_drawable, struct pipe_surface *surf)
-{
-       if (surf)
-               nouveau_copy_buffer(dri_drawable, surf, NULL);
-}
-
-void
-nouveau_flush_frontbuffer(struct pipe_winsys *pws, struct pipe_surface *surf,
-                         void *context_private)
-{
-       struct nouveau_context_vl       *nv;
-       dri_drawable_t                  *dri_drawable;
-
-       assert(pws);
-       assert(surf);
-       assert(context_private);
-
-       nv = context_private;
-       dri_drawable = nv->dri_drawable;
-
-       nouveau_copy_buffer(dri_drawable, surf, NULL);
-}
-
-void
-nouveau_contended_lock(struct nouveau_context *nv)
-{
-       struct nouveau_context_vl       *nv_vl = (struct nouveau_context_vl*)nv;
-       dri_drawable_t                  *dri_drawable = nv_vl->dri_drawable;
-       dri_screen_t                    *dri_screen = nv_vl->dri_context->dri_screen;
-
-       /* If the window moved, may need to set a new cliprect now.
-        *
-        * NOTE: This releases and regains the hw lock, so all state
-        * checking must be done *after* this call:
-        */
-       if (dri_drawable)
-               DRI_VALIDATE_DRAWABLE_INFO(dri_screen, dri_drawable);
-}
diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_swapbuffers.h b/src/gallium/winsys/g3dvl/nouveau/nouveau_swapbuffers.h
deleted file mode 100644 (file)
index 35e934a..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __NOUVEAU_SWAPBUFFERS_H__
-#define __NOUVEAU_SWAPBUFFERS_H__
-
-extern void nouveau_copy_buffer(dri_drawable_t *, struct pipe_surface *,
-                               const drm_clip_rect_t *);
-extern void nouveau_copy_sub_buffer(dri_drawable_t *, struct pipe_surface *,
-                                   int x, int y, int w, int h);
-extern void nouveau_swap_buffers(dri_drawable_t *, struct pipe_surface *);
-
-#endif